diff options
author | Andres Salomon <dilinger@queued.net> | 2021-01-18 04:00:14 -0500 |
---|---|---|
committer | Andres Salomon <dilinger@queued.net> | 2021-01-18 04:00:14 -0500 |
commit | 09eb39236666e81d5da014acea011dcd74d0999b (patch) | |
tree | 52876d96be71be1a39d5d935c1295a51995e8949 /lib/csapi/presence.h | |
parent | f1788ee27f33e9339334e0d79bde9a27d9ce2e44 (diff) | |
parent | a4e78956f105875625b572d8b98459ffa86fafe5 (diff) | |
download | libquotient-09eb39236666e81d5da014acea011dcd74d0999b.tar.gz libquotient-09eb39236666e81d5da014acea011dcd74d0999b.zip |
Update upstream source from tag 'upstream/0.6.4'
Update to upstream version '0.6.4'
with Debian dir aa8705fd74743e79c043bc9e3e425d5064404cfe
Diffstat (limited to 'lib/csapi/presence.h')
-rw-r--r-- | lib/csapi/presence.h | 119 |
1 files changed, 60 insertions, 59 deletions
diff --git a/lib/csapi/presence.h b/lib/csapi/presence.h index 5e132d24..a885bf4f 100644 --- a/lib/csapi/presence.h +++ b/lib/csapi/presence.h @@ -6,71 +6,72 @@ #include "jobs/basejob.h" -#include "converters.h" +namespace Quotient { -namespace QMatrixClient -{ - // Operations +/*! \brief Update this user's presence state. + * + * This API sets the given user's presence state. When setting the status, + * the activity time is updated to reflect that activity; the client does + * not need to specify the ``last_active_ago`` field. You cannot set the + * presence state of another user. + */ +class SetPresenceJob : public BaseJob { +public: + /*! \brief Update this user's presence state. + * + * \param userId + * The user whose presence state to update. + * + * \param presence + * The new presence state. + * + * \param statusMsg + * The status message to attach to this state. + */ + explicit SetPresenceJob(const QString& userId, const QString& presence, + const QString& statusMsg = {}); +}; - /// Update this user's presence state. - /// - /// This API sets the given user's presence state. When setting the status, - /// the activity time is updated to reflect that activity; the client does - /// not need to specify the ``last_active_ago`` field. You cannot set the - /// presence state of another user. - class SetPresenceJob : public BaseJob - { - public: - /*! Update this user's presence state. - * \param userId - * The user whose presence state to update. - * \param presence - * The new presence state. - * \param statusMsg - * The status message to attach to this state. - */ - explicit SetPresenceJob(const QString& userId, const QString& presence, const QString& statusMsg = {}); - }; +/*! \brief Get this user's presence state. + * + * Get the given user's presence state. + */ +class GetPresenceJob : public BaseJob { +public: + /*! \brief Get this user's presence state. + * + * \param userId + * The user whose presence state to get. + */ + explicit GetPresenceJob(const QString& userId); - /// Get this user's presence state. - /// - /// Get the given user's presence state. - class GetPresenceJob : public BaseJob - { - public: - /*! Get this user's presence state. - * \param userId - * The user whose presence state to get. - */ - explicit GetPresenceJob(const QString& userId); + /*! \brief Construct a URL without creating a full-fledged job object + * + * This function can be used when a URL for GetPresenceJob + * is necessary but the job itself isn't. + */ + static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId); - /*! Construct a URL without creating a full-fledged job object - * - * This function can be used when a URL for - * GetPresenceJob is necessary but the job - * itself isn't. - */ - static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId); + // Result properties - ~GetPresenceJob() override; + /// This user's presence. + QString presence() const { return loadFromJson<QString>("presence"_ls); } - // Result properties + /// The length of time in milliseconds since an action was performed + /// by this user. + Omittable<int> lastActiveAgo() const + { + return loadFromJson<Omittable<int>>("last_active_ago"_ls); + } - /// This user's presence. - const QString& presence() const; - /// The length of time in milliseconds since an action was performed - /// by this user. - Omittable<int> lastActiveAgo() const; - /// The state message for this user if one was set. - const QString& statusMsg() const; - /// Whether the user is currently active - Omittable<bool> currentlyActive() const; + /// The state message for this user if one was set. + QString statusMsg() const { return loadFromJson<QString>("status_msg"_ls); } - protected: - Status parseJson(const QJsonDocument& data) override; + /// Whether the user is currently active + Omittable<bool> currentlyActive() const + { + return loadFromJson<Omittable<bool>>("currently_active"_ls); + } +}; - private: - class Private; - QScopedPointer<Private> d; - }; -} // namespace QMatrixClient +} // namespace Quotient |