• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     DISABLE_NOTIFICATION_FEATURE_REASON_DELETE = 31,
89     DISTRIBUTED_COLLABORATIVE_DELETE = 32,
90     USER_LOGOUT_REASON_DELETE = 33,
91     DISTRIBUTED_COLLABORATIVE_CLICK_DELETE = 34,
92     DISTRIBUTED_ENABLE_CLOSE_DELETE = 35,
93     DISTRIBUTED_RELEASE_DELETE = 36,
94     APP_CANCEL_REASON_OTHER = 100,
95 };
96 
97 enum class DoNotDisturbType {
98     TYPE_NONE, TYPE_ONCE,
99     TYPE_DAILY, TYPE_CLEARLY
100 };
101 
102 enum class SourceType {
103     TYPE_NORMAL = 0x00000000,
104     TYPE_CONTINUOUS = 0x00000001,
105     TYPE_TIMER = 0x00000002
106 };
107 
108 enum class NotificationControlFlagStatus {
109     NOTIFICATION_STATUS_CLOSE_SOUND = 1 << 0,
110     NOTIFICATION_STATUS_CLOSE_LOCKSCREEN = 1 << 1,
111     NOTIFICATION_STATUS_CLOSE_BANNER = 1 << 2,
112     NOTIFICATION_STATUS_CLOSE_LIGHT_SCREEN = 1 << 3,
113     NOTIFICATION_STATUS_CLOSE_VIBRATION = 1 << 4,
114     NOTIFICATION_STATUS_CLOSE_STATUSBAR_ICON = 1 << 5
115 };
116 
117 enum class DeviceRemindType {
118     IDLE_DONOT_REMIND,
119     IDLE_REMIND,
120     ACTIVE_DONOT_REMIND,
121     ACTIVE_REMIND
122 };
123 
124 enum class LiveViewStatus {
125     LIVE_VIEW_CREATE,
126     LIVE_VIEW_INCREMENTAL_UPDATE,
127     LIVE_VIEW_END,
128     LIVE_VIEW_FULL_UPDATE,
129     LIVE_VIEW_BUTT
130 };
131 
132 enum class LiveViewTypes {
133     LIVE_VIEW_ACTIVITY,
134     LIVE_VIEW_INSTANT,
135     LIVE_VIEW_LONG_TERM,
136     LIVE_VIEW_INSTANT_BANNER
137 };
138 
139 enum class SwitchState {
140     USER_MODIFIED_OFF,
141     USER_MODIFIED_ON,
142     SYSTEM_DEFAULT_OFF,
143     SYSTEM_DEFAULT_ON
144 };
145 
146 class AnsEnumUtil {
147 public:
148     /**
149      * @brief Converts content type from js to native
150      *
151      * @param inType Indicates a js ContentType object
152      * @param outType Indicates a NotificationContent object
153      * @return Returns true if success, returns false otherwise
154      */
155     static bool ContentTypeJSToC(const ContentType &inType, NotificationContent::Type &outType);
156 
157     /**
158      * @brief Converts content type from native to js
159      *
160      * @param inType Indicates a NotificationContent object
161      * @param outType Indicates a js ContentType object
162      * @return Returns true if success, returns false otherwise
163      */
164     static bool ContentTypeCToJS(const NotificationContent::Type &inType, ContentType &outType);
165 
166     /**
167      * @brief Converts slot type from js to native
168      *
169      * @param inType Indicates a native SlotType object
170      * @param outType Indicates a js SlotType object
171      * @return Returns true if success, returns false otherwise
172      */
173     static bool SlotTypeJSToC(const SlotType &inType, NotificationConstant::SlotType &outType);
174 
175     /**
176      * @brief Converts slot type from native to js
177      *
178      * @param inType Indicates a js SlotType object
179      * @param outType Indicates a native SlotType object
180      * @return Returns true if success, returns false otherwise
181      */
182     static bool SlotTypeCToJS(const NotificationConstant::SlotType &inType, SlotType &outType);
183 
184     /**
185      * @brief Converts slot level from js to native
186      *
187      * @param inType Indicates a native SlotLevel object
188      * @param outType Indicates a js NotificationLevel object
189      * @return Returns true if success, returns false otherwise
190      */
191     static bool SlotLevelJSToC(const SlotLevel &inLevel, NotificationSlot::NotificationLevel &outLevel);
192 
193     /**
194      * @brief Converts liveview status from js to native
195      *
196      * @param inType Indicates a js liveview status object
197      * @param outType Indicates a liveview status object
198      * @return Returns true if success, returns false otherwise
199      */
200     static bool LiveViewStatusJSToC(const LiveViewStatus &inType, NotificationLiveViewContent::LiveViewStatus &outType);
201 
202     /**
203      * @brief Converts liveview types from js to native
204      *
205      * @param in Indicates a js liveview type object
206      * @param out Indicates a liveview type object
207      * @return Returns true if success, returns false otherwise
208      */
209     static bool LiveViewTypesJSToC(const LiveViewTypes &in, NotificationLocalLiveViewContent::LiveViewTypes &out);
210 
211     /**
212      * @brief Converts slot level from native to js
213      *
214      * @param inType Indicates a js NotificationLevel object
215      * @param outType Indicates a native SlotLevel object
216      * @return Returns true if success, returns false otherwise
217      */
218     static bool SlotLevelCToJS(const NotificationSlot::NotificationLevel &inLevel, SlotLevel &outLevel);
219 
220     /**
221      * @brief Converts reason type from native to js
222      *
223      * @param inType Indicates a native reason type
224      * @param outType Indicates a js reason type
225      * @return Returns true if success, returns false otherwise
226      */
227     static bool ReasonCToJS(const int32_t &inType, int32_t &outType);
228 
229     /**
230      * @brief Converts reason type from native to js
231      *
232      * @param inType Indicates a native reason type
233      * @param outType Indicates a js reason type
234      * @return Returns true if success, returns false otherwise
235      */
236     static void ReasonCToJSExt(const int32_t &inType, int32_t &outType);
237 
238     /**
239      * @brief Converts reason type from native to js
240      *
241      * @param inType Indicates a native reason type
242      * @param outType Indicates a js reason type
243      * @return Returns true if success, returns false otherwise
244      */
245     static void ReasonCToJSSecondExt(const int32_t &inType, int32_t &outType);
246 
247     /**
248      * @brief Converts do-not-disturb type from js to native
249      *
250      * @param inType Indicates a js DoNotDisturbType object
251      * @param outType Indicates a native DoNotDisturbType object
252      * @return Returns true if success, returns false otherwise
253      */
254     static bool DoNotDisturbTypeJSToC(const DoNotDisturbType &inType, NotificationConstant::DoNotDisturbType &outType);
255 
256     /**
257      * @brief Converts do-not-disturb type from native to js
258      *
259      * @param inType Indicates a native DoNotDisturbType object
260      * @param outType Indicates a js DoNotDisturbType object
261      * @return Returns true if success, returns false otherwise
262      */
263     static bool DoNotDisturbTypeCToJS(const NotificationConstant::DoNotDisturbType &inType, DoNotDisturbType &outType);
264 
265     /**
266      * @brief Converts remind type from native to js
267      *
268      * @param inType Indicates a native RemindType object
269      * @param outType Indicates a js DeviceRemindType object
270      * @return Returns true if success, returns false otherwise
271      */
272     static bool DeviceRemindTypeCToJS(const NotificationConstant::RemindType &inType, DeviceRemindType &outType);
273 
274     /**
275      * @brief Converts source type from native to js
276      *
277      * @param inType Indicates a native SourceType object
278      * @param outType Indicates a js SourceType object
279      * @return Returns true if success, returns false otherwise
280      */
281     static bool SourceTypeCToJS(const NotificationConstant::SourceType &inType, SourceType &outType);
282 
283     /**
284      * @brief Converts liveview status type from native to js
285      *
286      * @param inType Indicates a native liveview status object
287      * @param outType Indicates a js liveview status object
288      * @return Returns true if success, returns false otherwise
289      */
290     static bool LiveViewStatusCToJS(const NotificationLiveViewContent::LiveViewStatus &inType, LiveViewStatus &outType);
291 
292     /**
293      * @brief Converts liveview type from native to js
294      *
295      * @param in Indicates a native liveview type object
296      * @param out Indicates a js liveview type object
297      * @return Returns true if success, returns false otherwise
298      */
299     static bool LiveViewTypesCToJS(const NotificationLocalLiveViewContent::LiveViewTypes &in, LiveViewTypes &out);
300 };
301 }
302 }
303 
304 #endif
305