AtomID *id;
char *title;
GPtrArray *authors;
+ GPtrArray *categories;
char *summary;
};
void atom_entry_author_add (AtomEntry *, AtomPerson *);
static void atom_entry_authors_delete (AtomEntry *);
+void atom_entry_category_add (AtomEntry *, AtomCategory *);
+static void atom_entry_categories_delete (AtomEntry *);
+
AtomEntry *
atom_entry_new (char *title, AtomPerson *author)
{
entry->id = NULL;
entry->title = g_strdup (title);
entry->authors = NULL;
+ entry->categories = NULL;
atom_entry_author_add (entry, author);
entry->summary = NULL;
return entry;
entry->summary = g_strdup (content);
else if (!xmlStrcmp (child->name, "author"))
atom_entry_author_add (entry, atom_person_new_from_xmlnode (child));
+ else if (!xmlStrcmp (child->name, "category"))
+ atom_entry_category_add (entry, atom_category_new_from_xmlnode (child));
else
xmlFree (content);
}
g_free (entry->title);
if (entry->authors)
atom_entry_authors_delete (entry);
+ if (entry->categories)
+ atom_entry_categories_delete (entry);
if (entry->summary)
g_free (entry->summary);
g_slice_free (AtomEntry, entry);
g_ptr_array_free (entry->authors, TRUE);
}
+void
+atom_entry_categories (AtomEntry *entry, AtomCategory *** categories,
+ size_t *len)
+{
+ if (len)
+ *len = entry->categories->len;
+ if (categories)
+ *categories = entry->categories->pdata;
+}
+
+void
+atom_entry_category_add (AtomEntry *entry, AtomCategory *category)
+{
+ g_ptr_array_add (entry->categories, category);
+ if (entry->categories == NULL)
+ {
+ entry->categories = g_ptr_array_new ();
+ }
+ g_ptr_array_add (entry->categories, category);
+}
+
+static void
+atom_entry_categories_delete (AtomEntry *entry)
+{
+ size_t len = entry->categories->len;
+ int i;
+ for (i = 0; i < len; i++)
+ atom_category_delete (g_ptr_array_index (entry->categories, i));
+ g_ptr_array_free (entry->categories, TRUE);
+}
+
char *
atom_entry_summary (AtomEntry *entry)
{
xmlNodePtr title;
xmlNodePtr summary;
xmlNodePtr author;
+ xmlNodePtr cat;
int i;
if (entry->doc == NULL)
{
if (!xmlStrcmp (child->name, "id") ||
!xmlStrcmp (child->name, "title") ||
!xmlStrcmp (child->name, "summary") ||
- !xmlStrcmp (child->name, "author"))
+ !xmlStrcmp (child->name, "author") ||
+ !xmlStrcmp (child->name, "category"))
{
xmlUnlinkNode (child);
xmlFreeNode (child);
author = atom_person_to_xmlnode (person, "author");
xmlAddChild (root, author);
}
+ for (i = 0; entry->categories && i < entry->categories->len; i++)
+ {
+ AtomCategory *category;
+ category = g_ptr_array_index (entry->categories, i);
+ cat = atom_category_to_xmlnode (category, "category");
+ xmlAddChild (root, category);
+ }
}
void
#include <sys/types.h>
#include <atompub/person.h>
+#include <atompub/category.h>
#include <atompub/id.h>
typedef struct _atom_entry AtomEntry;
void atom_entry_title_set (AtomEntry *, char *);
void atom_entry_authors (AtomEntry *, AtomPerson ***, size_t *);
void atom_entry_author_add (AtomEntry *, AtomPerson *);
+void atom_entry_categories (AtomEntry *, AtomCategory ***, size_t *);
+void atom_entry_category_add (AtomEntry *, AtomCategory *);
char * atom_entry_summary (AtomEntry *);
void atom_entry_summary_set (AtomEntry *, char *);
void atom_entry_string (AtomEntry *, char **, size_t *);