2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 ////////////////////////////////////////////////////////////////////////////////
18 /// \ingroup tag_HMI_CWORD77_Controller
21 ////////////////////////////////////////////////////////////////////////////////
23 #include <native_service/frameworkunified_service_if.h>
25 //////////////////////////////////////////
26 /// Function : CFrameworkunifiedServiceInterface
27 //////////////////////////////////////////
28 CFrameworkunifiedServiceInterface::CFrameworkunifiedServiceInterface() {
30 //////////////////////////////////////////
31 /// Function : ~CFrameworkunifiedServiceInterface
32 //////////////////////////////////////////
33 CFrameworkunifiedServiceInterface::~CFrameworkunifiedServiceInterface() {
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());
44 FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
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;
57 if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedCloseService(f_hApp, f_hService))) {
58 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "CloseService Failed");
61 FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
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__, "+");
71 return eFrameworkunifiedStatusInvldParam;
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,
79 FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
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__, "-");
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;
101 if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedCloseSession(f_hService, f_hSession))) {
102 FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, " Failed to send session close request");
104 FRAMEWORKUNIFIEDLOG0(ZONE_NS__CWORD77_, __FUNCTION__, " Session close request sent successfully");
106 FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
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;
119 if (eFrameworkunifiedStatusOK == (l_eStatus = FrameworkunifiedGetMsgDataOfSize(hClient, &tCloseAck, sizeof(tCloseAck)))) {
120 l_eStatus = tCloseAck.eStatus;
122 FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR,
124 "Failed to get message data:%x", l_eStatus);
126 FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");