RSSyl: use procheader_date_parse() instead of parseRFC822Date().
[claws.git] / src / plugins / rssyl / libfeed / feed.h
1 /*
2  * Copyright (C) 2006 Andrej Kacian <andrej@kacian.sk>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public
15  * License along with this program; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #ifndef __FEED_H
21 #define __FEED_H
22
23 #include <glib.h>
24 #include <expat.h>
25
26 #define FEED_DEFAULT_TIMEOUT    20      /* In seconds */
27
28 /* ---------------- Structures */
29
30 typedef struct _Feed Feed;
31 typedef struct _FeedItem FeedItem;
32 typedef struct _FeedParserCtx FeedParserCtx;
33 typedef struct _FeedAuth FeedAuth;
34
35 typedef enum {
36         FEED_AUTH_NONE,
37         FEED_AUTH_BASIC
38 } FeedAuthType;
39
40 struct _FeedAuth {
41         FeedAuthType type;
42         gchar *username;
43         gchar *password;
44 };
45         
46 struct _Feed {
47         gchar *url;
48         FeedAuth *auth;
49         gchar *title;
50         gchar *description;
51         gchar *language;
52         gchar *author;
53         gchar *generator;
54         gchar *link;
55         time_t date;
56
57         guint timeout;
58         gchar *fetcherr;
59         gchar *cookies_path;
60         gboolean ssl_verify_peer;
61
62         GSList *items;
63 };
64
65 struct _FeedParserCtx {
66         XML_Parser parser;
67         guint depth;
68         guint location;
69         GString *str;
70         gchar *name;
71         gchar *mail;
72         gboolean id_is_permalink;
73
74         Feed *feed;
75         FeedItem *curitem;
76 };
77
78 typedef enum {
79         FEED_ERR_NOFEED,
80         FEED_ERR_NOURL,
81         FEED_ERR_INIT,
82         FEED_ERR_FETCH,
83         FEED_ERR_UNAUTH
84 } FeedErrCodes;
85
86 /* ---------------- Prototypes */
87
88 Feed *feed_new(gchar *url);
89 void feed_free(Feed *feed);
90
91 void feed_free_items(Feed *feed);
92
93 void feed_set_timeout(Feed *feed, guint timeout);
94 guint feed_get_timeout(Feed *feed);
95
96 void feed_set_url(Feed *feed, gchar *url);
97 gchar *feed_get_url(Feed *feed);
98
99 void feed_set_auth(Feed *feed, FeedAuth *auth);
100 FeedAuth *feed_get_auth(Feed *feed);
101
102 gchar *feed_get_title(Feed *feed);
103 void feed_set_title(Feed *feed, gchar *new_title);
104
105 gchar *feed_get_description(Feed *feed);
106 gchar *feed_get_language(Feed *feed);
107 gchar *feed_get_author(Feed *feed);
108 gchar *feed_get_generator(Feed *feed);
109 gchar *feed_get_link(Feed *feed);
110 gchar *feed_get_fetcherror(Feed *feed);
111
112 gchar *feed_get_cookies_path(Feed *feed);
113 void feed_set_cookies_path(Feed *feed, gchar *path);
114
115 gboolean feed_get_ssl_verify_peer(Feed *feed);
116 void feed_set_ssl_verify_peer(Feed *feed, gboolean ssl_verify_peer);
117
118 gint feed_n_items(Feed *feed);
119 FeedItem *feed_nth_item(Feed *feed, guint n);
120
121 void feed_foreach_item(Feed *feed, GFunc func, gpointer data);
122
123 gboolean feed_prepend_item(Feed *feed, FeedItem *item);
124 gboolean feed_append_item(Feed *feed, FeedItem *item);
125 gboolean feed_insert_item(Feed *feed, FeedItem *item, gint pos);
126
127 guint feed_update(Feed *feed, time_t last_update);
128
129 #define FILL(n)         do { g_free(n); n = g_strdup(text); } while(0);
130
131 #include "feeditem.h"
132
133 #endif /* __FEED_H */