RSSyl: Allow giving custom CA cert file to libfeed
[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         gchar *cacert_file;
62
63         GSList *items;
64 };
65
66 struct _FeedParserCtx {
67         XML_Parser parser;
68         guint depth;
69         guint location;
70         GString *str;
71         gchar *name;
72         gchar *mail;
73         gboolean id_is_permalink;
74
75         Feed *feed;
76         FeedItem *curitem;
77 };
78
79 typedef enum {
80         FEED_ERR_NOFEED,
81         FEED_ERR_NOURL,
82         FEED_ERR_INIT,
83         FEED_ERR_FETCH,
84         FEED_ERR_UNAUTH
85 } FeedErrCodes;
86
87 /* ---------------- Prototypes */
88
89 Feed *feed_new(gchar *url);
90 void feed_free(Feed *feed);
91
92 void feed_free_items(Feed *feed);
93
94 void feed_set_timeout(Feed *feed, guint timeout);
95 guint feed_get_timeout(Feed *feed);
96
97 void feed_set_url(Feed *feed, gchar *url);
98 gchar *feed_get_url(Feed *feed);
99
100 void feed_set_auth(Feed *feed, FeedAuth *auth);
101 FeedAuth *feed_get_auth(Feed *feed);
102
103 gchar *feed_get_title(Feed *feed);
104 void feed_set_title(Feed *feed, gchar *new_title);
105
106 gchar *feed_get_description(Feed *feed);
107 gchar *feed_get_language(Feed *feed);
108 gchar *feed_get_author(Feed *feed);
109 gchar *feed_get_generator(Feed *feed);
110 gchar *feed_get_link(Feed *feed);
111 gchar *feed_get_fetcherror(Feed *feed);
112
113 gchar *feed_get_cookies_path(Feed *feed);
114 void feed_set_cookies_path(Feed *feed, gchar *path);
115
116 gboolean feed_get_ssl_verify_peer(Feed *feed);
117 void feed_set_ssl_verify_peer(Feed *feed, gboolean ssl_verify_peer);
118
119 gchar *feed_get_cacert_file(Feed *feed);
120 void feed_set_cacert_file(Feed *feed, gchar *path);
121
122 gint feed_n_items(Feed *feed);
123 FeedItem *feed_nth_item(Feed *feed, guint n);
124
125 void feed_foreach_item(Feed *feed, GFunc func, gpointer data);
126
127 gboolean feed_prepend_item(Feed *feed, FeedItem *item);
128 gboolean feed_append_item(Feed *feed, FeedItem *item);
129 gboolean feed_insert_item(Feed *feed, FeedItem *item, gint pos);
130
131 guint feed_update(Feed *feed, time_t last_update);
132
133 #define FILL(n)         do { g_free(n); n = g_strdup(text); } while(0);
134
135 #include "feeditem.h"
136
137 #endif /* __FEED_H */