1 /* 2 * Copyright (C) 2023 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 INTERFACES_KITS_JS_MEDIALIBRARY_INCLUDE_DELETE_CALLBACK_H 16 #define INTERFACES_KITS_JS_MEDIALIBRARY_INCLUDE_DELETE_CALLBACK_H 17 18 #include <js_native_api.h> 19 #include <string> 20 #include <uv.h> 21 #include <napi/native_api.h> 22 #include <node_api.h> 23 24 #include "want.h" 25 #ifdef HAS_ACE_ENGINE_PART 26 #include "ui_content.h" 27 #endif 28 #include "medialibrary_client_errno.h" 29 30 namespace OHOS { 31 namespace Media { 32 const std::string DELETE_UI_PACKAGE_NAME = "com.ohos.photos"; 33 const std::string DELETE_UI_EXT_ABILITY_NAME = "DeleteUIExtensionAbility"; 34 const std::string DELETE_UI_EXTENSION_TYPE = "ability.want.params.uiExtensionType"; 35 const std::string DELETE_UI_REQUEST_TYPE = "sysDialog/common"; 36 const std::string DELETE_UI_APPNAME = "appName"; 37 const std::string DELETE_UI_URIS = "uris"; 38 const std::string RESULT = "result"; 39 const int32_t DELETE_CODE_SUCCESS = 0; 40 const int32_t DEFAULT_SESSION_ID = 0; 41 42 class DeleteCallback { 43 public: 44 #ifdef HAS_ACE_ENGINE_PART 45 explicit DeleteCallback(napi_env env, Ace::UIContent *uiContent); 46 #else 47 explicit DeleteCallback(napi_env env); 48 #endif 49 void OnRelease(int32_t releaseCode); 50 void OnResult(int32_t resultCode, const OHOS::AAFwk::Want &result); 51 void OnReceive(const OHOS::AAFwk::WantParams &request); 52 void OnError(int32_t code, const std::string &name, const std::string &message); 53 void SetSessionId(int32_t sessionId); 54 void SetUris(std::vector<std::string> uris); 55 void SetFunc(napi_value func); 56 57 private: 58 int32_t sessionId_ = DEFAULT_SESSION_ID; 59 int32_t resultCode_ = JS_ERR_PERMISSION_DENIED; 60 std::vector<std::string> uris_; 61 napi_env env_ = nullptr; 62 napi_ref callbackRef = nullptr; 63 #ifdef HAS_ACE_ENGINE_PART 64 Ace::UIContent *uiContent = nullptr; 65 #endif 66 void SendMessageBack(); 67 void CloseModalUIExtension(); 68 }; 69 } 70 } 71 #endif 72