[gupnp-av] Allow 'upnp:createClass' attributes retrieval



commit 58c792f24221d9989acff5b18bbf7f8f25233bba
Author: Christophe Guiraud <christophe guiraud intel com>
Date:   Tue Sep 18 15:37:22 2012 +0200

    Allow 'upnp:createClass' attributes retrieval
    
    Existing gupnp_didl_lite_container_get_create_classes (...)) API doesn't
    allow to retrieve the "IncludeDerived" and friendlyName attributes of the
    "upnp:createClass" elements, the returned result is a Glist of UTF8 string
     representing the class name.
    
    To enable the retrieval of these attributes, this change adds:
    
    - A new GUPnPDIDLLiteCreateClasses GObject with the "upnp:createClass"
     properties (content, includeDerived, friendly name) and their related
     Getter/Setter APIs.
    
    - A new GUPnPDIDLLiteContainer GObject method to get all its
    "upnp:createClass" elements as a GList of GUPnPDIDLLiteCreateClasses
     objects:
    
    GList * gupnp_didl_lite_container_get_create_classes_full(
    					GUPnPDIDLLiteContainer *container);
    
    https://bugzilla.gnome.org/show_bug.cgi?id=684297

 libgupnp-av/Makefile.am                           |    4 +
 libgupnp-av/gupnp-av.h                            |    1 +
 libgupnp-av/gupnp-didl-lite-container.c           |   56 +++-
 libgupnp-av/gupnp-didl-lite-container.h           |    5 +
 libgupnp-av/gupnp-didl-lite-createclass-private.h |   39 ++
 libgupnp-av/gupnp-didl-lite-createclass.c         |  445 +++++++++++++++++++++
 libgupnp-av/gupnp-didl-lite-createclass.h         |  109 +++++
 libgupnp-av/gupnp-didl-lite-object.c              |    1 -
 8 files changed, 657 insertions(+), 3 deletions(-)
---
diff --git a/libgupnp-av/Makefile.am b/libgupnp-av/Makefile.am
index 40475ed..1570657 100644
--- a/libgupnp-av/Makefile.am
+++ b/libgupnp-av/Makefile.am
@@ -18,6 +18,7 @@ lib_LTLIBRARIES = libgupnp-av-1.0.la
 libgupnp_av_inc_HEADERS = gupnp-didl-lite-object.h \
 			  gupnp-didl-lite-item.h \
 			  gupnp-didl-lite-container.h \
+			  gupnp-didl-lite-createclass.h \
 			  gupnp-didl-lite-parser.h \
 			  gupnp-didl-lite-resource.h \
 			  gupnp-didl-lite-descriptor.h \
@@ -47,6 +48,8 @@ libgupnp_av_1_0_la_SOURCES = gupnp-didl-lite-object.c \
 			     gupnp-didl-lite-object-private.h \
 			     gupnp-didl-lite-item.c \
 			     gupnp-didl-lite-container.c \
+			     gupnp-didl-lite-createclass.c \
+			     gupnp-didl-lite-createclass-private.h \
 			     gupnp-didl-lite-parser.c \
 			     gupnp-didl-lite-resource.c \
 			     gupnp-didl-lite-resource-private.h \
@@ -87,6 +90,7 @@ introspection_sources = \
 	    $(top_srcdir)/libgupnp-av/gupnp-didl-lite-descriptor.c \
 	    $(top_srcdir)/libgupnp-av/gupnp-didl-lite-contributor.c \
 	    $(top_srcdir)/libgupnp-av/gupnp-didl-lite-writer.c \
+	    $(top_srcdir)/libgupnp-av/gupnp-didl-lite-createclass.c \
 	    $(top_srcdir)/libgupnp-av/gupnp-protocol-info.c \
 	    $(top_srcdir)/libgupnp-av/gupnp-search-criteria-parser.c \
 	    $(top_srcdir)/libgupnp-av/gupnp-last-change-parser.c \
diff --git a/libgupnp-av/gupnp-av.h b/libgupnp-av/gupnp-av.h
index 63ee485..0a822a3 100644
--- a/libgupnp-av/gupnp-av.h
+++ b/libgupnp-av/gupnp-av.h
@@ -23,6 +23,7 @@
 
 #include "gupnp-didl-lite-object.h"
 #include "gupnp-didl-lite-container.h"
