コード例 #1
0
        private void ImgurRefreshAlbumList()
        {
            try
            {
                lvImgurAlbumList.Items.Clear();

                if (OAuth2Info.CheckOAuth(Config.ImgurOAuth2Info))
                {
                    Config.ImgurAlbumList = new Imgur(Config.ImgurOAuth2Info).GetAlbums();
                    ImgurFillAlbumList();
                    lvImgurAlbumList.Focus();
                }
            }
            catch (Exception ex)
            {
                ex.ShowError();
            }
        }
コード例 #2
0
        private bool OAuth2Refresh(IOAuth2 uploader, OAuthControl oauth2)
        {
            try
            {
                if (OAuth2Info.CheckOAuth(uploader.AuthInfo))
                {
                    bool result = uploader.RefreshAccessToken();
                    ConfigureOAuthStatus(oauth2, result);
                    return(result);
                }
            }
            catch (Exception ex)
            {
                ex.ShowError();
            }

            return(false);
        }
コード例 #3
0
ファイル: GoogleOAuth2.cs プロジェクト: ywscr/ShareX
        public bool CheckAuthorization()
        {
            if (OAuth2Info.CheckOAuth(AuthInfo))
            {
                if (AuthInfo.Token.IsExpired && !RefreshAccessToken())
                {
                    GoogleUploader.Errors.Add("Refresh access token failed.");
                    return(false);
                }
            }
            else
            {
                GoogleUploader.Errors.Add("Login is required.");
                return(false);
            }

            return(true);
        }
コード例 #4
0
 public void BoxListFolders(BoxFileEntry fileEntry)
 {
     if (!OAuth2Info.CheckOAuth(Config.BoxOAuth2Info))
     {
         MessageBox.Show(Resources.UploadersConfigForm_ListFolders_Authentication_required_, Resources.UploadersConfigForm_BoxListFolders_Box_refresh_folders_list_failed,
                         MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         Box         box   = new Box(Config.BoxOAuth2Info);
         BoxFileInfo files = box.GetFiles(fileEntry);
         if (files != null && files.entries != null && files.entries.Length > 0)
         {
             foreach (BoxFileEntry folder in files.entries.Where(x => x.type == "folder"))
             {
                 BoxAddFolder(folder);
             }
         }
     }
 }
コード例 #5
0
        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.YOURLS:
                return(!string.IsNullOrEmpty(YourlsAPIURL) && (!string.IsNullOrEmpty(YourlsSignature) || (!string.IsNullOrEmpty(YourlsUsername) && !string.IsNullOrEmpty(YourlsPassword))));

            case UrlShortenerType.AdFly:
                return(!string.IsNullOrEmpty(AdFlyAPIKEY) && !string.IsNullOrEmpty(AdFlyAPIUID));

            case UrlShortenerType.CustomURLShortener:
                return(CustomUploadersList != null && CustomUploadersList.IsValidIndex(CustomURLShortenerSelected));
            }

            return(true);
        }
コード例 #6
0
ファイル: UploadersConfig.cs プロジェクト: felartu/ShareX
        public bool IsValid(ImageDestination destination)
        {
            ImageUploaderService service = UploaderFactory.GetImageUploaderServiceByEnum(destination);

            if (service != null)
            {
                return(service.CheckConfig(this));
            }

            switch (destination)
            {
            case ImageDestination.ImageShack:
                return(ImageShackSettings != null && !string.IsNullOrEmpty(ImageShackSettings.Auth_token));

            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));

            case ImageDestination.Twitter:
                return(TwitterOAuthInfoList != null && TwitterOAuthInfoList.IsValidIndex(TwitterSelectedAccount) && OAuthInfo.CheckOAuth(TwitterOAuthInfoList[TwitterSelectedAccount]));

            case ImageDestination.Chevereto:
                return(CheveretoUploader != null && !string.IsNullOrEmpty(CheveretoUploader.UploadURL) && !string.IsNullOrEmpty(CheveretoUploader.APIKey));

            case ImageDestination.CustomImageUploader:
                return(CustomUploadersList != null && CustomUploadersList.IsValidIndex(CustomImageUploaderSelected));
            }

            return(true);
        }
コード例 #7
0
ファイル: UploadersConfig.cs プロジェクト: sp1r00000/ShareX
        public bool IsValid(FileDestination destination)
        {
            switch (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.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.OwnCloud:
                return(!string.IsNullOrEmpty(OwnCloudHost) && !string.IsNullOrEmpty(OwnCloudUsername) && !string.IsNullOrEmpty(OwnCloudPassword));

            case FileDestination.MediaFire:
                return(!string.IsNullOrEmpty(MediaFireUsername) && !string.IsNullOrEmpty(MediaFirePassword));

            case FileDestination.Lambda:
                return(LambdaSettings != null && !string.IsNullOrEmpty(LambdaSettings.UserAPIKey));
            }

            return(true);
        }
コード例 #8
0
ファイル: UploadersConfig.cs プロジェクト: felartu/ShareX
        public bool IsValid(FileDestination destination)
        {
            FileUploaderService service = UploaderFactory.GetFileUploaderServiceByEnum(destination);

            if (service != null)
            {
                return(service.CheckConfig(this));
            }

            switch (destination)
            {
            case FileDestination.FTP:
                return(FTPAccountList != null && FTPAccountList.IsValidIndex(FTPSelectedFile));

            case FileDestination.OneDrive:
                return(OAuth2Info.CheckOAuth(OneDriveOAuth2Info));

            case FileDestination.GoogleDrive:
                return(OAuth2Info.CheckOAuth(GoogleDriveOAuth2Info));

            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));

            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.Pomf:
                return(PomfUploader != null && !string.IsNullOrEmpty(PomfUploader.UploadURL));

            case FileDestination.Sul:
                return(!string.IsNullOrEmpty(SulAPIKey));

            case FileDestination.Seafile:
                return(!string.IsNullOrEmpty(SeafileAPIURL) && !string.IsNullOrEmpty(SeafileAuthToken) && !string.IsNullOrEmpty(SeafileRepoID));

            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);
        }