• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 #ifndef OHOS_CLOUD_FILE_DATA_SYNC_MANAGER_H
16 #define OHOS_CLOUD_FILE_DATA_SYNC_MANAGER_H
17 
18 #include <memory>
19 
20 #include "data_sync_const.h"
21 #include "i_cloud_download_callback.h"
22 #include "i_cloud_sync_callback.h"
23 
24 namespace OHOS::FileManagement::CloudFile {
25 class DataSyncManager {
26 public:
27     using BundleNameUserInfo = CloudSync::BundleNameUserInfo;
28     using SyncTriggerType = CloudSync::SyncTriggerType;
29     DataSyncManager() = default;
30     virtual ~DataSyncManager() = default;
31 
32     virtual int32_t TriggerStartSync(const std::string &bundleName,
33                                      const int32_t userId,
34                                      bool forceFlag,
35                                      SyncTriggerType triggerType,
36                                      std::string prepareTraceId = "");
37     virtual int32_t TriggerStopSync(const std::string &bundleName, const int32_t userId,
38                                     bool forceFlag, SyncTriggerType triggerType);
39     virtual int32_t TriggerRecoverySync(SyncTriggerType triggerType);
40     virtual int32_t StopUploadTask(const std::string &bundleName, const int32_t userId);
41     virtual int32_t ResetCursor(const std::string &bundleName, const int32_t &userId);
42     virtual void RegisterCloudSyncCallback(const std::string &bundleName,
43                                            const std::string &callerBundleName,
44                                            const int32_t userId,
45                                            const sptr<CloudSync::ICloudSyncCallback> &callback);
46     virtual void UnRegisterCloudSyncCallback(const std::string &bundleName, const std::string &callerBundleName);
47     virtual int32_t IsSkipSync(const std::string &bundleName, const int32_t userId, bool forceFlag);
48     virtual int32_t StartDownloadFile(const BundleNameUserInfo &bundleNameUserInfo,
49                                       const std::vector<std::string> pathVec,
50                                       int64_t &downloadId,
51                                       const sptr<CloudSync::ICloudDownloadCallback> &downloadCallback);
52     virtual int32_t StopDownloadFile(const BundleNameUserInfo &bundleNameUserInfo,
53                                      const std::string path,
54                                      bool needClean = false);
55     virtual int32_t StopFileCache(const BundleNameUserInfo &bundleNameUserInfo,
56                                   const int64_t &downloadId,
57                                   bool needClean);
58     virtual int32_t RegisterDownloadFileCallback(const BundleNameUserInfo &bundleNameUserInfo,
59                                                  const sptr<CloudSync::ICloudDownloadCallback> &downloadCallback);
60     virtual int32_t UnregisterDownloadFileCallback(const BundleNameUserInfo &bundleNameUserInfo);
61     virtual int32_t CleanCloudFile(const int32_t userId, const std::string &bundleName, const int action);
62     virtual int32_t CleanRemainFile(const std::string &bundleName, const int32_t userId);
63     virtual int32_t OptimizeStorage(const std::string &bundleName, const int32_t userId, const int32_t agingDays);
64     virtual int32_t DownloadThumb();
65     virtual int32_t TriggerDownloadThumb();
66     virtual int32_t CacheVideo();
67     virtual int32_t CleanVideoCache();
68     virtual int32_t CleanCache(const std::string &bundleName, const int32_t userId, const std::string &uri);
69     virtual int32_t BatchDentryFileInsert(const std::vector<CloudSync::DentryFileInfo> &fileInfo,
70         std::vector<std::string> &failCloudId);
71     virtual int32_t DisableCloud(const int32_t userId);
72     virtual int32_t GetUserId(int32_t &userId);
73     virtual int32_t SaveSubscription(const std::string &bundleName, const int32_t userId);
74     virtual int32_t ReportEntry(const std::string &bundleName, const int32_t userId);
75 };
76 } // namespace OHOS::FileManagement::CloudSync
77 
78 #endif // OHOS_CLOUD_FILE_DATA_SYNC_MANAGER_H