Merge pull request #1061 from zikeji/master

Added Seafile Support
This commit is contained in:
Jaex 2015-10-13 08:28:38 +03:00
commit 668519bb62
11 changed files with 2810 additions and 117 deletions

View file

@ -129,6 +129,8 @@ public enum FileDestination
Dropfile,
[Description("Up1")]
Up1,
[Description("Seafile")]
Seafile,
SharedFolder, // Localized
Email, // Localized
CustomFileUploader // Localized

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View file

@ -0,0 +1,581 @@
#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)
// Credits: https://github.com/zikeji
using Newtonsoft.Json;
using ShareX.HelpersLib;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Net;
using System.Net.Cache;
using System.Text;
namespace ShareX.UploadersLib.FileUploaders
{
public sealed class Seafile : FileUploader
{
public string APIURL { get; set; }
public string AuthToken { get; set; }
public string RepoID { get; set; }
public string Path { get; set; }
public bool IsLibraryEncrypted { get; set; }
public string EncryptedLibraryPassword { get; set; }
public int ShareDaysToExpire { get; set; }
public string SharePassword { get; set; }
public bool CreateShareableURL { get; set; }
public bool IgnoreInvalidCert { get; set; }
public Seafile(string apiurl, string authtoken, string repoid)
{
APIURL = apiurl;
AuthToken = authtoken;
RepoID = repoid;
}
#region SeafileAuth
public string GetAuthToken(string username, string password)
{
string url = URLHelpers.FixPrefix(APIURL);
url = URLHelpers.CombineURL(APIURL, "auth-token/?format=json");
Dictionary<string, string> args = new Dictionary<string, string>
{
{ "username", username },
{ "password", password }
};
string response = SendRequest(HttpMethod.POST, url, args);
if (!string.IsNullOrEmpty(response))
{
SeafileAuthResponse AuthResult = JsonConvert.DeserializeObject<SeafileAuthResponse>(response);
return AuthResult.token;
}
return string.Empty;
}
public class SeafileAuthResponse
{
public string token { get; set; }
}
#endregion SeafileAuth
#region SeafileChecks
public bool CheckAPIURL()
{
string url = URLHelpers.FixPrefix(APIURL);
url = URLHelpers.CombineURL(APIURL, "ping/?format=json");
SSLBypassHelper sslBypassHelper = null;
try
{
if (IgnoreInvalidCert)
{
sslBypassHelper = new SSLBypassHelper();
}
string response = SendRequest(HttpMethod.GET, url);
if (!string.IsNullOrEmpty(response))
{
if (response == "\"pong\"")
{
return true;
}
}
return false;
}
finally
{
if (sslBypassHelper != null)
{
sslBypassHelper.Dispose();
}
}
}
public bool CheckAuthToken()
{
string url = URLHelpers.FixPrefix(APIURL);
url = URLHelpers.CombineURL(APIURL, "auth/ping/?format=json");
NameValueCollection headers = new NameValueCollection();
headers.Add("Authorization", "Token " + AuthToken);
SSLBypassHelper sslBypassHelper = null;
try
{
if (IgnoreInvalidCert)
{
sslBypassHelper = new SSLBypassHelper();
}
string response = SendRequest(HttpMethod.GET, url, null, headers);
if (!string.IsNullOrEmpty(response))
{
if (response == "\"pong\"")
{
return true;
}
}
return false;
}
finally
{
if (sslBypassHelper != null)
{
sslBypassHelper.Dispose();
}
}
}
#endregion SeafileChecks
#region SeafileAccountInformation
public SeafileCheckAccInfoResponse GetAccountInfo()
{
string url = URLHelpers.FixPrefix(APIURL);
url = URLHelpers.CombineURL(APIURL, "account/info/?format=json");
NameValueCollection headers = new NameValueCollection();
headers.Add("Authorization", "Token " + AuthToken);
SSLBypassHelper sslBypassHelper = null;
try
{
if (IgnoreInvalidCert)
{
sslBypassHelper = new SSLBypassHelper();
}
string response = SendRequest(HttpMethod.GET, url, null, headers);
if (!string.IsNullOrEmpty(response))
{
SeafileCheckAccInfoResponse AccInfoResponse = JsonConvert.DeserializeObject<SeafileCheckAccInfoResponse>(response);
return AccInfoResponse;
}
return null;
}
finally
{
if (sslBypassHelper != null)
{
sslBypassHelper.Dispose();
}
}
}
public class SeafileCheckAccInfoResponse
{
public long usage { get; set; }
public long total { get; set; }
public string email { get; set; }
}
#endregion SeafileAccountInformation
#region SeafileLibraries
public string GetOrMakeDefaultLibrary(string authtoken = null)
{
string url = URLHelpers.FixPrefix(APIURL);
url = URLHelpers.CombineURL(APIURL, "default-repo/?format=json");
NameValueCollection headers = new NameValueCollection();
headers.Add("Authorization", "Token " + (authtoken == null ? AuthToken : authtoken));
SSLBypassHelper sslBypassHelper = null;
try
{
if (IgnoreInvalidCert)
{
sslBypassHelper = new SSLBypassHelper();
}
string response = SendRequest(HttpMethod.GET, url, null, headers);
if (!string.IsNullOrEmpty(response))
{
SeafileDefaultLibraryObj JsonResponse = JsonConvert.DeserializeObject<SeafileDefaultLibraryObj>(response);
return JsonResponse.repo_id;
}
return null;
}
finally
{
if (sslBypassHelper != null)
{
sslBypassHelper.Dispose();
}
}
}
public class SeafileDefaultLibraryObj
{
public string repo_id { get; set; }
public bool exists { get; set; }
}
public List<SeafileLibraryObj> GetLibraries()
{
string url = URLHelpers.FixPrefix(APIURL);
url = URLHelpers.CombineURL(APIURL, "repos/?format=json");
NameValueCollection headers = new NameValueCollection();
headers.Add("Authorization", "Token " + AuthToken);
SSLBypassHelper sslBypassHelper = null;
try
{
if (IgnoreInvalidCert)
{
sslBypassHelper = new SSLBypassHelper();
}
string response = SendRequest(HttpMethod.GET, url, null, headers);
if (!string.IsNullOrEmpty(response))
{
List<SeafileLibraryObj> JsonResponse = JsonConvert.DeserializeObject<List<SeafileLibraryObj>>(response);
return JsonResponse;
}
return null;
}
finally
{
if (sslBypassHelper != null)
{
sslBypassHelper.Dispose();
}
}
}
public bool ValidatePath(string path)
{
string url = URLHelpers.FixPrefix(APIURL);
url = URLHelpers.CombineURL(APIURL, "repos/" + RepoID + "/dir/?p=" + path + "&format=json");
NameValueCollection headers = new NameValueCollection();
headers.Add("Authorization", "Token " + AuthToken);
SSLBypassHelper sslBypassHelper = null;
try
{
if (IgnoreInvalidCert)
{
sslBypassHelper = new SSLBypassHelper();
}
string response = SendRequest(HttpMethod.GET, url, null, headers);
if (!string.IsNullOrEmpty(response))
{
return true;
}
return false;
}
finally
{
if (sslBypassHelper != null)
{
sslBypassHelper.Dispose();
}
}
}
public class SeafileLibraryObj
{
public string permission { get; set; }
public bool encrypted { get; set; }
public long mtime { get; set; }
public string owner { get; set; }
public string id { get; set; }
public long size { get; set; }
public string name { get; set; }
public string type { get; set; }
[JsonProperty("virtual")]
public string _virtual { get; set; }
public string desc { get; set; }
public string root { get; set; }
}
#endregion SeafileLibraries
#region SeafileEncryptedLibrary
public bool DecryptLibrary(string libraryPassword)
{
string url = URLHelpers.FixPrefix(APIURL);
url = URLHelpers.CombineURL(APIURL, "repos/" + RepoID + "/?format=json");
NameValueCollection headers = new NameValueCollection();
headers.Add("Authorization", "Token " + AuthToken);
Dictionary<string, string> args = new Dictionary<string, string>();
args.Add("password", libraryPassword);
SSLBypassHelper sslBypassHelper = null;
try
{
if (IgnoreInvalidCert)
{
sslBypassHelper = new SSLBypassHelper();
}
string response = SendRequest(HttpMethod.POST, url, args, headers);
if (!string.IsNullOrEmpty(response))
{
if (response == "\"success\"")
{
return true;
}
else
{
return false;
}
}
return false;
}
finally
{
if (sslBypassHelper != null)
{
sslBypassHelper.Dispose();
}
}
}
#endregion SeafileEncryptedLibrary
#region SeafileUpload
public override UploadResult Upload(Stream stream, string fileName)
{
if (string.IsNullOrEmpty(APIURL))
{
throw new Exception("Seafile API URL is empty.");
}
if (string.IsNullOrEmpty(AuthToken))
{
throw new Exception("Seafile Authentication Token is empty.");
}
if (string.IsNullOrEmpty(Path))
{
Path = "/";
}
else
{
char pathLast = Path[Path.Length - 1];
if (pathLast != '/')
{
Path += "/";
}
}
string url = URLHelpers.FixPrefix(APIURL);
url = URLHelpers.CombineURL(APIURL, "repos/" + RepoID + "/upload-link/?format=json");
NameValueCollection headers = new NameValueCollection();
headers.Add("Authorization", "Token " + AuthToken);
SSLBypassHelper sslBypassHelper = null;
try
{
if (IgnoreInvalidCert)
{
sslBypassHelper = new SSLBypassHelper();
}
string response = SendRequest(HttpMethod.GET, url, null, headers);
string responseURL = response.Trim('"');
Dictionary<string, string> args = new Dictionary<string, string>();
args.Add("filename", fileName);
args.Add("parent_dir", Path);
UploadResult result = UploadData(stream, responseURL, fileName, "file", args, headers);
if (!IsError)
{
if (CreateShareableURL && !IsLibraryEncrypted)
{
AllowReportProgress = false;
result.URL = ShareFile(Path + fileName, result.Response.Trim('"'));
}
else
{
result.IsURLExpected = false;
}
}
return result;
}
finally
{
if (sslBypassHelper != null)
{
sslBypassHelper.Dispose();
}
}
}
public string ShareFile(string path, string id = null)
{
string url = URLHelpers.FixPrefix(APIURL);
url = URLHelpers.CombineURL(APIURL, "repos/" + RepoID + "/file/shared-link/");
Dictionary<string, string> args = new Dictionary<string, string>();
if (!String.IsNullOrEmpty(SharePassword)) args.Add("password", SharePassword);
args.Add("p", path);
args.Add("format", "json");
args.Add("expire", ShareDaysToExpire.ToString());
NameValueCollection headers = new NameValueCollection();
headers.Add("Authorization", "Token " + AuthToken);
SSLBypassHelper sslBypassHelper = null;
try
{
if (IgnoreInvalidCert)
{
sslBypassHelper = new SSLBypassHelper();
}
//had to do this to get the ContentLength header to use for the PUT request
string boundary = new string('-', 20) + DateTime.Now.Ticks.ToString("x");
byte[] POSTDATA;
using (MemoryStream stream = new MemoryStream())
{
byte[] bytes;
if (args != null)
{
foreach (KeyValuePair<string, string> content in args)
{
if (!string.IsNullOrEmpty(content.Key) && !string.IsNullOrEmpty(content.Value))
{
string format = string.Format("--{0}\r\nContent-Disposition: form-data; name=\"{1}\"\r\n\r\n{2}\r\n", boundary, content.Key, content.Value);
bytes = Encoding.UTF8.GetBytes(format);
stream.Write(bytes, 0, bytes.Length);
}
}
bytes = Encoding.UTF8.GetBytes(string.Format("--{0}--\r\n", boundary));
stream.Write(bytes, 0, bytes.Length);
}
POSTDATA = stream.ToArray();
}
MemoryStream dataStream = new MemoryStream();
dataStream.Write(POSTDATA, 0, POSTDATA.Length);
HttpWebResponse response = null;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.ContentLength = POSTDATA.Length;
request.Accept = "application/json";
request.Method = "PUT";
request.Headers.Add(headers);
request.UserAgent = "ShareX";
string contentType = "multipart/form-data";
request.AllowWriteStreamBuffering = HelpersOptions.CurrentProxy.IsValidProxy();
request.CachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
request.ContentLength = dataStream.Length;
if (!string.IsNullOrEmpty(boundary)) contentType += "; boundary=" + boundary;
request.ContentType = contentType;
request.CookieContainer = new CookieContainer();
request.KeepAlive = true;
request.Pipelined = false;
request.ProtocolVersion = HttpVersion.Version11;
request.Proxy = HelpersOptions.CurrentProxy.GetWebProxy();
request.Timeout = -1;
using (Stream requestStream = request.GetRequestStream())
{
if (!TransferData(dataStream, requestStream))
{
}
}
response = (HttpWebResponse)request.GetResponse();
string Location = response.Headers["Location"];
response.Close();
dataStream.Close();
if (!string.IsNullOrEmpty(Location))
{
return Location;
}
return null;
}
finally
{
if (sslBypassHelper != null)
{
sslBypassHelper.Dispose();
}
}
}
#endregion SeafileUpload
}
}

