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 APP_DISTRIBUTED_KVSTORE_APP_TYPES_H
17 #define APP_DISTRIBUTED_KVSTORE_APP_TYPES_H
18 
19 #include <errors.h>
20 
21 #include <cstdint>
22 #include <string>
23 #include <vector>
24 
25 #include "visibility.h"
26 
27 namespace OHOS {
28 namespace ObjectStore {
29 struct PipeInfo {
30     std::string pipeId;
31 };
32 
33 struct DeviceInfo {
34     std::string deviceId;
35     std::string deviceName;
36     std::string deviceType;
37 };
38 
39 enum class MessageType {
40     DEFAULT = 0,
41 };
42 
43 struct MessageInfo {
44     MessageType msgType;
45 };
46 
47 enum class DeviceChangeType {
48     DEVICE_OFFLINE = 0,
49     DEVICE_ONLINE = 1,
50 };
51 
52 struct DeviceId {
53     std::string deviceId;
54 };
55 
56 enum RouteType : int32_t {
57     INVALID_ROUTE_TYPE = -1,
58     ROUTE_TYPE_ALL = 0,
59     WIFI_STA = 1,
60     WIFI_P2P = 2,
61     BT_BR = 3,
62     BT_BLE = 4,
63     BUTT = 5,
64 };
65 
66 enum RecOperate : int32_t {
67     KEEP,
68     CHANGE_TO_P2P,
69     CHANGE_TO_BLUETOOTH,
70 };
71 
72 struct DataInfo {
73     uint8_t *data;
74     uint32_t length;
75 };
76 
77 // app_distributed_data_manager using sub error code 0
78 constexpr ErrCode APP_DISTRIBUTEDDATAMGR_ERR_OFFSET = ErrCodeOffset(SUBSYS_DISTRIBUTEDDATAMNG, 0);
79 
80 enum class Status {
81     SUCCESS = ERR_OK,
82     ERROR = APP_DISTRIBUTEDDATAMGR_ERR_OFFSET,
83     INVALID_ARGUMENT = APP_DISTRIBUTEDDATAMGR_ERR_OFFSET + 1,
84     ILLEGAL_STATE = APP_DISTRIBUTEDDATAMGR_ERR_OFFSET + 2,
85     KEY_NOT_FOUND = APP_DISTRIBUTEDDATAMGR_ERR_OFFSET + 7,
86     REPEATED_REGISTER = APP_DISTRIBUTEDDATAMGR_ERR_OFFSET + 14,
87 };
88 } // namespace ObjectStore
89 } // namespace OHOS
90 #endif // APP_DISTRIBUTED_KVSTORE_TYPES_H
91