1bc03f14fSopenharmony_ci/* 2bc03f14fSopenharmony_ci * Copyright (C) 2021 Huawei Device Co., Ltd. 3bc03f14fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4bc03f14fSopenharmony_ci * you may not use this file except in compliance with the License. 5bc03f14fSopenharmony_ci * You may obtain a copy of the License at 6bc03f14fSopenharmony_ci * 7bc03f14fSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8bc03f14fSopenharmony_ci * 9bc03f14fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10bc03f14fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11bc03f14fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12bc03f14fSopenharmony_ci * See the License for the specific language governing permissions and 13bc03f14fSopenharmony_ci * limitations under the License. 14bc03f14fSopenharmony_ci */ 15bc03f14fSopenharmony_ci#ifndef N_NAPI_PASTEDATA_H 16bc03f14fSopenharmony_ci#define N_NAPI_PASTEDATA_H 17bc03f14fSopenharmony_ci 18bc03f14fSopenharmony_ci#include "napi/native_api.h" 19bc03f14fSopenharmony_ci#include "napi/native_node_api.h" 20bc03f14fSopenharmony_ci#include "paste_data.h" 21bc03f14fSopenharmony_ci#include "paste_data_record.h" 22bc03f14fSopenharmony_ci#include "pasteboard_client.h" 23bc03f14fSopenharmony_ci#include "pixel_map_napi.h" 24bc03f14fSopenharmony_ci#include "uri.h" 25bc03f14fSopenharmony_ci 26bc03f14fSopenharmony_cinamespace OHOS { 27bc03f14fSopenharmony_cinamespace MiscServicesNapi { 28bc03f14fSopenharmony_ciclass PasteDataNapi { 29bc03f14fSopenharmony_cipublic: 30bc03f14fSopenharmony_ci PasteDataNapi(); 31bc03f14fSopenharmony_ci ~PasteDataNapi(); 32bc03f14fSopenharmony_ci static napi_value PasteDataInit(napi_env env, napi_value exports); 33bc03f14fSopenharmony_ci static napi_value New(napi_env env, napi_callback_info info); 34bc03f14fSopenharmony_ci static napi_status NewInstance(napi_env env, napi_value &instance); 35bc03f14fSopenharmony_ci static void Destructor(napi_env env, void *nativeObject, void *finalize_hint); 36bc03f14fSopenharmony_ci static napi_value GetSystemPasteboard(napi_env env, napi_callback_info info); 37bc03f14fSopenharmony_ci static bool IsPasteData(napi_env env, napi_value in); 38bc03f14fSopenharmony_ci std::shared_ptr<MiscServices::PasteData> value_ = nullptr; 39bc03f14fSopenharmony_ci 40bc03f14fSopenharmony_ciprivate: 41bc03f14fSopenharmony_ci static napi_value AddHtmlRecord(napi_env env, napi_callback_info info); 42bc03f14fSopenharmony_ci static napi_value AddPixelMapRecord(napi_env env, napi_callback_info info); 43bc03f14fSopenharmony_ci static napi_value AddTextRecord(napi_env env, napi_callback_info info); 44bc03f14fSopenharmony_ci static napi_value AddUriRecord(napi_env env, napi_callback_info info); 45bc03f14fSopenharmony_ci static void AddRecord(napi_env env, napi_value *argv, size_t argc, PasteDataNapi *obj); 46bc03f14fSopenharmony_ci static void AddRecord(napi_env env, napi_value argv, PasteDataNapi *obj); 47bc03f14fSopenharmony_ci static napi_value GetPrimaryHtml(napi_env env, napi_callback_info info); 48bc03f14fSopenharmony_ci static napi_value GetPrimaryPixelMap(napi_env env, napi_callback_info info); 49bc03f14fSopenharmony_ci static napi_value GetPrimaryText(napi_env env, napi_callback_info info); 50bc03f14fSopenharmony_ci static napi_value GetPrimaryUri(napi_env env, napi_callback_info info); 51bc03f14fSopenharmony_ci static napi_value HasMimeType(napi_env env, napi_callback_info info); 52bc03f14fSopenharmony_ci static napi_value HasType(napi_env env, napi_callback_info info); 53bc03f14fSopenharmony_ci static napi_value RemoveRecordAt(napi_env env, napi_callback_info info); 54bc03f14fSopenharmony_ci static napi_value RemoveRecord(napi_env env, napi_callback_info info); 55bc03f14fSopenharmony_ci static napi_value GetPrimaryMimeType(napi_env env, napi_callback_info info); 56bc03f14fSopenharmony_ci static napi_value GetRecordCount(napi_env env, napi_callback_info info); 57bc03f14fSopenharmony_ci static napi_value GetTag(napi_env env, napi_callback_info info); 58bc03f14fSopenharmony_ci static napi_value GetMimeTypes(napi_env env, napi_callback_info info); 59bc03f14fSopenharmony_ci static napi_value AddRecord(napi_env env, napi_callback_info info); 60bc03f14fSopenharmony_ci static napi_value ReplaceRecordAt(napi_env env, napi_callback_info info); 61bc03f14fSopenharmony_ci static napi_value ReplaceRecord(napi_env env, napi_callback_info info); 62bc03f14fSopenharmony_ci static napi_value AddWantRecord(napi_env env, napi_callback_info info); 63bc03f14fSopenharmony_ci static napi_value GetPrimaryWant(napi_env env, napi_callback_info info); 64bc03f14fSopenharmony_ci static napi_value GetProperty(napi_env env, napi_callback_info info); 65bc03f14fSopenharmony_ci static napi_value GetRecordAt(napi_env env, napi_callback_info info); 66bc03f14fSopenharmony_ci static napi_value GetRecord(napi_env env, napi_callback_info info); 67bc03f14fSopenharmony_ci static PasteDataNapi *RemoveAndGetRecordCommon(napi_env env, napi_callback_info info, uint32_t &index); 68bc03f14fSopenharmony_ci static std::shared_ptr<MiscServices::PasteDataRecord> ParseRecord(napi_env env, napi_value &recordNapi); 69bc03f14fSopenharmony_ci static bool SetStringProp(napi_env env, const std::string &propName, napi_value &propValueNapi, 70bc03f14fSopenharmony_ci MiscServices::PasteDataRecord::Builder &builder); 71bc03f14fSopenharmony_ci static napi_value SetProperty(napi_env env, napi_callback_info info); 72bc03f14fSopenharmony_ci static void SetProperty(napi_env env, napi_value in, PasteDataNapi *obj); 73bc03f14fSopenharmony_ci static bool IsProperty(napi_env env, napi_value in); 74bc03f14fSopenharmony_ci static bool SetNapiProperty(napi_env env, const MiscServices::PasteDataProperty &property, napi_value &nProperty); 75bc03f14fSopenharmony_ci napi_env env_; 76bc03f14fSopenharmony_ci static napi_value PasteStart(napi_env env, napi_callback_info info); 77bc03f14fSopenharmony_ci static napi_value PasteComplete(napi_env env, napi_callback_info info); 78bc03f14fSopenharmony_ci}; 79bc03f14fSopenharmony_ci} // namespace MiscServicesNapi 80bc03f14fSopenharmony_ci} // namespace OHOS 81bc03f14fSopenharmony_ci#endif 82