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_mock.h"
17
18 namespace OHOS {
19 namespace Storage {
20 namespace DistributedFile {
21 SoftBusHandler::SoftBusHandler() = default;
22 SoftBusHandler::~SoftBusHandler() = default;
23
GetInstance()24 SoftBusHandler &SoftBusHandler::GetInstance()
25 {
26 static SoftBusHandler handle;
27 return handle;
28 }
29
OnSinkSessionOpened(int32_t sessionId,PeerSocketInfo info)30 void SoftBusHandler::OnSinkSessionOpened(int32_t sessionId, PeerSocketInfo info)
31 {
32 return;
33 }
34
GetSessionName(int32_t sessionId)35 std::string SoftBusHandler::GetSessionName(int32_t sessionId)
36 {
37 return "test";
38 }
39
CreateSessionServer(const std::string & packageName,const std::string & sessionName,DFS_CHANNEL_ROLE role,const std::string physicalPath)40 int32_t SoftBusHandler::CreateSessionServer(const std::string &packageName, const std::string &sessionName,
41 DFS_CHANNEL_ROLE role, const std::string physicalPath)
42 {
43 if (ISoftBusHandlerMock::iSoftBusHandlerMock_ == nullptr) {
44 return -1;
45 }
46 return ISoftBusHandlerMock::iSoftBusHandlerMock_->CreateSessionServer(packageName, sessionName, role, physicalPath);
47 }
48
OpenSession(const std::string & mySessionName,const std::string & peerSessionName,const std::string & peerDevId,int32_t & socketId)49 int32_t SoftBusHandler::OpenSession(const std::string &mySessionName, const std::string &peerSessionName,
50 const std::string &peerDevId, int32_t &socketId)
51 {
52 if (ISoftBusHandlerMock::iSoftBusHandlerMock_ == nullptr) {
53 return -1;
54 }
55 return ISoftBusHandlerMock::iSoftBusHandlerMock_->OpenSession(mySessionName,
56 peerSessionName, peerDevId, socketId);
57 }
58
CreatSocketId(const std::string & mySessionName,const std::string & peerSessionName,const std::string & peerDevId,int32_t & socketId)59 bool SoftBusHandler::CreatSocketId(const std::string &mySessionName, const std::string &peerSessionName,
60 const std::string &peerDevId, int32_t &socketId)
61 {
62 return true;
63 }
64
CopySendFile(int32_t socketId,const std::string & sessionName,const std::string & srcUri,const std::string & dstPath)65 int32_t SoftBusHandler::CopySendFile(int32_t socketId,
66 const std::string &sessionName,
67 const std::string &srcUri,
68 const std::string &dstPath)
69 {
70 if (ISoftBusHandlerMock::iSoftBusHandlerMock_ == nullptr) {
71 return -1;
72 }
73 return ISoftBusHandlerMock::iSoftBusHandlerMock_->CopySendFile(socketId, sessionName, srcUri, dstPath);
74 }
75
ChangeOwnerIfNeeded(int32_t sessionId,const std::string sessionName)76 void SoftBusHandler::ChangeOwnerIfNeeded(int32_t sessionId, const std::string sessionName)
77 {
78 return;
79 }
80
CloseSession(int32_t sessionId,const std::string sessionName)81 void SoftBusHandler::CloseSession(int32_t sessionId, const std::string sessionName)
82 {
83 return;
84 }
85
CloseSessionWithSessionName(const std::string sessionName)86 void SoftBusHandler::CloseSessionWithSessionName(const std::string sessionName)
87 {
88 return;
89 }
RemoveNetworkId(int32_t socketId)90 void SoftBusHandler::RemoveNetworkId(int32_t socketId)
91 {
92 return;
93 }
94
GetsocketIdFromPeerNetworkId(const std::string & peerNetworkId)95 std::vector<int32_t> SoftBusHandler::GetsocketIdFromPeerNetworkId(const std::string &peerNetworkId)
96 {
97 return {0};
98 }
99
IsService(std::string & sessionName)100 bool SoftBusHandler::IsService(std::string &sessionName)
101 {
102 return true;
103 }
104
CopyOnStop(const std::string & peerNetworkId)105 void SoftBusHandler::CopyOnStop(const std::string &peerNetworkId)
106 {
107 return;
108 }
109 } // namespace DistributedFile
110 } // namespace Storage
111 } // namespace OHOS