/* * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { AsyncCallback } from './../@ohos.base'; import { CommonEventSubscribeInfo } from './commonEventSubscribeInfo'; /** * the subscriber of common event * * @interface CommonEventSubscriber * @syscap SystemCapability.Notification.CommonEvent * @since 7 */ export interface CommonEventSubscriber { /** * Obtains the result code of the current ordered common event. * * @param { AsyncCallback } callback - Indicate the callback function to receive the common event. * @syscap SystemCapability.Notification.CommonEvent * @since 7 */ getCode(callback: AsyncCallback): void; /** * Obtains the result code of the current ordered common event. * * @returns { Promise } Returns code of this common event * @syscap SystemCapability.Notification.CommonEvent * @since 7 */ getCode(): Promise; /** * Obtains the result code of the current ordered common event. * * @returns { number } Returns code of this common event * @syscap SystemCapability.Notification.CommonEvent * @since 10 */ getCodeSync(): number; /** * Sets the result code of the current ordered common event. * * @param { number } code - Indicates the custom result code to set. You can set it to any value. * @param { AsyncCallback } callback - Indicate the callback function to receive the common event. * @syscap SystemCapability.Notification.CommonEvent * @since 7 */ setCode(code: number, callback: AsyncCallback): void; /** * Sets the result code of the current ordered common event. * * @param { number } code - Indicates the custom result code to set. You can set it to any value. * @returns { Promise } The promise returned by the function. * @syscap SystemCapability.Notification.CommonEvent * @since 7 */ setCode(code: number): Promise; /** * Sets the result code of the current ordered common event. * * @param { number } code - Indicates the custom result code to set. You can set it to any value. * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Notification.CommonEvent * @since 10 */ setCodeSync(code: number): void; /** * Obtains the result data of the current ordered common event. * * @param { AsyncCallback } callback - Indicate the callback function to receive the common event. * @syscap SystemCapability.Notification.CommonEvent * @since 7 */ getData(callback: AsyncCallback): void; /** * Obtains the result data of the current ordered common event. * * @returns { Promise } Returns data of this common event * @syscap SystemCapability.Notification.CommonEvent * @since 7 */ getData(): Promise; /** * Obtains the result data of the current ordered common event. * * @returns { string } Returns data of this common event * @syscap SystemCapability.Notification.CommonEvent * @since 10 */ getDataSync(): string; /** * Sets the result data of the current ordered common event. * * @param { string } data - Indicates the custom result data to set. You can set it to any character string. * @param { AsyncCallback } callback - Indicate the callback function to receive the common event. * @syscap SystemCapability.Notification.CommonEvent * @since 7 */ setData(data: string, callback: AsyncCallback): void; /** * Sets the result data of the current ordered common event. * * @param { string } data - Indicates the custom result data to set. You can set it to any character string. * @returns { Promise } the promise returned by the function. * @syscap SystemCapability.Notification.CommonEvent * @since 7 */ setData(data: string): Promise; /** * Sets the result data of the current ordered common event. * * @param { string } data - Indicates the custom result data to set. You can set it to any character string. * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Notification.CommonEvent * @since 10 */ setDataSync(data: string): void; /** * Sets the result of the current ordered common event. * * @param { number } code - Indicates the custom result code to set. You can set it to any value. * @param { string } data - Indicates the custom result data to set. You can set it to any character string. * @param { AsyncCallback } callback - Indicate the callback function to receive the common event. * @syscap SystemCapability.Notification.CommonEvent * @since 7 */ setCodeAndData(code: number, data: string, callback: AsyncCallback): void; /** * Sets the result of the current ordered common event. * * @param { number } code - Indicates the custom result code to set. You can set it to any value. * @param { string } data - Indicates the custom result data to set. You can set it to any character string. * @returns { Promise } The promise returned by the function. * @syscap SystemCapability.Notification.CommonEvent * @since 7 */ setCodeAndData(code: number, data: string): Promise; /** * Sets the result of the current ordered common event. * * @param { number } code - Indicates the custom result code to set. You can set it to any value. * @param { string } data - Indicates the custom result data to set. You can set it to any character string. * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Notification.CommonEvent * @since 10 */ setCodeAndDataSync(code: number, data: string): void; /** * Checks whether the current common event is an ordered common event. * * @param { AsyncCallback } callback - Indicate the callback function to receive the common event. * @syscap SystemCapability.Notification.CommonEvent * @since 7 */ isOrderedCommonEvent(callback: AsyncCallback): void; /** * Checks whether the current common event is an ordered common event. * * @returns { Promise } Returns true if this common event is ordered, false otherwise * @syscap SystemCapability.Notification.CommonEvent * @since 7 */ isOrderedCommonEvent(): Promise; /** * Checks whether the current common event is an ordered common event. * * @returns { boolean } Returns true if this common event is ordered, false otherwise * @syscap SystemCapability.Notification.CommonEvent * @since 10 */ isOrderedCommonEventSync(): boolean; /** * Checks whether the current common event is a sticky common event. * * @param { AsyncCallback } callback - Indicate the callback function to receive the common event. * @syscap SystemCapability.Notification.CommonEvent * @since 7 */ isStickyCommonEvent(callback: AsyncCallback): void; /** * Checks whether the current common event is a sticky common event. * * @returns { Promise } Returns true if this common event is sticky, false otherwise * @syscap SystemCapability.Notification.CommonEvent * @since 7 */ isStickyCommonEvent(): Promise; /** * Checks whether the current common event is a sticky common event. * * @returns { boolean } Returns true if this common event is sticky, false otherwise * @syscap SystemCapability.Notification.CommonEvent * @since 10 */ isStickyCommonEventSync(): boolean; /** * Abort the current ordered common event. * * @param { AsyncCallback } callback - Indicate the callback function to receive the common event. * @syscap SystemCapability.Notification.CommonEvent * @since 7 */ abortCommonEvent(callback: AsyncCallback): void; /** * Abort the current ordered common event. * * @returns { Promise } The promise returned by the function. * @syscap SystemCapability.Notification.CommonEvent * @since 7 */ abortCommonEvent(): Promise; /** * Abort the current ordered common event. * * @syscap SystemCapability.Notification.CommonEvent * @since 10 */ abortCommonEventSync(): void; /** * Clears the abort state of the current ordered common event * * @param { AsyncCallback } callback - Indicate the callback function to receive the common event. * @syscap SystemCapability.Notification.CommonEvent * @since 7 */ clearAbortCommonEvent(callback: AsyncCallback): void; /** * Clears the abort state of the current ordered common event * * @returns { Promise } The promise returned by the function. * @syscap SystemCapability.Notification.CommonEvent * @since 7 */ clearAbortCommonEvent(): Promise; /** * Clears the abort state of the current ordered common event * * @syscap SystemCapability.Notification.CommonEvent * @since 10 */ clearAbortCommonEventSync(): void; /** * Checks whether the current ordered common event should be aborted. * * @param { AsyncCallback } callback - Indicate the callback function to receive the common event. * @syscap SystemCapability.Notification.CommonEvent * @since 7 */ getAbortCommonEvent(callback: AsyncCallback): void; /** * Checks whether the current ordered common event should be aborted. * * @returns { Promise } Returns true if this common event is aborted, false otherwise * @syscap SystemCapability.Notification.CommonEvent * @since 7 */ getAbortCommonEvent(): Promise; /** * Checks whether the current ordered common event should be aborted. * * @returns { boolean } Returns true if this common event is aborted, false otherwise * @syscap SystemCapability.Notification.CommonEvent * @since 10 */ getAbortCommonEventSync(): boolean; /** * get the CommonEventSubscribeInfo of this CommonEventSubscriber. * * @param { AsyncCallback } callback - Indicate callback function to receive common event. * @syscap SystemCapability.Notification.CommonEvent * @since 7 */ getSubscribeInfo(callback: AsyncCallback): void; /** * get the CommonEventSubscribeInfo of this CommonEventSubscriber. * * @returns { Promise } Returns the commonEvent subscribe information * @syscap SystemCapability.Notification.CommonEvent * @since 7 */ getSubscribeInfo(): Promise; /** * Get the CommonEventSubscribeInfo of this CommonEventSubscriber. * * @returns { CommonEventSubscribeInfo } Returns the commonEvent subscribe information * @syscap SystemCapability.Notification.CommonEvent * @since 10 */ getSubscribeInfoSync(): CommonEventSubscribeInfo; /** * finish the current ordered common event. * * @param { AsyncCallback } callback - Indicate the callback function after ordered common event is finished. * @syscap SystemCapability.Notification.CommonEvent * @since 9 */ finishCommonEvent(callback: AsyncCallback): void; /** * finish the current ordered common event. * * @returns { Promise } The promise returned by the function. * @syscap SystemCapability.Notification.CommonEvent * @since 9 */ finishCommonEvent(): Promise; }