[f-spot] Handle any unexpected exceptions during login



commit 2051a462c27199f3cbc0fe93b97f3a015e0374fd
Author: Jim Ramsay <i am jimramsay com>
Date:   Fri Jun 19 14:04:19 2009 -0400

    Handle any unexpected exceptions during login
    
    This basically puts most of DoLogin code inside a big try block, in case
    something goes wrong while initializing the facebook information.

 .../Exporters/FacebookExport/FacebookExport.cs     |   74 +++++++++++--------
 1 files changed, 43 insertions(+), 31 deletions(-)
---
diff --git a/extensions/Exporters/FacebookExport/FacebookExport.cs b/extensions/Exporters/FacebookExport/FacebookExport.cs
index 808ca27..964afca 100644
--- a/extensions/Exporters/FacebookExport/FacebookExport.cs
+++ b/extensions/Exporters/FacebookExport/FacebookExport.cs
@@ -438,37 +438,49 @@ namespace FSpot.Exporter.Facebook
 				log_buttons_hbox.Sensitive = false;
 				dialog_action_area.Sensitive = false;
 
-				LoginProgress (0.2, Catalog.GetString ("Session established, fetching user info..."));
-				User me = account.Facebook.GetLoggedInUser ().GetUserInfo ();
-
-				LoginProgress (0.4, Catalog.GetString ("Session established, fetching friend list..."));
-				Friend[] friend_list = account.Facebook.GetFriends ();
-				long[] uids = new long [friend_list.Length];
-
-				for (int i = 0; i < friend_list.Length; i++)
-					uids [i] = friend_list [i].UId;
-
-				LoginProgress (0.6, Catalog.GetString ("Session established, fetching friend details..."));
-				User[] infos = account.Facebook.GetUserInfo (uids, new string[] { "first_name", "last_name" });
-				friends = new Dictionary<long, User> ();
-
-				foreach (User user in infos)
-					friends.Add (user.UId, user);
-
-				LoginProgress (0.8, Catalog.GetString ("Session established, fetching photo albums..."));
-				Album[] albums = account.Facebook.GetAlbums ();
-				AlbumStore store = new AlbumStore (albums);
-				existing_album_combobox.Model = store;
-				existing_album_combobox.Active = 0;
-
-				album_info_vbox.Sensitive = true;
-				picture_info_vbox.Sensitive = true;
-				login_button.Visible = false;
-				logout_button.Visible = true;
-				log_buttons_hbox.Sensitive = true;
-				dialog_action_area.Sensitive = true;
-				// Note for translators: {0} and {1} are respectively firstname and surname of the user
-				LoginProgress (1.0, String.Format (Catalog.GetString ("{0} {1} is logged into Facebook"), me.FirstName, me.LastName));
+				try {
+					LoginProgress (0.2, Catalog.GetString ("Session established, fetching user info..."));
+					User me = account.Facebook.GetLoggedInUser ().GetUserInfo ();
+
+					LoginProgress (0.4, Catalog.GetString ("Session established, fetching friend list..."));
+					Friend[] friend_list = account.Facebook.GetFriends ();
+					long[] uids = new long [friend_list.Length];
+
+					for (int i = 0; i < friend_list.Length; i++)
+						uids [i] = friend_list [i].UId;
+
+					LoginProgress (0.6, Catalog.GetString ("Session established, fetching friend details..."));
+					User[] infos = account.Facebook.GetUserInfo (uids, new string[] { "first_name", "last_name" });
+					friends = new Dictionary<long, User> ();
+
+					foreach (User user in infos)
+						friends.Add (user.UId, user);
+
+					LoginProgress (0.8, Catalog.GetString ("Session established, fetching photo albums..."));
+					Album[] albums = account.Facebook.GetAlbums ();
+					AlbumStore store = new AlbumStore (albums);
+					existing_album_combobox.Model = store;
+					existing_album_combobox.Active = 0;
+
+					album_info_vbox.Sensitive = true;
+					picture_info_vbox.Sensitive = true;
+					login_button.Visible = false;
+					logout_button.Visible = true;
+					log_buttons_hbox.Sensitive = true;
+					dialog_action_area.Sensitive = true;
+					// Note for translators: {0} and {1} are respectively firstname and surname of the user
+					LoginProgress (1.0, String.Format (Catalog.GetString ("{0} {1} is logged into Facebook"), me.FirstName, me.LastName));
+				} catch (Exception e) {
+					Log.DebugException (e);
+					HigMessageDialog error = new HigMessageDialog (Dialog, Gtk.DialogFlags.DestroyWithParent | Gtk.DialogFlags.Modal, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, Catalog.GetString ("Error connecting to Facebook"), Catalog.GetString ("There was an unexpected problem when downloading your information from Facebook."));
+					error.Run ();
+					error.Destroy ();
+
+					log_buttons_hbox.Sensitive = true;
+					dialog_action_area.Sensitive = true;
+
+					DoLogout ();
+				}
 			}
 		}
 



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