+#include "gupnp-didl-lite-createclass.h"
 #include "gupnp-didl-lite-item.h"
 #include "gupnp-didl-lite-parser.h"
 #include "gupnp-didl-lite-resource.h"
diff --git a/libgupnp-av/gupnp-didl-lite-container.c b/libgupnp-av/gupnp-didl-lite-container.c
index 03fce35..16a535a 100644
--- a/libgupnp-av/gupnp-didl-lite-container.c
+++ b/libgupnp-av/gupnp-didl-lite-container.c
@@ -2,9 +2,10 @@
  * Copyright (C) 2009 Nokia Corporation.
  * Copyright (C) 2012 Intel Corporation
  *
- * Authors: Zeeshan Ali (Khattak) <zeeshan ali nokia com>
- *                                <zeeshanak gnome org>
+ * Authors: Zeeshan Ali (Khattak) <zeeshanak gnome org>
+ *                                <zeeshan ali nokia com>
  *          Krzesimir Nowak <krnowak openismus com>
+ *          Christophe Guiraud <christophe guiraud intel com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -33,8 +34,11 @@
 
 #include "gupnp-didl-lite-container.h"
 #include "gupnp-didl-lite-object-private.h"
+#include "gupnp-didl-lite-createclass.h"
+#include "gupnp-didl-lite-createclass-private.h"
 #include "xml-util.h"
 
+
 G_DEFINE_TYPE (GUPnPDIDLLiteContainer,
                gupnp_didl_lite_container,
                GUPNP_TYPE_DIDL_LITE_OBJECT);
@@ -419,6 +423,7 @@ gupnp_didl_lite_container_get_create_classes (GUPnPDIDLLiteContainer *container)
                 xmlNode *node;
 
                 node = (xmlNode *) l->data;
+
                 if (node->children != NULL) {
                     create_class = g_strdup ((const char *) node->children->content);
 
@@ -432,6 +437,53 @@ gupnp_didl_lite_container_get_create_classes (GUPnPDIDLLiteContainer *container)
 }
 
 /**
+ * gupnp_didl_lite_container_get_create_classes_full:
+ * @container: #GUPnPDIDLLiteContainer
+ *
+ * Gets the list of create classes of the @container.
+ *
+ * Returns: (element-type GUPnPDIDLLiteCreateClass*) (transfer full): The list
+ * of create classes belonging to @container, or %NULL.
+ * #g_list_free the returned list after usage and unref each object in it.
+ **/
+GList *
+gupnp_didl_lite_container_get_create_classes_full (
+                                            GUPnPDIDLLiteContainer *container)
+{
+        GList *cc_list = 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);
+
+        cc_list = gupnp_didl_lite_object_get_properties (
+                                           GUPNP_DIDL_LITE_OBJECT (container),
+                                           "createClass");
+
+        for (l = cc_list; l; l = l->next) {
+                GUPnPDIDLLiteCreateClass *cc;
+                xmlNode *cc_node;
+                GUPnPXMLDoc *cc_doc;
+
+                cc_node = (xmlNode *) l->data;
+                if (!cc_node->children)
+                        continue;
+
+                cc_doc = gupnp_didl_lite_object_get_gupnp_xml_doc (
+                                           GUPNP_DIDL_LITE_OBJECT (container));
+
+                cc = gupnp_didl_lite_create_class_new_from_xml (cc_node, cc_doc);
+
+                ret = g_list_append (ret, cc);
+        }
+
+        g_list_free (cc_list);
+
+        return ret;
+}
+
+/**
  * gupnp_didl_lite_container_get_search_classes:
  * @container: #GUPnPDIDLLiteContainer
  *
diff --git a/libgupnp-av/gupnp-didl-lite-container.h b/libgupnp-av/gupnp-didl-lite-container.h
index b9a28fa..7c4ced7 100644
--- a/libgupnp-av/gupnp-didl-lite-container.h
+++ b/libgupnp-av/gupnp-didl-lite-container.h
@@ -4,6 +4,7 @@
  *
  * Authors: Zeeshan Ali (Khattak) <zeeshan ali nokia com>
  *                                <zeeshanak gnome org>
+ *          Christophe Guiraud <christophe guiraud intel com>
  *          Krzesimir Nowak <krnowak openismus com>
  *
  * This library is free software; you can redistribute it and/or
@@ -97,6 +98,9 @@ gupnp_didl_lite_container_get_create_classes
                                         (GUPnPDIDLLiteContainer *container);
 
 GList *
+gupnp_didl_lite_container_get_create_classes_full
+                                        (GUPnPDIDLLiteContainer *container);
+GList *
 gupnp_didl_lite_container_get_search_classes
                                         (GUPnPDIDLLiteContainer *container);
 
@@ -157,6 +161,7 @@ void
 gupnp_didl_lite_container_set_storage_used
                                        (GUPnPDIDLLiteContainer *container,
                                         gint64                  storage_used);
+
 G_END_DECLS
 
 #endif /* __GUPNP_DIDL_LITE_CONTAINER_H__ */
