From 80e26e9bfe2fc98f02edbe07c901a7bc9747305f Mon Sep 17 00:00:00 2001 From: lithium_ Date: Sun, 15 May 2016 04:57:30 -0700 Subject: [PATCH] New File Uploader - lithi.io Added a new file uploader. --- ShareX.UploadersLib/Enums.cs | 2 + ShareX.UploadersLib/Favicons/Lithiio.ico | Bin 0 -> 1150 bytes ShareX.UploadersLib/FileUploaders/Lithiio.cs | 105 +++++++ .../Forms/UploadersConfigForm.Designer.cs | 58 ++++ .../Forms/UploadersConfigForm.cs | 34 +++ .../Forms/UploadersConfigForm.resx | 288 ++++++++++++++++-- .../Properties/Resources.Designer.cs | 10 + ShareX.UploadersLib/Properties/Resources.resx | 3 + .../ShareX.UploadersLib.csproj | 5 + ShareX.UploadersLib/UploadersConfig.cs | 4 + ShareX/Forms/AboutForm.cs | 3 +- 11 files changed, 483 insertions(+), 29 deletions(-) create mode 100644 ShareX.UploadersLib/Favicons/Lithiio.ico create mode 100644 ShareX.UploadersLib/FileUploaders/Lithiio.cs diff --git a/ShareX.UploadersLib/Enums.cs b/ShareX.UploadersLib/Enums.cs index 3cfd55423..a42d25134 100644 --- a/ShareX.UploadersLib/Enums.cs +++ b/ShareX.UploadersLib/Enums.cs @@ -118,6 +118,8 @@ public enum FileDestination Jira, [Description("Lambda")] Lambda, + [Description("Lithiio")] + Lithiio, [Description("VideoBin")] VideoBin, [Description("Pomf")] diff --git a/ShareX.UploadersLib/Favicons/Lithiio.ico b/ShareX.UploadersLib/Favicons/Lithiio.ico new file mode 100644 index 0000000000000000000000000000000000000000..a9f109b02d57d0c2ec7d6d4dc6e4391fc19090f9 GIT binary patch literal 1150 zcmc(fI}U&_3_~9hGwQ_5*rRbz4pt1o5;Fr<mbDP89_r+lPzo%{6@d}vQ@T!C}| literal 0 HcmV?d00001 diff --git a/ShareX.UploadersLib/FileUploaders/Lithiio.cs b/ShareX.UploadersLib/FileUploaders/Lithiio.cs new file mode 100644 index 000000000..f4c64593e --- /dev/null +++ b/ShareX.UploadersLib/FileUploaders/Lithiio.cs @@ -0,0 +1,105 @@ +#region License Information (GPL v3) + +/* + ShareX - A program that allows you to take screenshots and share any file type + Copyright (c) 2007-2016 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 . +*/ + +#endregion License Information (GPL v3) + +// Copied Lambda.cs FileUploader and modified it a little to work with https://lithi.io/. +// To-do: add the other domains to the dropdown menu. +// Credits: https://github.com/mstojcevich +// Minor changes: https://github.com/lithium720 + +using Newtonsoft.Json; +using System.Collections.Generic; +using System.IO; +using System.Windows.Forms; + +namespace ShareX.UploadersLib.FileUploaders +{ + public class LithiioFileUploaderService : FileUploaderService + { + public override FileDestination EnumValue { get; } = FileDestination.Lithiio; + + public override bool CheckConfig(UploadersConfig config) + { + return config.LithiioSettings != null; + } + + public override GenericUploader CreateUploader(UploadersConfig config, TaskReferenceHelper taskInfo) + { + return new Lithiio(config.LithiioSettings); + } + + public override TabPage GetUploadersConfigTabPage(UploadersConfigForm form) => form.tpLithiio; + } + + public sealed class Lithiio : FileUploader + { + public LithiioSettings Config { get; private set; } + + public Lithiio(LithiioSettings config) + { + Config = config; + } + + private const string uploadUrl = "http://api.lithi.io/upload.php"; + + public static string[] UploadURLs = new string[] { "https://lithi.io/" }; + + public override UploadResult Upload(Stream stream, string fileName) + { + Dictionary arguments = new Dictionary(); + arguments.Add("key", Config.UserAPIKey); + UploadResult result = UploadData(stream, uploadUrl, fileName, "file", arguments, method: HttpMethod.POST); + + if (result.Response == null) + { + Errors.Add("Upload failed for unknown reason. Check your API key."); + return result; + } + + if (result.IsSuccess) + { + result.URL = result.Response; + } + + return result; + } + + internal class LithiioResponse + { + public string url { get; set; } + public List errors { get; set; } + } + + internal class LithiioFile + { + public string url { get; set; } + } + } + + public class LithiioSettings + { + public string UserAPIKey = string.Empty; + public string UploadURL = "https://lithi.io/"; + } +} diff --git a/ShareX.UploadersLib/Forms/UploadersConfigForm.Designer.cs b/ShareX.UploadersLib/Forms/UploadersConfigForm.Designer.cs index 2bf9100ee..82a2e591a 100644 --- a/ShareX.UploadersLib/Forms/UploadersConfigForm.Designer.cs +++ b/ShareX.UploadersLib/Forms/UploadersConfigForm.Designer.cs @@ -313,6 +313,12 @@ private void InitializeComponent() this.txtLambdaApiKey = new System.Windows.Forms.TextBox(); this.lblLambdaUploadURL = new System.Windows.Forms.Label(); this.cbLambdaUploadURL = new System.Windows.Forms.ComboBox(); + this.tpLithiio = new System.Windows.Forms.TabPage(); + this.lblLithiioInfo = new System.Windows.Forms.Label(); + this.lblLithiioApiKey = new System.Windows.Forms.Label(); + this.txtLithiioApiKey = new System.Windows.Forms.TextBox(); + this.lblLithiioUploadURL = new System.Windows.Forms.Label(); + this.cbLithiioUploadURL = new System.Windows.Forms.ComboBox(); this.tpPomf = new System.Windows.Forms.TabPage(); this.btnPomfTest = new System.Windows.Forms.Button(); this.txtPomfResultURL = new System.Windows.Forms.TextBox(); @@ -572,6 +578,7 @@ private void InitializeComponent() this.tpJira.SuspendLayout(); this.gpJiraServer.SuspendLayout(); this.tpLambda.SuspendLayout(); + this.tpLithiio.SuspendLayout(); this.tpPomf.SuspendLayout(); this.tpUp1.SuspendLayout(); this.tpSeafile.SuspendLayout(); @@ -1615,6 +1622,7 @@ private void InitializeComponent() this.tcFileUploaders.Controls.Add(this.tpMinus); this.tcFileUploaders.Controls.Add(this.tpJira); this.tcFileUploaders.Controls.Add(this.tpLambda); + this.tcFileUploaders.Controls.Add(this.tpLithiio); this.tcFileUploaders.Controls.Add(this.tpPomf); this.tcFileUploaders.Controls.Add(this.tpUp1); this.tcFileUploaders.Controls.Add(this.tpSeafile); @@ -2682,6 +2690,48 @@ private void InitializeComponent() this.cbLambdaUploadURL.Name = "cbLambdaUploadURL"; this.cbLambdaUploadURL.SelectedIndexChanged += new System.EventHandler(this.cbLambdaUploadURL_SelectedIndexChanged); // + // tpLithiio + // + this.tpLithiio.Controls.Add(this.lblLithiioInfo); + this.tpLithiio.Controls.Add(this.lblLithiioApiKey); + this.tpLithiio.Controls.Add(this.txtLithiioApiKey); + this.tpLithiio.Controls.Add(this.lblLithiioUploadURL); + this.tpLithiio.Controls.Add(this.cbLithiioUploadURL); + resources.ApplyResources(this.tpLithiio, "tpLithiio"); + this.tpLithiio.Name = "tpLithiio"; + this.tpLithiio.UseVisualStyleBackColor = true; + // + // lblLithiioInfo + // + resources.ApplyResources(this.lblLithiioInfo, "lblLithiioInfo"); + this.lblLithiioInfo.Name = "lblLithiioInfo"; + this.lblLithiioInfo.Click += new System.EventHandler(this.lithiioInfoLabel_Click); + // + // lblLithiioApiKey + // + resources.ApplyResources(this.lblLithiioApiKey, "lblLithiioApiKey"); + this.lblLithiioApiKey.Name = "lblLithiioApiKey"; + // + // txtLithiioApiKey + // + resources.ApplyResources(this.txtLithiioApiKey, "txtLithiioApiKey"); + this.txtLithiioApiKey.Name = "txtLithiioApiKey"; + this.txtLithiioApiKey.UseSystemPasswordChar = true; + this.txtLithiioApiKey.TextChanged += new System.EventHandler(this.txtLithiioApiKey_TextChanged); + // + // lblLithiioUploadURL + // + resources.ApplyResources(this.lblLithiioUploadURL, "lblLithiioUploadURL"); + this.lblLithiioUploadURL.Name = "lblLithiioUploadURL"; + // + // cbLithiioUploadURL + // + this.cbLithiioUploadURL.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cbLithiioUploadURL.FormattingEnabled = true; + resources.ApplyResources(this.cbLithiioUploadURL, "cbLithiioUploadURL"); + this.cbLithiioUploadURL.Name = "cbLithiioUploadURL"; + this.cbLithiioUploadURL.SelectedIndexChanged += new System.EventHandler(this.cbLithiioUploadURL_SelectedIndexChanged); + // // tpPomf // this.tpPomf.Controls.Add(this.btnPomfTest); @@ -4334,6 +4384,8 @@ private void InitializeComponent() this.gpJiraServer.PerformLayout(); this.tpLambda.ResumeLayout(false); this.tpLambda.PerformLayout(); + this.tpLithiio.ResumeLayout(false); + this.tpLithiio.PerformLayout(); this.tpPomf.ResumeLayout(false); this.tpPomf.PerformLayout(); this.tpUp1.ResumeLayout(false); @@ -4735,6 +4787,11 @@ private void InitializeComponent() private System.Windows.Forms.Label lblLambdaInfo; private System.Windows.Forms.Label lblLambdaUploadURL; private System.Windows.Forms.ComboBox cbLambdaUploadURL; + private System.Windows.Forms.Label lblLithiioApiKey; + private System.Windows.Forms.TextBox txtLithiioApiKey; + private System.Windows.Forms.Label lblLithiioInfo; + private System.Windows.Forms.Label lblLithiioUploadURL; + private System.Windows.Forms.ComboBox cbLithiioUploadURL; private OAuthControl oauthTwitter; private System.Windows.Forms.TextBox txtTwitterDescription; private System.Windows.Forms.Label lblTwitterDescription; @@ -4886,6 +4943,7 @@ private void InitializeComponent() public System.Windows.Forms.TabPage tpMinus; public System.Windows.Forms.TabPage tpJira; public System.Windows.Forms.TabPage tpLambda; + public System.Windows.Forms.TabPage tpLithiio; public System.Windows.Forms.TabPage tpPomf; public System.Windows.Forms.TabPage tpUp1; public System.Windows.Forms.TabPage tpSeafile; diff --git a/ShareX.UploadersLib/Forms/UploadersConfigForm.cs b/ShareX.UploadersLib/Forms/UploadersConfigForm.cs index 335f1ae04..e8fc9da2d 100644 --- a/ShareX.UploadersLib/Forms/UploadersConfigForm.cs +++ b/ShareX.UploadersLib/Forms/UploadersConfigForm.cs @@ -112,6 +112,7 @@ private void InitializeControls() AddIconToTab(tpImgur, Resources.Imgur); AddIconToTab(tpJira, Resources.jira); AddIconToTab(tpLambda, Resources.Lambda); + AddIconToTab(tpLithiio, Resources.Lithiio); AddIconToTab(tpMediaFire, Resources.MediaFire); AddIconToTab(tpMega, Resources.Mega); AddIconToTab(tpMinus, Resources.Minus); @@ -567,6 +568,12 @@ public void LoadSettings() cbLambdaUploadURL.Items.AddRange(Lambda.UploadURLs); cbLambdaUploadURL.SelectedItem = Config.LambdaSettings.UploadURL; + // Lithiio + + txtLithiioApiKey.Text = Config.LithiioSettings.UserAPIKey; + cbLithiioUploadURL.Items.AddRange(Lithiio.UploadURLs); + cbLithiioUploadURL.SelectedItem = Config.LithiioSettings.UploadURL; + // Pomf if (Config.PomfUploader == null) Config.PomfUploader = new PomfUploader(); @@ -2137,6 +2144,33 @@ private void cbLambdaUploadURL_SelectedIndexChanged(object sender, EventArgs e) #endregion Lambda + #region Lithiio + + private void lithiioInfoLabel_Click(object sender, EventArgs e) + { + URLHelpers.OpenURL("https://lithi.io/"); + } + + private void txtLithiioApiKey_TextChanged(object sender, EventArgs e) + { + Config.LithiioSettings.UserAPIKey = txtLithiioApiKey.Text; + } + + private void cbLithiioUploadURL_SelectedIndexChanged(object sender, EventArgs e) + { + if (cbLithiioUploadURL.SelectedIndex > -1) + { + string url = cbLithiioUploadURL.SelectedItem as string; + + if (url != null) + { + Config.LithiioSettings.UploadURL = url; + } + } + } + + #endregion Lithiio + #region Pomf private void cbPomfUploaders_SelectedIndexChanged(object sender, EventArgs e) diff --git a/ShareX.UploadersLib/Forms/UploadersConfigForm.resx b/ShareX.UploadersLib/Forms/UploadersConfigForm.resx index 7f6070170..ca5d8559e 100644 --- a/ShareX.UploadersLib/Forms/UploadersConfigForm.resx +++ b/ShareX.UploadersLib/Forms/UploadersConfigForm.resx @@ -1,17 +1,17 @@  - @@ -4672,6 +4672,18 @@ store.book[0].title 15 + + tpLithiio + + + System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tcFileUploaders + + + 15 + tpPomf @@ -10284,6 +10296,226 @@ store.book[0].title 4 + + lblLithiioInfo + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tpLithiio + + + 0 + + + lblLithiioApiKey + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tpLithiio + + + 1 + + + txtLithiioApiKey + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tpLithiio + + + 2 + + + lblLithiioUploadURL + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tpLithiio + + + 3 + + + cbLithiioUploadURL + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tpLithiio + + + 4 + + + 4, 40 + + + 3, 3, 3, 3 + + + 972, 475 + + + 20 + + + Lithiio + + + tpLithiio + + + System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tcFileUploaders + + + 15 + + + True + + + NoControl + + + 13, 16 + + + 554, 13 + + + 0 + + + For anonymous usage, leave the API field blank. 50 MB max per upload, files expire after 3 months minimum. +Otherwise, for file management options and a larger file upload size, visit https://lithi.io/ and sign in through Steam to get an API key. + + + lblLithiioInfo + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tpLithiio + + + 0 + + + True + + + NoControl + + + 13, 52 + + + 47, 13 + + + 1 + + + API key: + + + lblLithiioApiKey + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tpLithiio + + + 1 + + + 16, 69 + + + 346, 20 + + + 6 + + + txtLithiioApiKey + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tpLithiio + + + 2 + + + True + + + NoControl + + + 13, 98 + + + 55, 13 + + + 1 + + + Link URL: + + + lblLithiioUploadURL + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tpLithiio + + + 3 + + + 16, 114 + + + 216, 21 + + + 0 + + + cbLithiioUploadURL + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tpLithiio + + + 4 + btnPomfTest @@ -18265,4 +18497,4 @@ Using an encrypted library disables sharing. System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - \ No newline at end of file + diff --git a/ShareX.UploadersLib/Properties/Resources.Designer.cs b/ShareX.UploadersLib/Properties/Resources.Designer.cs index 5d80a8c28..eceacab97 100644 --- a/ShareX.UploadersLib/Properties/Resources.Designer.cs +++ b/ShareX.UploadersLib/Properties/Resources.Designer.cs @@ -420,6 +420,16 @@ internal class Resources { } } + /// + /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). + /// + internal static System.Drawing.Icon Lithiio { + get { + object obj = ResourceManager.GetObject("Lithiio", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/ShareX.UploadersLib/Properties/Resources.resx b/ShareX.UploadersLib/Properties/Resources.resx index 2bf6d7e92..c69f900ed 100644 --- a/ShareX.UploadersLib/Properties/Resources.resx +++ b/ShareX.UploadersLib/Properties/Resources.resx @@ -422,6 +422,9 @@ Created folders: ..\Favicons\Lambda.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Favicons\Lithiio.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Favicons\Pushbullet.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a diff --git a/ShareX.UploadersLib/ShareX.UploadersLib.csproj b/ShareX.UploadersLib/ShareX.UploadersLib.csproj index b296906a7..e29145a7e 100644 --- a/ShareX.UploadersLib/ShareX.UploadersLib.csproj +++ b/ShareX.UploadersLib/ShareX.UploadersLib.csproj @@ -128,6 +128,7 @@ + @@ -657,6 +658,7 @@ UploadersConfigForm.cs + Designer UploadersConfigForm.cs @@ -929,6 +931,9 @@ + + + diff --git a/ShareX.UploadersLib/UploadersConfig.cs b/ShareX.UploadersLib/UploadersConfig.cs index 4a9f2dd82..a9218d5f9 100644 --- a/ShareX.UploadersLib/UploadersConfig.cs +++ b/ShareX.UploadersLib/UploadersConfig.cs @@ -257,6 +257,10 @@ public class UploadersConfig : SettingsBase public LambdaSettings LambdaSettings = new LambdaSettings(); + // Lithiio + + public LithiioSettings LithiioSettings = new LithiioSettings(); + // Pomf public PomfUploader PomfUploader = new PomfUploader("https://pomf.cat/upload.php", "https://a.pomf.cat"); diff --git a/ShareX/Forms/AboutForm.cs b/ShareX/Forms/AboutForm.cs index 5864432ca..68530905b 100644 --- a/ShareX/Forms/AboutForm.cs +++ b/ShareX/Forms/AboutForm.cs @@ -90,6 +90,7 @@ public AboutForm() Streamable support: https://github.com/streamablevideo s-ul support: https://github.com/corin12355 Imgland support: https://github.com/jibcore +Lithiio support: https://github.com/lithium720 {1}: @@ -338,4 +339,4 @@ private void bounceTimer_Tick(object sender, EventArgs e) #endregion Easter egg } -} \ No newline at end of file +}