blob: 09ce09a6584da3e5e07becdb35859cfb42848e86 (
plain)
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
|
#pragma once
#include <string>
#include <vector>
#include <memory>
namespace QuickMedia {
class BodyItem {
public:
BodyItem(const std::string &_title): title(_title), visible(true) {
}
std::string title;
std::string url;
std::string thumbnail_url;
bool visible;
};
enum class SearchResult {
OK,
ERR,
NET_ERR
};
enum class SuggestionResult {
OK,
ERR,
NET_ERR
};
enum class DownloadResult {
OK,
ERR,
NET_ERR
};
struct CommandArg {
std::string option;
std::string value;
};
class Plugin {
public:
virtual ~Plugin() = default;
virtual SearchResult search(const std::string &text, std::vector<std::unique_ptr<BodyItem>> &result_items) = 0;
virtual SuggestionResult update_search_suggestions(const std::string &text, std::vector<std::unique_ptr<BodyItem>> &result_items);
virtual std::vector<std::unique_ptr<BodyItem>> get_related_media(const std::string &url);
protected:
DownloadResult download_to_string(const std::string &url, std::string &result, const std::vector<CommandArg> &additional_args = {});
std::string url_param_encode(const std::string ¶m) const;
};
}
|