1 /*
2 * Copyright (c) 2023 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 #include "data_syncer.h"
17
18 #include <functional>
19
20 #include "dfs_error.h"
21
22 namespace OHOS {
23 namespace FileManagement {
24 namespace CloudSync {
25 using namespace std;
26 using namespace placeholders;
27 using namespace DriveKit;
28
DataSyncer(const std::string bundleName,const int32_t userId)29 DataSyncer::DataSyncer(const std::string bundleName, const int32_t userId)
30 : bundleName_(bundleName), userId_(userId)
31 {
32 }
33
~DataSyncer()34 DataSyncer::~DataSyncer()
35 {
36 }
37
AsyncRun(std::shared_ptr<TaskContext> context,void (DataSyncer::* f)(std::shared_ptr<TaskContext>))38 int32_t DataSyncer::AsyncRun(std::shared_ptr<TaskContext> context,
39 void(DataSyncer::*f)(std::shared_ptr<TaskContext>))
40 {
41 return E_OK;
42 }
43
44 template<typename T, typename RET, typename... ARGS>
AsyncCallback(RET (T::* f)(ARGS...))45 function<RET(ARGS...)> DataSyncer::AsyncCallback(RET(T::*f)(ARGS...))
46 {
47 return nullptr;
48 }
49
StartSync(bool forceFlag,SyncTriggerType triggerType)50 int32_t DataSyncer::StartSync(bool forceFlag, SyncTriggerType triggerType)
51 {
52 return E_OK;
53 }
54
StopSync(SyncTriggerType triggerType)55 int32_t DataSyncer::StopSync(SyncTriggerType triggerType)
56 {
57 return E_OK;
58 }
59
StartDownloadFile(const std::string path,const int32_t userId)60 int32_t DataSyncer::StartDownloadFile(const std::string path, const int32_t userId)
61 {
62 return E_OK;
63 }
64
StopDownloadFile(const std::string path,const int32_t userId)65 int32_t DataSyncer::StopDownloadFile(const std::string path, const int32_t userId)
66 {
67 return E_OK;
68 }
69
RegisterDownloadFileCallback(const int32_t userId,const sptr<ICloudDownloadCallback> downloadCallback)70 int32_t DataSyncer::RegisterDownloadFileCallback(const int32_t userId,
71 const sptr<ICloudDownloadCallback> downloadCallback)
72 {
73 return E_OK;
74 }
75
UnregisterDownloadFileCallback(const int32_t userId)76 int32_t DataSyncer::UnregisterDownloadFileCallback(const int32_t userId)
77 {
78 return E_OK;
79 }
80
Clean(const int action)81 int32_t DataSyncer::Clean(const int action)
82 {
83 return E_OK;
84 }
85
Abort()86 void DataSyncer::Abort()
87 {
88 }
89
Reset()90 void DataSyncer::Reset()
91 {
92 }
93
SetSdkHelper(shared_ptr<SdkHelper> & sdkHelper)94 void DataSyncer::SetSdkHelper(shared_ptr<SdkHelper> &sdkHelper)
95 {
96 }
97
Pull(shared_ptr<DataHandler> handler)98 int32_t DataSyncer::Pull(shared_ptr<DataHandler> handler)
99 {
100 return E_OK;
101 }
102
PullRecords(shared_ptr<TaskContext> context)103 void DataSyncer::PullRecords(shared_ptr<TaskContext> context)
104 {
105 }
106
PullDatabaseChanges(shared_ptr<TaskContext> context)107 void DataSyncer::PullDatabaseChanges(shared_ptr<TaskContext> context)
108 {
109 }
110
DownloadAssets(DownloadContext & ctx)111 void DataSyncer::DownloadAssets(DownloadContext &ctx)
112 {
113 }
114
CleanInner(std::shared_ptr<DataHandler> handler,const int action)115 int32_t DataSyncer::CleanInner(std::shared_ptr<DataHandler> handler, const int action)
116 {
117 return E_OK;
118 }
119
ClearCursor()120 void DataSyncer::ClearCursor()
121 {
122 }
123
EmptyDownLoadAssetsprogress(std::shared_ptr<DKContext>,DKDownloadAsset,TotalSize,DownloadSize)124 void EmptyDownLoadAssetsprogress(std::shared_ptr<DKContext>, DKDownloadAsset, TotalSize, DownloadSize)
125 {
126 return;
127 }
128
HandleOnFetchRecords(const std::shared_ptr<DownloadTaskContext> context,std::shared_ptr<const DKDatabase> database,std::shared_ptr<std::vector<DKRecord>> records,bool checkOrRetry)129 int DataSyncer::HandleOnFetchRecords(const std::shared_ptr<DownloadTaskContext> context,
130 std::shared_ptr<const DKDatabase> database, std::shared_ptr<std::vector<DKRecord>> records, bool checkOrRetry)
131 {
132 return E_OK;
133 }
134
OnFetchRecords(const std::shared_ptr<DKContext> context,std::shared_ptr<const DKDatabase> database,std::shared_ptr<std::vector<DKRecord>> records,DKQueryCursor nextCursor,const DKError & err)135 void DataSyncer::OnFetchRecords(const std::shared_ptr<DKContext> context, std::shared_ptr<const DKDatabase> database,
136 std::shared_ptr<std::vector<DKRecord>> records, DKQueryCursor nextCursor, const DKError &err)
137 {
138 }
139
DownloadInner(std::shared_ptr<DataHandler> handler,const std::string path,const int32_t userId)140 int32_t DataSyncer::DownloadInner(std::shared_ptr<DataHandler> handler,
141 const std::string path,
142 const int32_t userId)
143 {
144 return E_OK;
145 }
146
OnFetchDatabaseChanges(const std::shared_ptr<DKContext> context,std::shared_ptr<const DKDatabase> database,std::shared_ptr<std::vector<DriveKit::DKRecord>> records,DKQueryCursor nextCursor,bool hasMore,const DKError & err)147 void DataSyncer::OnFetchDatabaseChanges(const std::shared_ptr<DKContext> context,
148 std::shared_ptr<const DKDatabase> database,
149 std::shared_ptr<std::vector<DriveKit::DKRecord>> records, DKQueryCursor nextCursor,
150 bool hasMore, const DKError &err)
151 {
152 }
153
PullRecordsWithId(shared_ptr<TaskContext> context,const std::vector<DriveKit::DKRecordId> & records,bool retry)154 void DataSyncer::PullRecordsWithId(shared_ptr<TaskContext> context, const std::vector<DriveKit::DKRecordId> &records,
155 bool retry)
156 {
157 }
158
OnFetchRecordWithId(shared_ptr<DKContext> context,shared_ptr<DKDatabase> database,DKRecordId recordId,const DKRecord & record,const DKError & error)159 void DataSyncer::OnFetchRecordWithId(shared_ptr<DKContext> context, shared_ptr<DKDatabase> database,
160 DKRecordId recordId, const DKRecord &record, const DKError &error)
161 {
162 }
163
Push(shared_ptr<DataHandler> handler)164 int32_t DataSyncer::Push(shared_ptr<DataHandler> handler)
165 {
166 return E_OK;
167 }
168
CreateRecords(shared_ptr<TaskContext> context)169 void DataSyncer::CreateRecords(shared_ptr<TaskContext> context)
170 {
171 }
172
DeleteRecords(shared_ptr<TaskContext> context)173 void DataSyncer::DeleteRecords(shared_ptr<TaskContext> context)
174 {
175 }
176
ModifyMdirtyRecords(shared_ptr<TaskContext> context)177 void DataSyncer::ModifyMdirtyRecords(shared_ptr<TaskContext> context)
178 {
179 }
180
ModifyFdirtyRecords(shared_ptr<TaskContext> context)181 void DataSyncer::ModifyFdirtyRecords(shared_ptr<TaskContext> context)
182 {
183 }
184
OnCreateRecords(shared_ptr<DKContext> context,shared_ptr<const DKDatabase> database,shared_ptr<const map<DKRecordId,DKRecordOperResult>> map,const DKError & err)185 void DataSyncer::OnCreateRecords(shared_ptr<DKContext> context,
186 shared_ptr<const DKDatabase> database,
187 shared_ptr<const map<DKRecordId, DKRecordOperResult>> map, const DKError &err)
188 {
189 }
190
OnDeleteRecords(shared_ptr<DKContext> context,shared_ptr<const DKDatabase> database,shared_ptr<const map<DKRecordId,DKRecordOperResult>> map,const DKError & err)191 void DataSyncer::OnDeleteRecords(shared_ptr<DKContext> context,
192 shared_ptr<const DKDatabase> database,
193 shared_ptr<const map<DKRecordId, DKRecordOperResult>> map, const DKError &err)
194 {
195 }
196
OnModifyMdirtyRecords(shared_ptr<DKContext> context,shared_ptr<const DKDatabase> database,shared_ptr<const map<DKRecordId,DKRecordOperResult>> saveMap,shared_ptr<const map<DKRecordId,DKRecordOperResult>> deleteMap,const DKError & err)197 void DataSyncer::OnModifyMdirtyRecords(shared_ptr<DKContext> context,
198 shared_ptr<const DKDatabase> database,
199 shared_ptr<const map<DKRecordId, DKRecordOperResult>> saveMap,
200 shared_ptr<const map<DKRecordId, DKRecordOperResult>> deleteMap,
201 const DKError &err)
202 {
203 }
204
OnModifyFdirtyRecords(shared_ptr<DKContext> context,shared_ptr<const DKDatabase> database,shared_ptr<const map<DKRecordId,DKRecordOperResult>> saveMap,shared_ptr<const map<DKRecordId,DKRecordOperResult>> deleteMap,const DKError & err)205 void DataSyncer::OnModifyFdirtyRecords(shared_ptr<DKContext> context,
206 shared_ptr<const DKDatabase> database,
207 shared_ptr<const map<DKRecordId, DKRecordOperResult>> saveMap,
208 shared_ptr<const map<DKRecordId, DKRecordOperResult>> deleteMap,
209 const DKError &err)
210 {
211 }
212
BeginTransaction()213 void DataSyncer::BeginTransaction()
214 {
215 }
216
EndTransaction()217 void DataSyncer::EndTransaction()
218 {
219 }
220
GetBundleName() const221 std::string DataSyncer::GetBundleName() const
222 {
223 return bundleName_;
224 }
225
GetUserId() const226 int32_t DataSyncer::GetUserId() const
227 {
228 return userId_;
229 }
230
GetSyncState() const231 SyncState DataSyncer::GetSyncState() const
232 {
233 if (bundleName_ == "com.ohos.photos") {
234 return SyncState::SYNC_SUCCEED;
235 }
236
237 return SyncState::SYNC_FAILED;
238 }
239
CompletePull()240 int DataSyncer::CompletePull()
241 {
242 return E_OK;
243 }
244
CompletePush()245 int DataSyncer::CompletePush()
246 {
247 return E_OK;
248 }
249
CompleteAll(bool isNeedNotify)250 void DataSyncer::CompleteAll(bool isNeedNotify)
251 {
252 }
253
SyncStateChangedNotify(const CloudSyncState state,const ErrorType error)254 void DataSyncer::SyncStateChangedNotify(const CloudSyncState state, const ErrorType error)
255 {
256 }
257 } // namespace CloudSync
258 } // namespace FileManagement
259 } // namespace OHOS
260