mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Removed unused Hubic codes
This commit is contained in:
parent
1dbab850b5
commit
81e3911d38
10 changed files with 1096 additions and 6485 deletions
Binary file not shown.
Before Width: | Height: | Size: 1.4 KiB |
|
@ -1,272 +0,0 @@
|
|||
#region License Information (GPL v3)
|
||||
|
||||
/*
|
||||
ShareX - A program that allows you to take screenshots and share any file type
|
||||
Copyright (c) 2007-2015 ShareX Team
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#endregion License Information (GPL v3)
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using ShareX.HelpersLib;
|
||||
using ShareX.UploadersLib.HelperClasses;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace ShareX.UploadersLib.FileUploaders
|
||||
{
|
||||
public sealed class Hubic : FileUploader, IOAuth2
|
||||
{
|
||||
public OAuth2Info AuthInfo { get; set; }
|
||||
public HubicOpenstackAuthInfo HubicOpenstackAuthInfo { get; set; }
|
||||
public HubicFolderInfo SelectedFolder { get; set; }
|
||||
public bool Publish { get; set; }
|
||||
public static HubicFolderInfo RootFolder = new HubicFolderInfo
|
||||
{
|
||||
name = ""
|
||||
};
|
||||
public const string Scope = @"usage.r,account.r,getAllLinks.r,credentials.r,sponsorCode.r,activate.w,sponsored.r,links.drw";
|
||||
public const string URLApi = @"https://api.hubic.com/1.0/account/credentials/";
|
||||
|
||||
public Hubic(OAuth2Info oauth, HubicOpenstackAuthInfo osauth)
|
||||
{
|
||||
AuthInfo = oauth;
|
||||
HubicOpenstackAuthInfo = osauth;
|
||||
}
|
||||
|
||||
public string GetAuthorizationURL()
|
||||
{
|
||||
Dictionary<string, string> args = new Dictionary<string, string>();
|
||||
//Hubic only accepts https callback URL
|
||||
args.Add("redirect_uri", Links.URL_CALLBACK);
|
||||
args.Add("client_id", AuthInfo.Client_ID);
|
||||
args.Add("scope", Scope);
|
||||
args.Add("response_type", "code");
|
||||
|
||||
return CreateQuery("https://api.hubic.com/oauth/auth/", args);
|
||||
}
|
||||
|
||||
public bool GetAccessToken(string code)
|
||||
{
|
||||
Dictionary<string, string> args = new Dictionary<string, string>();
|
||||
args.Add("code", code);
|
||||
//Hubic only accepts https callback URL
|
||||
args.Add("redirect_uri", Links.URL_CALLBACK);
|
||||
args.Add("grant_type", "authorization_code");
|
||||
|
||||
string response = SendRequest(HttpMethod.POST, "https://api.hubic.com/oauth/token/", args, GetAuthHeaders("Basic"));
|
||||
|
||||
if (!string.IsNullOrEmpty(response))
|
||||
{
|
||||
OAuth2Token token = JsonConvert.DeserializeObject<OAuth2Token>(response);
|
||||
|
||||
if (token != null && !string.IsNullOrEmpty(token.access_token))
|
||||
{
|
||||
token.UpdateExpireDate();
|
||||
AuthInfo.Token = token;
|
||||
GetHubicOpenStackAuthInfo();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private NameValueCollection GetAuthHeaders(string headerType)
|
||||
{
|
||||
NameValueCollection headers = new NameValueCollection();
|
||||
switch (headerType)
|
||||
{
|
||||
case "Basic":
|
||||
string secretInBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(AuthInfo.Client_ID + ":" + AuthInfo.Client_Secret));
|
||||
headers["Authorization"] = headerType + " " + secretInBase64;
|
||||
break;
|
||||
case "Bearer":
|
||||
headers["Authorization"] = headerType + " " + AuthInfo.Token.access_token;
|
||||
break;
|
||||
case "X-Auth-Token":
|
||||
headers["X-Auth-Token"] = " " + HubicOpenstackAuthInfo.token;
|
||||
headers["X-Detect-Content-Type"] = " " + "true";
|
||||
break;
|
||||
}
|
||||
return headers;
|
||||
}
|
||||
|
||||
public bool RefreshAccessToken()
|
||||
{
|
||||
if (OAuth2Info.CheckOAuth(AuthInfo) && !string.IsNullOrEmpty(AuthInfo.Token.refresh_token))
|
||||
{
|
||||
Dictionary<string, string> args = new Dictionary<string, string>();
|
||||
args.Add("grant_type", "refresh_token");
|
||||
args.Add("refresh_token", AuthInfo.Token.refresh_token);
|
||||
args.Add("client_id", AuthInfo.Client_ID);
|
||||
args.Add("client_secret", AuthInfo.Client_Secret);
|
||||
|
||||
string response = SendRequest(HttpMethod.POST, "https://api.hubic.com/oauth/token", args);
|
||||
|
||||
if (!string.IsNullOrEmpty(response))
|
||||
{
|
||||
OAuth2Token token = JsonConvert.DeserializeObject<OAuth2Token>(response);
|
||||
|
||||
if (token != null && !string.IsNullOrEmpty(token.access_token))
|
||||
{
|
||||
token.UpdateExpireDate();
|
||||
AuthInfo.Token = token;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool CheckAuthorization()
|
||||
{
|
||||
if (OAuth2Info.CheckOAuth(AuthInfo))
|
||||
{
|
||||
if (AuthInfo.Token.IsExpired && !RefreshAccessToken())
|
||||
{
|
||||
Errors.Add("Refresh access token failed.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Errors.Add("Hubic login is required.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void GetHubicOpenStackAuthInfo()
|
||||
{
|
||||
string response = SendRequest(HttpMethod.GET, URLApi, headers: GetAuthHeaders("Bearer"));
|
||||
if (!string.IsNullOrEmpty(response))
|
||||
{
|
||||
HubicOpenstackAuthInfo resp = JsonConvert.DeserializeObject<HubicOpenstackAuthInfo>(response);
|
||||
HubicOpenstackAuthInfo.endpoint = resp.endpoint;
|
||||
HubicOpenstackAuthInfo.expires = resp.expires;
|
||||
HubicOpenstackAuthInfo.token = resp.token;
|
||||
}
|
||||
}
|
||||
|
||||
public List<HubicFolderInfo> GetFiles(HubicFolderInfo fileInfo)
|
||||
{
|
||||
if (!CheckAuthorization())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
string response = SendRequest(HttpMethod.GET, HubicOpenstackAuthInfo.endpoint + "/default" + "/?path=" + fileInfo.name + "&format=json", headers: GetAuthHeaders("X-Auth-Token"));
|
||||
|
||||
if (!string.IsNullOrEmpty(response))
|
||||
{
|
||||
return JsonConvert.DeserializeObject<List<HubicFolderInfo>>(response);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public override UploadResult Upload(Stream stream, string fileName)
|
||||
{
|
||||
if (!CheckAuthorization())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
string url = URLHelpers.CombineURL(HubicOpenstackAuthInfo.endpoint, "default", SelectedFolder.path, fileName);
|
||||
|
||||
NameValueCollection headers = new NameValueCollection();
|
||||
headers.Add("X-Auth-Token", HubicOpenstackAuthInfo.token);
|
||||
headers.Add("X-Detect-Content-Type", "true");
|
||||
|
||||
UploadResult result = UploadData(stream, url, fileName, headers: headers, method: HttpMethod.PUT);
|
||||
|
||||
if (Publish)
|
||||
{
|
||||
AllowReportProgress = false;
|
||||
Dictionary<string, string> args = new Dictionary<string, string>();
|
||||
args.Add("comment", fileName);
|
||||
args.Add("container", "default");
|
||||
args.Add("mode", "ro");
|
||||
args.Add("ttl", "30");
|
||||
args.Add("type", "file");
|
||||
args.Add("uri", "/" + SelectedFolder.path + "/" + fileName);
|
||||
|
||||
string response = SendRequest(HttpMethod.POST, "https://api.hubic.com/1.0/account/links", args, GetAuthHeaders("Bearer"));
|
||||
|
||||
if (!string.IsNullOrEmpty(response))
|
||||
{
|
||||
HubicPublishURLResponse resp = JsonConvert.DeserializeObject<HubicPublishURLResponse>(response);
|
||||
string respURL = resp.indirectUrl;
|
||||
result.IsURLExpected = true;
|
||||
result.URL = respURL;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class HubicOpenstackAuthInfo
|
||||
{
|
||||
public string token { get; set; }
|
||||
public string endpoint { get; set; }
|
||||
public string expires { get; set; }
|
||||
}
|
||||
|
||||
public class HubicFolderInfo
|
||||
{
|
||||
private string _name;
|
||||
public string hash { get; set; }
|
||||
public string last_modified { get; set; }
|
||||
public int bytes { get; set; }
|
||||
public string name
|
||||
{
|
||||
get
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
set
|
||||
{
|
||||
//split the folder path and jsut store the folder name
|
||||
path = value;
|
||||
string[] temp = value.Split('/');
|
||||
_name = temp[temp.Length - 1];
|
||||
}
|
||||
}
|
||||
public string content_type { get; set; }
|
||||
public string path { get; set; }
|
||||
}
|
||||
|
||||
public class HubicPublishURLResponse
|
||||
{
|
||||
public string indirectUrl { get; set; }
|
||||
public string mode { get; set; }
|
||||
public string container { get; set; }
|
||||
public string expirationDate { get; set; }
|
||||
public string creationDate { get; set; }
|
||||
public string comment { get; set; }
|
||||
public string type { get; set; }
|
||||
}
|
||||
}
|
|
@ -191,14 +191,6 @@ private void InitializeComponent()
|
|||
this.lblCopyPath = new System.Windows.Forms.Label();
|
||||
this.txtCopyPath = new System.Windows.Forms.TextBox();
|
||||
this.oAuthCopy = new ShareX.UploadersLib.OAuthControl();
|
||||
this.tpHubic = new System.Windows.Forms.TabPage();
|
||||
this.cbHubicPublishLink = new System.Windows.Forms.CheckBox();
|
||||
this.lblHubicSelectedFolderNote = new System.Windows.Forms.Label();
|
||||
this.lvHubicFolders = new ShareX.HelpersLib.MyListView();
|
||||
this.chHubicFolderName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.lblHubicSelectedFolder = new System.Windows.Forms.Label();
|
||||
this.btnHubicRefreshFolders = new System.Windows.Forms.Button();
|
||||
this.oauth2Hubic = new ShareX.UploadersLib.OAuthControl();
|
||||
this.tpAmazonS3 = new System.Windows.Forms.TabPage();
|
||||
this.txtAmazonS3CustomDomain = new System.Windows.Forms.TextBox();
|
||||
this.lblAmazonS3PathPreviewLabel = new System.Windows.Forms.Label();
|
||||
|
@ -474,7 +466,6 @@ private void InitializeComponent()
|
|||
this.tpBox.SuspendLayout();
|
||||
this.tpCopy.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pbCopyLogo)).BeginInit();
|
||||
this.tpHubic.SuspendLayout();
|
||||
this.tpAmazonS3.SuspendLayout();
|
||||
this.tpMega.SuspendLayout();
|
||||
this.tpOwnCloud.SuspendLayout();
|
||||
|
@ -1323,7 +1314,6 @@ private void InitializeComponent()
|
|||
this.tcFileUploaders.Controls.Add(this.tpGoogleDrive);
|
||||
this.tcFileUploaders.Controls.Add(this.tpBox);
|
||||
this.tcFileUploaders.Controls.Add(this.tpCopy);
|
||||
this.tcFileUploaders.Controls.Add(this.tpHubic);
|
||||
this.tcFileUploaders.Controls.Add(this.tpAmazonS3);
|
||||
this.tcFileUploaders.Controls.Add(this.tpMega);
|
||||
this.tcFileUploaders.Controls.Add(this.tpOwnCloud);
|
||||
|
@ -1727,68 +1717,6 @@ private void InitializeComponent()
|
|||
this.oAuthCopy.CompleteButtonClicked += new ShareX.UploadersLib.OAuthControl.CompleteButtonClickedEventHandler(this.oAuthCopy_CompleteButtonClicked);
|
||||
this.oAuthCopy.ClearButtonClicked += new ShareX.UploadersLib.OAuthControl.ClearButtonclickedEventHandler(this.oAuthCopy_ClearButtonClicked);
|
||||
//
|
||||
// tpHubic
|
||||
//
|
||||
this.tpHubic.Controls.Add(this.cbHubicPublishLink);
|
||||
this.tpHubic.Controls.Add(this.lblHubicSelectedFolderNote);
|
||||
this.tpHubic.Controls.Add(this.lvHubicFolders);
|
||||
this.tpHubic.Controls.Add(this.lblHubicSelectedFolder);
|
||||
this.tpHubic.Controls.Add(this.btnHubicRefreshFolders);
|
||||
this.tpHubic.Controls.Add(this.oauth2Hubic);
|
||||
resources.ApplyResources(this.tpHubic, "tpHubic");
|
||||
this.tpHubic.Name = "tpHubic";
|
||||
this.tpHubic.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// cbHubicPublishLink
|
||||
//
|
||||
resources.ApplyResources(this.cbHubicPublishLink, "cbHubicPublishLink");
|
||||
this.cbHubicPublishLink.Name = "cbHubicPublishLink";
|
||||
this.cbHubicPublishLink.UseVisualStyleBackColor = true;
|
||||
this.cbHubicPublishLink.CheckedChanged += new System.EventHandler(this.cbHubicPublishLink_CheckedChanged);
|
||||
//
|
||||
// lblHubicSelectedFolderNote
|
||||
//
|
||||
resources.ApplyResources(this.lblHubicSelectedFolderNote, "lblHubicSelectedFolderNote");
|
||||
this.lblHubicSelectedFolderNote.Name = "lblHubicSelectedFolderNote";
|
||||
//
|
||||
// lvHubicFolders
|
||||
//
|
||||
this.lvHubicFolders.AutoFillColumn = true;
|
||||
this.lvHubicFolders.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.chHubicFolderName});
|
||||
this.lvHubicFolders.FullRowSelect = true;
|
||||
resources.ApplyResources(this.lvHubicFolders, "lvHubicFolders");
|
||||
this.lvHubicFolders.Name = "lvHubicFolders";
|
||||
this.lvHubicFolders.UseCompatibleStateImageBehavior = false;
|
||||
this.lvHubicFolders.View = System.Windows.Forms.View.Details;
|
||||
this.lvHubicFolders.SelectedIndexChanged += new System.EventHandler(this.lvHubicFolders_SelectedIndexChanged);
|
||||
this.lvHubicFolders.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.lvHubicFolders_MouseDoubleClick);
|
||||
//
|
||||
// chHubicFolderName
|
||||
//
|
||||
resources.ApplyResources(this.chHubicFolderName, "chHubicFolderName");
|
||||
//
|
||||
// lblHubicSelectedFolder
|
||||
//
|
||||
resources.ApplyResources(this.lblHubicSelectedFolder, "lblHubicSelectedFolder");
|
||||
this.lblHubicSelectedFolder.Name = "lblHubicSelectedFolder";
|
||||
//
|
||||
// btnHubicRefreshFolders
|
||||
//
|
||||
resources.ApplyResources(this.btnHubicRefreshFolders, "btnHubicRefreshFolders");
|
||||
this.btnHubicRefreshFolders.Name = "btnHubicRefreshFolders";
|
||||
this.btnHubicRefreshFolders.UseVisualStyleBackColor = true;
|
||||
this.btnHubicRefreshFolders.Click += new System.EventHandler(this.btnHubicRefreshFolders_Click);
|
||||
//
|
||||
// oauth2Hubic
|
||||
//
|
||||
resources.ApplyResources(this.oauth2Hubic, "oauth2Hubic");
|
||||
this.oauth2Hubic.Name = "oauth2Hubic";
|
||||
this.oauth2Hubic.OpenButtonClicked += new ShareX.UploadersLib.OAuthControl.OpenButtonClickedEventHandler(this.oAuth2Hubic_OpenButtonClicked);
|
||||
this.oauth2Hubic.CompleteButtonClicked += new ShareX.UploadersLib.OAuthControl.CompleteButtonClickedEventHandler(this.oAuth2Hubic_CompleteButtonClicked);
|
||||
this.oauth2Hubic.ClearButtonClicked += new ShareX.UploadersLib.OAuthControl.ClearButtonclickedEventHandler(this.oAuth2Hubic_ClearButtonClicked);
|
||||
this.oauth2Hubic.RefreshButtonClicked += new ShareX.UploadersLib.OAuthControl.RefreshButtonClickedEventHandler(this.oAuth2Hubic_RefreshButtonClicked);
|
||||
//
|
||||
// tpAmazonS3
|
||||
//
|
||||
this.tpAmazonS3.Controls.Add(this.txtAmazonS3CustomDomain);
|
||||
|
@ -3617,8 +3545,6 @@ private void InitializeComponent()
|
|||
this.tpCopy.ResumeLayout(false);
|
||||
this.tpCopy.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pbCopyLogo)).EndInit();
|
||||
this.tpHubic.ResumeLayout(false);
|
||||
this.tpHubic.PerformLayout();
|
||||
this.tpAmazonS3.ResumeLayout(false);
|
||||
this.tpAmazonS3.PerformLayout();
|
||||
this.tpMega.ResumeLayout(false);
|
||||
|
@ -4070,14 +3996,6 @@ private void InitializeComponent()
|
|||
private System.Windows.Forms.CheckBox cbOneDriveCreateShareableLink;
|
||||
private System.Windows.Forms.Label lblOneDriveFolderID;
|
||||
private System.Windows.Forms.TreeView tvOneDrive;
|
||||
private System.Windows.Forms.TabPage tpHubic;
|
||||
private OAuthControl oauth2Hubic;
|
||||
private System.Windows.Forms.Label lblHubicSelectedFolderNote;
|
||||
private HelpersLib.MyListView lvHubicFolders;
|
||||
private System.Windows.Forms.ColumnHeader chHubicFolderName;
|
||||
private System.Windows.Forms.Label lblHubicSelectedFolder;
|
||||
private System.Windows.Forms.Button btnHubicRefreshFolders;
|
||||
private System.Windows.Forms.CheckBox cbHubicPublishLink;
|
||||
private System.Windows.Forms.TabPage tpLambda;
|
||||
private System.Windows.Forms.Label lblLambdaApiKey;
|
||||
private System.Windows.Forms.TextBox txtLambdaApiKey;
|
||||
|
|
|
@ -77,7 +77,6 @@ private void FormSettings()
|
|||
AddIconToTab(tpBitly, Resources.Bitly);
|
||||
AddIconToTab(tpBox, Resources.Box);
|
||||
AddIconToTab(tpCopy, Resources.Copy);
|
||||
AddIconToTab(tpHubic, Resources.Hubic);
|
||||
AddIconToTab(tpChevereto, Resources.Chevereto);
|
||||
AddIconToTab(tpCoinURL, Resources.CoinURL);
|
||||
AddIconToTab(tpCustomUploaders, Resources.globe_network);
|
||||
|
@ -115,8 +114,6 @@ private void FormSettings()
|
|||
AddIconToTab(tpOneTimeSecret, Resources.OneTimeSecret);
|
||||
AddIconToTab(tpPolr, Resources.Polr);
|
||||
|
||||
tcFileUploaders.TabPages.Remove(tpHubic);
|
||||
|
||||
ttlvMain.ImageList = uploadersImageList;
|
||||
ttlvMain.MainTabControl = tcUploaders;
|
||||
ttlvMain.FocusListView();
|
||||
|
@ -368,16 +365,6 @@ public void LoadSettings()
|
|||
cbBoxShare.Checked = Config.BoxShare;
|
||||
lblBoxFolderID.Text = Resources.UploadersConfigForm_LoadSettings_Selected_folder_ + " " + Config.BoxSelectedFolder.name;
|
||||
|
||||
// Hubic
|
||||
|
||||
if (OAuth2Info.CheckOAuth(Config.HubicOAuth2Info))
|
||||
{
|
||||
oauth2Hubic.Status = OAuthLoginStatus.LoginSuccessful;
|
||||
btnHubicRefreshFolders.Enabled = true;
|
||||
}
|
||||
|
||||
cbHubicPublishLink.Checked = Config.HubicPublish;
|
||||
|
||||
// Ge.tt
|
||||
|
||||
if (Config.Ge_ttLogin != null && !string.IsNullOrEmpty(Config.Ge_ttLogin.AccessToken))
|
||||
|
@ -1174,69 +1161,6 @@ private void cbCopyURLType_SelectedIndexChanged(object sender, EventArgs e)
|
|||
|
||||
#endregion Copy
|
||||
|
||||
#region Hubic
|
||||
|
||||
private void oAuth2Hubic_OpenButtonClicked()
|
||||
{
|
||||
HubicAuthOpen();
|
||||
}
|
||||
|
||||
private void oAuth2Hubic_CompleteButtonClicked(string code)
|
||||
{
|
||||
HubicAuthComplete(code);
|
||||
}
|
||||
|
||||
private void oAuth2Hubic_RefreshButtonClicked()
|
||||
{
|
||||
HubicAuthRefresh();
|
||||
}
|
||||
|
||||
private void oAuth2Hubic_ClearButtonClicked()
|
||||
{
|
||||
Config.HubicOAuth2Info = null;
|
||||
Config.HubicOpenstackAuthInfo = null;
|
||||
}
|
||||
|
||||
private void btnHubicRefreshFolders_Click(object sender, EventArgs e)
|
||||
{
|
||||
HubicListFolders(Hubic.RootFolder);
|
||||
}
|
||||
|
||||
private void lvHubicFolders_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (lvHubicFolders.SelectedItems.Count > 0)
|
||||
{
|
||||
ListViewItem lvi = lvHubicFolders.SelectedItems[0];
|
||||
HubicFolderInfo folder = lvi.Tag as HubicFolderInfo;
|
||||
if (folder != null)
|
||||
{
|
||||
lblHubicSelectedFolder.Text = Resources.UploadersConfigForm_LoadSettings_Selected_folder_ + " " + folder.name;
|
||||
Config.HubicSelectedFolder = folder;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void lvHubicFolders_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left && lvHubicFolders.SelectedItems.Count > 0)
|
||||
{
|
||||
ListViewItem lvi = lvHubicFolders.SelectedItems[0];
|
||||
HubicFolderInfo folder = lvi.Tag as HubicFolderInfo;
|
||||
if (folder != null)
|
||||
{
|
||||
lvHubicFolders.Items.Clear();
|
||||
HubicListFolders(folder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void cbHubicPublishLink_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
Config.HubicPublish = cbHubicPublishLink.Checked;
|
||||
}
|
||||
|
||||
#endregion Hubic
|
||||
|
||||
#region OneDrive
|
||||
|
||||
private void oAuth2OneDrive_OpenButtonClicked()
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -883,122 +883,6 @@ private void BoxAddFolder(BoxFileEntry folder)
|
|||
|
||||
#endregion Box
|
||||
|
||||
#region Hubic
|
||||
|
||||
public void HubicAuthOpen()
|
||||
{
|
||||
try
|
||||
{
|
||||
OAuth2Info oauth = new OAuth2Info(APIKeys.HubicClientID, APIKeys.HubicClientSecret);
|
||||
HubicOpenstackAuthInfo osauth = new HubicOpenstackAuthInfo();
|
||||
|
||||
string url = new Hubic(oauth, osauth).GetAuthorizationURL();
|
||||
|
||||
if (!string.IsNullOrEmpty(url))
|
||||
{
|
||||
Config.HubicOAuth2Info = oauth;
|
||||
Config.HubicOpenstackAuthInfo = osauth;
|
||||
URLHelpers.OpenURL(url);
|
||||
DebugHelper.WriteLine("HubicAuthOpen - Authorization URL is opened: " + url);
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugHelper.WriteLine("HubicAuthOpen - Authorization URL is empty.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
public void HubicAuthComplete(string code)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(code) && Config.HubicOAuth2Info != null)
|
||||
{
|
||||
bool result = new Hubic(Config.HubicOAuth2Info, Config.HubicOpenstackAuthInfo).GetAccessToken(code);
|
||||
|
||||
if (result)
|
||||
{
|
||||
oauth2Hubic.Status = OAuthLoginStatus.LoginSuccessful;
|
||||
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
oauth2Hubic.Status = OAuthLoginStatus.LoginFailed;
|
||||
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
btnHubicRefreshFolders.Enabled = result;
|
||||
btnHubicRefreshFolders.PerformClick();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
public void HubicAuthRefresh()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (OAuth2Info.CheckOAuth(Config.HubicOAuth2Info))
|
||||
{
|
||||
bool result = new Hubic(Config.HubicOAuth2Info, Config.HubicOpenstackAuthInfo).RefreshAccessToken();
|
||||
|
||||
if (result)
|
||||
{
|
||||
oauth2Hubic.Status = OAuthLoginStatus.LoginSuccessful;
|
||||
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
oauth2Hubic.Status = OAuthLoginStatus.LoginFailed;
|
||||
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
public void HubicListFolders(HubicFolderInfo fileInfo)
|
||||
{
|
||||
lvHubicFolders.Items.Clear();
|
||||
|
||||
if (!OAuth2Info.CheckOAuth(Config.HubicOAuth2Info))
|
||||
{
|
||||
MessageBox.Show(Resources.UploadersConfigForm_ListFolders_Authentication_required_, Resources.UploadersConfigForm_HubicListFolders_Hubic_refresh_folders_list_failed,
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
else
|
||||
{
|
||||
Hubic hubic = new Hubic(Config.HubicOAuth2Info, Config.HubicOpenstackAuthInfo);
|
||||
List<HubicFolderInfo> folders = hubic.GetFiles(fileInfo);
|
||||
if (folders != null && folders.Count != 0)
|
||||
{
|
||||
foreach (HubicFolderInfo folder in folders.Where(x => x.content_type == "application/directory" && x.name[0] != '.'))
|
||||
{
|
||||
HubicAddFolder(folder);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void HubicAddFolder(HubicFolderInfo folder)
|
||||
{
|
||||
ListViewItem lvi = new ListViewItem(folder.name);
|
||||
lvi.Tag = folder;
|
||||
lvHubicFolders.Items.Add(lvi);
|
||||
}
|
||||
|
||||
#endregion Hubic
|
||||
|
||||
#region OneDrive
|
||||
|
||||
public void OneDriveAuthOpen()
|
||||
|
|
10
ShareX.UploadersLib/Properties/Resources.Designer.cs
generated
10
ShareX.UploadersLib/Properties/Resources.Designer.cs
generated
|
@ -363,16 +363,6 @@ internal static System.Drawing.Icon Hostr {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||
/// </summary>
|
||||
internal static System.Drawing.Icon Hubic {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Hubic", resourceCulture);
|
||||
return ((System.Drawing.Icon)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||
/// </summary>
|
||||
|
|
|
@ -458,9 +458,6 @@ Created folders:</value>
|
|||
<data name="OneDrive_RootFolder_Root_folder" xml:space="preserve">
|
||||
<value>Root folder</value>
|
||||
</data>
|
||||
<data name="Hubic" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Favicons\hubic.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="CoinURL" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Favicons\CoinURL.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
|
|
|
@ -130,7 +130,6 @@
|
|||
<Compile Include="FileUploaders\Ge_tt.cs" />
|
||||
<Compile Include="FileUploaders\AmazonS3.cs" />
|
||||
<Compile Include="FileUploaders\GoogleDrive.cs" />
|
||||
<Compile Include="FileUploaders\Hubic.cs" />
|
||||
<Compile Include="FileUploaders\Jira.cs" />
|
||||
<Compile Include="FileUploaders\Hostr.cs" />
|
||||
<Compile Include="FileUploaders\MaxFile.cs" />
|
||||
|
@ -746,7 +745,6 @@
|
|||
<None Include="Favicons\OneDrive.ico" />
|
||||
<None Include="Favicons\Chevereto.png" />
|
||||
<None Include="Favicons\Hastebin.png" />
|
||||
<None Include="Favicons\hubic.ico" />
|
||||
<None Include="Favicons\Up1.ico" />
|
||||
<None Include="Favicons\CoinURL.ico" />
|
||||
<None Include="Favicons\copy.ico" />
|
||||
|
|
|
@ -140,13 +140,6 @@ public class UploadersConfig : SettingsBase<UploadersConfig>
|
|||
public string CopyUploadPath = "ShareX/%y/%mo";
|
||||
public CopyURLType CopyURLType = CopyURLType.Shortened;
|
||||
|
||||
// Hubic
|
||||
|
||||
public OAuth2Info HubicOAuth2Info = null;
|
||||
public HubicOpenstackAuthInfo HubicOpenstackAuthInfo = null;
|
||||
public HubicFolderInfo HubicSelectedFolder = Hubic.RootFolder;
|
||||
public bool HubicPublish = false;
|
||||
|
||||
// Google Drive
|
||||
|
||||
public OAuth2Info GoogleDriveOAuth2Info = null;
|
||||
|
|
Loading…
Reference in a new issue