diff options
author | n-peugnet <n.peugnet@free.fr> | 2022-10-06 19:27:24 +0200 |
---|---|---|
committer | n-peugnet <n.peugnet@free.fr> | 2022-10-06 19:27:24 +0200 |
commit | d911b207f49e936b3e992200796110f0749ed150 (patch) | |
tree | 96d20ebb4d074a4c1755e21cb316a52d584daee3 /lib/csapi/presence.h | |
parent | 8ad8a74152c5701b6ca1f9a00487ba9257a439b4 (diff) | |
parent | 56c2f2e2b809b9077393eb617828f33d144f5634 (diff) | |
download | libquotient-d911b207f49e936b3e992200796110f0749ed150.tar.gz libquotient-d911b207f49e936b3e992200796110f0749ed150.zip |
New upstream version 0.7.0
Diffstat (limited to 'lib/csapi/presence.h')
-rw-r--r-- | lib/csapi/presence.h | 180 |
1 files changed, 64 insertions, 116 deletions
diff --git a/lib/csapi/presence.h b/lib/csapi/presence.h index 86b9d395..52445205 100644 --- a/lib/csapi/presence.h +++ b/lib/csapi/presence.h @@ -6,124 +6,72 @@ #include "jobs/basejob.h" -#include "events/eventloader.h" -#include "converters.h" - -namespace QMatrixClient -{ - // Operations - - /// 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 = {}); - }; - - /// Get this user's presence state. - /// - /// Get the given user's presence state. - class GetPresenceJob : public BaseJob +namespace Quotient { + +/*! \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 QUOTIENT_API 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 = {}); +}; + +/*! \brief Get this user's presence state. + * + * Get the given user's presence state. + */ +class QUOTIENT_API 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); + + /*! \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); + + // Result properties + + /// This user's presence. + QString presence() const { return loadFromJson<QString>("presence"_ls); } + + /// The length of time in milliseconds since an action was performed + /// by this user. + Omittable<int> lastActiveAgo() const { - public: - /*! Get this user's presence state. - * \param userId - * The user whose presence state to get. - */ - explicit GetPresenceJob(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); - - ~GetPresenceJob() override; - - // Result properties + 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 - 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; - - private: - class Private; - QScopedPointer<Private> d; - }; - - /// Add or remove users from this presence list. - /// - /// Adds or removes users from this presence list. - class ModifyPresenceListJob : public BaseJob + /// Whether the user is currently active + Omittable<bool> currentlyActive() const { - public: - /*! Add or remove users from this presence list. - * \param userId - * The user whose presence list is being modified. - * \param invite - * A list of user IDs to add to the list. - * \param drop - * A list of user IDs to remove from the list. - */ - explicit ModifyPresenceListJob(const QString& userId, const QStringList& invite = {}, const QStringList& drop = {}); - }; - - /// Get presence events for this presence list. - /// - /// Retrieve a list of presence events for every user on this list. - class GetPresenceForListJob : public BaseJob - { - public: - /*! Get presence events for this presence list. - * \param userId - * The user whose presence list should be retrieved. - */ - explicit GetPresenceForListJob(const QString& userId); - - /*! Construct a URL without creating a full-fledged job object - * - * This function can be used when a URL for - * GetPresenceForListJob is necessary but the job - * itself isn't. - */ - static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId); - - ~GetPresenceForListJob() override; - - // Result properties - - /// A list of presence events for this list. - Events&& data(); - - protected: - Status parseJson(const QJsonDocument& data) override; + return loadFromJson<Omittable<bool>>("currently_active"_ls); + } +}; - private: - class Private; - QScopedPointer<Private> d; - }; -} // namespace QMatrixClient +} // namespace Quotient |