lib_LTLIBRARIES = libatom.la
libatom_la_SOURCES = id.c entry.c person.c category.c feed.c \
config.c ctx.c backend.c error.c frontend.c request.c \
- core.c
+ core.c content.c
libatom_la_CFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS)
libatom_la_CFLAGS += $(XML_CFLAGS) $(GIO_CFLAGS) $(SOUP_CFLAGS)
libatom_la_LIBADD = $(GIO_LIBS) $(GLIB_LIBS) $(XML_LIBS) $(SOUP_LIBS)
--- /dev/null
+/*
+ * Copyright (C) 2009 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+#include <atompub/content.h>
+#include <atompub/content-xml.h>
+
+#include <glib.h>
+#include <libxml/tree.h>
+#include <string.h>
+
+struct _atom_content
+{
+ char *type;
+ char *src;
+ char *content;
+ size_t content_len;
+ xmlNodePtr xmlcontent;
+};
+
+AtomContent *
+atom_content_new (char *type, char *buffer, size_t len)
+{
+ AtomContent *content;
+ content = g_slice_new0 (AtomContent);
+ content->type = g_strdup (type);
+ content->content = g_malloc (len);
+ memcpy (content->content, buffer, len);
+ content->content_len = len;
+ return content;
+}
+
+AtomContent *
+atom_content_new_src (char *type, char *src)
+{
+ AtomContent *content;
+ content = g_slice_new0 (AtomContent);
+ content->type = g_strdup (type);
+ content->src = g_strdup (src);
+ return content;
+}
+
+AtomContent *
+atom_content_new_data_len (char *buffer, size_t len)
+{
+ /* TODO: Here we decode the XML to find content type, possible
+ source and data */
+ return NULL;
+}
+
+void
+atom_content_delete (AtomContent *content)
+{
+ if (content->type)
+ g_free (content->type);
+ if (content->src)
+ g_free (content->src);
+ if (content->content)
+ g_free (content->content);
+ if (content->xmlcontent)
+ xmlFreeNode (content->xmlcontent);
+ g_slice_free (AtomContent, content);
+}
+
+char *
+atom_content_type (AtomContent *content)
+{
+ return content->type;
+}
+
+void
+atom_content_type_set (AtomContent *content, char *type)
+{
+ if (content->type)
+ g_free (content->type);
+ content->type = g_strdup (type);
+}
+
+char *
+atom_content_src (AtomContent *content)
+{
+ return content->src;
+}
+
+void
+atom_content_src_set (AtomContent *content, char *src)
+{
+ if (content->src)
+ g_free (content->src);
+ content->src = g_strdup (src);
+}
+
+void
+atom_content_content (AtomContent *content, char **buffer, size_t *len)
+{
+ /* TODO: Copy the content or allocated the buffer? */
+}
+
+void
+atom_content_content_set (AtomContent *content, char *buffer, size_t len)
+{
+ if (content->content)
+ g_free (content->content);
+ content->content = g_malloc (len);
+ memcpy (content->content, buffer, len);
+}
+
+void
+atom_content_string (AtomContent *content, char **buffer, size_t *len)
+{
+ /* TODO: convert everything into a string, like
+ "<content type="html"><br></content>" */
+}
+
+AtomContent *
+atom_content_new_xmlnode (char *type, xmlNodePtr node)
+{
+ AtomContent *content;
+ content = g_slice_new0 (AtomContent);
+ content->type = g_strdup (type);
+ content->xmlcontent = xmlCopyNodeList (node);
+ return content;
+}
+
+xmlNodePtr
+atom_content_to_xmlnode (AtomContent *content)
+{
+ /* TODO: Convert everything into a xmlnode */
+ return NULL;
+}
+
+xmlNodePtr
+atom_content_content_xmlnode (AtomContent *content)
+{
+ return content->xmlcontent;
+}
+
+void
+atom_content_content_set_xmlnode (AtomContent *content, xmlNodePtr node)
+{
+ if (content->xmlcontent)
+ xmlFreeNode (content->xmlcontent);
+ content->xmlcontent = xmlCopyNodeList (node);
+}
id.h iri.h backend.h atom-glib.h error-glib.h atom-xml.h \
entry-xml.h person-xml.h feed-xml.h globals.h \
map.h frontend.h request.h core.h category.h \
- category-xml.h
+ category-xml.h content.h content-xml.h
#include <atompub/person-xml.h>
#include <atompub/category-xml.h>
+#include <atompub/content-xml.h>
#include <atompub/entry-xml.h>
#include <atompub/feed-xml.h>
#include <atompub/error.h>
#include <atompub/iri.h>
#include <atompub/id.h>
+#include <atompub/content.h>
#include <atompub/entry.h>
#include <atompub/person.h>
#include <atompub/category.h>
--- /dev/null
+/*
+ * Copyright (C) 2009 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+#ifndef ATOMPUB_CONTENT_XML_H
+#define ATOMPUB_CONTENT_XML_H
+
+#include <atompub/content.h>
+
+#include <libxml/tree.h>
+
+AtomContent * atom_content_new_xmlnode (char *, xmlNodePtr);
+xmlNodePtr atom_content_to_xmlnode (AtomContent *);
+xmlNodePtr atom_content_content_to_xmlnode (AtomContent *);
+void atom_content_content_set_xmlnode (AtomContent *, xmlNodePtr);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 2009 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+#ifndef ATOMPUB_CONTENT_H
+#define ATOMPUB_CONTENT_H
+
+#include <sys/types.h>
+
+typedef struct _atom_content AtomContent;
+
+AtomContent * atom_content_new (char *, char *, size_t);
+AtomContent * atom_content_new_src (char *, char *);
+AtomContent * atom_content_new_data_len (char *, size_t);
+void atom_content_delete (AtomContent *);
+char * atom_content_type (AtomContent *);
+void atom_content_type_set (AtomContent *, char *);
+char * atom_content_src (AtomContent *);
+void atom_content_src_set (AtomContent *, char *);
+void atom_content_content (AtomContent *, char **, size_t *);
+void atom_content_content_set (AtomContent *, char *, size_t);
+void atom_content_string (AtomContent *, char **, size_t *);
+
+#endif