diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Manga.hpp | 4 | ||||
-rw-r--r-- | plugins/Mangadex.hpp | 3 | ||||
-rw-r--r-- | plugins/Manganelo.hpp | 11 | ||||
-rw-r--r-- | plugins/Mangatown.hpp | 5 | ||||
-rw-r--r-- | plugins/Page.hpp | 12 |
5 files changed, 29 insertions, 6 deletions
diff --git a/plugins/Manga.hpp b/plugins/Manga.hpp index 732e208..96a5d53 100644 --- a/plugins/Manga.hpp +++ b/plugins/Manga.hpp @@ -53,5 +53,9 @@ namespace QuickMedia { 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; + void on_navigate_to_page() override; + protected: + virtual bool extract_id_from_url(const std::string &url, std::string &manga_id) const = 0; + virtual const char* get_service_name() const = 0; }; }
\ No newline at end of file diff --git a/plugins/Mangadex.hpp b/plugins/Mangadex.hpp index 1b238a2..96bfc50 100644 --- a/plugins/Mangadex.hpp +++ b/plugins/Mangadex.hpp @@ -21,6 +21,9 @@ namespace QuickMedia { public: MangadexChaptersPage(Program *program, std::string manga_name, std::string manga_url) : MangaChaptersPage(program, std::move(manga_name), std::move(manga_url)) {} PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override; + protected: + bool extract_id_from_url(const std::string &url, std::string &manga_id) const override; + const char* get_service_name() const override { return "mangadex"; } }; class MangadexImagesPage : public MangaImagesPage { diff --git a/plugins/Manganelo.hpp b/plugins/Manganelo.hpp index 4fbce5b..e2b602f 100644 --- a/plugins/Manganelo.hpp +++ b/plugins/Manganelo.hpp @@ -12,21 +12,24 @@ namespace QuickMedia { SearchResult search(const std::string &str, BodyItems &result_items) override; PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override; sf::Vector2i get_thumbnail_max_size() override { return sf::Vector2i(101, 141); }; - private: - bool extract_id_from_url(const std::string &url, std::string &manga_id) const; }; class ManganeloChaptersPage : public MangaChaptersPage { public: ManganeloChaptersPage(Program *program, std::string manga_name, std::string manga_url) : MangaChaptersPage(program, std::move(manga_name), std::move(manga_url)) {} PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override; + protected: + bool extract_id_from_url(const std::string &url, std::string &manga_id) const override; + const char* get_service_name() const override { return "manganelo"; } }; - class ManganeloCreatorPage : public Page { + class ManganeloCreatorPage : public LazyFetchPage { public: - ManganeloCreatorPage(Program *program, Creator creator) : Page(program), creator(std::move(creator)) {} + ManganeloCreatorPage(Program *program, Creator creator) : LazyFetchPage(program), creator(std::move(creator)) {} const char* get_title() const override { return creator.name.c_str(); } PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override; + PluginResult lazy_fetch(BodyItems &result_items) override; + sf::Vector2i get_thumbnail_max_size() override { return sf::Vector2i(101, 141); }; private: Creator creator; }; diff --git a/plugins/Mangatown.hpp b/plugins/Mangatown.hpp index 10f2500..66d9d2a 100644 --- a/plugins/Mangatown.hpp +++ b/plugins/Mangatown.hpp @@ -13,14 +13,15 @@ namespace QuickMedia { PluginResult get_page(const std::string &str, int page, BodyItems &result_items) override; PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override; sf::Vector2i get_thumbnail_max_size() override { return sf::Vector2i(101, 141); }; - private: - bool extract_id_from_url(const std::string &url, std::string &manga_id) const; }; class MangatownChaptersPage : public MangaChaptersPage { public: MangatownChaptersPage(Program *program, std::string manga_name, std::string manga_url) : MangaChaptersPage(program, std::move(manga_name), std::move(manga_url)) {} PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override; + protected: + bool extract_id_from_url(const std::string &url, std::string &manga_id) const override; + const char* get_service_name() const override { return "mangatown"; } }; class MangatownImagesPage : public MangaImagesPage { diff --git a/plugins/Page.hpp b/plugins/Page.hpp index f65cd21..b4ea9a6 100644 --- a/plugins/Page.hpp +++ b/plugins/Page.hpp @@ -34,6 +34,11 @@ namespace QuickMedia { // Mutually exclusive with |is_manga_images_page|, |is_image_board_thread_page| and |is_video_page| virtual bool is_single_page() const { return false; } virtual bool is_trackable() const { return false; } + // Mutually exclusive with |is_manga_images_page|, |is_image_board_thread_page| and |is_video_page| + virtual bool is_lazy_fetch_page() const { return false; } + + // This is called both when first navigating to page and when going back to page + virtual void on_navigate_to_page() {}; bool is_tor_enabled(); std::unique_ptr<Body> create_body(); @@ -61,4 +66,11 @@ namespace QuickMedia { const std::string content_title; const std::string content_url; }; + + class LazyFetchPage : public Page { + public: + LazyFetchPage(Program *program) : Page(program) {} + bool is_lazy_fetch_page() const override { return true; } + virtual PluginResult lazy_fetch(BodyItems &result_items) = 0; + }; }
\ No newline at end of file |