1 /* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_FRAMEWORKS_ETS_ANI_INCLUDE_STS_CONVERT_NOTIFICATION_H 17 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_FRAMEWORKS_ETS_ANI_INCLUDE_STS_CONVERT_NOTIFICATION_H 18 #include "ani.h" 19 20 #include "notification_progress.h" 21 #include "notification_time.h" 22 #include "notification_icon_button.h" 23 #include "notification_local_live_view_button.h" 24 #include "notification_capsule.h" 25 26 #include "notification_content.h" 27 #include "notification_basic_content.h" 28 #include "notification_normal_content.h" 29 #include "notification_long_text_content.h" 30 #include "notification_multiline_content.h" 31 #include "notification_picture_content.h" 32 #include "notification_live_view_content.h" 33 #include "notification_local_live_view_content.h" 34 35 using LiveViewStatus = OHOS::Notification::NotificationLiveViewContent::LiveViewStatus; 36 using LiveViewTypes = OHOS::Notification::NotificationLocalLiveViewContent::LiveViewTypes; 37 namespace OHOS { 38 namespace NotificationSts { 39 using namespace OHOS::Notification; 40 41 enum STSLiveViewStatus { 42 LIVE_VIEW_CREATE = 0, 43 LIVE_VIEW_INCREMENTAL_UPDATE = 1, 44 LIVE_VIEW_END = 2, 45 LIVE_VIEW_FULL_UPDATE = 3 46 }; 47 48 class StsLiveViewStatusUtils { 49 public: 50 static bool StsToC(const STSLiveViewStatus inType, LiveViewStatus &outType); 51 static bool CToSts(const LiveViewStatus inType, STSLiveViewStatus &outType); 52 }; 53 54 bool LiveViewStatusEtsToC(ani_env *env, ani_enum_item enumItem, LiveViewStatus &liveViewStatus); 55 bool LiveViewStatusCToEts(ani_env *env, LiveViewStatus liveViewStatus, ani_enum_item &enumItem); 56 57 bool LiveViewTypesEtsToC(ani_env *env, ani_enum_item enumItem, LiveViewTypes &liveViewTypes); 58 bool LiveViewTypesCToEts(ani_env *env, LiveViewTypes liveViewTypes, ani_enum_item &enumItem); 59 60 void UnWarpNotificationProgress(ani_env *env, ani_object obj, NotificationProgress ¬ificationProgress); 61 bool WarpNotificationProgress(ani_env *env, const NotificationProgress &progress, ani_object &progressObject); 62 63 void UnWarpNotificationTime(ani_env *env, ani_object obj, NotificationTime ¬ificationTime); 64 bool WarpNotificationTime(ani_env *env, const NotificationTime &time, bool isInitialTimeExist, ani_object &timeObject); 65 66 ani_status UnWarpNotificationIconButton(ani_env *env, ani_object obj, 67 NotificationIconButton &iconButton); 68 ani_object WarpNotificationIconButton(ani_env *env, const NotificationIconButton &button); 69 ani_status GetIconButtonArray(ani_env *env, 70 ani_object param, const char *name, std::vector<NotificationIconButton> &res); 71 ani_object GetAniIconButtonArray(ani_env *env, const std::vector<NotificationIconButton> buttons); 72 73 void UnWarpNotificationLocalLiveViewButton(ani_env *env, ani_object obj, 74 NotificationLocalLiveViewButton &button); 75 bool WarpNotificationLocalLiveViewButton(ani_env *env, const NotificationLocalLiveViewButton &button, 76 ani_object &buttonObject); 77 78 bool UnWarpNotificationCapsule(ani_env *env, ani_object obj, NotificationCapsule &capsule); 79 bool WarpNotificationCapsule(ani_env *env, const NotificationCapsule &capsule, ani_object &capsuleObject); 80 81 ani_status UnWarpNotificationBasicContent(ani_env *env, ani_object obj, 82 std::shared_ptr<NotificationBasicContent> basicContent); 83 84 ani_status UnWarpNotificationNormalContent(ani_env *env, ani_object obj, 85 std::shared_ptr<NotificationNormalContent> &normalContent); 86 ani_status UnWarpNotificationLongTextContent(ani_env *env, ani_object obj, 87 std::shared_ptr<NotificationLongTextContent> &longTextContent); 88 ani_status UnWarpNotificationMultiLineContent(ani_env *env, ani_object obj, 89 std::shared_ptr<NotificationMultiLineContent> &multiLineContent); 90 ani_status UnWarpNotificationPictureContent(ani_env *env, ani_object obj, 91 std::shared_ptr<NotificationPictureContent> &pictureContent); 92 ani_status UnWarpNotificationLiveViewContent(ani_env *env, ani_object obj, 93 std::shared_ptr<NotificationLiveViewContent> &liveViewContent); 94 ani_status UnWarpNotificationLocalLiveViewContent(ani_env *env, ani_object obj, 95 std::shared_ptr<NotificationLocalLiveViewContent> &localLiveViewContent); 96 97 bool SetNotificationContent(ani_env* env, std::shared_ptr<NotificationContent> ncContent, ani_object &ncObj); 98 } // namespace NotificationSts 99 } // OHOS 100 #endif