1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef SERVICE_MSG_MESSENGER_WRAPPER_H
17 #define SERVICE_MSG_MESSENGER_WRAPPER_H
18 
19 #include <stdbool.h>
20 #include <stdint.h>
21 
22 #include "device_security_defines.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #define ONLINE 1
29 #define OFFLINE 0
30 
31 typedef int32_t (*MessageReceiver)(const DeviceIdentify *devId, const uint8_t *msg, uint32_t len);
32 
33 typedef int32_t (*StatusReceiver)(const DeviceIdentify *devId, uint32_t status, int32_t level);
34 
35 typedef int32_t (*SendResultNotifier)(const DeviceIdentify *devId, uint64_t transNo, uint32_t result);
36 
37 typedef int32_t (*DeviceProcessor)(const DeviceIdentify *devId, int32_t level, void *para);
38 
39 void SendMsgToDevice(uint64_t transNo, const DeviceIdentify *devId, const uint8_t *msg, uint32_t msgLen);
40 
41 uint32_t InitMessenger(const MessageReceiver messageReceiver, const StatusReceiver statusReceiver,
42     const SendResultNotifier notifier);
43 
44 uint32_t DeinitMessenger(void);
45 
46 bool GetMessengerStatus(void);
47 
48 bool GetPeerDeviceOnlineStatus(const DeviceIdentify *devId, int32_t *level);
49 
50 const DeviceIdentify *GetSelfDevice(int32_t *level);
51 
52 const char *GetMessengerPackageName(void) __attribute__((weak));
53 const char *GetMessengerPrimarySessionName(void) __attribute__((weak));
54 const char *GetMessengerSecondarySessionName(void) __attribute__((weak));
55 
56 #ifdef __cplusplus
57 }
58 #endif
59 
60 #endif // SERVICE_MSG_MESSENGER_WRAPPER_H
61