Gist implementation with test application

This commit is contained in:
Gregoire Pailler 2013-12-03 00:11:30 +01:00
parent 38e4c5f4ac
commit 7277f69b56
9 changed files with 344 additions and 183 deletions

View file

@ -667,7 +667,7 @@ public UploadResult UploadText(Stream stream, string fileName)
textUploader = new Paste_ee(Program.UploadersConfig.Paste_eeUserAPIKey);
break;
case TextDestination.Gist:
textUploader = new Gist();
textUploader = Program.UploadersConfig.GistAnonymousLogin ? new Gist() : new Gist(Program.UploadersConfig.GistOAuth2Info);
break;
case TextDestination.CustomTextUploader:
if (Program.UploadersConfig.CustomUploadersList.IsValidIndex(Program.UploadersConfig.CustomTextUploaderSelected))

View file

@ -60,6 +60,8 @@ public static class ApiKeys
// Text Uploaders
public const string PastebinKey = "4b23be71ec78bbd4fb96735320aa09ef";
public const string PastebinCaKey = "KxTofLKQThSBZ63Gpa7hYLlMdyQlMD6u";
public const string GistId = "60cd5843cab0522f8501";
public const string GistSecret = "fa6eec2009b7fee1037548a96886992acc39fee8";
// URL Shorteners
public const string BitlyLogin = "jaex";

View file

@ -98,6 +98,11 @@ public class UploadersConfig : SettingsBase<UploadersConfig>
public string Paste_eeUserAPIKey = "public";
// Gist
public bool GistAnonymousLogin = true;
public OAuth2Info GistOAuth2Info = null;
#endregion Text uploaders
#region File uploaders

View file

