diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/ImageBoard.hpp | 2 | ||||
-rw-r--r-- | plugins/Manga.hpp | 2 | ||||
-rw-r--r-- | plugins/Matrix.hpp | 26 | ||||
-rw-r--r-- | plugins/Page.hpp | 14 | ||||
-rw-r--r-- | plugins/Pornhub.hpp | 2 | ||||
-rw-r--r-- | plugins/Youtube.hpp | 2 |
6 files changed, 36 insertions, 12 deletions
diff --git a/plugins/ImageBoard.hpp b/plugins/ImageBoard.hpp index 6f2a276..2d235ec 100644 --- a/plugins/ImageBoard.hpp +++ b/plugins/ImageBoard.hpp @@ -21,7 +21,7 @@ namespace QuickMedia { return PluginResult::ERR; } - bool is_image_board_thread_page() const override { return true; } + PageTypez get_type() const override { return PageTypez::IMAGE_BOARD_THREAD; } virtual BodyItems get_related_media(const std::string &url) override; virtual PluginResult login(const std::string &token, const std::string &pin, std::string &response_msg); diff --git a/plugins/Manga.hpp b/plugins/Manga.hpp index 96a5d53..d3725da 100644 --- a/plugins/Manga.hpp +++ b/plugins/Manga.hpp @@ -24,7 +24,7 @@ namespace QuickMedia { return PluginResult::OK; } - bool is_manga_images_page() const override { return true; } + PageTypez get_type() const override { return PageTypez::MANGA_IMAGES; } virtual ImageResult get_number_of_images(int &num_images) = 0; virtual ImageResult for_each_page_in_chapter(PageCallback callback) = 0; diff --git a/plugins/Matrix.hpp b/plugins/Matrix.hpp index c3c5539..f0ca4f5 100644 --- a/plugins/Matrix.hpp +++ b/plugins/Matrix.hpp @@ -20,7 +20,7 @@ namespace QuickMedia { (void)result_tabs; return PluginResult::ERR; } - bool is_video_page() const override { return true; } + PageTypez get_type() const override { return PageTypez::VIDEO; } }; struct RoomData; @@ -90,10 +90,19 @@ namespace QuickMedia { const std::vector<std::shared_ptr<Message>>& get_messages_thread_unsafe() const; const std::vector<std::string>& get_pinned_events_unsafe() const; + bool has_prev_batch(); + void set_prev_batch(const std::string &new_prev_batch); + std::string get_prev_batch(); + + bool has_name(); + void set_name(const std::string &new_name); + std::string get_name(); + + bool has_avatar_url(); + void set_avatar_url(const std::string &new_avatar_url); + std::string get_avatar_url(); + std::string id; - std::string name; - std::string avatar_url; - std::string prev_batch; bool initial_fetch_finished = false; // These 4 variables are set by QuickMedia, not the matrix plugin @@ -106,9 +115,16 @@ namespace QuickMedia { // The value is nullptr if the message is fetched and cached but the event if referenced an invalid message. // TODO: Verify if replied to messages are also part of /sync; then this is not needed. std::unordered_map<std::string, std::shared_ptr<Message>> fetched_messages_by_event_id; + + size_t index; private: std::mutex user_mutex; std::mutex room_mutex; + + std::string name; + std::string avatar_url; + std::string prev_batch; + // Each room has its own list of user data, even if multiple rooms has the same user // because users can have different display names and avatars in different rooms. std::unordered_map<std::string, std::shared_ptr<UserInfo>> user_info_by_user_id; @@ -194,6 +210,7 @@ namespace QuickMedia { void events_add_messages(const rapidjson::Value &events_json, RoomData *room_data, MessageDirection message_dir, RoomSyncData *room_sync_data, bool has_unread_notifications); void events_set_room_name(const rapidjson::Value &events_json, RoomData *room_data); void events_add_pinned_events(const rapidjson::Value &events_json, RoomData *room_data, RoomSyncData &room_sync_data); + void events_add_room_to_tags(const rapidjson::Value &events_json, RoomData *room_data); std::shared_ptr<Message> parse_message_event(const rapidjson::Value &event_item_json, RoomData *room_data); PluginResult upload_file(RoomData *room, const std::string &filepath, UploadInfo &file_info, UploadInfo &thumbnail_info, std::string &err_msg); @@ -205,6 +222,7 @@ namespace QuickMedia { private: std::vector<std::unique_ptr<RoomData>> rooms; std::unordered_map<std::string, size_t> room_data_by_id; // value is an index into |rooms| + std::map<std::string, std::vector<size_t>> rooms_by_tag_name; // value is an index into |rooms| size_t room_list_read_index = 0; std::mutex room_data_mutex; std::string user_id; diff --git a/plugins/Page.hpp b/plugins/Page.hpp index 2e85cad..de80b4f 100644 --- a/plugins/Page.hpp +++ b/plugins/Page.hpp @@ -9,6 +9,14 @@ namespace QuickMedia { constexpr int SEARCH_DELAY_FILTER = 50; + // TODO: Remove to PageType when the other PageType is removed + enum class PageTypez { + REGULAR, + MANGA_IMAGES, + IMAGE_BOARD_THREAD, + VIDEO + }; + class Page { public: Page(Program *program) : program(program) {} @@ -29,10 +37,8 @@ namespace QuickMedia { DownloadResult download_json(Json::Value &result, const std::string &url, std::vector<CommandArg> additional_args, bool use_browser_useragent = false, std::string *err_msg = nullptr); - virtual bool is_manga_images_page() const { return false; } - virtual bool is_image_board_thread_page() const { return false; } - virtual bool is_video_page() const { return false; } - // Mutually exclusive with |is_manga_images_page|, |is_image_board_thread_page| and |is_video_page| + virtual PageTypez get_type() const { return PageTypez::REGULAR; } + // Mutually exclusive with |get_type| when |get_type| is not PageTypez::REGULAR virtual bool is_single_page() const { return false; } virtual bool is_trackable() const { return false; } virtual bool is_lazy_fetch_page() const { return false; } diff --git a/plugins/Pornhub.hpp b/plugins/Pornhub.hpp index b058bbe..74fb00e 100644 --- a/plugins/Pornhub.hpp +++ b/plugins/Pornhub.hpp @@ -24,6 +24,6 @@ namespace QuickMedia { return PluginResult::ERR; } BodyItems get_related_media(const std::string &url) override; - bool is_video_page() const override { return true; } + PageTypez get_type() const override { return PageTypez::VIDEO; } }; }
\ No newline at end of file diff --git a/plugins/Youtube.hpp b/plugins/Youtube.hpp index 007f398..bdb9c8b 100644 --- a/plugins/Youtube.hpp +++ b/plugins/Youtube.hpp @@ -30,6 +30,6 @@ namespace QuickMedia { return PluginResult::ERR; } BodyItems get_related_media(const std::string &url) override; - bool is_video_page() const override { return true; } + PageTypez get_type() const override { return PageTypez::VIDEO; } }; }
\ No newline at end of file |