From 77ed51898157d99112be7550471ec06e32344c9e Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 11 Oct 2020 21:35:37 +0200 Subject: Refactor plugin into seperate pages TODO: Readd 4chan login page, manganelo creators page, autocomplete --- plugins/Matrix.hpp | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'plugins/Matrix.hpp') diff --git a/plugins/Matrix.hpp b/plugins/Matrix.hpp index 4d7bc11..5819420 100644 --- a/plugins/Matrix.hpp +++ b/plugins/Matrix.hpp @@ -2,10 +2,27 @@ #include "../include/FileAnalyzer.hpp" #include "Plugin.hpp" +#include "Page.hpp" +#include #include +#include #include namespace QuickMedia { + // Dummy, only play one video. TODO: Play all videos in room, as related videos? + class MatrixVideoPage : public Page { + public: + MatrixVideoPage(Program *program) : Page(program) {} + const char* get_title() const override { return ""; } + PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override { + (void)title; + (void)url; + (void)result_tabs; + return PluginResult::ERR; + } + bool is_video_page() const override { return true; } + }; + struct RoomData; struct UserInfo { @@ -91,22 +108,13 @@ namespace QuickMedia { using RoomSyncMessages = std::unordered_map, std::vector>>; - class Matrix : public Plugin { + class Matrix { public: - Matrix(); - virtual ~Matrix() = default; - bool search_is_filter() override { return true; } - bool search_suggestions_has_thumbnails() const override { return true; } - bool search_results_has_thumbnails() const override { return false; } - int get_search_delay() const override { return 0; } - bool search_suggestion_is_search() const override { return true; } - Page get_page_after_search() const override { return Page::EXIT; } PluginResult sync(RoomSyncMessages &room_messages); PluginResult get_joined_rooms(BodyItems &result_items); PluginResult get_all_synced_room_messages(const std::string &room_id, BodyItems &result_items); PluginResult get_new_room_messages(const std::string &room_id, BodyItems &result_items); PluginResult get_previous_room_messages(const std::string &room_id, BodyItems &result_items); - SearchResult search(const std::string &text, BodyItems &result_items) override; // |url| should only be set when uploading media. // TODO: Make api better. @@ -139,6 +147,8 @@ namespace QuickMedia { PluginResult get_config(int *upload_size); std::shared_ptr get_me(const std::string &room_id); + + bool use_tor = false; private: PluginResult sync_response_to_body_items(const Json::Value &root, RoomSyncMessages &room_messages); PluginResult get_previous_room_messages(std::shared_ptr &room_data); @@ -152,6 +162,7 @@ namespace QuickMedia { std::shared_ptr get_room_by_id(const std::string &id); void add_room(std::shared_ptr room); + DownloadResult download_json(Json::Value &result, const std::string &url, std::vector additional_args, bool use_browser_useragent = false, std::string *err_msg = nullptr) const; private: std::unordered_map> room_data_by_id; std::mutex room_data_mutex; -- cgit v1.2.3