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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
#ifndef NEWSBEUTER_CONTROLLER__H
#define NEWSBEUTER_CONTROLLER__H
#include <urlreader.h>
#include <rss.h>
#include <cache.h>
#include <configcontainer.h>
#include <filtercontainer.h>
#include <colormanager.h>
#include <regexmanager.h>
#include <remote_api.h>
#include <libxml/tree.h>
namespace newsbeuter {
extern int ctrl_c_hit;
extern std::string lock_file;
class view;
class curl_handle;
class controller {
public:
controller();
~controller();
void set_view(view * vv);
view * get_view() {
return v;
}
void run(int argc = 0, char * argv[] = NULL);
void reload(unsigned int pos, unsigned int max = 0, bool unattended = false, curl_handle *easyhandle = 0);
void reload_all(bool unattended = false);
void reload_indexes(const std::vector<int>& indexes, bool unattended = false);
void reload_range(unsigned int start, unsigned int end, unsigned int size, bool unattended = false);
void start_reload_all_thread(std::vector<int> * indexes = 0);
std::shared_ptr<rss_feed> get_feed(unsigned int pos);
std::shared_ptr<rss_feed> get_feed_by_url(const std::string& feedurl);
std::vector<std::shared_ptr<rss_item>> search_for_items(const std::string& query, const std::string& feedurl);
inline unsigned int get_feedcount() {
return feeds.size();
}
inline void unlock_reload_mutex() {
reload_mutex.unlock();
}
bool trylock_reload_mutex();
void update_feedlist();
void update_visible_feeds();
void mark_all_read(unsigned int pos);
void mark_article_read(const std::string& guid, bool read);
void record_google_replay(const std::string& guid, bool read);
void catchup_all();
inline void catchup_all(std::shared_ptr<rss_feed> feed) {
rsscache->catchup_all(feed);
}
inline bool get_refresh_on_start() const {
return refresh_on_start;
}
bool is_valid_podcast_type(const std::string& mimetype);
void enqueue_url(const std::string& url, std::shared_ptr<rss_feed> feed);
void notify(const std::string& msg);
unsigned int get_pos_of_next_unread(unsigned int pos);
void reload_urls_file();
void edit_urls_file();
std::vector<std::shared_ptr<rss_feed>> get_all_feeds();
std::vector<std::shared_ptr<rss_feed>> get_all_feeds_unlocked();
inline filtercontainer& get_filters() {
return filters;
}
std::string bookmark(const std::string& url, const std::string& title, const std::string& description);
inline cache * get_cache() {
return rsscache;
}
inline configcontainer * get_cfg() {
return &cfg;
}
void write_item(std::shared_ptr<rss_item> item, const std::string& filename);
void write_item(std::shared_ptr<rss_item> item, std::ostream& ostr);
std::string write_temporary_item(std::shared_ptr<rss_item> item);
void mark_deleted(const std::string& guid, bool b);
void update_config();
void load_configfile(const std::string& filename);
void dump_config(const std::string& filename);
void sort_feeds();
void update_flags(std::shared_ptr<rss_item> item);
unsigned int get_feed_count_per_tag(const std::string& tag);
private:
void usage(char * argv0);
bool setup_dirs_xdg(const char *env_home, bool silent);
void setup_dirs(bool silent);
void version_information(const char * argv0, unsigned int level);
void import_opml(const char * filename);
void export_opml();
void rec_find_rss_outlines(xmlNode * node, std::string tag);
void compute_unread_numbers(unsigned int&, unsigned int& );
void execute_commands(char ** argv, unsigned int i);
std::string prepare_message(unsigned int pos, unsigned int max);
void save_feed(std::shared_ptr<rss_feed> feed, unsigned int pos);
void enqueue_items(std::shared_ptr<rss_feed> feed);
std::string generate_enqueue_filename(const std::string& url, std::shared_ptr<rss_feed> feed);
std::string get_hostname_from_url(const std::string& url);
void import_read_information(const std::string& readinfofile);
void export_read_information(const std::string& readinfofile);
view * v;
urlreader * urlcfg;
cache * rsscache;
std::vector<std::shared_ptr<rss_feed>> feeds;
std::string config_dir;
std::string url_file;
std::string cache_file;
std::string config_file;
std::string queue_file;
std::string searchfile;
std::string cmdlinefile;
bool refresh_on_start;
configcontainer cfg;
rss_ignores ign;
filtercontainer filters;
std::mutex reload_mutex;
configparser cfgparser;
colormanager colorman;
regexmanager rxman;
remote_api * api;
std::mutex feeds_mutex;
bool offline_mode;
};
}
#endif
|