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 std::string deviceType; 61 bool hasDeviceType = false; 62 }; 63 64 struct AsyncCallbackInfoIsEnabledByBundle { 65 napi_env env = nullptr; 66 napi_async_work asyncWork = nullptr; 67 CallbackPromiseInfo info; 68 IsEnabledByBundleParams params; 69 bool enable = false; 70 }; 71 72 struct AsyncCallbackInfoGetRemindType { 73 napi_env env = nullptr; 74 napi_async_work asyncWork = nullptr; 75 CallbackPromiseInfo info; 76 NotificationConstant::RemindType remindType = NotificationConstant::RemindType::NONE; 77 }; 78 79 struct EnabledWithoutAppParams { 80 int32_t userId = SUBSCRIBE_USER_INIT; 81 bool enable = false; 82 napi_ref callback = nullptr; 83 }; 84 85 struct AsyncCallbackInfoEnabledWithoutApp { 86 napi_env env = nullptr; 87 napi_async_work asyncWork = nullptr; 88 CallbackPromiseInfo info; 89 EnabledWithoutAppParams params; 90 }; 91 92 struct GetEnabledWithoutAppParams { 93 int32_t userId = SUBSCRIBE_USER_INIT; 94 napi_ref callback = nullptr; 95 }; 96 97 struct AsyncCallbackInfoGetEnabledWithoutApp { 98 napi_env env = nullptr; 99 napi_async_work asyncWork = nullptr; 100 CallbackPromiseInfo info; 101 GetEnabledWithoutAppParams params; 102 bool enable = false; 103 }; 104 105 napi_value IsDistributedEnabled(napi_env env, napi_callback_info info); 106 napi_value EnableDistributed(napi_env env, napi_callback_info info); 107 napi_value EnableDistributedByBundle(napi_env env, napi_callback_info info); 108 napi_value EnableDistributedSelf(napi_env env, napi_callback_info info); 109 napi_value IsDistributedEnableByBundle(napi_env env, napi_callback_info info); 110 napi_value GetDeviceRemindType(napi_env env, napi_callback_info info); 111 napi_value SetSyncNotificationEnabledWithoutApp(napi_env env, napi_callback_info info); 112 napi_value GetSyncNotificationEnabledWithoutApp(napi_env env, napi_callback_info info); 113 114 napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, EnabledParams ¶ms); 115 napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, EnabledByBundleParams ¶ms); 116 napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, IsEnabledByBundleParams ¶ms); 117 napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, EnabledWithoutAppParams ¶ms); 118 napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, GetEnabledWithoutAppParams ¶ms); 119 } // namespace NotificationNapi 120 } // namespace OHOS 121 122 #endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_FRAMEWORKS_JS_NAPI_INCLUDE_DISTRIBUTED_H 123