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 16/** 17 * @file The subscriber of common event 18 * @kit BasicServicesKit 19 */ 20 21import { AsyncCallback } from './../@ohos.base'; 22import { CommonEventSubscribeInfo } from './commonEventSubscribeInfo'; 23 24/** 25 * the subscriber of common event 26 * 27 * @interface CommonEventSubscriber 28 * @syscap SystemCapability.Notification.CommonEvent 29 * @since 7 30 */ 31/** 32 * the subscriber of common event 33 * 34 * @interface CommonEventSubscriber 35 * @syscap SystemCapability.Notification.CommonEvent 36 * @atomicservice 37 * @since 11 38 */ 39export interface CommonEventSubscriber { 40 /** 41 * Obtains the result code of the current ordered common event. 42 * 43 * @param { AsyncCallback<number> } callback - Indicate the callback function to receive the common event. 44 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 45 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 46 * @syscap SystemCapability.Notification.CommonEvent 47 * @since 7 48 */ 49 /** 50 * Obtains the result code of the current ordered common event. 51 * 52 * @param { AsyncCallback<number> } callback - Indicate the callback function to receive the common event. 53 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 54 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 55 * @syscap SystemCapability.Notification.CommonEvent 56 * @atomicservice 57 * @since 11 58 */ 59 getCode(callback: AsyncCallback<number>): void; 60 61 /** 62 * Obtains the result code of the current ordered common event. 63 * 64 * @returns { Promise<number> } Returns code of this common event 65 * @syscap SystemCapability.Notification.CommonEvent 66 * @since 7 67 */ 68 /** 69 * Obtains the result code of the current ordered common event. 70 * 71 * @returns { Promise<number> } Returns code of this common event 72 * @syscap SystemCapability.Notification.CommonEvent 73 * @atomicservice 74 * @since 11 75 */ 76 getCode(): Promise<number>; 77 78 /** 79 * Obtains the result code of the current ordered common event. 80 * 81 * @returns { number } Returns code of this common event 82 * @syscap SystemCapability.Notification.CommonEvent 83 * @since 10 84 */ 85 /** 86 * Obtains the result code of the current ordered common event. 87 * 88 * @returns { number } Returns code of this common event 89 * @syscap SystemCapability.Notification.CommonEvent 90 * @atomicservice 91 * @since 11 92 */ 93 getCodeSync(): number; 94 95 /** 96 * Sets the result code of the current ordered common event. 97 * 98 * @param { number } code - Indicates the custom result code to set. You can set it to any value. 99 * @param { AsyncCallback<void> } callback - Indicate the callback function to receive the common event. 100 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 101 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 102 * @syscap SystemCapability.Notification.CommonEvent 103 * @since 7 104 */ 105 /** 106 * Sets the result code of the current ordered common event. 107 * 108 * @param { number } code - Indicates the custom result code to set. You can set it to any value. 109 * @param { AsyncCallback<void> } callback - Indicate the callback function to receive the common event. 110 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 111 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 112 * @syscap SystemCapability.Notification.CommonEvent 113 * @atomicservice 114 * @since 11 115 */ 116 setCode(code: number, callback: AsyncCallback<void>): void; 117 118 /** 119 * Sets the result code of the current ordered common event. 120 * 121 * @param { number } code - Indicates the custom result code to set. You can set it to any value. 122 * @returns { Promise<void> } The promise returned by the function. 123 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 124 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 125 * @syscap SystemCapability.Notification.CommonEvent 126 * @since 7 127 */ 128 /** 129 * Sets the result code of the current ordered common event. 130 * 131 * @param { number } code - Indicates the custom result code to set. You can set it to any value. 132 * @returns { Promise<void> } The promise returned by the function. 133 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 134 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 135 * @syscap SystemCapability.Notification.CommonEvent 136 * @atomicservice 137 * @since 11 138 */ 139 setCode(code: number): Promise<void>; 140 141 /** 142 * Sets the result code 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 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 146 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 147 * @syscap SystemCapability.Notification.CommonEvent 148 * @since 10 149 */ 150 /** 151 * Sets the result code of the current ordered common event. 152 * 153 * @param { number } code - Indicates the custom result code to set. You can set it to any value. 154 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 155 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 156 * @syscap SystemCapability.Notification.CommonEvent 157 * @atomicservice 158 * @since 11 159 */ 160 setCodeSync(code: number): void; 161 162 /** 163 * Obtains the result data of the current ordered common event. 164 * 165 * @param { AsyncCallback<string> } callback - Indicate the callback function to receive the common event. 166 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 167 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 168 * @syscap SystemCapability.Notification.CommonEvent 169 * @since 7 170 */ 171 /** 172 * Obtains the result data of the current ordered common event. 173 * 174 * @param { AsyncCallback<string> } callback - Indicate the callback function to receive the common event. 175 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 176 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 177 * @syscap SystemCapability.Notification.CommonEvent 178 * @atomicservice 179 * @since 11 180 */ 181 getData(callback: AsyncCallback<string>): void; 182 183 /** 184 * Obtains the result data of the current ordered common event. 185 * 186 * @returns { Promise<string> } Returns data of this common event 187 * @syscap SystemCapability.Notification.CommonEvent 188 * @since 7 189 */ 190 /** 191 * Obtains the result data of the current ordered common event. 192 * 193 * @returns { Promise<string> } Returns data of this common event 194 * @syscap SystemCapability.Notification.CommonEvent 195 * @atomicservice 196 * @since 11 197 */ 198 getData(): Promise<string>; 199 200 /** 201 * Obtains the result data of the current ordered common event. 202 * 203 * @returns { string } Returns data of this common event 204 * @syscap SystemCapability.Notification.CommonEvent 205 * @since 10 206 */ 207 /** 208 * Obtains the result data of the current ordered common event. 209 * 210 * @returns { string } Returns data of this common event 211 * @syscap SystemCapability.Notification.CommonEvent 212 * @atomicservice 213 * @since 11 214 */ 215 getDataSync(): string; 216 217 /** 218 * Sets the result data of the current ordered common event. 219 * 220 * @param { string } data - Indicates the custom result data to set. You can set it to any character string. 221 * @param { AsyncCallback<void> } callback - Indicate the callback function to receive the common event. 222 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 223 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 224 * @syscap SystemCapability.Notification.CommonEvent 225 * @since 7 226 */ 227 /** 228 * Sets the result data of the current ordered common event. 229 * 230 * @param { string } data - Indicates the custom result data to set. You can set it to any character string. 231 * @param { AsyncCallback<void> } callback - Indicate the callback function to receive the common event. 232 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 233 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 234 * @syscap SystemCapability.Notification.CommonEvent 235 * @atomicservice 236 * @since 11 237 */ 238 setData(data: string, callback: AsyncCallback<void>): void; 239 240 /** 241 * Sets the result data of the current ordered common event. 242 * 243 * @param { string } data - Indicates the custom result data to set. You can set it to any character string. 244 * @returns { Promise<void> } the promise returned by the function. 245 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 246 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 247 * @syscap SystemCapability.Notification.CommonEvent 248 * @since 7 249 */ 250 /** 251 * Sets the result data of the current ordered common event. 252 * 253 * @param { string } data - Indicates the custom result data to set. You can set it to any character string. 254 * @returns { Promise<void> } the promise returned by the function. 255 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 256 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 257 * @syscap SystemCapability.Notification.CommonEvent 258 * @atomicservice 259 * @since 11 260 */ 261 setData(data: string): Promise<void>; 262 263 /** 264 * Sets the result data of the current ordered common event. 265 * 266 * @param { string } data - Indicates the custom result data to set. You can set it to any character string. 267 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 268 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 269 * @syscap SystemCapability.Notification.CommonEvent 270 * @since 10 271 */ 272 /** 273 * Sets the result data of the current ordered common event. 274 * 275 * @param { string } data - Indicates the custom result data to set. You can set it to any character string. 276 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 277 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 278 * @syscap SystemCapability.Notification.CommonEvent 279 * @atomicservice 280 * @since 11 281 */ 282 setDataSync(data: string): void; 283 284 /** 285 * Sets the result of the current ordered common event. 286 * 287 * @param { number } code - Indicates the custom result code to set. You can set it to any value. 288 * @param { string } data - Indicates the custom result data to set. You can set it to any character string. 289 * @param { AsyncCallback<void> } callback - Indicate the callback function to receive the common event. 290 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 291 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 292 * @syscap SystemCapability.Notification.CommonEvent 293 * @since 7 294 */ 295 /** 296 * Sets the result of the current ordered common event. 297 * 298 * @param { number } code - Indicates the custom result code to set. You can set it to any value. 299 * @param { string } data - Indicates the custom result data to set. You can set it to any character string. 300 * @param { AsyncCallback<void> } callback - Indicate the callback function to receive the common event. 301 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 302 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 303 * @syscap SystemCapability.Notification.CommonEvent 304 * @atomicservice 305 * @since 11 306 */ 307 setCodeAndData(code: number, data: string, callback: AsyncCallback<void>): void; 308 309 /** 310 * Sets the result of the current ordered common event. 311 * 312 * @param { number } code - Indicates the custom result code to set. You can set it to any value. 313 * @param { string } data - Indicates the custom result data to set. You can set it to any character string. 314 * @returns { Promise<void> } The promise returned by the function. 315 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 316 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 317 * @syscap SystemCapability.Notification.CommonEvent 318 * @since 7 319 */ 320 /** 321 * Sets the result of the current ordered common event. 322 * 323 * @param { number } code - Indicates the custom result code to set. You can set it to any value. 324 * @param { string } data - Indicates the custom result data to set. You can set it to any character string. 325 * @returns { Promise<void> } The promise returned by the function. 326 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 327 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 328 * @syscap SystemCapability.Notification.CommonEvent 329 * @atomicservice 330 * @since 11 331 */ 332 setCodeAndData(code: number, data: string): Promise<void>; 333 334 /** 335 * Sets the result of the current ordered common event. 336 * 337 * @param { number } code - Indicates the custom result code to set. You can set it to any value. 338 * @param { string } data - Indicates the custom result data to set. You can set it to any character string. 339 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 340 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 341 * @syscap SystemCapability.Notification.CommonEvent 342 * @since 10 343 */ 344 /** 345 * Sets the result of the current ordered common event. 346 * 347 * @param { number } code - Indicates the custom result code to set. You can set it to any value. 348 * @param { string } data - Indicates the custom result data to set. You can set it to any character string. 349 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 350 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 351 * @syscap SystemCapability.Notification.CommonEvent 352 * @atomicservice 353 * @since 11 354 */ 355 setCodeAndDataSync(code: number, data: string): void; 356 357 /** 358 * Checks whether the current common event is an ordered common event. 359 * 360 * @param { AsyncCallback<boolean> } callback - Indicate the callback function to receive the common event. 361 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 362 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 363 * @syscap SystemCapability.Notification.CommonEvent 364 * @since 7 365 */ 366 isOrderedCommonEvent(callback: AsyncCallback<boolean>): void; 367 368 /** 369 * Checks whether the current common event is an ordered common event. 370 * 371 * @returns { Promise<boolean> } Returns true if this common event is ordered, false otherwise 372 * @syscap SystemCapability.Notification.CommonEvent 373 * @since 7 374 */ 375 isOrderedCommonEvent(): Promise<boolean>; 376 377 /** 378 * Checks whether the current common event is an ordered common event. 379 * 380 * @returns { boolean } Returns true if this common event is ordered, false otherwise 381 * @syscap SystemCapability.Notification.CommonEvent 382 * @since 10 383 */ 384 isOrderedCommonEventSync(): boolean; 385 386 /** 387 * Checks whether the current common event is a sticky common event. 388 * 389 * @param { AsyncCallback<boolean> } callback - Indicate the callback function to receive the common event. 390 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 391 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 392 * @syscap SystemCapability.Notification.CommonEvent 393 * @since 7 394 */ 395 isStickyCommonEvent(callback: AsyncCallback<boolean>): void; 396 397 /** 398 * Checks whether the current common event is a sticky common event. 399 * 400 * @returns { Promise<boolean> } Returns true if this common event is sticky, false otherwise 401 * @syscap SystemCapability.Notification.CommonEvent 402 * @since 7 403 */ 404 isStickyCommonEvent(): Promise<boolean>; 405 406 /** 407 * Checks whether the current common event is a sticky common event. 408 * 409 * @returns { boolean } Returns true if this common event is sticky, false otherwise 410 * @syscap SystemCapability.Notification.CommonEvent 411 * @since 10 412 */ 413 isStickyCommonEventSync(): boolean; 414 415 /** 416 * Abort the current ordered common event. 417 * 418 * @param { AsyncCallback<void> } callback - Indicate the callback function to receive the common event. 419 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 420 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 421 * @syscap SystemCapability.Notification.CommonEvent 422 * @since 7 423 */ 424 abortCommonEvent(callback: AsyncCallback<void>): void; 425 426 /** 427 * Abort the current ordered common event. 428 * 429 * @returns { Promise<void> } The promise returned by the function. 430 * @syscap SystemCapability.Notification.CommonEvent 431 * @since 7 432 */ 433 abortCommonEvent(): Promise<void>; 434 435 /** 436 * Abort the current ordered common event. 437 * 438 * @syscap SystemCapability.Notification.CommonEvent 439 * @since 10 440 */ 441 abortCommonEventSync(): void; 442 443 /** 444 * Clears the abort state of the current ordered common event 445 * 446 * @param { AsyncCallback<void> } callback - Indicate the callback function to receive the common event. 447 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 448 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 449 * @syscap SystemCapability.Notification.CommonEvent 450 * @since 7 451 */ 452 clearAbortCommonEvent(callback: AsyncCallback<void>): void; 453 454 /** 455 * Clears the abort state of the current ordered common event 456 * 457 * @returns { Promise<void> } The promise returned by the function. 458 * @syscap SystemCapability.Notification.CommonEvent 459 * @since 7 460 */ 461 clearAbortCommonEvent(): Promise<void>; 462 463 /** 464 * Clears the abort state of the current ordered common event 465 * 466 * @syscap SystemCapability.Notification.CommonEvent 467 * @since 10 468 */ 469 clearAbortCommonEventSync(): void; 470 471 /** 472 * Checks whether the current ordered common event should be aborted. 473 * 474 * @param { AsyncCallback<boolean> } callback - Indicate the callback function to receive the common event. 475 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 476 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 477 * @syscap SystemCapability.Notification.CommonEvent 478 * @since 7 479 */ 480 getAbortCommonEvent(callback: AsyncCallback<boolean>): void; 481 482 /** 483 * Checks whether the current ordered common event should be aborted. 484 * 485 * @returns { Promise<boolean> } Returns true if this common event is aborted, false otherwise 486 * @syscap SystemCapability.Notification.CommonEvent 487 * @since 7 488 */ 489 getAbortCommonEvent(): Promise<boolean>; 490 491 /** 492 * Checks whether the current ordered common event should be aborted. 493 * 494 * @returns { boolean } Returns true if this common event is aborted, false otherwise 495 * @syscap SystemCapability.Notification.CommonEvent 496 * @since 10 497 */ 498 getAbortCommonEventSync(): boolean; 499 500 /** 501 * get the CommonEventSubscribeInfo of this CommonEventSubscriber. 502 * 503 * @param { AsyncCallback<CommonEventSubscribeInfo> } callback - Indicate callback function to receive common event. 504 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 505 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 506 * @syscap SystemCapability.Notification.CommonEvent 507 * @since 7 508 */ 509 /** 510 * get the CommonEventSubscribeInfo of this CommonEventSubscriber. 511 * 512 * @param { AsyncCallback<CommonEventSubscribeInfo> } callback - Indicate callback function to receive common event. 513 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 514 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 515 * @syscap SystemCapability.Notification.CommonEvent 516 * @crossplatform 517 * @atomicservice 518 * @since 11 519 */ 520 getSubscribeInfo(callback: AsyncCallback<CommonEventSubscribeInfo>): void; 521 522 /** 523 * get the CommonEventSubscribeInfo of this CommonEventSubscriber. 524 * 525 * @returns { Promise<CommonEventSubscribeInfo> } Returns the commonEvent subscribe information 526 * @syscap SystemCapability.Notification.CommonEvent 527 * @since 7 528 */ 529 /** 530 * get the CommonEventSubscribeInfo of this CommonEventSubscriber. 531 * 532 * @returns { Promise<CommonEventSubscribeInfo> } Returns the commonEvent subscribe information 533 * @syscap SystemCapability.Notification.CommonEvent 534 * @crossplatform 535 * @atomicservice 536 * @since 11 537 */ 538 getSubscribeInfo(): Promise<CommonEventSubscribeInfo>; 539 540 /** 541 * Get the CommonEventSubscribeInfo of this CommonEventSubscriber. 542 * 543 * @returns { CommonEventSubscribeInfo } Returns the commonEvent subscribe information 544 * @syscap SystemCapability.Notification.CommonEvent 545 * @since 10 546 */ 547 /** 548 * Get the CommonEventSubscribeInfo of this CommonEventSubscriber. 549 * 550 * @returns { CommonEventSubscribeInfo } Returns the commonEvent subscribe information 551 * @syscap SystemCapability.Notification.CommonEvent 552 * @atomicservice 553 * @since 11 554 */ 555 getSubscribeInfoSync(): CommonEventSubscribeInfo; 556 557 /** 558 * finish the current ordered common event. 559 * 560 * @param { AsyncCallback<void> } callback - Indicate the callback function after ordered common event is finished. 561 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 562 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 563 * @syscap SystemCapability.Notification.CommonEvent 564 * @since 9 565 */ 566 finishCommonEvent(callback: AsyncCallback<void>): void; 567 568 /** 569 * finish the current ordered common event. 570 * 571 * @returns { Promise<void> } The promise returned by the function. 572 * @syscap SystemCapability.Notification.CommonEvent 573 * @since 9 574 */ 575 finishCommonEvent(): Promise<void>; 576} 577