• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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_JS_NAPI_INCLUDE_DISTRIBUTED_H
17 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_FRAMEWORKS_JS_NAPI_INCLUDE_DISTRIBUTED_H
18 
19 #include "common.h"
20 
21 namespace OHOS {
22 namespace NotificationNapi {
23 using namespace OHOS::Notification;
24 
25 const int32_t DISTURB_DEFAULT_FLAG = 13;
26 struct AsyncCallbackInfoIsEnabled {
27     napi_env env = nullptr;
28     napi_async_work asyncWork = nullptr;
29     CallbackPromiseInfo info;
30     bool enable = false;
31 };
32 
33 struct EnabledParams {
34     napi_ref callback = nullptr;
35     bool enable = false;
36 };
37 
38 struct AsyncCallbackInfoEnabled {
39     napi_env env = nullptr;
40     napi_async_work asyncWork = nullptr;
41     CallbackPromiseInfo info;
42     EnabledParams params;
43 };
44 
45 struct EnabledByBundleParams {
46     NotificationBundleOption option;
47     napi_ref callback = nullptr;
48     bool enable = false;
49 };
50 
51 struct AsyncCallbackInfoEnabledByBundle {
52     napi_env env = nullptr;
53     napi_async_work asyncWork = nullptr;
54     CallbackPromiseInfo info;
55     EnabledByBundleParams params;
56 };
57 
58 struct IsEnabledByBundleParams {
59     NotificationBundleOption option;
60     napi_ref callback = nullptr;
61     std::string deviceType;
62     bool hasDeviceType = false;
63 };
64 
65 struct AsyncCallbackInfoIsEnabledByBundle {
66     napi_env env = nullptr;
67     napi_async_work asyncWork = nullptr;
68     CallbackPromiseInfo info;
69     IsEnabledByBundleParams params;
70     bool enable = false;
71 };
72 
73 struct AsyncCallbackInfoGetRemindType {
74     napi_env env = nullptr;
75     napi_async_work asyncWork = nullptr;
76     CallbackPromiseInfo info;
77     NotificationConstant::RemindType remindType = NotificationConstant::RemindType::NONE;
78 };
79 
80 struct EnabledWithoutAppParams {
81     int32_t userId = SUBSCRIBE_USER_INIT;
82     bool enable = false;
83     napi_ref callback = nullptr;
84 };
85 
86 struct AsyncCallbackInfoEnabledWithoutApp {
87     napi_env env = nullptr;
88     napi_async_work asyncWork = nullptr;
89     CallbackPromiseInfo info;
90     EnabledWithoutAppParams params;
91 };
92 
93 struct GetEnabledWithoutAppParams {
94     int32_t userId = SUBSCRIBE_USER_INIT;
95     napi_ref callback = nullptr;
96 };
97 
98 struct AsyncCallbackInfoGetEnabledWithoutApp {
99     napi_env env = nullptr;
100     napi_async_work asyncWork = nullptr;
101     CallbackPromiseInfo info;
102     GetEnabledWithoutAppParams params;
103     bool enable = false;
104 };
105 
106 struct DeviceStatus {
107     std::string deviceType;
108     int32_t status;
109     napi_ref callback = nullptr;
110 };
111 
112 struct AsynDeviceStatusConfig {
113     napi_env env = nullptr;
114     napi_async_work asyncWork = nullptr;
115     DeviceStatus deviceStatus;
116     CallbackPromiseInfo info;
117 };
118 
119 napi_value IsDistributedEnabled(napi_env env, napi_callback_info info);
120 napi_value EnableDistributed(napi_env env, napi_callback_info info);
121 napi_value EnableDistributedByBundle(napi_env env, napi_callback_info info);
122 napi_value EnableDistributedSelf(napi_env env, napi_callback_info info);
123 napi_value IsDistributedEnableByBundle(napi_env env, napi_callback_info info);
124 napi_value GetDeviceRemindType(napi_env env, napi_callback_info info);
125 napi_value SetSyncNotificationEnabledWithoutApp(napi_env env, napi_callback_info info);
126 napi_value GetSyncNotificationEnabledWithoutApp(napi_env env, napi_callback_info info);
127 
128 napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, DeviceStatus &params);
129 napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, EnabledParams &params);
130 napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, EnabledByBundleParams &params);
131 napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, IsEnabledByBundleParams &params);
132 napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, EnabledWithoutAppParams &params);
133 napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, GetEnabledWithoutAppParams &params);
134 }  // namespace NotificationNapi
135 }  // namespace OHOS
136 
137 #endif  // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_FRAMEWORKS_JS_NAPI_INCLUDE_DISTRIBUTED_H
138