diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Matrix.hpp | 35 | ||||
-rw-r--r-- | plugins/Page.hpp | 2 |
2 files changed, 36 insertions, 1 deletions
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<Tab> &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<Tab> &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<Tab> &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<UserInfo> get_me(RoomData *room); + const std::string& get_homeserver_domain() const; + // Returns nullptr if message cant be found. Note: cached std::shared_ptr<Message> 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<int> upload_limit; std::string next_batch; std::mutex next_batch_mutex; diff --git a/plugins/Page.hpp b/plugins/Page.hpp index 8ef2b59..b5af7a9 100644 --- a/plugins/Page.hpp +++ b/plugins/Page.hpp @@ -47,6 +47,8 @@ namespace QuickMedia { virtual bool is_single_page() const { return false; } virtual bool is_trackable() const { return false; } virtual bool is_lazy_fetch_page() const { return false; } + // Note: If submit is done without any selection, then the search term is sent as the |title|, not |url| + virtual bool allow_submit_no_selection() const { return false; } // This is called both when first navigating to page and when going back to page virtual void on_navigate_to_page(Body *body) { (void)body; } |