Preventing that the Photobucket login is shown while using the Dynamic-Destination picker "mouse-over".

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2505 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2013-02-20 12:02:37 +00:00
commit 652ca64e9f
3 changed files with 46 additions and 16 deletions

View file

@ -75,12 +75,16 @@ namespace GreenshotPhotobucketPlugin {
}
public override IEnumerable<IDestination> DynamicDestinations() {
List<string> albums = PhotobucketUtils.RetrievePhotobucketAlbums();
List<string> albums = null;
try {
albums = PhotobucketUtils.RetrievePhotobucketAlbums();
} catch {
}
if (albums == null || albums.Count == 0) {
yield break;
}
foreach(string album in albums) {
foreach (string album in albums) {
yield return new PhotobucketDestination(plugin, album);
}
}

View file

@ -47,8 +47,10 @@ namespace GreenshotPhotobucketPlugin {
albumPath = "!";
}
OAuthSession oAuth = createSession();
OAuthSession oAuth = createSession(true);
if (oAuth == null) {
return null;
}
IDictionary<string, object> signedParameters = new Dictionary<string, object>();
// add album
if (albumPath == null) {
@ -83,6 +85,9 @@ namespace GreenshotPhotobucketPlugin {
config.TokenSecret = oAuth.TokenSecret;
}
}
if (responseString == null) {
return null;
}
LOG.Info(responseString);
PhotobucketInfo PhotobucketInfo = PhotobucketInfo.FromUploadResponse(responseString);
LOG.Debug("Upload to Photobucket was finished");
@ -93,8 +98,9 @@ namespace GreenshotPhotobucketPlugin {
/// Helper method to create an OAuth session object for contacting the Photobucket API
/// </summary>
/// <returns>OAuthSession</returns>
private static OAuthSession createSession() {
private static OAuthSession createSession(bool autoLogin) {
OAuthSession oAuth = new OAuthSession(PhotobucketCredentials.ConsumerKey, PhotobucketCredentials.ConsumerSecret);
oAuth.AutoLogin = autoLogin;
oAuth.CheckVerifier = false;
// This url is configured in the Photobucket API settings in the Photobucket site!!
oAuth.CallbackUrl = "http://getgreenshot.org";
@ -108,6 +114,9 @@ namespace GreenshotPhotobucketPlugin {
oAuth.LoginTitle = "Photobucket authorization";
if (string.IsNullOrEmpty(config.SubDomain) || string.IsNullOrEmpty(config.Token) || string.IsNullOrEmpty(config.Username)) {
if (!autoLogin) {
return null;
}
if (!oAuth.Authorize()) {
return null;
}
@ -140,8 +149,10 @@ namespace GreenshotPhotobucketPlugin {
}
string responseString;
OAuthSession oAuth = createSession();
OAuthSession oAuth = createSession(false);
if (oAuth == null) {
return null;
}
IDictionary<string, object> signedParameters = new Dictionary<string, object>();
try {
string apiUrl = string.Format("http://api.photobucket.com/album/{0}", config.Username);
@ -157,6 +168,9 @@ namespace GreenshotPhotobucketPlugin {
config.TokenSecret = oAuth.TokenSecret;
}
}
if (responseString == null) {
return null;
}
try {
XmlDocument doc = new XmlDocument();
doc.LoadXml(responseString);