aboutsummaryrefslogtreecommitdiff
path: root/plugins/Manga.hpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-10-11 21:35:37 +0200
committerdec05eba <dec05eba@protonmail.com>2020-10-13 13:13:01 +0200
commit77ed51898157d99112be7550471ec06e32344c9e (patch)
tree0645274d0f13b4fa6940d4054f74a070611a8ef0 /plugins/Manga.hpp
parentda89ec98fb34757f0c46dc8cb2dd87ae78d317ce (diff)
Refactor plugin into seperate pages
TODO: Readd 4chan login page, manganelo creators page, autocomplete
Diffstat (limited to 'plugins/Manga.hpp')
-rw-r--r--plugins/Manga.hpp49
1 files changed, 38 insertions, 11 deletions
diff --git a/plugins/Manga.hpp b/plugins/Manga.hpp
index 13c494e..732e208 100644
--- a/plugins/Manga.hpp
+++ b/plugins/Manga.hpp
@@ -1,8 +1,7 @@
#pragma once
-#include "Plugin.hpp"
+#include "Page.hpp"
#include <functional>
-#include <mutex>
namespace QuickMedia {
// Return false to stop iteration
@@ -13,18 +12,46 @@ namespace QuickMedia {
std::string url;
};
- class Manga : public Plugin {
+ class MangaImagesPage : public Page {
public:
- Manga(const std::string &plugin_name) : Plugin(plugin_name) {}
- bool is_manga() override { return true; }
- virtual ImageResult get_number_of_images(const std::string &url, int &num_images) = 0;
- virtual ImageResult for_each_page_in_chapter(const std::string &chapter_url, PageCallback callback) = 0;
- virtual bool extract_id_from_url(const std::string &url, std::string &manga_id) = 0;
+ MangaImagesPage(Program *program, std::string manga_name, std::string chapter_name, std::string url) : Page(program), manga_name(std::move(manga_name)), chapter_name(std::move(chapter_name)), url(std::move(url)) {}
+ virtual ~MangaImagesPage() = default;
+ const char* get_title() const override { return chapter_name.c_str(); }
+ PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override {
+ (void)title;
+ (void)url;
+ (void)result_tabs;
+ return PluginResult::OK;
+ }
- virtual PluginResult get_creators_manga_list(const std::string &url, BodyItems &result_items) { (void)url; (void)result_items; return {}; }
+ bool is_manga_images_page() const override { return true; }
- const std::vector<Creator>& get_creators() const;
+ virtual ImageResult get_number_of_images(int &num_images) = 0;
+ virtual ImageResult for_each_page_in_chapter(PageCallback callback) = 0;
+
+ virtual void change_chapter(std::string new_chapter_name, std::string new_url) {
+ chapter_name = std::move(new_chapter_name);
+ if(url != new_url) {
+ url = std::move(new_url);
+ chapter_image_urls.clear();
+ }
+ }
+
+ const std::string& get_chapter_name() const { return chapter_name; }
+ const std::string& get_url() const { return url; }
+
+ virtual const char* get_service_name() const = 0;
+
+ const std::string manga_name;
protected:
- std::vector<Creator> creators;
+ std::string chapter_name;
+ std::string url;
+ std::vector<std::string> chapter_image_urls;
+ };
+
+ class MangaChaptersPage : public TrackablePage {
+ public:
+ MangaChaptersPage(Program *program, std::string manga_name, std::string manga_url) : TrackablePage(program, std::move(manga_name), std::move(manga_url)) {}
+ TrackResult track(const std::string &str) override;
};
} \ No newline at end of file