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
16 #include "clouddisk_rdbstore.h"
17
18 namespace OHOS::FileManagement::CloudDisk {
19 using namespace std;
20 using namespace OHOS::NativeRdb;
21
CloudDiskRdbStore(const std::string & bundleName,const int32_t & userId)22 CloudDiskRdbStore::CloudDiskRdbStore(const std::string &bundleName, const int32_t &userId)
23 : bundleName_(bundleName), userId_(userId)
24 {
25 RdbInit();
26 }
27
~CloudDiskRdbStore()28 CloudDiskRdbStore::~CloudDiskRdbStore()
29 {
30 Stop();
31 }
32
ReBuildDatabase(const string & databasePath)33 int32_t CloudDiskRdbStore::ReBuildDatabase(const string &databasePath)
34 {
35 return E_OK;
36 }
37
RdbInit()38 int32_t CloudDiskRdbStore::RdbInit()
39 {
40 return E_OK;
41 }
42
Stop()43 void CloudDiskRdbStore::Stop()
44 {
45 if (rdbStore_ == nullptr) {
46 return;
47 }
48 rdbStore_ = nullptr;
49 }
50
GetRaw()51 shared_ptr<RdbStore> CloudDiskRdbStore::GetRaw()
52 {
53 return rdbStore_;
54 }
55
DatabaseRestore()56 void CloudDiskRdbStore::DatabaseRestore()
57 {
58 }
59
LookUp(const std::string & parentCloudId,const std::string & fileName,CloudDiskFileInfo & info)60 int32_t CloudDiskRdbStore::LookUp(const std::string &parentCloudId,
61 const std::string &fileName, CloudDiskFileInfo &info)
62 {
63 return E_OK;
64 }
65
GetAttr(const std::string & cloudId,CloudDiskFileInfo & info)66 int32_t CloudDiskRdbStore::GetAttr(const std::string &cloudId, CloudDiskFileInfo &info)
67 {
68 return E_OK;
69 }
70
SetAttr(const std::string & fileName,const std::string & parentCloudId,const std::string & cloudId,const unsigned long long & size)71 int32_t CloudDiskRdbStore::SetAttr(const std::string &fileName, const std::string &parentCloudId,
72 const std::string &cloudId, const unsigned long long &size)
73 {
74 if (cloudId == "") {
75 return 1;
76 } else if (size == 1) {
77 return 1;
78 }
79 return E_OK;
80 }
81
ReadDir(const std::string & cloudId,vector<CloudDiskFileInfo> & infos)82 int32_t CloudDiskRdbStore::ReadDir(const std::string &cloudId, vector<CloudDiskFileInfo> &infos)
83 {
84 return E_OK;
85 }
86
Create(const std::string & cloudId,const std::string & parentCloudId,const std::string & fileName,bool noNeedUpload)87 int32_t CloudDiskRdbStore::Create(const std::string &cloudId, const std::string &parentCloudId,
88 const std::string &fileName, bool noNeedUpload)
89 {
90 return E_OK;
91 }
92
MkDir(const std::string & cloudId,const std::string & parentCloudId,const std::string & directoryName,bool noNeedUpload)93 int32_t CloudDiskRdbStore::MkDir(const std::string &cloudId, const std::string &parentCloudId,
94 const std::string &directoryName, bool noNeedUpload)
95 {
96 return E_OK;
97 }
98
Write(const std::string & fileName,const std::string & parentCloudId,const std::string & cloudId)99 int32_t CloudDiskRdbStore::Write(const std::string &fileName, const std::string &parentCloudId,
100 const std::string &cloudId)
101 {
102 return E_OK;
103 }
104
LocationSetXattr(const std::string & name,const std::string & parentCloudId,const std::string & cloudId,const std::string & value)105 int32_t CloudDiskRdbStore::LocationSetXattr(const std::string &name, const std::string &parentCloudId,
106 const std::string &cloudId, const std::string &value)
107 {
108 return E_OK;
109 }
110
GetRowId(const std::string & cloudId,int64_t & rowId)111 int32_t CloudDiskRdbStore::GetRowId(const std::string &cloudId, int64_t &rowId)
112 {
113 if (cloudId == "mock") {
114 return 1;
115 }
116 return E_OK;
117 }
118
GetParentCloudId(const std::string & cloudId,std::string & parentCloudId)119 int32_t CloudDiskRdbStore::GetParentCloudId(const std::string &cloudId, std::string &parentCloudId)
120 {
121 return E_OK;
122 }
123
RecycleSetXattr(const std::string & name,const std::string & parentCloudId,const std::string & cloudId,const std::string & value)124 int32_t CloudDiskRdbStore::RecycleSetXattr(const std::string &name, const std::string &parentCloudId,
125 const std::string &cloudId, const std::string &value)
126 {
127 return E_OK;
128 }
129
FavoriteSetXattr(const std::string & cloudId,const std::string & value)130 int32_t CloudDiskRdbStore::FavoriteSetXattr(const std::string &cloudId, const std::string &value)
131 {
132 return E_OK;
133 }
134
LocationGetXattr(const std::string & name,const std::string & key,std::string & value,const std::string & parentCloudId)135 int32_t CloudDiskRdbStore::LocationGetXattr(const std::string &name, const std::string &key, std::string &value,
136 const std::string &parentCloudId)
137 {
138 return E_OK;
139 }
140
FavoriteGetXattr(const std::string & cloudId,const std::string & key,std::string & value)141 int32_t CloudDiskRdbStore::FavoriteGetXattr(const std::string &cloudId, const std::string &key, std::string &value)
142 {
143 return E_OK;
144 }
145
FileStatusGetXattr(const std::string & cloudId,const std::string & key,std::string & value)146 int32_t CloudDiskRdbStore::FileStatusGetXattr(const std::string &cloudId, const std::string &key, std::string &value)
147 {
148 return E_OK;
149 }
150
GetExtAttrValue(const std::string & cloudId,const std::string & key,std::string & value)151 int32_t CloudDiskRdbStore::GetExtAttrValue(const std::string &cloudId, const std::string &key, std::string &value)
152 {
153 return E_OK;
154 }
155
GetExtAttr(const std::string & cloudId,std::string & value,int32_t & position)156 int32_t CloudDiskRdbStore::GetExtAttr(const std::string &cloudId, std::string &value, int32_t &position)
157 {
158 return E_OK;
159 }
160
GetXAttr(const std::string & cloudId,const std::string & key,std::string & value,const CacheNode & node,const std::string & extAttrKey)161 int32_t CloudDiskRdbStore::GetXAttr(const std::string &cloudId, const std::string &key, std::string &value,
162 const CacheNode &node, const std::string &extAttrKey)
163 {
164 if (cloudId == "rootId") {
165 return 1;
166 }
167 return E_OK;
168 }
169
ExtAttributeSetXattr(const std::string & cloudId,const std::string & value,const std::string & key)170 int32_t CloudDiskRdbStore::ExtAttributeSetXattr(const std::string &cloudId, const std::string &value,
171 const std::string &key)
172 {
173 return E_OK;
174 }
175
SetXAttr(const std::string & cloudId,const std::string & key,const std::string & value,const std::string & name,const std::string & parentCloudId)176 int32_t CloudDiskRdbStore::SetXAttr(const std::string &cloudId, const std::string &key, const std::string &value,
177 const std::string &name, const std::string &parentCloudId)
178 {
179 if (value == "") {
180 return 1;
181 }
182 return E_OK;
183 }
184
Rename(const std::string & oldParentCloudId,const std::string & oldFileName,const std::string & newParentCloudId,const std::string & newFileName)185 int32_t CloudDiskRdbStore::Rename(const std::string &oldParentCloudId, const std::string &oldFileName,
186 const std::string &newParentCloudId, const std::string &newFileName)
187 {
188 if (oldFileName == "mock" || newFileName == "mock") {
189 return 1;
190 }
191 return E_OK;
192 }
193
GetHasChild(const std::string & cloudId,bool & hasChild)194 int32_t CloudDiskRdbStore::GetHasChild(const std::string &cloudId, bool &hasChild)
195 {
196 return E_OK;
197 }
198
UnlinkSynced(const std::string & cloudId)199 int32_t CloudDiskRdbStore::UnlinkSynced(const std::string &cloudId)
200 {
201 return E_OK;
202 }
203
UnlinkLocal(const std::string & cloudId)204 int32_t CloudDiskRdbStore::UnlinkLocal(const std::string &cloudId)
205 {
206 return E_OK;
207 }
208
Unlink(const std::string & cloudId,const int32_t & position)209 int32_t CloudDiskRdbStore::Unlink(const std::string &cloudId, const int32_t &position)
210 {
211 return E_OK;
212 }
213
GetDirtyType(const std::string & cloudId,int32_t & dirtyType)214 int32_t CloudDiskRdbStore::GetDirtyType(const std::string &cloudId, int32_t &dirtyType)
215 {
216 return E_OK;
217 }
218
GetCurNode(const std::string & cloudId,CacheNode & curNode)219 int32_t CloudDiskRdbStore::GetCurNode(const std::string &cloudId, CacheNode &curNode)
220 {
221 return E_OK;
222 }
223
GetParentNode(const std::string & parentCloudId,std::string & nextCloudId,std::string & fileName)224 int32_t CloudDiskRdbStore::GetParentNode(const std::string &parentCloudId, std::string &nextCloudId,
225 std::string &fileName)
226 {
227 return E_OK;
228 }
229
GetUriFromDB(const std::string & parentCloudId,std::string & uri)230 int32_t CloudDiskRdbStore::GetUriFromDB(const std::string &parentCloudId, std::string &uri)
231 {
232 return E_OK;
233 }
234
GetNotifyUri(const CacheNode & cacheNode,std::string & uri)235 int32_t CloudDiskRdbStore::GetNotifyUri(const CacheNode &cacheNode, std::string &uri)
236 {
237 if (cacheNode.cloudId == "mock") {
238 return 1;
239 }
240 return E_OK;
241 }
242
GetNotifyData(const CacheNode & cacheNode,NotifyData & notifyData)243 int32_t CloudDiskRdbStore::GetNotifyData(const CacheNode &cacheNode, NotifyData ¬ifyData)
244 {
245 if (cacheNode.cloudId == "mock" || cacheNode.fileName == "mock") {
246 return 1;
247 }
248 return E_OK;
249 }
250
CheckRootIdValid()251 int32_t CloudDiskRdbStore::CheckRootIdValid()
252 {
253 return E_OK;
254 }
255
OnCreate(RdbStore & store)256 int32_t CloudDiskDataCallBack::OnCreate(RdbStore &store)
257 {
258 return E_OK;
259 }
260
OnUpgrade(RdbStore & store,int32_t oldVersion,int32_t newVersion)261 int32_t CloudDiskDataCallBack::OnUpgrade(RdbStore &store, int32_t oldVersion, int32_t newVersion)
262 {
263 return E_OK;
264 }
265 }