• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 UDMF_UNIFIED_TYPES_H
17 #define UDMF_UNIFIED_TYPES_H
18 
19 #include <map>
20 #include <string>
21 
22 #include "error_code.h"
23 #include "unified_key.h"
24 #include "unified_meta.h"
25 
26 namespace OHOS {
27 namespace UDMF {
28 enum DataStatus : int32_t {
29     WORKING = 0,
30     HISTORY,
31     DELETED,
32     FADE
33 };
34 
35 struct Summary {
36     std::map<std::string, int64_t> summary;
37     int64_t totalSize;
38 };
39 
40 struct Privilege {
41     uint32_t tokenId;
42     std::string readPermission;
43     std::string writePermission;
44 };
45 
46 struct Runtime {
47     UnifiedKey key;
48     bool isPrivate {};
49     std::vector<Privilege> privileges;
50     // time when the data is created
51     time_t createTime {};
52     // name of the package for creating data
53     std::string sourcePackage;
54     // current data status
55     DataStatus dataStatus { WORKING };
56     // current data version
57     std::int32_t dataVersion {};
58     // time when the data is last modified
59     time_t lastModifiedTime {};
60     // time when data is written to the udmf
61     std::string createPackage;
62     // device ID of the data source
63     std::string deviceId;
64     std::uint32_t recordTotalNum {};
65     uint32_t tokenId;
66     std::string sdkVersion;
67 };
68 
69 /*
70  * Options for sharing data through UDMF.
71  */
72 struct CustomOption {
73     Intention intention {};
74     uint32_t tokenId {};
75 };
76 
77 /*
78  * Options for querying data from UDMF.
79  */
80 struct QueryOption {
81     std::string key;
82     Intention intention {};
83     uint32_t  tokenId {};
84 };
85 
86 enum AsyncTaskStatus : uint32_t {
87     ASYNC_IDLE = 0,
88     ASYNC_RUNNING,
89     ASYNC_SUCCESS,
90     ASYNC_FAILURE,
91 };
92 
93 struct AsyncProcessInfo {
94     AsyncTaskStatus syncStatus { ASYNC_IDLE };
95     AsyncTaskStatus permStatus { ASYNC_IDLE };
96     std::string srcDevName;
97     uint32_t syncFinished = 0;
98     uint32_t syncTotal = 0;
99     uint32_t syncId = 0;
100     uint32_t permFnished = 0;
101     uint32_t permTotal = 0;
102     std::string businessUdKey;
103 };
104 
105 struct ProgressInfo {
106     int32_t progress = 0;
107     int32_t progressStatus;
108     Status errorCode;
109     std::string srcDevName;
110 };
111 
112 struct UriInfo {
113     std::string oriUri;
114     std::string authUri;
115     std::string dfsUri;
116     uint32_t position;
117 };
118 } // namespace UDMF
119 } // namespace OHOS
120 #endif // UDMF_UNIFIED_TYPES_H