1 /* 2 * Copyright (c) 2025 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 16 #ifndef ASYNC_TASK_PARAMS_H 17 #define ASYNC_TASK_PARAMS_H 18 19 #include <map> 20 #include <mutex> 21 #include <string> 22 23 #ifndef IOS_PLATFORM 24 #include "executor_pool.h" 25 #endif 26 #include "progress_queue.h" 27 #include "unified_types.h" 28 #include "unified_data.h" 29 30 namespace OHOS::UDMF { 31 enum class FileConflictOptions: uint32_t { 32 OVERWRITE = 0, 33 SKIP = 1 34 }; 35 36 enum class ProgressIndicator: uint32_t { 37 NONE = 0, 38 DEFAULT = 1 39 }; 40 41 using ProgressListener = std::function<void(ProgressInfo progressInfo, std::shared_ptr<UnifiedData> data)>; 42 43 struct GetDataParams { 44 public: 45 FileConflictOptions fileConflictOptions; 46 ProgressIndicator progressIndicator; 47 ProgressListener progressListener; 48 std::string destUri; 49 QueryOption query; 50 }; 51 52 struct AsyncHelper { 53 uint32_t sycnRetryTime = 0; 54 int32_t lastProgress = 0; 55 ProgressIndicator progressIndicator; 56 #ifndef IOS_PLATFORM 57 ExecutorPool::TaskId invokeHapTask = ExecutorPool::INVALID_TASK_ID; 58 ExecutorPool::TaskId getDataTask = ExecutorPool::INVALID_TASK_ID; 59 ExecutorPool::TaskId progressTask = ExecutorPool::INVALID_TASK_ID; 60 #endif 61 ProgressListener progressListener; 62 FileConflictOptions fileConflictOptions; 63 std::string businessUdKey; 64 std::string processKey; 65 std::string cancelKey; 66 std::string destUri; 67 std::shared_ptr<UnifiedData> data = std::make_shared<UnifiedData>(); 68 ProgressQueue progressQueue; 69 }; 70 71 enum ListenerStatus: int32_t { 72 FINISHED = 0, 73 PROCESSING, 74 CANCEL, 75 INNER_ERROR = 200, 76 INVALID_PARAMETERS, 77 DATA_NOT_FOUND, 78 SYNC_FAILED, 79 COPY_FILE_FAILED, 80 }; 81 82 enum ProgressStatus { 83 NORMAL_PASTE = 0, 84 CANCEL_PASTE = 1, 85 PASTE_TIME_OUT = 2, 86 }; 87 88 } // namespace OHOS::UDMF 89 #endif // ASYNC_TASK_PARAMS_H