~ubuntu-branches/ubuntu/maverick/newsbeuter/maverick

« back to all changes in this revision

Viewing changes to include/rss.h

  • Committer: Bazaar Package Importer
  • Author(s): Nico Golde
  • Date: 2007-04-21 19:44:35 UTC
  • Revision ID: james.westby@ubuntu.com-20070421194435-21g6134ws2yvarlt
Tags: upstream-0.3
ImportĀ upstreamĀ versionĀ 0.3

Show diffs side-by-side

added added

removed removed

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