This repository has been archived by the owner on Oct 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 100
/
rss.h
140 lines (104 loc) · 3.56 KB
/
rss.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#ifndef NEWSBEUTER_RSS__H
#define NEWSBEUTER_RSS__H
#include <string>
#include <vector>
#include <configcontainer.h>
extern "C" {
#include <mrss.h>
}
namespace newsbeuter {
class cache;
class rss_item {
public:
rss_item(cache * c) : unread_(true), ch(c), enqueued_(false) { }
~rss_item() { }
std::string title() const;
std::string title_raw() const { return title_; }
void set_title(const std::string& t);
inline const std::string& link() const { return link_; }
void set_link(const std::string& l);
std::string author() const;
std::string author_raw() const { return author_; }
void set_author(const std::string& a);
std::string description() const;
std::string description_raw() const { return description_; }
void set_description(const std::string& d);
std::string pubDate() const;
inline time_t pubDate_timestamp() const {
return pubDate_;
}
void set_pubDate(time_t t);
inline const std::string& guid() const { return guid_; }
void set_guid(const std::string& g);
inline bool unread() const { return unread_; }
void set_unread(bool u);
void set_unread_nowrite(bool u);
inline void set_cache(cache * c) { ch = c; }
inline void set_feedurl(const std::string& f) { feedurl_ = f; }
inline const std::string& feedurl() const { return feedurl_; }
inline const std::string& enclosure_url() const { return enclosure_url_; }
inline const std::string& enclosure_type() const { return enclosure_type_; }
void set_enclosure_url(const std::string& url);
void set_enclosure_type(const std::string& type);
inline bool enqueued() { return enqueued_; }
inline void set_enqueued(bool v) { enqueued_ = v; }
private:
std::string title_;
std::string link_;
std::string author_;
std::string description_;
time_t pubDate_;
std::string guid_;
std::string feedurl_;
bool unread_;
cache * ch;
std::string enclosure_url_;
std::string enclosure_type_;
bool enqueued_;
};
class rss_feed {
public:
rss_feed(cache * c) : ch(c) { }
~rss_feed() { }
std::string title_raw() const { return title_; }
std::string title() const;
inline void set_title(const std::string& t) { title_ = t; }
std::string description_raw() const { return description_; }
std::string description() const;
inline void set_description(const std::string& d) { description_ = d; }
inline const std::string& link() const { return link_; }
inline void set_link(const std::string& l) { link_ = l; }
inline std::string pubDate() const { return "TODO"; }
inline void set_pubDate(time_t t) { pubDate_ = t; }
inline std::vector<rss_item>& items() { return items_; }
rss_item& get_item_by_guid(const std::string& guid);
inline const std::string& rssurl() const { return rssurl_; }
inline void set_rssurl(const std::string& u) { rssurl_ = u; }
unsigned int unread_item_count() const;
void set_tags(const std::vector<std::string>& tags);
bool matches_tag(const std::string& tag);
std::string get_tags();
private:
std::string title_;
std::string description_;
std::string link_;
time_t pubDate_;
std::string rssurl_;
std::vector<rss_item> items_;
std::vector<std::string> tags_;
cache * ch;
};
class rss_parser {
public:
rss_parser(const char * uri, cache * c, configcontainer *);
~rss_parser();
rss_feed parse();
static time_t parse_date(const std::string& datestr);
private:
std::string my_uri;
cache * ch;
configcontainer *cfgcont;
mrss_t * mrss;
};
}
#endif