aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/events/simplestateevents.h17
-rw-r--r--lib/room.cpp14
-rw-r--r--lib/room.h2
3 files changed, 33 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);
diff --git a/lib/room.h b/lib/room.h
index a8275ce9..60eadacc 100644
--- a/lib/room.h
+++ b/lib/room.h
@@ -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);