[frogr] After changing proxy configuration re-fetch things if needed



commit 4f0778aa8dc2461925021ab5a1b08adb6b435025
Author: Mario Sanchez Prada <msanchez igalia com>
Date:   Tue May 3 19:22:34 2011 +0200

    After changing proxy configuration re-fetch things if needed

 src/flicksoup/fsp-session.c |   10 ++++++++--
 src/flicksoup/fsp-session.h |    2 +-
 src/frogr-controller.c      |    9 ++++++++-
 3 files changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/src/flicksoup/fsp-session.c b/src/flicksoup/fsp-session.c
index 1c4cb7d..ccca1fe 100644
--- a/src/flicksoup/fsp-session.c
+++ b/src/flicksoup/fsp-session.c
@@ -1261,12 +1261,12 @@ fsp_session_new                         (const gchar *api_key,
   return FSP_SESSION (object);
 }
 
-void
+gboolean
 fsp_session_set_http_proxy              (FspSession *self,
                                          const char *host, const char *port,
                                          const char *username, const char *password)
 {
-  g_return_if_fail (FSP_IS_SESSION (self));
+  g_return_val_if_fail (FSP_IS_SESSION (self), FALSE);
 
   SoupURI *proxy_uri = NULL;
   if (host != NULL)
@@ -1314,7 +1314,13 @@ fsp_session_set_http_proxy              (FspSession *self,
         soup_uri_free (self->priv->proxy_uri);
 
       self->priv->proxy_uri = proxy_uri;
+
+      /* Proxy configuration actually changed */
+      return TRUE;
     }
+
+  /* Proxy configuration has not changed */
+  return FALSE;
 }
 
 const gchar *
diff --git a/src/flicksoup/fsp-session.h b/src/flicksoup/fsp-session.h
index f60db9a..8fcfee6 100644
--- a/src/flicksoup/fsp-session.h
+++ b/src/flicksoup/fsp-session.h
@@ -67,7 +67,7 @@ FspSession *
 fsp_session_new                         (const gchar *api_key,
                                          const gchar *secret,
                                          const gchar *token);
-void
+gboolean
 fsp_session_set_http_proxy              (FspSession *self,
                                          const char *host, const char *port,
                                          const char *username, const char *password);
diff --git a/src/frogr-controller.c b/src/frogr-controller.c
index 5a1ad2f..50b7869 100644
--- a/src/frogr-controller.c
+++ b/src/frogr-controller.c
@@ -1957,6 +1957,7 @@ frogr_controller_set_proxy (FrogrController *self,
   } else {
     gboolean has_username = FALSE;
     gboolean has_password = FALSE;
+    gboolean proxy_changed = FALSE;
     gchar *auth_part = NULL;
 
     has_username = (username != NULL && *username != '\0');
@@ -1968,7 +1969,13 @@ frogr_controller_set_proxy (FrogrController *self,
     DEBUG ("Using HTTP proxy: %s%s:%s", auth_part ? auth_part : "", host, port);
     g_free (auth_part);
 
-    fsp_session_set_http_proxy (priv->session, host, port, username, password);
+    proxy_changed = fsp_session_set_http_proxy (priv->session,
+                                                host, port,
+                                                username, password);
+
+    /* Re-fetch information if needed after changing proxy configuration */
+    if (priv->app_running && proxy_changed)
+      _fetch_everything (self, TRUE);
   }
 }
 



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