[gupnp] Try to use UDN to generate description location



commit ce345d1e36a2123c1afd254504de00b43dde5ff7
Author: Jens Georg <mail jensge org>
Date:   Wed Jun 29 16:05:40 2011 +0200

    Try to use UDN to generate description location
    
    Previously the device location url was generated from the address of
    the GUPnPRootDevice object, which meant that it changes on each
    restart. Under some circumstances a more stable location url is
    necessary.

 libgupnp/gupnp-root-device.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/libgupnp/gupnp-root-device.c b/libgupnp/gupnp-root-device.c
index 1b24ce9..65115f1 100644
--- a/libgupnp/gupnp-root-device.c
+++ b/libgupnp/gupnp-root-device.c
@@ -404,7 +404,11 @@ gupnp_root_device_constructor (GType                  type,
         device = GUPNP_ROOT_DEVICE (object);
 
         /* Generate location relative to HTTP root */
-        device->priv->relative_location = g_strdup_printf ("RootDevice%p.xml",                                                             object);
+        udn = gupnp_device_info_get_udn (GUPNP_DEVICE_INFO (device));
+        if (udn && strstr (udn, "uuid:") == udn)
+                device->priv->relative_location = g_strdup_printf ("%s.xml", udn + 5);
+        else
+                device->priv->relative_location = g_strdup_printf ("RootDevice%p.xml", device);
 
         relative_location = g_strjoin (NULL,
                                        "/",
@@ -441,7 +445,6 @@ gupnp_root_device_constructor (GType                  type,
         device->priv->group = gssdp_resource_group_new (GSSDP_CLIENT (context));
 
         /* Add services and devices to resource group */
-        udn = gupnp_device_info_get_udn (GUPNP_DEVICE_INFO (device));
         usn = g_strdup_printf ("%s::upnp:rootdevice", (const char *) udn);
         gssdp_resource_group_add_resource_simple (device->priv->group,
                                                   "upnp:rootdevice",



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