@ -34,6 +34,7 @@ private void InitializeComponent()
this.tpImageUploaders = new System.Windows.Forms.TabPage();
this.tcImageUploaders = new System.Windows.Forms.TabControl();
this.tpImageShack = new System.Windows.Forms.TabPage();
this.atcImageShackAccountType = new UploadersLib.GUI.AccountTypeControl();
this.btnImageShackOpenPublicProfile = new System.Windows.Forms.Button();
this.cbImageShackIsPublic = new System.Windows.Forms.CheckBox();
this.btnImageShackOpenMyImages = new System.Windows.Forms.Button();
@ -43,6 +44,7 @@ private void InitializeComponent()
this.txtImageShackRegistrationCode = new System.Windows.Forms.TextBox();
this.lblImageShackRegistrationCode = 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();
@ -53,6 +55,7 @@ private void InitializeComponent()
this.lblTinyPicRegistrationCode = new System.Windows.Forms.Label();
this.txtTinyPicRegistrationCode = new System.Windows.Forms.TextBox();
this.tpImgur = new System.Windows.Forms.TabPage();
this.oauth2Imgur = new UploadersLib.GUI.OAuth2Control();
this.txtImgurAlbumID = new System.Windows.Forms.TextBox();
this.lblImgurAlbumID = new System.Windows.Forms.Label();
this.lvImgurAlbumList = new System.Windows.Forms.ListView();
@ -62,6 +65,7 @@ private void InitializeComponent()
this.btnImgurRefreshAlbumList = new System.Windows.Forms.Button();
this.cbImgurThumbnailType = new System.Windows.Forms.ComboBox();
this.lblImgurThumbnailType = new System.Windows.Forms.Label();
this.atcImgurAccountType = new UploadersLib.GUI.AccountTypeControl();
this.tpFlickr = new System.Windows.Forms.TabPage();
this.btnFlickrOpenImages = new System.Windows.Forms.Button();
this.pgFlickrAuthInfo = new System.Windows.Forms.PropertyGrid();
@ -108,6 +112,7 @@ 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.OAuth2Control();
this.tpTextUploaders = new System.Windows.Forms.TabPage();
this.tcTextUploaders = new System.Windows.Forms.TabControl();
this.tpPastebin = new System.Windows.Forms.TabPage();
@ -117,6 +122,8 @@ private void InitializeComponent()
this.lblPaste_eeUserAPIKey = new System.Windows.Forms.Label();
this.txtPaste_eeUserAPIKey = new System.Windows.Forms.TextBox();
this.tpGist = new System.Windows.Forms.TabPage();
this.oAuth2Gist = new UploadersLib.GUI.OAuth2Control();
this.atcGistAccountType = new UploadersLib.GUI.AccountTypeControl();
this.tpFileUploaders = new System.Windows.Forms.TabPage();
this.tcFileUploaders = new System.Windows.Forms.TabControl();
this.tpDropbox = new System.Windows.Forms.TabPage();
@ -132,6 +139,7 @@ private void InitializeComponent()
this.btnDropboxOpenAuthorize = new System.Windows.Forms.Button();
this.txtDropboxPath = new System.Windows.Forms.TextBox();
this.tpMega = new System.Windows.Forms.TabPage();
this.atcMegaAccountType = new UploadersLib.GUI.AccountTypeControl();
this.lblMegaStatus = new System.Windows.Forms.Label();
this.pnlMegaLogin = new System.Windows.Forms.Panel();
this.btnMegaRefreshFolders = new System.Windows.Forms.Button();
@ -151,6 +159,7 @@ private void InitializeComponent()
this.btnFTPExport = new System.Windows.Forms.Button();
this.btnFTPImport = new System.Windows.Forms.Button();
this.btnFtpHelp = new System.Windows.Forms.Button();
this.ucFTPAccounts = new UploadersLib.AccountsControl();
this.gbFtpSettings = new System.Windows.Forms.GroupBox();
this.lblFtpFiles = new System.Windows.Forms.Label();
this.lblFtpText = new System.Windows.Forms.Label();
@ -180,6 +189,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_ttAccessToken = new System.Windows.Forms.Label();
this.lblGe_ttPassword = new System.Windows.Forms.Label();
@ -200,7 +210,9 @@ 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.OAuth2Control();
this.tpGoogleDrive = new System.Windows.Forms.TabPage();
this.oauth2GoogleDrive = new UploadersLib.GUI.OAuth2Control();
this.tpMinus = new System.Windows.Forms.TabPage();
this.gbMinusUserPass = new System.Windows.Forms.GroupBox();
this.btnAuthRefresh = new System.Windows.Forms.Button();
@ -235,6 +247,7 @@ private void InitializeComponent()
this.txtEmailDefaultSubject = new System.Windows.Forms.TextBox();
this.tpSharedFolder = new System.Windows.Forms.TabPage();
this.tlpSharedFolders = new System.Windows.Forms.TableLayoutPanel();
this.ucLocalhostAccounts = new UploadersLib.AccountsControl();
this.gbSharedFolder = new System.Windows.Forms.GroupBox();
this.lblSharedFolderFiles = new System.Windows.Forms.Label();
this.lblSharedFolderText = new System.Windows.Forms.Label();
@ -245,10 +258,13 @@ private void InitializeComponent()
this.tpURLShorteners = new System.Windows.Forms.TabPage();
this.tcURLShorteners = new System.Windows.Forms.TabControl();
this.tpGoogleURLShortener = new System.Windows.Forms.TabPage();
this.oauth2GoogleURLShortener = new UploadersLib.GUI.OAuth2Control();
this.atcGoogleURLShortenerAccountType = new UploadersLib.GUI.AccountTypeControl();
this.tpSocialNetworkingServices = new System.Windows.Forms.TabPage();
this.tcSocialNetworkingServices = new System.Windows.Forms.TabControl();
this.tpTwitter = new System.Windows.Forms.TabPage();
this.btnTwitterLogin = new System.Windows.Forms.Button();
this.ucTwitterAccounts = new UploadersLib.AccountsControl();
this.tpCustomUploaders = new System.Windows.Forms.TabPage();
this.lblCustomUploaderImageUploader = new System.Windows.Forms.Label();
this.btnCustomUploaderFileUploaderTest = new System.Windows.Forms.Button();
@ -306,23 +322,7 @@ private void InitializeComponent()
this.txtCustomUploaderArgName = new System.Windows.Forms.TextBox();
this.txtRapidSharePremiumUserName = new System.Windows.Forms.TextBox();
this.ttHelpTip = new System.Windows.Forms.ToolTip(this.components);
this.atcImageShackAccountType = new UploadersLib.GUI.AccountTypeControl();
this.atcTinyPicAccountType = new UploadersLib.GUI.AccountTypeControl();
this.oauth2Imgur = new UploadersLib.GUI.OAuth2Control();
this.atcImgurAccountType = new UploadersLib.GUI.AccountTypeControl();
this.oauth2Picasa = new UploadersLib.GUI.OAuth2Control();
this.atcMegaAccountType = new UploadersLib.GUI.AccountTypeControl();
this.ucFTPAccounts = new UploadersLib.AccountsControl();
this.atcSendSpaceAccountType = new UploadersLib.GUI.AccountTypeControl();
this.oAuthJira = new UploadersLib.GUI.OAuth2Control();
this.oauth2GoogleDrive = new UploadersLib.GUI.OAuth2Control();
this.ucLocalhostAccounts = new UploadersLib.AccountsControl();
this.oauth2GoogleURLShortener = new UploadersLib.GUI.OAuth2Control();
this.atcGoogleURLShortenerAccountType = new UploadersLib.GUI.AccountTypeControl();
this.ucTwitterAccounts = new UploadersLib.AccountsControl();
this.actRapidShareAccountType = new UploadersLib.GUI.AccountTypeControl();
this.atcGistAccountType = new UploadersLib.GUI.AccountTypeControl();
this.oAuthGist = new UploadersLib.GUI.OAuth2Control();
this.tcUploaders.SuspendLayout();
this.tpImageUploaders.SuspendLayout();
this.tcImageUploaders.SuspendLayout();
@ -445,6 +445,15 @@ private void InitializeComponent()
this.tpImageShack.Text = "ImageShack";
this.tpImageShack.UseVisualStyleBackColor = true;
//
// atcImageShackAccountType
//
this.atcImageShackAccountType.Location = new System.Drawing.Point(8, 16);
this.atcImageShackAccountType.Name = "atcImageShackAccountType";
this.atcImageShackAccountType.SelectedAccountType = UploadersLib.AccountType.Anonymous;
this.atcImageShackAccountType.Size = new System.Drawing.Size(272, 29);
this.atcImageShackAccountType.TabIndex = 0;
this.atcImageShackAccountType.AccountTypeChanged += new UploadersLib.GUI.AccountTypeControl.AccountTypeChangedEventHandler(this.atcImageShackAccountType_AccountTypeChanged);
//
// btnImageShackOpenPublicProfile
//
this.btnImageShackOpenPublicProfile.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
@ -545,6 +554,15 @@ private void InitializeComponent()
this.tpTinyPic.Text = "TinyPic";
this.tpTinyPic.UseVisualStyleBackColor = true;
//
// atcTinyPicAccountType
//
this.atcTinyPicAccountType.Location = new System.Drawing.Point(8, 16);
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(16, 168);
@ -650,6 +668,18 @@ private void InitializeComponent()
this.tpImgur.Text = "Imgur";
this.tpImgur.UseVisualStyleBackColor = true;
//
// oauth2Imgur
//
this.oauth2Imgur.Location = new System.Drawing.Point(464, 16);
this.oauth2Imgur.LoginStatus = false;
this.oauth2Imgur.Name = "oauth2Imgur";
this.oauth2Imgur.Size = new System.Drawing.Size(328, 207);
this.oauth2Imgur.Status = "Status: Login required.";
this.oauth2Imgur.TabIndex = 6;
this.oauth2Imgur.OpenButtonClicked += new UploadersLib.GUI.OAuth2Control.OpenButtonClickedEventHandler(this.oauth2Imgur_OpenButtonClicked);
this.oauth2Imgur.CompleteButtonClicked += new UploadersLib.GUI.OAuth2Control.CompleteButtonClickedEventHandler(this.oauth2Imgur_CompleteButtonClicked);
this.oauth2Imgur.RefreshButtonClicked += new UploadersLib.GUI.OAuth2Control.RefreshButtonClickedEventHandler(this.oauth2Imgur_RefreshButtonClicked);
//
// txtImgurAlbumID
//
this.txtImgurAlbumID.Location = new System.Drawing.Point(256, 84);
@ -728,6 +758,15 @@ private void InitializeComponent()
this.lblImgurThumbnailType.TabIndex = 1;
this.lblImgurThumbnailType.Text = "Thumbnail type:";
//
// atcImgurAccountType
//
this.atcImgurAccountType.Location = new System.Drawing.Point(8, 16);
this.atcImgurAccountType.Name = "atcImgurAccountType";
this.atcImgurAccountType.SelectedAccountType = UploadersLib.AccountType.Anonymous;
this.atcImgurAccountType.Size = new System.Drawing.Size(272, 29);
this.atcImgurAccountType.TabIndex = 0;
this.atcImgurAccountType.AccountTypeChanged += new UploadersLib.GUI.AccountTypeControl.AccountTypeChangedEventHandler(this.atcImgurAccountType_AccountTypeChanged);
//
// tpFlickr
//
this.tpFlickr.Controls.Add(this.btnFlickrOpenImages);
@ -1204,6 +1243,18 @@ 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.LoginStatus = false;
this.oauth2Picasa.Name = "oauth2Picasa";
this.oauth2Picasa.Size = new System.Drawing.Size(328, 207);
this.oauth2Picasa.Status = "Login required.";
this.oauth2Picasa.TabIndex = 0;
this.oauth2Picasa.OpenButtonClicked += new UploadersLib.GUI.OAuth2Control.OpenButtonClickedEventHandler(this.oauth2Picasa_OpenButtonClicked);
this.oauth2Picasa.CompleteButtonClicked += new UploadersLib.GUI.OAuth2Control.CompleteButtonClickedEventHandler(this.oauth2Picasa_CompleteButtonClicked);
this.oauth2Picasa.RefreshButtonClicked += new UploadersLib.GUI.OAuth2Control.RefreshButtonClickedEventHandler(this.oauth2Picasa_RefreshButtonClicked);
//
// tpTextUploaders
//
this.tpTextUploaders.Controls.Add(this.tcTextUploaders);
@ -1289,7 +1340,7 @@ private void InitializeComponent()
//
// tpGist
//
this.tpGist.Controls.Add(this.oAuthGist);
this.tpGist.Controls.Add(this.oAuth2Gist);
this.tpGist.Controls.Add(this.atcGistAccountType);
this.tpGist.Location = new System.Drawing.Point(4, 22);
this.tpGist.Name = "tpGist";
@ -1298,6 +1349,28 @@ private void InitializeComponent()
this.tpGist.Text = "Gist";
this.tpGist.UseVisualStyleBackColor = true;
//
// oAuth2Gist
//
this.oAuth2Gist.Enabled = false;
this.oAuth2Gist.Location = new System.Drawing.Point(15, 51);
this.oAuth2Gist.LoginStatus = false;
this.oAuth2Gist.Name = "oAuth2Gist";
this.oAuth2Gist.Size = new System.Drawing.Size(328, 207);
this.oAuth2Gist.Status = "Status: Login required.";
this.oAuth2Gist.TabIndex = 16;
this.oAuth2Gist.OpenButtonClicked += new UploadersLib.GUI.OAuth2Control.OpenButtonClickedEventHandler(this.oAuth2Gist_OpenButtonClicked);
this.oAuth2Gist.CompleteButtonClicked += new UploadersLib.GUI.OAuth2Control.CompleteButtonClickedEventHandler(this.oAuth2Gist_CompleteButtonClicked);
this.oAuth2Gist.RefreshButtonClicked += new UploadersLib.GUI.OAuth2Control.RefreshButtonClickedEventHandler(this.oAuth2Gist_RefreshButtonClicked);
//
// 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 = 15;
this.atcGistAccountType.AccountTypeChanged += new UploadersLib.GUI.AccountTypeControl.AccountTypeChangedEventHandler(this.atcGistAccountType_AccountTypeChanged);
//
// tpFileUploaders
//
this.tpFileUploaders.Controls.Add(this.tcFileUploaders);
@ -1476,6 +1549,14 @@ private void InitializeComponent()
this.tpMega.Text = "Mega";
this.tpMega.UseVisualStyleBackColor = true;
//
// atcMegaAccountType
//
this.atcMegaAccountType.Location = new System.Drawing.Point(16, 34);
this.atcMegaAccountType.Name = "atcMegaAccountType";
this.atcMegaAccountType.SelectedAccountType = UploadersLib.AccountType.Anonymous;
this.atcMegaAccountType.Size = new System.Drawing.Size(214, 29);
this.atcMegaAccountType.TabIndex = 14;
//
// lblMegaStatus
//
this.lblMegaStatus.AutoSize = true;
@ -1682,6 +1763,15 @@ private void InitializeComponent()
this.btnFtpHelp.Visible = false;
this.btnFtpHelp.Click += new System.EventHandler(this.btnFtpHelp_Click);
//
// ucFTPAccounts
//
this.ucFTPAccounts.Dock = System.Windows.Forms.DockStyle.Fill;
this.ucFTPAccounts.Location = new System.Drawing.Point(0, 0);
this.ucFTPAccounts.Margin = new System.Windows.Forms.Padding(4);
this.ucFTPAccounts.Name = "ucFTPAccounts";
this.ucFTPAccounts.Size = new System.Drawing.Size(792, 345);
this.ucFTPAccounts.TabIndex = 0;
//
// gbFtpSettings
//
this.gbFtpSettings.Controls.Add(this.lblFtpFiles);
@ -1976,6 +2066,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_ttAccessToken);
@ -2178,6 +2277,18 @@ private void InitializeComponent()
this.lblJiraHost.TabIndex = 0;
this.lblJiraHost.Text = "Jira host: ";
//
// oAuthJira
//
this.oAuthJira.Location = new System.Drawing.Point(473, 13);
this.oAuthJira.LoginStatus = false;
this.oAuthJira.Name = "oAuthJira";
this.oAuthJira.Size = new System.Drawing.Size(328, 207);
this.oAuthJira.Status = "Status: Login required.";
this.oAuthJira.TabIndex = 1;
this.oAuthJira.OpenButtonClicked += new UploadersLib.GUI.OAuth2Control.OpenButtonClickedEventHandler(this.oAuthJira_OpenButtonClicked);
this.oAuthJira.CompleteButtonClicked += new UploadersLib.GUI.OAuth2Control.CompleteButtonClickedEventHandler(this.oAuthJira_CompleteButtonClicked);
this.oAuthJira.RefreshButtonClicked += new UploadersLib.GUI.OAuth2Control.RefreshButtonClickedEventHandler(this.oAuthJira_RefreshButtonClicked);
//
// tpGoogleDrive
//
this.tpGoogleDrive.Controls.Add(this.oauth2GoogleDrive);
@ -2189,6 +2300,18 @@ private void InitializeComponent()
this.tpGoogleDrive.Text = "Google Drive";
this.tpGoogleDrive.UseVisualStyleBackColor = true;
//
// oauth2GoogleDrive
//
this.oauth2GoogleDrive.Location = new System.Drawing.Point(16, 16);
this.oauth2GoogleDrive.LoginStatus = false;
this.oauth2GoogleDrive.Name = "oauth2GoogleDrive";
this.oauth2GoogleDrive.Size = new System.Drawing.Size(328, 207);
this.oauth2GoogleDrive.Status = "Status: Login required.";
this.oauth2GoogleDrive.TabIndex = 0;
this.oauth2GoogleDrive.OpenButtonClicked += new UploadersLib.GUI.OAuth2Control.OpenButtonClickedEventHandler(this.oauth2GoogleDrive_OpenButtonClicked);
this.oauth2GoogleDrive.CompleteButtonClicked += new UploadersLib.GUI.OAuth2Control.CompleteButtonClickedEventHandler(this.oauth2GoogleDrive_CompleteButtonClicked);
this.oauth2GoogleDrive.RefreshButtonClicked += new UploadersLib.GUI.OAuth2Control.RefreshButtonClickedEventHandler(this.oauth2GoogleDrive_RefreshButtonClicked);
//
// tpMinus
//
this.tpMinus.Controls.Add(this.gbMinusUserPass);
@ -2560,6 +2683,15 @@ private void InitializeComponent()
this.tlpSharedFolders.Size = new System.Drawing.Size(798, 469);
this.tlpSharedFolders.TabIndex = 0;
//
// ucLocalhostAccounts
//
this.ucLocalhostAccounts.Dock = System.Windows.Forms.DockStyle.Fill;
this.ucLocalhostAccounts.Location = new System.Drawing.Point(4, 4);
this.ucLocalhostAccounts.Margin = new System.Windows.Forms.Padding(4);
this.ucLocalhostAccounts.Name = "ucLocalhostAccounts";
this.ucLocalhostAccounts.Size = new System.Drawing.Size(790, 343);
this.ucLocalhostAccounts.TabIndex = 0;
//
// gbSharedFolder
//
this.gbSharedFolder.Controls.Add(this.lblSharedFolderFiles);
@ -2666,6 +2798,27 @@ private void InitializeComponent()
this.tpGoogleURLShortener.Text = "Google";
this.tpGoogleURLShortener.UseVisualStyleBackColor = true;
//
// oauth2GoogleURLShortener
//
this.oauth2GoogleURLShortener.Location = new System.Drawing.Point(16, 56);
this.oauth2GoogleURLShortener.LoginStatus = false;
this.oauth2GoogleURLShortener.Name = "oauth2GoogleURLShortener";
this.oauth2GoogleURLShortener.Size = new System.Drawing.Size(328, 207);
this.oauth2GoogleURLShortener.Status = "Status: Login required.";
this.oauth2GoogleURLShortener.TabIndex = 1;
this.oauth2GoogleURLShortener.OpenButtonClicked += new UploadersLib.GUI.OAuth2Control.OpenButtonClickedEventHandler(this.oauth2GoogleURLShortener_OpenButtonClicked);
this.oauth2GoogleURLShortener.CompleteButtonClicked += new UploadersLib.GUI.OAuth2Control.CompleteButtonClickedEventHandler(this.oauth2GoogleURLShortener_CompleteButtonClicked);
this.oauth2GoogleURLShortener.RefreshButtonClicked += new UploadersLib.GUI.OAuth2Control.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);
//
// tpSocialNetworkingServices
//
this.tpSocialNetworkingServices.Controls.Add(this.tcSocialNetworkingServices);
@ -2709,6 +2862,14 @@ 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(3, 3);
this.ucTwitterAccounts.Name = "ucTwitterAccounts";
this.ucTwitterAccounts.Size = new System.Drawing.Size(798, 469);
this.ucTwitterAccounts.TabIndex = 0;
//
// tpCustomUploaders
//
this.tpCustomUploaders.Controls.Add(this.lblCustomUploaderImageUploader);
@ -3290,145 +3451,6 @@ private void InitializeComponent()
this.ttHelpTip.UseAnimation = false;
this.ttHelpTip.UseFading = false;
//
// atcImageShackAccountType
//
this.atcImageShackAccountType.Location = new System.Drawing.Point(8, 16);
this.atcImageShackAccountType.Name = "atcImageShackAccountType";
this.atcImageShackAccountType.SelectedAccountType = UploadersLib.AccountType.Anonymous;
this.atcImageShackAccountType.Size = new System.Drawing.Size(272, 29);
this.atcImageShackAccountType.TabIndex = 0;
this.atcImageShackAccountType.AccountTypeChanged += new UploadersLib.GUI.AccountTypeControl.AccountTypeChangedEventHandler(this.atcImageShackAccountType_AccountTypeChanged);
//
// atcTinyPicAccountType
//
this.atcTinyPicAccountType.Location = new System.Drawing.Point(8, 16);
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);
//
// oauth2Imgur
//
this.oauth2Imgur.Location = new System.Drawing.Point(464, 16);
this.oauth2Imgur.LoginStatus = false;
this.oauth2Imgur.Name = "oauth2Imgur";
this.oauth2Imgur.Size = new System.Drawing.Size(328, 207);
this.oauth2Imgur.Status = "Status: Login required.";
this.oauth2Imgur.TabIndex = 6;
this.oauth2Imgur.OpenButtonClicked += new UploadersLib.GUI.OAuth2Control.OpenButtonClickedEventHandler(this.oauth2Imgur_OpenButtonClicked);
this.oauth2Imgur.CompleteButtonClicked += new UploadersLib.GUI.OAuth2Control.CompleteButtonClickedEventHandler(this.oauth2Imgur_CompleteButtonClicked);
this.oauth2Imgur.RefreshButtonClicked += new UploadersLib.GUI.OAuth2Control.RefreshButtonClickedEventHandler(this.oauth2Imgur_RefreshButtonClicked);
//
// atcImgurAccountType
//
this.atcImgurAccountType.Location = new System.Drawing.Point(8, 16);
this.atcImgurAccountType.Name = "atcImgurAccountType";
this.atcImgurAccountType.SelectedAccountType = UploadersLib.AccountType.Anonymous;
this.atcImgurAccountType.Size = new System.Drawing.Size(272, 29);
this.atcImgurAccountType.TabIndex = 0;
this.atcImgurAccountType.AccountTypeChanged += new UploadersLib.GUI.AccountTypeControl.AccountTypeChangedEventHandler(this.atcImgurAccountType_AccountTypeChanged);
//
// oauth2Picasa
//
this.oauth2Picasa.Location = new System.Drawing.Point(16, 16);
this.oauth2Picasa.LoginStatus = false;
this.oauth2Picasa.Name = "oauth2Picasa";
this.oauth2Picasa.Size = new System.Drawing.Size(328, 207);
this.oauth2Picasa.Status = "Login required.";
this.oauth2Picasa.TabIndex = 0;
this.oauth2Picasa.OpenButtonClicked += new UploadersLib.GUI.OAuth2Control.OpenButtonClickedEventHandler(this.oauth2Picasa_OpenButtonClicked);
this.oauth2Picasa.CompleteButtonClicked += new UploadersLib.GUI.OAuth2Control.CompleteButtonClickedEventHandler(this.oauth2Picasa_CompleteButtonClicked);
this.oauth2Picasa.RefreshButtonClicked += new UploadersLib.GUI.OAuth2Control.RefreshButtonClickedEventHandler(this.oauth2Picasa_RefreshButtonClicked);
//
// atcMegaAccountType
//
this.atcMegaAccountType.Location = new System.Drawing.Point(16, 34);
this.atcMegaAccountType.Name = "atcMegaAccountType";
this.atcMegaAccountType.SelectedAccountType = UploadersLib.AccountType.Anonymous;
this.atcMegaAccountType.Size = new System.Drawing.Size(214, 29);
this.atcMegaAccountType.TabIndex = 14;
//
// ucFTPAccounts
//
this.ucFTPAccounts.Dock = System.Windows.Forms.DockStyle.Fill;
this.ucFTPAccounts.Location = new System.Drawing.Point(0, 0);
this.ucFTPAccounts.Margin = new System.Windows.Forms.Padding(4);
this.ucFTPAccounts.Name = "ucFTPAccounts";
this.ucFTPAccounts.Size = new System.Drawing.Size(792, 345);
this.ucFTPAccounts.TabIndex = 0;
//
// 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.LoginStatus = false;
this.oAuthJira.Name = "oAuthJira";
this.oAuthJira.Size = new System.Drawing.Size(328, 207);
this.oAuthJira.Status = "Status: Login required.";
this.oAuthJira.TabIndex = 1;
this.oAuthJira.OpenButtonClicked += new UploadersLib.GUI.OAuth2Control.OpenButtonClickedEventHandler(this.oAuthJira_OpenButtonClicked);
this.oAuthJira.CompleteButtonClicked += new UploadersLib.GUI.OAuth2Control.CompleteButtonClickedEventHandler(this.oAuthJira_CompleteButtonClicked);
this.oAuthJira.RefreshButtonClicked += new UploadersLib.GUI.OAuth2Control.RefreshButtonClickedEventHandler(this.oAuthJira_RefreshButtonClicked);
//
// oauth2GoogleDrive
//
this.oauth2GoogleDrive.Location = new System.Drawing.Point(16, 16);
this.oauth2GoogleDrive.LoginStatus = false;
this.oauth2GoogleDrive.Name = "oauth2GoogleDrive";
this.oauth2GoogleDrive.Size = new System.Drawing.Size(328, 207);
this.oauth2GoogleDrive.Status = "Status: Login required.";
this.oauth2GoogleDrive.TabIndex = 0;
this.oauth2GoogleDrive.OpenButtonClicked += new UploadersLib.GUI.OAuth2Control.OpenButtonClickedEventHandler(this.oauth2GoogleDrive_OpenButtonClicked);
this.oauth2GoogleDrive.CompleteButtonClicked += new UploadersLib.GUI.OAuth2Control.CompleteButtonClickedEventHandler(this.oauth2GoogleDrive_CompleteButtonClicked);
this.oauth2GoogleDrive.RefreshButtonClicked += new UploadersLib.GUI.OAuth2Control.RefreshButtonClickedEventHandler(this.oauth2GoogleDrive_RefreshButtonClicked);
//
// ucLocalhostAccounts
//
this.ucLocalhostAccounts.Dock = System.Windows.Forms.DockStyle.Fill;
this.ucLocalhostAccounts.Location = new System.Drawing.Point(4, 4);
this.ucLocalhostAccounts.Margin = new System.Windows.Forms.Padding(4);
this.ucLocalhostAccounts.Name = "ucLocalhostAccounts";
this.ucLocalhostAccounts.Size = new System.Drawing.Size(790, 343);
this.ucLocalhostAccounts.TabIndex = 0;
//
// oauth2GoogleURLShortener
//
this.oauth2GoogleURLShortener.Location = new System.Drawing.Point(16, 56);
this.oauth2GoogleURLShortener.LoginStatus = false;
this.oauth2GoogleURLShortener.Name = "oauth2GoogleURLShortener";
this.oauth2GoogleURLShortener.Size = new System.Drawing.Size(328, 207);
this.oauth2GoogleURLShortener.Status = "Status: Login required.";
this.oauth2GoogleURLShortener.TabIndex = 1;
this.oauth2GoogleURLShortener.OpenButtonClicked += new UploadersLib.GUI.OAuth2Control.OpenButtonClickedEventHandler(this.oauth2GoogleURLShortener_OpenButtonClicked);
this.oauth2GoogleURLShortener.CompleteButtonClicked += new UploadersLib.GUI.OAuth2Control.CompleteButtonClickedEventHandler(this.oauth2GoogleURLShortener_CompleteButtonClicked);
this.oauth2GoogleURLShortener.RefreshButtonClicked += new UploadersLib.GUI.OAuth2Control.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(3, 3);
this.ucTwitterAccounts.Name = "ucTwitterAccounts";
this.ucTwitterAccounts.Size = new System.Drawing.Size(798, 469);
this.ucTwitterAccounts.TabIndex = 0;
//
// actRapidShareAccountType
//
this.actRapidShareAccountType.Location = new System.Drawing.Point(8, 16);
@ -3437,23 +3459,6 @@ private void InitializeComponent()
this.actRapidShareAccountType.Size = new System.Drawing.Size(214, 29);
this.actRapidShareAccountType.TabIndex = 16;
//
// 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 = 15;
//
// oAuthGist
//
this.oAuthGist.Location = new System.Drawing.Point(15, 51);
this.oAuthGist.LoginStatus = false;
this.oAuthGist.Name = "oAuthGist";
this.oAuthGist.Size = new System.Drawing.Size(328, 207);
this.oAuthGist.Status = "Status: Login required.";
this.oAuthGist.TabIndex = 16;
//
// UploadersConfigForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -3853,6 +3858,6 @@ private void InitializeComponent()
private System.Windows.Forms.Button btnMegaRefreshFolders;
private System.Windows.Forms.TabPage tpGist;
private GUI.AccountTypeControl atcGistAccountType;
private GUI.OAuth2Control oAuthGist;
private GUI.OAuth2Control oAuth2Gist;
}
}

