예제 #1
0
        private void FlickrAuthComplete(string code)
        {
            try
            {
                if (!string.IsNullOrEmpty(code) && Config.FlickrOAuthInfo != null)
                {
                    bool result = new FlickrUploader(Config.FlickrOAuthInfo).GetAccessToken(code);

                    if (result)
                    {
                        oauthFlickr.Status = OAuthLoginStatus.LoginSuccessful;
                        MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        oauthFlickr.Status = OAuthLoginStatus.LoginFailed;
                        MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                ex.ShowError();
            }
        }
예제 #2
0
 public void FlickrOpenImages()
 {
     if (Config.FlickrAuthInfo != null)
     {
         string userID = Config.FlickrAuthInfo.UserID;
         if (!string.IsNullOrEmpty(userID))
         {
             FlickrUploader flickr = new FlickrUploader(APIKeys.FlickrKey, APIKeys.FlickrSecret);
             string         url    = flickr.GetPhotosLink(userID);
             if (!string.IsNullOrEmpty(url))
             {
                 ZAppHelper.LoadBrowserAsync(url);
             }
         }
     }
 }
예제 #3
0
 public void FlickrAuthOpen()
 {
     try
     {
         FlickrUploader flickr = new FlickrUploader(APIKeys.FlickrKey, APIKeys.FlickrSecret);
         btnFlickrOpenAuthorize.Tag = flickr.GetFrob();
         string url = flickr.GetAuthLink(FlickrPermission.Write);
         if (!string.IsNullOrEmpty(url))
         {
             ZAppHelper.LoadBrowserAsync(url);
             btnFlickrCompleteAuth.Enabled = true;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #4
0
 public void FlickrAuthComplete()
 {
     try
     {
         string token = btnFlickrOpenAuthorize.Tag as string;
         if (!string.IsNullOrEmpty(token))
         {
             FlickrUploader flickr = new FlickrUploader(APIKeys.FlickrKey, APIKeys.FlickrSecret);
             Config.FlickrAuthInfo           = flickr.GetToken(token);
             pgFlickrAuthInfo.SelectedObject = Config.FlickrAuthInfo;
             // btnFlickrOpenImages.Text = string.Format("{0}'s photostream", Config.FlickrAuthInfo.Username);
             MessageBox.Show("Login successful.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #5
0
 public void FlickrCheckToken()
 {
     try
     {
         if (Config.FlickrAuthInfo != null)
         {
             string token = Config.FlickrAuthInfo.Token;
             if (!string.IsNullOrEmpty(token))
             {
                 FlickrUploader flickr = new FlickrUploader(APIKeys.FlickrKey, APIKeys.FlickrSecret);
                 Config.FlickrAuthInfo           = flickr.CheckToken(token);
                 pgFlickrAuthInfo.SelectedObject = Config.FlickrAuthInfo;
                 MessageBox.Show("Login successful.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #6
0
        private void FlickrAuthOpen()
        {
            try
            {
                OAuthInfo oauth = new OAuthInfo(APIKeys.FlickrKey, APIKeys.FlickrSecret);

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

                if (!string.IsNullOrEmpty(url))
                {
                    Config.FlickrOAuthInfo = oauth;
                    URLHelpers.OpenURL(url);
                    DebugHelper.WriteLine("FlickrAuthOpen - Authorization URL is opened: " + url);
                }
                else
                {
                    DebugHelper.WriteLine("FlickrAuthOpen - Authorization URL is empty.");
                }
            }
            catch (Exception ex)
            {
                ex.ShowError();
            }
        }
예제 #7
0
파일: UploadTask.cs 프로젝트: Z1ni/ShareX
        public UploadResult UploadImage(Stream stream, string fileName)
        {
            ImageUploader imageUploader = null;

            switch (Info.TaskSettings.ImageDestination)
            {
            case ImageDestination.ImageShack:
                Program.UploadersConfig.ImageShackSettings.ThumbnailWidth  = Info.TaskSettings.AdvancedSettings.ThumbnailPreferredWidth;
                Program.UploadersConfig.ImageShackSettings.ThumbnailHeight = Info.TaskSettings.AdvancedSettings.ThumbnailPreferredHeight;
                imageUploader = new ImageShackUploader(APIKeys.ImageShackKey, Program.UploadersConfig.ImageShackSettings);
                break;

            case ImageDestination.TinyPic:
                imageUploader = new TinyPicUploader(APIKeys.TinyPicID, APIKeys.TinyPicKey, Program.UploadersConfig.TinyPicAccountType, Program.UploadersConfig.TinyPicRegistrationCode);
                break;

            case ImageDestination.Imgur:
                if (Program.UploadersConfig.ImgurOAuth2Info == null)
                {
                    Program.UploadersConfig.ImgurOAuth2Info = new OAuth2Info(APIKeys.ImgurClientID, APIKeys.ImgurClientSecret);
                }

                imageUploader = new Imgur_v3(Program.UploadersConfig.ImgurOAuth2Info)
                {
                    UploadMethod  = Program.UploadersConfig.ImgurAccountType,
                    ThumbnailType = Program.UploadersConfig.ImgurThumbnailType,
                    UploadAlbumID = Program.UploadersConfig.ImgurAlbumID
                };
                break;

            case ImageDestination.Flickr:
                imageUploader = new FlickrUploader(APIKeys.FlickrKey, APIKeys.FlickrSecret, Program.UploadersConfig.FlickrAuthInfo, Program.UploadersConfig.FlickrSettings);
                break;

            case ImageDestination.Photobucket:
                imageUploader = new Photobucket(Program.UploadersConfig.PhotobucketOAuthInfo, Program.UploadersConfig.PhotobucketAccountInfo);
                break;

            case ImageDestination.Picasa:
                imageUploader = new Picasa(Program.UploadersConfig.PicasaOAuth2Info)
                {
                    AlbumID = Program.UploadersConfig.PicasaAlbumID
                };
                break;

            case ImageDestination.Twitpic:
                int indexTwitpic = Program.UploadersConfig.TwitterSelectedAccount;

                if (Program.UploadersConfig.TwitterOAuthInfoList != null && Program.UploadersConfig.TwitterOAuthInfoList.IsValidIndex(indexTwitpic))
                {
                    imageUploader = new TwitPicUploader(APIKeys.TwitPicKey, Program.UploadersConfig.TwitterOAuthInfoList[indexTwitpic])
                    {
                        TwitPicThumbnailMode = Program.UploadersConfig.TwitPicThumbnailMode,
                        ShowFull             = Program.UploadersConfig.TwitPicShowFull
                    };
                }
                break;

            case ImageDestination.Twitsnaps:
                int indexTwitsnaps = Program.UploadersConfig.TwitterSelectedAccount;

                if (Program.UploadersConfig.TwitterOAuthInfoList.IsValidIndex(indexTwitsnaps))
                {
                    imageUploader = new TwitSnapsUploader(APIKeys.TwitsnapsKey, Program.UploadersConfig.TwitterOAuthInfoList[indexTwitsnaps]);
                }
                break;

            case ImageDestination.yFrog:
                YfrogOptions yFrogOptions = new YfrogOptions(APIKeys.ImageShackKey);
                yFrogOptions.Username = Program.UploadersConfig.YFrogUsername;
                yFrogOptions.Password = Program.UploadersConfig.YFrogPassword;
                yFrogOptions.Source   = Application.ProductName;
                imageUploader         = new YfrogUploader(yFrogOptions);
                break;

            case ImageDestination.MediaCrush:
                imageUploader = new MediaCrushUploader();
                break;

            case ImageDestination.CustomImageUploader:
                if (Program.UploadersConfig.CustomUploadersList.IsValidIndex(Program.UploadersConfig.CustomImageUploaderSelected))
                {
                    imageUploader = new CustomImageUploader(Program.UploadersConfig.CustomUploadersList[Program.UploadersConfig.CustomImageUploaderSelected]);
                }
                break;
            }

            if (imageUploader != null)
            {
                PrepareUploader(imageUploader);
                return(imageUploader.Upload(stream, fileName));
            }

            return(null);
        }
        public UploadResult UploadImage(Stream stream, string fileName)
        {
            ImageUploader imageUploader = null;

            switch (UploadManager.ImageUploader)
            {
            case ImageDestination.ImageShack:
                imageUploader = new ImageShackUploader(ZKeys.ImageShackKey, Program.UploadersConfig.ImageShackAccountType,
                                                       Program.UploadersConfig.ImageShackRegistrationCode)
                {
                    IsPublic = Program.UploadersConfig.ImageShackShowImagesInPublic
                };
                break;

            case ImageDestination.TinyPic:
                imageUploader = new TinyPicUploader(ZKeys.TinyPicID, ZKeys.TinyPicKey, Program.UploadersConfig.TinyPicAccountType,
                                                    Program.UploadersConfig.TinyPicRegistrationCode);
                break;

            case ImageDestination.Imgur:
                imageUploader = new Imgur(Program.UploadersConfig.ImgurAccountType, ZKeys.ImgurAnonymousKey, Program.UploadersConfig.ImgurOAuthInfo)
                {
                    ThumbnailType = Program.UploadersConfig.ImgurThumbnailType
                };
                break;

            case ImageDestination.Flickr:
                imageUploader = new FlickrUploader(ZKeys.FlickrKey, ZKeys.FlickrSecret, Program.UploadersConfig.FlickrAuthInfo, Program.UploadersConfig.FlickrSettings);
                break;

            case ImageDestination.Photobucket:
                imageUploader = new Photobucket(Program.UploadersConfig.PhotobucketOAuthInfo, Program.UploadersConfig.PhotobucketAccountInfo);
                break;

            case ImageDestination.UploadScreenshot:
                imageUploader = new UploadScreenshot(ZKeys.UploadScreenshotKey);
                break;

            case ImageDestination.Twitpic:
                TwitPicOptions twitPicOptions = new TwitPicOptions();
                twitPicOptions.Username             = Program.UploadersConfig.TwitPicUsername;
                twitPicOptions.Password             = Program.UploadersConfig.TwitPicPassword;
                twitPicOptions.TwitPicThumbnailMode = Program.UploadersConfig.TwitPicThumbnailMode;
                twitPicOptions.ShowFull             = Program.UploadersConfig.TwitPicShowFull;
                imageUploader = new TwitPicUploader(twitPicOptions);
                break;

            case ImageDestination.Twitsnaps:
                int index = Program.UploadersConfig.TwitterSelectedAccount;

                if (Program.UploadersConfig.TwitterOAuthInfoList.HasValidIndex(index))
                {
                    imageUploader = new TwitSnapsUploader(ZKeys.TwitsnapsKey, Program.UploadersConfig.TwitterOAuthInfoList[index]);
                }
                break;

            case ImageDestination.yFrog:
                YfrogOptions yFrogOptions = new YfrogOptions(ZKeys.ImageShackKey);
                yFrogOptions.Username = Program.UploadersConfig.YFrogUsername;
                yFrogOptions.Password = Program.UploadersConfig.YFrogPassword;
                yFrogOptions.Source   = Application.ProductName;
                imageUploader         = new YfrogUploader(yFrogOptions);
                break;
            }

            if (imageUploader != null)
            {
                PrepareUploader(imageUploader);
                return(imageUploader.Upload(stream, fileName));
            }

            return(null);
        }
예제 #9
0
파일: TorrentInfo.cs 프로젝트: Jaex/TDMaker
        private UploadResult UploadImage(string ssPath)
        {
            ImageUploader imageUploader = null;

            if (!string.IsNullOrEmpty(Program.Settings.PtpImgCode))
            {
                imageUploader = new PtpImageUploader(Crypt.Decrypt(Program.Settings.PtpImgCode));
            }
            else
            {
                switch ((ImageDestination)Program.Settings.ImageUploaderType)
                {
                case ImageDestination.TinyPic:
                    imageUploader = new TinyPicUploader(ZKeys.TinyPicID, ZKeys.TinyPicKey, Program.UploadersConfig.TinyPicAccountType,
                                                        Program.UploadersConfig.TinyPicRegistrationCode);
                    break;

                case ImageDestination.Imgur:
                    if (Program.UploadersConfig.ImgurOAuth2Info == null)
                    {
                        Program.UploadersConfig.ImgurOAuth2Info = new OAuth2Info(APIKeys.ImgurClientID, APIKeys.ImgurClientSecret);
                    }

                    string albumID = null;

                    if (Program.UploadersConfig.ImgurUploadSelectedAlbum && Program.UploadersConfig.ImgurSelectedAlbum != null)
                    {
                        albumID = Program.UploadersConfig.ImgurSelectedAlbum.id;
                    }

                    imageUploader = new Imgur_v3(Program.UploadersConfig.ImgurOAuth2Info)
                    {
                        UploadMethod  = Program.UploadersConfig.ImgurAccountType,
                        DirectLink    = Program.UploadersConfig.ImgurDirectLink,
                        ThumbnailType = Program.UploadersConfig.ImgurThumbnailType,
                        UploadAlbumID = albumID
                    };
                    break;

                case ImageDestination.Flickr:
                    imageUploader = new FlickrUploader(APIKeys.FlickrKey, APIKeys.FlickrSecret, Program.UploadersConfig.FlickrAuthInfo, Program.UploadersConfig.FlickrSettings);
                    break;

                case ImageDestination.Photobucket:
                    imageUploader = new Photobucket(Program.UploadersConfig.PhotobucketOAuthInfo, Program.UploadersConfig.PhotobucketAccountInfo);
                    break;

                case ImageDestination.Picasa:
                    imageUploader = new Picasa(Program.UploadersConfig.PicasaOAuth2Info)
                    {
                        AlbumID = Program.UploadersConfig.PicasaAlbumID
                    };
                    break;

                case ImageDestination.Twitter:
                    OAuthInfo twitterOAuth = Program.UploadersConfig.TwitterOAuthInfoList.ReturnIfValidIndex(Program.UploadersConfig.TwitterSelectedAccount);
                    imageUploader = new Twitter(twitterOAuth);
                    break;

                case ImageDestination.Chevereto:
                    imageUploader = new Chevereto(Program.UploadersConfig.CheveretoWebsite, Program.UploadersConfig.CheveretoAPIKey)
                    {
                        DirectURL = Program.UploadersConfig.CheveretoDirectURL
                    };
                    break;

                case ImageDestination.HizliResim:
                    imageUploader = new HizliResim()
                    {
                        DirectURL = true
                    };
                    break;

                case ImageDestination.CustomImageUploader:
                    if (Program.UploadersConfig.CustomUploadersList.IsValidIndex(Program.UploadersConfig.CustomImageUploaderSelected))
                    {
                        imageUploader = new CustomImageUploader(Program.UploadersConfig.CustomUploadersList[Program.UploadersConfig.CustomImageUploaderSelected]);
                    }
                    break;

                case ImageDestination.FileUploader:
                    return(UploadFile(ssPath));
                }
            }

            if (imageUploader != null)
            {
                ReportProgress(ProgressType.UPDATE_STATUSBAR_DEBUG, string.Format("Uploading {0}.", Path.GetFileName(ssPath)));
                return(imageUploader.Upload(ssPath));
            }

            return(null);
        }
예제 #10
0
        private UploadResult UploadImage(string ssPath)
        {
            ImageUploader imageUploader = null;

            if (!string.IsNullOrEmpty(App.Settings.PtpImgCode))
            {
                imageUploader = new PtpImageUploader(Crypt.Decrypt(App.Settings.PtpImgCode));
            }
            else
            {
                switch (App.Settings.ProfileActive.ImageUploaderType)
                {
                    case ImageDestination.Imgur:
                        if (App.UploadersConfig.ImgurOAuth2Info == null)
                        {
                            App.UploadersConfig.ImgurOAuth2Info = new OAuth2Info(APIKeys.ImgurClientID, APIKeys.ImgurClientSecret);
                        }

                        string albumID = null;

                        if (App.UploadersConfig.ImgurUploadSelectedAlbum && App.UploadersConfig.ImgurSelectedAlbum != null)
                        {
                            albumID = App.UploadersConfig.ImgurSelectedAlbum.id;
                        }

                        imageUploader = new Imgur(App.UploadersConfig.ImgurOAuth2Info)
                        {
                            UploadMethod = App.UploadersConfig.ImgurAccountType,
                            DirectLink = App.UploadersConfig.ImgurDirectLink,
                            ThumbnailType = App.UploadersConfig.ImgurThumbnailType,
                            UploadAlbumID = albumID
                        };
                        break;
                    case ImageDestination.TinyPic:
                        imageUploader = new TinyPicUploader(APIKeys.TinyPicID, APIKeys.TinyPicKey, App.UploadersConfig.TinyPicAccountType, App.UploadersConfig.TinyPicRegistrationCode);
                        break;
                    case ImageDestination.Flickr:
                        imageUploader = new FlickrUploader(APIKeys.FlickrKey, APIKeys.FlickrSecret, App.UploadersConfig.FlickrAuthInfo, App.UploadersConfig.FlickrSettings);
                        break;
                    case ImageDestination.Photobucket:
                        imageUploader = new Photobucket(App.UploadersConfig.PhotobucketOAuthInfo, App.UploadersConfig.PhotobucketAccountInfo);
                        break;
                    case ImageDestination.Picasa:
                        imageUploader = new Picasa(App.UploadersConfig.PicasaOAuth2Info)
                        {
                            AlbumID = App.UploadersConfig.PicasaAlbumID
                        };
                        break;
                    case ImageDestination.Twitter:
                        OAuthInfo twitterOAuth = App.UploadersConfig.TwitterOAuthInfoList.ReturnIfValidIndex(App.UploadersConfig.TwitterSelectedAccount);
                        imageUploader = new Twitter(twitterOAuth);
                        break;
                    case ImageDestination.Chevereto:
                        imageUploader = new Chevereto(App.UploadersConfig.CheveretoWebsite, App.UploadersConfig.CheveretoAPIKey)
                        {
                            DirectURL = App.UploadersConfig.CheveretoDirectURL
                        };
                        break;
                    case ImageDestination.HizliResim:
                        imageUploader = new HizliResim()
                        {
                            DirectURL = true
                        };
                        break;
                    case ImageDestination.CustomImageUploader:
                        if (App.UploadersConfig.CustomUploadersList.IsValidIndex(App.UploadersConfig.CustomImageUploaderSelected))
                        {
                            imageUploader = new CustomImageUploader(App.UploadersConfig.CustomUploadersList[App.UploadersConfig.CustomImageUploaderSelected]);
                        }
                        break;
                    case ImageDestination.FileUploader:
                        return UploadFile(ssPath);
                }
            }

            if (imageUploader != null)
            {
                PrepareUploader(imageUploader);

                return imageUploader.Upload(ssPath);
            }

            return null;
        }
예제 #11
0
        public UploadResult UploadImage(Stream stream, string fileName)
        {
            ImageUploader imageUploader = null;

            switch (Info.TaskSettings.ImageDestination)
            {
            case ImageDestination.Imgur:
                if (Program.UploadersConfig.ImgurOAuth2Info == null)
                {
                    Program.UploadersConfig.ImgurOAuth2Info = new OAuth2Info(APIKeys.ImgurClientID, APIKeys.ImgurClientSecret);
                }

                imageUploader = new Imgur_v3(Program.UploadersConfig.ImgurOAuth2Info)
                {
                    UploadMethod  = Program.UploadersConfig.ImgurAccountType,
                    DirectLink    = Program.UploadersConfig.ImgurDirectLink,
                    ThumbnailType = Program.UploadersConfig.ImgurThumbnailType,
                    UploadAlbumID = Program.UploadersConfig.ImgurAlbumID
                };
                break;

            case ImageDestination.ImageShack:
                Program.UploadersConfig.ImageShackSettings.ThumbnailWidth  = Info.TaskSettings.AdvancedSettings.ThumbnailPreferredWidth;
                Program.UploadersConfig.ImageShackSettings.ThumbnailHeight = Info.TaskSettings.AdvancedSettings.ThumbnailPreferredHeight;
                imageUploader = new ImageShackUploader(APIKeys.ImageShackKey, Program.UploadersConfig.ImageShackSettings);
                break;

            case ImageDestination.TinyPic:
                imageUploader = new TinyPicUploader(APIKeys.TinyPicID, APIKeys.TinyPicKey, Program.UploadersConfig.TinyPicAccountType, Program.UploadersConfig.TinyPicRegistrationCode);
                break;

            case ImageDestination.Flickr:
                imageUploader = new FlickrUploader(APIKeys.FlickrKey, APIKeys.FlickrSecret, Program.UploadersConfig.FlickrAuthInfo, Program.UploadersConfig.FlickrSettings);
                break;

            case ImageDestination.Photobucket:
                imageUploader = new Photobucket(Program.UploadersConfig.PhotobucketOAuthInfo, Program.UploadersConfig.PhotobucketAccountInfo);
                break;

            case ImageDestination.Picasa:
                imageUploader = new Picasa(Program.UploadersConfig.PicasaOAuth2Info)
                {
                    AlbumID = Program.UploadersConfig.PicasaAlbumID
                };
                break;

            case ImageDestination.Twitter:
                OAuthInfo twitterOAuth = Program.UploadersConfig.TwitterOAuthInfoList.ReturnIfValidIndex(Program.UploadersConfig.TwitterSelectedAccount);
                imageUploader = new Twitter(twitterOAuth);
                break;

            case ImageDestination.CustomImageUploader:
                if (Program.UploadersConfig.CustomUploadersList.IsValidIndex(Program.UploadersConfig.CustomImageUploaderSelected))
                {
                    imageUploader = new CustomImageUploader(Program.UploadersConfig.CustomUploadersList[Program.UploadersConfig.CustomImageUploaderSelected]);
                }
                break;
            }

            if (imageUploader != null)
            {
                PrepareUploader(imageUploader);
                return(imageUploader.Upload(stream, fileName));
            }

            return(null);
        }