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 16 #ifndef BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_FRAMEWORKS_JS_NAPI_CANCEL_H 17 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_FRAMEWORKS_JS_NAPI_CANCEL_H 18 19 #include "common.h" 20 #include "commonlibrary/utils_lite/include/ohos_types.h" 21 22 namespace OHOS { 23 namespace NotificationNapi { 24 using namespace OHOS::Notification; 25 26 struct ParametersInfoCancel { 27 int32_t id = 0; 28 std::string label = ""; 29 napi_ref callback = nullptr; 30 NotificationBundleOption option; 31 bool hasOption = false; 32 }; 33 34 struct AsyncCallbackInfoCancel { 35 napi_env env = nullptr; 36 napi_async_work asyncWork = nullptr; 37 int32_t id = 0; 38 std::string label; 39 CallbackPromiseInfo info; 40 NotificationBundleOption option; 41 bool hasOption = false; 42 }; 43 44 struct ParametersInfoCancelGroup { 45 std::string groupName = ""; 46 napi_ref callback = nullptr; 47 }; 48 49 struct AsyncCallbackInfoCancelGroup { 50 napi_env env = nullptr; 51 napi_async_work asyncWork = nullptr; 52 CallbackPromiseInfo info; 53 ParametersInfoCancelGroup params {}; 54 }; 55 56 struct ParametersInfoCancelAsBundle { 57 int32_t id = 0; 58 std::string representativeBundle = ""; 59 int32_t userId = 0; 60 NotificationBundleOption option; 61 bool hasOption = false; 62 napi_ref callback = nullptr; 63 }; 64 65 struct AsyncCallbackInfoCancelAsBundle { 66 napi_env env = nullptr; 67 napi_async_work asyncWork = nullptr; 68 int32_t id = 0; 69 std::string representativeBundle = ""; 70 int32_t userId = 0; 71 NotificationBundleOption option; 72 bool hasOption = false; 73 CallbackPromiseInfo info; 74 }; 75 76 napi_value Cancel(napi_env env, napi_callback_info info); 77 napi_value CancelAll(napi_env env, napi_callback_info info); 78 napi_value CancelGroup(napi_env env, napi_callback_info info); 79 napi_value CancelAsBundle(napi_env env, napi_callback_info info); 80 81 napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, ParametersInfoCancelAsBundle ¶s); 82 napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, ParametersInfoCancelGroup ¶s); 83 napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, ParametersInfoCancel ¶s); 84 } // namespace NotificationNapi 85 } // namespace OHOS 86 87 #endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_FRAMEWORKS_JS_NAPI_CANCEL_H