From 435283b80becb3eb79ea7a15e80166fc1a2c130f Mon Sep 17 00:00:00 2001 From: Jaex Date: Mon, 16 Jun 2014 18:24:30 +0300 Subject: [PATCH] Proper stop upload support --- ShareX/UploadTask.cs | 2 +- .../GUI/UploadersConfigForm.Designer.cs | 408 +++++++++--------- UploadersLib/GUI/UploadersConfigForm.cs | 4 +- UploadersLib/Uploader.cs | 58 ++- UploadersLib/UploadersConfig.cs | 36 +- 5 files changed, 262 insertions(+), 246 deletions(-) diff --git a/ShareX/UploadTask.cs b/ShareX/UploadTask.cs index 29015f742..09ecd305d 100644 --- a/ShareX/UploadTask.cs +++ b/ShareX/UploadTask.cs @@ -316,7 +316,7 @@ private void ThreadDoWork() { if (string.IsNullOrEmpty(Info.Result.URL)) { - Info.Result.Errors.Add("URL is empty.\r\n\r\n" + Info.Result.ErrorsToString()); + Info.Result.Errors.Add("URL is empty."); } else { diff --git a/UploadersLib/GUI/UploadersConfigForm.Designer.cs b/UploadersLib/GUI/UploadersConfigForm.Designer.cs index cc8cda556..74e1b8ba6 100644 --- a/UploadersLib/GUI/UploadersConfigForm.Designer.cs +++ b/UploadersLib/GUI/UploadersConfigForm.Designer.cs @@ -93,10 +93,14 @@ private void InitializeComponent() this.txtCustomUploaderArgName = new System.Windows.Forms.TextBox(); this.tpTwitter = new System.Windows.Forms.TabPage(); this.btnTwitterLogin = new System.Windows.Forms.Button(); + this.ucTwitterAccounts = new UploadersLib.AccountsControl(); this.tpURLShorteners = new System.Windows.Forms.TabPage(); this.tcURLShorteners = new System.Windows.Forms.TabControl(); this.tpBitly = new System.Windows.Forms.TabPage(); + this.oauth2Bitly = new UploadersLib.GUI.OAuthControl(); this.tpGoogleURLShortener = new System.Windows.Forms.TabPage(); + this.oauth2GoogleURLShortener = new UploadersLib.GUI.OAuthControl(); + this.atcGoogleURLShortenerAccountType = new UploadersLib.GUI.AccountTypeControl(); this.tpYourls = new System.Windows.Forms.TabPage(); this.txtYourlsPassword = new System.Windows.Forms.TextBox(); this.txtYourlsUsername = new System.Windows.Forms.TextBox(); @@ -110,6 +114,7 @@ private void InitializeComponent() this.tpFileUploaders = new System.Windows.Forms.TabPage(); this.tcFileUploaders = new System.Windows.Forms.TabControl(); this.tpDropbox = new System.Windows.Forms.TabPage(); + this.oauth2Dropbox = new UploadersLib.GUI.OAuthControl(); this.cbDropboxURLType = new System.Windows.Forms.ComboBox(); this.cbDropboxAutoCreateShareableLink = new System.Windows.Forms.CheckBox(); this.btnDropboxShowFiles = new System.Windows.Forms.Button(); @@ -127,6 +132,7 @@ private void InitializeComponent() this.lblCopyStatus = new System.Windows.Forms.Label(); this.lblCopyPath = new System.Windows.Forms.Label(); this.txtCopyPath = new System.Windows.Forms.TextBox(); + this.oAuthCopy = new UploadersLib.GUI.OAuthControl(); this.tpFTP = new System.Windows.Forms.TabPage(); this.eiFTP = new HelpersLib.UserControls.ExportImportControl(); this.btnFtpClient = new System.Windows.Forms.Button(); @@ -136,6 +142,7 @@ private void InitializeComponent() this.cboFtpImages = new System.Windows.Forms.ComboBox(); this.cboFtpFiles = new System.Windows.Forms.ComboBox(); this.cboFtpText = new System.Windows.Forms.ComboBox(); + this.ucFTPAccounts = new UploadersLib.AccountsControl(); this.tpMega = new System.Windows.Forms.TabPage(); this.btnMegaRefreshFolders = new System.Windows.Forms.Button(); this.lblMegaStatus = new System.Windows.Forms.Label(); @@ -172,6 +179,7 @@ private void InitializeComponent() this.txtPushbulletUserKey = new System.Windows.Forms.TextBox(); this.tpGoogleDrive = new System.Windows.Forms.TabPage(); this.cbGoogleDriveIsPublic = new System.Windows.Forms.CheckBox(); + this.oauth2GoogleDrive = new UploadersLib.GUI.OAuthControl(); this.tpBox = new System.Windows.Forms.TabPage(); this.lblBoxFolderTip = new System.Windows.Forms.Label(); this.cbBoxShare = new System.Windows.Forms.CheckBox(); @@ -179,6 +187,7 @@ private void InitializeComponent() this.chBoxFoldersName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.lblBoxFolderID = new System.Windows.Forms.Label(); this.btnBoxRefreshFolders = new System.Windows.Forms.Button(); + this.oauth2Box = new UploadersLib.GUI.OAuthControl(); this.tpRapidShare = new System.Windows.Forms.TabPage(); this.txtRapidShareFolderID = new System.Windows.Forms.TextBox(); this.lblRapidShareFolderID = new System.Windows.Forms.Label(); @@ -194,6 +203,7 @@ private void InitializeComponent() this.lblSendSpaceUsername = new System.Windows.Forms.Label(); this.txtSendSpacePassword = new System.Windows.Forms.TextBox(); this.txtSendSpaceUserName = new System.Windows.Forms.TextBox(); + this.atcSendSpaceAccountType = new UploadersLib.GUI.AccountTypeControl(); this.tpGe_tt = new System.Windows.Forms.TabPage(); this.lblGe_ttStatus = new System.Windows.Forms.Label(); this.lblGe_ttPassword = new System.Windows.Forms.Label(); @@ -231,6 +241,7 @@ private void InitializeComponent() this.txtJiraConfigHelp = new System.Windows.Forms.TextBox(); this.txtJiraHost = new System.Windows.Forms.TextBox(); this.lblJiraHost = new System.Windows.Forms.Label(); + this.oAuthJira = new UploadersLib.GUI.OAuthControl(); this.tpEmail = new System.Windows.Forms.TabPage(); this.chkEmailConfirm = new System.Windows.Forms.CheckBox(); this.lblEmailSmtpServer = new System.Windows.Forms.Label(); @@ -253,6 +264,7 @@ private void InitializeComponent() this.lblSharedFolderImages = new System.Windows.Forms.Label(); this.cboSharedFolderText = new System.Windows.Forms.ComboBox(); this.cboSharedFolderImages = new System.Windows.Forms.ComboBox(); + this.ucLocalhostAccounts = new UploadersLib.AccountsControl(); this.btnCopyShowFiles = new System.Windows.Forms.Button(); this.tpTextUploaders = new System.Windows.Forms.TabPage(); this.tcTextUploaders = new System.Windows.Forms.TabControl(); @@ -264,6 +276,8 @@ private void InitializeComponent() this.txtPaste_eeUserAPIKey = new System.Windows.Forms.TextBox(); this.tpGist = new System.Windows.Forms.TabPage(); this.chkGistPublishPublic = new System.Windows.Forms.CheckBox(); + this.oAuth2Gist = new UploadersLib.GUI.OAuthControl(); + this.atcGistAccountType = new UploadersLib.GUI.AccountTypeControl(); this.tpUpaste = new System.Windows.Forms.TabPage(); this.cbUpasteIsPublic = new System.Windows.Forms.CheckBox(); this.lblUpasteUserKey = new System.Windows.Forms.Label(); @@ -271,6 +285,8 @@ private void InitializeComponent() this.tpImageUploaders = new System.Windows.Forms.TabPage(); this.tcImageUploaders = new System.Windows.Forms.TabControl(); this.tpImgur = new System.Windows.Forms.TabPage(); + this.atcImgurAccountType = new UploadersLib.GUI.AccountTypeControl(); + this.oauth2Imgur = new UploadersLib.GUI.OAuthControl(); this.txtImgurAlbumID = new System.Windows.Forms.TextBox(); this.lblImgurAlbumID = new System.Windows.Forms.Label(); this.lvImgurAlbumList = new System.Windows.Forms.ListView(); @@ -290,6 +306,7 @@ private void InitializeComponent() this.txtImageShackPassword = new System.Windows.Forms.TextBox(); this.lblImageShackPassword = new System.Windows.Forms.Label(); this.tpTinyPic = new System.Windows.Forms.TabPage(); + this.atcTinyPicAccountType = new UploadersLib.GUI.AccountTypeControl(); this.btnTinyPicLogin = new System.Windows.Forms.Button(); this.txtTinyPicPassword = new System.Windows.Forms.TextBox(); this.lblTinyPicPassword = new System.Windows.Forms.Label(); @@ -330,26 +347,9 @@ private void InitializeComponent() this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.btnPicasaRefreshAlbumList = new System.Windows.Forms.Button(); + this.oauth2Picasa = new UploadersLib.GUI.OAuthControl(); this.tcUploaders = new System.Windows.Forms.TabControl(); this.ttlvMain = new HelpersLib.TabToListView(); - this.oauth2Imgur = new UploadersLib.GUI.OAuthControl(); - this.atcImgurAccountType = new UploadersLib.GUI.AccountTypeControl(); - this.atcTinyPicAccountType = new UploadersLib.GUI.AccountTypeControl(); - this.oauth2Picasa = new UploadersLib.GUI.OAuthControl(); - this.oAuth2Gist = new UploadersLib.GUI.OAuthControl(); - this.atcGistAccountType = new UploadersLib.GUI.AccountTypeControl(); - this.oauth2Dropbox = new UploadersLib.GUI.OAuthControl(); - this.oAuthCopy = new UploadersLib.GUI.OAuthControl(); - this.ucFTPAccounts = new UploadersLib.AccountsControl(); - this.oauth2GoogleDrive = new UploadersLib.GUI.OAuthControl(); - this.oauth2Box = new UploadersLib.GUI.OAuthControl(); - this.atcSendSpaceAccountType = new UploadersLib.GUI.AccountTypeControl(); - this.oAuthJira = new UploadersLib.GUI.OAuthControl(); - this.ucLocalhostAccounts = new UploadersLib.AccountsControl(); - this.oauth2Bitly = new UploadersLib.GUI.OAuthControl(); - this.oauth2GoogleURLShortener = new UploadersLib.GUI.OAuthControl(); - this.atcGoogleURLShortenerAccountType = new UploadersLib.GUI.AccountTypeControl(); - this.ucTwitterAccounts = new UploadersLib.AccountsControl(); this.actRapidShareAccountType = new UploadersLib.GUI.AccountTypeControl(); this.tpOtherUploaders.SuspendLayout(); this.tcOtherUploaders.SuspendLayout(); @@ -1051,6 +1051,15 @@ private void InitializeComponent() this.btnTwitterLogin.UseVisualStyleBackColor = true; this.btnTwitterLogin.Click += new System.EventHandler(this.btnTwitterLogin_Click); // + // ucTwitterAccounts + // + this.ucTwitterAccounts.Dock = System.Windows.Forms.DockStyle.Fill; + this.ucTwitterAccounts.Location = new System.Drawing.Point(0, 0); + this.ucTwitterAccounts.Margin = new System.Windows.Forms.Padding(0); + this.ucTwitterAccounts.Name = "ucTwitterAccounts"; + this.ucTwitterAccounts.Size = new System.Drawing.Size(972, 493); + this.ucTwitterAccounts.TabIndex = 0; + // // tpURLShorteners // this.tpURLShorteners.Controls.Add(this.tcURLShorteners); @@ -1085,6 +1094,17 @@ private void InitializeComponent() this.tpBitly.Text = "bit.ly"; this.tpBitly.UseVisualStyleBackColor = true; // + // oauth2Bitly + // + this.oauth2Bitly.IsRefreshable = false; + this.oauth2Bitly.Location = new System.Drawing.Point(16, 16); + this.oauth2Bitly.Name = "oauth2Bitly"; + this.oauth2Bitly.Size = new System.Drawing.Size(328, 208); + this.oauth2Bitly.TabIndex = 0; + this.oauth2Bitly.OpenButtonClicked += new UploadersLib.GUI.OAuthControl.OpenButtonClickedEventHandler(this.oauth2Bitly_OpenButtonClicked); + this.oauth2Bitly.CompleteButtonClicked += new UploadersLib.GUI.OAuthControl.CompleteButtonClickedEventHandler(this.oauth2Bitly_CompleteButtonClicked); + this.oauth2Bitly.ClearButtonClicked += new UploadersLib.GUI.OAuthControl.ClearButtonclickedEventHandler(this.oauth2Bitly_ClearButtonClicked); + // // tpGoogleURLShortener // this.tpGoogleURLShortener.Controls.Add(this.oauth2GoogleURLShortener); @@ -1097,6 +1117,26 @@ private void InitializeComponent() this.tpGoogleURLShortener.Text = "Google"; this.tpGoogleURLShortener.UseVisualStyleBackColor = true; // + // oauth2GoogleURLShortener + // + this.oauth2GoogleURLShortener.Location = new System.Drawing.Point(16, 56); + this.oauth2GoogleURLShortener.Name = "oauth2GoogleURLShortener"; + this.oauth2GoogleURLShortener.Size = new System.Drawing.Size(328, 240); + this.oauth2GoogleURLShortener.TabIndex = 1; + this.oauth2GoogleURLShortener.OpenButtonClicked += new UploadersLib.GUI.OAuthControl.OpenButtonClickedEventHandler(this.oauth2GoogleURLShortener_OpenButtonClicked); + this.oauth2GoogleURLShortener.CompleteButtonClicked += new UploadersLib.GUI.OAuthControl.CompleteButtonClickedEventHandler(this.oauth2GoogleURLShortener_CompleteButtonClicked); + this.oauth2GoogleURLShortener.ClearButtonClicked += new UploadersLib.GUI.OAuthControl.ClearButtonclickedEventHandler(this.oauth2GoogleURLShortener_ClearButtonClicked); + this.oauth2GoogleURLShortener.RefreshButtonClicked += new UploadersLib.GUI.OAuthControl.RefreshButtonClickedEventHandler(this.oauth2GoogleURLShortener_RefreshButtonClicked); + // + // atcGoogleURLShortenerAccountType + // + this.atcGoogleURLShortenerAccountType.Location = new System.Drawing.Point(8, 16); + this.atcGoogleURLShortenerAccountType.Name = "atcGoogleURLShortenerAccountType"; + this.atcGoogleURLShortenerAccountType.SelectedAccountType = UploadersLib.AccountType.Anonymous; + this.atcGoogleURLShortenerAccountType.Size = new System.Drawing.Size(214, 29); + this.atcGoogleURLShortenerAccountType.TabIndex = 0; + this.atcGoogleURLShortenerAccountType.AccountTypeChanged += new UploadersLib.GUI.AccountTypeControl.AccountTypeChangedEventHandler(this.atcGoogleURLShortenerAccountType_AccountTypeChanged); + // // tpYourls // this.tpYourls.Controls.Add(this.txtYourlsPassword); @@ -1252,6 +1292,17 @@ private void InitializeComponent() this.tpDropbox.Text = "Dropbox"; this.tpDropbox.UseVisualStyleBackColor = true; // + // oauth2Dropbox + // + this.oauth2Dropbox.IsRefreshable = false; + this.oauth2Dropbox.Location = new System.Drawing.Point(16, 88); + this.oauth2Dropbox.Name = "oauth2Dropbox"; + this.oauth2Dropbox.Size = new System.Drawing.Size(328, 200); + this.oauth2Dropbox.TabIndex = 20; + this.oauth2Dropbox.OpenButtonClicked += new UploadersLib.GUI.OAuthControl.OpenButtonClickedEventHandler(this.oauth2Dropbox_OpenButtonClicked); + this.oauth2Dropbox.CompleteButtonClicked += new UploadersLib.GUI.OAuthControl.CompleteButtonClickedEventHandler(this.oauth2Dropbox_CompleteButtonClicked); + this.oauth2Dropbox.ClearButtonClicked += new UploadersLib.GUI.OAuthControl.ClearButtonclickedEventHandler(this.oauth2Dropbox_ClearButtonClicked); + // // cbDropboxURLType // this.cbDropboxURLType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; @@ -1427,6 +1478,17 @@ private void InitializeComponent() this.txtCopyPath.TabIndex = 4; this.txtCopyPath.TextChanged += new System.EventHandler(this.txtCopyPath_TextChanged); // + // oAuthCopy + // + this.oAuthCopy.IsRefreshable = false; + this.oAuthCopy.Location = new System.Drawing.Point(16, 88); + this.oAuthCopy.Name = "oAuthCopy"; + this.oAuthCopy.Size = new System.Drawing.Size(328, 208); + this.oAuthCopy.TabIndex = 2; + this.oAuthCopy.OpenButtonClicked += new UploadersLib.GUI.OAuthControl.OpenButtonClickedEventHandler(this.oAuthCopy_OpenButtonClicked); + this.oAuthCopy.CompleteButtonClicked += new UploadersLib.GUI.OAuthControl.CompleteButtonClickedEventHandler(this.oAuthCopy_CompleteButtonClicked); + this.oAuthCopy.ClearButtonClicked += new UploadersLib.GUI.OAuthControl.ClearButtonclickedEventHandler(this.oAuthCopy_ClearButtonClicked); + // // tpFTP // this.tpFTP.Controls.Add(this.eiFTP); @@ -1523,6 +1585,16 @@ private void InitializeComponent() this.cboFtpText.TabIndex = 3; this.cboFtpText.SelectedIndexChanged += new System.EventHandler(this.cboFtpText_SelectedIndexChanged); // + // ucFTPAccounts + // + this.ucFTPAccounts.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.ucFTPAccounts.Location = new System.Drawing.Point(8, 40); + this.ucFTPAccounts.Margin = new System.Windows.Forms.Padding(4); + this.ucFTPAccounts.Name = "ucFTPAccounts"; + this.ucFTPAccounts.Size = new System.Drawing.Size(792, 448); + this.ucFTPAccounts.TabIndex = 6; + // // tpMega // this.tpMega.Controls.Add(this.btnMegaRefreshFolders); @@ -1903,6 +1975,17 @@ private void InitializeComponent() this.cbGoogleDriveIsPublic.UseVisualStyleBackColor = true; this.cbGoogleDriveIsPublic.CheckedChanged += new System.EventHandler(this.cbGoogleDriveIsPublic_CheckedChanged); // + // oauth2GoogleDrive + // + this.oauth2GoogleDrive.Location = new System.Drawing.Point(16, 16); + this.oauth2GoogleDrive.Name = "oauth2GoogleDrive"; + this.oauth2GoogleDrive.Size = new System.Drawing.Size(328, 240); + this.oauth2GoogleDrive.TabIndex = 0; + this.oauth2GoogleDrive.OpenButtonClicked += new UploadersLib.GUI.OAuthControl.OpenButtonClickedEventHandler(this.oauth2GoogleDrive_OpenButtonClicked); + this.oauth2GoogleDrive.CompleteButtonClicked += new UploadersLib.GUI.OAuthControl.CompleteButtonClickedEventHandler(this.oauth2GoogleDrive_CompleteButtonClicked); + this.oauth2GoogleDrive.ClearButtonClicked += new UploadersLib.GUI.OAuthControl.ClearButtonclickedEventHandler(this.oauth2GoogleDrive_ClearButtonClicked); + this.oauth2GoogleDrive.RefreshButtonClicked += new UploadersLib.GUI.OAuthControl.RefreshButtonClickedEventHandler(this.oauth2GoogleDrive_RefreshButtonClicked); + // // tpBox // this.tpBox.Controls.Add(this.lblBoxFolderTip); @@ -1979,6 +2062,17 @@ private void InitializeComponent() this.btnBoxRefreshFolders.UseVisualStyleBackColor = true; this.btnBoxRefreshFolders.Click += new System.EventHandler(this.btnBoxRefreshFolders_Click); // + // oauth2Box + // + this.oauth2Box.Location = new System.Drawing.Point(16, 16); + this.oauth2Box.Name = "oauth2Box"; + this.oauth2Box.Size = new System.Drawing.Size(328, 240); + this.oauth2Box.TabIndex = 0; + this.oauth2Box.OpenButtonClicked += new UploadersLib.GUI.OAuthControl.OpenButtonClickedEventHandler(this.oauth2Box_OpenButtonClicked); + this.oauth2Box.CompleteButtonClicked += new UploadersLib.GUI.OAuthControl.CompleteButtonClickedEventHandler(this.oauth2Box_CompleteButtonClicked); + this.oauth2Box.ClearButtonClicked += new UploadersLib.GUI.OAuthControl.ClearButtonclickedEventHandler(this.oauth2Box_ClearButtonClicked); + this.oauth2Box.RefreshButtonClicked += new UploadersLib.GUI.OAuthControl.RefreshButtonClickedEventHandler(this.oauth2Box_RefreshButtonClicked); + // // tpRapidShare // this.tpRapidShare.Controls.Add(this.txtRapidShareFolderID); @@ -2128,6 +2222,15 @@ private void InitializeComponent() this.txtSendSpaceUserName.TabIndex = 3; this.txtSendSpaceUserName.TextChanged += new System.EventHandler(this.txtSendSpaceUserName_TextChanged); // + // atcSendSpaceAccountType + // + this.atcSendSpaceAccountType.Location = new System.Drawing.Point(8, 16); + this.atcSendSpaceAccountType.Name = "atcSendSpaceAccountType"; + this.atcSendSpaceAccountType.SelectedAccountType = UploadersLib.AccountType.Anonymous; + this.atcSendSpaceAccountType.Size = new System.Drawing.Size(214, 29); + this.atcSendSpaceAccountType.TabIndex = 0; + this.atcSendSpaceAccountType.AccountTypeChanged += new UploadersLib.GUI.AccountTypeControl.AccountTypeChangedEventHandler(this.atcSendSpaceAccountType_AccountTypeChanged); + // // tpGe_tt // this.tpGe_tt.Controls.Add(this.lblGe_ttStatus); @@ -2506,6 +2609,17 @@ private void InitializeComponent() this.lblJiraHost.TabIndex = 0; this.lblJiraHost.Text = "Jira host: "; // + // oAuthJira + // + this.oAuthJira.Location = new System.Drawing.Point(473, 13); + this.oAuthJira.Name = "oAuthJira"; + this.oAuthJira.Size = new System.Drawing.Size(328, 243); + this.oAuthJira.TabIndex = 1; + this.oAuthJira.OpenButtonClicked += new UploadersLib.GUI.OAuthControl.OpenButtonClickedEventHandler(this.oAuthJira_OpenButtonClicked); + this.oAuthJira.CompleteButtonClicked += new UploadersLib.GUI.OAuthControl.CompleteButtonClickedEventHandler(this.oAuthJira_CompleteButtonClicked); + this.oAuthJira.ClearButtonClicked += new UploadersLib.GUI.OAuthControl.ClearButtonclickedEventHandler(this.oAuthJira_ClearButtonClicked); + this.oAuthJira.RefreshButtonClicked += new UploadersLib.GUI.OAuthControl.RefreshButtonClickedEventHandler(this.oAuthJira_RefreshButtonClicked); + // // tpEmail // this.tpEmail.Controls.Add(this.chkEmailConfirm); @@ -2741,6 +2855,16 @@ private void InitializeComponent() this.cboSharedFolderImages.TabIndex = 1; this.cboSharedFolderImages.SelectedIndexChanged += new System.EventHandler(this.cboSharedFolderImages_SelectedIndexChanged); // + // ucLocalhostAccounts + // + this.ucLocalhostAccounts.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.ucLocalhostAccounts.Location = new System.Drawing.Point(8, 40); + this.ucLocalhostAccounts.Margin = new System.Windows.Forms.Padding(4); + this.ucLocalhostAccounts.Name = "ucLocalhostAccounts"; + this.ucLocalhostAccounts.Size = new System.Drawing.Size(792, 448); + this.ucLocalhostAccounts.TabIndex = 0; + // // btnCopyShowFiles // this.btnCopyShowFiles.Location = new System.Drawing.Point(0, 0); @@ -2857,6 +2981,27 @@ private void InitializeComponent() this.chkGistPublishPublic.UseVisualStyleBackColor = true; this.chkGistPublishPublic.CheckedChanged += new System.EventHandler(this.chkGistPublishPublic_CheckedChanged); // + // oAuth2Gist + // + this.oAuth2Gist.Enabled = false; + this.oAuth2Gist.IsRefreshable = false; + this.oAuth2Gist.Location = new System.Drawing.Point(16, 51); + this.oAuth2Gist.Name = "oAuth2Gist"; + this.oAuth2Gist.Size = new System.Drawing.Size(328, 205); + this.oAuth2Gist.TabIndex = 2; + this.oAuth2Gist.OpenButtonClicked += new UploadersLib.GUI.OAuthControl.OpenButtonClickedEventHandler(this.oAuth2Gist_OpenButtonClicked); + this.oAuth2Gist.CompleteButtonClicked += new UploadersLib.GUI.OAuthControl.CompleteButtonClickedEventHandler(this.oAuth2Gist_CompleteButtonClicked); + this.oAuth2Gist.ClearButtonClicked += new UploadersLib.GUI.OAuthControl.ClearButtonclickedEventHandler(this.oAuth2Gist_ClearButtonClicked); + // + // atcGistAccountType + // + this.atcGistAccountType.Location = new System.Drawing.Point(15, 16); + this.atcGistAccountType.Name = "atcGistAccountType"; + this.atcGistAccountType.SelectedAccountType = UploadersLib.AccountType.Anonymous; + this.atcGistAccountType.Size = new System.Drawing.Size(214, 29); + this.atcGistAccountType.TabIndex = 0; + this.atcGistAccountType.AccountTypeChanged += new UploadersLib.GUI.AccountTypeControl.AccountTypeChangedEventHandler(this.atcGistAccountType_AccountTypeChanged); + // // tpUpaste // this.tpUpaste.Controls.Add(this.cbUpasteIsPublic); @@ -2944,6 +3089,26 @@ private void InitializeComponent() this.tpImgur.Text = "Imgur"; this.tpImgur.UseVisualStyleBackColor = true; // + // atcImgurAccountType + // + this.atcImgurAccountType.Location = new System.Drawing.Point(8, 260); + this.atcImgurAccountType.Name = "atcImgurAccountType"; + this.atcImgurAccountType.SelectedAccountType = UploadersLib.AccountType.Anonymous; + this.atcImgurAccountType.Size = new System.Drawing.Size(208, 32); + this.atcImgurAccountType.TabIndex = 4; + this.atcImgurAccountType.AccountTypeChanged += new UploadersLib.GUI.AccountTypeControl.AccountTypeChangedEventHandler(this.atcImgurAccountType_AccountTypeChanged); + // + // oauth2Imgur + // + this.oauth2Imgur.Location = new System.Drawing.Point(16, 16); + this.oauth2Imgur.Name = "oauth2Imgur"; + this.oauth2Imgur.Size = new System.Drawing.Size(328, 240); + this.oauth2Imgur.TabIndex = 0; + this.oauth2Imgur.OpenButtonClicked += new UploadersLib.GUI.OAuthControl.OpenButtonClickedEventHandler(this.oauth2Imgur_OpenButtonClicked); + this.oauth2Imgur.CompleteButtonClicked += new UploadersLib.GUI.OAuthControl.CompleteButtonClickedEventHandler(this.oauth2Imgur_CompleteButtonClicked); + this.oauth2Imgur.ClearButtonClicked += new UploadersLib.GUI.OAuthControl.ClearButtonclickedEventHandler(this.oauth2Imgur_ClearButtonClicked); + this.oauth2Imgur.RefreshButtonClicked += new UploadersLib.GUI.OAuthControl.RefreshButtonClickedEventHandler(this.oauth2Imgur_RefreshButtonClicked); + // // txtImgurAlbumID // this.txtImgurAlbumID.Location = new System.Drawing.Point(592, 12); @@ -3133,6 +3298,15 @@ private void InitializeComponent() this.tpTinyPic.Text = "TinyPic"; this.tpTinyPic.UseVisualStyleBackColor = true; // + // atcTinyPicAccountType + // + this.atcTinyPicAccountType.Location = new System.Drawing.Point(8, 8); + this.atcTinyPicAccountType.Name = "atcTinyPicAccountType"; + this.atcTinyPicAccountType.SelectedAccountType = UploadersLib.AccountType.Anonymous; + this.atcTinyPicAccountType.Size = new System.Drawing.Size(272, 29); + this.atcTinyPicAccountType.TabIndex = 0; + this.atcTinyPicAccountType.AccountTypeChanged += new UploadersLib.GUI.AccountTypeControl.AccountTypeChangedEventHandler(this.atcTinyPicAccountType_AccountTypeChanged); + // // btnTinyPicLogin // this.btnTinyPicLogin.Location = new System.Drawing.Point(296, 74); @@ -3538,6 +3712,17 @@ private void InitializeComponent() this.btnPicasaRefreshAlbumList.UseVisualStyleBackColor = true; this.btnPicasaRefreshAlbumList.Click += new System.EventHandler(this.btnPicasaRefreshAlbumList_Click); // + // oauth2Picasa + // + this.oauth2Picasa.Location = new System.Drawing.Point(16, 16); + this.oauth2Picasa.Name = "oauth2Picasa"; + this.oauth2Picasa.Size = new System.Drawing.Size(328, 240); + this.oauth2Picasa.TabIndex = 0; + this.oauth2Picasa.OpenButtonClicked += new UploadersLib.GUI.OAuthControl.OpenButtonClickedEventHandler(this.oauth2Picasa_OpenButtonClicked); + this.oauth2Picasa.CompleteButtonClicked += new UploadersLib.GUI.OAuthControl.CompleteButtonClickedEventHandler(this.oauth2Picasa_CompleteButtonClicked); + this.oauth2Picasa.ClearButtonClicked += new UploadersLib.GUI.OAuthControl.ClearButtonclickedEventHandler(this.oauth2Picasa_ClearButtonClicked); + this.oauth2Picasa.RefreshButtonClicked += new UploadersLib.GUI.OAuthControl.RefreshButtonClickedEventHandler(this.oauth2Picasa_RefreshButtonClicked); + // // tcUploaders // this.tcUploaders.Controls.Add(this.tpImageUploaders); @@ -3565,191 +3750,6 @@ private void InitializeComponent() this.ttlvMain.Size = new System.Drawing.Size(994, 551); this.ttlvMain.TabIndex = 0; // - // oauth2Imgur - // - this.oauth2Imgur.Location = new System.Drawing.Point(16, 16); - this.oauth2Imgur.Name = "oauth2Imgur"; - this.oauth2Imgur.Size = new System.Drawing.Size(328, 240); - this.oauth2Imgur.TabIndex = 0; - this.oauth2Imgur.OpenButtonClicked += new UploadersLib.GUI.OAuthControl.OpenButtonClickedEventHandler(this.oauth2Imgur_OpenButtonClicked); - this.oauth2Imgur.CompleteButtonClicked += new UploadersLib.GUI.OAuthControl.CompleteButtonClickedEventHandler(this.oauth2Imgur_CompleteButtonClicked); - this.oauth2Imgur.ClearButtonClicked += new UploadersLib.GUI.OAuthControl.ClearButtonclickedEventHandler(this.oauth2Imgur_ClearButtonClicked); - this.oauth2Imgur.RefreshButtonClicked += new UploadersLib.GUI.OAuthControl.RefreshButtonClickedEventHandler(this.oauth2Imgur_RefreshButtonClicked); - // - // atcImgurAccountType - // - this.atcImgurAccountType.Location = new System.Drawing.Point(8, 260); - this.atcImgurAccountType.Name = "atcImgurAccountType"; - this.atcImgurAccountType.SelectedAccountType = UploadersLib.AccountType.Anonymous; - this.atcImgurAccountType.Size = new System.Drawing.Size(208, 32); - this.atcImgurAccountType.TabIndex = 4; - this.atcImgurAccountType.AccountTypeChanged += new UploadersLib.GUI.AccountTypeControl.AccountTypeChangedEventHandler(this.atcImgurAccountType_AccountTypeChanged); - // - // atcTinyPicAccountType - // - this.atcTinyPicAccountType.Location = new System.Drawing.Point(8, 8); - this.atcTinyPicAccountType.Name = "atcTinyPicAccountType"; - this.atcTinyPicAccountType.SelectedAccountType = UploadersLib.AccountType.Anonymous; - this.atcTinyPicAccountType.Size = new System.Drawing.Size(272, 29); - this.atcTinyPicAccountType.TabIndex = 0; - this.atcTinyPicAccountType.AccountTypeChanged += new UploadersLib.GUI.AccountTypeControl.AccountTypeChangedEventHandler(this.atcTinyPicAccountType_AccountTypeChanged); - // - // oauth2Picasa - // - this.oauth2Picasa.Location = new System.Drawing.Point(16, 16); - this.oauth2Picasa.Name = "oauth2Picasa"; - this.oauth2Picasa.Size = new System.Drawing.Size(328, 240); - this.oauth2Picasa.TabIndex = 0; - this.oauth2Picasa.OpenButtonClicked += new UploadersLib.GUI.OAuthControl.OpenButtonClickedEventHandler(this.oauth2Picasa_OpenButtonClicked); - this.oauth2Picasa.CompleteButtonClicked += new UploadersLib.GUI.OAuthControl.CompleteButtonClickedEventHandler(this.oauth2Picasa_CompleteButtonClicked); - this.oauth2Picasa.ClearButtonClicked += new UploadersLib.GUI.OAuthControl.ClearButtonclickedEventHandler(this.oauth2Picasa_ClearButtonClicked); - this.oauth2Picasa.RefreshButtonClicked += new UploadersLib.GUI.OAuthControl.RefreshButtonClickedEventHandler(this.oauth2Picasa_RefreshButtonClicked); - // - // oAuth2Gist - // - this.oAuth2Gist.Enabled = false; - this.oAuth2Gist.IsRefreshable = false; - this.oAuth2Gist.Location = new System.Drawing.Point(16, 51); - this.oAuth2Gist.Name = "oAuth2Gist"; - this.oAuth2Gist.Size = new System.Drawing.Size(328, 205); - this.oAuth2Gist.TabIndex = 2; - this.oAuth2Gist.OpenButtonClicked += new UploadersLib.GUI.OAuthControl.OpenButtonClickedEventHandler(this.oAuth2Gist_OpenButtonClicked); - this.oAuth2Gist.CompleteButtonClicked += new UploadersLib.GUI.OAuthControl.CompleteButtonClickedEventHandler(this.oAuth2Gist_CompleteButtonClicked); - this.oAuth2Gist.ClearButtonClicked += new UploadersLib.GUI.OAuthControl.ClearButtonclickedEventHandler(this.oAuth2Gist_ClearButtonClicked); - // - // atcGistAccountType - // - this.atcGistAccountType.Location = new System.Drawing.Point(15, 16); - this.atcGistAccountType.Name = "atcGistAccountType"; - this.atcGistAccountType.SelectedAccountType = UploadersLib.AccountType.Anonymous; - this.atcGistAccountType.Size = new System.Drawing.Size(214, 29); - this.atcGistAccountType.TabIndex = 0; - this.atcGistAccountType.AccountTypeChanged += new UploadersLib.GUI.AccountTypeControl.AccountTypeChangedEventHandler(this.atcGistAccountType_AccountTypeChanged); - // - // oauth2Dropbox - // - this.oauth2Dropbox.IsRefreshable = false; - this.oauth2Dropbox.Location = new System.Drawing.Point(16, 88); - this.oauth2Dropbox.Name = "oauth2Dropbox"; - this.oauth2Dropbox.Size = new System.Drawing.Size(328, 200); - this.oauth2Dropbox.TabIndex = 20; - this.oauth2Dropbox.OpenButtonClicked += new UploadersLib.GUI.OAuthControl.OpenButtonClickedEventHandler(this.oauth2Dropbox_OpenButtonClicked); - this.oauth2Dropbox.CompleteButtonClicked += new UploadersLib.GUI.OAuthControl.CompleteButtonClickedEventHandler(this.oauth2Dropbox_CompleteButtonClicked); - this.oauth2Dropbox.ClearButtonClicked += new UploadersLib.GUI.OAuthControl.ClearButtonclickedEventHandler(this.oauth2Dropbox_ClearButtonClicked); - // - // oAuthCopy - // - this.oAuthCopy.IsRefreshable = false; - this.oAuthCopy.Location = new System.Drawing.Point(16, 88); - this.oAuthCopy.Name = "oAuthCopy"; - this.oAuthCopy.Size = new System.Drawing.Size(328, 208); - this.oAuthCopy.TabIndex = 2; - this.oAuthCopy.OpenButtonClicked += new UploadersLib.GUI.OAuthControl.OpenButtonClickedEventHandler(this.oAuthCopy_OpenButtonClicked); - this.oAuthCopy.CompleteButtonClicked += new UploadersLib.GUI.OAuthControl.CompleteButtonClickedEventHandler(this.oAuthCopy_CompleteButtonClicked); - this.oAuthCopy.ClearButtonClicked += new UploadersLib.GUI.OAuthControl.ClearButtonclickedEventHandler(this.oAuthCopy_ClearButtonClicked); - // - // ucFTPAccounts - // - this.ucFTPAccounts.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); - this.ucFTPAccounts.Location = new System.Drawing.Point(8, 40); - this.ucFTPAccounts.Margin = new System.Windows.Forms.Padding(4); - this.ucFTPAccounts.Name = "ucFTPAccounts"; - this.ucFTPAccounts.Size = new System.Drawing.Size(792, 448); - this.ucFTPAccounts.TabIndex = 6; - // - // oauth2GoogleDrive - // - this.oauth2GoogleDrive.Location = new System.Drawing.Point(16, 16); - this.oauth2GoogleDrive.Name = "oauth2GoogleDrive"; - this.oauth2GoogleDrive.Size = new System.Drawing.Size(328, 240); - this.oauth2GoogleDrive.TabIndex = 0; - this.oauth2GoogleDrive.OpenButtonClicked += new UploadersLib.GUI.OAuthControl.OpenButtonClickedEventHandler(this.oauth2GoogleDrive_OpenButtonClicked); - this.oauth2GoogleDrive.CompleteButtonClicked += new UploadersLib.GUI.OAuthControl.CompleteButtonClickedEventHandler(this.oauth2GoogleDrive_CompleteButtonClicked); - this.oauth2GoogleDrive.ClearButtonClicked += new UploadersLib.GUI.OAuthControl.ClearButtonclickedEventHandler(this.oauth2GoogleDrive_ClearButtonClicked); - this.oauth2GoogleDrive.RefreshButtonClicked += new UploadersLib.GUI.OAuthControl.RefreshButtonClickedEventHandler(this.oauth2GoogleDrive_RefreshButtonClicked); - // - // oauth2Box - // - this.oauth2Box.Location = new System.Drawing.Point(16, 16); - this.oauth2Box.Name = "oauth2Box"; - this.oauth2Box.Size = new System.Drawing.Size(328, 240); - this.oauth2Box.TabIndex = 0; - this.oauth2Box.OpenButtonClicked += new UploadersLib.GUI.OAuthControl.OpenButtonClickedEventHandler(this.oauth2Box_OpenButtonClicked); - this.oauth2Box.CompleteButtonClicked += new UploadersLib.GUI.OAuthControl.CompleteButtonClickedEventHandler(this.oauth2Box_CompleteButtonClicked); - this.oauth2Box.ClearButtonClicked += new UploadersLib.GUI.OAuthControl.ClearButtonclickedEventHandler(this.oauth2Box_ClearButtonClicked); - this.oauth2Box.RefreshButtonClicked += new UploadersLib.GUI.OAuthControl.RefreshButtonClickedEventHandler(this.oauth2Box_RefreshButtonClicked); - // - // atcSendSpaceAccountType - // - this.atcSendSpaceAccountType.Location = new System.Drawing.Point(8, 16); - this.atcSendSpaceAccountType.Name = "atcSendSpaceAccountType"; - this.atcSendSpaceAccountType.SelectedAccountType = UploadersLib.AccountType.Anonymous; - this.atcSendSpaceAccountType.Size = new System.Drawing.Size(214, 29); - this.atcSendSpaceAccountType.TabIndex = 0; - this.atcSendSpaceAccountType.AccountTypeChanged += new UploadersLib.GUI.AccountTypeControl.AccountTypeChangedEventHandler(this.atcSendSpaceAccountType_AccountTypeChanged); - // - // oAuthJira - // - this.oAuthJira.Location = new System.Drawing.Point(473, 13); - this.oAuthJira.Name = "oAuthJira"; - this.oAuthJira.Size = new System.Drawing.Size(328, 243); - this.oAuthJira.TabIndex = 1; - this.oAuthJira.OpenButtonClicked += new UploadersLib.GUI.OAuthControl.OpenButtonClickedEventHandler(this.oAuthJira_OpenButtonClicked); - this.oAuthJira.CompleteButtonClicked += new UploadersLib.GUI.OAuthControl.CompleteButtonClickedEventHandler(this.oAuthJira_CompleteButtonClicked); - this.oAuthJira.ClearButtonClicked += new UploadersLib.GUI.OAuthControl.ClearButtonclickedEventHandler(this.oAuthJira_ClearButtonClicked); - this.oAuthJira.RefreshButtonClicked += new UploadersLib.GUI.OAuthControl.RefreshButtonClickedEventHandler(this.oAuthJira_RefreshButtonClicked); - // - // ucLocalhostAccounts - // - this.ucLocalhostAccounts.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); - this.ucLocalhostAccounts.Location = new System.Drawing.Point(8, 40); - this.ucLocalhostAccounts.Margin = new System.Windows.Forms.Padding(4); - this.ucLocalhostAccounts.Name = "ucLocalhostAccounts"; - this.ucLocalhostAccounts.Size = new System.Drawing.Size(792, 448); - this.ucLocalhostAccounts.TabIndex = 0; - // - // oauth2Bitly - // - this.oauth2Bitly.IsRefreshable = false; - this.oauth2Bitly.Location = new System.Drawing.Point(16, 16); - this.oauth2Bitly.Name = "oauth2Bitly"; - this.oauth2Bitly.Size = new System.Drawing.Size(328, 208); - this.oauth2Bitly.TabIndex = 0; - this.oauth2Bitly.OpenButtonClicked += new UploadersLib.GUI.OAuthControl.OpenButtonClickedEventHandler(this.oauth2Bitly_OpenButtonClicked); - this.oauth2Bitly.CompleteButtonClicked += new UploadersLib.GUI.OAuthControl.CompleteButtonClickedEventHandler(this.oauth2Bitly_CompleteButtonClicked); - this.oauth2Bitly.ClearButtonClicked += new UploadersLib.GUI.OAuthControl.ClearButtonclickedEventHandler(this.oauth2Bitly_ClearButtonClicked); - // - // oauth2GoogleURLShortener - // - this.oauth2GoogleURLShortener.Location = new System.Drawing.Point(16, 56); - this.oauth2GoogleURLShortener.Name = "oauth2GoogleURLShortener"; - this.oauth2GoogleURLShortener.Size = new System.Drawing.Size(328, 240); - this.oauth2GoogleURLShortener.TabIndex = 1; - this.oauth2GoogleURLShortener.OpenButtonClicked += new UploadersLib.GUI.OAuthControl.OpenButtonClickedEventHandler(this.oauth2GoogleURLShortener_OpenButtonClicked); - this.oauth2GoogleURLShortener.CompleteButtonClicked += new UploadersLib.GUI.OAuthControl.CompleteButtonClickedEventHandler(this.oauth2GoogleURLShortener_CompleteButtonClicked); - this.oauth2GoogleURLShortener.ClearButtonClicked += new UploadersLib.GUI.OAuthControl.ClearButtonclickedEventHandler(this.oauth2GoogleURLShortener_ClearButtonClicked); - this.oauth2GoogleURLShortener.RefreshButtonClicked += new UploadersLib.GUI.OAuthControl.RefreshButtonClickedEventHandler(this.oauth2GoogleURLShortener_RefreshButtonClicked); - // - // atcGoogleURLShortenerAccountType - // - this.atcGoogleURLShortenerAccountType.Location = new System.Drawing.Point(8, 16); - this.atcGoogleURLShortenerAccountType.Name = "atcGoogleURLShortenerAccountType"; - this.atcGoogleURLShortenerAccountType.SelectedAccountType = UploadersLib.AccountType.Anonymous; - this.atcGoogleURLShortenerAccountType.Size = new System.Drawing.Size(214, 29); - this.atcGoogleURLShortenerAccountType.TabIndex = 0; - this.atcGoogleURLShortenerAccountType.AccountTypeChanged += new UploadersLib.GUI.AccountTypeControl.AccountTypeChangedEventHandler(this.atcGoogleURLShortenerAccountType_AccountTypeChanged); - // - // ucTwitterAccounts - // - this.ucTwitterAccounts.Dock = System.Windows.Forms.DockStyle.Fill; - this.ucTwitterAccounts.Location = new System.Drawing.Point(0, 0); - this.ucTwitterAccounts.Margin = new System.Windows.Forms.Padding(0); - this.ucTwitterAccounts.Name = "ucTwitterAccounts"; - this.ucTwitterAccounts.Size = new System.Drawing.Size(972, 493); - this.ucTwitterAccounts.TabIndex = 0; - // // actRapidShareAccountType // this.actRapidShareAccountType.Location = new System.Drawing.Point(8, 16); @@ -3771,7 +3771,7 @@ private void InitializeComponent() this.Padding = new System.Windows.Forms.Padding(3); this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "Outputs Configuration"; + this.Text = "ShareX - Destination settings"; this.Shown += new System.EventHandler(this.UploadersConfigForm_Shown); this.Resize += new System.EventHandler(this.UploadersConfigForm_Resize); this.tpOtherUploaders.ResumeLayout(false); diff --git a/UploadersLib/GUI/UploadersConfigForm.cs b/UploadersLib/GUI/UploadersConfigForm.cs index 13b8bdce1..16d5b3b7d 100644 --- a/UploadersLib/GUI/UploadersConfigForm.cs +++ b/UploadersLib/GUI/UploadersConfigForm.cs @@ -45,12 +45,10 @@ public UploadersConfigForm(UploadersConfig uploadersConfig) { Config = uploadersConfig; InitializeComponent(); - string title = "ShareX - Destination settings"; if (!string.IsNullOrEmpty(Config.FilePath)) { - title += " - " + Config.FilePath; + Text += " - " + Config.FilePath; } - Text = title; Icon = ShareXResources.Icon; } diff --git a/UploadersLib/Uploader.cs b/UploadersLib/Uploader.cs index a6a55a448..518a2efe1 100644 --- a/UploadersLib/Uploader.cs +++ b/UploadersLib/Uploader.cs @@ -54,6 +54,8 @@ public class Uploader protected bool stopUpload; + private HttpWebRequest currentRequest; + public Uploader() { Errors = new List(); @@ -84,6 +86,18 @@ public virtual void StopUpload() if (IsUploading) { stopUpload = true; + + if (currentRequest != null) + { + try + { + currentRequest.Abort(); + } + catch (Exception e) + { + DebugHelper.WriteException(e); + } + } } } @@ -177,17 +191,17 @@ public virtual void StopUpload() return (HttpWebResponse)request.GetResponse(); } - catch (WebException e) - { - if (SuppressWebExceptions) throw; - if (!stopUpload) AddWebError(e); - } catch (Exception e) { - if (!stopUpload) AddWebError(e); + if (!stopUpload) + { + if (SuppressWebExceptions && e is WebException) throw; + AddWebError(e); + } } finally { + currentRequest = null; IsUploading = false; } @@ -254,17 +268,17 @@ private HttpWebResponse PostResponseJSON(string url, string json, CookieCollecti return (HttpWebResponse)request.GetResponse(); } - catch (WebException e) - { - if (SuppressWebExceptions) throw; - if (!stopUpload) AddWebError(e); - } catch (Exception e) { - if (!stopUpload) AddWebError(e); + if (!stopUpload) + { + if (SuppressWebExceptions && e is WebException) throw; + AddWebError(e); + } } finally { + currentRequest = null; IsUploading = false; } @@ -302,17 +316,17 @@ private HttpWebResponse PostResponseJSON(string url, string json, CookieCollecti result.Response = ResponseToString(request.GetResponse(), responseType); result.IsSuccess = true; } - catch (WebException e) - { - if (SuppressWebExceptions) throw; - if (!stopUpload) result.Response = AddWebError(e); - } catch (Exception e) { - if (!stopUpload) result.Response = AddWebError(e); + if (!stopUpload) + { + if (SuppressWebExceptions && e is WebException) throw; + AddWebError(e); + } } finally { + currentRequest = null; IsUploading = false; } @@ -323,10 +337,10 @@ private HttpWebResponse PostResponseJSON(string url, string json, CookieCollecti #region Helper methods - private HttpWebRequest PreparePostWebRequest(string url, string boundary, long length, string contentType, CookieCollection cookies = null, - NameValueCollection headers = null) + private HttpWebRequest PreparePostWebRequest(string url, string boundary, long length, string contentType, CookieCollection cookies = null, NameValueCollection headers = null) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); + if (headers != null && headers["Accept"] != null) { request.Accept = headers["Accept"]; @@ -349,6 +363,8 @@ private HttpWebResponse PostResponseJSON(string url, string json, CookieCollecti request.Timeout = -1; request.UserAgent = UserAgent; + currentRequest = request; + return request; } @@ -364,6 +380,8 @@ private HttpWebRequest PrepareWebRequest(HttpMethod method, string url, NameValu if (proxy != null) request.Proxy = proxy; request.UserAgent = UserAgent; + currentRequest = request; + return request; } diff --git a/UploadersLib/UploadersConfig.cs b/UploadersLib/UploadersConfig.cs index 6feb9efe1..b583b7ba9 100644 --- a/UploadersLib/UploadersConfig.cs +++ b/UploadersLib/UploadersConfig.cs @@ -281,12 +281,12 @@ public bool IsActive(ImageDestination destination) { switch (destination) { + case ImageDestination.Imgur: + return ImgurAccountType == AccountType.Anonymous || OAuth2Info.CheckOAuth(ImgurOAuth2Info); case ImageDestination.ImageShack: return ImageShackSettings != null && !string.IsNullOrEmpty(ImageShackSettings.Auth_token); case ImageDestination.TinyPic: return TinyPicAccountType == AccountType.Anonymous || !string.IsNullOrEmpty(TinyPicRegistrationCode); - case ImageDestination.Imgur: - return ImgurAccountType == AccountType.Anonymous || OAuth2Info.CheckOAuth(ImgurOAuth2Info); case ImageDestination.Flickr: return !string.IsNullOrEmpty(FlickrAuthInfo.Token); case ImageDestination.Photobucket: @@ -294,12 +294,12 @@ public bool IsActive(ImageDestination destination) case ImageDestination.Picasa: return OAuth2Info.CheckOAuth(PicasaOAuth2Info); case ImageDestination.Twitter: - return TwitterOAuthInfoList != null && TwitterOAuthInfoList.IsValidIndex(TwitterSelectedAccount); + return TwitterOAuthInfoList != null && TwitterOAuthInfoList.IsValidIndex(TwitterSelectedAccount) && OAuthInfo.CheckOAuth(TwitterOAuthInfoList[TwitterSelectedAccount]); case ImageDestination.CustomImageUploader: return CustomUploadersList != null && CustomUploadersList.IsValidIndex(CustomImageUploaderSelected); - default: - return true; } + + return true; } public bool IsActive(TextDestination destination) @@ -308,9 +308,9 @@ public bool IsActive(TextDestination destination) { case TextDestination.CustomTextUploader: return CustomUploadersList != null && CustomUploadersList.IsValidIndex(CustomTextUploaderSelected); - default: - return true; } + + return true; } public bool IsActive(FileDestination destination) @@ -350,9 +350,9 @@ public bool IsActive(FileDestination destination) case FileDestination.Pushbullet: return PushbulletSettings != null && !string.IsNullOrEmpty(PushbulletSettings.UserAPIKey) && PushbulletSettings.DeviceList != null && PushbulletSettings.DeviceList.IsValidIndex(PushbulletSettings.SelectedDevice); - default: - return true; } + + return true; } public bool IsActive(UrlShortenerType destination) @@ -367,9 +367,9 @@ public bool IsActive(UrlShortenerType destination) return !string.IsNullOrEmpty(YourlsAPIURL) && (!string.IsNullOrEmpty(YourlsSignature) || (!string.IsNullOrEmpty(YourlsUsername) && !string.IsNullOrEmpty(YourlsPassword))); case UrlShortenerType.CustomURLShortener: return CustomUploadersList != null && CustomUploadersList.IsValidIndex(CustomURLShortenerSelected); - default: - return true; } + + return true; } public bool IsActive(SocialNetworkingService destination) @@ -377,10 +377,10 @@ public bool IsActive(SocialNetworkingService destination) switch (destination) { case SocialNetworkingService.Twitter: - return TwitterOAuthInfoList != null && TwitterOAuthInfoList.IsValidIndex(TwitterSelectedAccount); - default: - return true; + return TwitterOAuthInfoList != null && TwitterOAuthInfoList.IsValidIndex(TwitterSelectedAccount) && OAuthInfo.CheckOAuth(TwitterOAuthInfoList[TwitterSelectedAccount]); } + + return true; } public int GetFTPIndex(EDataType dataType) @@ -391,9 +391,9 @@ public int GetFTPIndex(EDataType dataType) return FTPSelectedImage; case EDataType.Text: return FTPSelectedText; - default: - return FTPSelectedFile; } + + return FTPSelectedFile; } public int GetLocalhostIndex(EDataType dataType) @@ -404,9 +404,9 @@ public int GetLocalhostIndex(EDataType dataType) return LocalhostSelectedImages; case EDataType.Text: return LocalhostSelectedText; - default: - return LocalhostSelectedFiles; } + + return LocalhostSelectedFiles; } #endregion Helper Methods