Пример #1
0
        public override void ShareURL(string url, UploadersConfig config)
        {
            using (EmailForm emailForm = new EmailForm(config.EmailRememberLastTo ? config.EmailLastTo : string.Empty, config.EmailDefaultSubject, url))
            {
                if (emailForm.ShowDialog() == DialogResult.OK)
                {
                    if (config.EmailRememberLastTo)
                    {
                        config.EmailLastTo = emailForm.ToEmail;
                    }

                    Email email = new Email
                    {
                        SmtpServer = config.EmailSmtpServer,
                        SmtpPort = config.EmailSmtpPort,
                        FromEmail = config.EmailFrom,
                        Password = config.EmailPassword
                    };

                    email.Send(emailForm.ToEmail, emailForm.Subject, emailForm.Body);
                }
            }

            //URLHelpers.OpenURL("mailto:?body=" + URLHelpers.URLEncode(url));
        }
Пример #2
0
        public override void ShareURL(string url, UploadersConfig config)
        {
            if (config.EmailAutomaticSend && !string.IsNullOrEmpty(config.EmailAutomaticSendTo))
            {
                Email email = new Email()
                {
                    SmtpServer = config.EmailSmtpServer,
                    SmtpPort = config.EmailSmtpPort,
                    FromEmail = config.EmailFrom,
                    Password = config.EmailPassword,
                    ToEmail = config.EmailAutomaticSendTo,
                    Subject = config.EmailDefaultSubject,
                    Body = url
                };

                email.Send();
            }
            else
            {
                using (EmailForm emailForm = new EmailForm(config.EmailRememberLastTo ? config.EmailLastTo : "", config.EmailDefaultSubject, url))
                {
                    if (emailForm.ShowDialog() == DialogResult.OK)
                    {
                        if (config.EmailRememberLastTo)
                        {
                            config.EmailLastTo = emailForm.ToEmail;
                        }

                        Email email = new Email()
                        {
                            SmtpServer = config.EmailSmtpServer,
                            SmtpPort = config.EmailSmtpPort,
                            FromEmail = config.EmailFrom,
                            Password = config.EmailPassword,
                            ToEmail = emailForm.ToEmail,
                            Subject = emailForm.Subject,
                            Body = emailForm.Body
                        };

                        email.Send();
                    }
                }
            }

            //URLHelpers.OpenURL("mailto:?body=" + URLHelpers.URLEncode(url));
        }
