1 /* 2 * Copyright (c) 2021-2025 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_stub.h" 22 23 namespace OHOS { 24 #define READ_PARCEL_WITH_RET(parcel, type, data, retVal) \ 25 do { \ 26 if (!(parcel).Read##type(data)) { \ 27 COMM_LOGE(COMM_SDK, "read data failed."); \ 28 return (retVal); \ 29 } \ 30 } while (false) \ 31 32 class SoftBusClientStub : public IRemoteStub<ISoftBusClient> { 33 public: 34 SoftBusClientStub(); 35 virtual ~SoftBusClientStub() = default; 36 int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; 37 int32_t OnChannelOpened(const char *sessionName, const ChannelInfo *info) override; 38 int32_t OnChannelOpenFailed(int32_t channelId, int32_t channelType, int32_t errCode) override; 39 int32_t OnChannelLinkDown(const char *networkId, int32_t routeType) override; 40 int32_t OnChannelClosed(int32_t channelId, int32_t channelType, int32_t messageType) override; 41 int32_t OnChannelMsgReceived(int32_t channelId, int32_t channelType, const void *data, 42 uint32_t len, int32_t type) override; 43 int32_t OnChannelQosEvent(int32_t channelId, int32_t channelType, int32_t eventId, int32_t tvCount, 44 const QosTv *tvList) override; 45 int32_t SetChannelInfo(const char *sessionName, int32_t sessionId, int32_t channelId, int32_t channelType) override; 46 int32_t OnJoinLNNResult(void *addr, uint32_t addrTypeLen, const char *networkId, int retCode) override; 47 int32_t OnLeaveLNNResult(const char *networkId, int retCode) override; 48 int32_t OnNodeOnlineStateChanged(const char *pkgName, bool isOnline, void *info, uint32_t infoTypeLen) override; 49 int32_t OnNodeBasicInfoChanged(const char *pkgName, void *info, uint32_t infoTypeLen, int32_t type) override; 50 int32_t OnNodeStatusChanged(const char *pkgName, void *info, uint32_t infoTypeLen, int32_t type) override; 51 int32_t OnLocalNetworkIdChanged(const char *pkgName) override; 52 int32_t OnNodeDeviceTrustedChange(const char *pkgName, int32_t type, const char *msg, uint32_t msgLen) override; 53 int32_t OnHichainProofException(const char *pkgName, const char *proofInfo, uint32_t proofLen, 54 uint16_t deviceTypeId, int32_t errCode) override; 55 int32_t OnTimeSyncResult(const void *info, uint32_t infoTypeLen, int32_t retCode) override; 56 void OnPublishLNNResult(int32_t publishId, int32_t reason) override; 57 void OnRefreshLNNResult(int32_t refreshId, int32_t reason) override; 58 void OnRefreshDeviceFound(const void *device, uint32_t deviceLen) override; 59 void OnDataLevelChanged(const char *networkId, const DataLevelInfo *dataLevelInfo) override; 60 void OnMsdpRangeResult(const RangeResultInnerInfo *rangeInfo) override; 61 int32_t OnClientTransLimitChange(int32_t channelId, uint8_t tos) override; 62 int32_t OnChannelBind(int32_t channelId, int32_t channelType) override; 63 int32_t OnClientChannelOnQos( 64 int32_t channelId, int32_t channelType, QoSEvent event, const QosTV *qos, uint32_t count) override; 65 int32_t OnCheckCollabRelation(const CollabInfo *sourceInfo, 66 bool isSinkSide, const CollabInfo *sinkInfo, int32_t channelId, int32_t channelType) override; 67 int32_t OnConnectionStateChange(uint32_t handle, int32_t state, int32_t reason) override; 68 int32_t OnAcceptConnect(const char *name, uint32_t handle) override; 69 int32_t OnDataReceived(uint32_t handle, const uint8_t *data, uint32_t len) override; 70 71 private: 72 int32_t OnChannelOpenedInner(MessageParcel &data, MessageParcel &reply); 73 int32_t OnChannelOpenFailedInner(MessageParcel &data, MessageParcel &reply); 74 int32_t OnChannelLinkDownInner(MessageParcel &data, MessageParcel &reply); 75 int32_t OnChannelClosedInner(MessageParcel &data, MessageParcel &reply); 76 int32_t OnChannelMsgReceivedInner(MessageParcel &data, MessageParcel &reply); 77 int32_t OnChannelQosEventInner(MessageParcel &data, MessageParcel &reply); 78 int32_t SetChannelInfoInner(MessageParcel &data, MessageParcel &reply); 79 int32_t OnJoinLNNResultInner(MessageParcel &data, MessageParcel &reply); 80 int32_t OnLeaveLNNResultInner(MessageParcel &data, MessageParcel &reply); 81 int32_t OnNodeOnlineStateChangedInner(MessageParcel &data, MessageParcel &reply); 82 int32_t OnNodeBasicInfoChangedInner(MessageParcel &data, MessageParcel &reply); 83 int32_t OnNodeStatusChangedInner(MessageParcel &data, MessageParcel &reply); 84 int32_t OnLocalNetworkIdChangedInner(MessageParcel &data, MessageParcel &reply); 85 int32_t OnNodeDeviceTrustedChangeInner(MessageParcel &data, MessageParcel &reply); 86 int32_t OnHichainProofExceptionInner(MessageParcel &data, MessageParcel &reply); 87 int32_t OnTimeSyncResultInner(MessageParcel &data, MessageParcel &reply); 88 int32_t OnPublishLNNResultInner(MessageParcel &data, MessageParcel &reply); 89 int32_t OnRefreshLNNResultInner(MessageParcel &data, MessageParcel &reply); 90 int32_t OnRefreshDeviceFoundInner(MessageParcel &data, MessageParcel &reply); 91 int32_t OnClientPermissonChangeInner(MessageParcel &data, MessageParcel &reply); 92 int32_t OnDataLevelChangedInner(MessageParcel &data, MessageParcel &reply); 93 int32_t OnMsdpRangeResultInner(MessageParcel &data, MessageParcel &reply); 94 int32_t OnClientTransLimitChangeInner(MessageParcel &data, MessageParcel &reply); 95 int32_t OnChannelBindInner(MessageParcel &data, MessageParcel &reply); 96 int32_t OnChannelOnQosInner(MessageParcel &data, MessageParcel &reply); 97 int32_t OnCheckCollabRelationInner(MessageParcel &data, MessageParcel &reply); 98 int32_t OnConnectionStateChangeInner(MessageParcel &data, MessageParcel &reply); 99 int32_t OnAcceptConnectInner(MessageParcel &data, MessageParcel &reply); 100 int32_t OnDataReceivedInner(MessageParcel &data, MessageParcel &reply); 101 int32_t OnBrProxyOpenedInner(MessageParcel &data, MessageParcel &reply); 102 int32_t OnBrProxyDataRecvInner(MessageParcel &data, MessageParcel &reply); 103 int32_t OnBrProxyStateChangedInner(MessageParcel &data, MessageParcel &reply); 104 int32_t OnBrProxyQueryPermissionInner(MessageParcel &data, MessageParcel &reply); 105 using SoftBusClientStubFunc = 106 int32_t (SoftBusClientStub::*)(MessageParcel &data, MessageParcel &reply); 107 std::map<uint32_t, SoftBusClientStubFunc> memberFuncMap_; 108 }; 109 } // namespace OHOS 110 111 #endif // SOFTBUS_CLIENT_STUB_H_ 112