[gupnp] Signalize higher version services
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gupnp] Signalize higher version services
- Date: Wed, 28 Nov 2012 23:15:12 +0000 (UTC)
commit eb5b31290ffa8f82512f29847983c430adff49cf
Author: Jens Georg <mail jensge org>
Date: Sun Nov 25 15:25:31 2012 +0100
Signalize higher version services
If a control point was looking for a service instead of a device it was
only responding on exact version matches, but according to UDA also
higher versions are compatible as well.
This patch introduces a compare function that takes the service version
into account instead of a simple string comparison.
https://bugzilla.gnome.org/show_bug.cgi?id=689028
libgupnp/gupnp-control-point.c | 42 ++++++++++++++++++++++++++++++++++++++-
1 files changed, 40 insertions(+), 2 deletions(-)
---
diff --git a/libgupnp/gupnp-control-point.c b/libgupnp/gupnp-control-point.c
index 8e78042..deb19da 100644
--- a/libgupnp/gupnp-control-point.c
+++ b/libgupnp/gupnp-control-point.c
@@ -323,6 +323,44 @@ create_and_report_device_proxy (GUPnPControlPoint *control_point,
proxy);
}
+static gboolean
+compare_service_types_versioned (const char *searched_service,
+ const char *current_service)
+{
+ const char *searched_version_ptr, *current_version_ptr;
+ guint searched_version, current_version, searched_length;
+ guint current_length;
+
+ searched_version_ptr = strrchr (searched_service, ':');
+ if (searched_version_ptr == NULL)
+ return FALSE;
+
+ current_version_ptr = strrchr (current_service, ':');
+ if (current_version_ptr == NULL)
+ return FALSE;
+
+ searched_length = (searched_version_ptr - searched_service);
+ current_length = (current_version_ptr - current_service);
+
+ if (searched_length != current_length)
+ return FALSE;
+
+ searched_version = (guint) atol (searched_version_ptr + 1);
+ if (searched_version == 0)
+ return FALSE;
+
+ current_version = (guint) atol (current_version_ptr + 1);
+ if (current_version == 0)
+ return FALSE;
+
+ if (current_version < searched_version)
+ return FALSE;
+
+ return strncmp (searched_service,
+ current_service,
+ searched_length) == 0;
+}
+
/* Search @element for matching services */
static void
process_service_list (xmlNode *element,
@@ -348,8 +386,8 @@ process_service_list (xmlNode *element,
if (!prop)
continue;
- match = (strcmp ((char *) prop, service_type) == 0);
-
+ match = compare_service_types_versioned (service_type,
+ (char *) prop);
xmlFree (prop);
if (!match)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]