Пример #3
0
        public UploadResult UploadFile(Stream stream, string fileName)
        {
            FileUploader fileUploader = null;

            FileDestination fileDestination;

            switch (Info.DataType)
            {
                case EDataType.Image:
                    fileDestination = Info.TaskSettings.ImageFileDestination;
                    break;
                case EDataType.Text:
                    fileDestination = Info.TaskSettings.TextFileDestination;
                    break;
                default:
                case EDataType.File:
                    fileDestination = Info.TaskSettings.FileDestination;
                    break;
            }

            switch (fileDestination)
            {
                case FileDestination.Dropbox:
                    fileUploader = new Dropbox(Program.UploadersConfig.DropboxOAuth2Info, Program.UploadersConfig.DropboxAccountInfo)
                    {
                        UploadPath = NameParser.Parse(NameParserType.URL, Dropbox.TidyUploadPath(Program.UploadersConfig.DropboxUploadPath)),
                        AutoCreateShareableLink = Program.UploadersConfig.DropboxAutoCreateShareableLink,
                        ShareURLType = Program.UploadersConfig.DropboxURLType
                    };
                    break;
                case FileDestination.OneDrive:
                    fileUploader = new OneDrive(Program.UploadersConfig.OneDriveOAuth2Info)
                    {
                        FolderID = Program.UploadersConfig.OneDriveSelectedFolder.id,
                        AutoCreateShareableLink = Program.UploadersConfig.OneDriveAutoCreateShareableLink
                    };
                    break;
                case FileDestination.GoogleDrive:
                    fileUploader = new GoogleDrive(Program.UploadersConfig.GoogleDriveOAuth2Info)
                    {
                        IsPublic = Program.UploadersConfig.GoogleDriveIsPublic,
                        FolderID = Program.UploadersConfig.GoogleDriveUseFolder ? Program.UploadersConfig.GoogleDriveFolderID : null
                    };
                    break;
                case FileDestination.Copy:
                    fileUploader = new Copy(Program.UploadersConfig.CopyOAuthInfo, Program.UploadersConfig.CopyAccountInfo)
                    {
                        UploadPath = NameParser.Parse(NameParserType.URL, Copy.TidyUploadPath(Program.UploadersConfig.CopyUploadPath)),
                        URLType = Program.UploadersConfig.CopyURLType
                    };
                    break;
                /*case FileDestination.Hubic:
                    fileUploader = new Hubic(Program.UploadersConfig.HubicOAuth2Info, Program.UploadersConfig.HubicOpenstackAuthInfo)
                    {
                        SelectedFolder = Program.UploadersConfig.HubicSelectedFolder,
                        Publish = Program.UploadersConfig.HubicPublish
                    };
                    break;*/
                case FileDestination.SendSpace:
                    fileUploader = new SendSpace(APIKeys.SendSpaceKey);
                    switch (Program.UploadersConfig.SendSpaceAccountType)
                    {
                        case AccountType.Anonymous:
                            SendSpaceManager.PrepareUploadInfo(APIKeys.SendSpaceKey);
                            break;
                        case AccountType.User:
                            SendSpaceManager.PrepareUploadInfo(APIKeys.SendSpaceKey, Program.UploadersConfig.SendSpaceUsername, Program.UploadersConfig.SendSpacePassword);
                            break;
                    }
                    break;
                case FileDestination.Minus:
                    fileUploader = new Minus(Program.UploadersConfig.MinusConfig, Program.UploadersConfig.MinusOAuth2Info);
                    break;
                case FileDestination.Box:
                    fileUploader = new Box(Program.UploadersConfig.BoxOAuth2Info)
                    {
                        FolderID = Program.UploadersConfig.BoxSelectedFolder.id,
                        Share = Program.UploadersConfig.BoxShare
                    };
                    break;
                case FileDestination.Gfycat:
                    fileUploader = new GfycatUploader();
                    break;
                case FileDestination.Ge_tt:
                    fileUploader = new Ge_tt(APIKeys.Ge_ttKey)
                    {
                        AccessToken = Program.UploadersConfig.Ge_ttLogin.AccessToken
                    };
                    break;
                case FileDestination.Localhostr:
                    fileUploader = new Hostr(Program.UploadersConfig.LocalhostrEmail, Program.UploadersConfig.LocalhostrPassword)
                    {
                        DirectURL = Program.UploadersConfig.LocalhostrDirectURL
                    };
                    break;
                case FileDestination.CustomFileUploader:
                    CustomUploaderItem customUploader = GetCustomUploader(Program.UploadersConfig.CustomFileUploaderSelected);
                    if (customUploader != null)
                    {
                        fileUploader = new CustomFileUploader(customUploader);
                    }
                    break;
                case FileDestination.FTP:
                    FTPAccount ftpAccount = GetFTPAccount(Program.UploadersConfig.GetFTPIndex(Info.DataType));
                    if (ftpAccount != null)
                    {
                        if (ftpAccount.Protocol == FTPProtocol.FTP || ftpAccount.Protocol == FTPProtocol.FTPS)
                        {
                            fileUploader = new FTP(ftpAccount);
                        }
                        else if (ftpAccount.Protocol == FTPProtocol.SFTP)
                        {
                            fileUploader = new SFTP(ftpAccount);
                        }
                    }
                    break;
                case FileDestination.SharedFolder:
                    int idLocalhost = Program.UploadersConfig.GetLocalhostIndex(Info.DataType);
                    if (Program.UploadersConfig.LocalhostAccountList.IsValidIndex(idLocalhost))
                    {
                        fileUploader = new SharedFolderUploader(Program.UploadersConfig.LocalhostAccountList[idLocalhost]);
                    }
                    break;
                case FileDestination.Email:
                    using (EmailForm emailForm = new EmailForm(Program.UploadersConfig.EmailRememberLastTo ? Program.UploadersConfig.EmailLastTo : string.Empty,
                        Program.UploadersConfig.EmailDefaultSubject, Program.UploadersConfig.EmailDefaultBody))
                    {
                        emailForm.Icon = ShareXResources.Icon;

                        if (emailForm.ShowDialog() == DialogResult.OK)
                        {
                            if (Program.UploadersConfig.EmailRememberLastTo)
                            {
                                Program.UploadersConfig.EmailLastTo = emailForm.ToEmail;
                            }

                            fileUploader = new Email
                            {
                                SmtpServer = Program.UploadersConfig.EmailSmtpServer,
                                SmtpPort = Program.UploadersConfig.EmailSmtpPort,
                                FromEmail = Program.UploadersConfig.EmailFrom,
                                Password = Program.UploadersConfig.EmailPassword,
                                ToEmail = emailForm.ToEmail,
                                Subject = emailForm.Subject,
                                Body = emailForm.Body
                            };
                        }
                        else
                        {
                            StopRequested = true;
                        }
                    }
                    break;
                case FileDestination.Jira:
                    fileUploader = new Jira(Program.UploadersConfig.JiraHost, Program.UploadersConfig.JiraOAuthInfo, Program.UploadersConfig.JiraIssuePrefix);
                    break;
                case FileDestination.Mega:
                    fileUploader = new Mega(Program.UploadersConfig.MegaAuthInfos, Program.UploadersConfig.MegaParentNodeId);
                    break;
                case FileDestination.AmazonS3:
                    fileUploader = new AmazonS3(Program.UploadersConfig.AmazonS3Settings);
                    break;
                case FileDestination.OwnCloud:
                    fileUploader = new OwnCloud(Program.UploadersConfig.OwnCloudHost, Program.UploadersConfig.OwnCloudUsername, Program.UploadersConfig.OwnCloudPassword)
                    {
                        Path = Program.UploadersConfig.OwnCloudPath,
                        CreateShare = Program.UploadersConfig.OwnCloudCreateShare,
                        DirectLink = Program.UploadersConfig.OwnCloudDirectLink,
                        IgnoreInvalidCert = Program.UploadersConfig.OwnCloudIgnoreInvalidCert
                    };
                    break;
                case FileDestination.Pushbullet:
                    fileUploader = new Pushbullet(Program.UploadersConfig.PushbulletSettings);
                    break;
                case FileDestination.MediaFire:
                    fileUploader = new MediaFire(APIKeys.MediaFireAppId, APIKeys.MediaFireApiKey, Program.UploadersConfig.MediaFireUsername, Program.UploadersConfig.MediaFirePassword)
                    {
                        UploadPath = NameParser.Parse(NameParserType.URL, Program.UploadersConfig.MediaFirePath),
                        UseLongLink = Program.UploadersConfig.MediaFireUseLongLink
                    };
                    break;
                case FileDestination.Lambda:
                    fileUploader = new Lambda(Program.UploadersConfig.LambdaSettings);
                    break;
                case FileDestination.Imgrush:
                    fileUploader = new MediaCrushUploader("https://imgrush.com");
                    break;
                case FileDestination.VideoBin:
                    fileUploader = new VideoBin();
                    break;
                case FileDestination.MaxFile:
                    fileUploader = new MaxFile();
                    break;
                case FileDestination.Dropfile:
                    fileUploader = new Dropfile();
                    break;
            }

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

            return null;
        }
Пример #4
0
        public void ShareURL(string url)
        {
            if (!string.IsNullOrEmpty(url))
            {
                string encodedUrl = URLHelpers.URLEncode(url);

                switch (Info.TaskSettings.URLSharingServiceDestination)
                {
                    case URLSharingServices.Email:
                        if (Program.UploadersConfig.IsValid(URLSharingServices.Email))
                        {
                            using (EmailForm emailForm = new EmailForm(Program.UploadersConfig.EmailRememberLastTo ? Program.UploadersConfig.EmailLastTo : string.Empty,
                                Program.UploadersConfig.EmailDefaultSubject, url))
                            {
                                if (emailForm.ShowDialog() == DialogResult.OK)
                                {
                                    if (Program.UploadersConfig.EmailRememberLastTo)
                                    {
                                        Program.UploadersConfig.EmailLastTo = emailForm.ToEmail;
                                    }

                                    Email email = new Email
                                    {
                                        SmtpServer = Program.UploadersConfig.EmailSmtpServer,
                                        SmtpPort = Program.UploadersConfig.EmailSmtpPort,
                                        FromEmail = Program.UploadersConfig.EmailFrom,
                                        Password = Program.UploadersConfig.EmailPassword
                                    };

                                    email.Send(emailForm.ToEmail, emailForm.Subject, emailForm.Body);
                                }
                            }
                        }
                        else
                        {
                            URLHelpers.OpenURL("mailto:?body=" + encodedUrl);
                        }
                        break;
                    case URLSharingServices.Twitter:
                        if (Program.UploadersConfig.IsValid(URLSharingServices.Twitter))
                        {
                            OAuthInfo twitterOAuth = Program.UploadersConfig.TwitterOAuthInfoList[Program.UploadersConfig.TwitterSelectedAccount];

                            if (Program.UploadersConfig.TwitterSkipMessageBox)
                            {
                                try
                                {
                                    new Twitter(twitterOAuth).TweetMessage(url);
                                }
                                catch (Exception ex)
                                {
                                    DebugHelper.WriteException(ex);
                                }
                            }
                            else
                            {
                                using (TwitterTweetForm twitter = new TwitterTweetForm(twitterOAuth, url))
                                {
                                    twitter.ShowDialog();
                                }
                            }
                        }
                        else
                        {
                            //URLHelpers.OpenURL("https://twitter.com/intent/tweet?text=" + encodedUrl);
                            MessageBox.Show(Resources.TaskHelpers_TweetMessage_Unable_to_find_valid_Twitter_account_, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        break;
                    case URLSharingServices.Facebook:
                        URLHelpers.OpenURL("https://www.facebook.com/sharer/sharer.php?u=" + encodedUrl);
                        break;
                    case URLSharingServices.GooglePlus:
                        URLHelpers.OpenURL("https://plus.google.com/share?url=" + encodedUrl);
                        break;
                    case URLSharingServices.Reddit:
                        URLHelpers.OpenURL("http://www.reddit.com/submit?url=" + encodedUrl);
                        break;
                    case URLSharingServices.Pinterest:
                        URLHelpers.OpenURL(string.Format("http://pinterest.com/pin/create/button/?url={0}&media={0}", encodedUrl));
                        break;
                    case URLSharingServices.Tumblr:
                        URLHelpers.OpenURL("https://www.tumblr.com/share?v=3&u=" + encodedUrl);
                        break;
                    case URLSharingServices.LinkedIn:
                        URLHelpers.OpenURL("https://www.linkedin.com/shareArticle?url=" + encodedUrl);
                        break;
                    case URLSharingServices.StumbleUpon:
                        URLHelpers.OpenURL("http://www.stumbleupon.com/submit?url=" + encodedUrl);
                        break;
                    case URLSharingServices.Delicious:
                        URLHelpers.OpenURL("https://delicious.com/save?v=5&url=" + encodedUrl);
                        break;
                    case URLSharingServices.VK:
                        URLHelpers.OpenURL("http://vk.com/share.php?url=" + encodedUrl);
                        break;
                    case URLSharingServices.Pushbullet:
                        new Pushbullet(Program.UploadersConfig.PushbulletSettings).PushLink(url, "ShareX: URL Share");
                        break;
                }
            }
        }
Пример #5
0
        private UploadResult UploadFile(string ssPath)
        {
            FileUploader fileUploader = null;

            switch (App.Settings.ProfileActive.ImageFileUploaderType)
            {
                case FileDestination.Dropbox:
                    fileUploader = new Dropbox(App.UploadersConfig.DropboxOAuth2Info, App.UploadersConfig.DropboxAccountInfo)
                    {
                        UploadPath = NameParser.Parse(NameParserType.URL, Dropbox.TidyUploadPath(App.UploadersConfig.DropboxUploadPath)),
                        AutoCreateShareableLink = App.UploadersConfig.DropboxAutoCreateShareableLink,
                        ShareURLType = App.UploadersConfig.DropboxURLType
                    };
                    break;
                case FileDestination.Copy:
                    fileUploader = new Copy(App.UploadersConfig.CopyOAuthInfo, App.UploadersConfig.CopyAccountInfo)
                    {
                        UploadPath = NameParser.Parse(NameParserType.URL, Copy.TidyUploadPath(App.UploadersConfig.CopyUploadPath)),
                        URLType = App.UploadersConfig.CopyURLType
                    };
                    break;
                case FileDestination.GoogleDrive:
                    fileUploader = new GoogleDrive(App.UploadersConfig.GoogleDriveOAuth2Info)
                    {
                        IsPublic = App.UploadersConfig.GoogleDriveIsPublic,
                        FolderID = App.UploadersConfig.GoogleDriveUseFolder ? App.UploadersConfig.GoogleDriveFolderID : null
                    };
                    break;
                case FileDestination.SendSpace:
                    fileUploader = new SendSpace(APIKeys.SendSpaceKey);
                    switch (App.UploadersConfig.SendSpaceAccountType)
                    {
                        case AccountType.Anonymous:
                            SendSpaceManager.PrepareUploadInfo(APIKeys.SendSpaceKey);
                            break;
                        case AccountType.User:
                            SendSpaceManager.PrepareUploadInfo(APIKeys.SendSpaceKey, App.UploadersConfig.SendSpaceUsername, App.UploadersConfig.SendSpacePassword);
                            break;
                    }
                    break;
                case FileDestination.Minus:
                    fileUploader = new Minus(App.UploadersConfig.MinusConfig, App.UploadersConfig.MinusOAuth2Info);
                    break;
                case FileDestination.Box:
                    fileUploader = new Box(App.UploadersConfig.BoxOAuth2Info)
                    {
                        FolderID = App.UploadersConfig.BoxSelectedFolder.id,
                        Share = App.UploadersConfig.BoxShare
                    };
                    break;
                case FileDestination.Gfycat:
                    fileUploader = new GfycatUploader();
                    break;
                case FileDestination.Ge_tt:
                    fileUploader = new Ge_tt(APIKeys.Ge_ttKey)
                    {
                        AccessToken = App.UploadersConfig.Ge_ttLogin.AccessToken
                    };
                    break;
                case FileDestination.Localhostr:
                    fileUploader = new Hostr(App.UploadersConfig.LocalhostrEmail, App.UploadersConfig.LocalhostrPassword)
                    {
                        DirectURL = App.UploadersConfig.LocalhostrDirectURL
                    };
                    break;
                case FileDestination.CustomFileUploader:
                    if (App.UploadersConfig.CustomUploadersList.IsValidIndex(App.UploadersConfig.CustomFileUploaderSelected))
                    {
                        fileUploader = new CustomFileUploader(App.UploadersConfig.CustomUploadersList[App.UploadersConfig.CustomFileUploaderSelected]);
                    }
                    break;
                case FileDestination.FTP:
                    FTPAccount account = App.UploadersConfig.FTPAccountList.ReturnIfValidIndex(App.UploadersConfig.FTPSelectedImage);

                    if (account != null)
                    {
                        if (account.Protocol == FTPProtocol.FTP || account.Protocol == FTPProtocol.FTPS)
                        {
                            fileUploader = new FTP(account);
                        }
                        else if (account.Protocol == FTPProtocol.SFTP)
                        {
                            fileUploader = new SFTP(account);
                        }
                    }
                    break;
                case FileDestination.SharedFolder:
                    int idLocalhost = App.UploadersConfig.LocalhostSelectedImages;
                    if (App.UploadersConfig.LocalhostAccountList.IsValidIndex(idLocalhost))
                    {
                        fileUploader = new SharedFolderUploader(App.UploadersConfig.LocalhostAccountList[idLocalhost]);
                    }
                    break;
                case FileDestination.Email:
                    using (EmailForm emailForm = new EmailForm(App.UploadersConfig.EmailRememberLastTo ? App.UploadersConfig.EmailLastTo : string.Empty,
                        App.UploadersConfig.EmailDefaultSubject, App.UploadersConfig.EmailDefaultBody))
                    {
                        emailForm.Icon = ShareXResources.Icon;

                        if (emailForm.ShowDialog() == DialogResult.OK)
                        {
                            if (App.UploadersConfig.EmailRememberLastTo)
                            {
                                App.UploadersConfig.EmailLastTo = emailForm.ToEmail;
                            }

                            fileUploader = new Email
                            {
                                SmtpServer = App.UploadersConfig.EmailSmtpServer,
                                SmtpPort = App.UploadersConfig.EmailSmtpPort,
                                FromEmail = App.UploadersConfig.EmailFrom,
                                Password = App.UploadersConfig.EmailPassword,
                                ToEmail = emailForm.ToEmail,
                                Subject = emailForm.Subject,
                                Body = emailForm.Body
                            };
                        }
                    }
                    break;
                case FileDestination.Jira:
                    fileUploader = new Jira(App.UploadersConfig.JiraHost, App.UploadersConfig.JiraOAuthInfo, App.UploadersConfig.JiraIssuePrefix);
                    break;
                case FileDestination.Mega:
                    fileUploader = new Mega(App.UploadersConfig.MegaAuthInfos, App.UploadersConfig.MegaParentNodeId);
                    break;
                case FileDestination.AmazonS3:
                    fileUploader = new AmazonS3(App.UploadersConfig.AmazonS3Settings);
                    break;
                case FileDestination.OwnCloud:
                    fileUploader = new OwnCloud(App.UploadersConfig.OwnCloudHost, App.UploadersConfig.OwnCloudUsername, App.UploadersConfig.OwnCloudPassword)
                    {
                        Path = App.UploadersConfig.OwnCloudPath,
                        CreateShare = App.UploadersConfig.OwnCloudCreateShare,
                        DirectLink = App.UploadersConfig.OwnCloudDirectLink,
                        IgnoreInvalidCert = App.UploadersConfig.OwnCloudIgnoreInvalidCert
                    };
                    break;
                case FileDestination.Pushbullet:
                    fileUploader = new Pushbullet(App.UploadersConfig.PushbulletSettings);
                    break;
                case FileDestination.MediaFire:
                    fileUploader = new MediaFire(APIKeys.MediaFireAppId, APIKeys.MediaFireApiKey, App.UploadersConfig.MediaFireUsername, App.UploadersConfig.MediaFirePassword)
                    {
                        UploadPath = NameParser.Parse(NameParserType.URL, App.UploadersConfig.MediaFirePath),
                        UseLongLink = App.UploadersConfig.MediaFireUseLongLink
                    };
                    break;

            }

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

            return null;
        }