Account checks for all uploaders

This commit is contained in:
Jaex 2015-09-17 11:17:21 +03:00
parent d7659933ce
commit b1251b45a9
2 changed files with 38 additions and 33 deletions

View file

@ -41,10 +41,8 @@ namespace ShareX.UploadersLib.FileUploaders
{
public sealed class AmazonS3 : FileUploader
{
private AmazonS3Settings s3Settings { get; set; }
private static readonly AmazonS3Region UnknownEndpoint = new AmazonS3Region("Unknown Endpoint");
private static readonly AmazonS3Region DreamObjectsEndpoint = new AmazonS3Region("DreamObjects", "dreamobjects", "objects.dreamhost.com");
public static readonly AmazonS3Region UnknownEndpoint = new AmazonS3Region("Unknown Endpoint");
public static readonly AmazonS3Region DreamObjectsEndpoint = new AmazonS3Region("DreamObjects", "dreamobjects", "objects.dreamhost.com");
private static IList<AmazonS3Region> regionEndpoints = new List<AmazonS3Region>();
@ -63,6 +61,8 @@ public static IEnumerable<AmazonS3Region> RegionEndpoints
}
}
private AmazonS3Settings s3Settings { get; set; }
public AmazonS3(AmazonS3Settings s3Settings)
{
this.s3Settings = s3Settings;

View file

@ -341,12 +341,10 @@ public bool IsValid<T>(int index)
return IsValid((UrlShortenerType)destination);
}
/*
if (destination is URLSharingServices)
{
return IsValid((URLSharingServices)destination);
}
*/
return true;
}
@ -369,6 +367,8 @@ public bool IsValid(ImageDestination destination)
return OAuth2Info.CheckOAuth(PicasaOAuth2Info);
case ImageDestination.Twitter:
return TwitterOAuthInfoList != null && TwitterOAuthInfoList.IsValidIndex(TwitterSelectedAccount) && OAuthInfo.CheckOAuth(TwitterOAuthInfoList[TwitterSelectedAccount]);
case ImageDestination.Chevereto:
return !string.IsNullOrEmpty(CheveretoWebsite) && !string.IsNullOrEmpty(CheveretoAPIKey);
case ImageDestination.CustomImageUploader:
return CustomUploadersList != null && CustomUploadersList.IsValidIndex(CustomImageUploaderSelected);
}
@ -393,41 +393,46 @@ public bool IsValid(FileDestination destination)
{
case FileDestination.Dropbox:
return OAuth2Info.CheckOAuth(DropboxOAuth2Info);
case FileDestination.Copy:
return OAuthInfo.CheckOAuth(CopyOAuthInfo);
case FileDestination.GoogleDrive:
return OAuth2Info.CheckOAuth(GoogleDriveOAuth2Info);
case FileDestination.SendSpace:
return SendSpaceAccountType == AccountType.Anonymous || (!string.IsNullOrEmpty(SendSpaceUsername) && !string.IsNullOrEmpty(SendSpacePassword));
case FileDestination.Minus:
return MinusConfig != null && MinusConfig.MinusUser != null;
case FileDestination.Box:
return OAuth2Info.CheckOAuth(BoxOAuth2Info);
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.CustomFileUploader:
return CustomUploadersList != null && CustomUploadersList.IsValidIndex(CustomFileUploaderSelected);
case FileDestination.FTP:
return FTPAccountList != null && FTPAccountList.IsValidIndex(FTPSelectedFile);
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.Jira:
return OAuthInfo.CheckOAuth(JiraOAuthInfo);
case FileDestination.OneDrive:
return OAuth2Info.CheckOAuth(OneDriveOAuth2Info);
case FileDestination.GoogleDrive:
return OAuth2Info.CheckOAuth(GoogleDriveOAuth2Info);
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.Pushbullet:
return PushbulletSettings != null && !string.IsNullOrEmpty(PushbulletSettings.UserAPIKey) && PushbulletSettings.DeviceList != null &&
PushbulletSettings.DeviceList.IsValidIndex(PushbulletSettings.SelectedDevice);
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);
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);
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);
}
return true;
@ -437,10 +442,10 @@ public bool IsValid(UrlShortenerType destination)
{
switch (destination)
{
case UrlShortenerType.Google:
return GoogleURLShortenerAccountType == AccountType.Anonymous || OAuth2Info.CheckOAuth(GoogleURLShortenerOAuth2Info);
case UrlShortenerType.BITLY:
return OAuth2Info.CheckOAuth(BitlyOAuth2Info);
case UrlShortenerType.Google:
return GoogleURLShortenerAccountType == AccountType.Anonymous || OAuth2Info.CheckOAuth(GoogleURLShortenerOAuth2Info);
case UrlShortenerType.YOURLS:
return !string.IsNullOrEmpty(YourlsAPIURL) && (!string.IsNullOrEmpty(YourlsSignature) || (!string.IsNullOrEmpty(YourlsUsername) && !string.IsNullOrEmpty(YourlsPassword)));
case UrlShortenerType.AdFly: