[gupnp] Propagate port property to GSSDPClient



commit b8f2cbf18f22930c661f3a24a4b42000c54d08e1
Author: Jens Georg <mail jensge org>
Date:   Tue Oct 29 13:18:20 2013 +0100

    Propagate port property to GSSDPClient
    
    GSSDPClient introduced a new msearch-port property that this patch sets from
    the port property in GUPnPContext.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=711015

 libgupnp/gupnp-context.c |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/libgupnp/gupnp-context.c b/libgupnp/gupnp-context.c
index 81c030c..94c0cc5 100644
--- a/libgupnp/gupnp-context.c
+++ b/libgupnp/gupnp-context.c
@@ -347,6 +347,43 @@ gupnp_context_finalize (GObject *object)
         object_class->finalize (object);
 }
 
+static GObject *
+gupnp_context_constructor (GType                  type,
+                           guint                  n_construct_params,
+                           GObjectConstructParam *construct_params)
+{
+        GObjectClass *object_class;
+        guint port = 0, msearch_port = 0;
+        int i, msearch_idx = -1;
+
+        for (i = 0; i < n_construct_params; i++) {
+                const char *par_name;
+
+                par_name = construct_params[i].pspec->name;
+
+                if (strcmp (par_name, "port") == 0)
+                        port = g_value_get_uint (construct_params[i].value);
+                else if (strcmp (par_name, "msearch-port") == 0) {
+                        msearch_idx = i;
+                        msearch_port = g_value_get_uint
+                                        (construct_params[i].value);
+                }
+        }
+
+        object_class = G_OBJECT_CLASS (gupnp_context_parent_class);
+
+        /* Override msearch-port property if port is set, the property exists
+         * and wasn't provided otherwise */
+        if (port != 0 && msearch_port != -1 && msearch_port == 0) {
+                g_value_set_uint (construct_params[msearch_idx].value, port);
+        }
+
+        return object_class->constructor (type,
+                                          n_construct_params,
+                                          construct_params);
+}
+
+
 static void
 gupnp_context_class_init (GUPnPContextClass *klass)
 {
@@ -358,6 +395,7 @@ gupnp_context_class_init (GUPnPContextClass *klass)
         object_class->get_property = gupnp_context_get_property;
         object_class->dispose      = gupnp_context_dispose;
         object_class->finalize     = gupnp_context_finalize;
+        object_class->constructor  = gupnp_context_constructor;
 
         g_type_class_add_private (klass, sizeof (GUPnPContextPrivate));
 


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