diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Matrix.hpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/plugins/Matrix.hpp b/plugins/Matrix.hpp index b7d6d66..11989e3 100644 --- a/plugins/Matrix.hpp +++ b/plugins/Matrix.hpp @@ -78,10 +78,18 @@ namespace QuickMedia { std::optional<std::string> avatar_url; }; + struct MatrixEventRoomInfo { + RoomData *room; + std::optional<std::string> name; + std::optional<std::string> topic; + std::optional<std::string> avatar_url; + }; + enum class MatrixEventType { ADD_USER, REMOVE_USER, - USER_INFO + USER_INFO, + ROOM_INFO }; struct Message { @@ -272,6 +280,7 @@ namespace QuickMedia { virtual void add_user(MatrixEventUserInfo user_info) = 0; virtual void remove_user(MatrixEventUserInfo user_info) = 0; virtual void set_user_info(MatrixEventUserInfo user_info) = 0; + virtual void set_room_info(MatrixEventRoomInfo room_info) = 0; virtual void clear_data() = 0; }; @@ -303,6 +312,7 @@ namespace QuickMedia { void add_user(MatrixEventUserInfo user_info) override; void remove_user(MatrixEventUserInfo user_info) override; void set_user_info(MatrixEventUserInfo user_info) override; + void set_room_info(MatrixEventRoomInfo room_info) override; void for_each_user_in_room(RoomData *room, std::function<void(const MatrixEventUserInfo&)> callback); void set_room_as_read(RoomData *room); @@ -430,6 +440,8 @@ namespace QuickMedia { std::string filename; }; + using MatrixRoomInfoUpdateCallback = std::function<void(const MatrixEventRoomInfo &room_info)>; + class MatrixChatPage : public Page { public: MatrixChatPage(Program *program, std::string room_id, MatrixRoomsPage *rooms_page, std::string jump_to_event_id = ""); @@ -441,8 +453,9 @@ namespace QuickMedia { void add_user(MatrixEventUserInfo user_info); void remove_user(MatrixEventUserInfo user_info); void set_user_info(MatrixEventUserInfo user_info); + void set_room_info(MatrixEventRoomInfo room_info); - void set_current_room(RoomData *room, Body *users_body); + void set_current_room(RoomData *room, Body *users_body, MatrixRoomInfoUpdateCallback room_info_update_callback); size_t get_num_users_in_current_room() const; void set_room_as_read(RoomData *room); @@ -458,6 +471,7 @@ namespace QuickMedia { private: RoomData *current_room = nullptr; Body *users_body = nullptr; + MatrixRoomInfoUpdateCallback room_info_update_callback; }; class MatrixRoomDirectoryPage : public Page { @@ -609,6 +623,7 @@ namespace QuickMedia { void update(); private: void trigger_event(RoomData *room, MatrixEventType type, MatrixEventUserInfo user_info); + void trigger_event(RoomData *room, MatrixEventType type, MatrixEventRoomInfo room_info); void formatted_body_add_line(RoomData *room, std::string &formatted_body, const std::string &line_str); void replace_mentions(RoomData *room, std::string &text); |