From 276395f468c8ee05951401a1d352e0dec3c3a3a8 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 1 Apr 2021 17:59:36 +0200 Subject: Matrix: add room directory for joining rooms, resize video thumbnail --- plugins/Matrix.hpp | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'plugins/Matrix.hpp') diff --git a/plugins/Matrix.hpp b/plugins/Matrix.hpp index b240cb8..eea7f9b 100644 --- a/plugins/Matrix.hpp +++ b/plugins/Matrix.hpp @@ -427,7 +427,7 @@ namespace QuickMedia { class MatrixChatPage : public Page { public: MatrixChatPage(Program *program, std::string room_id, MatrixRoomsPage *rooms_page); - ~MatrixChatPage() override; + ~MatrixChatPage(); const char* get_title() const override { return ""; } PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override { @@ -445,6 +445,33 @@ namespace QuickMedia { bool should_clear_data = false; }; + class MatrixRoomDirectoryPage : public Page { + public: + MatrixRoomDirectoryPage(Program *program, Matrix *matrix) : Page(program), matrix(matrix) {} + const char* get_title() const override { return "Room directory"; } + bool allow_submit_no_selection() const override { return true; } + PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + private: + Matrix *matrix; + }; + + class MatrixServerRoomListPage : public LazyFetchPage { + public: + MatrixServerRoomListPage(Program *program, Matrix *matrix, const std::string &server_name) : LazyFetchPage(program), matrix(matrix), server_name(server_name), current_page(0) {} + const char* get_title() const override { return "Select a room to join"; } + bool search_is_filter() override { return false; } + 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; + private: + Matrix *matrix; + const std::string server_name; + std::string next_batch; + std::string search_term; + int current_page; + }; + class Matrix { public: void start_sync(MatrixDelegate *delegate, bool &cached); @@ -486,6 +513,9 @@ namespace QuickMedia { PluginResult join_room(const std::string &room_id); PluginResult leave_room(const std::string &room_id); + // If |since| is empty, then the first page is fetched + PluginResult get_public_rooms(const std::string &server, const std::string &search_term, const std::string &since, BodyItems &rooms, std::string &next_batch); + // |message| is from |BodyItem.userdata| and is of type |Message*| bool was_message_posted_by_me(void *message); @@ -496,6 +526,8 @@ namespace QuickMedia { std::shared_ptr get_me(RoomData *room); + const std::string& get_homeserver_domain() const; + // Returns nullptr if message cant be found. Note: cached std::shared_ptr get_message_by_id(RoomData *room, const std::string &event_id); @@ -541,6 +573,7 @@ namespace QuickMedia { std::string my_user_id; std::string access_token; std::string homeserver; + std::string homeserver_domain; std::optional upload_limit; std::string next_batch; std::mutex next_batch_mutex; -- cgit v1.2.3