1 // Copyright (C) 2023 Huawei Device Co., Ltd. 2 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // you may not use this file except in compliance with the License. 4 // You may obtain a copy of the License at 5 // 6 // http://www.apache.org/licenses/LICENSE-2.0 7 // 8 // Unless required by applicable law or agreed to in writing, software 9 // distributed under the License is distributed on an "AS IS" BASIS, 10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 use crate::utils::c_wrapper::CStringWrapper; 15 16 #[derive(Clone)] 17 pub(crate) struct SystemProxyManager; 18 19 impl SystemProxyManager { init() -> Self20 pub(crate) fn init() -> Self { 21 unsafe { 22 RegisterProxySubscriber(); 23 } 24 Self 25 } 26 host(&self) -> String27 pub(crate) fn host(&self) -> String { 28 unsafe { GetHost() }.to_string() 29 } 30 port(&self) -> String31 pub(crate) fn port(&self) -> String { 32 unsafe { GetPort() }.to_string() 33 } 34 exlist(&self) -> String35 pub(crate) fn exlist(&self) -> String { 36 unsafe { GetExclusionList() }.to_string() 37 } 38 } 39 40 #[cfg(feature = "oh")] 41 extern "C" { RegisterProxySubscriber()42 pub(crate) fn RegisterProxySubscriber(); GetHost() -> CStringWrapper43 pub(crate) fn GetHost() -> CStringWrapper; GetPort() -> CStringWrapper44 pub(crate) fn GetPort() -> CStringWrapper; GetExclusionList() -> CStringWrapper45 pub(crate) fn GetExclusionList() -> CStringWrapper; 46 } 47