• 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 struct AsyncCallbackInfoIsEnabled {
26     napi_env env = nullptr;
27     napi_async_work asyncWork = nullptr;
28     CallbackPromiseInfo info;
29     bool enable = false;
30 };
31 
32 struct EnabledParams {
33     napi_ref callback = nullptr;
34     bool enable = false;
35 };
36 
37 struct AsyncCallbackInfoEnabled {
38     napi_env env = nullptr;
39     napi_async_work asyncWork = nullptr;
40     CallbackPromiseInfo info;
41     EnabledParams params;
42 };
43 
44 struct EnabledByBundleParams {
45     NotificationBundleOption option;
46     napi_ref callback = nullptr;
47     bool enable = false;
48 };
49 
50 struct AsyncCallbackInfoEnabledByBundle {
51     napi_env env = nullptr;
52     napi_async_work asyncWork = nullptr;
53     CallbackPromiseInfo info;
54     EnabledByBundleParams params;
55 };
56 
57 struct IsEnabledByBundleParams {
58     NotificationBundleOption option;
59     napi_ref callback = nullptr;
60 };
61 
62 struct AsyncCallbackInfoIsEnabledByBundle {
63     napi_env env = nullptr;
64     napi_async_work asyncWork = nullptr;
65     CallbackPromiseInfo info;
66     IsEnabledByBundleParams params;
67     bool enable = false;
68 };
69 
70 struct AsyncCallbackInfoGetRemindType {
71     napi_env env = nullptr;
72     napi_async_work asyncWork = nullptr;
73     CallbackPromiseInfo info;
74     NotificationConstant::RemindType remindType = NotificationConstant::RemindType::NONE;
75 };
76 
77 struct EnabledWithoutAppParams {
78     int32_t userId = SUBSCRIBE_USER_INIT;
79     bool enable = false;
80     napi_ref callback = nullptr;
81 };
82 
83 struct AsyncCallbackInfoEnabledWithoutApp {
84     napi_env env = nullptr;
85     napi_async_work asyncWork = nullptr;
86     CallbackPromiseInfo info;
87     EnabledWithoutAppParams params;
88 };
89 
90 struct GetEnabledWithoutAppParams {
91     int32_t userId = SUBSCRIBE_USER_INIT;
92     napi_ref callback = nullptr;
93 };
94 
95 struct AsyncCallbackInfoGetEnabledWithoutApp {
96     napi_env env = nullptr;
97     napi_async_work asyncWork = nullptr;
98     CallbackPromiseInfo info;
99     GetEnabledWithoutAppParams params;
100     bool enable = false;
101 };
102 
103 napi_value IsDistributedEnabled(napi_env env, napi_callback_info info);
104 napi_value EnableDistributed(napi_env env, napi_callback_info info);
105 napi_value EnableDistributedByBundle(napi_env env, napi_callback_info info);
106 napi_value EnableDistributedSelf(napi_env env, napi_callback_info info);
107 napi_value IsDistributedEnableByBundle(napi_env env, napi_callback_info info);
108 napi_value GetDeviceRemindType(napi_env env, napi_callback_info info);
109 napi_value SetSyncNotificationEnabledWithoutApp(napi_env env, napi_callback_info info);
110 napi_value GetSyncNotificationEnabledWithoutApp(napi_env env, napi_callback_info info);
111 
112 napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, EnabledParams &params);
113 napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, EnabledByBundleParams &params);
114 napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, IsEnabledByBundleParams &params);
115 napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, EnabledWithoutAppParams &params);
116 napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, GetEnabledWithoutAppParams &params);
117 }  // namespace NotificationNapi
118 }  // namespace OHOS
119 
120 #endif  // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_FRAMEWORKS_JS_NAPI_INCLUDE_DISTRIBUTED_H