Init basesystem source codes.
[staging/basesystem.git] / vehicleservice / positioning / server / src / ServiceInterface / PSMShadowIf.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  * @file
19  *    PSMShadowIf.cpp
20  * @brief
21  *    PSMShadow service-to-service interface
22  */
23
24 /*---------------------------------------------------------------------------------*
25  * Include Files                                                                   *
26  *---------------------------------------------------------------------------------*/
27 #include <vehicle_service/positioning_base_library.h>
28 #include "PSMShadowIf.h"
29
30 /*---------------------------------------------------------------------------------*
31  * Definition                                                                      *
32  *---------------------------------------------------------------------------------*/
33
34 /*---------------------------------------------------------------------------------*
35  * Structre                                                                        *
36  *---------------------------------------------------------------------------------*/
37
38 /*---------------------------------------------------------------------------------*
39  * Local Function Prototype                                                        *
40  *---------------------------------------------------------------------------------*/
41
42 /*---------------------------------------------------------------------------------*
43  * Grobal Value                                                                    *
44  *---------------------------------------------------------------------------------*/
45
46 /*---------------------------------------------------------------------------------*
47  * Function                                                                        *
48  *---------------------------------------------------------------------------------*/
49 /**
50  * @brief
51  *    PSMShadow Services IF Availability Change Notification Registration
52  *
53  * @param[in]  fp_on_cmd    Callback function
54  * @return     eFrameworkunifiedStatusOK
55  * @return     eFrameworkunifiedStatusFail
56  */
57 EFrameworkunifiedStatus PSMShadowIfNotifyOnPSMShadowAvailability(CbFuncPtr fp_on_cmd) {
58     EFrameworkunifiedStatus estatus = eFrameworkunifiedStatusFail;
59     HANDLE happ;
60
61     happ = _pb_GetAppHandle();
62     if (happ != NULL) {
63         /* PS_PSMShadow/Availability Changing notification registration */
64         estatus = FrameworkunifiedSubscribeNotificationWithCallback(happ, NTFY_PSMShadowService_Availability, fp_on_cmd);  // LCOV_EXCL_BR_LINE 6:unexpected branch  //NOLINT (whitespace/line_length)
65         if (eFrameworkunifiedStatusOK != estatus) {  // LCOV_EXCL_BR_LINE 4: nsfw error
66             FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
67                           "PositioningSubscriveNotificationswithCallback ERROR!! [estatus=%d]", estatus);
68         }
69     } else {
70         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "_pb_GetAppHandle ERROR!! [happ=%p]", happ);
71     }
72
73     return estatus;
74 }
75
76 /**
77  * @brief
78  *    Register PSMShadow services IF start completion notification
79  *
80  * @param[in]  fp_on_cmd    Callback function
81  * @return     eFrameworkunifiedStatusOK
82  * @return     eFrameworkunifiedStatusFail
83  */
84 EFrameworkunifiedStatus PSMShadowIfNotifyOnPSMShadowInitComp(CbFuncPtr fp_on_cmd) {
85     EFrameworkunifiedStatus estatus = eFrameworkunifiedStatusFail;
86     HANDLE happ;
87
88     happ = _pb_GetAppHandle();
89     if (happ != NULL) {
90         /* PS_PSMShadow startup completion notice */
91         estatus = FrameworkunifiedSubscribeNotificationWithCallback(happ, NTFY_PSM_INITCOMP, fp_on_cmd);  // LCOV_EXCL_BR_LINE 6:unexpected branch  //NOLINT (whitespace/line_length)
92         if (eFrameworkunifiedStatusOK != estatus) {  // LCOV_EXCL_BR_LINE 4: nsfw error
93             FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
94                           "PositioningSubscriveNotificationswithCallback ERROR!! [estatus=%d]", estatus);
95         }
96     } else {
97         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "_pb_GetAppHandle ERROR!! [happ=%p]", happ);
98     }
99
100     return estatus;
101 }
102