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 std::string deviceType; 32 }; 33 34 struct EnabledParams { 35 napi_ref callback = nullptr; 36 bool enable = false; 37 std::string deviceType; 38 }; 39 40 struct AsyncCallbackInfoEnabled { 41 napi_env env = nullptr; 42 napi_async_work asyncWork = nullptr; 43 CallbackPromiseInfo info; 44 EnabledParams params; 45 }; 46 47 struct EnabledByBundleParams { 48 NotificationBundleOption option; 49 napi_ref callback = nullptr; 50 bool enable = false; 51 }; 52 53 struct AsyncCallbackInfoEnabledByBundle { 54 napi_env env = nullptr; 55 napi_async_work asyncWork = nullptr; 56 CallbackPromiseInfo info; 57 EnabledByBundleParams params; 58 }; 59 60 struct IsEnabledByBundleParams { 61 NotificationBundleOption option; 62 napi_ref callback = nullptr; 63 std::string deviceType; 64 bool hasDeviceType = false; 65 }; 66 67 struct AsyncCallbackInfoIsEnabledByBundle { 68 napi_env env = nullptr; 69 napi_async_work asyncWork = nullptr; 70 CallbackPromiseInfo info; 71 IsEnabledByBundleParams params; 72 bool enable = false; 73 }; 74 75 struct AsyncCallbackInfoGetRemindType { 76 napi_env env = nullptr; 77 napi_async_work asyncWork = nullptr; 78 CallbackPromiseInfo info; 79 NotificationConstant::RemindType remindType = NotificationConstant::RemindType::NONE; 80 }; 81 82 struct EnabledWithoutAppParams { 83 int32_t userId = SUBSCRIBE_USER_INIT; 84 bool enable = false; 85 napi_ref callback = nullptr; 86 }; 87 88 struct AsyncCallbackInfoEnabledWithoutApp { 89 napi_env env = nullptr; 90 napi_async_work asyncWork = nullptr; 91 CallbackPromiseInfo info; 92 EnabledWithoutAppParams params; 93 }; 94 95 struct GetEnabledWithoutAppParams { 96 int32_t userId = SUBSCRIBE_USER_INIT; 97 napi_ref callback = nullptr; 98 }; 99 100 struct AsyncCallbackInfoGetEnabledWithoutApp { 101 napi_env env = nullptr; 102 napi_async_work asyncWork = nullptr; 103 CallbackPromiseInfo info; 104 GetEnabledWithoutAppParams params; 105 bool enable = false; 106 }; 107 108 struct DeviceStatus { 109 std::string deviceType; 110 int32_t status; 111 napi_ref callback = nullptr; 112 }; 113 114 struct AsynDeviceStatusConfig { 115 napi_env env = nullptr; 116 napi_async_work asyncWork = nullptr; 117 DeviceStatus deviceStatus; 118 CallbackPromiseInfo info; 119 }; 120 121 struct AsynCallbackInfoGetDistributedDeviceList { 122 napi_env env = nullptr; 123 napi_async_work asyncWork = nullptr; 124 CallbackPromiseInfo info; 125 std::vector<std::string> deviceList; 126 }; 127 128 napi_value IsDistributedEnabled(napi_env env, napi_callback_info info); 129 napi_value EnableDistributed(napi_env env, napi_callback_info info); 130 napi_value EnableDistributedByBundle(napi_env env, napi_callback_info info); 131 napi_value EnableDistributedSelf(napi_env env, napi_callback_info info); 132 napi_value IsDistributedEnableByBundle(napi_env env, napi_callback_info info); 133 napi_value GetDeviceRemindType(napi_env env, napi_callback_info info); 134 napi_value SetSyncNotificationEnabledWithoutApp(napi_env env, napi_callback_info info); 135 napi_value GetSyncNotificationEnabledWithoutApp(napi_env env, napi_callback_info info); 136 137 napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, DeviceStatus ¶ms); 138 napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, EnabledParams ¶ms); 139 napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, EnabledByBundleParams ¶ms); 140 napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, IsEnabledByBundleParams ¶ms); 141 napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, EnabledWithoutAppParams ¶ms); 142 napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, GetEnabledWithoutAppParams ¶ms); 143 napi_value ParseSetDistributedEnabledParams(const napi_env &env, const napi_callback_info &info, EnabledParams ¶ms); 144 napi_value ParseIsDistributedEnabledParams(const napi_env &env, const napi_callback_info &info, EnabledParams ¶ms); 145 } // namespace NotificationNapi 146 } // namespace OHOS 147 148 #endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_FRAMEWORKS_JS_NAPI_INCLUDE_DISTRIBUTED_H 149