[gupnp] Ensure ResourceFactory creates proxies with right GType



commit 639e7fdc072d44cd1a619cc766e0e124dbfb48ca
Author: Jussi Kukkonen <jussi kukkonen intel com>
Date:   Sat Jan 18 17:37:48 2014 +0200

    Ensure ResourceFactory creates proxies with right GType
    
    https://bugzilla.gnome.org/show_bug.cgi?id=678701

 libgupnp/gupnp-resource-factory.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/libgupnp/gupnp-resource-factory.c b/libgupnp/gupnp-resource-factory.c
index 0ff9aea..3a65b4d 100644
--- a/libgupnp/gupnp-resource-factory.c
+++ b/libgupnp/gupnp-resource-factory.c
@@ -206,7 +206,8 @@ gupnp_resource_factory_create_device_proxy
  * @element: The #xmlNode ponting to the right service element
  * @location: The location of the service description file
  * @udn: The UDN of the device the service is contained in
- * @service_type: The service type
+ * @service_type: (allow-none): The service type, or %NULL to use service
+ * type from @element
  * @url_base: The URL base for this service, or %NULL if none
  *
  * Create a #GUPnPServiceProxy for the service with element @element, as
@@ -225,6 +226,7 @@ gupnp_resource_factory_create_service_proxy
                                  const char           *location,
                                  const SoupURI        *url_base)
 {
+        char              *type_from_xml = NULL;
         GUPnPServiceProxy *proxy;
         GType              proxy_type = GUPNP_TYPE_SERVICE_PROXY;
 
@@ -235,6 +237,13 @@ gupnp_resource_factory_create_service_proxy
         g_return_val_if_fail (location != NULL, NULL);
         g_return_val_if_fail (url_base != NULL, NULL);
 
+        if (!service_type) {
+                type_from_xml =
+                    xml_util_get_child_element_content_glib (element,
+                                                             "serviceType");
+                service_type = type_from_xml;
+        }
+
         if (service_type) {
                 gpointer value;
 
@@ -254,6 +263,8 @@ gupnp_resource_factory_create_service_proxy
                               "element", element,
                               NULL);
 
+        g_free (type_from_xml);
+
         return proxy;
 }
 


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