From 75c610d1f65d741bbeba9f1ddeef60a6e9315427 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 7 Feb 2022 22:54:20 +0100 Subject: Use one struct for all args in Page::submit instead of multiple args (easier to add new fields without changing code) Also remove submit_body_item from page. --- plugins/AniList.hpp | 8 ++++---- plugins/FileManager.hpp | 2 +- plugins/Fourchan.hpp | 4 ++-- plugins/HotExamples.hpp | 6 +++--- plugins/Info.hpp | 2 +- plugins/Lbry.hpp | 4 ++-- plugins/MangaCombined.hpp | 2 +- plugins/MangaGeneric.hpp | 6 +++--- plugins/Mangadex.hpp | 6 +++--- plugins/Manganelo.hpp | 6 +++--- plugins/Matrix.hpp | 16 ++++++++-------- plugins/MediaGeneric.hpp | 4 ++-- plugins/MyAnimeList.hpp | 6 +++--- plugins/NyaaSi.hpp | 8 ++++---- plugins/Page.hpp | 21 +++++++++++++-------- plugins/Peertube.hpp | 8 ++++---- plugins/Pipe.hpp | 2 +- plugins/Saucenao.hpp | 2 +- plugins/Soundcloud.hpp | 4 ++-- plugins/Youtube.hpp | 16 ++++++++-------- 20 files changed, 69 insertions(+), 64 deletions(-) (limited to 'plugins') diff --git a/plugins/AniList.hpp b/plugins/AniList.hpp index 5fc5eef..8e57b4e 100644 --- a/plugins/AniList.hpp +++ b/plugins/AniList.hpp @@ -15,7 +15,7 @@ namespace QuickMedia { bool search_is_filter() override { return false; } bool submit_is_async() const override { return false; } SearchResult search(const std::string &str, BodyItems &result_items) override; - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; PluginResult get_page(const std::string &str, int page, BodyItems &result_items) override; private: SearchResult search_page(const std::string &str, int page, BodyItems &result_items); @@ -28,7 +28,7 @@ namespace QuickMedia { AniListRelatedPage(Program *program, std::string id) : LazyFetchPage(program), id(std::move(id)) {} const char* get_title() const override { return "Related"; } bool submit_is_async() const override { return false; } - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; PluginResult lazy_fetch(BodyItems &result_items) override; private: std::string id; @@ -39,7 +39,7 @@ namespace QuickMedia { AniListDetailsPage(Program *program, std::string id) : LazyFetchPage(program), id(std::move(id)) {} const char* get_title() const override { return "Details"; } bool submit_is_async() const override { return false; } - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; PluginResult lazy_fetch(BodyItems &result_items) override; private: std::string id; @@ -50,7 +50,7 @@ namespace QuickMedia { AniListRecommendationsPage(Program *program, std::string id) : LazyFetchPage(program), id(std::move(id)) {} const char* get_title() const override { return "Recommendations"; } bool submit_is_async() const override { return false; } - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; PluginResult lazy_fetch(BodyItems &result_items) override; PluginResult get_page(const std::string &str, int page, BodyItems &result_items) override; private: diff --git a/plugins/FileManager.hpp b/plugins/FileManager.hpp index 4e36b3c..e31eb41 100644 --- a/plugins/FileManager.hpp +++ b/plugins/FileManager.hpp @@ -21,7 +21,7 @@ namespace QuickMedia { FileManagerPage(Program *program, FileManagerMimeType mime_type = FILE_MANAGER_MIME_TYPE_ALL, FileSelectionHandler selection_handler = nullptr) : Page(program), current_dir("/"), mime_type(mime_type), selection_handler(selection_handler) {} const char* get_title() const override { return current_dir.c_str(); } - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; bool is_single_page() const override { return true; } bool set_current_directory(const std::string &path); diff --git a/plugins/Fourchan.hpp b/plugins/Fourchan.hpp index 8c608a1..05fb784 100644 --- a/plugins/Fourchan.hpp +++ b/plugins/Fourchan.hpp @@ -7,7 +7,7 @@ namespace QuickMedia { public: FourchanBoardsPage(Program *program, std::string resources_root) : Page(program), resources_root(std::move(resources_root)) {} const char* get_title() const override { return "Select board"; } - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; void get_boards(BodyItems &result_items); const std::string resources_root; @@ -17,7 +17,7 @@ namespace QuickMedia { public: FourchanThreadListPage(Program *program, std::string title, std::string board_id) : LazyFetchPage(program), title(std::move(title)), board_id(std::move(board_id)) {} const char* get_title() const override { return title.c_str(); } - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; PluginResult lazy_fetch(BodyItems &result_items) override; const std::string title; diff --git a/plugins/HotExamples.hpp b/plugins/HotExamples.hpp index 73bc150..9bca74a 100644 --- a/plugins/HotExamples.hpp +++ b/plugins/HotExamples.hpp @@ -9,7 +9,7 @@ namespace QuickMedia { public: HotExamplesLanguageSelectPage(Program *program) : Page(program) {} const char* get_title() const override { return "Select language"; } - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; bool submit_is_async() const override { return false; } }; @@ -19,7 +19,7 @@ namespace QuickMedia { const char* get_title() const override { return "Select result"; } bool search_is_filter() override { return false; } SearchResult search(const std::string &str, BodyItems &result_items) override; - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; private: std::string language; }; @@ -28,7 +28,7 @@ namespace QuickMedia { public: HotExamplesCodeExamplesPage(Program *program, std::string title) : Page(program), title(std::move(title)) {} const char* get_title() const override { return title.c_str(); } - PluginResult submit(const std::string&, const std::string&, std::vector&) override { return PluginResult::OK; } + PluginResult submit(const SubmitArgs &args, std::vector&) override { (void)args; return PluginResult::OK; } bool submit_is_async() const override { return false; } private: std::string title; diff --git a/plugins/Info.hpp b/plugins/Info.hpp index cdaefd3..3ede60d 100644 --- a/plugins/Info.hpp +++ b/plugins/Info.hpp @@ -7,7 +7,7 @@ namespace QuickMedia { public: InfoPage(Program *program) : Page(program) {} const char* get_title() const override { return "Info"; } - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; bool submit_is_async() const override { return false; } void copy_to_clipboard(const BodyItem *body_item) override; diff --git a/plugins/Lbry.hpp b/plugins/Lbry.hpp index 1cddf56..224e43b 100644 --- a/plugins/Lbry.hpp +++ b/plugins/Lbry.hpp @@ -10,7 +10,7 @@ namespace QuickMedia { bool search_is_filter() override { return false; } SearchResult search(const std::string &str, BodyItems &result_items) override; 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 &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; bool submit_is_async() const override { return false; } private: std::string channel_id; @@ -25,7 +25,7 @@ namespace QuickMedia { bool search_is_filter() override { return false; } SearchResult search(const std::string &str, BodyItems &result_items) override; 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 &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; PluginResult lazy_fetch(BodyItems &result_items) override; private: LbrySearchPage search_page; diff --git a/plugins/MangaCombined.hpp b/plugins/MangaCombined.hpp index 39a143c..1348b1b 100644 --- a/plugins/MangaCombined.hpp +++ b/plugins/MangaCombined.hpp @@ -21,7 +21,7 @@ namespace QuickMedia { bool search_is_filter() override { return false; } SearchResult search(const std::string &str, BodyItems &result_items) override; 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 &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; void cancel_operation() override; private: std::vector search_pages; diff --git a/plugins/MangaGeneric.hpp b/plugins/MangaGeneric.hpp index 439fc19..56d7c74 100644 --- a/plugins/MangaGeneric.hpp +++ b/plugins/MangaGeneric.hpp @@ -112,7 +112,7 @@ namespace QuickMedia { SearchResult search(const std::string &str, BodyItems &result_items) override; PluginResult get_page(const std::string &url, bool is_post, const std::vector &form_data, BodyItems &result_items); 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 &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; const char* get_bookmark_name() const override { return service_name; } MangaGenericSearchPage& search_handler(const char *search_template, int page_start); @@ -157,7 +157,7 @@ namespace QuickMedia { public: MangaGenericChaptersPage(Program *program, std::string manga_name, std::string manga_url, const std::string &thumbnail_url, const MangaIdExtractor &manga_id_extractor, const char *service_name, const std::string &website_url, const ListPageQuery *list_page_query, bool fail_on_http_error) : MangaChaptersPage(program, std::move(manga_name), std::move(manga_url), thumbnail_url), manga_id_extractor(manga_id_extractor), service_name(service_name), website_url(website_url), list_page_query(list_page_query), fail_on_http_error(fail_on_http_error) {} - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; const char* get_bookmark_name() const override { return service_name; } protected: bool extract_id_from_url(const std::string &url, std::string &manga_id) const override; @@ -174,7 +174,7 @@ namespace QuickMedia { public: MangaGenericCreatorPage(Program *program, MangaGenericSearchPage *search_page, Creator creator) : LazyFetchPage(program), search_page(search_page), 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 &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; PluginResult lazy_fetch(BodyItems &result_items) override; private: MangaGenericSearchPage *search_page; diff --git a/plugins/Mangadex.hpp b/plugins/Mangadex.hpp index d6206cc..8735326 100644 --- a/plugins/Mangadex.hpp +++ b/plugins/Mangadex.hpp @@ -16,7 +16,7 @@ namespace QuickMedia { bool search_is_filter() override { return false; } SearchResult search(const std::string &str, BodyItems &result_items) override; 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 &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; const char* get_bookmark_name() const override { return "mangadex"; } private: bool get_rememberme_token(std::string &rememberme_token); @@ -27,7 +27,7 @@ namespace QuickMedia { public: MangadexChaptersPage(Program *program, MangadexSearchPage *search_page, std::string manga_name, std::string manga_url, const std::string &thumbnail_url) : MangaChaptersPage(program, std::move(manga_name), std::move(manga_url), thumbnail_url), search_page(search_page) {} - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; PluginResult get_page(const std::string &str, int page, BodyItems &result_items) override; const char* get_bookmark_name() const override { return "mangadex"; } protected: @@ -41,7 +41,7 @@ namespace QuickMedia { public: MangadexCreatorPage(Program *program, MangadexSearchPage *search_page, Creator creator) : LazyFetchPage(program), search_page(search_page), 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 &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; PluginResult get_page(const std::string &str, int page, BodyItems &result_items) override; PluginResult lazy_fetch(BodyItems &result_items) override; private: diff --git a/plugins/Manganelo.hpp b/plugins/Manganelo.hpp index 8946447..d835a06 100644 --- a/plugins/Manganelo.hpp +++ b/plugins/Manganelo.hpp @@ -9,14 +9,14 @@ namespace QuickMedia { const char* get_title() const override { return "Search"; } bool search_is_filter() override { return false; } SearchResult search(const std::string &str, BodyItems &result_items) override; - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; const char* get_bookmark_name() const override { return "manganelo"; } }; class ManganeloChaptersPage : public MangaChaptersPage { public: ManganeloChaptersPage(Program *program, std::string manga_name, std::string manga_url, const std::string &thumbnail_url) : MangaChaptersPage(program, std::move(manga_name), std::move(manga_url), thumbnail_url) {} - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; const char* get_bookmark_name() const override { return "manganelo"; } protected: bool extract_id_from_url(const std::string &url, std::string &manga_id) const override; @@ -27,7 +27,7 @@ namespace QuickMedia { public: 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 &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; PluginResult lazy_fetch(BodyItems &result_items) override; private: Creator creator; diff --git a/plugins/Matrix.hpp b/plugins/Matrix.hpp index 7244ee3..9b0fc58 100644 --- a/plugins/Matrix.hpp +++ b/plugins/Matrix.hpp @@ -323,7 +323,7 @@ namespace QuickMedia { ~MatrixRoomsPage() override; const char* get_title() const override { return title.c_str(); } - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; bool submit_is_async() const override { return false; } bool clear_search_after_submit() override { return true; } @@ -353,7 +353,7 @@ namespace QuickMedia { public: MatrixRoomTagsPage(Program *program, Body *body) : Page(program), body(body) {} const char* get_title() const override { return "Tags"; } - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; bool submit_is_async() const override { return false; } bool clear_search_after_submit() override { return true; } @@ -384,7 +384,7 @@ namespace QuickMedia { MatrixInvitesPage(Program *program, Matrix *matrix, Body *body); const char* get_title() const override { return title.c_str(); } - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; bool submit_is_async() const override { return false; } bool clear_search_after_submit() override { return true; } @@ -404,7 +404,7 @@ namespace QuickMedia { MatrixInviteDetailsPage(Program *program, Matrix *matrix, MatrixInvitesPage *invites_page, std::string room_id, std::string title) : Page(program), matrix(matrix), invites_page(invites_page), room_id(std::move(room_id)), title(std::move(title)) {} const char* get_title() const override { return title.c_str(); } - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; Matrix *matrix; MatrixInvitesPage *invites_page; @@ -455,7 +455,7 @@ namespace QuickMedia { const char* get_title() const override { return "Room directory"; } bool allow_submit_no_selection() const override { return true; } bool clear_search_after_submit() override { return true; } - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; private: Matrix *matrix; }; @@ -468,7 +468,7 @@ namespace QuickMedia { PluginResult lazy_fetch(BodyItems &result_items) override; PluginResult get_page(const std::string &str, int page, BodyItems &result_items) override; SearchResult search(const std::string &str, BodyItems &result_items) override; - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; private: Matrix *matrix; const std::string server_name; @@ -481,7 +481,7 @@ namespace QuickMedia { public: MatrixNotificationsPage(Program *program, Matrix *matrix, Body *notifications_body, MatrixRoomsPage *all_rooms_page); const char* get_title() const override { return "Notifications"; } - PluginResult submit(const std::string&, const std::string&, std::vector&) override; + PluginResult submit(const SubmitArgs &args, std::vector&) override; PluginResult get_page(const std::string &str, int page, BodyItems &result_items) override; PluginResult lazy_fetch(BodyItems &result_items) override; bool is_ready() override; @@ -507,7 +507,7 @@ namespace QuickMedia { const char* get_title() const override { return "Invite user"; } bool search_is_filter() override { return false; } SearchResult search(const std::string &str, BodyItems &result_items) override; - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; bool allow_submit_no_selection() const override { return true; } private: Matrix *matrix; diff --git a/plugins/MediaGeneric.hpp b/plugins/MediaGeneric.hpp index f0d5462..3720ba3 100644 --- a/plugins/MediaGeneric.hpp +++ b/plugins/MediaGeneric.hpp @@ -39,7 +39,7 @@ namespace QuickMedia { bool search_is_filter() override { return false; } SearchResult search(const std::string &str, BodyItems &result_items) override; 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 &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; PluginResult get_related_media(const std::string &url, BodyItems &result_items); @@ -74,7 +74,7 @@ namespace QuickMedia { class MediaGenericRelatedPage : public RelatedVideosPage { public: MediaGenericRelatedPage(Program *program, MediaGenericSearchPage *search_page) : RelatedVideosPage(program), search_page(search_page) {} - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; private: MediaGenericSearchPage *search_page; }; diff --git a/plugins/MyAnimeList.hpp b/plugins/MyAnimeList.hpp index 192f0f3..8f35043 100644 --- a/plugins/MyAnimeList.hpp +++ b/plugins/MyAnimeList.hpp @@ -10,7 +10,7 @@ namespace QuickMedia { bool search_is_filter() override { return false; } bool submit_is_async() const override { return false; } SearchResult search(const std::string &str, BodyItems &result_items) override; - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; }; class MyAnimeListDetailsPage : public LazyFetchPage { @@ -18,7 +18,7 @@ namespace QuickMedia { MyAnimeListDetailsPage(Program *program, std::string url) : LazyFetchPage(program), url(std::move(url)) {} const char* get_title() const override { return "Details"; } bool submit_is_async() const override { return false; } - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; PluginResult lazy_fetch(BodyItems &result_items) override; private: std::string url; @@ -29,7 +29,7 @@ namespace QuickMedia { MyAnimeListRecommendationsPage(Program *program, std::string url) : LazyFetchPage(program), url(std::move(url)) {} const char* get_title() const override { return "Recommendations"; } bool submit_is_async() const override { return false; } - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; PluginResult lazy_fetch(BodyItems &result_items) override; private: std::string url; diff --git a/plugins/NyaaSi.hpp b/plugins/NyaaSi.hpp index 5556fa8..3236fc5 100644 --- a/plugins/NyaaSi.hpp +++ b/plugins/NyaaSi.hpp @@ -10,7 +10,7 @@ namespace QuickMedia { public: NyaaSiCategoryPage(Program *program, bool is_sukebei) : Page(program), is_sukebei(is_sukebei) {} const char* get_title() const override { return is_sukebei ? "Select sukebei category" : "Select nyaa.si category"; } - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; const bool is_sukebei; }; @@ -36,7 +36,7 @@ namespace QuickMedia { bool search_is_filter() override { return false; } SearchResult search(const std::string &str, BodyItems &result_items) override; 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 &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; void set_sort_type(NyaaSiSortType sort_type); @@ -52,7 +52,7 @@ namespace QuickMedia { public: NyaaSiSortOrderPage(Program *program, Body *body, NyaaSiSearchPage *search_page) : Page(program), body(body), search_page(search_page) {} const char* get_title() const override { return "Sort order"; } - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; bool submit_is_async() const override { return false; } private: Body *body; @@ -63,7 +63,7 @@ namespace QuickMedia { public: NyaaSiTorrentPage(Program *program) : Page(program) {} const char* get_title() const override { return "Torrent"; } - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; bool submit_is_async() const override { return false; } }; } \ No newline at end of file diff --git a/plugins/Page.hpp b/plugins/Page.hpp index b9f220d..0e904c2 100644 --- a/plugins/Page.hpp +++ b/plugins/Page.hpp @@ -20,6 +20,14 @@ namespace QuickMedia { CHAT }; + struct SubmitArgs { + std::string title; + std::string url; + std::string thumbnail_url; + void *userdata; + std::shared_ptr extra; + }; + class Page { public: Page(Program *program) : program(program) {} @@ -34,18 +42,16 @@ namespace QuickMedia { virtual bool search_is_suggestion() { return false; } // Return empty |result_tabs| and PluginResult::OK to do nothing; which is useful for implementing custom actions on item submit - virtual PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) { - (void)title; - (void)url; + virtual PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) { + (void)args; (void)result_tabs; return PluginResult::ERR; } // Override and return false to make submit run in the main (ui) thread virtual bool submit_is_async() const { return true; } virtual bool clear_search_after_submit() { return false; } - virtual PluginResult submit_suggestion(const std::string &title, const std::string &url, BodyItems &result_items) { - (void)title; - (void)url; + virtual PluginResult submit_suggestion(const SubmitArgs &args, BodyItems &result_items) { + (void)args; (void)result_items; return PluginResult::ERR; } @@ -84,7 +90,6 @@ namespace QuickMedia { void set_clipboard(const std::string &str); Program *program; - std::shared_ptr submit_body_item; // TODO: Remove this bool needs_refresh = false; // Set to true to refresh the page. Note: only works for search pages and lazy fetch pages }; @@ -173,7 +178,7 @@ namespace QuickMedia { public: BookmarksPage(Program *program, Page *redirect_page) : LazyFetchPage(program), redirect_page(redirect_page) {} const char* get_title() const override { return "Bookmarks"; } - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; PluginResult lazy_fetch(BodyItems &result_items) override; bool reload_on_page_change() override { return true; } const char* get_bookmark_name() const override { return redirect_page->get_bookmark_name(); } diff --git a/plugins/Peertube.hpp b/plugins/Peertube.hpp index 90453ee..10c2761 100644 --- a/plugins/Peertube.hpp +++ b/plugins/Peertube.hpp @@ -9,7 +9,7 @@ namespace QuickMedia { const char* get_title() const override { return "Select instance"; } bool allow_submit_no_selection() const override { return true; } bool submit_is_async() const override { return false; } - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; PluginResult lazy_fetch(BodyItems &result_items) override; }; @@ -28,7 +28,7 @@ namespace QuickMedia { // Fetches local videos if |str| is empty SearchResult search(const std::string &str, BodyItems &result_items) override; 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 &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; // Fetches all local videos PluginResult lazy_fetch(BodyItems &result_items) override; private: @@ -45,7 +45,7 @@ namespace QuickMedia { const char* get_title() const override { return title.c_str(); } bool submit_is_async() const override { return false; } 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 &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; PluginResult lazy_fetch(BodyItems &result_items) override; private: std::string server; @@ -60,7 +60,7 @@ namespace QuickMedia { const char* get_title() const override { return title.c_str(); } bool submit_is_async() const override { return false; } 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 &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; PluginResult lazy_fetch(BodyItems &result_items) override; private: std::string server; diff --git a/plugins/Pipe.hpp b/plugins/Pipe.hpp index 46864be..8a6454a 100644 --- a/plugins/Pipe.hpp +++ b/plugins/Pipe.hpp @@ -7,7 +7,7 @@ namespace QuickMedia { public: PipePage(Program *program, const char *title = "") : Page(program), title(title) {} const char* get_title() const override { return title; } - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; bool is_single_page() const override { return true; } static void load_body_items_from_stdin(BodyItems &items); diff --git a/plugins/Saucenao.hpp b/plugins/Saucenao.hpp index d58b424..997fb05 100644 --- a/plugins/Saucenao.hpp +++ b/plugins/Saucenao.hpp @@ -8,7 +8,7 @@ namespace QuickMedia { SaucenaoPage(Program *program, const std::string &path, bool is_local) : LazyFetchPage(program), path(path), is_local(is_local) {} const char* get_title() const override { return "SauceNAO"; } bool submit_is_async() const override { return false; } - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; PluginResult lazy_fetch(BodyItems &result_items) override; private: std::string path; diff --git a/plugins/Soundcloud.hpp b/plugins/Soundcloud.hpp index 5850fab..7e65cc1 100644 --- a/plugins/Soundcloud.hpp +++ b/plugins/Soundcloud.hpp @@ -11,7 +11,7 @@ namespace QuickMedia { SoundcloudPage(Program *program) : Page(program) {} virtual ~SoundcloudPage() = default; virtual const char* get_title() const override { return ""; } - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; }; class SoundcloudSearchPage : public LazyFetchPage { @@ -19,7 +19,7 @@ namespace QuickMedia { SoundcloudSearchPage(Program *program) : LazyFetchPage(program), submit_page(program) {} const char* get_title() const override { return "Search"; } bool search_is_filter() override { return false; } - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; SearchResult search(const std::string &str, BodyItems &result_items) override; PluginResult get_page(const std::string &str, int page, BodyItems &result_items) override; PluginResult lazy_fetch(BodyItems &result_items) override; diff --git a/plugins/Youtube.hpp b/plugins/Youtube.hpp index 53fb3b7..511c78a 100644 --- a/plugins/Youtube.hpp +++ b/plugins/Youtube.hpp @@ -46,8 +46,8 @@ namespace QuickMedia { bool search_is_filter() override { return false; } SearchResult search(const std::string &str, BodyItems &result_items) override; 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 &result_tabs) override; - PluginResult submit_suggestion(const std::string &title, const std::string &url, BodyItems &result_items) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; + PluginResult submit_suggestion(const SubmitArgs &args, BodyItems &result_items) override; PluginResult lazy_fetch(BodyItems &result_items) override; bool lazy_fetch_is_loader() override { return true; } private: @@ -71,7 +71,7 @@ namespace QuickMedia { YoutubeCommentsPage(Program *program, const std::string &video_url, const std::string &continuation_token) : LazyFetchPage(program), video_url(video_url), continuation_token(continuation_token) {} const char* get_title() const override { return "Comments"; } 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 &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; PluginResult lazy_fetch(BodyItems &result_items) override; private: int current_page = 0; @@ -84,7 +84,7 @@ namespace QuickMedia { YoutubeCommentRepliesPage(Program *program, const std::string &video_url, const std::string &continuation_token) : LazyFetchPage(program), video_url(video_url), continuation_token(continuation_token) {} const char* get_title() const override { return "Comment replies"; } 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 &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; PluginResult lazy_fetch(BodyItems &result_items) override; private: int current_page = 0; @@ -99,7 +99,7 @@ namespace QuickMedia { bool search_is_filter() override { return false; } SearchResult search(const std::string &str, BodyItems &result_items) override; 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 &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; PluginResult lazy_fetch(BodyItems &result_items) override; TrackResult track(const std::string &str) override; @@ -124,7 +124,7 @@ namespace QuickMedia { public: YoutubeSubscriptionsPage(Program *program) : LazyFetchPage(program) {} const char* get_title() const override { return "Subscriptions"; } - PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; PluginResult lazy_fetch(BodyItems &result_items) override; private: std::array>, 4> subscription_load_tasks; // TODO: Use multiple curl outputs instead? @@ -135,7 +135,7 @@ namespace QuickMedia { YoutubeRecommendedPage(Program *program) : LazyFetchPage(program) {} const char* get_title() const override { return "Recommended"; } 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 &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; PluginResult lazy_fetch(BodyItems &result_items) override; bool reload_on_page_change() override { return true; } private: @@ -149,7 +149,7 @@ namespace QuickMedia { class YoutubeRelatedVideosPage : public RelatedVideosPage { public: YoutubeRelatedVideosPage(Program *program) : RelatedVideosPage(program) {} - PluginResult submit(const std::string&, const std::string&, std::vector &result_tabs) override; + PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; }; class YoutubeVideoPage : public VideoPage { -- cgit v1.2.3