]> err.no Git - libchamplain/commitdiff
Add support for Proxy
authorPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Fri, 6 Mar 2009 08:28:34 +0000 (10:28 +0200)
committerPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Fri, 6 Mar 2009 08:28:34 +0000 (10:28 +0200)
In the future, libchamplain should link against libsoup-gnome
and auto-detect proxy settings.  If libsoup-gnome is not
available, then this new proxy-uri is the fall back.

champlain/champlain-network-map-source.c

index 34dd9716b973fe8c5b9d9ee9fe3e1f5267250cc8..5c1fcc9302061e30f739ff779380c20b7994447d 100644 (file)
@@ -50,7 +50,8 @@ enum
 {
   PROP_0,
   PROP_URI_FORMAT,
-  PROP_OFFLINE
+  PROP_OFFLINE,
+  PROP_PROXY_URI
 };
 
 /* static guint champlain_network_map_source_signals[LAST_SIGNAL] = { 0, }; */
@@ -66,6 +67,7 @@ struct _ChamplainNetworkMapSourcePrivate
 {
   gboolean offline;
   gchar *uri_format;
+  gchar *proxy_uri;
 };
 
 static void
@@ -85,6 +87,9 @@ champlain_network_map_source_get_property (GObject *object,
       case PROP_OFFLINE:
         g_value_set_boolean (value, priv->offline);
         break;
+      case PROP_PROXY_URI:
+        g_value_set_string (value, priv->proxy_uri);
+        break;
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
     }
@@ -107,6 +112,9 @@ champlain_network_map_source_set_property (GObject *object,
       case PROP_OFFLINE:
         priv->offline = g_value_get_boolean (value);
         break;
+      case PROP_PROXY_URI:
+        priv->proxy_uri = g_value_dup_string (value);
+        break;
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
     }
@@ -164,6 +172,20 @@ champlain_network_map_source_class_init (ChamplainNetworkMapSourceClass *klass)
                                 FALSE,
                                 (G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
   g_object_class_install_property (object_class, PROP_OFFLINE, pspec);
+
+  /**
+  * ChamplainNetworkMapSource:proxy-uri
+  *
+  * The proxy uri to use to access network
+  *
+  * Since: 0.4
+  */
+  pspec = g_param_spec_string ("proxy-uri",
+                               "Proxy URI",
+                               "The proxy URI to use to access network",
+                               "",
+                               (G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+  g_object_class_install_property (object_class, PROP_PROXY_URI, pspec);
 }
 
 static void
@@ -455,7 +477,7 @@ champlain_network_map_source_get_tile (ChamplainMapSource *map_source,
       ctx->tile = tile;
 
       if (!soup_session)
-        soup_session = soup_session_async_new ();
+        soup_session = soup_session_async_new_with_options ("proxy-uri", soup_uri_new (priv->proxy_uri));
 
       uri = champlain_network_map_source_get_tile_uri (network_map_source,
                champlain_tile_get_x (tile), champlain_tile_get_y (tile),