• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 OHOS_DM_TRANSPORT_MSG_H
17 #define OHOS_DM_TRANSPORT_MSG_H
18 
19 #include <string>
20 #include <cJSON.h>
21 
22 namespace OHOS {
23 namespace DistributedHardware {
24 struct UserIdsMsg {
25     std::vector<uint32_t> foregroundUserIds;
26     std::vector<uint32_t> backgroundUserIds;
UserIdsMsgUserIdsMsg27     UserIdsMsg() : foregroundUserIds({}), backgroundUserIds({}) {}
UserIdsMsgUserIdsMsg28     UserIdsMsg(std::vector<uint32_t> foregroundUserIds, std::vector<uint32_t> backgroundUserIds)
29         : foregroundUserIds(foregroundUserIds), backgroundUserIds(backgroundUserIds) {}
30 };
31 
32 void ToJson(cJSON *jsonObject, const UserIdsMsg &userIdsMsg);
33 void FromJson(const cJSON *jsonObject, UserIdsMsg &userIdsMsg);
34 
35 struct CommMsg {
36     int32_t code;
37     std::string msg;
CommMsgCommMsg38     CommMsg() : code(-1), msg("") {}
CommMsgCommMsg39     CommMsg(int32_t code, std::string msg) : code(code), msg(msg) {}
40 };
41 
42 void ToJson(cJSON *jsonObject, const CommMsg &commMsg);
43 void FromJson(const cJSON *jsonObject, CommMsg &commMsg);
44 
45 std::string GetCommMsgString(const CommMsg &commMsg);
46 
47 struct InnerCommMsg {
48     std::string remoteNetworkId;
49     std::shared_ptr<CommMsg> commMsg;
50     int32_t socketId = 0;
InnerCommMsgInnerCommMsg51     InnerCommMsg(std::string remoteNetworkId, std::shared_ptr<CommMsg> commMsg, int32_t socketId)
52         : remoteNetworkId(remoteNetworkId), commMsg(commMsg), socketId(socketId) {}
53 };
54 
55 struct NotifyUserIds {
56     std::string remoteUdid;
57     std::vector<uint32_t> userIds;
NotifyUserIdsNotifyUserIds58     NotifyUserIds() : remoteUdid(""), userIds({}) {}
NotifyUserIdsNotifyUserIds59     NotifyUserIds(std::string remoteUdid, std::vector<uint32_t> userIds)
60         : remoteUdid(remoteUdid), userIds(userIds) {}
61 
62     std::string ToString();
63 };
64 
65 void ToJson(cJSON *jsonObject, const NotifyUserIds &userIds);
66 void FromJson(const cJSON *jsonObject, NotifyUserIds &userIds);
67 
68 struct LogoutAccountMsg {
69     std::string accountId;
70     int32_t userId;
LogoutAccountMsgLogoutAccountMsg71     LogoutAccountMsg() : userId(-1) {}
LogoutAccountMsgLogoutAccountMsg72     LogoutAccountMsg(const std::string &accountId, int32_t userId)
73         : accountId(accountId), userId(userId) {}
74 };
75 
76 void ToJson(cJSON *jsonObject, const LogoutAccountMsg &accountInfo);
77 void FromJson(const cJSON *jsonObject, LogoutAccountMsg &accountInfo);
78 } // DistributedHardware
79 } // OHOS
80 #endif