View file

@ -307,6 +307,42 @@ private void InitializeComponent()
this.txtUp1Host = new System.Windows.Forms.TextBox();
this.lblUp1Key = new System.Windows.Forms.Label();
this.lblUp1Host = new System.Windows.Forms.Label();
this.tpSeafile = new System.Windows.Forms.TabPage();
this.btnSeafileLibraryPasswordValidate = new System.Windows.Forms.Button();
this.txtSeafileLibraryPassword = new System.Windows.Forms.TextBox();
this.lblSeafileLibraryPassword = new System.Windows.Forms.Label();
this.lvSeafileLibraries = new ShareX.HelpersLib.MyListView();
this.colSeafileLibraryName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.colSeafileLibrarySize = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.colSeafileLibraryEncrypted = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.btnSeafilePathValidate = new System.Windows.Forms.Button();
this.txtSeafileDirectoryPath = new System.Windows.Forms.TextBox();
this.lblSeafileWritePermNotif = new System.Windows.Forms.Label();
this.lblSeafilePath = new System.Windows.Forms.Label();
this.txtSeafileUploadLocationRefresh = new System.Windows.Forms.Button();
this.lblSeafileSelectLibrary = new System.Windows.Forms.Label();
this.grpSeafileAccInfo = new System.Windows.Forms.GroupBox();
this.myListView1 = new ShareX.HelpersLib.MyListView();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.btnRefreshSeafileAccInfo = new System.Windows.Forms.Button();
this.txtSeafileAccInfoUsage = new System.Windows.Forms.TextBox();
this.txtSeafileAccInfoEmail = new System.Windows.Forms.TextBox();
this.lblSeafileAccInfoEmail = new System.Windows.Forms.Label();
this.lblSeafileAccInfoUsage = new System.Windows.Forms.Label();
this.btnSeafileCheckAuthToken = new System.Windows.Forms.Button();
this.btnSeafileCheckAPIURL = new System.Windows.Forms.Button();
this.grpSeafileObtainAuthToken = new System.Windows.Forms.GroupBox();
this.btnSeafileGetAuthToken = new System.Windows.Forms.Button();
this.txtSeafilePassword = new System.Windows.Forms.TextBox();
this.txtSeafileUsername = new System.Windows.Forms.TextBox();
this.lblSeafileUsername = new System.Windows.Forms.Label();
this.lblSeafilePassword = new System.Windows.Forms.Label();
this.cbSeafileIgnoreInvalidCert = new System.Windows.Forms.CheckBox();
this.cbSeafileCreateShareableURL = new System.Windows.Forms.CheckBox();
this.txtSeafileAuthToken = new System.Windows.Forms.TextBox();
this.txtSeafileAPIURL = new System.Windows.Forms.TextBox();
this.lblSeafileAuthToken = new System.Windows.Forms.Label();
this.lblSeafileAPIURL = new System.Windows.Forms.Label();
this.tpEmail = new System.Windows.Forms.TabPage();
this.chkEmailConfirm = new System.Windows.Forms.CheckBox();
this.lblEmailSmtpServer = new System.Windows.Forms.Label();
@ -448,6 +484,11 @@ private void InitializeComponent()
this.lblWidthHint = new System.Windows.Forms.Label();
this.ttlvMain = new ShareX.HelpersLib.TabToListView();
this.actRapidShareAccountType = new ShareX.UploadersLib.AccountTypeControl();
this.grpSeafileShareSettings = new System.Windows.Forms.GroupBox();
this.lblSeafileDaysToExpire = new System.Windows.Forms.Label();
this.nudSeafileExpireDays = new System.Windows.Forms.NumericUpDown();
this.txtSeafileSharePassword = new System.Windows.Forms.TextBox();
this.lblSeafileSharePassword = new System.Windows.Forms.Label();
this.tpOtherUploaders.SuspendLayout();
this.tcOtherUploaders.SuspendLayout();
this.tpTwitter.SuspendLayout();
@ -489,6 +530,9 @@ private void InitializeComponent()
this.tpLambda.SuspendLayout();
this.tpPomf.SuspendLayout();
this.tpUp1.SuspendLayout();
this.tpSeafile.SuspendLayout();
this.grpSeafileAccInfo.SuspendLayout();
this.grpSeafileObtainAuthToken.SuspendLayout();
this.tpEmail.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nudEmailSmtpPort)).BeginInit();
this.tpSharedFolder.SuspendLayout();
@ -513,6 +557,8 @@ private void InitializeComponent()
this.tpPicasa.SuspendLayout();
this.tpChevereto.SuspendLayout();
this.tcUploaders.SuspendLayout();
this.grpSeafileShareSettings.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nudSeafileExpireDays)).BeginInit();
this.SuspendLayout();
//
// txtRapidSharePremiumUserName
@ -1335,6 +1381,7 @@ private void InitializeComponent()
this.tcFileUploaders.Controls.Add(this.tpLambda);
this.tcFileUploaders.Controls.Add(this.tpPomf);
this.tcFileUploaders.Controls.Add(this.tpUp1);
this.tcFileUploaders.Controls.Add(this.tpSeafile);
this.tcFileUploaders.Controls.Add(this.tpEmail);
this.tcFileUploaders.Controls.Add(this.tpSharedFolder);
resources.ApplyResources(this.tcFileUploaders, "tcFileUploaders");
@ -2527,6 +2574,267 @@ private void InitializeComponent()
resources.ApplyResources(this.lblUp1Host, "lblUp1Host");
this.lblUp1Host.Name = "lblUp1Host";
//
// tpSeafile
//
this.tpSeafile.Controls.Add(this.grpSeafileShareSettings);
this.tpSeafile.Controls.Add(this.btnSeafileLibraryPasswordValidate);
this.tpSeafile.Controls.Add(this.txtSeafileLibraryPassword);
this.tpSeafile.Controls.Add(this.lblSeafileLibraryPassword);
this.tpSeafile.Controls.Add(this.lvSeafileLibraries);
this.tpSeafile.Controls.Add(this.btnSeafilePathValidate);
this.tpSeafile.Controls.Add(this.txtSeafileDirectoryPath);
this.tpSeafile.Controls.Add(this.lblSeafileWritePermNotif);
this.tpSeafile.Controls.Add(this.lblSeafilePath);
this.tpSeafile.Controls.Add(this.txtSeafileUploadLocationRefresh);
this.tpSeafile.Controls.Add(this.lblSeafileSelectLibrary);
this.tpSeafile.Controls.Add(this.grpSeafileAccInfo);
this.tpSeafile.Controls.Add(this.btnSeafileCheckAuthToken);
this.tpSeafile.Controls.Add(this.btnSeafileCheckAPIURL);
this.tpSeafile.Controls.Add(this.grpSeafileObtainAuthToken);
this.tpSeafile.Controls.Add(this.cbSeafileIgnoreInvalidCert);
this.tpSeafile.Controls.Add(this.cbSeafileCreateShareableURL);
this.tpSeafile.Controls.Add(this.txtSeafileAuthToken);
this.tpSeafile.Controls.Add(this.txtSeafileAPIURL);
this.tpSeafile.Controls.Add(this.lblSeafileAuthToken);
this.tpSeafile.Controls.Add(this.lblSeafileAPIURL);
resources.ApplyResources(this.tpSeafile, "tpSeafile");
this.tpSeafile.Name = "tpSeafile";
this.tpSeafile.UseVisualStyleBackColor = true;
//
// btnSeafileLibraryPasswordValidate
//
resources.ApplyResources(this.btnSeafileLibraryPasswordValidate, "btnSeafileLibraryPasswordValidate");
this.btnSeafileLibraryPasswordValidate.Name = "btnSeafileLibraryPasswordValidate";
this.btnSeafileLibraryPasswordValidate.UseVisualStyleBackColor = true;
this.btnSeafileLibraryPasswordValidate.Click += new System.EventHandler(this.btnSeafileLibraryPasswordValidate_Click);
//
// txtSeafileLibraryPassword
//
resources.ApplyResources(this.txtSeafileLibraryPassword, "txtSeafileLibraryPassword");
this.txtSeafileLibraryPassword.Name = "txtSeafileLibraryPassword";
this.txtSeafileLibraryPassword.UseSystemPasswordChar = true;
this.txtSeafileLibraryPassword.TextChanged += new System.EventHandler(this.txtSeafileLibraryPassword_TextChanged);
//
// lblSeafileLibraryPassword
//
resources.ApplyResources(this.lblSeafileLibraryPassword, "lblSeafileLibraryPassword");
this.lblSeafileLibraryPassword.Name = "lblSeafileLibraryPassword";
//
// lvSeafileLibraries
//
this.lvSeafileLibraries.AllowColumnSort = true;
this.lvSeafileLibraries.AutoFillColumn = true;
this.lvSeafileLibraries.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.colSeafileLibraryName,
this.colSeafileLibrarySize,
this.colSeafileLibraryEncrypted});
this.lvSeafileLibraries.DisableDeselect = true;
this.lvSeafileLibraries.FullRowSelect = true;
this.lvSeafileLibraries.HideSelection = false;
resources.ApplyResources(this.lvSeafileLibraries, "lvSeafileLibraries");
this.lvSeafileLibraries.Name = "lvSeafileLibraries";
this.lvSeafileLibraries.UseCompatibleStateImageBehavior = false;
this.lvSeafileLibraries.View = System.Windows.Forms.View.Details;
this.lvSeafileLibraries.SelectedIndexChanged += new System.EventHandler(this.lvSeafileLibraries_SelectedIndexChanged);
//
// colSeafileLibraryName
//
resources.ApplyResources(this.colSeafileLibraryName, "colSeafileLibraryName");
//
// colSeafileLibrarySize
//
resources.ApplyResources(this.colSeafileLibrarySize, "colSeafileLibrarySize");
//
// colSeafileLibraryEncrypted
//
resources.ApplyResources(this.colSeafileLibraryEncrypted, "colSeafileLibraryEncrypted");
//
// btnSeafilePathValidate
//
resources.ApplyResources(this.btnSeafilePathValidate, "btnSeafilePathValidate");
this.btnSeafilePathValidate.Name = "btnSeafilePathValidate";
this.btnSeafilePathValidate.UseVisualStyleBackColor = true;
this.btnSeafilePathValidate.Click += new System.EventHandler(this.btnSeafilePathValidate_Click);
//
// txtSeafileDirectoryPath
//
resources.ApplyResources(this.txtSeafileDirectoryPath, "txtSeafileDirectoryPath");
this.txtSeafileDirectoryPath.Name = "txtSeafileDirectoryPath";
this.txtSeafileDirectoryPath.TextChanged += new System.EventHandler(this.txtSeafileDirectoryPath_TextChanged);
//
// lblSeafileWritePermNotif
//
resources.ApplyResources(this.lblSeafileWritePermNotif, "lblSeafileWritePermNotif");
this.lblSeafileWritePermNotif.Name = "lblSeafileWritePermNotif";
//
// lblSeafilePath
//
resources.ApplyResources(this.lblSeafilePath, "lblSeafilePath");
this.lblSeafilePath.Name = "lblSeafilePath";
//
// txtSeafileUploadLocationRefresh
//
resources.ApplyResources(this.txtSeafileUploadLocationRefresh, "txtSeafileUploadLocationRefresh");
this.txtSeafileUploadLocationRefresh.Name = "txtSeafileUploadLocationRefresh";
this.txtSeafileUploadLocationRefresh.UseVisualStyleBackColor = true;
this.txtSeafileUploadLocationRefresh.Click += new System.EventHandler(this.txtSeafileUploadLocationRefresh_Click);
//
// lblSeafileSelectLibrary
//
resources.ApplyResources(this.lblSeafileSelectLibrary, "lblSeafileSelectLibrary");
this.lblSeafileSelectLibrary.Name = "lblSeafileSelectLibrary";
//
// grpSeafileAccInfo
//
this.grpSeafileAccInfo.Controls.Add(this.myListView1);
this.grpSeafileAccInfo.Controls.Add(this.btnRefreshSeafileAccInfo);
this.grpSeafileAccInfo.Controls.Add(this.txtSeafileAccInfoUsage);
this.grpSeafileAccInfo.Controls.Add(this.txtSeafileAccInfoEmail);
this.grpSeafileAccInfo.Controls.Add(this.lblSeafileAccInfoEmail);
this.grpSeafileAccInfo.Controls.Add(this.lblSeafileAccInfoUsage);
resources.ApplyResources(this.grpSeafileAccInfo, "grpSeafileAccInfo");
this.grpSeafileAccInfo.Name = "grpSeafileAccInfo";
this.grpSeafileAccInfo.TabStop = false;
//
// myListView1
//
this.myListView1.AutoFillColumn = true;
this.myListView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1});
this.myListView1.FullRowSelect = true;
resources.ApplyResources(this.myListView1, "myListView1");
this.myListView1.Name = "myListView1";
this.myListView1.UseCompatibleStateImageBehavior = false;
this.myListView1.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
resources.ApplyResources(this.columnHeader1, "columnHeader1");
//
// btnRefreshSeafileAccInfo
//
resources.ApplyResources(this.btnRefreshSeafileAccInfo, "btnRefreshSeafileAccInfo");
this.btnRefreshSeafileAccInfo.Name = "btnRefreshSeafileAccInfo";
this.btnRefreshSeafileAccInfo.UseVisualStyleBackColor = true;
this.btnRefreshSeafileAccInfo.Click += new System.EventHandler(this.btnRefreshSeafileAccInfo_Click);
//
// txtSeafileAccInfoUsage
//
resources.ApplyResources(this.txtSeafileAccInfoUsage, "txtSeafileAccInfoUsage");
this.txtSeafileAccInfoUsage.Name = "txtSeafileAccInfoUsage";
this.txtSeafileAccInfoUsage.ReadOnly = true;
//
// txtSeafileAccInfoEmail
//
resources.ApplyResources(this.txtSeafileAccInfoEmail, "txtSeafileAccInfoEmail");
this.txtSeafileAccInfoEmail.Name = "txtSeafileAccInfoEmail";
this.txtSeafileAccInfoEmail.ReadOnly = true;
//
// lblSeafileAccInfoEmail
//
resources.ApplyResources(this.lblSeafileAccInfoEmail, "lblSeafileAccInfoEmail");
this.lblSeafileAccInfoEmail.Name = "lblSeafileAccInfoEmail";
//
// lblSeafileAccInfoUsage
//
resources.ApplyResources(this.lblSeafileAccInfoUsage, "lblSeafileAccInfoUsage");
this.lblSeafileAccInfoUsage.Name = "lblSeafileAccInfoUsage";
//
// btnSeafileCheckAuthToken
//
resources.ApplyResources(this.btnSeafileCheckAuthToken, "btnSeafileCheckAuthToken");
this.btnSeafileCheckAuthToken.Name = "btnSeafileCheckAuthToken";
this.btnSeafileCheckAuthToken.UseVisualStyleBackColor = true;
this.btnSeafileCheckAuthToken.Click += new System.EventHandler(this.btnSeafileCheckAuthToken_Click);
//
// btnSeafileCheckAPIURL
//
resources.ApplyResources(this.btnSeafileCheckAPIURL, "btnSeafileCheckAPIURL");
this.btnSeafileCheckAPIURL.Name = "btnSeafileCheckAPIURL";
this.btnSeafileCheckAPIURL.UseVisualStyleBackColor = true;
this.btnSeafileCheckAPIURL.Click += new System.EventHandler(this.btnSeafileCheckAPIURL_Click);
//
// grpSeafileObtainAuthToken
//
this.grpSeafileObtainAuthToken.Controls.Add(this.btnSeafileGetAuthToken);
this.grpSeafileObtainAuthToken.Controls.Add(this.txtSeafilePassword);
this.grpSeafileObtainAuthToken.Controls.Add(this.txtSeafileUsername);
this.grpSeafileObtainAuthToken.Controls.Add(this.lblSeafileUsername);
this.grpSeafileObtainAuthToken.Controls.Add(this.lblSeafilePassword);
resources.ApplyResources(this.grpSeafileObtainAuthToken, "grpSeafileObtainAuthToken");
this.grpSeafileObtainAuthToken.Name = "grpSeafileObtainAuthToken";
this.grpSeafileObtainAuthToken.TabStop = false;
//
// btnSeafileGetAuthToken
//
resources.ApplyResources(this.btnSeafileGetAuthToken, "btnSeafileGetAuthToken");
this.btnSeafileGetAuthToken.Name = "btnSeafileGetAuthToken";
this.btnSeafileGetAuthToken.UseVisualStyleBackColor = true;
this.btnSeafileGetAuthToken.Click += new System.EventHandler(this.btnSeafileGetAuthToken_Click);
//
// txtSeafilePassword
//
resources.ApplyResources(this.txtSeafilePassword, "txtSeafilePassword");
this.txtSeafilePassword.Name = "txtSeafilePassword";
this.txtSeafilePassword.UseSystemPasswordChar = true;
this.txtSeafilePassword.KeyUp += new System.Windows.Forms.KeyEventHandler(this.txtSeafilePassword_KeyUp);
//
// txtSeafileUsername
//
resources.ApplyResources(this.txtSeafileUsername, "txtSeafileUsername");
this.txtSeafileUsername.Name = "txtSeafileUsername";
//
// lblSeafileUsername
//
resources.ApplyResources(this.lblSeafileUsername, "lblSeafileUsername");
this.lblSeafileUsername.Name = "lblSeafileUsername";
//
// lblSeafilePassword
//
resources.ApplyResources(this.lblSeafilePassword, "lblSeafilePassword");
this.lblSeafilePassword.Name = "lblSeafilePassword";
//
// cbSeafileIgnoreInvalidCert
//
resources.ApplyResources(this.cbSeafileIgnoreInvalidCert, "cbSeafileIgnoreInvalidCert");
this.cbSeafileIgnoreInvalidCert.Name = "cbSeafileIgnoreInvalidCert";
this.cbSeafileIgnoreInvalidCert.UseVisualStyleBackColor = true;
this.cbSeafileIgnoreInvalidCert.CheckedChanged += new System.EventHandler(this.cbSeafileIgnoreInvalidCert_CheckedChanged);
//
// cbSeafileCreateShareableURL
//
resources.ApplyResources(this.cbSeafileCreateShareableURL, "cbSeafileCreateShareableURL");
this.cbSeafileCreateShareableURL.Name = "cbSeafileCreateShareableURL";
this.cbSeafileCreateShareableURL.UseVisualStyleBackColor = true;
this.cbSeafileCreateShareableURL.CheckedChanged += new System.EventHandler(this.cbSeafileCreateShareableURL_CheckedChanged);
//
// txtSeafileAuthToken
//
resources.ApplyResources(this.txtSeafileAuthToken, "txtSeafileAuthToken");
this.txtSeafileAuthToken.Name = "txtSeafileAuthToken";
this.txtSeafileAuthToken.TextChanged += new System.EventHandler(this.txtSeafileAuthToken_TextChanged);
//
// txtSeafileAPIURL
//
this.txtSeafileAPIURL.AutoCompleteCustomSource.AddRange(new string[] {
resources.GetString("txtSeafileAPIURL.AutoCompleteCustomSource"),
resources.GetString("txtSeafileAPIURL.AutoCompleteCustomSource1")});
this.txtSeafileAPIURL.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest;
this.txtSeafileAPIURL.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource;
resources.ApplyResources(this.txtSeafileAPIURL, "txtSeafileAPIURL");
this.txtSeafileAPIURL.Name = "txtSeafileAPIURL";
this.txtSeafileAPIURL.TextChanged += new System.EventHandler(this.txtSeafileAPIURL_TextChanged);
//
// lblSeafileAuthToken
//
resources.ApplyResources(this.lblSeafileAuthToken, "lblSeafileAuthToken");
this.lblSeafileAuthToken.Name = "lblSeafileAuthToken";
//
// lblSeafileAPIURL
//
resources.ApplyResources(this.lblSeafileAPIURL, "lblSeafileAPIURL");
this.lblSeafileAPIURL.Name = "lblSeafileAPIURL";
//
// tpEmail
//
this.tpEmail.Controls.Add(this.chkEmailConfirm);
@ -3548,6 +3856,54 @@ private void InitializeComponent()
this.actRapidShareAccountType.Name = "actRapidShareAccountType";
this.actRapidShareAccountType.SelectedAccountType = ShareX.UploadersLib.AccountType.Anonymous;
//
// grpSeafileShareSettings
//
this.grpSeafileShareSettings.Controls.Add(this.txtSeafileSharePassword);
this.grpSeafileShareSettings.Controls.Add(this.lblSeafileSharePassword);
this.grpSeafileShareSettings.Controls.Add(this.nudSeafileExpireDays);
this.grpSeafileShareSettings.Controls.Add(this.lblSeafileDaysToExpire);
resources.ApplyResources(this.grpSeafileShareSettings, "grpSeafileShareSettings");
this.grpSeafileShareSettings.Name = "grpSeafileShareSettings";
this.grpSeafileShareSettings.TabStop = false;
//
// lblSeafileDaysToExpire
//
resources.ApplyResources(this.lblSeafileDaysToExpire, "lblSeafileDaysToExpire");
this.lblSeafileDaysToExpire.Name = "lblSeafileDaysToExpire";
//
// nudSeafileExpireDays
//
resources.ApplyResources(this.nudSeafileExpireDays, "nudSeafileExpireDays");
this.nudSeafileExpireDays.Maximum = new decimal(new int[] {
900,
0,
0,
0});
this.nudSeafileExpireDays.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.nudSeafileExpireDays.Name = "nudSeafileExpireDays";
this.nudSeafileExpireDays.Value = new decimal(new int[] {
7,
0,
0,
0});
this.nudSeafileExpireDays.ValueChanged += new System.EventHandler(this.nudSeafileExpireDays_ValueChanged);
//
// txtSeafileSharePassword
//
resources.ApplyResources(this.txtSeafileSharePassword, "txtSeafileSharePassword");
this.txtSeafileSharePassword.Name = "txtSeafileSharePassword";
this.txtSeafileSharePassword.UseSystemPasswordChar = true;
this.txtSeafileSharePassword.TextChanged += new System.EventHandler(this.txtSeafileSharePassword_TextChanged);
//
// lblSeafileSharePassword
//
resources.ApplyResources(this.lblSeafileSharePassword, "lblSeafileSharePassword");
this.lblSeafileSharePassword.Name = "lblSeafileSharePassword";
//
// UploadersConfigForm
//
resources.ApplyResources(this, "$this");
@ -3633,6 +3989,12 @@ private void InitializeComponent()
this.tpPomf.PerformLayout();
this.tpUp1.ResumeLayout(false);
this.tpUp1.PerformLayout();
this.tpSeafile.ResumeLayout(false);
this.tpSeafile.PerformLayout();
this.grpSeafileAccInfo.ResumeLayout(false);
this.grpSeafileAccInfo.PerformLayout();
this.grpSeafileObtainAuthToken.ResumeLayout(false);
this.grpSeafileObtainAuthToken.PerformLayout();
this.tpEmail.ResumeLayout(false);
this.tpEmail.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.nudEmailSmtpPort)).EndInit();
@ -3673,6 +4035,9 @@ private void InitializeComponent()
this.tpChevereto.ResumeLayout(false);
this.tpChevereto.PerformLayout();
this.tcUploaders.ResumeLayout(false);
this.grpSeafileShareSettings.ResumeLayout(false);
this.grpSeafileShareSettings.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.nudSeafileExpireDays)).EndInit();
this.ResumeLayout(false);
}
@ -4097,5 +4462,46 @@ private void InitializeComponent()
private System.Windows.Forms.ComboBox cbPomfUploaders;
private System.Windows.Forms.TextBox txtPomfUploadURL;
private System.Windows.Forms.TextBox txtPomfResultURL;
private System.Windows.Forms.TabPage tpSeafile;
private System.Windows.Forms.Button btnSeafileCheckAuthToken;
private System.Windows.Forms.Button btnSeafileCheckAPIURL;
private System.Windows.Forms.GroupBox grpSeafileObtainAuthToken;
private System.Windows.Forms.Button btnSeafileGetAuthToken;
private System.Windows.Forms.TextBox txtSeafilePassword;
private System.Windows.Forms.TextBox txtSeafileUsername;
private System.Windows.Forms.Label lblSeafileUsername;
private System.Windows.Forms.Label lblSeafilePassword;
private System.Windows.Forms.CheckBox cbSeafileIgnoreInvalidCert;
private System.Windows.Forms.CheckBox cbSeafileCreateShareableURL;
private System.Windows.Forms.TextBox txtSeafileAuthToken;
private System.Windows.Forms.TextBox txtSeafileAPIURL;
private System.Windows.Forms.Label lblSeafileAuthToken;
private System.Windows.Forms.Label lblSeafileAPIURL;
private System.Windows.Forms.GroupBox grpSeafileAccInfo;
private System.Windows.Forms.Button btnRefreshSeafileAccInfo;
private System.Windows.Forms.TextBox txtSeafileAccInfoUsage;
private System.Windows.Forms.TextBox txtSeafileAccInfoEmail;
private System.Windows.Forms.Label lblSeafileAccInfoEmail;
private System.Windows.Forms.Label lblSeafileAccInfoUsage;
private System.Windows.Forms.Button txtSeafileUploadLocationRefresh;
private System.Windows.Forms.Label lblSeafileSelectLibrary;
private System.Windows.Forms.Label lblSeafileWritePermNotif;
private HelpersLib.MyListView lvSeafileLibraries;
private System.Windows.Forms.ColumnHeader colSeafileLibraryName;
private System.Windows.Forms.Button btnSeafilePathValidate;
private System.Windows.Forms.TextBox txtSeafileDirectoryPath;
private System.Windows.Forms.Label lblSeafilePath;
private HelpersLib.MyListView myListView1;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader colSeafileLibrarySize;
private System.Windows.Forms.ColumnHeader colSeafileLibraryEncrypted;
private System.Windows.Forms.Button btnSeafileLibraryPasswordValidate;
private System.Windows.Forms.TextBox txtSeafileLibraryPassword;
private System.Windows.Forms.Label lblSeafileLibraryPassword;
private System.Windows.Forms.GroupBox grpSeafileShareSettings;
private System.Windows.Forms.TextBox txtSeafileSharePassword;
private System.Windows.Forms.Label lblSeafileSharePassword;
private System.Windows.Forms.NumericUpDown nudSeafileExpireDays;
private System.Windows.Forms.Label lblSeafileDaysToExpire;
}
}

