tasque r104 - in trunk: . src src/Backends/Rtm



Author: sharm
Date: Sun Sep 21 14:09:16 2008
New Revision: 104
URL: http://svn.gnome.org/viewvc/tasque?rev=104&view=rev

Log:
* src/Application.cs: If there's a valid backend that fails to
  authenticate, retry instead of just showing the preferences window.
   Fixes bug #538019, patch courtesy of Joseph Method and Andrew
  Conkling.
* src/Backends/Rtm/RtmBackend.cs: More informative exception handling
  during authentication.

Modified:
   trunk/ChangeLog
   trunk/src/Application.cs
   trunk/src/Backends/Rtm/RtmBackend.cs

Modified: trunk/src/Application.cs
==============================================================================
--- trunk/src/Application.cs	(original)
+++ trunk/src/Application.cs	Sun Sep 21 14:09:16 2008
@@ -106,9 +106,6 @@
 				
 				Logger.Debug("Configuration status: {0}",
 							 tasque.backend.Configured.ToString());
-				if (tasque.backend.Configured == false) {
-					Application.ShowPreferences();
-				}
 			}
 		}
 		
@@ -321,9 +318,25 @@
 			} else {
 				TaskWindow.ShowWindow();
 			}
-			
+			if(backend.Configured == false){
+				GLib.Timeout.Add(1000, new GLib.TimeoutHandler(RetryBackend));
+			}
 			return false;
 		}
+		private bool RetryBackend(){
+			try{
+				backend.Cleanup();
+				backend.Initialize();
+			} catch (Exception e){
+				Logger.Error("{0}", e.Message);
+			}
+			if(backend.Configured == false)
+			{
+				return true;
+			} else {
+				return false;
+			}
+		}
 		
 		private bool CheckForDaySwitch ()
 		{

Modified: trunk/src/Backends/Rtm/RtmBackend.cs
==============================================================================
--- trunk/src/Backends/Rtm/RtmBackend.cs	(original)
+++ trunk/src/Backends/Rtm/RtmBackend.cs	Sun Sep 21 14:09:16 2008
@@ -216,13 +216,24 @@
 					Logger.Debug("RTM Auth Token is valid!");
 					Logger.Debug("Setting configured status to true");
 					configured = true;
-				} catch (Exception e) {
+				} catch (RtmNet.RtmApiException e) {
+					
 					Application.Preferences.Set (Preferences.AuthTokenKey, null);
 					Application.Preferences.Set (Preferences.UserIdKey, null);
 					Application.Preferences.Set (Preferences.UserNameKey, null);
 					rtm = null;
 					rtmAuth = null;
 					Logger.Error("Exception authenticating, reverting" + e.Message);
+				} 			
+				catch (RtmNet.RtmWebException e) {
+					rtm = null;
+					rtmAuth = null;
+					Logger.Error("Not connected to RTM, maybe proxy: #{0}", e.Message);
+ 				}
+				catch (System.Net.WebException e) {
+					rtm = null;
+					rtmAuth = null;
+					Logger.Error("Problem connecting to internet: #{0}", e.Message);
 				}
 			}
 



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