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/** 17 * @file 18 * @kit CoreFileKit 19 */ 20 21import type { AsyncCallback } from './@ohos.base'; 22 23/** 24 * Provides the capabilities to manage the state and data of cloud file synchronization. 25 * 26 * @namespace cloudSyncManager 27 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 28 * @since 10 29 */ 30declare namespace cloudSyncManager { 31 /** 32 * Modify switch state of the application's cloud synchronization capability. 33 * 34 * @param { string } accountId - Current account id 35 * @param { string } bundleName - Name of bundle whose switchStatus is changing 36 * @param { boolean } status - New switch status 37 * @returns { Promise<void> } - Return Promise 38 * @throws { BusinessError } 201 - Permission verification failed. 39 * @throws { BusinessError } 202 - The caller is not a system application. 40 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 41 * <br>2.Incorrect parameter types. 42 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 43 * @systemapi 44 * @since 10 45 */ 46 function changeAppCloudSwitch(accountId: string, bundleName: string, status: boolean): Promise<void>; 47 48 /** 49 * Modify switch state of the application's cloud synchronization capability. 50 * 51 * @param { string } accountId - Current account id 52 * @param { string } bundleName - Name of bundle whose switchStatus is changing 53 * @param { boolean } status - New switch status 54 * @param { AsyncCallback<void> } [callback] - Callback function 55 * @throws { BusinessError } 201 - Permission verification failed. 56 * @throws { BusinessError } 202 - The caller is not a system application. 57 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 58 * <br>2.Incorrect parameter types. 59 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 60 * @systemapi 61 * @since 10 62 */ 63 function changeAppCloudSwitch( 64 accountId: string, 65 bundleName: string, 66 status: boolean, 67 callback: AsyncCallback<void> 68 ): void; 69 70 /** 71 * Notify the change of data in cloud. 72 * 73 * @param { string } accountId - Current account id 74 * @param { string } bundleName - Name of bundle whose switchStatus is changing 75 * @returns { Promise<void> } Return Promise 76 * @throws { BusinessError } 201 - Permission verification failed. 77 * @throws { BusinessError } 202 - The caller is not a system application. 78 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 79 * <br>2.Incorrect parameter types. 80 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 81 * @systemapi 82 * @since 10 83 */ 84 function notifyDataChange(accountId: string, bundleName: string): Promise<void>; 85 86 /** 87 * Notify the change of data in cloud. 88 * 89 * @param { string } accountId - Current account id 90 * @param { string } bundleName - Name of bundle whose switchStatus is changing 91 * @param { AsyncCallback<void> } [callback] - Callback function 92 * @throws { BusinessError } 201 - Permission verification failed. 93 * @throws { BusinessError } 202 - The caller is not a system application. 94 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 95 * <br>2.Incorrect parameter types. 96 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 97 * @systemapi 98 * @since 10 99 */ 100 function notifyDataChange(accountId: string, bundleName: string, callback: AsyncCallback<void>): void; 101 102 /** 103 * Enable the cloud file synchronization function. 104 * 105 * @permission ohos.permission.CLOUDFILE_SYNC_MANAGER 106 * @param { string } accountId - Current account id. 107 * @param { Record<string, boolean> } switches - Indicates switches information of all applications. 108 * @returns { Promise<void> } Return Promise 109 * @throws { BusinessError } 201 - Permission verification failed. 110 * @throws { BusinessError } 202 - The caller is not a system application. 111 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 112 * <br>2.Incorrect parameter types. 113 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 114 * @systemapi 115 * @since 10 116 */ 117 function enableCloud(accountId: string, switches: Record<string, boolean>): Promise<void>; 118 119 /** 120 * Enable the cloud file synchronization function. 121 * 122 * @permission ohos.permission.CLOUDFILE_SYNC_MANAGER 123 * @param { string } accountId - Current account id 124 * @param { Record<string, boolean> } switches - Indicates switches information of all applications. 125 * @param { AsyncCallback<void> } [callback] - Callback function 126 * @throws { BusinessError } 201 - Permission verification failed. 127 * @throws { BusinessError } 202 - The caller is not a system application. 128 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 129 * <br>2.Incorrect parameter types. 130 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 131 * @systemapi 132 * @since 10 133 */ 134 function enableCloud(accountId: string, switches: Record<string, boolean>, callback: AsyncCallback<void>): void; 135 136 /** 137 * Disable the cloud file synchronization function. 138 * 139 * @permission ohos.permission.CLOUDFILE_SYNC_MANAGER 140 * @param { string } accountId - Current account id. 141 * @returns { Promise<void> } Return Promise. 142 * @throws { BusinessError } 201 - Permission verification failed. 143 * @throws { BusinessError } 202 - The caller is not a system application. 144 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 145 * <br>2.Incorrect parameter types. 146 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 147 * @systemapi 148 * @since 10 149 */ 150 function disableCloud(accountId: string): Promise<void>; 151 152 /** 153 * Disable the cloud file synchronization function. 154 * 155 * @permission ohos.permission.CLOUDFILE_SYNC_MANAGER 156 * @param { string } accountId - Current account id. 157 * @param { AsyncCallback<void> } callback - Callback function 158 * @throws { BusinessError } 201 - Permission verification failed. 159 * @throws { BusinessError } 202 - The caller is not a system application. 160 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 161 * <br>2.Incorrect parameter types. 162 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 163 * @systemapi 164 * @since 10 165 */ 166 function disableCloud(accountId: string, callback: AsyncCallback<void>): void; 167 168 /** 169 * Describes the clear action type. 170 * 171 * @enum { number } 172 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 173 * @systemapi 174 * @since 10 175 */ 176 enum Action { 177 /** 178 * Indicates clearing cloud identification only, retaining local cached data. 179 * 180 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 181 * @systemapi 182 * @since 10 183 */ 184 RETAIN_DATA, 185 186 /** 187 * Indicates clearing all cloud-related file data, which synchronized with the cloud. 188 * 189 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 190 * @systemapi 191 * @since 10 192 */ 193 CLEAR_DATA 194 } 195 196 /** 197 * Clean up cloud-related file data based on specific action. 198 * 199 * @permission ohos.permission.CLOUDFILE_SYNC_MANAGER 200 * @param { string } accountId - Current account id. 201 * @param { Record<string, Action> } appActions - Indicates information about cloud file need to clear in which way. 202 * @returns { Promise<void> } Return Promise. 203 * @throws { BusinessError } 201 - Permission verification failed. 204 * @throws { BusinessError } 202 - The caller is not a system application. 205 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 206 * <br>2.Incorrect parameter types. 207 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 208 * @systemapi 209 * @since 10 210 */ 211 function clean(accountId: string, appActions: Record<string, Action>): Promise<void>; 212 213 /** 214 * Clean up cloud-related file data based on specific action. 215 * 216 * @permission ohos.permission.CLOUDFILE_SYNC_MANAGER 217 * @param { string } accountId - Current account id. 218 * @param { Record<string, Action> } appActions - Indicates information about cloud file need to clear in which way. 219 * @param { AsyncCallback<void> } callback - Callback function 220 * @throws { BusinessError } 201 - Permission verification failed. 221 * @throws { BusinessError } 202 - The caller is not a system application. 222 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 223 * <br>2.Incorrect parameter types. 224 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 225 * @systemapi 226 * @since 10 227 */ 228 function clean(accountId: string, appActions: Record<string, Action>, callback: AsyncCallback<void>): void; 229 230 /** 231 * Notify the change of data in cloud. 232 * 233 * @permission ohos.permission.CLOUDFILE_SYNC_MANAGER 234 * @param { number } userId - The Id of the user whose cloud data changed 235 * @param { ExtraData } extraData - The change info from push notification 236 * @returns { Promise<void> } Return Promise 237 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 238 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 239 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 240 * <br>2.Incorrect parameter types. 241 * @throws { BusinessError } 13600001 - IPC error. 242 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 243 * @systemapi 244 * @since 11 245 */ 246 function notifyDataChange(userId: number, extraData: ExtraData): Promise<void>; 247 248 /** 249 * Notify the change of data in cloud. 250 * 251 * @permission ohos.permission.CLOUDFILE_SYNC_MANAGER 252 * @param { number } userId - The Id of the user whose cloud data changed 253 * @param { ExtraData } extraData - The change info from push notification 254 * @param { AsyncCallback<void> } callback - Callback function 255 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 256 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 257 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 258 * <br>2.Incorrect parameter types. 259 * @throws { BusinessError } 13600001 - IPC error. 260 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 261 * @systemapi 262 * @since 11 263 */ 264 function notifyDataChange(userId: number, extraData: ExtraData, callback: AsyncCallback<void>): void; 265 266 /** 267 * The change info from push notification. 268 * 269 * @interface ExtraData 270 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 271 * @systemapi 272 * @since 11 273 */ 274 interface ExtraData { 275 /** 276 * The eventId of the push info. 277 * 278 * @type { string } 279 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 280 * @systemapi 281 * @since 11 282 */ 283 eventId: string; 284 /** 285 * The change info. 286 * 287 * @type { string } 288 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager 289 * @systemapi 290 * @since 11 291 */ 292 extraData: string; 293 } 294} 295 296export default cloudSyncManager; 297