[gupnp] [PATCH] new function gupnp_device_info_list_dlna_capabilities()
- From: Sven Neumann <s neumann raumfeld com>
- To: gupnp o-hand com
- Subject: [gupnp] [PATCH] new function gupnp_device_info_list_dlna_capabilities()
- Date: Thu, 02 Jul 2009 10:49:52 +0200
Hi,
attached patch gives access to the DLNA capabilities of a device as
announced in the <dlna:X_DLNACAP> element. Please consider this for
inclusion in libgupnp.
Sven
>From c767801dbc388a0ac4095afc2e8dd0e4c8e4527f Mon Sep 17 00:00:00 2001
From: Sven Neumann <s neumann raumfeld com>
Date: Thu, 2 Jul 2009 10:36:25 +0200
Subject: [PATCH] new function gupnp_device_info_list_dlna_capabilities()
The new function introduced by this commit allows to retrieve the
capabilities of a DLNA device as announced in the device description
file using the <dlna:X_DLNACAP> element.
---
libgupnp/gupnp-device-info.c | 55 ++++++++++++++++++++++++++++++++
libgupnp/gupnp-device-info.h | 72 ++++++++++++++++++++++--------------------
2 files changed, 93 insertions(+), 34 deletions(-)
diff --git a/libgupnp/gupnp-device-info.c b/libgupnp/gupnp-device-info.c
index 1170b2e..3116ef9 100644
--- a/libgupnp/gupnp-device-info.c
+++ b/libgupnp/gupnp-device-info.c
@@ -928,6 +928,61 @@ resource_type_match (const char *query,
}
/**
+ * gupnp_device_info_list_dlna_capabilities
+ * @info: A #GUPnPDeviceInfo
+ *
+ * Get a #GList of strings that represent the device capabilities as
+ * announced in the device description file using the
+ * <dlna:X_DLNACAP> element.
+ *
+ * Return value: a #GList of newly allocated strings or %NULL if
+ * the device description doesn't contain the
+ * <dlna:X_DLNACAP> element.
+ **/
+GList *
+gupnp_device_info_list_dlna_capabilities (GUPnPDeviceInfo *info)
+{
+ xmlChar *caps;
+
+ g_return_val_if_fail (GUPNP_IS_DEVICE_INFO (info), NULL);
+
+ caps = xml_util_get_child_element_content (info->priv->element,
+ "X_DLNACAP");
+
+ if (caps) {
+ GList *list = NULL;
+ const xmlChar *start = caps;
+
+ while (*start) {
+ const xmlChar *end = start;
+
+ while (*end && *end != ',')
+ end++;
+
+ if (end > start) {
+ gchar *value;
+
+ value = g_strndup ((const gchar *) start,
+ end - start);
+
+ list = g_list_prepend (list, value);
+ }
+
+ if (*end)
+ start = end + 1;
+ else
+ break;
+ }
+
+ xmlFree (caps);
+
+ return g_list_reverse (list);
+ }
+
+ return NULL;
+}
+
+/**
* gupnp_device_info_list_devices
* @info: A #GUPnPDeviceInfo
*
diff --git a/libgupnp/gupnp-device-info.h b/libgupnp/gupnp-device-info.h
index 49439d0..3aaf6ec 100644
--- a/libgupnp/gupnp-device-info.h
+++ b/libgupnp/gupnp-device-info.h
@@ -87,85 +87,89 @@ typedef struct {
void (* _gupnp_reserved4) (void);
} GUPnPDeviceInfoClass;
+
GUPnPContext *
-gupnp_device_info_get_context (GUPnPDeviceInfo *info);
+gupnp_device_info_get_context (GUPnPDeviceInfo *info);
const char *
-gupnp_device_info_get_location (GUPnPDeviceInfo *info);
+gupnp_device_info_get_location (GUPnPDeviceInfo *info);
const SoupURI *
-gupnp_device_info_get_url_base (GUPnPDeviceInfo *info);
+gupnp_device_info_get_url_base (GUPnPDeviceInfo *info);
const char *
-gupnp_device_info_get_udn (GUPnPDeviceInfo *info);
+gupnp_device_info_get_udn (GUPnPDeviceInfo *info);
const char *
-gupnp_device_info_get_device_type (GUPnPDeviceInfo *info);
+gupnp_device_info_get_device_type (GUPnPDeviceInfo *info);
char *
-gupnp_device_info_get_friendly_name (GUPnPDeviceInfo *info);
+gupnp_device_info_get_friendly_name (GUPnPDeviceInfo *info);
char *
-gupnp_device_info_get_manufacturer (GUPnPDeviceInfo *info);
+gupnp_device_info_get_manufacturer (GUPnPDeviceInfo *info);
char *
-gupnp_device_info_get_manufacturer_url (GUPnPDeviceInfo *info);
+gupnp_device_info_get_manufacturer_url (GUPnPDeviceInfo *info);
char *
-gupnp_device_info_get_model_description (GUPnPDeviceInfo *info);
+gupnp_device_info_get_model_description (GUPnPDeviceInfo *info);
char *
-gupnp_device_info_get_model_name (GUPnPDeviceInfo *info);
+gupnp_device_info_get_model_name (GUPnPDeviceInfo *info);
char *
-gupnp_device_info_get_model_number (GUPnPDeviceInfo *info);
+gupnp_device_info_get_model_number (GUPnPDeviceInfo *info);
char *
-gupnp_device_info_get_model_url (GUPnPDeviceInfo *info);
+gupnp_device_info_get_model_url (GUPnPDeviceInfo *info);
char *
-gupnp_device_info_get_serial_number (GUPnPDeviceInfo *info);
+gupnp_device_info_get_serial_number (GUPnPDeviceInfo *info);
char *
-gupnp_device_info_get_upc (GUPnPDeviceInfo *info);
+gupnp_device_info_get_upc (GUPnPDeviceInfo *info);
char *
-gupnp_device_info_get_icon_url (GUPnPDeviceInfo *info,
- const char *requested_mime_type,
- int requested_depth,
- int requested_width,
- int requested_height,
- gboolean prefer_bigger,
- char **mime_type,
- int *depth,
- int *width,
- int *height);
+gupnp_device_info_get_icon_url (GUPnPDeviceInfo *info,
+ const char *requested_mime_type,
+ int requested_depth,
+ int requested_width,
+ int requested_height,
+ gboolean prefer_bigger,
+ char **mime_type,
+ int *depth,
+ int *width,
+ int *height);
char *
-gupnp_device_info_get_presentation_url (GUPnPDeviceInfo *info);
+gupnp_device_info_get_presentation_url (GUPnPDeviceInfo *info);
+
+GList *
+gupnp_device_info_list_dlna_capabilities (GUPnPDeviceInfo *info);
GList *
-gupnp_device_info_list_devices (GUPnPDeviceInfo *info);
+gupnp_device_info_list_devices (GUPnPDeviceInfo *info);
GList *
-gupnp_device_info_list_device_types (GUPnPDeviceInfo *info);
+gupnp_device_info_list_device_types (GUPnPDeviceInfo *info);
GUPnPDeviceInfo *
-gupnp_device_info_get_device (GUPnPDeviceInfo *info,
- const char *type);
+gupnp_device_info_get_device (GUPnPDeviceInfo *info,
+ const char *type);
GList *
-gupnp_device_info_list_services (GUPnPDeviceInfo *info);
+gupnp_device_info_list_services (GUPnPDeviceInfo *info);
GList *
-gupnp_device_info_list_service_types (GUPnPDeviceInfo *info);
+gupnp_device_info_list_service_types (GUPnPDeviceInfo *info);
GUPnPServiceInfo *
-gupnp_device_info_get_service (GUPnPDeviceInfo *info,
- const char *type);
+gupnp_device_info_get_service (GUPnPDeviceInfo *info,
+ const char *type);
GUPnPResourceFactory *
-gupnp_device_info_get_resource_factory (GUPnPDeviceInfo *device_info);
+gupnp_device_info_get_resource_factory (GUPnPDeviceInfo *device_info);
G_END_DECLS
--
1.6.0.4
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]