View file

@ -1167,6 +1167,31 @@ private void txtPaste_eeUserAPIKey_TextChanged(object sender, EventArgs e)
#endregion Paste.ee
#region Gist
private void atcGistAccountType_AccountTypeChanged(AccountType accountType)
{
Config.GistAnonymousLogin = accountType == AccountType.Anonymous;
oAuth2Gist.Enabled = !Config.GistAnonymousLogin;
}
private void oAuth2Gist_CompleteButtonClicked(string code)
{
this.GistAuthComplete(code);
}
private void oAuth2Gist_OpenButtonClicked()
{
this.GistAuthOpen();
}
private void oAuth2Gist_RefreshButtonClicked()
{
MessageBox.Show("Refresh authorization is not supported.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
#endregion
#endregion Text Uploaders
#region URL Shorteners

View file

@ -216,6 +216,10 @@ public void LoadSettings(UploadersConfig uploadersConfig)
txtPaste_eeUserAPIKey.Text = Config.Paste_eeUserAPIKey;
// Gist
atcGistAccountType.SelectedAccountType = Config.GistAnonymousLogin ? AccountType.Anonymous : AccountType.User;
#endregion Text uploaders
#region File uploaders

View file

@ -1419,5 +1419,56 @@ public void JiraAuthComplete(string code)
}
#endregion Jira
#region Gist
public void GistAuthOpen()
{
try
{
OAuth2Info oauth = new OAuth2Info(ApiKeys.GistId, ApiKeys.GistSecret);
string url = new Gist(oauth).GetAuthorizationURL();
if (!string.IsNullOrEmpty(url))
{
Config.GistOAuth2Info = oauth;
Helpers.LoadBrowserAsync(url);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
public void GistAuthComplete(string code)
{
try
{
if (!string.IsNullOrEmpty(code) && Config.GistOAuth2Info != null)
{
bool result = new Gist(Config.GistOAuth2Info).GetAccessToken(code);
if (result)
{
oAuth2Gist.Status = "Login successful.";
MessageBox.Show("Login successful.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
oAuth2Gist.Status = "Login failed.";
MessageBox.Show("Login failed.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
atcGistAccountType.SelectedAccountType = AccountType.Anonymous;
}
oAuth2Gist.LoginStatus = result;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
#endregion Gist
}
}

View file

@ -23,17 +23,74 @@ You should have received a copy of the GNU General Public License
#endregion License Information (GPL v3)
// gpailler
using Newtonsoft.Json;
using System.Collections.Generic;
using UploadersLib.HelperClasses;
namespace UploadersLib.TextUploaders
{
using System;
using System.Collections.Specialized;
using System.Net;
public sealed class Gist : TextUploader
{
private const string GistUploadUrl = "https://api.github.com/gists";
private readonly Uri GistUri = new Uri("https://api.github.com/gists");
private readonly Uri GistAuthorizeUri = new Uri("https://github.com/login/oauth/authorize");
private readonly Uri GistCompleteUri = new Uri("https://github.com/login/oauth/access_token");
private readonly Uri GistRedirectUri = new Uri("http://ksr.pailler.fr/gist/gist.html");
private readonly OAuth2Info oAuthInfos;
public Gist()
: this(null)
{
}
public Gist(OAuth2Info oAuthInfos)
{
this.oAuthInfos = oAuthInfos;
}
public string GetAuthorizationURL()
{
NameValueCollection queryString = System.Web.HttpUtility.ParseQueryString(string.Empty);
queryString["client_id"] = this.oAuthInfos.Client_ID;
queryString["redirect_uri"] = this.GistRedirectUri.ToString();
queryString["scope"] = "gist";
UriBuilder uri = new UriBuilder(this.GistAuthorizeUri);
uri.Query = queryString.ToString();
return uri.ToString();
}
public bool GetAccessToken(string code)
{
Dictionary<string, string> args = new Dictionary<string, string>();
args.Add("client_id", this.oAuthInfos.Client_ID);
args.Add("client_secret", this.oAuthInfos.Client_Secret);
args.Add("code", code);
WebHeaderCollection headers = new WebHeaderCollection();
headers.Add("Accept", "application/json");
string response = this.SendPostRequest(this.GistCompleteUri.ToString(), args, headers: headers);
if (!string.IsNullOrEmpty(response))
{
OAuth2Token token = JsonConvert.DeserializeObject<OAuth2Token>(response);
if (token != null && !string.IsNullOrEmpty(token.access_token))
{
this.oAuthInfos.Token = token;
return true;
}
}
return false;
}
public override UploadResult UploadText(string text, string fileName)
{
@ -52,7 +109,13 @@ public override UploadResult UploadText(string text, string fileName)
string argsJson = JsonConvert.SerializeObject(gistUploadObject);
string response = SendPostRequestJSON(GistUploadUrl, argsJson);
string Uri = GistUri.ToString();
if (this.oAuthInfos != null)
{
Uri += "?access_token=" + this.oAuthInfos.Token.access_token;
}
string response = SendPostRequestJSON(Uri, argsJson);
if (response != null)
{
var gistReturnType = new { html_url = "" };

View file

@ -108,9 +108,9 @@ protected string SendRequest(HttpMethod httpMethod, string url, Dictionary<strin
#region Post methods
protected string SendPostRequest(string url, Dictionary<string, string> arguments = null, ResponseType responseType = ResponseType.Text,
CookieCollection cookies = null)
CookieCollection cookies = null, NameValueCollection headers = null)
{
using (HttpWebResponse response = PostResponseMultiPart(url, arguments, cookies))
using (HttpWebResponse response = PostResponseMultiPart(url, arguments, cookies, headers))
{
return ResponseToString(response, responseType);
}
@ -145,7 +145,7 @@ protected string SendPostRequestStream(string url, Stream stream, string content
}
}
private HttpWebResponse PostResponseMultiPart(string url, Dictionary<string, string> arguments, CookieCollection cookies = null)
private HttpWebResponse PostResponseMultiPart(string url, Dictionary<string, string> arguments, CookieCollection cookies = null, NameValueCollection headers = null)
{
string boundary = CreateBoundary();
byte[] data = MakeInputContent(boundary, arguments);
@ -153,7 +153,7 @@ private HttpWebResponse PostResponseMultiPart(string url, Dictionary<string, str
using (MemoryStream stream = new MemoryStream())
{
stream.Write(data, 0, data.Length);
return GetResponseUsingPost(url, stream, boundary, "multipart/form-data", cookies);
return GetResponseUsingPost(url, stream, boundary, "multipart/form-data", cookies, headers);
}
}
@ -347,6 +347,12 @@ private HttpWebRequest PreparePostWebRequest(string url, string boundary, long l
NameValueCollection headers = null)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
if (headers != null && headers["Accept"] != null)
{
request.Accept = headers["Accept"];
headers.Remove("Accept");
}
request.AllowWriteStreamBuffering = ProxyInfo.IsValidProxy();
request.CachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
request.ContentLength = length;