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 #include "ans_convert_enum.h" 27 #include "ffrt.h" 28 29 namespace OHOS { 30 namespace NotificationNapi { 31 using namespace OHOS::Notification; 32 33 constexpr int32_t STR_MAX_SIZE = 204; 34 constexpr int32_t LONG_STR_MAX_SIZE = 1028; 35 constexpr uint8_t OPERATION_MAX_TYPE = 3; 36 constexpr int32_t LONG_LONG_STR_MAX_SIZE = 25600; 37 constexpr int32_t COMMON_TEXT_SIZE = 3074; 38 constexpr int32_t SHORT_TEXT_SIZE = 1026; 39 constexpr int8_t NO_ERROR = 0; 40 constexpr int8_t ERROR = -1; 41 constexpr uint8_t PARAM0 = 0; 42 constexpr uint8_t PARAM1 = 1; 43 constexpr uint8_t PARAM2 = 2; 44 constexpr uint8_t PARAM3 = 3; 45 constexpr uint8_t PARAM4 = 4; 46 constexpr float MAX_PIXEL_SIZE = 128.0f; 47 48 enum class SemanticActionButton { 49 NONE_ACTION_BUTTON, 50 REPLY_ACTION_BUTTON, 51 READ_ACTION_BUTTON, 52 UNREAD_ACTION_BUTTON, 53 DELETE_ACTION_BUTTON, 54 ARCHIVE_ACTION_BUTTON, 55 MUTE_ACTION_BUTTON, 56 UNMUTE_ACTION_BUTTON, 57 THUMBS_UP_ACTION_BUTTON, 58 THUMBS_DOWN_ACTION_BUTTON, 59 CALL_ACTION_BUTTON 60 }; 61 62 enum class InputsSource { 63 FREE_FORM_INPUT, 64 OPTION 65 }; 66 67 enum class DisturbMode { 68 ALLOW_UNKNOWN, 69 ALLOW_ALL, 70 ALLOW_PRIORITY, 71 ALLOW_NONE, 72 ALLOW_ALARMS 73 }; 74 75 enum class InputEditType { 76 EDIT_AUTO, 77 EDIT_DISABLED, 78 EDIT_ENABLED 79 }; 80 81 82 enum class NotificationFlagStatus { 83 TYPE_NONE, 84 TYPE_OPEN, 85 TYPE_CLOSE 86 }; 87 88 struct NotificationSubscribeInfo { 89 std::vector<std::string> bundleNames; 90 int32_t userId = 0; 91 bool hasSubscribeInfo = false; 92 std::string deviceType; 93 std::vector<NotificationConstant::SlotType> slotTypes; 94 uint32_t filterType = 0; 95 }; 96 97 struct CallbackPromiseInfo { 98 napi_ref callback = nullptr; 99 napi_deferred deferred = nullptr; 100 bool isCallback = false; 101 int32_t errorCode = 0; 102 }; 103 104 class Common { 105 Common(); 106 107 ~Common(); 108 109 public: 110 /** 111 * @brief Gets a napi value that is used to represent specified bool value 112 * 113 * @param env Indicates the environment that the API is invoked under 114 * @param isValue Indicates a bool value 115 * @return Returns a napi value that is used to represent specified bool value 116 */ 117 static napi_value NapiGetBoolean(napi_env env, const bool &isValue); 118 119 /** 120 * @brief Gets the napi value that is used to represent the null object 121 * 122 * @param env Indicates the environment that the API is invoked under 123 * @return Returns the napi value that is used to represent the null object 124 */ 125 static napi_value NapiGetNull(napi_env env); 126 127 /** 128 * @brief Gets the napi value that is used to represent the undefined object 129 * 130 * @param env Indicates the environment that the API is invoked under 131 * @return Returns the napi value that is used to represent the undefined object 132 */ 133 static napi_value NapiGetUndefined(napi_env env); 134 135 /** 136 * @brief Gets a napi value with specified error code for callback 137 * 138 * @param env Indicates the environment that the API is invoked under 139 * @param errCode Indicates specified err code 140 * @return Returns a napi value with specified error code for callback 141 */ 142 static napi_value GetCallbackErrorValue(napi_env env, int32_t errCode); 143 144 /** 145 * @brief Pads the CallbackPromiseInfo struct 146 * 147 * @param env Indicates the environment that the API is invoked under 148 * @param callback Indicates a napi_ref for callback 149 * @param info Indicates the CallbackPromiseInfo struct to be padded 150 * @param promise Indicates the promise to be created when the callback is null 151 */ 152 static void PaddingCallbackPromiseInfo( 153 const napi_env &env, const napi_ref &callback, CallbackPromiseInfo &info, napi_value &promise); 154 155 /** 156 * @brief Gets the returned result by the CallbackPromiseInfo struct 157 * 158 * @param env Indicates the environment that the API is invoked under 159 * @param info Indicates the CallbackPromiseInfo struct 160 * @param result Indicates the returned result 161 */ 162 static void ReturnCallbackPromise(const napi_env &env, const CallbackPromiseInfo &info, const napi_value &result); 163 164 /** 165 * @brief Calls the callback with the result and error code 166 * 167 * @param env Indicates the environment that the API is invoked under 168 * @param callbackIn Indicates the callback to be called 169 * @param errCode Indicates the error code returned by the callback 170 * @param result Indicates the result returned by the callback 171 */ 172 static void SetCallback(const napi_env &env, 173 const napi_ref &callbackIn, const int32_t &errorCode, const napi_value &result, bool newType); 174 175 /** 176 * @brief Calls the callback with the result 177 * 178 * @param env Indicates the environment that the API is invoked under 179 * @param callbackIn Indicates the callback to be called 180 * @param result Indicates the result returned by the callback 181 */ 182 static void SetCallback( 183 const napi_env &env, const napi_ref &callbackIn, const napi_value &result); 184 185 /** 186 * @brief Calls the callback with the result 187 * 188 * @param env Indicates the environment that the API is invoked under 189 * @param callbackIn Indicates the callback to be called 190 * @param result Indicates the result returned by the callback 191 */ 192 static void SetCallbackArg2( 193 const napi_env &env, const napi_ref &callbackIn, const napi_value &result0, const napi_value &result1); 194 195 /** 196 * @brief Processes the promise with the result and error code 197 * 198 * @param env Indicates the environment that the API is invoked under 199 * @param deferred Indicates the deferred object whose associated promise to resolve 200 * @param errorCode Indicates the error code returned by the callback 201 * @param result Indicates the result returned by the callback 202 */ 203 static void SetPromise(const napi_env &env, 204 const napi_deferred &deferred, const int32_t &errorCode, const napi_value &result, bool newType); 205 206 /** 207 * @brief Gets the returned result by the callback when an error occurs 208 * 209 * @param env Indicates the environment that the API is invoked under 210 * @param callback Indicates a napi_ref for callback 211 * @return Returns the null object 212 */ 213 static napi_value JSParaError(const napi_env &env, const napi_ref &callback); 214 215 /** 216 * @brief Parses a single parameter for callback 217 * 218 * @param env Indicates the environment that the API is invoked under 219 * @param info Indicates the callback info passed into the callback function 220 * @param callback Indicates the napi_ref for the callback parameter 221 * @return Returns the null object if success, returns the null value otherwise 222 */ 223 static napi_value ParseParaOnlyCallback(const napi_env &env, const napi_callback_info &info, napi_ref &callback); 224 225 /** 226 * @brief Sets a js object by specified Notification object 227 * 228 * @param env Indicates the environment that the API is invoked under 229 * @param notification Indicates a Notification object to be converted 230 * @param result Indicates a js object to be set 231 * @return Returns the null object if success, returns the null value otherwise 232 */ 233 static napi_value SetNotification( 234 const napi_env &env, const OHOS::Notification::Notification *notification, napi_value &result); 235 236 /** 237 * @brief Sets a js object by specified NotificationRequest object 238 * 239 * @param env Indicates the environment that the API is invoked under 240 * @param request Indicates a NotificationRequest object to be converted 241 * @param result Indicates a js object to be set 242 * @return Returns the null object if success, returns the null value otherwise 243 */ 244 static napi_value SetNotificationRequest( 245 const napi_env &env, const OHOS::Notification::NotificationRequest *request, napi_value &result); 246 247 /** 248 * @brief Sets a js object by the string obejcts of specified NotificationRequest object 249 * 250 * @param env Indicates the environment that the API is invoked under 251 * @param request Indicates a NotificationRequest object to be converted 252 * @param result Indicates a js object to be set 253 * @return Returns the null object if success, returns the null value otherwise 254 */ 255 static napi_value SetNotificationRequestByString( 256 const napi_env &env, const OHOS::Notification::NotificationRequest *request, napi_value &result); 257 258 /** 259 * @brief Sets a js object by the number obejcts of specified NotificationRequest object 260 * 261 * @param env Indicates the environment that the API is invoked under 262 * @param request Indicates a NotificationRequest object to be converted 263 * @param result Indicates a js object to be set 264 * @return Returns the null object if success, returns the null value otherwise 265 */ 266 static napi_value SetNotificationRequestByNumber( 267 const napi_env &env, const OHOS::Notification::NotificationRequest *request, napi_value &result); 268 269 /** 270 * @brief Sets a js object by the bool obejcts of specified NotificationRequest object 271 * 272 * @param env Indicates the environment that the API is invoked under 273 * @param request Indicates a NotificationRequest object to be converted 274 * @param result Indicates a js object to be set 275 * @return Returns the null object if success, returns the null value otherwise 276 */ 277 static napi_value SetNotificationRequestByBool( 278 const napi_env &env, const OHOS::Notification::NotificationRequest *request, napi_value &result); 279 280 /** 281 * @brief Sets a js object by the WantAgent obejct of specified NotificationRequest object 282 * 283 * @param env Indicates the environment that the API is invoked under 284 * @param request Indicates a NotificationRequest object to be converted 285 * @param result Indicates a js object to be set 286 * @return Returns the null object if success, returns the null value otherwise 287 */ 288 static napi_value SetNotificationRequestByWantAgent( 289 const napi_env &env, const OHOS::Notification::NotificationRequest *request, napi_value &result); 290 291 /** 292 * @brief Sets a js object by the PixelMap obejct of specified NotificationRequest object 293 * 294 * @param env Indicates the environment that the API is invoked under 295 * @param request Indicates a NotificationRequest object to be converted 296 * @param result Indicates a js object to be set 297 * @return Returns the null object if success, returns the null value otherwise 298 */ 299 static napi_value SetNotificationRequestByPixelMap( 300 const napi_env &env, const OHOS::Notification::NotificationRequest *request, napi_value &result); 301 302 /** 303 * @brief Sets a js object by the custom obejcts of specified NotificationRequest object 304 * 305 * @param env Indicates the environment that the API is invoked under 306 * @param request Indicates a NotificationRequest object to be converted 307 * @param result Indicates a js object to be set 308 * @return Returns the null object if success, returns the null value otherwise 309 */ 310 static napi_value SetNotificationRequestByCustom( 311 const napi_env &env, const OHOS::Notification::NotificationRequest *request, napi_value &result); 312 313 /** 314 * @brief Sets a js object by the Distributed Options object of specified Notification object 315 * 316 * @param env Indicates the environment that the API is invoked under 317 * @param notification Indicates a Notification object to be converted 318 * @param result Indicates a js object to be set 319 * @return Returns the null object if success, returns the null value otherwise 320 */ 321 static napi_value SetNotificationByDistributedOptions( 322 const napi_env &env, const OHOS::Notification::Notification *notification, napi_value &result); 323 324 /** 325 * @brief Sets a js object by specified NotificationSortingMap object 326 * 327 * @param env Indicates the environment that the API is invoked under 328 * @param sortingMap Indicates a NotificationSortingMap object to be converted 329 * @param result Indicates a js object to be set 330 * @return Returns the null object if success, returns the null value otherwise 331 */ 332 static napi_value SetNotificationSortingMap( 333 const napi_env &env, const std::shared_ptr<NotificationSortingMap> &sortingMap, napi_value &result); 334 335 /** 336 * @brief Sets a js object by specified NotificationSorting object 337 * 338 * @param env Indicates the environment that the API is invoked under 339 * @param sorting Indicates a NotificationSorting object to be converted 340 * @param result Indicates a js object to be set 341 * @return Returns the null object if success, returns the null value otherwise 342 */ 343 static napi_value SetNotificationSorting( 344 const napi_env &env, NotificationSorting &sorting, napi_value &result); 345 346 /** 347 * @brief Sets a js object by specified NotificationSlot object 348 * 349 * @param env Indicates the environment that the API is invoked under 350 * @param slot Indicates a NotificationSlot object to be converted 351 * @param result Indicates a js object to be set 352 * @return Returns the null object if success, returns the null value otherwise 353 */ 354 static napi_value SetNotificationSlot(const napi_env &env, const NotificationSlot &slot, napi_value &result); 355 356 /** 357 * @brief Sets a js object by specified NotificationContent object 358 * 359 * @param env Indicates the environment that the API is invoked under 360 * @param content Indicates a NotificationContent object to be converted 361 * @param result Indicates a js object to be set 362 * @return Returns the null object if success, returns the null value otherwise 363 */ 364 static napi_value SetNotificationContent( 365 const napi_env &env, const std::shared_ptr<NotificationContent> &content, napi_value &result); 366 367 /** 368 * @brief Sets a js object by the object of specified type in specified NotificationContent object 369 * 370 * @param env Indicates the environment that the API is invoked under 371 * @param type Indicates the content type 372 * @param content Indicates a NotificationContent object to be converted 373 * @param result Indicates a js object to be set 374 * @return Returns the null object if success, returns the null value otherwise 375 */ 376 static napi_value SetNotificationContentDetailed(const napi_env &env, const ContentType &type, 377 const std::shared_ptr<NotificationContent> &content, napi_value &result); 378 379 /** 380 * @brief Sets a js NotificationBasicContent object by specified NotificationBasicContent object 381 * 382 * @param env Indicates the environment that the API is invoked under 383 * @param basicContent Indicates a NotificationBasicContent object to be converted 384 * @param result Indicates a js object to be set 385 * @return Returns the null object if success, returns the null value otherwise 386 */ 387 static napi_value SetNotificationBasicContent( 388 const napi_env &env, const NotificationBasicContent *basicContent, napi_value &result); 389 390 /** 391 * @brief Sets a js NotificationLongTextContent object by specified NotificationBasicContent object 392 * 393 * @param env Indicates the environment that the API is invoked under 394 * @param basicContent Indicates a NotificationBasicContent 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 SetNotificationLongTextContent( 399 const napi_env &env, NotificationBasicContent *basicContent, napi_value &result); 400 401 /** 402 * @brief Sets a js NotificationPictureContent object by specified NotificationBasicContent object 403 * 404 * @param env Indicates the environment that the API is invoked under 405 * @param basicContent Indicates a NotificationBasicContent object to be converted 406 * @param result Indicates a js object to be set 407 * @return Returns the null object if success, returns the null value otherwise 408 */ 409 static napi_value SetNotificationPictureContent( 410 const napi_env &env, NotificationBasicContent *basicContent, napi_value &result); 411 412 /** 413 * @brief Sets a js NotificationConversationalContent object by specified NotificationBasicContent object 414 * 415 * @param env Indicates the environment that the API is invoked under 416 * @param basicContent Indicates a NotificationBasicContent 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 SetNotificationConversationalContent(const napi_env &env, 421 NotificationBasicContent *basicContent, napi_value &result); 422 423 /** 424 * @brief Sets a js NotificationMultiLineContent object by specified NotificationBasicContent object 425 * 426 * @param env Indicates the environment that the API is invoked under 427 * @param basicContent Indicates a NotificationBasicContent object to be converted 428 * @param result Indicates a js object to be set 429 * @return Returns the null object if success, returns the null value otherwise 430 */ 431 static napi_value SetNotificationMultiLineContent( 432 const napi_env &env, NotificationBasicContent *basicContent, napi_value &result); 433 434 /** 435 * @brief Sets a js NotificationLocalLiveViewContent object by specified NotificationBasicContent object 436 * 437 * @param env Indicates the environment that the API is invoked under 438 * @param basicContent Indicates a NotificationBasicContent object to be converted 439 * @param result Indicates a js object to be set 440 * @return Returns the null object if success, returns the null value otherwise 441 */ 442 static napi_value SetNotificationLocalLiveViewContent( 443 const napi_env &env, NotificationBasicContent *basicContent, napi_value &result); 444 445 /** 446 * @brief Sets a js object by specified NotificationCapsule object 447 * 448 * @param env Indicates the environment that the API is invoked under 449 * @param capsule Indicates a NotificationCapsule object to be converted 450 * @param result Indicates a js object to be set 451 * @return Returns the null object if success, returns the null value otherwise 452 */ 453 static napi_value SetCapsule(const napi_env &env, const NotificationCapsule &capsule, napi_value &result); 454 455 /** 456 * @brief Sets a js object by specified NotificationLocalLiveViewButton object 457 * 458 * @param env Indicates the environment that the API is invoked under 459 * @param capsule Indicates a NotificationLocalLiveViewButton object to be converted 460 * @param result Indicates a js object to be set 461 * @return Returns the null object if success, returns the null value otherwise 462 */ 463 static napi_value SetButton(const napi_env &env, const NotificationLocalLiveViewButton &button, napi_value &result); 464 465 /** 466 * @brief Sets a js object by specified NotificationIconButton array 467 * 468 * @param env Indicates the environment that the API is invoked under 469 * @param buttons Indicates a NotificationIconButton object to be converted 470 * @param result Indicates a js object to be set 471 * @return Returns the null object if success, returns the null value otherwise 472 */ 473 static napi_value SetCardButton(const napi_env &env, const std::vector<NotificationIconButton> buttons, 474 napi_value &result); 475 476 /** 477 * @brief Sets a js object by specified NotificationProgress object 478 * 479 * @param env Indicates the environment that the API is invoked under 480 * @param capsule Indicates a NotificationProgress object to be converted 481 * @param result Indicates a js object to be set 482 * @return Returns the null object if success, returns the null value otherwise 483 */ 484 static napi_value SetProgress(const napi_env &env, const NotificationProgress &progress, napi_value &result); 485 486 /** 487 * @brief Sets a js object by specified NotificationTime object 488 * 489 * @param env Indicates the environment that the API is invoked under 490 * @param time Indicates a NotificationTime object to be converted 491 * @param isInitialTimeExist Indicates is initialTime exists 492 * @param result Indicates a js object to be set 493 * @return Returns the null object if success, returns the null value otherwise 494 */ 495 static napi_value SetTime(const napi_env &env, const NotificationTime &time, 496 napi_value &result, bool isInitialTimeExist); 497 498 /** 499 * @brief Sets a js NotificationLiveViewContent object by specified NotificationBasicContent object 500 * 501 * @param env Indicates the environment that the API is invoked under 502 * @param basicContent Indicates a NotificationBasicContent object to be converted 503 * @param result Indicates a js object to be set 504 * @return Returns the null object if success, returns the null value otherwise 505 */ 506 static napi_value SetNotificationLiveViewContent( 507 const napi_env &env, NotificationBasicContent *basicContent, napi_value &result); 508 509 /** 510 * @brief Sets a js liveview picturemap object by specified liveview picturemap 511 * 512 * @param env Indicates the environment that the API is invoked under 513 * @param pictureMap Indicates a picturemap object to be converted 514 * @return Returns the null object if success, returns the null value otherwise 515 */ 516 static napi_value SetLiveViewPictureInfo( 517 const napi_env &env, const std::map<std::string, std::vector<std::shared_ptr<Media::PixelMap>>> &pictureMap); 518 519 /** 520 * @brief Sets a js object by specified MessageUser object 521 * 522 * @param env Indicates the environment that the API is invoked under 523 * @param messageUser Indicates a MessageUser object to be converted 524 * @param result Indicates a js object to be set 525 * @return Returns the null object if success, returns the null value otherwise 526 */ 527 static napi_value SetMessageUser(const napi_env &env, const MessageUser &messageUser, napi_value &result); 528 529 /** 530 * @brief Sets a js object by specified NotificationConversationalContent object 531 * 532 * @param env Indicates the environment that the API is invoked under 533 * @param conversationalContent Indicates a NotificationConversationalContent object to be converted 534 * @param arr Indicates a js object to be set 535 * @return Returns the null object if success, returns the null value otherwise 536 */ 537 static napi_value SetConversationalMessages(const napi_env &env, 538 const OHOS::Notification::NotificationConversationalContent *conversationalContent, napi_value &arr); 539 540 /** 541 * @brief Sets a js object by specified NotificationConversationalMessage object 542 * 543 * @param env Indicates the environment that the API is invoked under 544 * @param conversationalMessage Indicates a NotificationConversationalMessage object to be converted 545 * @param result Indicates a js object to be set 546 * @return Returns the null object if success, returns the null value otherwise 547 */ 548 static napi_value SetConversationalMessage(const napi_env &env, 549 const std::shared_ptr<NotificationConversationalMessage> &conversationalMessage, napi_value &result); 550 551 /** 552 * @brief Sets a js object by specified NotificationActionButton object 553 * 554 * @param env Indicates the environment that the API is invoked under 555 * @param actionButton Indicates a NotificationActionButton object to be converted 556 * @param result Indicates a js object to be set 557 * @return Returns the null object if success, returns the null value otherwise 558 */ 559 static napi_value SetNotificationActionButton( 560 const napi_env &env, const std::shared_ptr<NotificationActionButton> &actionButton, napi_value &result); 561 562 /** 563 * @brief Sets a js object by the extra objects of specified NotificationActionButton object 564 * 565 * @param env Indicates the environment that the API is invoked under 566 * @param actionButton Indicates a NotificationActionButton 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 SetNotificationActionButtonByExtras( 571 const napi_env &env, const std::shared_ptr<NotificationActionButton> &actionButton, napi_value &result); 572 573 /** 574 * @brief Sets a js object by specified NotificationUserInput object 575 * 576 * @param env Indicates the environment that the API is invoked under 577 * @param userInput Indicates a NotificationUserInput object to be converted 578 * @param result Indicates a js object to be set 579 * @return Returns the null object if success, returns the null value otherwise 580 */ 581 static napi_value SetNotificationActionButtonByUserInput( 582 const napi_env &env, const std::shared_ptr<NotificationUserInput> &userInput, napi_value &result); 583 584 /** 585 * @brief Sets a js object by specified NotificationDoNotDisturbDate object 586 * 587 * @param env Indicates the environment that the API is invoked under 588 * @param date Indicates a NotificationDoNotDisturbDate object to be converted 589 * @param result Indicates a js object to be set 590 * @return Returns the null object if success, returns the null value otherwise 591 */ 592 static napi_value SetDoNotDisturbDate( 593 const napi_env &env, const NotificationDoNotDisturbDate &date, napi_value &result); 594 595 /** 596 * @brief Sets a js object by specified EnabledNotificationCallbackData object 597 * 598 * @param env Indicates the environment that the API is invoked under 599 * @param date Indicates a EnabledNotificationCallbackData object to be converted 600 * @param result Indicates a js object to be set 601 * @return Returns the null object if success, returns the null value otherwise 602 */ 603 static napi_value SetEnabledNotificationCallbackData(const napi_env &env, 604 const EnabledNotificationCallbackData &data, napi_value &result); 605 606 /** 607 * @brief Gets a NotificationSubscribeInfo object from specified js object 608 * 609 * @param env Indicates the environment that the API is invoked under 610 * @param value Indicates a js object to be converted 611 * @param result Indicates a NotificationSubscribeInfo object from specified js object 612 * @return Returns the null object if success, returns the null value otherwise 613 */ 614 static napi_value GetNotificationSubscriberInfo( 615 const napi_env &env, const napi_value &value, NotificationSubscribeInfo &result); 616 617 /** 618 * @brief Gets a NotificationRequest object from specified js object 619 * 620 * @param env Indicates the environment that the API is invoked under 621 * @param value Indicates a js object to be converted 622 * @param result Indicates a NotificationRequest object from specified js object 623 * @return Returns the null object if success, returns the null value otherwise 624 */ 625 static napi_value GetNotificationRequest( 626 const napi_env &env, const napi_value &value, NotificationRequest &request); 627 628 /** 629 * @brief Gets a NotificationRequest object by number type from specified js object 630 * 631 * @param env Indicates the environment that the API is invoked under 632 * @param value Indicates a js object to be converted 633 * @param request Indicates a NotificationRequest object from specified js object 634 * @return Returns the null object if success, returns the null value otherwise 635 */ 636 static napi_value GetNotificationRequestByNumber( 637 const napi_env &env, const napi_value &value, NotificationRequest &request); 638 639 /** 640 * @brief Gets a NotificationRequest object by string type from specified js object 641 * 642 * @param env Indicates the environment that the API is invoked under 643 * @param value Indicates a js object to be converted 644 * @param request Indicates a NotificationRequest object from specified js object 645 * @return Returns the null object if success, returns the null value otherwise 646 */ 647 static napi_value GetNotificationRequestByString( 648 const napi_env &env, const napi_value &value, NotificationRequest &request); 649 650 /** 651 * @brief Gets a NotificationRequest object by bool type from specified js object 652 * 653 * @param env Indicates the environment that the API is invoked under 654 * @param value Indicates a js object to be converted 655 * @param request Indicates a NotificationRequest object from specified js object 656 * @return Returns the null object if success, returns the null value otherwise 657 */ 658 static napi_value GetNotificationRequestByBool( 659 const napi_env &env, const napi_value &value, NotificationRequest &request); 660 661 /** 662 * @brief Gets a NotificationRequest object by custom type from specified js object 663 * 664 * @param env Indicates the environment that the API is invoked under 665 * @param value Indicates a js object to be converted 666 * @param request Indicates a NotificationRequest object from specified js object 667 * @return Returns the null object if success, returns the null value otherwise 668 */ 669 static napi_value GetNotificationRequestByCustom( 670 const napi_env &env, const napi_value &value, NotificationRequest &request); 671 672 /** 673 * @brief Gets the id of NotificationRequest object from specified js object 674 * 675 * @param env Indicates the environment that the API is invoked under 676 * @param value Indicates a js object to be converted 677 * @param request Indicates a NotificationRequest object from specified js object 678 * @return Returns the null object if success, returns the null value otherwise 679 */ 680 static napi_value GetNotificationId(const napi_env &env, const napi_value &value, NotificationRequest &request); 681 682 /** 683 * @brief Gets the slot type of NotificationRequest object 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 GetNotificationSlotType( 691 const napi_env &env, const napi_value &value, NotificationRequest &request); 692 693 /** 694 * @brief Gets the isOngoing flag of NotificationRequest object 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 GetNotificationIsOngoing( 702 const napi_env &env, const napi_value &value, NotificationRequest &request); 703 704 /** 705 * @brief Gets the isUnremovable flag of NotificationRequest object 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 GetNotificationIsUnremovable( 713 const napi_env &env, const napi_value &value, NotificationRequest &request); 714 715 /** 716 * @brief Gets the delivery time 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 GetNotificationDeliveryTime( 724 const napi_env &env, const napi_value &value, NotificationRequest &request); 725 726 /** 727 * @brief Gets the tapDismissed flag of NotificationRequest object from specified js object 728 * 729 * @param env Indicates the environment that the API is invoked under 730 * @param value Indicates a js object to be converted 731 * @param request Indicates a NotificationRequest object from specified js object 732 * @return Returns the null object if success, returns the null value otherwise 733 */ 734 static napi_value GetNotificationtapDismissed( 735 const napi_env &env, const napi_value &value, NotificationRequest &request); 736 737 /** 738 * @brief Gets the extra information of NotificationRequest object from specified js object 739 * 740 * @param env Indicates the environment that the API is invoked under 741 * @param value Indicates a js object to be converted 742 * @param request Indicates a NotificationRequest object from specified js object 743 * @return Returns the null object if success, returns the null value otherwise 744 */ 745 static napi_value GetNotificationExtraInfo( 746 const napi_env &env, const napi_value &value, NotificationRequest &request); 747 748 /** 749 * @brief Gets the extendInfo of NotificationRequest object from specified js object 750 * 751 * @param env Indicates the environment that the API is invoked under 752 * @param value Indicates a js object to be converted 753 * @param request Indicates a NotificationRequest object from specified js object 754 * @return Returns the null object if success, returns the null value otherwise 755 */ 756 static napi_value GetNotificationExtendInfo( 757 const napi_env &env, const napi_value &value, NotificationRequest &request); 758 759 /** 760 * @brief Gets the group name of NotificationRequest object from specified js object 761 * 762 * @param env Indicates the environment that the API is invoked under 763 * @param value Indicates a js object to be converted 764 * @param request Indicates a NotificationRequest object from specified js object 765 * @return Returns the null object if success, returns the null value otherwise 766 */ 767 static napi_value GetNotificationGroupName( 768 const napi_env &env, const napi_value &value, NotificationRequest &request); 769 770 /** 771 * @brief Gets the removal WantAgent object of NotificationRequest object from specified js object 772 * 773 * @param env Indicates the environment that the API is invoked under 774 * @param value Indicates a js object to be converted 775 * @param request Indicates a NotificationRequest object from specified js object 776 * @return Returns the null object if success, returns the null value otherwise 777 */ 778 static napi_value GetNotificationRemovalWantAgent( 779 const napi_env &env, const napi_value &value, NotificationRequest &request); 780 781 /** 782 * @brief Gets the max screen WantAgent object of NotificationRequest object from specified js object 783 * 784 * @param env Indicates the environment that the API is invoked under 785 * @param value Indicates a js object to be converted 786 * @param request Indicates a NotificationRequest object from specified js object 787 * @return Returns the null object if success, returns the null value otherwise 788 */ 789 static napi_value GetNotificationMaxScreenWantAgent( 790 const napi_env &env, const napi_value &value, NotificationRequest &request); 791 792 /** 793 * @brief Gets the auto deleted time of NotificationRequest object from specified js object 794 * 795 * @param env Indicates the environment that the API is invoked under 796 * @param value Indicates a js object to be converted 797 * @param request Indicates a NotificationRequest object from specified js object 798 * @return Returns the null object if success, returns the null value otherwise 799 */ 800 static napi_value GetNotificationAutoDeletedTime( 801 const napi_env &env, const napi_value &value, NotificationRequest &request); 802 803 /** 804 * @brief Gets the classification of NotificationRequest object from specified js object 805 * 806 * @param env Indicates the environment that the API is invoked under 807 * @param value Indicates a js object to be converted 808 * @param request Indicates a NotificationRequest object from specified js object 809 * @return Returns the null object if success, returns the null value otherwise 810 */ 811 static napi_value GetNotificationClassification( 812 const napi_env &env, const napi_value &value, NotificationRequest &request); 813 814 /** 815 * @brief Gets the appMessageId of NotificationRequest object from specified js object 816 * 817 * @param env Indicates the environment that the API is invoked under 818 * @param value Indicates a js object to be converted 819 * @param request Indicates a NotificationRequest object from specified js object 820 * @return Returns the null object if success, returns the null value otherwise 821 */ 822 static napi_value GetNotificationAppMessageId( 823 const napi_env &env, const napi_value &value, NotificationRequest &request); 824 825 /** 826 * @brief Gets the sound of NotificationRequest object from specified js object 827 * 828 * @param env Indicates the environment that the API is invoked under 829 * @param value Indicates a js object to be converted 830 * @param request Indicates a NotificationRequest object from specified js object 831 * @return Returns the null object if success, returns the null value otherwise 832 */ 833 static napi_value GetNotificationSound( 834 const napi_env &env, const napi_value &value, NotificationRequest &request); 835 836 /** 837 * @brief Gets the color of NotificationRequest object from specified js object 838 * 839 * @param env Indicates the environment that the API is invoked under 840 * @param value Indicates a js object to be converted 841 * @param request Indicates a NotificationRequest object from specified js object 842 * @return Returns the null object if success, returns the null value otherwise 843 */ 844 static napi_value GetNotificationColor(const napi_env &env, const napi_value &value, NotificationRequest &request); 845 846 /** 847 * @brief Gets the colorEnabled flag 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 GetNotificationColorEnabled( 855 const napi_env &env, const napi_value &value, NotificationRequest &request); 856 857 /** 858 * @brief Gets the isAlertOnce flag of NotificationRequest object from specified js object 859 * 860 * @param env Indicates the environment that the API is invoked under 861 * @param value Indicates a js object to be converted 862 * @param request Indicates a NotificationRequest object from specified js object 863 * @return Returns the null object if success, returns the null value otherwise 864 */ 865 static napi_value GetNotificationIsAlertOnce( 866 const napi_env &env, const napi_value &value, NotificationRequest &request); 867 868 /** 869 * @brief Gets the isStopwatch flag of NotificationRequest object from specified js object 870 * 871 * @param env Indicates the environment that the API is invoked under 872 * @param value Indicates a js object to be converted 873 * @param request Indicates a NotificationRequest object from specified js object 874 * @return Returns the null object if success, returns the null value otherwise 875 */ 876 static napi_value GetNotificationIsStopwatch( 877 const napi_env &env, const napi_value &value, NotificationRequest &request); 878 879 /** 880 * @brief Gets the isCountDown flag of NotificationRequest object from specified js object 881 * 882 * @param env Indicates the environment that the API is invoked under 883 * @param value Indicates a js object to be converted 884 * @param request Indicates a NotificationRequest object from specified js object 885 * @return Returns the null object if success, returns the null value otherwise 886 */ 887 static napi_value GetNotificationIsCountDown( 888 const napi_env &env, const napi_value &value, NotificationRequest &request); 889 890 /** 891 * @brief Gets the status bar text of NotificationRequest object from specified js object 892 * 893 * @param env Indicates the environment that the API is invoked under 894 * @param value Indicates a js object to be converted 895 * @param request Indicates a NotificationRequest object from specified js object 896 * @return Returns the null object if success, returns the null value otherwise 897 */ 898 static napi_value GetNotificationStatusBarText( 899 const napi_env &env, const napi_value &value, NotificationRequest &request); 900 901 /** 902 * @brief Gets the label of NotificationRequest object from specified js object 903 * 904 * @param env Indicates the environment that the API is invoked under 905 * @param value Indicates a js object to be converted 906 * @param request Indicates a NotificationRequest object from specified js object 907 * @return Returns the null object if success, returns the null value otherwise 908 */ 909 static napi_value GetNotificationLabel(const napi_env &env, const napi_value &value, NotificationRequest &request); 910 911 /** 912 * @brief Gets the badge icon style 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 GetNotificationBadgeIconStyle( 920 const napi_env &env, const napi_value &value, NotificationRequest &request); 921 922 /** 923 * @brief Gets the showDeliveryTime flag of NotificationRequest object from specified js object 924 * 925 * @param env Indicates the environment that the API is invoked under 926 * @param value Indicates a js object to be converted 927 * @param request Indicates a NotificationRequest object from specified js object 928 * @return Returns the null object if success, returns the null value otherwise 929 */ 930 static napi_value GetNotificationShowDeliveryTime( 931 const napi_env &env, const napi_value &value, NotificationRequest &request); 932 933 /** 934 * @brief Gets the updateOnly flag of NotificationRequest object from specified js object 935 * 936 * @param env Indicates the environment that the API is invoked under 937 * @param value Indicates a js object to be converted 938 * @param request Indicates a NotificationRequest object from specified js object 939 * @return Returns the null object if success, returns the null value otherwise 940 */ 941 static napi_value GetNotificationIsUpdateOnly( 942 const napi_env &env, const napi_value &value, NotificationRequest &request); 943 944 static napi_value GetNotificationIsRemoveAllowed( 945 const napi_env &env, const napi_value &value, NotificationRequest &request); 946 947 /** 948 * @brief Gets the forceDistributed flag 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 GetNotificationForceDistributed( 956 const napi_env &env, const napi_value &value, NotificationRequest &request); 957 958 /** 959 * @brief Gets the notDistributed flag 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 GetNotificationIsNotDistributed( 967 const napi_env &env, const napi_value &value, NotificationRequest &request); 968 969 /** 970 * @brief Gets the content of NotificationRequest 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 request Indicates a NotificationRequest object from specified js object 975 * @return Returns the null object if success, returns the null value otherwise 976 */ 977 static napi_value GetNotificationContent( 978 const napi_env &env, const napi_value &value, NotificationRequest &request); 979 980 /** 981 * @brief Gets the WantAgent object of NotificationRequest 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 request Indicates a NotificationRequest object from specified js object 986 * @return Returns the null object if success, returns the null value otherwise 987 */ 988 static napi_value GetNotificationWantAgent( 989 const napi_env &env, const napi_value &value, NotificationRequest &request); 990 991 /** 992 * @brief Gets a 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 GetNotificationSlot( 1000 const napi_env &env, const napi_value &value, NotificationSlot &slot); 1001 1002 /** 1003 * @brief Gets the string 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 GetNotificationSlotByString( 1011 const napi_env &env, const napi_value &value, NotificationSlot &slot); 1012 1013 /** 1014 * @brief Gets the bool objects 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 GetNotificationSlotByBool( 1022 const napi_env &env, const napi_value &value, NotificationSlot &slot); 1023 1024 /** 1025 * @brief Gets the number objects of NotificationSlot 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 slot Indicates a NotificationSlot object from specified js object 1030 * @return Returns the null object if success, returns the null value otherwise 1031 */ 1032 static napi_value GetNotificationSlotByNumber( 1033 const napi_env &env, const napi_value &value, NotificationSlot &slot); 1034 1035 /** 1036 * @brief Gets the vibration of NotificationSlot object from specified js object 1037 * 1038 * @param env Indicates the environment that the API is invoked under 1039 * @param value Indicates a js object to be converted 1040 * @param slot Indicates a NotificationSlot object from specified js object 1041 * @return Returns the null object if success, returns the null value otherwise 1042 */ 1043 static napi_value GetNotificationSlotByVibration( 1044 const napi_env &env, const napi_value &value, NotificationSlot &slot); 1045 1046 /** 1047 * @brief Gets the action buttons of NotificationRequest object from specified js object 1048 * 1049 * @param env Indicates the environment that the API is invoked under 1050 * @param value Indicates a js object to be converted 1051 * @param request Indicates a NotificationRequest object from specified js object 1052 * @return Returns the null object if success, returns the null value otherwise 1053 */ 1054 static napi_value GetNotificationActionButtons( 1055 const napi_env &env, const napi_value &value, NotificationRequest &request); 1056 1057 /** 1058 * @brief Gets a 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 GetNotificationActionButtonsDetailed( 1066 const napi_env &env, const napi_value &actionButton, std::shared_ptr<NotificationActionButton> &pActionButton); 1067 1068 /** 1069 * @brief Gets the basic information 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 GetNotificationActionButtonsDetailedBasicInfo( 1077 const napi_env &env, const napi_value &actionButton, std::shared_ptr<NotificationActionButton> &pActionButton); 1078 1079 /** 1080 * @brief Gets the extras of NotificationActionButton object from specified js object 1081 * 1082 * @param env Indicates the environment that the API is invoked under 1083 * @param actionButton Indicates a js object to be converted 1084 * @param pActionButton Indicates a NotificationActionButton object from specified js object 1085 * @return Returns the null object if success, returns the null value otherwise 1086 */ 1087 static napi_value GetNotificationActionButtonsDetailedByExtras( 1088 const napi_env &env, const napi_value &actionButton, std::shared_ptr<NotificationActionButton> &pActionButton); 1089 1090 /** 1091 * @brief Gets the user input of NotificationActionButton object from specified js object 1092 * 1093 * @param env Indicates the environment that the API is invoked under 1094 * @param actionButton Indicates a js object to be converted 1095 * @param pActionButton Indicates a NotificationActionButton object from specified js object 1096 * @return Returns the null object if success, returns the null value otherwise 1097 */ 1098 static napi_value GetNotificationUserInput( 1099 const napi_env &env, const napi_value &actionButton, std::shared_ptr<NotificationActionButton> &pActionButton); 1100 1101 /** 1102 * @brief Gets the input key 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 GetNotificationUserInputByInputKey( 1110 const napi_env &env, const napi_value &userInputResult, std::shared_ptr<NotificationUserInput> &userInput); 1111 1112 /** 1113 * @brief Gets the tag 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 GetNotificationUserInputByTag( 1121 const napi_env &env, const napi_value &userInputResult, std::shared_ptr<NotificationUserInput> &userInput); 1122 1123 /** 1124 * @brief Gets the options 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 GetNotificationUserInputByOptions( 1132 const napi_env &env, const napi_value &userInputResult, std::shared_ptr<NotificationUserInput> &userInput); 1133 1134 /** 1135 * @brief Gets the permit mime types 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 GetNotificationUserInputByPermitMimeTypes( 1143 const napi_env &env, const napi_value &userInputResult, std::shared_ptr<NotificationUserInput> &userInput); 1144 1145 /** 1146 * @brief Gets the permit free from input 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 GetNotificationUserInputByPermitFreeFormInput( 1154 const napi_env &env, const napi_value &userInputResult, std::shared_ptr<NotificationUserInput> &userInput); 1155 1156 /** 1157 * @brief Gets the edit type of NotificationUserInput object from specified js object 1158 * 1159 * @param env Indicates the environment that the API is invoked under 1160 * @param userInputResult Indicates a js object to be converted 1161 * @param userInput Indicates a NotificationUserInput object from specified js object 1162 * @return Returns the null object if success, returns the null value otherwise 1163 */ 1164 static napi_value GetNotificationUserInputByEditType( 1165 const napi_env &env, const napi_value &userInputResult, std::shared_ptr<NotificationUserInput> &userInput); 1166 1167 /** 1168 * @brief Gets the additional data of NotificationUserInput object from specified js object 1169 * 1170 * @param env Indicates the environment that the API is invoked under 1171 * @param userInputResult Indicates a js object to be converted 1172 * @param userInput Indicates a NotificationUserInput object from specified js object 1173 * @return Returns the null object if success, returns the null value otherwise 1174 */ 1175 static napi_value GetNotificationUserInputByAdditionalData( 1176 const napi_env &env, const napi_value &userInputResult, std::shared_ptr<NotificationUserInput> &userInput); 1177 1178 /** 1179 * @brief Gets the small 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 GetNotificationSmallIcon( 1187 const napi_env &env, const napi_value &value, NotificationRequest &request); 1188 1189 /** 1190 * @brief Gets the large icon 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 GetNotificationLargeIcon( 1198 const napi_env &env, const napi_value &value, NotificationRequest &request); 1199 1200 /** 1201 * @brief Gets the overlay icon 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 GetNotificationOverlayIcon( 1209 const napi_env &env, const napi_value &value, NotificationRequest &request); 1210 1211 /** 1212 * @brief Gets the distributed options 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 GetNotificationRequestDistributedOptions( 1220 const napi_env &env, const napi_value &value, NotificationRequest &request); 1221 1222 /** 1223 * @brief Gets the isDistributed flag 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 GetNotificationIsDistributed( 1231 const napi_env &env, const napi_value &value, NotificationRequest &request); 1232 1233 /** 1234 * @brief Gets the devices that support display of NotificationRequest object 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 request Indicates a NotificationRequest object from specified js object 1239 * @return Returns the null object if success, returns the null value otherwise 1240 */ 1241 static napi_value GetNotificationSupportDisplayDevices( 1242 const napi_env &env, const napi_value &value, NotificationRequest &request); 1243 1244 /** 1245 * @brief Gets the devices that support operation of NotificationRequest object from specified js object 1246 * 1247 * @param env Indicates the environment that the API is invoked under 1248 * @param value Indicates a js object to be converted 1249 * @param request Indicates a NotificationRequest object from specified js object 1250 * @return Returns the null object if success, returns the null value otherwise 1251 */ 1252 static napi_value GetNotificationSupportOperateDevices( 1253 const napi_env &env, const napi_value &value, NotificationRequest &request); 1254 1255 /** 1256 * @brief Gets a content type of notification from specified js object 1257 * 1258 * @param env Indicates the environment that the API is invoked under 1259 * @param value Indicates a js object to be converted 1260 * @param type Indicates a the content type of notification from specified js object 1261 * @return Returns the null object if success, returns the null value otherwise 1262 */ 1263 static napi_value GetNotificationContentType(const napi_env &env, const napi_value &result, int32_t &type); 1264 1265 /** 1266 * @brief Gets a basic 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 GetNotificationBasicContent( 1274 const napi_env &env, const napi_value &result, NotificationRequest &request); 1275 1276 /** 1277 * @brief Gets a NotificationBasicContent 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 basicContent Indicates a NotificationBasicContent object from specified js object 1282 * @return Returns the null object if success, returns the null value otherwise 1283 */ 1284 static napi_value GetNotificationBasicContentDetailed( 1285 const napi_env &env, const napi_value &contentResult, std::shared_ptr<NotificationBasicContent> basicContent); 1286 1287 /** 1288 * @brief Gets a long-text content of NotificationRequest object from specified js object 1289 * 1290 * @param env Indicates the environment that the API is invoked under 1291 * @param value Indicates a js object to be converted 1292 * @param request Indicates a NotificationRequest object from specified js object 1293 * @return Returns the null object if success, returns the null value otherwise 1294 */ 1295 static napi_value GetNotificationLongTextContent( 1296 const napi_env &env, const napi_value &result, NotificationRequest &request); 1297 1298 /** 1299 * @brief Gets a NotificationLongTextContent object from specified js object 1300 * 1301 * @param env Indicates the environment that the API is invoked under 1302 * @param contentResult Indicates a js object to be converted 1303 * @param longContent Indicates a NotificationLongTextContent object from specified js object 1304 * @return Returns the null object if success, returns the null value otherwise 1305 */ 1306 static napi_value GetNotificationLongTextContentDetailed( 1307 const napi_env &env, const napi_value &contentResult, 1308 std::shared_ptr<OHOS::Notification::NotificationLongTextContent> &longContent); 1309 1310 /** 1311 * @brief Gets a picture content of NotificationRequest 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 request Indicates a NotificationRequest object from specified js object 1316 * @return Returns the null object if success, returns the null value otherwise 1317 */ 1318 static napi_value GetNotificationPictureContent( 1319 const napi_env &env, const napi_value &result, NotificationRequest &request); 1320 1321 /** 1322 * @brief Gets a NotificationPictureContent object from specified js object 1323 * 1324 * @param env Indicates the environment that the API is invoked under 1325 * @param contentResult Indicates a js object to be converted 1326 * @param pictureContent Indicates a NotificationPictureContent object from specified js object 1327 * @return Returns the null object if success, returns the null value otherwise 1328 */ 1329 static napi_value GetNotificationPictureContentDetailed( 1330 const napi_env &env, const napi_value &contentResult, 1331 std::shared_ptr<OHOS::Notification::NotificationPictureContent> &pictureContent); 1332 1333 /** 1334 * @brief Gets a NotificationLocalLiveViewContent object from specified js object 1335 * 1336 * @param env Indicates the environment that the API is invoked under 1337 * @param result Indicates a js object to be converted 1338 * @param request Indicates a NotificationLocalLiveViewContent object from specified js object 1339 * @return Returns the null object if success, returns the null value otherwise 1340 */ 1341 static napi_value GetNotificationLocalLiveViewContent( 1342 const napi_env &env, const napi_value &result, NotificationRequest &request); 1343 1344 /** 1345 * @brief Gets a capsule of NotificationLocalLiveViewContent object from specified js object 1346 * 1347 * @param env Indicates the environment that the API is invoked under 1348 * @param contentResult Indicates a js object to be converted 1349 * @param content Indicates a capsule object from specified js object 1350 * @return Returns the null object if success, returns the null value otherwise 1351 */ 1352 static napi_value GetNotificationLocalLiveViewCapsule( 1353 const napi_env &env, const napi_value &contentResult, 1354 std::shared_ptr<OHOS::Notification::NotificationLocalLiveViewContent> content); 1355 1356 /** 1357 * @brief Gets a button of NotificationLocalLiveViewContent object from specified js object 1358 * 1359 * @param env Indicates the environment that the API is invoked under 1360 * @param contentResult Indicates a js object to be converted 1361 * @param content Indicates a button object from specified js object 1362 * @return Returns the null object if success, returns the null value otherwise 1363 */ 1364 static napi_value GetNotificationLocalLiveViewButton( 1365 const napi_env &env, const napi_value &contentResult, 1366 std::shared_ptr<OHOS::Notification::NotificationLocalLiveViewContent> content); 1367 1368 /** 1369 * @brief Gets a card button of NotificationLocalLiveViewContent object from specified js object 1370 * 1371 * @param env Indicates the environment that the API is invoked under 1372 * @param contentResult Indicates a js object to be converted 1373 * @param content Indicates a button object from specified js object 1374 * @return Returns the null object if success, returns the null value otherwise 1375 */ 1376 static napi_value GetNotificationLocalLiveViewCardButton( 1377 const napi_env &env, const napi_value &contentResult, 1378 std::shared_ptr<OHOS::Notification::NotificationLocalLiveViewContent> content); 1379 1380 /** 1381 * @brief Gets a capsule button of NotificationCapsule object from specified js object 1382 * 1383 * @param env Indicates the environment that the API is invoked under 1384 * @param capsuletResult Indicates a js object to be converted 1385 * @param capsule Indicates a capsule object from specified js object 1386 * @return Returns the null object if success, returns the null value otherwise 1387 */ 1388 static napi_value GetNotificationLocalLiveViewCapsuleCardButton( 1389 const napi_env &env, const napi_value &capsuletResult, 1390 OHOS::Notification::NotificationCapsule &capsule); 1391 1392 /** 1393 * @brief Gets array<iconbutton> of NotificationCapsule object from specified js object 1394 * 1395 * @param env Indicates the environment that the API is invoked under 1396 * @param buttonResult Indicates a js array<object> to be converted 1397 * @param cardButtons Indicates a button array from specified js object 1398 * @return Returns the null object if success, returns the null value otherwise 1399 */ 1400 static napi_value GetNotificationIconButton( 1401 const napi_env &env, const napi_value &buttonResult, 1402 std::vector<NotificationIconButton> &cardButtons, const uint32_t maxLen); 1403 1404 /** 1405 * @brief Gets a time of NotificationLocalLiveViewContent 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 content Indicates a time object from specified js object 1410 * @return Returns the null object if success, returns the null value otherwise 1411 */ 1412 static napi_value GetNotificationLocalLiveViewTime( 1413 const napi_env &env, const napi_value &contentResult, 1414 std::shared_ptr<OHOS::Notification::NotificationLocalLiveViewContent> content); 1415 1416 /** 1417 * @brief Gets a progress of NotificationLocalLiveViewContent 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 content Indicates a progress object from specified js object 1422 * @return Returns the null object if success, returns the null value otherwise 1423 */ 1424 static napi_value GetNotificationLocalLiveViewProgress( 1425 const napi_env &env, const napi_value &contentResult, 1426 std::shared_ptr<OHOS::Notification::NotificationLocalLiveViewContent> content); 1427 1428 /** 1429 * @brief Gets a NotificationLocalLiveViewContent 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 content Indicates a NotificationLocalLiveViewContent object from specified js object 1434 * @return Returns the null object if success, returns the null value otherwise 1435 */ 1436 static napi_value GetNotificationLocalLiveViewContentDetailed( 1437 const napi_env &env, const napi_value &contentResult, 1438 std::shared_ptr<OHOS::Notification::NotificationLocalLiveViewContent> content); 1439 1440 /** 1441 * @brief Gets a conversational content of NotificationRequest object from specified js object 1442 * 1443 * @param env Indicates the environment that the API is invoked under 1444 * @param result Indicates a js object to be converted 1445 * @param request Indicates a NotificationRequest object from specified js object 1446 * @return Returns the null object if success, returns the null value otherwise 1447 */ 1448 static napi_value GetNotificationConversationalContent( 1449 const napi_env &env, const napi_value &result, NotificationRequest &request); 1450 1451 /** 1452 * @brief Gets the user of NotificationConversationalContent object from specified js object 1453 * 1454 * @param env Indicates the environment that the API is invoked under 1455 * @param contentResult Indicates a js object to be converted 1456 * @param user Indicates a MessageUser object from specified js object 1457 * @return Returns the null object if success, returns the null value otherwise 1458 */ 1459 static napi_value GetNotificationConversationalContentByUser( 1460 const napi_env &env, const napi_value &contentResult, MessageUser &user); 1461 1462 /** 1463 * @brief Gets the title of NotificationConversationalContent object from specified js object 1464 * 1465 * @param env Indicates the environment that the API is invoked under 1466 * @param contentResult Indicates a js object to be converted 1467 * @param conversationalContent Indicates a NotificationConversationalContent object from specified js object 1468 * @return Returns the null object if success, returns the null value otherwise 1469 */ 1470 static napi_value GetNotificationConversationalContentTitle( 1471 const napi_env &env, const napi_value &contentResult, 1472 std::shared_ptr<OHOS::Notification::NotificationConversationalContent> &conversationalContent); 1473 1474 /** 1475 * @brief Gets the group of NotificationConversationalContent object from specified js object 1476 * 1477 * @param env Indicates the environment that the API is invoked under 1478 * @param contentResult Indicates a js object to be converted 1479 * @param conversationalContent Indicates a NotificationConversationalContent object from specified js object 1480 * @return Returns the null object if success, returns the null value otherwise 1481 */ 1482 static napi_value GetNotificationConversationalContentGroup( 1483 const napi_env &env, const napi_value &contentResult, 1484 std::shared_ptr<OHOS::Notification::NotificationConversationalContent> &conversationalContent); 1485 1486 /** 1487 * @brief Gets the messages of NotificationConversationalContent object from specified js object 1488 * 1489 * @param env Indicates the environment that the API is invoked under 1490 * @param contentResult Indicates a js object to be converted 1491 * @param conversationalContent Indicates a NotificationConversationalContent object from specified js object 1492 * @return Returns the null object if success, returns the null value otherwise 1493 */ 1494 static napi_value GetNotificationConversationalContentMessages( 1495 const napi_env &env, const napi_value &contentResult, 1496 std::shared_ptr<OHOS::Notification::NotificationConversationalContent> &conversationalContent); 1497 1498 /** 1499 * @brief Gets a NotificationConversationalMessage object from specified js object 1500 * 1501 * @param env Indicates the environment that the API is invoked under 1502 * @param conversationalMessage Indicates a js object to be converted 1503 * @param message Indicates a NotificationConversationalMessage object from specified js object 1504 * @return Returns the null object if success, returns the null value otherwise 1505 */ 1506 static napi_value GetConversationalMessage( 1507 const napi_env &env, const napi_value &conversationalMessage, 1508 std::shared_ptr<NotificationConversationalMessage> &message); 1509 1510 /** 1511 * @brief Gets the basic information of NotificationConversationalMessage object from specified js object 1512 * 1513 * @param env Indicates the environment that the API is invoked under 1514 * @param conversationalMessage Indicates a js object to be converted 1515 * @param message Indicates a NotificationConversationalMessage object from specified js object 1516 * @return Returns the null object if success, returns the null value otherwise 1517 */ 1518 static napi_value GetConversationalMessageBasicInfo( 1519 const napi_env &env, const napi_value &conversationalMessage, 1520 std::shared_ptr<NotificationConversationalMessage> &message); 1521 1522 /** 1523 * @brief Gets the other information of NotificationConversationalMessage object from specified js object 1524 * 1525 * @param env Indicates the environment that the API is invoked under 1526 * @param conversationalMessage Indicates a js object to be converted 1527 * @param message Indicates a NotificationConversationalMessage object from specified js object 1528 * @return Returns the null object if success, returns the null value otherwise 1529 */ 1530 static napi_value GetConversationalMessageOtherInfo( 1531 const napi_env &env, const napi_value &conversationalMessage, 1532 std::shared_ptr<NotificationConversationalMessage> &message); 1533 1534 /** 1535 * @brief Gets a MessageUser object from specified js object 1536 * 1537 * @param env Indicates the environment that the API is invoked under 1538 * @param result Indicates a js object to be converted 1539 * @param messageUser Indicates a MessageUser object from specified js object 1540 * @return Returns the null object if success, returns the null value otherwise 1541 */ 1542 static napi_value GetMessageUser(const napi_env &env, const napi_value &result, MessageUser &messageUser); 1543 1544 /** 1545 * @brief Gets a MessageUser object from specified js object 1546 * 1547 * @param env Indicates the environment that the API is invoked under 1548 * @param result Indicates a js object to be converted 1549 * @param messageUser Indicates a MessageUser object from specified js object 1550 * @return Returns the null object if success, returns the null value otherwise 1551 */ 1552 static napi_value GetMessageUserByString(const napi_env &env, const napi_value &result, MessageUser &messageUser); 1553 1554 /** 1555 * @brief Gets the bool objects of MessageUser object from specified js object 1556 * 1557 * @param env Indicates the environment that the API is invoked under 1558 * @param result Indicates a js object to be converted 1559 * @param messageUser Indicates a MessageUser object from specified js object 1560 * @return Returns the null object if success, returns the null value otherwise 1561 */ 1562 static napi_value GetMessageUserByBool(const napi_env &env, const napi_value &result, MessageUser &messageUser); 1563 1564 /** 1565 * @brief Gets the custom objects of MessageUser object from specified js object 1566 * 1567 * @param env Indicates the environment that the API is invoked under 1568 * @param result Indicates a js object to be converted 1569 * @param messageUser Indicates a MessageUser object from specified js object 1570 * @return Returns the null object if success, returns the null value otherwise 1571 */ 1572 static napi_value GetMessageUserByCustom(const napi_env &env, const napi_value &result, MessageUser &messageUser); 1573 1574 /** 1575 * @brief Gets the multi-line content of NotificationRequest object from specified js object 1576 * 1577 * @param env Indicates the environment that the API is invoked under 1578 * @param result Indicates a js object to be converted 1579 * @param multiLineContent Indicates a NotificationMultiLineContent object from specified js object 1580 * @return Returns the null object if success, returns the null value otherwise 1581 */ 1582 static napi_value GetNotificationContentLineWantAgents(const napi_env &env, const napi_value &result, 1583 std::shared_ptr<OHOS::Notification::NotificationMultiLineContent> &multiLineContent); 1584 1585 /** 1586 * @brief Gets the multi-line content of NotificationRequest object from specified js object 1587 * 1588 * @param env Indicates the environment that the API is invoked under 1589 * @param result Indicates a js object to be converted 1590 * @param request Indicates a NotificationRequest object from specified js object 1591 * @return Returns the null object if success, returns the null value otherwise 1592 */ 1593 static napi_value GetNotificationMultiLineContent( 1594 const napi_env &env, const napi_value &result, NotificationRequest &request); 1595 1596 /** 1597 * @brief Gets the lines of NotificationMultiLineContent object from specified js object 1598 * 1599 * @param env Indicates the environment that the API is invoked under 1600 * @param result Indicates a js object to be converted 1601 * @param multiLineContent Indicates a NotificationMultiLineContent object from specified js object 1602 * @return Returns the null object if success, returns the null value otherwise 1603 */ 1604 static napi_value GetNotificationMultiLineContentLines(const napi_env &env, const napi_value &result, 1605 std::shared_ptr<OHOS::Notification::NotificationMultiLineContent> &multiLineContent); 1606 1607 /** 1608 * @brief Gets the liveView content of NotificationRequest object from specified js object 1609 * 1610 * @param env Indicates the environment that the API is invoked under 1611 * @param result Indicates a js object to be converted 1612 * @param request Indicates a NotificationRequest object from specified js object 1613 * @return Returns the null object if success, returns the null value otherwise 1614 */ 1615 static napi_value GetNotificationLiveViewContent( 1616 const napi_env &env, const napi_value &result, NotificationRequest &request); 1617 1618 /** 1619 * @brief Gets a NotificationLiveViewContent object from specified js object 1620 * 1621 * @param env Indicates the environment that the API is invoked under 1622 * @param contentResult Indicates a js object to be converted 1623 * @param liveViewContent Indicates a NotificationMultiLineContent object from specified js object 1624 * @return Returns the null object if success, returns the null value otherwise 1625 */ 1626 static napi_value GetNotificationLiveViewContentDetailed(const napi_env &env, const napi_value &contentResult, 1627 std::shared_ptr<NotificationLiveViewContent> &liveViewContent); 1628 1629 /** 1630 * @brief Gets a GetLiveViewPictures from specified js object 1631 * 1632 * @param env Indicates the environment that the API is invoked under 1633 * @param picturesObj Indicates a js object to be converted 1634 * @param pictures Indicates pictures object from specified js object 1635 * @return Returns the null object if success, returns the null value otherwise 1636 */ 1637 static napi_value GetLiveViewPictures(const napi_env &env, const napi_value &picturesObj, 1638 std::vector<std::shared_ptr<Media::PixelMap>> &pictures); 1639 1640 /** 1641 * @brief Gets a GetLiveViewPictures from specified js object 1642 * 1643 * @param env Indicates the environment that the API is invoked under 1644 * @param pictureMapObj Indicates a js object to be converted 1645 * @param pictureMap Indicates picturemap from specified js object 1646 * @return Returns the null object if success, returns the null value otherwise 1647 */ 1648 static napi_value GetLiveViewPictureInfo(const napi_env &env, const napi_value &pictureMapObj, 1649 std::map<std::string, std::vector<std::shared_ptr<Media::PixelMap>>> &pictureMap); 1650 1651 /** 1652 * @brief Gets a NotificationBundleOption object from specified js object 1653 * 1654 * @param env Indicates the environment that the API is invoked under 1655 * @param value Indicates a js object to be converted 1656 * @param option Indicates a NotificationBundleOption object from specified js object 1657 * @return Returns the null object if success, returns the null value otherwise 1658 */ 1659 static napi_value GetBundleOption(const napi_env &env, const napi_value &value, NotificationBundleOption &option); 1660 1661 /** 1662 * @brief Gets a NotificationButtonOption object from specified js object 1663 * 1664 * @param env Indicates the environment that the API is invoked under 1665 * @param value Indicates a js object to be converted 1666 * @param option Indicates a NotificationButtonOption object from specified js object 1667 * @return Returns the null object if success, returns the null value otherwise 1668 */ 1669 static napi_value GetButtonOption(const napi_env &env, const napi_value &value, NotificationButtonOption &option); 1670 1671 /** 1672 * @brief Gets a NotificationBundleOption object from specified js object 1673 * 1674 * @param env Indicates the environment that the API is invoked under 1675 * @param value Indicates a js object to be converted 1676 * @param option Indicates a NotificationBundleOption object from specified js object 1677 * @return Returns the null object if success, returns the null value otherwise 1678 */ 1679 static napi_value GetBundleOption( 1680 const napi_env &env, 1681 const napi_value &value, 1682 std::shared_ptr<NotificationBundleOption> &option); 1683 1684 /** 1685 * @brief Gets a DistributedBundleOption object from specified js object 1686 * 1687 * @param env Indicates the environment that the API is invoked under 1688 * @param value Indicates a js object to be converted 1689 * @param option Indicates a DistributedBundleOption object from specified js object 1690 * @return Returns the null object if success, returns the null value otherwise 1691 */ 1692 static napi_value GetDistributedBundleOption( 1693 const napi_env &env, 1694 const napi_value &value, 1695 DistributedBundleOption &option); 1696 1697 static napi_value GetHashCodes(const napi_env &env, const napi_value &value, std::vector<std::string> &hashCodes); 1698 1699 static napi_value GetLiveViewWantAgent(const napi_env &env, const napi_value &value, 1700 std::shared_ptr<NotificationLiveViewContent> &liveViewContent); 1701 /** 1702 * @brief Gets a NotificationKey object from specified js object 1703 * 1704 * @param env Indicates the environment that the API is invoked under 1705 * @param value Indicates a js object to be converted 1706 * @param key Indicates a NotificationKey object from specified js object 1707 * @return Returns the null object if success, returns the null value otherwise 1708 */ 1709 static napi_value GetNotificationKey(const napi_env &env, const napi_value &value, NotificationKey &key); 1710 1711 /** 1712 * @brief Creates a js object from specified WantAgent object 1713 * 1714 * @param env Indicates the environment that the API is invoked under 1715 * @param agent Indicates specified WantAgent object 1716 * @return Returns a js object from specified WantAgent object 1717 */ 1718 static napi_value CreateWantAgentByJS(const napi_env &env, 1719 const std::shared_ptr<AbilityRuntime::WantAgent::WantAgent> &agent); 1720 1721 /** 1722 * @brief Gets the template of NotificationRequest object from specified js object 1723 * 1724 * @param env Indicates the environment that the API is invoked under 1725 * @param value Indicates a js object to be converted 1726 * @param request Indicates a NotificationRequest object from specified js object 1727 * @return Returns the null object if success, returns the null value otherwise 1728 */ 1729 static napi_value GetNotificationTemplate( 1730 const napi_env &env, const napi_value &value, NotificationRequest &request); 1731 1732 /** 1733 * @brief Gets a NotificationTemplate object from specified js object 1734 * 1735 * @param env Indicates the environment that the API is invoked under 1736 * @param value Indicates a js object to be converted 1737 * @param templ Indicates a NotificationTemplate object from specified js object 1738 * @return Returns the null object if success, returns the null value otherwise 1739 */ 1740 static napi_value GetNotificationTemplateInfo(const napi_env &env, const napi_value &value, 1741 std::shared_ptr<NotificationTemplate> &templ); 1742 1743 /** 1744 * @brief Sets a js object by specified NotificationTemplate object 1745 * 1746 * @param env Indicates the environment that the API is invoked under 1747 * @param templ Indicates a NotificationTemplate object to be converted 1748 * @param result Indicates a js object to be set 1749 * @return Returns the null object if success, returns the null value otherwise 1750 */ 1751 static napi_value SetNotificationTemplateInfo( 1752 const napi_env &env, const std::shared_ptr<NotificationTemplate> &templ, napi_value &result); 1753 1754 /** 1755 * @brief Sets a js object by specified NotificationBundleOption object. 1756 * 1757 * @param env Indicates the environment that the API is invoked under. 1758 * @param NotificationBundleOption Indicates a NotificationBundleOption object to be converted. 1759 * @param result Indicates a js object to be set. 1760 * @return Returns the null object if success, returns the null value otherwise. 1761 */ 1762 static napi_value SetNotificationEnableStatus( 1763 const napi_env &env, const NotificationBundleOption &bundleOption, napi_value &result); 1764 1765 /** 1766 * @brief Sets a js object by specified NotificationFlags object 1767 * 1768 * @param env Indicates the environment that the API is invoked under 1769 * @param flags Indicates a NotificationFlags object to be converted 1770 * @param result Indicates a js object to be set 1771 * @return Returns the null object if success, returns the null value otherwise 1772 */ 1773 static napi_value SetNotificationFlags( 1774 const napi_env &env, const std::shared_ptr<NotificationFlags> &flags, napi_value &result); 1775 1776 /** 1777 * @brief Sets a js object by specified NotificationUnifiedGroupInfo object 1778 * 1779 * @param env Indicates the environment that the API is invoked under 1780 * @param flags Indicates a NotificationUnifiedGroupInfo object to be converted 1781 * @param result Indicates a js object to be set 1782 * @return Returns the null object if success, returns the null value otherwise 1783 */ 1784 static napi_value SetNotificationUnifiedGroupInfo( 1785 const napi_env &env, const std::shared_ptr<NotificationUnifiedGroupInfo> &info, napi_value &result); 1786 1787 /** 1788 * @brief Gets the number of badge of NotificationRequest object from specified js object 1789 * 1790 * @param env Indicates the environment that the API is invoked under 1791 * @param value Indicates a js object to be converted 1792 * @param request Indicates a NotificationRequest object from specified js object 1793 * @return Returns the null object if success, returns the null value otherwise 1794 */ 1795 static napi_value GetNotificationBadgeNumber( 1796 const napi_env &env, const napi_value &value, NotificationRequest &request); 1797 1798 /** 1799 * @brief Gets a NotificationUnifiedGroupInfo object from specified js object 1800 * 1801 * @param env Indicates the environment that the API is invoked under 1802 * @param value Indicates a js object to be converted 1803 * @param templ Indicates a NotificationUnifiedGroupInfo object from specified js object 1804 * @return Returns the null object if success, returns the null value otherwise 1805 */ 1806 static napi_value GetNotificationUnifiedGroupInfo( 1807 const napi_env &env, const napi_value &value, NotificationRequest &request); 1808 1809 /** 1810 * @brief Gets the notification control flags of NotificationRequest object from specified js object. 1811 * 1812 * @param env Indicates the environment that the API is invoked under 1813 * @param value Indicates a js object to be converted 1814 * @param request Indicates a NotificationRequest object from specified js object 1815 * @return Returns the null object if success, returns the null value otherwise 1816 */ 1817 static napi_value GetNotificationControlFlags( 1818 const napi_env &env, const napi_value &value, NotificationRequest &request); 1819 1820 /** 1821 * @brief Create a napi value with specified error object for callback 1822 * 1823 * @param env Indicates the environment that the API is invoked under 1824 * @param errCode Indicates specified err code 1825 * @return Returns a napi value with specified error object for callback 1826 */ 1827 static napi_value CreateErrorValue(napi_env env, int32_t errCode, bool newType); 1828 1829 /** 1830 * @brief Create a napi value with specified error object for callback 1831 * 1832 * @param env Indicates the environment that the API is invoked under 1833 * @param errCode Indicates specified err code 1834 * @param msg Indicates specified msg 1835 * @return Returns a napi value with specified error object for callback 1836 */ 1837 static napi_value CreateErrorValue(napi_env env, int32_t errCode, std::string &msg); 1838 1839 /** 1840 * @brief Sets a js object by specified BadgeNumberCallbackData object 1841 * 1842 * @param env Indicates the environment that the API is invoked under 1843 * @param date Indicates a BadgeNumberCallbackData object to be converted 1844 * @param result Indicates a js object to be set 1845 * @return Returns the null object if success, returns the null value otherwise 1846 */ 1847 static napi_value SetBadgeCallbackData(const napi_env &env, 1848 const BadgeNumberCallbackData &data, napi_value &result); 1849 1850 /** 1851 * @brief Gets the notificationBundleOption of NotificationRequest object from specified js object 1852 * 1853 * @param env Indicates the environment that the API is invoked under 1854 * @param value Indicates a js object to be converted 1855 * @param request Indicates a NotificationRequest object from specified js object 1856 * @return Returns the null object if success, returns the null value otherwise 1857 */ 1858 static napi_value GetNotificationBundleOption( 1859 const napi_env &env, const napi_value &value, NotificationRequest &request); 1860 /** 1861 * @brief Sets a js object by specified NotificationDoNotDisturbProfile object 1862 * 1863 * @param env Indicates the environment that the API is invoked under 1864 * @param date Indicates a NotificationDoNotDisturbProfile object to be converted 1865 * @param result Indicates a js object to be set 1866 * @return Returns the null object if success, returns the null value otherwise 1867 */ 1868 static napi_value SetDoNotDisturbProfile( 1869 const napi_env &env, const NotificationDoNotDisturbProfile &data, napi_value &result); 1870 1871 static napi_value SetBundleOption( 1872 const napi_env &env, const NotificationBundleOption &bundleInfo, napi_value &result); 1873 static bool IsValidRemoveReason(int32_t reasonType); 1874 static void NapiThrow(napi_env env, int32_t errCode); 1875 static void NapiThrow(napi_env env, int32_t errCode, std::string &msg); 1876 static napi_value NapiReturnCapErrCb(napi_env env, napi_callback_info info); 1877 static napi_value NapiReturnCapErr(napi_env env, napi_callback_info info); 1878 static napi_value NapiReturnFalseCb(napi_env env, napi_callback_info info); 1879 static napi_value NapiReturnFalseCbNewType(napi_env env, napi_callback_info info); 1880 static void CreateReturnValue(const napi_env &env, const CallbackPromiseInfo &info, const napi_value &result); 1881 static napi_value GetLockScreenPicture( 1882 const napi_env &env, const napi_value &contentResult, std::shared_ptr<NotificationBasicContent> basicContent); 1883 static napi_value SetLockScreenPicture( 1884 const napi_env &env, const NotificationBasicContent *basicContent, napi_value &result); 1885 static napi_value SetAgentBundle(const napi_env &env, 1886 const std::shared_ptr<NotificationBundleOption> &agentBundle, napi_value &result); 1887 static napi_value GetResourceObject(napi_env env, std::shared_ptr<ResourceManager::Resource> &resource, 1888 napi_value &value); 1889 static napi_value SetResourceObject(napi_env env, const std::shared_ptr<ResourceManager::Resource> &resource, 1890 napi_value &value); 1891 static napi_value SetObjectStringProperty(const napi_env &env, napi_value& object, const std::string& key, 1892 const std::string& value); 1893 static napi_value SetObjectUint32Property(const napi_env &env, napi_value& object, const std::string& key, 1894 uint32_t value); 1895 static std::string GetAppInstanceKey(); 1896 static void PictureScale(std::shared_ptr<Media::PixelMap> pixelMap); 1897 private: 1898 static const int32_t ARGS_ONE = 1; 1899 static const int32_t ARGS_TWO = 2; 1900 static const int32_t ONLY_CALLBACK_MAX_PARA = 1; 1901 static const int32_t ONLY_CALLBACK_MIN_PARA = 0; 1902 static std::set<std::shared_ptr<AbilityRuntime::WantAgent::WantAgent>> wantAgent_; 1903 static ffrt::mutex mutex_; 1904 static const char *GetPropertyNameByContentType(ContentType type); 1905 static napi_value NapiReturnFalseCbInner(napi_env env, napi_callback_info info, bool newType); 1906 }; 1907 } // namespace NotificationNapi 1908 } // namespace OHOS 1909 1910 #endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_FRAMEWORKS_JS_NAPI_INCLUDE_COMMON_H 1911