ShareX/ShareX.UploadersLib/UploadersConfig.cs

546 lines
20 KiB
C#
Raw Normal View History

2013-11-03 23:53:49 +13:00
#region License Information (GPL v3)
/*
ShareX - A program that allows you to take screenshots and share any file type
2016-01-04 04:16:01 +13:00
Copyright (c) 2007-2016 ShareX Team
2013-11-03 23:53:49 +13:00
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)
using System;
using System.Collections.Generic;
2013-11-03 23:53:49 +13:00
using CG.Web.MegaApiClient;
2014-12-11 09:25:20 +13:00
using ShareX.HelpersLib;
using ShareX.UploadersLib.FileUploaders;
using ShareX.UploadersLib.HelperClasses;
using ShareX.UploadersLib.ImageUploaders;
using ShareX.UploadersLib.TextUploaders;
2013-11-03 23:53:49 +13:00
2014-12-11 09:25:20 +13:00
namespace ShareX.UploadersLib
2013-11-03 23:53:49 +13:00
{
public class UploadersConfig : SettingsBase<UploadersConfig>
{
#region Image uploaders
// Imgur
public AccountType ImgurAccountType = AccountType.Anonymous;
2014-07-22 12:12:07 +12:00
public bool ImgurDirectLink = true;
public ImgurThumbnailType ImgurThumbnailType = ImgurThumbnailType.Large_Thumbnail;
2015-08-08 23:38:37 +12:00
public bool ImgurUseGIFV = true;
public OAuth2Info ImgurOAuth2Info = null;
2014-09-07 13:11:55 +12:00
public bool ImgurUploadSelectedAlbum = false;
public ImgurAlbumData ImgurSelectedAlbum = null;
public List<ImgurAlbumData> ImgurAlbumList = null;
2013-11-03 23:53:49 +13:00
// ImageShack
2014-02-01 11:11:25 +13:00
2014-01-12 23:44:06 +13:00
public ImageShackOptions ImageShackSettings = new ImageShackOptions();
2013-11-03 23:53:49 +13:00
// TinyPic
public AccountType TinyPicAccountType = AccountType.Anonymous;
public string TinyPicRegistrationCode = string.Empty;
public string TinyPicUsername = string.Empty;
public string TinyPicPassword = string.Empty;
public bool TinyPicRememberUserPass = false;
// Flickr
public FlickrAuthInfo FlickrAuthInfo = new FlickrAuthInfo();
public FlickrSettings FlickrSettings = new FlickrSettings();
// Photobucket
public OAuthInfo PhotobucketOAuthInfo = null;
public PhotobucketAccountInfo PhotobucketAccountInfo = null;
// Picasa
public OAuth2Info PicasaOAuth2Info = null;
public string PicasaAlbumID = string.Empty;
2014-09-18 07:25:23 +12:00
// Chevereto
public string CheveretoWebsite = string.Empty;
2014-09-29 18:46:41 +13:00
public string CheveretoAPIKey = string.Empty;
2014-09-18 07:33:11 +12:00
public bool CheveretoDirectURL = true;
2014-09-18 07:25:23 +12:00
// SomeImage
public string SomeImageAPIKey = string.Empty;
2016-02-15 01:12:53 +13:00
public bool SomeImageDirectURL = true;
2016-02-14 13:28:41 +13:00
// vgy.me
public string VgymeUserKey = string.Empty;
2013-11-03 23:53:49 +13:00
#endregion Image uploaders
#region Text uploaders
// Pastebin
public PastebinSettings PastebinSettings = new PastebinSettings();
// Paste.ee
public string Paste_eeUserAPIKey = "public";
// Gist
public bool GistAnonymousLogin = true;
public OAuth2Info GistOAuth2Info = null;
public bool GistPublishPublic = false;
2014-02-01 10:17:39 +13:00
// uPaste
public string UpasteUserKey = string.Empty;
2014-02-01 11:11:25 +13:00
public bool UpasteIsPublic = false;
2014-02-01 10:17:39 +13:00
2014-09-26 17:18:44 +12:00
// Hastebin
public string HastebinCustomDomain = "http://hastebin.com";
public string HastebinSyntaxHighlighting = "hs";
2015-08-04 00:59:33 +12:00
// OneTimeSecret
public string OneTimeSecretAPIKey = string.Empty;
public string OneTimeSecretAPIUsername = string.Empty;
2013-11-03 23:53:49 +13:00
#endregion Text uploaders
#region File uploaders
// Dropbox
public OAuth2Info DropboxOAuth2Info = null;
2013-11-03 23:53:49 +13:00
public DropboxAccountInfo DropboxAccountInfo = null;
2014-04-16 07:30:46 +12:00
public string DropboxUploadPath = "Public/ShareX/%y/%mo";
2013-11-03 23:53:49 +13:00
public bool DropboxAutoCreateShareableLink = false;
public DropboxURLType DropboxURLType = DropboxURLType.Default;
2013-11-03 23:53:49 +13:00
2014-07-16 00:17:02 +12:00
// OneDrive
public OAuth2Info OneDriveOAuth2Info = null;
public OneDriveFileInfo OneDriveSelectedFolder = OneDrive.RootFolder;
public bool OneDriveAutoCreateShareableLink = true;
2014-07-16 00:17:02 +12:00
2014-06-06 06:19:45 +12:00
// Copy
public OAuthInfo CopyOAuthInfo = null;
public CopyAccountInfo CopyAccountInfo = null;
public string CopyUploadPath = "ShareX/%y/%mo";
2014-06-10 07:25:23 +12:00
public CopyURLType CopyURLType = CopyURLType.Shortened;
2014-06-06 06:19:45 +12:00
2013-11-03 23:53:49 +13:00
// Google Drive
public OAuth2Info GoogleDriveOAuth2Info = null;
public bool GoogleDriveIsPublic = true;
public bool GoogleDriveUseFolder = false;
public string GoogleDriveFolderID = string.Empty;
2013-11-03 23:53:49 +13:00
// SendSpace
public AccountType SendSpaceAccountType = AccountType.Anonymous;
public string SendSpaceUsername = string.Empty;
public string SendSpacePassword = string.Empty;
// Minus
2014-03-21 12:37:43 +13:00
public OAuth2Info MinusOAuth2Info = null;
2013-11-03 23:53:49 +13:00
public MinusOptions MinusConfig = new MinusOptions();
// Box
2014-04-17 04:18:25 +12:00
public OAuth2Info BoxOAuth2Info = null;
2014-04-17 11:34:31 +12:00
public BoxFileEntry BoxSelectedFolder = Box.RootFolder;
2013-11-03 23:53:49 +13:00
public bool BoxShare = true;
// Ge.tt
public Ge_ttLogin Ge_ttLogin = null;
// Localhostr
public string LocalhostrEmail = string.Empty;
public string LocalhostrPassword = string.Empty;
public bool LocalhostrDirectURL = true;
// FTP Server
public List<FTPAccount> FTPAccountList = new List<FTPAccount>();
public int FTPSelectedImage = 0;
public int FTPSelectedText = 0;
public int FTPSelectedFile = 0;
// Shared Folder
public List<LocalhostAccount> LocalhostAccountList = new List<LocalhostAccount>();
public int LocalhostSelectedImages = 0;
public int LocalhostSelectedText = 0;
public int LocalhostSelectedFiles = 0;
// Email
public string EmailSmtpServer = "smtp.gmail.com";
public int EmailSmtpPort = 587;
public string EmailFrom = "...@gmail.com";
public string EmailPassword = string.Empty;
public bool EmailRememberLastTo = true;
public bool EmailConfirmSend = true;
public string EmailLastTo = string.Empty;
public string EmailDefaultSubject = "Sending email from ShareX";
2013-11-03 23:53:49 +13:00
public string EmailDefaultBody = "Screenshot is attached.";
// Jira
public string JiraHost = "http://";
public string JiraIssuePrefix = "PROJECT-";
public OAuthInfo JiraOAuthInfo = null;
// Mega
public MegaApiClient.AuthInfos MegaAuthInfos = null;
public string MegaParentNodeId = null;
2014-03-27 05:56:05 +13:00
// Amazon S3
2014-03-29 01:55:41 +13:00
public AmazonS3Settings AmazonS3Settings = new AmazonS3Settings()
{
2014-04-16 07:30:46 +12:00
ObjectPrefix = "ShareX/%y/%mo",
2014-03-27 05:56:05 +13:00
UseReducedRedundancyStorage = true
};
2014-07-07 06:45:36 +12:00
// ownCloud
public string OwnCloudHost = "";
public string OwnCloudUsername = "";
public string OwnCloudPassword = "";
public string OwnCloudPath = "/";
public bool OwnCloudCreateShare = true;
2014-07-07 09:06:37 +12:00
public bool OwnCloudDirectLink = false;
public bool OwnCloudIgnoreInvalidCert = false;
public bool OwnCloud81Compatibility = false;
2014-07-07 06:45:36 +12:00
2014-07-23 10:32:14 +12:00
// MediaFire
public string MediaFireUsername = "";
public string MediaFirePassword = "";
public string MediaFirePath = "";
2014-07-23 13:59:45 +12:00
public bool MediaFireUseLongLink = false;
2014-07-23 10:32:14 +12:00
// Pushbullet
public PushbulletSettings PushbulletSettings = new PushbulletSettings();
// Up1
public string Up1Host = "https://up1.ca";
public string Up1Key = "c61540b5ceecd05092799f936e27755f";
2015-02-04 09:12:53 +13:00
// Lambda
public LambdaSettings LambdaSettings = new LambdaSettings();
// Pomf
2016-02-04 17:38:54 +13:00
public PomfUploader PomfUploader = new PomfUploader("https://pomf.cat/upload.php", "https://a.pomf.cat");
2015-12-12 15:30:12 +13:00
// s-ul
public string SulAPIKey = string.Empty;
// 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;
2015-10-16 21:23:30 +13:00
public int SeafileShareDaysToExpire = 0;
public string SeafileSharePassword = "";
public string SeafileAccInfoEmail = "";
public string SeafileAccInfoUsage = "";
2015-12-02 07:02:06 +13:00
// Streamable
public string StreamableUsername = "";
public string StreamablePassword = "";
public bool StreamableAnonymous = true;
2013-11-03 23:53:49 +13:00
#endregion File uploaders
#region URL shorteners
2013-12-21 04:59:26 +13:00
// bit.ly
public OAuth2Info BitlyOAuth2Info = null;
2014-06-18 08:10:31 +12:00
public string BitlyDomain = string.Empty;
2013-12-21 04:59:26 +13:00
// Google URL Shortener
2013-11-03 23:53:49 +13:00
public AccountType GoogleURLShortenerAccountType = AccountType.Anonymous;
public OAuth2Info GoogleURLShortenerOAuth2Info = null;
// yourls.org
public string YourlsAPIURL = "http://yoursite.com/yourls-api.php";
public string YourlsSignature = string.Empty;
public string YourlsUsername = string.Empty;
public string YourlsPassword = string.Empty;
2014-07-13 23:10:42 +12:00
// adf.ly
public string AdFlyAPIKEY = String.Empty;
public string AdFlyAPIUID = String.Empty;
2014-07-13 23:10:42 +12:00
2015-07-21 08:12:13 +12:00
// coinurl.com
public string CoinURLUUID = string.Empty;
2015-08-05 06:49:07 +12:00
// polr
public string PolrAPIHostname = string.Empty;
public string PolrAPIKey = string.Empty;
2013-11-03 23:53:49 +13:00
#endregion URL shorteners
2014-07-12 05:41:39 +12:00
#region URL sharing services
2013-11-03 23:53:49 +13:00
// Twitter
public List<OAuthInfo> TwitterOAuthInfoList = new List<OAuthInfo>();
public int TwitterSelectedAccount = 0;
2015-04-28 19:50:41 +12:00
public bool TwitterSkipMessageBox = false;
public string TwitterDefaultMessage = string.Empty;
2013-11-03 23:53:49 +13:00
2014-07-12 05:41:39 +12:00
#endregion URL sharing services
2013-11-03 23:53:49 +13:00
#region Custom Uploaders
public List<CustomUploaderItem> CustomUploadersList = new List<CustomUploaderItem>();
public int CustomImageUploaderSelected = 0;
public int CustomTextUploaderSelected = 0;
public int CustomFileUploaderSelected = 0;
public int CustomURLShortenerSelected = 0;
#endregion Custom Uploaders
#region Helper Methods
2014-07-12 05:41:39 +12:00
public bool IsValid<T>(int index)
2013-11-03 23:53:49 +13:00
{
Enum destination = (Enum)Enum.ToObject(typeof(T), index);
if (destination is ImageDestination)
{
2014-07-12 05:41:39 +12:00
return IsValid((ImageDestination)destination);
2013-11-03 23:53:49 +13:00
}
if (destination is TextDestination)
{
2014-07-12 05:41:39 +12:00
return IsValid((TextDestination)destination);
2013-11-03 23:53:49 +13:00
}
if (destination is FileDestination)
{
2014-07-12 05:41:39 +12:00
return IsValid((FileDestination)destination);
2013-11-03 23:53:49 +13:00
}
if (destination is UrlShortenerType)
{
2014-07-12 05:41:39 +12:00
return IsValid((UrlShortenerType)destination);
2013-11-03 23:53:49 +13:00
}
if (destination is URLSharingServices)
2013-11-03 23:53:49 +13:00
{
2014-07-12 05:41:39 +12:00
return IsValid((URLSharingServices)destination);
2013-11-03 23:53:49 +13:00
}
return true;
}
2014-07-12 05:41:39 +12:00
public bool IsValid(ImageDestination destination)
2013-11-03 23:53:49 +13:00
{
switch (destination)
{
2014-06-17 03:24:30 +12:00
case ImageDestination.Imgur:
return ImgurAccountType == AccountType.Anonymous || OAuth2Info.CheckOAuth(ImgurOAuth2Info);
2013-11-03 23:53:49 +13:00
case ImageDestination.ImageShack:
return ImageShackSettings != null && !string.IsNullOrEmpty(ImageShackSettings.Auth_token);
2013-11-03 23:53:49 +13:00
case ImageDestination.TinyPic:
return TinyPicAccountType == AccountType.Anonymous || !string.IsNullOrEmpty(TinyPicRegistrationCode);
case ImageDestination.Flickr:
return !string.IsNullOrEmpty(FlickrAuthInfo.Token);
case ImageDestination.Photobucket:
return PhotobucketAccountInfo != null && OAuthInfo.CheckOAuth(PhotobucketOAuthInfo);
case ImageDestination.Picasa:
return OAuth2Info.CheckOAuth(PicasaOAuth2Info);
2014-06-15 22:29:09 +12:00
case ImageDestination.Twitter:
2014-06-17 03:24:30 +12:00
return TwitterOAuthInfoList != null && TwitterOAuthInfoList.IsValidIndex(TwitterSelectedAccount) && OAuthInfo.CheckOAuth(TwitterOAuthInfoList[TwitterSelectedAccount]);
2015-09-17 20:17:21 +12:00
case ImageDestination.Chevereto:
return !string.IsNullOrEmpty(CheveretoWebsite) && !string.IsNullOrEmpty(CheveretoAPIKey);
case ImageDestination.SomeImage:
2016-02-15 01:12:53 +13:00
return !string.IsNullOrEmpty(SomeImageAPIKey);
2013-11-03 23:53:49 +13:00
case ImageDestination.CustomImageUploader:
return CustomUploadersList != null && CustomUploadersList.IsValidIndex(CustomImageUploaderSelected);
}
2014-06-17 03:24:30 +12:00
return true;
2013-11-03 23:53:49 +13:00
}
2014-07-12 05:41:39 +12:00
public bool IsValid(TextDestination destination)
2013-11-03 23:53:49 +13:00
{
switch (destination)
{
case TextDestination.CustomTextUploader:
return CustomUploadersList != null && CustomUploadersList.IsValidIndex(CustomTextUploaderSelected);
}
2014-06-17 03:24:30 +12:00
return true;
2013-11-03 23:53:49 +13:00
}
2014-07-12 05:41:39 +12:00
public bool IsValid(FileDestination destination)
2013-11-03 23:53:49 +13:00
{
switch (destination)
{
case FileDestination.Dropbox:
return OAuth2Info.CheckOAuth(DropboxOAuth2Info);
2015-09-17 20:17:21 +12:00
case FileDestination.FTP:
return FTPAccountList != null && FTPAccountList.IsValidIndex(FTPSelectedFile);
case FileDestination.OneDrive:
return OAuth2Info.CheckOAuth(OneDriveOAuth2Info);
2013-11-03 23:53:49 +13:00
case FileDestination.GoogleDrive:
return OAuth2Info.CheckOAuth(GoogleDriveOAuth2Info);
2015-09-17 20:17:21 +12:00
case FileDestination.Copy:
return OAuthInfo.CheckOAuth(CopyOAuthInfo);
case FileDestination.Box:
return OAuth2Info.CheckOAuth(BoxOAuth2Info);
case FileDestination.Mega:
return MegaAuthInfos != null && MegaAuthInfos.Email != null && MegaAuthInfos.Hash != null && MegaAuthInfos.PasswordAesKey != null;
case FileDestination.AmazonS3:
return AmazonS3Settings != null && !string.IsNullOrEmpty(AmazonS3Settings.AccessKeyID) && !string.IsNullOrEmpty(AmazonS3Settings.SecretAccessKey) &&
!string.IsNullOrEmpty(AmazonS3Settings.Bucket) && AmazonS3.GetCurrentRegion(AmazonS3Settings) != AmazonS3.UnknownEndpoint;
case FileDestination.OwnCloud:
return !string.IsNullOrEmpty(OwnCloudHost) && !string.IsNullOrEmpty(OwnCloudUsername) && !string.IsNullOrEmpty(OwnCloudPassword);
case FileDestination.MediaFire:
return !string.IsNullOrEmpty(MediaFireUsername) && !string.IsNullOrEmpty(MediaFirePassword);
case FileDestination.Pushbullet:
return PushbulletSettings != null && !string.IsNullOrEmpty(PushbulletSettings.UserAPIKey) && PushbulletSettings.DeviceList != null &&
PushbulletSettings.DeviceList.IsValidIndex(PushbulletSettings.SelectedDevice);
2013-11-03 23:53:49 +13:00
case FileDestination.SendSpace:
return SendSpaceAccountType == AccountType.Anonymous || (!string.IsNullOrEmpty(SendSpaceUsername) && !string.IsNullOrEmpty(SendSpacePassword));
case FileDestination.Minus:
return MinusConfig != null && MinusConfig.MinusUser != null;
case FileDestination.Ge_tt:
return Ge_ttLogin != null && !string.IsNullOrEmpty(Ge_ttLogin.AccessToken);
case FileDestination.Localhostr:
return !string.IsNullOrEmpty(LocalhostrEmail) && !string.IsNullOrEmpty(LocalhostrPassword);
case FileDestination.Jira:
return OAuthInfo.CheckOAuth(JiraOAuthInfo);
case FileDestination.Lambda:
return LambdaSettings != null && !string.IsNullOrEmpty(LambdaSettings.UserAPIKey);
2015-10-07 12:43:51 +13:00
case FileDestination.Pomf:
return PomfUploader != null && !string.IsNullOrEmpty(PomfUploader.UploadURL);
2015-12-12 15:30:12 +13:00
case FileDestination.Sul:
return !string.IsNullOrEmpty(SulAPIKey);
2015-10-16 21:23:30 +13:00
case FileDestination.Seafile:
return !string.IsNullOrEmpty(SeafileAPIURL) && !string.IsNullOrEmpty(SeafileAuthToken) && !string.IsNullOrEmpty(SeafileRepoID);
2015-09-17 20:17:21 +12:00
case FileDestination.SharedFolder:
return LocalhostAccountList != null && LocalhostAccountList.IsValidIndex(LocalhostSelectedFiles);
case FileDestination.Email:
return !string.IsNullOrEmpty(EmailSmtpServer) && EmailSmtpPort > 0 && !string.IsNullOrEmpty(EmailFrom) && !string.IsNullOrEmpty(EmailPassword);
case FileDestination.CustomFileUploader:
return CustomUploadersList != null && CustomUploadersList.IsValidIndex(CustomFileUploaderSelected);
2013-11-03 23:53:49 +13:00
}
2014-06-17 03:24:30 +12:00
return true;
2013-11-03 23:53:49 +13:00
}
2014-07-12 05:41:39 +12:00
public bool IsValid(UrlShortenerType destination)
2013-11-03 23:53:49 +13:00
{
switch (destination)
{
2013-12-21 04:59:26 +13:00
case UrlShortenerType.BITLY:
return OAuth2Info.CheckOAuth(BitlyOAuth2Info);
2015-09-17 20:17:21 +12:00
case UrlShortenerType.Google:
return GoogleURLShortenerAccountType == AccountType.Anonymous || OAuth2Info.CheckOAuth(GoogleURLShortenerOAuth2Info);
2014-01-20 15:49:14 +13:00
case UrlShortenerType.YOURLS:
return !string.IsNullOrEmpty(YourlsAPIURL) && (!string.IsNullOrEmpty(YourlsSignature) || (!string.IsNullOrEmpty(YourlsUsername) && !string.IsNullOrEmpty(YourlsPassword)));
case UrlShortenerType.AdFly:
return !string.IsNullOrEmpty(AdFlyAPIKEY) && !string.IsNullOrEmpty(AdFlyAPIUID);
2015-07-21 08:12:13 +12:00
case UrlShortenerType.CoinURL:
return !string.IsNullOrEmpty(CoinURLUUID);
2015-08-05 06:49:07 +12:00
case UrlShortenerType.Polr:
return !string.IsNullOrEmpty(PolrAPIKey);
2013-11-03 23:53:49 +13:00
case UrlShortenerType.CustomURLShortener:
return CustomUploadersList != null && CustomUploadersList.IsValidIndex(CustomURLShortenerSelected);
}
2014-06-17 03:24:30 +12:00
return true;
2013-11-03 23:53:49 +13:00
}
2014-07-12 05:41:39 +12:00
public bool IsValid(URLSharingServices destination)
2013-11-03 23:53:49 +13:00
{
switch (destination)
{
2014-07-12 05:41:39 +12:00
case URLSharingServices.Email:
return !string.IsNullOrEmpty(EmailSmtpServer) && EmailSmtpPort > 0 && !string.IsNullOrEmpty(EmailFrom) && !string.IsNullOrEmpty(EmailPassword);
case URLSharingServices.Twitter:
2014-06-17 03:24:30 +12:00
return TwitterOAuthInfoList != null && TwitterOAuthInfoList.IsValidIndex(TwitterSelectedAccount) && OAuthInfo.CheckOAuth(TwitterOAuthInfoList[TwitterSelectedAccount]);
case URLSharingServices.Pushbullet:
return PushbulletSettings != null && !string.IsNullOrEmpty(PushbulletSettings.UserAPIKey) && PushbulletSettings.DeviceList != null &&
PushbulletSettings.DeviceList.IsValidIndex(PushbulletSettings.SelectedDevice);
2013-11-03 23:53:49 +13:00
}
2014-06-17 03:24:30 +12:00
return true;
2013-11-03 23:53:49 +13:00
}
public int GetFTPIndex(EDataType dataType)
{
switch (dataType)
{
case EDataType.Image:
return FTPSelectedImage;
case EDataType.Text:
return FTPSelectedText;
2014-07-12 05:41:39 +12:00
default:
case EDataType.File:
return FTPSelectedFile;
2013-11-03 23:53:49 +13:00
}
}
public int GetLocalhostIndex(EDataType dataType)
{
switch (dataType)
{
case EDataType.Image:
return LocalhostSelectedImages;
case EDataType.Text:
return LocalhostSelectedText;
2014-07-12 05:41:39 +12:00
default:
case EDataType.File:
return LocalhostSelectedFiles;
2013-11-03 23:53:49 +13:00
}
}
#endregion Helper Methods
}
2016-02-14 13:28:41 +13:00
}