• 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      * @return int32_t 同步返回执行结果
61      */
62     virtual int32_t StopSync() = 0;
63     /**
64      * @brief 切换应用云同步开关
65      *
66      * @param accoutId 账号ID
67      * @param bundleName 应用包名
68      * @param status 应用开关状态
69      * @return int32_t 同步返回执行结果
70      */
71     virtual int32_t ChangeAppSwitch(const std::string &accoutId, const std::string &bundleName, bool status) = 0;
72     /**
73      * @brief 云数据变化触发同步
74      *
75      * @param accoutId 账号ID
76      * @param bundleName 应用包名
77      * @return int32_t 同步返回执行结果
78      */
79     virtual int32_t NotifyDataChange(const std::string &accoutId, const std::string &bundleName) = 0;
80     virtual int32_t EnableCloud(const std::string &accoutId, const SwitchDataObj &switchData) = 0;
81     virtual int32_t DisableCloud(const std::string &accoutId) = 0;
82     /**
83      * @brief 云账号退出选择保留或清除云数据
84      *
85      * @param accoutId 账号ID
86      * @param cleanOptions 说明云文件如何处理的方式
87      * @return int32_t 同步返回执行结果
88      */
89     virtual int32_t Clean(const std::string &accountId, const CleanOptions &cleanOptions) = 0;
90     virtual int32_t StartDownloadFile(const std::string &path) = 0;
91     virtual int32_t StopDownloadFile(const std::string &path) = 0;
92     virtual int32_t RegisterDownloadFileCallback(const std::shared_ptr<CloudDownloadCallback> downloadCallback) = 0;
93     virtual int32_t UnregisterDownloadFileCallback() = 0;
94 };
95 } // namespace OHOS::FileManagement::CloudSync
96 
97 #endif // OHOS_FILEMGMT_CLOUD_SYNC_MANAGER_H
98