diff options
-rw-r--r-- | lib/events/simplestateevents.h | 17 | ||||
-rw-r--r-- | lib/room.cpp | 14 | ||||
-rw-r--r-- | lib/room.h | 2 | ||||
-rw-r--r-- | libQuotient.kdev4 | 4 |
4 files changed, 37 insertions, 0 deletions
diff --git a/lib/events/simplestateevents.h b/lib/events/simplestateevents.h index d6261a8f..f22f313d 100644 --- a/lib/events/simplestateevents.h +++ b/lib/events/simplestateevents.h @@ -71,4 +71,21 @@ public: QStringList aliases() const { return content().value; } }; REGISTER_EVENT_TYPE(RoomAliasesEvent) + +class RoomPinnedEvent + : public StateEvent<EventContent::SimpleContent<QStringList>> +{ +public: + DEFINE_EVENT_TYPEID("m.room.pinned_messages", RoomPinnedEvent) + + explicit RoomPinnedEvent(const QJsonObject& json) + : StateEvent(typeId(), json, QStringLiteral("pinned")) + { } + explicit RoomPinnedEvent(const QStringList& roomEvents) + : StateEvent(typeId(), matrixTypeId(), {}, + QStringLiteral("pinned"), roomEvents) + { } + QStringList pinnedEvents() const { return content().value; } +}; +REGISTER_EVENT_TYPE(RoomPinnedEvent) } // namespace Quotient diff --git a/lib/room.cpp b/lib/room.cpp index fadcea17..4f7f7ca9 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -557,6 +557,16 @@ QString Room::canonicalAlias() const QString Room::displayName() const { return d->displayname; } +QList<const RoomEvent*> Room::pinnedEvents() const +{ + QStringList events = d->getCurrentState<RoomPinnedEvent>()->pinnedEvents(); + QList<const RoomEvent*> pinnedEvents; + QStringList::iterator i; + for (i = events.begin(); i != events.end(); ++i) + pinnedEvents.append(findInTimeline(*i)->event()); + return pinnedEvents; +} + void Room::refreshDisplayName() { d->updateDisplayname(); } QString Room::topic() const @@ -1830,6 +1840,10 @@ void Room::setCanonicalAlias(const QString& newAlias) d->requestSetState<RoomCanonicalAliasEvent>(newAlias, altAliases()); } +void Room::setPinnedMessages(const QStringList& events) +{ + d->requestSetState<RoomPinnedEvent>(events); +} void Room::setLocalAliases(const QStringList& aliases) { d->requestSetState<RoomCanonicalAliasEvent>(canonicalAlias(), aliases); @@ -191,6 +191,7 @@ public: QStringList altAliases() const; QStringList aliases() const; QString displayName() const; + QList<const RoomEvent*> pinnedEvents() const; QString topic() const; QString avatarMediaId() const; QUrl avatarUrl() const; @@ -566,6 +567,7 @@ public Q_SLOTS: SetRoomStateWithKeyJob* setState(const StateEventBase& evt) const; void setName(const QString& newName); void setCanonicalAlias(const QString& newAlias); + void setPinnedMessages(const QStringList& events); /// Set room aliases on the user's current server void setLocalAliases(const QStringList& aliases); void setTopic(const QString& newTopic); diff --git a/libQuotient.kdev4 b/libQuotient.kdev4 new file mode 100644 index 00000000..2afdb72d --- /dev/null +++ b/libQuotient.kdev4 @@ -0,0 +1,4 @@ +[Project] +CreatedFrom=CMakeLists.txt +Manager=KDevCMakeManager +Name=libQuotient |