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