161847f8eSopenharmony_ci/*
261847f8eSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"),
461847f8eSopenharmony_ci * you may not use this file except in compliance with the License.
561847f8eSopenharmony_ci * You may obtain a copy of the License at
661847f8eSopenharmony_ci *
761847f8eSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
861847f8eSopenharmony_ci *
961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and
1361847f8eSopenharmony_ci * limitations under the License.
1461847f8eSopenharmony_ci */
1561847f8eSopenharmony_ci
1661847f8eSopenharmony_ci/**
1761847f8eSopenharmony_ci * @file
1861847f8eSopenharmony_ci * @kit CoreFileKit
1961847f8eSopenharmony_ci */
2061847f8eSopenharmony_ci
2161847f8eSopenharmony_ciimport type { AsyncCallback } from './@ohos.base';
2261847f8eSopenharmony_ci
2361847f8eSopenharmony_ci/**
2461847f8eSopenharmony_ci * Provides the capabilities to manage the state and data of cloud file synchronization.
2561847f8eSopenharmony_ci *
2661847f8eSopenharmony_ci * @namespace cloudSyncManager
2761847f8eSopenharmony_ci * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager
2861847f8eSopenharmony_ci * @since 10
2961847f8eSopenharmony_ci */
3061847f8eSopenharmony_cideclare namespace cloudSyncManager {
3161847f8eSopenharmony_ci  /**
3261847f8eSopenharmony_ci   * Modify switch state of the application's cloud synchronization capability.
3361847f8eSopenharmony_ci   *
3461847f8eSopenharmony_ci   * @param { string } accountId - Current account id
3561847f8eSopenharmony_ci   * @param { string } bundleName - Name of bundle whose switchStatus is changing
3661847f8eSopenharmony_ci   * @param { boolean } status - New switch status
3761847f8eSopenharmony_ci   * @returns { Promise<void> } - Return Promise
3861847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission verification failed.
3961847f8eSopenharmony_ci   * @throws { BusinessError } 202 - The caller is not a system application.
4061847f8eSopenharmony_ci   * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
4161847f8eSopenharmony_ci   * <br>2.Incorrect parameter types.
4261847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager
4361847f8eSopenharmony_ci   * @systemapi
4461847f8eSopenharmony_ci   * @since 10
4561847f8eSopenharmony_ci   */
4661847f8eSopenharmony_ci  function changeAppCloudSwitch(accountId: string, bundleName: string, status: boolean): Promise<void>;
4761847f8eSopenharmony_ci
4861847f8eSopenharmony_ci  /**
4961847f8eSopenharmony_ci   * Modify switch state of the application's cloud synchronization capability.
5061847f8eSopenharmony_ci   *
5161847f8eSopenharmony_ci   * @param { string } accountId - Current account id
5261847f8eSopenharmony_ci   * @param { string } bundleName - Name of bundle whose switchStatus is changing
5361847f8eSopenharmony_ci   * @param { boolean } status - New switch status
5461847f8eSopenharmony_ci   * @param { AsyncCallback<void> } [callback] - Callback function
5561847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission verification failed.
5661847f8eSopenharmony_ci   * @throws { BusinessError } 202 - The caller is not a system application.
5761847f8eSopenharmony_ci   * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
5861847f8eSopenharmony_ci   * <br>2.Incorrect parameter types.
5961847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager
6061847f8eSopenharmony_ci   * @systemapi
6161847f8eSopenharmony_ci   * @since 10
6261847f8eSopenharmony_ci   */
6361847f8eSopenharmony_ci  function changeAppCloudSwitch(
6461847f8eSopenharmony_ci    accountId: string,
6561847f8eSopenharmony_ci    bundleName: string,
6661847f8eSopenharmony_ci    status: boolean,
6761847f8eSopenharmony_ci    callback: AsyncCallback<void>
6861847f8eSopenharmony_ci  ): void;
6961847f8eSopenharmony_ci
7061847f8eSopenharmony_ci  /**
7161847f8eSopenharmony_ci   * Notify the change of data in cloud.
7261847f8eSopenharmony_ci   *
7361847f8eSopenharmony_ci   * @param { string } accountId - Current account id
7461847f8eSopenharmony_ci   * @param { string } bundleName - Name of bundle whose switchStatus is changing
7561847f8eSopenharmony_ci   * @returns { Promise<void> } Return Promise
7661847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission verification failed.
7761847f8eSopenharmony_ci   * @throws { BusinessError } 202 - The caller is not a system application.
7861847f8eSopenharmony_ci   * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
7961847f8eSopenharmony_ci   * <br>2.Incorrect parameter types.
8061847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager
8161847f8eSopenharmony_ci   * @systemapi
8261847f8eSopenharmony_ci   * @since 10
8361847f8eSopenharmony_ci   */
8461847f8eSopenharmony_ci  function notifyDataChange(accountId: string, bundleName: string): Promise<void>;
8561847f8eSopenharmony_ci
8661847f8eSopenharmony_ci  /**
8761847f8eSopenharmony_ci   * Notify the change of data in cloud.
8861847f8eSopenharmony_ci   *
8961847f8eSopenharmony_ci   * @param { string } accountId - Current account id
9061847f8eSopenharmony_ci   * @param { string } bundleName - Name of bundle whose switchStatus is changing
9161847f8eSopenharmony_ci   * @param { AsyncCallback<void> } [callback] - Callback function
9261847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission verification failed.
9361847f8eSopenharmony_ci   * @throws { BusinessError } 202 - The caller is not a system application.
9461847f8eSopenharmony_ci   * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
9561847f8eSopenharmony_ci   * <br>2.Incorrect parameter types.
9661847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager
9761847f8eSopenharmony_ci   * @systemapi
9861847f8eSopenharmony_ci   * @since 10
9961847f8eSopenharmony_ci   */
10061847f8eSopenharmony_ci  function notifyDataChange(accountId: string, bundleName: string, callback: AsyncCallback<void>): void;
10161847f8eSopenharmony_ci
10261847f8eSopenharmony_ci  /**
10361847f8eSopenharmony_ci   * Enable the cloud file synchronization function.
10461847f8eSopenharmony_ci   *
10561847f8eSopenharmony_ci   * @permission ohos.permission.CLOUDFILE_SYNC_MANAGER
10661847f8eSopenharmony_ci   * @param { string } accountId - Current account id.
10761847f8eSopenharmony_ci   * @param { Record<string, boolean> } switches - Indicates switches information of all applications.
10861847f8eSopenharmony_ci   * @returns { Promise<void> } Return Promise
10961847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission verification failed.
11061847f8eSopenharmony_ci   * @throws { BusinessError } 202 - The caller is not a system application.
11161847f8eSopenharmony_ci   * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
11261847f8eSopenharmony_ci   * <br>2.Incorrect parameter types.
11361847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager
11461847f8eSopenharmony_ci   * @systemapi
11561847f8eSopenharmony_ci   * @since 10
11661847f8eSopenharmony_ci   */
11761847f8eSopenharmony_ci  function enableCloud(accountId: string, switches: Record<string, boolean>): Promise<void>;
11861847f8eSopenharmony_ci
11961847f8eSopenharmony_ci  /**
12061847f8eSopenharmony_ci   * Enable the cloud file synchronization function.
12161847f8eSopenharmony_ci   *
12261847f8eSopenharmony_ci   * @permission ohos.permission.CLOUDFILE_SYNC_MANAGER
12361847f8eSopenharmony_ci   * @param { string } accountId - Current account id
12461847f8eSopenharmony_ci   * @param { Record<string, boolean> } switches - Indicates switches information of all applications.
12561847f8eSopenharmony_ci   * @param { AsyncCallback<void> } [callback] - Callback function
12661847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission verification failed.
12761847f8eSopenharmony_ci   * @throws { BusinessError } 202 - The caller is not a system application.
12861847f8eSopenharmony_ci   * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
12961847f8eSopenharmony_ci   * <br>2.Incorrect parameter types.
13061847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager
13161847f8eSopenharmony_ci   * @systemapi
13261847f8eSopenharmony_ci   * @since 10
13361847f8eSopenharmony_ci   */
13461847f8eSopenharmony_ci  function enableCloud(accountId: string, switches: Record<string, boolean>, callback: AsyncCallback<void>): void;
13561847f8eSopenharmony_ci
13661847f8eSopenharmony_ci  /**
13761847f8eSopenharmony_ci   * Disable the cloud file synchronization function.
13861847f8eSopenharmony_ci   *
13961847f8eSopenharmony_ci   * @permission ohos.permission.CLOUDFILE_SYNC_MANAGER
14061847f8eSopenharmony_ci   * @param { string } accountId - Current account id.
14161847f8eSopenharmony_ci   * @returns { Promise<void> } Return Promise.
14261847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission verification failed.
14361847f8eSopenharmony_ci   * @throws { BusinessError } 202 - The caller is not a system application.
14461847f8eSopenharmony_ci   * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
14561847f8eSopenharmony_ci   * <br>2.Incorrect parameter types.
14661847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager
14761847f8eSopenharmony_ci   * @systemapi
14861847f8eSopenharmony_ci   * @since 10
14961847f8eSopenharmony_ci   */
15061847f8eSopenharmony_ci  function disableCloud(accountId: string): Promise<void>;
15161847f8eSopenharmony_ci
15261847f8eSopenharmony_ci  /**
15361847f8eSopenharmony_ci   * Disable the cloud file synchronization function.
15461847f8eSopenharmony_ci   *
15561847f8eSopenharmony_ci   * @permission ohos.permission.CLOUDFILE_SYNC_MANAGER
15661847f8eSopenharmony_ci   * @param { string } accountId - Current account id.
15761847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback - Callback function
15861847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission verification failed.
15961847f8eSopenharmony_ci   * @throws { BusinessError } 202 - The caller is not a system application.
16061847f8eSopenharmony_ci   * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
16161847f8eSopenharmony_ci   * <br>2.Incorrect parameter types.
16261847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager
16361847f8eSopenharmony_ci   * @systemapi
16461847f8eSopenharmony_ci   * @since 10
16561847f8eSopenharmony_ci   */
16661847f8eSopenharmony_ci  function disableCloud(accountId: string, callback: AsyncCallback<void>): void;
16761847f8eSopenharmony_ci
16861847f8eSopenharmony_ci  /**
16961847f8eSopenharmony_ci   * Describes the clear action type.
17061847f8eSopenharmony_ci   *
17161847f8eSopenharmony_ci   * @enum { number }
17261847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager
17361847f8eSopenharmony_ci   * @systemapi
17461847f8eSopenharmony_ci   * @since 10
17561847f8eSopenharmony_ci   */
17661847f8eSopenharmony_ci  enum Action {
17761847f8eSopenharmony_ci    /**
17861847f8eSopenharmony_ci     * Indicates clearing cloud identification only, retaining local cached data.
17961847f8eSopenharmony_ci     *
18061847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager
18161847f8eSopenharmony_ci     * @systemapi
18261847f8eSopenharmony_ci     * @since 10
18361847f8eSopenharmony_ci     */
18461847f8eSopenharmony_ci    RETAIN_DATA,
18561847f8eSopenharmony_ci
18661847f8eSopenharmony_ci    /**
18761847f8eSopenharmony_ci     * Indicates clearing all cloud-related file data, which synchronized with the cloud.
18861847f8eSopenharmony_ci     *
18961847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager
19061847f8eSopenharmony_ci     * @systemapi
19161847f8eSopenharmony_ci     * @since 10
19261847f8eSopenharmony_ci     */
19361847f8eSopenharmony_ci    CLEAR_DATA
19461847f8eSopenharmony_ci  }
19561847f8eSopenharmony_ci
19661847f8eSopenharmony_ci  /**
19761847f8eSopenharmony_ci   * Clean up cloud-related file data based on specific action.
19861847f8eSopenharmony_ci   *
19961847f8eSopenharmony_ci   * @permission ohos.permission.CLOUDFILE_SYNC_MANAGER
20061847f8eSopenharmony_ci   * @param { string } accountId - Current account id.
20161847f8eSopenharmony_ci   * @param { Record<string, Action> } appActions - Indicates information about cloud file need to clear in which way.
20261847f8eSopenharmony_ci   * @returns { Promise<void> } Return Promise.
20361847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission verification failed.
20461847f8eSopenharmony_ci   * @throws { BusinessError } 202 - The caller is not a system application.
20561847f8eSopenharmony_ci   * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
20661847f8eSopenharmony_ci   * <br>2.Incorrect parameter types.
20761847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager
20861847f8eSopenharmony_ci   * @systemapi
20961847f8eSopenharmony_ci   * @since 10
21061847f8eSopenharmony_ci   */
21161847f8eSopenharmony_ci  function clean(accountId: string, appActions: Record<string, Action>): Promise<void>;
21261847f8eSopenharmony_ci
21361847f8eSopenharmony_ci  /**
21461847f8eSopenharmony_ci   * Clean up cloud-related file data based on specific action.
21561847f8eSopenharmony_ci   *
21661847f8eSopenharmony_ci   * @permission ohos.permission.CLOUDFILE_SYNC_MANAGER
21761847f8eSopenharmony_ci   * @param { string } accountId - Current account id.
21861847f8eSopenharmony_ci   * @param { Record<string, Action> } appActions - Indicates information about cloud file need to clear in which way.
21961847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback - Callback function
22061847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission verification failed.
22161847f8eSopenharmony_ci   * @throws { BusinessError } 202 - The caller is not a system application.
22261847f8eSopenharmony_ci   * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
22361847f8eSopenharmony_ci   * <br>2.Incorrect parameter types.
22461847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager
22561847f8eSopenharmony_ci   * @systemapi
22661847f8eSopenharmony_ci   * @since 10
22761847f8eSopenharmony_ci   */
22861847f8eSopenharmony_ci  function clean(accountId: string, appActions: Record<string, Action>, callback: AsyncCallback<void>): void;
22961847f8eSopenharmony_ci
23061847f8eSopenharmony_ci  /**
23161847f8eSopenharmony_ci   * Notify the change of data in cloud.
23261847f8eSopenharmony_ci   *
23361847f8eSopenharmony_ci   * @permission ohos.permission.CLOUDFILE_SYNC_MANAGER
23461847f8eSopenharmony_ci   * @param { number } userId - The Id of the user whose cloud data changed
23561847f8eSopenharmony_ci   * @param { ExtraData } extraData - The change info from push notification
23661847f8eSopenharmony_ci   * @returns { Promise<void> } Return Promise
23761847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
23861847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
23961847f8eSopenharmony_ci   * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
24061847f8eSopenharmony_ci   * <br>2.Incorrect parameter types.
24161847f8eSopenharmony_ci   * @throws { BusinessError } 13600001 - IPC error.
24261847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager
24361847f8eSopenharmony_ci   * @systemapi
24461847f8eSopenharmony_ci   * @since 11
24561847f8eSopenharmony_ci   */
24661847f8eSopenharmony_ci  function notifyDataChange(userId: number, extraData: ExtraData): Promise<void>;
24761847f8eSopenharmony_ci
24861847f8eSopenharmony_ci  /**
24961847f8eSopenharmony_ci   * Notify the change of data in cloud.
25061847f8eSopenharmony_ci   *
25161847f8eSopenharmony_ci   * @permission ohos.permission.CLOUDFILE_SYNC_MANAGER
25261847f8eSopenharmony_ci   * @param { number } userId - The Id of the user whose cloud data changed
25361847f8eSopenharmony_ci   * @param { ExtraData } extraData - The change info from push notification
25461847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback - Callback function
25561847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
25661847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
25761847f8eSopenharmony_ci   * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;
25861847f8eSopenharmony_ci   * <br>2.Incorrect parameter types.
25961847f8eSopenharmony_ci   * @throws { BusinessError } 13600001 - IPC error.
26061847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager
26161847f8eSopenharmony_ci   * @systemapi
26261847f8eSopenharmony_ci   * @since 11
26361847f8eSopenharmony_ci   */
26461847f8eSopenharmony_ci  function notifyDataChange(userId: number, extraData: ExtraData, callback: AsyncCallback<void>): void;
26561847f8eSopenharmony_ci
26661847f8eSopenharmony_ci  /**
26761847f8eSopenharmony_ci   * The change info from push notification.
26861847f8eSopenharmony_ci   *
26961847f8eSopenharmony_ci   * @interface ExtraData
27061847f8eSopenharmony_ci   * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager
27161847f8eSopenharmony_ci   * @systemapi
27261847f8eSopenharmony_ci   * @since 11
27361847f8eSopenharmony_ci   */
27461847f8eSopenharmony_ci  interface ExtraData {
27561847f8eSopenharmony_ci    /**
27661847f8eSopenharmony_ci     * The eventId of the push info.
27761847f8eSopenharmony_ci     *
27861847f8eSopenharmony_ci     * @type { string }
27961847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager
28061847f8eSopenharmony_ci     * @systemapi
28161847f8eSopenharmony_ci     * @since 11
28261847f8eSopenharmony_ci     */
28361847f8eSopenharmony_ci    eventId: string;
28461847f8eSopenharmony_ci    /**
28561847f8eSopenharmony_ci     * The change info.
28661847f8eSopenharmony_ci     *
28761847f8eSopenharmony_ci     * @type { string }
28861847f8eSopenharmony_ci     * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSyncManager
28961847f8eSopenharmony_ci     * @systemapi
29061847f8eSopenharmony_ci     * @since 11
29161847f8eSopenharmony_ci     */
29261847f8eSopenharmony_ci    extraData: string;
29361847f8eSopenharmony_ci  }
29461847f8eSopenharmony_ci}
29561847f8eSopenharmony_ci
29661847f8eSopenharmony_ciexport default cloudSyncManager;
297