[gthumb] auto start the authentication process if the session is invalid



commit a6b19491a7745953b53c6d0a3095096156e756e7
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sat Apr 10 10:56:43 2010 +0200

    auto start the authentication process if the session is invalid

 extensions/facebook/facebook-authentication.c |   18 ++++++++----------
 extensions/facebook/facebook-authentication.h |    3 +++
 extensions/facebook/facebook-connection.h     |    2 ++
 extensions/flicker/flickr-authentication.c    |   18 ++++++++----------
 extensions/flicker/flickr-connection.h        |    1 +
 5 files changed, 22 insertions(+), 20 deletions(-)
---
diff --git a/extensions/facebook/facebook-authentication.c b/extensions/facebook/facebook-authentication.c
index 17d088b..bb983db 100644
--- a/extensions/facebook/facebook-authentication.c
+++ b/extensions/facebook/facebook-authentication.c
@@ -59,13 +59,6 @@ static GObjectClass *parent_class = NULL;
 static guint facebook_authentication_signals[LAST_SIGNAL] = { 0 };
 
 
-GQuark
-facebook_authentication_error_quark (void)
-{
-	return g_quark_from_static_string ("facebook-authentication-error-quark");
-}
-
-
 static void
 facebook_authentication_finalize (GObject *object)
 {
@@ -207,12 +200,20 @@ authentication_error_dialog_response_cb (GtkDialog *dialog,
 }
 
 
+static void start_authorization_process (FacebookAuthentication *self);
+
+
 static void
 show_authentication_error_dialog (FacebookAuthentication  *self,
 				  GError                 **error)
 {
 	GtkWidget *dialog;
 
+	if (g_error_matches (*error, FACEBOOK_CONNECTION_ERROR, FACEBOOK_CONNECTION_ERROR_SESSION_KEY_INVALID)) {
+		start_authorization_process (self);
+		return;
+	}
+
 	if (self->priv->conn != NULL)
 		gth_task_dialog (GTH_TASK (self->priv->conn), TRUE);
 
@@ -261,9 +262,6 @@ get_user_info_ready_cb (GObject      *source_object,
 }
 
 
-static void start_authorization_process (FacebookAuthentication *self);
-
-
 static void
 get_logged_in_user_ready_cb (GObject      *source_object,
 			     GAsyncResult *res,
diff --git a/extensions/facebook/facebook-authentication.h b/extensions/facebook/facebook-authentication.h
index 499066c..76efc74 100644
--- a/extensions/facebook/facebook-authentication.h
+++ b/extensions/facebook/facebook-authentication.h
@@ -32,6 +32,8 @@
 
 G_BEGIN_DECLS
 
+#define FACEBOOK_AUTHENTICATION_ERROR facebook_authentication_error_quark()
+
 #define FACEBOOK_TYPE_AUTHENTICATION            (facebook_authentication_get_type ())
 #define FACEBOOK_AUTHENTICATION(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), FACEBOOK_TYPE_AUTHENTICATION, FacebookAuthentication))
 #define FACEBOOK_AUTHENTICATION_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), FACEBOOK_TYPE_AUTHENTICATION, FacebookAuthenticationClass))
@@ -58,6 +60,7 @@ struct _FacebookAuthenticationClass {
 	void  (*accounts_changed)  (FacebookAuthentication *auth);
 };
 
+
 GType                     facebook_authentication_get_type       (void);
 FacebookAuthentication *  facebook_authentication_new            (FacebookConnection     *conn,
 								  FacebookService        *service,
diff --git a/extensions/facebook/facebook-connection.h b/extensions/facebook/facebook-connection.h
index 405de55..1864811 100644
--- a/extensions/facebook/facebook-connection.h
+++ b/extensions/facebook/facebook-connection.h
@@ -43,6 +43,8 @@ typedef enum {
 #define FACEBOOK_CONNECTION_ERROR facebook_connection_error_quark ()
 GQuark facebook_connection_error_quark (void);
 
+#define FACEBOOK_CONNECTION_ERROR_SESSION_KEY_INVALID 102
+
 #define FACEBOOK_TYPE_CONNECTION         (facebook_connection_get_type ())
 #define FACEBOOK_CONNECTION(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), FACEBOOK_TYPE_CONNECTION, FacebookConnection))
 #define FACEBOOK_CONNECTION_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST ((k), FACEBOOK_TYPE_CONNECTION, FacebookConnectionClass))
diff --git a/extensions/flicker/flickr-authentication.c b/extensions/flicker/flickr-authentication.c
index e2ee867..f5cf03f 100644
--- a/extensions/flicker/flickr-authentication.c
+++ b/extensions/flicker/flickr-authentication.c
@@ -58,13 +58,6 @@ static GObjectClass *parent_class = NULL;
 static guint flickr_authentication_signals[LAST_SIGNAL] = { 0 };
 
 
-GQuark
-flickr_authentication_error_quark (void)
-{
-	return g_quark_from_static_string ("flickr-authentication-error-quark");
-}
-
-
 static void
 flickr_authentication_finalize (GObject *object)
 {
@@ -206,12 +199,20 @@ authentication_error_dialog_response_cb (GtkDialog *dialog,
 }
 
 
+static void start_authorization_process (FlickrAuthentication *self);
+
+
 static void
 show_authentication_error_dialog (FlickrAuthentication  *self,
 				  GError               **error)
 {
 	GtkWidget *dialog;
 
+	if (g_error_matches (*error, FLICKR_CONNECTION_ERROR, FLICKR_CONNECTION_ERROR_INVALID_TOKEN)) {
+		start_authorization_process (self);
+		return;
+	}
+
 	if (self->priv->conn != NULL)
 		gth_task_dialog (GTH_TASK (self->priv->conn), TRUE);
 
@@ -258,9 +259,6 @@ upload_status_ready_cb (GObject      *source_object,
 }
 
 
-static void start_authorization_process (FlickrAuthentication *self);
-
-
 static void
 connect_to_server_step2 (FlickrAuthentication *self)
 {
diff --git a/extensions/flicker/flickr-connection.h b/extensions/flicker/flickr-connection.h
index 09d193f..8674c70 100644
--- a/extensions/flicker/flickr-connection.h
+++ b/extensions/flicker/flickr-connection.h
@@ -40,6 +40,7 @@ typedef enum {
 
 #define FLICKR_CONNECTION_ERROR flickr_connection_error_quark ()
 GQuark flickr_connection_error_quark (void);
+#define FLICKR_CONNECTION_ERROR_INVALID_TOKEN 98
 
 #define FLICKR_TYPE_CONNECTION         (flickr_connection_get_type ())
 #define FLICKR_CONNECTION(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), FLICKR_TYPE_CONNECTION, FlickrConnection))



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