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 #ifndef BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_FRAMEWORKS_JS_NAPI_ENABLE_NOTIFICATION_H 16 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_FRAMEWORKS_JS_NAPI_ENABLE_NOTIFICATION_H 17 18 #include "common.h" 19 #include "enable_notification.h" 20 #include "ui_content.h" 21 #include "ability.h" 22 #include "ability_context.h" 23 24 namespace OHOS { 25 namespace NotificationNapi { 26 using namespace OHOS::Notification; 27 28 napi_value NapiEnableNotification(napi_env env, napi_callback_info info); 29 napi_value NapiIsNotificationEnabled(napi_env env, napi_callback_info info); 30 napi_value NapiIsNotificationEnabledSelf(napi_env env, napi_callback_info info); 31 napi_value NapiRequestEnableNotification(napi_env env, napi_callback_info info); 32 napi_value NapiGetAllNotificationEnabledBundles(napi_env env, napi_callback_info info); 33 napi_value ParseRequestEnableParameters(const napi_env &env, const napi_callback_info &info, IsEnableParams ¶ms); 34 napi_value NapiIsNotificationEnabledSync(napi_env env, napi_callback_info info); 35 bool CreateUIExtension(std::shared_ptr<OHOS::AbilityRuntime::Context> context, std::string &bundleName); 36 void SetEnableParam(IsEnableParams ¶ms, const napi_env &env, napi_value &object); 37 38 class ModalExtensionCallback { 39 public: 40 ModalExtensionCallback(); 41 ~ModalExtensionCallback(); 42 void OnRelease(int32_t releaseCode); 43 void OnResult(int32_t resultCode, const OHOS::AAFwk::Want& result); 44 void OnReceive(const OHOS::AAFwk::WantParams& request); 45 void OnError(int32_t code, const std::string& name, const std::string &message); 46 void OnRemoteReady(const std::shared_ptr<OHOS::Ace::ModalUIExtensionProxy> &uiProxy); 47 void OnDestroy(); 48 void SetSessionId(int32_t sessionId); 49 void SetBundleName(std::string bundleName); 50 void SetAbilityContext(std::shared_ptr<OHOS::AbilityRuntime::AbilityContext> abilityContext); 51 void ReleaseOrErrorHandle(int32_t code); 52 53 private: 54 int32_t sessionId_ = 0; 55 std::string bundleName_; 56 std::shared_ptr<OHOS::AbilityRuntime::AbilityContext> abilityContext_; 57 }; 58 } // namespace NotificationNapi 59 } // namespace OHOS 60 #endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_FRAMEWORKS_JS_NAPI_ENABLE_NOTIFICATION_H