• 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 
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 
TriggerSyncForWrite(const std::string & fileName,const std::string & parentCloudId)99 void CloudDiskRdbStore::TriggerSyncForWrite(const std::string &fileName, const std::string &parentCloudId)
100 {
101 }
102 
Write(const std::string & fileName,const std::string & parentCloudId,const std::string & cloudId)103 int32_t CloudDiskRdbStore::Write(const std::string &fileName, const std::string &parentCloudId,
104     const std::string &cloudId)
105 {
106     return E_OK;
107 }
108 
LocationSetXattr(const std::string & name,const std::string & parentCloudId,const std::string & cloudId,const std::string & value)109 int32_t CloudDiskRdbStore::LocationSetXattr(const std::string &name, const std::string &parentCloudId,
110     const std::string &cloudId, const std::string &value)
111 {
112     return E_OK;
113 }
114 
GetRowId(const std::string & cloudId,int64_t & rowId)115 int32_t CloudDiskRdbStore::GetRowId(const std::string &cloudId, int64_t &rowId)
116 {
117     if (cloudId == "mock") {
118         return 1;
119     }
120     return E_OK;
121 }
122 
GetParentCloudId(const std::string & cloudId,std::string & parentCloudId)123 int32_t CloudDiskRdbStore::GetParentCloudId(const std::string &cloudId, std::string &parentCloudId)
124 {
125     return E_OK;
126 }
127 
RecycleSetXattr(const std::string & name,const std::string & parentCloudId,const std::string & cloudId,const std::string & value)128 int32_t CloudDiskRdbStore::RecycleSetXattr(const std::string &name, const std::string &parentCloudId,
129     const std::string &cloudId, const std::string &value)
130 {
131     return E_OK;
132 }
133 
FavoriteSetXattr(const std::string & cloudId,const std::string & value)134 int32_t CloudDiskRdbStore::FavoriteSetXattr(const std::string &cloudId, const std::string &value)
135 {
136     return E_OK;
137 }
138 
LocationGetXattr(const std::string & name,const std::string & key,std::string & value,const std::string & parentCloudId)139 int32_t CloudDiskRdbStore::LocationGetXattr(const std::string &name, const std::string &key, std::string &value,
140     const std::string &parentCloudId)
141 {
142     return E_OK;
143 }
144 
FavoriteGetXattr(const std::string & cloudId,const std::string & key,std::string & value)145 int32_t CloudDiskRdbStore::FavoriteGetXattr(const std::string &cloudId, const std::string &key, std::string &value)
146 {
147     return E_OK;
148 }
149 
FileStatusGetXattr(const std::string & cloudId,const std::string & key,std::string & value)150 int32_t CloudDiskRdbStore::FileStatusGetXattr(const std::string &cloudId, const std::string &key, std::string &value)
151 {
152     return E_OK;
153 }
154 
GetExtAttrValue(const std::string & cloudId,const std::string & key,std::string & value)155 int32_t CloudDiskRdbStore::GetExtAttrValue(const std::string &cloudId, const std::string &key, std::string &value)
156 {
157     return E_OK;
158 }
159 
GetExtAttr(const std::string & cloudId,std::string & value,int32_t & position,int32_t & dirtyType)160 int32_t CloudDiskRdbStore::GetExtAttr(const std::string &cloudId, std::string &value, int32_t &position,
161     int32_t &dirtyType)
162 {
163     return E_OK;
164 }
165 
GetXAttr(const std::string & cloudId,const std::string & key,std::string & value,const CacheNode & node,const std::string & extAttrKey)166 int32_t CloudDiskRdbStore::GetXAttr(const std::string &cloudId, const std::string &key, std::string &value,
167     const CacheNode &node, const std::string &extAttrKey)
168 {
169     if (cloudId == "rootId") {
170         return 1;
171     }
172     return E_OK;
173 }
174 
ExtAttributeSetXattr(const std::string & cloudId,const std::string & value,const std::string & key)175 int32_t CloudDiskRdbStore::ExtAttributeSetXattr(const std::string &cloudId, const std::string &value,
176     const std::string &key)
177 {
178     return E_OK;
179 }
180 
SetXAttr(const std::string & cloudId,const std::string & key,const std::string & value,const std::string & name,const std::string & parentCloudId)181 int32_t CloudDiskRdbStore::SetXAttr(const std::string &cloudId, const std::string &key, const std::string &value,
182     const std::string &name, const std::string &parentCloudId)
183 {
184     if (value == "") {
185         return 1;
186     }
187     return E_OK;
188 }
189 
Rename(const std::string & oldParentCloudId,const std::string & oldFileName,const std::string & newParentCloudId,const std::string & newFileName,bool newFileNoNeedUpload)190 int32_t CloudDiskRdbStore::Rename(const std::string &oldParentCloudId, const std::string &oldFileName,
191     const std::string &newParentCloudId, const std::string &newFileName, bool newFileNoNeedUpload)
192 {
193     if (oldFileName == "mock" || newFileName == "mock") {
194         return 1;
195     }
196     return E_OK;
197 }
198 
GetHasChild(const std::string & cloudId,bool & hasChild)199 int32_t CloudDiskRdbStore::GetHasChild(const std::string &cloudId, bool &hasChild)
200 {
201     return E_OK;
202 }
203 
UnlinkSynced(const std::string & cloudId)204 int32_t CloudDiskRdbStore::UnlinkSynced(const std::string &cloudId)
205 {
206     return E_OK;
207 }
208 
UnlinkLocal(const std::string & cloudId)209 int32_t CloudDiskRdbStore::UnlinkLocal(const std::string &cloudId)
210 {
211     return E_OK;
212 }
213 
Unlink(const std::string & cloudId,const int32_t & position)214 int32_t CloudDiskRdbStore::Unlink(const std::string &cloudId, const int32_t &position)
215 {
216     return E_OK;
217 }
218 
GetDirtyType(const std::string & cloudId,int32_t & dirtyType)219 int32_t CloudDiskRdbStore::GetDirtyType(const std::string &cloudId, int32_t &dirtyType)
220 {
221     return E_OK;
222 }
223 
GetCurNode(const std::string & cloudId,CacheNode & curNode)224 int32_t CloudDiskRdbStore::GetCurNode(const std::string &cloudId, CacheNode &curNode)
225 {
226     return E_OK;
227 }
228 
GetParentNode(const std::string & parentCloudId,std::string & nextCloudId,std::string & fileName)229 int32_t CloudDiskRdbStore::GetParentNode(const std::string &parentCloudId, std::string &nextCloudId,
230     std::string &fileName)
231 {
232     return E_OK;
233 }
234 
GetUriFromDB(const std::string & parentCloudId,std::string & uri)235 int32_t CloudDiskRdbStore::GetUriFromDB(const std::string &parentCloudId, std::string &uri)
236 {
237     return E_OK;
238 }
239 
GetNotifyUri(const CacheNode & cacheNode,std::string & uri)240 int32_t CloudDiskRdbStore::GetNotifyUri(const CacheNode &cacheNode, std::string &uri)
241 {
242     if (cacheNode.cloudId == "mock") {
243         return 1;
244     }
245     return E_OK;
246 }
247 
GetNotifyData(const CacheNode & cacheNode,NotifyData & notifyData)248 int32_t CloudDiskRdbStore::GetNotifyData(const CacheNode &cacheNode, NotifyData &notifyData)
249 {
250     if (cacheNode.cloudId == "mock" || cacheNode.fileName == "mock") {
251         return 1;
252     }
253     return E_OK;
254 }
255 
CheckRootIdValid()256 int32_t CloudDiskRdbStore::CheckRootIdValid()
257 {
258     return E_OK;
259 }
260 
OnCreate(RdbStore & store)261 int32_t CloudDiskDataCallBack::OnCreate(RdbStore &store)
262 {
263     return E_OK;
264 }
265 
OnUpgrade(RdbStore & store,int32_t oldVersion,int32_t newVersion)266 int32_t CloudDiskDataCallBack::OnUpgrade(RdbStore &store, int32_t oldVersion, int32_t newVersion)
267 {
268     return E_OK;
269 }
270 }