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 */ 15 #ifndef BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_FRAMEWORKS_JS_NAPI_INCLUDE_COMMON_H 16 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_FRAMEWORKS_JS_NAPI_INCLUDE_COMMON_H 17 18 #include "ans_log_wrapper.h" 19 #include "napi/native_api.h" 20 #include "napi/native_node_api.h" 21 #include "notification_helper.h" 22 23 namespace OHOS { 24 namespace NotificationNapi { 25 using namespace OHOS::Notification; 26 27 constexpr int32_t STR_MAX_SIZE = 200; 28 constexpr int32_t LONG_STR_MAX_SIZE = 1024; 29 constexpr int8_t NO_ERROR = 0; 30 constexpr int8_t ERROR = -1; 31 constexpr uint8_t PARAM0 = 0; 32 constexpr uint8_t PARAM1 = 1; 33 constexpr uint8_t PARAM2 = 2; 34 constexpr uint8_t PARAM3 = 3; 35 36 enum class ContentType { 37 NOTIFICATION_CONTENT_BASIC_TEXT, 38 NOTIFICATION_CONTENT_LONG_TEXT, 39 NOTIFICATION_CONTENT_PICTURE, 40 NOTIFICATION_CONTENT_CONVERSATION, 41 NOTIFICATION_CONTENT_MULTILINE 42 }; 43 44 enum class SlotType { 45 UNKNOWN_TYPE = 0, 46 SOCIAL_COMMUNICATION = 1, 47 SERVICE_INFORMATION = 2, 48 CONTENT_INFORMATION = 3, 49 OTHER_TYPES = 0xFFFF, 50 }; 51 52 enum class SlotLevel { 53 LEVEL_NONE = 0, 54 LEVEL_MIN = 1, 55 LEVEL_LOW = 2, 56 LEVEL_DEFAULT = 3, 57 LEVEL_HIGH = 4, 58 }; 59 60 enum class RemoveReason { 61 CLICK_REASON_REMOVE = 1, 62 CANCEL_REASON_REMOVE = 2, 63 CANCEL_ALL_REASON_REMOVE = 3, 64 ERROR_REASON_REMOVE = 4, 65 PACKAGE_CHANGED_REASON_REMOVE = 5, 66 USER_STOPPED_REASON_REMOVE = 6, 67 PACKAGE_BANNED_REASON_REMOVE = 7, 68 APP_CANCEL_REASON_REMOVE = 8, 69 APP_CANCEL_ALL_REASON_REMOVE = 9, 70 APP_CANCEL_REASON_OTHER = 10, 71 }; 72 73 enum class SemanticActionButton { 74 NONE_ACTION_BUTTON, 75 REPLY_ACTION_BUTTON, 76 READ_ACTION_BUTTON, 77 UNREAD_ACTION_BUTTON, 78 DELETE_ACTION_BUTTON, 79 ARCHIVE_ACTION_BUTTON, 80 MUTE_ACTION_BUTTON, 81 UNMUTE_ACTION_BUTTON, 82 THUMBS_UP_ACTION_BUTTON, 83 THUMBS_DOWN_ACTION_BUTTON, 84 CALL_ACTION_BUTTON 85 }; 86 87 enum class InputsSource { 88 FREE_FORM_INPUT, 89 OPTION 90 }; 91 92 enum class DisturbMode { 93 ALLOW_UNKNOWN, 94 ALLOW_ALL, 95 ALLOW_PRIORITY, 96 ALLOW_NONE, 97 ALLOW_ALARMS 98 }; 99 100 enum class InputEditType { 101 EDIT_AUTO, 102 EDIT_DISABLED, 103 EDIT_ENABLED 104 }; 105 106 enum class DoNotDisturbType { 107 TYPE_NONE, TYPE_ONCE, 108 TYPE_DAILY, TYPE_CLEARLY 109 }; 110 111 enum class SourceType { 112 TYPE_NORMAL = 0x00000000, 113 TYPE_CONTINUOUS = 0x00000001, 114 TYPE_TIMER = 0x00000002 115 }; 116 117 enum class DeviceRemindType { 118 IDLE_DONOT_REMIND, 119 IDLE_REMIND, 120 ACTIVE_DONOT_REMIND, 121 ACTIVE_REMIND 122 }; 123 124 enum class NotificationFlagStatus { 125 TYPE_NONE, 126 TYPE_OPEN, 127 TYPE_CLOSE 128 }; 129 130 struct NotificationSubscribeInfo { 131 std::vector<std::string> bundleNames; 132 int32_t userId = 0; 133 bool hasSubscribeInfo = false; 134 }; 135 136 struct NotificationKey { 137 int32_t id {}; 138 std::string label {}; 139 }; 140 141 struct CallbackPromiseInfo { 142 napi_ref callback = nullptr; 143 napi_deferred deferred = nullptr; 144 bool isCallback = false; 145 int32_t errorCode = 0; 146 }; 147 148 class Common { 149 Common(); 150 151 ~Common(); 152 153 public: 154 /** 155 * @brief Gets a napi value that is used to represent specified bool value 156 * 157 * @param env Indicates the environment that the API is invoked under 158 * @param isValue Indicates a bool value 159 * @return Returns a napi value that is used to represent specified bool value 160 */ 161 static napi_value NapiGetBoolean(napi_env env, const bool &isValue); 162 163 /** 164 * @brief Gets the napi value that is used to represent the null object 165 * 166 * @param env Indicates the environment that the API is invoked under 167 * @return Returns the napi value that is used to represent the null object 168 */ 169 static napi_value NapiGetNull(napi_env env); 170 171 /** 172 * @brief Gets the napi value that is used to represent the undefined object 173 * 174 * @param env Indicates the environment that the API is invoked under 175 * @return Returns the napi value that is used to represent the undefined object 176 */ 177 static napi_value NapiGetUndefined(napi_env env); 178 179 /** 180 * @brief Gets a napi value with specified error code for callback 181 * 182 * @param env Indicates the environment that the API is invoked under 183 * @param errCode Indicates specified err code 184 * @return Returns a napi value with specified error code for callback 185 */ 186 static napi_value GetCallbackErrorValue(napi_env env, int32_t errCode); 187 188 /** 189 * @brief Pads the CallbackPromiseInfo struct 190 * 191 * @param env Indicates the environment that the API is invoked under 192 * @param callback Indicates a napi_ref for callback 193 * @param info Indicates the CallbackPromiseInfo struct to be padded 194 * @param promise Indicates the promise to be created when the callback is null 195 */ 196 static void PaddingCallbackPromiseInfo( 197 const napi_env &env, const napi_ref &callback, CallbackPromiseInfo &info, napi_value &promise); 198 199 /** 200 * @brief Gets the returned result by the CallbackPromiseInfo struct 201 * 202 * @param env Indicates the environment that the API is invoked under 203 * @param info Indicates the CallbackPromiseInfo struct 204 * @param result Indicates the returned result 205 */ 206 static void ReturnCallbackPromise(const napi_env &env, const CallbackPromiseInfo &info, const napi_value &result); 207 208 /** 209 * @brief Calls the callback with the result and error code 210 * 211 * @param env Indicates the environment that the API is invoked under 212 * @param callbackIn Indicates the callback to be called 213 * @param errCode Indicates the error code returned by the callback 214 * @param result Indicates the result returned by the callback 215 */ 216 static void SetCallback(const napi_env &env, 217 const napi_ref &callbackIn, const int32_t &errorCode, const napi_value &result, bool newType); 218 219 /** 220 * @brief Calls the callback with the result 221 * 222 * @param env Indicates the environment that the API is invoked under 223 * @param callbackIn Indicates the callback to be called 224 * @param result Indicates the result returned by the callback 225 */ 226 static void SetCallback( 227 const napi_env &env, const napi_ref &callbackIn, const napi_value &result); 228 229 /** 230 * @brief Processes the promise with the result and error code 231 * 232 * @param env Indicates the environment that the API is invoked under 233 * @param deferred Indicates the deferred object whose associated promise to resolve 234 * @param errorCode Indicates the error code returned by the callback 235 * @param result Indicates the result returned by the callback 236 */ 237 static void SetPromise(const napi_env &env, 238 const napi_deferred &deferred, const int32_t &errorCode, const napi_value &result, bool newType); 239 240 /** 241 * @brief Gets the returned result by the callback when an error occurs 242 * 243 * @param env Indicates the environment that the API is invoked under 244 * @param callback Indicates a napi_ref for callback 245 * @return Returns the null object 246 */ 247 static napi_value JSParaError(const napi_env &env, const napi_ref &callback); 248 249 /** 250 * @brief Parses a single parameter for callback 251 * 252 * @param env Indicates the environment that the API is invoked under 253 * @param info Indicates the callback info passed into the callback function 254 * @param callback Indicates the napi_ref for the callback parameter 255 * @return Returns the null object if success, returns the null value otherwise 256 */ 257 static napi_value ParseParaOnlyCallback(const napi_env &env, const napi_callback_info &info, napi_ref &callback); 258 259 /** 260 * @brief Sets a js object by specified Notification object 261 * 262 * @param env Indicates the environment that the API is invoked under 263 * @param notification Indicates a Notification object to be converted 264 * @param result Indicates a js object to be set 265 * @return Returns the null object if success, returns the null value otherwise 266 */ 267 static napi_value SetNotification( 268 const napi_env &env, const OHOS::Notification::Notification *notification, napi_value &result); 269 270 /** 271 * @brief Sets a js object by specified NotificationRequest object 272 * 273 * @param env Indicates the environment that the API is invoked under 274 * @param request Indicates a NotificationRequest object to be converted 275 * @param result Indicates a js object to be set 276 * @return Returns the null object if success, returns the null value otherwise 277 */ 278 static napi_value SetNotificationRequest( 279 const napi_env &env, const OHOS::Notification::NotificationRequest *request, napi_value &result); 280 281 /** 282 * @brief Sets a js object by the string obejcts of specified NotificationRequest object 283 * 284 * @param env Indicates the environment that the API is invoked under 285 * @param request Indicates a NotificationRequest object to be converted 286 * @param result Indicates a js object to be set 287 * @return Returns the null object if success, returns the null value otherwise 288 */ 289 static napi_value SetNotificationRequestByString( 290 const napi_env &env, const OHOS::Notification::NotificationRequest *request, napi_value &result); 291 292 /** 293 * @brief Sets a js object by the number obejcts of specified NotificationRequest object 294 * 295 * @param env Indicates the environment that the API is invoked under 296 * @param request Indicates a NotificationRequest object to be converted 297 * @param result Indicates a js object to be set 298 * @return Returns the null object if success, returns the null value otherwise 299 */ 300 static napi_value SetNotificationRequestByNumber( 301 const napi_env &env, const OHOS::Notification::NotificationRequest *request, napi_value &result); 302 303 /** 304 * @brief Sets a js object by the bool obejcts of specified NotificationRequest object 305 * 306 * @param env Indicates the environment that the API is invoked under 307 * @param request Indicates a NotificationRequest object to be converted 308 * @param result Indicates a js object to be set 309 * @return Returns the null object if success, returns the null value otherwise 310 */ 311 static napi_value SetNotificationRequestByBool( 312 const napi_env &env, const OHOS::Notification::NotificationRequest *request, napi_value &result); 313 314 /** 315 * @brief Sets a js object by the WantAgent obejct of specified NotificationRequest object 316 * 317 * @param env Indicates the environment that the API is invoked under 318 * @param request Indicates a NotificationRequest object to be converted 319 * @param result Indicates a js object to be set 320 * @return Returns the null object if success, returns the null value otherwise 321 */ 322 static napi_value SetNotificationRequestByWantAgent( 323 const napi_env &env, const OHOS::Notification::NotificationRequest *request, napi_value &result); 324 325 /** 326 * @brief Sets a js object by the PixelMap obejct of specified NotificationRequest object 327 * 328 * @param env Indicates the environment that the API is invoked under 329 * @param request Indicates a NotificationRequest object to be converted 330 * @param result Indicates a js object to be set 331 * @return Returns the null object if success, returns the null value otherwise 332 */ 333 static napi_value SetNotificationRequestByPixelMap( 334 const napi_env &env, const OHOS::Notification::NotificationRequest *request, napi_value &result); 335 336 /** 337 * @brief Sets a js object by the custom obejcts of specified NotificationRequest object 338 * 339 * @param env Indicates the environment that the API is invoked under 340 * @param request Indicates a NotificationRequest object to be converted 341 * @param result Indicates a js object to be set 342 * @return Returns the null object if success, returns the null value otherwise 343 */ 344 static napi_value SetNotificationRequestByCustom( 345 const napi_env &env, const OHOS::Notification::NotificationRequest *request, napi_value &result); 346 347 /** 348 * @brief Sets a js object by the Distributed Options object of specified Notification object 349 * 350 * @param env Indicates the environment that the API is invoked under 351 * @param notification Indicates a Notification object to be converted 352 * @param result Indicates a js object to be set 353 * @return Returns the null object if success, returns the null value otherwise 354 */ 355 static napi_value SetNotificationByDistributedOptions( 356 const napi_env &env, const OHOS::Notification::Notification *notification, napi_value &result); 357 358 /** 359 * @brief Sets a js object by specified NotificationSortingMap object 360 * 361 * @param env Indicates the environment that the API is invoked under 362 * @param sortingMap Indicates a NotificationSortingMap object to be converted 363 * @param result Indicates a js object to be set 364 * @return Returns the null object if success, returns the null value otherwise 365 */ 366 static napi_value SetNotificationSortingMap( 367 const napi_env &env, const std::shared_ptr<NotificationSortingMap> &sortingMap, napi_value &result); 368 369 /** 370 * @brief Sets a js object by specified NotificationSorting object 371 * 372 * @param env Indicates the environment that the API is invoked under 373 * @param sorting Indicates a NotificationSorting object to be converted 374 * @param result Indicates a js object to be set 375 * @return Returns the null object if success, returns the null value otherwise 376 */ 377 static napi_value SetNotificationSorting( 378 const napi_env &env, const NotificationSorting &sorting, napi_value &result); 379 380 /** 381 * @brief Sets a js object by specified NotificationSlot object 382 * 383 * @param env Indicates the environment that the API is invoked under 384 * @param slot Indicates a NotificationSlot object to be converted 385 * @param result Indicates a js object to be set 386 * @return Returns the null object if success, returns the null value otherwise 387 */ 388 static napi_value SetNotificationSlot(const napi_env &env, const NotificationSlot &slot, napi_value &result); 389 390 /** 391 * @brief Sets a js object by specified NotificationContent object 392 * 393 * @param env Indicates the environment that the API is invoked under 394 * @param content Indicates a NotificationContent object to be converted 395 * @param result Indicates a js object to be set 396 * @return Returns the null object if success, returns the null value otherwise 397 */ 398 static napi_value SetNotificationContent( 399 const napi_env &env, const std::shared_ptr<NotificationContent> &content, napi_value &result); 400 401 /** 402 * @brief Sets a js object by the object of specified type in specified NotificationContent object 403 * 404 * @param env Indicates the environment that the API is invoked under 405 * @param type Indicates the content type 406 * @param content Indicates a NotificationContent object to be converted 407 * @param result Indicates a js object to be set 408 * @return Returns the null object if success, returns the null value otherwise 409 */ 410 static napi_value SetNotificationContentDetailed(const napi_env &env, const ContentType &type, 411 const std::shared_ptr<NotificationContent> &content, napi_value &result); 412 413 /** 414 * @brief Sets a js NotificationBasicContent object by specified NotificationBasicContent object 415 * 416 * @param env Indicates the environment that the API is invoked under 417 * @param basicContent Indicates a NotificationBasicContent object to be converted 418 * @param result Indicates a js object to be set 419 * @return Returns the null object if success, returns the null value otherwise 420 */ 421 static napi_value SetNotificationBasicContent( 422 const napi_env &env, const NotificationBasicContent *basicContent, napi_value &result); 423 424 /** 425 * @brief Sets a js NotificationLongTextContent object by specified NotificationBasicContent object 426 * 427 * @param env Indicates the environment that the API is invoked under 428 * @param basicContent Indicates a NotificationBasicContent object to be converted 429 * @param result Indicates a js object to be set 430 * @return Returns the null object if success, returns the null value otherwise 431 */ 432 static napi_value SetNotificationLongTextContent( 433 const napi_env &env, NotificationBasicContent *basicContent, napi_value &result); 434 435 /** 436 * @brief Sets a js NotificationPictureContent object by specified NotificationBasicContent object 437 * 438 * @param env Indicates the environment that the API is invoked under 439 * @param basicContent Indicates a NotificationBasicContent object to be converted 440 * @param result Indicates a js object to be set 441 * @return Returns the null object if success, returns the null value otherwise 442 */ 443 static napi_value SetNotificationPictureContent( 444 const napi_env &env, NotificationBasicContent *basicContent, napi_value &result); 445 446 /** 447 * @brief Sets a js NotificationConversationalContent object by specified NotificationBasicContent object 448 * 449 * @param env Indicates the environment that the API is invoked under 450 * @param basicContent Indicates a NotificationBasicContent object to be converted 451 * @param result Indicates a js object to be set 452 * @return Returns the null object if success, returns the null value otherwise 453 */ 454 static napi_value SetNotificationConversationalContent(const napi_env &env, 455 NotificationBasicContent *basicContent, napi_value &result); 456 457 /** 458 * @brief Sets a js NotificationMultiLineContent object by specified NotificationBasicContent object 459 * 460 * @param env Indicates the environment that the API is invoked under 461 * @param basicContent Indicates a NotificationBasicContent object to be converted 462 * @param result Indicates a js object to be set 463 * @return Returns the null object if success, returns the null value otherwise 464 */ 465 static napi_value SetNotificationMultiLineContent( 466 const napi_env &env, NotificationBasicContent *basicContent, napi_value &result); 467 468 /** 469 * @brief Sets a js object by specified MessageUser object 470 * 471 * @param env Indicates the environment that the API is invoked under 472 * @param messageUser Indicates a MessageUser object to be converted 473 * @param result Indicates a js object to be set 474 * @return Returns the null object if success, returns the null value otherwise 475 */ 476 static napi_value SetMessageUser(const napi_env &env, const MessageUser &messageUser, napi_value &result); 477 478 /** 479 * @brief Sets a js object by specified NotificationConversationalContent object 480 * 481 * @param env Indicates the environment that the API is invoked under 482 * @param conversationalContent Indicates a NotificationConversationalContent object to be converted 483 * @param arr Indicates a js object to be set 484 * @return Returns the null object if success, returns the null value otherwise 485 */ 486 static napi_value SetConversationalMessages(const napi_env &env, 487 const OHOS::Notification::NotificationConversationalContent *conversationalContent, napi_value &arr); 488 489 /** 490 * @brief Sets a js object by specified NotificationConversationalMessage object 491 * 492 * @param env Indicates the environment that the API is invoked under 493 * @param conversationalMessage Indicates a NotificationConversationalMessage object to be converted 494 * @param result Indicates a js object to be set 495 * @return Returns the null object if success, returns the null value otherwise 496 */ 497 static napi_value SetConversationalMessage(const napi_env &env, 498 const std::shared_ptr<NotificationConversationalMessage> &conversationalMessage, napi_value &result); 499 500 /** 501 * @brief Sets a js object by specified NotificationActionButton object 502 * 503 * @param env Indicates the environment that the API is invoked under 504 * @param actionButton Indicates a NotificationActionButton object to be converted 505 * @param result Indicates a js object to be set 506 * @return Returns the null object if success, returns the null value otherwise 507 */ 508 static napi_value SetNotificationActionButton( 509 const napi_env &env, const std::shared_ptr<NotificationActionButton> &actionButton, napi_value &result); 510 511 /** 512 * @brief Sets a js object by the extra objects of specified NotificationActionButton object 513 * 514 * @param env Indicates the environment that the API is invoked under 515 * @param actionButton Indicates a NotificationActionButton object to be converted 516 * @param result Indicates a js object to be set 517 * @return Returns the null object if success, returns the null value otherwise 518 */ 519 static napi_value SetNotificationActionButtonByExtras( 520 const napi_env &env, const std::shared_ptr<NotificationActionButton> &actionButton, napi_value &result); 521 522 /** 523 * @brief Sets a js object by specified NotificationUserInput object 524 * 525 * @param env Indicates the environment that the API is invoked under 526 * @param userInput Indicates a NotificationUserInput object to be converted 527 * @param result Indicates a js object to be set 528 * @return Returns the null object if success, returns the null value otherwise 529 */ 530 static napi_value SetNotificationActionButtonByUserInput( 531 const napi_env &env, const std::shared_ptr<NotificationUserInput> &userInput, napi_value &result); 532 533 /** 534 * @brief Sets a js object by specified NotificationDoNotDisturbDate object 535 * 536 * @param env Indicates the environment that the API is invoked under 537 * @param date Indicates a NotificationDoNotDisturbDate object to be converted 538 * @param result Indicates a js object to be set 539 * @return Returns the null object if success, returns the null value otherwise 540 */ 541 static napi_value SetDoNotDisturbDate( 542 const napi_env &env, const NotificationDoNotDisturbDate &date, napi_value &result); 543 544 /** 545 * @brief Sets a js object by specified EnabledNotificationCallbackData object 546 * 547 * @param env Indicates the environment that the API is invoked under 548 * @param date Indicates a EnabledNotificationCallbackData object to be converted 549 * @param result Indicates a js object to be set 550 * @return Returns the null object if success, returns the null value otherwise 551 */ 552 static napi_value SetEnabledNotificationCallbackData(const napi_env &env, 553 const EnabledNotificationCallbackData &data, napi_value &result); 554 555 /** 556 * @brief Gets a NotificationSubscribeInfo object from specified js object 557 * 558 * @param env Indicates the environment that the API is invoked under 559 * @param value Indicates a js object to be converted 560 * @param result Indicates a NotificationSubscribeInfo object from specified js object 561 * @return Returns the null object if success, returns the null value otherwise 562 */ 563 static napi_value GetNotificationSubscriberInfo( 564 const napi_env &env, const napi_value &value, NotificationSubscribeInfo &result); 565 566 /** 567 * @brief Gets a NotificationRequest object from specified js object 568 * 569 * @param env Indicates the environment that the API is invoked under 570 * @param value Indicates a js object to be converted 571 * @param result Indicates a NotificationRequest object from specified js object 572 * @return Returns the null object if success, returns the null value otherwise 573 */ 574 static napi_value GetNotificationRequest( 575 const napi_env &env, const napi_value &value, NotificationRequest &request); 576 577 /** 578 * @brief Gets a NotificationRequest object by number type from specified js object 579 * 580 * @param env Indicates the environment that the API is invoked under 581 * @param value Indicates a js object to be converted 582 * @param request Indicates a NotificationRequest object from specified js object 583 * @return Returns the null object if success, returns the null value otherwise 584 */ 585 static napi_value GetNotificationRequestByNumber( 586 const napi_env &env, const napi_value &value, NotificationRequest &request); 587 588 /** 589 * @brief Gets a NotificationRequest object by string type from specified js object 590 * 591 * @param env Indicates the environment that the API is invoked under 592 * @param value Indicates a js object to be converted 593 * @param request Indicates a NotificationRequest object from specified js object 594 * @return Returns the null object if success, returns the null value otherwise 595 */ 596 static napi_value GetNotificationRequestByString( 597 const napi_env &env, const napi_value &value, NotificationRequest &request); 598 599 /** 600 * @brief Gets a NotificationRequest object by bool type from specified js object 601 * 602 * @param env Indicates the environment that the API is invoked under 603 * @param value Indicates a js object to be converted 604 * @param request Indicates a NotificationRequest object from specified js object 605 * @return Returns the null object if success, returns the null value otherwise 606 */ 607 static napi_value GetNotificationRequestByBool( 608 const napi_env &env, const napi_value &value, NotificationRequest &request); 609 610 /** 611 * @brief Gets a NotificationRequest object by custom type from specified js object 612 * 613 * @param env Indicates the environment that the API is invoked under 614 * @param value Indicates a js object to be converted 615 * @param request Indicates a NotificationRequest object from specified js object 616 * @return Returns the null object if success, returns the null value otherwise 617 */ 618 static napi_value GetNotificationRequestByCustom( 619 const napi_env &env, const napi_value &value, NotificationRequest &request); 620 621 /** 622 * @brief Gets the id of NotificationRequest object from specified js object 623 * 624 * @param env Indicates the environment that the API is invoked under 625 * @param value Indicates a js object to be converted 626 * @param request Indicates a NotificationRequest object from specified js object 627 * @return Returns the null object if success, returns the null value otherwise 628 */ 629 static napi_value GetNotificationId(const napi_env &env, const napi_value &value, NotificationRequest &request); 630 631 /** 632 * @brief Gets the slot type of NotificationRequest object from specified js object 633 * 634 * @param env Indicates the environment that the API is invoked under 635 * @param value Indicates a js object to be converted 636 * @param request Indicates a NotificationRequest object from specified js object 637 * @return Returns the null object if success, returns the null value otherwise 638 */ 639 static napi_value GetNotificationSlotType( 640 const napi_env &env, const napi_value &value, NotificationRequest &request); 641 642 /** 643 * @brief Gets the isOngoing flag of NotificationRequest object from specified js object 644 * 645 * @param env Indicates the environment that the API is invoked under 646 * @param value Indicates a js object to be converted 647 * @param request Indicates a NotificationRequest object from specified js object 648 * @return Returns the null object if success, returns the null value otherwise 649 */ 650 static napi_value GetNotificationIsOngoing( 651 const napi_env &env, const napi_value &value, NotificationRequest &request); 652 653 /** 654 * @brief Gets the isUnremovable flag of NotificationRequest object from specified js object 655 * 656 * @param env Indicates the environment that the API is invoked under 657 * @param value Indicates a js object to be converted 658 * @param request Indicates a NotificationRequest object from specified js object 659 * @return Returns the null object if success, returns the null value otherwise 660 */ 661 static napi_value GetNotificationIsUnremovable( 662 const napi_env &env, const napi_value &value, NotificationRequest &request); 663 664 /** 665 * @brief Gets the delivery time of NotificationRequest object from specified js object 666 * 667 * @param env Indicates the environment that the API is invoked under 668 * @param value Indicates a js object to be converted 669 * @param request Indicates a NotificationRequest object from specified js object 670 * @return Returns the null object if success, returns the null value otherwise 671 */ 672 static napi_value GetNotificationDeliveryTime( 673 const napi_env &env, const napi_value &value, NotificationRequest &request); 674 675 /** 676 * @brief Gets the tapDismissed flag of NotificationRequest object from specified js object 677 * 678 * @param env Indicates the environment that the API is invoked under 679 * @param value Indicates a js object to be converted 680 * @param request Indicates a NotificationRequest object from specified js object 681 * @return Returns the null object if success, returns the null value otherwise 682 */ 683 static napi_value GetNotificationtapDismissed( 684 const napi_env &env, const napi_value &value, NotificationRequest &request); 685 686 /** 687 * @brief Gets the extra information of NotificationRequest object from specified js object 688 * 689 * @param env Indicates the environment that the API is invoked under 690 * @param value Indicates a js object to be converted 691 * @param request Indicates a NotificationRequest object from specified js object 692 * @return Returns the null object if success, returns the null value otherwise 693 */ 694 static napi_value GetNotificationExtraInfo( 695 const napi_env &env, const napi_value &value, NotificationRequest &request); 696 697 /** 698 * @brief Gets the group name of NotificationRequest object from specified js object 699 * 700 * @param env Indicates the environment that the API is invoked under 701 * @param value Indicates a js object to be converted 702 * @param request Indicates a NotificationRequest object from specified js object 703 * @return Returns the null object if success, returns the null value otherwise 704 */ 705 static napi_value GetNotificationGroupName( 706 const napi_env &env, const napi_value &value, NotificationRequest &request); 707 708 /** 709 * @brief Gets the removal WantAgent object of NotificationRequest object from specified js object 710 * 711 * @param env Indicates the environment that the API is invoked under 712 * @param value Indicates a js object to be converted 713 * @param request Indicates a NotificationRequest object from specified js object 714 * @return Returns the null object if success, returns the null value otherwise 715 */ 716 static napi_value GetNotificationRemovalWantAgent( 717 const napi_env &env, const napi_value &value, NotificationRequest &request); 718 719 /** 720 * @brief Gets the max screen WantAgent object of NotificationRequest object from specified js object 721 * 722 * @param env Indicates the environment that the API is invoked under 723 * @param value Indicates a js object to be converted 724 * @param request Indicates a NotificationRequest object from specified js object 725 * @return Returns the null object if success, returns the null value otherwise 726 */ 727 static napi_value GetNotificationMaxScreenWantAgent( 728 const napi_env &env, const napi_value &value, NotificationRequest &request); 729 730 /** 731 * @brief Gets the auto deleted time of NotificationRequest object from specified js object 732 * 733 * @param env Indicates the environment that the API is invoked under 734 * @param value Indicates a js object to be converted 735 * @param request Indicates a NotificationRequest object from specified js object 736 * @return Returns the null object if success, returns the null value otherwise 737 */ 738 static napi_value GetNotificationAutoDeletedTime( 739 const napi_env &env, const napi_value &value, NotificationRequest &request); 740 741 /** 742 * @brief Gets the classification of NotificationRequest object from specified js object 743 * 744 * @param env Indicates the environment that the API is invoked under 745 * @param value Indicates a js object to be converted 746 * @param request Indicates a NotificationRequest object from specified js object 747 * @return Returns the null object if success, returns the null value otherwise 748 */ 749 static napi_value GetNotificationClassification( 750 const napi_env &env, const napi_value &value, NotificationRequest &request); 751 752 /** 753 * @brief Gets the color of NotificationRequest object from specified js object 754 * 755 * @param env Indicates the environment that the API is invoked under 756 * @param value Indicates a js object to be converted 757 * @param request Indicates a NotificationRequest object from specified js object 758 * @return Returns the null object if success, returns the null value otherwise 759 */ 760 static napi_value GetNotificationColor(const napi_env &env, const napi_value &value, NotificationRequest &request); 761 762 /** 763 * @brief Gets the colorEnabled flag of NotificationRequest object from specified js object 764 * 765 * @param env Indicates the environment that the API is invoked under 766 * @param value Indicates a js object to be converted 767 * @param request Indicates a NotificationRequest object from specified js object 768 * @return Returns the null object if success, returns the null value otherwise 769 */ 770 static napi_value GetNotificationColorEnabled( 771 const napi_env &env, const napi_value &value, NotificationRequest &request); 772 773 /** 774 * @brief Gets the isAlertOnce flag of NotificationRequest object from specified js object 775 * 776 * @param env Indicates the environment that the API is invoked under 777 * @param value Indicates a js object to be converted 778 * @param request Indicates a NotificationRequest object from specified js object 779 * @return Returns the null object if success, returns the null value otherwise 780 */ 781 static napi_value GetNotificationIsAlertOnce( 782 const napi_env &env, const napi_value &value, NotificationRequest &request); 783 784 /** 785 * @brief Gets the isStopwatch flag of NotificationRequest object from specified js object 786 * 787 * @param env Indicates the environment that the API is invoked under 788 * @param value Indicates a js object to be converted 789 * @param request Indicates a NotificationRequest object from specified js object 790 * @return Returns the null object if success, returns the null value otherwise 791 */ 792 static napi_value GetNotificationIsStopwatch( 793 const napi_env &env, const napi_value &value, NotificationRequest &request); 794 795 /** 796 * @brief Gets the isCountDown flag of NotificationRequest object from specified js object 797 * 798 * @param env Indicates the environment that the API is invoked under 799 * @param value Indicates a js object to be converted 800 * @param request Indicates a NotificationRequest object from specified js object 801 * @return Returns the null object if success, returns the null value otherwise 802 */ 803 static napi_value GetNotificationIsCountDown( 804 const napi_env &env, const napi_value &value, NotificationRequest &request); 805 806 /** 807 * @brief Gets the status bar text of NotificationRequest object from specified js object 808 * 809 * @param env Indicates the environment that the API is invoked under 810 * @param value Indicates a js object to be converted 811 * @param request Indicates a NotificationRequest object from specified js object 812 * @return Returns the null object if success, returns the null value otherwise 813 */ 814 static napi_value GetNotificationStatusBarText( 815 const napi_env &env, const napi_value &value, NotificationRequest &request); 816 817 /** 818 * @brief Gets the label of NotificationRequest object from specified js object 819 * 820 * @param env Indicates the environment that the API is invoked under 821 * @param value Indicates a js object to be converted 822 * @param request Indicates a NotificationRequest object from specified js object 823 * @return Returns the null object if success, returns the null value otherwise 824 */ 825 static napi_value GetNotificationLabel(const napi_env &env, const napi_value &value, NotificationRequest &request); 826 827 /** 828 * @brief Gets the badge icon style of NotificationRequest object from specified js object 829 * 830 * @param env Indicates the environment that the API is invoked under 831 * @param value Indicates a js object to be converted 832 * @param request Indicates a NotificationRequest object from specified js object 833 * @return Returns the null object if success, returns the null value otherwise 834 */ 835 static napi_value GetNotificationBadgeIconStyle( 836 const napi_env &env, const napi_value &value, NotificationRequest &request); 837 838 /** 839 * @brief Gets the showDeliveryTime flag of NotificationRequest object from specified js object 840 * 841 * @param env Indicates the environment that the API is invoked under 842 * @param value Indicates a js object to be converted 843 * @param request Indicates a NotificationRequest object from specified js object 844 * @return Returns the null object if success, returns the null value otherwise 845 */ 846 static napi_value GetNotificationShowDeliveryTime( 847 const napi_env &env, const napi_value &value, NotificationRequest &request); 848 849 /** 850 * @brief Gets the content of NotificationRequest object from specified js object 851 * 852 * @param env Indicates the environment that the API is invoked under 853 * @param value Indicates a js object to be converted 854 * @param request Indicates a NotificationRequest object from specified js object 855 * @return Returns the null object if success, returns the null value otherwise 856 */ 857 static napi_value GetNotificationContent( 858 const napi_env &env, const napi_value &value, NotificationRequest &request); 859 860 /** 861 * @brief Gets the WantAgent object of NotificationRequest object from specified js object 862 * 863 * @param env Indicates the environment that the API is invoked under 864 * @param value Indicates a js object to be converted 865 * @param request Indicates a NotificationRequest object from specified js object 866 * @return Returns the null object if success, returns the null value otherwise 867 */ 868 static napi_value GetNotificationWantAgent( 869 const napi_env &env, const napi_value &value, NotificationRequest &request); 870 871 /** 872 * @brief Gets a NotificationSlot object from specified js object 873 * 874 * @param env Indicates the environment that the API is invoked under 875 * @param value Indicates a js object to be converted 876 * @param slot Indicates a NotificationSlot object from specified js object 877 * @return Returns the null object if success, returns the null value otherwise 878 */ 879 static napi_value GetNotificationSlot( 880 const napi_env &env, const napi_value &value, NotificationSlot &slot); 881 882 /** 883 * @brief Gets the string objects of NotificationSlot object from specified js object 884 * 885 * @param env Indicates the environment that the API is invoked under 886 * @param value Indicates a js object to be converted 887 * @param slot Indicates a NotificationSlot object from specified js object 888 * @return Returns the null object if success, returns the null value otherwise 889 */ 890 static napi_value GetNotificationSlotByString( 891 const napi_env &env, const napi_value &value, NotificationSlot &slot); 892 893 /** 894 * @brief Gets the bool objects of NotificationSlot object from specified js object 895 * 896 * @param env Indicates the environment that the API is invoked under 897 * @param value Indicates a js object to be converted 898 * @param slot Indicates a NotificationSlot object from specified js object 899 * @return Returns the null object if success, returns the null value otherwise 900 */ 901 static napi_value GetNotificationSlotByBool( 902 const napi_env &env, const napi_value &value, NotificationSlot &slot); 903 904 /** 905 * @brief Gets the number objects of NotificationSlot object from specified js object 906 * 907 * @param env Indicates the environment that the API is invoked under 908 * @param value Indicates a js object to be converted 909 * @param slot Indicates a NotificationSlot object from specified js object 910 * @return Returns the null object if success, returns the null value otherwise 911 */ 912 static napi_value GetNotificationSlotByNumber( 913 const napi_env &env, const napi_value &value, NotificationSlot &slot); 914 915 /** 916 * @brief Gets the vibration of NotificationSlot object from specified js object 917 * 918 * @param env Indicates the environment that the API is invoked under 919 * @param value Indicates a js object to be converted 920 * @param slot Indicates a NotificationSlot object from specified js object 921 * @return Returns the null object if success, returns the null value otherwise 922 */ 923 static napi_value GetNotificationSlotByVibration( 924 const napi_env &env, const napi_value &value, NotificationSlot &slot); 925 926 /** 927 * @brief Gets the action buttons of NotificationRequest object from specified js object 928 * 929 * @param env Indicates the environment that the API is invoked under 930 * @param value Indicates a js object to be converted 931 * @param request Indicates a NotificationRequest object from specified js object 932 * @return Returns the null object if success, returns the null value otherwise 933 */ 934 static napi_value GetNotificationActionButtons( 935 const napi_env &env, const napi_value &value, NotificationRequest &request); 936 937 /** 938 * @brief Gets a NotificationActionButton object from specified js object 939 * 940 * @param env Indicates the environment that the API is invoked under 941 * @param actionButton Indicates a js object to be converted 942 * @param pActionButton Indicates a NotificationActionButton object from specified js object 943 * @return Returns the null object if success, returns the null value otherwise 944 */ 945 static napi_value GetNotificationActionButtonsDetailed( 946 const napi_env &env, const napi_value &actionButton, std::shared_ptr<NotificationActionButton> &pActionButton); 947 948 /** 949 * @brief Gets the basic information of NotificationActionButton object from specified js object 950 * 951 * @param env Indicates the environment that the API is invoked under 952 * @param actionButton Indicates a js object to be converted 953 * @param pActionButton Indicates a NotificationActionButton object from specified js object 954 * @return Returns the null object if success, returns the null value otherwise 955 */ 956 static napi_value GetNotificationActionButtonsDetailedBasicInfo( 957 const napi_env &env, const napi_value &actionButton, std::shared_ptr<NotificationActionButton> &pActionButton); 958 959 /** 960 * @brief Gets the extras of NotificationActionButton object from specified js object 961 * 962 * @param env Indicates the environment that the API is invoked under 963 * @param actionButton Indicates a js object to be converted 964 * @param pActionButton Indicates a NotificationActionButton object from specified js object 965 * @return Returns the null object if success, returns the null value otherwise 966 */ 967 static napi_value GetNotificationActionButtonsDetailedByExtras( 968 const napi_env &env, const napi_value &actionButton, std::shared_ptr<NotificationActionButton> &pActionButton); 969 970 /** 971 * @brief Gets the user input of NotificationActionButton object from specified js object 972 * 973 * @param env Indicates the environment that the API is invoked under 974 * @param actionButton Indicates a js object to be converted 975 * @param pActionButton Indicates a NotificationActionButton object from specified js object 976 * @return Returns the null object if success, returns the null value otherwise 977 */ 978 static napi_value GetNotificationUserInput( 979 const napi_env &env, const napi_value &actionButton, std::shared_ptr<NotificationActionButton> &pActionButton); 980 981 /** 982 * @brief Gets the input key of NotificationUserInput object from specified js object 983 * 984 * @param env Indicates the environment that the API is invoked under 985 * @param userInputResult Indicates a js object to be converted 986 * @param userInput Indicates a NotificationUserInput object from specified js object 987 * @return Returns the null object if success, returns the null value otherwise 988 */ 989 static napi_value GetNotificationUserInputByInputKey( 990 const napi_env &env, const napi_value &userInputResult, std::shared_ptr<NotificationUserInput> &userInput); 991 992 /** 993 * @brief Gets the tag of NotificationUserInput object from specified js object 994 * 995 * @param env Indicates the environment that the API is invoked under 996 * @param userInputResult Indicates a js object to be converted 997 * @param userInput Indicates a NotificationUserInput object from specified js object 998 * @return Returns the null object if success, returns the null value otherwise 999 */ 1000 static napi_value GetNotificationUserInputByTag( 1001 const napi_env &env, const napi_value &userInputResult, std::shared_ptr<NotificationUserInput> &userInput); 1002 1003 /** 1004 * @brief Gets the options of NotificationUserInput object from specified js object 1005 * 1006 * @param env Indicates the environment that the API is invoked under 1007 * @param userInputResult Indicates a js object to be converted 1008 * @param userInput Indicates a NotificationUserInput object from specified js object 1009 * @return Returns the null object if success, returns the null value otherwise 1010 */ 1011 static napi_value GetNotificationUserInputByOptions( 1012 const napi_env &env, const napi_value &userInputResult, std::shared_ptr<NotificationUserInput> &userInput); 1013 1014 /** 1015 * @brief Gets the permit mime types of NotificationUserInput object from specified js object 1016 * 1017 * @param env Indicates the environment that the API is invoked under 1018 * @param userInputResult Indicates a js object to be converted 1019 * @param userInput Indicates a NotificationUserInput object from specified js object 1020 * @return Returns the null object if success, returns the null value otherwise 1021 */ 1022 static napi_value GetNotificationUserInputByPermitMimeTypes( 1023 const napi_env &env, const napi_value &userInputResult, std::shared_ptr<NotificationUserInput> &userInput); 1024 1025 /** 1026 * @brief Gets the permit free from input of NotificationUserInput object from specified js object 1027 * 1028 * @param env Indicates the environment that the API is invoked under 1029 * @param userInputResult Indicates a js object to be converted 1030 * @param userInput Indicates a NotificationUserInput object from specified js object 1031 * @return Returns the null object if success, returns the null value otherwise 1032 */ 1033 static napi_value GetNotificationUserInputByPermitFreeFormInput( 1034 const napi_env &env, const napi_value &userInputResult, std::shared_ptr<NotificationUserInput> &userInput); 1035 1036 /** 1037 * @brief Gets the edit type of NotificationUserInput object from specified js object 1038 * 1039 * @param env Indicates the environment that the API is invoked under 1040 * @param userInputResult Indicates a js object to be converted 1041 * @param userInput Indicates a NotificationUserInput object from specified js object 1042 * @return Returns the null object if success, returns the null value otherwise 1043 */ 1044 static napi_value GetNotificationUserInputByEditType( 1045 const napi_env &env, const napi_value &userInputResult, std::shared_ptr<NotificationUserInput> &userInput); 1046 1047 /** 1048 * @brief Gets the additional data of NotificationUserInput object from specified js object 1049 * 1050 * @param env Indicates the environment that the API is invoked under 1051 * @param userInputResult Indicates a js object to be converted 1052 * @param userInput Indicates a NotificationUserInput object from specified js object 1053 * @return Returns the null object if success, returns the null value otherwise 1054 */ 1055 static napi_value GetNotificationUserInputByAdditionalData( 1056 const napi_env &env, const napi_value &userInputResult, std::shared_ptr<NotificationUserInput> &userInput); 1057 1058 /** 1059 * @brief Gets the small icon of NotificationRequest object from specified js object 1060 * 1061 * @param env Indicates the environment that the API is invoked under 1062 * @param value Indicates a js object to be converted 1063 * @param request Indicates a NotificationRequest object from specified js object 1064 * @return Returns the null object if success, returns the null value otherwise 1065 */ 1066 static napi_value GetNotificationSmallIcon( 1067 const napi_env &env, const napi_value &value, NotificationRequest &request); 1068 1069 /** 1070 * @brief Gets the large icon of NotificationRequest object from specified js object 1071 * 1072 * @param env Indicates the environment that the API is invoked under 1073 * @param value Indicates a js object to be converted 1074 * @param request Indicates a NotificationRequest object from specified js object 1075 * @return Returns the null object if success, returns the null value otherwise 1076 */ 1077 static napi_value GetNotificationLargeIcon( 1078 const napi_env &env, const napi_value &value, NotificationRequest &request); 1079 1080 /** 1081 * @brief Gets the distributed options of NotificationRequest object from specified js object 1082 * 1083 * @param env Indicates the environment that the API is invoked under 1084 * @param value Indicates a js object to be converted 1085 * @param request Indicates a NotificationRequest object from specified js object 1086 * @return Returns the null object if success, returns the null value otherwise 1087 */ 1088 static napi_value GetNotificationRequestDistributedOptions( 1089 const napi_env &env, const napi_value &value, NotificationRequest &request); 1090 1091 /** 1092 * @brief Gets the isDistributed flag of NotificationRequest object from specified js object 1093 * 1094 * @param env Indicates the environment that the API is invoked under 1095 * @param value Indicates a js object to be converted 1096 * @param request Indicates a NotificationRequest object from specified js object 1097 * @return Returns the null object if success, returns the null value otherwise 1098 */ 1099 static napi_value GetNotificationIsDistributed( 1100 const napi_env &env, const napi_value &value, NotificationRequest &request); 1101 1102 /** 1103 * @brief Gets the devices that support display of NotificationRequest object from specified js object 1104 * 1105 * @param env Indicates the environment that the API is invoked under 1106 * @param value Indicates a js object to be converted 1107 * @param request Indicates a NotificationRequest object from specified js object 1108 * @return Returns the null object if success, returns the null value otherwise 1109 */ 1110 static napi_value GetNotificationSupportDisplayDevices( 1111 const napi_env &env, const napi_value &value, NotificationRequest &request); 1112 1113 /** 1114 * @brief Gets the devices that support operation of NotificationRequest object from specified js object 1115 * 1116 * @param env Indicates the environment that the API is invoked under 1117 * @param value Indicates a js object to be converted 1118 * @param request Indicates a NotificationRequest object from specified js object 1119 * @return Returns the null object if success, returns the null value otherwise 1120 */ 1121 static napi_value GetNotificationSupportOperateDevices( 1122 const napi_env &env, const napi_value &value, NotificationRequest &request); 1123 1124 /** 1125 * @brief Gets a content type of notification from specified js object 1126 * 1127 * @param env Indicates the environment that the API is invoked under 1128 * @param value Indicates a js object to be converted 1129 * @param type Indicates a the content type of notification from specified js object 1130 * @return Returns the null object if success, returns the null value otherwise 1131 */ 1132 static napi_value GetNotificationContentType(const napi_env &env, const napi_value &result, int32_t &type); 1133 1134 /** 1135 * @brief Gets a basic content of NotificationRequest object from specified js object 1136 * 1137 * @param env Indicates the environment that the API is invoked under 1138 * @param value Indicates a js object to be converted 1139 * @param request Indicates a NotificationRequest object from specified js object 1140 * @return Returns the null object if success, returns the null value otherwise 1141 */ 1142 static napi_value GetNotificationBasicContent( 1143 const napi_env &env, const napi_value &result, NotificationRequest &request); 1144 1145 /** 1146 * @brief Gets a NotificationBasicContent object from specified js object 1147 * 1148 * @param env Indicates the environment that the API is invoked under 1149 * @param contentResult Indicates a js object to be converted 1150 * @param basicContent Indicates a NotificationBasicContent object from specified js object 1151 * @return Returns the null object if success, returns the null value otherwise 1152 */ 1153 static napi_value GetNotificationBasicContentDetailed( 1154 const napi_env &env, const napi_value &contentResult, std::shared_ptr<NotificationBasicContent> basicContent); 1155 1156 /** 1157 * @brief Gets a long-text content of NotificationRequest object from specified js object 1158 * 1159 * @param env Indicates the environment that the API is invoked under 1160 * @param value Indicates a js object to be converted 1161 * @param request Indicates a NotificationRequest object from specified js object 1162 * @return Returns the null object if success, returns the null value otherwise 1163 */ 1164 static napi_value GetNotificationLongTextContent( 1165 const napi_env &env, const napi_value &result, NotificationRequest &request); 1166 1167 /** 1168 * @brief Gets a NotificationLongTextContent object from specified js object 1169 * 1170 * @param env Indicates the environment that the API is invoked under 1171 * @param contentResult Indicates a js object to be converted 1172 * @param longContent Indicates a NotificationLongTextContent object from specified js object 1173 * @return Returns the null object if success, returns the null value otherwise 1174 */ 1175 static napi_value GetNotificationLongTextContentDetailed( 1176 const napi_env &env, const napi_value &contentResult, 1177 std::shared_ptr<OHOS::Notification::NotificationLongTextContent> &longContent); 1178 1179 /** 1180 * @brief Gets a picture content of NotificationRequest object from specified js object 1181 * 1182 * @param env Indicates the environment that the API is invoked under 1183 * @param result Indicates a js object to be converted 1184 * @param request Indicates a NotificationRequest object from specified js object 1185 * @return Returns the null object if success, returns the null value otherwise 1186 */ 1187 static napi_value GetNotificationPictureContent( 1188 const napi_env &env, const napi_value &result, NotificationRequest &request); 1189 1190 /** 1191 * @brief Gets a NotificationPictureContent object from specified js object 1192 * 1193 * @param env Indicates the environment that the API is invoked under 1194 * @param contentResult Indicates a js object to be converted 1195 * @param pictureContent Indicates a NotificationPictureContent object from specified js object 1196 * @return Returns the null object if success, returns the null value otherwise 1197 */ 1198 static napi_value GetNotificationPictureContentDetailed( 1199 const napi_env &env, const napi_value &contentResult, 1200 std::shared_ptr<OHOS::Notification::NotificationPictureContent> &pictureContent); 1201 1202 /** 1203 * @brief Gets a conversational content of NotificationRequest object from specified js object 1204 * 1205 * @param env Indicates the environment that the API is invoked under 1206 * @param result Indicates a js object to be converted 1207 * @param request Indicates a NotificationRequest object from specified js object 1208 * @return Returns the null object if success, returns the null value otherwise 1209 */ 1210 static napi_value GetNotificationConversationalContent( 1211 const napi_env &env, const napi_value &result, NotificationRequest &request); 1212 1213 /** 1214 * @brief Gets the user of NotificationConversationalContent object from specified js object 1215 * 1216 * @param env Indicates the environment that the API is invoked under 1217 * @param contentResult Indicates a js object to be converted 1218 * @param user Indicates a MessageUser object from specified js object 1219 * @return Returns the null object if success, returns the null value otherwise 1220 */ 1221 static napi_value GetNotificationConversationalContentByUser( 1222 const napi_env &env, const napi_value &contentResult, MessageUser &user); 1223 1224 /** 1225 * @brief Gets the title of NotificationConversationalContent object from specified js object 1226 * 1227 * @param env Indicates the environment that the API is invoked under 1228 * @param contentResult Indicates a js object to be converted 1229 * @param conversationalContent Indicates a NotificationConversationalContent object from specified js object 1230 * @return Returns the null object if success, returns the null value otherwise 1231 */ 1232 static napi_value GetNotificationConversationalContentTitle( 1233 const napi_env &env, const napi_value &contentResult, 1234 std::shared_ptr<OHOS::Notification::NotificationConversationalContent> &conversationalContent); 1235 1236 /** 1237 * @brief Gets the group of NotificationConversationalContent object from specified js object 1238 * 1239 * @param env Indicates the environment that the API is invoked under 1240 * @param contentResult Indicates a js object to be converted 1241 * @param conversationalContent Indicates a NotificationConversationalContent object from specified js object 1242 * @return Returns the null object if success, returns the null value otherwise 1243 */ 1244 static napi_value GetNotificationConversationalContentGroup( 1245 const napi_env &env, const napi_value &contentResult, 1246 std::shared_ptr<OHOS::Notification::NotificationConversationalContent> &conversationalContent); 1247 1248 /** 1249 * @brief Gets the messages of NotificationConversationalContent object from specified js object 1250 * 1251 * @param env Indicates the environment that the API is invoked under 1252 * @param contentResult Indicates a js object to be converted 1253 * @param conversationalContent Indicates a NotificationConversationalContent object from specified js object 1254 * @return Returns the null object if success, returns the null value otherwise 1255 */ 1256 static napi_value GetNotificationConversationalContentMessages( 1257 const napi_env &env, const napi_value &contentResult, 1258 std::shared_ptr<OHOS::Notification::NotificationConversationalContent> &conversationalContent); 1259 1260 /** 1261 * @brief Gets a NotificationConversationalMessage object from specified js object 1262 * 1263 * @param env Indicates the environment that the API is invoked under 1264 * @param conversationalMessage Indicates a js object to be converted 1265 * @param message Indicates a NotificationConversationalMessage object from specified js object 1266 * @return Returns the null object if success, returns the null value otherwise 1267 */ 1268 static napi_value GetConversationalMessage( 1269 const napi_env &env, const napi_value &conversationalMessage, 1270 std::shared_ptr<NotificationConversationalMessage> &message); 1271 1272 /** 1273 * @brief Gets the basic information of NotificationConversationalMessage object from specified js object 1274 * 1275 * @param env Indicates the environment that the API is invoked under 1276 * @param conversationalMessage Indicates a js object to be converted 1277 * @param message Indicates a NotificationConversationalMessage object from specified js object 1278 * @return Returns the null object if success, returns the null value otherwise 1279 */ 1280 static napi_value GetConversationalMessageBasicInfo( 1281 const napi_env &env, const napi_value &conversationalMessage, 1282 std::shared_ptr<NotificationConversationalMessage> &message); 1283 1284 /** 1285 * @brief Gets the other information of NotificationConversationalMessage object from specified js object 1286 * 1287 * @param env Indicates the environment that the API is invoked under 1288 * @param conversationalMessage Indicates a js object to be converted 1289 * @param message Indicates a NotificationConversationalMessage object from specified js object 1290 * @return Returns the null object if success, returns the null value otherwise 1291 */ 1292 static napi_value GetConversationalMessageOtherInfo( 1293 const napi_env &env, const napi_value &conversationalMessage, 1294 std::shared_ptr<NotificationConversationalMessage> &message); 1295 1296 /** 1297 * @brief Gets a MessageUser object from specified js object 1298 * 1299 * @param env Indicates the environment that the API is invoked under 1300 * @param result Indicates a js object to be converted 1301 * @param messageUser Indicates a MessageUser object from specified js object 1302 * @return Returns the null object if success, returns the null value otherwise 1303 */ 1304 static napi_value GetMessageUser(const napi_env &env, const napi_value &result, MessageUser &messageUser); 1305 1306 /** 1307 * @brief Gets a MessageUser object from specified js object 1308 * 1309 * @param env Indicates the environment that the API is invoked under 1310 * @param result Indicates a js object to be converted 1311 * @param messageUser Indicates a MessageUser object from specified js object 1312 * @return Returns the null object if success, returns the null value otherwise 1313 */ 1314 static napi_value GetMessageUserByString(const napi_env &env, const napi_value &result, MessageUser &messageUser); 1315 1316 /** 1317 * @brief Gets the bool objects of MessageUser object from specified js object 1318 * 1319 * @param env Indicates the environment that the API is invoked under 1320 * @param result Indicates a js object to be converted 1321 * @param messageUser Indicates a MessageUser object from specified js object 1322 * @return Returns the null object if success, returns the null value otherwise 1323 */ 1324 static napi_value GetMessageUserByBool(const napi_env &env, const napi_value &result, MessageUser &messageUser); 1325 1326 /** 1327 * @brief Gets the custom objects of MessageUser object from specified js object 1328 * 1329 * @param env Indicates the environment that the API is invoked under 1330 * @param result Indicates a js object to be converted 1331 * @param messageUser Indicates a MessageUser object from specified js object 1332 * @return Returns the null object if success, returns the null value otherwise 1333 */ 1334 static napi_value GetMessageUserByCustom(const napi_env &env, const napi_value &result, MessageUser &messageUser); 1335 1336 /** 1337 * @brief Gets the multi-line content of NotificationRequest object from specified js object 1338 * 1339 * @param env Indicates the environment that the API is invoked under 1340 * @param result Indicates a js object to be converted 1341 * @param request Indicates a NotificationRequest object from specified js object 1342 * @return Returns the null object if success, returns the null value otherwise 1343 */ 1344 static napi_value GetNotificationMultiLineContent( 1345 const napi_env &env, const napi_value &result, NotificationRequest &request); 1346 1347 /** 1348 * @brief Gets the lines of NotificationMultiLineContent object from specified js object 1349 * 1350 * @param env Indicates the environment that the API is invoked under 1351 * @param result Indicates a js object to be converted 1352 * @param multiLineContent Indicates a NotificationMultiLineContent object from specified js object 1353 * @return Returns the null object if success, returns the null value otherwise 1354 */ 1355 static napi_value GetNotificationMultiLineContentLines(const napi_env &env, const napi_value &result, 1356 std::shared_ptr<OHOS::Notification::NotificationMultiLineContent> &multiLineContent); 1357 1358 /** 1359 * @brief Gets a NotificationBundleOption object from specified js object 1360 * 1361 * @param env Indicates the environment that the API is invoked under 1362 * @param value Indicates a js object to be converted 1363 * @param option Indicates a NotificationBundleOption object from specified js object 1364 * @return Returns the null object if success, returns the null value otherwise 1365 */ 1366 static napi_value GetBundleOption(const napi_env &env, const napi_value &value, NotificationBundleOption &option); 1367 1368 /** 1369 * @brief Gets a NotificationKey object from specified js object 1370 * 1371 * @param env Indicates the environment that the API is invoked under 1372 * @param value Indicates a js object to be converted 1373 * @param key Indicates a NotificationKey object from specified js object 1374 * @return Returns the null object if success, returns the null value otherwise 1375 */ 1376 static napi_value GetNotificationKey(const napi_env &env, const napi_value &value, NotificationKey &key); 1377 1378 /** 1379 * @brief Converts content type from js to native 1380 * 1381 * @param inType Indicates a js ContentType object 1382 * @param outType Indicates a NotificationContent object 1383 * @return Returns true if success, returns false otherwise 1384 */ 1385 static bool ContentTypeJSToC(const ContentType &inType, NotificationContent::Type &outType); 1386 1387 /** 1388 * @brief Converts content type from native to js 1389 * 1390 * @param inType Indicates a NotificationContent object 1391 * @param outType Indicates a js ContentType object 1392 * @return Returns true if success, returns false otherwise 1393 */ 1394 static bool ContentTypeCToJS(const NotificationContent::Type &inType, ContentType &outType); 1395 1396 /** 1397 * @brief Converts slot type from js to native 1398 * 1399 * @param inType Indicates a native SlotType object 1400 * @param outType Indicates a js SlotType object 1401 * @return Returns true if success, returns false otherwise 1402 */ 1403 static bool SlotTypeJSToC(const SlotType &inType, NotificationConstant::SlotType &outType); 1404 1405 /** 1406 * @brief Converts slot type from native to js 1407 * 1408 * @param inType Indicates a js SlotType object 1409 * @param outType Indicates a native SlotType object 1410 * @return Returns true if success, returns false otherwise 1411 */ 1412 static bool SlotTypeCToJS(const NotificationConstant::SlotType &inType, SlotType &outType); 1413 1414 /** 1415 * @brief Converts slot level from js to native 1416 * 1417 * @param inType Indicates a native SlotLevel object 1418 * @param outType Indicates a js NotificationLevel object 1419 * @return Returns true if success, returns false otherwise 1420 */ 1421 static bool SlotLevelJSToC(const SlotLevel &inLevel, NotificationSlot::NotificationLevel &outLevel); 1422 1423 /** 1424 * @brief Converts slot level from native to js 1425 * 1426 * @param inType Indicates a js NotificationLevel object 1427 * @param outType Indicates a native SlotLevel object 1428 * @return Returns true if success, returns false otherwise 1429 */ 1430 static bool SlotLevelCToJS(const NotificationSlot::NotificationLevel &inLevel, SlotLevel &outLevel); 1431 1432 /** 1433 * @brief Converts reason type from native to js 1434 * 1435 * @param inType Indicates a native reason type 1436 * @param outType Indicates a js reason type 1437 * @return Returns true if success, returns false otherwise 1438 */ 1439 static bool ReasonCToJS(const int32_t &inType, int32_t &outType); 1440 1441 /** 1442 * @brief Converts do-not-disturb type from js to native 1443 * 1444 * @param inType Indicates a js DoNotDisturbType object 1445 * @param outType Indicates a native DoNotDisturbType object 1446 * @return Returns true if success, returns false otherwise 1447 */ 1448 static bool DoNotDisturbTypeJSToC(const DoNotDisturbType &inType, NotificationConstant::DoNotDisturbType &outType); 1449 1450 /** 1451 * @brief Converts do-not-disturb type from native to js 1452 * 1453 * @param inType Indicates a native DoNotDisturbType object 1454 * @param outType Indicates a js DoNotDisturbType object 1455 * @return Returns true if success, returns false otherwise 1456 */ 1457 static bool DoNotDisturbTypeCToJS(const NotificationConstant::DoNotDisturbType &inType, DoNotDisturbType &outType); 1458 1459 /** 1460 * @brief Converts remind type from native to js 1461 * 1462 * @param inType Indicates a native RemindType object 1463 * @param outType Indicates a js DeviceRemindType object 1464 * @return Returns true if success, returns false otherwise 1465 */ 1466 static bool DeviceRemindTypeCToJS(const NotificationConstant::RemindType &inType, DeviceRemindType &outType); 1467 1468 /** 1469 * @brief Converts source type from native to js 1470 * 1471 * @param inType Indicates a native SourceType object 1472 * @param outType Indicates a js SourceType object 1473 * @return Returns true if success, returns false otherwise 1474 */ 1475 static bool SourceTypeCToJS(const NotificationConstant::SourceType &inType, SourceType &outType); 1476 1477 /** 1478 * @brief Creates a js object from specified WantAgent object 1479 * 1480 * @param env Indicates the environment that the API is invoked under 1481 * @param agent Indicates specified WantAgent object 1482 * @return Returns a js object from specified WantAgent object 1483 */ 1484 static napi_value CreateWantAgentByJS(const napi_env &env, 1485 const std::shared_ptr<AbilityRuntime::WantAgent::WantAgent> &agent); 1486 1487 /** 1488 * @brief Gets the template of NotificationRequest object from specified js object 1489 * 1490 * @param env Indicates the environment that the API is invoked under 1491 * @param value Indicates a js object to be converted 1492 * @param request Indicates a NotificationRequest object from specified js object 1493 * @return Returns the null object if success, returns the null value otherwise 1494 */ 1495 static napi_value GetNotificationTemplate( 1496 const napi_env &env, const napi_value &value, NotificationRequest &request); 1497 1498 /** 1499 * @brief Gets a NotificationTemplate object from specified js object 1500 * 1501 * @param env Indicates the environment that the API is invoked under 1502 * @param value Indicates a js object to be converted 1503 * @param templ Indicates a NotificationTemplate object from specified js object 1504 * @return Returns the null object if success, returns the null value otherwise 1505 */ 1506 static napi_value GetNotificationTemplateInfo(const napi_env &env, const napi_value &value, 1507 std::shared_ptr<NotificationTemplate> &templ); 1508 1509 /** 1510 * @brief Sets a js object by specified NotificationTemplate object 1511 * 1512 * @param env Indicates the environment that the API is invoked under 1513 * @param templ Indicates a NotificationTemplate object to be converted 1514 * @param result Indicates a js object to be set 1515 * @return Returns the null object if success, returns the null value otherwise 1516 */ 1517 static napi_value SetNotificationTemplateInfo( 1518 const napi_env &env, const std::shared_ptr<NotificationTemplate> &templ, napi_value &result); 1519 1520 /** 1521 * @brief Sets a js object by specified NotificationFlags object 1522 * 1523 * @param env Indicates the environment that the API is invoked under 1524 * @param flags Indicates a NotificationFlags object to be converted 1525 * @param result Indicates a js object to be set 1526 * @return Returns the null object if success, returns the null value otherwise 1527 */ 1528 static napi_value SetNotificationFlags( 1529 const napi_env &env, const std::shared_ptr<NotificationFlags> &flags, napi_value &result); 1530 1531 /** 1532 * @brief Gets the number of badge of NotificationRequest object from specified js object 1533 * 1534 * @param env Indicates the environment that the API is invoked under 1535 * @param value Indicates a js object to be converted 1536 * @param request Indicates a NotificationRequest object from specified js object 1537 * @return Returns the null object if success, returns the null value otherwise 1538 */ 1539 static napi_value GetNotificationBadgeNumber( 1540 const napi_env &env, const napi_value &value, NotificationRequest &request); 1541 1542 /** 1543 * @brief Create a napi value with specified error object for callback 1544 * 1545 * @param env Indicates the environment that the API is invoked under 1546 * @param errCode Indicates specified err code 1547 * @return Returns a napi value with specified error object for callback 1548 */ 1549 static napi_value CreateErrorValue(napi_env env, int32_t errCode, bool newType); 1550 1551 static bool IsValidRemoveReason(int32_t reasonType); 1552 static void NapiThrow(napi_env env, int32_t errCode); 1553 static int32_t ErrorToExternal(uint32_t errCode); 1554 static void CreateReturnValue(const napi_env &env, const CallbackPromiseInfo &info, const napi_value &result); 1555 1556 private: 1557 static const int32_t ARGS_ONE = 1; 1558 static const int32_t ARGS_TWO = 2; 1559 static const int32_t ONLY_CALLBACK_MAX_PARA = 1; 1560 static const int32_t ONLY_CALLBACK_MIN_PARA = 0; 1561 static std::set<std::shared_ptr<AbilityRuntime::WantAgent::WantAgent>> wantAgent_; 1562 }; 1563 } // namespace NotificationNapi 1564 } // namespace OHOS 1565 1566 #endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_FRAMEWORKS_JS_NAPI_INCLUDE_COMMON_H