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 "unified_key.h"
23 #include "unified_meta.h"
24 
25 namespace OHOS {
26 namespace UDMF {
27 enum DataStatus : int32_t {
28     WORKING = 0,
29     HISTORY,
30     DELETED,
31     FADE
32 };
33 
34 struct Summary {
35     std::map<std::string, int64_t> summary;
36     int64_t totalSize;
37 };
38 
39 struct Privilege {
40     uint32_t tokenId;
41     std::string readPermission;
42     std::string writePermission;
43 };
44 
45 struct Runtime {
46     UnifiedKey key;
47     bool isPrivate {};
48     std::vector<Privilege> privileges;
49     // time when the data is created
50     time_t createTime {};
51     // name of the package for creating data
52     std::string sourcePackage;
53     // current data status
54     DataStatus dataStatus { WORKING };
55     // current data version
56     std::int32_t dataVersion {};
57     // time when the data is last modified
58     time_t lastModifiedTime {};
59     // time when data is written to the udmf
60     std::string createPackage;
61     // device ID of the data source
62     std::string deviceId;
63     std::uint32_t recordTotalNum {};
64     uint32_t tokenId;
65 };
66 
67 /*
68  * Options for sharing data through UDMF.
69  */
70 struct CustomOption {
71     Intention intention {};
72     uint32_t tokenId {};
73 };
74 
75 /*
76  * Options for querying data from UDMF.
77  */
78 struct QueryOption {
79     std::string key;
80     Intention intention {};
81     uint32_t  tokenId {};
82 };
83 } // namespace UDMF
84 } // namespace OHOS
85 #endif // UDMF_UNIFIED_TYPES_H