Straightn http client generation
[citadel.git] / citadel / modules / rssclient / rss_atom_parser.h
1 /*
2  * Bring external RSS feeds into rooms.
3  *
4  * Copyright (c) 2007-2010 by the citadel.org team
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21
22 #define RSS_UNSET       (1<<0)
23 #define RSS_RSS         (1<<1)
24 #define RSS_ATOM        (1<<2)
25 #define RSS_REQUIRE_BUF (1<<3)
26
27 typedef struct rss_aggregator rss_aggregator;
28 typedef struct rss_item rss_item;
29 typedef struct rss_room_counter rss_room_counter;
30
31 typedef void (*rss_handler_func)(StrBuf *CData, 
32                                  rss_item *ri, 
33                                  rss_aggregator *Cfg, 
34                                  const char** Attr);
35
36
37 typedef struct __rss_xml_handler {
38         int              Flags;
39         rss_handler_func Handler;
40 }rss_xml_handler;
41
42 struct rss_item {
43         int     done_parsing;
44         int     item_tag_nesting;
45         time_t  pubdate;
46         StrBuf *guid;
47         StrBuf *title;
48         StrBuf *link;
49         StrBuf *linkTitle;
50         StrBuf *reLink;
51         StrBuf *reLinkTitle;
52         StrBuf *description;
53         StrBuf *channel_title;
54         StrBuf *author_or_creator;
55         StrBuf *author_url;
56         StrBuf *author_email;
57 };
58
59 struct rss_room_counter {
60         int count;
61         long QRnumber;
62 };
63
64 typedef struct __networker_save_message {
65         struct CtdlMessage Msg;
66         StrBuf *MsgGUID;
67         StrBuf *Message;
68         struct UseTable ut;
69 } networker_save_message;
70
71 struct rss_aggregator {
72         AsyncIO          IO;
73         XML_Parser       xp;
74
75         int              ItemType;
76         int              roomlist_parts;
77
78         time_t           last_error_when;
79         time_t           next_poll;
80         StrBuf          *Url;
81         StrBuf          *rooms;
82         long             QRnumber;
83         HashList        *OtherQRnumbers;
84                         
85         StrBuf          *CData;
86         StrBuf          *Key;
87
88         rss_item        *Item;
89         struct recptypes recp;
90         HashPos         *Pos;
91         HashList        *Messages;
92         networker_save_message *ThisMsg;
93         const rss_xml_handler *Current;
94 };
95
96
97
98 eNextState RSSAggregator_ParseReply(AsyncIO *IO);
99
100 void rss_save_item(rss_item *ri, rss_aggregator *Cfg);
101
102 eNextState RSS_FetchNetworkUsetableEntry(AsyncIO *IO);