diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-09-21 20:55:37 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-21 20:55:37 +0900 |
commit | 4eeecd2cf3c9a33878974b93211b29df891ecc9a (patch) | |
tree | 8d2cb44133edc2237278025e2260f88595fa9971 /connection.h | |
parent | f936182135d166e5dea734775e24cabd4b763c64 (diff) | |
parent | 9cc3f82026c64862bae6a535d2b883b8cf97fba0 (diff) | |
download | libquotient-4eeecd2cf3c9a33878974b93211b29df891ecc9a.tar.gz libquotient-4eeecd2cf3c9a33878974b93211b29df891ecc9a.zip |
Merge pull request #83 from QMatrixClient/kitsune-invite-kick
Support inviting, kicking and dealing with rooms in Invite state
Diffstat (limited to 'connection.h')
-rw-r--r-- | connection.h | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/connection.h b/connection.h index 96cfb63d..4ca6fbc5 100644 --- a/connection.h +++ b/connection.h @@ -18,6 +18,8 @@ #pragma once +#include "joinstate.h" + #include <QtCore/QObject> #include <QtCore/QUrl> #include <QtCore/QSize> @@ -47,11 +49,16 @@ namespace QMatrixClient */ Q_PROPERTY(bool cacheState READ cacheState WRITE setCacheState NOTIFY cacheStateChanged) public: + using room_factory_t = + std::function<Room*(Connection*, const QString&, JoinState joinState)>; + using user_factory_t = + std::function<User*(Connection*, const QString&)>; + explicit Connection(const QUrl& server, QObject* parent = nullptr); Connection(); virtual ~Connection(); - QHash<QString, Room*> roomMap() const; + QHash<QPair<QString, bool>, Room*> roomMap() const; Q_INVOKABLE virtual void resolveServer(const QString& domain); Q_INVOKABLE virtual void connectToServer(const QString& user, @@ -149,7 +156,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 <typename T = User> @@ -167,8 +175,10 @@ namespace QMatrixClient void syncDone(); void newRoom(Room* room); - void joinedRoom(Room* room); - void leftRoom(Room* room); + 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); void networkError(size_t nextAttempt, int inMilliseconds); @@ -193,7 +203,7 @@ 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); /** @@ -205,7 +215,7 @@ namespace QMatrixClient class Private; Private* d; - static std::function<Room*(Connection*, const QString&)> createRoom; - static std::function<User*(Connection*, const QString&)> createUser; + static room_factory_t createRoom; + static user_factory_t createUser; }; } // namespace QMatrixClient |