Added expiration support to Teknik file and text uploaders

This commit is contained in:
Jaex 2019-03-12 09:31:29 +03:00
parent 777502396f
commit 087b9044ec
6 changed files with 8201 additions and 2026 deletions

View file

@ -62,13 +62,13 @@ public override GenericUploader CreateUploader(UploadersConfig config, TaskRefer
public enum TeknikExpirationUnit
{
Never = 0,
Views = 1,
Minutes = 10,
Hours = 11,
Days = 12,
Months = 13,
Years = 14
Never,
Views,
Minutes,
Hours,
Days,
Months,
Years
}
public class Teknik : Uploader, IOAuth2Basic

View file

@ -631,6 +631,9 @@ private void InitializeComponent()
this.lblWidthHint = new System.Windows.Forms.Label();
this.ttlvMain = new ShareX.HelpersLib.TabToListView();
this.actRapidShareAccountType = new ShareX.UploadersLib.AccountTypeControl();
this.lblTeknikExpiration = new System.Windows.Forms.Label();
this.cbTeknikExpirationUnit = new System.Windows.Forms.ComboBox();
this.nudTeknikExpirationLength = new System.Windows.Forms.NumericUpDown();
this.tpOtherUploaders.SuspendLayout();
this.tcOtherUploaders.SuspendLayout();
this.tpTwitter.SuspendLayout();
@ -714,6 +717,7 @@ private void InitializeComponent()
this.tpChevereto.SuspendLayout();
this.tpVgyme.SuspendLayout();
this.tcUploaders.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nudTeknikExpirationLength)).BeginInit();
this.SuspendLayout();
//
// txtRapidSharePremiumUserName
@ -3002,6 +3006,9 @@ private void InitializeComponent()
// tpTeknik
//
this.tpTeknik.BackColor = System.Drawing.SystemColors.Window;
this.tpTeknik.Controls.Add(this.nudTeknikExpirationLength);
this.tpTeknik.Controls.Add(this.cbTeknikExpirationUnit);
this.tpTeknik.Controls.Add(this.lblTeknikExpiration);
this.tpTeknik.Controls.Add(this.lblTeknikUrlShortenerAPIUrl);
this.tpTeknik.Controls.Add(this.tbTeknikUrlShortenerAPIUrl);
this.tpTeknik.Controls.Add(this.lblTeknikPasteAPIUrl);
@ -4934,6 +4941,30 @@ private void InitializeComponent()
this.actRapidShareAccountType.Name = "actRapidShareAccountType";
this.actRapidShareAccountType.SelectedAccountType = ShareX.UploadersLib.AccountType.Anonymous;
//
// lblTeknikExpiration
//
resources.ApplyResources(this.lblTeknikExpiration, "lblTeknikExpiration");
this.lblTeknikExpiration.Name = "lblTeknikExpiration";
//
// cbTeknikExpirationUnit
//
this.cbTeknikExpirationUnit.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbTeknikExpirationUnit.FormattingEnabled = true;
resources.ApplyResources(this.cbTeknikExpirationUnit, "cbTeknikExpirationUnit");
this.cbTeknikExpirationUnit.Name = "cbTeknikExpirationUnit";
this.cbTeknikExpirationUnit.SelectedIndexChanged += new System.EventHandler(this.cbTeknikExpirationUnit_SelectedIndexChanged);
//
// nudTeknikExpirationLength
//
resources.ApplyResources(this.nudTeknikExpirationLength, "nudTeknikExpirationLength");
this.nudTeknikExpirationLength.Maximum = new decimal(new int[] {
10000,
0,
0,
0});
this.nudTeknikExpirationLength.Name = "nudTeknikExpirationLength";
this.nudTeknikExpirationLength.ValueChanged += new System.EventHandler(this.nudTeknikExpirationLength_ValueChanged);
//
// UploadersConfigForm
//
resources.ApplyResources(this, "$this");
@ -5096,6 +5127,7 @@ private void InitializeComponent()
this.tpVgyme.ResumeLayout(false);
this.tpVgyme.PerformLayout();
this.tcUploaders.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.nudTeknikExpirationLength)).EndInit();
this.ResumeLayout(false);
}
@ -5679,5 +5711,8 @@ private void InitializeComponent()
private System.Windows.Forms.TextBox tbTeknikPasteAPIUrl;
private System.Windows.Forms.Label lblTeknikUrlShortenerAPIUrl;
private System.Windows.Forms.TextBox tbTeknikUrlShortenerAPIUrl;
private System.Windows.Forms.Label lblTeknikExpiration;
private System.Windows.Forms.ComboBox cbTeknikExpirationUnit;
private System.Windows.Forms.NumericUpDown nudTeknikExpirationLength;
}
}

View file

