diff options
-rw-r--r-- | lib/connection.cpp | 11 | ||||
-rw-r--r-- | lib/connection.h | 15 | ||||
-rw-r--r-- | lib/room.cpp | 11 | ||||
-rw-r--r-- | lib/room.h | 13 |
4 files changed, 50 insertions, 0 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp index a5c74d88..2bdbb2e5 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -336,6 +336,7 @@ void Connection::onSyncSuccess(SyncData &&data) { } d->accountData[accountEvent->jsonType()] = accountEvent->contentJson().toVariantHash(); + emit accountDataChanged(accountEvent->jsonType()); } } @@ -647,6 +648,16 @@ QHash< QPair<QString, bool>, Room* > Connection::roomMap() const return roomMap; } +bool Connection::hasAccountData(const QString& type) const +{ + return d->accountData.contains(type); +} + +QVariantHash Connection::accountData(const QString& type) const +{ + return d->accountData.value(type); +} + QHash<QString, QVector<Room*>> Connection::tagsToRooms() const { QHash<QString, QVector<Room*>> result; diff --git a/lib/connection.h b/lib/connection.h index 016c7e3c..5a2df012 100644 --- a/lib/connection.h +++ b/lib/connection.h @@ -78,6 +78,18 @@ namespace QMatrixClient */ QHash<QPair<QString, bool>, Room*> roomMap() const; + /** Check whether the account has data of the given type + * Direct chats map is not supported by this method _yet_. + */ + bool hasAccountData(const QString& type) const; + + /** Get a generic account data event of the given type + * This returns a generic hashmap for any account data event + * stored on the server. Direct chats map cannot be retrieved + * using this method _yet_; use directChats() instead. + */ + QVariantHash accountData(const QString& type) const; + /** Get all Invited and Joined rooms grouped by tag * \return a hashmap from tag name to a vector of room pointers, * sorted by their order in the tag - details are at @@ -414,6 +426,9 @@ namespace QMatrixClient */ void createdRoom(Room* room); + /** Account data (except direct chats) have changed */ + void accountDataChanged(QString type); + /** The direct chat room is ready for using * This signal is emitted upon any successful outcome from * requestDirectChat. diff --git a/lib/room.cpp b/lib/room.cpp index 25669889..edbc9266 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -632,6 +632,16 @@ void Room::resetHighlightCount() emit highlightCountChanged(this); } +bool Room::hasAccountData(const QString& type) const +{ + return d->accountData.contains(type); +} + +QVariantHash Room::accountData(const QString& type) const +{ + return d->accountData.value(type); +} + QStringList Room::tagNames() const { return d->tags.keys(); @@ -1644,6 +1654,7 @@ void Room::processAccountDataEvent(EventPtr event) default: d->accountData[event->jsonType()] = event->contentJson().toVariantHash(); + emit accountDataChanged(event->jsonType()); } } @@ -259,6 +259,18 @@ namespace QMatrixClient Q_INVOKABLE int highlightCount() const; Q_INVOKABLE void resetHighlightCount(); + /** Check whether the room has account data of the given type + * Tags and read markers are not supported by this method _yet_. + */ + bool hasAccountData(const QString& type) const; + + /** Get a generic account data event of the given type + * This returns a generic hashmap for any room account data event + * stored on the server. Tags and read markers cannot be retrieved + * using this method _yet_. + */ + QVariantHash accountData(const QString& type) const; + QStringList tagNames() const; TagsMap tags() const; TagRecord tag(const QString& name) const; @@ -377,6 +389,7 @@ namespace QMatrixClient void readMarkerMoved(); void unreadMessagesChanged(Room* room); + void accountDataChanged(QString type); void tagsChanged(); void replacedEvent(const RoomEvent* newEvent, |