1 /* 2 * Copyright (C) 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 #ifndef INTERFACES_KITS_JS_MEDIALIBRARY_INCLUDE_CONFIRM_CALLBACK_H 16 #define INTERFACES_KITS_JS_MEDIALIBRARY_INCLUDE_CONFIRM_CALLBACK_H 17 18 #include <js_native_api.h> 19 #include <napi/native_api.h> 20 #include <node_api.h> 21 #include <string> 22 #include <vector> 23 #include <uv.h> 24 25 #include "want.h" 26 #include "ui_content.h" 27 #include "medialibrary_client_errno.h" 28 29 namespace OHOS { 30 namespace Media { 31 struct PhotoCreationConfig { 32 std::string title; 33 std::string fileNameExtension; 34 int32_t photoType; 35 int32_t subtype; 36 }; 37 38 class ConfirmCallback { 39 public: 40 explicit ConfirmCallback(napi_env env, Ace::UIContent *uiContent); 41 virtual ~ConfirmCallback() = default; 42 void OnRelease(int32_t releaseCode); 43 void OnResult(int32_t resultCode, const OHOS::AAFwk::Want &want); 44 void OnReceive(const OHOS::AAFwk::WantParams &request); 45 void OnError(int32_t code, const std::string &name, const std::string &message); 46 void SetSessionId(int32_t sessionId); 47 void SetUris(const std::vector<std::string> &uris); 48 void SetFunc(napi_value func); 49 50 private: 51 int32_t sessionId_ = 0; 52 int32_t resultCode_ = JS_ERR_PERMISSION_DENIED; 53 napi_env env_ = nullptr; 54 napi_ref callbackRef = nullptr; 55 Ace::UIContent *uiContent = nullptr; 56 57 void SendMessageBack(const std::vector<std::string> &desFileUris); 58 void CloseModalUIExtension(); 59 }; 60 } 61 } 62 #endif 63