[gupnp-av] Add child item on container in DIDLWriter



commit 71e46f7db6e1906a4fbfcaaf30f69d40d6abaf45
Author: Jens Georg <mail jensge org>
Date:   Tue Oct 30 19:41:53 2012 +0100

    Add child item on container in DIDLWriter

 libgupnp-av/Makefile.am                      |    1 +
 libgupnp-av/gupnp-didl-lite-writer-private.h |   37 +++++++++++++++++++++++
 libgupnp-av/gupnp-didl-lite-writer.c         |   41 ++++++++++++++++++++++++++
 3 files changed, 79 insertions(+), 0 deletions(-)
---
diff --git a/libgupnp-av/Makefile.am b/libgupnp-av/Makefile.am
index 8c5ea5c..3699367 100644
--- a/libgupnp-av/Makefile.am
+++ b/libgupnp-av/Makefile.am
@@ -61,6 +61,7 @@ libgupnp_av_1_0_la_SOURCES = gupnp-didl-lite-object.c \
 			     gupnp-didl-lite-contributor.c \
 			     gupnp-didl-lite-contributor-private.h \
 			     gupnp-didl-lite-writer.c \
+			     gupnp-didl-lite-writer-private.h \
 			     gupnp-protocol-info.c \
 			     gupnp-search-criteria-parser.c \
 			     gupnp-last-change-parser.c \
diff --git a/libgupnp-av/gupnp-didl-lite-writer-private.h b/libgupnp-av/gupnp-didl-lite-writer-private.h
new file mode 100644
index 0000000..f7008c9
--- /dev/null
+++ b/libgupnp-av/gupnp-didl-lite-writer-private.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * Authors: Jens Georg <jensg openismus 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_WRITER_PRIVATE_H__
+#define __GUPNP_DIDL_LITE_WRITER_PRIVATE_H__
+
+#include "gupnp-didl-lite-writer.h"
+#include "gupnp-didl-lite-container.h"
+
+G_BEGIN_DECLS
+
+G_GNUC_INTERNAL GUPnPDIDLLiteItem *
+gupnp_didl_lite_writer_add_container_child_item
+                                        (GUPnPDIDLLiteWriter    *writer,
+                                         GUPnPDIDLLiteContainer *container);
+
+G_END_DECLS
+
+#endif /* __GUPNP_DIDL_LITE_WRITER_PRIVATE_H__ */
diff --git a/libgupnp-av/gupnp-didl-lite-writer.c b/libgupnp-av/gupnp-didl-lite-writer.c
index ca11a70..bd6ac84 100644
--- a/libgupnp-av/gupnp-didl-lite-writer.c
+++ b/libgupnp-av/gupnp-didl-lite-writer.c
@@ -1,7 +1,9 @@
 /*
  * Copyright (C) 2007, 2008 OpenedHand Ltd.
+ * Copyright (C) 2012 Intel Corporation.
  *
  * Authors: Jorn Baayen <jorn openedhand com>
+ *          Jens Georg <jensg openismus com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -32,6 +34,7 @@
 #include "gupnp-didl-lite-object.h"
 #include "gupnp-didl-lite-object-private.h"
 #include "gupnp-didl-lite-descriptor-private.h"
+#include "gupnp-didl-lite-writer-private.h"
 
 #include "xml-util.h"
 
@@ -491,6 +494,44 @@ gupnp_didl_lite_writer_add_item (GUPnPDIDLLiteWriter *writer)
 }
 
 /**
+ * gupnp_didl_lite_writer_add_container_child_item:
+ * @writer: #GUPnPDIDLLiteWriter
+ * @container: #GUPnPDIDLLiteContainer
+ *
+ * Add a child item to a container. This is only useful in DIDL_S playlist
+ * creation.
+ *
+ * Returns: (transfer full): A new #GUPnPDIDLLiteItem object. Unref after
+ * usage.
+ **/
+GUPnPDIDLLiteItem *
+gupnp_didl_lite_writer_add_container_child_item
+                                        (GUPnPDIDLLiteWriter    *writer,
+                                         GUPnPDIDLLiteContainer *container)
+{
+        xmlNode *item_node, *container_node;
+        GUPnPDIDLLiteObject *object;
+        GUPnPXMLDoc *doc;
+
+        g_return_val_if_fail (GUPNP_IS_DIDL_LITE_CONTAINER (container), NULL);
+
+        object = GUPNP_DIDL_LITE_OBJECT (container);
+        container_node = gupnp_didl_lite_object_get_xml_node (object);
+
+        item_node = xmlNewChild (container_node,
+                                 NULL,
+                                 (xmlChar *) "item",
+                                 NULL);
+
+        object = gupnp_didl_lite_object_new_from_xml (item_node,
+                                                      writer->priv->xml_doc,
+                                                      writer->priv->upnp_ns,
+                                                      writer->priv->dc_ns,
+                                                      writer->priv->dlna_ns);
+        return GUPNP_DIDL_LITE_ITEM (object);
+}
+
+/**
  * gupnp_didl_lite_writer_add_container:
  * @writer: A #GUPnPDIDLLiteWriter
  *



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