1060ff233Sopenharmony_ci/*
2060ff233Sopenharmony_ci * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
3060ff233Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4060ff233Sopenharmony_ci * you may not use this file except in compliance with the License.
5060ff233Sopenharmony_ci * You may obtain a copy of the License at
6060ff233Sopenharmony_ci *
7060ff233Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8060ff233Sopenharmony_ci *
9060ff233Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10060ff233Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11060ff233Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12060ff233Sopenharmony_ci * See the License for the specific language governing permissions and
13060ff233Sopenharmony_ci * limitations under the License.
14060ff233Sopenharmony_ci */
15060ff233Sopenharmony_ci
16060ff233Sopenharmony_ci#ifndef SOFTBUS_CLIENT_STUB_H_
17060ff233Sopenharmony_ci#define SOFTBUS_CLIENT_STUB_H_
18060ff233Sopenharmony_ci
19060ff233Sopenharmony_ci#include <map>
20060ff233Sopenharmony_ci#include "if_softbus_client.h"
21060ff233Sopenharmony_ci#include "iremote_object.h"
22060ff233Sopenharmony_ci#include "iremote_stub.h"
23060ff233Sopenharmony_ci
24060ff233Sopenharmony_cinamespace OHOS {
25060ff233Sopenharmony_ci#define READ_PARCEL_WITH_RET(parcel, type, data, retVal)        \
26060ff233Sopenharmony_ci    do {                                                        \
27060ff233Sopenharmony_ci        if (!(parcel).Read##type(data)) {                       \
28060ff233Sopenharmony_ci            COMM_LOGE(COMM_SDK, "read data failed.");           \
29060ff233Sopenharmony_ci            return (retVal);                                    \
30060ff233Sopenharmony_ci        }                                                       \
31060ff233Sopenharmony_ci    } while (false)                                             \
32060ff233Sopenharmony_ci
33060ff233Sopenharmony_ciclass SoftBusClientStub : public IRemoteStub<ISoftBusClient> {
34060ff233Sopenharmony_cipublic:
35060ff233Sopenharmony_ci    SoftBusClientStub();
36060ff233Sopenharmony_ci    virtual ~SoftBusClientStub() = default;
37060ff233Sopenharmony_ci    int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
38060ff233Sopenharmony_ci    int32_t OnChannelOpened(const char *sessionName, const ChannelInfo *info) override;
39060ff233Sopenharmony_ci    int32_t OnChannelOpenFailed(int32_t channelId, int32_t channelType, int32_t errCode) override;
40060ff233Sopenharmony_ci    int32_t OnChannelLinkDown(const char *networkId, int32_t routeType) override;
41060ff233Sopenharmony_ci    int32_t OnChannelClosed(int32_t channelId, int32_t channelType, int32_t messageType) override;
42060ff233Sopenharmony_ci    int32_t OnChannelMsgReceived(int32_t channelId, int32_t channelType, const void *data,
43060ff233Sopenharmony_ci        uint32_t len, int32_t type) override;
44060ff233Sopenharmony_ci    int32_t OnChannelQosEvent(int32_t channelId, int32_t channelType, int32_t eventId, int32_t tvCount,
45060ff233Sopenharmony_ci        const QosTv *tvList) override;
46060ff233Sopenharmony_ci    int32_t SetChannelInfo(const char *sessionName, int32_t sessionId, int32_t channelId, int32_t channelType) override;
47060ff233Sopenharmony_ci    int32_t OnJoinLNNResult(void *addr, uint32_t addrTypeLen, const char *networkId, int retCode) override;
48060ff233Sopenharmony_ci    int32_t OnLeaveLNNResult(const char *networkId, int retCode) override;
49060ff233Sopenharmony_ci    int32_t OnNodeOnlineStateChanged(const char *pkgName, bool isOnline, void *info, uint32_t infoTypeLen) override;
50060ff233Sopenharmony_ci    int32_t OnNodeBasicInfoChanged(const char *pkgName, void *info, uint32_t infoTypeLen, int32_t type) override;
51060ff233Sopenharmony_ci    int32_t OnNodeStatusChanged(const char *pkgName, void *info, uint32_t infoTypeLen, int32_t type) override;
52060ff233Sopenharmony_ci    int32_t OnLocalNetworkIdChanged(const char *pkgName) override;
53060ff233Sopenharmony_ci    int32_t OnNodeDeviceTrustedChange(const char *pkgName, int32_t type, const char *msg, uint32_t msgLen) override;
54060ff233Sopenharmony_ci    int32_t OnHichainProofException(const char *pkgName, const char *deviceList, uint32_t deviceListLen,
55060ff233Sopenharmony_ci        uint16_t deviceTypeId, int32_t errCode) override;
56060ff233Sopenharmony_ci    int32_t OnTimeSyncResult(const void *info, uint32_t infoTypeLen, int32_t retCode) override;
57060ff233Sopenharmony_ci    void OnPublishLNNResult(int32_t publishId, int32_t reason) override;
58060ff233Sopenharmony_ci    void OnRefreshLNNResult(int32_t refreshId, int32_t reason) override;
59060ff233Sopenharmony_ci    void OnRefreshDeviceFound(const void *device, uint32_t deviceLen) override;
60060ff233Sopenharmony_ci    void OnDataLevelChanged(const char *networkId, const DataLevelInfo *dataLevelInfo) override;
61060ff233Sopenharmony_ci    int32_t OnClientTransLimitChange(int32_t channelId, uint8_t tos) override;
62060ff233Sopenharmony_ci    int32_t OnChannelBind(int32_t channelId, int32_t channelType) override;
63060ff233Sopenharmony_ci
64060ff233Sopenharmony_ciprivate:
65060ff233Sopenharmony_ci    int32_t OnChannelOpenedInner(MessageParcel &data, MessageParcel &reply);
66060ff233Sopenharmony_ci    int32_t OnChannelOpenFailedInner(MessageParcel &data, MessageParcel &reply);
67060ff233Sopenharmony_ci    int32_t OnChannelLinkDownInner(MessageParcel &data, MessageParcel &reply);
68060ff233Sopenharmony_ci    int32_t OnChannelClosedInner(MessageParcel &data, MessageParcel &reply);
69060ff233Sopenharmony_ci    int32_t OnChannelMsgReceivedInner(MessageParcel &data, MessageParcel &reply);
70060ff233Sopenharmony_ci    int32_t OnChannelQosEventInner(MessageParcel &data, MessageParcel &reply);
71060ff233Sopenharmony_ci    int32_t SetChannelInfoInner(MessageParcel &data, MessageParcel &reply);
72060ff233Sopenharmony_ci    int32_t OnJoinLNNResultInner(MessageParcel &data, MessageParcel &reply);
73060ff233Sopenharmony_ci    int32_t OnLeaveLNNResultInner(MessageParcel &data, MessageParcel &reply);
74060ff233Sopenharmony_ci    int32_t OnNodeOnlineStateChangedInner(MessageParcel &data, MessageParcel &reply);
75060ff233Sopenharmony_ci    int32_t OnNodeBasicInfoChangedInner(MessageParcel &data, MessageParcel &reply);
76060ff233Sopenharmony_ci    int32_t OnNodeStatusChangedInner(MessageParcel &data, MessageParcel &reply);
77060ff233Sopenharmony_ci    int32_t OnLocalNetworkIdChangedInner(MessageParcel &data, MessageParcel &reply);
78060ff233Sopenharmony_ci    int32_t OnNodeDeviceTrustedChangeInner(MessageParcel &data, MessageParcel &reply);
79060ff233Sopenharmony_ci    int32_t OnHichainProofExceptionInner(MessageParcel &data, MessageParcel &reply);
80060ff233Sopenharmony_ci    int32_t OnTimeSyncResultInner(MessageParcel &data, MessageParcel &reply);
81060ff233Sopenharmony_ci    int32_t OnPublishLNNResultInner(MessageParcel &data, MessageParcel &reply);
82060ff233Sopenharmony_ci    int32_t OnRefreshLNNResultInner(MessageParcel &data, MessageParcel &reply);
83060ff233Sopenharmony_ci    int32_t OnRefreshDeviceFoundInner(MessageParcel &data, MessageParcel &reply);
84060ff233Sopenharmony_ci    int32_t OnClientPermissonChangeInner(MessageParcel &data, MessageParcel &reply);
85060ff233Sopenharmony_ci    int32_t OnDataLevelChangedInner(MessageParcel &data, MessageParcel &reply);
86060ff233Sopenharmony_ci    int32_t OnClientTransLimitChangeInner(MessageParcel &data, MessageParcel &reply);
87060ff233Sopenharmony_ci    int32_t OnChannelBindInner(MessageParcel &data, MessageParcel &reply);
88060ff233Sopenharmony_ci    using SoftBusClientStubFunc =
89060ff233Sopenharmony_ci        int32_t (SoftBusClientStub::*)(MessageParcel &data, MessageParcel &reply);
90060ff233Sopenharmony_ci    std::map<uint32_t, SoftBusClientStubFunc> memberFuncMap_;
91060ff233Sopenharmony_ci};
92060ff233Sopenharmony_ci} // namespace OHOS
93060ff233Sopenharmony_ci
94060ff233Sopenharmony_ci#endif // SOFTBUS_CLIENT_STUB_H_
95