• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 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
76   * @return Returns data of this common event
77   */
78  getData(): Promise<string>;
79
80  /**
81   * Sets the result data of the current ordered common event.
82   *
83   * @since 7
84   * @param data Indicates the custom result data to set. You can set it to any character string.
85   * @param callback Indicate the callback function to receive the common event.
86   * @return -
87   */
88  setData(data: string, callback: AsyncCallback<void>): void;
89
90  /**
91   * Sets the result data of the current ordered common event.
92   *
93   * @since 7
94   * @param data Indicates the custom result data to set. You can set it to any character string.
95   * @return -
96   */
97  setData(data: string): Promise<void>;
98
99  /**
100   * Sets the result of the current ordered common event.
101   *
102   * @since 7
103   * @param code Indicates the custom result code to set. You can set it to any value.
104   * @param data Indicates the custom result data to set. You can set it to any character string.
105   * @param callback Indicate the callback function to receive the common event.
106   * @return -
107   */
108  setCodeAndData(code: number, data: string, callback: AsyncCallback<void>): void;
109
110  /**
111   * Sets the result of the current ordered common event.
112   *
113   * @since 7
114   * @param code Indicates the custom result code to set. You can set it to any value.
115   * @param data Indicates the custom result data to set. You can set it to any character string.
116   * @return -
117   */
118  setCodeAndData(code: number, data: string): Promise<void>;
119
120  /**
121   * Checks whether the current common event is an ordered common event.
122   *
123   * @since 7
124   * @param callback Indicate the callback function to receive the common event.
125   * @return -
126   */
127  isOrderedCommonEvent(callback: AsyncCallback<boolean>): void;
128
129  /**
130   * Checks whether the current common event is an ordered common event.
131   *
132   * @since 7
133   * @return Returns true if this common event is ordered, false otherwise
134   */
135  isOrderedCommonEvent(): Promise<boolean>;
136
137  /**
138   * Checks whether the current common event is a sticky common event.
139   *
140   * @since 7
141   * @param callback Indicate the callback function to receive the common event.
142   * @return -
143   */
144  isStickyCommonEvent(callback: AsyncCallback<boolean>): void;
145
146  /**
147   * Checks whether the current common event is a sticky common event.
148   *
149   * @since 7
150   * @return Returns true if this common event is sticky, false otherwise
151   */
152  isStickyCommonEvent(): Promise<boolean>;
153
154  /**
155   * Aborts the current ordered common event.
156   *
157   * @since 7
158   * @param callback Indicate the callback function to receive the common event.
159   * @return -
160   */
161  abortCommonEvent(callback: AsyncCallback<void>): void;
162
163  /**
164   * Aborts the current ordered common event.
165   *
166   * @since 7
167   * @return -
168   */
169  abortCommonEvent(): Promise<void>;
170
171  /**
172   * Clears the abort state of the current ordered common event
173   *
174   * @since 7
175   * @param callback Indicate the callback function to receive the common event.
176   * @return -
177   */
178  clearAbortCommonEvent(callback: AsyncCallback<void>): void;
179
180  /**
181   * Clears the abort state of the current ordered common event
182   *
183   * @since 7
184   * @return -
185   */
186  clearAbortCommonEvent(): Promise<void>;
187
188  /**
189   * Checks whether the current ordered common event should be aborted.
190   *
191   * @since 7
192   * @param callback Indicate the callback function to receive the common event.
193   * @return -
194   */
195  getAbortCommonEvent(callback: AsyncCallback<boolean>): void;
196
197  /**
198   * Checks whether the current ordered common event should be aborted.
199   *
200   * @since 7
201   * @return Returns true if this common event is aborted, false otherwise
202   */
203  getAbortCommonEvent(): Promise<boolean>;
204
205  /**
206   * get the CommonEventSubscribeInfo of this CommonEventSubscriber.
207   *
208   * @since 7
209   * @param callback Indicate the callback function to receive the common event.
210   * @return -
211   */
212  getSubscribeInfo(callback: AsyncCallback<CommonEventSubscribeInfo>): void;
213
214  /**
215   * get the CommonEventSubscribeInfo of this CommonEventSubscriber.
216   *
217   * @since 7
218   * @return Returns the commonEvent subscribe information
219   */
220  getSubscribeInfo(): Promise<CommonEventSubscribeInfo>;
221}
222