/*   Cataract - Static web photo gallery generator
 *   Copyright (C) 2010 Tomas Bzatek <tbzatek@users.sourceforge.net>
 *
 *   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 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 __CGG__ATOM_WRITER_H__
#define __CGG__ATOM_WRITER_H__

#include <glib.h>
#include "setup.h"

G_BEGIN_DECLS


/*
 *  Resources:
 *     http://tools.ietf.org/html/rfc4287
 *     http://www.atomenabled.org/developers/syndication/
 *     http://feedvalidator.org/
 *     http://diveintomark.org/archives/2004/05/28/howto-atom-id
 *
 */


typedef struct {
  gchar *title;
  gchar *base_url;
  gchar *feed_url;

  GSList *items;
} TAtomFeed;

typedef struct {
  gchar *title;
  gchar *path;           /*  relative path in the gallery structure  */
  gchar *date;           /*  format ISO.8601.1988 yyyy-mm-ddThh:mm:ssZ or yyyy-mm-ddThh:mm:ss+hh:mm (timezone)  */
  gchar *summary;        /*  escaped automatically  */
  gchar *summary_type;   /*  valid values are "text", "html", "xhtml"  */
} TAtomFeedItem;


/*  Global instances  */
TAtomFeed *news_feed;


TAtomFeed *      atom_writer_new ();
void             atom_writer_write_to_file (TAtomFeed *feed, const gchar *filename, TGallerySetup *setup);
void             atom_writer_set_title     (TAtomFeed *feed, const gchar *title);
void             atom_writer_set_base_url  (TAtomFeed *feed, const gchar *base_url);
void             atom_writer_set_feed_url  (TAtomFeed *feed, const gchar *feed_url);
void             atom_writer_free          (TAtomFeed *feed);    /*  will free data of all items  */

TAtomFeedItem *  atom_writer_add_item      (TAtomFeed *feed);
void             atom_feed_item_set_title        (TAtomFeedItem *item, const gchar *title);
void             atom_feed_item_set_path         (TAtomFeedItem *item, const gchar *path);
void             atom_feed_item_set_date         (TAtomFeedItem *item, const gchar *date);
void             atom_feed_item_set_summary      (TAtomFeedItem *item, const gchar *summary);
void             atom_feed_item_set_summary_type (TAtomFeedItem *item, const gchar *summary_type);


G_END_DECLS

#endif /* __CGG__ATOM_WRITER_H__ */
