• 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_adapter_mock.h"
17 
18 namespace OHOS::FileManagement::CloudSync {
19 
GetInstance()20 SoftbusAdapter &SoftbusAdapter::GetInstance()
21 {
22     static SoftbusAdapter adapter;
23     return adapter;
24 }
25 
CreateSessionServer(const char * packageName,const char * sessionName)26 int32_t SoftbusAdapter::CreateSessionServer(const char *packageName, const char *sessionName)
27 {
28     if (ISoftbusAdapterMock::iSoftbusAdapterMock_ == nullptr) {
29         return -1;
30     }
31     return ISoftbusAdapterMock::iSoftbusAdapterMock_->CreateSessionServer(packageName, sessionName);
32 }
33 
RemoveSessionServer(const char * packageName,const char * sessionName)34 int32_t SoftbusAdapter::RemoveSessionServer(const char *packageName, const char *sessionName)
35 {
36     return 0;
37 }
38 
OpenSession(char * sessionName,char * peerDeviceId,char * groupId,TransDataType dataType)39 int32_t SoftbusAdapter::OpenSession(char *sessionName, char *peerDeviceId, char *groupId, TransDataType dataType)
40 {
41     if (ISoftbusAdapterMock::iSoftbusAdapterMock_ == nullptr) {
42         return -1;
43     }
44     return ISoftbusAdapterMock::iSoftbusAdapterMock_->OpenSession(sessionName,
45         peerDeviceId, groupId, dataType);
46 }
47 
OpenSessionByP2P(char * sessionName,char * peerDeviceId,char * groupId,bool isFileType)48 int SoftbusAdapter::OpenSessionByP2P(char *sessionName, char *peerDeviceId, char *groupId, bool isFileType)
49 {
50     TransDataType dataType;
51     if (isFileType) {
52         dataType = DATA_TYPE_FILE;
53     } else {
54         dataType = DATA_TYPE_BYTES;
55     }
56     return OpenSession(sessionName, peerDeviceId, groupId, dataType);
57 }
58 
SendBytes(int sessionId,const void * data,unsigned int dataLen)59 int SoftbusAdapter::SendBytes(int sessionId, const void *data, unsigned int dataLen)
60 {
61     if (ISoftbusAdapterMock::iSoftbusAdapterMock_ == nullptr) {
62         return -1;
63     }
64     return ISoftbusAdapterMock::iSoftbusAdapterMock_->SendBytes(sessionId, data, dataLen);
65 }
66 
SendFile(int sessionId,const std::vector<std::string> & sFileList,const std::vector<std::string> & dFileList)67 int SoftbusAdapter::SendFile(int sessionId, const std::vector<std::string> &sFileList,
68     const std::vector<std::string> &dFileList)
69 {
70     if (ISoftbusAdapterMock::iSoftbusAdapterMock_ == nullptr) {
71         return -1;
72     }
73     return ISoftbusAdapterMock::iSoftbusAdapterMock_->SendFile(sessionId, sFileList, dFileList);
74 }
75 
OnBind(int socket,PeerSocketInfo info)76 void SoftbusAdapter::OnBind(int socket, PeerSocketInfo info)
77 {
78     return;
79 }
80 
OnShutdown(int32_t socket,ShutdownReason reason)81 void SoftbusAdapter::OnShutdown(int32_t socket, ShutdownReason reason)
82 {
83     return;
84 }
85 
OnFile(int32_t socket,FileEvent * event)86 void SoftbusAdapter::OnFile(int32_t socket, FileEvent *event)
87 {
88     return;
89 }
OnBytes(int sessionId,const void * data,unsigned int dataLen)90 void SoftbusAdapter::OnBytes(int sessionId, const void *data, unsigned int dataLen)
91 {
92     return;
93 }
94 
OnReceiveFileProcess(int sessionId,const char * firstFile,uint64_t bytesUpload,uint64_t bytesTotal)95 int SoftbusAdapter::OnReceiveFileProcess(int sessionId, const char *firstFile,
96     uint64_t bytesUpload, uint64_t bytesTotal)
97 {
98     return 0;
99 }
100 
OnReceiveFileFinished(int sessionId,const char * files,int fileCnt)101 void SoftbusAdapter::OnReceiveFileFinished(int sessionId, const char *files, int fileCnt)
102 {
103     return;
104 }
105 
GetRecvPath()106 const char* SoftbusAdapter::GetRecvPath()
107 {
108     return "";
109 }
110 
RegisterSessionListener(std::string sessionName,std::shared_ptr<ISoftbusListener> listener)111 void SoftbusAdapter::RegisterSessionListener(std::string sessionName, std::shared_ptr<ISoftbusListener> listener)
112 {
113     return;
114 }
115 
UnRegisterSessionListener(std::string sessionName)116 void SoftbusAdapter::UnRegisterSessionListener(std::string sessionName)
117 {
118     return;
119 }
120 
CloseSession(int sessionId)121 void SoftbusAdapter::CloseSession(int sessionId)
122 {
123     return;
124 }
125 
IsSessionOpened(int sessionId)126 bool SoftbusAdapter::IsSessionOpened(int sessionId)
127 {
128     return false;
129 }
130 
UpdateFileRecvPath(const std::string & bundleName,int32_t userId)131 void SoftbusAdapter::UpdateFileRecvPath(const std::string &bundleName, int32_t userId)
132 {
133     return;
134 }
135 }