diff --git a/ShareX.UploadersLib/Enums.cs b/ShareX.UploadersLib/Enums.cs index a00cedfec..a28c3d49a 100644 --- a/ShareX.UploadersLib/Enums.cs +++ b/ShareX.UploadersLib/Enums.cs @@ -145,6 +145,8 @@ public enum FileDestination Transfersh, [Description("Uplea")] Uplea, + [Description("Plik")] + Plik, SharedFolder, // Localized Email, // Localized CustomFileUploader // Localized diff --git a/ShareX.UploadersLib/Favicons/Plik.ico b/ShareX.UploadersLib/Favicons/Plik.ico new file mode 100644 index 000000000..136f52251 Binary files /dev/null and b/ShareX.UploadersLib/Favicons/Plik.ico differ diff --git a/ShareX.UploadersLib/FileUploaders/Plik.cs b/ShareX.UploadersLib/FileUploaders/Plik.cs new file mode 100644 index 000000000..eaa39c6ad --- /dev/null +++ b/ShareX.UploadersLib/FileUploaders/Plik.cs @@ -0,0 +1,229 @@ +using Newtonsoft.Json; +using ShareX.HelpersLib; +using ShareX.UploadersLib.Properties; +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Drawing; +using System.IO; +using System.Text.RegularExpressions; +using System.Windows.Forms; + +namespace ShareX.UploadersLib.FileUploaders +{ + public class PlikFileUploaderService : FileUploaderService + { + public override FileDestination EnumValue { get; } = FileDestination.Plik; + + public override GenericUploader CreateUploader(UploadersConfig config, TaskReferenceHelper taskInfo) + { + return new Plik(config.PlikURL, config.PlikAPIKey) + { + APIKey = config.PlikAPIKey, + Removable = config.PlikRemovable, + OneShot = config.PlikOneShot, + hasComment = config.PlikhasComment, + Comment = config.PlikComment, + isSecured = config.PlikIsSecured, + Login = config.PlikLogin, + Password = config.PlikPassword, + TTL = config.PlikTTL, + TTLUnit = config.PlikTTLUnit + }; + } + + public override bool CheckConfig(UploadersConfig config) + { + Regex APIrgx = new Regex(@"^([0-9A-Fa-f]{8}[-][0-9A-Fa-f]{4}[-][0-9A-Fa-f]{4}[-][0-9A-Fa-f]{4}[-][0-9A-Fa-f]{12})$"); + Regex URLrgex = new Regex(@"^http(s)?://([\w-]+.)+[\w-]+(/[\w- ./?%&=])?$"); + return URLrgex.IsMatch(config.PlikURL) && APIrgx.IsMatch(config.PlikAPIKey); + } + + public override TabPage GetUploadersConfigTabPage(UploadersConfigForm form) => form.tpPlik; + + public override Icon ServiceIcon => Resources.Plik; + } + + public sealed class Plik : FileUploader + { + public string URL { get; set; } + public string APIKey { get; set; } + public bool OneShot { get; set; } + public bool Removable { get; set; } + public bool isSecured { get; set; } + public string Login { get; set; } + public string Password { get; set; } + public bool hasComment { get; set; } + public string Comment { get; set; } + public decimal TTL { get; set; } + public int TTLUnit { get; set; } + + public Plik(string url, string apikey) + { + URL = url; + APIKey = apikey; + } + + public override UploadResult Upload(Stream stream, string fileName) + { + if (string.IsNullOrEmpty(URL)) + { + throw new Exception("Plik Host is empty."); + } + NameValueCollection requestHeaders = new NameValueCollection(); + requestHeaders["X-PlikToken"] = APIKey; + UploadMetadataRequest metaDataReq = new UploadMetadataRequest(); + metaDataReq.Files = new UploadMetadataRequestFile0(); + metaDataReq.Files.File0 = new UploadMetadataRequestFile(); + metaDataReq.Files.File0.FileName = fileName; + metaDataReq.Files.File0.FileType = Helpers.GetMimeType(fileName); + metaDataReq.Files.File0.FileSize = Convert.ToInt32(stream.Length); + metaDataReq.Removable = Removable; + metaDataReq.OneShot = OneShot; + metaDataReq.Ttl = Convert.ToInt32(GetMultiplyIndex(2, TTLUnit) * TTL * 60); + + if (hasComment) + { + metaDataReq.Comment = Comment; + } + if (isSecured) + { + metaDataReq.Login = Login; + metaDataReq.Password = Password; + } + string metaDataResp = SendRequest(HttpMethod.POST, URL + "/upload", JsonConvert.SerializeObject(metaDataReq), headers: requestHeaders); + UploadMetadataResponse metaData = JsonConvert.DeserializeObject(metaDataResp); + requestHeaders["x-uploadtoken"] = metaData.uploadToken; + string url = $"{URL}/file/{metaData.id}/{metaData.files[getMetaFileKey(metaData)].id.ToString()}/{fileName}"; + UploadResult FileDatReq = SendRequestFile(url, stream, fileName, "file", headers: requestHeaders); + + return ConvertResult(metaData, FileDatReq); + } + + private string getMetaFileKey(UploadMetadataResponse md) + { + string firstElement = ""; + foreach (var key in md.files) + { + firstElement = key.Key; + break; + } + return firstElement; + } + + private UploadResult ConvertResult(UploadMetadataResponse metaData, UploadResult fileDataReq) + { + UploadResult result = new UploadResult(fileDataReq.Response); + UploadMetadataResponse fileData = JsonConvert.DeserializeObject(fileDataReq.Response); + UploadMetadataResponseFile actFile = metaData.files[getMetaFileKey(metaData)]; + result.URL = $"{URL}/file/{metaData.id}/{actFile.id.ToString()}/{actFile.fileName}"; + return result; + } + + internal static decimal GetMultiplyIndex(int newUnit, int oldUnit) + { + decimal multiplyValue = 1m; + switch (newUnit) + { + case 0: // days + switch (oldUnit) + { + case 1: // hours + multiplyValue = 1m / 24m; + break; + case 2: // minutes + multiplyValue = 1m / 24m / 60m; + break; + } + break; + case 1: // hours + switch (oldUnit) + { + case 0: // days + multiplyValue = 24m; + break; + case 2: // minutes + multiplyValue = 1m / 60m; + break; + } + break; + case 2: // minutes + switch (oldUnit) + { + case 0: // days + multiplyValue = 60m * 24m; + break; + case 1: // hours + multiplyValue = 60m; + break; + } + break; + } + return multiplyValue; + } + } + + public class UploadMetadataRequestFile + { + [JsonProperty("fileName")] + public string FileName { get; set; } + [JsonProperty("fileType")] + public string FileType { get; set; } + [JsonProperty("fileSize")] + public int FileSize { get; set; } + } + + public class UploadMetadataRequestFile0 + { + [JsonProperty("0")] + public UploadMetadataRequestFile File0 { get; set; } + } + + public class UploadMetadataRequest + { + [JsonProperty("ttl")] + public int Ttl { get; set; } + [JsonProperty("removable")] + public bool Removable { get; set; } + [JsonProperty("oneShot")] + public bool OneShot { get; set; } + [JsonProperty("comments")] + public string Comment { get; set; } + [JsonProperty("login")] + public string Login { get; set; } + [JsonProperty("password")] + public string Password { get; set; } + [JsonProperty("files")] + public UploadMetadataRequestFile0 Files { get; set; } + } + + public class UploadMetadataResponseFile + { + public string id { get; set; } + public string fileName { get; set; } + public string fileMd5 { get; set; } + public string status { get; set; } + public string fileType { get; set; } + public int fileUploadDate { get; set; } + public int fileSize { get; set; } + public string reference { get; set; } + } + + public class UploadMetadataResponse + { + public string id { get; set; } + public int uploadDate { get; set; } + public int ttl { get; set; } + public string shortUrl { get; set; } + public string downloadDomain { get; set; } + public string comments { get; set; } + public Dictionary files { get; set; } + public string uploadToken { get; set; } + public bool admin { get; set; } + public bool stream { get; set; } + public bool oneShot { get; set; } + public bool removable { get; set; } + public bool protectedByPassword { get; set; } + public bool protectedByYubikey { get; set; } + } +} \ No newline at end of file diff --git a/ShareX.UploadersLib/Forms/UploadersConfigForm.Designer.cs b/ShareX.UploadersLib/Forms/UploadersConfigForm.Designer.cs index 6c89984fb..0583b68a0 100644 --- a/ShareX.UploadersLib/Forms/UploadersConfigForm.Designer.cs +++ b/ShareX.UploadersLib/Forms/UploadersConfigForm.Designer.cs @@ -424,6 +424,25 @@ private void InitializeComponent() this.nudEmailSmtpPort = new System.Windows.Forms.NumericUpDown(); this.lblEmailSmtpPort = new System.Windows.Forms.Label(); this.txtEmailDefaultSubject = new System.Windows.Forms.TextBox(); + this.tpPlik = new System.Windows.Forms.TabPage(); + this.gpPlikSettings = new System.Windows.Forms.GroupBox(); + this.cbPlikOneShot = new System.Windows.Forms.CheckBox(); + this.txtPlikComment = new System.Windows.Forms.TextBox(); + this.cbPlikComment = new System.Windows.Forms.CheckBox(); + this.cbPlikRemovable = new System.Windows.Forms.CheckBox(); + this.gpPlikLoginCredentials = new System.Windows.Forms.GroupBox(); + this.nudPlikTTL = new System.Windows.Forms.NumericUpDown(); + this.cbxPlikTTLUnit = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); + this.txtPlikURL = new System.Windows.Forms.TextBox(); + this.lblPlikURL = new System.Windows.Forms.Label(); + this.cbPlikIsSecured = new System.Windows.Forms.CheckBox(); + this.lblPlikAPIKey = new System.Windows.Forms.Label(); + this.txtPlikAPIKey = new System.Windows.Forms.TextBox(); + this.lblPlikPassword = new System.Windows.Forms.Label(); + this.lblPlikUsername = new System.Windows.Forms.Label(); + this.txtPlikPassword = new System.Windows.Forms.TextBox(); + this.txtPlikLogin = new System.Windows.Forms.TextBox(); this.btnCopyShowFiles = new System.Windows.Forms.Button(); this.tpTextUploaders = new System.Windows.Forms.TabPage(); this.tcTextUploaders = new System.Windows.Forms.TabControl(); @@ -632,6 +651,10 @@ private void InitializeComponent() this.tpSharedFolder.SuspendLayout(); this.tpEmail.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudEmailSmtpPort)).BeginInit(); + this.tpPlik.SuspendLayout(); + this.gpPlikSettings.SuspendLayout(); + this.gpPlikLoginCredentials.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nudPlikTTL)).BeginInit(); this.tpTextUploaders.SuspendLayout(); this.tcTextUploaders.SuspendLayout(); this.tpPastebin.SuspendLayout(); @@ -1672,6 +1695,7 @@ private void InitializeComponent() this.tcFileUploaders.Controls.Add(this.tpUplea); this.tcFileUploaders.Controls.Add(this.tpSharedFolder); this.tcFileUploaders.Controls.Add(this.tpEmail); + this.tcFileUploaders.Controls.Add(this.tpPlik); resources.ApplyResources(this.tcFileUploaders, "tcFileUploaders"); this.tcFileUploaders.Multiline = true; this.tcFileUploaders.Name = "tcFileUploaders"; @@ -3516,6 +3540,155 @@ private void InitializeComponent() this.txtEmailDefaultSubject.Name = "txtEmailDefaultSubject"; this.txtEmailDefaultSubject.TextChanged += new System.EventHandler(this.txtDefaultSubject_TextChanged); // + // tpPlik + // + this.tpPlik.Controls.Add(this.gpPlikSettings); + this.tpPlik.Controls.Add(this.gpPlikLoginCredentials); + resources.ApplyResources(this.tpPlik, "tpPlik"); + this.tpPlik.Name = "tpPlik"; + this.tpPlik.UseVisualStyleBackColor = true; + // + // gpPlikSettings + // + this.gpPlikSettings.Controls.Add(this.cbPlikOneShot); + this.gpPlikSettings.Controls.Add(this.txtPlikComment); + this.gpPlikSettings.Controls.Add(this.cbPlikComment); + this.gpPlikSettings.Controls.Add(this.cbPlikRemovable); + resources.ApplyResources(this.gpPlikSettings, "gpPlikSettings"); + this.gpPlikSettings.Name = "gpPlikSettings"; + this.gpPlikSettings.TabStop = false; + // + // cbPlikOneShot + // + resources.ApplyResources(this.cbPlikOneShot, "cbPlikOneShot"); + this.cbPlikOneShot.Name = "cbPlikOneShot"; + this.cbPlikOneShot.UseVisualStyleBackColor = true; + this.cbPlikOneShot.CheckedChanged += new System.EventHandler(this.cbPlikOneShot_CheckedChanged); + // + // txtPlikComment + // + resources.ApplyResources(this.txtPlikComment, "txtPlikComment"); + this.txtPlikComment.Name = "txtPlikComment"; + this.txtPlikComment.ReadOnly = true; + this.txtPlikComment.TextChanged += new System.EventHandler(this.txtPlikComment_TextChanged); + // + // cbPlikComment + // + resources.ApplyResources(this.cbPlikComment, "cbPlikComment"); + this.cbPlikComment.Name = "cbPlikComment"; + this.cbPlikComment.UseVisualStyleBackColor = true; + this.cbPlikComment.CheckedChanged += new System.EventHandler(this.cbPlikComment_CheckedChanged); + // + // cbPlikRemovable + // + resources.ApplyResources(this.cbPlikRemovable, "cbPlikRemovable"); + this.cbPlikRemovable.Name = "cbPlikRemovable"; + this.cbPlikRemovable.UseVisualStyleBackColor = true; + this.cbPlikRemovable.CheckedChanged += new System.EventHandler(this.cbPlikRemovable_CheckedChanged); + // + // gpPlikLoginCredentials + // + this.gpPlikLoginCredentials.Controls.Add(this.nudPlikTTL); + this.gpPlikLoginCredentials.Controls.Add(this.cbxPlikTTLUnit); + this.gpPlikLoginCredentials.Controls.Add(this.label1); + this.gpPlikLoginCredentials.Controls.Add(this.txtPlikURL); + this.gpPlikLoginCredentials.Controls.Add(this.lblPlikURL); + this.gpPlikLoginCredentials.Controls.Add(this.cbPlikIsSecured); + this.gpPlikLoginCredentials.Controls.Add(this.lblPlikAPIKey); + this.gpPlikLoginCredentials.Controls.Add(this.txtPlikAPIKey); + this.gpPlikLoginCredentials.Controls.Add(this.lblPlikPassword); + this.gpPlikLoginCredentials.Controls.Add(this.lblPlikUsername); + this.gpPlikLoginCredentials.Controls.Add(this.txtPlikPassword); + this.gpPlikLoginCredentials.Controls.Add(this.txtPlikLogin); + resources.ApplyResources(this.gpPlikLoginCredentials, "gpPlikLoginCredentials"); + this.gpPlikLoginCredentials.Name = "gpPlikLoginCredentials"; + this.gpPlikLoginCredentials.TabStop = false; + // + // nudPlikTTL + // + this.nudPlikTTL.DecimalPlaces = 2; + resources.ApplyResources(this.nudPlikTTL, "nudPlikTTL"); + this.nudPlikTTL.Maximum = new decimal(new int[] { + 1661992960, + 1808227885, + 5, + 0}); + this.nudPlikTTL.Name = "nudPlikTTL"; + this.nudPlikTTL.Value = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.nudPlikTTL.ValueChanged += new System.EventHandler(this.nudPlikTTL_ValueChanged); + // + // cbxPlikTTLUnit + // + this.cbxPlikTTLUnit.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cbxPlikTTLUnit.FormattingEnabled = true; + this.cbxPlikTTLUnit.Items.AddRange(new object[] { + resources.GetString("cbxPlikTTLUnit.Items"), + resources.GetString("cbxPlikTTLUnit.Items1"), + resources.GetString("cbxPlikTTLUnit.Items2")}); + resources.ApplyResources(this.cbxPlikTTLUnit, "cbxPlikTTLUnit"); + this.cbxPlikTTLUnit.Name = "cbxPlikTTLUnit"; + this.cbxPlikTTLUnit.SelectedIndexChanged += new System.EventHandler(this.cbxPlikTTLUnit_SelectedIndexChanged); + // + // label1 + // + resources.ApplyResources(this.label1, "label1"); + this.label1.Name = "label1"; + // + // txtPlikURL + // + resources.ApplyResources(this.txtPlikURL, "txtPlikURL"); + this.txtPlikURL.Name = "txtPlikURL"; + this.txtPlikURL.TextChanged += new System.EventHandler(this.txtPlikURL_TextChanged); + // + // lblPlikURL + // + resources.ApplyResources(this.lblPlikURL, "lblPlikURL"); + this.lblPlikURL.Name = "lblPlikURL"; + // + // cbPlikIsSecured + // + resources.ApplyResources(this.cbPlikIsSecured, "cbPlikIsSecured"); + this.cbPlikIsSecured.Name = "cbPlikIsSecured"; + this.cbPlikIsSecured.UseVisualStyleBackColor = true; + this.cbPlikIsSecured.CheckedChanged += new System.EventHandler(this.cbPlikIsSecured_CheckedChanged); + // + // lblPlikAPIKey + // + resources.ApplyResources(this.lblPlikAPIKey, "lblPlikAPIKey"); + this.lblPlikAPIKey.Name = "lblPlikAPIKey"; + // + // txtPlikAPIKey + // + resources.ApplyResources(this.txtPlikAPIKey, "txtPlikAPIKey"); + this.txtPlikAPIKey.Name = "txtPlikAPIKey"; + this.txtPlikAPIKey.TextChanged += new System.EventHandler(this.txtPlikAPIKey_TextChanged); + // + // lblPlikPassword + // + resources.ApplyResources(this.lblPlikPassword, "lblPlikPassword"); + this.lblPlikPassword.Name = "lblPlikPassword"; + // + // lblPlikUsername + // + resources.ApplyResources(this.lblPlikUsername, "lblPlikUsername"); + this.lblPlikUsername.Name = "lblPlikUsername"; + // + // txtPlikPassword + // + resources.ApplyResources(this.txtPlikPassword, "txtPlikPassword"); + this.txtPlikPassword.Name = "txtPlikPassword"; + this.txtPlikPassword.TextChanged += new System.EventHandler(this.txtPlikPassword_TextChanged); + // + // txtPlikLogin + // + resources.ApplyResources(this.txtPlikLogin, "txtPlikLogin"); + this.txtPlikLogin.Name = "txtPlikLogin"; + this.txtPlikLogin.TextChanged += new System.EventHandler(this.txtPlikLogin_TextChanged); + // // btnCopyShowFiles // resources.ApplyResources(this.btnCopyShowFiles, "btnCopyShowFiles"); @@ -4719,6 +4892,12 @@ private void InitializeComponent() this.tpEmail.ResumeLayout(false); this.tpEmail.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudEmailSmtpPort)).EndInit(); + this.tpPlik.ResumeLayout(false); + this.gpPlikSettings.ResumeLayout(false); + this.gpPlikSettings.PerformLayout(); + this.gpPlikLoginCredentials.ResumeLayout(false); + this.gpPlikLoginCredentials.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nudPlikTTL)).EndInit(); this.tpTextUploaders.ResumeLayout(false); this.tcTextUploaders.ResumeLayout(false); this.tpPastebin.ResumeLayout(false); @@ -5308,5 +5487,24 @@ private void InitializeComponent() private System.Windows.Forms.TextBox txtAzureStorageContainer; private System.Windows.Forms.Label lblAzureStorageContainer; private System.Windows.Forms.Button btnAzureStoragePortal; + internal System.Windows.Forms.TabPage tpPlik; + private System.Windows.Forms.GroupBox gpPlikSettings; + private System.Windows.Forms.TextBox txtPlikComment; + private System.Windows.Forms.CheckBox cbPlikComment; + private System.Windows.Forms.CheckBox cbPlikRemovable; + private System.Windows.Forms.GroupBox gpPlikLoginCredentials; + private System.Windows.Forms.CheckBox cbPlikIsSecured; + private System.Windows.Forms.Label lblPlikAPIKey; + private System.Windows.Forms.TextBox txtPlikAPIKey; + private System.Windows.Forms.Label lblPlikPassword; + private System.Windows.Forms.Label lblPlikUsername; + private System.Windows.Forms.TextBox txtPlikPassword; + private System.Windows.Forms.TextBox txtPlikLogin; + private System.Windows.Forms.Label lblPlikURL; + private System.Windows.Forms.TextBox txtPlikURL; + private System.Windows.Forms.CheckBox cbPlikOneShot; + private System.Windows.Forms.ComboBox cbxPlikTTLUnit; + private System.Windows.Forms.NumericUpDown nudPlikTTL; + private System.Windows.Forms.Label label1; } } diff --git a/ShareX.UploadersLib/Forms/UploadersConfigForm.cs b/ShareX.UploadersLib/Forms/UploadersConfigForm.cs index 6597665d2..d95e2ec4c 100644 --- a/ShareX.UploadersLib/Forms/UploadersConfigForm.cs +++ b/ShareX.UploadersLib/Forms/UploadersConfigForm.cs @@ -595,6 +595,22 @@ public void LoadSettings() txtAzureStorageAccessKey.Text = Config.AzureStorageAccountAccessKey; txtAzureStorageContainer.Text = Config.AzureStorageContainer; + // Plik + txtPlikAPIKey.Text = Config.PlikAPIKey; + txtPlikURL.Text = Config.PlikURL; + txtPlikPassword.Text = Config.PlikPassword; + txtPlikLogin.Text = Config.PlikLogin; + txtPlikComment.Text = Config.PlikComment; + cbPlikComment.Checked = Config.PlikhasComment; + cbPlikIsSecured.Checked = Config.PlikIsSecured; + cbPlikRemovable.Checked = Config.PlikRemovable; + cbPlikOneShot.Checked = Config.PlikOneShot; + nudPlikTTL.Value = Config.PlikTTL; + cbxPlikTTLUnit.SelectedIndex = Config.PlikTTLUnit; + txtPlikComment.ReadOnly = !cbPlikComment.Checked; + txtPlikLogin.ReadOnly = !cbPlikIsSecured.Checked; + txtPlikPassword.ReadOnly = !cbPlikIsSecured.Checked; + #endregion File uploaders #region URL shorteners @@ -2632,6 +2648,69 @@ private void btnAzureStoragePortal_Click(object sender, EventArgs e) #endregion Azure Storage + #region Plik + + private void txtPlikURL_TextChanged(object sender, EventArgs e) + { + Config.PlikURL = txtPlikURL.Text; + } + + private void txtPlikAPIKey_TextChanged(object sender, EventArgs e) + { + Config.PlikAPIKey = txtPlikAPIKey.Text; + } + + private void txtPlikLogin_TextChanged(object sender, EventArgs e) + { + Config.PlikLogin = txtPlikLogin.Text; + } + + private void txtPlikPassword_TextChanged(object sender, EventArgs e) + { + Config.PlikPassword = txtPlikPassword.Text; + } + + private void cbPlikIsSecured_CheckedChanged(object sender, EventArgs e) + { + Config.PlikIsSecured = cbPlikIsSecured.Checked; + txtPlikLogin.ReadOnly = !cbPlikIsSecured.Checked; + txtPlikPassword.ReadOnly = !cbPlikIsSecured.Checked; + } + + private void cbPlikRemovable_CheckedChanged(object sender, EventArgs e) + { + Config.PlikRemovable = cbPlikRemovable.Checked; + } + + private void cbPlikComment_CheckedChanged(object sender, EventArgs e) + { + Config.PlikhasComment = cbPlikComment.Checked; + txtPlikComment.ReadOnly = !cbPlikComment.Checked; + } + + private void txtPlikComment_TextChanged(object sender, EventArgs e) + { + Config.PlikComment = txtPlikComment.Text; + } + + private void cbPlikOneShot_CheckedChanged(object sender, EventArgs e) + { + Config.PlikOneShot = cbPlikOneShot.Checked; + } + + private void cbxPlikTTLUnit_SelectedIndexChanged(object sender, EventArgs e) + { + nudPlikTTL.Value = nudPlikTTL.Value * Plik.GetMultiplyIndex(cbxPlikTTLUnit.SelectedIndex, Config.PlikTTLUnit); ; + Config.PlikTTLUnit = cbxPlikTTLUnit.SelectedIndex; + } + + private void nudPlikTTL_ValueChanged(object sender, EventArgs e) + { + Config.PlikTTL = nudPlikTTL.Value; + } + + #endregion Plik + #endregion File Uploaders #region URL Shorteners diff --git a/ShareX.UploadersLib/Forms/UploadersConfigForm.resx b/ShareX.UploadersLib/Forms/UploadersConfigForm.resx index dd6e08c3c..bf1bec9a0 100644 --- a/ShareX.UploadersLib/Forms/UploadersConfigForm.resx +++ b/ShareX.UploadersLib/Forms/UploadersConfigForm.resx @@ -10588,6 +10588,513 @@ Using an encrypted library disables sharing. 25 + + True + + + NoControl + + + 6, 34 + + + 176, 17 + + + 3 + + + Destruct after the first download + + + cbPlikOneShot + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gpPlikSettings + + + 0 + + + 6, 74 + + + True + + + 332, 164 + + + 2 + + + txtPlikComment + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gpPlikSettings + + + 1 + + + True + + + NoControl + + + 6, 54 + + + 129, 17 + + + 1 + + + Comment (Markdown) + + + cbPlikComment + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gpPlikSettings + + + 2 + + + True + + + NoControl + + + 6, 15 + + + 80, 17 + + + 0 + + + Removable + + + cbPlikRemovable + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gpPlikSettings + + + 3 + + + 292, 19 + + + 344, 247 + + + 14 + + + Other settings + + + gpPlikSettings + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tpPlik + + + 0 + + + 9, 217 + + + 102, 20 + + + 28 + + + nudPlikTTL + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gpPlikLoginCredentials + + + 0 + + + days + + + hours + + + minutes + + + 117, 217 + + + 147, 21 + + + 15 + + + cbxPlikTTLUnit + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gpPlikLoginCredentials + + + 1 + + + True + + + NoControl + + + 7, 202 + + + 182, 13 + + + 17 + + + Files will be automatically removed in + + + label1 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gpPlikLoginCredentials + + + 2 + + + 9, 31 + + + 255, 20 + + + 15 + + + txtPlikURL + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gpPlikLoginCredentials + + + 3 + + + True + + + NoControl + + + 8, 15 + + + 29, 13 + + + 16 + + + Host + + + lblPlikURL + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gpPlikLoginCredentials + + + 4 + + + True + + + NoControl + + + 9, 100 + + + 190, 17 + + + 13 + + + Username and password required? + + + cbPlikIsSecured + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gpPlikLoginCredentials + + + 5 + + + True + + + NoControl + + + 6, 58 + + + 51, 13 + + + 12 + + + API Key: + + + lblPlikAPIKey + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gpPlikLoginCredentials + + + 6 + + + 9, 74 + + + 255, 20 + + + 11 + + + txtPlikAPIKey + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gpPlikLoginCredentials + + + 7 + + + True + + + NoControl + + + 8, 159 + + + 56, 13 + + + 10 + + + Password: + + + lblPlikPassword + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gpPlikLoginCredentials + + + 8 + + + True + + + NoControl + + + 6, 120 + + + 58, 13 + + + 9 + + + Username: + + + lblPlikUsername + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gpPlikLoginCredentials + + + 9 + + + 9, 175 + + + * + + + 255, 20 + + + 8 + + + txtPlikPassword + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gpPlikLoginCredentials + + + 10 + + + 9, 136 + + + 255, 20 + + + 7 + + + txtPlikLogin + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gpPlikLoginCredentials + + + 11 + + + 15, 19 + + + 271, 247 + + + 13 + + + Login Credentials + + + gpPlikLoginCredentials + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tpPlik + + + 1 + + + 4, 40 + + + 3, 3, 3, 3 + + + 972, 475 + + + 29 + + + Plik + + + tpPlik + + + System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tcFileUploaders + + + 26 + Fill diff --git a/ShareX.UploadersLib/Properties/Resources.resx b/ShareX.UploadersLib/Properties/Resources.resx index 4d0a2c4b0..2caf27c14 100644 --- a/ShareX.UploadersLib/Properties/Resources.resx +++ b/ShareX.UploadersLib/Properties/Resources.resx @@ -401,4 +401,7 @@ Created folders: ..\Favicons\AzureStorage.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Favicons\Plik.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/ShareX.UploadersLib/ShareX.UploadersLib.csproj b/ShareX.UploadersLib/ShareX.UploadersLib.csproj index 1fdd08cc9..985029061 100644 --- a/ShareX.UploadersLib/ShareX.UploadersLib.csproj +++ b/ShareX.UploadersLib/ShareX.UploadersLib.csproj @@ -128,6 +128,7 @@ + diff --git a/ShareX.UploadersLib/UploadersConfig.cs b/ShareX.UploadersLib/UploadersConfig.cs index 81c88529b..9c9a435a1 100644 --- a/ShareX.UploadersLib/UploadersConfig.cs +++ b/ShareX.UploadersLib/UploadersConfig.cs @@ -304,6 +304,20 @@ public class UploadersConfig : SettingsBase public string AzureStorageAccountAccessKey = ""; public string AzureStorageContainer = ""; + // Plik + + public string PlikURL = ""; + public string PlikAPIKey = ""; + public bool PlikIsSecured = false; + public string PlikLogin = ""; + public string PlikPassword = ""; + public bool PlikRemovable = false; + public bool PlikOneShot = false; + public int PlikTTLUnit = 0; + public decimal PlikTTL = 30; + public string PlikComment = ""; + public bool PlikhasComment = false; + #endregion File uploaders #region URL shorteners