• 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 <bitset>
19 #include <memory>
20 
21 #include "data_sync_const.h"
22 #include "i_cloud_download_callback.h"
23 #include "i_cloud_optimize_callback.h"
24 #include "i_cloud_sync_callback.h"
25 
26 namespace OHOS::FileManagement::CloudFile {
27 class DataSyncManager {
28 public:
29     using BundleNameUserInfo = CloudSync::BundleNameUserInfo;
30     using SyncTriggerType = CloudSync::SyncTriggerType;
31     DataSyncManager() = default;
32     virtual ~DataSyncManager() = default;
33 
34     virtual int32_t TriggerStartSync(const std::string &bundleName,
35                                      const int32_t userId,
36                                      bool forceFlag,
37                                      SyncTriggerType triggerType,
38                                      std::string prepareTraceId = "");
39     virtual int32_t TriggerStopSync(const std::string &bundleName, const int32_t userId,
40                                     bool forceFlag, SyncTriggerType triggerType);
41     virtual int32_t TriggerRecoverySync(SyncTriggerType triggerType);
42     virtual int32_t StopUploadTask(const std::string &bundleName, const int32_t userId);
43     virtual int32_t ResetCursor(const std::string &bundleName, const int32_t &userId);
44     virtual void RegisterCloudSyncCallback(const std::string &bundleName,
45                                            const std::string &callerBundleName,
46                                            const int32_t userId,
47                                            const sptr<CloudSync::ICloudSyncCallback> &callback);
48     virtual void UnRegisterCloudSyncCallback(const std::string &bundleName, const std::string &callerBundleName);
49     virtual int32_t IsSkipSync(const std::string &bundleName, const int32_t userId, bool forceFlag);
50     virtual int32_t StartDownloadFile(const BundleNameUserInfo &bundleNameUserInfo,
51                                       const std::vector<std::string> &pathVec,
52                                       int64_t &downloadId,
53                                       std::bitset<FIELD_KEY_MAX_SIZE> fieldkey,
54                                       const sptr<CloudSync::ICloudDownloadCallback> &downloadCallback,
55                                       int32_t timeout = -1);
56     virtual int32_t StopDownloadFile(const BundleNameUserInfo &bundleNameUserInfo,
57                                      const std::string &path,
58                                      bool needClean = false);
59     virtual int32_t StopFileCache(const BundleNameUserInfo &bundleNameUserInfo,
60                                   int64_t downloadId,
61                                   bool needClean,
62                                   int32_t timeout = -1);
63     virtual int32_t RegisterDownloadFileCallback(const BundleNameUserInfo &bundleNameUserInfo,
64                                                  const sptr<CloudSync::ICloudDownloadCallback> &downloadCallback);
65     virtual int32_t UnregisterDownloadFileCallback(const BundleNameUserInfo &bundleNameUserInfo);
66     virtual int32_t CleanCloudFile(const int32_t userId, const std::string &bundleName, const int action);
67     virtual int32_t CleanRemainFile(const std::string &bundleName, const int32_t userId);
68     virtual int32_t OptimizeStorage(const std::string &bundleName, const int32_t userId, const int32_t agingDays);
69     virtual int32_t StartOptimizeStorage(const BundleNameUserInfo &bundleNameUserInfo,
70         const CloudSync::OptimizeSpaceOptions &optimizeOptions,
71         const sptr<CloudSync::ICloudOptimizeCallback> &optimizeCallback);
72     virtual int32_t StopOptimizeStorage(const BundleNameUserInfo &bundleNameUserInfo);
73     virtual int32_t BatchCleanFile(const std::vector<CloudSync::CleanFileInfo> &fileInfo,
74         std::vector<std::string> &failCloudId);
75     virtual int32_t DownloadThumb();
76     virtual int32_t TriggerDownloadThumb();
77     virtual int32_t CacheVideo();
78     virtual int32_t CleanVideoCache();
79     virtual int32_t CleanCache(const std::string &bundleName, const int32_t userId, const std::string &uri);
80     virtual int32_t BatchDentryFileInsert(const std::vector<CloudSync::DentryFileInfo> &fileInfo,
81         std::vector<std::string> &failCloudId);
82     virtual int32_t DisableCloud(const int32_t userId);
83     virtual int32_t GetUserId(int32_t &userId);
84     virtual int32_t SaveSubscription(const std::string &bundleName, const int32_t userId);
85     virtual int32_t ReportEntry(const std::string &bundleName, const int32_t userId);
86     virtual int32_t ChangeAppSwitch(const std::string &bundleName, const int32_t userId, bool status);
87 };
88 } // namespace OHOS::FileManagement::CloudSync
89 
90 #endif // OHOS_CLOUD_FILE_DATA_SYNC_MANAGER_H