1 /* 2 * Copyright (c) 2023 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 NETWORKVPN_SERVICE_PROXY_H 17 #define NETWORKVPN_SERVICE_PROXY_H 18 19 #include <string> 20 21 #include "i_networkvpn_service.h" 22 #include "iremote_proxy.h" 23 24 namespace OHOS { 25 namespace NetManagerStandard { 26 class NetworkVpnServiceProxy : public IRemoteProxy<INetworkVpnService> { 27 public: 28 explicit NetworkVpnServiceProxy(const sptr<IRemoteObject> &impl); 29 virtual ~NetworkVpnServiceProxy() = default; 30 31 int32_t Prepare(bool &isExistVpn, bool &isRun, std::string &pkg) override; 32 int32_t SetUpVpn(const sptr<VpnConfig> &config, bool isVpnExtCall = false) override; 33 int32_t Protect(bool isVpnExtCall = false) override; 34 int32_t DestroyVpn(bool isVpnExtCall = false) override; 35 int32_t RegisterVpnEvent(sptr<IVpnEventCallback> callback) override; 36 int32_t UnregisterVpnEvent(sptr<IVpnEventCallback> callback) override; 37 int32_t CreateVpnConnection(bool isVpnExtCall = false) override; 38 int32_t FactoryResetVpn() override; 39 int32_t RegisterBundleName(const std::string &bundleName, const std::string &abilityName) override; 40 int32_t GetSelfAppName(std::string &selfAppName, std::string &selfBundleName) override; 41 int32_t SetSelfVpnPid() override; 42 #ifdef SUPPORT_SYSVPN 43 int32_t SetUpVpn(const sptr<SysVpnConfig> &config) override; 44 int32_t AddSysVpnConfig(sptr<SysVpnConfig> &config) override; 45 int32_t DeleteSysVpnConfig(const std::string &vpnId) override; 46 int32_t GetSysVpnConfigList(std::vector<SysVpnConfig> &vpnList) override; 47 int32_t GetSysVpnConfig(sptr<SysVpnConfig> &config, const std::string &vpnId) override; 48 int32_t GetConnectedSysVpnConfig(sptr<SysVpnConfig> &config) override; 49 int32_t NotifyConnectStage(const std::string &stage, const int32_t &result) override; 50 int32_t GetSysVpnCertUri(const int32_t certType, std::string &certUri) override; 51 #endif // SUPPORT_SYSVPN 52 53 private: 54 int32_t WriteTokenAndSendRequest(INetworkVpnService::MessageCode code, MessageParcel &data, MessageParcel &reply); 55 int32_t SendRequest(INetworkVpnService::MessageCode code, MessageParcel &data, MessageParcel &reply); 56 57 private: 58 static inline BrokerDelegator<NetworkVpnServiceProxy> delegator_; 59 }; 60 } // namespace NetManagerStandard 61 } // namespace OHOS 62 #endif // NETWORKVPN_SERVICE_PROXY_H 63