예제 #1
0
        public bool CheckAuthorization()
        {
            if (OAuth2Info.CheckOAuth(AuthInfo))
            {
                if (AuthInfo.Token.IsExpired && !RefreshAccessToken())
                {
                    Errors.Add("Refresh access token failed.");
                    return(false);
                }
            }
            else
            {
                Errors.Add("Login is required.");
                return(false);
            }

            return(true);
        }
예제 #2
0
        public string CreateShareableLink(string path, DropboxURLType urlType)
        {
            if (!string.IsNullOrEmpty(path) && OAuth2Info.CheckOAuth(AuthInfo))
            {
                string json = JsonConvert.SerializeObject(new
                {
                    path     = VerifyPath(path),
                    settings = new
                    {
                        requested_visibility = "public" // Anyone who has received the link can access it. No login required.
                    }
                });

                // TODO: Missing: args.Add("short_url", urlType == DropboxURLType.Shortened ? "true" : "false");

                string response = SendRequestJSON(URLCreateSharedLink, json, GetAuthHeaders());

                if (!string.IsNullOrEmpty(response))
                {
                    DropboxLinkMetadata linkMetadata = JsonConvert.DeserializeObject <DropboxLinkMetadata>(response);

                    if (urlType == DropboxURLType.Direct)
                    {
                        Match match = Regex.Match(linkMetadata.url, @"https?://(?:www\.)?dropbox.com/s/(?<path>\w+/.+)");

                        if (match.Success)
                        {
                            string urlPath = match.Groups["path"].Value;

                            if (!string.IsNullOrEmpty(urlPath))
                            {
                                return(URLHelpers.CombineURL(URLShareDirect, urlPath));
                            }
                        }
                    }
                    else
                    {
                        return(linkMetadata.url);
                    }
                }
            }

            return(null);
        }
예제 #3
0
 internal void UpdateDropboxStatus()
 {
     if (OAuth2Info.CheckOAuth(DropboxUploader.Config.DropboxOAuth2Info) && DropboxUploader.Config.DropboxAccountInfo != null)
     {
         StringBuilder sb = new StringBuilder();
         sb.AppendLine("Email: " + DropboxUploader.Config.DropboxAccountInfo.Email);
         sb.AppendLine("Name: " + DropboxUploader.Config.DropboxAccountInfo.Display_name);
         sb.AppendLine("ID: " + DropboxUploader.Config.DropboxAccountInfo.Uid.ToString());
         // string uploadPath = GetDropboxUploadPath();
         // sb.AppendLine("Upload path: " + uploadPath);
         // sb.AppendLine("Download path: " + DropboxUploader.GetPublicURL(DropboxUploader.Config.DropboxAccountInfo.Uid, uploadPath + "Example.png"));
         lblDropboxStatus.Text = sb.ToString();
         // btnDropboxShowFiles.Enabled = true;
     }
     else
     {
         lblDropboxStatus.Text = string.Empty;
     }
 }
예제 #4
0
파일: Dropbox.cs 프로젝트: thebaby/ShareX
        // https://www.dropbox.com/developers/core/docs#fileops-delete
        public DropboxContentInfo Delete(string path)
        {
            DropboxContentInfo contentInfo = null;

            if (!string.IsNullOrEmpty(path) && OAuth2Info.CheckOAuth(AuthInfo))
            {
                Dictionary <string, string> args = new Dictionary <string, string>();
                args.Add("root", Root);
                args.Add("path", path);

                string response = SendRequest(HttpMethod.POST, URLDelete, args, GetAuthHeaders());

                if (!string.IsNullOrEmpty(response))
                {
                    contentInfo = JsonConvert.DeserializeObject <DropboxContentInfo>(response);
                }
            }

            return(contentInfo);
        }
예제 #5
0
        public bool IsActive(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.CustomURLShortener:
                return(CustomUploadersList != null && CustomUploadersList.IsValidIndex(CustomURLShortenerSelected));

            default:
                return(true);
            }
        }
예제 #6
0
        public DropboxAccount GetCurrentAccount()
        {
            DropboxAccount account = null;

            if (OAuth2Info.CheckOAuth(AuthInfo))
            {
                string response = SendRequestJSON(URLGetCurrentAccount, "null", GetAuthHeaders());

                if (!string.IsNullOrEmpty(response))
                {
                    account = JsonConvert.DeserializeObject <DropboxAccount>(response);

                    if (account != null)
                    {
                        Account = account;
                    }
                }
            }

            return(account);
        }
예제 #7
0
        public DropboxMetadata Delete(string path)
        {
            DropboxMetadata metadata = null;

            if (!string.IsNullOrEmpty(path) && OAuth2Info.CheckOAuth(AuthInfo))
            {
                string json = JsonConvert.SerializeObject(new
                {
                    path = VerifyPath(path)
                });

                string response = SendRequest(HttpMethod.POST, URLDelete, json, ContentTypeJSON, null, GetAuthHeaders());

                if (!string.IsNullOrEmpty(response))
                {
                    metadata = JsonConvert.DeserializeObject <DropboxMetadata>(response);
                }
            }

            return(metadata);
        }
예제 #8
0
파일: Dropbox.cs 프로젝트: thebaby/ShareX
        /* OAuth 1.0
         * // https://www.dropbox.com/developers/core/docs#request-token
         * // https://www.dropbox.com/developers/core/docs#authorize
         * public string GetAuthorizationURL()
         * {
         *  return GetAuthorizationURL(URLAPI + "/oauth/request_token", URLWEB + "/oauth/authorize", AuthInfo);
         * }
         *
         * // https://www.dropbox.com/developers/core/docs#access-token
         * public bool GetAccessToken(string verificationCode = null)
         * {
         *  AuthInfo.AuthVerifier = verificationCode;
         *  return GetAccessToken(URLAPI + "/oauth/access_token", AuthInfo);
         * }
         */

        #region Dropbox accounts

        // https://www.dropbox.com/developers/core/docs#account-info
        public DropboxAccountInfo GetAccountInfo()
        {
            DropboxAccountInfo account = null;

            if (OAuth2Info.CheckOAuth(AuthInfo))
            {
                string response = SendRequest(HttpMethod.GET, URLAccountInfo, headers: GetAuthHeaders());

                if (!string.IsNullOrEmpty(response))
                {
                    account = JsonConvert.DeserializeObject <DropboxAccountInfo>(response);

                    if (account != null)
                    {
                        AccountInfo = account;
                    }
                }
            }

            return(account);
        }
예제 #9
0
        public DropboxMetadata CreateFolder(string path)
        {
            DropboxMetadata metadata = null;

            if (!string.IsNullOrEmpty(path) && OAuth2Info.CheckOAuth(AuthInfo))
            {
                string json = JsonConvert.SerializeObject(new
                {
                    path = VerifyPath(path)
                });

                string response = SendRequestJSON(URLCreateFolder, json, GetAuthHeaders());

                if (!string.IsNullOrEmpty(response))
                {
                    metadata = JsonConvert.DeserializeObject <DropboxMetadata>(response);
                }
            }

            return(metadata);
        }
예제 #10
0
파일: Dropbox.cs 프로젝트: thebaby/ShareX
        // https://www.dropbox.com/developers/core/docs#metadata
        public DropboxContentInfo GetMetadata(string path, bool list)
        {
            DropboxContentInfo contentInfo = null;

            if (OAuth2Info.CheckOAuth(AuthInfo))
            {
                string url = URLHelpers.CombineURL(URLMetaData, URLHelpers.URLPathEncode(path));

                Dictionary <string, string> args = new Dictionary <string, string>();
                args.Add("list", list ? "true" : "false");

                string response = SendRequest(HttpMethod.GET, url, args, GetAuthHeaders());

                if (!string.IsNullOrEmpty(response))
                {
                    contentInfo = JsonConvert.DeserializeObject <DropboxContentInfo>(response);
                }
            }

            return(contentInfo);
        }
예제 #11
0
        public DropboxMetadata Copy(string fromPath, string toPath)
        {
            DropboxMetadata metadata = null;

            if (!string.IsNullOrEmpty(fromPath) && !string.IsNullOrEmpty(toPath) && OAuth2Info.CheckOAuth(AuthInfo))
            {
                string json = JsonConvert.SerializeObject(new
                {
                    from_path = VerifyPath(fromPath),
                    to_path   = VerifyPath(toPath)
                });

                string response = SendRequest(HttpMethod.POST, URLCopy, json, RequestHelpers.ContentTypeJSON, null, GetAuthHeaders());

                if (!string.IsNullOrEmpty(response))
                {
                    metadata = JsonConvert.DeserializeObject <DropboxMetadata>(response);
                }
            }

            return(metadata);
        }
예제 #12
0
        public DropboxMetadata Move(string fromPath, string toPath)
        {
            DropboxMetadata metadata = null;

            if (!string.IsNullOrEmpty(fromPath) && !string.IsNullOrEmpty(toPath) && OAuth2Info.CheckOAuth(AuthInfo))
            {
                string json = JsonConvert.SerializeObject(new
                {
                    from_path = VerifyPath(fromPath),
                    to_path   = VerifyPath(toPath)
                });

                string response = SendRequestJSON(URLMove, json, GetAuthHeaders());

                if (!string.IsNullOrEmpty(response))
                {
                    metadata = JsonConvert.DeserializeObject <DropboxMetadata>(response);
                }
            }

            return(metadata);
        }
예제 #13
0
        public DropboxListSharedLinksResult ListSharedLinks(string path, bool directOnly = false)
        {
            DropboxListSharedLinksResult result = null;

            if (path != null && OAuth2Info.CheckOAuth(AuthInfo))
            {
                string json = JsonConvert.SerializeObject(new
                {
                    path        = VerifyPath(path),
                    direct_only = directOnly
                });

                string response = SendRequest(HttpMethod.POST, URLListSharedLinks, json, ContentTypeJSON, null, GetAuthHeaders());

                if (!string.IsNullOrEmpty(response))
                {
                    result = JsonConvert.DeserializeObject <DropboxListSharedLinksResult>(response);
                }
            }

            return(result);
        }
예제 #14
0
        public bool IsActive(ImageDestination destination)
        {
            switch (destination)
            {
            case ImageDestination.ImageShack:
                return(ImageShackAccountType == AccountType.Anonymous || !string.IsNullOrEmpty(ImageShackRegistrationCode));

            case ImageDestination.TinyPic:
                return(TinyPicAccountType == AccountType.Anonymous || !string.IsNullOrEmpty(TinyPicRegistrationCode));

            case ImageDestination.Imgur:
                return(ImgurAccountType == AccountType.Anonymous || OAuth2Info.CheckOAuth(ImgurOAuth2Info));

            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.Twitpic:
            case ImageDestination.Twitsnaps:
                return(TwitterOAuthInfoList != null && TwitterOAuthInfoList.IsValidIndex(TwitterSelectedAccount));

            case ImageDestination.yFrog:
                return(!string.IsNullOrEmpty(YFrogUsername) && !string.IsNullOrEmpty(YFrogPassword));

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

            default:
                return(true);
            }
        }
예제 #15
0
        public DropboxMetadata GetMetadata(string path)
        {
            DropboxMetadata metadata = null;

            if (path != null && OAuth2Info.CheckOAuth(AuthInfo))
            {
                string json = JsonConvert.SerializeObject(new
                {
                    path = VerifyPath(path),
                    include_media_info = false,
                    include_deleted    = false,
                    include_has_explicit_shared_members = false
                });

                string response = SendRequest(HttpMethod.POST, URLGetMetadata, json, ContentTypeJSON, null, GetAuthHeaders());

                if (!string.IsNullOrEmpty(response))
                {
                    metadata = JsonConvert.DeserializeObject <DropboxMetadata>(response);
                }
            }

            return(metadata);
        }
예제 #16
0
파일: Dropbox.cs 프로젝트: thebaby/ShareX
        // https://www.dropbox.com/developers/core/docs#shares
        public string CreateShareableLink(string path, DropboxURLType urlType)
        {
            if (!string.IsNullOrEmpty(path) && OAuth2Info.CheckOAuth(AuthInfo))
            {
                string url = URLHelpers.CombineURL(URLShares, URLHelpers.URLPathEncode(path));

                Dictionary <string, string> args = new Dictionary <string, string>();
                args.Add("short_url", urlType == DropboxURLType.Shortened ? "true" : "false");

                string response = SendRequest(HttpMethod.POST, url, args, GetAuthHeaders());

                if (!string.IsNullOrEmpty(response))
                {
                    DropboxShares shares = JsonConvert.DeserializeObject <DropboxShares>(response);

                    if (urlType == DropboxURLType.Direct)
                    {
                        Match match = Regex.Match(shares.URL, @"https?://(?:www\.)?dropbox.com/s/(?<path>\w+/.+)");
                        if (match.Success)
                        {
                            string urlPath = match.Groups["path"].Value;
                            if (!string.IsNullOrEmpty(urlPath))
                            {
                                return(URLHelpers.CombineURL(URLShareDirect, urlPath));
                            }
                        }
                    }
                    else
                    {
                        return(shares.URL);
                    }
                }
            }

            return(null);
        }
예제 #17
0
 public override bool CheckConfig(UploadersConfig config)
 {
     return(OAuth2Info.CheckOAuth(config.PicasaOAuth2Info));
 }
예제 #18
0
 public override bool CheckConfig(UploadersConfig config)
 {
     return(OAuth2Info.CheckOAuth(config.GooglePhotosOAuth2Info));
 }
예제 #19
0
 public override bool CheckConfig(UploadersConfig config)
 {
     return(config.GoogleURLShortenerAccountType == AccountType.Anonymous || OAuth2Info.CheckOAuth(config.GoogleURLShortenerOAuth2Info));
 }
예제 #20
0
        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.RapidShare:
                return(!string.IsNullOrEmpty(RapidShareUsername) && !string.IsNullOrEmpty(RapidSharePassword));

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

            return(true);
        }
예제 #21
0
파일: Dropbox.cs 프로젝트: dasilva94/ShareX
        // https://www.dropbox.com/developers/core/docs#fileops-copy
        public DropboxContentInfo Copy(string from_path, string to_path)
        {
            DropboxContentInfo contentInfo = null;

            if (!string.IsNullOrEmpty(from_path) && !string.IsNullOrEmpty(to_path) && OAuth2Info.CheckOAuth(AuthInfo))
            {
                Dictionary<string, string> args = new Dictionary<string, string>();
                args.Add("root", Root);
                args.Add("from_path", from_path);
                args.Add("to_path", to_path);

                string response = SendRequest(HttpMethod.POST, URLCopy, args, GetAuthHeaders());

                if (!string.IsNullOrEmpty(response))
                {
                    contentInfo = JsonConvert.DeserializeObject<DropboxContentInfo>(response);
                }
            }

            return contentInfo;
        }
예제 #22
0
파일: OneDrive.cs 프로젝트: ywscr/ShareX
 public override bool CheckConfig(UploadersConfig config)
 {
     return(OAuth2Info.CheckOAuth(config.OneDriveV2OAuth2Info));
 }
예제 #23
0
 public override bool CheckConfig(UploadersConfig config)
 {
     return OAuth2Info.CheckOAuth(config.BitlyOAuth2Info);
 }
예제 #24
0
 public override bool CheckConfig(UploadersConfig config)
 {
     return(!string.IsNullOrEmpty(config.TeknikUploadAPIUrl) &&
            !string.IsNullOrEmpty(config.TeknikAuthUrl) &&
            OAuth2Info.CheckOAuth(config.TeknikOAuth2Info));
 }
예제 #25
0
 public override bool CheckConfig(UploadersConfig config)
 {
     return(OAuth2Info.CheckOAuth(config.GoogleCloudStorageOAuth2Info) && !string.IsNullOrEmpty(config.GoogleCloudStorageBucket));
 }
