1 /*
2  * Copyright (c) 2024 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_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_CONVER_ENUM_H
17 #define BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_CONVER_ENUM_H
18 
19 #include "notification_constant.h"
20 #include "notification_content.h"
21 #include "notification_slot.h"
22 
23 namespace OHOS {
24 namespace NotificationNapi {
25 using namespace OHOS::Notification;
26 
27 enum class ContentType {
28     NOTIFICATION_CONTENT_BASIC_TEXT,
29     NOTIFICATION_CONTENT_LONG_TEXT,
30     NOTIFICATION_CONTENT_PICTURE,
31     NOTIFICATION_CONTENT_CONVERSATION,
32     NOTIFICATION_CONTENT_MULTILINE,
33     NOTIFICATION_CONTENT_LOCAL_LIVE_VIEW,
34     NOTIFICATION_CONTENT_LIVE_VIEW
35 };
36 
37 enum class SlotType {
38     UNKNOWN_TYPE = 0,
39     SOCIAL_COMMUNICATION = 1,
40     SERVICE_INFORMATION = 2,
41     CONTENT_INFORMATION = 3,
42     LIVE_VIEW = 4,
43     CUSTOMER_SERVICE = 5,
44     EMERGENCY_INFORMATION = 10,
45     OTHER_TYPES = 0xFFFF,
46 };
47 
48 enum class SlotLevel {
49     LEVEL_NONE = 0,
50     LEVEL_MIN = 1,
51     LEVEL_LOW = 2,
52     LEVEL_DEFAULT = 3,
53     LEVEL_HIGH = 4,
54 };
55 
56 enum class RemoveReason {
57     DEFAULT_REASON_DELETE = 0,
58     CLICK_REASON_REMOVE = 1,
59     CANCEL_REASON_REMOVE = 2,
60     CANCEL_ALL_REASON_REMOVE = 3,
61     ERROR_REASON_REMOVE = 4,
62     PACKAGE_CHANGED_REASON_REMOVE = 5,
63     USER_STOPPED_REASON_REMOVE = 6,
64     PACKAGE_BANNED_REASON_REMOVE = 7,
65     APP_CANCEL_REASON_REMOVE = 8,
66     APP_CANCEL_ALL_REASON_REMOVE = 9,
67     USER_REMOVED_REASON_DELETE = 10,
68     FLOW_CONTROL_REASON_DELETE = 11,
69     DISABLE_SLOT_REASON_DELETE = 12,
70     DISABLE_NOTIFICATION_REASON_DELETE = 13,
71     APP_CANCEL_AS_BUNELE_REASON_DELETE = 14,
72     APP_CANCEL_AS_BUNELE_WITH_AGENT_REASON_DELETE = 15,
73     APP_CANCEL_REMINDER_REASON_DELETE = 16,
74     APP_CANCEL_GROPU_REASON_DELETE = 17,
75     APP_REMOVE_GROUP_REASON_DELETE = 18,
76     APP_REMOVE_ALL_REASON_DELETE = 19,
77     APP_REMOVE_ALL_USER_REASON_DELETE = 20,
78     TRIGGER_EIGHT_HOUR_REASON_DELETE = 21,
79     TRIGGER_FOUR_HOUR_REASON_DELETE = 22,
80     TRIGGER_TEN_MINUTES_REASON_DELETE = 23,
81     TRIGGER_FIFTEEN_MINUTES_REASON_DELETE = 24,
82     TRIGGER_THIRTY_MINUTES_REASON_DELETE = 25,
83     TRIGGER_START_ARCHIVE_REASON_DELETE = 26,
84     TRIGGER_AUTO_DELETE_REASON_DELETE = 27,
85     PACKAGE_REMOVE_REASON_DELETE = 28,
86     SLOT_ENABLED_REASON_DELETE = 29,
87     RECOVER_LIVE_VIEW_DELETE = 30,
88     APP_CANCEL_REASON_OTHER = 100,
89 };
90 
91 enum class DoNotDisturbType {
92     TYPE_NONE, TYPE_ONCE,
93     TYPE_DAILY, TYPE_CLEARLY
94 };
95 
96 enum class SourceType {
97     TYPE_NORMAL = 0x00000000,
98     TYPE_CONTINUOUS = 0x00000001,
99     TYPE_TIMER = 0x00000002
100 };
101 
102 enum class NotificationControlFlagStatus {
103     NOTIFICATION_STATUS_CLOSE_SOUND = 1 << 0,
104     NOTIFICATION_STATUS_CLOSE_LOCKSCREEN = 1 << 1,
105     NOTIFICATION_STATUS_CLOSE_BANNER = 1 << 2,
106     NOTIFICATION_STATUS_CLOSE_LIGHT_SCREEN = 1 << 3,
107     NOTIFICATION_STATUS_CLOSE_VIBRATION = 1 << 4,
108     NOTIFICATION_STATUS_CLOSE_STATUSBAR_ICON = 1 << 5
109 };
110 
111 enum class DeviceRemindType {
112     IDLE_DONOT_REMIND,
113     IDLE_REMIND,
114     ACTIVE_DONOT_REMIND,
115     ACTIVE_REMIND
116 };
117 
118 enum class LiveViewStatus {
119     LIVE_VIEW_CREATE,
120     LIVE_VIEW_INCREMENTAL_UPDATE,
121     LIVE_VIEW_END,
122     LIVE_VIEW_FULL_UPDATE,
123     LIVE_VIEW_BUTT
124 };
125 
126 class AnsEnumUtil {
127 public:
128     /**
129      * @brief Converts content type from js to native
130      *
131      * @param inType Indicates a js ContentType object
132      * @param outType Indicates a NotificationContent object
133      * @return Returns true if success, returns false otherwise
134      */
135     static bool ContentTypeJSToC(const ContentType &inType, NotificationContent::Type &outType);
136 
137     /**
138      * @brief Converts content type from native to js
139      *
140      * @param inType Indicates a NotificationContent object
141      * @param outType Indicates a js ContentType object
142      * @return Returns true if success, returns false otherwise
143      */
144     static bool ContentTypeCToJS(const NotificationContent::Type &inType, ContentType &outType);
145 
146     /**
147      * @brief Converts slot type from js to native
148      *
149      * @param inType Indicates a native SlotType object
150      * @param outType Indicates a js SlotType object
151      * @return Returns true if success, returns false otherwise
152      */
153     static bool SlotTypeJSToC(const SlotType &inType, NotificationConstant::SlotType &outType);
154 
155     /**
156      * @brief Converts slot type from native to js
157      *
158      * @param inType Indicates a js SlotType object
159      * @param outType Indicates a native SlotType object
160      * @return Returns true if success, returns false otherwise
161      */
162     static bool SlotTypeCToJS(const NotificationConstant::SlotType &inType, SlotType &outType);
163 
164     /**
165      * @brief Converts slot level from js to native
166      *
167      * @param inType Indicates a native SlotLevel object
168      * @param outType Indicates a js NotificationLevel object
169      * @return Returns true if success, returns false otherwise
170      */
171     static bool SlotLevelJSToC(const SlotLevel &inLevel, NotificationSlot::NotificationLevel &outLevel);
172 
173     /**
174      * @brief Converts liveview status from js to native
175      *
176      * @param inType Indicates a js liveview status object
177      * @param outType Indicates a liveview status object
178      * @return Returns true if success, returns false otherwise
179      */
180     static bool LiveViewStatusJSToC(const LiveViewStatus &inType, NotificationLiveViewContent::LiveViewStatus &outType);
181 
182     /**
183      * @brief Converts slot level from native to js
184      *
185      * @param inType Indicates a js NotificationLevel object
186      * @param outType Indicates a native SlotLevel object
187      * @return Returns true if success, returns false otherwise
188      */
189     static bool SlotLevelCToJS(const NotificationSlot::NotificationLevel &inLevel, SlotLevel &outLevel);
190 
191     /**
192      * @brief Converts reason type from native to js
193      *
194      * @param inType Indicates a native reason type
195      * @param outType Indicates a js reason type
196      * @return Returns true if success, returns false otherwise
197      */
198     static bool ReasonCToJS(const int32_t &inType, int32_t &outType);
199 
200     /**
201      * @brief Converts do-not-disturb type from js to native
202      *
203      * @param inType Indicates a js DoNotDisturbType object
204      * @param outType Indicates a native DoNotDisturbType object
205      * @return Returns true if success, returns false otherwise
206      */
207     static bool DoNotDisturbTypeJSToC(const DoNotDisturbType &inType, NotificationConstant::DoNotDisturbType &outType);
208 
209     /**
210      * @brief Converts do-not-disturb type from native to js
211      *
212      * @param inType Indicates a native DoNotDisturbType object
213      * @param outType Indicates a js DoNotDisturbType object
214      * @return Returns true if success, returns false otherwise
215      */
216     static bool DoNotDisturbTypeCToJS(const NotificationConstant::DoNotDisturbType &inType, DoNotDisturbType &outType);
217 
218     /**
219      * @brief Converts remind type from native to js
220      *
221      * @param inType Indicates a native RemindType object
222      * @param outType Indicates a js DeviceRemindType object
223      * @return Returns true if success, returns false otherwise
224      */
225     static bool DeviceRemindTypeCToJS(const NotificationConstant::RemindType &inType, DeviceRemindType &outType);
226 
227     /**
228      * @brief Converts source type from native to js
229      *
230      * @param inType Indicates a native SourceType object
231      * @param outType Indicates a js SourceType object
232      * @return Returns true if success, returns false otherwise
233      */
234     static bool SourceTypeCToJS(const NotificationConstant::SourceType &inType, SourceType &outType);
235 
236     /**
237      * @brief Converts liveview status type from native to js
238      *
239      * @param inType Indicates a native liveview status object
240      * @param outType Indicates a js liveview status object
241      * @return Returns true if success, returns false otherwise
242      */
243     static bool LiveViewStatusCToJS(const NotificationLiveViewContent::LiveViewStatus &inType, LiveViewStatus &outType);
244 };
245 }
246 }
247 
248 #endif
249