mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-02 18:26:27 +13:00
ProxyInfo static Current class instead using Uploader.ProxyInfo
This commit is contained in:
parent
b801eedafc
commit
6d7708efd6
6 changed files with 48 additions and 37 deletions
|
@ -377,7 +377,7 @@ private void RegisterMenuClosing()
|
||||||
|
|
||||||
private void AfterSettingsJobs()
|
private void AfterSettingsJobs()
|
||||||
{
|
{
|
||||||
Uploader.ProxyInfo = Program.Settings.ProxySettings;
|
ProxyInfo.Current = Program.Settings.ProxySettings;
|
||||||
ClipboardHelpers.UseAlternativeCopyImage = Program.Settings.UseAlternativeClipboardCopyImage;
|
ClipboardHelpers.UseAlternativeCopyImage = Program.Settings.UseAlternativeClipboardCopyImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -409,6 +409,16 @@ private void UpdateUploaderMenuNames()
|
||||||
tsmiSocialServices.Text = tsmiTraySocialServices.Text = "Social networking service: " + Program.DefaultTaskSettings.SocialNetworkingServiceDestination.GetDescription();
|
tsmiSocialServices.Text = tsmiTraySocialServices.Text = "Social networking service: " + Program.DefaultTaskSettings.SocialNetworkingServiceDestination.GetDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AutoCheckUpdate()
|
||||||
|
{
|
||||||
|
if (Program.Settings.AutoCheckUpdate)
|
||||||
|
{
|
||||||
|
Thread updateThread = new Thread(CheckUpdate);
|
||||||
|
updateThread.IsBackground = true;
|
||||||
|
updateThread.Start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void CheckUpdate()
|
private void CheckUpdate()
|
||||||
{
|
{
|
||||||
UpdateChecker updateChecker = TaskHelpers.CheckUpdate();
|
UpdateChecker updateChecker = TaskHelpers.CheckUpdate();
|
||||||
|
@ -427,16 +437,6 @@ private void CheckUpdate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AutoCheckUpdate()
|
|
||||||
{
|
|
||||||
if (Program.Settings.AutoCheckUpdate)
|
|
||||||
{
|
|
||||||
Thread updateThread = new Thread(CheckUpdate);
|
|
||||||
updateThread.IsBackground = true;
|
|
||||||
updateThread.Start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ForceClose()
|
private void ForceClose()
|
||||||
{
|
{
|
||||||
forceClose = true;
|
forceClose = true;
|
||||||
|
|
|
@ -323,15 +323,15 @@ public static UpdateChecker CheckUpdate()
|
||||||
{
|
{
|
||||||
UpdateChecker updateChecker = new GitHubUpdateChecker("ShareX", "ShareX");
|
UpdateChecker updateChecker = new GitHubUpdateChecker("ShareX", "ShareX");
|
||||||
updateChecker.CurrentVersion = Program.AssemblyVersion;
|
updateChecker.CurrentVersion = Program.AssemblyVersion;
|
||||||
updateChecker.Proxy = Uploader.ProxyInfo.GetWebProxy();
|
updateChecker.Proxy = ProxyInfo.Current.GetWebProxy();
|
||||||
updateChecker.CheckUpdate();
|
updateChecker.CheckUpdate();
|
||||||
|
|
||||||
// Backup if GitHub API fails
|
// Fallback if GitHub API fails
|
||||||
if (updateChecker.UpdateInfo == null || updateChecker.UpdateInfo.Status == UpdateStatus.UpdateCheckFailed)
|
if (updateChecker.UpdateInfo == null || updateChecker.UpdateInfo.Status == UpdateStatus.UpdateCheckFailed)
|
||||||
{
|
{
|
||||||
updateChecker = new XMLUpdateChecker("https://raw.github.com/ShareX/ShareX/master/Update.xml", "ShareX");
|
updateChecker = new XMLUpdateChecker("https://raw.github.com/ShareX/ShareX/master/Update.xml", "ShareX");
|
||||||
updateChecker.CurrentVersion = Program.AssemblyVersion;
|
updateChecker.CurrentVersion = Program.AssemblyVersion;
|
||||||
updateChecker.Proxy = Uploader.ProxyInfo.GetWebProxy();
|
updateChecker.Proxy = ProxyInfo.Current.GetWebProxy();
|
||||||
updateChecker.CheckUpdate();
|
updateChecker.CheckUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,9 +72,9 @@ public FTP(FTPAccount account, int bufferSize = 8192)
|
||||||
|
|
||||||
Client.DataTransferMode = account.IsActive ? TransferMode.Active : TransferMode.Passive;
|
Client.DataTransferMode = account.IsActive ? TransferMode.Active : TransferMode.Passive;
|
||||||
|
|
||||||
if (Uploader.ProxyInfo != null)
|
if (ProxyInfo.Current != null)
|
||||||
{
|
{
|
||||||
IProxyClient proxy = Uploader.ProxyInfo.GetProxyClient();
|
IProxyClient proxy = ProxyInfo.Current.GetProxyClient();
|
||||||
|
|
||||||
if (proxy != null)
|
if (proxy != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,6 +31,25 @@ namespace UploadersLib
|
||||||
{
|
{
|
||||||
public class ProxyInfo
|
public class ProxyInfo
|
||||||
{
|
{
|
||||||
|
private static ProxyInfo current;
|
||||||
|
|
||||||
|
public static ProxyInfo Current
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (current == null)
|
||||||
|
{
|
||||||
|
current = new ProxyInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
return current;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
current = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ProxyMethod ProxyMethod { get; set; }
|
public ProxyMethod ProxyMethod { get; set; }
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
|
|
|
@ -23,17 +23,15 @@ You should have received a copy of the GNU General Public License
|
||||||
|
|
||||||
#endregion License Information (GPL v3)
|
#endregion License Information (GPL v3)
|
||||||
|
|
||||||
namespace UploadersLib.TextUploaders
|
using Newtonsoft.Json;
|
||||||
{
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
using UploadersLib.HelperClasses;
|
using UploadersLib.HelperClasses;
|
||||||
|
|
||||||
|
namespace UploadersLib.TextUploaders
|
||||||
|
{
|
||||||
public sealed class Gist : TextUploader
|
public sealed class Gist : TextUploader
|
||||||
{
|
{
|
||||||
private readonly Uri GistUri = new Uri("https://api.github.com/gists");
|
private readonly Uri GistUri = new Uri("https://api.github.com/gists");
|
||||||
|
|
|
@ -40,7 +40,6 @@ namespace UploadersLib
|
||||||
{
|
{
|
||||||
public class Uploader
|
public class Uploader
|
||||||
{
|
{
|
||||||
public static ProxyInfo ProxyInfo = new ProxyInfo();
|
|
||||||
public static string UserAgent = string.Format("{0} {1}", Application.ProductName, Application.ProductVersion);
|
public static string UserAgent = string.Format("{0} {1}", Application.ProductName, Application.ProductVersion);
|
||||||
|
|
||||||
public delegate void ProgressEventHandler(ProgressManager progress);
|
public delegate void ProgressEventHandler(ProgressManager progress);
|
||||||
|
@ -64,11 +63,6 @@ public Uploader()
|
||||||
ServicePointManager.DefaultConnectionLimit = 25;
|
ServicePointManager.DefaultConnectionLimit = 25;
|
||||||
ServicePointManager.Expect100Continue = false;
|
ServicePointManager.Expect100Continue = false;
|
||||||
ServicePointManager.UseNagleAlgorithm = false;
|
ServicePointManager.UseNagleAlgorithm = false;
|
||||||
|
|
||||||
if (ProxyInfo == null)
|
|
||||||
{
|
|
||||||
ProxyInfo = new ProxyInfo();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void OnProgressChanged(ProgressManager progress)
|
protected void OnProgressChanged(ProgressManager progress)
|
||||||
|
@ -353,7 +347,7 @@ private HttpWebRequest PreparePostWebRequest(string url, string boundary, long l
|
||||||
headers.Remove("Accept");
|
headers.Remove("Accept");
|
||||||
}
|
}
|
||||||
|
|
||||||
request.AllowWriteStreamBuffering = ProxyInfo.IsValidProxy();
|
request.AllowWriteStreamBuffering = ProxyInfo.Current.IsValidProxy();
|
||||||
request.CachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
|
request.CachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
|
||||||
request.ContentLength = length;
|
request.ContentLength = length;
|
||||||
if (!string.IsNullOrEmpty(boundary)) contentType += "; boundary=" + boundary;
|
if (!string.IsNullOrEmpty(boundary)) contentType += "; boundary=" + boundary;
|
||||||
|
@ -365,7 +359,7 @@ private HttpWebRequest PreparePostWebRequest(string url, string boundary, long l
|
||||||
request.Method = HttpMethod.Post.GetDescription();
|
request.Method = HttpMethod.Post.GetDescription();
|
||||||
request.Pipelined = false;
|
request.Pipelined = false;
|
||||||
request.ProtocolVersion = HttpVersion.Version11;
|
request.ProtocolVersion = HttpVersion.Version11;
|
||||||
request.Proxy = ProxyInfo.GetWebProxy();
|
request.Proxy = ProxyInfo.Current.GetWebProxy();
|
||||||
request.Timeout = -1;
|
request.Timeout = -1;
|
||||||
request.UserAgent = UserAgent;
|
request.UserAgent = UserAgent;
|
||||||
|
|
||||||
|
@ -380,7 +374,7 @@ private HttpWebRequest PrepareGetWebRequest(string url, CookieCollection cookies
|
||||||
if (headers != null) request.Headers.Add(headers);
|
if (headers != null) request.Headers.Add(headers);
|
||||||
request.KeepAlive = false;
|
request.KeepAlive = false;
|
||||||
request.Method = HttpMethod.Get.GetDescription();
|
request.Method = HttpMethod.Get.GetDescription();
|
||||||
IWebProxy proxy = ProxyInfo.GetWebProxy();
|
IWebProxy proxy = ProxyInfo.Current.GetWebProxy();
|
||||||
if (proxy != null) request.Proxy = proxy;
|
if (proxy != null) request.Proxy = proxy;
|
||||||
request.UserAgent = UserAgent;
|
request.UserAgent = UserAgent;
|
||||||
|
|
||||||
|
@ -392,7 +386,7 @@ private HttpWebRequest PrepareDeleteWebRequest(string url)
|
||||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
||||||
request.KeepAlive = false;
|
request.KeepAlive = false;
|
||||||
request.Method = HttpMethod.Delete.GetDescription();
|
request.Method = HttpMethod.Delete.GetDescription();
|
||||||
IWebProxy proxy = ProxyInfo.GetWebProxy();
|
IWebProxy proxy = ProxyInfo.Current.GetWebProxy();
|
||||||
if (proxy != null) request.Proxy = proxy;
|
if (proxy != null) request.Proxy = proxy;
|
||||||
request.UserAgent = UserAgent;
|
request.UserAgent = UserAgent;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue