示例#1
0
        public override GenericUploader CreateUploader(UploadersConfig config, TaskReferenceHelper taskInfo)
        {
            OAuth2Info oauth = new OAuth2Info(APIKeys.SlimgClientID, APIKeys.SlimgClientSecret);

            return new Slimg(oauth)
            {
                UploadMethod = AccountType.Anonymous
            };
        }
示例#2
0
        public DropboxFilesForm(OAuth2Info oauth, string path, DropboxAccountInfo accountInfo)
        {
            InitializeComponent();
            Icon = ShareXResources.Icon;

            dropbox = new Dropbox(oauth);
            dropboxAccountInfo = accountInfo;
            ilm = new ImageListManager(lvDropboxFiles);

            if (path != null)
            {
                Shown += (sender, e) => OpenDirectory(path);
            }
        }
示例#3
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);
        }
示例#4
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 = SendRequest(HttpMethod.POST, URLCreateFolder, json, RequestHelpers.ContentTypeJSON, null, GetAuthHeaders());

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

            return(metadata);
        }
示例#5
0
        // 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;
        }
示例#6
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 = SendRequestJSON(URLDelete, json, GetAuthHeaders());

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

            return(metadata);
        }
示例#7
0
        public DropboxAccountInfo GetCurrentAccountAPIv1()
        {
            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);
        }
示例#8
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 = SendRequestJSON(URLCopy, json, GetAuthHeaders());

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

            return(metadata);
        }
示例#9
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);
        }
示例#10
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 = SendRequest(HttpMethod.POST, URLMove, json, ContentTypeJSON, null, GetAuthHeaders());

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

            return(metadata);
        }
示例#11
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);
        }
示例#12
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);
            }
        }
        private void ImgurAuthOpen()
        {
            try
            {
                OAuth2Info oauth = new OAuth2Info(APIKeys.ImgurClientID, APIKeys.ImgurClientSecret);

                string url = new Imgur(oauth).GetAuthorizationURL();

                if (!string.IsNullOrEmpty(url))
                {
                    Config.ImgurOAuth2Info = oauth;
                    URLHelpers.OpenURL(url);
                    DebugHelper.WriteLine("ImgurAuthOpen - Authorization URL is opened: " + url);
                }
                else
                {
                    DebugHelper.WriteLine("ImgurAuthOpen - Authorization URL is empty.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#14
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);
        }
示例#15
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);
        }
