From 0f30c0e57eed355edad768b4ede61b41c9d4831d Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Sat, 10 Jun 2017 21:42:54 +0200 Subject: [PATCH] Plik FileUploader changes - added the ability to upload files with an infinity expire time - adjusted the default ttl --- ShareX.UploadersLib/FileUploaders/Plik.cs | 28 ++++++++++- .../FileUploaders/PlikSettings.cs | 2 +- .../Forms/UploadersConfigForm.Designer.cs | 46 +++++++++++-------- .../Forms/UploadersConfigForm.cs | 2 +- .../Forms/UploadersConfigForm.resx | 3 ++ 5 files changed, 57 insertions(+), 24 deletions(-) diff --git a/ShareX.UploadersLib/FileUploaders/Plik.cs b/ShareX.UploadersLib/FileUploaders/Plik.cs index d8712f137..50b2a6db1 100644 --- a/ShareX.UploadersLib/FileUploaders/Plik.cs +++ b/ShareX.UploadersLib/FileUploaders/Plik.cs @@ -82,8 +82,14 @@ public override UploadResult Upload(Stream stream, string fileName) metaDataReq.Files.File0.FileSize = Convert.ToInt32(stream.Length); metaDataReq.Removable = Settings.Removable; metaDataReq.OneShot = Settings.OneShot; - metaDataReq.Ttl = Convert.ToInt32(GetMultiplyIndex(2, Settings.TTLUnit) * Settings.TTL * 60); - + if (Settings.TTLUnit != 3) // everything except the expire time -1 + { + metaDataReq.Ttl = Convert.ToInt32(GetMultiplyIndex(2, Settings.TTLUnit) * Settings.TTL * 60); + } + else + { + metaDataReq.Ttl = -1; + } if (Settings.HasComment) { metaDataReq.Comment = Settings.Comment; @@ -111,6 +117,24 @@ private UploadResult ConvertResult(UploadMetadataResponse metaData, UploadResult return result; } + internal static void CalculateTTLValue(NumericUpDown ttlElement, int newUnit, int oldUnit) + { + if (newUnit != 3) + { + if (ttlElement.Value == -1) + { + ttlElement.Value = 1; + } + ttlElement.Value = ttlElement.Value * GetMultiplyIndex(newUnit, oldUnit); + ttlElement.ReadOnly = false; + } + else + { + ttlElement.Value = -1; + ttlElement.ReadOnly = true; + } + } + internal static decimal GetMultiplyIndex(int newUnit, int oldUnit) { decimal multiplyValue = 1m; diff --git a/ShareX.UploadersLib/FileUploaders/PlikSettings.cs b/ShareX.UploadersLib/FileUploaders/PlikSettings.cs index ccea7cfaa..04068c953 100644 --- a/ShareX.UploadersLib/FileUploaders/PlikSettings.cs +++ b/ShareX.UploadersLib/FileUploaders/PlikSettings.cs @@ -34,7 +34,7 @@ public class PlikSettings public string Password = ""; public bool Removable = false; public bool OneShot = false; - public int TTLUnit = 0; + public int TTLUnit = 2; public decimal TTL = 30; public bool HasComment = false; public string Comment = ""; diff --git a/ShareX.UploadersLib/Forms/UploadersConfigForm.Designer.cs b/ShareX.UploadersLib/Forms/UploadersConfigForm.Designer.cs index 0d4c5c842..b5fb7c78b 100644 --- a/ShareX.UploadersLib/Forms/UploadersConfigForm.Designer.cs +++ b/ShareX.UploadersLib/Forms/UploadersConfigForm.Designer.cs @@ -289,6 +289,8 @@ private void InitializeComponent() this.lblAmazonS3AccessKey = new System.Windows.Forms.Label(); this.txtAmazonS3AccessKey = new System.Windows.Forms.TextBox(); this.tpAzureStorage = new System.Windows.Forms.TabPage(); + this.cbAzureStorageEnvironment = new System.Windows.Forms.ComboBox(); + this.lblAzureStorageEnvironment = new System.Windows.Forms.Label(); this.btnAzureStoragePortal = new System.Windows.Forms.Button(); this.txtAzureStorageContainer = new System.Windows.Forms.TextBox(); this.lblAzureStorageContainer = new System.Windows.Forms.Label(); @@ -648,8 +650,6 @@ private void InitializeComponent() this.lblWidthHint = new System.Windows.Forms.Label(); this.ttlvMain = new ShareX.HelpersLib.TabToListView(); this.actRapidShareAccountType = new ShareX.UploadersLib.AccountTypeControl(); - this.lblAzureStorageEnvironment = new System.Windows.Forms.Label(); - this.cbAzureStorageEnvironment = new System.Windows.Forms.ComboBox(); this.tpOtherUploaders.SuspendLayout(); this.tcOtherUploaders.SuspendLayout(); this.tpTwitter.SuspendLayout(); @@ -2698,6 +2698,23 @@ private void InitializeComponent() this.tpAzureStorage.Name = "tpAzureStorage"; this.tpAzureStorage.UseVisualStyleBackColor = true; // + // cbAzureStorageEnvironment + // + this.cbAzureStorageEnvironment.FormattingEnabled = true; + this.cbAzureStorageEnvironment.Items.AddRange(new object[] { + resources.GetString("cbAzureStorageEnvironment.Items"), + resources.GetString("cbAzureStorageEnvironment.Items1"), + resources.GetString("cbAzureStorageEnvironment.Items2"), + resources.GetString("cbAzureStorageEnvironment.Items3")}); + resources.ApplyResources(this.cbAzureStorageEnvironment, "cbAzureStorageEnvironment"); + this.cbAzureStorageEnvironment.Name = "cbAzureStorageEnvironment"; + this.cbAzureStorageEnvironment.SelectedIndexChanged += new System.EventHandler(this.cbAzureStorageEnvironment_SelectedIndexChanged); + // + // lblAzureStorageEnvironment + // + resources.ApplyResources(this.lblAzureStorageEnvironment, "lblAzureStorageEnvironment"); + this.lblAzureStorageEnvironment.Name = "lblAzureStorageEnvironment"; + // // btnAzureStoragePortal // resources.ApplyResources(this.btnAzureStoragePortal, "btnAzureStoragePortal"); @@ -4001,6 +4018,11 @@ private void InitializeComponent() 1808227885, 5, 0}); + this.nudPlikTTL.Minimum = new decimal(new int[] { + 1, + 0, + 0, + -2147483648}); this.nudPlikTTL.Name = "nudPlikTTL"; this.nudPlikTTL.Value = new decimal(new int[] { 1, @@ -4016,7 +4038,8 @@ private void InitializeComponent() this.cbxPlikTTLUnit.Items.AddRange(new object[] { resources.GetString("cbxPlikTTLUnit.Items"), resources.GetString("cbxPlikTTLUnit.Items1"), - resources.GetString("cbxPlikTTLUnit.Items2")}); + resources.GetString("cbxPlikTTLUnit.Items2"), + resources.GetString("cbxPlikTTLUnit.Items3")}); resources.ApplyResources(this.cbxPlikTTLUnit, "cbxPlikTTLUnit"); this.cbxPlikTTLUnit.Name = "cbxPlikTTLUnit"; this.cbxPlikTTLUnit.SelectedIndexChanged += new System.EventHandler(this.cbxPlikTTLUnit_SelectedIndexChanged); @@ -5266,23 +5289,6 @@ private void InitializeComponent() this.actRapidShareAccountType.Name = "actRapidShareAccountType"; this.actRapidShareAccountType.SelectedAccountType = ShareX.UploadersLib.AccountType.Anonymous; // - // lblAzureStorageEnvironment - // - resources.ApplyResources(this.lblAzureStorageEnvironment, "lblAzureStorageEnvironment"); - this.lblAzureStorageEnvironment.Name = "lblAzureStorageEnvironment"; - // - // cbAzureStorageEnvironment - // - this.cbAzureStorageEnvironment.FormattingEnabled = true; - this.cbAzureStorageEnvironment.Items.AddRange(new object[] { - resources.GetString("cbAzureStorageEnvironment.Items"), - resources.GetString("cbAzureStorageEnvironment.Items1"), - resources.GetString("cbAzureStorageEnvironment.Items2"), - resources.GetString("cbAzureStorageEnvironment.Items3")}); - resources.ApplyResources(this.cbAzureStorageEnvironment, "cbAzureStorageEnvironment"); - this.cbAzureStorageEnvironment.Name = "cbAzureStorageEnvironment"; - this.cbAzureStorageEnvironment.SelectedIndexChanged += new System.EventHandler(this.cbAzureStorageEnvironment_SelectedIndexChanged); - // // UploadersConfigForm // resources.ApplyResources(this, "$this"); diff --git a/ShareX.UploadersLib/Forms/UploadersConfigForm.cs b/ShareX.UploadersLib/Forms/UploadersConfigForm.cs index 0f7ca2ee6..bf97334c3 100644 --- a/ShareX.UploadersLib/Forms/UploadersConfigForm.cs +++ b/ShareX.UploadersLib/Forms/UploadersConfigForm.cs @@ -2972,7 +2972,7 @@ private void cbPlikOneShot_CheckedChanged(object sender, EventArgs e) private void cbxPlikTTLUnit_SelectedIndexChanged(object sender, EventArgs e) { - nudPlikTTL.Value = nudPlikTTL.Value * Plik.GetMultiplyIndex(cbxPlikTTLUnit.SelectedIndex, Config.PlikSettings.TTLUnit); ; + Plik.CalculateTTLValue(nudPlikTTL, cbxPlikTTLUnit.SelectedIndex, Config.PlikSettings.TTLUnit); Config.PlikSettings.TTLUnit = cbxPlikTTLUnit.SelectedIndex; } diff --git a/ShareX.UploadersLib/Forms/UploadersConfigForm.resx b/ShareX.UploadersLib/Forms/UploadersConfigForm.resx index f2221d6ac..bbec67659 100644 --- a/ShareX.UploadersLib/Forms/UploadersConfigForm.resx +++ b/ShareX.UploadersLib/Forms/UploadersConfigForm.resx @@ -11497,6 +11497,9 @@ Using an encrypted library disables sharing. minutes + + never + 117, 217