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 OHOS_FILEMGMT_CLOUD_SYNC_COMMON_H 17 #define OHOS_FILEMGMT_CLOUD_SYNC_COMMON_H 18 19 #include <map> 20 21 #include "parcel.h" 22 #include "cloud_sync_asset_manager.h" 23 24 namespace OHOS::FileManagement::CloudSync { 25 26 struct DownloadProgressObj : public Parcelable { 27 enum Status : int32_t { 28 RUNNING = 0, 29 COMPLETED = 1, 30 FAILED = 2, 31 STOPPED = 3, 32 }; 33 std::string path; 34 Status state; 35 int64_t downloadedSize; 36 int64_t totalSize; 37 bool ReadFromParcel(Parcel &parcel); 38 bool Marshalling(Parcel &parcel) const override; 39 static DownloadProgressObj *Unmarshalling(Parcel &parcel); 40 std::string to_string(); 41 }; 42 43 struct SwitchDataObj : public Parcelable { 44 std::map<std::string, bool> switchData; 45 bool ReadFromParcel(Parcel &parcel); 46 bool Marshalling(Parcel &parcel) const override; 47 static SwitchDataObj *Unmarshalling(Parcel &parcel); 48 }; 49 50 struct CleanOptions : public Parcelable { 51 std::map<std::string, int32_t> appActionsData; 52 bool ReadFromParcel(Parcel &parcel); 53 bool Marshalling(Parcel &parcel) const override; 54 static CleanOptions *Unmarshalling(Parcel &parcel); 55 }; 56 57 struct AssetInfoObj : public Parcelable { 58 std::string uri; 59 std::string recordType; 60 std::string recordId; 61 std::string fieldKey; 62 std::string assetName; 63 bool ReadFromParcel(Parcel &parcel); 64 bool Marshalling(Parcel &parcel) const override; 65 static AssetInfoObj *Unmarshalling(Parcel &parcel); 66 67 AssetInfoObj() = default; AssetInfoObjAssetInfoObj68 AssetInfoObj(const AssetInfo &assetInfo) 69 : uri(assetInfo.uri), 70 recordType(assetInfo.recordType), 71 recordId(assetInfo.recordId), 72 fieldKey(assetInfo.fieldKey), 73 assetName(assetInfo.assetName) 74 { 75 } 76 }; 77 } // namespace OHOS::FileManagement::CloudSync 78 #endif 79