1 /*
2  * Copyright (c) 2021-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 #ifndef BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_FRAMEWORKS_JS_NAPI_INCLUDE_DISTURB_MODE_H
16 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_FRAMEWORKS_JS_NAPI_INCLUDE_DISTURB_MODE_H
17 
18 #include "common.h"
19 
20 namespace OHOS {
21 namespace NotificationNapi {
22 using namespace OHOS::Notification;
23 
24 struct GetDoNotDisturbProfileParams {
25     int32_t profileId = INVALID_PROFILE_ID;
26     napi_ref callback = nullptr;
27 };
28 
29 struct SetDoNotDisturbDateParams {
30     NotificationDoNotDisturbDate date;
31     bool hasUserId = false;
32     int32_t userId = SUBSCRIBE_USER_INIT;
33     napi_ref callback = nullptr;
34 };
35 
36 struct GetDoNotDisturbDateParams {
37     bool hasUserId = false;
38     int32_t userId = SUBSCRIBE_USER_INIT;
39     napi_ref callback = nullptr;
40 };
41 
42 struct AsyncCallbackInfoSetDoNotDisturb {
43     napi_env env = nullptr;
44     napi_async_work asyncWork = nullptr;
45     SetDoNotDisturbDateParams params;
46     CallbackPromiseInfo info;
47 };
48 
49 struct AsyncCallbackInfoDoNotDisturbProfile {
50     napi_env env = nullptr;
51     napi_async_work asyncWork = nullptr;
52     std::vector<sptr<NotificationDoNotDisturbProfile>> profiles;
53     CallbackPromiseInfo info;
54 };
55 
56 struct AsyncCallbackInfoGetDoNotDisturb {
57     napi_env env = nullptr;
58     napi_async_work asyncWork = nullptr;
59     GetDoNotDisturbDateParams params;
60     NotificationDoNotDisturbDate date;
61     CallbackPromiseInfo info;
62 };
63 
64 struct AsyncCallbackInfoSupportDoNotDisturb {
65     napi_env env = nullptr;
66     napi_async_work asyncWork = nullptr;
67     napi_ref callback = nullptr;
68     bool isSupported = false;
69     CallbackPromiseInfo info;
70 };
71 
72 struct AsyncCallbackInfoGetDoNotDisturbProfile {
73     napi_env env = nullptr;
74     napi_async_work asyncWork = nullptr;
75     GetDoNotDisturbProfileParams params;
76     sptr<NotificationDoNotDisturbProfile> data;
77     CallbackPromiseInfo info;
78 };
79 
80 napi_value SetDoNotDisturbDate(napi_env env, napi_callback_info info);
81 napi_value GetDoNotDisturbDate(napi_env env, napi_callback_info info);
82 napi_value SupportDoNotDisturbMode(napi_env env, napi_callback_info info);
83 
84 napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, SetDoNotDisturbDateParams &params);
85 napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, GetDoNotDisturbDateParams &params);
86 napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, GetDoNotDisturbProfileParams &params);
87 bool ParseProfilesParameters(
88     const napi_env &env, const napi_callback_info &info, std::vector<sptr<NotificationDoNotDisturbProfile>> &profiles);
89 bool AnalyseTrustlist(const napi_env &env, const napi_value &value, sptr<NotificationDoNotDisturbProfile> &profile);
90 }  // namespace NotificationNapi
91 }  // namespace OHOS
92 #endif  // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_FRAMEWORKS_JS_NAPI_INCLUDE_DISTURB_MODE_H
93