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 }; 67 68 /* 69 * Options for sharing data through UDMF. 70 */ 71 struct CustomOption { 72 Intention intention {}; 73 uint32_t tokenId {}; 74 }; 75 76 /* 77 * Options for querying data from UDMF. 78 */ 79 struct QueryOption { 80 std::string key; 81 Intention intention {}; 82 uint32_t tokenId {}; 83 }; 84 85 enum AsyncTaskStatus : uint32_t { 86 ASYNC_IDLE = 0, 87 ASYNC_RUNNING, 88 ASYNC_SUCCESS, 89 ASYNC_FAILURE, 90 }; 91 92 struct AsyncProcessInfo { 93 AsyncTaskStatus syncStatus { ASYNC_IDLE }; 94 AsyncTaskStatus permStatus { ASYNC_IDLE }; 95 std::string srcDevName; 96 uint32_t syncFinished = 0; 97 uint32_t syncTotal = 0; 98 uint32_t syncId = 0; 99 uint32_t permFnished = 0; 100 uint32_t permTotal = 0; 101 std::string businessUdKey; 102 }; 103 104 struct ProgressInfo { 105 int32_t progress = 0; 106 int32_t progressStatus; 107 Status errorCode; 108 std::string srcDevName; 109 }; 110 111 } // namespace UDMF 112 } // namespace OHOS 113 #endif // UDMF_UNIFIED_TYPES_H