@ -627,6 +627,10 @@ private void LoadFileUploaderSettings()
tbTeknikAuthUrl.Text = Config.TeknikAuthUrl;
cbTeknikEncrypt.Checked = Config.TeknikEncryption;
cbTeknikGenDeleteKey.Checked = Config.TeknikGenerateDeletionKey;
cbTeknikExpirationUnit.Items.AddRange(Enum.GetNames(typeof(TeknikExpirationUnit)));
cbTeknikExpirationUnit.SelectedIndex = (int)Config.TeknikExpirationUnit;
nudTeknikExpirationLength.SetValue(Config.TeknikExpirationLength);
nudTeknikExpirationLength.Visible = Config.TeknikExpirationUnit != TeknikExpirationUnit.Never;
#endregion Teknik
@ -2522,6 +2526,11 @@ private void oauthTeknik_ClearButtonClicked()
Config.TeknikOAuth2Info = null;
}
private void tbTeknikAuthUrl_TextChanged(object sender, EventArgs e)
{
Config.TeknikAuthUrl = tbTeknikAuthUrl.Text;
}
private void tbTeknikUploadAPIUrl_TextChanged(object sender, EventArgs e)
{
Config.TeknikUploadAPIUrl = tbTeknikUploadAPIUrl.Text;
@ -2537,11 +2546,6 @@ private void tbTeknikUrlShortenerAPIUrl_TextChanged(object sender, EventArgs e)
Config.TeknikUrlShortenerAPIUrl = tbTeknikUrlShortenerAPIUrl.Text;
}
private void tbTeknikAuthUrl_TextChanged(object sender, EventArgs e)
{
Config.TeknikAuthUrl = tbTeknikAuthUrl.Text;
}
private void cbTeknikEncrypt_CheckedChanged(object sender, EventArgs e)
{
Config.TeknikEncryption = cbTeknikEncrypt.Checked;
@ -2552,7 +2556,18 @@ private void cbTeknikGenDeleteKey_CheckedChanged(object sender, EventArgs e)
Config.TeknikGenerateDeletionKey = cbTeknikGenDeleteKey.Checked;
}
#endregion
private void cbTeknikExpirationUnit_SelectedIndexChanged(object sender, EventArgs e)
{
Config.TeknikExpirationUnit = (TeknikExpirationUnit)cbTeknikExpirationUnit.SelectedIndex;
nudTeknikExpirationLength.Visible = Config.TeknikExpirationUnit != TeknikExpirationUnit.Never;
}
private void nudTeknikExpirationLength_ValueChanged(object sender, EventArgs e)
{
Config.TeknikExpirationLength = (int)nudTeknikExpirationLength.Value;
}
#endregion Teknik
#region Pomf

File diff suppressed because it is too large Load diff

View file

@ -47,7 +47,9 @@ public override GenericUploader CreateUploader(UploadersConfig config, TaskRefer
{
return new TeknikPaster(config.TeknikOAuth2Info, config.TeknikAuthUrl)
{
APIUrl = config.TeknikPasteAPIUrl
APIUrl = config.TeknikPasteAPIUrl,
ExpirationUnit = config.TeknikExpirationUnit,
ExpirationLength = config.TeknikExpirationLength
};
}
@ -58,6 +60,8 @@ public sealed class TeknikPaster : TextUploader, IOAuth2Basic
{
public OAuth2Info AuthInfo { get; set; }
public string APIUrl { get; set; }
public TeknikExpirationUnit ExpirationUnit { get; set; }
public int ExpirationLength { get; set; }
private Teknik teknik;
@ -81,6 +85,8 @@ public override UploadResult UploadText(string text, string fileName)
{
Dictionary<string, string> args = new Dictionary<string, string>();
args.Add("code", text);
args.Add("expirationUnit", ExpirationUnit.ToString());
args.Add("expirationLength", ExpirationLength.ToString());
string response = SendRequestMultiPart(APIUrl, args, teknik.GetAuthHeaders());
TeknikPasteResponseWrapper apiResponse = JsonConvert.DeserializeObject<TeknikPasteResponseWrapper>(response);

View file

@ -334,17 +334,16 @@ public class UploadersConfig : SettingsBase<UploadersConfig>
#region Teknik
public OAuth2Info TeknikOAuth2Info = null;
public string TeknikUploadAPIUrl = Teknik.DefaultUploadAPIURL;
public string TeknikPasteAPIUrl = Teknik.DefaultPasteAPIURL;
public string TeknikUrlShortenerAPIUrl = Teknik.DefaultUrlShortenerAPIURL;
public string TeknikAuthUrl = Teknik.DefaultAuthURL;
public int TeknikExpirationLength = 1;
public TeknikExpirationUnit TeknikExpirationUnit = TeknikExpirationUnit.Never;
public int TeknikExpirationLength = 1;
public bool TeknikEncryption = false;
public bool TeknikGenerateDeletionKey = false;
#endregion
#endregion Teknik
#region Pomf