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_DISTRIBUTED_HARDWARE_TRANSPORT_OBJ_H
17 #define OHOS_DISTRIBUTED_HARDWARE_TRANSPORT_OBJ_H
18 
19 #include <cstdint>
20 #include <string>
21 #include <cJSON.h>
22 
23 #include "capability_info.h"
24 
25 namespace OHOS {
26 namespace DistributedHardware {
27 const char* const CAPS_RSP_NETWORKID_KEY = "networkId";
28 const char* const CAPS_RSP_CAPS_KEY = "caps";
29 const char* const COMM_MSG_CODE_KEY = "code";
30 const char* const COMM_MSG_MSG_KEY = "msg";
31 
32 struct FullCapsRsp {
33     // the networkd id of rsp from which device
34     std::string networkId;
35     // the full dh caps
36     std::vector<std::shared_ptr<CapabilityInfo>> caps;
FullCapsRspFullCapsRsp37     FullCapsRsp() : networkId(""), caps({}) {}
FullCapsRspFullCapsRsp38     FullCapsRsp(std::string networkId, std::vector<std::shared_ptr<CapabilityInfo>> caps) : networkId(networkId),
39         caps(caps) {}
40 };
41 
42 void ToJson(cJSON *jsonObject, const FullCapsRsp &capsRsp);
43 void FromJson(const cJSON *jsonObject, FullCapsRsp &capsRsp);
44 
45 struct CommMsg {
46     int32_t code;
47     std::string msg;
CommMsgCommMsg48     CommMsg() : code(-1), msg("") {}
CommMsgCommMsg49     CommMsg(int32_t code, std::string msg) : code(code), msg(msg) {}
50 };
51 
52 void ToJson(cJSON *jsonObject, const CommMsg &commMsg);
53 void FromJson(const cJSON *jsonObject, CommMsg &commMsg);
54 
55 std::string GetCommMsgString(const CommMsg &commMsg);
56 
57 } // DistributedHardware
58 } // OHOS
59 #endif