File: remoteapi.h

package info (click to toggle)
newsboat 2.36-1.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,348 kB
  • sloc: cpp: 88,615; xml: 525; sh: 437; makefile: 351; ruby: 258; python: 239; ansic: 210; php: 63; awk: 59; perl: 38
file content (50 lines) | stat: -rw-r--r-- 1,428 bytes parent folder | download | duplicates (2)
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
#ifndef NEWSBOAT_REMOTEAPI_H_
#define NEWSBOAT_REMOTEAPI_H_

#include <curl/curl.h>
#include <functional>
#include <string>
#include <utility>
#include <vector>

namespace newsboat {

class ConfigContainer;

typedef std::pair<std::string, std::vector<std::string>> TaggedFeedUrl;

typedef struct {
	std::string user;
	std::string pass;
	std::string token;
} Credentials;

class RemoteApi {
public:
	explicit RemoteApi(ConfigContainer& c);
	virtual ~RemoteApi() = default;
	virtual bool authenticate() = 0;
	virtual std::vector<TaggedFeedUrl> get_subscribed_urls() = 0;
	virtual void add_custom_headers(curl_slist** custom_headers) = 0;
	virtual bool mark_all_read(const std::string& feedurl) = 0;
	virtual bool mark_article_read(const std::string& guid, bool read) = 0;
	virtual bool mark_articles_read(const std::vector<std::string>& guids);
	virtual bool update_article_flags(const std::string& oldflags,
		const std::string& newflags,
		const std::string& guid) = 0;
	static const std::string read_password(const std::string& file);
	static const std::string eval_password(const std::string& cmd);

protected:
	static void update_flag(const std::string& oldflags,
		const std::string& newflags,
		char flag, std::function<void(bool added)>&& do_update);

	ConfigContainer& cfg;
	Credentials get_credentials(const std::string& scope,
		const std::string& name);
};

} // namespace newsboat

#endif /* NEWSBOAT_REMOTEAPI_H_ */