Commit 29a3ecc1 authored by Honfika's avatar Honfika

Use the common remove proxy method. Unused internal methods removed.

parent fc8576bf
...@@ -71,37 +71,12 @@ namespace Titanium.Web.Proxy.Helpers ...@@ -71,37 +71,12 @@ namespace Titanium.Web.Proxy.Helpers
internal const int InternetOptionSettingsChanged = 39; internal const int InternetOptionSettingsChanged = 39;
internal const int InternetOptionRefresh = 37; internal const int InternetOptionRefresh = 37;
internal void SetHttpProxy(string hostname, int port)
{
SetProxy(hostname, port, ProxyProtocolType.Http);
}
/// <summary>
/// Remove the http proxy setting from current machine
/// </summary>
internal void RemoveHttpProxy()
{
RemoveProxy(ProxyProtocolType.Http);
}
/// <summary> /// <summary>
/// Set the HTTPS proxy server for current machine /// Set the HTTP and/or HTTPS proxy server for current machine
/// </summary> /// </summary>
/// <param name="hostname"></param> /// <param name="hostname"></param>
/// <param name="port"></param> /// <param name="port"></param>
internal void SetHttpsProxy(string hostname, int port) /// <param name="protocolType"></param>
{
SetProxy(hostname, port, ProxyProtocolType.Https);
}
/// <summary>
/// Removes the https proxy setting to nothing
/// </summary>
internal void RemoveHttpsProxy()
{
RemoveProxy(ProxyProtocolType.Https);
}
internal void SetProxy(string hostname, int port, ProxyProtocolType protocolType) internal void SetProxy(string hostname, int port, ProxyProtocolType protocolType)
{ {
var reg = Registry.CurrentUser.OpenSubKey( var reg = Registry.CurrentUser.OpenSubKey(
...@@ -141,6 +116,9 @@ namespace Titanium.Web.Proxy.Helpers ...@@ -141,6 +116,9 @@ namespace Titanium.Web.Proxy.Helpers
Refresh(); Refresh();
} }
/// <summary>
/// Remove the HTTP and/or HTTPS proxy setting from current machine
/// </summary>
internal void RemoveProxy(ProxyProtocolType protocolType) internal void RemoveProxy(ProxyProtocolType protocolType)
{ {
var reg = Registry.CurrentUser.OpenSubKey( var reg = Registry.CurrentUser.OpenSubKey(
...@@ -150,7 +128,7 @@ namespace Titanium.Web.Proxy.Helpers ...@@ -150,7 +128,7 @@ namespace Titanium.Web.Proxy.Helpers
var exisitingContent = reg.GetValue("ProxyServer") as string; var exisitingContent = reg.GetValue("ProxyServer") as string;
var existingSystemProxyValues = GetSystemProxyValues(exisitingContent); var existingSystemProxyValues = GetSystemProxyValues(exisitingContent);
existingSystemProxyValues.RemoveAll(x => (protocolType | x.ProtocolType) != 0); existingSystemProxyValues.RemoveAll(x => (protocolType & x.ProtocolType) != 0);
if (existingSystemProxyValues.Count != 0) if (existingSystemProxyValues.Count != 0)
{ {
......
...@@ -449,12 +449,7 @@ namespace Titanium.Web.Proxy ...@@ -449,12 +449,7 @@ namespace Titanium.Web.Proxy
/// </summary> /// </summary>
public void DisableSystemHttpProxy() public void DisableSystemHttpProxy()
{ {
if (RunTime.IsRunningOnMono) DisableSystemProxy(ProxyProtocolType.Http);
{
throw new Exception("Mono Runtime do not support system proxy settings.");
}
systemProxySettingsManager.RemoveHttpProxy();
} }
/// <summary> /// <summary>
...@@ -462,12 +457,7 @@ namespace Titanium.Web.Proxy ...@@ -462,12 +457,7 @@ namespace Titanium.Web.Proxy
/// </summary> /// </summary>
public void DisableSystemHttpsProxy() public void DisableSystemHttpsProxy()
{ {
if (RunTime.IsRunningOnMono) DisableSystemProxy(ProxyProtocolType.Https);
{
throw new Exception("Mono Runtime do not support system proxy settings.");
}
systemProxySettingsManager.RemoveHttpsProxy();
} }
/// <summary> /// <summary>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment