f-spot r4308 - in trunk/extensions: . GalleryExport



Author: lmilesi
Date: Wed Sep  3 07:30:46 2008
New Revision: 4308
URL: http://svn.gnome.org/viewvc/f-spot?rev=4308&view=rev

Log:
2008-09-03  Lorenzo Milesi <maxxer yetopen it>

       * GalleryExport/GalleryRemote.cs:
       * GalleryExport/GalleryExport.cs: catch some G2 communication errors
       instead of crashing. fix bgo#498568.
       * GalleryExport/GalleryExport.addin.xml: bump addin version.



Modified:
   trunk/extensions/ChangeLog
   trunk/extensions/GalleryExport/GalleryExport.addin.xml
   trunk/extensions/GalleryExport/GalleryExport.cs
   trunk/extensions/GalleryExport/GalleryRemote.cs

Modified: trunk/extensions/GalleryExport/GalleryExport.addin.xml
==============================================================================
--- trunk/extensions/GalleryExport/GalleryExport.addin.xml	(original)
+++ trunk/extensions/GalleryExport/GalleryExport.addin.xml	Wed Sep  3 07:30:46 2008
@@ -1,5 +1,5 @@
 <Addin namespace="FSpot"
-	version="0.4.4.101"
+	version="0.4.4.102"
 	name="Gallery Export"
 	description="This extension allows you to export your photos to PHP Gallery (http://gallery.menalto.com)."
 	author="F-Spot team"

Modified: trunk/extensions/GalleryExport/GalleryExport.cs
==============================================================================
--- trunk/extensions/GalleryExport/GalleryExport.cs	(original)
+++ trunk/extensions/GalleryExport/GalleryExport.cs	Wed Sep  3 07:30:46 2008
@@ -49,7 +49,7 @@
 			} else if (version == GalleryVersion.Version2) {
 				gal = new Gallery2 (url, url);
 			} else {
-				throw new Exception ("Cannot connect to a Gallery for which the version is unknown");
+				throw new GalleryException (Catalog.GetString("Cannot connect to a Gallery for which the version is unknown.\nPlease check that you have Remote plugin 1.0.8 or later"));
 			}
 
 			System.Console.WriteLine ("Gallery created: " + gal);
@@ -385,7 +385,6 @@
 					GalleryAccountManager.GetInstance ().AddAccount (created);
 					account = created;
 				} catch (System.UriFormatException) {
-					
 					HigMessageDialog md = 
 						new HigMessageDialog (add_dialog, 
 								      Gtk.DialogFlags.Modal |
@@ -596,8 +595,13 @@
 					md.Destroy ();
 					return;
 				}
-				gallery.NewAlbum (parent, name, title, description);
-				export.HandleAlbumAdded (title);
+				try {
+					gallery.NewAlbum (parent, name, title, description);
+					export.HandleAlbumAdded (title);
+ 				} catch (GalleryCommandException e) {
+ 					gallery.PopupException(e, add_album_dialog);
+ 					return;
+ 				}
 			}
 			add_album_dialog.Destroy ();
 		}
@@ -782,23 +786,23 @@
 					FilterRequest req = new FilterRequest (item.DefaultVersionUri);
 
 					filters.Convert (req);
-				try {
-					int id = album.Add (item, req.Current.LocalPath);
-
-					if (item != null && item is Photo && Core.Database != null && id != 0) {
-						Core.Database.Exports.Create ((item as Photo).Id, (item as Photo).DefaultVersionId,
-									      ExportStore.Gallery2ExportType,
-									      String.Format("{0}:{1}",album.Gallery.Uri.ToString (), id.ToString ()));
-					}
-				} catch (System.Exception e) {
-					progress_dialog.Message = String.Format (Catalog.GetString ("Error uploading picture \"{0}\" to Gallery: {1}"), item.Name, e.Message);
-					progress_dialog.ProgressText = Catalog.GetString ("Error");
-					Console.WriteLine (e);
+					try {
+						int id = album.Add (item, req.Current.LocalPath);
 
-					if (progress_dialog.PerformRetrySkip ()) {
-						photo_index--;
+						if (item != null && item is Photo && Core.Database != null && id != 0) {
+							Core.Database.Exports.Create ((item as Photo).Id, (item as Photo).DefaultVersionId,
+										      ExportStore.Gallery2ExportType,
+										      String.Format("{0}:{1}",album.Gallery.Uri.ToString (), id.ToString ()));
+						}
+					} catch (System.Exception e) {
+						progress_dialog.Message = String.Format (Catalog.GetString ("Error uploading picture \"{0}\" to Gallery: {1}"), item.Name, e.Message);
+						progress_dialog.ProgressText = Catalog.GetString ("Error");
+						Console.WriteLine (e);
+
+						if (progress_dialog.PerformRetrySkip ()) {
+							photo_index--;
+						}
 					}
-				}
 			}
 
 			progress_dialog.Message = Catalog.GetString ("Done Sending Photos");
@@ -897,8 +901,13 @@
 			System.Collections.ArrayList albums = null;
 			if (gallery != null) {
 				//gallery.FetchAlbumsPrune ();
-				gallery.FetchAlbums ();
-				albums = gallery.Albums;
+				try {
+					gallery.FetchAlbums ();
+					albums = gallery.Albums;
+				} catch (GalleryCommandException e) {
+					gallery.PopupException (e, export_dialog);
+					return;
+				}
 			}
 
 			Gtk.Menu menu = new Gtk.Menu ();
@@ -959,7 +968,7 @@
 		public void HandleAddAlbum (object sender, System.EventArgs args)
 		{
 			if (account == null)
-				throw new Exception (Catalog.GetString ("No account selected"));
+				throw new GalleryException (Catalog.GetString ("No account selected"));
 				
 			new GalleryAddAlbum (this, account.Gallery);
 		}

Modified: trunk/extensions/GalleryExport/GalleryRemote.cs
==============================================================================
--- trunk/extensions/GalleryExport/GalleryRemote.cs	(original)
+++ trunk/extensions/GalleryExport/GalleryRemote.cs	Wed Sep  3 07:30:46 2008
@@ -7,6 +7,7 @@
 using System.Web;
 using Mono.Unix;
 using FSpot;
+using FSpot.UI.Dialog;
 
 /* These classes are based off the documentation at 
  *
@@ -190,7 +191,7 @@
 		VersionFormatInvalid = 103,
 		VersionMissing = 104,
 		PasswordWrong = 201,
-		LoginMisssing = 202,
+		LoginMissing = 202,
 		UnknownComand = 301,
 		NoAddPermission = 401,
 		NoFilename = 402,
@@ -646,7 +647,7 @@
 				}
 				//Console.WriteLine ("Found: {0} cookies", response.Cookies.Count);
 				if (status != ResultCode.Success) {
-					Console.WriteLine (status_text);
+					Console.WriteLine (status_text + " Status: " + status);
 					throw new GalleryCommandException (status_text, status);
 				}
 
@@ -697,6 +698,20 @@
 			return fixedUrl;
 			
 		}
+
+		public void PopupException (GalleryCommandException e, Gtk.Dialog d) 
+		{
+			System.Console.WriteLine(String.Format ("{0} : {1} ({2})", e.Message, e.ResponseText, e.Status));
+			HigMessageDialog md = 
+				new HigMessageDialog (d, 
+						      Gtk.DialogFlags.Modal |
+						      Gtk.DialogFlags.DestroyWithParent,
+						      Gtk.MessageType.Error, Gtk.ButtonsType.Ok,
+						      Catalog.GetString ("Error while creating new album"),
+						      String.Format (Catalog.GetString ("The following error was encountered while attempting to perform the requested operation:\n{0} ({1})"), e.Message, e.Status));
+			md.Run ();
+			md.Destroy ();
+		}
 		
 	}
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]