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 49 // member for batch download(same downloadId) 50 int64_t batchDownloadSize; 51 int64_t batchTotalSize; 52 int64_t batchSuccNum; 53 int64_t batchFailNum; 54 int64_t batchTotalNum; 55 Status batchState; 56 57 bool ReadBatchFromParcel(Parcel &parcel); 58 bool ReadFromParcel(Parcel &parcel); 59 bool MarshallingBatch(Parcel &parcel) const; 60 bool Marshalling(Parcel &parcel) const override; 61 static DownloadProgressObj *Unmarshalling(Parcel &parcel); 62 std::string to_string(); 63 }; 64 65 struct SwitchDataObj : public Parcelable { 66 std::map<std::string, bool> switchData; 67 bool ReadFromParcel(Parcel &parcel); 68 bool Marshalling(Parcel &parcel) const override; 69 static SwitchDataObj *Unmarshalling(Parcel &parcel); 70 }; 71 72 struct CleanOptions : public Parcelable { 73 std::map<std::string, int32_t> appActionsData; 74 bool ReadFromParcel(Parcel &parcel); 75 bool Marshalling(Parcel &parcel) const override; 76 static CleanOptions *Unmarshalling(Parcel &parcel); 77 }; 78 79 struct AssetInfoObj : public Parcelable { 80 std::string uri; 81 std::string recordType; 82 std::string recordId; 83 std::string fieldKey; 84 std::string assetName; 85 bool ReadFromParcel(Parcel &parcel); 86 bool Marshalling(Parcel &parcel) const override; 87 static AssetInfoObj *Unmarshalling(Parcel &parcel); 88 89 AssetInfoObj() = default; AssetInfoObjAssetInfoObj90 AssetInfoObj(const AssetInfo &assetInfo) 91 : uri(assetInfo.uri), 92 recordType(assetInfo.recordType), 93 recordId(assetInfo.recordId), 94 fieldKey(assetInfo.fieldKey), 95 assetName(assetInfo.assetName) 96 { 97 } 98 }; 99 } // namespace OHOS::FileManagement::CloudSync 100 #endif 101