summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Ferrandis <ludovic.ferrandis@intel.com>2013-09-16 15:20:26 +0200
committerLudovic Ferrandis <ludovic.ferrandis@intel.com>2013-09-16 15:25:25 +0200
commitc60ec4fb2df0e9a67f3bf6c7b9e0436e9c73de6c (patch)
tree8476e24683cb4f6a3e238a4e1a4164275a1000c7
parent47fa9521e80b32877a41f5945c2357d80c557b2f (diff)
downloaddleyna-renderer-c60ec4fb2df0e9a67f3bf6c7b9e0436e9c73de6c.tar.gz
[Path] Make object paths stable across restarts
Fix issue #114: <https://github.com/01org/dleyna-renderer/issues/114> Root paths for servers were builded using an incremental counter, based of the discovery order made by GSSDP: Results were of this form: /com/intel/dLeynaRenderer/server/0 /com/intel/dLeynaRenderer/server/1 Object paths were builded on these root paths: /com/intel/dLeynaRenderer/server/0/xxxxxxxxxx There is no persistence between restarts of dleyna because we can't assign the same index to the same server. To fix this issue, we replace the volatile part of the root path, id the index, by a non volatile and unique part, id the server udn. The server udn is a string of this form: "uuid:<uuid string>" <uuid string> is defined by RFC 4122(<http://www.ietf.org/rfc/rfc4122.txt> and it's composed only with hex digit and char '-' To make the path compatible with dbus and 'reversible': 1 - remove the prefix 'uuid:' 2 - convert '-' char to '_' char Result is of the form below: /com/intel/dLeynaRenderer/server/99951d71_23d5_5525_94eb_a4aa78a98211 This path is stable accross dleyna restart and identify uniquely a server. This can be sued to save object path and to use them after multiple restart of the server and dLeyna. Signed-off-by: Ludovic Ferrandis <ludovic.ferrandis@intel.com>
-rw-r--r--libdleyna/renderer/device.c12
-rw-r--r--libdleyna/renderer/device.h2
-rw-r--r--libdleyna/renderer/upnp.c7
3 files changed, 12 insertions, 9 deletions
diff --git a/libdleyna/renderer/device.c b/libdleyna/renderer/device.c
index d5aa82c..f2766e1 100644
--- a/libdleyna/renderer/device.c
+++ b/libdleyna/renderer/device.c
@@ -820,18 +820,26 @@ dlr_device_t *dlr_device_new(
dleyna_connector_id_t connection,
GUPnPDeviceProxy *proxy,
const gchar *ip_address,
- guint counter,
+ const char *udn,
const dleyna_connector_dispatch_cb_t *dispatch_table,
const dleyna_task_queue_key_t *queue_id)
{
dlr_device_t *dev;
gchar *new_path;
+ gchar *uuid;
dlr_device_context_t *context;
DLEYNA_LOG_DEBUG("New Device on %s", ip_address);
- new_path = g_strdup_printf("%s/%u", DLEYNA_SERVER_PATH, counter);
+ /* Strip 'uuid:' string prefix if exists and replace unauthorized
+ * dbus path char from uuid string */
+ uuid = strchr(udn, ':');
+ uuid = g_strdup(uuid ? uuid + 1 : udn);
+ uuid = g_strdelimit(uuid, "-", '_');
+
+ new_path = g_strdup_printf("%s/%s", DLEYNA_SERVER_PATH, uuid);
DLEYNA_LOG_DEBUG("Server Path %s", new_path);
+ g_free(uuid);
dev = g_new0(dlr_device_t, 1);
diff --git a/libdleyna/renderer/device.h b/libdleyna/renderer/device.h
index 70692f3..dd39081 100644
--- a/libdleyna/renderer/device.h
+++ b/libdleyna/renderer/device.h
@@ -101,7 +101,7 @@ dlr_device_t *dlr_device_new(
dleyna_connector_id_t connection,
GUPnPDeviceProxy *proxy,
const gchar *ip_address,
- guint counter,
+ const char *udn,
const dleyna_connector_dispatch_cb_t *dispatch_table,
const dleyna_task_queue_key_t *queue_id);
diff --git a/libdleyna/renderer/upnp.c b/libdleyna/renderer/upnp.c
index fefc340..bd9a688 100644
--- a/libdleyna/renderer/upnp.c
+++ b/libdleyna/renderer/upnp.c
@@ -45,7 +45,6 @@ struct dlr_upnp_t_ {
void *user_data;
GHashTable *server_udn_map;
GHashTable *server_uc_map;
- guint counter;
dlr_host_service_t *host_service;
};
@@ -186,14 +185,10 @@ static void prv_server_available_cb(GUPnPControlPoint *cp,
queue_id = prv_create_device_queue(&priv_t);
device = dlr_device_new(upnp->connection, proxy, ip_address,
- upnp->counter,
- upnp->interface_info,
- queue_id);
+ udn, upnp->interface_info, queue_id);
prv_update_device_context(priv_t, upnp, udn, device, ip_address,
queue_id);
-
- upnp->counter++;
} else {
DLEYNA_LOG_DEBUG("Device Found");