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 static napi_value GetNotificationIsRemoveAllowed( 851 const napi_env &env, const napi_value &value, NotificationRequest &request); 852 853 /** 854 * @brief Gets the content of NotificationRequest object from specified js object 855 * 856 * @param env Indicates the environment that the API is invoked under 857 * @param value Indicates a js object to be converted 858 * @param request Indicates a NotificationRequest object from specified js object 859 * @return Returns the null object if success, returns the null value otherwise 860 */ 861 static napi_value GetNotificationContent( 862 const napi_env &env, const napi_value &value, NotificationRequest &request); 863 864 /** 865 * @brief Gets the WantAgent object of NotificationRequest object from specified js object 866 * 867 * @param env Indicates the environment that the API is invoked under 868 * @param value Indicates a js object to be converted 869 * @param request Indicates a NotificationRequest object from specified js object 870 * @return Returns the null object if success, returns the null value otherwise 871 */ 872 static napi_value GetNotificationWantAgent( 873 const napi_env &env, const napi_value &value, NotificationRequest &request); 874 875 /** 876 * @brief Gets a NotificationSlot object from specified js object 877 * 878 * @param env Indicates the environment that the API is invoked under 879 * @param value Indicates a js object to be converted 880 * @param slot Indicates a NotificationSlot object from specified js object 881 * @return Returns the null object if success, returns the null value otherwise 882 */ 883 static napi_value GetNotificationSlot( 884 const napi_env &env, const napi_value &value, NotificationSlot &slot); 885 886 /** 887 * @brief Gets the string objects of NotificationSlot object from specified js object 888 * 889 * @param env Indicates the environment that the API is invoked under 890 * @param value Indicates a js object to be converted 891 * @param slot Indicates a NotificationSlot object from specified js object 892 * @return Returns the null object if success, returns the null value otherwise 893 */ 894 static napi_value GetNotificationSlotByString( 895 const napi_env &env, const napi_value &value, NotificationSlot &slot); 896 897 /** 898 * @brief Gets the bool objects of NotificationSlot object from specified js object 899 * 900 * @param env Indicates the environment that the API is invoked under 901 * @param value Indicates a js object to be converted 902 * @param slot Indicates a NotificationSlot object from specified js object 903 * @return Returns the null object if success, returns the null value otherwise 904 */ 905 static napi_value GetNotificationSlotByBool( 906 const napi_env &env, const napi_value &value, NotificationSlot &slot); 907 908 /** 909 * @brief Gets the number objects of NotificationSlot object from specified js object 910 * 911 * @param env Indicates the environment that the API is invoked under 912 * @param value Indicates a js object to be converted 913 * @param slot Indicates a NotificationSlot object from specified js object 914 * @return Returns the null object if success, returns the null value otherwise 915 */ 916 static napi_value GetNotificationSlotByNumber( 917 const napi_env &env, const napi_value &value, NotificationSlot &slot); 918 919 /** 920 * @brief Gets the vibration of NotificationSlot object from specified js object 921 * 922 * @param env Indicates the environment that the API is invoked under 923 * @param value Indicates a js object to be converted 924 * @param slot Indicates a NotificationSlot object from specified js object 925 * @return Returns the null object if success, returns the null value otherwise 926 */ 927 static napi_value GetNotificationSlotByVibration( 928 const napi_env &env, const napi_value &value, NotificationSlot &slot); 929 930 /** 931 * @brief Gets the action buttons of NotificationRequest object from specified js object 932 * 933 * @param env Indicates the environment that the API is invoked under 934 * @param value Indicates a js object to be converted 935 * @param request Indicates a NotificationRequest object from specified js object 936 * @return Returns the null object if success, returns the null value otherwise 937 */ 938 static napi_value GetNotificationActionButtons( 939 const napi_env &env, const napi_value &value, NotificationRequest &request); 940 941 /** 942 * @brief Gets a NotificationActionButton object from specified js object 943 * 944 * @param env Indicates the environment that the API is invoked under 945 * @param actionButton Indicates a js object to be converted 946 * @param pActionButton Indicates a NotificationActionButton object from specified js object 947 * @return Returns the null object if success, returns the null value otherwise 948 */ 949 static napi_value GetNotificationActionButtonsDetailed( 950 const napi_env &env, const napi_value &actionButton, std::shared_ptr<NotificationActionButton> &pActionButton); 951 952 /** 953 * @brief Gets the basic information of NotificationActionButton object from specified js object 954 * 955 * @param env Indicates the environment that the API is invoked under 956 * @param actionButton Indicates a js object to be converted 957 * @param pActionButton Indicates a NotificationActionButton object from specified js object 958 * @return Returns the null object if success, returns the null value otherwise 959 */ 960 static napi_value GetNotificationActionButtonsDetailedBasicInfo( 961 const napi_env &env, const napi_value &actionButton, std::shared_ptr<NotificationActionButton> &pActionButton); 962 963 /** 964 * @brief Gets the extras of NotificationActionButton object from specified js object 965 * 966 * @param env Indicates the environment that the API is invoked under 967 * @param actionButton Indicates a js object to be converted 968 * @param pActionButton Indicates a NotificationActionButton object from specified js object 969 * @return Returns the null object if success, returns the null value otherwise 970 */ 971 static napi_value GetNotificationActionButtonsDetailedByExtras( 972 const napi_env &env, const napi_value &actionButton, std::shared_ptr<NotificationActionButton> &pActionButton); 973 974 /** 975 * @brief Gets the user input of NotificationActionButton object from specified js object 976 * 977 * @param env Indicates the environment that the API is invoked under 978 * @param actionButton Indicates a js object to be converted 979 * @param pActionButton Indicates a NotificationActionButton object from specified js object 980 * @return Returns the null object if success, returns the null value otherwise 981 */ 982 static napi_value GetNotificationUserInput( 983 const napi_env &env, const napi_value &actionButton, std::shared_ptr<NotificationActionButton> &pActionButton); 984 985 /** 986 * @brief Gets the input key of NotificationUserInput object from specified js object 987 * 988 * @param env Indicates the environment that the API is invoked under 989 * @param userInputResult Indicates a js object to be converted 990 * @param userInput Indicates a NotificationUserInput object from specified js object 991 * @return Returns the null object if success, returns the null value otherwise 992 */ 993 static napi_value GetNotificationUserInputByInputKey( 994 const napi_env &env, const napi_value &userInputResult, std::shared_ptr<NotificationUserInput> &userInput); 995 996 /** 997 * @brief Gets the tag of NotificationUserInput object from specified js object 998 * 999 * @param env Indicates the environment that the API is invoked under 1000 * @param userInputResult Indicates a js object to be converted 1001 * @param userInput Indicates a NotificationUserInput object from specified js object 1002 * @return Returns the null object if success, returns the null value otherwise 1003 */ 1004 static napi_value GetNotificationUserInputByTag( 1005 const napi_env &env, const napi_value &userInputResult, std::shared_ptr<NotificationUserInput> &userInput); 1006 1007 /** 1008 * @brief Gets the options of NotificationUserInput object from specified js object 1009 * 1010 * @param env Indicates the environment that the API is invoked under 1011 * @param userInputResult Indicates a js object to be converted 1012 * @param userInput Indicates a NotificationUserInput object from specified js object 1013 * @return Returns the null object if success, returns the null value otherwise 1014 */ 1015 static napi_value GetNotificationUserInputByOptions( 1016 const napi_env &env, const napi_value &userInputResult, std::shared_ptr<NotificationUserInput> &userInput); 1017 1018 /** 1019 * @brief Gets the permit mime types of NotificationUserInput object from specified js object 1020 * 1021 * @param env Indicates the environment that the API is invoked under 1022 * @param userInputResult Indicates a js object to be converted 1023 * @param userInput Indicates a NotificationUserInput object from specified js object 1024 * @return Returns the null object if success, returns the null value otherwise 1025 */ 1026 static napi_value GetNotificationUserInputByPermitMimeTypes( 1027 const napi_env &env, const napi_value &userInputResult, std::shared_ptr<NotificationUserInput> &userInput); 1028 1029 /** 1030 * @brief Gets the permit free from input of NotificationUserInput object from specified js object 1031 * 1032 * @param env Indicates the environment that the API is invoked under 1033 * @param userInputResult Indicates a js object to be converted 1034 * @param userInput Indicates a NotificationUserInput object from specified js object 1035 * @return Returns the null object if success, returns the null value otherwise 1036 */ 1037 static napi_value GetNotificationUserInputByPermitFreeFormInput( 1038 const napi_env &env, const napi_value &userInputResult, std::shared_ptr<NotificationUserInput> &userInput); 1039 1040 /** 1041 * @brief Gets the edit type of NotificationUserInput object from specified js object 1042 * 1043 * @param env Indicates the environment that the API is invoked under 1044 * @param userInputResult Indicates a js object to be converted 1045 * @param userInput Indicates a NotificationUserInput object from specified js object 1046 * @return Returns the null object if success, returns the null value otherwise 1047 */ 1048 static napi_value GetNotificationUserInputByEditType( 1049 const napi_env &env, const napi_value &userInputResult, std::shared_ptr<NotificationUserInput> &userInput); 1050 1051 /** 1052 * @brief Gets the additional data of NotificationUserInput object from specified js object 1053 * 1054 * @param env Indicates the environment that the API is invoked under 1055 * @param userInputResult Indicates a js object to be converted 1056 * @param userInput Indicates a NotificationUserInput object from specified js object 1057 * @return Returns the null object if success, returns the null value otherwise 1058 */ 1059 static napi_value GetNotificationUserInputByAdditionalData( 1060 const napi_env &env, const napi_value &userInputResult, std::shared_ptr<NotificationUserInput> &userInput); 1061 1062 /** 1063 * @brief Gets the small icon of NotificationRequest object from specified js object 1064 * 1065 * @param env Indicates the environment that the API is invoked under 1066 * @param value Indicates a js object to be converted 1067 * @param request Indicates a NotificationRequest object from specified js object 1068 * @return Returns the null object if success, returns the null value otherwise 1069 */ 1070 static napi_value GetNotificationSmallIcon( 1071 const napi_env &env, const napi_value &value, NotificationRequest &request); 1072 1073 /** 1074 * @brief Gets the large icon of NotificationRequest object from specified js object 1075 * 1076 * @param env Indicates the environment that the API is invoked under 1077 * @param value Indicates a js object to be converted 1078 * @param request Indicates a NotificationRequest object from specified js object 1079 * @return Returns the null object if success, returns the null value otherwise 1080 */ 1081 static napi_value GetNotificationLargeIcon( 1082 const napi_env &env, const napi_value &value, NotificationRequest &request); 1083 1084 /** 1085 * @brief Gets the distributed options of NotificationRequest object from specified js object 1086 * 1087 * @param env Indicates the environment that the API is invoked under 1088 * @param value Indicates a js object to be converted 1089 * @param request Indicates a NotificationRequest object from specified js object 1090 * @return Returns the null object if success, returns the null value otherwise 1091 */ 1092 static napi_value GetNotificationRequestDistributedOptions( 1093 const napi_env &env, const napi_value &value, NotificationRequest &request); 1094 1095 /** 1096 * @brief Gets the isDistributed flag of NotificationRequest object from specified js object 1097 * 1098 * @param env Indicates the environment that the API is invoked under 1099 * @param value Indicates a js object to be converted 1100 * @param request Indicates a NotificationRequest object from specified js object 1101 * @return Returns the null object if success, returns the null value otherwise 1102 */ 1103 static napi_value GetNotificationIsDistributed( 1104 const napi_env &env, const napi_value &value, NotificationRequest &request); 1105 1106 /** 1107 * @brief Gets the devices that support display of NotificationRequest object from specified js object 1108 * 1109 * @param env Indicates the environment that the API is invoked under 1110 * @param value Indicates a js object to be converted 1111 * @param request Indicates a NotificationRequest object from specified js object 1112 * @return Returns the null object if success, returns the null value otherwise 1113 */ 1114 static napi_value GetNotificationSupportDisplayDevices( 1115 const napi_env &env, const napi_value &value, NotificationRequest &request); 1116 1117 /** 1118 * @brief Gets the devices that support operation of NotificationRequest object from specified js object 1119 * 1120 * @param env Indicates the environment that the API is invoked under 1121 * @param value Indicates a js object to be converted 1122 * @param request Indicates a NotificationRequest object from specified js object 1123 * @return Returns the null object if success, returns the null value otherwise 1124 */ 1125 static napi_value GetNotificationSupportOperateDevices( 1126 const napi_env &env, const napi_value &value, NotificationRequest &request); 1127 1128 /** 1129 * @brief Gets a content type of notification from specified js object 1130 * 1131 * @param env Indicates the environment that the API is invoked under 1132 * @param value Indicates a js object to be converted 1133 * @param type Indicates a the content type of notification from specified js object 1134 * @return Returns the null object if success, returns the null value otherwise 1135 */ 1136 static napi_value GetNotificationContentType(const napi_env &env, const napi_value &result, int32_t &type); 1137 1138 /** 1139 * @brief Gets a basic content of NotificationRequest object from specified js object 1140 * 1141 * @param env Indicates the environment that the API is invoked under 1142 * @param value Indicates a js object to be converted 1143 * @param request Indicates a NotificationRequest object from specified js object 1144 * @return Returns the null object if success, returns the null value otherwise 1145 */ 1146 static napi_value GetNotificationBasicContent( 1147 const napi_env &env, const napi_value &result, NotificationRequest &request); 1148 1149 /** 1150 * @brief Gets a NotificationBasicContent object from specified js object 1151 * 1152 * @param env Indicates the environment that the API is invoked under 1153 * @param contentResult Indicates a js object to be converted 1154 * @param basicContent Indicates a NotificationBasicContent object from specified js object 1155 * @return Returns the null object if success, returns the null value otherwise 1156 */ 1157 static napi_value GetNotificationBasicContentDetailed( 1158 const napi_env &env, const napi_value &contentResult, std::shared_ptr<NotificationBasicContent> basicContent); 1159 1160 /** 1161 * @brief Gets a long-text content of NotificationRequest object from specified js object 1162 * 1163 * @param env Indicates the environment that the API is invoked under 1164 * @param value Indicates a js object to be converted 1165 * @param request Indicates a NotificationRequest object from specified js object 1166 * @return Returns the null object if success, returns the null value otherwise 1167 */ 1168 static napi_value GetNotificationLongTextContent( 1169 const napi_env &env, const napi_value &result, NotificationRequest &request); 1170 1171 /** 1172 * @brief Gets a NotificationLongTextContent object from specified js object 1173 * 1174 * @param env Indicates the environment that the API is invoked under 1175 * @param contentResult Indicates a js object to be converted 1176 * @param longContent Indicates a NotificationLongTextContent object from specified js object 1177 * @return Returns the null object if success, returns the null value otherwise 1178 */ 1179 static napi_value GetNotificationLongTextContentDetailed( 1180 const napi_env &env, const napi_value &contentResult, 1181 std::shared_ptr<OHOS::Notification::NotificationLongTextContent> &longContent); 1182 1183 /** 1184 * @brief Gets a picture content of NotificationRequest object from specified js object 1185 * 1186 * @param env Indicates the environment that the API is invoked under 1187 * @param result Indicates a js object to be converted 1188 * @param request Indicates a NotificationRequest object from specified js object 1189 * @return Returns the null object if success, returns the null value otherwise 1190 */ 1191 static napi_value GetNotificationPictureContent( 1192 const napi_env &env, const napi_value &result, NotificationRequest &request); 1193 1194 /** 1195 * @brief Gets a NotificationPictureContent object from specified js object 1196 * 1197 * @param env Indicates the environment that the API is invoked under 1198 * @param contentResult Indicates a js object to be converted 1199 * @param pictureContent Indicates a NotificationPictureContent object from specified js object 1200 * @return Returns the null object if success, returns the null value otherwise 1201 */ 1202 static napi_value GetNotificationPictureContentDetailed( 1203 const napi_env &env, const napi_value &contentResult, 1204 std::shared_ptr<OHOS::Notification::NotificationPictureContent> &pictureContent); 1205 1206 /** 1207 * @brief Gets a conversational content of NotificationRequest object from specified js object 1208 * 1209 * @param env Indicates the environment that the API is invoked under 1210 * @param result Indicates a js object to be converted 1211 * @param request Indicates a NotificationRequest object from specified js object 1212 * @return Returns the null object if success, returns the null value otherwise 1213 */ 1214 static napi_value GetNotificationConversationalContent( 1215 const napi_env &env, const napi_value &result, NotificationRequest &request); 1216 1217 /** 1218 * @brief Gets the user of NotificationConversationalContent object from specified js object 1219 * 1220 * @param env Indicates the environment that the API is invoked under 1221 * @param contentResult Indicates a js object to be converted 1222 * @param user Indicates a MessageUser object from specified js object 1223 * @return Returns the null object if success, returns the null value otherwise 1224 */ 1225 static napi_value GetNotificationConversationalContentByUser( 1226 const napi_env &env, const napi_value &contentResult, MessageUser &user); 1227 1228 /** 1229 * @brief Gets the title of NotificationConversationalContent object from specified js object 1230 * 1231 * @param env Indicates the environment that the API is invoked under 1232 * @param contentResult Indicates a js object to be converted 1233 * @param conversationalContent Indicates a NotificationConversationalContent object from specified js object 1234 * @return Returns the null object if success, returns the null value otherwise 1235 */ 1236 static napi_value GetNotificationConversationalContentTitle( 1237 const napi_env &env, const napi_value &contentResult, 1238 std::shared_ptr<OHOS::Notification::NotificationConversationalContent> &conversationalContent); 1239 1240 /** 1241 * @brief Gets the group of NotificationConversationalContent object from specified js object 1242 * 1243 * @param env Indicates the environment that the API is invoked under 1244 * @param contentResult Indicates a js object to be converted 1245 * @param conversationalContent Indicates a NotificationConversationalContent object from specified js object 1246 * @return Returns the null object if success, returns the null value otherwise 1247 */ 1248 static napi_value GetNotificationConversationalContentGroup( 1249 const napi_env &env, const napi_value &contentResult, 1250 std::shared_ptr<OHOS::Notification::NotificationConversationalContent> &conversationalContent); 1251 1252 /** 1253 * @brief Gets the messages of NotificationConversationalContent object from specified js object 1254 * 1255 * @param env Indicates the environment that the API is invoked under 1256 * @param contentResult Indicates a js object to be converted 1257 * @param conversationalContent Indicates a NotificationConversationalContent object from specified js object 1258 * @return Returns the null object if success, returns the null value otherwise 1259 */ 1260 static napi_value GetNotificationConversationalContentMessages( 1261 const napi_env &env, const napi_value &contentResult, 1262 std::shared_ptr<OHOS::Notification::NotificationConversationalContent> &conversationalContent); 1263 1264 /** 1265 * @brief Gets a NotificationConversationalMessage object from specified js object 1266 * 1267 * @param env Indicates the environment that the API is invoked under 1268 * @param conversationalMessage Indicates a js object to be converted 1269 * @param message Indicates a NotificationConversationalMessage object from specified js object 1270 * @return Returns the null object if success, returns the null value otherwise 1271 */ 1272 static napi_value GetConversationalMessage( 1273 const napi_env &env, const napi_value &conversationalMessage, 1274 std::shared_ptr<NotificationConversationalMessage> &message); 1275 1276 /** 1277 * @brief Gets the basic information of NotificationConversationalMessage object from specified js object 1278 * 1279 * @param env Indicates the environment that the API is invoked under 1280 * @param conversationalMessage Indicates a js object to be converted 1281 * @param message Indicates a NotificationConversationalMessage object from specified js object 1282 * @return Returns the null object if success, returns the null value otherwise 1283 */ 1284 static napi_value GetConversationalMessageBasicInfo( 1285 const napi_env &env, const napi_value &conversationalMessage, 1286 std::shared_ptr<NotificationConversationalMessage> &message); 1287 1288 /** 1289 * @brief Gets the other information of NotificationConversationalMessage object from specified js object 1290 * 1291 * @param env Indicates the environment that the API is invoked under 1292 * @param conversationalMessage Indicates a js object to be converted 1293 * @param message Indicates a NotificationConversationalMessage object from specified js object 1294 * @return Returns the null object if success, returns the null value otherwise 1295 */ 1296 static napi_value GetConversationalMessageOtherInfo( 1297 const napi_env &env, const napi_value &conversationalMessage, 1298 std::shared_ptr<NotificationConversationalMessage> &message); 1299 1300 /** 1301 * @brief Gets a MessageUser object from specified js object 1302 * 1303 * @param env Indicates the environment that the API is invoked under 1304 * @param result Indicates a js object to be converted 1305 * @param messageUser Indicates a MessageUser object from specified js object 1306 * @return Returns the null object if success, returns the null value otherwise 1307 */ 1308 static napi_value GetMessageUser(const napi_env &env, const napi_value &result, MessageUser &messageUser); 1309 1310 /** 1311 * @brief Gets a MessageUser object from specified js object 1312 * 1313 * @param env Indicates the environment that the API is invoked under 1314 * @param result Indicates a js object to be converted 1315 * @param messageUser Indicates a MessageUser object from specified js object 1316 * @return Returns the null object if success, returns the null value otherwise 1317 */ 1318 static napi_value GetMessageUserByString(const napi_env &env, const napi_value &result, MessageUser &messageUser); 1319 1320 /** 1321 * @brief Gets the bool objects of MessageUser object from specified js object 1322 * 1323 * @param env Indicates the environment that the API is invoked under 1324 * @param result Indicates a js object to be converted 1325 * @param messageUser Indicates a MessageUser object from specified js object 1326 * @return Returns the null object if success, returns the null value otherwise 1327 */ 1328 static napi_value GetMessageUserByBool(const napi_env &env, const napi_value &result, MessageUser &messageUser); 1329 1330 /** 1331 * @brief Gets the custom objects of MessageUser object from specified js object 1332 * 1333 * @param env Indicates the environment that the API is invoked under 1334 * @param result Indicates a js object to be converted 1335 * @param messageUser Indicates a MessageUser object from specified js object 1336 * @return Returns the null object if success, returns the null value otherwise 1337 */ 1338 static napi_value GetMessageUserByCustom(const napi_env &env, const napi_value &result, MessageUser &messageUser); 1339 1340 /** 1341 * @brief Gets the multi-line content of NotificationRequest object from specified js object 1342 * 1343 * @param env Indicates the environment that the API is invoked under 1344 * @param result Indicates a js object to be converted 1345 * @param request Indicates a NotificationRequest object from specified js object 1346 * @return Returns the null object if success, returns the null value otherwise 1347 */ 1348 static napi_value GetNotificationMultiLineContent( 1349 const napi_env &env, const napi_value &result, NotificationRequest &request); 1350 1351 /** 1352 * @brief Gets the lines of NotificationMultiLineContent object from specified js object 1353 * 1354 * @param env Indicates the environment that the API is invoked under 1355 * @param result Indicates a js object to be converted 1356 * @param multiLineContent Indicates a NotificationMultiLineContent object from specified js object 1357 * @return Returns the null object if success, returns the null value otherwise 1358 */ 1359 static napi_value GetNotificationMultiLineContentLines(const napi_env &env, const napi_value &result, 1360 std::shared_ptr<OHOS::Notification::NotificationMultiLineContent> &multiLineContent); 1361 1362 /** 1363 * @brief Gets a NotificationBundleOption object from specified js object 1364 * 1365 * @param env Indicates the environment that the API is invoked under 1366 * @param value Indicates a js object to be converted 1367 * @param option Indicates a NotificationBundleOption object from specified js object 1368 * @return Returns the null object if success, returns the null value otherwise 1369 */ 1370 static napi_value GetBundleOption(const napi_env &env, const napi_value &value, NotificationBundleOption &option); 1371 1372 static napi_value GetHashCodes(const napi_env &env, const napi_value &value, std::vector<std::string> &hashCodes); 1373 1374 /** 1375 * @brief Gets a NotificationKey object from specified js object 1376 * 1377 * @param env Indicates the environment that the API is invoked under 1378 * @param value Indicates a js object to be converted 1379 * @param key Indicates a NotificationKey object from specified js object 1380 * @return Returns the null object if success, returns the null value otherwise 1381 */ 1382 static napi_value GetNotificationKey(const napi_env &env, const napi_value &value, NotificationKey &key); 1383 1384 /** 1385 * @brief Converts content type from js to native 1386 * 1387 * @param inType Indicates a js ContentType object 1388 * @param outType Indicates a NotificationContent object 1389 * @return Returns true if success, returns false otherwise 1390 */ 1391 static bool ContentTypeJSToC(const ContentType &inType, NotificationContent::Type &outType); 1392 1393 /** 1394 * @brief Converts content type from native to js 1395 * 1396 * @param inType Indicates a NotificationContent object 1397 * @param outType Indicates a js ContentType object 1398 * @return Returns true if success, returns false otherwise 1399 */ 1400 static bool ContentTypeCToJS(const NotificationContent::Type &inType, ContentType &outType); 1401 1402 /** 1403 * @brief Converts slot type from js to native 1404 * 1405 * @param inType Indicates a native SlotType object 1406 * @param outType Indicates a js SlotType object 1407 * @return Returns true if success, returns false otherwise 1408 */ 1409 static bool SlotTypeJSToC(const SlotType &inType, NotificationConstant::SlotType &outType); 1410 1411 /** 1412 * @brief Converts slot type from native to js 1413 * 1414 * @param inType Indicates a js SlotType object 1415 * @param outType Indicates a native SlotType object 1416 * @return Returns true if success, returns false otherwise 1417 */ 1418 static bool SlotTypeCToJS(const NotificationConstant::SlotType &inType, SlotType &outType); 1419 1420 /** 1421 * @brief Converts slot level from js to native 1422 * 1423 * @param inType Indicates a native SlotLevel object 1424 * @param outType Indicates a js NotificationLevel object 1425 * @return Returns true if success, returns false otherwise 1426 */ 1427 static bool SlotLevelJSToC(const SlotLevel &inLevel, NotificationSlot::NotificationLevel &outLevel); 1428 1429 /** 1430 * @brief Converts slot level from native to js 1431 * 1432 * @param inType Indicates a js NotificationLevel object 1433 * @param outType Indicates a native SlotLevel object 1434 * @return Returns true if success, returns false otherwise 1435 */ 1436 static bool SlotLevelCToJS(const NotificationSlot::NotificationLevel &inLevel, SlotLevel &outLevel); 1437 1438 /** 1439 * @brief Converts reason type from native to js 1440 * 1441 * @param inType Indicates a native reason type 1442 * @param outType Indicates a js reason type 1443 * @return Returns true if success, returns false otherwise 1444 */ 1445 static bool ReasonCToJS(const int32_t &inType, int32_t &outType); 1446 1447 /** 1448 * @brief Converts do-not-disturb type from js to native 1449 * 1450 * @param inType Indicates a js DoNotDisturbType object 1451 * @param outType Indicates a native DoNotDisturbType object 1452 * @return Returns true if success, returns false otherwise 1453 */ 1454 static bool DoNotDisturbTypeJSToC(const DoNotDisturbType &inType, NotificationConstant::DoNotDisturbType &outType); 1455 1456 /** 1457 * @brief Converts do-not-disturb type from native to js 1458 * 1459 * @param inType Indicates a native DoNotDisturbType object 1460 * @param outType Indicates a js DoNotDisturbType object 1461 * @return Returns true if success, returns false otherwise 1462 */ 1463 static bool DoNotDisturbTypeCToJS(const NotificationConstant::DoNotDisturbType &inType, DoNotDisturbType &outType); 1464 1465 /** 1466 * @brief Converts remind type from native to js 1467 * 1468 * @param inType Indicates a native RemindType object 1469 * @param outType Indicates a js DeviceRemindType object 1470 * @return Returns true if success, returns false otherwise 1471 */ 1472 static bool DeviceRemindTypeCToJS(const NotificationConstant::RemindType &inType, DeviceRemindType &outType); 1473 1474 /** 1475 * @brief Converts source type from native to js 1476 * 1477 * @param inType Indicates a native SourceType object 1478 * @param outType Indicates a js SourceType object 1479 * @return Returns true if success, returns false otherwise 1480 */ 1481 static bool SourceTypeCToJS(const NotificationConstant::SourceType &inType, SourceType &outType); 1482 1483 /** 1484 * @brief Creates a js object from specified WantAgent object 1485 * 1486 * @param env Indicates the environment that the API is invoked under 1487 * @param agent Indicates specified WantAgent object 1488 * @return Returns a js object from specified WantAgent object 1489 */ 1490 static napi_value CreateWantAgentByJS(const napi_env &env, 1491 const std::shared_ptr<AbilityRuntime::WantAgent::WantAgent> &agent); 1492 1493 /** 1494 * @brief Gets the template of NotificationRequest object from specified js object 1495 * 1496 * @param env Indicates the environment that the API is invoked under 1497 * @param value Indicates a js object to be converted 1498 * @param request Indicates a NotificationRequest object from specified js object 1499 * @return Returns the null object if success, returns the null value otherwise 1500 */ 1501 static napi_value GetNotificationTemplate( 1502 const napi_env &env, const napi_value &value, NotificationRequest &request); 1503 1504 /** 1505 * @brief Gets a NotificationTemplate object from specified js object 1506 * 1507 * @param env Indicates the environment that the API is invoked under 1508 * @param value Indicates a js object to be converted 1509 * @param templ Indicates a NotificationTemplate object from specified js object 1510 * @return Returns the null object if success, returns the null value otherwise 1511 */ 1512 static napi_value GetNotificationTemplateInfo(const napi_env &env, const napi_value &value, 1513 std::shared_ptr<NotificationTemplate> &templ); 1514 1515 /** 1516 * @brief Sets a js object by specified NotificationTemplate object 1517 * 1518 * @param env Indicates the environment that the API is invoked under 1519 * @param templ Indicates a NotificationTemplate object to be converted 1520 * @param result Indicates a js object to be set 1521 * @return Returns the null object if success, returns the null value otherwise 1522 */ 1523 static napi_value SetNotificationTemplateInfo( 1524 const napi_env &env, const std::shared_ptr<NotificationTemplate> &templ, napi_value &result); 1525 1526 /** 1527 * @brief Sets a js object by specified NotificationFlags object 1528 * 1529 * @param env Indicates the environment that the API is invoked under 1530 * @param flags Indicates a NotificationFlags object to be converted 1531 * @param result Indicates a js object to be set 1532 * @return Returns the null object if success, returns the null value otherwise 1533 */ 1534 static napi_value SetNotificationFlags( 1535 const napi_env &env, const std::shared_ptr<NotificationFlags> &flags, napi_value &result); 1536 1537 /** 1538 * @brief Gets the number of badge of NotificationRequest object from specified js object 1539 * 1540 * @param env Indicates the environment that the API is invoked under 1541 * @param value Indicates a js object to be converted 1542 * @param request Indicates a NotificationRequest object from specified js object 1543 * @return Returns the null object if success, returns the null value otherwise 1544 */ 1545 static napi_value GetNotificationBadgeNumber( 1546 const napi_env &env, const napi_value &value, NotificationRequest &request); 1547 1548 /** 1549 * @brief Create a napi value with specified error object for callback 1550 * 1551 * @param env Indicates the environment that the API is invoked under 1552 * @param errCode Indicates specified err code 1553 * @return Returns a napi value with specified error object for callback 1554 */ 1555 static napi_value CreateErrorValue(napi_env env, int32_t errCode, bool newType); 1556 1557 /** 1558 * @brief Sets a js object by specified BadgeNumberCallbackData object 1559 * 1560 * @param env Indicates the environment that the API is invoked under 1561 * @param date Indicates a BadgeNumberCallbackData object to be converted 1562 * @param result Indicates a js object to be set 1563 * @return Returns the null object if success, returns the null value otherwise 1564 */ 1565 static napi_value SetBadgeCallbackData(const napi_env &env, 1566 const BadgeNumberCallbackData &data, napi_value &result); 1567 1568 static bool IsValidRemoveReason(int32_t reasonType); 1569 static void NapiThrow(napi_env env, int32_t errCode); 1570 static int32_t ErrorToExternal(uint32_t errCode); 1571 static void CreateReturnValue(const napi_env &env, const CallbackPromiseInfo &info, const napi_value &result); 1572 1573 private: 1574 static const int32_t ARGS_ONE = 1; 1575 static const int32_t ARGS_TWO = 2; 1576 static const int32_t ONLY_CALLBACK_MAX_PARA = 1; 1577 static const int32_t ONLY_CALLBACK_MIN_PARA = 0; 1578 static std::set<std::shared_ptr<AbilityRuntime::WantAgent::WantAgent>> wantAgent_; 1579 }; 1580 } // namespace NotificationNapi 1581 } // namespace OHOS 1582 1583 #endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_FRAMEWORKS_JS_NAPI_INCLUDE_COMMON_H