• 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 "softbus_handler_asset_mock.h"
17 
18 namespace OHOS {
19 namespace Storage {
20 namespace DistributedFile {
21 SoftBusHandlerAsset::SoftBusHandlerAsset() = default;
22 SoftBusHandlerAsset::~SoftBusHandlerAsset() = default;
23 
GetInstance()24 SoftBusHandlerAsset &SoftBusHandlerAsset::GetInstance()
25 {
26     static SoftBusHandlerAsset assetHandle;
27     return assetHandle;
28 }
29 
CreateAssetLocalSessionServer()30 void SoftBusHandlerAsset::CreateAssetLocalSessionServer()
31 {
32     return;
33 }
34 
DeleteAssetLocalSessionServer()35 void SoftBusHandlerAsset::DeleteAssetLocalSessionServer()
36 {
37     return;
38 }
39 
AssetBind(const std::string & dstNetworkId,int32_t & socketId)40 int32_t SoftBusHandlerAsset::AssetBind(const std::string &dstNetworkId, int32_t &socketId)
41 {
42     if (ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_ == nullptr) {
43         return -1;
44     }
45     return ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_->AssetBind(dstNetworkId, socketId);
46 }
47 
AssetSendFile(int32_t socketId,const std::string & sendFile,bool isSingleFile)48 int32_t SoftBusHandlerAsset::AssetSendFile(int32_t socketId, const std::string &sendFile, bool isSingleFile)
49 {
50     if (ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_ == nullptr) {
51         return -1;
52     }
53     return ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_->AssetSendFile(socketId, sendFile, isSingleFile);
54 }
55 
closeAssetBind(int32_t socketId)56 void SoftBusHandlerAsset::closeAssetBind(int32_t socketId)
57 {
58     return;
59 }
60 
OnAssetRecvBind(int32_t socketId,const std::string & srcNetWorkId)61 void SoftBusHandlerAsset::OnAssetRecvBind(int32_t socketId, const std::string &srcNetWorkId)
62 {
63     return;
64 }
65 
GetSocketIdFromAssetObj(const std::string & peerNetworkId)66 std::vector<int32_t> GetSocketIdFromAssetObj(const std::string &peerNetworkId)
67 {
68     return {};
69 }
GetSocketIdFromClientInfo(const std::string & peerNetworkId)70 std::vector<int32_t> GetSocketIdFromClientInfo(const std::string &peerNetworkId)
71 {
72     return {};
73 }
74 
GetClientInfo(int32_t socketId)75 std::string SoftBusHandlerAsset::GetClientInfo(int32_t socketId)
76 {
77     if (ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_ == nullptr) {
78         return "";
79     }
80     return ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_->GetClientInfo(socketId);
81 }
82 
RemoveClientInfo(int32_t socketId)83 void SoftBusHandlerAsset::RemoveClientInfo(int32_t socketId)
84 {
85     return;
86 }
87 
AddAssetObj(int32_t socketId,const sptr<AssetObj> & assetObj)88 void SoftBusHandlerAsset::AddAssetObj(int32_t socketId, const sptr<AssetObj> &assetObj)
89 {
90     return;
91 }
92 
GetAssetObj(int32_t socketId)93 sptr<AssetObj> SoftBusHandlerAsset::GetAssetObj(int32_t socketId)
94 {
95     if (ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_ == nullptr) {
96         return nullptr;
97     }
98     return ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_->GetAssetObj(socketId);
99 }
100 
RemoveAssetObj(int32_t socketId)101 void SoftBusHandlerAsset::RemoveAssetObj(int32_t socketId)
102 {
103     return;
104 }
105 
GenerateAssetObjInfo(int32_t socketId,const std::string & fileName,const sptr<AssetObj> & assetObj)106 int32_t SoftBusHandlerAsset::GenerateAssetObjInfo(int32_t socketId,
107                                                   const std::string &fileName,
108                                                   const sptr<AssetObj> &assetObj)
109 {
110     if (ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_ == nullptr) {
111         return -1;
112     }
113     return ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_->GenerateAssetObjInfo(socketId, fileName, assetObj);
114 }
115 
GetDstFile(const std::string & file,const std::string & srcBundleName,const std::string & dstBundleName,const std::string & sessionId,bool isSingleFile)116 std::string SoftBusHandlerAsset::GetDstFile(const std::string &file,
117                                             const std::string &srcBundleName,
118                                             const std::string &dstBundleName,
119                                             const std::string &sessionId,
120                                             bool isSingleFile)
121 {
122     return "test";
123 }
124 
GenerateUris(const std::vector<std::string> & fileList,const std::string & dstBundleName,bool isSingleFile)125 std::vector<std::string> SoftBusHandlerAsset::GenerateUris(const std::vector<std::string> &fileList,
126                                                            const std::string &dstBundleName,
127                                                            bool isSingleFile)
128 {
129     if (ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_ == nullptr) {
130         return {};
131     }
132     return ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_->GenerateUris(fileList, dstBundleName, isSingleFile);
133 }
134 
CompressFile(const std::vector<std::string> & fileList,const std::string & relativePath,const std::string & zipFileName)135 int32_t SoftBusHandlerAsset::CompressFile(const std::vector<std::string> &fileList,
136                                           const std::string &relativePath,
137                                           const std::string &zipFileName)
138 {
139     if (ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_ == nullptr) {
140         return -1;
141     }
142     return ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_->CompressFile(fileList, relativePath, zipFileName);
143 }
144 
DecompressFile(const std::string & unZipFileName,const std::string & relativePath)145 std::vector<std::string> SoftBusHandlerAsset::DecompressFile(const std::string &unZipFileName,
146                                                              const std::string &relativePath)
147 {
148     if (ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_ == nullptr) {
149         return {};
150     }
151     return ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_->DecompressFile(unZipFileName, relativePath);
152 }
153 
GetLocalNetworkId()154 std::string SoftBusHandlerAsset::GetLocalNetworkId()
155 {
156     return "test";
157 }
158 
MkDir(const std::string & path,mode_t mode)159 int32_t SoftBusHandlerAsset::MkDir(const std::string &path, mode_t mode)
160 {
161     return 0;
162 }
163 
MkDirRecurse(const std::string & path,mode_t mode)164 bool SoftBusHandlerAsset::MkDirRecurse(const std::string &path, mode_t mode)
165 {
166     if (ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_ == nullptr) {
167         return -1;
168     }
169     return ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_->MkDirRecurse(path, mode);
170 }
171 
IsDir(const std::string & path)172 bool SoftBusHandlerAsset::IsDir(const std::string &path)
173 {
174     return true;
175 }
176 
ExtractFile(unzFile unZipFile,const std::string & dir)177 std::string SoftBusHandlerAsset::ExtractFile(unzFile unZipFile, const std::string &dir)
178 {
179     return "test";
180 }
181 
RemoveFile(const std::string & path,bool isRemove)182 void SoftBusHandlerAsset::RemoveFile(const std::string &path, bool isRemove)
183 {
184     return;
185 }
186 } // namespace DistributedFile
187 } // namespace Storage
188 } // namespace OHOS