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