示例#16
0
        private void OAuth_OpenAuthorizePageClick(object sender, RoutedEventArgs e)
        {
            try
            {
                OAuth2Info oauth = new OAuth2Info(APIKeys.DropboxConsumerKey, APIKeys.DropboxConsumerSecret);

                string url = new DropboxUploader(oauth).GetAuthorizationURL();

                if (!string.IsNullOrEmpty(url))
                {
                    DropboxUploader.Config.DropboxOAuth2Info = oauth;
                    URLHelper.OpenURL(url);
                    DebugHelper.WriteLine("DropboxAuthOpen - Authorization URL is opened: " + url);
                }
                else
                {
                    DebugHelper.WriteLine("DropboxAuthOpen - Authorization URL is empty.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
示例#17
0
文件: OneDrive.cs 项目: ywscr/ShareX
 public override bool CheckConfig(UploadersConfig config)
 {
     return(OAuth2Info.CheckOAuth(config.OneDriveV2OAuth2Info));
 }
示例#18
0
 public GfycatUploader(OAuth2Info oauth)
 {
     AuthInfo = oauth;
 }
示例#19
0
文件: Dropbox.cs 项目: thebaby/ShareX
 public Dropbox(OAuth2Info oauth)
 {
     AuthInfo = oauth;
 }
        public void DropboxAuthOpen()
        {
            try
            {
                OAuth2Info oauth = new OAuth2Info(APIKeys.DropboxConsumerKey, APIKeys.DropboxConsumerSecret);

                string url = new Dropbox(oauth).GetAuthorizationURL();

                if (!string.IsNullOrEmpty(url))
                {
                    Config.DropboxOAuth2Info = oauth;
                    URLHelpers.OpenURL(url);
                    DebugHelper.WriteLine("DropboxAuthOpen - Authorization URL is opened: " + url);
                }
                else
                {
                    DebugHelper.WriteLine("DropboxAuthOpen - Authorization URL is empty.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#21
0
 public GoogleURLShortener(AccountType uploadMethod, string anonymousKey, OAuth2Info oauth)
 {
     UploadMethod = uploadMethod;
     AnonymousKey = anonymousKey;
     AuthInfo     = oauth;
 }
示例#22
0
 public Box(OAuth2Info oauth)
 {
     AuthInfo = oauth;
     FolderID = "0";
     Share    = true;
 }
示例#23
0
 public GoogleURLShortener(OAuth2Info oauth)
 {
     UploadMethod = AccountType.User;
     AuthInfo = oauth;
 }
示例#24
0
 public GoogleURLShortener(AccountType uploadMethod, string anonymousKey, OAuth2Info oauth)
 {
     UploadMethod = uploadMethod;
     AnonymousKey = anonymousKey;
     AuthInfo = oauth;
 }
示例#25
0
 public Dropbox(OAuth2Info oauth)
 {
     AuthInfo = oauth;
 }
示例#26
0
文件: Imgur.cs 项目: Xanaxiel/ShareX
 public Imgur(OAuth2Info oauth)
 {
     AuthInfo = oauth;
 }
示例#27
0
 public GoogleDrive(OAuth2Info oauth)
 {
     AuthInfo = oauth;
 }
 public static bool CheckOAuth(OAuth2Info oauth)
 {
     return oauth != null && !string.IsNullOrEmpty(oauth.Client_ID) && !string.IsNullOrEmpty(oauth.Client_Secret) &&
            oauth.Token != null && !string.IsNullOrEmpty(oauth.Token.access_token);
 }
示例#29
0
 public Slimg(OAuth2Info oauth)
 {
     AuthInfo = oauth;
 }
示例#30
0
文件: Picasa.cs 项目: L1Q/ShareX
 public Picasa(OAuth2Info oauth)
 {
     AuthInfo = oauth;
 }
示例#31
0
 public override bool CheckConfig(UploadersConfig config)
 {
     return(OAuth2Info.CheckOAuth(config.GoogleCloudStorageOAuth2Info) && !string.IsNullOrEmpty(config.GoogleCloudStorageBucket));
 }
示例#32
0
 public OneDrive(OAuth2Info authInfo)
 {
     AuthInfo = authInfo;
 }
示例#33
0
文件: Imgur.cs 项目: qimingnan/ShareX
 public Imgur(OAuth2Info oauth)
 {
     AuthInfo = oauth;
 }
示例#34
0
 public GoogleURLShortener(OAuth2Info oauth)
 {
     UploadMethod = AccountType.User;
     AuthInfo     = oauth;
 }
示例#35
0
文件: Minus.cs 项目: Xanaxiel/ShareX
 public Minus(MinusOptions config, OAuth2Info auth)
 {
     Config = config;
     AuthInfo = auth;
 }
        public void GistAuthOpen()
        {
            try
            {
                OAuth2Info oauth = new OAuth2Info(APIKeys.GitHubID, APIKeys.GitHubSecret);
                string url = new Gist(oauth).GetAuthorizationURL();

                if (!string.IsNullOrEmpty(url))
                {
                    Config.GistOAuth2Info = oauth;
                    URLHelpers.OpenURL(url);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#37
0
文件: Box.cs 项目: RailTracker/ShareX
 public Box(OAuth2Info oauth)
 {
     AuthInfo = oauth;
     FolderID = "0";
     Share = true;
 }
示例#38
0
文件: Dropbox.cs 项目: thebaby/ShareX
        // https://www.dropbox.com/developers/core/docs#fileops-move
        public DropboxContentInfo Move(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, URLMove, args, GetAuthHeaders());

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

            return(contentInfo);
        }
示例#39
0
 public BitlyURLShortener(OAuth2Info oauth)
 {
     AuthInfo = oauth;
 }
示例#40
0
文件: Dropbox.cs 项目: thebaby/ShareX
 public Dropbox(OAuth2Info oauth, DropboxAccountInfo accountInfo)
     : this(oauth)
 {
     AccountInfo = accountInfo;
 }
示例#41
0
 public Minus(MinusOptions config, OAuth2Info auth)
 {
     Config   = config;
     AuthInfo = auth;
 }
示例#42
0
 public GoogleDrive(OAuth2Info oauth)
 {
     AuthInfo = oauth;
 }
示例#43
0
 public static bool CheckOAuth(OAuth2Info oauth)
 {
     return(oauth != null && !string.IsNullOrEmpty(oauth.Client_ID) && !string.IsNullOrEmpty(oauth.Client_Secret) &&
            oauth.Token != null && !string.IsNullOrEmpty(oauth.Token.access_token));
 }
示例#44
0
文件: OneDrive.cs 项目: ywscr/ShareX
 public OneDrive(OAuth2Info authInfo)
 {
     AuthInfo = authInfo;
 }
示例#45
0
 public Dropbox(OAuth2Info oauth, DropboxAccountInfo accountInfo) : this(oauth)
 {
     AccountInfo = accountInfo;
 }
示例#46
0
 public override bool CheckConfig(UploadersConfig config)
 {
     return(OAuth2Info.CheckOAuth(config.PicasaOAuth2Info));
 }
示例#47
0
文件: Hubic.cs 项目: andre-d/ShareXYZ
 public Hubic(OAuth2Info oauth, HubicOpenstackAuthInfo osauth)
 {
     AuthInfo = oauth;
     HubicOpenstackAuthInfo = osauth;
 }
示例#48
0
文件: Imgur.cs 项目: qimingnan/ShareX
 public override bool CheckConfig(UploadersConfig config)
 {
     return(config.ImgurAccountType == AccountType.Anonymous || OAuth2Info.CheckOAuth(config.ImgurOAuth2Info));
 }
示例#49
0
 public GitHubGist(OAuth2Info oAuthInfos)
 {
     AuthInfo = oAuthInfos;
 }