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 enum DownloadErrorType : int32_t { 34 NO_ERROR = 0, 35 UNKNOWN_ERROR = 1, 36 NETWORK_UNAVAILABLE = 2, 37 LOCAL_STORAGE_FULL = 3, 38 CONTENT_NOT_FOUND = 4, 39 FREQUENT_USER_REQUESTS = 5, 40 }; 41 uint32_t refCount; 42 std::string path; 43 int64_t downloadId; 44 Status state; 45 int32_t downloadErrorType; 46 int64_t downloadedSize; 47 int64_t totalSize; 48 bool ReadFromParcel(Parcel &parcel); 49 bool Marshalling(Parcel &parcel) const override; 50 static DownloadProgressObj *Unmarshalling(Parcel &parcel); 51 std::string to_string(); 52 }; 53 54 struct SwitchDataObj : public Parcelable { 55 std::map<std::string, bool> switchData; 56 bool ReadFromParcel(Parcel &parcel); 57 bool Marshalling(Parcel &parcel) const override; 58 static SwitchDataObj *Unmarshalling(Parcel &parcel); 59 }; 60 61 struct CleanOptions : public Parcelable { 62 std::map<std::string, int32_t> appActionsData; 63 bool ReadFromParcel(Parcel &parcel); 64 bool Marshalling(Parcel &parcel) const override; 65 static CleanOptions *Unmarshalling(Parcel &parcel); 66 }; 67 68 struct AssetInfoObj : public Parcelable { 69 std::string uri; 70 std::string recordType; 71 std::string recordId; 72 std::string fieldKey; 73 std::string assetName; 74 bool ReadFromParcel(Parcel &parcel); 75 bool Marshalling(Parcel &parcel) const override; 76 static AssetInfoObj *Unmarshalling(Parcel &parcel); 77 78 AssetInfoObj() = default; AssetInfoObjAssetInfoObj79 AssetInfoObj(const AssetInfo &assetInfo) 80 : uri(assetInfo.uri), 81 recordType(assetInfo.recordType), 82 recordId(assetInfo.recordId), 83 fieldKey(assetInfo.fieldKey), 84 assetName(assetInfo.assetName) 85 { 86 } 87 }; 88 } // namespace OHOS::FileManagement::CloudSync 89 #endif 90