diff --git a/libgupnp-av/gupnp-didl-lite-createclass-private.h b/libgupnp-av/gupnp-didl-lite-createclass-private.h
new file mode 100644
index 0000000..59ce5f6
--- /dev/null
+++ b/libgupnp-av/gupnp-didl-lite-createclass-private.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2012 Intel Corporation.
+ * Copyright (C) 2009 Nokia Corporation.
+ *
+ * Author: Christophe Guiraud <christophe guiraud intel com>
+ * Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
+ *                               <zeeshan ali nokia com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GUPNP_DIDL_LITE_CREATE_CLASS_PRIVATE_H__
+#define __GUPNP_DIDL_LITE_CREATE_CLASS_PRIVATE_H__
+
+#include <glib-object.h>
+#include <libxml/tree.h>
+
+G_BEGIN_DECLS
+
+G_GNUC_INTERNAL GUPnPDIDLLiteCreateClass *
+gupnp_didl_lite_create_class_new_from_xml (xmlNode     *xml_node,
+                                           GUPnPXMLDoc *xml_doc);
+
+G_END_DECLS
+
+#endif /* __GUPNP_DIDL_LITE_CREATE_CLASS_PRIVATE_H__ */
diff --git a/libgupnp-av/gupnp-didl-lite-createclass.c b/libgupnp-av/gupnp-didl-lite-createclass.c
new file mode 100644
index 0000000..707d187
--- /dev/null
+++ b/libgupnp-av/gupnp-didl-lite-createclass.c
@@ -0,0 +1,445 @@
+/*
+ * Copyright (C) 2012 Intel Corporation.
+ * Copyright (C) 2009 Nokia Corporation.
+ *
+ * Author: Christophe Guiraud <christophe guiraud intel com>
+ * Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
+ *                               <zeeshan ali nokia com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/**
+ * SECTION:gupnp-didl-lite-create-class
+ * @short_description: DIDL-Lite CreateClass
+ *
+ * #GUPnPDIDLLiteCreateClass respresents a DIDL-Lite create class element.
+ */
+
+#include <string.h>
+
+#include "gupnp-didl-lite-createclass.h"
+#include "xml-util.h"
+
+G_DEFINE_TYPE (GUPnPDIDLLiteCreateClass,
+               gupnp_didl_lite_create_class,
+               G_TYPE_OBJECT);
+
+struct _GUPnPDIDLLiteCreateClassPrivate {
+        xmlNode     *xml_node;
+        GUPnPXMLDoc *xml_doc;
+};
+
+enum {
+        PROP_0,
+        PROP_XML_NODE,
+        PROP_XML_DOC,
+        PROP_CONTENT,
+        PROP_INCLUDE_DERIVED,
+        PROP_FRIENDLY_NAME,
+};
+
+static void
+gupnp_didl_lite_create_class_init (GUPnPDIDLLiteCreateClass *create_class)
+{
+        create_class->priv = G_TYPE_INSTANCE_GET_PRIVATE
+                                        (create_class,
+                                         GUPNP_TYPE_DIDL_LITE_CREATE_CLASS,
+                                         GUPnPDIDLLiteCreateClassPrivate);
+}
+
+static void
+gupnp_didl_lite_create_class_get_property (GObject    *object,
+                                           guint       property_id,
+                                           GValue     *value,
+                                           GParamSpec *pspec)
+{
+        GUPnPDIDLLiteCreateClass *create_class;
+
+        create_class = GUPNP_DIDL_LITE_CREATE_CLASS (object);
+
+        switch (property_id) {
+        case PROP_XML_NODE:
+                g_value_set_pointer
+                    (value,
+                     gupnp_didl_lite_create_class_get_xml_node
+                                                            (create_class));
+                break;
+        case PROP_CONTENT:
+                g_value_set_string
+                    (value,
+                     gupnp_didl_lite_create_class_get_content
+                                                            (create_class));
+                break;
+        case PROP_INCLUDE_DERIVED:
+                g_value_set_boolean
+                    (value,
+                     gupnp_didl_lite_create_class_get_include_derived
+                                                            (create_class));
+                break;
+        case PROP_FRIENDLY_NAME:
+                g_value_set_string
+                    (value,
+                     gupnp_didl_lite_create_class_get_friendly_name
+                                                            (create_class));
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                break;
+        }
+}
+
+static void
+gupnp_didl_lite_create_class_set_property (GObject      *object,
+                                            guint         property_id,
+                                            const GValue *value,
+                                            GParamSpec   *pspec)
+{
+        GUPnPDIDLLiteCreateClass *create_class;
+
+        create_class = GUPNP_DIDL_LITE_CREATE_CLASS (object);
+
+        switch (property_id) {
+        case PROP_XML_NODE:
+                create_class->priv->xml_node = g_value_get_pointer (value);
+                break;
+        case PROP_XML_DOC:
+                create_class->priv->xml_doc = g_value_dup_object (value);
+                break;
+        case PROP_CONTENT:
+                gupnp_didl_lite_create_class_set_content
+                                                 (create_class,
+                                                  g_value_get_string (value));
+                break;
+        case PROP_INCLUDE_DERIVED:
+                gupnp_didl_lite_create_class_set_include_derived
+                                                 (create_class,
+                                                  g_value_get_boolean (value));
+                break;
+        case PROP_FRIENDLY_NAME:
+                gupnp_didl_lite_create_class_set_friendly_name
+                                                 (create_class,
+                                                  g_value_get_string (value));
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                break;
+        }
+}
+
+static void
+gupnp_didl_lite_create_class_dispose (GObject *object)
+{
+        GObjectClass                    *object_class;
+        GUPnPDIDLLiteCreateClassPrivate *priv;
+
+        priv = GUPNP_DIDL_LITE_CREATE_CLASS (object)->priv;
+
+        if (priv->xml_doc) {
+                g_object_unref (priv->xml_doc);
+                priv->xml_doc = NULL;
+        }
+
+        object_class = G_OBJECT_CLASS
+                                   (gupnp_didl_lite_create_class_parent_class);
+        object_class->dispose (object);
+}
+
+static void
+gupnp_didl_lite_create_class_class_init (GUPnPDIDLLiteCreateClassClass *klass)
+{
+        GObjectClass *object_class;
+
+        object_class = G_OBJECT_CLASS (klass);
+
+        object_class->get_property = gupnp_didl_lite_create_class_get_property;
+        object_class->set_property = gupnp_didl_lite_create_class_set_property;
+        object_class->dispose = gupnp_didl_lite_create_class_dispose;
+
+        g_type_class_add_private (klass,
+                                  sizeof (GUPnPDIDLLiteCreateClassPrivate));
+
+        /**
+         * GUPnPDIDLLiteCreateClass:xml-node:
+         *
+         * The pointer to desc node in XML document.
+         **/
+        g_object_class_install_property
+                (object_class,
+                 PROP_XML_NODE,
+                 g_param_spec_pointer
+                                   ("xml-node",
+                                    "XMLNode",
+                                    "The pointer to desc node in XML"
+                                    " document.",
+                                    G_PARAM_READWRITE |
+                                    G_PARAM_CONSTRUCT_ONLY |
+                                    G_PARAM_STATIC_NAME |
+                                    G_PARAM_STATIC_NICK |
+                                    G_PARAM_STATIC_BLURB));
+
+        /**
+         * GUPnPDIDLLiteCreateClass:xml-doc:
+         *
+         * The reference to XML document containing this object.
+         *
+         * Internal property.
+         *
+         * Stability: Private
+         **/
+        g_object_class_install_property
+                (object_class,
+                 PROP_XML_DOC,
+                 g_param_spec_object
+                                   ("xml-doc",
+                                    "XMLDoc",
+                                    "The reference to XML document"
+                                    " containing this object.",
+                                    GUPNP_TYPE_XML_DOC,
+                                    G_PARAM_WRITABLE |
+                                    G_PARAM_CONSTRUCT_ONLY |
+                                    G_PARAM_STATIC_NAME |
+                                    G_PARAM_STATIC_NICK |
+                                    G_PARAM_STATIC_BLURB));
+
+        /**
+         * GUPnPDIDLLiteCreateClass:content:
+         *
+         * The content of this create Class.
+         **/
+        g_object_class_install_property
+                (object_class,
+                 PROP_CONTENT,
+                 g_param_spec_string
+                                   ("content",
+                                    "Content",
+                                    "The content of this create Class.",
+                                    NULL,
+                                    G_PARAM_READWRITE |
+                                    G_PARAM_STATIC_NAME |
+                                    G_PARAM_STATIC_NICK |
+                                    G_PARAM_STATIC_BLURB));
+
+        /**
+         * GUPnPDIDLLiteCreateClass:include-derived:
+         *
+         * Whether this create Class can be derived.
+         **/
+        g_object_class_install_property
+                (object_class,
+                 PROP_INCLUDE_DERIVED,
+                 g_param_spec_boolean
+                                   ("include-derived",
+                                    "IncludeDerived",
+                                    "Wether this create Class can be derived.",
+                                    FALSE,
+                                    G_PARAM_READWRITE |
+                                    G_PARAM_STATIC_NAME |
+                                    G_PARAM_STATIC_NICK |
+                                    G_PARAM_STATIC_BLURB));
+
+        /**
+         * GUPnPDIDLLiteCreateClass:friendly-name:
+         *
+         * The friendly name of this create Class.
+         **/
+        g_object_class_install_property
+                (object_class,
+                 PROP_FRIENDLY_NAME,
+                 g_param_spec_string
+                                   ("friendly-name",
+                                    "FriendlyName",
+                                    "The friendly name of this create Class.",
+                                    NULL,
+                                    G_PARAM_READWRITE |
+                                    G_PARAM_STATIC_NAME |
+                                    G_PARAM_STATIC_NICK |
+                                    G_PARAM_STATIC_BLURB));
+}
+
+/**
+ * gupnp_didl_lite_create_class_get_content:
+ * @create_class: #GUPnPDIDLLiteCreateClass
+ *
+ * Get the content of the @create_class.
+ *
+ * Return value: The Content of the @create_class, or %NULL.
+ **/
+const char *
+gupnp_didl_lite_create_class_get_content
+                                    (GUPnPDIDLLiteCreateClass *create_class)
+{
+        g_return_val_if_fail (GUPNP_IS_DIDL_LITE_CREATE_CLASS (create_class),
+                              NULL);
+
+        if (G_UNLIKELY (create_class->priv->xml_node->children == NULL))
+                return NULL;
+
+        return (const char *) create_class->priv->xml_node->children->content;
+}
+
+/**
+ * gupnp_didl_lite_create_class_set_content:
+ * @create_class: #GUPnPDIDLLiteCreateClass
+ * @content: The content
+ *
+ * Set the content of the @create_class.
+ **/
+void
+gupnp_didl_lite_create_class_set_content
+                                    (GUPnPDIDLLiteCreateClass *create_class,
+                                     const char               *content)
+{
+        xmlChar *escaped;
+
+        g_return_if_fail (GUPNP_IS_DIDL_LITE_CREATE_CLASS (create_class));
+        g_return_if_fail (create_class != NULL);
+
+        escaped = xmlEncodeSpecialChars (create_class->priv->xml_doc->doc,
+                                         (const unsigned char *) content);
+        xmlNodeSetContent (create_class->priv->xml_node, escaped);
+        xmlFree (escaped);
+
+        g_object_notify (G_OBJECT (create_class), "content");
+}
+
+/**
+ * gupnp_didl_lite_create_class_get_include_derived:
+ * @create_class: #GUPnPDIDLLiteCreateClass
+ *
+ * Checks whether @create_class can be derived.
+ *
+ * Return value: #TRUE if @create_class can be derived.
+ **/
+gboolean
+gupnp_didl_lite_create_class_get_include_derived
+                                    (GUPnPDIDLLiteCreateClass *create_class)
+{
+        g_return_val_if_fail (GUPNP_IS_DIDL_LITE_CREATE_CLASS (create_class),
+                              FALSE);
+
+        return xml_util_get_boolean_attribute (create_class->priv->xml_node,
+                                               "includeDerived");
+}
+
+/**
+ * gupnp_didl_lite_create_class_set_include_derived:
+ * @create_class: #GUPnPDIDLLiteCreateClass
+ * @include_derived: the derivability
+ *
+ * (Un)set the derivability of create_class.
+ **/
+void
+gupnp_didl_lite_create_class_set_include_derived
+                                    (GUPnPDIDLLiteCreateClass *create_class,
+                                     gboolean                 include_derived)
+{
+        const char *str;
+
+        g_return_if_fail (create_class != NULL);
+        g_return_if_fail (GUPNP_IS_DIDL_LITE_CREATE_CLASS (create_class));
+
+        if (include_derived)
+                str = "1";
+        else
+                str = "0";
+        xmlSetProp (create_class->priv->xml_node,
+                    (unsigned char *) "includeDerived",
+                    (unsigned char *) str);
+
+        g_object_notify (G_OBJECT (create_class), "include-derived");
+}
+
+/**
+ * gupnp_didl_lite_create_class_get_friendly_name:
+ * @create_class: #GUPnPDIDLLiteCreateClass
+ *
+ * Get the friendly name of the @create_class.
+ *
+ * Return value: The FriendlyName of the @create_class, or %NULL.
+ **/
+const char *
+gupnp_didl_lite_create_class_get_friendly_name
+                                    (GUPnPDIDLLiteCreateClass *create_class)
+{
+        g_return_val_if_fail (GUPNP_IS_DIDL_LITE_CREATE_CLASS (create_class),
+                              NULL);
+        return xml_util_get_attribute_content (create_class->priv->xml_node,
+                                               "name");
+}
+
+/**
+ * gupnp_didl_lite_create_class_set_friendly_name:
+ * @create_class: #GUPnPDIDLLiteCreateClass
+ * @friendly_name: The friendly name
+ *
+ * Set the friendly name of the @create_class.
+ **/
+void
+gupnp_didl_lite_create_class_set_friendly_name
+                                    (GUPnPDIDLLiteCreateClass *create_class,
+                                     const char               *friendly_name)
+{
+        g_return_if_fail (create_class != NULL);
+        g_return_if_fail (GUPNP_IS_DIDL_LITE_CREATE_CLASS (create_class));
+
+        xmlSetProp (create_class->priv->xml_node,
+                    (unsigned char *) "name",
+                    (const unsigned char *) friendly_name);
+
+        g_object_notify (G_OBJECT (create_class), "friendly-name");
+}
+
+/**
+ * gupnp_didl_lite_create_class_new_from_xml:
+ * @xml_node: The pointer to relevant node in XML document
+ * @xml_doc: The reference to containing XML document
+ *
+ * Creates a new #GUPnPDIDLLiteCreateClass for the @xml_node.
+ *
+ * Returns: (transfer full): A new #GUPnPDIDLLiteCreateClass object. Unref after usage.
+ **/
+GUPnPDIDLLiteCreateClass *
+gupnp_didl_lite_create_class_new_from_xml (xmlNode     *xml_node,
+                                           GUPnPXMLDoc *xml_doc)
+{
+        GUPnPDIDLLiteCreateClass *create_class;
+
+        return g_object_new (GUPNP_TYPE_DIDL_LITE_CREATE_CLASS,
+                             "xml-node", xml_node,
+                             "xml-doc", xml_doc,
+                             NULL);
+
+        return create_class;
+}
+
+/**
+ * gupnp_didl_lite_create_class_get_xml_node:
+ * @create_class: The #GUPnPDIDLLiteCreateClass
+ *
+ * Get the pointer to relevant node in XML document.
+ *
+ * Returns: (transfer none): The pointer to relevant node in XML document.
+ **/
+xmlNode *
+gupnp_didl_lite_create_class_get_xml_node
+                                      (GUPnPDIDLLiteCreateClass *create_class)
+{
+        g_return_val_if_fail (GUPNP_IS_DIDL_LITE_CREATE_CLASS (create_class),
+                              NULL);
+
+        return create_class->priv->xml_node;
+}
diff --git a/libgupnp-av/gupnp-didl-lite-createclass.h b/libgupnp-av/gupnp-didl-lite-createclass.h
new file mode 100644
index 0000000..7df5935
--- /dev/null
+++ b/libgupnp-av/gupnp-didl-lite-createclass.h
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2012 Intel Corporation.
+ * Copyright (C) 2009 Nokia Corporation.
+ *
+ * Author: Christophe Guiraud <christophe guiraud intel com>
+ * Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
+ *                               <zeeshan ali nokia com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GUPNP_DIDL_LITE_CREATE_CLASS_H__
+#define __GUPNP_DIDL_LITE_CREATE_CLASS_H__
+
+#include <glib-object.h>
+#include <libxml/tree.h>
+#include "gupnp-didl-lite-container.h"
+
+G_BEGIN_DECLS
+
+GType
+gupnp_didl_lite_create_class_get_type (void) G_GNUC_CONST;
+
+#define GUPNP_TYPE_DIDL_LITE_CREATE_CLASS \
+                (gupnp_didl_lite_create_class_get_type ())
+#define GUPNP_DIDL_LITE_CREATE_CLASS(obj) \
+                (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+                 GUPNP_TYPE_DIDL_LITE_CREATE_CLASS, \
+                 GUPnPDIDLLiteCreateClass))
+#define GUPNP_DIDL_LITE_CREATE_CLASS_CLASS(obj) \
+                (G_TYPE_CHECK_CLASS_CAST ((obj), \
+                 GUPNP_TYPE_DIDL_LITE_CREATE_CLASS, \
+                 GUPnPDIDLLiteCreateClassClass))
+#define GUPNP_IS_DIDL_LITE_CREATE_CLASS(obj) \
+                (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+                 GUPNP_TYPE_DIDL_LITE_CREATE_CLASS))
+#define GUPNP_IS_DIDL_LITE_CREATE_CLASS_CLASS(obj) \
+                (G_TYPE_CHECK_CLASS_TYPE ((obj), \
+                 GUPNP_TYPE_DIDL_LITE_CREATE_CLASS))
+#define GUPNP_DIDL_LITE_CREATE_CLASS_GET_CLASS(obj) \
+                (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+                 GUPNP_TYPE_DIDL_LITE_CREATE_CLASS, \
+                 GUPnPDIDLLiteCreateClassClass))
+
+typedef struct _GUPnPDIDLLiteCreateClassPrivate GUPnPDIDLLiteCreateClassPrivate;
+
+typedef struct {
+        GObject parent;
+
+        GUPnPDIDLLiteCreateClassPrivate *priv;
+} GUPnPDIDLLiteCreateClass;
+
+typedef struct {
+        GObjectClass parent_class;
+
+        /* future padding */
+        void (* _gupnp_reserved1) (void);
+        void (* _gupnp_reserved2) (void);
+        void (* _gupnp_reserved3) (void);
+        void (* _gupnp_reserved4) (void);
+} GUPnPDIDLLiteCreateClassClass;
+
+const char *
+gupnp_didl_lite_create_class_get_content
+                                    (GUPnPDIDLLiteCreateClass *create_class);
+
+void
+gupnp_didl_lite_create_class_set_content
+                                    (GUPnPDIDLLiteCreateClass *create_class,
+                                     const char               *content);
+
+gboolean
+gupnp_didl_lite_create_class_get_include_derived
+                                    (GUPnPDIDLLiteCreateClass *create_class);
+
+void
+gupnp_didl_lite_create_class_set_include_derived
+                                    (GUPnPDIDLLiteCreateClass *create_class,
+                                     gboolean                 include_derived);
+
+const char *
+gupnp_didl_lite_create_class_get_friendly_name
+                                    (GUPnPDIDLLiteCreateClass *create_class);
+
+void
+gupnp_didl_lite_create_class_set_friendly_name
+                                    (GUPnPDIDLLiteCreateClass *create_class,
+                                     const char               *friendly_name);
+
+xmlNode *
+gupnp_didl_lite_create_class_get_xml_node
+                                    (GUPnPDIDLLiteCreateClass *create_class);
+
+G_END_DECLS
+
+#endif /* __GUPNP_DIDL_LITE_CREATE_CLASS_H__ */
diff --git a/libgupnp-av/gupnp-didl-lite-object.c b/libgupnp-av/gupnp-didl-lite-object.c
index aa6b150..47c2476 100644
--- a/libgupnp-av/gupnp-didl-lite-object.c
+++ b/libgupnp-av/gupnp-didl-lite-object.c
@@ -2097,4 +2097,3 @@ gupnp_didl_lite_object_add_descriptor (GUPnPDIDLLiteObject *object)
         return gupnp_didl_lite_descriptor_new_from_xml (desc_node,
                                                         object->priv->xml_doc);
 }
-



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