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 "dsoftbus_adapter.h"
17
18 #include "dsoftbus_adapter_impl.h"
19
20 namespace OHOS {
21 namespace Msdp {
22 namespace DeviceStatus {
Enable()23 int32_t DSoftbusAdapter::Enable()
24 {
25 return DSoftbusAdapterImpl::GetInstance()->Enable();
26 }
27
Disable()28 void DSoftbusAdapter::Disable()
29 {
30 DSoftbusAdapterImpl::GetInstance()->Disable();
31 }
32
AddObserver(std::shared_ptr<IDSoftbusObserver> observer)33 void DSoftbusAdapter::AddObserver(std::shared_ptr<IDSoftbusObserver> observer)
34 {
35 DSoftbusAdapterImpl::GetInstance()->AddObserver(observer);
36 }
37
RemoveObserver(std::shared_ptr<IDSoftbusObserver> observer)38 void DSoftbusAdapter::RemoveObserver(std::shared_ptr<IDSoftbusObserver> observer)
39 {
40 DSoftbusAdapterImpl::GetInstance()->RemoveObserver(observer);
41 }
42
CheckDeviceOnline(const std::string & networkId)43 int32_t DSoftbusAdapter::CheckDeviceOnline(const std::string &networkId)
44 {
45 return DSoftbusAdapterImpl::GetInstance()->CheckDeviceOnline(networkId);
46 }
47
OpenSession(const std::string & networkId)48 int32_t DSoftbusAdapter::OpenSession(const std::string &networkId)
49 {
50 return DSoftbusAdapterImpl::GetInstance()->OpenSession(networkId);
51 }
52
CloseSession(const std::string & networkId)53 void DSoftbusAdapter::CloseSession(const std::string &networkId)
54 {
55 DSoftbusAdapterImpl::GetInstance()->CloseSession(networkId);
56 }
57
StartHeartBeat(const std::string & networkId)58 void DSoftbusAdapter::StartHeartBeat(const std::string &networkId)
59 {
60 DSoftbusAdapterImpl::GetInstance()->StartHeartBeat(networkId);
61 }
62
StopHeartBeat(const std::string & networkId)63 void DSoftbusAdapter::StopHeartBeat(const std::string &networkId)
64 {
65 DSoftbusAdapterImpl::GetInstance()->StopHeartBeat(networkId);
66 }
67
CloseAllSessions()68 void DSoftbusAdapter::CloseAllSessions()
69 {
70 DSoftbusAdapterImpl::GetInstance()->CloseAllSessions();
71 }
72
SendPacket(const std::string & networkId,NetPacket & packet)73 int32_t DSoftbusAdapter::SendPacket(const std::string &networkId, NetPacket &packet)
74 {
75 return DSoftbusAdapterImpl::GetInstance()->SendPacket(networkId, packet);
76 }
77
SendParcel(const std::string & networkId,Parcel & parcel)78 int32_t DSoftbusAdapter::SendParcel(const std::string &networkId, Parcel &parcel)
79 {
80 return DSoftbusAdapterImpl::GetInstance()->SendParcel(networkId, parcel);
81 }
82
BroadcastPacket(NetPacket & packet)83 int32_t DSoftbusAdapter::BroadcastPacket(NetPacket &packet)
84 {
85 return DSoftbusAdapterImpl::GetInstance()->BroadcastPacket(packet);
86 }
87
HasSessionExisted(const std::string & networkId)88 bool DSoftbusAdapter::HasSessionExisted(const std::string &networkId)
89 {
90 return DSoftbusAdapterImpl::GetInstance()->HasSessionExisted(networkId);
91 }
92
93 } // namespace DeviceStatus
94 } // namespace Msdp
95 } // namespace OHOS
96