mirror of
https://github.com/ShareX/ShareX.git
synced 2024-06-28 03:00:22 +12:00
Few user account checks
This commit is contained in:
parent
3e25bbdb04
commit
42e036a925
|
@ -1,3 +1 @@
|
|||
### [Download latest version](https://github.com/ShareX/ShareX/releases/latest)
|
||||
|
||||
### Website: [getsharex.com](http://www.getsharex.com)
|
||||
### [getsharex.com](http://getsharex.com)
|
|
@ -135,7 +135,7 @@ private void AddDestination<T>(int index, EDataType dataType, TaskSettings taskS
|
|||
{
|
||||
Enum destination = (Enum)Enum.ToObject(typeof(T), index);
|
||||
|
||||
if (Program.UploadersConfig.IsActive<T>(index))
|
||||
if (Program.UploadersConfig.IsValid<T>(index))
|
||||
{
|
||||
RadioButton rb = new RadioButton() { AutoSize = true };
|
||||
rb.Text = destination.GetDescription();
|
||||
|
|
|
@ -286,7 +286,7 @@ private void EnableDisableToolStripMenuItems<T>(params ToolStripDropDownItem[] p
|
|||
{
|
||||
for (int i = 0; i < parent.DropDownItems.Count; i++)
|
||||
{
|
||||
parent.DropDownItems[i].Enabled = Program.UploadersConfig.IsActive<T>(i);
|
||||
parent.DropDownItems[i].Enabled = Program.UploadersConfig.IsValid<T>(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -403,7 +403,7 @@ private void EnableDisableToolStripMenuItems<T>(params ToolStripDropDownItem[] p
|
|||
{
|
||||
for (int i = 0; i < parent.DropDownItems.Count; i++)
|
||||
{
|
||||
parent.DropDownItems[i].Enabled = Program.UploadersConfig.IsActive<T>(i);
|
||||
parent.DropDownItems[i].Enabled = Program.UploadersConfig.IsValid<T>(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,5 +11,5 @@
|
|||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("82E6AC09-0FEF-4390-AD9F-0DD3F5561EFC")]
|
||||
[assembly: AssemblyVersion("9.2.0")]
|
||||
[assembly: AssemblyFileVersion("9.2.0")]
|
||||
[assembly: AssemblyVersion("9.1.0")]
|
||||
[assembly: AssemblyFileVersion("9.1.0")]
|
|
@ -819,13 +819,10 @@ public UploadResult UploadFile(Stream stream, string fileName)
|
|||
fileUploader = new GfycatUploader();
|
||||
break;
|
||||
case FileDestination.Ge_tt:
|
||||
if (Program.UploadersConfig.IsActive(FileDestination.Ge_tt))
|
||||
fileUploader = new Ge_tt(APIKeys.Ge_ttKey)
|
||||
{
|
||||
fileUploader = new Ge_tt(APIKeys.Ge_ttKey)
|
||||
{
|
||||
AccessToken = Program.UploadersConfig.Ge_ttLogin.AccessToken
|
||||
};
|
||||
}
|
||||
AccessToken = Program.UploadersConfig.Ge_ttLogin.AccessToken
|
||||
};
|
||||
break;
|
||||
case FileDestination.Localhostr:
|
||||
fileUploader = new Hostr(Program.UploadersConfig.LocalhostrEmail, Program.UploadersConfig.LocalhostrPassword)
|
||||
|
|
|
@ -236,14 +236,14 @@ public class UploadersConfig : SettingsBase<UploadersConfig>
|
|||
|
||||
#endregion URL shorteners
|
||||
|
||||
#region Social networking services
|
||||
#region URL sharing services
|
||||
|
||||
// Twitter
|
||||
|
||||
public List<OAuthInfo> TwitterOAuthInfoList = new List<OAuthInfo>();
|
||||
public int TwitterSelectedAccount = 0;
|
||||
|
||||
#endregion Social networking services
|
||||
#endregion URL sharing services
|
||||
|
||||
#region Custom Uploaders
|
||||
|
||||
|
@ -257,39 +257,39 @@ public class UploadersConfig : SettingsBase<UploadersConfig>
|
|||
|
||||
#region Helper Methods
|
||||
|
||||
public bool IsActive<T>(int index)
|
||||
public bool IsValid<T>(int index)
|
||||
{
|
||||
Enum destination = (Enum)Enum.ToObject(typeof(T), index);
|
||||
|
||||
if (destination is ImageDestination)
|
||||
{
|
||||
return IsActive((ImageDestination)destination);
|
||||
return IsValid((ImageDestination)destination);
|
||||
}
|
||||
|
||||
if (destination is TextDestination)
|
||||
{
|
||||
return IsActive((TextDestination)destination);
|
||||
return IsValid((TextDestination)destination);
|
||||
}
|
||||
|
||||
if (destination is FileDestination)
|
||||
{
|
||||
return IsActive((FileDestination)destination);
|
||||
return IsValid((FileDestination)destination);
|
||||
}
|
||||
|
||||
if (destination is UrlShortenerType)
|
||||
{
|
||||
return IsActive((UrlShortenerType)destination);
|
||||
return IsValid((UrlShortenerType)destination);
|
||||
}
|
||||
|
||||
if (destination is URLSharingServices)
|
||||
{
|
||||
return IsActive((URLSharingServices)destination);
|
||||
return IsValid((URLSharingServices)destination);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool IsActive(ImageDestination destination)
|
||||
public bool IsValid(ImageDestination destination)
|
||||
{
|
||||
switch (destination)
|
||||
{
|
||||
|
@ -314,7 +314,7 @@ public bool IsActive(ImageDestination destination)
|
|||
return true;
|
||||
}
|
||||
|
||||
public bool IsActive(TextDestination destination)
|
||||
public bool IsValid(TextDestination destination)
|
||||
{
|
||||
switch (destination)
|
||||
{
|
||||
|
@ -325,7 +325,7 @@ public bool IsActive(TextDestination destination)
|
|||
return true;
|
||||
}
|
||||
|
||||
public bool IsActive(FileDestination destination)
|
||||
public bool IsValid(FileDestination destination)
|
||||
{
|
||||
switch (destination)
|
||||
{
|
||||
|
@ -362,12 +362,14 @@ public bool IsActive(FileDestination destination)
|
|||
case FileDestination.Pushbullet:
|
||||
return PushbulletSettings != null && !string.IsNullOrEmpty(PushbulletSettings.UserAPIKey) && PushbulletSettings.DeviceList != null &&
|
||||
PushbulletSettings.DeviceList.IsValidIndex(PushbulletSettings.SelectedDevice);
|
||||
case FileDestination.OwnCloud:
|
||||
return !string.IsNullOrEmpty(OwnCloudHost) && !string.IsNullOrEmpty(OwnCloudUsername) && !string.IsNullOrEmpty(OwnCloudPassword);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool IsActive(UrlShortenerType destination)
|
||||
public bool IsValid(UrlShortenerType destination)
|
||||
{
|
||||
switch (destination)
|
||||
{
|
||||
|
@ -384,10 +386,12 @@ public bool IsActive(UrlShortenerType destination)
|
|||
return true;
|
||||
}
|
||||
|
||||
public bool IsActive(URLSharingServices destination)
|
||||
public bool IsValid(URLSharingServices destination)
|
||||
{
|
||||
switch (destination)
|
||||
{
|
||||
case URLSharingServices.Email:
|
||||
return !string.IsNullOrEmpty(EmailSmtpServer) && EmailSmtpPort > 0 && !string.IsNullOrEmpty(EmailFrom) && !string.IsNullOrEmpty(EmailPassword);
|
||||
case URLSharingServices.Twitter:
|
||||
return TwitterOAuthInfoList != null && TwitterOAuthInfoList.IsValidIndex(TwitterSelectedAccount) && OAuthInfo.CheckOAuth(TwitterOAuthInfoList[TwitterSelectedAccount]);
|
||||
}
|
||||
|
@ -403,9 +407,10 @@ public int GetFTPIndex(EDataType dataType)
|
|||
return FTPSelectedImage;
|
||||
case EDataType.Text:
|
||||
return FTPSelectedText;
|
||||
default:
|
||||
case EDataType.File:
|
||||
return FTPSelectedFile;
|
||||
}
|
||||
|
||||
return FTPSelectedFile;
|
||||
}
|
||||
|
||||
public int GetLocalhostIndex(EDataType dataType)
|
||||
|
@ -416,9 +421,10 @@ public int GetLocalhostIndex(EDataType dataType)
|
|||
return LocalhostSelectedImages;
|
||||
case EDataType.Text:
|
||||
return LocalhostSelectedText;
|
||||
default:
|
||||
case EDataType.File:
|
||||
return LocalhostSelectedFiles;
|
||||
}
|
||||
|
||||
return LocalhostSelectedFiles;
|
||||
}
|
||||
|
||||
#endregion Helper Methods
|
||||
|
|
Loading…
Reference in a new issue