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