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