common_library: gettid is multiple declaration in cl_error
[staging/basesystem.git] / video_in_hal / nsframework / framework_unified / client / NS_FrameworkCore / src / frameworkunified_service_if.cpp
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 ////////////////////////////////////////////////////////////////////////////////
18 /// \ingroup  tag_HMI_CWORD77_Controller
19 /// \brief
20 ///
21 ////////////////////////////////////////////////////////////////////////////////
22
23 #include <native_service/frameworkunified_service_if.h>
24 #include <string>
25 //////////////////////////////////////////
26 /// Function : CFrameworkunifiedServiceInterface
27 //////////////////////////////////////////
28 CFrameworkunifiedServiceInterface::CFrameworkunifiedServiceInterface() {
29 }
30 //////////////////////////////////////////
31 /// Function : ~CFrameworkunifiedServiceInterface
32 //////////////////////////////////////////
33 CFrameworkunifiedServiceInterface::~CFrameworkunifiedServiceInterface() {
34 }
35 //////////////////////////////////////////
36 /// Function : OpenService
37 //////////////////////////////////////////
38 HANDLE CFrameworkunifiedServiceInterface::OpenService(const HANDLE f_hApp, std::string f_sServiceName) {
39   FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
40   HANDLE l_hService = NULL;
41   if (NULL == (l_hService = FrameworkunifiedOpenService(f_hApp, f_sServiceName.c_str()))) {
42     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Failed to open Service [%s]", f_sServiceName.c_str());
43   }
44   FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
45   return l_hService;
46 }
47 //////////////////////////////////////////
48 /// Function : CloseService
49 //////////////////////////////////////////
50 EFrameworkunifiedStatus CFrameworkunifiedServiceInterface::CloseService(const HANDLE f_hApp, const HANDLE f_hService) {
51   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
52   FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
53   if ((NULL == f_hApp) || (NULL == f_hService)) {
54     return eFrameworkunifiedStatusInvldParam;
55   }
56
57   if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedCloseService(f_hApp, f_hService))) {
58     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "CloseService Failed");
59   }
60
61   FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
62   return l_eStatus;
63 }
64 //////////////////////////////////////////
65 /// Function : OpenSession
66 //////////////////////////////////////////
67 EFrameworkunifiedStatus CFrameworkunifiedServiceInterface::OpenSession(const HANDLE f_hApp, UI_32 f_uisessionType) {
68   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
69   FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
70   if (NULL == f_hApp) {
71     return eFrameworkunifiedStatusInvldParam;
72   }
73
74   l_eStatus = FrameworkunifiedOpenSessionWithData(f_hApp, (PVOID)&f_uisessionType, sizeof(UI_32));
75   if (eFrameworkunifiedStatusOK != l_eStatus) {
76     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedOpenSession Failed, eFrameworkunifiedStatusOK = 0x%x, l_eStatus = 0x%x", eFrameworkunifiedStatusOK,
77            l_eStatus);
78   }
79   FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
80   return l_eStatus;
81 }
82 //////////////////////////////////////////
83 /// Function : OpenSessionAcknowledge
84 //////////////////////////////////////////
85 EFrameworkunifiedStatus CFrameworkunifiedServiceInterface::OpenSessionAcknowledge(const HANDLE f_hApp, HANDLE &hSession) {
86   FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
87   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
88   FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
89   return l_eStatus;
90 }
91 //////////////////////////////////////////
92 /// Function : CloseSession
93 //////////////////////////////////////////
94 EFrameworkunifiedStatus CFrameworkunifiedServiceInterface::CloseSession(const HANDLE f_hService, const HANDLE f_hSession) {
95   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
96   FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
97   if ((NULL == f_hService) || (NULL == f_hSession)) {
98     return eFrameworkunifiedStatusInvldParam;
99   }
100
101   if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedCloseSession(f_hService, f_hSession))) {
102     FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, " Failed to send session close request");
103   } else {
104     FRAMEWORKUNIFIEDLOG0(ZONE_NS__CWORD77_, __FUNCTION__, " Session close request sent successfully");
105   }
106   FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
107   return l_eStatus;
108 }
109 //////////////////////////////////////////
110 /// Function : CloseSessionAcknowledge
111 //////////////////////////////////////////
112 EFrameworkunifiedStatus CFrameworkunifiedServiceInterface::CloseSessionAcknowledge(const HANDLE hClient) {
113   FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
114   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
115   CloseSessionAck tCloseAck;
116   if (NULL == hClient) {
117     return eFrameworkunifiedStatusNullPointer;
118   }
119   if (eFrameworkunifiedStatusOK == (l_eStatus = FrameworkunifiedGetMsgDataOfSize(hClient, &tCloseAck, sizeof(tCloseAck)))) {
120     l_eStatus = tCloseAck.eStatus;
121   } else {
122     FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR,
123             __FUNCTION__,
124             "Failed to get message data:%x", l_eStatus);
125   }
126   FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
127   return l_eStatus;
128 }