2013-11-03 23:53:49 +13:00
|
|
|
|
#region License Information (GPL v3)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
ShareX - A program that allows you to take screenshots and share any file type
|
2017-01-11 21:39:40 +13:00
|
|
|
|
Copyright (c) 2007-2017 ShareX Team
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
|
|
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#endregion License Information (GPL v3)
|
|
|
|
|
|
2014-12-11 09:25:20 +13:00
|
|
|
|
using ShareX.HelpersLib;
|
|
|
|
|
using ShareX.UploadersLib.FileUploaders;
|
|
|
|
|
using ShareX.UploadersLib.ImageUploaders;
|
2014-12-11 12:19:28 +13:00
|
|
|
|
using ShareX.UploadersLib.Properties;
|
2014-12-11 09:25:20 +13:00
|
|
|
|
using ShareX.UploadersLib.TextUploaders;
|
|
|
|
|
using ShareX.UploadersLib.URLShorteners;
|
2014-12-11 12:19:28 +13:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
2014-12-11 09:25:20 +13:00
|
|
|
|
|
|
|
|
|
namespace ShareX.UploadersLib
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-10-19 10:48:47 +13:00
|
|
|
|
public partial class UploadersConfigForm
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
#region Imgur
|
|
|
|
|
|
2015-04-28 13:33:53 +12:00
|
|
|
|
private void ImgurAuthOpen()
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
OAuth2Info oauth = new OAuth2Info(APIKeys.ImgurClientID, APIKeys.ImgurClientSecret);
|
|
|
|
|
|
2015-07-20 06:11:34 +12:00
|
|
|
|
string url = new Imgur(oauth).GetAuthorizationURL();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(url))
|
|
|
|
|
{
|
|
|
|
|
Config.ImgurOAuth2Info = oauth;
|
2014-06-28 12:22:56 +12:00
|
|
|
|
URLHelpers.OpenURL(url);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
DebugHelper.WriteLine("ImgurAuthOpen - Authorization URL is opened: " + url);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DebugHelper.WriteLine("ImgurAuthOpen - Authorization URL is empty.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-28 13:33:53 +12:00
|
|
|
|
private void ImgurAuthComplete(string code)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(code) && Config.ImgurOAuth2Info != null)
|
|
|
|
|
{
|
2015-07-20 06:11:34 +12:00
|
|
|
|
bool result = new Imgur(Config.ImgurOAuth2Info).GetAccessToken(code);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
2014-06-17 00:20:06 +12:00
|
|
|
|
oauth2Imgur.Status = OAuthLoginStatus.LoginSuccessful;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-06-17 00:20:06 +12:00
|
|
|
|
oauth2Imgur.Status = OAuthLoginStatus.LoginFailed;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
btnImgurRefreshAlbumList.Enabled = result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-28 13:33:53 +12:00
|
|
|
|
private void ImgurAuthRefresh()
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (OAuth2Info.CheckOAuth(Config.ImgurOAuth2Info))
|
|
|
|
|
{
|
2015-07-20 06:11:34 +12:00
|
|
|
|
bool result = new Imgur(Config.ImgurOAuth2Info).RefreshAccessToken();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
2014-06-17 00:20:06 +12:00
|
|
|
|
oauth2Imgur.Status = OAuthLoginStatus.LoginSuccessful;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-06-17 00:20:06 +12:00
|
|
|
|
oauth2Imgur.Status = OAuthLoginStatus.LoginFailed;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
atcImgurAccountType.SelectedAccountType = AccountType.Anonymous;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
btnImgurRefreshAlbumList.Enabled = result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-28 13:33:53 +12:00
|
|
|
|
private void ImgurRefreshAlbumList()
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
lvImgurAlbumList.Items.Clear();
|
|
|
|
|
|
|
|
|
|
if (OAuth2Info.CheckOAuth(Config.ImgurOAuth2Info))
|
|
|
|
|
{
|
2015-07-20 06:11:34 +12:00
|
|
|
|
Config.ImgurAlbumList = new Imgur(Config.ImgurOAuth2Info).GetAlbums();
|
2014-09-07 13:11:55 +12:00
|
|
|
|
ImgurFillAlbumList();
|
|
|
|
|
lvImgurAlbumList.Focus();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-07 13:11:55 +12:00
|
|
|
|
private void ImgurFillAlbumList()
|
|
|
|
|
{
|
|
|
|
|
if (Config.ImgurAlbumList != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (ImgurAlbumData album in Config.ImgurAlbumList)
|
|
|
|
|
{
|
|
|
|
|
ListViewItem lvi = new ListViewItem(album.id ?? "");
|
|
|
|
|
lvi.SubItems.Add(album.title ?? "");
|
|
|
|
|
lvi.SubItems.Add(album.description ?? "");
|
|
|
|
|
lvi.Selected = Config.ImgurSelectedAlbum != null && !string.IsNullOrEmpty(Config.ImgurSelectedAlbum.id) &&
|
|
|
|
|
album.id.Equals(Config.ImgurSelectedAlbum.id, StringComparison.InvariantCultureIgnoreCase);
|
|
|
|
|
lvi.Tag = album;
|
|
|
|
|
lvImgurAlbumList.Items.Add(lvi);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
#endregion Imgur
|
|
|
|
|
|
|
|
|
|
#region Flickr
|
|
|
|
|
|
|
|
|
|
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))
|
|
|
|
|
{
|
2014-06-28 12:22:56 +12:00
|
|
|
|
URLHelpers.OpenURL(url);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
btnFlickrCompleteAuth.Enabled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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))
|
|
|
|
|
{
|
2014-06-28 12:22:56 +12:00
|
|
|
|
URLHelpers.OpenURL(url);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion Flickr
|
|
|
|
|
|
|
|
|
|
#region Photobucket
|
|
|
|
|
|
|
|
|
|
public void PhotobucketAuthOpen()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
OAuthInfo oauth = new OAuthInfo(APIKeys.PhotobucketConsumerKey, APIKeys.PhotobucketConsumerSecret);
|
|
|
|
|
|
|
|
|
|
string url = new Photobucket(oauth).GetAuthorizationURL();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(url))
|
|
|
|
|
{
|
|
|
|
|
Config.PhotobucketOAuthInfo = oauth;
|
2014-06-28 12:22:56 +12:00
|
|
|
|
URLHelpers.OpenURL(url);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void PhotobucketAuthComplete()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string verification = txtPhotobucketVerificationCode.Text;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(verification) && Config.PhotobucketOAuthInfo != null &&
|
|
|
|
|
!string.IsNullOrEmpty(Config.PhotobucketOAuthInfo.AuthToken) && !string.IsNullOrEmpty(Config.PhotobucketOAuthInfo.AuthSecret))
|
|
|
|
|
{
|
|
|
|
|
Photobucket pb = new Photobucket(Config.PhotobucketOAuthInfo);
|
|
|
|
|
bool result = pb.GetAccessToken(verification);
|
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
Config.PhotobucketAccountInfo = pb.GetAccountInfo();
|
2014-10-18 00:48:41 +13:00
|
|
|
|
lblPhotobucketAccountStatus.Text = Resources.UploadersConfigForm_Login_successful;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
txtPhotobucketDefaultAlbumName.Text = Config.PhotobucketAccountInfo.AlbumID;
|
|
|
|
|
Config.PhotobucketAccountInfo.AlbumList.Add(Config.PhotobucketAccountInfo.AlbumID);
|
|
|
|
|
cboPhotobucketAlbumPaths.Items.Add(Config.PhotobucketAccountInfo.AlbumID);
|
|
|
|
|
cboPhotobucketAlbumPaths.SelectedIndex = 0;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
lblPhotobucketAccountStatus.Text = Resources.UploadersConfigForm_Login_failed;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void PhotobucketCreateAlbum()
|
|
|
|
|
{
|
|
|
|
|
Photobucket pb = new Photobucket(Config.PhotobucketOAuthInfo, Config.PhotobucketAccountInfo);
|
|
|
|
|
if (pb.CreateAlbum(txtPhotobucketParentAlbumPath.Text, txtPhotobucketNewAlbumName.Text))
|
|
|
|
|
{
|
|
|
|
|
string albumPath = txtPhotobucketParentAlbumPath.Text + "/" + txtPhotobucketNewAlbumName.Text;
|
|
|
|
|
Config.PhotobucketAccountInfo.AlbumList.Add(albumPath);
|
|
|
|
|
cboPhotobucketAlbumPaths.Items.Add(albumPath);
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(string.Format(Resources.UploadersConfigForm_PhotobucketCreateAlbum__0__successfully_created_, albumPath), "ShareX",
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion Photobucket
|
|
|
|
|
|
|
|
|
|
#region Picasa
|
|
|
|
|
|
|
|
|
|
public void PicasaAuthOpen()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
OAuth2Info oauth = new OAuth2Info(APIKeys.GoogleClientID, APIKeys.GoogleClientSecret);
|
|
|
|
|
|
|
|
|
|
string url = new Picasa(oauth).GetAuthorizationURL();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(url))
|
|
|
|
|
{
|
|
|
|
|
Config.PicasaOAuth2Info = oauth;
|
2014-06-28 12:22:56 +12:00
|
|
|
|
URLHelpers.OpenURL(url);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
DebugHelper.WriteLine("PicasaAuthOpen - Authorization URL is opened: " + url);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DebugHelper.WriteLine("PicasaAuthOpen - Authorization URL is empty.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void PicasaAuthComplete(string code)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(code) && Config.PicasaOAuth2Info != null)
|
|
|
|
|
{
|
|
|
|
|
bool result = new GoogleDrive(Config.PicasaOAuth2Info).GetAccessToken(code);
|
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
2014-06-17 00:20:06 +12:00
|
|
|
|
oauth2Picasa.Status = OAuthLoginStatus.LoginSuccessful;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-06-17 00:20:06 +12:00
|
|
|
|
oauth2Picasa.Status = OAuthLoginStatus.LoginFailed;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
btnPicasaRefreshAlbumList.Enabled = result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void PicasaAuthRefresh()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (OAuth2Info.CheckOAuth(Config.PicasaOAuth2Info))
|
|
|
|
|
{
|
|
|
|
|
bool result = new GoogleDrive(Config.PicasaOAuth2Info).RefreshAccessToken();
|
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
2014-06-17 00:20:06 +12:00
|
|
|
|
oauth2Picasa.Status = OAuthLoginStatus.LoginSuccessful;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-06-17 00:20:06 +12:00
|
|
|
|
oauth2Picasa.Status = OAuthLoginStatus.LoginFailed;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
btnPicasaRefreshAlbumList.Enabled = result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void PicasaRefreshAlbumList()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
lvPicasaAlbumList.Items.Clear();
|
|
|
|
|
|
|
|
|
|
if (OAuth2Info.CheckOAuth(Config.PicasaOAuth2Info))
|
|
|
|
|
{
|
|
|
|
|
List<PicasaAlbumInfo> albums = new Picasa(Config.PicasaOAuth2Info).GetAlbumList();
|
|
|
|
|
|
|
|
|
|
if (albums != null && albums.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (PicasaAlbumInfo album in albums)
|
|
|
|
|
{
|
|
|
|
|
ListViewItem lvi = new ListViewItem(album.ID);
|
|
|
|
|
lvi.SubItems.Add(album.Name ?? "");
|
|
|
|
|
lvi.SubItems.Add(album.Summary ?? "");
|
|
|
|
|
lvi.Tag = album;
|
|
|
|
|
lvPicasaAlbumList.Items.Add(lvi);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion Picasa
|
|
|
|
|
|
|
|
|
|
#region Dropbox
|
|
|
|
|
|
|
|
|
|
public void DropboxAuthOpen()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2014-06-09 07:11:44 +12:00
|
|
|
|
OAuth2Info oauth = new OAuth2Info(APIKeys.DropboxConsumerKey, APIKeys.DropboxConsumerSecret);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
|
|
|
|
string url = new Dropbox(oauth).GetAuthorizationURL();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(url))
|
|
|
|
|
{
|
2014-06-09 07:11:44 +12:00
|
|
|
|
Config.DropboxOAuth2Info = oauth;
|
2014-06-28 12:22:56 +12:00
|
|
|
|
URLHelpers.OpenURL(url);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
DebugHelper.WriteLine("DropboxAuthOpen - Authorization URL is opened: " + url);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DebugHelper.WriteLine("DropboxAuthOpen - Authorization URL is empty.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-09 07:59:13 +12:00
|
|
|
|
public void DropboxAuthComplete(string code)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-06-09 07:59:13 +12:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(code) && Config.DropboxOAuth2Info != null)
|
|
|
|
|
{
|
|
|
|
|
Dropbox dropbox = new Dropbox(Config.DropboxOAuth2Info);
|
|
|
|
|
bool result = dropbox.GetAccessToken(code);
|
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
2014-06-17 01:01:36 +12:00
|
|
|
|
oauth2Dropbox.Status = OAuthLoginStatus.LoginSuccessful;
|
2017-03-16 19:18:08 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
2014-06-09 07:59:13 +12:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-06-17 00:20:06 +12:00
|
|
|
|
oauth2Dropbox.Status = OAuthLoginStatus.LoginFailed;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2014-06-09 07:59:13 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
DebugHelper.WriteException(ex);
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), "ShareX - " + Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2014-06-09 07:59:13 +12:00
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion Dropbox
|
|
|
|
|
|
2014-05-06 11:24:00 +12:00
|
|
|
|
#region Amazon S3
|
|
|
|
|
|
|
|
|
|
private void UpdateAmazonS3Status()
|
|
|
|
|
{
|
2017-03-11 14:07:36 +13:00
|
|
|
|
lblAmazonS3PathPreview.Text = new AmazonS3(Config.AmazonS3Settings).GenerateURL("Example.png");
|
2014-05-06 11:24:00 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion Amazon S3
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
#region Google Drive
|
|
|
|
|
|
|
|
|
|
public void GoogleDriveAuthOpen()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
OAuth2Info oauth = new OAuth2Info(APIKeys.GoogleClientID, APIKeys.GoogleClientSecret);
|
|
|
|
|
|
|
|
|
|
string url = new GoogleDrive(oauth).GetAuthorizationURL();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(url))
|
|
|
|
|
{
|
|
|
|
|
Config.GoogleDriveOAuth2Info = oauth;
|
2014-06-28 12:22:56 +12:00
|
|
|
|
URLHelpers.OpenURL(url);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
DebugHelper.WriteLine("GoogleDriveAuthOpen - Authorization URL is opened: " + url);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DebugHelper.WriteLine("GoogleDriveAuthOpen - Authorization URL is empty.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void GoogleDriveAuthComplete(string code)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(code) && Config.GoogleDriveOAuth2Info != null)
|
|
|
|
|
{
|
|
|
|
|
bool result = new GoogleDrive(Config.GoogleDriveOAuth2Info).GetAccessToken(code);
|
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
2014-06-17 00:20:06 +12:00
|
|
|
|
oauth2GoogleDrive.Status = OAuthLoginStatus.LoginSuccessful;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-06-17 00:20:06 +12:00
|
|
|
|
oauth2GoogleDrive.Status = OAuthLoginStatus.LoginFailed;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
2014-07-01 22:18:07 +12:00
|
|
|
|
|
|
|
|
|
btnGoogleDriveRefreshFolders.Enabled = result;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void GoogleDriveAuthRefresh()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (OAuth2Info.CheckOAuth(Config.GoogleDriveOAuth2Info))
|
|
|
|
|
{
|
|
|
|
|
bool result = new GoogleDrive(Config.GoogleDriveOAuth2Info).RefreshAccessToken();
|
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
2014-06-17 00:20:06 +12:00
|
|
|
|
oauth2GoogleDrive.Status = OAuthLoginStatus.LoginSuccessful;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-06-17 00:20:06 +12:00
|
|
|
|
oauth2GoogleDrive.Status = OAuthLoginStatus.LoginFailed;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
2014-07-01 22:18:07 +12:00
|
|
|
|
|
|
|
|
|
btnGoogleDriveRefreshFolders.Enabled = result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2014-07-01 22:18:07 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void GoogleDriveRefreshFolders()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
lvGoogleDriveFoldersList.Items.Clear();
|
|
|
|
|
|
|
|
|
|
if (OAuth2Info.CheckOAuth(Config.GoogleDriveOAuth2Info))
|
|
|
|
|
{
|
2016-09-17 19:07:02 +12:00
|
|
|
|
List<GoogleDriveFile> folders = new GoogleDrive(Config.GoogleDriveOAuth2Info).GetFolders();
|
2014-07-01 22:18:07 +12:00
|
|
|
|
|
|
|
|
|
if (folders != null)
|
|
|
|
|
{
|
2016-09-17 19:07:02 +12:00
|
|
|
|
foreach (GoogleDriveFile folder in folders)
|
2014-07-01 22:18:07 +12:00
|
|
|
|
{
|
|
|
|
|
ListViewItem lvi = new ListViewItem(folder.title);
|
2014-07-02 04:40:40 +12:00
|
|
|
|
lvi.SubItems.Add(folder.description);
|
2014-07-01 22:18:07 +12:00
|
|
|
|
lvi.Tag = folder;
|
|
|
|
|
lvGoogleDriveFoldersList.Items.Add(lvi);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion Google Drive
|
|
|
|
|
|
|
|
|
|
#region Box
|
|
|
|
|
|
|
|
|
|
public void BoxAuthOpen()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2014-04-17 04:18:25 +12:00
|
|
|
|
OAuth2Info oauth = new OAuth2Info(APIKeys.BoxClientID, APIKeys.BoxClientSecret);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2014-04-17 04:18:25 +12:00
|
|
|
|
string url = new Box(oauth).GetAuthorizationURL();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(url))
|
|
|
|
|
{
|
2014-04-17 04:18:25 +12:00
|
|
|
|
Config.BoxOAuth2Info = oauth;
|
2015-01-19 08:01:22 +13:00
|
|
|
|
URLHelpers.OpenURL(url);
|
2014-04-17 04:18:25 +12:00
|
|
|
|
DebugHelper.WriteLine("BoxAuthOpen - Authorization URL is opened: " + url);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DebugHelper.WriteLine("BoxAuthOpen - Authorization URL is empty.");
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-17 04:18:25 +12:00
|
|
|
|
public void BoxAuthComplete(string code)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-04-17 04:18:25 +12:00
|
|
|
|
try
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-04-17 04:18:25 +12:00
|
|
|
|
if (!string.IsNullOrEmpty(code) && Config.BoxOAuth2Info != null)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-04-17 04:18:25 +12:00
|
|
|
|
bool result = new Box(Config.BoxOAuth2Info).GetAccessToken(code);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2014-04-17 04:18:25 +12:00
|
|
|
|
if (result)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-06-17 00:20:06 +12:00
|
|
|
|
oauth2Box.Status = OAuthLoginStatus.LoginSuccessful;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-06-17 00:20:06 +12:00
|
|
|
|
oauth2Box.Status = OAuthLoginStatus.LoginFailed;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
2014-04-17 04:18:25 +12:00
|
|
|
|
|
|
|
|
|
btnBoxRefreshFolders.Enabled = result;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
2014-04-17 04:18:25 +12:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2014-04-17 04:18:25 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void BoxAuthRefresh()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (OAuth2Info.CheckOAuth(Config.BoxOAuth2Info))
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-04-17 04:18:25 +12:00
|
|
|
|
bool result = new Box(Config.BoxOAuth2Info).RefreshAccessToken();
|
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
2014-06-17 00:20:06 +12:00
|
|
|
|
oauth2Box.Status = OAuthLoginStatus.LoginSuccessful;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
2014-04-17 04:18:25 +12:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-06-17 00:20:06 +12:00
|
|
|
|
oauth2Box.Status = OAuthLoginStatus.LoginFailed;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2014-04-17 04:18:25 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
btnBoxRefreshFolders.Enabled = result;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-04-17 04:18:25 +12:00
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2014-04-17 04:18:25 +12:00
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void BoxListFolders()
|
2014-04-17 11:34:31 +12:00
|
|
|
|
{
|
|
|
|
|
lvBoxFolders.Items.Clear();
|
|
|
|
|
BoxAddFolder(Box.RootFolder);
|
|
|
|
|
BoxListFolders(Box.RootFolder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void BoxListFolders(BoxFileEntry fileEntry)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-04-17 04:18:25 +12:00
|
|
|
|
if (!OAuth2Info.CheckOAuth(Config.BoxOAuth2Info))
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-12-27 02:58:38 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_ListFolders_Authentication_required_, Resources.UploadersConfigForm_BoxListFolders_Box_refresh_folders_list_failed,
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-04-17 04:18:25 +12:00
|
|
|
|
Box box = new Box(Config.BoxOAuth2Info);
|
2014-04-17 11:34:31 +12:00
|
|
|
|
BoxFileInfo files = box.GetFiles(fileEntry);
|
2014-04-17 08:35:10 +12:00
|
|
|
|
if (files != null && files.entries != null && files.entries.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (BoxFileEntry folder in files.entries.Where(x => x.type == "folder"))
|
|
|
|
|
{
|
|
|
|
|
BoxAddFolder(folder);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-17 08:35:10 +12:00
|
|
|
|
private void BoxAddFolder(BoxFileEntry folder)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-04-17 08:35:10 +12:00
|
|
|
|
ListViewItem lvi = new ListViewItem(folder.name);
|
|
|
|
|
lvi.Tag = folder;
|
|
|
|
|
lvBoxFolders.Items.Add(lvi);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion Box
|
|
|
|
|
|
2014-08-09 12:28:09 +12:00
|
|
|
|
#region OneDrive
|
|
|
|
|
|
|
|
|
|
public void OneDriveAuthOpen()
|
|
|
|
|
{
|
2014-12-26 07:36:15 +13:00
|
|
|
|
try
|
2014-08-09 12:28:09 +12:00
|
|
|
|
{
|
|
|
|
|
OAuth2Info oauth = new OAuth2Info(APIKeys.OneDriveClientID, APIKeys.OneDriveClientSecret);
|
|
|
|
|
string url = new OneDrive(oauth).GetAuthorizationURL();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(url))
|
|
|
|
|
{
|
|
|
|
|
Config.OneDriveOAuth2Info = oauth;
|
|
|
|
|
URLHelpers.OpenURL(url);
|
|
|
|
|
DebugHelper.WriteLine("OneDriveAuthOpen - Authorization URL is opened: " + url);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DebugHelper.WriteLine("OneDriveAuthOpen - Authorization URL is empty.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), "ShareX - " + Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2014-12-26 07:36:15 +13:00
|
|
|
|
}
|
2014-08-09 12:28:09 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OneDriveAuthComplete(string code)
|
|
|
|
|
{
|
2014-12-26 07:36:15 +13:00
|
|
|
|
try
|
2014-08-09 12:28:09 +12:00
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(code) && Config.OneDriveOAuth2Info != null)
|
|
|
|
|
{
|
2014-12-28 09:54:18 +13:00
|
|
|
|
bool result = new OneDrive(Config.OneDriveOAuth2Info).GetAccessToken(code);
|
2014-08-09 12:28:09 +12:00
|
|
|
|
|
2014-12-28 09:54:18 +13:00
|
|
|
|
if (result)
|
2014-08-09 12:28:09 +12:00
|
|
|
|
{
|
|
|
|
|
oAuth2OneDrive.Status = OAuthLoginStatus.LoginSuccessful;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
2014-08-09 12:28:09 +12:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
oAuth2OneDrive.Status = OAuthLoginStatus.LoginFailed;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2014-08-09 12:28:09 +12:00
|
|
|
|
}
|
2014-12-28 09:54:18 +13:00
|
|
|
|
|
|
|
|
|
tvOneDrive.Enabled = result;
|
2014-08-09 12:28:09 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
DebugHelper.WriteException(ex);
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), "ShareX - " + Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2014-12-26 07:36:15 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OneDriveAuthRefresh()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (OAuth2Info.CheckOAuth(Config.OneDriveOAuth2Info))
|
|
|
|
|
{
|
|
|
|
|
bool result = new OneDrive(Config.OneDriveOAuth2Info).RefreshAccessToken();
|
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
oAuth2OneDrive.Status = OAuthLoginStatus.LoginSuccessful;
|
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
oAuth2OneDrive.Status = OAuthLoginStatus.LoginFailed;
|
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
}
|
2014-12-28 09:54:18 +13:00
|
|
|
|
|
|
|
|
|
tvOneDrive.Enabled = result;
|
2014-12-26 07:36:15 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
}
|
2014-08-09 12:28:09 +12:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-27 13:33:23 +13:00
|
|
|
|
public void OneDriveListFolders(OneDriveFileInfo fileEntry, TreeNode tnParent)
|
2014-12-27 02:58:38 +13:00
|
|
|
|
{
|
2014-12-28 09:54:18 +13:00
|
|
|
|
Application.DoEvents();
|
|
|
|
|
OneDrive oneDrive = new OneDrive(Config.OneDriveOAuth2Info);
|
|
|
|
|
OneDrivePathInfo oneDrivePathInfo = oneDrive.GetPathInfo(fileEntry.id);
|
|
|
|
|
tnParent.Nodes.Clear();
|
|
|
|
|
foreach (OneDriveFileInfo folder in oneDrivePathInfo.data.Where(x => x.id.StartsWith("folder.")))
|
2014-12-27 02:58:38 +13:00
|
|
|
|
{
|
2014-12-28 09:54:18 +13:00
|
|
|
|
OneDriveAddFolder(folder, tnParent);
|
2014-12-27 02:58:38 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-27 13:33:23 +13:00
|
|
|
|
private void OneDriveAddFolder(OneDriveFileInfo folder, TreeNode tnParent)
|
2014-12-27 02:58:38 +13:00
|
|
|
|
{
|
2014-12-27 13:33:23 +13:00
|
|
|
|
TreeNode tn = new TreeNode(folder.name);
|
|
|
|
|
tn.Tag = folder;
|
2014-12-28 12:47:48 +13:00
|
|
|
|
tn.Nodes.Add(new TreeNode(Resources.UploadersConfigForm_OneDriveAddFolder_Querying_folders___));
|
2014-12-27 19:22:35 +13:00
|
|
|
|
|
|
|
|
|
if (tnParent != null)
|
|
|
|
|
{
|
|
|
|
|
tnParent.Nodes.Add(tn);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tvOneDrive.Nodes.Add(tn);
|
|
|
|
|
}
|
2014-12-27 02:58:38 +13:00
|
|
|
|
}
|
|
|
|
|
|
2014-08-09 12:28:09 +12:00
|
|
|
|
#endregion OneDrive
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
#region Minus
|
|
|
|
|
|
|
|
|
|
public void MinusAuth()
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(txtMinusUsername.Text) && !string.IsNullOrEmpty(txtMinusPassword.Text))
|
|
|
|
|
{
|
|
|
|
|
btnMinusAuth.Enabled = false;
|
2014-03-21 12:37:43 +13:00
|
|
|
|
btnMinusRefreshAuth.Enabled = false;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Config.MinusConfig.Username = txtMinusUsername.Text;
|
|
|
|
|
Config.MinusConfig.Password = txtMinusPassword.Text;
|
2014-03-21 12:37:43 +13:00
|
|
|
|
Config.MinusOAuth2Info = new OAuth2Info(APIKeys.MinusConsumerKey, APIKeys.MinusConsumerSecret);
|
|
|
|
|
Minus minus = new Minus(Config.MinusConfig, Config.MinusOAuth2Info);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2014-03-21 12:37:43 +13:00
|
|
|
|
if (minus.GetAccessToken())
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-03-21 12:37:43 +13:00
|
|
|
|
minus.ReadFolderList();
|
|
|
|
|
MinusUpdateControls();
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Error + ": " + ex.Message, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
btnMinusAuth.Enabled = true;
|
2014-03-21 12:37:43 +13:00
|
|
|
|
btnMinusRefreshAuth.Enabled = true;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void MinusAuthRefresh()
|
|
|
|
|
{
|
2014-03-21 12:37:43 +13:00
|
|
|
|
btnMinusAuth.Enabled = false;
|
|
|
|
|
btnMinusRefreshAuth.Enabled = false;
|
|
|
|
|
|
|
|
|
|
try
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-03-21 12:37:43 +13:00
|
|
|
|
if (OAuth2Info.CheckOAuth(Config.MinusOAuth2Info))
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-03-21 12:37:43 +13:00
|
|
|
|
bool result = new Minus(Config.MinusConfig, Config.MinusOAuth2Info).RefreshAccessToken();
|
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
2014-03-21 12:37:43 +13:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2014-03-21 12:37:43 +13:00
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-21 12:37:43 +13:00
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2014-03-21 12:37:43 +13:00
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
btnMinusAuth.Enabled = true;
|
|
|
|
|
btnMinusRefreshAuth.Enabled = true;
|
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void MinusUpdateControls()
|
|
|
|
|
{
|
2014-03-21 12:37:43 +13:00
|
|
|
|
if (Config.MinusConfig != null && Config.MinusConfig.MinusUser != null && OAuth2Info.CheckOAuth(Config.MinusOAuth2Info))
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
lblMinusAuthStatus.Text = string.Format(Resources.UploadersConfigForm_MinusUpdateControls_Logged_in_as__0__, Config.MinusConfig.MinusUser.display_name);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
txtMinusUsername.Text = Config.MinusConfig.Username;
|
|
|
|
|
txtMinusPassword.Text = Config.MinusConfig.Password;
|
|
|
|
|
cboMinusFolders.Items.Clear();
|
|
|
|
|
if (Config.MinusConfig.FolderList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
cboMinusFolders.Items.AddRange(Config.MinusConfig.FolderList.ToArray());
|
|
|
|
|
cboMinusFolders.SelectedIndex = Config.MinusConfig.FolderID.BetweenOrDefault(0, cboMinusFolders.Items.Count - 1);
|
|
|
|
|
}
|
|
|
|
|
cbMinusURLType.SelectedIndex = (int)Config.MinusConfig.LinkType;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
lblMinusAuthStatus.Text = Resources.UploadersConfigForm_MinusUpdateControls_Not_logged_in_;
|
2014-03-21 12:37:43 +13:00
|
|
|
|
btnMinusRefreshAuth.Enabled = false;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-21 12:37:43 +13:00
|
|
|
|
private bool MinusHasFolder(string name)
|
|
|
|
|
{
|
|
|
|
|
return cboMinusFolders.Items.Cast<MinusFolder>().Any(mf => mf.name == name);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
#endregion Minus
|
|
|
|
|
|
|
|
|
|
#region FTP
|
|
|
|
|
|
2017-04-21 01:56:16 +12:00
|
|
|
|
public bool FTPCheckAccount(int index)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2017-04-21 01:56:16 +12:00
|
|
|
|
return Config.FTPAccountList.IsValidIndex(index);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-21 01:56:16 +12:00
|
|
|
|
public FTPAccount FTPGetSelectedAccount()
|
2014-06-07 06:01:02 +12:00
|
|
|
|
{
|
2017-04-21 01:56:16 +12:00
|
|
|
|
int index = cbFTPAccounts.SelectedIndex;
|
|
|
|
|
|
|
|
|
|
if (FTPCheckAccount(index))
|
2014-06-07 06:01:02 +12:00
|
|
|
|
{
|
2017-04-21 01:56:16 +12:00
|
|
|
|
return Config.FTPAccountList[index];
|
2014-06-07 06:01:02 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-21 01:56:16 +12:00
|
|
|
|
public void FTPAddAccount(FTPAccount account)
|
2014-06-07 06:01:02 +12:00
|
|
|
|
{
|
|
|
|
|
if (account != null)
|
|
|
|
|
{
|
|
|
|
|
Config.FTPAccountList.Add(account);
|
2017-04-21 01:56:16 +12:00
|
|
|
|
cbFTPAccounts.Items.Add(account);
|
|
|
|
|
FTPUpdateControls();
|
2014-06-07 06:01:02 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-21 01:56:16 +12:00
|
|
|
|
private void FTPUpdateControls()
|
|
|
|
|
{
|
|
|
|
|
FTPUpdateControls(Config.FTPAccountList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void FTPUpdateControls(List<FTPAccount> accounts)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2017-04-21 01:56:16 +12:00
|
|
|
|
if (accounts != null)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2017-04-21 01:56:16 +12:00
|
|
|
|
int selected = cbFTPAccounts.SelectedIndex;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2017-04-21 01:56:16 +12:00
|
|
|
|
cbFTPAccounts.Items.Clear();
|
|
|
|
|
cbFTPImage.Items.Clear();
|
|
|
|
|
cbFTPText.Items.Clear();
|
|
|
|
|
cbFTPFile.Items.Clear();
|
|
|
|
|
|
|
|
|
|
Config.FTPAccountList = new List<FTPAccount>();
|
|
|
|
|
Config.FTPAccountList.AddRange(accounts);
|
|
|
|
|
|
|
|
|
|
if (Config.FTPAccountList.Count > 0)
|
2014-05-22 13:48:27 +12:00
|
|
|
|
{
|
2017-04-21 01:56:16 +12:00
|
|
|
|
foreach (FTPAccount account in Config.FTPAccountList)
|
|
|
|
|
{
|
|
|
|
|
cbFTPAccounts.Items.Add(account);
|
|
|
|
|
cbFTPImage.Items.Add(account);
|
|
|
|
|
cbFTPText.Items.Add(account);
|
|
|
|
|
cbFTPFile.Items.Add(account);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cbFTPAccounts.SelectedIndex = selected.Between(0, Config.FTPAccountList.Count - 1);
|
|
|
|
|
cbFTPImage.SelectedIndex = Config.FTPSelectedImage.Between(0, Config.FTPAccountList.Count - 1);
|
|
|
|
|
cbFTPText.SelectedIndex = Config.FTPSelectedText.Between(0, Config.FTPAccountList.Count - 1);
|
|
|
|
|
cbFTPFile.SelectedIndex = Config.FTPSelectedFile.Between(0, Config.FTPAccountList.Count - 1);
|
|
|
|
|
}
|
2017-04-21 04:38:20 +12:00
|
|
|
|
|
|
|
|
|
FTPUpdateEnabledStates();
|
2014-05-22 13:48:27 +12:00
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-21 04:38:20 +12:00
|
|
|
|
private void FTPUpdateEnabledStates()
|
|
|
|
|
{
|
|
|
|
|
cbFTPImage.Enabled = cbFTPText.Enabled = cbFTPFile.Enabled = cbFTPAccounts.Enabled = cbFTPAccounts.Items.Count > 0;
|
|
|
|
|
btnFTPRemove.Enabled = btnFTPDuplicate.Enabled = gbFTPAccount.Enabled = cbFTPAccounts.SelectedIndex > -1;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-21 01:56:16 +12:00
|
|
|
|
public void FTPLoadSelectedAccount()
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2017-04-21 01:56:16 +12:00
|
|
|
|
FTPAccount account = FTPGetSelectedAccount();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2015-07-15 01:52:44 +12:00
|
|
|
|
if (account != null)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2017-04-21 01:56:16 +12:00
|
|
|
|
FTPLoadAccount(account);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void FTPLoadAccount(FTPAccount account)
|
|
|
|
|
{
|
|
|
|
|
txtFTPName.Text = account.Name;
|
2015-07-15 01:52:44 +12:00
|
|
|
|
|
2017-04-21 01:56:16 +12:00
|
|
|
|
switch (account.Protocol)
|
|
|
|
|
{
|
|
|
|
|
case FTPProtocol.FTP:
|
|
|
|
|
rbFTPProtocolFTP.Checked = true;
|
|
|
|
|
break;
|
|
|
|
|
case FTPProtocol.FTPS:
|
|
|
|
|
rbFTPProtocolFTPS.Checked = true;
|
|
|
|
|
break;
|
|
|
|
|
case FTPProtocol.SFTP:
|
|
|
|
|
rbFTPProtocolSFTP.Checked = true;
|
|
|
|
|
break;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
2015-07-15 01:52:44 +12:00
|
|
|
|
|
2017-04-21 01:56:16 +12:00
|
|
|
|
txtFTPHost.Text = account.Host;
|
|
|
|
|
nudFTPPort.Value = account.Port;
|
|
|
|
|
txtFTPUsername.Text = account.Username;
|
|
|
|
|
txtFTPPassword.Text = account.Password;
|
|
|
|
|
|
|
|
|
|
if (account.IsActive)
|
|
|
|
|
{
|
|
|
|
|
rbFTPTransferModeActive.Checked = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rbFTPTransferModePassive.Checked = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
txtFTPRemoteDirectory.Text = account.SubFolderPath;
|
2017-04-21 04:38:20 +12:00
|
|
|
|
cbFTPURLPathProtocol.SelectedIndex = (int)account.BrowserProtocol;
|
2017-04-21 01:56:16 +12:00
|
|
|
|
txtFTPURLPath.Text = account.HttpHomePath;
|
|
|
|
|
cbFTPAppendRemoteDirectory.Checked = account.HttpHomePathAutoAddSubFolderPath;
|
|
|
|
|
cbFTPRemoveFileExtension.Checked = account.HttpHomePathNoExtension;
|
2017-04-21 04:38:20 +12:00
|
|
|
|
lblFTPURLPreviewValue.Text = account.PreviewHttpPath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void FTPClearFields()
|
|
|
|
|
{
|
|
|
|
|
FTPAccount account = new FTPAccount()
|
|
|
|
|
{
|
|
|
|
|
Name = "",
|
|
|
|
|
HttpHomePathAutoAddSubFolderPath = false
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
FTPLoadAccount(account);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void FTPUpdateURLPreview()
|
|
|
|
|
{
|
|
|
|
|
FTPAccount account = FTPGetSelectedAccount();
|
|
|
|
|
|
|
|
|
|
if (account != null)
|
|
|
|
|
{
|
|
|
|
|
lblFTPURLPreviewValue.Text = account.PreviewHttpPath;
|
|
|
|
|
}
|
2017-04-21 01:56:16 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void FTPTestAccountAsync(FTPAccount account)
|
|
|
|
|
{
|
|
|
|
|
if (account != null)
|
|
|
|
|
{
|
|
|
|
|
btnFTPTest.Enabled = false;
|
|
|
|
|
|
|
|
|
|
TaskEx.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
FTPTestAccount(account);
|
|
|
|
|
},
|
|
|
|
|
() =>
|
|
|
|
|
{
|
|
|
|
|
btnFTPTest.Enabled = true;
|
|
|
|
|
});
|
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-21 01:56:16 +12:00
|
|
|
|
public static void FTPTestAccount(FTPAccount account)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2016-05-25 06:15:45 +12:00
|
|
|
|
string msg = "";
|
2014-05-31 02:59:08 +12:00
|
|
|
|
string remotePath = account.GetSubFolderPath();
|
|
|
|
|
List<string> directories = new List<string>();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2014-05-31 02:59:08 +12:00
|
|
|
|
try
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-05-31 02:59:08 +12:00
|
|
|
|
if (account.Protocol == FTPProtocol.FTP || account.Protocol == FTPProtocol.FTPS)
|
|
|
|
|
{
|
|
|
|
|
using (FTP ftp = new FTP(account))
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-05-31 02:59:08 +12:00
|
|
|
|
if (ftp.Connect())
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-05-31 02:59:08 +12:00
|
|
|
|
if (!ftp.DirectoryExists(remotePath))
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-05-31 02:59:08 +12:00
|
|
|
|
directories = ftp.CreateMultiDirectory(remotePath);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-31 02:59:08 +12:00
|
|
|
|
if (ftp.IsConnected)
|
|
|
|
|
{
|
|
|
|
|
if (directories.Count > 0)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
msg = Resources.UploadersConfigForm_TestFTPAccount_Connected_Created_folders + "\r\n" + string.Join("\r\n", directories);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
2014-05-31 02:59:08 +12:00
|
|
|
|
else
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
msg = Resources.UploadersConfigForm_TestFTPAccount_Connected_;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-05-31 02:59:08 +12:00
|
|
|
|
}
|
|
|
|
|
else if (account.Protocol == FTPProtocol.SFTP)
|
|
|
|
|
{
|
|
|
|
|
using (SFTP sftp = new SFTP(account))
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-05-31 02:59:08 +12:00
|
|
|
|
if (sftp.Connect())
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-05-31 02:59:08 +12:00
|
|
|
|
if (!sftp.DirectoryExists(remotePath))
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-05-31 02:59:08 +12:00
|
|
|
|
directories = sftp.CreateMultiDirectory(remotePath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sftp.IsConnected)
|
|
|
|
|
{
|
|
|
|
|
if (directories.Count > 0)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
msg = Resources.UploadersConfigForm_TestFTPAccount_Connected_Created_folders + "\r\n" + string.Join("\r\n", directories);
|
2014-05-31 02:59:08 +12:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
msg = Resources.UploadersConfigForm_TestFTPAccount_Connected_;
|
2014-05-31 02:59:08 +12:00
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-05-31 02:59:08 +12:00
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
2014-05-31 02:59:08 +12:00
|
|
|
|
catch (Exception e)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-05-31 02:59:08 +12:00
|
|
|
|
msg = e.Message;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
2014-05-31 02:59:08 +12:00
|
|
|
|
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(msg, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
2017-04-21 01:56:16 +12:00
|
|
|
|
|
|
|
|
|
private void FTPOpenClient(FTPAccount account)
|
|
|
|
|
{
|
|
|
|
|
if (account.Protocol == FTPProtocol.FTP || account.Protocol == FTPProtocol.FTPS)
|
|
|
|
|
{
|
|
|
|
|
new FTPClientForm(account).Show();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_FTPOpenClient_FTP_client_only_supports_FTP_or_FTPS_, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
|
|
|
|
#endregion FTP
|
|
|
|
|
|
|
|
|
|
#region SendSpace
|
|
|
|
|
|
|
|
|
|
public UserPassBox SendSpaceRegister()
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
UserPassBox upb = new UserPassBox(Resources.UploadersConfigForm_SendSpaceRegister_SendSpace_Registration___, "John Doe", "john.doe@gmail.com", "JohnDoe", "");
|
2013-11-03 23:53:49 +13:00
|
|
|
|
upb.ShowDialog();
|
|
|
|
|
if (upb.DialogResult == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
SendSpace sendSpace = new SendSpace(APIKeys.SendSpaceKey);
|
|
|
|
|
upb.Success = sendSpace.AuthRegister(upb.UserName, upb.FullName, upb.Email, upb.Password);
|
|
|
|
|
if (!upb.Success && sendSpace.Errors.Count > 0)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(sendSpace.ToErrorString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return upb;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion SendSpace
|
|
|
|
|
|
|
|
|
|
#region Ge.tt
|
|
|
|
|
|
|
|
|
|
public void Ge_ttLogin()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Ge_tt gett = new Ge_tt(APIKeys.Ge_ttKey);
|
|
|
|
|
Ge_ttLogin login = gett.Login(txtGe_ttEmail.Text, txtGe_ttPassword.Text);
|
|
|
|
|
Config.Ge_ttLogin = login;
|
2014-10-18 00:48:41 +13:00
|
|
|
|
lblGe_ttStatus.Text = Resources.UploadersConfigForm_Login_successful;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Config.Ge_ttLogin = null;
|
2014-10-18 00:48:41 +13:00
|
|
|
|
lblGe_ttStatus.Text = Resources.UploadersConfigForm_Login_failed;
|
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion Ge.tt
|
|
|
|
|
|
|
|
|
|
#region Pastebin
|
|
|
|
|
|
|
|
|
|
public void PastebinLogin()
|
|
|
|
|
{
|
|
|
|
|
if (Config.PastebinSettings != null)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Pastebin pastebin = new Pastebin(APIKeys.PastebinKey, Config.PastebinSettings);
|
|
|
|
|
|
|
|
|
|
if (pastebin.Login())
|
|
|
|
|
{
|
2014-09-15 21:33:29 +12:00
|
|
|
|
UpdatePastebinStatus();
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-09-15 21:33:29 +12:00
|
|
|
|
UpdatePastebinStatus();
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-15 21:33:29 +12:00
|
|
|
|
public void UpdatePastebinStatus()
|
|
|
|
|
{
|
|
|
|
|
if (Config.PastebinSettings == null || string.IsNullOrEmpty(Config.PastebinSettings.UserKey))
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
lblPastebinLoginStatus.Text = Resources.OAuthControl_Status_Status__Not_logged_in_;
|
2014-09-15 21:33:29 +12:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
lblPastebinLoginStatus.Text = Resources.OAuthControl_Status_Status__Logged_in_;
|
2014-09-15 21:33:29 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
#endregion Pastebin
|
|
|
|
|
|
2014-03-27 20:05:14 +13:00
|
|
|
|
#region Pushbullet
|
|
|
|
|
|
|
|
|
|
public void PushbulletGetDevices()
|
|
|
|
|
{
|
|
|
|
|
cboPushbulletDevices.Items.Clear();
|
2014-03-31 00:37:38 +13:00
|
|
|
|
cboPushbulletDevices.ResetText();
|
2014-03-27 20:05:14 +13:00
|
|
|
|
|
2014-03-31 00:37:38 +13:00
|
|
|
|
Pushbullet pushbullet = new Pushbullet(Config.PushbulletSettings);
|
2014-03-27 20:05:14 +13:00
|
|
|
|
Config.PushbulletSettings.DeviceList = pushbullet.GetDeviceList();
|
|
|
|
|
|
2014-03-30 23:28:34 +13:00
|
|
|
|
if (Config.PushbulletSettings.DeviceList.Count > 0)
|
|
|
|
|
{
|
2014-03-31 00:37:38 +13:00
|
|
|
|
Config.PushbulletSettings.SelectedDevice = 0;
|
2014-03-27 20:05:14 +13:00
|
|
|
|
|
2014-03-30 23:28:34 +13:00
|
|
|
|
cboPushbulletDevices.Enabled = true;
|
2014-03-27 20:05:14 +13:00
|
|
|
|
|
2014-03-30 23:28:34 +13:00
|
|
|
|
Config.PushbulletSettings.DeviceList.ForEach(pbDevice =>
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
cboPushbulletDevices.Items.Add(pbDevice.Name ?? Resources.UploadersConfigForm_LoadSettings_Invalid_device_name);
|
2014-03-30 23:28:34 +13:00
|
|
|
|
});
|
2014-03-27 20:05:14 +13:00
|
|
|
|
|
2014-03-31 00:37:38 +13:00
|
|
|
|
cboPushbulletDevices.SelectedIndex = 0;
|
2014-03-30 23:28:34 +13:00
|
|
|
|
}
|
2014-03-27 20:05:14 +13:00
|
|
|
|
}
|
2014-03-27 21:17:28 +13:00
|
|
|
|
|
2014-03-27 20:05:14 +13:00
|
|
|
|
#endregion Pushbullet
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
#region Twitter
|
|
|
|
|
|
2015-04-28 13:33:53 +12:00
|
|
|
|
private OAuthInfo GetSelectedTwitterAccount()
|
|
|
|
|
{
|
|
|
|
|
return Config.TwitterOAuthInfoList.ReturnIfValidIndex(Config.TwitterSelectedAccount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool CheckTwitterAccounts()
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
return Config.TwitterOAuthInfoList.IsValidIndex(Config.TwitterSelectedAccount);
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-28 13:33:53 +12:00
|
|
|
|
private bool TwitterUpdateSelected()
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2015-09-03 03:41:02 +12:00
|
|
|
|
Config.TwitterSelectedAccount = lbTwitterAccounts.SelectedIndex;
|
2015-04-28 13:33:53 +12:00
|
|
|
|
|
|
|
|
|
if (Config.TwitterSelectedAccount > -1)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2015-05-02 23:55:43 +12:00
|
|
|
|
OAuthInfo oauth = Config.TwitterOAuthInfoList[Config.TwitterSelectedAccount];
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2015-04-28 13:33:53 +12:00
|
|
|
|
if (oauth != null)
|
2014-05-30 23:38:23 +12:00
|
|
|
|
{
|
2015-05-02 23:55:43 +12:00
|
|
|
|
txtTwitterDescription.Enabled = true;
|
2015-04-28 13:33:53 +12:00
|
|
|
|
txtTwitterDescription.Text = oauth.Description;
|
|
|
|
|
oauthTwitter.Enabled = true;
|
|
|
|
|
|
|
|
|
|
if (OAuthInfo.CheckOAuth(oauth))
|
|
|
|
|
{
|
|
|
|
|
oauthTwitter.Status = OAuthLoginStatus.LoginSuccessful;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
oauthTwitter.Status = OAuthLoginStatus.LoginRequired;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
2014-05-30 23:38:23 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-04-28 13:33:53 +12:00
|
|
|
|
|
2015-05-02 23:55:43 +12:00
|
|
|
|
txtTwitterDescription.Enabled = false;
|
2016-05-25 06:15:45 +12:00
|
|
|
|
txtTwitterDescription.Text = "";
|
2015-04-28 13:33:53 +12:00
|
|
|
|
oauthTwitter.Enabled = false;
|
|
|
|
|
return false;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2015-04-28 13:33:53 +12:00
|
|
|
|
private void TwitterAuthOpen()
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-05-30 23:38:23 +12:00
|
|
|
|
if (CheckTwitterAccounts())
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2015-04-28 13:33:53 +12:00
|
|
|
|
try
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2015-04-28 13:33:53 +12:00
|
|
|
|
OAuthInfo oauth = new OAuthInfo(APIKeys.TwitterConsumerKey, APIKeys.TwitterConsumerSecret);
|
2014-05-30 23:38:23 +12:00
|
|
|
|
|
2015-04-28 13:33:53 +12:00
|
|
|
|
string url = new Twitter(oauth).GetAuthorizationURL();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(url))
|
2014-05-30 23:38:23 +12:00
|
|
|
|
{
|
2015-04-28 13:33:53 +12:00
|
|
|
|
oauth.Description = Config.TwitterOAuthInfoList[Config.TwitterSelectedAccount].Description;
|
|
|
|
|
Config.TwitterOAuthInfoList[Config.TwitterSelectedAccount] = oauth;
|
|
|
|
|
URLHelpers.OpenURL(url);
|
|
|
|
|
DebugHelper.WriteLine("TwitterAuthOpen - Authorization URL is opened: " + url);
|
2014-05-30 23:38:23 +12:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-04-28 13:33:53 +12:00
|
|
|
|
DebugHelper.WriteLine("TwitterAuthOpen - Authorization URL is empty.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void TwitterAuthComplete(string code)
|
|
|
|
|
{
|
|
|
|
|
if (CheckTwitterAccounts())
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
OAuthInfo oauth = GetSelectedTwitterAccount();
|
|
|
|
|
|
|
|
|
|
if (oauth != null && !string.IsNullOrEmpty(oauth.AuthToken) && !string.IsNullOrEmpty(oauth.AuthSecret))
|
|
|
|
|
{
|
|
|
|
|
bool result = new Twitter(oauth).GetAccessToken(code);
|
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
2016-05-25 06:15:45 +12:00
|
|
|
|
oauth.AuthVerifier = "";
|
2015-04-28 13:33:53 +12:00
|
|
|
|
oauthTwitter.Status = OAuthLoginStatus.LoginSuccessful;
|
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
oauthTwitter.Status = OAuthLoginStatus.LoginFailed;
|
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
}
|
2014-05-30 23:38:23 +12:00
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
2015-04-28 13:33:53 +12:00
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void TwitterAuthClear()
|
|
|
|
|
{
|
|
|
|
|
if (CheckTwitterAccounts())
|
|
|
|
|
{
|
|
|
|
|
OAuthInfo oauth = new OAuthInfo();
|
|
|
|
|
|
|
|
|
|
OAuthInfo oauth2 = GetSelectedTwitterAccount();
|
|
|
|
|
|
|
|
|
|
if (oauth2 != null)
|
|
|
|
|
{
|
|
|
|
|
oauth.Description = oauth2.Description;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Config.TwitterOAuthInfoList[Config.TwitterSelectedAccount] = oauth;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion Twitter
|
|
|
|
|
|
|
|
|
|
#region goo.gl
|
|
|
|
|
|
|
|
|
|
public void GoogleURLShortenerAuthOpen()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
OAuth2Info oauth = new OAuth2Info(APIKeys.GoogleClientID, APIKeys.GoogleClientSecret);
|
|
|
|
|
|
|
|
|
|
string url = new GoogleURLShortener(oauth).GetAuthorizationURL();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(url))
|
|
|
|
|
{
|
|
|
|
|
Config.GoogleURLShortenerOAuth2Info = oauth;
|
2014-06-28 12:22:56 +12:00
|
|
|
|
URLHelpers.OpenURL(url);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
DebugHelper.WriteLine("GoogleURLShortenerAuthOpen - Authorization URL is opened: " + url);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DebugHelper.WriteLine("GoogleURLShortenerAuthOpen - Authorization URL is empty.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void GoogleURLShortenerAuthComplete(string code)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(code) && Config.GoogleURLShortenerOAuth2Info != null)
|
|
|
|
|
{
|
|
|
|
|
bool result = new GoogleDrive(Config.GoogleURLShortenerOAuth2Info).GetAccessToken(code);
|
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
2014-06-17 00:20:06 +12:00
|
|
|
|
oauth2GoogleURLShortener.Status = OAuthLoginStatus.LoginSuccessful;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-06-17 00:20:06 +12:00
|
|
|
|
oauth2GoogleURLShortener.Status = OAuthLoginStatus.LoginFailed;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void GoogleURLShortenerAuthRefresh()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (OAuth2Info.CheckOAuth(Config.GoogleURLShortenerOAuth2Info))
|
|
|
|
|
{
|
|
|
|
|
bool result = new GoogleDrive(Config.GoogleURLShortenerOAuth2Info).RefreshAccessToken();
|
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
2014-06-17 00:20:06 +12:00
|
|
|
|
oauth2GoogleURLShortener.Status = OAuthLoginStatus.LoginSuccessful;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-06-17 00:20:06 +12:00
|
|
|
|
oauth2GoogleURLShortener.Status = OAuthLoginStatus.LoginFailed;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion goo.gl
|
|
|
|
|
|
2013-12-21 04:59:26 +13:00
|
|
|
|
#region bit.ly
|
|
|
|
|
|
|
|
|
|
public void BitlyAuthOpen()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
OAuth2Info oauth = new OAuth2Info(APIKeys.BitlyClientID, APIKeys.BitlyClientSecret);
|
|
|
|
|
|
|
|
|
|
string url = new BitlyURLShortener(oauth).GetAuthorizationURL();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(url))
|
|
|
|
|
{
|
|
|
|
|
Config.BitlyOAuth2Info = oauth;
|
2014-06-28 12:22:56 +12:00
|
|
|
|
URLHelpers.OpenURL(url);
|
2013-12-21 04:59:26 +13:00
|
|
|
|
DebugHelper.WriteLine("BitlyAuthOpen - Authorization URL is opened: " + url);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DebugHelper.WriteLine("BitlyAuthOpen - Authorization URL is empty.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-12-21 04:59:26 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void BitlyAuthComplete(string code)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(code) && Config.BitlyOAuth2Info != null)
|
|
|
|
|
{
|
|
|
|
|
bool result = new BitlyURLShortener(Config.BitlyOAuth2Info).GetAccessToken(code);
|
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
2014-06-17 00:20:06 +12:00
|
|
|
|
oauth2Bitly.Status = OAuthLoginStatus.LoginSuccessful;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
2013-12-21 04:59:26 +13:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-06-17 00:20:06 +12:00
|
|
|
|
oauth2Bitly.Status = OAuthLoginStatus.LoginFailed;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-12-21 04:59:26 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-12-21 04:59:26 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion bit.ly
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
#region Custom uploader
|
|
|
|
|
|
2017-01-17 06:57:40 +13:00
|
|
|
|
private void LoadCustomUploaderTab(bool selectLastItem = false)
|
|
|
|
|
{
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
|
btnCustomUploadersExportAll.Visible = true;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
CustomUploaderClearFields();
|
|
|
|
|
|
|
|
|
|
if (selectLastItem && lbCustomUploaderList.Items.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
lbCustomUploaderList.SelectedIndex = lbCustomUploaderList.Items.Count - 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void UpdateCustomUploaderTab()
|
|
|
|
|
{
|
|
|
|
|
if (IsInstanceActive)
|
|
|
|
|
{
|
|
|
|
|
UploadersConfigForm form = GetFormInstance(null);
|
|
|
|
|
form.LoadCustomUploaderTab(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-15 11:34:53 +13:00
|
|
|
|
private void AddCustomUploaderDestinationTypes()
|
|
|
|
|
{
|
|
|
|
|
string[] enums = Helpers.GetLocalizedEnumDescriptions<CustomUploaderDestinationType>().Skip(1).Select(x => x.Replace("&", "&&")).ToArray();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < enums.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
ToolStripMenuItem tsmi = new ToolStripMenuItem(enums[i]);
|
|
|
|
|
|
|
|
|
|
int index = i;
|
|
|
|
|
|
|
|
|
|
tsmi.Click += (sender, e) =>
|
|
|
|
|
{
|
|
|
|
|
ToolStripMenuItem tsmi2 = (ToolStripMenuItem)cmsCustomUploaderDestinationType.Items[index];
|
|
|
|
|
tsmi2.Checked = !tsmi2.Checked;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
cmsCustomUploaderDestinationType.Items.Add(tsmi);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cmsCustomUploaderDestinationType.Closing += (sender, e) => e.Cancel = e.CloseReason == ToolStripDropDownCloseReason.ItemClicked;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetCustomUploaderDestinationType(CustomUploaderDestinationType destinationType)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < cmsCustomUploaderDestinationType.Items.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
ToolStripMenuItem tsmi = (ToolStripMenuItem)cmsCustomUploaderDestinationType.Items[i];
|
|
|
|
|
tsmi.Checked = destinationType.HasFlag(1 << i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private CustomUploaderDestinationType GetCustomUploaderDestinationType()
|
|
|
|
|
{
|
|
|
|
|
CustomUploaderDestinationType destinationType = CustomUploaderDestinationType.None;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < cmsCustomUploaderDestinationType.Items.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
ToolStripMenuItem tsmi = (ToolStripMenuItem)cmsCustomUploaderDestinationType.Items[i];
|
|
|
|
|
|
|
|
|
|
if (tsmi.Checked)
|
|
|
|
|
{
|
|
|
|
|
destinationType |= (CustomUploaderDestinationType)(1 << i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return destinationType;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
private void UpdateCustomUploader()
|
|
|
|
|
{
|
|
|
|
|
int index = lbCustomUploaderList.SelectedIndex;
|
|
|
|
|
|
2013-12-03 01:08:09 +13:00
|
|
|
|
if (index >= 0)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
CustomUploaderItem customUploader = GetCustomUploaderFromFields();
|
|
|
|
|
|
2013-12-03 01:08:09 +13:00
|
|
|
|
if (customUploader != null && !string.IsNullOrEmpty(customUploader.Name))
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
Config.CustomUploadersList[index] = customUploader;
|
|
|
|
|
lbCustomUploaderList.Items[index] = customUploader.Name;
|
|
|
|
|
PrepareCustomUploaderList();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-07 05:21:03 +12:00
|
|
|
|
private CustomUploaderItem GetSelectedCustomUploader()
|
2013-12-03 01:08:09 +13:00
|
|
|
|
{
|
2014-06-07 05:21:03 +12:00
|
|
|
|
if (lbCustomUploaderList.SelectedIndex >= 0)
|
2013-12-03 01:08:09 +13:00
|
|
|
|
{
|
|
|
|
|
CustomUploaderItem customUploader = GetCustomUploaderFromFields();
|
|
|
|
|
|
|
|
|
|
if (customUploader != null && !string.IsNullOrEmpty(customUploader.Name))
|
|
|
|
|
{
|
2014-06-07 05:21:03 +12:00
|
|
|
|
return customUploader;
|
2013-12-03 01:08:09 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-06-07 05:21:03 +12:00
|
|
|
|
|
|
|
|
|
return null;
|
2013-12-03 01:08:09 +13:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-07 05:21:03 +12:00
|
|
|
|
private void AddCustomUploader(CustomUploaderItem customUploader)
|
2013-12-03 01:08:09 +13:00
|
|
|
|
{
|
2014-06-07 05:21:03 +12:00
|
|
|
|
if (customUploader != null && !string.IsNullOrEmpty(customUploader.Name))
|
2013-12-03 01:08:09 +13:00
|
|
|
|
{
|
2014-06-07 05:21:03 +12:00
|
|
|
|
Config.CustomUploadersList.Add(customUploader);
|
|
|
|
|
lbCustomUploaderList.Items.Add(customUploader.Name);
|
|
|
|
|
lbCustomUploaderList.SelectedIndex = lbCustomUploaderList.Items.Count - 1;
|
|
|
|
|
PrepareCustomUploaderList();
|
2013-12-03 01:08:09 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-23 02:07:21 +12:00
|
|
|
|
private void CustomUploaderClearUploaders()
|
|
|
|
|
{
|
|
|
|
|
Config.CustomUploadersList.Clear();
|
|
|
|
|
lbCustomUploaderList.Items.Clear();
|
|
|
|
|
CustomUploaderClearFields();
|
|
|
|
|
Config.CustomImageUploaderSelected = Config.CustomTextUploaderSelected = Config.CustomFileUploaderSelected = Config.CustomURLShortenerSelected = 0;
|
|
|
|
|
PrepareCustomUploaderList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CustomUploaderClearFields()
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
LoadCustomUploader(new CustomUploaderItem());
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-22 04:44:28 +13:00
|
|
|
|
private void CustomUploaderExportAll()
|
|
|
|
|
{
|
|
|
|
|
if (Config.CustomUploadersList != null)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < lbCustomUploaderList.Items.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
lbCustomUploaderList.SelectedIndex = i;
|
|
|
|
|
UpdateCustomUploader();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
using (FolderSelectDialog fsd = new FolderSelectDialog())
|
|
|
|
|
{
|
|
|
|
|
if (fsd.ShowDialog())
|
|
|
|
|
{
|
|
|
|
|
foreach (CustomUploaderItem item in Config.CustomUploadersList)
|
|
|
|
|
{
|
|
|
|
|
string json = eiCustomUploaders.Serialize(item);
|
2017-01-17 09:49:08 +13:00
|
|
|
|
string filepath = Path.Combine(fsd.FileName, item.Name + ".sxcu");
|
2015-12-22 04:44:28 +13:00
|
|
|
|
File.WriteAllText(filepath, json, Encoding.UTF8);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-23 02:07:21 +12:00
|
|
|
|
private void CustomUploaderFixSelectedUploader(int removedIndex)
|
|
|
|
|
{
|
|
|
|
|
if (Config.CustomImageUploaderSelected == removedIndex) Config.CustomImageUploaderSelected = 0;
|
|
|
|
|
else if (Config.CustomImageUploaderSelected > removedIndex) Config.CustomImageUploaderSelected--;
|
|
|
|
|
|
|
|
|
|
if (Config.CustomTextUploaderSelected == removedIndex) Config.CustomTextUploaderSelected = 0;
|
|
|
|
|
else if (Config.CustomTextUploaderSelected > removedIndex) Config.CustomTextUploaderSelected--;
|
|
|
|
|
|
|
|
|
|
if (Config.CustomFileUploaderSelected == removedIndex) Config.CustomFileUploaderSelected = 0;
|
|
|
|
|
else if (Config.CustomFileUploaderSelected > removedIndex) Config.CustomFileUploaderSelected--;
|
|
|
|
|
|
|
|
|
|
if (Config.CustomURLShortenerSelected == removedIndex) Config.CustomURLShortenerSelected = 0;
|
|
|
|
|
else if (Config.CustomURLShortenerSelected > removedIndex) Config.CustomURLShortenerSelected--;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
private void PrepareCustomUploaderList()
|
|
|
|
|
{
|
|
|
|
|
cbCustomUploaderImageUploader.Items.Clear();
|
|
|
|
|
cbCustomUploaderTextUploader.Items.Clear();
|
|
|
|
|
cbCustomUploaderFileUploader.Items.Clear();
|
|
|
|
|
cbCustomUploaderURLShortener.Items.Clear();
|
|
|
|
|
|
|
|
|
|
foreach (CustomUploaderItem item in Config.CustomUploadersList)
|
|
|
|
|
{
|
|
|
|
|
cbCustomUploaderImageUploader.Items.Add(item);
|
|
|
|
|
cbCustomUploaderTextUploader.Items.Add(item);
|
|
|
|
|
cbCustomUploaderFileUploader.Items.Add(item);
|
|
|
|
|
cbCustomUploaderURLShortener.Items.Add(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Config.CustomUploadersList.IsValidIndex(Config.CustomImageUploaderSelected))
|
|
|
|
|
{
|
|
|
|
|
cbCustomUploaderImageUploader.SelectedIndex = Config.CustomImageUploaderSelected;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Config.CustomUploadersList.IsValidIndex(Config.CustomTextUploaderSelected))
|
|
|
|
|
{
|
|
|
|
|
cbCustomUploaderTextUploader.SelectedIndex = Config.CustomTextUploaderSelected;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Config.CustomUploadersList.IsValidIndex(Config.CustomFileUploaderSelected))
|
|
|
|
|
{
|
|
|
|
|
cbCustomUploaderFileUploader.SelectedIndex = Config.CustomFileUploaderSelected;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Config.CustomUploadersList.IsValidIndex(Config.CustomURLShortenerSelected))
|
|
|
|
|
{
|
|
|
|
|
cbCustomUploaderURLShortener.SelectedIndex = Config.CustomURLShortenerSelected;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadCustomUploader(CustomUploaderItem customUploader)
|
|
|
|
|
{
|
2015-12-23 03:51:47 +13:00
|
|
|
|
txtCustomUploaderName.Text = customUploader.Name ?? "";
|
2017-01-15 11:34:53 +13:00
|
|
|
|
SetCustomUploaderDestinationType(customUploader.DestinationType);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
|
|
|
|
cbCustomUploaderRequestType.SelectedIndex = (int)customUploader.RequestType;
|
2015-12-23 03:51:47 +13:00
|
|
|
|
txtCustomUploaderRequestURL.Text = customUploader.RequestURL ?? "";
|
2015-12-22 03:31:59 +13:00
|
|
|
|
txtCustomUploaderFileForm.Text = customUploader.FileFormName ?? "";
|
2013-11-03 23:53:49 +13:00
|
|
|
|
txtCustomUploaderFileForm.Enabled = customUploader.RequestType == CustomUploaderRequestType.POST;
|
|
|
|
|
|
2015-12-22 03:31:59 +13:00
|
|
|
|
txtCustomUploaderArgName.Text = "";
|
|
|
|
|
txtCustomUploaderArgValue.Text = "";
|
2013-11-03 23:53:49 +13:00
|
|
|
|
lvCustomUploaderArguments.Items.Clear();
|
2015-12-22 03:31:59 +13:00
|
|
|
|
if (customUploader.Arguments != null)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2015-12-22 03:31:59 +13:00
|
|
|
|
foreach (KeyValuePair<string, string> arg in customUploader.Arguments)
|
|
|
|
|
{
|
|
|
|
|
lvCustomUploaderArguments.Items.Add(arg.Key).SubItems.Add(arg.Value);
|
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-22 03:31:59 +13:00
|
|
|
|
txtCustomUploaderHeaderName.Text = "";
|
|
|
|
|
txtCustomUploaderHeaderValue.Text = "";
|
2015-10-20 01:26:36 +13:00
|
|
|
|
lvCustomUploaderHeaders.Items.Clear();
|
2015-12-22 03:31:59 +13:00
|
|
|
|
if (customUploader.Headers != null)
|
2015-10-20 01:26:36 +13:00
|
|
|
|
{
|
2015-12-22 03:31:59 +13:00
|
|
|
|
foreach (KeyValuePair<string, string> arg in customUploader.Headers)
|
|
|
|
|
{
|
|
|
|
|
lvCustomUploaderHeaders.Items.Add(arg.Key).SubItems.Add(arg.Value);
|
|
|
|
|
}
|
2015-10-20 01:26:36 +13:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
cbCustomUploaderResponseType.SelectedIndex = (int)customUploader.ResponseType;
|
2015-12-22 03:31:59 +13:00
|
|
|
|
txtCustomUploaderRegexp.Text = "";
|
2013-11-03 23:53:49 +13:00
|
|
|
|
lvCustomUploaderRegexps.Items.Clear();
|
2015-12-22 03:31:59 +13:00
|
|
|
|
if (customUploader.RegexList != null)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2015-12-22 03:31:59 +13:00
|
|
|
|
foreach (string regexp in customUploader.RegexList)
|
|
|
|
|
{
|
|
|
|
|
lvCustomUploaderRegexps.Items.Add(regexp);
|
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
2015-12-23 03:51:47 +13:00
|
|
|
|
txtCustomUploaderJsonPath.Text = "";
|
|
|
|
|
txtCustomUploaderXPath.Text = "";
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2015-12-22 03:31:59 +13:00
|
|
|
|
txtCustomUploaderURL.Text = customUploader.URL ?? "";
|
|
|
|
|
txtCustomUploaderThumbnailURL.Text = customUploader.ThumbnailURL ?? "";
|
|
|
|
|
txtCustomUploaderDeletionURL.Text = customUploader.DeletionURL ?? "";
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private CustomUploaderItem GetCustomUploaderFromFields()
|
|
|
|
|
{
|
|
|
|
|
CustomUploaderItem item = new CustomUploaderItem(txtCustomUploaderName.Text);
|
2015-10-20 01:26:36 +13:00
|
|
|
|
|
2017-01-15 11:34:53 +13:00
|
|
|
|
item.DestinationType = GetCustomUploaderDestinationType();
|
|
|
|
|
|
2015-10-20 01:26:36 +13:00
|
|
|
|
item.RequestType = (CustomUploaderRequestType)cbCustomUploaderRequestType.SelectedIndex;
|
2015-12-22 03:31:59 +13:00
|
|
|
|
|
2015-10-20 01:26:36 +13:00
|
|
|
|
item.RequestURL = txtCustomUploaderRequestURL.Text;
|
|
|
|
|
|
2015-12-22 03:31:59 +13:00
|
|
|
|
if (!string.IsNullOrEmpty(txtCustomUploaderFileForm.Text))
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2015-12-22 03:31:59 +13:00
|
|
|
|
item.FileFormName = txtCustomUploaderFileForm.Text;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-22 03:31:59 +13:00
|
|
|
|
if (lvCustomUploaderArguments.Items.Count > 0)
|
2015-10-20 01:26:36 +13:00
|
|
|
|
{
|
2015-12-22 03:31:59 +13:00
|
|
|
|
item.Arguments = new Dictionary<string, string>();
|
|
|
|
|
|
|
|
|
|
foreach (ListViewItem lvItem in lvCustomUploaderArguments.Items)
|
|
|
|
|
{
|
|
|
|
|
item.Arguments.Add(lvItem.Text, lvItem.SubItems[1].Text);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (lvCustomUploaderHeaders.Items.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
item.Headers = new Dictionary<string, string>();
|
|
|
|
|
|
|
|
|
|
foreach (ListViewItem lvItem in lvCustomUploaderHeaders.Items)
|
|
|
|
|
{
|
|
|
|
|
item.Headers.Add(lvItem.Text, lvItem.SubItems[1].Text);
|
|
|
|
|
}
|
2015-10-20 01:26:36 +13:00
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
|
|
|
|
item.ResponseType = (ResponseType)cbCustomUploaderResponseType.SelectedIndex;
|
2015-12-22 03:31:59 +13:00
|
|
|
|
|
|
|
|
|
if (lvCustomUploaderRegexps.Items.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
item.RegexList = new List<string>();
|
|
|
|
|
|
|
|
|
|
foreach (ListViewItem lvItem in lvCustomUploaderRegexps.Items)
|
|
|
|
|
{
|
|
|
|
|
item.RegexList.Add(lvItem.Text);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(txtCustomUploaderURL.Text))
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2015-12-22 03:31:59 +13:00
|
|
|
|
item.URL = txtCustomUploaderURL.Text;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-22 03:31:59 +13:00
|
|
|
|
if (!string.IsNullOrEmpty(txtCustomUploaderThumbnailURL.Text))
|
|
|
|
|
{
|
|
|
|
|
item.ThumbnailURL = txtCustomUploaderThumbnailURL.Text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(txtCustomUploaderDeletionURL.Text))
|
|
|
|
|
{
|
|
|
|
|
item.DeletionURL = txtCustomUploaderDeletionURL.Text;
|
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-22 13:22:32 +12:00
|
|
|
|
private void TestCustomUploader(CustomUploaderType type, CustomUploaderItem item)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2015-06-06 22:15:54 +12:00
|
|
|
|
btnCustomUploaderImageUploaderTest.Enabled = btnCustomUploaderTextUploaderTest.Enabled =
|
|
|
|
|
btnCustomUploaderFileUploaderTest.Enabled = btnCustomUploaderURLShortenerTest.Enabled = false;
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
UploadResult result = null;
|
|
|
|
|
|
2014-01-20 20:14:36 +13:00
|
|
|
|
txtCustomUploaderLog.ResetText();
|
|
|
|
|
|
2014-05-24 03:39:14 +12:00
|
|
|
|
TaskEx.Run(() =>
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case CustomUploaderType.Image:
|
2013-11-06 06:58:22 +13:00
|
|
|
|
using (Stream stream = ShareXResources.Logo.GetStream())
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
CustomImageUploader imageUploader = new CustomImageUploader(item);
|
|
|
|
|
result = imageUploader.Upload(stream, "Test.png");
|
|
|
|
|
result.Errors = imageUploader.Errors;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case CustomUploaderType.Text:
|
|
|
|
|
CustomTextUploader textUploader = new CustomTextUploader(item);
|
2014-10-18 00:48:41 +13:00
|
|
|
|
result = textUploader.UploadText("ShareX text upload test", "Test.txt");
|
2013-11-03 23:53:49 +13:00
|
|
|
|
result.Errors = textUploader.Errors;
|
|
|
|
|
break;
|
|
|
|
|
case CustomUploaderType.File:
|
2013-11-06 06:58:22 +13:00
|
|
|
|
using (Stream stream = ShareXResources.Logo.GetStream())
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
CustomFileUploader fileUploader = new CustomFileUploader(item);
|
|
|
|
|
result = fileUploader.Upload(stream, "Test.png");
|
|
|
|
|
result.Errors = fileUploader.Errors;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case CustomUploaderType.URL:
|
|
|
|
|
CustomURLShortener urlShortener = new CustomURLShortener(item);
|
|
|
|
|
result = urlShortener.ShortenURL(Links.URL_WEBSITE);
|
|
|
|
|
result.Errors = urlShortener.Errors;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
result = new UploadResult();
|
|
|
|
|
result.Errors.Add(e.Message);
|
|
|
|
|
}
|
2014-05-22 13:22:32 +12:00
|
|
|
|
},
|
|
|
|
|
() =>
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2015-06-06 22:15:54 +12:00
|
|
|
|
if (!IsDisposed)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2015-06-06 22:15:54 +12:00
|
|
|
|
if (result != null)
|
2014-05-22 13:22:32 +12:00
|
|
|
|
{
|
2015-06-06 22:15:54 +12:00
|
|
|
|
if ((type != CustomUploaderType.URL && !string.IsNullOrEmpty(result.URL)) || (type == CustomUploaderType.URL && !string.IsNullOrEmpty(result.ShortenedURL)))
|
|
|
|
|
{
|
|
|
|
|
txtCustomUploaderLog.AppendText("URL: " + result + Environment.NewLine);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2015-06-06 22:15:54 +12:00
|
|
|
|
if (!string.IsNullOrEmpty(result.ThumbnailURL))
|
|
|
|
|
{
|
|
|
|
|
txtCustomUploaderLog.AppendText("Thumbnail URL: " + result.ThumbnailURL + Environment.NewLine);
|
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2015-06-06 22:15:54 +12:00
|
|
|
|
if (!string.IsNullOrEmpty(result.DeletionURL))
|
|
|
|
|
{
|
|
|
|
|
txtCustomUploaderLog.AppendText("Deletion URL: " + result.DeletionURL + Environment.NewLine);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (result.IsError)
|
|
|
|
|
{
|
|
|
|
|
txtCustomUploaderLog.AppendText(Resources.UploadersConfigForm_Error + ": " + result.ErrorsToString() + Environment.NewLine);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
txtCustomUploaderLog.AppendText(Resources.UploadersConfigForm_TestCustomUploader_Error__Result_is_empty_ + Environment.NewLine);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
txtCustomUploaderLog.ScrollToCaret();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2015-06-06 22:15:54 +12:00
|
|
|
|
btnCustomUploaderShowLastResponse.Tag = result.Response;
|
|
|
|
|
btnCustomUploaderShowLastResponse.Enabled = !string.IsNullOrEmpty(result.Response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
btnCustomUploaderImageUploaderTest.Enabled = btnCustomUploaderTextUploaderTest.Enabled =
|
|
|
|
|
btnCustomUploaderFileUploaderTest.Enabled = btnCustomUploaderURLShortenerTest.Enabled = true;
|
|
|
|
|
}
|
2014-05-22 13:22:32 +12:00
|
|
|
|
});
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion Custom uploader
|
|
|
|
|
|
|
|
|
|
#region Jira
|
|
|
|
|
|
|
|
|
|
public void JiraAuthOpen()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
OAuthInfo oauth = new OAuthInfo(APIKeys.JiraConsumerKey);
|
|
|
|
|
oauth.SignatureMethod = OAuthInfo.OAuthInfoSignatureMethod.RSA_SHA1;
|
|
|
|
|
oauth.ConsumerPrivateKey = Jira.PrivateKey;
|
|
|
|
|
|
|
|
|
|
string url = new Jira(Config.JiraHost, oauth).GetAuthorizationURL();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(url))
|
|
|
|
|
{
|
|
|
|
|
Config.JiraOAuthInfo = oauth;
|
2014-06-28 12:22:56 +12:00
|
|
|
|
URLHelpers.OpenURL(url);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void JiraAuthComplete(string code)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2014-05-30 23:38:23 +12:00
|
|
|
|
if (!string.IsNullOrEmpty(code) && Config.JiraOAuthInfo != null && !string.IsNullOrEmpty(Config.JiraOAuthInfo.AuthToken) && !string.IsNullOrEmpty(Config.JiraOAuthInfo.AuthSecret))
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
Jira jira = new Jira(Config.JiraHost, Config.JiraOAuthInfo);
|
|
|
|
|
bool result = jira.GetAccessToken(code);
|
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
2014-06-17 00:20:06 +12:00
|
|
|
|
oAuthJira.Status = OAuthLoginStatus.LoginSuccessful;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-06-17 00:20:06 +12:00
|
|
|
|
oAuthJira.Status = OAuthLoginStatus.LoginFailed;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion Jira
|
2013-12-03 12:11:30 +13:00
|
|
|
|
|
|
|
|
|
#region Gist
|
2013-12-04 10:49:15 +13:00
|
|
|
|
|
2013-12-03 12:11:30 +13:00
|
|
|
|
public void GistAuthOpen()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2014-05-02 01:52:46 +12:00
|
|
|
|
OAuth2Info oauth = new OAuth2Info(APIKeys.GitHubID, APIKeys.GitHubSecret);
|
2016-03-23 05:28:55 +13:00
|
|
|
|
string url = new GitHubGist(oauth).GetAuthorizationURL();
|
2013-12-03 12:11:30 +13:00
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(url))
|
|
|
|
|
{
|
|
|
|
|
Config.GistOAuth2Info = oauth;
|
2014-06-28 12:22:56 +12:00
|
|
|
|
URLHelpers.OpenURL(url);
|
2013-12-03 12:11:30 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-12-03 12:11:30 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void GistAuthComplete(string code)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(code) && Config.GistOAuth2Info != null)
|
|
|
|
|
{
|
2016-03-23 05:28:55 +13:00
|
|
|
|
bool result = new GitHubGist(Config.GistOAuth2Info).GetAccessToken(code);
|
2013-12-03 12:11:30 +13:00
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
2014-06-17 00:20:06 +12:00
|
|
|
|
oAuth2Gist.Status = OAuthLoginStatus.LoginSuccessful;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
2013-12-03 12:11:30 +13:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-06-17 00:20:06 +12:00
|
|
|
|
oAuth2Gist.Status = OAuthLoginStatus.LoginFailed;
|
2014-10-18 01:19:28 +13:00
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-12-03 12:11:30 +13:00
|
|
|
|
atcGistAccountType.SelectedAccountType = AccountType.Anonymous;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-10-18 00:48:41 +13:00
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2013-12-03 12:11:30 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion Gist
|
2017-03-30 10:03:08 +13:00
|
|
|
|
|
2017-03-28 12:05:28 +13:00
|
|
|
|
#region Gfycat
|
|
|
|
|
|
|
|
|
|
private void GfycatAuthOpen()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
OAuth2Info oauth = new OAuth2Info(APIKeys.GfycatClientID, APIKeys.GfycatClientSecret);
|
|
|
|
|
|
|
|
|
|
string url = new GfycatUploader(oauth).GetAuthorizationURL();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(url))
|
|
|
|
|
{
|
|
|
|
|
Config.GfycatOAuth2Info = oauth;
|
|
|
|
|
URLHelpers.OpenURL(url);
|
|
|
|
|
DebugHelper.WriteLine("GfycatAuthOpen - Authorization URL is opened: " + url);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DebugHelper.WriteLine("GfycatAuthOpen - Authorization URL is empty.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void GfycatAuthComplete(string code)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(code) && Config.GfycatOAuth2Info != null)
|
|
|
|
|
{
|
|
|
|
|
bool result = new GfycatUploader(Config.GfycatOAuth2Info).GetAccessToken(code);
|
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
oauth2Gfycat.Status = OAuthLoginStatus.LoginSuccessful;
|
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
oauth2Gfycat.Status = OAuthLoginStatus.LoginFailed;
|
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void GfycatAuthRefresh()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (OAuth2Info.CheckOAuth(Config.GfycatOAuth2Info))
|
|
|
|
|
{
|
|
|
|
|
bool result = new GfycatUploader(Config.GfycatOAuth2Info).RefreshAccessToken();
|
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
oauth2Gfycat.Status = OAuthLoginStatus.LoginSuccessful;
|
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
oauth2Gfycat.Status = OAuthLoginStatus.LoginFailed;
|
|
|
|
|
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
atcGfycatAccountType.SelectedAccountType = AccountType.Anonymous;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion Gfycat
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|