• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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_MANAGER_H
17 #define OHOS_FILEMGMT_CLOUD_SYNC_MANAGER_H
18 
19 #include <memory>
20 
21 #include "cloud_download_callback.h"
22 #include "cloud_sync_callback.h"
23 #include "cloud_sync_common.h"
24 
25 namespace OHOS::FileManagement::CloudSync {
26 class CloudSyncManager {
27 public:
28     static CloudSyncManager &GetInstance();
29     /**
30      * @brief 注册
31      *
32      * @param callback 注册同步回调
33      * @return int32_t 同步返回执行结果
34      */
35     virtual int32_t RegisterCallback(const std::shared_ptr<CloudSyncCallback> callback) = 0;
36     /**
37      * @brief 注册
38      *
39      * @param callback 卸载同步回调
40      * @return int32_t 返回执行结果
41      */
42     virtual int32_t UnRegisterCallback() = 0;
43     /**
44      * @brief 启动同步
45      *
46      * @return int32_t 同步返回执行结果
47      */
48     virtual int32_t StartSync() = 0;
49     /**
50      * @brief 启动同步
51      *
52      * @param forceFlag 是否强制继续同步,当前仅支持低电量下暂停后继续上传
53      * @param callback 注册同步回调
54      * @return int32_t 同步返回执行结果
55      */
56     virtual int32_t StartSync(bool forceFlag, const std::shared_ptr<CloudSyncCallback> callback) = 0;
57     /**
58      * @brief 触发同步
59      *
60      * @param bundleName 应用包名
61      * @param userId 用户ID
62      * @return int32_t 同步返回执行结果
63      */
64     virtual int32_t TriggerSync(const std::string &bundleName, const int32_t &userId) = 0;
65     /**
66      * @brief 停止同步
67      *
68      * @return int32_t 同步返回执行结果
69      */
70     virtual int32_t StopSync() = 0;
71     /**
72      * @brief 切换应用云同步开关
73      *
74      * @param accoutId 账号ID
75      * @param bundleName 应用包名
76      * @param status 应用开关状态
77      * @return int32_t 同步返回执行结果
78      */
79     virtual int32_t ChangeAppSwitch(const std::string &accoutId, const std::string &bundleName, bool status) = 0;
80     /**
81      * @brief 云数据变化触发同步
82      *
83      * @param accoutId 账号ID
84      * @param bundleName 应用包名
85      * @return int32_t 同步返回执行结果
86      */
87     virtual int32_t NotifyDataChange(const std::string &accoutId, const std::string &bundleName) = 0;
88     virtual int32_t NotifyEventChange(int32_t userId, const std::string &eventId, const std::string &extraData) = 0;
89     virtual int32_t EnableCloud(const std::string &accoutId, const SwitchDataObj &switchData) = 0;
90     virtual int32_t DisableCloud(const std::string &accoutId) = 0;
91     /**
92      * @brief 云账号退出选择保留或清除云数据
93      *
94      * @param accoutId 账号ID
95      * @param cleanOptions 说明云文件如何处理的方式
96      * @return int32_t 同步返回执行结果
97      */
98     virtual int32_t Clean(const std::string &accountId, const CleanOptions &cleanOptions) = 0;
99     virtual int32_t StartDownloadFile(const std::string &path) = 0;
100     virtual int32_t StartFileCache(const std::string &path) = 0;
101     virtual int32_t StopDownloadFile(const std::string &path) = 0;
102     virtual int32_t RegisterDownloadFileCallback(const std::shared_ptr<CloudDownloadCallback> downloadCallback) = 0;
103     virtual int32_t UnregisterDownloadFileCallback() = 0;
104     virtual int32_t GetSyncTime(int64_t &syncTime) = 0;
105     virtual int32_t CleanCache(const std::string &uri) = 0;
106 };
107 } // namespace OHOS::FileManagement::CloudSync
108 
109 #endif // OHOS_FILEMGMT_CLOUD_SYNC_MANAGER_H
110