• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (c) 2025 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 #include "clone_backup_info.h"
16 
17 namespace OHOS {
18 namespace DistributedData {
Unmarshal(const json & node)19 bool CloneEncryptionInfo::Unmarshal(const json &node)
20 {
21     bool res = GetValue(node, "encryption_symkey", symkey);
22     res = GetValue(node, "encryption_algname", algName) && res;
23     res = GetValue(node, "gcmParams_iv", iv) && res;
24     return res;
25 }
26 
Marshal(json & node) const27 bool CloneEncryptionInfo::Marshal(json &node) const
28 {
29     return false;
30 }
31 
~CloneEncryptionInfo()32 CloneEncryptionInfo::~CloneEncryptionInfo()
33 {
34     symkey.assign(symkey.size(), 0);
35     algName.assign(algName.size(), 0);
36     iv.assign(iv.size(), 0);
37 }
38 
Unmarshal(const json & node)39 bool CloneBundleInfo::Unmarshal(const json &node)
40 {
41     bool res = GetValue(node, GET_NAME(bundleName), bundleName);
42     res = GetValue(node, GET_NAME(accessTokenId), accessTokenId) && res;
43     return res;
44 }
45 
Marshal(json & node) const46 bool CloneBundleInfo::Marshal(json &node) const
47 {
48     return false;
49 }
50 
Unmarshal(const json & node)51 bool CloneBackupInfo::Unmarshal(const json &node)
52 {
53     auto items = DistributedData::Serializable::ToJson(node);
54     if (!items.is_array()) {
55         return false;
56     }
57     std::string type;
58     auto size = items.size();
59     for (size_t i = 0; i < size; i++) {
60         bool result = GetValue(items[i], GET_NAME(type), type);
61         if (!result || type.empty()) {
62             continue;
63         }
64         if (type == "encryption_info") {
65             GetValue(items[i], "detail", encryptionInfo);
66         } else if (type == "application_selection") {
67             GetValue(items[i], "detail", bundleInfos);
68         } else if (type == "userId") {
69             GetValue(items[i], "detail", userId);
70         }
71     }
72     return true;
73 }
74 
Marshal(json & node) const75 bool CloneBackupInfo::Marshal(json &node) const
76 {
77     return false;
78 }
79 
Marshal(json & node) const80 bool CloneReplyResult::Marshal(json &node) const
81 {
82     SetValue(node[GET_NAME(type)], type);
83     SetValue(node[GET_NAME(errorCode)], errorCode);
84     SetValue(node[GET_NAME(errorInfo)], errorInfo);
85     return true;
86 }
87 
Unmarshal(const json & node)88 bool CloneReplyResult::Unmarshal(const json &node)
89 {
90     return false;
91 }
92 
Marshal(json & node) const93 bool CloneReplyCode::Marshal(json &node) const
94 {
95     SetValue(node[GET_NAME(resultInfo)], resultInfo);
96     return true;
97 }
98 
Unmarshal(const json & node)99 bool CloneReplyCode::Unmarshal(const json &node)
100 {
101     return false;
102 }
103 } // namespace DistributedData
104 } // namespace OHOS
105