예제 #26
0
        public void LoadSettings(UploadersConfig uploadersConfig)
        {
            #region Image uploaders

            // ImageShack

            atcImageShackAccountType.SelectedAccountType = Config.ImageShackSettings.AccountType;
            txtImageShackUsername.Text   = Config.ImageShackSettings.Username;
            txtImageShackPassword.Text   = Config.ImageShackSettings.Password;
            cbImageShackIsPublic.Checked = Config.ImageShackSettings.IsPublic;

            // TinyPic

            atcTinyPicAccountType.SelectedAccountType = Config.TinyPicAccountType;
            txtTinyPicUsername.Text = Config.TinyPicUsername;
            txtTinyPicPassword.Text = Config.TinyPicPassword;

            // Imgur

            atcImgurAccountType.SelectedAccountType = Config.ImgurAccountType;
            cbImgurThumbnailType.Items.Clear();
            cbImgurThumbnailType.Items.AddRange(Helpers.GetEnumDescriptions <ImgurThumbnailType>());
            cbImgurThumbnailType.SelectedIndex = (int)Config.ImgurThumbnailType;
            txtImgurAlbumID.Text = Config.ImgurAlbumID;

            if (OAuth2Info.CheckOAuth(Config.ImgurOAuth2Info))
            {
                oauth2Imgur.Status               = "Login successful.";
                oauth2Imgur.LoginStatus          = true;
                btnImgurRefreshAlbumList.Enabled = true;
            }

            // Photobucket

            if (OAuthInfo.CheckOAuth(Config.PhotobucketOAuthInfo))
            {
                lblPhotobucketAccountStatus.Text    = "Login successful: " + Config.PhotobucketOAuthInfo.UserToken;
                txtPhotobucketDefaultAlbumName.Text = Config.PhotobucketAccountInfo.AlbumID;
                lblPhotobucketParentAlbumPath.Text  = "Parent album path e.g. " + Config.PhotobucketAccountInfo.AlbumID + "/Personal/" + DateTime.Now.Year;
            }

            if (Config.PhotobucketAccountInfo != null)
            {
                cboPhotobucketAlbumPaths.Items.Clear();

                if (Config.PhotobucketAccountInfo.AlbumList.Count > 0)
                {
                    cboPhotobucketAlbumPaths.Items.AddRange(Config.PhotobucketAccountInfo.AlbumList.ToArray());
                    cboPhotobucketAlbumPaths.SelectedIndex = Config.PhotobucketAccountInfo.ActiveAlbumID.
                                                             BetweenOrDefault(0, Config.PhotobucketAccountInfo.AlbumList.Count - 1);
                }
            }

            // Picasa

            if (OAuth2Info.CheckOAuth(Config.PicasaOAuth2Info))
            {
                oauth2Picasa.Status               = "Login successful.";
                oauth2Picasa.LoginStatus          = true;
                btnPicasaRefreshAlbumList.Enabled = true;
            }

            txtPicasaAlbumID.Text = Config.PicasaAlbumID;

            // Flickr

            pgFlickrAuthInfo.SelectedObject = Config.FlickrAuthInfo;
            pgFlickrSettings.SelectedObject = Config.FlickrSettings;

            // TwitPic

            chkTwitPicShowFull.Checked = Config.TwitPicShowFull;
            cboTwitPicThumbnailMode.Items.Clear();
            cboTwitPicThumbnailMode.Items.AddRange(Helpers.GetEnumDescriptions <TwitPicThumbnailType>());
            cboTwitPicThumbnailMode.SelectedIndex = (int)Config.TwitPicThumbnailMode;

            // YFrog

            txtYFrogUsername.Text = Config.YFrogUsername;
            txtYFrogPassword.Text = Config.YFrogPassword;

            #endregion Image uploaders

            #region Text uploaders

            // Pastebin

            pgPastebinSettings.SelectedObject = Config.PastebinSettings;

            // Paste.ee

            txtPaste_eeUserAPIKey.Text = Config.Paste_eeUserAPIKey;

            // Gist

            atcGistAccountType.SelectedAccountType = Config.GistAnonymousLogin ? AccountType.Anonymous : AccountType.User;
            chkGistPublishPublic.Checked           = Config.GistPublishPublic;

            if (OAuth2Info.CheckOAuth(Config.GistOAuth2Info))
            {
                oAuth2Gist.Status      = "Login successful.";
                oAuth2Gist.LoginStatus = true;
            }

            // Upaste

            txtUpasteUserKey.Text    = Config.UpasteUserKey;
            cbUpasteIsPublic.Checked = Config.UpasteIsPublic;

            #endregion Text uploaders

            #region File uploaders

            // Dropbox

            txtDropboxPath.Text = Config.DropboxUploadPath;
            cbDropboxAutoCreateShareableLink.Checked = Config.DropboxAutoCreateShareableLink;
            cbDropboxURLType.Enabled = Config.DropboxAutoCreateShareableLink;
            cbDropboxURLType.Items.AddRange(Helpers.GetEnumNamesProper <DropboxURLType>());
            cbDropboxURLType.SelectedIndex = (int)Config.DropboxURLType;
            UpdateDropboxStatus();

            // Google Drive

            if (OAuth2Info.CheckOAuth(Config.GoogleDriveOAuth2Info))
            {
                oauth2GoogleDrive.Status      = "Login successful.";
                oauth2GoogleDrive.LoginStatus = true;
            }

            cbGoogleDriveIsPublic.Checked = Config.GoogleDriveIsPublic;

            // Minus

            cbMinusURLType.Items.Clear();
            cbMinusURLType.Items.AddRange(Enum.GetNames(typeof(MinusLinkType)));
            MinusUpdateControls();

            // Box

            if (OAuth2Info.CheckOAuth(Config.BoxOAuth2Info))
            {
                oauth2Box.Status             = "Login successful.";
                oauth2Box.LoginStatus        = true;
                btnBoxRefreshFolders.Enabled = true;
            }

            cbBoxShare.Checked  = Config.BoxShare;
            lblBoxFolderID.Text = "Selected folder: " + Config.BoxSelectedFolder.name;

            // Ge.tt

            lblGe_ttAccessToken.Text = "Access token:";

            if (Config.Ge_ttLogin != null && !string.IsNullOrEmpty(Config.Ge_ttLogin.AccessToken))
            {
                lblGe_ttAccessToken.Text += " " + Config.Ge_ttLogin.AccessToken;
            }

            // Localhostr

            txtLocalhostrEmail.Text       = Config.LocalhostrEmail;
            txtLocalhostrPassword.Text    = Config.LocalhostrPassword;
            cbLocalhostrDirectURL.Checked = Config.LocalhostrDirectURL;

            // FTP

            if (Config.FTPAccountList == null || Config.FTPAccountList.Count == 0)
            {
                FTPSetup(new List <FTPAccount>());
            }
            else
            {
                FTPSetup(Config.FTPAccountList);
                if (ucFTPAccounts.lbAccounts.Items.Count > 0)
                {
                    ucFTPAccounts.lbAccounts.SelectedIndex = 0;
                }
            }

            // Email

            txtEmailSmtpServer.Text       = Config.EmailSmtpServer;
            nudEmailSmtpPort.Value        = Config.EmailSmtpPort;
            txtEmailFrom.Text             = Config.EmailFrom;
            txtEmailPassword.Text         = Config.EmailPassword;
            chkEmailConfirm.Checked       = Config.EmailConfirmSend;
            cbEmailRememberLastTo.Checked = Config.EmailRememberLastTo;
            txtEmailDefaultSubject.Text   = Config.EmailDefaultSubject;
            txtEmailDefaultBody.Text      = Config.EmailDefaultBody;

            // RapidShare

            txtRapidShareUsername.Text = Config.RapidShareUsername;
            txtRapidSharePassword.Text = Config.RapidSharePassword;
            txtRapidShareFolderID.Text = Config.RapidShareFolderID;

            // SendSpace

            atcSendSpaceAccountType.SelectedAccountType = Config.SendSpaceAccountType;
            txtSendSpacePassword.Text = Config.SendSpacePassword;
            txtSendSpaceUserName.Text = Config.SendSpaceUsername;

            // Localhost

            if (Config.LocalhostAccountList == null || Config.LocalhostAccountList.Count == 0)
            {
                LocalhostAccountsSetup(new List <LocalhostAccount>());
            }
            else
            {
                LocalhostAccountsSetup(Config.LocalhostAccountList);
                if (ucLocalhostAccounts.lbAccounts.Items.Count > 0)
                {
                    ucLocalhostAccounts.lbAccounts.SelectedIndex = 0;
                    cboSharedFolderImages.SelectedIndex          = Config.LocalhostSelectedImages.Between(0, ucLocalhostAccounts.lbAccounts.Items.Count - 1);
                    cboSharedFolderText.SelectedIndex            = Config.LocalhostSelectedText.Between(0, ucLocalhostAccounts.lbAccounts.Items.Count - 1);
                    cboSharedFolderFiles.SelectedIndex           = Config.LocalhostSelectedFiles.Between(0, ucLocalhostAccounts.lbAccounts.Items.Count - 1);
                }
            }

            // Custom uploaders

            lbCustomUploaderList.Items.Clear();

            if (Config.CustomUploadersList == null)
            {
                Config.CustomUploadersList = new List <CustomUploaderItem>();
            }
            else
            {
                foreach (CustomUploaderItem customUploader in Config.CustomUploadersList)
                {
                    lbCustomUploaderList.Items.Add(customUploader.Name);
                }

                PrepareCustomUploaderList();
            }

            cbCustomUploaderRequestType.Items.AddRange(Enum.GetNames(typeof(CustomUploaderRequestType)));
            cbCustomUploaderResponseType.Items.AddRange(Helpers.GetEnumDescriptions <ResponseType>());

            CustomUploaderClear();

            // Jira

            txtJiraHost.Text        = Config.JiraHost;
            txtJiraIssuePrefix.Text = Config.JiraIssuePrefix;
            txtJiraConfigHelp.Text  = string.Format(@"Howto configure your Jira server:

- Go to 'Administration' -> 'Add-ons'
- Select 'Application Links'

- Add a new 'Application Link' with following settings:
    - Server URL: {0}
    - Application Name: {1}
    - Application Type: Generic Application

- Now, you have to configure Incoming Authentication
        - Consumer Key: {2}
        - Consumer Name: {1}
        - Public Key (without quotes): '{3}'

- You can now authenticate to Jira", Links.URL_WEBSITE, Application.ProductName, APIKeys.JiraConsumerKey, Jira.PublicKey);

            if (OAuthInfo.CheckOAuth(Config.JiraOAuthInfo))
            {
                oAuthJira.Status      = "Login successful.";
                oAuthJira.LoginStatus = true;
            }

            // Mega

            MegaConfigureTab(false);

            //Pushbullet

            txtPushbulletUserKey.Text = Config.PushbulletSettings.UserAPIKey;

            if (Config.PushbulletSettings.DeviceList.Count > 0)
            {
                Config.PushbulletSettings.DeviceList.ForEach(x => cboPushbulletDevices.Items.Add(x.Name ?? "Invalid device name"));

                if (Config.PushbulletSettings.DeviceList.IsValidIndex(Config.PushbulletSettings.SelectedDevice))
                {
                    cboPushbulletDevices.SelectedIndex = Config.PushbulletSettings.SelectedDevice;
                }
                else
                {
                    cboPushbulletDevices.SelectedIndex = 0;
                }
            }

            // Amazon S3

            txtAmazonS3AccessKey.Text     = Config.AmazonS3Settings.AccessKeyID;
            txtAmazonS3SecretKey.Text     = Config.AmazonS3Settings.SecretAccessKey;
            cbAmazonS3UseRRS.Checked      = Config.AmazonS3Settings.UseReducedRedundancyStorage;
            cbAmazonS3Endpoint.Text       = Config.AmazonS3Settings.Endpoint;
            cbAmazonS3CustomCNAME.Checked = Config.AmazonS3Settings.UseCustomCNAME;
            txtAmazonS3BucketName.Text    = Config.AmazonS3Settings.Bucket;
            txtAmazonS3ObjectPrefix.Text  = Config.AmazonS3Settings.ObjectPrefix;

            #endregion File uploaders

            #region URL Shorteners

            // Google URL Shortener

            atcGoogleURLShortenerAccountType.SelectedAccountType = Config.GoogleURLShortenerAccountType;

            if (OAuth2Info.CheckOAuth(Config.GoogleURLShortenerOAuth2Info))
            {
                oauth2GoogleURLShortener.Status      = "Login successful.";
                oauth2GoogleURLShortener.LoginStatus = true;
            }

            // bit.ly

            if (OAuth2Info.CheckOAuth(Config.BitlyOAuth2Info))
            {
                oauth2Bitly.Status      = "Login successful.";
                oauth2Bitly.LoginStatus = true;
            }

            // yourls.org

            txtYourlsAPIURL.Text      = Config.YourlsAPIURL;
            txtYourlsSignature.Text   = Config.YourlsSignature;
            txtYourlsUsername.Enabled = txtYourlsPassword.Enabled = string.IsNullOrEmpty(Config.YourlsSignature);
            txtYourlsUsername.Text    = Config.YourlsUsername;
            txtYourlsPassword.Text    = Config.YourlsPassword;

            #endregion URL Shorteners

            #region Other Services

            ucTwitterAccounts.lbAccounts.Items.Clear();

            foreach (OAuthInfo acc in Config.TwitterOAuthInfoList)
            {
                ucTwitterAccounts.lbAccounts.Items.Add(acc);
            }

            if (ucTwitterAccounts.lbAccounts.Items.Count > 0)
            {
                ucTwitterAccounts.lbAccounts.SelectedIndex = Config.TwitterSelectedAccount;
            }

            #endregion Other Services
        }
예제 #27
0
파일: Imgur.cs 프로젝트: qimingnan/ShareX
 public override bool CheckConfig(UploadersConfig config)
 {
     return(config.ImgurAccountType == AccountType.Anonymous || OAuth2Info.CheckOAuth(config.ImgurOAuth2Info));
 }
예제 #28
0
파일: Dropbox.cs 프로젝트: felartu/ShareX
 public override bool CheckConfig(UploadersConfig uploadersConfig)
 {
     return(OAuth2Info.CheckOAuth(uploadersConfig.DropboxOAuth2Info));
 }