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 CLOUD_DISK_DATA_SYNCER_H 17 #define CLOUD_DISK_DATA_SYNCER_H 18 19 #include "cloud_disk_data_handler.h" 20 #include "functional" 21 #include "file_column.h" 22 #include "data_syncer.h" 23 #include "data_sync_const.h" 24 25 namespace OHOS { 26 namespace FileManagement { 27 namespace CloudSync { 28 class CloudDiskDataSyncer : public DataSyncer, std::enable_shared_from_this<CloudDiskDataSyncer> { 29 public: 30 CloudDiskDataSyncer(const std::string bundleName, const int32_t userId); 31 virtual ~CloudDiskDataSyncer() = default; 32 virtual void Schedule() override; 33 virtual void ScheduleByType(SyncTriggerType syncTriggerType) override; 34 virtual void Reset() override; 35 36 virtual int32_t StartDownloadFile(const std::string path, const int32_t userId) override; 37 virtual int32_t StopDownloadFile(const std::string path, const int32_t userId) override; 38 virtual int32_t CleanCache(const std::string &uri) override; 39 virtual int32_t Init(const std::string bundleName, const int32_t userId) override; 40 virtual int32_t Clean(const int action) override; 41 42 private: 43 enum { 44 BEGIN, 45 DOWNLOADFILE, 46 COMPLETEPULL, 47 UPLOADFILE, 48 COMPLETEPUSH, 49 END 50 }; 51 52 int32_t DownloadFile(); 53 int32_t UploadFile(); 54 int32_t Complete(bool isNeedNotify = true) override; 55 void ChangesNotify(); 56 57 int32_t stage_ = BEGIN; 58 std::shared_ptr<CloudDiskDataHandler> cloudDiskHandler_; 59 }; 60 } // namespace CloudSync 61 } // namespace FileManagement 62 } // namespace OHOS 63 #endif // CLOUD_DISK_DATA_SYNCER_H 64