[libsoup] SoupConnection: added a new construction-time property "local-address"



commit 50cb7bdd1232316c74fc5b019bf235910f732e59
Author: Jonh Wendell <jonh wendell oiwifi com br>
Date:   Tue Feb 5 13:38:09 2013 -0200

    SoupConnection: added a new construction-time property "local-address"
    
    It will be proxied to the SoupSocket upon its creation.

 libsoup/soup-connection.c |   18 ++++++++++++++++++
 libsoup/soup-connection.h |    1 +
 2 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/libsoup/soup-connection.c b/libsoup/soup-connection.c
index a6ed524..3dff7ec 100644
--- a/libsoup/soup-connection.c
+++ b/libsoup/soup-connection.c
@@ -18,6 +18,7 @@
 typedef struct {
 	SoupSocket  *socket;
 
+	SoupAddress *local_addr;
 	SoupURI *remote_uri, *proxy_uri;
 	SoupProxyURIResolver *proxy_resolver;
 	gboolean use_gproxyresolver;
@@ -49,6 +50,7 @@ static guint signals[LAST_SIGNAL] = { 0 };
 enum {
 	PROP_0,
 
+	PROP_LOCAL_ADDRESS,
 	PROP_REMOTE_URI,
 	PROP_PROXY_RESOLVER,
 	PROP_SSL,
@@ -85,6 +87,7 @@ soup_connection_finalize (GObject *object)
 	g_clear_pointer (&priv->proxy_uri, soup_uri_free);
 	g_clear_object (&priv->tlsdb);
 	g_clear_object (&priv->proxy_resolver);
+	g_clear_object (&priv->local_addr);
 	g_clear_pointer (&priv->async_context, g_main_context_unref);
 
 	G_OBJECT_CLASS (soup_connection_parent_class)->finalize (object);
@@ -114,6 +117,9 @@ soup_connection_set_property (GObject *object, guint prop_id,
 	SoupProxyURIResolver *proxy_resolver;
 
 	switch (prop_id) {
+	case PROP_LOCAL_ADDRESS:
+		priv->local_addr = g_value_dup_object (value);
+		break;
 	case PROP_REMOTE_URI:
 		priv->remote_uri = g_value_dup_boxed (value);
 		break;
@@ -168,6 +174,9 @@ soup_connection_get_property (GObject *object, guint prop_id,
 	SoupConnectionPrivate *priv = SOUP_CONNECTION_GET_PRIVATE (object);
 
 	switch (prop_id) {
+	case PROP_LOCAL_ADDRESS:
+		g_value_set_object (value, priv->local_addr);
+		break;
 	case PROP_REMOTE_URI:
 		g_value_set_boxed (value, priv->remote_uri);
 		break;
@@ -239,6 +248,13 @@ soup_connection_class_init (SoupConnectionClass *connection_class)
 
 	/* properties */
 	g_object_class_install_property (
+		object_class, PROP_LOCAL_ADDRESS,
+		g_param_spec_object (SOUP_CONNECTION_LOCAL_ADDRESS,
+				     "Local address",
+				     "Address of local end of socket",
+				     SOUP_TYPE_ADDRESS,
+				     G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+	g_object_class_install_property (
 		object_class, PROP_REMOTE_URI,
 		g_param_spec_boxed (SOUP_CONNECTION_REMOTE_URI,
 				    "Remote URI",
@@ -527,6 +543,7 @@ connect_async_to_uri (SoupConnectionAsyncConnectData *data, SoupURI *uri)
 				 SOUP_SOCKET_USE_PROXY, priv->use_gproxyresolver,
 				 SOUP_SOCKET_TIMEOUT, priv->io_timeout,
 				 SOUP_SOCKET_CLEAN_DISPOSE, TRUE,
+				 SOUP_SOCKET_LOCAL_ADDRESS, priv->local_addr,
 				 NULL);
 	g_object_unref (remote_addr);
 
@@ -637,6 +654,7 @@ soup_connection_connect_sync (SoupConnection *conn, GCancellable *cancellable)
 				 SOUP_SOCKET_FLAG_NONBLOCKING, FALSE,
 				 SOUP_SOCKET_TIMEOUT, priv->io_timeout,
 				 SOUP_SOCKET_CLEAN_DISPOSE, TRUE,
+				 SOUP_SOCKET_LOCAL_ADDRESS, priv->local_addr,
 				 NULL);
 	g_object_unref (remote_addr);
 
diff --git a/libsoup/soup-connection.h b/libsoup/soup-connection.h
index 52e638f..50fb701 100644
--- a/libsoup/soup-connection.h
+++ b/libsoup/soup-connection.h
@@ -39,6 +39,7 @@ typedef void  (*SoupConnectionCallback)        (SoupConnection   *conn,
 						guint             status,
 						gpointer          data);
 
+#define SOUP_CONNECTION_LOCAL_ADDRESS   "local-address"
 #define SOUP_CONNECTION_REMOTE_URI      "remote-uri"
 #define SOUP_CONNECTION_PROXY_RESOLVER  "proxy-resolver"
 #define SOUP_CONNECTION_SSL             "ssl"



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