/* * Copyright (c) 2021-2022 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 './../basic'; import { CommonEventSubscribeInfo } from './commoneventsubscribeinfo'; /** * the subscriber of common event * @name CommonEventSubscriber * @since 7 * @syscap SystemCapability.Notification.commonEvent * @permission N/A */ export interface CommonEventSubscriber { /** * Obtains the result code of the current ordered common event. * * @since 7 * @param callback Indicate the callback function to receive the common event. * @return - */ getCode(callback: AsyncCallback): void; /** * Obtains the result code of the current ordered common event. * * @since 7 * @return Returns code of this common event */ getCode(): Promise; /** * Sets the result code of the current ordered common event. * * @since 7 * @param code Indicates the custom result code to set. You can set it to any value. * @param callback Indicate the callback function to receive the common event. * @return - */ setCode(code: number, callback: AsyncCallback): void; /** * Sets the result code of the current ordered common event. * * @since 7 * @param code Indicates the custom result code to set. You can set it to any value. * @return - */ setCode(code: number): Promise; /** * Obtains the result data of the current ordered common event. * * @since 7 * @param callback Indicate the callback function to receive the common event. * @return - */ getData(callback: AsyncCallback): void; /** * Obtains the result data of the current ordered common event. * * @since 7 * @return Returns data of this common event */ getData(): Promise; /** * Sets the result data of the current ordered common event. * * @since 7 * @param data Indicates the custom result data to set. You can set it to any character string. * @param callback Indicate the callback function to receive the common event. * @return - */ setData(data: string, callback: AsyncCallback): void; /** * Sets the result data of the current ordered common event. * * @since 7 * @param data Indicates the custom result data to set. You can set it to any character string. * @return - */ setData(data: string): Promise; /** * Sets the result of the current ordered common event. * * @since 7 * @param code Indicates the custom result code to set. You can set it to any value. * @param data Indicates the custom result data to set. You can set it to any character string. * @param callback Indicate the callback function to receive the common event. * @return - */ setCodeAndData(code: number, data: string, callback: AsyncCallback): void; /** * Sets the result of the current ordered common event. * * @since 7 * @param code Indicates the custom result code to set. You can set it to any value. * @param data Indicates the custom result data to set. You can set it to any character string. * @return - */ setCodeAndData(code: number, data: string): Promise; /** * Checks whether the current common event is an ordered common event. * * @since 7 * @param callback Indicate the callback function to receive the common event. * @return - */ isOrderedCommonEvent(callback: AsyncCallback): void; /** * Checks whether the current common event is an ordered common event. * * @since 7 * @return Returns true if this common event is ordered, false otherwise */ isOrderedCommonEvent(): Promise; /** * Checks whether the current common event is a sticky common event. * * @since 7 * @param callback Indicate the callback function to receive the common event. * @return - */ isStickyCommonEvent(callback: AsyncCallback): void; /** * Checks whether the current common event is a sticky common event. * * @since 7 * @return Returns true if this common event is sticky, false otherwise */ isStickyCommonEvent(): Promise; /** * Aborts the current ordered common event. * * @since 7 * @param callback Indicate the callback function to receive the common event. * @return - */ abortCommonEvent(callback: AsyncCallback): void; /** * Aborts the current ordered common event. * * @since 7 * @return - */ abortCommonEvent(): Promise; /** * Clears the abort state of the current ordered common event * * @since 7 * @param callback Indicate the callback function to receive the common event. * @return - */ clearAbortCommonEvent(callback: AsyncCallback): void; /** * Clears the abort state of the current ordered common event * * @since 7 * @return - */ clearAbortCommonEvent(): Promise; /** * Checks whether the current ordered common event should be aborted. * * @since 7 * @param callback Indicate the callback function to receive the common event. * @return - */ getAbortCommonEvent(callback: AsyncCallback): void; /** * Checks whether the current ordered common event should be aborted. * * @since 7 * @return Returns true if this common event is aborted, false otherwise */ getAbortCommonEvent(): Promise; /** * get the CommonEventSubscribeInfo of this CommonEventSubscriber. * * @since 7 * @param callback Indicate the callback function to receive the common event. * @return - */ getSubscribeInfo(callback: AsyncCallback): void; /** * get the CommonEventSubscribeInfo of this CommonEventSubscriber. * * @since 7 * @return Returns true if this common event is aborted, false otherwise */ getSubscribeInfo(): Promise; }