diff options
author | Alexey Rusakov <Kitsune-Ral@users.sf.net> | 2022-07-27 20:10:03 +0200 |
---|---|---|
committer | Alexey Rusakov <Kitsune-Ral@users.sf.net> | 2022-08-05 12:34:44 +0200 |
commit | deb6c1141af445de6f3f1fd5afc83ed2ac4def4b (patch) | |
tree | 28bc31cdb721f7b72addbaf004fd3f297e3f077a /lib/connection.h | |
parent | 16fbc40f741594f44c84b29842f9287c7e2e0d5b (diff) | |
download | libquotient-deb6c1141af445de6f3f1fd5afc83ed2ac4def4b.tar.gz libquotient-deb6c1141af445de6f3f1fd5afc83ed2ac4def4b.zip |
Fix Connection::accountData<>()
The template version has never worked, to the point where instantiating
it would immediately lead to FTBFS. The new version returns an event
pointer as a simpler fix that would make it usable - in particular,
there's no more need to have separate
Connection::Private::unpackAccountData(). To simplify the fix,
eventCast() has been made more tolerating - passing nullptr to it is
processed in an expected (no-op) way now.
Diffstat (limited to 'lib/connection.h')
-rw-r--r-- | lib/connection.h | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/lib/connection.h b/lib/connection.h index b8246ecb..0d0c85b6 100644 --- a/lib/connection.h +++ b/lib/connection.h @@ -174,24 +174,25 @@ public: */ bool hasAccountData(const QString& type) const; - /** Get a generic account data event of the given type - * This returns an account data event of the given type - * stored on the server. Direct chats map cannot be retrieved - * using this method _yet_; use directChats() instead. - */ + //! \brief Get a generic account data event of the given type + //! + //! \return an account data event of the given type stored on the server, + //! or nullptr if there's none of that type. + //! \note Direct chats map cannot be retrieved using this method _yet_; + //! use directChats() instead. const EventPtr& accountData(const QString& type) const; - /** Get a generic account data event of the given type - * This returns an account data event of the given type - * stored on the server. Direct chats map cannot be retrieved - * using this method _yet_; use directChats() instead. - */ + //! \brief Get an account data event of the given type + //! + //! \return the account data content for the given event type stored + //! on the server, or a default-constructed object if there's none + //! of that type. + //! \note Direct chats map cannot be retrieved using this method _yet_; + //! use directChats() instead. template <typename EventT> - const typename EventT::content_type accountData() const + const EventT* accountData() const { - if (const auto& eventPtr = accountData(EventT::matrixTypeId())) - return eventPtr->content(); - return {}; + return eventCast<EventT>(accountData(EventT::TypeId)); } /** Get account data as a JSON object |