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 OH_PASTEBOARD_COMMON_H 16 #define OH_PASTEBOARD_COMMON_H 17 #include <cstdint> 18 #include <map> 19 #include "pasteboard_observer.h" 20 #include "oh_pasteboard.h" 21 #include "pasteboard_error.h" 22 #include "oh_pasteboard_err_code.h" 23 24 namespace OHOS { 25 namespace MiscServices { 26 static constexpr uint32_t MAX_MIMETYPES_NUM = 10000; 27 28 const std::map<PasteboardError, PASTEBOARD_ErrCode> errCodeMap = { 29 { PasteboardError::PERMISSION_VERIFICATION_ERROR, ERR_PERMISSION_ERROR }, 30 { PasteboardError::INVALID_PARAM_ERROR, ERR_INVALID_PARAMETER }, 31 { PasteboardError::TASK_PROCESSING, ERR_BUSY }, 32 { PasteboardError::COPY_FILE_ERROR, ERR_PASTEBOARD_COPY_FILE_ERROR }, 33 { PasteboardError::PROGRESS_START_ERROR, ERR_PASTEBOARD_PROGRESS_START_ERROR }, 34 { PasteboardError::PROGRESS_ABNORMAL, ERR_PASTEBOARD_PROGRESS_ABNORMAL }, 35 }; 36 37 class PasteboardObserverCapiImpl; 38 } 39 } 40 41 enum PasteboardNdkStructId : std::int64_t { 42 SUBSCRIBER_STRUCT_ID = 1002950, 43 PASTEBOARD_STRUCT_ID, 44 }; 45 46 struct OH_Pasteboard { 47 const int64_t cid = PASTEBOARD_STRUCT_ID; 48 std::mutex mutex; 49 std::map<const OH_PasteboardObserver*, OHOS::sptr<OHOS::MiscServices::PasteboardObserverCapiImpl>> observers_; 50 std::vector<std::string> mimeTypes_; 51 char **mimeTypesPtr = nullptr; 52 }; 53 54 struct Pasteboard_ProgressInfo { 55 int progress; 56 }; 57 58 struct Pasteboard_GetDataParams { 59 char *destUri; 60 uint32_t destUriLen; 61 Pasteboard_FileConflictOptions fileConflictOptions; 62 Pasteboard_ProgressIndicator progressIndicator; 63 OH_Pasteboard_ProgressListener progressListener; 64 Pasteboard_ProgressInfo info; 65 }; 66 67 /** @} */ 68 #endif