[gupnp-av] Add setter/getter API for 'upnp:searchClass'
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gupnp-av] Add setter/getter API for 'upnp:searchClass'
- Date: Tue, 14 Jun 2011 20:14:34 +0000 (UTC)
commit f786b879c2dd411cd7f78137cb22dd012d865382
Author: Topi Santakivi <topi santakivi digia com>
Date: Thu May 26 11:06:24 2011 +0300
Add setter/getter API for 'upnp:searchClass'
Co-author & reviewer: Zeeshan Ali (Khattak) <zeeshanak gnome org>
libgupnp-av/gupnp-didl-lite-container.c | 100 +++++++++++++++++++++++++++++++
libgupnp-av/gupnp-didl-lite-container.h | 15 +++++
2 files changed, 115 insertions(+), 0 deletions(-)
---
diff --git a/libgupnp-av/gupnp-didl-lite-container.c b/libgupnp-av/gupnp-didl-lite-container.c
index ac56d62..0201025 100644
--- a/libgupnp-av/gupnp-didl-lite-container.c
+++ b/libgupnp-av/gupnp-didl-lite-container.c
@@ -235,6 +235,45 @@ gupnp_didl_lite_container_get_create_classes (GUPnPDIDLLiteContainer *container)
}
/**
+ * gupnp_didl_lite_container_get_search_classes:
+ * @container: #GUPnPDIDLLiteContainer
+ *
+ * Gets the list of search classes of the @object.
+ *
+ * Return value: (element-type utf8) (transfer full): The list of search classes
+ * belonging to @object, or %NULL. #g_list_free the returned list after usage
+ * and #g_free each string in it.
+ **/
+GList *
+gupnp_didl_lite_container_get_search_classes (GUPnPDIDLLiteContainer *container)
+{
+ GList *classes = NULL;
+ GList *ret = NULL;
+ GList *l;
+
+ g_return_val_if_fail (container != NULL, NULL);
+ g_return_val_if_fail (GUPNP_IS_DIDL_LITE_CONTAINER (container), NULL);
+
+ classes = gupnp_didl_lite_object_get_properties (
+ GUPNP_DIDL_LITE_OBJECT (container),
+ "searchClass");
+
+ for (l = classes; l; l = l->next) {
+ char *search_class;
+ xmlNode *node;
+
+ node = (xmlNode *) l->data;
+ search_class = g_strdup ((const char *) node->content);
+
+ ret = g_list_append (ret, search_class);
+ }
+
+ g_list_free (classes);
+
+ return ret;
+}
+
+/**
* gupnp_didl_lite_container_set_searchable:
* @container: #GUPnPDIDLLiteContainer
* @searchable: The searchibility
@@ -324,3 +363,64 @@ gupnp_didl_lite_container_add_create_class (
(unsigned char *) "createClass",
(unsigned char *) create_class);
}
+
+/**
+ * gupnp_didl_lite_container_add_search_class:
+ * @container: #GUPnPDIDLLiteContainer
+ * @search_class: The searchClass to add.
+ * Add a new search class to the @object.
+ *
+ * Return value: None.
+ **/
+void
+gupnp_didl_lite_container_add_search_class (
+ GUPnPDIDLLiteContainer *container,
+ const char *search_class)
+{
+ gupnp_didl_lite_container_add_search_class_full (container,
+ search_class,
+ TRUE);
+}
+
+/**
+ * gupnp_didl_lite_container_add_search_class_full:
+ * @container: #GUPnPDIDLLiteContainer
+ * @search_class: The searchClass to add.
+ * @include_derived: includeDerived attribute of the DIDL
+ * Add a new search class to the @object.
+ *
+ * Return value: None.
+ **/
+void
+gupnp_didl_lite_container_add_search_class_full (
+ GUPnPDIDLLiteContainer *container,
+ const char *search_class,
+ gboolean include_derived)
+{
+ xmlNode *xml_node;
+ xmlNode *new_xml_node;
+ xmlNs *namespace;
+ const char *str;
+
+ g_return_if_fail (container != NULL);
+ g_return_if_fail (GUPNP_IS_DIDL_LITE_CONTAINER (container));
+
+ xml_node = gupnp_didl_lite_object_get_xml_node
+ (GUPNP_DIDL_LITE_OBJECT (container));
+ namespace = gupnp_didl_lite_object_get_upnp_namespace
+ (GUPNP_DIDL_LITE_OBJECT (container));
+
+ new_xml_node = xmlNewChild (xml_node,
+ namespace,
+ (unsigned char *) "searchClass",
+ (unsigned char *) search_class);
+
+ if (include_derived)
+ str = "1";
+ else
+ str = "0";
+
+ xmlSetProp (new_xml_node,
+ (unsigned char*) "includeDerived",
+ (unsigned char*) str);
+}
diff --git a/libgupnp-av/gupnp-didl-lite-container.h b/libgupnp-av/gupnp-didl-lite-container.h
index 082915e..8fb1958 100644
--- a/libgupnp-av/gupnp-didl-lite-container.h
+++ b/libgupnp-av/gupnp-didl-lite-container.h
@@ -78,6 +78,10 @@ GList *
gupnp_didl_lite_container_get_create_classes
(GUPnPDIDLLiteContainer *container);
+GList *
+gupnp_didl_lite_container_get_search_classes
+ (GUPnPDIDLLiteContainer *container);
+
void
gupnp_didl_lite_container_set_searchable
(GUPnPDIDLLiteContainer *container,
@@ -93,6 +97,17 @@ gupnp_didl_lite_container_add_create_class
(GUPnPDIDLLiteContainer *container,
const char *create_class);
+void
+gupnp_didl_lite_container_add_search_class
+ (GUPnPDIDLLiteContainer *container,
+ const char *search_class);
+
+void
+gupnp_didl_lite_container_add_search_class_full
+ (GUPnPDIDLLiteContainer *container,
+ const char *search_class,
+ gboolean include_derived);
+
G_END_DECLS
#endif /* __GUPNP_DIDL_LITE_CONTAINER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]