RSSClient: Add the location header provided URL to the error message, if we fail...
[citadel.git] / citadel / modules / rssclient / rss_atom_parser.h
1 /*
2  * Bring external RSS feeds into rooms.
3  *
4  * Copyright (c) 2007-2012 by the citadel.org team
5  *
6  * This program is open source software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 3.
8  * 
9  * 
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  * 
17  * 
18  * 
19  */
20
21 #include "internet_addressing.h"
22
23 #define RSS_UNSET       (1<<0)
24 #define RSS_RSS         (1<<1)
25 #define RSS_ATOM        (1<<2)
26 #define RSS_REQUIRE_BUF (1<<3)
27
28 typedef struct rss_aggregator rss_aggregator;
29 typedef struct rss_item rss_item;
30 typedef struct rss_room_counter rss_room_counter;
31
32 typedef void (*rss_handler_func)(StrBuf *CData, 
33                                  rss_item *ri, 
34                                  rss_aggregator *Cfg, 
35                                  const char** Attr);
36
37
38 typedef struct __rss_xml_handler {
39         int              Flags;
40         rss_handler_func Handler;
41 }rss_xml_handler;
42
43 struct rss_item {
44         int     done_parsing;
45         int     item_tag_nesting;
46         time_t  pubdate;
47         StrBuf *guid;
48         StrBuf *title;
49         StrBuf *link;
50         StrBuf *linkTitle;
51         StrBuf *reLink;
52         StrBuf *reLinkTitle;
53         StrBuf *description;
54         StrBuf *channel_title;
55         StrBuf *author_or_creator;
56         StrBuf *author_url;
57         StrBuf *author_email;
58 };
59 void flush_rss_item(rss_item *ri);
60
61 struct rss_room_counter {
62         int count;
63         long QRnumber;
64 };
65
66 typedef struct __networker_save_message {
67         struct CtdlMessage Msg;
68         StrBuf *MsgGUID;
69         StrBuf *Message;
70
71         StrBuf *author_email;
72         StrBuf *author_or_creator;
73         StrBuf *title;
74         StrBuf *description;
75
76         StrBuf *link;
77         StrBuf *linkTitle;
78
79         StrBuf *reLink;
80         StrBuf *reLinkTitle;
81 } networker_save_message;
82
83 typedef struct RSSCfgLine RSSCfgLine;
84 struct RSSCfgLine {
85         RSSCfgLine *next;
86         StrBuf *Url;
87         time_t last_known_good;
88 };
89
90 typedef struct __pRSSConfig {
91         const RSSCfgLine *pCfg;
92         long             QRnumber;
93 }pRSSConfig;
94
95 struct rss_aggregator {
96         AsyncIO          IO;
97         XML_Parser       xp;
98
99         int              ItemType;
100         int              roomlist_parts;
101
102         time_t           last_error_when;
103         time_t           next_poll;
104         StrBuf          *Url;
105         StrBuf          *RedirectUrl;
106         StrBuf          *rooms;
107         pRSSConfig       Cfg;
108         HashList        *OtherQRnumbers;
109                         
110         StrBuf          *CData;
111         StrBuf          *Key;
112
113         rss_item        *Item;
114         recptypes        recp;
115         HashPos         *Pos;
116         HashList        *Messages;
117         networker_save_message *ThisMsg;
118 };
119
120
121
122 eNextState RSSAggregator_ParseReply(AsyncIO *IO);
123
124 eNextState RSS_FetchNetworkUsetableEntry(AsyncIO *IO);