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