Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: core/details/MeGUISettings.cs
- ===================================================================
- --- core/details/MeGUISettings.cs (revision 2258)
- +++ core/details/MeGUISettings.cs (working copy)
- @@ -56,7 +56,7 @@
- private bool recalculateMainMovieBitrate, autoForceFilm, autoStartQueue, enableMP3inMP4, autoOpenScript,
- overwriteStats, keep2of3passOutput, autoUpdate, deleteCompletedJobs, deleteIntermediateFiles,
- deleteAbortedOutput, openProgressWindow, useadvancedtooltips, autoSelectHDStreams, autoscroll,
- - alwaysOnTop, safeProfileAlteration, usehttpproxy, addTimePosition, alwaysbackupfiles, bUseITU,
- + alwaysOnTop, safeProfileAlteration, addTimePosition, alwaysbackupfiles, bUseITU,
- forcerawavcextension, bAutoLoadDG, bAutoStartQueueStartup, bAlwaysMuxMKV, b64bitX264, bUseQAAC,
- bEnsureCorrectPlaybackSpeed, bOpenAVSInThread, bUseDGIndexNV, bUseNeroAacEnc;
- private ulong audioSamplesPerUpdate;
- @@ -78,6 +78,7 @@
- private Dar[] customDARs;
- private OCGUIMode ocGUIMode;
- private AfterEncoding afterEncoding;
- + private ProxyMode httpProxyMode;
- #endregion
- public MeGUISettings()
- {
- @@ -155,7 +156,7 @@
- audioExtension = "";
- safeProfileAlteration = false;
- alwaysOnTop = false;
- - usehttpproxy = false;
- + httpProxyMode = ProxyMode.None;
- httpproxyaddress = "";
- httpproxyport = "";
- httpproxyuid = "";
- @@ -1036,10 +1037,10 @@
- /// <summary>
- /// gets / sets the default settings for the Proxy
- /// </summary>
- - public bool UseHttpProxy
- + public ProxyMode HttpProxyMode
- {
- - get { return usehttpproxy; }
- - set { usehttpproxy = value; }
- + get { return httpProxyMode; }
- + set { httpProxyMode = value; }
- }
- /// <summary>
- /// gets / sets the default settings for the Proxy Adress
- @@ -1204,4 +1205,5 @@
- #endregion
- }
- public enum AfterEncoding { DoNothing = 0, Shutdown = 1, RunCommand = 2, CloseMeGUI = 3 }
- + public enum ProxyMode { None = 0, SystemProxy = 1, CustomProxy = 2, CustomProxyWithLogin = 3 }
- }
- Index: core/gui/SettingsForm.cs
- ===================================================================
- --- core/gui/SettingsForm.cs (revision 2258)
- +++ core/gui/SettingsForm.cs (working copy)
- @@ -95,7 +95,6 @@
- private Label label20;
- private Label label19;
- private Label label18;
- - private CheckBox cbx_usehttpproxy;
- private TextBox txt_httpproxypwd;
- private TextBox txt_httpproxyport;
- private GroupBox gbDefaultOutput;
- @@ -141,6 +140,8 @@
- private Label lblNero;
- private CheckBox useDGIndexNV;
- private CheckBox useQAAC;
- + private Label label1;
- + private ComboBox cbHttpProxyMode;
- private XmlDocument ContextHelp = new XmlDocument();
- #region start / stop
- public SettingsForm()
- @@ -272,6 +273,8 @@
- this.clearDefaultOutputDir = new System.Windows.Forms.Button();
- this.tabPage3 = new System.Windows.Forms.TabPage();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- + this.label1 = new System.Windows.Forms.Label();
- + this.cbHttpProxyMode = new System.Windows.Forms.ComboBox();
- this.txt_httpproxyport = new System.Windows.Forms.TextBox();
- this.txt_httpproxypwd = new System.Windows.Forms.TextBox();
- this.txt_httpproxyuid = new System.Windows.Forms.TextBox();
- @@ -280,7 +283,6 @@
- this.label20 = new System.Windows.Forms.Label();
- this.label19 = new System.Windows.Forms.Label();
- this.label18 = new System.Windows.Forms.Label();
- - this.cbx_usehttpproxy = new System.Windows.Forms.CheckBox();
- this.gbVideoPreview = new System.Windows.Forms.GroupBox();
- this.chkEnsureCorrectPlaybackSpeed = new System.Windows.Forms.CheckBox();
- this.cbAddTimePos = new System.Windows.Forms.CheckBox();
- @@ -807,6 +809,8 @@
- //
- // groupBox2
- //
- + this.groupBox2.Controls.Add(this.label1);
- + this.groupBox2.Controls.Add(this.cbHttpProxyMode);
- this.groupBox2.Controls.Add(this.txt_httpproxyport);
- this.groupBox2.Controls.Add(this.txt_httpproxypwd);
- this.groupBox2.Controls.Add(this.txt_httpproxyuid);
- @@ -815,7 +819,6 @@
- this.groupBox2.Controls.Add(this.label20);
- this.groupBox2.Controls.Add(this.label19);
- this.groupBox2.Controls.Add(this.label18);
- - this.groupBox2.Controls.Add(this.cbx_usehttpproxy);
- this.groupBox2.Location = new System.Drawing.Point(227, 234);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(240, 144);
- @@ -823,6 +826,30 @@
- this.groupBox2.TabStop = false;
- this.groupBox2.Text = " Auto Update Http Proxy ";
- //
- + // label1
- + //
- + this.label1.AutoSize = true;
- + this.label1.Location = new System.Drawing.Point(7, 19);
- + this.label1.Name = "label1";
- + this.label1.Size = new System.Drawing.Size(35, 13);
- + this.label1.TabIndex = 10;
- + this.label1.Text = "Use:";
- + //
- + // cbHttpProxyMode
- + //
- + this.cbHttpProxyMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- + this.cbHttpProxyMode.FormattingEnabled = true;
- + this.cbHttpProxyMode.Items.AddRange(new object[] {
- + "None",
- + "System Proxy",
- + "Custom Proxy",
- + "Custom Proxy With Login"});
- + this.cbHttpProxyMode.Location = new System.Drawing.Point(55, 16);
- + this.cbHttpProxyMode.Name = "cbHttpProxyMode";
- + this.cbHttpProxyMode.Size = new System.Drawing.Size(179, 21);
- + this.cbHttpProxyMode.TabIndex = 9;
- + this.cbHttpProxyMode.SelectedIndexChanged += new System.EventHandler(this.cbHttpProxyMode_SelectedIndexChanged);
- + //
- // txt_httpproxyport
- //
- this.txt_httpproxyport.Enabled = false;
- @@ -892,17 +919,6 @@
- this.label18.TabIndex = 1;
- this.label18.Text = "Server:";
- //
- - // cbx_usehttpproxy
- - //
- - this.cbx_usehttpproxy.AutoSize = true;
- - this.cbx_usehttpproxy.Location = new System.Drawing.Point(9, 21);
- - this.cbx_usehttpproxy.Name = "cbx_usehttpproxy";
- - this.cbx_usehttpproxy.Size = new System.Drawing.Size(75, 17);
- - this.cbx_usehttpproxy.TabIndex = 0;
- - this.cbx_usehttpproxy.Text = "Use Proxy";
- - this.cbx_usehttpproxy.UseVisualStyleBackColor = true;
- - this.cbx_usehttpproxy.CheckedChanged += new System.EventHandler(this.cbx_usehttpproxy_CheckedChanged);
- - //
- // gbVideoPreview
- //
- this.gbVideoPreview.Controls.Add(this.chkEnsureCorrectPlaybackSpeed);
- @@ -1589,12 +1605,14 @@
- }
- }
- - private void cbx_usehttpproxy_CheckedChanged(object sender, EventArgs e)
- + private void cbHttpProxyMode_SelectedIndexChanged(object sender, EventArgs e)
- {
- - txt_httpproxyaddress.Enabled = cbx_usehttpproxy.Checked;
- - txt_httpproxyport.Enabled = cbx_usehttpproxy.Checked;
- - txt_httpproxyuid.Enabled = cbx_usehttpproxy.Checked;
- - txt_httpproxypwd.Enabled = cbx_usehttpproxy.Checked;
- + var httpProxyMode = (ProxyMode)this.cbHttpProxyMode.SelectedIndex;
- +
- + txt_httpproxyaddress.Enabled = httpProxyMode == ProxyMode.CustomProxy || httpProxyMode == ProxyMode.CustomProxyWithLogin;
- + txt_httpproxyport.Enabled = httpProxyMode == ProxyMode.CustomProxy || httpProxyMode == ProxyMode.CustomProxyWithLogin;
- + txt_httpproxyuid.Enabled = httpProxyMode == ProxyMode.CustomProxyWithLogin;
- + txt_httpproxypwd.Enabled = httpProxyMode == ProxyMode.CustomProxyWithLogin;
- }
- private void clearDefaultOutputDir_Click(object sender, EventArgs e)
- @@ -1655,7 +1673,7 @@
- settings.AutoSelectHDStreams = chkSelectHDTracks.Checked;
- settings.AedSettings = this.autoEncodeDefaults;
- settings.AlwaysOnTop = chAlwaysOnTop.Checked;
- - settings.UseHttpProxy = cbx_usehttpproxy.Checked;
- + settings.HttpProxyMode = (ProxyMode)this.cbHttpProxyMode.SelectedIndex;
- settings.HttpProxyAddress = txt_httpproxyaddress.Text;
- settings.HttpProxyPort = txt_httpproxyport.Text;
- settings.HttpProxyUid = txt_httpproxyuid.Text;
- @@ -1721,7 +1739,7 @@
- chkSelectHDTracks.Checked = settings.AutoSelectHDStreams;
- this.autoEncodeDefaults = settings.AedSettings;
- chAlwaysOnTop.Checked = settings.AlwaysOnTop;
- - cbx_usehttpproxy.Checked = settings.UseHttpProxy;
- + cbHttpProxyMode.SelectedIndex = (int)settings.HttpProxyMode;
- txt_httpproxyaddress.Text = settings.HttpProxyAddress;
- txt_httpproxyport.Text = settings.HttpProxyPort;
- txt_httpproxyuid.Text = settings.HttpProxyUid;
- Index: core/gui/UpdateCacher.cs
- ===================================================================
- --- core/gui/UpdateCacher.cs (revision 2258)
- +++ core/gui/UpdateCacher.cs (working copy)
- @@ -135,26 +135,8 @@
- WebClient wc = new WebClient();
- // check for proxy authentication...
- - if (MainForm.Instance.Settings.UseHttpProxy == true)
- - {
- - WebProxy wprox = null;
- - ICredentials icred = null;
- + wc.Proxy = HttpProxy.GetProxy(MainForm.Instance.Settings);
- - if (MainForm.Instance.Settings.HttpProxyUid != null)
- - {
- - icred = new NetworkCredential(MainForm.Instance.Settings.HttpProxyUid, MainForm.Instance.Settings.HttpProxyPwd);
- - }
- -
- - wprox = new WebProxy(MainForm.Instance.Settings.HttpProxyAddress + ":" + MainForm.Instance.Settings.HttpProxyPort, true, null, icred);
- -
- - WebRequest.DefaultWebProxy = wprox;
- - wc.Proxy = wprox;
- - }
- - else
- - {
- - wc.Proxy = null;
- - }
- -
- ManualResetEvent mre = new ManualResetEvent(false);
- wc.DownloadFileCompleted += delegate(object sender, AsyncCompletedEventArgs e)
- {
- Index: core/gui/UpdateWindow.cs
- ===================================================================
- --- core/gui/UpdateWindow.cs (revision 2258)
- +++ core/gui/UpdateWindow.cs (working copy)
- @@ -1265,18 +1265,7 @@
- WebClient serverClient = new WebClient();
- // check for proxy authentication...
- - if (meGUISettings.UseHttpProxy && !String.IsNullOrEmpty(meGUISettings.HttpProxyAddress))
- - {
- - WebProxy wprox = null;
- - ICredentials icred = null;
- - if (meGUISettings.HttpProxyUid != null)
- - icred = new NetworkCredential(meGUISettings.HttpProxyUid, meGUISettings.HttpProxyPwd);
- - wprox = new WebProxy(meGUISettings.HttpProxyAddress + ":" + meGUISettings.HttpProxyPort, true, null, icred);
- - WebRequest.DefaultWebProxy = wprox;
- - serverClient.Proxy = wprox;
- - }
- - else
- - serverClient.Proxy = null;
- + serverClient.Proxy = HttpProxy.GetProxy(meGUISettings);
- try
- {
- Index: MeGUI.csproj
- ===================================================================
- --- MeGUI.csproj (revision 2258)
- +++ MeGUI.csproj (working copy)
- @@ -498,6 +498,7 @@
- <Compile Include="core\util\FileUtil.cs" />
- <Compile Include="core\util\FilmCutter.cs" />
- <Compile Include="core\util\GenericRegisterer.cs" />
- + <Compile Include="core\util\HttpProxy.cs" />
- <Compile Include="core\util\IFOparser.cs" />
- <Compile Include="core\util\JobUtil.cs" />
- <Compile Include="core\util\LanguageSelectionContainer.cs" />
- Index: core/util/HttpProxy.cs
- ===================================================================
- --- core/util/HttpProxy.cs (revision 0)
- +++ core/util/HttpProxy.cs (working copy)
- @@ -0,0 +1,55 @@
- +namespace MeGUI.core.util
- +{
- + using System;
- + using System.Net;
- +
- + internal class HttpProxy
- + {
- + #region Public Methods and Operators
- +
- + public static IWebProxy GetProxy(MeGUISettings settings)
- + {
- + // if None then return null
- + if (settings.HttpProxyMode == ProxyMode.None)
- + {
- + return null;
- + }
- +
- + // if SystemProxy then return the System proxy details with the logged in credentials
- + if (settings.HttpProxyMode == ProxyMode.SystemProxy)
- + {
- + var systemProxy = WebRequest.GetSystemWebProxy();
- + systemProxy.Credentials = CredentialCache.DefaultCredentials;
- + return systemProxy;
- + }
- +
- + // CustomProxy and CustomProxyWithLogin both require a Url
- + if (String.IsNullOrEmpty(settings.HttpProxyAddress))
- + {
- + return null;
- + }
- +
- + var address = string.IsNullOrEmpty(settings.HttpProxyPort)
- + ? settings.HttpProxyAddress
- + : string.Format("{0}:{1}", settings.HttpProxyAddress, settings.HttpProxyPort);
- +
- + // if CustomProxyWithLogin then generate the credentials
- + ICredentials credentials;
- +
- + if (settings.HttpProxyMode == ProxyMode.CustomProxy || string.IsNullOrEmpty(settings.HttpProxyUid))
- + {
- + credentials = null;
- + }
- + else
- + {
- + credentials = new NetworkCredential(settings.HttpProxyUid, settings.HttpProxyPwd);
- + }
- +
- + var proxy = new WebProxy(address, true, null, credentials);
- +
- + return proxy;
- + }
- +
- + #endregion
- + }
- +}
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement