1 /*
2  * Copyright (c) 2021-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 OHOS_DISTRIBUTED_HARDWARE_IMPL_UTILS_H
17 #define OHOS_DISTRIBUTED_HARDWARE_IMPL_UTILS_H
18 
19 #include <unordered_map>
20 
21 #include "device_type.h"
22 #include "constants.h"
23 
24 namespace OHOS {
25 namespace DistributedHardware {
26 enum class TaskType : int32_t {
27     UNKNOWN = 0,
28     ENABLE = 1,
29     DISABLE = 2,
30     ON_LINE = 3,
31     OFF_LINE = 4,
32     META_ENABLE = 5,
33     META_DISABLE = 6
34 };
35 
36 enum class TaskStep : int32_t {
37     DO_ENABLE = 1,
38     DO_DISABLE = 2,
39     SYNC_ONLINE_INFO = 3,
40     REGISTER_ONLINE_DISTRIBUTED_HARDWARE = 4,
41     UNREGISTER_OFFLINE_DISTRIBUTED_HARDWARE = 5,
42     CLEAR_OFFLINE_INFO = 6,
43     WAIT_UNREGISTGER_COMPLETE = 7,
44     META_ENABLE_TASK = 8,
45     META_DISABLE_TASK = 9,
46     DO_MODEM_META_ENABLE = 10,
47     DO_MODEM_META_DISABLE = 11
48 };
49 
50 enum class TaskState : int32_t {
51     INIT = 0,
52     RUNNING = 1,
53     SUCCESS = 2,
54     FAIL = 3
55 };
56 
57 struct CompVersion {
58     std::string name;
59     DHType dhType;
60     std::string handlerVersion;
61     std::string sourceVersion;
62     std::string sinkVersion;
63 };
64 
65 struct DHVersion {
66     std::string uuid;
67     std::string dhVersion;
68     std::unordered_map<DHType, CompVersion> compVersions;
69 };
70 
71 struct TaskParam {
72     // remote device networkid
73     std::string networkId;
74     // remote device uuid
75     std::string uuid;
76     // remote device udid
77     std::string udid;
78     // remote device dhid
79     std::string dhId;
80     // remote device dh type
81     DHType dhType;
82 };
83 
84 struct TaskDump {
85     std::string id;
86     TaskType taskType;
87     TaskParam taskParm;
88     TaskState taskState;
89     std::vector<TaskStep> taskSteps;
90 };
91 } // namespace DistributedHardware
92 } // namespace OHOS
93 #endif
94