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