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 NET_SUPPLIER_CALLBACK_STUB_H 17 #define NET_SUPPLIER_CALLBACK_STUB_H 18 19 #include <map> 20 #include <set> 21 22 #include "iremote_stub.h" 23 24 #include "i_net_supplier_callback.h" 25 #include "net_supplier_callback_base.h" 26 #include "net_all_capabilities.h" 27 #include "net_manager_constants.h" 28 namespace OHOS { 29 namespace NetManagerStandard { 30 class NetSupplierCallbackStub : public IRemoteStub<INetSupplierCallback> { 31 public: 32 NetSupplierCallbackStub(); 33 virtual ~NetSupplierCallbackStub(); 34 35 void RegisterSupplierCallbackImpl(const sptr<NetSupplierCallbackBase> &callback); 36 37 int32_t OnRemoteRequest( 38 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; 39 40 int32_t RequestNetwork(const std::string &ident, const std::set<NetCap> &netCaps, 41 const NetRequest &netRequest = {}) override; 42 int32_t ReleaseNetwork(const std::string &ident, const std::set<NetCap> &netCaps) override; 43 44 private: 45 using NetSupplierCallbackFunc = int32_t (NetSupplierCallbackStub::*)(MessageParcel &, MessageParcel &); 46 47 private: 48 int32_t OnRequestNetwork(MessageParcel &data, MessageParcel &reply); 49 int32_t OnReleaseNetwork(MessageParcel &data, MessageParcel &reply); 50 51 private: 52 std::map<uint32_t, NetSupplierCallbackFunc> memberFuncMap_; 53 sptr<NetSupplierCallbackBase> callback_; 54 }; 55 } // namespace NetManagerStandard 56 } // namespace OHOS 57 #endif // NET_SUPPLIER_CALLBACK_STUB_H 58