aboutsummaryrefslogtreecommitdiff
path: root/lib/room.h
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2019-10-01 13:14:30 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2019-10-01 13:14:30 +0900
commitf71d16b56ab90e494d6a41c276210a4ce593987e (patch)
tree72a029da3aea15952c673c1bc15a44f29f6e51b2 /lib/room.h
parentd0a0f8cda88d644ca38b2b90024303fbe362602c (diff)
downloadlibquotient-f71d16b56ab90e494d6a41c276210a4ce593987e.tar.gz
libquotient-f71d16b56ab90e494d6a41c276210a4ce593987e.zip
Room::getCurrentState()
Diffstat (limited to 'lib/room.h')
-rw-r--r--lib/room.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/room.h b/lib/room.h
index 698f74c8..cded7eb9 100644
--- a/lib/room.h
+++ b/lib/room.h
@@ -434,6 +434,24 @@ public:
Q_INVOKABLE bool supportsCalls() const;
+ /// Get a state event with the given event type and state key
+ /*! This method returns a (potentially empty) state event corresponding
+ * to the pair of event type \p evtType and state key \p stateKey.
+ */
+ Q_INVOKABLE const StateEventBase*
+ getCurrentState(const QString& evtType, const QString& stateKey = {}) const;
+
+ template <typename EvT>
+ const EvT* getCurrentState(const QString& stateKey = {}) const
+ {
+ const auto* evt =
+ eventCast<const EvT>(getCurrentState(EvT::matrixTypeId(), stateKey));
+ Q_ASSERT(evt);
+ Q_ASSERT(evt->matrixTypeId() == EvT::matrixTypeId()
+ && evt->stateKey() == stateKey);
+ return evt;
+ }
+
template <typename EvT, typename... ArgTs>
auto setState(ArgTs&&... args) const
{