• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-2023 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 */
15
16import { AsyncCallback } from './../@ohos.base';
17import { CommonEventSubscribeInfo } from './commonEventSubscribeInfo';
18
19/**
20 * the subscriber of common event
21 *
22 * @interface CommonEventSubscriber
23 * @syscap SystemCapability.Notification.CommonEvent
24 * @since 7
25 */
26export interface CommonEventSubscriber {
27  /**
28   * Obtains the result code of the current ordered common event.
29   *
30   * @param { AsyncCallback<number> } callback - Indicate the callback function to receive the common event.
31   * @syscap SystemCapability.Notification.CommonEvent
32   * @since 7
33   */
34  getCode(callback: AsyncCallback<number>): void;
35
36  /**
37   * Obtains the result code of the current ordered common event.
38   *
39   * @returns { Promise<number> } Returns code of this common event
40   * @syscap SystemCapability.Notification.CommonEvent
41   * @since 7
42   */
43  getCode(): Promise<number>;
44
45  /**
46   * Obtains the result code of the current ordered common event.
47   *
48   * @returns { number } Returns code of this common event
49   * @syscap SystemCapability.Notification.CommonEvent
50   * @since 10
51   */
52  getCodeSync(): number;
53
54  /**
55   * Sets the result code of the current ordered common event.
56   *
57   * @param { number } code - Indicates the custom result code to set. You can set it to any value.
58   * @param { AsyncCallback<void> } callback - Indicate the callback function to receive the common event.
59   * @syscap SystemCapability.Notification.CommonEvent
60   * @since 7
61   */
62  setCode(code: number, callback: AsyncCallback<void>): void;
63
64  /**
65   * Sets the result code of the current ordered common event.
66   *
67   * @param { number } code - Indicates the custom result code to set. You can set it to any value.
68   * @returns { Promise<void> } The promise returned by the function.
69   * @syscap SystemCapability.Notification.CommonEvent
70   * @since 7
71   */
72  setCode(code: number): Promise<void>;
73
74  /**
75   * Sets the result code of the current ordered common event.
76   *
77   * @param { number } code - Indicates the custom result code to set. You can set it to any value.
78   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
79   * @syscap SystemCapability.Notification.CommonEvent
80   * @since 10
81   */
82  setCodeSync(code: number): void;
83
84  /**
85   * Obtains the result data of the current ordered common event.
86   *
87   * @param { AsyncCallback<string> } callback - Indicate the callback function to receive the common event.
88   * @syscap SystemCapability.Notification.CommonEvent
89   * @since 7
90   */
91  getData(callback: AsyncCallback<string>): void;
92
93  /**
94   * Obtains the result data of the current ordered common event.
95   *
96   * @returns { Promise<string> } Returns data of this common event
97   * @syscap SystemCapability.Notification.CommonEvent
98   * @since 7
99   */
100  getData(): Promise<string>;
101
102  /**
103   * Obtains the result data of the current ordered common event.
104   *
105   * @returns { string } Returns data of this common event
106   * @syscap SystemCapability.Notification.CommonEvent
107   * @since 10
108   */
109  getDataSync(): string;
110
111  /**
112   * Sets the result data of the current ordered common event.
113   *
114   * @param { string } data - Indicates the custom result data to set. You can set it to any character string.
115   * @param { AsyncCallback<void> } callback - Indicate the callback function to receive the common event.
116   * @syscap SystemCapability.Notification.CommonEvent
117   * @since 7
118   */
119  setData(data: string, callback: AsyncCallback<void>): void;
120
121  /**
122   * Sets the result data of the current ordered common event.
123   *
124   * @param { string } data - Indicates the custom result data to set. You can set it to any character string.
125   * @returns { Promise<void> } the promise returned by the function.
126   * @syscap SystemCapability.Notification.CommonEvent
127   * @since 7
128   */
129  setData(data: string): Promise<void>;
130
131  /**
132   * Sets the result data of the current ordered common event.
133   *
134   * @param { string } data - Indicates the custom result data to set. You can set it to any character string.
135   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
136   * @syscap SystemCapability.Notification.CommonEvent
137   * @since 10
138   */
139  setDataSync(data: string): void;
140
141  /**
142   * Sets the result of the current ordered common event.
143   *
144   * @param { number } code - Indicates the custom result code to set. You can set it to any value.
145   * @param { string } data - Indicates the custom result data to set. You can set it to any character string.
146   * @param { AsyncCallback<void> } callback - Indicate the callback function to receive the common event.
147   * @syscap SystemCapability.Notification.CommonEvent
148   * @since 7
149   */
150  setCodeAndData(code: number, data: string, callback: AsyncCallback<void>): void;
151
152  /**
153   * Sets the result of the current ordered common event.
154   *
155   * @param { number } code - Indicates the custom result code to set. You can set it to any value.
156   * @param { string } data - Indicates the custom result data to set. You can set it to any character string.
157   * @returns { Promise<void> } The promise returned by the function.
158   * @syscap SystemCapability.Notification.CommonEvent
159   * @since 7
160   */
161  setCodeAndData(code: number, data: string): Promise<void>;
162
163  /**
164   * Sets the result of the current ordered common event.
165   *
166   * @param { number } code - Indicates the custom result code to set. You can set it to any value.
167   * @param { string } data - Indicates the custom result data to set. You can set it to any character string.
168   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
169   * @syscap SystemCapability.Notification.CommonEvent
170   * @since 10
171   */
172  setCodeAndDataSync(code: number, data: string): void;
173
174  /**
175   * Checks whether the current common event is an ordered common event.
176   *
177   * @param { AsyncCallback<boolean> } callback - Indicate the callback function to receive the common event.
178   * @syscap SystemCapability.Notification.CommonEvent
179   * @since 7
180   */
181  isOrderedCommonEvent(callback: AsyncCallback<boolean>): void;
182
183  /**
184   * Checks whether the current common event is an ordered common event.
185   *
186   * @returns { Promise<boolean> } Returns true if this common event is ordered, false otherwise
187   * @syscap SystemCapability.Notification.CommonEvent
188   * @since 7
189   */
190  isOrderedCommonEvent(): Promise<boolean>;
191
192  /**
193   * Checks whether the current common event is an ordered common event.
194   *
195   * @returns { boolean } Returns true if this common event is ordered, false otherwise
196   * @syscap SystemCapability.Notification.CommonEvent
197   * @since 10
198   */
199  isOrderedCommonEventSync(): boolean;
200
201  /**
202   * Checks whether the current common event is a sticky common event.
203   *
204   * @param { AsyncCallback<boolean> } callback - Indicate the callback function to receive the common event.
205   * @syscap SystemCapability.Notification.CommonEvent
206   * @since 7
207   */
208  isStickyCommonEvent(callback: AsyncCallback<boolean>): void;
209
210  /**
211   * Checks whether the current common event is a sticky common event.
212   *
213   * @returns { Promise<boolean> } Returns true if this common event is sticky, false otherwise
214   * @syscap SystemCapability.Notification.CommonEvent
215   * @since 7
216   */
217  isStickyCommonEvent(): Promise<boolean>;
218
219  /**
220   * Checks whether the current common event is a sticky common event.
221   *
222   * @returns { boolean } Returns true if this common event is sticky, false otherwise
223   * @syscap SystemCapability.Notification.CommonEvent
224   * @since 10
225   */
226  isStickyCommonEventSync(): boolean;
227
228  /**
229   * Abort the current ordered common event.
230   *
231   * @param { AsyncCallback<void> } callback - Indicate the callback function to receive the common event.
232   * @syscap SystemCapability.Notification.CommonEvent
233   * @since 7
234   */
235  abortCommonEvent(callback: AsyncCallback<void>): void;
236
237  /**
238   * Abort the current ordered common event.
239   *
240   * @returns { Promise<void> } The promise returned by the function.
241   * @syscap SystemCapability.Notification.CommonEvent
242   * @since 7
243   */
244  abortCommonEvent(): Promise<void>;
245
246  /**
247   * Abort the current ordered common event.
248   *
249   * @syscap SystemCapability.Notification.CommonEvent
250   * @since 10
251   */
252  abortCommonEventSync(): void;
253
254  /**
255   * Clears the abort state of the current ordered common event
256   *
257   * @param { AsyncCallback<void> } callback - Indicate the callback function to receive the common event.
258   * @syscap SystemCapability.Notification.CommonEvent
259   * @since 7
260   */
261  clearAbortCommonEvent(callback: AsyncCallback<void>): void;
262
263  /**
264   * Clears the abort state of the current ordered common event
265   *
266   * @returns { Promise<void> } The promise returned by the function.
267   * @syscap SystemCapability.Notification.CommonEvent
268   * @since 7
269   */
270  clearAbortCommonEvent(): Promise<void>;
271
272  /**
273   * Clears the abort state of the current ordered common event
274   *
275   * @syscap SystemCapability.Notification.CommonEvent
276   * @since 10
277   */
278  clearAbortCommonEventSync(): void;
279
280  /**
281   * Checks whether the current ordered common event should be aborted.
282   *
283   * @param { AsyncCallback<boolean> } callback - Indicate the callback function to receive the common event.
284   * @syscap SystemCapability.Notification.CommonEvent
285   * @since 7
286   */
287  getAbortCommonEvent(callback: AsyncCallback<boolean>): void;
288
289  /**
290   * Checks whether the current ordered common event should be aborted.
291   *
292   * @returns { Promise<boolean> } Returns true if this common event is aborted, false otherwise
293   * @syscap SystemCapability.Notification.CommonEvent
294   * @since 7
295   */
296  getAbortCommonEvent(): Promise<boolean>;
297
298  /**
299   * Checks whether the current ordered common event should be aborted.
300   *
301   * @returns { boolean } Returns true if this common event is aborted, false otherwise
302   * @syscap SystemCapability.Notification.CommonEvent
303   * @since 10
304   */
305  getAbortCommonEventSync(): boolean;
306
307  /**
308   * get the CommonEventSubscribeInfo of this CommonEventSubscriber.
309   *
310   * @param { AsyncCallback<CommonEventSubscribeInfo> } callback - Indicate callback function to receive common event.
311   * @syscap SystemCapability.Notification.CommonEvent
312   * @since 7
313   */
314  getSubscribeInfo(callback: AsyncCallback<CommonEventSubscribeInfo>): void;
315
316  /**
317   * get the CommonEventSubscribeInfo of this CommonEventSubscriber.
318   *
319   * @returns { Promise<CommonEventSubscribeInfo> } Returns the commonEvent subscribe information
320   * @syscap SystemCapability.Notification.CommonEvent
321   * @since 7
322   */
323  getSubscribeInfo(): Promise<CommonEventSubscribeInfo>;
324
325  /**
326   * Get the CommonEventSubscribeInfo of this CommonEventSubscriber.
327   *
328   * @returns { CommonEventSubscribeInfo } Returns the commonEvent subscribe information
329   * @syscap SystemCapability.Notification.CommonEvent
330   * @since 10
331   */
332  getSubscribeInfoSync(): CommonEventSubscribeInfo;
333
334  /**
335   * finish the current ordered common event.
336   *
337   * @param { AsyncCallback<void> } callback - Indicate the callback function after ordered common event is finished.
338   * @syscap SystemCapability.Notification.CommonEvent
339   * @since 9
340   */
341  finishCommonEvent(callback: AsyncCallback<void>): void;
342
343  /**
344   * finish the current ordered common event.
345   *
346   * @returns { Promise<void> } The promise returned by the function.
347   * @syscap SystemCapability.Notification.CommonEvent
348   * @since 9
349   */
350  finishCommonEvent(): Promise<void>;
351}
352