161847f8eSopenharmony_ci/*
261847f8eSopenharmony_ci * Copyright (C) 2023-2024 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 TelephonyKit
1961847f8eSopenharmony_ci */
2061847f8eSopenharmony_ci
2161847f8eSopenharmony_ciimport type { AsyncCallback } from './@ohos.base';
2261847f8eSopenharmony_ciimport type dataSharePredicates from './@ohos.data.dataSharePredicates';
2361847f8eSopenharmony_ci
2461847f8eSopenharmony_ciimport type Context from './application/BaseContext';
2561847f8eSopenharmony_ci
2661847f8eSopenharmony_ci/**
2761847f8eSopenharmony_ci * Provides applications with APIs for obtaining vcard.
2861847f8eSopenharmony_ci *
2961847f8eSopenharmony_ci * @namespace vcard
3061847f8eSopenharmony_ci * @syscap SystemCapability.Telephony.CoreService
3161847f8eSopenharmony_ci * @since 11
3261847f8eSopenharmony_ci */
3361847f8eSopenharmony_cideclare namespace vcard {
3461847f8eSopenharmony_ci  /**
3561847f8eSopenharmony_ci   * Import contacts from the specified vcf file.
3661847f8eSopenharmony_ci   *
3761847f8eSopenharmony_ci   * @permission ohos.permission.WRITE_CONTACTS and
3861847f8eSopenharmony_ci   * ohos.permission.READ_CONTACTS
3961847f8eSopenharmony_ci   * @param { Context } context - Indicates the context of application or
4061847f8eSopenharmony_ci   *     capability.
4161847f8eSopenharmony_ci   * @param { string } filePath - Vcf file path.
4261847f8eSopenharmony_ci   * @param { number } accountId - Contact account ID. When the app chooses to
4361847f8eSopenharmony_ci   *     import the vcf file into a contact account,
4461847f8eSopenharmony_ci   * it needs to pass in the accountId. If the accountId is not passed, a new
4561847f8eSopenharmony_ci   * contact account will be added by default.
4661847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback - The callback of the function.
4761847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
4861847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Non-system applications use system APIs.
4961847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
5061847f8eSopenharmony_ci   *     2. Incorrect parameter types.
5161847f8eSopenharmony_ci   * @throws { BusinessError } 8300001 - Invalid parameter value.
5261847f8eSopenharmony_ci   * @throws { BusinessError } 8300003 - System internal error.
5361847f8eSopenharmony_ci   * @throws { BusinessError } 8300999 - Unknown error.
5461847f8eSopenharmony_ci   * @syscap SystemCapability.Telephony.CoreService
5561847f8eSopenharmony_ci   * @systemapi Hide this for inner system use.
5661847f8eSopenharmony_ci   * @since 11
5761847f8eSopenharmony_ci   */
5861847f8eSopenharmony_ci  function importVCard(context: Context, filePath: string, accountId: number, callback: AsyncCallback<void>): void;
5961847f8eSopenharmony_ci
6061847f8eSopenharmony_ci  /**
6161847f8eSopenharmony_ci   * Import contacts from the specified vcf file.
6261847f8eSopenharmony_ci   *
6361847f8eSopenharmony_ci   * @permission ohos.permission.WRITE_CONTACTS and
6461847f8eSopenharmony_ci   * ohos.permission.READ_CONTACTS
6561847f8eSopenharmony_ci   * @param { Context } context - Indicates the context of application or
6661847f8eSopenharmony_ci   *     capability.
6761847f8eSopenharmony_ci   * @param { string } filePath - Vcf file path.
6861847f8eSopenharmony_ci   * @param { number } accountId - Contact account ID.When the app chooses to
6961847f8eSopenharmony_ci   *     import the vcf file into a contact account,
7061847f8eSopenharmony_ci   * it needs to pass in the accountId. If the accountId is not passed, a new
7161847f8eSopenharmony_ci   * contact account will be added by default.
7261847f8eSopenharmony_ci   * @returns { Promise<void> } the promise returned by the function.
7361847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
7461847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Non-system applications use system APIs.
7561847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
7661847f8eSopenharmony_ci   *     2. Incorrect parameter types.
7761847f8eSopenharmony_ci   * @throws { BusinessError } 8300001 - Invalid parameter value.
7861847f8eSopenharmony_ci   * @throws { BusinessError } 8300003 - System internal error.
7961847f8eSopenharmony_ci   * @throws { BusinessError } 8300999 - Unknown error.
8061847f8eSopenharmony_ci   * @syscap SystemCapability.Telephony.CoreService
8161847f8eSopenharmony_ci   * @systemapi Hide this for inner system use.
8261847f8eSopenharmony_ci   * @since 11
8361847f8eSopenharmony_ci   */
8461847f8eSopenharmony_ci  function importVCard(context: Context, filePath: string, accountId?: number): Promise<void>;
8561847f8eSopenharmony_ci
8661847f8eSopenharmony_ci  /**
8761847f8eSopenharmony_ci   * Import contacts from the specified vcf file.
8861847f8eSopenharmony_ci   *
8961847f8eSopenharmony_ci   * @permission ohos.permission.WRITE_CONTACTS and
9061847f8eSopenharmony_ci   * ohos.permission.READ_CONTACTS
9161847f8eSopenharmony_ci   * @param { Context } context - Indicates the context of application or
9261847f8eSopenharmony_ci   *     capability.
9361847f8eSopenharmony_ci   * @param { string } filePath - Vcf file path.
9461847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback - The callback of the function.
9561847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
9661847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Non-system applications use system APIs.
9761847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
9861847f8eSopenharmony_ci   *     2. Incorrect parameter types.
9961847f8eSopenharmony_ci   * @throws { BusinessError } 8300001 - Invalid parameter value.
10061847f8eSopenharmony_ci   * @throws { BusinessError } 8300003 - System internal error.
10161847f8eSopenharmony_ci   * @throws { BusinessError } 8300999 - Unknown error.
10261847f8eSopenharmony_ci   * @syscap SystemCapability.Telephony.CoreService
10361847f8eSopenharmony_ci   * @systemapi Hide this for inner system use.
10461847f8eSopenharmony_ci   * @since 11
10561847f8eSopenharmony_ci   */
10661847f8eSopenharmony_ci  function importVCard(context: Context, filePath: string, callback: AsyncCallback<void>): void;
10761847f8eSopenharmony_ci
10861847f8eSopenharmony_ci  /**
10961847f8eSopenharmony_ci   * Export contact data to a vcf file.
11061847f8eSopenharmony_ci   *
11161847f8eSopenharmony_ci   * @permission ohos.permission.WRITE_CONTACTS and ohos.permission.READ_CONTACTS
11261847f8eSopenharmony_ci   * @param { Context } context - Indicates the context of application or capability.
11361847f8eSopenharmony_ci   * @param { dataSharePredicates.DataSharePredicates } predicates - Execute statement.
11461847f8eSopenharmony_ci   * @param { VCardBuilderOptions } options - Encoding and version.
11561847f8eSopenharmony_ci   * @param { AsyncCallback<string> } callback - Represents the address of the generated vcf file.
11661847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
11761847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Non-system applications use system APIs.
11861847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
11961847f8eSopenharmony_ci   *     2. Incorrect parameter types.
12061847f8eSopenharmony_ci   * @throws { BusinessError } 8300001 - Invalid parameter value.
12161847f8eSopenharmony_ci   * @throws { BusinessError } 8300003 - System internal error.
12261847f8eSopenharmony_ci   * @throws { BusinessError } 8300999 - Unknown error.
12361847f8eSopenharmony_ci   * @syscap SystemCapability.Telephony.CoreService
12461847f8eSopenharmony_ci   * @systemapi Hide this for inner system use.
12561847f8eSopenharmony_ci   * @since 11
12661847f8eSopenharmony_ci   */
12761847f8eSopenharmony_ci  function exportVCard(context: Context, predicates: dataSharePredicates.DataSharePredicates,
12861847f8eSopenharmony_ci    options: VCardBuilderOptions, callback: AsyncCallback<string>): void;
12961847f8eSopenharmony_ci
13061847f8eSopenharmony_ci  /**
13161847f8eSopenharmony_ci   * Export contact data to a vcf file.
13261847f8eSopenharmony_ci   *
13361847f8eSopenharmony_ci   * @permission ohos.permission.WRITE_CONTACTS and ohos.permission.READ_CONTACTS
13461847f8eSopenharmony_ci   * @param { Context } context - Indicates the context of application or capability.
13561847f8eSopenharmony_ci   * @param { dataSharePredicates.DataSharePredicates } predicates - Execute statement.
13661847f8eSopenharmony_ci   * @param { VCardBuilderOptions } options - Encoding and version.
13761847f8eSopenharmony_ci   * @returns { Promise<string> } the promise represents the address of the generated vcf file..
13861847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
13961847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Non-system applications use system APIs.
14061847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
14161847f8eSopenharmony_ci   *     2. Incorrect parameter types.
14261847f8eSopenharmony_ci   * @throws { BusinessError } 8300001 - Invalid parameter value.
14361847f8eSopenharmony_ci   * @throws { BusinessError } 8300003 - System internal error.
14461847f8eSopenharmony_ci   * @throws { BusinessError } 8300999 - Unknown error.
14561847f8eSopenharmony_ci   * @syscap SystemCapability.Telephony.CoreService
14661847f8eSopenharmony_ci   * @systemapi Hide this for inner system use.
14761847f8eSopenharmony_ci   * @since 11
14861847f8eSopenharmony_ci   */
14961847f8eSopenharmony_ci  function exportVCard(context: Context, predicates: dataSharePredicates.DataSharePredicates,
15061847f8eSopenharmony_ci    options?: VCardBuilderOptions): Promise<string>;
15161847f8eSopenharmony_ci
15261847f8eSopenharmony_ci  /**
15361847f8eSopenharmony_ci   * Export contact data to a vcf file.
15461847f8eSopenharmony_ci   *
15561847f8eSopenharmony_ci   * @permission ohos.permission.WRITE_CONTACTS and ohos.permission.READ_CONTACTS
15661847f8eSopenharmony_ci   * @param { Context } context - Indicates the context of application or capability.
15761847f8eSopenharmony_ci   * @param { dataSharePredicates.DataSharePredicates } predicates - Execute statement.
15861847f8eSopenharmony_ci   * @param { AsyncCallback<string> } callback - Represents the address of the generated vcf file.
15961847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
16061847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Non-system applications use system APIs.
16161847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
16261847f8eSopenharmony_ci   *     2. Incorrect parameter types.
16361847f8eSopenharmony_ci   * @throws { BusinessError } 8300001 - Invalid parameter value.
16461847f8eSopenharmony_ci   * @throws { BusinessError } 8300003 - System internal error.
16561847f8eSopenharmony_ci   * @throws { BusinessError } 8300999 - Unknown error.
16661847f8eSopenharmony_ci   * @syscap SystemCapability.Telephony.CoreService
16761847f8eSopenharmony_ci   * @systemapi Hide this for inner system use.
16861847f8eSopenharmony_ci   * @since 11
16961847f8eSopenharmony_ci   */
17061847f8eSopenharmony_ci  function exportVCard(context: Context, predicates: dataSharePredicates.DataSharePredicates,
17161847f8eSopenharmony_ci    callback: AsyncCallback<string>): void;
17261847f8eSopenharmony_ci
17361847f8eSopenharmony_ci  /**
17461847f8eSopenharmony_ci   * Indicates the VCard types.
17561847f8eSopenharmony_ci   *
17661847f8eSopenharmony_ci   * @enum { string }
17761847f8eSopenharmony_ci   * @syscap SystemCapability.Telephony.CoreService
17861847f8eSopenharmony_ci   * @systemapi Hide this for inner system use.
17961847f8eSopenharmony_ci   * @since 11
18061847f8eSopenharmony_ci   */
18161847f8eSopenharmony_ci  export enum VCardType {
18261847f8eSopenharmony_ci    /**
18361847f8eSopenharmony_ci     * Indicates the VCard version 2.1.
18461847f8eSopenharmony_ci     *
18561847f8eSopenharmony_ci     * @syscap SystemCapability.Telephony.CoreService
18661847f8eSopenharmony_ci     * @systemapi Hide this for inner system use.
18761847f8eSopenharmony_ci     * @since 11
18861847f8eSopenharmony_ci     */
18961847f8eSopenharmony_ci    VERSION_21 = 0,
19061847f8eSopenharmony_ci
19161847f8eSopenharmony_ci    /**
19261847f8eSopenharmony_ci     * Indicates the VCard version 3.0.
19361847f8eSopenharmony_ci     *
19461847f8eSopenharmony_ci     * @syscap SystemCapability.Telephony.CoreService
19561847f8eSopenharmony_ci     * @systemapi Hide this for inner system use.
19661847f8eSopenharmony_ci     * @since 11
19761847f8eSopenharmony_ci     */
19861847f8eSopenharmony_ci    VERSION_30 = 1,
19961847f8eSopenharmony_ci
20061847f8eSopenharmony_ci    /**
20161847f8eSopenharmony_ci     * Indicates the VCard version 4.0.
20261847f8eSopenharmony_ci     *
20361847f8eSopenharmony_ci     * @syscap SystemCapability.Telephony.CoreService
20461847f8eSopenharmony_ci     * @systemapi Hide this for inner system use.
20561847f8eSopenharmony_ci     * @since 11
20661847f8eSopenharmony_ci     */
20761847f8eSopenharmony_ci    VERSION_40 = 2,
20861847f8eSopenharmony_ci  }
20961847f8eSopenharmony_ci
21061847f8eSopenharmony_ci  /**
21161847f8eSopenharmony_ci   * Indicates the options for VCard export.
21261847f8eSopenharmony_ci   *
21361847f8eSopenharmony_ci   * @interface VCardBuilderOptions
21461847f8eSopenharmony_ci   * @syscap SystemCapability.Telephony.CoreService
21561847f8eSopenharmony_ci   * @systemapi Hide this for inner system use.
21661847f8eSopenharmony_ci   * @since 11
21761847f8eSopenharmony_ci   */
21861847f8eSopenharmony_ci  export interface VCardBuilderOptions {
21961847f8eSopenharmony_ci    /**
22061847f8eSopenharmony_ci     * Indicates the VCard types.
22161847f8eSopenharmony_ci     *
22261847f8eSopenharmony_ci     * @type { ?VCardType }
22361847f8eSopenharmony_ci     * @syscap SystemCapability.Telephony.CoreService
22461847f8eSopenharmony_ci     * @systemapi Hide this for inner system use.
22561847f8eSopenharmony_ci     * @since 11
22661847f8eSopenharmony_ci     */
22761847f8eSopenharmony_ci    cardType?: VCardType;
22861847f8eSopenharmony_ci    /**
22961847f8eSopenharmony_ci     * Indicates the Encoding format.
23061847f8eSopenharmony_ci     *
23161847f8eSopenharmony_ci     * @type { ?string }
23261847f8eSopenharmony_ci     * @syscap SystemCapability.Telephony.CoreService
23361847f8eSopenharmony_ci     * @systemapi Hide this for inner system use.
23461847f8eSopenharmony_ci     * @since 11
23561847f8eSopenharmony_ci     */
23661847f8eSopenharmony_ci    charset?: string;
23761847f8eSopenharmony_ci  }
23861847f8eSopenharmony_ci
23961847f8eSopenharmony_ci}
24061847f8eSopenharmony_ci
24161847f8eSopenharmony_ciexport default vcard;
242