1 /* 2 * Copyright (c) 2021 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 #ifndef SOFTBUS_CLIENT_STUB_H_ 17 #define SOFTBUS_CLIENT_STUB_H_ 18 19 #include <map> 20 #include "if_softbus_client.h" 21 #include "iremote_object.h" 22 #include "iremote_stub.h" 23 24 namespace OHOS { 25 class SoftBusClientStub : public IRemoteStub<ISoftBusClient> { 26 public: 27 SoftBusClientStub(); 28 virtual ~SoftBusClientStub() = default; 29 int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; 30 void OnDeviceFound(const DeviceInfo *device) override; 31 void OnDiscoverFailed(int subscribeId, int failReason) override; 32 void OnDiscoverySuccess(int subscribeId) override; 33 void OnPublishSuccess(int publishId) override; 34 void OnPublishFail(int publishId, int reason) override; 35 int32_t OnChannelOpened(const char *sessionName, const ChannelInfo *info) override; 36 int32_t OnChannelOpenFailed(int32_t channelId, int32_t channelType, int32_t errCode) override; 37 int32_t OnChannelLinkDown(const char *networkId, int32_t routeType) override; 38 int32_t OnChannelClosed(int32_t channelId, int32_t channelType) override; 39 int32_t OnChannelMsgReceived(int32_t channelId, int32_t channelType, const void *data, 40 uint32_t len, int32_t type) override; 41 int32_t OnChannelQosEvent(int32_t channelId, int32_t channelType, int32_t eventId, int32_t tvCount, 42 const QosTv *tvList) override; 43 int32_t OnJoinLNNResult(void *addr, uint32_t addrTypeLen, const char *networkId, int retCode) override; 44 int32_t OnJoinMetaNodeResult(void *addr, uint32_t addrTypeLen, const char *networkId, int retCode) override; 45 int32_t OnLeaveLNNResult(const char *networkId, int retCode) override; 46 int32_t OnLeaveMetaNodeResult(const char *networkId, int retCode) override; 47 int32_t OnNodeOnlineStateChanged(bool isOnline, void *info, uint32_t infoTypeLen) override; 48 int32_t OnNodeBasicInfoChanged(void *info, uint32_t infoTypeLen, int32_t type) override; 49 int32_t OnTimeSyncResult(const void *info, uint32_t infoTypeLen, int32_t retCode) override; 50 void OnPublishLNNResult(int32_t publishId, int32_t reason) override; 51 void OnRefreshLNNResult(int32_t refreshId, int32_t reason) override; 52 void OnRefreshDeviceFound(const void *device, uint32_t deviceLen) override; 53 54 private: 55 int32_t OnDeviceFoundInner(MessageParcel &data, MessageParcel &reply); 56 int32_t OnDiscoverFailedInner(MessageParcel &data, MessageParcel &reply); 57 int32_t OnDiscoverySuccessInner(MessageParcel &data, MessageParcel &reply); 58 int32_t OnPublishSuccessInner(MessageParcel &data, MessageParcel &reply); 59 int32_t OnPublishFailInner(MessageParcel &data, MessageParcel &reply); 60 int32_t OnChannelOpenedInner(MessageParcel &data, MessageParcel &reply); 61 int32_t OnChannelOpenFailedInner(MessageParcel &data, MessageParcel &reply); 62 int32_t OnChannelLinkDownInner(MessageParcel &data, MessageParcel &reply); 63 int32_t OnChannelClosedInner(MessageParcel &data, MessageParcel &reply); 64 int32_t OnChannelMsgReceivedInner(MessageParcel &data, MessageParcel &reply); 65 int32_t OnChannelQosEventInner(MessageParcel &data, MessageParcel &reply); 66 int32_t OnJoinLNNResultInner(MessageParcel &data, MessageParcel &reply); 67 int32_t OnJoinMetaNodeResultInner(MessageParcel &data, MessageParcel &reply); 68 int32_t OnLeaveLNNResultInner(MessageParcel &data, MessageParcel &reply); 69 int32_t OnLeaveMetaNodeResultInner(MessageParcel &data, MessageParcel &reply); 70 int32_t OnNodeOnlineStateChangedInner(MessageParcel &data, MessageParcel &reply); 71 int32_t OnNodeBasicInfoChangedInner(MessageParcel &data, MessageParcel &reply); 72 int32_t OnTimeSyncResultInner(MessageParcel &data, MessageParcel &reply); 73 int32_t OnPublishLNNResultInner(MessageParcel &data, MessageParcel &reply); 74 int32_t OnRefreshLNNResultInner(MessageParcel &data, MessageParcel &reply); 75 int32_t OnRefreshDeviceFoundInner(MessageParcel &data, MessageParcel &reply); 76 int32_t OnClientPermissonChangeInner(MessageParcel &data, MessageParcel &reply); 77 78 using SoftBusClientStubFunc = 79 int32_t (SoftBusClientStub::*)(MessageParcel &data, MessageParcel &reply); 80 std::map<uint32_t, SoftBusClientStubFunc> memberFuncMap_; 81 }; 82 } // namespace OHOS 83 84 #endif // SOFTBUS_CLIENT_STUB_H_