1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #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_button_option.h" 22 #include "notification_helper.h" 23 #include "notification_local_live_view_button.h" 24 #include "notification_progress.h" 25 #include "notification_time.h" 26 27 namespace OHOS { 28 namespace NotificationNapi { 29 using namespace OHOS::Notification; 30 31 constexpr int32_t STR_MAX_SIZE = 200; 32 constexpr int32_t LONG_STR_MAX_SIZE = 1024; 33 constexpr int8_t NO_ERROR = 0; 34 constexpr int8_t ERROR = -1; 35 constexpr uint8_t PARAM0 = 0; 36 constexpr uint8_t PARAM1 = 1; 37 constexpr uint8_t PARAM2 = 2; 38 constexpr uint8_t PARAM3 = 3; 39 constexpr uint8_t PARAM4 = 4; 40 41 enum class ContentType { 42 NOTIFICATION_CONTENT_BASIC_TEXT, 43 NOTIFICATION_CONTENT_LONG_TEXT, 44 NOTIFICATION_CONTENT_PICTURE, 45 NOTIFICATION_CONTENT_CONVERSATION, 46 NOTIFICATION_CONTENT_MULTILINE, 47 NOTIFICATION_CONTENT_LOCAL_LIVE_VIEW, 48 NOTIFICATION_CONTENT_LIVE_VIEW 49 }; 50 51 enum class SlotType { 52 UNKNOWN_TYPE = 0, 53 SOCIAL_COMMUNICATION = 1, 54 SERVICE_INFORMATION = 2, 55 CONTENT_INFORMATION = 3, 56 LIVE_VIEW = 4, 57 CUSTOMER_SERVICE = 5, 58 OTHER_TYPES = 0xFFFF, 59 }; 60 61 enum class SlotLevel { 62 LEVEL_NONE = 0, 63 LEVEL_MIN = 1, 64 LEVEL_LOW = 2, 65 LEVEL_DEFAULT = 3, 66 LEVEL_HIGH = 4, 67 }; 68 69 enum class RemoveReason { 70 CLICK_REASON_REMOVE = 1, 71 CANCEL_REASON_REMOVE = 2, 72 CANCEL_ALL_REASON_REMOVE = 3, 73 ERROR_REASON_REMOVE = 4, 74 PACKAGE_CHANGED_REASON_REMOVE = 5, 75 USER_STOPPED_REASON_REMOVE = 6, 76 PACKAGE_BANNED_REASON_REMOVE = 7, 77 APP_CANCEL_REASON_REMOVE = 8, 78 APP_CANCEL_ALL_REASON_REMOVE = 9, 79 APP_CANCEL_REASON_OTHER = 10, 80 }; 81 82 enum class SemanticActionButton { 83 NONE_ACTION_BUTTON, 84 REPLY_ACTION_BUTTON, 85 READ_ACTION_BUTTON, 86 UNREAD_ACTION_BUTTON, 87 DELETE_ACTION_BUTTON, 88 ARCHIVE_ACTION_BUTTON, 89 MUTE_ACTION_BUTTON, 90 UNMUTE_ACTION_BUTTON, 91 THUMBS_UP_ACTION_BUTTON, 92 THUMBS_DOWN_ACTION_BUTTON, 93 CALL_ACTION_BUTTON 94 }; 95 96 enum class InputsSource { 97 FREE_FORM_INPUT, 98 OPTION 99 }; 100 101 enum class DisturbMode { 102 ALLOW_UNKNOWN, 103 ALLOW_ALL, 104 ALLOW_PRIORITY, 105 ALLOW_NONE, 106 ALLOW_ALARMS 107 }; 108 109 enum class InputEditType { 110 EDIT_AUTO, 111 EDIT_DISABLED, 112 EDIT_ENABLED 113 }; 114 115 enum class DoNotDisturbType { 116 TYPE_NONE, TYPE_ONCE, 117 TYPE_DAILY, TYPE_CLEARLY 118 }; 119 120 enum class SourceType { 121 TYPE_NORMAL = 0x00000000, 122 TYPE_CONTINUOUS = 0x00000001, 123 TYPE_TIMER = 0x00000002 124 }; 125 126 enum class DeviceRemindType { 127 IDLE_DONOT_REMIND, 128 IDLE_REMIND, 129 ACTIVE_DONOT_REMIND, 130 ACTIVE_REMIND 131 }; 132 133 enum class NotificationFlagStatus { 134 TYPE_NONE, 135 TYPE_OPEN, 136 TYPE_CLOSE 137 }; 138 139 enum class LiveViewStatus { 140 LIVE_VIEW_CREATE, 141 LIVE_VIEW_INCREMENTAL_UPDATE, 142 LIVE_VIEW_END, 143 LIVE_VIEW_FULL_UPDATE, 144 LIVE_VIEW_BUTT 145 }; 146 147 struct NotificationSubscribeInfo { 148 std::vector<std::string> bundleNames; 149 int32_t userId = 0; 150 bool hasSubscribeInfo = false; 151 }; 152 153 struct CallbackPromiseInfo { 154 napi_ref callback = nullptr; 155 napi_deferred deferred = nullptr; 156 bool isCallback = false; 157 int32_t errorCode = 0; 158 }; 159 160 class Common { 161 Common(); 162 163 ~Common(); 164 165 public: 166 /** 167 * @brief Gets a napi value that is used to represent specified bool value 168 * 169 * @param env Indicates the environment that the API is invoked under 170 * @param isValue Indicates a bool value 171 * @return Returns a napi value that is used to represent specified bool value 172 */ 173 static napi_value NapiGetBoolean(napi_env env, const bool &isValue); 174 175 /** 176 * @brief Gets the napi value that is used to represent the null object 177 * 178 * @param env Indicates the environment that the API is invoked under 179 * @return Returns the napi value that is used to represent the null object 180 */ 181 static napi_value NapiGetNull(napi_env env); 182 183 /** 184 * @brief Gets the napi value that is used to represent the undefined object 185 * 186 * @param env Indicates the environment that the API is invoked under 187 * @return Returns the napi value that is used to represent the undefined object 188 */ 189 static napi_value NapiGetUndefined(napi_env env); 190 191 /** 192 * @brief Gets a napi value with specified error code for callback 193 * 194 * @param env Indicates the environment that the API is invoked under 195 * @param errCode Indicates specified err code 196 * @return Returns a napi value with specified error code for callback 197 */ 198 static napi_value GetCallbackErrorValue(napi_env env, int32_t errCode); 199 200 /** 201 * @brief Pads the CallbackPromiseInfo struct 202 * 203 * @param env Indicates the environment that the API is invoked under 204 * @param callback Indicates a napi_ref for callback 205 * @param info Indicates the CallbackPromiseInfo struct to be padded 206 * @param promise Indicates the promise to be created when the callback is null 207 */ 208 static void PaddingCallbackPromiseInfo( 209 const napi_env &env, const napi_ref &callback, CallbackPromiseInfo &info, napi_value &promise); 210 211 /** 212 * @brief Gets the returned result by the CallbackPromiseInfo struct 213 * 214 * @param env Indicates the environment that the API is invoked under 215 * @param info Indicates the CallbackPromiseInfo struct 216 * @param result Indicates the returned result 217 */ 218 static void ReturnCallbackPromise(const napi_env &env, const CallbackPromiseInfo &info, const napi_value &result); 219 220 /** 221 * @brief Calls the callback with the result and error code 222 * 223 * @param env Indicates the environment that the API is invoked under 224 * @param callbackIn Indicates the callback to be called 225 * @param errCode Indicates the error code returned by the callback 226 * @param result Indicates the result returned by the callback 227 */ 228 static void SetCallback(const napi_env &env, 229 const napi_ref &callbackIn, const int32_t &errorCode, const napi_value &result, bool newType); 230 231 /** 232 * @brief Calls the callback with the result 233 * 234 * @param env Indicates the environment that the API is invoked under 235 * @param callbackIn Indicates the callback to be called 236 * @param result Indicates the result returned by the callback 237 */ 238 static void SetCallback( 239 const napi_env &env, const napi_ref &callbackIn, const napi_value &result); 240 241 /** 242 * @brief Calls the callback with the result 243 * 244 * @param env Indicates the environment that the API is invoked under 245 * @param callbackIn Indicates the callback to be called 246 * @param result Indicates the result returned by the callback 247 */ 248 static void SetCallbackArg2( 249 const napi_env &env, const napi_ref &callbackIn, const napi_value &result0, const napi_value &result1); 250 251 /** 252 * @brief Processes the promise with the result and error code 253 * 254 * @param env Indicates the environment that the API is invoked under 255 * @param deferred Indicates the deferred object whose associated promise to resolve 256 * @param errorCode Indicates the error code returned by the callback 257 * @param result Indicates the result returned by the callback 258 */ 259 static void SetPromise(const napi_env &env, 260 const napi_deferred &deferred, const int32_t &errorCode, const napi_value &result, bool newType); 261 262 /** 263 * @brief Gets the returned result by the callback when an error occurs 264 * 265 * @param env Indicates the environment that the API is invoked under 266 * @param callback Indicates a napi_ref for callback 267 * @return Returns the null object 268 */ 269 static napi_value JSParaError(const napi_env &env, const napi_ref &callback); 270 271 /** 272 * @brief Parses a single parameter for callback 273 * 274 * @param env Indicates the environment that the API is invoked under 275 * @param info Indicates the callback info passed into the callback function 276 * @param callback Indicates the napi_ref for the callback parameter 277 * @return Returns the null object if success, returns the null value otherwise 278 */ 279 static napi_value ParseParaOnlyCallback(const napi_env &env, const napi_callback_info &info, napi_ref &callback); 280 281 /** 282 * @brief Sets a js object by specified Notification object 283 * 284 * @param env Indicates the environment that the API is invoked under 285 * @param notification Indicates a Notification 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 SetNotification( 290 const napi_env &env, const OHOS::Notification::Notification *notification, napi_value &result); 291 292 /** 293 * @brief Sets a js object by 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 SetNotificationRequest( 301 const napi_env &env, const OHOS::Notification::NotificationRequest *request, napi_value &result); 302 303 /** 304 * @brief Sets a js object by the string 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 SetNotificationRequestByString( 312 const napi_env &env, const OHOS::Notification::NotificationRequest *request, napi_value &result); 313 314 /** 315 * @brief Sets a js object by the number obejcts 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 SetNotificationRequestByNumber( 323 const napi_env &env, const OHOS::Notification::NotificationRequest *request, napi_value &result); 324 325 /** 326 * @brief Sets a js object by the bool obejcts 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 SetNotificationRequestByBool( 334 const napi_env &env, const OHOS::Notification::NotificationRequest *request, napi_value &result); 335 336 /** 337 * @brief Sets a js object by the WantAgent obejct 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 SetNotificationRequestByWantAgent( 345 const napi_env &env, const OHOS::Notification::NotificationRequest *request, napi_value &result); 346 347 /** 348 * @brief Sets a js object by the PixelMap obejct of specified NotificationRequest object 349 * 350 * @param env Indicates the environment that the API is invoked under 351 * @param request Indicates a NotificationRequest 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 SetNotificationRequestByPixelMap( 356 const napi_env &env, const OHOS::Notification::NotificationRequest *request, napi_value &result); 357 358 /** 359 * @brief Sets a js object by the custom obejcts of specified NotificationRequest object 360 * 361 * @param env Indicates the environment that the API is invoked under 362 * @param request Indicates a NotificationRequest 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 SetNotificationRequestByCustom( 367 const napi_env &env, const OHOS::Notification::NotificationRequest *request, napi_value &result); 368 369 /** 370 * @brief Sets a js object by the Distributed Options object of specified Notification object 371 * 372 * @param env Indicates the environment that the API is invoked under 373 * @param notification Indicates a Notification 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 SetNotificationByDistributedOptions( 378 const napi_env &env, const OHOS::Notification::Notification *notification, napi_value &result); 379 380 /** 381 * @brief Sets a js object by specified NotificationSortingMap object 382 * 383 * @param env Indicates the environment that the API is invoked under 384 * @param sortingMap Indicates a NotificationSortingMap 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 SetNotificationSortingMap( 389 const napi_env &env, const std::shared_ptr<NotificationSortingMap> &sortingMap, napi_value &result); 390 391 /** 392 * @brief Sets a js object by specified NotificationSorting object 393 * 394 * @param env Indicates the environment that the API is invoked under 395 * @param sorting Indicates a NotificationSorting object to be converted 396 * @param result Indicates a js object to be set 397 * @return Returns the null object if success, returns the null value otherwise 398 */ 399 static napi_value SetNotificationSorting( 400 const napi_env &env, const NotificationSorting &sorting, napi_value &result); 401 402 /** 403 * @brief Sets a js object by specified NotificationSlot object 404 * 405 * @param env Indicates the environment that the API is invoked under 406 * @param slot Indicates a NotificationSlot 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 SetNotificationSlot(const napi_env &env, const NotificationSlot &slot, napi_value &result); 411 412 /** 413 * @brief Sets a js object by specified NotificationContent object 414 * 415 * @param env Indicates the environment that the API is invoked under 416 * @param content Indicates a NotificationContent object to be converted 417 * @param result Indicates a js object to be set 418 * @return Returns the null object if success, returns the null value otherwise 419 */ 420 static napi_value SetNotificationContent( 421 const napi_env &env, const std::shared_ptr<NotificationContent> &content, napi_value &result); 422 423 /** 424 * @brief Sets a js object by the object of specified type in specified NotificationContent object 425 * 426 * @param env Indicates the environment that the API is invoked under 427 * @param type Indicates the content type 428 * @param content Indicates a NotificationContent 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 SetNotificationContentDetailed(const napi_env &env, const ContentType &type, 433 const std::shared_ptr<NotificationContent> &content, napi_value &result); 434 435 /** 436 * @brief Sets a js NotificationBasicContent 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 SetNotificationBasicContent( 444 const napi_env &env, const NotificationBasicContent *basicContent, napi_value &result); 445 446 /** 447 * @brief Sets a js NotificationLongTextContent 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 SetNotificationLongTextContent( 455 const napi_env &env, NotificationBasicContent *basicContent, napi_value &result); 456 457 /** 458 * @brief Sets a js NotificationPictureContent 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 SetNotificationPictureContent( 466 const napi_env &env, NotificationBasicContent *basicContent, napi_value &result); 467 468 /** 469 * @brief Sets a js NotificationConversationalContent object by specified NotificationBasicContent object 470 * 471 * @param env Indicates the environment that the API is invoked under 472 * @param basicContent Indicates a NotificationBasicContent 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 SetNotificationConversationalContent(const napi_env &env, 477 NotificationBasicContent *basicContent, napi_value &result); 478 479 /** 480 * @brief Sets a js NotificationMultiLineContent object by specified NotificationBasicContent object 481 * 482 * @param env Indicates the environment that the API is invoked under 483 * @param basicContent Indicates a NotificationBasicContent object to be converted 484 * @param result Indicates a js object to be set 485 * @return Returns the null object if success, returns the null value otherwise 486 */ 487 static napi_value SetNotificationMultiLineContent( 488 const napi_env &env, NotificationBasicContent *basicContent, napi_value &result); 489 490 /** 491 * @brief Sets a js NotificationLocalLiveViewContent object by specified NotificationBasicContent object 492 * 493 * @param env Indicates the environment that the API is invoked under 494 * @param basicContent Indicates a NotificationBasicContent object to be converted 495 * @param result Indicates a js object to be set 496 * @return Returns the null object if success, returns the null value otherwise 497 */ 498 static napi_value SetNotificationLocalLiveViewContent( 499 const napi_env &env, NotificationBasicContent *basicContent, napi_value &result); 500 501 /** 502 * @brief Sets a js object by specified NotificationCapsule object 503 * 504 * @param env Indicates the environment that the API is invoked under 505 * @param capsule Indicates a NotificationCapsule object to be converted 506 * @param result Indicates a js object to be set 507 * @return Returns the null object if success, returns the null value otherwise 508 */ 509 static napi_value SetCapsule(const napi_env &env, const NotificationCapsule &capsule, napi_value &result); 510 511 /** 512 * @brief Sets a js object by specified NotificationLocalLiveViewButton object 513 * 514 * @param env Indicates the environment that the API is invoked under 515 * @param capsule Indicates a NotificationLocalLiveViewButton 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 SetButton(const napi_env &env, const NotificationLocalLiveViewButton &button, napi_value &result); 520 521 /** 522 * @brief Sets a js object by specified NotificationProgress object 523 * 524 * @param env Indicates the environment that the API is invoked under 525 * @param capsule Indicates a NotificationProgress object to be converted 526 * @param result Indicates a js object to be set 527 * @return Returns the null object if success, returns the null value otherwise 528 */ 529 static napi_value SetProgress(const napi_env &env, const NotificationProgress &progress, napi_value &result); 530 531 /** 532 * @brief Sets a js object by specified NotificationTime object 533 * 534 * @param env Indicates the environment that the API is invoked under 535 * @param time Indicates a NotificationTime object to be converted 536 * @param result Indicates a js object to be set 537 * @return Returns the null object if success, returns the null value otherwise 538 */ 539 static napi_value SetTime(const napi_env &env, const NotificationTime &time, napi_value &result); 540 541 /** 542 * @brief Sets a js NotificationLiveViewContent object by specified NotificationBasicContent object 543 * 544 * @param env Indicates the environment that the API is invoked under 545 * @param basicContent Indicates a NotificationBasicContent object to be converted 546 * @param result Indicates a js object to be set 547 * @return Returns the null object if success, returns the null value otherwise 548 */ 549 static napi_value SetNotificationLiveViewContent( 550 const napi_env &env, NotificationBasicContent *basicContent, napi_value &result); 551 552 /** 553 * @brief Sets a js liveview picturemap object by specified liveview picturemap 554 * 555 * @param env Indicates the environment that the API is invoked under 556 * @param pictureMap Indicates a picturemap object to be converted 557 * @return Returns the null object if success, returns the null value otherwise 558 */ 559 static napi_value SetLiveViewPictureInfo( 560 const napi_env &env, const std::map<std::string, std::vector<std::shared_ptr<Media::PixelMap>>> &pictureMap); 561 562 /** 563 * @brief Sets a js object by specified MessageUser object 564 * 565 * @param env Indicates the environment that the API is invoked under 566 * @param messageUser Indicates a MessageUser object to be converted 567 * @param result Indicates a js object to be set 568 * @return Returns the null object if success, returns the null value otherwise 569 */ 570 static napi_value SetMessageUser(const napi_env &env, const MessageUser &messageUser, napi_value &result); 571 572 /** 573 * @brief Sets a js object by specified NotificationConversationalContent object 574 * 575 * @param env Indicates the environment that the API is invoked under 576 * @param conversationalContent Indicates a NotificationConversationalContent object to be converted 577 * @param arr Indicates a js object to be set 578 * @return Returns the null object if success, returns the null value otherwise 579 */ 580 static napi_value SetConversationalMessages(const napi_env &env, 581 const OHOS::Notification::NotificationConversationalContent *conversationalContent, napi_value &arr); 582 583 /** 584 * @brief Sets a js object by specified NotificationConversationalMessage object 585 * 586 * @param env Indicates the environment that the API is invoked under 587 * @param conversationalMessage Indicates a NotificationConversationalMessage object to be converted 588 * @param result Indicates a js object to be set 589 * @return Returns the null object if success, returns the null value otherwise 590 */ 591 static napi_value SetConversationalMessage(const napi_env &env, 592 const std::shared_ptr<NotificationConversationalMessage> &conversationalMessage, napi_value &result); 593 594 /** 595 * @brief Sets a js object by specified NotificationActionButton object 596 * 597 * @param env Indicates the environment that the API is invoked under 598 * @param actionButton Indicates a NotificationActionButton object to be converted 599 * @param result Indicates a js object to be set 600 * @return Returns the null object if success, returns the null value otherwise 601 */ 602 static napi_value SetNotificationActionButton( 603 const napi_env &env, const std::shared_ptr<NotificationActionButton> &actionButton, napi_value &result); 604 605 /** 606 * @brief Sets a js object by the extra objects of specified NotificationActionButton object 607 * 608 * @param env Indicates the environment that the API is invoked under 609 * @param actionButton Indicates a NotificationActionButton object to be converted 610 * @param result Indicates a js object to be set 611 * @return Returns the null object if success, returns the null value otherwise 612 */ 613 static napi_value SetNotificationActionButtonByExtras( 614 const napi_env &env, const std::shared_ptr<NotificationActionButton> &actionButton, napi_value &result); 615 616 /** 617 * @brief Sets a js object by specified NotificationUserInput object 618 * 619 * @param env Indicates the environment that the API is invoked under 620 * @param userInput Indicates a NotificationUserInput object to be converted 621 * @param result Indicates a js object to be set 622 * @return Returns the null object if success, returns the null value otherwise 623 */ 624 static napi_value SetNotificationActionButtonByUserInput( 625 const napi_env &env, const std::shared_ptr<NotificationUserInput> &userInput, napi_value &result); 626 627 /** 628 * @brief Sets a js object by specified NotificationDoNotDisturbDate object 629 * 630 * @param env Indicates the environment that the API is invoked under 631 * @param date Indicates a NotificationDoNotDisturbDate object to be converted 632 * @param result Indicates a js object to be set 633 * @return Returns the null object if success, returns the null value otherwise 634 */ 635 static napi_value SetDoNotDisturbDate( 636 const napi_env &env, const NotificationDoNotDisturbDate &date, napi_value &result); 637 638 /** 639 * @brief Sets a js object by specified EnabledNotificationCallbackData object 640 * 641 * @param env Indicates the environment that the API is invoked under 642 * @param date Indicates a EnabledNotificationCallbackData object to be converted 643 * @param result Indicates a js object to be set 644 * @return Returns the null object if success, returns the null value otherwise 645 */ 646 static napi_value SetEnabledNotificationCallbackData(const napi_env &env, 647 const EnabledNotificationCallbackData &data, napi_value &result); 648 649 /** 650 * @brief Gets a NotificationSubscribeInfo object from specified js object 651 * 652 * @param env Indicates the environment that the API is invoked under 653 * @param value Indicates a js object to be converted 654 * @param result Indicates a NotificationSubscribeInfo object from specified js object 655 * @return Returns the null object if success, returns the null value otherwise 656 */ 657 static napi_value GetNotificationSubscriberInfo( 658 const napi_env &env, const napi_value &value, NotificationSubscribeInfo &result); 659 660 /** 661 * @brief Gets a NotificationRequest object from specified js object 662 * 663 * @param env Indicates the environment that the API is invoked under 664 * @param value Indicates a js object to be converted 665 * @param result Indicates a NotificationRequest object from specified js object 666 * @return Returns the null object if success, returns the null value otherwise 667 */ 668 static napi_value GetNotificationRequest( 669 const napi_env &env, const napi_value &value, NotificationRequest &request); 670 671 /** 672 * @brief Gets a NotificationRequest object by number type from specified js object 673 * 674 * @param env Indicates the environment that the API is invoked under 675 * @param value Indicates a js object to be converted 676 * @param request Indicates a NotificationRequest object from specified js object 677 * @return Returns the null object if success, returns the null value otherwise 678 */ 679 static napi_value GetNotificationRequestByNumber( 680 const napi_env &env, const napi_value &value, NotificationRequest &request); 681 682 /** 683 * @brief Gets a NotificationRequest object by string type from specified js object 684 * 685 * @param env Indicates the environment that the API is invoked under 686 * @param value Indicates a js object to be converted 687 * @param request Indicates a NotificationRequest object from specified js object 688 * @return Returns the null object if success, returns the null value otherwise 689 */ 690 static napi_value GetNotificationRequestByString( 691 const napi_env &env, const napi_value &value, NotificationRequest &request); 692 693 /** 694 * @brief Gets a NotificationRequest object by bool type from specified js object 695 * 696 * @param env Indicates the environment that the API is invoked under 697 * @param value Indicates a js object to be converted 698 * @param request Indicates a NotificationRequest object from specified js object 699 * @return Returns the null object if success, returns the null value otherwise 700 */ 701 static napi_value GetNotificationRequestByBool( 702 const napi_env &env, const napi_value &value, NotificationRequest &request); 703 704 /** 705 * @brief Gets a NotificationRequest object by custom type from specified js object 706 * 707 * @param env Indicates the environment that the API is invoked under 708 * @param value Indicates a js object to be converted 709 * @param request Indicates a NotificationRequest object from specified js object 710 * @return Returns the null object if success, returns the null value otherwise 711 */ 712 static napi_value GetNotificationRequestByCustom( 713 const napi_env &env, const napi_value &value, NotificationRequest &request); 714 715 /** 716 * @brief Gets the id of NotificationRequest object from specified js object 717 * 718 * @param env Indicates the environment that the API is invoked under 719 * @param value Indicates a js object to be converted 720 * @param request Indicates a NotificationRequest object from specified js object 721 * @return Returns the null object if success, returns the null value otherwise 722 */ 723 static napi_value GetNotificationId(const napi_env &env, const napi_value &value, NotificationRequest &request); 724 725 /** 726 * @brief Gets the slot type of NotificationRequest object from specified js object 727 * 728 * @param env Indicates the environment that the API is invoked under 729 * @param value Indicates a js object to be converted 730 * @param request Indicates a NotificationRequest object from specified js object 731 * @return Returns the null object if success, returns the null value otherwise 732 */ 733 static napi_value GetNotificationSlotType( 734 const napi_env &env, const napi_value &value, NotificationRequest &request); 735 736 /** 737 * @brief Gets the isOngoing flag of NotificationRequest object from specified js object 738 * 739 * @param env Indicates the environment that the API is invoked under 740 * @param value Indicates a js object to be converted 741 * @param request Indicates a NotificationRequest object from specified js object 742 * @return Returns the null object if success, returns the null value otherwise 743 */ 744 static napi_value GetNotificationIsOngoing( 745 const napi_env &env, const napi_value &value, NotificationRequest &request); 746 747 /** 748 * @brief Gets the isUnremovable flag of NotificationRequest object from specified js object 749 * 750 * @param env Indicates the environment that the API is invoked under 751 * @param value Indicates a js object to be converted 752 * @param request Indicates a NotificationRequest object from specified js object 753 * @return Returns the null object if success, returns the null value otherwise 754 */ 755 static napi_value GetNotificationIsUnremovable( 756 const napi_env &env, const napi_value &value, NotificationRequest &request); 757 758 /** 759 * @brief Gets the delivery time of NotificationRequest object from specified js object 760 * 761 * @param env Indicates the environment that the API is invoked under 762 * @param value Indicates a js object to be converted 763 * @param request Indicates a NotificationRequest object from specified js object 764 * @return Returns the null object if success, returns the null value otherwise 765 */ 766 static napi_value GetNotificationDeliveryTime( 767 const napi_env &env, const napi_value &value, NotificationRequest &request); 768 769 /** 770 * @brief Gets the tapDismissed flag of NotificationRequest object from specified js object 771 * 772 * @param env Indicates the environment that the API is invoked under 773 * @param value Indicates a js object to be converted 774 * @param request Indicates a NotificationRequest object from specified js object 775 * @return Returns the null object if success, returns the null value otherwise 776 */ 777 static napi_value GetNotificationtapDismissed( 778 const napi_env &env, const napi_value &value, NotificationRequest &request); 779 780 /** 781 * @brief Gets the extra information of NotificationRequest object from specified js object 782 * 783 * @param env Indicates the environment that the API is invoked under 784 * @param value Indicates a js object to be converted 785 * @param request Indicates a NotificationRequest object from specified js object 786 * @return Returns the null object if success, returns the null value otherwise 787 */ 788 static napi_value GetNotificationExtraInfo( 789 const napi_env &env, const napi_value &value, NotificationRequest &request); 790 791 /** 792 * @brief Gets the group name of NotificationRequest object from specified js object 793 * 794 * @param env Indicates the environment that the API is invoked under 795 * @param value Indicates a js object to be converted 796 * @param request Indicates a NotificationRequest object from specified js object 797 * @return Returns the null object if success, returns the null value otherwise 798 */ 799 static napi_value GetNotificationGroupName( 800 const napi_env &env, const napi_value &value, NotificationRequest &request); 801 802 /** 803 * @brief Gets the removal WantAgent object of NotificationRequest object from specified js object 804 * 805 * @param env Indicates the environment that the API is invoked under 806 * @param value Indicates a js object to be converted 807 * @param request Indicates a NotificationRequest object from specified js object 808 * @return Returns the null object if success, returns the null value otherwise 809 */ 810 static napi_value GetNotificationRemovalWantAgent( 811 const napi_env &env, const napi_value &value, NotificationRequest &request); 812 813 /** 814 * @brief Gets the max screen WantAgent object of NotificationRequest object from specified js object 815 * 816 * @param env Indicates the environment that the API is invoked under 817 * @param value Indicates a js object to be converted 818 * @param request Indicates a NotificationRequest object from specified js object 819 * @return Returns the null object if success, returns the null value otherwise 820 */ 821 static napi_value GetNotificationMaxScreenWantAgent( 822 const napi_env &env, const napi_value &value, NotificationRequest &request); 823 824 /** 825 * @brief Gets the auto deleted time of NotificationRequest object from specified js object 826 * 827 * @param env Indicates the environment that the API is invoked under 828 * @param value Indicates a js object to be converted 829 * @param request Indicates a NotificationRequest object from specified js object 830 * @return Returns the null object if success, returns the null value otherwise 831 */ 832 static napi_value GetNotificationAutoDeletedTime( 833 const napi_env &env, const napi_value &value, NotificationRequest &request); 834 835 /** 836 * @brief Gets the classification of NotificationRequest object from specified js object 837 * 838 * @param env Indicates the environment that the API is invoked under 839 * @param value Indicates a js object to be converted 840 * @param request Indicates a NotificationRequest object from specified js object 841 * @return Returns the null object if success, returns the null value otherwise 842 */ 843 static napi_value GetNotificationClassification( 844 const napi_env &env, const napi_value &value, NotificationRequest &request); 845 846 /** 847 * @brief Gets the color of NotificationRequest object from specified js object 848 * 849 * @param env Indicates the environment that the API is invoked under 850 * @param value Indicates a js object to be converted 851 * @param request Indicates a NotificationRequest object from specified js object 852 * @return Returns the null object if success, returns the null value otherwise 853 */ 854 static napi_value GetNotificationColor(const napi_env &env, const napi_value &value, NotificationRequest &request); 855 856 /** 857 * @brief Gets the colorEnabled flag of NotificationRequest object from specified js object 858 * 859 * @param env Indicates the environment that the API is invoked under 860 * @param value Indicates a js object to be converted 861 * @param request Indicates a NotificationRequest object from specified js object 862 * @return Returns the null object if success, returns the null value otherwise 863 */ 864 static napi_value GetNotificationColorEnabled( 865 const napi_env &env, const napi_value &value, NotificationRequest &request); 866 867 /** 868 * @brief Gets the isAlertOnce flag of NotificationRequest object from specified js object 869 * 870 * @param env Indicates the environment that the API is invoked under 871 * @param value Indicates a js object to be converted 872 * @param request Indicates a NotificationRequest object from specified js object 873 * @return Returns the null object if success, returns the null value otherwise 874 */ 875 static napi_value GetNotificationIsAlertOnce( 876 const napi_env &env, const napi_value &value, NotificationRequest &request); 877 878 /** 879 * @brief Gets the isStopwatch flag of NotificationRequest object from specified js object 880 * 881 * @param env Indicates the environment that the API is invoked under 882 * @param value Indicates a js object to be converted 883 * @param request Indicates a NotificationRequest object from specified js object 884 * @return Returns the null object if success, returns the null value otherwise 885 */ 886 static napi_value GetNotificationIsStopwatch( 887 const napi_env &env, const napi_value &value, NotificationRequest &request); 888 889 /** 890 * @brief Gets the isCountDown flag of NotificationRequest object from specified js object 891 * 892 * @param env Indicates the environment that the API is invoked under 893 * @param value Indicates a js object to be converted 894 * @param request Indicates a NotificationRequest object from specified js object 895 * @return Returns the null object if success, returns the null value otherwise 896 */ 897 static napi_value GetNotificationIsCountDown( 898 const napi_env &env, const napi_value &value, NotificationRequest &request); 899 900 /** 901 * @brief Gets the status bar text of NotificationRequest object from specified js object 902 * 903 * @param env Indicates the environment that the API is invoked under 904 * @param value Indicates a js object to be converted 905 * @param request Indicates a NotificationRequest object from specified js object 906 * @return Returns the null object if success, returns the null value otherwise 907 */ 908 static napi_value GetNotificationStatusBarText( 909 const napi_env &env, const napi_value &value, NotificationRequest &request); 910 911 /** 912 * @brief Gets the label of NotificationRequest object from specified js object 913 * 914 * @param env Indicates the environment that the API is invoked under 915 * @param value Indicates a js object to be converted 916 * @param request Indicates a NotificationRequest object from specified js object 917 * @return Returns the null object if success, returns the null value otherwise 918 */ 919 static napi_value GetNotificationLabel(const napi_env &env, const napi_value &value, NotificationRequest &request); 920 921 /** 922 * @brief Gets the badge icon style of NotificationRequest object from specified js object 923 * 924 * @param env Indicates the environment that the API is invoked under 925 * @param value Indicates a js object to be converted 926 * @param request Indicates a NotificationRequest object from specified js object 927 * @return Returns the null object if success, returns the null value otherwise 928 */ 929 static napi_value GetNotificationBadgeIconStyle( 930 const napi_env &env, const napi_value &value, NotificationRequest &request); 931 932 /** 933 * @brief Gets the showDeliveryTime flag of NotificationRequest object from specified js object 934 * 935 * @param env Indicates the environment that the API is invoked under 936 * @param value Indicates a js object to be converted 937 * @param request Indicates a NotificationRequest object from specified js object 938 * @return Returns the null object if success, returns the null value otherwise 939 */ 940 static napi_value GetNotificationShowDeliveryTime( 941 const napi_env &env, const napi_value &value, NotificationRequest &request); 942 943 944 static napi_value GetNotificationIsRemoveAllowed( 945 const napi_env &env, const napi_value &value, NotificationRequest &request); 946 947 /** 948 * @brief Gets the content of NotificationRequest object from specified js object 949 * 950 * @param env Indicates the environment that the API is invoked under 951 * @param value Indicates a js object to be converted 952 * @param request Indicates a NotificationRequest object from specified js object 953 * @return Returns the null object if success, returns the null value otherwise 954 */ 955 static napi_value GetNotificationContent( 956 const napi_env &env, const napi_value &value, NotificationRequest &request); 957 958 /** 959 * @brief Gets the WantAgent object of NotificationRequest object from specified js object 960 * 961 * @param env Indicates the environment that the API is invoked under 962 * @param value Indicates a js object to be converted 963 * @param request Indicates a NotificationRequest object from specified js object 964 * @return Returns the null object if success, returns the null value otherwise 965 */ 966 static napi_value GetNotificationWantAgent( 967 const napi_env &env, const napi_value &value, NotificationRequest &request); 968 969 /** 970 * @brief Gets a NotificationSlot object from specified js object 971 * 972 * @param env Indicates the environment that the API is invoked under 973 * @param value Indicates a js object to be converted 974 * @param slot Indicates a NotificationSlot object from specified js object 975 * @return Returns the null object if success, returns the null value otherwise 976 */ 977 static napi_value GetNotificationSlot( 978 const napi_env &env, const napi_value &value, NotificationSlot &slot); 979 980 /** 981 * @brief Gets the string objects of NotificationSlot object from specified js object 982 * 983 * @param env Indicates the environment that the API is invoked under 984 * @param value Indicates a js object to be converted 985 * @param slot Indicates a NotificationSlot object from specified js object 986 * @return Returns the null object if success, returns the null value otherwise 987 */ 988 static napi_value GetNotificationSlotByString( 989 const napi_env &env, const napi_value &value, NotificationSlot &slot); 990 991 /** 992 * @brief Gets the bool objects of NotificationSlot object from specified js object 993 * 994 * @param env Indicates the environment that the API is invoked under 995 * @param value Indicates a js object to be converted 996 * @param slot Indicates a NotificationSlot object from specified js object 997 * @return Returns the null object if success, returns the null value otherwise 998 */ 999 static napi_value GetNotificationSlotByBool( 1000 const napi_env &env, const napi_value &value, NotificationSlot &slot); 1001 1002 /** 1003 * @brief Gets the number objects of NotificationSlot object from specified js object 1004 * 1005 * @param env Indicates the environment that the API is invoked under 1006 * @param value Indicates a js object to be converted 1007 * @param slot Indicates a NotificationSlot object from specified js object 1008 * @return Returns the null object if success, returns the null value otherwise 1009 */ 1010 static napi_value GetNotificationSlotByNumber( 1011 const napi_env &env, const napi_value &value, NotificationSlot &slot); 1012 1013 /** 1014 * @brief Gets the vibration of NotificationSlot object from specified js object 1015 * 1016 * @param env Indicates the environment that the API is invoked under 1017 * @param value Indicates a js object to be converted 1018 * @param slot Indicates a NotificationSlot object from specified js object 1019 * @return Returns the null object if success, returns the null value otherwise 1020 */ 1021 static napi_value GetNotificationSlotByVibration( 1022 const napi_env &env, const napi_value &value, NotificationSlot &slot); 1023 1024 /** 1025 * @brief Gets the action buttons of NotificationRequest object from specified js object 1026 * 1027 * @param env Indicates the environment that the API is invoked under 1028 * @param value Indicates a js object to be converted 1029 * @param request Indicates a NotificationRequest object from specified js object 1030 * @return Returns the null object if success, returns the null value otherwise 1031 */ 1032 static napi_value GetNotificationActionButtons( 1033 const napi_env &env, const napi_value &value, NotificationRequest &request); 1034 1035 /** 1036 * @brief Gets a NotificationActionButton object from specified js object 1037 * 1038 * @param env Indicates the environment that the API is invoked under 1039 * @param actionButton Indicates a js object to be converted 1040 * @param pActionButton Indicates a NotificationActionButton object from specified js object 1041 * @return Returns the null object if success, returns the null value otherwise 1042 */ 1043 static napi_value GetNotificationActionButtonsDetailed( 1044 const napi_env &env, const napi_value &actionButton, std::shared_ptr<NotificationActionButton> &pActionButton); 1045 1046 /** 1047 * @brief Gets the basic information of NotificationActionButton object from specified js object 1048 * 1049 * @param env Indicates the environment that the API is invoked under 1050 * @param actionButton Indicates a js object to be converted 1051 * @param pActionButton Indicates a NotificationActionButton object from specified js object 1052 * @return Returns the null object if success, returns the null value otherwise 1053 */ 1054 static napi_value GetNotificationActionButtonsDetailedBasicInfo( 1055 const napi_env &env, const napi_value &actionButton, std::shared_ptr<NotificationActionButton> &pActionButton); 1056 1057 /** 1058 * @brief Gets the extras of NotificationActionButton object from specified js object 1059 * 1060 * @param env Indicates the environment that the API is invoked under 1061 * @param actionButton Indicates a js object to be converted 1062 * @param pActionButton Indicates a NotificationActionButton object from specified js object 1063 * @return Returns the null object if success, returns the null value otherwise 1064 */ 1065 static napi_value GetNotificationActionButtonsDetailedByExtras( 1066 const napi_env &env, const napi_value &actionButton, std::shared_ptr<NotificationActionButton> &pActionButton); 1067 1068 /** 1069 * @brief Gets the user input of NotificationActionButton object from specified js object 1070 * 1071 * @param env Indicates the environment that the API is invoked under 1072 * @param actionButton Indicates a js object to be converted 1073 * @param pActionButton Indicates a NotificationActionButton object from specified js object 1074 * @return Returns the null object if success, returns the null value otherwise 1075 */ 1076 static napi_value GetNotificationUserInput( 1077 const napi_env &env, const napi_value &actionButton, std::shared_ptr<NotificationActionButton> &pActionButton); 1078 1079 /** 1080 * @brief Gets the input key of NotificationUserInput object from specified js object 1081 * 1082 * @param env Indicates the environment that the API is invoked under 1083 * @param userInputResult Indicates a js object to be converted 1084 * @param userInput Indicates a NotificationUserInput object from specified js object 1085 * @return Returns the null object if success, returns the null value otherwise 1086 */ 1087 static napi_value GetNotificationUserInputByInputKey( 1088 const napi_env &env, const napi_value &userInputResult, std::shared_ptr<NotificationUserInput> &userInput); 1089 1090 /** 1091 * @brief Gets the tag of NotificationUserInput object from specified js object 1092 * 1093 * @param env Indicates the environment that the API is invoked under 1094 * @param userInputResult Indicates a js object to be converted 1095 * @param userInput Indicates a NotificationUserInput object from specified js object 1096 * @return Returns the null object if success, returns the null value otherwise 1097 */ 1098 static napi_value GetNotificationUserInputByTag( 1099 const napi_env &env, const napi_value &userInputResult, std::shared_ptr<NotificationUserInput> &userInput); 1100 1101 /** 1102 * @brief Gets the options of NotificationUserInput object from specified js object 1103 * 1104 * @param env Indicates the environment that the API is invoked under 1105 * @param userInputResult Indicates a js object to be converted 1106 * @param userInput Indicates a NotificationUserInput object from specified js object 1107 * @return Returns the null object if success, returns the null value otherwise 1108 */ 1109 static napi_value GetNotificationUserInputByOptions( 1110 const napi_env &env, const napi_value &userInputResult, std::shared_ptr<NotificationUserInput> &userInput); 1111 1112 /** 1113 * @brief Gets the permit mime types of NotificationUserInput object from specified js object 1114 * 1115 * @param env Indicates the environment that the API is invoked under 1116 * @param userInputResult Indicates a js object to be converted 1117 * @param userInput Indicates a NotificationUserInput object from specified js object 1118 * @return Returns the null object if success, returns the null value otherwise 1119 */ 1120 static napi_value GetNotificationUserInputByPermitMimeTypes( 1121 const napi_env &env, const napi_value &userInputResult, std::shared_ptr<NotificationUserInput> &userInput); 1122 1123 /** 1124 * @brief Gets the permit free from input of NotificationUserInput object from specified js object 1125 * 1126 * @param env Indicates the environment that the API is invoked under 1127 * @param userInputResult Indicates a js object to be converted 1128 * @param userInput Indicates a NotificationUserInput object from specified js object 1129 * @return Returns the null object if success, returns the null value otherwise 1130 */ 1131 static napi_value GetNotificationUserInputByPermitFreeFormInput( 1132 const napi_env &env, const napi_value &userInputResult, std::shared_ptr<NotificationUserInput> &userInput); 1133 1134 /** 1135 * @brief Gets the edit type of NotificationUserInput object from specified js object 1136 * 1137 * @param env Indicates the environment that the API is invoked under 1138 * @param userInputResult Indicates a js object to be converted 1139 * @param userInput Indicates a NotificationUserInput object from specified js object 1140 * @return Returns the null object if success, returns the null value otherwise 1141 */ 1142 static napi_value GetNotificationUserInputByEditType( 1143 const napi_env &env, const napi_value &userInputResult, std::shared_ptr<NotificationUserInput> &userInput); 1144 1145 /** 1146 * @brief Gets the additional data of NotificationUserInput object from specified js object 1147 * 1148 * @param env Indicates the environment that the API is invoked under 1149 * @param userInputResult Indicates a js object to be converted 1150 * @param userInput Indicates a NotificationUserInput object from specified js object 1151 * @return Returns the null object if success, returns the null value otherwise 1152 */ 1153 static napi_value GetNotificationUserInputByAdditionalData( 1154 const napi_env &env, const napi_value &userInputResult, std::shared_ptr<NotificationUserInput> &userInput); 1155 1156 /** 1157 * @brief Gets the small icon 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 GetNotificationSmallIcon( 1165 const napi_env &env, const napi_value &value, NotificationRequest &request); 1166 1167 /** 1168 * @brief Gets the large icon of NotificationRequest object from specified js object 1169 * 1170 * @param env Indicates the environment that the API is invoked under 1171 * @param value Indicates a js object to be converted 1172 * @param request Indicates a NotificationRequest object from specified js object 1173 * @return Returns the null object if success, returns the null value otherwise 1174 */ 1175 static napi_value GetNotificationLargeIcon( 1176 const napi_env &env, const napi_value &value, NotificationRequest &request); 1177 1178 /** 1179 * @brief Gets the overlay icon of NotificationRequest object from specified js object 1180 * 1181 * @param env Indicates the environment that the API is invoked under 1182 * @param value Indicates a js object to be converted 1183 * @param request Indicates a NotificationRequest object from specified js object 1184 * @return Returns the null object if success, returns the null value otherwise 1185 */ 1186 static napi_value GetNotificationOverlayIcon( 1187 const napi_env &env, const napi_value &value, NotificationRequest &request); 1188 1189 /** 1190 * @brief Gets the distributed options of NotificationRequest object from specified js object 1191 * 1192 * @param env Indicates the environment that the API is invoked under 1193 * @param value Indicates a js object to be converted 1194 * @param request Indicates a NotificationRequest object from specified js object 1195 * @return Returns the null object if success, returns the null value otherwise 1196 */ 1197 static napi_value GetNotificationRequestDistributedOptions( 1198 const napi_env &env, const napi_value &value, NotificationRequest &request); 1199 1200 /** 1201 * @brief Gets the isDistributed flag of NotificationRequest object from specified js object 1202 * 1203 * @param env Indicates the environment that the API is invoked under 1204 * @param value Indicates a js object to be converted 1205 * @param request Indicates a NotificationRequest object from specified js object 1206 * @return Returns the null object if success, returns the null value otherwise 1207 */ 1208 static napi_value GetNotificationIsDistributed( 1209 const napi_env &env, const napi_value &value, NotificationRequest &request); 1210 1211 /** 1212 * @brief Gets the devices that support display of NotificationRequest object from specified js object 1213 * 1214 * @param env Indicates the environment that the API is invoked under 1215 * @param value Indicates a js object to be converted 1216 * @param request Indicates a NotificationRequest object from specified js object 1217 * @return Returns the null object if success, returns the null value otherwise 1218 */ 1219 static napi_value GetNotificationSupportDisplayDevices( 1220 const napi_env &env, const napi_value &value, NotificationRequest &request); 1221 1222 /** 1223 * @brief Gets the devices that support operation of NotificationRequest object from specified js object 1224 * 1225 * @param env Indicates the environment that the API is invoked under 1226 * @param value Indicates a js object to be converted 1227 * @param request Indicates a NotificationRequest object from specified js object 1228 * @return Returns the null object if success, returns the null value otherwise 1229 */ 1230 static napi_value GetNotificationSupportOperateDevices( 1231 const napi_env &env, const napi_value &value, NotificationRequest &request); 1232 1233 /** 1234 * @brief Gets a content type of notification from specified js object 1235 * 1236 * @param env Indicates the environment that the API is invoked under 1237 * @param value Indicates a js object to be converted 1238 * @param type Indicates a the content type of notification from specified js object 1239 * @return Returns the null object if success, returns the null value otherwise 1240 */ 1241 static napi_value GetNotificationContentType(const napi_env &env, const napi_value &result, int32_t &type); 1242 1243 /** 1244 * @brief Gets a basic content of NotificationRequest object from specified js object 1245 * 1246 * @param env Indicates the environment that the API is invoked under 1247 * @param value Indicates a js object to be converted 1248 * @param request Indicates a NotificationRequest object from specified js object 1249 * @return Returns the null object if success, returns the null value otherwise 1250 */ 1251 static napi_value GetNotificationBasicContent( 1252 const napi_env &env, const napi_value &result, NotificationRequest &request); 1253 1254 /** 1255 * @brief Gets a NotificationBasicContent object from specified js object 1256 * 1257 * @param env Indicates the environment that the API is invoked under 1258 * @param contentResult Indicates a js object to be converted 1259 * @param basicContent Indicates a NotificationBasicContent object from specified js object 1260 * @return Returns the null object if success, returns the null value otherwise 1261 */ 1262 static napi_value GetNotificationBasicContentDetailed( 1263 const napi_env &env, const napi_value &contentResult, std::shared_ptr<NotificationBasicContent> basicContent); 1264 1265 /** 1266 * @brief Gets a long-text content of NotificationRequest object from specified js object 1267 * 1268 * @param env Indicates the environment that the API is invoked under 1269 * @param value Indicates a js object to be converted 1270 * @param request Indicates a NotificationRequest object from specified js object 1271 * @return Returns the null object if success, returns the null value otherwise 1272 */ 1273 static napi_value GetNotificationLongTextContent( 1274 const napi_env &env, const napi_value &result, NotificationRequest &request); 1275 1276 /** 1277 * @brief Gets a NotificationLongTextContent object from specified js object 1278 * 1279 * @param env Indicates the environment that the API is invoked under 1280 * @param contentResult Indicates a js object to be converted 1281 * @param longContent Indicates a NotificationLongTextContent object from specified js object 1282 * @return Returns the null object if success, returns the null value otherwise 1283 */ 1284 static napi_value GetNotificationLongTextContentDetailed( 1285 const napi_env &env, const napi_value &contentResult, 1286 std::shared_ptr<OHOS::Notification::NotificationLongTextContent> &longContent); 1287 1288 /** 1289 * @brief Gets a picture content of NotificationRequest object from specified js object 1290 * 1291 * @param env Indicates the environment that the API is invoked under 1292 * @param result Indicates a js object to be converted 1293 * @param request Indicates a NotificationRequest object from specified js object 1294 * @return Returns the null object if success, returns the null value otherwise 1295 */ 1296 static napi_value GetNotificationPictureContent( 1297 const napi_env &env, const napi_value &result, NotificationRequest &request); 1298 1299 /** 1300 * @brief Gets a NotificationPictureContent object from specified js object 1301 * 1302 * @param env Indicates the environment that the API is invoked under 1303 * @param contentResult Indicates a js object to be converted 1304 * @param pictureContent Indicates a NotificationPictureContent object from specified js object 1305 * @return Returns the null object if success, returns the null value otherwise 1306 */ 1307 static napi_value GetNotificationPictureContentDetailed( 1308 const napi_env &env, const napi_value &contentResult, 1309 std::shared_ptr<OHOS::Notification::NotificationPictureContent> &pictureContent); 1310 1311 /** 1312 * @brief Gets a NotificationLocalLiveViewContent object from specified js object 1313 * 1314 * @param env Indicates the environment that the API is invoked under 1315 * @param result Indicates a js object to be converted 1316 * @param request Indicates a NotificationLocalLiveViewContent object from specified js object 1317 * @return Returns the null object if success, returns the null value otherwise 1318 */ 1319 static napi_value GetNotificationLocalLiveViewContent( 1320 const napi_env &env, const napi_value &result, NotificationRequest &request); 1321 1322 /** 1323 * @brief Gets a capsule of NotificationLocalLiveViewContent object from specified js object 1324 * 1325 * @param env Indicates the environment that the API is invoked under 1326 * @param contentResult Indicates a js object to be converted 1327 * @param content Indicates a capsule object from specified js object 1328 * @return Returns the null object if success, returns the null value otherwise 1329 */ 1330 static napi_value GetNotificationLocalLiveViewCapsule( 1331 const napi_env &env, const napi_value &contentResult, 1332 std::shared_ptr<OHOS::Notification::NotificationLocalLiveViewContent> content); 1333 1334 /** 1335 * @brief Gets a button of NotificationLocalLiveViewContent object from specified js object 1336 * 1337 * @param env Indicates the environment that the API is invoked under 1338 * @param contentResult Indicates a js object to be converted 1339 * @param content Indicates a button object from specified js object 1340 * @return Returns the null object if success, returns the null value otherwise 1341 */ 1342 static napi_value GetNotificationLocalLiveViewButton( 1343 const napi_env &env, const napi_value &contentResult, 1344 std::shared_ptr<OHOS::Notification::NotificationLocalLiveViewContent> content); 1345 1346 /** 1347 * @brief Gets a time of NotificationLocalLiveViewContent object from specified js object 1348 * 1349 * @param env Indicates the environment that the API is invoked under 1350 * @param contentResult Indicates a js object to be converted 1351 * @param content Indicates a time object from specified js object 1352 * @return Returns the null object if success, returns the null value otherwise 1353 */ 1354 static napi_value GetNotificationLocalLiveViewTime( 1355 const napi_env &env, const napi_value &contentResult, 1356 std::shared_ptr<OHOS::Notification::NotificationLocalLiveViewContent> content); 1357 1358 /** 1359 * @brief Gets a progress of NotificationLocalLiveViewContent object from specified js object 1360 * 1361 * @param env Indicates the environment that the API is invoked under 1362 * @param contentResult Indicates a js object to be converted 1363 * @param content Indicates a progress object from specified js object 1364 * @return Returns the null object if success, returns the null value otherwise 1365 */ 1366 static napi_value GetNotificationLocalLiveViewProgress( 1367 const napi_env &env, const napi_value &contentResult, 1368 std::shared_ptr<OHOS::Notification::NotificationLocalLiveViewContent> content); 1369 1370 /** 1371 * @brief Gets a NotificationLocalLiveViewContent object from specified js object 1372 * 1373 * @param env Indicates the environment that the API is invoked under 1374 * @param contentResult Indicates a js object to be converted 1375 * @param content Indicates a NotificationLocalLiveViewContent object from specified js object 1376 * @return Returns the null object if success, returns the null value otherwise 1377 */ 1378 static napi_value GetNotificationLocalLiveViewContentDetailed( 1379 const napi_env &env, const napi_value &contentResult, 1380 std::shared_ptr<OHOS::Notification::NotificationLocalLiveViewContent> content); 1381 1382 /** 1383 * @brief Gets a conversational content of NotificationRequest object from specified js object 1384 * 1385 * @param env Indicates the environment that the API is invoked under 1386 * @param result Indicates a js object to be converted 1387 * @param request Indicates a NotificationRequest object from specified js object 1388 * @return Returns the null object if success, returns the null value otherwise 1389 */ 1390 static napi_value GetNotificationConversationalContent( 1391 const napi_env &env, const napi_value &result, NotificationRequest &request); 1392 1393 /** 1394 * @brief Gets the user of NotificationConversationalContent object from specified js object 1395 * 1396 * @param env Indicates the environment that the API is invoked under 1397 * @param contentResult Indicates a js object to be converted 1398 * @param user Indicates a MessageUser object from specified js object 1399 * @return Returns the null object if success, returns the null value otherwise 1400 */ 1401 static napi_value GetNotificationConversationalContentByUser( 1402 const napi_env &env, const napi_value &contentResult, MessageUser &user); 1403 1404 /** 1405 * @brief Gets the title of NotificationConversationalContent object from specified js object 1406 * 1407 * @param env Indicates the environment that the API is invoked under 1408 * @param contentResult Indicates a js object to be converted 1409 * @param conversationalContent Indicates a NotificationConversationalContent object from specified js object 1410 * @return Returns the null object if success, returns the null value otherwise 1411 */ 1412 static napi_value GetNotificationConversationalContentTitle( 1413 const napi_env &env, const napi_value &contentResult, 1414 std::shared_ptr<OHOS::Notification::NotificationConversationalContent> &conversationalContent); 1415 1416 /** 1417 * @brief Gets the group of NotificationConversationalContent object from specified js object 1418 * 1419 * @param env Indicates the environment that the API is invoked under 1420 * @param contentResult Indicates a js object to be converted 1421 * @param conversationalContent Indicates a NotificationConversationalContent object from specified js object 1422 * @return Returns the null object if success, returns the null value otherwise 1423 */ 1424 static napi_value GetNotificationConversationalContentGroup( 1425 const napi_env &env, const napi_value &contentResult, 1426 std::shared_ptr<OHOS::Notification::NotificationConversationalContent> &conversationalContent); 1427 1428 /** 1429 * @brief Gets the messages of NotificationConversationalContent object from specified js object 1430 * 1431 * @param env Indicates the environment that the API is invoked under 1432 * @param contentResult Indicates a js object to be converted 1433 * @param conversationalContent Indicates a NotificationConversationalContent object from specified js object 1434 * @return Returns the null object if success, returns the null value otherwise 1435 */ 1436 static napi_value GetNotificationConversationalContentMessages( 1437 const napi_env &env, const napi_value &contentResult, 1438 std::shared_ptr<OHOS::Notification::NotificationConversationalContent> &conversationalContent); 1439 1440 /** 1441 * @brief Gets a NotificationConversationalMessage object from specified js object 1442 * 1443 * @param env Indicates the environment that the API is invoked under 1444 * @param conversationalMessage Indicates a js object to be converted 1445 * @param message Indicates a NotificationConversationalMessage object from specified js object 1446 * @return Returns the null object if success, returns the null value otherwise 1447 */ 1448 static napi_value GetConversationalMessage( 1449 const napi_env &env, const napi_value &conversationalMessage, 1450 std::shared_ptr<NotificationConversationalMessage> &message); 1451 1452 /** 1453 * @brief Gets the basic information of NotificationConversationalMessage object from specified js object 1454 * 1455 * @param env Indicates the environment that the API is invoked under 1456 * @param conversationalMessage Indicates a js object to be converted 1457 * @param message Indicates a NotificationConversationalMessage object from specified js object 1458 * @return Returns the null object if success, returns the null value otherwise 1459 */ 1460 static napi_value GetConversationalMessageBasicInfo( 1461 const napi_env &env, const napi_value &conversationalMessage, 1462 std::shared_ptr<NotificationConversationalMessage> &message); 1463 1464 /** 1465 * @brief Gets the other information of NotificationConversationalMessage object from specified js object 1466 * 1467 * @param env Indicates the environment that the API is invoked under 1468 * @param conversationalMessage Indicates a js object to be converted 1469 * @param message Indicates a NotificationConversationalMessage object from specified js object 1470 * @return Returns the null object if success, returns the null value otherwise 1471 */ 1472 static napi_value GetConversationalMessageOtherInfo( 1473 const napi_env &env, const napi_value &conversationalMessage, 1474 std::shared_ptr<NotificationConversationalMessage> &message); 1475 1476 /** 1477 * @brief Gets a MessageUser object from specified js object 1478 * 1479 * @param env Indicates the environment that the API is invoked under 1480 * @param result Indicates a js object to be converted 1481 * @param messageUser Indicates a MessageUser object from specified js object 1482 * @return Returns the null object if success, returns the null value otherwise 1483 */ 1484 static napi_value GetMessageUser(const napi_env &env, const napi_value &result, MessageUser &messageUser); 1485 1486 /** 1487 * @brief Gets a MessageUser object from specified js object 1488 * 1489 * @param env Indicates the environment that the API is invoked under 1490 * @param result Indicates a js object to be converted 1491 * @param messageUser Indicates a MessageUser object from specified js object 1492 * @return Returns the null object if success, returns the null value otherwise 1493 */ 1494 static napi_value GetMessageUserByString(const napi_env &env, const napi_value &result, MessageUser &messageUser); 1495 1496 /** 1497 * @brief Gets the bool objects of MessageUser object from specified js object 1498 * 1499 * @param env Indicates the environment that the API is invoked under 1500 * @param result Indicates a js object to be converted 1501 * @param messageUser Indicates a MessageUser object from specified js object 1502 * @return Returns the null object if success, returns the null value otherwise 1503 */ 1504 static napi_value GetMessageUserByBool(const napi_env &env, const napi_value &result, MessageUser &messageUser); 1505 1506 /** 1507 * @brief Gets the custom objects of MessageUser object from specified js object 1508 * 1509 * @param env Indicates the environment that the API is invoked under 1510 * @param result Indicates a js object to be converted 1511 * @param messageUser Indicates a MessageUser object from specified js object 1512 * @return Returns the null object if success, returns the null value otherwise 1513 */ 1514 static napi_value GetMessageUserByCustom(const napi_env &env, const napi_value &result, MessageUser &messageUser); 1515 1516 /** 1517 * @brief Gets the multi-line content of NotificationRequest object from specified js object 1518 * 1519 * @param env Indicates the environment that the API is invoked under 1520 * @param result Indicates a js object to be converted 1521 * @param request Indicates a NotificationRequest object from specified js object 1522 * @return Returns the null object if success, returns the null value otherwise 1523 */ 1524 static napi_value GetNotificationMultiLineContent( 1525 const napi_env &env, const napi_value &result, NotificationRequest &request); 1526 1527 /** 1528 * @brief Gets the lines of NotificationMultiLineContent object from specified js object 1529 * 1530 * @param env Indicates the environment that the API is invoked under 1531 * @param result Indicates a js object to be converted 1532 * @param multiLineContent Indicates a NotificationMultiLineContent object from specified js object 1533 * @return Returns the null object if success, returns the null value otherwise 1534 */ 1535 static napi_value GetNotificationMultiLineContentLines(const napi_env &env, const napi_value &result, 1536 std::shared_ptr<OHOS::Notification::NotificationMultiLineContent> &multiLineContent); 1537 1538 /** 1539 * @brief Gets the liveView content of NotificationRequest object from specified js object 1540 * 1541 * @param env Indicates the environment that the API is invoked under 1542 * @param result Indicates a js object to be converted 1543 * @param request Indicates a NotificationRequest object from specified js object 1544 * @return Returns the null object if success, returns the null value otherwise 1545 */ 1546 static napi_value GetNotificationLiveViewContent( 1547 const napi_env &env, const napi_value &result, NotificationRequest &request); 1548 1549 /** 1550 * @brief Gets a NotificationLiveViewContent object from specified js object 1551 * 1552 * @param env Indicates the environment that the API is invoked under 1553 * @param contentResult Indicates a js object to be converted 1554 * @param liveViewContent Indicates a NotificationMultiLineContent object from specified js object 1555 * @return Returns the null object if success, returns the null value otherwise 1556 */ 1557 static napi_value GetNotificationLiveViewContentDetailed(const napi_env &env, const napi_value &contentResult, 1558 std::shared_ptr<NotificationLiveViewContent> &liveViewContent); 1559 1560 /** 1561 * @brief Gets a GetLiveViewPictures from specified js object 1562 * 1563 * @param env Indicates the environment that the API is invoked under 1564 * @param picturesObj Indicates a js object to be converted 1565 * @param pictures Indicates pictures object from specified js object 1566 * @return Returns the null object if success, returns the null value otherwise 1567 */ 1568 static napi_value GetLiveViewPictures(const napi_env &env, const napi_value &picturesObj, 1569 std::vector<std::shared_ptr<Media::PixelMap>> &pictures); 1570 1571 /** 1572 * @brief Gets a GetLiveViewPictures from specified js object 1573 * 1574 * @param env Indicates the environment that the API is invoked under 1575 * @param pictureMapObj Indicates a js object to be converted 1576 * @param pictureMap Indicates picturemap from specified js object 1577 * @return Returns the null object if success, returns the null value otherwise 1578 */ 1579 static napi_value GetLiveViewPictureInfo(const napi_env &env, const napi_value &pictureMapObj, 1580 std::map<std::string, std::vector<std::shared_ptr<Media::PixelMap>>> &pictureMap); 1581 1582 /** 1583 * @brief Gets a NotificationBundleOption object from specified js object 1584 * 1585 * @param env Indicates the environment that the API is invoked under 1586 * @param value Indicates a js object to be converted 1587 * @param option Indicates a NotificationBundleOption object from specified js object 1588 * @return Returns the null object if success, returns the null value otherwise 1589 */ 1590 static napi_value GetBundleOption(const napi_env &env, const napi_value &value, NotificationBundleOption &option); 1591 1592 /** 1593 * @brief Gets a NotificationButtonOption object from specified js object 1594 * 1595 * @param env Indicates the environment that the API is invoked under 1596 * @param value Indicates a js object to be converted 1597 * @param option Indicates a NotificationButtonOption object from specified js object 1598 * @return Returns the null object if success, returns the null value otherwise 1599 */ 1600 static napi_value GetButtonOption(const napi_env &env, const napi_value &value, NotificationButtonOption &option); 1601 1602 static napi_value GetHashCodes(const napi_env &env, const napi_value &value, std::vector<std::string> &hashCodes); 1603 1604 /** 1605 * @brief Gets a NotificationKey object from specified js object 1606 * 1607 * @param env Indicates the environment that the API is invoked under 1608 * @param value Indicates a js object to be converted 1609 * @param key Indicates a NotificationKey object from specified js object 1610 * @return Returns the null object if success, returns the null value otherwise 1611 */ 1612 static napi_value GetNotificationKey(const napi_env &env, const napi_value &value, NotificationKey &key); 1613 1614 /** 1615 * @brief Converts content type from js to native 1616 * 1617 * @param inType Indicates a js ContentType object 1618 * @param outType Indicates a NotificationContent object 1619 * @return Returns true if success, returns false otherwise 1620 */ 1621 static bool ContentTypeJSToC(const ContentType &inType, NotificationContent::Type &outType); 1622 1623 /** 1624 * @brief Converts content type from native to js 1625 * 1626 * @param inType Indicates a NotificationContent object 1627 * @param outType Indicates a js ContentType object 1628 * @return Returns true if success, returns false otherwise 1629 */ 1630 static bool ContentTypeCToJS(const NotificationContent::Type &inType, ContentType &outType); 1631 1632 /** 1633 * @brief Converts slot type from js to native 1634 * 1635 * @param inType Indicates a native SlotType object 1636 * @param outType Indicates a js SlotType object 1637 * @return Returns true if success, returns false otherwise 1638 */ 1639 static bool SlotTypeJSToC(const SlotType &inType, NotificationConstant::SlotType &outType); 1640 1641 /** 1642 * @brief Converts slot type from native to js 1643 * 1644 * @param inType Indicates a js SlotType object 1645 * @param outType Indicates a native SlotType object 1646 * @return Returns true if success, returns false otherwise 1647 */ 1648 static bool SlotTypeCToJS(const NotificationConstant::SlotType &inType, SlotType &outType); 1649 1650 /** 1651 * @brief Converts slot level from js to native 1652 * 1653 * @param inType Indicates a native SlotLevel object 1654 * @param outType Indicates a js NotificationLevel object 1655 * @return Returns true if success, returns false otherwise 1656 */ 1657 static bool SlotLevelJSToC(const SlotLevel &inLevel, NotificationSlot::NotificationLevel &outLevel); 1658 1659 /** 1660 * @brief Converts liveview status from js to native 1661 * 1662 * @param inType Indicates a js liveview status object 1663 * @param outType Indicates a liveview status object 1664 * @return Returns true if success, returns false otherwise 1665 */ 1666 static bool LiveViewStatusJSToC(const LiveViewStatus &inType, NotificationLiveViewContent::LiveViewStatus &outType); 1667 1668 /** 1669 * @brief Converts slot level from native to js 1670 * 1671 * @param inType Indicates a js NotificationLevel object 1672 * @param outType Indicates a native SlotLevel object 1673 * @return Returns true if success, returns false otherwise 1674 */ 1675 static bool SlotLevelCToJS(const NotificationSlot::NotificationLevel &inLevel, SlotLevel &outLevel); 1676 1677 /** 1678 * @brief Converts reason type from native to js 1679 * 1680 * @param inType Indicates a native reason type 1681 * @param outType Indicates a js reason type 1682 * @return Returns true if success, returns false otherwise 1683 */ 1684 static bool ReasonCToJS(const int32_t &inType, int32_t &outType); 1685 1686 /** 1687 * @brief Converts do-not-disturb type from js to native 1688 * 1689 * @param inType Indicates a js DoNotDisturbType object 1690 * @param outType Indicates a native DoNotDisturbType object 1691 * @return Returns true if success, returns false otherwise 1692 */ 1693 static bool DoNotDisturbTypeJSToC(const DoNotDisturbType &inType, NotificationConstant::DoNotDisturbType &outType); 1694 1695 /** 1696 * @brief Converts do-not-disturb type from native to js 1697 * 1698 * @param inType Indicates a native DoNotDisturbType object 1699 * @param outType Indicates a js DoNotDisturbType object 1700 * @return Returns true if success, returns false otherwise 1701 */ 1702 static bool DoNotDisturbTypeCToJS(const NotificationConstant::DoNotDisturbType &inType, DoNotDisturbType &outType); 1703 1704 /** 1705 * @brief Converts remind type from native to js 1706 * 1707 * @param inType Indicates a native RemindType object 1708 * @param outType Indicates a js DeviceRemindType object 1709 * @return Returns true if success, returns false otherwise 1710 */ 1711 static bool DeviceRemindTypeCToJS(const NotificationConstant::RemindType &inType, DeviceRemindType &outType); 1712 1713 /** 1714 * @brief Converts source type from native to js 1715 * 1716 * @param inType Indicates a native SourceType object 1717 * @param outType Indicates a js SourceType object 1718 * @return Returns true if success, returns false otherwise 1719 */ 1720 static bool SourceTypeCToJS(const NotificationConstant::SourceType &inType, SourceType &outType); 1721 1722 /** 1723 * @brief Converts liveview status type from native to js 1724 * 1725 * @param inType Indicates a native liveview status object 1726 * @param outType Indicates a js liveview status object 1727 * @return Returns true if success, returns false otherwise 1728 */ 1729 static bool LiveViewStatusCToJS(const NotificationLiveViewContent::LiveViewStatus &inType, LiveViewStatus &outType); 1730 1731 /** 1732 * @brief Creates a js object from specified WantAgent object 1733 * 1734 * @param env Indicates the environment that the API is invoked under 1735 * @param agent Indicates specified WantAgent object 1736 * @return Returns a js object from specified WantAgent object 1737 */ 1738 static napi_value CreateWantAgentByJS(const napi_env &env, 1739 const std::shared_ptr<AbilityRuntime::WantAgent::WantAgent> &agent); 1740 1741 /** 1742 * @brief Gets the template of NotificationRequest object from specified js object 1743 * 1744 * @param env Indicates the environment that the API is invoked under 1745 * @param value Indicates a js object to be converted 1746 * @param request Indicates a NotificationRequest object from specified js object 1747 * @return Returns the null object if success, returns the null value otherwise 1748 */ 1749 static napi_value GetNotificationTemplate( 1750 const napi_env &env, const napi_value &value, NotificationRequest &request); 1751 1752 /** 1753 * @brief Gets a NotificationTemplate object from specified js object 1754 * 1755 * @param env Indicates the environment that the API is invoked under 1756 * @param value Indicates a js object to be converted 1757 * @param templ Indicates a NotificationTemplate object from specified js object 1758 * @return Returns the null object if success, returns the null value otherwise 1759 */ 1760 static napi_value GetNotificationTemplateInfo(const napi_env &env, const napi_value &value, 1761 std::shared_ptr<NotificationTemplate> &templ); 1762 1763 /** 1764 * @brief Sets a js object by specified NotificationTemplate object 1765 * 1766 * @param env Indicates the environment that the API is invoked under 1767 * @param templ Indicates a NotificationTemplate object to be converted 1768 * @param result Indicates a js object to be set 1769 * @return Returns the null object if success, returns the null value otherwise 1770 */ 1771 static napi_value SetNotificationTemplateInfo( 1772 const napi_env &env, const std::shared_ptr<NotificationTemplate> &templ, napi_value &result); 1773 1774 /** 1775 * @brief Sets a js object by specified NotificationFlags object 1776 * 1777 * @param env Indicates the environment that the API is invoked under 1778 * @param flags Indicates a NotificationFlags object to be converted 1779 * @param result Indicates a js object to be set 1780 * @return Returns the null object if success, returns the null value otherwise 1781 */ 1782 static napi_value SetNotificationFlags( 1783 const napi_env &env, const std::shared_ptr<NotificationFlags> &flags, napi_value &result); 1784 1785 /** 1786 * @brief Gets the number of badge of NotificationRequest object from specified js object 1787 * 1788 * @param env Indicates the environment that the API is invoked under 1789 * @param value Indicates a js object to be converted 1790 * @param request Indicates a NotificationRequest object from specified js object 1791 * @return Returns the null object if success, returns the null value otherwise 1792 */ 1793 static napi_value GetNotificationBadgeNumber( 1794 const napi_env &env, const napi_value &value, NotificationRequest &request); 1795 1796 /** 1797 * @brief Create a napi value with specified error object for callback 1798 * 1799 * @param env Indicates the environment that the API is invoked under 1800 * @param errCode Indicates specified err code 1801 * @return Returns a napi value with specified error object for callback 1802 */ 1803 static napi_value CreateErrorValue(napi_env env, int32_t errCode, bool newType); 1804 1805 /** 1806 * @brief Sets a js object by specified BadgeNumberCallbackData object 1807 * 1808 * @param env Indicates the environment that the API is invoked under 1809 * @param date Indicates a BadgeNumberCallbackData object to be converted 1810 * @param result Indicates a js object to be set 1811 * @return Returns the null object if success, returns the null value otherwise 1812 */ 1813 static napi_value SetBadgeCallbackData(const napi_env &env, 1814 const BadgeNumberCallbackData &data, napi_value &result); 1815 1816 static bool IsValidRemoveReason(int32_t reasonType); 1817 static void NapiThrow(napi_env env, int32_t errCode); 1818 static int32_t ErrorToExternal(uint32_t errCode); 1819 static void CreateReturnValue(const napi_env &env, const CallbackPromiseInfo &info, const napi_value &result); 1820 1821 private: 1822 static const int32_t ARGS_ONE = 1; 1823 static const int32_t ARGS_TWO = 2; 1824 static const int32_t ONLY_CALLBACK_MAX_PARA = 1; 1825 static const int32_t ONLY_CALLBACK_MIN_PARA = 0; 1826 static std::set<std::shared_ptr<AbilityRuntime::WantAgent::WantAgent>> wantAgent_; 1827 static std::mutex mutex_; 1828 static const char *GetPropertyNameByContentType(ContentType type); 1829 }; 1830 } // namespace NotificationNapi 1831 } // namespace OHOS 1832 1833 #endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_FRAMEWORKS_JS_NAPI_INCLUDE_COMMON_H 1834