• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-2022 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 */
15import { AsyncCallback } from './../basic';
16import { CommonEventSubscribeInfo } from './commoneventsubscribeinfo';
17
18/**
19 * the subscriber of common event
20 * @name CommonEventSubscriber
21 * @since 7
22 * @syscap SystemCapability.Notification.commonEvent
23 * @permission N/A
24 */
25export interface CommonEventSubscriber {
26  /**
27   * Obtains the result code of the current ordered common event.
28   *
29   * @since 7
30   * @param callback Indicate the callback function to receive the common event.
31   * @return -
32   */
33  getCode(callback: AsyncCallback<number>): void;
34
35  /**
36   * Obtains the result code of the current ordered common event.
37   *
38   * @since 7
39   * @return Returns code of this common event
40   */
41  getCode(): Promise<number>;
42
43  /**
44   * Sets the result code of the current ordered common event.
45   *
46   * @since 7
47   * @param code Indicates the custom result code to set. You can set it to any value.
48   * @param callback Indicate the callback function to receive the common event.
49   * @return -
50   */
51  setCode(code: number, callback: AsyncCallback<void>): void;
52
53  /**
54   * Sets the result code of the current ordered common event.
55   *
56   * @since 7
57   * @param code Indicates the custom result code to set. You can set it to any value.
58   * @return -
59   */
60  setCode(code: number): Promise<void>;
61
62  /**
63   * Obtains the result data of the current ordered common event.
64   *
65   * @since 7
66   * @param callback Indicate the callback function to receive the common event.
67   * @return -
68   */
69  getData(callback: AsyncCallback<string>): void;
70
71  /**
72   * Obtains the result data of the current ordered common event.
73   *
74   * @since 7
75   * @return Returns data of this common event
76   */
77  getData(): Promise<string>;
78
79  /**
80   * Sets the result data of the current ordered common event.
81   *
82   * @since 7
83   * @param data Indicates the custom result data to set. You can set it to any character string.
84   * @param callback Indicate the callback function to receive the common event.
85   * @return -
86   */
87  setData(data: string, callback: AsyncCallback<void>): void;
88
89  /**
90   * Sets the result data of the current ordered common event.
91   *
92   * @since 7
93   * @param data Indicates the custom result data to set. You can set it to any character string.
94   * @return -
95   */
96  setData(data: string): Promise<void>;
97
98  /**
99   * Sets the result of the current ordered common event.
100   *
101   * @since 7
102   * @param code Indicates the custom result code to set. You can set it to any value.
103   * @param data Indicates the custom result data to set. You can set it to any character string.
104   * @param callback Indicate the callback function to receive the common event.
105   * @return -
106   */
107  setCodeAndData(code: number, data: string, callback: AsyncCallback<void>): void;
108
109  /**
110   * Sets the result of the current ordered common event.
111   *
112   * @since 7
113   * @param code Indicates the custom result code to set. You can set it to any value.
114   * @param data Indicates the custom result data to set. You can set it to any character string.
115   * @return -
116   */
117  setCodeAndData(code: number, data: string): Promise<void>;
118
119  /**
120   * Checks whether the current common event is an ordered common event.
121   *
122   * @since 7
123   * @param callback Indicate the callback function to receive the common event.
124   * @return -
125   */
126  isOrderedCommonEvent(callback: AsyncCallback<boolean>): void;
127
128  /**
129   * Checks whether the current common event is an ordered common event.
130   *
131   * @since 7
132   * @return Returns true if this common event is ordered, false otherwise
133   */
134  isOrderedCommonEvent(): Promise<boolean>;
135
136  /**
137   * Checks whether the current common event is a sticky common event.
138   *
139   * @since 7
140   * @param callback Indicate the callback function to receive the common event.
141   * @return -
142   */
143  isStickyCommonEvent(callback: AsyncCallback<boolean>): void;
144
145  /**
146   * Checks whether the current common event is a sticky common event.
147   *
148   * @since 7
149   * @return Returns true if this common event is sticky, false otherwise
150   */
151  isStickyCommonEvent(): Promise<boolean>;
152
153  /**
154   * Aborts the current ordered common event.
155   *
156   * @since 7
157   * @param callback Indicate the callback function to receive the common event.
158   * @return -
159   */
160  abortCommonEvent(callback: AsyncCallback<void>): void;
161
162  /**
163   * Aborts the current ordered common event.
164   *
165   * @since 7
166   * @return -
167   */
168  abortCommonEvent(): Promise<void>;
169
170  /**
171   * Clears the abort state of the current ordered common event
172   *
173   * @since 7
174   * @param callback Indicate the callback function to receive the common event.
175   * @return -
176   */
177  clearAbortCommonEvent(callback: AsyncCallback<void>): void;
178
179  /**
180   * Clears the abort state of the current ordered common event
181   *
182   * @since 7
183   * @return -
184   */
185  clearAbortCommonEvent(): Promise<void>;
186
187  /**
188   * Checks whether the current ordered common event should be aborted.
189   *
190   * @since 7
191   * @param callback Indicate the callback function to receive the common event.
192   * @return -
193   */
194  getAbortCommonEvent(callback: AsyncCallback<boolean>): void;
195
196  /**
197   * Checks whether the current ordered common event should be aborted.
198   *
199   * @since 7
200   * @return Returns true if this common event is aborted, false otherwise
201   */
202  getAbortCommonEvent(): Promise<boolean>;
203
204  /**
205   * get the CommonEventSubscribeInfo of this CommonEventSubscriber.
206   *
207   * @since 7
208   * @param callback Indicate the callback function to receive the common event.
209   * @return -
210   */
211  getSubscribeInfo(callback: AsyncCallback<CommonEventSubscribeInfo>): void;
212
213  /**
214   * get the CommonEventSubscribeInfo of this CommonEventSubscriber.
215   *
216   * @since 7
217   * @return Returns true if this common event is aborted, false otherwise
218   */
219  getSubscribeInfo(): Promise<CommonEventSubscribeInfo>;
220}
221