From 24e3d967d7c9029147202e10385b0b8e8881e4d9 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 9 Sep 2017 20:17:42 +0900 Subject: Kicking, inviting, exposing rooms in Invite state Kicking and inviting use generated job classes. Rooms in Invite state are stored separately in the hash from those in Join/Leave state because The Spec says so. For clients, this means that the same room may appear twice in the rooms map if it's been left and then the user was again invited to it. The code in Quaternion that properly processes this will arrive shortly. --- connection.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'connection.h') diff --git a/connection.h b/connection.h index 4b0413e3..b118ffb0 100644 --- a/connection.h +++ b/connection.h @@ -18,6 +18,8 @@ #pragma once +#include "joinstate.h" + #include #include #include @@ -41,11 +43,16 @@ namespace QMatrixClient class Connection: public QObject { Q_OBJECT public: + using room_factory_t = + std::function; + using user_factory_t = + std::function; + explicit Connection(const QUrl& server, QObject* parent = nullptr); Connection(); virtual ~Connection(); - QHash roomMap() const; + const QHash, Room*>& roomMap() const; Q_INVOKABLE virtual void resolveServer(const QString& domain); Q_INVOKABLE virtual void connectToServer(const QString& user, @@ -102,7 +109,8 @@ namespace QMatrixClient static void setRoomType() { createRoom = - [](Connection* c, const QString& id) { return new T(c, id); }; + [](Connection* c, const QString& id, JoinState joinState) + { return new T(c, id, joinState); }; } template @@ -144,13 +152,13 @@ namespace QMatrixClient * @return a pointer to a Room object with the specified id; nullptr * if roomId is empty if createRoom() failed to create a Room object. */ - Room* provideRoom(const QString& roomId); + Room* provideRoom(const QString& roomId, JoinState joinState); private: class Private; Private* d; - static std::function createRoom; - static std::function createUser; + static room_factory_t createRoom; + static user_factory_t createUser; }; } // namespace QMatrixClient -- cgit v1.2.3 From 6b40c313f8e4a0964e857973d8f9636a9f833f9d Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Thu, 14 Sep 2017 20:19:41 +0900 Subject: Better API for clients to catch up on room list changes joinedRoom() and leftRoom() now pass the preempted Invite state of the room as well; roomMap() only returns Invite and Join rooms, not Leave. --- connection.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'connection.h') diff --git a/connection.h b/connection.h index b118ffb0..361e0870 100644 --- a/connection.h +++ b/connection.h @@ -52,7 +52,7 @@ namespace QMatrixClient Connection(); virtual ~Connection(); - const QHash, Room*>& roomMap() const; + QHash, Room*> roomMap() const; Q_INVOKABLE virtual void resolveServer(const QString& domain); Q_INVOKABLE virtual void connectToServer(const QString& user, @@ -128,8 +128,9 @@ namespace QMatrixClient void syncDone(); void newRoom(Room* room); - void joinedRoom(Room* room); - void leftRoom(Room* room); + void joinedRoom(Room* room, Room* prevInvite); + void leftRoom(Room* room, Room* prevInvite); + void aboutToDeleteRoom(Room* room); void loginError(QString error); void networkError(size_t nextAttempt, int inMilliseconds); -- cgit v1.2.3 From 726f8d464f4b29f6fd3dc92fa5493e239970b209 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 16 Sep 2017 20:39:36 +0900 Subject: provideRoom: Added invitedRoom() signal; fixed issues with some transitions Notably: * setJoinState() invocation has been missing from the previous code * processing invites did not take into account that a Leave state may already exist, thereby forcing clients that display left rooms to look through their records just in case they have to replace a Leave with Invite. * joinedRoom() was emitted even when the room is not newly joined. --- connection.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'connection.h') diff --git a/connection.h b/connection.h index 361e0870..0dcb8c3f 100644 --- a/connection.h +++ b/connection.h @@ -128,8 +128,9 @@ namespace QMatrixClient void syncDone(); void newRoom(Room* room); - void joinedRoom(Room* room, Room* prevInvite); - void leftRoom(Room* room, Room* prevInvite); + void invitedRoom(Room* room, Room* prev); + void joinedRoom(Room* room, Room* prev); + void leftRoom(Room* room, Room* prev); void aboutToDeleteRoom(Room* room); void loginError(QString error); -- cgit v1.2.3