View file

@ -107,6 +107,7 @@ private void FormSettings()
AddIconToTab(tpPolr, Resources.Polr);
AddIconToTab(tpPomf, Resources.Pomf);
AddIconToTab(tpPushbullet, Resources.Pushbullet);
AddIconToTab(tpSeafile, Resources.Seafile);
AddIconToTab(tpSendSpace, Resources.SendSpace);
AddIconToTab(tpSharedFolder, Resources.server_network);
AddIconToTab(tpTinyPic, Resources.TinyPic);
@ -558,6 +559,21 @@ public void LoadSettings()
txtPomfUploadURL.Text = Config.PomfUploader.UploadURL;
txtPomfResultURL.Text = Config.PomfUploader.ResultURL;
// Seafile
txtSeafileAPIURL.Text = Config.SeafileAPIURL;
txtSeafileAuthToken.Text = Config.SeafileAuthToken;
txtSeafileDirectoryPath.Text = Config.SeafilePath;
txtSeafileLibraryPassword.Text = Config.SeafileEncryptedLibraryPassword;
txtSeafileLibraryPassword.ReadOnly = (Config.SeafileIsLibraryEncrypted ? true : false);
btnSeafileLibraryPasswordValidate.Enabled = (Config.SeafileIsLibraryEncrypted ? false : true);
cbSeafileCreateShareableURL.Checked = Config.SeafileCreateShareableURL;
cbSeafileIgnoreInvalidCert.Checked = Config.SeafileIgnoreInvalidCert;
nudSeafileExpireDays.Value = Config.SeafileShareDaysToExpire;
txtSeafileSharePassword.Text = Config.SeafileSharePassword;
txtSeafileAccInfoEmail.Text = Config.SeafileAccInfoEmail;
txtSeafileAccInfoUsage.Text = Config.SeafileAccInfoUsage;
#endregion File uploaders
#region URL Shorteners
@ -2044,6 +2060,252 @@ private void txtPomfResultURL_TextChanged(object sender, EventArgs e)
#endregion Pomf
#region Seafile
private void txtSeafileAPIURL_TextChanged(object sender, EventArgs e)
{
Config.SeafileAPIURL = txtSeafileAPIURL.Text;
}
private void btnSeafileCheckAPIURL_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(txtSeafileAPIURL.Text))
{
return;
}
Seafile sf = new Seafile(txtSeafileAPIURL.Text, null, null);
bool checkReturned = sf.CheckAPIURL();
if (checkReturned)
{
MessageBox.Show(Resources.UploadersConfigForm_TestFTPAccount_Connected_, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show(Resources.UploadersConfigForm_Error, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void txtSeafileAuthToken_TextChanged(object sender, EventArgs e)
{
Config.SeafileAuthToken = txtSeafileAuthToken.Text;
}
private void btnSeafileCheckAuthToken_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(txtSeafileAuthToken.Text) || string.IsNullOrEmpty(txtSeafileAPIURL.Text))
{
return;
}
Seafile sf = new Seafile(txtSeafileAPIURL.Text, txtSeafileAuthToken.Text, null);
bool checkReturned = sf.CheckAuthToken();
if (checkReturned)
{
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show(Resources.UploadersConfigForm_Error, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void txtSeafilePassword_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Return)
{
btnSeafileGetAuthToken.PerformClick();
}
}
private void btnSeafileGetAuthToken_Click(object sender, EventArgs e)
{
string username = txtSeafileUsername.Text;
string password = txtSeafilePassword.Text;
if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
{
try
{
Seafile sf = new Seafile(txtSeafileAPIURL.Text, null, null);
string authToken = sf.GetAuthToken(username, password);
if (!string.IsNullOrEmpty(authToken))
{
txtSeafileUsername.Text = "";
txtSeafilePassword.Text = "";
Config.SeafileAuthToken = authToken;
txtSeafileAuthToken.Text = authToken;
btnRefreshSeafileAccInfo.PerformClick();
Config.SeafileRepoID = sf.GetOrMakeDefaultLibrary(authToken);
txtSeafileUploadLocationRefresh.PerformClick();
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
DebugHelper.WriteException(ex);
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void cbSeafileCreateShareableURL_CheckedChanged(object sender, EventArgs e)
{
Config.SeafileCreateShareableURL = cbSeafileCreateShareableURL.Checked;
}
private void cbSeafileIgnoreInvalidCert_CheckedChanged(object sender, EventArgs e)
{
Config.SeafileIgnoreInvalidCert = cbSeafileIgnoreInvalidCert.Checked;
}
private void btnRefreshSeafileAccInfo_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(txtSeafileAuthToken.Text) || string.IsNullOrEmpty(txtSeafileAPIURL.Text))
{
return;
}
Seafile sf = new Seafile(txtSeafileAPIURL.Text, txtSeafileAuthToken.Text, null);
Seafile.SeafileCheckAccInfoResponse SeafileCheckAccInfoResponse = sf.GetAccountInfo();
if (SeafileCheckAccInfoResponse == null)
{
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
txtSeafileAccInfoEmail.Text = SeafileCheckAccInfoResponse.email;
txtSeafileAccInfoUsage.Text = HelpersLib.NumberExtensions.ToSizeString(SeafileCheckAccInfoResponse.usage).ToString() + " / " + HelpersLib.NumberExtensions.ToSizeString(SeafileCheckAccInfoResponse.total).ToString();
}
private void txtSeafileUploadLocationRefresh_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(txtSeafileAuthToken.Text) || string.IsNullOrEmpty(txtSeafileAPIURL.Text))
{
return;
}
lvSeafileLibraries.Items.Clear();
Seafile sf = new Seafile(txtSeafileAPIURL.Text, txtSeafileAuthToken.Text, null);
List<Seafile.SeafileLibraryObj> SeafileLibraries = sf.GetLibraries();
foreach (var SeafileLibrary in SeafileLibraries)
{
if (SeafileLibrary.permission == "rw")
{
ListViewItem libraryItem = lvSeafileLibraries.Items.Add(SeafileLibrary.name);
libraryItem.Name = SeafileLibrary.id;
libraryItem.Tag = SeafileLibrary;
libraryItem.SubItems.Add(HelpersLib.NumberExtensions.ToSizeString(SeafileLibrary.size));
if (SeafileLibrary.encrypted)
{
ListViewItem.ListViewSubItem isEncrypt = libraryItem.SubItems.Add("\u221A");
}
if (SeafileLibrary.id == Config.SeafileRepoID)
{
libraryItem.Selected = true;
}
}
}
}
private void lvSeafileLibraries_SelectedIndexChanged(object sender, EventArgs e)
{
int selIndex = lvSeafileLibraries.SelectedIndex;
if (selIndex > -1)
{
ListViewItem selectedItem = lvSeafileLibraries.Items[selIndex];
Config.SeafileRepoID = selectedItem.Name;
Seafile.SeafileLibraryObj SealileLibraryInfo = (Seafile.SeafileLibraryObj)selectedItem.Tag;
if (SealileLibraryInfo.encrypted)
{
Config.SeafileIsLibraryEncrypted = true;
txtSeafileLibraryPassword.ReadOnly = false;
btnSeafileLibraryPasswordValidate.Enabled = true;
}
else
{
Config.SeafileIsLibraryEncrypted = false;
txtSeafileLibraryPassword.ReadOnly = true;
txtSeafileLibraryPassword.Text = "";
Config.SeafileEncryptedLibraryPassword = "";
btnSeafileLibraryPasswordValidate.Enabled = false;
}
}
}
private void txtSeafileDirectoryPath_TextChanged(object sender, EventArgs e)
{
Config.SeafilePath = txtSeafileDirectoryPath.Text;
}
private void btnSeafilePathValidate_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(Config.SeafilePath) || string.IsNullOrEmpty(Config.SeafileAPIURL) || string.IsNullOrEmpty(Config.SeafileAuthToken) || string.IsNullOrEmpty(Config.SeafileRepoID))
{
return;
}
Seafile sf = new Seafile(txtSeafileAPIURL.Text, txtSeafileAuthToken.Text, Config.SeafileRepoID);
bool checkReturned = sf.ValidatePath(txtSeafileDirectoryPath.Text);
if (checkReturned)
{
MessageBox.Show(Resources.UploadersConfigForm_TestFTPAccount_Connected_, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show(Resources.UploadersConfigForm_Error, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void txtSeafileLibraryPassword_TextChanged(object sender, EventArgs e)
{
if (Config.SeafileIsLibraryEncrypted)
{
Config.SeafileEncryptedLibraryPassword = txtSeafileLibraryPassword.Text;
}
}
private void btnSeafileLibraryPasswordValidate_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(Config.SeafileEncryptedLibraryPassword) || string.IsNullOrEmpty(Config.SeafileAPIURL) || string.IsNullOrEmpty(Config.SeafileAuthToken) || string.IsNullOrEmpty(Config.SeafileRepoID))
{
return;
}
Seafile sf = new Seafile(txtSeafileAPIURL.Text, txtSeafileAuthToken.Text, Config.SeafileRepoID);
bool checkReturned = sf.DecryptLibrary(txtSeafileLibraryPassword.Text);
if (checkReturned)
{
MessageBox.Show(Resources.UploadersConfigForm_TestFTPAccount_Connected_, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show(Resources.UploadersConfigForm_Error, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void nudSeafileExpireDays_ValueChanged(object sender, EventArgs e)
{
Config.SeafileShareDaysToExpire = (int)nudSeafileExpireDays.Value;
}
private void txtSeafileSharePassword_TextChanged(object sender, EventArgs e)
{
Config.SeafileSharePassword = txtSeafileSharePassword.Text;
}
#endregion Seafile
#endregion File Uploaders
#region URL Shorteners

File diff suppressed because it is too large Load diff

View file

@ -866,6 +866,16 @@ internal class Resources {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Seafile {
get {
object obj = ResourceManager.GetObject("Seafile", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary>

View file

@ -479,4 +479,7 @@ Created folders:</value>
<data name="Pomf_Upload_Please_select_one_of_the_Pomf_uploaders_from__Destination_settings_window____Pomf_tab__" xml:space="preserve">
<value>Please select one of the Pomf uploaders from "Destination settings window -&gt; Pomf tab".</value>
</data>
<data name="Seafile" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Favicons\Seafile.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View file

@ -135,6 +135,7 @@
<Compile Include="FileUploaders\MediaFire.cs" />
<Compile Include="FileUploaders\Mega.cs" />
<Compile Include="FileUploaders\OneDrive.cs" />
<Compile Include="FileUploaders\Seafile.cs" />
<Compile Include="FileUploaders\OwnCloud.cs" />
<Compile Include="FileUploaders\Pomf.cs" />
<Compile Include="FileUploaders\PomfUploader.cs" />
@ -800,6 +801,9 @@
<ItemGroup>
<None Include="Favicons\Pomf.ico" />
</ItemGroup>
<ItemGroup>
<None Include="Favicons\Seafile.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<PropertyGroup>

View file

@ -254,6 +254,21 @@ public class UploadersConfig : SettingsBase<UploadersConfig>
public PomfUploader PomfUploader = Pomf.DefaultUploader;
// Seafile
public string SeafileAPIURL = "";
public string SeafileAuthToken = "";
public string SeafileRepoID = "";
public string SeafilePath = "/";
public bool SeafileIsLibraryEncrypted = false;
public string SeafileEncryptedLibraryPassword = "";
public bool SeafileCreateShareableURL = true;
public bool SeafileIgnoreInvalidCert = false;
public int SeafileShareDaysToExpire = 7;
public string SeafileSharePassword = "";
public string SeafileAccInfoEmail = "";
public string SeafileAccInfoUsage = "";
#endregion File uploaders
#region URL shorteners

View file

@ -1078,6 +1078,18 @@ public UploadResult UploadFile(Stream stream, string fileName)
case FileDestination.Up1:
fileUploader = new Up1(Program.UploadersConfig.Up1Host, Program.UploadersConfig.Up1Key);
break;
case FileDestination.Seafile:
fileUploader = new Seafile(Program.UploadersConfig.SeafileAPIURL, Program.UploadersConfig.SeafileAuthToken, Program.UploadersConfig.SeafileRepoID)
{
Path = Program.UploadersConfig.SeafilePath,
IsLibraryEncrypted = Program.UploadersConfig.SeafileIsLibraryEncrypted,
EncryptedLibraryPassword = Program.UploadersConfig.SeafileEncryptedLibraryPassword,
ShareDaysToExpire = Program.UploadersConfig.SeafileShareDaysToExpire,
SharePassword = Program.UploadersConfig.SeafileSharePassword,
CreateShareableURL = Program.UploadersConfig.SeafileCreateShareableURL,
IgnoreInvalidCert = Program.UploadersConfig.SeafileIgnoreInvalidCert
};
break;
}
if (fileUploader != null)