diff options
Diffstat (limited to 'lib/csapi')
112 files changed, 1523 insertions, 1902 deletions
diff --git a/lib/csapi/account-data.cpp b/lib/csapi/account-data.cpp index 2e466fa3..b7825718 100644 --- a/lib/csapi/account-data.cpp +++ b/lib/csapi/account-data.cpp @@ -12,11 +12,9 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -static const auto SetAccountDataJobName = QStringLiteral("SetAccountDataJob"); - SetAccountDataJob::SetAccountDataJob(const QString& userId, const QString& type, const QJsonObject& content) - : BaseJob(HttpVerb::Put, SetAccountDataJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SetAccountDataJob"), basePath % "/user/" % userId % "/account_data/" % type) { setRequestData(Data(toJson(content))); @@ -30,21 +28,16 @@ QUrl GetAccountDataJob::makeRequestUrl(QUrl baseUrl, const QString& userId, % "/account_data/" % type); } -static const auto GetAccountDataJobName = QStringLiteral("GetAccountDataJob"); - GetAccountDataJob::GetAccountDataJob(const QString& userId, const QString& type) - : BaseJob(HttpVerb::Get, GetAccountDataJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetAccountDataJob"), basePath % "/user/" % userId % "/account_data/" % type) {} -static const auto SetAccountDataPerRoomJobName = - QStringLiteral("SetAccountDataPerRoomJob"); - SetAccountDataPerRoomJob::SetAccountDataPerRoomJob(const QString& userId, const QString& roomId, const QString& type, const QJsonObject& content) - : BaseJob(HttpVerb::Put, SetAccountDataPerRoomJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SetAccountDataPerRoomJob"), basePath % "/user/" % userId % "/rooms/" % roomId % "/account_data/" % type) { @@ -61,13 +54,10 @@ QUrl GetAccountDataPerRoomJob::makeRequestUrl(QUrl baseUrl, % roomId % "/account_data/" % type); } -static const auto GetAccountDataPerRoomJobName = - QStringLiteral("GetAccountDataPerRoomJob"); - GetAccountDataPerRoomJob::GetAccountDataPerRoomJob(const QString& userId, const QString& roomId, const QString& type) - : BaseJob(HttpVerb::Get, GetAccountDataPerRoomJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetAccountDataPerRoomJob"), basePath % "/user/" % userId % "/rooms/" % roomId % "/account_data/" % type) {} diff --git a/lib/csapi/account-data.h b/lib/csapi/account-data.h index 7417da0d..a8dba5c0 100644 --- a/lib/csapi/account-data.h +++ b/lib/csapi/account-data.h @@ -8,21 +8,20 @@ #include <QtCore/QJsonObject> -namespace Quotient -{ +namespace Quotient { // Operations -/// Set some account_data for the user. -/*! +/*! \brief Set some account_data for the user. + * * Set some account_data for the client. This config is only visible to the user * that set the account_data. The config will be synced to clients in the * top-level ``account_data``. */ -class SetAccountDataJob : public BaseJob -{ +class SetAccountDataJob : public BaseJob { public: - /*! Set some account_data for the user. + /*! \brief Set some account_data for the user. + * * \param userId * The ID of the user to set account_data for. The access token must be * authorized to make requests for this user ID. @@ -36,15 +35,15 @@ public: const QJsonObject& content = {}); }; -/// Get some account_data for the user. -/*! +/*! \brief Get some account_data for the user. + * * Get some account_data for the client. This config is only visible to the user * that set the account_data. */ -class GetAccountDataJob : public BaseJob -{ +class GetAccountDataJob : public BaseJob { public: - /*! Get some account_data for the user. + /*! \brief Get some account_data for the user. + * * \param userId * The ID of the user to get account_data for. The access token must be * authorized to make requests for this user ID. @@ -54,26 +53,25 @@ public: */ explicit GetAccountDataJob(const QString& userId, const QString& type); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetAccountDataJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetAccountDataJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& type); }; -/// Set some account_data for the user. -/*! +/*! \brief Set some account_data for the user. + * * Set some account_data for the client on a given room. This config is only * visible to the user that set the account_data. The config will be synced to * clients in the per-room ``account_data``. */ -class SetAccountDataPerRoomJob : public BaseJob -{ +class SetAccountDataPerRoomJob : public BaseJob { public: - /*! Set some account_data for the user. + /*! \brief Set some account_data for the user. + * * \param userId * The ID of the user to set account_data for. The access token must be * authorized to make requests for this user ID. @@ -90,15 +88,15 @@ public: const QJsonObject& content = {}); }; -/// Get some account_data for the user. -/*! +/*! \brief Get some account_data for the user. + * * Get some account_data for the client on a given room. This config is only * visible to the user that set the account_data. */ -class GetAccountDataPerRoomJob : public BaseJob -{ +class GetAccountDataPerRoomJob : public BaseJob { public: - /*! Get some account_data for the user. + /*! \brief Get some account_data for the user. + * * \param userId * The ID of the user to set account_data for. The access token must be * authorized to make requests for this user ID. @@ -112,11 +110,10 @@ public: const QString& roomId, const QString& type); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetAccountDataPerRoomJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetAccountDataPerRoomJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& roomId, const QString& type); diff --git a/lib/csapi/admin.cpp b/lib/csapi/admin.cpp index d2c20ba8..14173e94 100644 --- a/lib/csapi/admin.cpp +++ b/lib/csapi/admin.cpp @@ -13,12 +13,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter<GetWhoIsJob::ConnectionInfo> -{ +struct JsonObjectConverter<GetWhoIsJob::ConnectionInfo> { static void fillFrom(const QJsonObject& jo, GetWhoIsJob::ConnectionInfo& result) { @@ -29,8 +27,7 @@ struct JsonObjectConverter<GetWhoIsJob::ConnectionInfo> }; template <> -struct JsonObjectConverter<GetWhoIsJob::SessionInfo> -{ +struct JsonObjectConverter<GetWhoIsJob::SessionInfo> { static void fillFrom(const QJsonObject& jo, GetWhoIsJob::SessionInfo& result) { fromJson(jo.value("connections"_ls), result.connections); @@ -38,8 +35,7 @@ struct JsonObjectConverter<GetWhoIsJob::SessionInfo> }; template <> -struct JsonObjectConverter<GetWhoIsJob::DeviceInfo> -{ +struct JsonObjectConverter<GetWhoIsJob::DeviceInfo> { static void fillFrom(const QJsonObject& jo, GetWhoIsJob::DeviceInfo& result) { fromJson(jo.value("sessions"_ls), result.sessions); @@ -48,8 +44,7 @@ struct JsonObjectConverter<GetWhoIsJob::DeviceInfo> } // namespace Quotient -class GetWhoIsJob::Private -{ +class GetWhoIsJob::Private { public: QString userId; QHash<QString, DeviceInfo> devices; @@ -61,10 +56,8 @@ QUrl GetWhoIsJob::makeRequestUrl(QUrl baseUrl, const QString& userId) basePath % "/admin/whois/" % userId); } -static const auto GetWhoIsJobName = QStringLiteral("GetWhoIsJob"); - GetWhoIsJob::GetWhoIsJob(const QString& userId) - : BaseJob(HttpVerb::Get, GetWhoIsJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetWhoIsJob"), basePath % "/admin/whois/" % userId) , d(new Private) {} diff --git a/lib/csapi/admin.h b/lib/csapi/admin.h index 472ccf72..75ae1eb0 100644 --- a/lib/csapi/admin.h +++ b/lib/csapi/admin.h @@ -11,29 +11,28 @@ #include <QtCore/QHash> #include <QtCore/QVector> -namespace Quotient -{ +namespace Quotient { // Operations -/// Gets information about a particular user. -/*! +/*! \brief Gets information about a particular user. + * * Gets information about a particular user. * * This API may be restricted to only be called by the user being looked * up, or by a server admin. Server-local administrator privileges are not * specified in this document. */ -class GetWhoIsJob : public BaseJob -{ +class GetWhoIsJob : public BaseJob { public: // Inner data structures - /// Gets information about a particular user.This API may be restricted to - /// only be called by the user being lookedup, or by a server admin. - /// Server-local administrator privileges are notspecified in this document. - struct ConnectionInfo - { + /// Gets information about a particular user. + /// + /// This API may be restricted to only be called by the user being looked + /// up, or by a server admin. Server-local administrator privileges are not + /// specified in this document. + struct ConnectionInfo { /// Most recently seen IP address of the session. QString ip; /// Unix timestamp that the session was last active. @@ -42,20 +41,22 @@ public: QString userAgent; }; - /// Gets information about a particular user.This API may be restricted to - /// only be called by the user being lookedup, or by a server admin. - /// Server-local administrator privileges are notspecified in this document. - struct SessionInfo - { + /// Gets information about a particular user. + /// + /// This API may be restricted to only be called by the user being looked + /// up, or by a server admin. Server-local administrator privileges are not + /// specified in this document. + struct SessionInfo { /// Information particular connections in the session. QVector<ConnectionInfo> connections; }; - /// Gets information about a particular user.This API may be restricted to - /// only be called by the user being lookedup, or by a server admin. - /// Server-local administrator privileges are notspecified in this document. - struct DeviceInfo - { + /// Gets information about a particular user. + /// + /// This API may be restricted to only be called by the user being looked + /// up, or by a server admin. Server-local administrator privileges are not + /// specified in this document. + struct DeviceInfo { /// A user's sessions (i.e. what they did with an access token from one /// login). QVector<SessionInfo> sessions; @@ -63,26 +64,26 @@ public: // Construction/destruction - /*! Gets information about a particular user. + /*! \brief Gets information about a particular user. + * * \param userId * The user to look up. */ explicit GetWhoIsJob(const QString& userId); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetWhoIsJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetWhoIsJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId); - ~GetWhoIsJob() override; // Result properties /// The Matrix user ID of the user. const QString& userId() const; + /// Each key is an identitfier for one of the user's devices. const QHash<QString, DeviceInfo>& devices() const; diff --git a/lib/csapi/administrative_contact.cpp b/lib/csapi/administrative_contact.cpp index 32bc8c86..36d93e73 100644 --- a/lib/csapi/administrative_contact.cpp +++ b/lib/csapi/administrative_contact.cpp @@ -13,12 +13,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter<GetAccount3PIDsJob::ThirdPartyIdentifier> -{ +struct JsonObjectConverter<GetAccount3PIDsJob::ThirdPartyIdentifier> { static void fillFrom(const QJsonObject& jo, GetAccount3PIDsJob::ThirdPartyIdentifier& result) { @@ -31,8 +29,7 @@ struct JsonObjectConverter<GetAccount3PIDsJob::ThirdPartyIdentifier> } // namespace Quotient -class GetAccount3PIDsJob::Private -{ +class GetAccount3PIDsJob::Private { public: QVector<ThirdPartyIdentifier> threepids; }; @@ -43,10 +40,9 @@ QUrl GetAccount3PIDsJob::makeRequestUrl(QUrl baseUrl) basePath % "/account/3pid"); } -static const auto GetAccount3PIDsJobName = QStringLiteral("GetAccount3PIDsJob"); - GetAccount3PIDsJob::GetAccount3PIDsJob() - : BaseJob(HttpVerb::Get, GetAccount3PIDsJobName, basePath % "/account/3pid") + : BaseJob(HttpVerb::Get, QStringLiteral("GetAccount3PIDsJob"), + basePath % "/account/3pid") , d(new Private) {} @@ -67,12 +63,10 @@ BaseJob::Status GetAccount3PIDsJob::parseJson(const QJsonDocument& data) } // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter<Post3PIDsJob::ThreePidCredentials> -{ +struct JsonObjectConverter<Post3PIDsJob::ThreePidCredentials> { static void dumpTo(QJsonObject& jo, const Post3PIDsJob::ThreePidCredentials& pod) { @@ -84,11 +78,10 @@ struct JsonObjectConverter<Post3PIDsJob::ThreePidCredentials> } // namespace Quotient -static const auto Post3PIDsJobName = QStringLiteral("Post3PIDsJob"); - Post3PIDsJob::Post3PIDsJob(const ThreePidCredentials& threePidCreds, Omittable<bool> bind) - : BaseJob(HttpVerb::Post, Post3PIDsJobName, basePath % "/account/3pid") + : BaseJob(HttpVerb::Post, QStringLiteral("Post3PIDsJob"), + basePath % "/account/3pid") { QJsonObject _data; addParam<>(_data, QStringLiteral("three_pid_creds"), threePidCreds); @@ -96,12 +89,9 @@ Post3PIDsJob::Post3PIDsJob(const ThreePidCredentials& threePidCreds, setRequestData(_data); } -static const auto Delete3pidFromAccountJobName = - QStringLiteral("Delete3pidFromAccountJob"); - Delete3pidFromAccountJob::Delete3pidFromAccountJob(const QString& medium, const QString& address) - : BaseJob(HttpVerb::Post, Delete3pidFromAccountJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("Delete3pidFromAccountJob"), basePath % "/account/3pid/delete") { QJsonObject _data; @@ -110,19 +100,15 @@ Delete3pidFromAccountJob::Delete3pidFromAccountJob(const QString& medium, setRequestData(_data); } -class RequestTokenTo3PIDEmailJob::Private -{ +class RequestTokenTo3PIDEmailJob::Private { public: Sid data; }; -static const auto RequestTokenTo3PIDEmailJobName = - QStringLiteral("RequestTokenTo3PIDEmailJob"); - RequestTokenTo3PIDEmailJob::RequestTokenTo3PIDEmailJob( const QString& clientSecret, const QString& email, int sendAttempt, const QString& idServer, const QString& nextLink) - : BaseJob(HttpVerb::Post, RequestTokenTo3PIDEmailJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenTo3PIDEmailJob"), basePath % "/account/3pid/email/requestToken", false) , d(new Private) { @@ -142,23 +128,20 @@ const Sid& RequestTokenTo3PIDEmailJob::data() const { return d->data; } BaseJob::Status RequestTokenTo3PIDEmailJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } -class RequestTokenTo3PIDMSISDNJob::Private -{ +class RequestTokenTo3PIDMSISDNJob::Private { public: Sid data; }; -static const auto RequestTokenTo3PIDMSISDNJobName = - QStringLiteral("RequestTokenTo3PIDMSISDNJob"); - RequestTokenTo3PIDMSISDNJob::RequestTokenTo3PIDMSISDNJob( const QString& clientSecret, const QString& country, const QString& phoneNumber, int sendAttempt, const QString& idServer, const QString& nextLink) - : BaseJob(HttpVerb::Post, RequestTokenTo3PIDMSISDNJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenTo3PIDMSISDNJob"), basePath % "/account/3pid/msisdn/requestToken", false) , d(new Private) { @@ -179,5 +162,6 @@ const Sid& RequestTokenTo3PIDMSISDNJob::data() const { return d->data; } BaseJob::Status RequestTokenTo3PIDMSISDNJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } diff --git a/lib/csapi/administrative_contact.h b/lib/csapi/administrative_contact.h index 4ccd7596..af98fe9c 100644 --- a/lib/csapi/administrative_contact.h +++ b/lib/csapi/administrative_contact.h @@ -12,13 +12,12 @@ #include <QtCore/QVector> -namespace Quotient -{ +namespace Quotient { // Operations -/// Gets a list of a user's third party identifiers. -/*! +/*! \brief Gets a list of a user's third party identifiers. + * * Gets a list of the third party identifiers that the homeserver has * associated with the user's account. * @@ -28,25 +27,25 @@ namespace Quotient * Identifiers in this list may be used by the homeserver as, for example, * identifiers that it will accept to reset the user's account password. */ -class GetAccount3PIDsJob : public BaseJob -{ +class GetAccount3PIDsJob : public BaseJob { public: // Inner data structures - /// Gets a list of the third party identifiers that the homeserver - /// hasassociated with the user's account.This is *not* the same as the list - /// of third party identifiers bound tothe user's Matrix ID in identity - /// servers.Identifiers in this list may be used by the homeserver as, for - /// example,identifiers that it will accept to reset the user's account - /// password. - struct ThirdPartyIdentifier - { + /// Gets a list of the third party identifiers that the homeserver has + /// associated with the user's account. + /// + /// This is *not* the same as the list of third party identifiers bound to + /// the user's Matrix ID in identity servers. + /// + /// Identifiers in this list may be used by the homeserver as, for example, + /// identifiers that it will accept to reset the user's account password. + struct ThirdPartyIdentifier { /// The medium of the third party identifier. QString medium; /// The third party identifier address. QString address; - /// The timestamp, in milliseconds, when the identifier wasvalidated by - /// the identity server. + /// The timestamp, in milliseconds, when the identifier was + /// validated by the identity server. qint64 validatedAt; /// The timestamp, in milliseconds, when the homeserver associated the /// third party identifier with the user. @@ -55,16 +54,15 @@ public: // Construction/destruction + /// Gets a list of a user's third party identifiers. explicit GetAccount3PIDsJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetAccount3PIDsJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetAccount3PIDsJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetAccount3PIDsJob() override; // Result properties @@ -87,18 +85,16 @@ private: QScopedPointer<Private> d; }; -/// Adds contact information to the user's account. -/*! +/*! \brief Adds contact information to the user's account. + * * Adds contact information to the user's account. */ -class Post3PIDsJob : public BaseJob -{ +class Post3PIDsJob : public BaseJob { public: // Inner data structures /// The third party credentials to associate with the account. - struct ThreePidCredentials - { + struct ThreePidCredentials { /// The client secret used in the session with the identity server. QString clientSecret; /// The identity server to use. @@ -109,7 +105,8 @@ public: // Construction/destruction - /*! Adds contact information to the user's account. + /*! \brief Adds contact information to the user's account. + * * \param threePidCreds * The third party credentials to associate with the account. * \param bind @@ -121,15 +118,15 @@ public: Omittable<bool> bind = none); }; -/// Deletes a third party identifier from the user's account -/*! +/*! \brief Deletes a third party identifier from the user's account + * * Removes a third party identifier from the user's account. This might not * cause an unbind of the identifier from the identity server. */ -class Delete3pidFromAccountJob : public BaseJob -{ +class Delete3pidFromAccountJob : public BaseJob { public: - /*! Deletes a third party identifier from the user's account + /*! \brief Deletes a third party identifier from the user's account + * * \param medium * The medium of the third party identifier being removed. * \param address @@ -139,9 +136,9 @@ public: const QString& address); }; -/// Begins the validation process for an email address for association with the -/// user's account. -/*! +/*! \brief Begins the validation process for an email address for association + * with the user's account. + * * Proxies the Identity Service API ``validate/email/requestToken``, but * first checks that the given email address is **not** already associated * with an account on this homeserver. This API should be used to request @@ -149,13 +146,14 @@ public: * parameters and response are identical to that of the * |/register/email/requestToken|_ endpoint. */ -class RequestTokenTo3PIDEmailJob : public BaseJob -{ +class RequestTokenTo3PIDEmailJob : public BaseJob { public: - /*! Begins the validation process for an email address for association with - * the user's account. \param clientSecret A unique string generated by the - * client, and used to identify the validation attempt. It must be a string - * consisting of the characters + /*! \brief Begins the validation process for an email address for + * association with the user's account. + * + * \param clientSecret + * A unique string generated by the client, and used to identify the + * validation attempt. It must be a string consisting of the characters * ``[0-9a-zA-Z.=_-]``. Its length must not exceed 255 characters and it * must not be empty. * \param email @@ -195,9 +193,9 @@ private: QScopedPointer<Private> d; }; -/// Begins the validation process for a phone number for association with the -/// user's account. -/*! +/*! \brief Begins the validation process for a phone number for association with + * the user's account. + * * Proxies the Identity Service API ``validate/msisdn/requestToken``, but * first checks that the given phone number is **not** already associated * with an account on this homeserver. This API should be used to request @@ -205,13 +203,14 @@ private: * parameters and response are identical to that of the * |/register/msisdn/requestToken|_ endpoint. */ -class RequestTokenTo3PIDMSISDNJob : public BaseJob -{ +class RequestTokenTo3PIDMSISDNJob : public BaseJob { public: - /*! Begins the validation process for a phone number for association with - * the user's account. \param clientSecret A unique string generated by the - * client, and used to identify the validation attempt. It must be a string - * consisting of the characters + /*! \brief Begins the validation process for a phone number for association + * with the user's account. + * + * \param clientSecret + * A unique string generated by the client, and used to identify the + * validation attempt. It must be a string consisting of the characters * ``[0-9a-zA-Z.=_-]``. Its length must not exceed 255 characters and it * must not be empty. * \param country diff --git a/lib/csapi/appservice_room_directory.cpp b/lib/csapi/appservice_room_directory.cpp index 87221aa4..bfcab2a7 100644 --- a/lib/csapi/appservice_room_directory.cpp +++ b/lib/csapi/appservice_room_directory.cpp @@ -12,12 +12,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -static const auto UpdateAppserviceRoomDirectoryVsibilityJobName = - QStringLiteral("UpdateAppserviceRoomDirectoryVsibilityJob"); - UpdateAppserviceRoomDirectoryVsibilityJob::UpdateAppserviceRoomDirectoryVsibilityJob( const QString& networkId, const QString& roomId, const QString& visibility) - : BaseJob(HttpVerb::Put, UpdateAppserviceRoomDirectoryVsibilityJobName, + : BaseJob(HttpVerb::Put, + QStringLiteral("UpdateAppserviceRoomDirectoryVsibilityJob"), basePath % "/directory/list/appservice/" % networkId % "/" % roomId) { QJsonObject _data; diff --git a/lib/csapi/appservice_room_directory.h b/lib/csapi/appservice_room_directory.h index e19bf320..f0ad78b0 100644 --- a/lib/csapi/appservice_room_directory.h +++ b/lib/csapi/appservice_room_directory.h @@ -6,13 +6,13 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Updates a room's visibility in the application service's room directory. -/*! +/*! \brief Updates a room's visibility in the application service's room + * directory. + * * Updates the visibility of a given room on the application service's room * directory. * @@ -23,10 +23,11 @@ namespace Quotient * (``as_token``) instead of a typical client's access_token. This API cannot be * invoked by users who are not identified as application services. */ -class UpdateAppserviceRoomDirectoryVsibilityJob : public BaseJob -{ +class UpdateAppserviceRoomDirectoryVsibilityJob : public BaseJob { public: - /*! Updates a room's visibility in the application service's room directory. + /*! \brief Updates a room's visibility in the application service's room + * directory. + * * \param networkId * The protocol (network) ID to update the room list for. This would * have been provided by the application service as being listed as diff --git a/lib/csapi/banning.cpp b/lib/csapi/banning.cpp index eac09d5a..6ac9b3ba 100644 --- a/lib/csapi/banning.cpp +++ b/lib/csapi/banning.cpp @@ -12,11 +12,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -static const auto BanJobName = QStringLiteral("BanJob"); - BanJob::BanJob(const QString& roomId, const QString& userId, const QString& reason) - : BaseJob(HttpVerb::Post, BanJobName, basePath % "/rooms/" % roomId % "/ban") + : BaseJob(HttpVerb::Post, QStringLiteral("BanJob"), + basePath % "/rooms/" % roomId % "/ban") { QJsonObject _data; addParam<>(_data, QStringLiteral("user_id"), userId); @@ -24,10 +23,8 @@ BanJob::BanJob(const QString& roomId, const QString& userId, setRequestData(_data); } -static const auto UnbanJobName = QStringLiteral("UnbanJob"); - UnbanJob::UnbanJob(const QString& roomId, const QString& userId) - : BaseJob(HttpVerb::Post, UnbanJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("UnbanJob"), basePath % "/rooms/" % roomId % "/unban") { QJsonObject _data; diff --git a/lib/csapi/banning.h b/lib/csapi/banning.h index 5df878a8..6bf782e7 100644 --- a/lib/csapi/banning.h +++ b/lib/csapi/banning.h @@ -6,13 +6,12 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Ban a user in the room. -/*! +/*! \brief Ban a user in the room. + * * Ban a user in the room. If the user is currently in the room, also kick them. * * When a user is banned from a room, they may not join it or be invited to it @@ -21,10 +20,10 @@ namespace Quotient * The caller must have the required power level in order to perform this * operation. */ -class BanJob : public BaseJob -{ +class BanJob : public BaseJob { public: - /*! Ban a user in the room. + /*! \brief Ban a user in the room. + * * \param roomId * The room identifier (not alias) from which the user should be banned. * \param userId @@ -37,8 +36,8 @@ public: const QString& reason = {}); }; -/// Unban a user from the room. -/*! +/*! \brief Unban a user from the room. + * * Unban a user from the room. This allows them to be invited to the room, * and join if they would otherwise be allowed to join according to its join * rules. @@ -46,10 +45,10 @@ public: * The caller must have the required power level in order to perform this * operation. */ -class UnbanJob : public BaseJob -{ +class UnbanJob : public BaseJob { public: - /*! Unban a user from the room. + /*! \brief Unban a user from the room. + * * \param roomId * The room identifier (not alias) from which the user should be unbanned. * \param userId diff --git a/lib/csapi/capabilities.cpp b/lib/csapi/capabilities.cpp index 6a544a1e..8c7ed141 100644 --- a/lib/csapi/capabilities.cpp +++ b/lib/csapi/capabilities.cpp @@ -13,12 +13,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter<GetCapabilitiesJob::ChangePasswordCapability> -{ +struct JsonObjectConverter<GetCapabilitiesJob::ChangePasswordCapability> { static void fillFrom(const QJsonObject& jo, GetCapabilitiesJob::ChangePasswordCapability& result) { @@ -27,8 +25,7 @@ struct JsonObjectConverter<GetCapabilitiesJob::ChangePasswordCapability> }; template <> -struct JsonObjectConverter<GetCapabilitiesJob::RoomVersionsCapability> -{ +struct JsonObjectConverter<GetCapabilitiesJob::RoomVersionsCapability> { static void fillFrom(const QJsonObject& jo, GetCapabilitiesJob::RoomVersionsCapability& result) { @@ -38,8 +35,7 @@ struct JsonObjectConverter<GetCapabilitiesJob::RoomVersionsCapability> }; template <> -struct JsonObjectConverter<GetCapabilitiesJob::Capabilities> -{ +struct JsonObjectConverter<GetCapabilitiesJob::Capabilities> { static void fillFrom(QJsonObject jo, GetCapabilitiesJob::Capabilities& result) { @@ -51,8 +47,7 @@ struct JsonObjectConverter<GetCapabilitiesJob::Capabilities> } // namespace Quotient -class GetCapabilitiesJob::Private -{ +class GetCapabilitiesJob::Private { public: Capabilities capabilities; }; @@ -63,10 +58,9 @@ QUrl GetCapabilitiesJob::makeRequestUrl(QUrl baseUrl) basePath % "/capabilities"); } -static const auto GetCapabilitiesJobName = QStringLiteral("GetCapabilitiesJob"); - GetCapabilitiesJob::GetCapabilitiesJob() - : BaseJob(HttpVerb::Get, GetCapabilitiesJobName, basePath % "/capabilities") + : BaseJob(HttpVerb::Get, QStringLiteral("GetCapabilitiesJob"), + basePath % "/capabilities") , d(new Private) {} diff --git a/lib/csapi/capabilities.h b/lib/csapi/capabilities.h index b608a2f2..9f46ab2e 100644 --- a/lib/csapi/capabilities.h +++ b/lib/csapi/capabilities.h @@ -11,63 +11,56 @@ #include <QtCore/QHash> #include <QtCore/QJsonObject> -namespace Quotient -{ +namespace Quotient { // Operations -/// Gets information about the server's capabilities. -/*! +/*! \brief Gets information about the server's capabilities. + * * Gets information about the server's supported feature set * and other relevant capabilities. */ -class GetCapabilitiesJob : public BaseJob -{ +class GetCapabilitiesJob : public BaseJob { public: // Inner data structures /// Capability to indicate if the user can change their password. - struct ChangePasswordCapability - { + struct ChangePasswordCapability { /// True if the user can change their password, false otherwise. bool enabled; }; /// The room versions the server supports. - struct RoomVersionsCapability - { + struct RoomVersionsCapability { /// The default room version the server is using for new rooms. QString defaultVersion; /// A detailed description of the room versions the server supports. QHash<QString, QString> available; }; - /// The custom capabilities the server supports, using theJava package - /// naming convention. - struct Capabilities - { + /// The custom capabilities the server supports, using the + /// Java package naming convention. + struct Capabilities { /// Capability to indicate if the user can change their password. Omittable<ChangePasswordCapability> changePassword; /// The room versions the server supports. Omittable<RoomVersionsCapability> roomVersions; - - /// The custom capabilities the server supports, using theJava package - /// naming convention. + /// The custom capabilities the server supports, using the + /// Java package naming convention. QHash<QString, QJsonObject> additionalProperties; }; // Construction/destruction + /// Gets information about the server's capabilities. explicit GetCapabilitiesJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetCapabilitiesJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetCapabilitiesJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetCapabilitiesJob() override; // Result properties diff --git a/lib/csapi/content-repo.cpp b/lib/csapi/content-repo.cpp index 395337f3..d811426d 100644 --- a/lib/csapi/content-repo.cpp +++ b/lib/csapi/content-repo.cpp @@ -13,8 +13,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/media/r0"); -class UploadContentJob::Private -{ +class UploadContentJob::Private { public: QString contentUri; }; @@ -26,12 +25,10 @@ BaseJob::Query queryToUploadContent(const QString& filename) return _q; } -static const auto UploadContentJobName = QStringLiteral("UploadContentJob"); - UploadContentJob::UploadContentJob(QIODevice* content, const QString& filename, const QString& contentType) - : BaseJob(HttpVerb::Post, UploadContentJobName, basePath % "/upload", - queryToUploadContent(filename)) + : BaseJob(HttpVerb::Post, QStringLiteral("UploadContentJob"), + basePath % "/upload", queryToUploadContent(filename)) , d(new Private) { setRequestHeader("Content-Type", contentType.toLatin1()); @@ -53,8 +50,7 @@ BaseJob::Status UploadContentJob::parseJson(const QJsonDocument& data) return Success; } -class GetContentJob::Private -{ +class GetContentJob::Private { public: QString contentType; QString contentDisposition; @@ -77,11 +73,9 @@ QUrl GetContentJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, queryToGetContent(allowRemote)); } -static const auto GetContentJobName = QStringLiteral("GetContentJob"); - GetContentJob::GetContentJob(const QString& serverName, const QString& mediaId, bool allowRemote) - : BaseJob(HttpVerb::Get, GetContentJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetContentJob"), basePath % "/download/" % serverName % "/" % mediaId, queryToGetContent(allowRemote), {}, false) , d(new Private) @@ -108,8 +102,7 @@ BaseJob::Status GetContentJob::parseReply(QNetworkReply* reply) return Success; } -class GetContentOverrideNameJob::Private -{ +class GetContentOverrideNameJob::Private { public: QString contentType; QString contentDisposition; @@ -135,14 +128,11 @@ QUrl GetContentOverrideNameJob::makeRequestUrl(QUrl baseUrl, queryToGetContentOverrideName(allowRemote)); } -static const auto GetContentOverrideNameJobName = - QStringLiteral("GetContentOverrideNameJob"); - GetContentOverrideNameJob::GetContentOverrideNameJob(const QString& serverName, const QString& mediaId, const QString& fileName, bool allowRemote) - : BaseJob(HttpVerb::Get, GetContentOverrideNameJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetContentOverrideNameJob"), basePath % "/download/" % serverName % "/" % mediaId % "/" % fileName, queryToGetContentOverrideName(allowRemote), {}, false) @@ -173,8 +163,7 @@ BaseJob::Status GetContentOverrideNameJob::parseReply(QNetworkReply* reply) return Success; } -class GetContentThumbnailJob::Private -{ +class GetContentThumbnailJob::Private { public: QString contentType; QIODevice* data; @@ -204,14 +193,11 @@ QUrl GetContentThumbnailJob::makeRequestUrl(QUrl baseUrl, queryToGetContentThumbnail(width, height, method, allowRemote)); } -static const auto GetContentThumbnailJobName = - QStringLiteral("GetContentThumbnailJob"); - GetContentThumbnailJob::GetContentThumbnailJob(const QString& serverName, const QString& mediaId, int width, int height, const QString& method, bool allowRemote) - : BaseJob(HttpVerb::Get, GetContentThumbnailJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetContentThumbnailJob"), basePath % "/thumbnail/" % serverName % "/" % mediaId, queryToGetContentThumbnail(width, height, method, allowRemote), {}, false) @@ -236,8 +222,7 @@ BaseJob::Status GetContentThumbnailJob::parseReply(QNetworkReply* reply) return Success; } -class GetUrlPreviewJob::Private -{ +class GetUrlPreviewJob::Private { public: Omittable<qint64> matrixImageSize; QString ogImage; @@ -258,11 +243,9 @@ QUrl GetUrlPreviewJob::makeRequestUrl(QUrl baseUrl, const QString& url, queryToGetUrlPreview(url, ts)); } -static const auto GetUrlPreviewJobName = QStringLiteral("GetUrlPreviewJob"); - GetUrlPreviewJob::GetUrlPreviewJob(const QString& url, Omittable<qint64> ts) - : BaseJob(HttpVerb::Get, GetUrlPreviewJobName, basePath % "/preview_url", - queryToGetUrlPreview(url, ts)) + : BaseJob(HttpVerb::Get, QStringLiteral("GetUrlPreviewJob"), + basePath % "/preview_url", queryToGetUrlPreview(url, ts)) , d(new Private) {} @@ -284,8 +267,7 @@ BaseJob::Status GetUrlPreviewJob::parseJson(const QJsonDocument& data) return Success; } -class GetConfigJob::Private -{ +class GetConfigJob::Private { public: Omittable<qint64> uploadSize; }; @@ -295,10 +277,9 @@ QUrl GetConfigJob::makeRequestUrl(QUrl baseUrl) return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/config"); } -static const auto GetConfigJobName = QStringLiteral("GetConfigJob"); - GetConfigJob::GetConfigJob() - : BaseJob(HttpVerb::Get, GetConfigJobName, basePath % "/config") + : BaseJob(HttpVerb::Get, QStringLiteral("GetConfigJob"), + basePath % "/config") , d(new Private) {} diff --git a/lib/csapi/content-repo.h b/lib/csapi/content-repo.h index 83069490..6263ef0b 100644 --- a/lib/csapi/content-repo.h +++ b/lib/csapi/content-repo.h @@ -10,17 +10,17 @@ #include <QtCore/QIODevice> -namespace Quotient -{ +namespace Quotient { // Operations -/// Upload some content to the content repository. - -class UploadContentJob : public BaseJob -{ +/*! \brief Upload some content to the content repository. + * + */ +class UploadContentJob : public BaseJob { public: - /*! Upload some content to the content repository. + /*! \brief Upload some content to the content repository. + * * \param content * \param filename * The name of the file being uploaded @@ -45,12 +45,13 @@ private: QScopedPointer<Private> d; }; -/// Download content from the content repository. - -class GetContentJob : public BaseJob -{ +/*! \brief Download content from the content repository. + * + */ +class GetContentJob : public BaseJob { public: - /*! Download content from the content repository. + /*! \brief Download content from the content repository. + * * \param serverName * The server name from the ``mxc://`` URI (the authoritory component) * \param mediaId @@ -63,23 +64,23 @@ public: explicit GetContentJob(const QString& serverName, const QString& mediaId, bool allowRemote = true); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetContentJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetContentJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, bool allowRemote = true); - ~GetContentJob() override; // Result properties /// The content type of the file that was previously uploaded. const QString& contentType() const; + /// The name of the file that was previously uploaded, if set. const QString& contentDisposition() const; + /// The content that was previously uploaded. QIODevice* data() const; @@ -91,12 +92,13 @@ private: QScopedPointer<Private> d; }; -/// Download content from the content repository as a given filename. - -class GetContentOverrideNameJob : public BaseJob -{ +/*! \brief Download content from the content repository as a given filename. + * + */ +class GetContentOverrideNameJob : public BaseJob { public: - /*! Download content from the content repository as a given filename. + /*! \brief Download content from the content repository as a given filename. + * * \param serverName * The server name from the ``mxc://`` URI (the authoritory component) * \param mediaId @@ -113,24 +115,24 @@ public: const QString& fileName, bool allowRemote = true); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetContentOverrideNameJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetContentOverrideNameJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, const QString& fileName, bool allowRemote = true); - ~GetContentOverrideNameJob() override; // Result properties /// The content type of the file that was previously uploaded. const QString& contentType() const; + /// The name of file given in the request const QString& contentDisposition() const; + /// The content that was previously uploaded. QIODevice* data() const; @@ -142,12 +144,13 @@ private: QScopedPointer<Private> d; }; -/// Download a thumbnail of the content from the content repository. - -class GetContentThumbnailJob : public BaseJob -{ +/*! \brief Download a thumbnail of the content from the content repository. + * + */ +class GetContentThumbnailJob : public BaseJob { public: - /*! Download a thumbnail of the content from the content repository. + /*! \brief Download a thumbnail of the content from the content repository. + * * \param serverName * The server name from the ``mxc://`` URI (the authoritory component) * \param mediaId @@ -170,23 +173,22 @@ public: int height, const QString& method = {}, bool allowRemote = true); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetContentThumbnailJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetContentThumbnailJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, int width, int height, const QString& method = {}, bool allowRemote = true); - ~GetContentThumbnailJob() override; // Result properties /// The content type of the thumbnail. const QString& contentType() const; + /// A thumbnail of the requested content. QIODevice* data() const; @@ -198,12 +200,13 @@ private: QScopedPointer<Private> d; }; -/// Get information about a URL for a client - -class GetUrlPreviewJob : public BaseJob -{ +/*! \brief Get information about a URL for a client + * + */ +class GetUrlPreviewJob : public BaseJob { public: - /*! Get information about a URL for a client + /*! \brief Get information about a URL for a client + * * \param url * The URL to get a preview of * \param ts @@ -213,21 +216,20 @@ public: */ explicit GetUrlPreviewJob(const QString& url, Omittable<qint64> ts = none); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetUrlPreviewJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetUrlPreviewJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& url, Omittable<qint64> ts = none); - ~GetUrlPreviewJob() override; // Result properties /// The byte-size of the image. Omitted if there is no image attached. Omittable<qint64> matrixImageSize() const; + /// An MXC URI to the image. Omitted if there is no image. const QString& ogImage() const; @@ -239,8 +241,8 @@ private: QScopedPointer<Private> d; }; -/// Get the configuration for the content repository. -/*! +/*! \brief Get the configuration for the content repository. + * * This endpoint allows clients to retrieve the configuration of the content * repository, such as upload limitations. * Clients SHOULD use this as a guide when using content repository endpoints. @@ -252,19 +254,17 @@ private: * content repository APIs, for example, proxies may enforce a lower upload size * limit than is advertised by the server on this endpoint. */ -class GetConfigJob : public BaseJob -{ +class GetConfigJob : public BaseJob { public: + /// Get the configuration for the content repository. explicit GetConfigJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetConfigJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetConfigJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetConfigJob() override; // Result properties diff --git a/lib/csapi/create_room.cpp b/lib/csapi/create_room.cpp index 68741f13..ec2a1855 100644 --- a/lib/csapi/create_room.cpp +++ b/lib/csapi/create_room.cpp @@ -13,12 +13,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter<CreateRoomJob::Invite3pid> -{ +struct JsonObjectConverter<CreateRoomJob::Invite3pid> { static void dumpTo(QJsonObject& jo, const CreateRoomJob::Invite3pid& pod) { addParam<>(jo, QStringLiteral("id_server"), pod.idServer); @@ -28,8 +26,7 @@ struct JsonObjectConverter<CreateRoomJob::Invite3pid> }; template <> -struct JsonObjectConverter<CreateRoomJob::StateEvent> -{ +struct JsonObjectConverter<CreateRoomJob::StateEvent> { static void dumpTo(QJsonObject& jo, const CreateRoomJob::StateEvent& pod) { addParam<>(jo, QStringLiteral("type"), pod.type); @@ -40,14 +37,11 @@ struct JsonObjectConverter<CreateRoomJob::StateEvent> } // namespace Quotient -class CreateRoomJob::Private -{ +class CreateRoomJob::Private { public: QString roomId; }; -static const auto CreateRoomJobName = QStringLiteral("CreateRoomJob"); - CreateRoomJob::CreateRoomJob(const QString& visibility, const QString& roomAliasName, const QString& name, const QString& topic, const QStringList& invite, @@ -57,7 +51,8 @@ CreateRoomJob::CreateRoomJob(const QString& visibility, const QVector<StateEvent>& initialState, const QString& preset, Omittable<bool> isDirect, const QJsonObject& powerLevelContentOverride) - : BaseJob(HttpVerb::Post, CreateRoomJobName, basePath % "/createRoom") + : BaseJob(HttpVerb::Post, QStringLiteral("CreateRoomJob"), + basePath % "/createRoom") , d(new Private) { QJsonObject _data; diff --git a/lib/csapi/create_room.h b/lib/csapi/create_room.h index e7000155..f2bd9333 100644 --- a/lib/csapi/create_room.h +++ b/lib/csapi/create_room.h @@ -11,13 +11,12 @@ #include <QtCore/QJsonObject> #include <QtCore/QVector> -namespace Quotient -{ +namespace Quotient { // Operations -/// Create a new room -/*! +/*! \brief Create a new room + * * Create a new room with various configuration options. * * The server MUST apply the normal state resolution rules when creating @@ -60,40 +59,55 @@ namespace Quotient * requesting user as the creator, alongside other keys provided in the * ``creation_content``. */ -class CreateRoomJob : public BaseJob -{ +class CreateRoomJob : public BaseJob { public: // Inner data structures - /// Create a new room with various configuration options.The server MUST - /// apply the normal state resolution rules when creatingthe new room, - /// including checking power levels for each event. It MUSTapply the events - /// implied by the request in the following order:0. A default - /// ``m.room.power_levels`` event, giving the room creator (and not other - /// members) permission to send state events. Overridden by the - /// ``power_level_content_override`` parameter.1. Events set by the - /// ``preset``. Currently these are the ``m.room.join_rules``, - /// ``m.room.history_visibility``, and ``m.room.guest_access`` state - /// events.2. Events listed in ``initial_state``, in the order that they are - /// listed.3. Events implied by ``name`` and ``topic`` (``m.room.name`` and - /// ``m.room.topic`` state events).4. Invite events implied by ``invite`` - /// and ``invite_3pid`` (``m.room.member`` with ``membership: invite`` and - /// ``m.room.third_party_invite``).The available presets do the following - /// with respect to room state:======================== ============== - /// ====================== ================ ========= Preset - /// ``join_rules`` ``history_visibility`` ``guest_access`` - /// Other======================== ============== ====================== - /// ================ =========``private_chat`` ``invite`` - /// ``shared`` ``can_join````trusted_private_chat`` ``invite`` - /// ``shared`` ``can_join`` All invitees are given the - /// same power level as the room creator.``public_chat`` ``public`` - /// ``shared`` ``forbidden``======================== - /// ============== ====================== ================ =========The - /// server will create a ``m.room.create`` event in the room with - /// therequesting user as the creator, alongside other keys provided in - /// the``creation_content``. - struct Invite3pid - { + /// Create a new room with various configuration options. + /// + /// The server MUST apply the normal state resolution rules when creating + /// the new room, including checking power levels for each event. It MUST + /// apply the events implied by the request in the following order: + /// + /// 0. A default ``m.room.power_levels`` event, giving the room creator + /// (and not other members) permission to send state events. Overridden + /// by the ``power_level_content_override`` parameter. + /// + /// 1. Events set by the ``preset``. Currently these are the + /// ``m.room.join_rules``, + /// ``m.room.history_visibility``, and ``m.room.guest_access`` state + /// events. + /// + /// 2. Events listed in ``initial_state``, in the order that they are + /// listed. + /// + /// 3. Events implied by ``name`` and ``topic`` (``m.room.name`` and + /// ``m.room.topic`` + /// state events). + /// + /// 4. Invite events implied by ``invite`` and ``invite_3pid`` + /// (``m.room.member`` with + /// ``membership: invite`` and ``m.room.third_party_invite``). + /// + /// The available presets do the following with respect to room state: + /// + /// ======================== ============== ====================== + /// ================ ========= + /// Preset ``join_rules`` ``history_visibility`` + /// ``guest_access`` Other + /// ======================== ============== ====================== + /// ================ ========= + /// ``private_chat`` ``invite`` ``shared`` ``can_join`` + /// ``trusted_private_chat`` ``invite`` ``shared`` ``can_join`` All + /// invitees are given the same power level as the room creator. + /// ``public_chat`` ``public`` ``shared`` ``forbidden`` + /// ======================== ============== ====================== + /// ================ ========= + /// + /// The server will create a ``m.room.create`` event in the room with the + /// requesting user as the creator, alongside other keys provided in the + /// ``creation_content``. + struct Invite3pid { /// The hostname+port of the identity server which should be used for /// third party identifier lookups. QString idServer; @@ -104,35 +118,51 @@ public: QString address; }; - /// Create a new room with various configuration options.The server MUST - /// apply the normal state resolution rules when creatingthe new room, - /// including checking power levels for each event. It MUSTapply the events - /// implied by the request in the following order:0. A default - /// ``m.room.power_levels`` event, giving the room creator (and not other - /// members) permission to send state events. Overridden by the - /// ``power_level_content_override`` parameter.1. Events set by the - /// ``preset``. Currently these are the ``m.room.join_rules``, - /// ``m.room.history_visibility``, and ``m.room.guest_access`` state - /// events.2. Events listed in ``initial_state``, in the order that they are - /// listed.3. Events implied by ``name`` and ``topic`` (``m.room.name`` and - /// ``m.room.topic`` state events).4. Invite events implied by ``invite`` - /// and ``invite_3pid`` (``m.room.member`` with ``membership: invite`` and - /// ``m.room.third_party_invite``).The available presets do the following - /// with respect to room state:======================== ============== - /// ====================== ================ ========= Preset - /// ``join_rules`` ``history_visibility`` ``guest_access`` - /// Other======================== ============== ====================== - /// ================ =========``private_chat`` ``invite`` - /// ``shared`` ``can_join````trusted_private_chat`` ``invite`` - /// ``shared`` ``can_join`` All invitees are given the - /// same power level as the room creator.``public_chat`` ``public`` - /// ``shared`` ``forbidden``======================== - /// ============== ====================== ================ =========The - /// server will create a ``m.room.create`` event in the room with - /// therequesting user as the creator, alongside other keys provided in - /// the``creation_content``. - struct StateEvent - { + /// Create a new room with various configuration options. + /// + /// The server MUST apply the normal state resolution rules when creating + /// the new room, including checking power levels for each event. It MUST + /// apply the events implied by the request in the following order: + /// + /// 0. A default ``m.room.power_levels`` event, giving the room creator + /// (and not other members) permission to send state events. Overridden + /// by the ``power_level_content_override`` parameter. + /// + /// 1. Events set by the ``preset``. Currently these are the + /// ``m.room.join_rules``, + /// ``m.room.history_visibility``, and ``m.room.guest_access`` state + /// events. + /// + /// 2. Events listed in ``initial_state``, in the order that they are + /// listed. + /// + /// 3. Events implied by ``name`` and ``topic`` (``m.room.name`` and + /// ``m.room.topic`` + /// state events). + /// + /// 4. Invite events implied by ``invite`` and ``invite_3pid`` + /// (``m.room.member`` with + /// ``membership: invite`` and ``m.room.third_party_invite``). + /// + /// The available presets do the following with respect to room state: + /// + /// ======================== ============== ====================== + /// ================ ========= + /// Preset ``join_rules`` ``history_visibility`` + /// ``guest_access`` Other + /// ======================== ============== ====================== + /// ================ ========= + /// ``private_chat`` ``invite`` ``shared`` ``can_join`` + /// ``trusted_private_chat`` ``invite`` ``shared`` ``can_join`` All + /// invitees are given the same power level as the room creator. + /// ``public_chat`` ``public`` ``shared`` ``forbidden`` + /// ======================== ============== ====================== + /// ================ ========= + /// + /// The server will create a ``m.room.create`` event in the room with the + /// requesting user as the creator, alongside other keys provided in the + /// ``creation_content``. + struct StateEvent { /// The type of event to send. QString type; /// The state_key of the state event. Defaults to an empty string. @@ -143,7 +173,8 @@ public: // Construction/destruction - /*! Create a new room + /*! \brief Create a new room + * * \param visibility * A ``public`` visibility indicates that the room will be shown * in the published room list. A ``private`` visibility will hide diff --git a/lib/csapi/definitions/auth_data.h b/lib/csapi/definitions/auth_data.h index 1aeea6c2..e564f7f3 100644 --- a/lib/csapi/definitions/auth_data.h +++ b/lib/csapi/definitions/auth_data.h @@ -9,17 +9,16 @@ #include <QtCore/QHash> #include <QtCore/QJsonObject> -namespace Quotient -{ +namespace Quotient { // Data structures /// Used by clients to submit authentication information to the /// interactive-authentication API -struct AuthenticationData -{ +struct AuthenticationData { /// The login type that the client is attempting to complete. QString type; + /// The value of the session key given by the homeserver. QString session; @@ -28,8 +27,7 @@ struct AuthenticationData }; template <> -struct JsonObjectConverter<AuthenticationData> -{ +struct JsonObjectConverter<AuthenticationData> { static void dumpTo(QJsonObject& jo, const AuthenticationData& pod); static void fillFrom(QJsonObject jo, AuthenticationData& pod); }; diff --git a/lib/csapi/definitions/client_device.h b/lib/csapi/definitions/client_device.h index f076c4da..2cf75950 100644 --- a/lib/csapi/definitions/client_device.h +++ b/lib/csapi/definitions/client_device.h @@ -6,30 +6,31 @@ #include "converters.h" -namespace Quotient -{ +namespace Quotient { // Data structures /// A client device -struct Device -{ +struct Device { /// Identifier of this device. QString deviceId; - /// Display name set by the user for this device. Absent if no name has - /// beenset. + + /// Display name set by the user for this device. Absent if no name has been + /// set. QString displayName; + /// The IP address where this device was last seen. (May be a few minutes - /// outof date, for efficiency reasons). + /// out of date, for efficiency reasons). QString lastSeenIp; - /// The timestamp (in milliseconds since the unix epoch) when this deviceswas - /// last seen. (May be a few minutes out of date, for efficiencyreasons). + + /// The timestamp (in milliseconds since the unix epoch) when this devices + /// was last seen. (May be a few minutes out of date, for efficiency + /// reasons). Omittable<qint64> lastSeenTs; }; template <> -struct JsonObjectConverter<Device> -{ +struct JsonObjectConverter<Device> { static void dumpTo(QJsonObject& jo, const Device& pod); static void fillFrom(const QJsonObject& jo, Device& pod); }; diff --git a/lib/csapi/definitions/device_keys.h b/lib/csapi/definitions/device_keys.h index d1d8abef..a067b4f3 100644 --- a/lib/csapi/definitions/device_keys.h +++ b/lib/csapi/definitions/device_keys.h @@ -8,35 +8,38 @@ #include <QtCore/QHash> -namespace Quotient -{ +namespace Quotient { // Data structures /// Device identity keys -struct DeviceKeys -{ - /// The ID of the user the device belongs to. Must match the user ID - /// usedwhen logging in. +struct DeviceKeys { + /// The ID of the user the device belongs to. Must match the user ID used + /// when logging in. QString userId; - /// The ID of the device these keys belong to. Must match the device ID - /// usedwhen logging in. + + /// The ID of the device these keys belong to. Must match the device ID used + /// when logging in. QString deviceId; + /// The encryption algorithms supported by this device. QStringList algorithms; - /// Public identity keys. The names of the properties should be in theformat - /// ``<algorithm>:<device_id>``. The keys themselves should beencoded as - /// specified by the key algorithm. + + /// Public identity keys. The names of the properties should be in the + /// format ``<algorithm>:<device_id>``. The keys themselves should be + /// encoded as specified by the key algorithm. QHash<QString, QString> keys; - /// Signatures for the device key object. A map from user ID, to a map - /// from``<algorithm>:<device_id>`` to the signature.The signature is - /// calculated using the process described at `SigningJSON`_. + + /// Signatures for the device key object. A map from user ID, to a map from + /// ``<algorithm>:<device_id>`` to the signature. + /// + /// The signature is calculated using the process described at `Signing + /// JSON`_. QHash<QString, QHash<QString, QString>> signatures; }; template <> -struct JsonObjectConverter<DeviceKeys> -{ +struct JsonObjectConverter<DeviceKeys> { static void dumpTo(QJsonObject& jo, const DeviceKeys& pod); static void fillFrom(const QJsonObject& jo, DeviceKeys& pod); }; diff --git a/lib/csapi/definitions/event_filter.h b/lib/csapi/definitions/event_filter.h index b41e2e9e..3958b125 100644 --- a/lib/csapi/definitions/event_filter.h +++ b/lib/csapi/definitions/event_filter.h @@ -6,27 +6,29 @@ #include "converters.h" -namespace Quotient -{ +namespace Quotient { // Data structures -struct EventFilter -{ +struct EventFilter { /// The maximum number of events to return. Omittable<int> limit; + /// A list of sender IDs to exclude. If this list is absent then no senders /// are excluded. A matching sender will be excluded even if it is listed in /// the ``'senders'`` filter. QStringList notSenders; + /// A list of event types to exclude. If this list is absent then no event /// types are excluded. A matching type will be excluded even if it is /// listed in the ``'types'`` filter. A '*' can be used as a wildcard to /// match any sequence of characters. QStringList notTypes; + /// A list of senders IDs to include. If this list is absent then all /// senders are included. QStringList senders; + /// A list of event types to include. If this list is absent then all event /// types are included. A ``'*'`` can be used as a wildcard to match any /// sequence of characters. @@ -34,8 +36,7 @@ struct EventFilter }; template <> -struct JsonObjectConverter<EventFilter> -{ +struct JsonObjectConverter<EventFilter> { static void dumpTo(QJsonObject& jo, const EventFilter& pod); static void fillFrom(const QJsonObject& jo, EventFilter& pod); }; diff --git a/lib/csapi/definitions/public_rooms_response.h b/lib/csapi/definitions/public_rooms_response.h index 1cb3aad5..36aa52b9 100644 --- a/lib/csapi/definitions/public_rooms_response.h +++ b/lib/csapi/definitions/public_rooms_response.h @@ -8,61 +8,68 @@ #include <QtCore/QVector> -namespace Quotient -{ +namespace Quotient { // Data structures -struct PublicRoomsChunk -{ +struct PublicRoomsChunk { /// Aliases of the room. May be empty. QStringList aliases; + /// The canonical alias of the room, if any. QString canonicalAlias; + /// The name of the room, if any. QString name; + /// The number of members joined to the room. int numJoinedMembers; + /// The ID of the room. QString roomId; + /// The topic of the room, if any. QString topic; + /// Whether the room may be viewed by guest users without joining. bool worldReadable; - /// Whether guest users may join the room and participate in it.If they can, - /// they will be subject to ordinary power levelrules like any other user. + + /// Whether guest users may join the room and participate in it. + /// If they can, they will be subject to ordinary power level + /// rules like any other user. bool guestCanJoin; + /// The URL for the room's avatar, if one is set. QString avatarUrl; }; template <> -struct JsonObjectConverter<PublicRoomsChunk> -{ +struct JsonObjectConverter<PublicRoomsChunk> { static void dumpTo(QJsonObject& jo, const PublicRoomsChunk& pod); static void fillFrom(const QJsonObject& jo, PublicRoomsChunk& pod); }; - /// A list of the rooms on the server. -struct PublicRoomsResponse -{ +struct PublicRoomsResponse { /// A paginated chunk of public rooms. QVector<PublicRoomsChunk> chunk; - /// A pagination token for the response. The absence of this tokenmeans - /// there are no more results to fetch and the client shouldstop paginating. + + /// A pagination token for the response. The absence of this token + /// means there are no more results to fetch and the client should + /// stop paginating. QString nextBatch; - /// A pagination token that allows fetching previous results. Theabsence of - /// this token means there are no results before thisbatch, i.e. this is the - /// first batch. + + /// A pagination token that allows fetching previous results. The + /// absence of this token means there are no results before this + /// batch, i.e. this is the first batch. QString prevBatch; - /// An estimate on the total number of public rooms, if theserver has an - /// estimate. + + /// An estimate on the total number of public rooms, if the + /// server has an estimate. Omittable<int> totalRoomCountEstimate; }; template <> -struct JsonObjectConverter<PublicRoomsResponse> -{ +struct JsonObjectConverter<PublicRoomsResponse> { static void dumpTo(QJsonObject& jo, const PublicRoomsResponse& pod); static void fillFrom(const QJsonObject& jo, PublicRoomsResponse& pod); }; diff --git a/lib/csapi/definitions/push_condition.h b/lib/csapi/definitions/push_condition.h index 34a183de..189153b3 100644 --- a/lib/csapi/definitions/push_condition.h +++ b/lib/csapi/definitions/push_condition.h @@ -6,32 +6,32 @@ #include "converters.h" -namespace Quotient -{ +namespace Quotient { // Data structures -struct PushCondition -{ - +struct PushCondition { QString kind; - /// Required for ``event_match`` conditions. The dot-separated field of - /// theevent to match. + + /// Required for ``event_match`` conditions. The dot-separated field of the + /// event to match. QString key; - /// Required for ``event_match`` conditions. The glob-style pattern tomatch - /// against. Patterns with no special glob characters should betreated as - /// having asterisks prepended and appended when testing thecondition. + + /// Required for ``event_match`` conditions. The glob-style pattern to + /// match against. Patterns with no special glob characters should be + /// treated as having asterisks prepended and appended when testing the + /// condition. QString pattern; - /// Required for ``room_member_count`` conditions. A decimal integeroptionally - /// prefixed by one of, ==, <, >, >= or <=. A prefix of < matchesrooms where - /// the member count is strictly less than the given number andso forth. If - /// no prefix is present, this parameter defaults to ==. + + /// Required for ``room_member_count`` conditions. A decimal integer + /// optionally prefixed by one of, ==, <, >, >= or <=. A prefix of < matches + /// rooms where the member count is strictly less than the given number and + /// so forth. If no prefix is present, this parameter defaults to ==. QString is; }; template <> -struct JsonObjectConverter<PushCondition> -{ +struct JsonObjectConverter<PushCondition> { static void dumpTo(QJsonObject& jo, const PushCondition& pod); static void fillFrom(const QJsonObject& jo, PushCondition& pod); }; diff --git a/lib/csapi/definitions/push_rule.h b/lib/csapi/definitions/push_rule.h index e64d6ba8..c09d063f 100644 --- a/lib/csapi/definitions/push_rule.h +++ b/lib/csapi/definitions/push_rule.h @@ -12,33 +12,35 @@ #include <QtCore/QVariant> #include <QtCore/QVector> -namespace Quotient -{ +namespace Quotient { // Data structures -struct PushRule -{ +struct PushRule { /// The actions to perform when this rule is matched. QVector<QVariant> actions; + /// Whether this is a default rule, or has been set explicitly. bool isDefault; + /// Whether the push rule is enabled or not. bool enabled; + /// The ID of this rule. QString ruleId; + /// The conditions that must hold true for an event in order for a rule to - /// beapplied to an event. A rule with no conditions always matches. - /// Onlyapplicable to ``underride`` and ``override`` rules. + /// be applied to an event. A rule with no conditions always matches. Only + /// applicable to ``underride`` and ``override`` rules. QVector<PushCondition> conditions; - /// The glob-style pattern to match against. Only applicable to - /// ``content``rules. + + /// The glob-style pattern to match against. Only applicable to ``content`` + /// rules. QString pattern; }; template <> -struct JsonObjectConverter<PushRule> -{ +struct JsonObjectConverter<PushRule> { static void dumpTo(QJsonObject& jo, const PushRule& pod); static void fillFrom(const QJsonObject& jo, PushRule& pod); }; diff --git a/lib/csapi/definitions/push_ruleset.h b/lib/csapi/definitions/push_ruleset.h index b6b9670e..98a21408 100644 --- a/lib/csapi/definitions/push_ruleset.h +++ b/lib/csapi/definitions/push_ruleset.h @@ -10,14 +10,11 @@ #include <QtCore/QVector> -namespace Quotient -{ +namespace Quotient { // Data structures -struct PushRuleset -{ - +struct PushRuleset { QVector<PushRule> content; QVector<PushRule> override; @@ -30,8 +27,7 @@ struct PushRuleset }; template <> -struct JsonObjectConverter<PushRuleset> -{ +struct JsonObjectConverter<PushRuleset> { static void dumpTo(QJsonObject& jo, const PushRuleset& pod); static void fillFrom(const QJsonObject& jo, PushRuleset& pod); }; diff --git a/lib/csapi/definitions/room_event_filter.h b/lib/csapi/definitions/room_event_filter.h index ae06a615..756f9ada 100644 --- a/lib/csapi/definitions/room_event_filter.h +++ b/lib/csapi/definitions/room_event_filter.h @@ -8,20 +8,20 @@ #include "csapi/definitions/event_filter.h" -namespace Quotient -{ +namespace Quotient { // Data structures -struct RoomEventFilter : EventFilter -{ +struct RoomEventFilter : EventFilter { /// A list of room IDs to exclude. If this list is absent then no rooms are /// excluded. A matching room will be excluded even if it is listed in the /// ``'rooms'`` filter. QStringList notRooms; + /// A list of room IDs to include. If this list is absent then all rooms are /// included. QStringList rooms; + /// If ``true``, includes only events with a ``url`` key in their content. /// If ``false``, excludes those events. If omitted, ``url`` key is not /// considered for filtering. @@ -29,8 +29,7 @@ struct RoomEventFilter : EventFilter }; template <> -struct JsonObjectConverter<RoomEventFilter> -{ +struct JsonObjectConverter<RoomEventFilter> { static void dumpTo(QJsonObject& jo, const RoomEventFilter& pod); static void fillFrom(const QJsonObject& jo, RoomEventFilter& pod); }; diff --git a/lib/csapi/definitions/sync_filter.h b/lib/csapi/definitions/sync_filter.h index 9ea39a65..ad8d055d 100644 --- a/lib/csapi/definitions/sync_filter.h +++ b/lib/csapi/definitions/sync_filter.h @@ -9,97 +9,102 @@ #include "csapi/definitions/event_filter.h" #include "csapi/definitions/room_event_filter.h" -namespace Quotient -{ +namespace Quotient { // Data structures /// The state events to include for rooms. -struct StateFilter : RoomEventFilter -{ - /// If ``true``, the only ``m.room.member`` events returned inthe ``state`` - /// section of the ``/sync`` response are thosewhich are definitely necessary - /// for a client to displaythe ``sender`` of the timeline events in that - /// response.If ``false``, ``m.room.member`` events are not filtered.By - /// default, servers should suppress duplicate redundantlazy-loaded - /// ``m.room.member`` events from being sent to a givenclient across multiple - /// calls to ``/sync``, given that most clientscache membership events (see - /// ``include_redundant_members``to change this behaviour). +struct StateFilter : RoomEventFilter { + /// If ``true``, the only ``m.room.member`` events returned in + /// the ``state`` section of the ``/sync`` response are those + /// which are definitely necessary for a client to display + /// the ``sender`` of the timeline events in that response. + /// If ``false``, ``m.room.member`` events are not filtered. + /// By default, servers should suppress duplicate redundant + /// lazy-loaded ``m.room.member`` events from being sent to a given + /// client across multiple calls to ``/sync``, given that most clients + /// cache membership events (see ``include_redundant_members`` + /// to change this behaviour). Omittable<bool> lazyLoadMembers; - /// If ``true``, the ``state`` section of the ``/sync`` response willalways - /// contain the ``m.room.member`` events required to displaythe ``sender`` - /// of the timeline events in that response, assuming``lazy_load_members`` - /// is enabled. This means that redundantduplicate member events may be - /// returned across multiple calls to``/sync``. This is useful for naive - /// clients who never trackmembership data. If ``false``, duplicate - /// ``m.room.member`` eventsmay be suppressed by the server across multiple - /// calls to ``/sync``.If ``lazy_load_members`` is ``false`` this field is - /// ignored. + + /// If ``true``, the ``state`` section of the ``/sync`` response will + /// always contain the ``m.room.member`` events required to display + /// the ``sender`` of the timeline events in that response, assuming + /// ``lazy_load_members`` is enabled. This means that redundant + /// duplicate member events may be returned across multiple calls to + /// ``/sync``. This is useful for naive clients who never track + /// membership data. If ``false``, duplicate ``m.room.member`` events + /// may be suppressed by the server across multiple calls to ``/sync``. + /// If ``lazy_load_members`` is ``false`` this field is ignored. Omittable<bool> includeRedundantMembers; }; template <> -struct JsonObjectConverter<StateFilter> -{ +struct JsonObjectConverter<StateFilter> { static void dumpTo(QJsonObject& jo, const StateFilter& pod); static void fillFrom(const QJsonObject& jo, StateFilter& pod); }; - /// Filters to be applied to room data. -struct RoomFilter -{ +struct RoomFilter { /// A list of room IDs to exclude. If this list is absent then no rooms are /// excluded. A matching room will be excluded even if it is listed in the /// ``'rooms'`` filter. This filter is applied before the filters in /// ``ephemeral``, ``state``, ``timeline`` or ``account_data`` QStringList notRooms; + /// A list of room IDs to include. If this list is absent then all rooms are /// included. This filter is applied before the filters in ``ephemeral``, /// ``state``, ``timeline`` or ``account_data`` QStringList rooms; + /// The events that aren't recorded in the room history, e.g. typing and /// receipts, to include for rooms. Omittable<RoomEventFilter> ephemeral; + /// Include rooms that the user has left in the sync, default false Omittable<bool> includeLeave; + /// The state events to include for rooms. Omittable<StateFilter> state; + /// The message and state update events to include for rooms. Omittable<RoomEventFilter> timeline; + /// The per user account data to include for rooms. Omittable<RoomEventFilter> accountData; }; template <> -struct JsonObjectConverter<RoomFilter> -{ +struct JsonObjectConverter<RoomFilter> { static void dumpTo(QJsonObject& jo, const RoomFilter& pod); static void fillFrom(const QJsonObject& jo, RoomFilter& pod); }; -struct Filter -{ +struct Filter { /// List of event fields to include. If this list is absent then all fields /// are included. The entries may include '.' charaters to indicate /// sub-fields. So ['content.body'] will include the 'body' field of the /// 'content' object. A literal '.' character in a field name may be escaped /// using a '\\'. A server may include more fields than were requested. QStringList eventFields; + /// The format to use for events. 'client' will return the events in a /// format suitable for clients. 'federation' will return the raw event as /// receieved over federation. The default is 'client'. QString eventFormat; + /// The presence updates to include. Omittable<EventFilter> presence; + /// The user account data that isn't associated with rooms to include. Omittable<EventFilter> accountData; + /// Filters to be applied to room data. Omittable<RoomFilter> room; }; template <> -struct JsonObjectConverter<Filter> -{ +struct JsonObjectConverter<Filter> { static void dumpTo(QJsonObject& jo, const Filter& pod); static void fillFrom(const QJsonObject& jo, Filter& pod); }; diff --git a/lib/csapi/definitions/user_identifier.h b/lib/csapi/definitions/user_identifier.h index 74e6ce2b..72a81677 100644 --- a/lib/csapi/definitions/user_identifier.h +++ b/lib/csapi/definitions/user_identifier.h @@ -8,14 +8,12 @@ #include <QtCore/QVariant> -namespace Quotient -{ +namespace Quotient { // Data structures /// Identification information for a user -struct UserIdentifier -{ +struct UserIdentifier { /// The type of identification. See `Identifier types`_ for supported /// values and additional property descriptions. QString type; @@ -25,8 +23,7 @@ struct UserIdentifier }; template <> -struct JsonObjectConverter<UserIdentifier> -{ +struct JsonObjectConverter<UserIdentifier> { static void dumpTo(QJsonObject& jo, const UserIdentifier& pod); static void fillFrom(QJsonObject jo, UserIdentifier& pod); }; diff --git a/lib/csapi/definitions/wellknown/full.h b/lib/csapi/definitions/wellknown/full.h index 92c8afff..88d7da79 100644 --- a/lib/csapi/definitions/wellknown/full.h +++ b/lib/csapi/definitions/wellknown/full.h @@ -12,20 +12,19 @@ #include <QtCore/QHash> #include <QtCore/QJsonObject> -namespace Quotient -{ +namespace Quotient { // Data structures -/// Used by clients to determine the homeserver, identity server, and other/// +/// Used by clients to determine the homeserver, identity server, and other /// optional components they should be interacting with. -struct DiscoveryInformation -{ - /// Used by clients to determine the homeserver, identity server, and - /// otheroptional components they should be interacting with. +struct DiscoveryInformation { + /// Used by clients to determine the homeserver, identity server, and other + /// optional components they should be interacting with. HomeserverInformation homeserver; - /// Used by clients to determine the homeserver, identity server, and - /// otheroptional components they should be interacting with. + + /// Used by clients to determine the homeserver, identity server, and other + /// optional components they should be interacting with. Omittable<IdentityServerInformation> identityServer; /// Application-dependent keys using Java package naming convention. @@ -33,8 +32,7 @@ struct DiscoveryInformation }; template <> -struct JsonObjectConverter<DiscoveryInformation> -{ +struct JsonObjectConverter<DiscoveryInformation> { static void dumpTo(QJsonObject& jo, const DiscoveryInformation& pod); static void fillFrom(QJsonObject jo, DiscoveryInformation& pod); }; diff --git a/lib/csapi/definitions/wellknown/homeserver.h b/lib/csapi/definitions/wellknown/homeserver.h index 606df88b..7607c8b5 100644 --- a/lib/csapi/definitions/wellknown/homeserver.h +++ b/lib/csapi/definitions/wellknown/homeserver.h @@ -6,21 +6,18 @@ #include "converters.h" -namespace Quotient -{ +namespace Quotient { // Data structures /// Used by clients to discover homeserver information. -struct HomeserverInformation -{ +struct HomeserverInformation { /// The base URL for the homeserver for client-server connections. QString baseUrl; }; template <> -struct JsonObjectConverter<HomeserverInformation> -{ +struct JsonObjectConverter<HomeserverInformation> { static void dumpTo(QJsonObject& jo, const HomeserverInformation& pod); static void fillFrom(const QJsonObject& jo, HomeserverInformation& pod); }; diff --git a/lib/csapi/definitions/wellknown/identity_server.h b/lib/csapi/definitions/wellknown/identity_server.h index b4304ef7..d272e527 100644 --- a/lib/csapi/definitions/wellknown/identity_server.h +++ b/lib/csapi/definitions/wellknown/identity_server.h @@ -6,21 +6,18 @@ #include "converters.h" -namespace Quotient -{ +namespace Quotient { // Data structures /// Used by clients to discover identity server information. -struct IdentityServerInformation -{ +struct IdentityServerInformation { /// The base URL for the identity server for client-server connections. QString baseUrl; }; template <> -struct JsonObjectConverter<IdentityServerInformation> -{ +struct JsonObjectConverter<IdentityServerInformation> { static void dumpTo(QJsonObject& jo, const IdentityServerInformation& pod); static void fillFrom(const QJsonObject& jo, IdentityServerInformation& pod); }; diff --git a/lib/csapi/device_management.cpp b/lib/csapi/device_management.cpp index 0889089e..ba7570f7 100644 --- a/lib/csapi/device_management.cpp +++ b/lib/csapi/device_management.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class GetDevicesJob::Private -{ +class GetDevicesJob::Private { public: QVector<Device> devices; }; @@ -23,10 +22,9 @@ QUrl GetDevicesJob::makeRequestUrl(QUrl baseUrl) return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/devices"); } -static const auto GetDevicesJobName = QStringLiteral("GetDevicesJob"); - GetDevicesJob::GetDevicesJob() - : BaseJob(HttpVerb::Get, GetDevicesJobName, basePath % "/devices") + : BaseJob(HttpVerb::Get, QStringLiteral("GetDevicesJob"), + basePath % "/devices") , d(new Private) {} @@ -42,8 +40,7 @@ BaseJob::Status GetDevicesJob::parseJson(const QJsonDocument& data) return Success; } -class GetDeviceJob::Private -{ +class GetDeviceJob::Private { public: Device data; }; @@ -54,10 +51,9 @@ QUrl GetDeviceJob::makeRequestUrl(QUrl baseUrl, const QString& deviceId) basePath % "/devices/" % deviceId); } -static const auto GetDeviceJobName = QStringLiteral("GetDeviceJob"); - GetDeviceJob::GetDeviceJob(const QString& deviceId) - : BaseJob(HttpVerb::Get, GetDeviceJobName, basePath % "/devices/" % deviceId) + : BaseJob(HttpVerb::Get, QStringLiteral("GetDeviceJob"), + basePath % "/devices/" % deviceId) , d(new Private) {} @@ -68,14 +64,13 @@ const Device& GetDeviceJob::data() const { return d->data; } BaseJob::Status GetDeviceJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } -static const auto UpdateDeviceJobName = QStringLiteral("UpdateDeviceJob"); - UpdateDeviceJob::UpdateDeviceJob(const QString& deviceId, const QString& displayName) - : BaseJob(HttpVerb::Put, UpdateDeviceJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("UpdateDeviceJob"), basePath % "/devices/" % deviceId) { QJsonObject _data; @@ -83,11 +78,9 @@ UpdateDeviceJob::UpdateDeviceJob(const QString& deviceId, setRequestData(_data); } -static const auto DeleteDeviceJobName = QStringLiteral("DeleteDeviceJob"); - DeleteDeviceJob::DeleteDeviceJob(const QString& deviceId, const Omittable<AuthenticationData>& auth) - : BaseJob(HttpVerb::Delete, DeleteDeviceJobName, + : BaseJob(HttpVerb::Delete, QStringLiteral("DeleteDeviceJob"), basePath % "/devices/" % deviceId) { QJsonObject _data; @@ -95,11 +88,10 @@ DeleteDeviceJob::DeleteDeviceJob(const QString& deviceId, setRequestData(_data); } -static const auto DeleteDevicesJobName = QStringLiteral("DeleteDevicesJob"); - DeleteDevicesJob::DeleteDevicesJob(const QStringList& devices, const Omittable<AuthenticationData>& auth) - : BaseJob(HttpVerb::Post, DeleteDevicesJobName, basePath % "/delete_devices") + : BaseJob(HttpVerb::Post, QStringLiteral("DeleteDevicesJob"), + basePath % "/delete_devices") { QJsonObject _data; addParam<>(_data, QStringLiteral("devices"), devices); diff --git a/lib/csapi/device_management.h b/lib/csapi/device_management.h index d380a44f..1c57db84 100644 --- a/lib/csapi/device_management.h +++ b/lib/csapi/device_management.h @@ -13,28 +13,25 @@ #include <QtCore/QVector> -namespace Quotient -{ +namespace Quotient { // Operations -/// List registered devices for the current user -/*! +/*! \brief List registered devices for the current user + * * Gets information about all devices for the current user. */ -class GetDevicesJob : public BaseJob -{ +class GetDevicesJob : public BaseJob { public: + /// List registered devices for the current user explicit GetDevicesJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetDevicesJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetDevicesJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetDevicesJob() override; // Result properties @@ -50,27 +47,25 @@ private: QScopedPointer<Private> d; }; -/// Get a single device -/*! +/*! \brief Get a single device + * * Gets information on a single device, by device id. */ -class GetDeviceJob : public BaseJob -{ +class GetDeviceJob : public BaseJob { public: - /*! Get a single device + /*! \brief Get a single device + * * \param deviceId * The device to retrieve. */ explicit GetDeviceJob(const QString& deviceId); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetDeviceJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetDeviceJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& deviceId); - ~GetDeviceJob() override; // Result properties @@ -86,14 +81,14 @@ private: QScopedPointer<Private> d; }; -/// Update a device -/*! +/*! \brief Update a device + * * Updates the metadata on the given device. */ -class UpdateDeviceJob : public BaseJob -{ +class UpdateDeviceJob : public BaseJob { public: - /*! Update a device + /*! \brief Update a device + * * \param deviceId * The device to update. * \param displayName @@ -104,16 +99,16 @@ public: const QString& displayName = {}); }; -/// Delete a device -/*! +/*! \brief Delete a device + * * This API endpoint uses the `User-Interactive Authentication API`_. * * Deletes the given device, and invalidates any access token associated with it. */ -class DeleteDeviceJob : public BaseJob -{ +class DeleteDeviceJob : public BaseJob { public: - /*! Delete a device + /*! \brief Delete a device + * * \param deviceId * The device to delete. * \param auth @@ -124,17 +119,17 @@ public: const Omittable<AuthenticationData>& auth = none); }; -/// Bulk deletion of devices -/*! +/*! \brief Bulk deletion of devices + * * This API endpoint uses the `User-Interactive Authentication API`_. * * Deletes the given devices, and invalidates any access token associated with * them. */ -class DeleteDevicesJob : public BaseJob -{ +class DeleteDevicesJob : public BaseJob { public: - /*! Bulk deletion of devices + /*! \brief Bulk deletion of devices + * * \param devices * The list of device IDs to delete. * \param auth diff --git a/lib/csapi/directory.cpp b/lib/csapi/directory.cpp index b2689d1e..0d4029bd 100644 --- a/lib/csapi/directory.cpp +++ b/lib/csapi/directory.cpp @@ -12,10 +12,8 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0/directory"); -static const auto SetRoomAliasJobName = QStringLiteral("SetRoomAliasJob"); - SetRoomAliasJob::SetRoomAliasJob(const QString& roomAlias, const QString& roomId) - : BaseJob(HttpVerb::Put, SetRoomAliasJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomAliasJob"), basePath % "/room/" % roomAlias) { QJsonObject _data; @@ -23,8 +21,7 @@ SetRoomAliasJob::SetRoomAliasJob(const QString& roomAlias, const QString& roomId setRequestData(_data); } -class GetRoomIdByAliasJob::Private -{ +class GetRoomIdByAliasJob::Private { public: QString roomId; QStringList servers; @@ -36,11 +33,8 @@ QUrl GetRoomIdByAliasJob::makeRequestUrl(QUrl baseUrl, const QString& roomAlias) basePath % "/room/" % roomAlias); } -static const auto GetRoomIdByAliasJobName = - QStringLiteral("GetRoomIdByAliasJob"); - GetRoomIdByAliasJob::GetRoomIdByAliasJob(const QString& roomAlias) - : BaseJob(HttpVerb::Get, GetRoomIdByAliasJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomIdByAliasJob"), basePath % "/room/" % roomAlias, false) , d(new Private) {} @@ -66,9 +60,7 @@ QUrl DeleteRoomAliasJob::makeRequestUrl(QUrl baseUrl, const QString& roomAlias) basePath % "/room/" % roomAlias); } -static const auto DeleteRoomAliasJobName = QStringLiteral("DeleteRoomAliasJob"); - DeleteRoomAliasJob::DeleteRoomAliasJob(const QString& roomAlias) - : BaseJob(HttpVerb::Delete, DeleteRoomAliasJobName, + : BaseJob(HttpVerb::Delete, QStringLiteral("DeleteRoomAliasJob"), basePath % "/room/" % roomAlias) {} diff --git a/lib/csapi/directory.h b/lib/csapi/directory.h index 7863aa1a..c13ca20a 100644 --- a/lib/csapi/directory.h +++ b/lib/csapi/directory.h @@ -6,17 +6,17 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Create a new mapping from room alias to room ID. - -class SetRoomAliasJob : public BaseJob -{ +/*! \brief Create a new mapping from room alias to room ID. + * + */ +class SetRoomAliasJob : public BaseJob { public: - /*! Create a new mapping from room alias to room ID. + /*! \brief Create a new mapping from room alias to room ID. + * * \param roomAlias * The room alias to set. * \param roomId @@ -25,37 +25,36 @@ public: explicit SetRoomAliasJob(const QString& roomAlias, const QString& roomId); }; -/// Get the room ID corresponding to this room alias. -/*! +/*! \brief Get the room ID corresponding to this room alias. + * * Requests that the server resolve a room alias to a room ID. * * The server will use the federation API to resolve the alias if the * domain part of the alias does not correspond to the server's own * domain. */ -class GetRoomIdByAliasJob : public BaseJob -{ +class GetRoomIdByAliasJob : public BaseJob { public: - /*! Get the room ID corresponding to this room alias. + /*! \brief Get the room ID corresponding to this room alias. + * * \param roomAlias * The room alias. */ explicit GetRoomIdByAliasJob(const QString& roomAlias); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetRoomIdByAliasJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetRoomIdByAliasJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomAlias); - ~GetRoomIdByAliasJob() override; // Result properties /// The room ID for this room alias. const QString& roomId() const; + /// A list of servers that are aware of this room alias. const QStringList& servers() const; @@ -67,28 +66,27 @@ private: QScopedPointer<Private> d; }; -/// Remove a mapping of room alias to room ID. -/*! +/*! \brief Remove a mapping of room alias to room ID. + * * Remove a mapping of room alias to room ID. * * Servers may choose to implement additional access control checks here, for * instance that room aliases can only be deleted by their creator or a server * administrator. */ -class DeleteRoomAliasJob : public BaseJob -{ +class DeleteRoomAliasJob : public BaseJob { public: - /*! Remove a mapping of room alias to room ID. + /*! \brief Remove a mapping of room alias to room ID. + * * \param roomAlias * The room alias to remove. */ explicit DeleteRoomAliasJob(const QString& roomAlias); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * DeleteRoomAliasJob is necessary but the job - * itself isn't. + * This function can be used when a URL for DeleteRoomAliasJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomAlias); }; diff --git a/lib/csapi/event_context.cpp b/lib/csapi/event_context.cpp index d233eedb..5bb2222e 100644 --- a/lib/csapi/event_context.cpp +++ b/lib/csapi/event_context.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class GetEventContextJob::Private -{ +class GetEventContextJob::Private { public: QString begin; QString end; @@ -40,12 +39,10 @@ QUrl GetEventContextJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, queryToGetEventContext(limit)); } -static const auto GetEventContextJobName = QStringLiteral("GetEventContextJob"); - GetEventContextJob::GetEventContextJob(const QString& roomId, const QString& eventId, Omittable<int> limit) - : BaseJob(HttpVerb::Get, GetEventContextJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetEventContextJob"), basePath % "/rooms/" % roomId % "/context/" % eventId, queryToGetEventContext(limit)) , d(new Private) diff --git a/lib/csapi/event_context.h b/lib/csapi/event_context.h index 755fc662..54441617 100644 --- a/lib/csapi/event_context.h +++ b/lib/csapi/event_context.h @@ -9,21 +9,20 @@ #include "events/eventloader.h" #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Get events and state around the specified event. -/*! +/*! \brief Get events and state around the specified event. + * * This API returns a number of events that happened just before and * after the specified event. This allows clients to get the context * surrounding an event. */ -class GetEventContextJob : public BaseJob -{ +class GetEventContextJob : public BaseJob { public: - /*! Get events and state around the specified event. + /*! \brief Get events and state around the specified event. + * * \param roomId * The room to get events from. * \param eventId @@ -34,32 +33,35 @@ public: explicit GetEventContextJob(const QString& roomId, const QString& eventId, Omittable<int> limit = none); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetEventContextJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetEventContextJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& eventId, Omittable<int> limit = none); - ~GetEventContextJob() override; // Result properties /// A token that can be used to paginate backwards with. const QString& begin() const; + /// A token that can be used to paginate forwards with. const QString& end() const; + /// A list of room events that happened just before the /// requested event, in reverse-chronological order. RoomEvents&& eventsBefore(); + /// Details of the requested event. RoomEventPtr&& event(); + /// A list of room events that happened just after the /// requested event, in chronological order. RoomEvents&& eventsAfter(); + /// The state of the room at the last event returned. StateEvents&& state(); diff --git a/lib/csapi/filter.cpp b/lib/csapi/filter.cpp index b4160ba4..98b85f83 100644 --- a/lib/csapi/filter.cpp +++ b/lib/csapi/filter.cpp @@ -12,16 +12,13 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class DefineFilterJob::Private -{ +class DefineFilterJob::Private { public: QString filterId; }; -static const auto DefineFilterJobName = QStringLiteral("DefineFilterJob"); - DefineFilterJob::DefineFilterJob(const QString& userId, const Filter& filter) - : BaseJob(HttpVerb::Post, DefineFilterJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("DefineFilterJob"), basePath % "/user/" % userId % "/filter") , d(new Private) { @@ -43,8 +40,7 @@ BaseJob::Status DefineFilterJob::parseJson(const QJsonDocument& data) return Success; } -class GetFilterJob::Private -{ +class GetFilterJob::Private { public: Filter data; }; @@ -57,10 +53,8 @@ QUrl GetFilterJob::makeRequestUrl(QUrl baseUrl, const QString& userId, % filterId); } -static const auto GetFilterJobName = QStringLiteral("GetFilterJob"); - GetFilterJob::GetFilterJob(const QString& userId, const QString& filterId) - : BaseJob(HttpVerb::Get, GetFilterJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetFilterJob"), basePath % "/user/" % userId % "/filter/" % filterId) , d(new Private) {} @@ -72,5 +66,6 @@ const Filter& GetFilterJob::data() const { return d->data; } BaseJob::Status GetFilterJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } diff --git a/lib/csapi/filter.h b/lib/csapi/filter.h index 5001a492..7a0f8958 100644 --- a/lib/csapi/filter.h +++ b/lib/csapi/filter.h @@ -10,21 +10,20 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Upload a new filter. -/*! +/*! \brief Upload a new filter. + * * Uploads a new filter definition to the homeserver. * Returns a filter ID that may be used in future requests to * restrict which events are returned to the client. */ -class DefineFilterJob : public BaseJob -{ +class DefineFilterJob : public BaseJob { public: - /*! Upload a new filter. + /*! \brief Upload a new filter. + * * \param userId * The id of the user uploading the filter. The access token must be * authorized to make requests for this user id. \param filter Uploads a new @@ -51,12 +50,13 @@ private: QScopedPointer<Private> d; }; -/// Download a filter - -class GetFilterJob : public BaseJob -{ +/*! \brief Download a filter + * + */ +class GetFilterJob : public BaseJob { public: - /*! Download a filter + /*! \brief Download a filter + * * \param userId * The user ID to download a filter for. * \param filterId @@ -64,15 +64,13 @@ public: */ explicit GetFilterJob(const QString& userId, const QString& filterId); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetFilterJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetFilterJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& filterId); - ~GetFilterJob() override; // Result properties diff --git a/lib/csapi/inviting.cpp b/lib/csapi/inviting.cpp index b60df6f8..f070c3ce 100644 --- a/lib/csapi/inviting.cpp +++ b/lib/csapi/inviting.cpp @@ -12,10 +12,8 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -static const auto InviteUserJobName = QStringLiteral("InviteUserJob"); - InviteUserJob::InviteUserJob(const QString& roomId, const QString& userId) - : BaseJob(HttpVerb::Post, InviteUserJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("InviteUserJob"), basePath % "/rooms/" % roomId % "/invite") { QJsonObject _data; diff --git a/lib/csapi/inviting.h b/lib/csapi/inviting.h index faf315b1..41d78ae6 100644 --- a/lib/csapi/inviting.h +++ b/lib/csapi/inviting.h @@ -6,13 +6,12 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Invite a user to participate in a particular room. -/*! +/*! \brief Invite a user to participate in a particular room. + * * .. _invite-by-user-id-endpoint: * * *Note that there are two forms of this API, which are documented separately. @@ -32,10 +31,10 @@ namespace Quotient * * .. _third party invites section: `invite-by-third-party-id-endpoint`_ */ -class InviteUserJob : public BaseJob -{ +class InviteUserJob : public BaseJob { public: - /*! Invite a user to participate in a particular room. + /*! \brief Invite a user to participate in a particular room. + * * \param roomId * The room identifier (not alias) to which to invite the user. * \param userId diff --git a/lib/csapi/joining.cpp b/lib/csapi/joining.cpp index 2dd617bb..cde179e0 100644 --- a/lib/csapi/joining.cpp +++ b/lib/csapi/joining.cpp @@ -13,12 +13,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter<JoinRoomByIdJob::ThirdPartySigned> -{ +struct JsonObjectConverter<JoinRoomByIdJob::ThirdPartySigned> { static void dumpTo(QJsonObject& jo, const JoinRoomByIdJob::ThirdPartySigned& pod) { @@ -31,17 +29,14 @@ struct JsonObjectConverter<JoinRoomByIdJob::ThirdPartySigned> } // namespace Quotient -class JoinRoomByIdJob::Private -{ +class JoinRoomByIdJob::Private { public: QString roomId; }; -static const auto JoinRoomByIdJobName = QStringLiteral("JoinRoomByIdJob"); - JoinRoomByIdJob::JoinRoomByIdJob( const QString& roomId, const Omittable<ThirdPartySigned>& thirdPartySigned) - : BaseJob(HttpVerb::Post, JoinRoomByIdJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("JoinRoomByIdJob"), basePath % "/rooms/" % roomId % "/join") , d(new Private) { @@ -67,12 +62,10 @@ BaseJob::Status JoinRoomByIdJob::parseJson(const QJsonDocument& data) } // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter<JoinRoomJob::Signed> -{ +struct JsonObjectConverter<JoinRoomJob::Signed> { static void dumpTo(QJsonObject& jo, const JoinRoomJob::Signed& pod) { addParam<>(jo, QStringLiteral("sender"), pod.sender); @@ -83,8 +76,7 @@ struct JsonObjectConverter<JoinRoomJob::Signed> }; template <> -struct JsonObjectConverter<JoinRoomJob::ThirdPartySigned> -{ +struct JsonObjectConverter<JoinRoomJob::ThirdPartySigned> { static void dumpTo(QJsonObject& jo, const JoinRoomJob::ThirdPartySigned& pod) { addParam<>(jo, QStringLiteral("signed"), pod.signedData); @@ -93,8 +85,7 @@ struct JsonObjectConverter<JoinRoomJob::ThirdPartySigned> } // namespace Quotient -class JoinRoomJob::Private -{ +class JoinRoomJob::Private { public: QString roomId; }; @@ -106,12 +97,10 @@ BaseJob::Query queryToJoinRoom(const QStringList& serverName) return _q; } -static const auto JoinRoomJobName = QStringLiteral("JoinRoomJob"); - JoinRoomJob::JoinRoomJob(const QString& roomIdOrAlias, const QStringList& serverName, const Omittable<ThirdPartySigned>& thirdPartySigned) - : BaseJob(HttpVerb::Post, JoinRoomJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("JoinRoomJob"), basePath % "/join/" % roomIdOrAlias, queryToJoinRoom(serverName)) , d(new Private) { diff --git a/lib/csapi/joining.h b/lib/csapi/joining.h index cf456da9..6d93bcb1 100644 --- a/lib/csapi/joining.h +++ b/lib/csapi/joining.h @@ -10,13 +10,12 @@ #include <QtCore/QJsonObject> -namespace Quotient -{ +namespace Quotient { // Operations -/// Start the requesting user participating in a particular room. -/*! +/*! \brief Start the requesting user participating in a particular room. + * * *Note that this API requires a room ID, not alias.* ``/join/{roomIdOrAlias}`` * *exists if you have a room alias.* * @@ -32,15 +31,13 @@ namespace Quotient * that it matches a pending ``m.room.third_party_invite`` event in the * room, and perform key validity checking if required by the event. */ -class JoinRoomByIdJob : public BaseJob -{ +class JoinRoomByIdJob : public BaseJob { public: // Inner data structures /// A signature of an ``m.third_party_invite`` token to prove that this user /// owns a third party identity which has been invited to the room. - struct ThirdPartySigned - { + struct ThirdPartySigned { /// The Matrix ID of the user who issued the invite. QString sender; /// The Matrix ID of the invitee. @@ -54,7 +51,8 @@ public: // Construction/destruction - /*! Start the requesting user participating in a particular room. + /*! \brief Start the requesting user participating in a particular room. + * * \param roomId * The room identifier (not alias) to join. * \param thirdPartySigned @@ -80,8 +78,8 @@ private: QScopedPointer<Private> d; }; -/// Start the requesting user participating in a particular room. -/*! +/*! \brief Start the requesting user participating in a particular room. + * * *Note that this API takes either a room ID or alias, unlike* * ``/room/{roomId}/join``. * @@ -97,23 +95,25 @@ private: * that it matches a pending ``m.room.third_party_invite`` event in the * room, and perform key validity checking if required by the event. */ -class JoinRoomJob : public BaseJob -{ +class JoinRoomJob : public BaseJob { public: // Inner data structures /// *Note that this API takes either a room ID or alias, unlike* - /// ``/room/{roomId}/join``.This API starts a user participating in a - /// particular room, if that useris allowed to participate in that room. - /// After this call, the client isallowed to see all current state events in - /// the room, and all subsequentevents associated with the room until the - /// user leaves the room.After a user has joined a room, the room will - /// appear as an entry in theresponse of the |/initialSync|_ and |/sync|_ - /// APIs.If a ``third_party_signed`` was supplied, the homeserver must - /// verifythat it matches a pending ``m.room.third_party_invite`` event in - /// theroom, and perform key validity checking if required by the event. - struct Signed - { + /// ``/room/{roomId}/join``. + /// + /// This API starts a user participating in a particular room, if that user + /// is allowed to participate in that room. After this call, the client is + /// allowed to see all current state events in the room, and all subsequent + /// events associated with the room until the user leaves the room. + /// + /// After a user has joined a room, the room will appear as an entry in the + /// response of the |/initialSync|_ and |/sync|_ APIs. + /// + /// If a ``third_party_signed`` was supplied, the homeserver must verify + /// that it matches a pending ``m.room.third_party_invite`` event in the + /// room, and perform key validity checking if required by the event. + struct Signed { /// The Matrix ID of the user who issued the invite. QString sender; /// The Matrix ID of the invitee. @@ -127,8 +127,7 @@ public: /// A signature of an ``m.third_party_invite`` token to prove that this user /// owns a third party identity which has been invited to the room. - struct ThirdPartySigned - { + struct ThirdPartySigned { /// A signature of an ``m.third_party_invite`` token to prove that this /// user owns a third party identity which has been invited to the room. Signed signedData; @@ -136,7 +135,8 @@ public: // Construction/destruction - /*! Start the requesting user participating in a particular room. + /*! \brief Start the requesting user participating in a particular room. + * * \param roomIdOrAlias * The room identifier or alias to join. * \param serverName diff --git a/lib/csapi/keys.cpp b/lib/csapi/keys.cpp index cd33ad19..b1a947b3 100644 --- a/lib/csapi/keys.cpp +++ b/lib/csapi/keys.cpp @@ -12,17 +12,15 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class UploadKeysJob::Private -{ +class UploadKeysJob::Private { public: QHash<QString, int> oneTimeKeyCounts; }; -static const auto UploadKeysJobName = QStringLiteral("UploadKeysJob"); - UploadKeysJob::UploadKeysJob(const Omittable<DeviceKeys>& deviceKeys, const QHash<QString, QVariant>& oneTimeKeys) - : BaseJob(HttpVerb::Post, UploadKeysJobName, basePath % "/keys/upload") + : BaseJob(HttpVerb::Post, QStringLiteral("UploadKeysJob"), + basePath % "/keys/upload") , d(new Private) { QJsonObject _data; @@ -50,12 +48,10 @@ BaseJob::Status UploadKeysJob::parseJson(const QJsonDocument& data) } // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter<QueryKeysJob::UnsignedDeviceInfo> -{ +struct JsonObjectConverter<QueryKeysJob::UnsignedDeviceInfo> { static void fillFrom(const QJsonObject& jo, QueryKeysJob::UnsignedDeviceInfo& result) { @@ -64,8 +60,7 @@ struct JsonObjectConverter<QueryKeysJob::UnsignedDeviceInfo> }; template <> -struct JsonObjectConverter<QueryKeysJob::DeviceInformation> -{ +struct JsonObjectConverter<QueryKeysJob::DeviceInformation> { static void fillFrom(const QJsonObject& jo, QueryKeysJob::DeviceInformation& result) { @@ -76,18 +71,16 @@ struct JsonObjectConverter<QueryKeysJob::DeviceInformation> } // namespace Quotient -class QueryKeysJob::Private -{ +class QueryKeysJob::Private { public: QHash<QString, QJsonObject> failures; QHash<QString, QHash<QString, DeviceInformation>> deviceKeys; }; -static const auto QueryKeysJobName = QStringLiteral("QueryKeysJob"); - QueryKeysJob::QueryKeysJob(const QHash<QString, QStringList>& deviceKeys, Omittable<int> timeout, const QString& token) - : BaseJob(HttpVerb::Post, QueryKeysJobName, basePath % "/keys/query") + : BaseJob(HttpVerb::Post, QStringLiteral("QueryKeysJob"), + basePath % "/keys/query") , d(new Private) { QJsonObject _data; @@ -119,19 +112,17 @@ BaseJob::Status QueryKeysJob::parseJson(const QJsonDocument& data) return Success; } -class ClaimKeysJob::Private -{ +class ClaimKeysJob::Private { public: QHash<QString, QJsonObject> failures; QHash<QString, QHash<QString, QVariant>> oneTimeKeys; }; -static const auto ClaimKeysJobName = QStringLiteral("ClaimKeysJob"); - ClaimKeysJob::ClaimKeysJob( const QHash<QString, QHash<QString, QString>>& oneTimeKeys, Omittable<int> timeout) - : BaseJob(HttpVerb::Post, ClaimKeysJobName, basePath % "/keys/claim") + : BaseJob(HttpVerb::Post, QStringLiteral("ClaimKeysJob"), + basePath % "/keys/claim") , d(new Private) { QJsonObject _data; @@ -161,8 +152,7 @@ BaseJob::Status ClaimKeysJob::parseJson(const QJsonDocument& data) return Success; } -class GetKeysChangesJob::Private -{ +class GetKeysChangesJob::Private { public: QStringList changed; QStringList left; @@ -184,11 +174,9 @@ QUrl GetKeysChangesJob::makeRequestUrl(QUrl baseUrl, const QString& from, queryToGetKeysChanges(from, to)); } -static const auto GetKeysChangesJobName = QStringLiteral("GetKeysChangesJob"); - GetKeysChangesJob::GetKeysChangesJob(const QString& from, const QString& to) - : BaseJob(HttpVerb::Get, GetKeysChangesJobName, basePath % "/keys/changes", - queryToGetKeysChanges(from, to)) + : BaseJob(HttpVerb::Get, QStringLiteral("GetKeysChangesJob"), + basePath % "/keys/changes", queryToGetKeysChanges(from, to)) , d(new Private) {} diff --git a/lib/csapi/keys.h b/lib/csapi/keys.h index 27867b8c..2673acc5 100644 --- a/lib/csapi/keys.h +++ b/lib/csapi/keys.h @@ -14,19 +14,18 @@ #include <QtCore/QJsonObject> #include <QtCore/QVariant> -namespace Quotient -{ +namespace Quotient { // Operations -/// Upload end-to-end encryption keys. -/*! +/*! \brief Upload end-to-end encryption keys. + * * Publishes end-to-end encryption keys for the device. */ -class UploadKeysJob : public BaseJob -{ +class UploadKeysJob : public BaseJob { public: - /*! Upload end-to-end encryption keys. + /*! \brief Upload end-to-end encryption keys. + * * \param deviceKeys * Identity keys for the device. May be absent if no new * identity keys are required. @@ -57,34 +56,34 @@ private: QScopedPointer<Private> d; }; -/// Download device identity keys. -/*! +/*! \brief Download device identity keys. + * * Returns the current devices and identity keys for the given users. */ -class QueryKeysJob : public BaseJob -{ +class QueryKeysJob : public BaseJob { public: // Inner data structures - /// Additional data added to the device key informationby intermediate - /// servers, and not covered by thesignatures. - struct UnsignedDeviceInfo - { + /// Additional data added to the device key information + /// by intermediate servers, and not covered by the + /// signatures. + struct UnsignedDeviceInfo { /// The display name which the user set on the device. QString deviceDisplayName; }; /// Returns the current devices and identity keys for the given users. - struct DeviceInformation : DeviceKeys - { - /// Additional data added to the device key informationby intermediate - /// servers, and not covered by thesignatures. + struct DeviceInformation : DeviceKeys { + /// Additional data added to the device key information + /// by intermediate servers, and not covered by the + /// signatures. Omittable<UnsignedDeviceInfo> unsignedData; }; // Construction/destruction - /*! Download device identity keys. + /*! \brief Download device identity keys. + * * \param deviceKeys * The keys to be downloaded. A map from user ID, to a list of * device IDs, or to an empty list to indicate all devices for the @@ -114,6 +113,7 @@ public: /// was unknown, no failure is recorded. Instead, the corresponding /// user or device is missing from the ``device_keys`` result. const QHash<QString, QJsonObject>& failures() const; + /// Information on the queried devices. A map from user ID, to a /// map from device ID to device information. For each device, /// the information returned will be the same as uploaded via @@ -129,14 +129,14 @@ private: QScopedPointer<Private> d; }; -/// Claim one-time encryption keys. -/*! +/*! \brief Claim one-time encryption keys. + * * Claims one-time keys for use in pre-key messages. */ -class ClaimKeysJob : public BaseJob -{ +class ClaimKeysJob : public BaseJob { public: - /*! Claim one-time encryption keys. + /*! \brief Claim one-time encryption keys. + * * \param oneTimeKeys * The keys to be claimed. A map from user ID, to a map from * device ID to algorithm name. @@ -160,6 +160,7 @@ public: /// was unknown, no failure is recorded. Instead, the corresponding /// user or device is missing from the ``one_time_keys`` result. const QHash<QString, QJsonObject>& failures() const; + /// One-time keys for the queried devices. A map from user ID, to a /// map from devices to a map from ``<algorithm>:<key_id>`` to the key object. const QHash<QString, QHash<QString, QVariant>>& oneTimeKeys() const; @@ -172,8 +173,8 @@ private: QScopedPointer<Private> d; }; -/// Query users with recent device key updates. -/*! +/*! \brief Query users with recent device key updates. + * * Gets a list of users who have updated their device identity keys since a * previous sync token. * @@ -184,10 +185,10 @@ private: * * added new device identity keys or removed an existing device with * identity keys, between ``from`` and ``to``. */ -class GetKeysChangesJob : public BaseJob -{ +class GetKeysChangesJob : public BaseJob { public: - /*! Query users with recent device key updates. + /*! \brief Query users with recent device key updates. + * * \param from * The desired start point of the list. Should be the ``next_batch`` field * from a response to an earlier call to |/sync|. Users who have not @@ -202,15 +203,13 @@ public: */ explicit GetKeysChangesJob(const QString& from, const QString& to); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetKeysChangesJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetKeysChangesJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& from, const QString& to); - ~GetKeysChangesJob() override; // Result properties @@ -218,6 +217,7 @@ public: /// The Matrix User IDs of all users who updated their device /// identity keys. const QStringList& changed() const; + /// The Matrix User IDs of all users who may have left all /// the end-to-end encrypted rooms they previously shared /// with the user. diff --git a/lib/csapi/kicking.cpp b/lib/csapi/kicking.cpp index ce7fcdad..39125f42 100644 --- a/lib/csapi/kicking.cpp +++ b/lib/csapi/kicking.cpp @@ -12,11 +12,9 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -static const auto KickJobName = QStringLiteral("KickJob"); - KickJob::KickJob(const QString& roomId, const QString& userId, const QString& reason) - : BaseJob(HttpVerb::Post, KickJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("KickJob"), basePath % "/rooms/" % roomId % "/kick") { QJsonObject _data; diff --git a/lib/csapi/kicking.h b/lib/csapi/kicking.h index d51edb47..0633a7f6 100644 --- a/lib/csapi/kicking.h +++ b/lib/csapi/kicking.h @@ -6,13 +6,12 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Kick a user from the room. -/*! +/*! \brief Kick a user from the room. + * * Kick a user from the room. * * The caller must have the required power level in order to perform this @@ -23,10 +22,10 @@ namespace Quotient * directly adjust the target member's state by making a request to * ``/rooms/<room id>/state/m.room.member/<user id>``. */ -class KickJob : public BaseJob -{ +class KickJob : public BaseJob { public: - /*! Kick a user from the room. + /*! \brief Kick a user from the room. + * * \param roomId * The room identifier (not alias) from which the user should be kicked. * \param userId diff --git a/lib/csapi/leaving.cpp b/lib/csapi/leaving.cpp index abf04888..2fa1da56 100644 --- a/lib/csapi/leaving.cpp +++ b/lib/csapi/leaving.cpp @@ -18,10 +18,8 @@ QUrl LeaveRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) basePath % "/rooms/" % roomId % "/leave"); } -static const auto LeaveRoomJobName = QStringLiteral("LeaveRoomJob"); - LeaveRoomJob::LeaveRoomJob(const QString& roomId) - : BaseJob(HttpVerb::Post, LeaveRoomJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("LeaveRoomJob"), basePath % "/rooms/" % roomId % "/leave") {} @@ -31,9 +29,7 @@ QUrl ForgetRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) basePath % "/rooms/" % roomId % "/forget"); } -static const auto ForgetRoomJobName = QStringLiteral("ForgetRoomJob"); - ForgetRoomJob::ForgetRoomJob(const QString& roomId) - : BaseJob(HttpVerb::Post, ForgetRoomJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("ForgetRoomJob"), basePath % "/rooms/" % roomId % "/forget") {} diff --git a/lib/csapi/leaving.h b/lib/csapi/leaving.h index 280545b0..45b983f3 100644 --- a/lib/csapi/leaving.h +++ b/lib/csapi/leaving.h @@ -6,13 +6,12 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Stop the requesting user participating in a particular room. -/*! +/*! \brief Stop the requesting user participating in a particular room. + * * This API stops a user participating in a particular room. * * If the user was already in the room, they will no longer be able to see @@ -25,26 +24,25 @@ namespace Quotient * The user will still be allowed to retrieve history from the room which * they were previously allowed to see. */ -class LeaveRoomJob : public BaseJob -{ +class LeaveRoomJob : public BaseJob { public: - /*! Stop the requesting user participating in a particular room. + /*! \brief Stop the requesting user participating in a particular room. + * * \param roomId * The room identifier to leave. */ explicit LeaveRoomJob(const QString& roomId); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * LeaveRoomJob is necessary but the job - * itself isn't. + * This function can be used when a URL for LeaveRoomJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId); }; -/// Stop the requesting user remembering about a particular room. -/*! +/*! \brief Stop the requesting user remembering about a particular room. + * * This API stops a user remembering about a particular room. * * In general, history is a first class citizen in Matrix. After this API @@ -55,20 +53,19 @@ public: * If the user is currently joined to the room, they must leave the room * before calling this API. */ -class ForgetRoomJob : public BaseJob -{ +class ForgetRoomJob : public BaseJob { public: - /*! Stop the requesting user remembering about a particular room. + /*! \brief Stop the requesting user remembering about a particular room. + * * \param roomId * The room identifier to forget. */ explicit ForgetRoomJob(const QString& roomId); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * ForgetRoomJob is necessary but the job - * itself isn't. + * This function can be used when a URL for ForgetRoomJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId); }; diff --git a/lib/csapi/list_joined_rooms.cpp b/lib/csapi/list_joined_rooms.cpp index 1260499a..34eb0d42 100644 --- a/lib/csapi/list_joined_rooms.cpp +++ b/lib/csapi/list_joined_rooms.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class GetJoinedRoomsJob::Private -{ +class GetJoinedRoomsJob::Private { public: QStringList joinedRooms; }; @@ -24,10 +23,9 @@ QUrl GetJoinedRoomsJob::makeRequestUrl(QUrl baseUrl) basePath % "/joined_rooms"); } -static const auto GetJoinedRoomsJobName = QStringLiteral("GetJoinedRoomsJob"); - GetJoinedRoomsJob::GetJoinedRoomsJob() - : BaseJob(HttpVerb::Get, GetJoinedRoomsJobName, basePath % "/joined_rooms") + : BaseJob(HttpVerb::Get, QStringLiteral("GetJoinedRoomsJob"), + basePath % "/joined_rooms") , d(new Private) {} diff --git a/lib/csapi/list_joined_rooms.h b/lib/csapi/list_joined_rooms.h index 5dab9dfc..a170d623 100644 --- a/lib/csapi/list_joined_rooms.h +++ b/lib/csapi/list_joined_rooms.h @@ -6,28 +6,25 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Lists the user's current rooms. -/*! +/*! \brief Lists the user's current rooms. + * * This API returns a list of the user's current rooms. */ -class GetJoinedRoomsJob : public BaseJob -{ +class GetJoinedRoomsJob : public BaseJob { public: + /// Lists the user's current rooms. explicit GetJoinedRoomsJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetJoinedRoomsJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetJoinedRoomsJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetJoinedRoomsJob() override; // Result properties diff --git a/lib/csapi/list_public_rooms.cpp b/lib/csapi/list_public_rooms.cpp index 0e065440..83320ec0 100644 --- a/lib/csapi/list_public_rooms.cpp +++ b/lib/csapi/list_public_rooms.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class GetRoomVisibilityOnDirectoryJob::Private -{ +class GetRoomVisibilityOnDirectoryJob::Private { public: QString visibility; }; @@ -25,12 +24,9 @@ QUrl GetRoomVisibilityOnDirectoryJob::makeRequestUrl(QUrl baseUrl, basePath % "/directory/list/room/" % roomId); } -static const auto GetRoomVisibilityOnDirectoryJobName = - QStringLiteral("GetRoomVisibilityOnDirectoryJob"); - GetRoomVisibilityOnDirectoryJob::GetRoomVisibilityOnDirectoryJob( const QString& roomId) - : BaseJob(HttpVerb::Get, GetRoomVisibilityOnDirectoryJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomVisibilityOnDirectoryJob"), basePath % "/directory/list/room/" % roomId, false) , d(new Private) {} @@ -51,12 +47,9 @@ GetRoomVisibilityOnDirectoryJob::parseJson(const QJsonDocument& data) return Success; } -static const auto SetRoomVisibilityOnDirectoryJobName = - QStringLiteral("SetRoomVisibilityOnDirectoryJob"); - SetRoomVisibilityOnDirectoryJob::SetRoomVisibilityOnDirectoryJob( const QString& roomId, const QString& visibility) - : BaseJob(HttpVerb::Put, SetRoomVisibilityOnDirectoryJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomVisibilityOnDirectoryJob"), basePath % "/directory/list/room/" % roomId) { QJsonObject _data; @@ -64,8 +57,7 @@ SetRoomVisibilityOnDirectoryJob::SetRoomVisibilityOnDirectoryJob( setRequestData(_data); } -class GetPublicRoomsJob::Private -{ +class GetPublicRoomsJob::Private { public: PublicRoomsResponse data; }; @@ -88,11 +80,10 @@ QUrl GetPublicRoomsJob::makeRequestUrl(QUrl baseUrl, Omittable<int> limit, queryToGetPublicRooms(limit, since, server)); } -static const auto GetPublicRoomsJobName = QStringLiteral("GetPublicRoomsJob"); - GetPublicRoomsJob::GetPublicRoomsJob(Omittable<int> limit, const QString& since, const QString& server) - : BaseJob(HttpVerb::Get, GetPublicRoomsJobName, basePath % "/publicRooms", + : BaseJob(HttpVerb::Get, QStringLiteral("GetPublicRoomsJob"), + basePath % "/publicRooms", queryToGetPublicRooms(limit, since, server), {}, false) , d(new Private) {} @@ -104,16 +95,15 @@ const PublicRoomsResponse& GetPublicRoomsJob::data() const { return d->data; } BaseJob::Status GetPublicRoomsJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter<QueryPublicRoomsJob::Filter> -{ +struct JsonObjectConverter<QueryPublicRoomsJob::Filter> { static void dumpTo(QJsonObject& jo, const QueryPublicRoomsJob::Filter& pod) { addParam<IfNotEmpty>(jo, QStringLiteral("generic_search_term"), @@ -123,8 +113,7 @@ struct JsonObjectConverter<QueryPublicRoomsJob::Filter> } // namespace Quotient -class QueryPublicRoomsJob::Private -{ +class QueryPublicRoomsJob::Private { public: PublicRoomsResponse data; }; @@ -136,16 +125,13 @@ BaseJob::Query queryToQueryPublicRooms(const QString& server) return _q; } -static const auto QueryPublicRoomsJobName = - QStringLiteral("QueryPublicRoomsJob"); - QueryPublicRoomsJob::QueryPublicRoomsJob(const QString& server, Omittable<int> limit, const QString& since, const Omittable<Filter>& filter, Omittable<bool> includeAllNetworks, const QString& thirdPartyInstanceId) - : BaseJob(HttpVerb::Post, QueryPublicRoomsJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("QueryPublicRoomsJob"), basePath % "/publicRooms", queryToQueryPublicRooms(server)) , d(new Private) { @@ -167,5 +153,6 @@ const PublicRoomsResponse& QueryPublicRoomsJob::data() const { return d->data; } BaseJob::Status QueryPublicRoomsJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } diff --git a/lib/csapi/list_public_rooms.h b/lib/csapi/list_public_rooms.h index e68030ad..0c9a2620 100644 --- a/lib/csapi/list_public_rooms.h +++ b/lib/csapi/list_public_rooms.h @@ -10,32 +10,29 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Gets the visibility of a room in the directory -/*! +/*! \brief Gets the visibility of a room in the directory + * * Gets the visibility of a given room on the server's public room directory. */ -class GetRoomVisibilityOnDirectoryJob : public BaseJob -{ +class GetRoomVisibilityOnDirectoryJob : public BaseJob { public: - /*! Gets the visibility of a room in the directory + /*! \brief Gets the visibility of a room in the directory + * * \param roomId * The room ID. */ explicit GetRoomVisibilityOnDirectoryJob(const QString& roomId); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetRoomVisibilityOnDirectoryJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetRoomVisibilityOnDirectoryJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId); - ~GetRoomVisibilityOnDirectoryJob() override; // Result properties @@ -51,8 +48,8 @@ private: QScopedPointer<Private> d; }; -/// Sets the visibility of a room in the room directory -/*! +/*! \brief Sets the visibility of a room in the room directory + * * Sets the visibility of a given room in the server's public room * directory. * @@ -60,10 +57,10 @@ private: * here, for instance that room visibility can only be changed by * the room creator or a server administrator. */ -class SetRoomVisibilityOnDirectoryJob : public BaseJob -{ +class SetRoomVisibilityOnDirectoryJob : public BaseJob { public: - /*! Sets the visibility of a room in the room directory + /*! \brief Sets the visibility of a room in the room directory + * * \param roomId * The room ID. * \param visibility @@ -74,17 +71,17 @@ public: const QString& visibility = {}); }; -/// Lists the public rooms on the server. -/*! +/*! \brief Lists the public rooms on the server. + * * Lists the public rooms on the server. * * This API returns paginated responses. The rooms are ordered by the number * of joined members, with the largest rooms first. */ -class GetPublicRoomsJob : public BaseJob -{ +class GetPublicRoomsJob : public BaseJob { public: - /*! Lists the public rooms on the server. + /*! \brief Lists the public rooms on the server. + * * \param limit * Limit the number of results returned. * \param since @@ -100,16 +97,14 @@ public: const QString& since = {}, const QString& server = {}); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetPublicRoomsJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetPublicRoomsJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, Omittable<int> limit = none, const QString& since = {}, const QString& server = {}); - ~GetPublicRoomsJob() override; // Result properties @@ -125,29 +120,28 @@ private: QScopedPointer<Private> d; }; -/// Lists the public rooms on the server with optional filter. -/*! +/*! \brief Lists the public rooms on the server with optional filter. + * * Lists the public rooms on the server, with optional filter. * * This API returns paginated responses. The rooms are ordered by the number * of joined members, with the largest rooms first. */ -class QueryPublicRoomsJob : public BaseJob -{ +class QueryPublicRoomsJob : public BaseJob { public: // Inner data structures /// Filter to apply to the results. - struct Filter - { - /// A string to search for in the room metadata, e.g. name,topic, - /// canonical alias etc. (Optional). + struct Filter { + /// A string to search for in the room metadata, e.g. name, + /// topic, canonical alias etc. (Optional). QString genericSearchTerm; }; // Construction/destruction - /*! Lists the public rooms on the server with optional filter. + /*! \brief Lists the public rooms on the server with optional filter. + * * \param server * The server to fetch the public room lists from. Defaults to the * local server. diff --git a/lib/csapi/login.cpp b/lib/csapi/login.cpp index 02730ff0..3e98f56b 100644 --- a/lib/csapi/login.cpp +++ b/lib/csapi/login.cpp @@ -13,12 +13,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter<GetLoginFlowsJob::LoginFlow> -{ +struct JsonObjectConverter<GetLoginFlowsJob::LoginFlow> { static void fillFrom(const QJsonObject& jo, GetLoginFlowsJob::LoginFlow& result) { @@ -28,8 +26,7 @@ struct JsonObjectConverter<GetLoginFlowsJob::LoginFlow> } // namespace Quotient -class GetLoginFlowsJob::Private -{ +class GetLoginFlowsJob::Private { public: QVector<LoginFlow> flows; }; @@ -39,10 +36,9 @@ QUrl GetLoginFlowsJob::makeRequestUrl(QUrl baseUrl) return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/login"); } -static const auto GetLoginFlowsJobName = QStringLiteral("GetLoginFlowsJob"); - GetLoginFlowsJob::GetLoginFlowsJob() - : BaseJob(HttpVerb::Get, GetLoginFlowsJobName, basePath % "/login", false) + : BaseJob(HttpVerb::Get, QStringLiteral("GetLoginFlowsJob"), + basePath % "/login", false) , d(new Private) {} @@ -61,8 +57,7 @@ BaseJob::Status GetLoginFlowsJob::parseJson(const QJsonDocument& data) return Success; } -class LoginJob::Private -{ +class LoginJob::Private { public: QString userId; QString accessToken; @@ -71,15 +66,14 @@ public: Omittable<DiscoveryInformation> wellKnown; }; -static const auto LoginJobName = QStringLiteral("LoginJob"); - LoginJob::LoginJob(const QString& type, const Omittable<UserIdentifier>& identifier, const QString& password, const QString& token, const QString& deviceId, const QString& initialDeviceDisplayName, const QString& user, const QString& medium, const QString& address) - : BaseJob(HttpVerb::Post, LoginJobName, basePath % "/login", false) + : BaseJob(HttpVerb::Post, QStringLiteral("LoginJob"), basePath % "/login", + false) , d(new Private) { QJsonObject _data; diff --git a/lib/csapi/login.h b/lib/csapi/login.h index dc944782..adecca6f 100644 --- a/lib/csapi/login.h +++ b/lib/csapi/login.h @@ -13,42 +13,39 @@ #include <QtCore/QVector> -namespace Quotient -{ +namespace Quotient { // Operations -/// Get the supported login types to authenticate users -/*! +/*! \brief Get the supported login types to authenticate users + * * Gets the homeserver's supported login types to authenticate users. Clients * should pick one of these and supply it as the ``type`` when logging in. */ -class GetLoginFlowsJob : public BaseJob -{ +class GetLoginFlowsJob : public BaseJob { public: // Inner data structures /// Gets the homeserver's supported login types to authenticate users. - /// Clientsshould pick one of these and supply it as the ``type`` when + /// Clients should pick one of these and supply it as the ``type`` when /// logging in. - struct LoginFlow - { - /// The login type. This is supplied as the ``type`` whenlogging in. + struct LoginFlow { + /// The login type. This is supplied as the ``type`` when + /// logging in. QString type; }; // Construction/destruction + /// Get the supported login types to authenticate users explicit GetLoginFlowsJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetLoginFlowsJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetLoginFlowsJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetLoginFlowsJob() override; // Result properties @@ -64,8 +61,8 @@ private: QScopedPointer<Private> d; }; -/// Authenticates the user. -/*! +/*! \brief Authenticates the user. + * * Authenticates the user, and issues an access token they can * use to authorize themself in subsequent requests. * @@ -77,10 +74,10 @@ private: * invalidate any access token previously associated with that device. See * `Relationship between access tokens and devices`_. */ -class LoginJob : public BaseJob -{ +class LoginJob : public BaseJob { public: - /*! Authenticates the user. + /*! \brief Authenticates the user. + * * \param type * The login type being used. * \param identifier @@ -116,9 +113,11 @@ public: /// The fully-qualified Matrix ID that has been registered. const QString& userId() const; + /// An access token for the account. /// This access token can then be used to authorize other requests. const QString& accessToken() const; + /// The server_name of the homeserver on which the account has /// been registered. /// @@ -126,9 +125,11 @@ public: /// ``user_id`` (by splitting at the first colon) if they require /// it. Note also that ``homeserver`` is not spelt this way. const QString& homeServer() const; + /// ID of the logged-in device. Will be the same as the /// corresponding parameter in the request, if one was specified. const QString& deviceId() const; + /// Optional client configuration provided by the server. If present, /// clients SHOULD use the provided object to reconfigure themselves, /// optionally validating the URLs within. This object takes the same diff --git a/lib/csapi/logout.cpp b/lib/csapi/logout.cpp index 4b391967..36281b79 100644 --- a/lib/csapi/logout.cpp +++ b/lib/csapi/logout.cpp @@ -17,10 +17,8 @@ QUrl LogoutJob::makeRequestUrl(QUrl baseUrl) return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/logout"); } -static const auto LogoutJobName = QStringLiteral("LogoutJob"); - LogoutJob::LogoutJob() - : BaseJob(HttpVerb::Post, LogoutJobName, basePath % "/logout") + : BaseJob(HttpVerb::Post, QStringLiteral("LogoutJob"), basePath % "/logout") {} QUrl LogoutAllJob::makeRequestUrl(QUrl baseUrl) @@ -28,8 +26,7 @@ QUrl LogoutAllJob::makeRequestUrl(QUrl baseUrl) return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/logout/all"); } -static const auto LogoutAllJobName = QStringLiteral("LogoutAllJob"); - LogoutAllJob::LogoutAllJob() - : BaseJob(HttpVerb::Post, LogoutAllJobName, basePath % "/logout/all") + : BaseJob(HttpVerb::Post, QStringLiteral("LogoutAllJob"), + basePath % "/logout/all") {} diff --git a/lib/csapi/logout.h b/lib/csapi/logout.h index 34d5a441..2a705620 100644 --- a/lib/csapi/logout.h +++ b/lib/csapi/logout.h @@ -6,32 +6,30 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Invalidates a user access token -/*! +/*! \brief Invalidates a user access token + * * Invalidates an existing access token, so that it can no longer be used for * authorization. */ -class LogoutJob : public BaseJob -{ +class LogoutJob : public BaseJob { public: + /// Invalidates a user access token explicit LogoutJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * LogoutJob is necessary but the job - * itself isn't. + * This function can be used when a URL for LogoutJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); }; -/// Invalidates all access tokens for a user -/*! +/*! \brief Invalidates all access tokens for a user + * * Invalidates all access tokens for a user, so that they can no longer be used * for authorization. This includes the access token that made this request. * @@ -41,16 +39,15 @@ public: * access tokens for the user, including the token used in the request, and * therefore the attacker is unable to take over the account in this way. */ -class LogoutAllJob : public BaseJob -{ +class LogoutAllJob : public BaseJob { public: + /// Invalidates all access tokens for a user explicit LogoutAllJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * LogoutAllJob is necessary but the job - * itself isn't. + * This function can be used when a URL for LogoutAllJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); }; diff --git a/lib/csapi/message_pagination.cpp b/lib/csapi/message_pagination.cpp index b612ee91..ba982748 100644 --- a/lib/csapi/message_pagination.cpp +++ b/lib/csapi/message_pagination.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class GetRoomEventsJob::Private -{ +class GetRoomEventsJob::Private { public: QString begin; QString end; @@ -38,17 +37,16 @@ QUrl GetRoomEventsJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& to, Omittable<int> limit, const QString& filter) { - return BaseJob::makeRequestUrl( - std::move(baseUrl), basePath % "/rooms/" % roomId % "/messages", - queryToGetRoomEvents(from, to, dir, limit, filter)); + return BaseJob::makeRequestUrl(std::move(baseUrl), + basePath % "/rooms/" % roomId % "/messages", + queryToGetRoomEvents(from, to, dir, limit, + filter)); } -static const auto GetRoomEventsJobName = QStringLiteral("GetRoomEventsJob"); - GetRoomEventsJob::GetRoomEventsJob(const QString& roomId, const QString& from, const QString& dir, const QString& to, Omittable<int> limit, const QString& filter) - : BaseJob(HttpVerb::Get, GetRoomEventsJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomEventsJob"), basePath % "/rooms/" % roomId % "/messages", queryToGetRoomEvents(from, to, dir, limit, filter)) , d(new Private) diff --git a/lib/csapi/message_pagination.h b/lib/csapi/message_pagination.h index 271e1dd9..b0d95bad 100644 --- a/lib/csapi/message_pagination.h +++ b/lib/csapi/message_pagination.h @@ -9,20 +9,19 @@ #include "events/eventloader.h" #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Get a list of events for this room -/*! +/*! \brief Get a list of events for this room + * * This API returns a list of message and state events for a room. It uses * pagination query parameters to paginate history in the room. */ -class GetRoomEventsJob : public BaseJob -{ +class GetRoomEventsJob : public BaseJob { public: - /*! Get a list of events for this room + /*! \brief Get a list of events for this room + * * \param roomId * The room to get events from. * \param from @@ -47,18 +46,16 @@ public: Omittable<int> limit = none, const QString& filter = {}); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetRoomEventsJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetRoomEventsJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& from, const QString& dir, const QString& to = {}, Omittable<int> limit = none, const QString& filter = {}); - ~GetRoomEventsJob() override; // Result properties @@ -66,9 +63,11 @@ public: /// The token the pagination starts from. If ``dir=b`` this will be /// the token supplied in ``from``. const QString& begin() const; + /// The token the pagination ends at. If ``dir=b`` this token should /// be used again to request even earlier events. const QString& end() const; + /// A list of room events. RoomEvents&& chunk(); diff --git a/lib/csapi/notifications.cpp b/lib/csapi/notifications.cpp index da568a0f..d00d5425 100644 --- a/lib/csapi/notifications.cpp +++ b/lib/csapi/notifications.cpp @@ -13,12 +13,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter<GetNotificationsJob::Notification> -{ +struct JsonObjectConverter<GetNotificationsJob::Notification> { static void fillFrom(const QJsonObject& jo, GetNotificationsJob::Notification& result) { @@ -33,8 +31,7 @@ struct JsonObjectConverter<GetNotificationsJob::Notification> } // namespace Quotient -class GetNotificationsJob::Private -{ +class GetNotificationsJob::Private { public: QString nextToken; std::vector<Notification> notifications; @@ -59,13 +56,10 @@ QUrl GetNotificationsJob::makeRequestUrl(QUrl baseUrl, const QString& from, queryToGetNotifications(from, limit, only)); } -static const auto GetNotificationsJobName = - QStringLiteral("GetNotificationsJob"); - GetNotificationsJob::GetNotificationsJob(const QString& from, Omittable<int> limit, const QString& only) - : BaseJob(HttpVerb::Get, GetNotificationsJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetNotificationsJob"), basePath % "/notifications", queryToGetNotifications(from, limit, only)) , d(new Private) diff --git a/lib/csapi/notifications.h b/lib/csapi/notifications.h index eeec5d4e..0e86e424 100644 --- a/lib/csapi/notifications.h +++ b/lib/csapi/notifications.h @@ -13,45 +13,43 @@ #include <QtCore/QVariant> #include <QtCore/QVector> -namespace Quotient -{ +namespace Quotient { // Operations -/// Gets a list of events that the user has been notified about -/*! +/*! \brief Gets a list of events that the user has been notified about + * * This API is used to paginate through the list of events that the * user has been, or would have been notified about. */ -class GetNotificationsJob : public BaseJob -{ +class GetNotificationsJob : public BaseJob { public: // Inner data structures - /// This API is used to paginate through the list of events that theuser has - /// been, or would have been notified about. - struct Notification - { - /// The action(s) to perform when the conditions for this rule are - /// met.See `Push Rules: API`_. + /// This API is used to paginate through the list of events that the + /// user has been, or would have been notified about. + struct Notification { + /// The action(s) to perform when the conditions for this rule are met. + /// See `Push Rules: API`_. QVector<QVariant> actions; /// The Event object for the event that triggered the notification. EventPtr event; /// The profile tag of the rule that matched this event. QString profileTag; - /// Indicates whether the user has sent a read receipt indicatingthat - /// they have read this message. + /// Indicates whether the user has sent a read receipt indicating + /// that they have read this message. bool read; /// The ID of the room in which the event was posted. QString roomId; - /// The unix timestamp at which the event notification was sent,in - /// milliseconds. + /// The unix timestamp at which the event notification was sent, + /// in milliseconds. int ts; }; // Construction/destruction - /*! Gets a list of events that the user has been notified about + /*! \brief Gets a list of events that the user has been notified about + * * \param from * Pagination token given to retrieve the next set of events. * \param limit @@ -65,16 +63,14 @@ public: Omittable<int> limit = none, const QString& only = {}); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetNotificationsJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetNotificationsJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& from = {}, Omittable<int> limit = none, const QString& only = {}); - ~GetNotificationsJob() override; // Result properties @@ -83,6 +79,7 @@ public: /// ``/notifications`` request in order to request more /// events. If this is absent, there are no more results. const QString& nextToken() const; + /// The list of events that triggered notifications. std::vector<Notification>&& notifications(); diff --git a/lib/csapi/openid.cpp b/lib/csapi/openid.cpp index 8c00df97..9def2377 100644 --- a/lib/csapi/openid.cpp +++ b/lib/csapi/openid.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class RequestOpenIdTokenJob::Private -{ +class RequestOpenIdTokenJob::Private { public: QString accessToken; QString tokenType; @@ -21,12 +20,9 @@ public: int expiresIn; }; -static const auto RequestOpenIdTokenJobName = - QStringLiteral("RequestOpenIdTokenJob"); - RequestOpenIdTokenJob::RequestOpenIdTokenJob(const QString& userId, const QJsonObject& body) - : BaseJob(HttpVerb::Post, RequestOpenIdTokenJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("RequestOpenIdTokenJob"), basePath % "/user/" % userId % "/openid/request_token") , d(new Private) { diff --git a/lib/csapi/openid.h b/lib/csapi/openid.h index b2f003e5..bda4ce74 100644 --- a/lib/csapi/openid.h +++ b/lib/csapi/openid.h @@ -10,13 +10,12 @@ #include <QtCore/QJsonObject> -namespace Quotient -{ +namespace Quotient { // Operations -/// Get an OpenID token object to verify the requester's identity. -/*! +/*! \brief Get an OpenID token object to verify the requester's identity. + * * Gets an OpenID token object that the requester may supply to another * service to verify their identity in Matrix. The generated token is only * valid for exchanging for user information from the federation API for @@ -26,10 +25,10 @@ namespace Quotient * be used to request another OpenID access token or call ``/sync``, for * example. */ -class RequestOpenIdTokenJob : public BaseJob -{ +class RequestOpenIdTokenJob : public BaseJob { public: - /*! Get an OpenID token object to verify the requester's identity. + /*! \brief Get an OpenID token object to verify the requester's identity. + * * \param userId * The user to request and OpenID token for. Should be the user who * is authenticated for the request. @@ -47,11 +46,14 @@ public: /// the person who generated the token. This is given to the federation /// API ``GET /openid/userinfo``. const QString& accessToken() const; + /// The string ``Bearer``. const QString& tokenType() const; + /// The homeserver domain the consumer should use when attempting to /// verify the user's identity. const QString& matrixServerName() const; + /// The number of seconds before this token expires and a new one must /// be generated. int expiresIn() const; diff --git a/lib/csapi/peeking_events.cpp b/lib/csapi/peeking_events.cpp index bc29b682..4d886812 100644 --- a/lib/csapi/peeking_events.cpp +++ b/lib/csapi/peeking_events.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class PeekEventsJob::Private -{ +class PeekEventsJob::Private { public: QString begin; QString end; @@ -37,12 +36,10 @@ QUrl PeekEventsJob::makeRequestUrl(QUrl baseUrl, const QString& from, queryToPeekEvents(from, timeout, roomId)); } -static const auto PeekEventsJobName = QStringLiteral("PeekEventsJob"); - PeekEventsJob::PeekEventsJob(const QString& from, Omittable<int> timeout, const QString& roomId) - : BaseJob(HttpVerb::Get, PeekEventsJobName, basePath % "/events", - queryToPeekEvents(from, timeout, roomId)) + : BaseJob(HttpVerb::Get, QStringLiteral("PeekEventsJob"), + basePath % "/events", queryToPeekEvents(from, timeout, roomId)) , d(new Private) {} diff --git a/lib/csapi/peeking_events.h b/lib/csapi/peeking_events.h index c5cc07f6..12a66a02 100644 --- a/lib/csapi/peeking_events.h +++ b/lib/csapi/peeking_events.h @@ -9,13 +9,12 @@ #include "events/eventloader.h" #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Listen on the event stream. -/*! +/*! \brief Listen on the event stream. + * * This will listen for new events related to a particular room and return * them to the caller. This will block until an event is received, or until * the ``timeout`` is reached. @@ -27,10 +26,10 @@ namespace Quotient * API will also be deprecated at some point, but its replacement is not * yet known. */ -class PeekEventsJob : public BaseJob -{ +class PeekEventsJob : public BaseJob { public: - /*! Listen on the event stream. + /*! \brief Listen on the event stream. + * * \param from * The token to stream from. This token is either from a previous * request to this API or from the initial sync API. @@ -43,16 +42,14 @@ public: Omittable<int> timeout = none, const QString& roomId = {}); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * PeekEventsJob is necessary but the job - * itself isn't. + * This function can be used when a URL for PeekEventsJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& from = {}, Omittable<int> timeout = none, const QString& roomId = {}); - ~PeekEventsJob() override; // Result properties @@ -60,9 +57,11 @@ public: /// A token which correlates to the first value in ``chunk``. This /// is usually the same token supplied to ``from=``. const QString& begin() const; + /// A token which correlates to the last value in ``chunk``. This /// token should be used in the next request to ``/events``. const QString& end() const; + /// An array of events. RoomEvents&& chunk(); diff --git a/lib/csapi/presence.cpp b/lib/csapi/presence.cpp index 0f019026..932ccc6e 100644 --- a/lib/csapi/presence.cpp +++ b/lib/csapi/presence.cpp @@ -12,11 +12,9 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -static const auto SetPresenceJobName = QStringLiteral("SetPresenceJob"); - SetPresenceJob::SetPresenceJob(const QString& userId, const QString& presence, const QString& statusMsg) - : BaseJob(HttpVerb::Put, SetPresenceJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SetPresenceJob"), basePath % "/presence/" % userId % "/status") { QJsonObject _data; @@ -25,8 +23,7 @@ SetPresenceJob::SetPresenceJob(const QString& userId, const QString& presence, setRequestData(_data); } -class GetPresenceJob::Private -{ +class GetPresenceJob::Private { public: QString presence; Omittable<int> lastActiveAgo; @@ -40,10 +37,8 @@ QUrl GetPresenceJob::makeRequestUrl(QUrl baseUrl, const QString& userId) basePath % "/presence/" % userId % "/status"); } -static const auto GetPresenceJobName = QStringLiteral("GetPresenceJob"); - GetPresenceJob::GetPresenceJob(const QString& userId) - : BaseJob(HttpVerb::Get, GetPresenceJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetPresenceJob"), basePath % "/presence/" % userId % "/status") , d(new Private) {} diff --git a/lib/csapi/presence.h b/lib/csapi/presence.h index c5ecb987..21e57603 100644 --- a/lib/csapi/presence.h +++ b/lib/csapi/presence.h @@ -8,22 +8,21 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Update this user's presence state. -/*! +/*! \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 -{ +class SetPresenceJob : public BaseJob { public: - /*! Update this user's presence state. + /*! \brief Update this user's presence state. + * * \param userId * The user whose presence state to update. * \param presence @@ -35,38 +34,39 @@ public: const QString& statusMsg = {}); }; -/// Get this user's presence state. -/*! +/*! \brief Get this user's presence state. + * * Get the given user's presence state. */ -class GetPresenceJob : public BaseJob -{ +class GetPresenceJob : public BaseJob { public: - /*! Get this user's presence state. + /*! \brief 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 + /*! \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. + * 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 /// 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; diff --git a/lib/csapi/profile.cpp b/lib/csapi/profile.cpp index 27168f77..d86e3bdc 100644 --- a/lib/csapi/profile.cpp +++ b/lib/csapi/profile.cpp @@ -12,11 +12,9 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -static const auto SetDisplayNameJobName = QStringLiteral("SetDisplayNameJob"); - SetDisplayNameJob::SetDisplayNameJob(const QString& userId, const QString& displayname) - : BaseJob(HttpVerb::Put, SetDisplayNameJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SetDisplayNameJob"), basePath % "/profile/" % userId % "/displayname") { QJsonObject _data; @@ -24,22 +22,20 @@ SetDisplayNameJob::SetDisplayNameJob(const QString& userId, setRequestData(_data); } -class GetDisplayNameJob::Private -{ +class GetDisplayNameJob::Private { public: QString displayname; }; QUrl GetDisplayNameJob::makeRequestUrl(QUrl baseUrl, const QString& userId) { - return BaseJob::makeRequestUrl( - std::move(baseUrl), basePath % "/profile/" % userId % "/displayname"); + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/profile/" + % userId + % "/displayname"); } -static const auto GetDisplayNameJobName = QStringLiteral("GetDisplayNameJob"); - GetDisplayNameJob::GetDisplayNameJob(const QString& userId) - : BaseJob(HttpVerb::Get, GetDisplayNameJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetDisplayNameJob"), basePath % "/profile/" % userId % "/displayname", false) , d(new Private) {} @@ -56,10 +52,8 @@ BaseJob::Status GetDisplayNameJob::parseJson(const QJsonDocument& data) return Success; } -static const auto SetAvatarUrlJobName = QStringLiteral("SetAvatarUrlJob"); - SetAvatarUrlJob::SetAvatarUrlJob(const QString& userId, const QString& avatarUrl) - : BaseJob(HttpVerb::Put, SetAvatarUrlJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SetAvatarUrlJob"), basePath % "/profile/" % userId % "/avatar_url") { QJsonObject _data; @@ -67,22 +61,20 @@ SetAvatarUrlJob::SetAvatarUrlJob(const QString& userId, const QString& avatarUrl setRequestData(_data); } -class GetAvatarUrlJob::Private -{ +class GetAvatarUrlJob::Private { public: QString avatarUrl; }; QUrl GetAvatarUrlJob::makeRequestUrl(QUrl baseUrl, const QString& userId) { - return BaseJob::makeRequestUrl( - std::move(baseUrl), basePath % "/profile/" % userId % "/avatar_url"); + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/profile/" + % userId + % "/avatar_url"); } -static const auto GetAvatarUrlJobName = QStringLiteral("GetAvatarUrlJob"); - GetAvatarUrlJob::GetAvatarUrlJob(const QString& userId) - : BaseJob(HttpVerb::Get, GetAvatarUrlJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetAvatarUrlJob"), basePath % "/profile/" % userId % "/avatar_url", false) , d(new Private) {} @@ -99,8 +91,7 @@ BaseJob::Status GetAvatarUrlJob::parseJson(const QJsonDocument& data) return Success; } -class GetUserProfileJob::Private -{ +class GetUserProfileJob::Private { public: QString avatarUrl; QString displayname; @@ -112,10 +103,8 @@ QUrl GetUserProfileJob::makeRequestUrl(QUrl baseUrl, const QString& userId) basePath % "/profile/" % userId); } -static const auto GetUserProfileJobName = QStringLiteral("GetUserProfileJob"); - GetUserProfileJob::GetUserProfileJob(const QString& userId) - : BaseJob(HttpVerb::Get, GetUserProfileJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetUserProfileJob"), basePath % "/profile/" % userId, false) , d(new Private) {} diff --git a/lib/csapi/profile.h b/lib/csapi/profile.h index 54dc53aa..8279fe20 100644 --- a/lib/csapi/profile.h +++ b/lib/csapi/profile.h @@ -6,20 +6,19 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Set the user's display name. -/*! +/*! \brief Set the user's display name. + * * This API sets the given user's display name. You must have permission to * set this user's display name, e.g. you need to have their ``access_token``. */ -class SetDisplayNameJob : public BaseJob -{ +class SetDisplayNameJob : public BaseJob { public: - /*! Set the user's display name. + /*! \brief Set the user's display name. + * * \param userId * The user whose display name to set. * \param displayname @@ -29,29 +28,27 @@ public: const QString& displayname = {}); }; -/// Get the user's display name. -/*! +/*! \brief Get the user's display name. + * * Get the user's display name. This API may be used to fetch the user's * own displayname or to query the name of other users; either locally or * on remote homeservers. */ -class GetDisplayNameJob : public BaseJob -{ +class GetDisplayNameJob : public BaseJob { public: - /*! Get the user's display name. + /*! \brief Get the user's display name. + * * \param userId * The user whose display name to get. */ explicit GetDisplayNameJob(const QString& userId); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetDisplayNameJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetDisplayNameJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId); - ~GetDisplayNameJob() override; // Result properties @@ -67,15 +64,15 @@ private: QScopedPointer<Private> d; }; -/// Set the user's avatar URL. -/*! +/*! \brief Set the user's avatar URL. + * * This API sets the given user's avatar URL. You must have permission to * set this user's avatar URL, e.g. you need to have their ``access_token``. */ -class SetAvatarUrlJob : public BaseJob -{ +class SetAvatarUrlJob : public BaseJob { public: - /*! Set the user's avatar URL. + /*! \brief Set the user's avatar URL. + * * \param userId * The user whose avatar URL to set. * \param avatarUrl @@ -85,29 +82,27 @@ public: const QString& avatarUrl = {}); }; -/// Get the user's avatar URL. -/*! +/*! \brief Get the user's avatar URL. + * * Get the user's avatar URL. This API may be used to fetch the user's * own avatar URL or to query the URL of other users; either locally or * on remote homeservers. */ -class GetAvatarUrlJob : public BaseJob -{ +class GetAvatarUrlJob : public BaseJob { public: - /*! Get the user's avatar URL. + /*! \brief Get the user's avatar URL. + * * \param userId * The user whose avatar URL to get. */ explicit GetAvatarUrlJob(const QString& userId); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetAvatarUrlJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetAvatarUrlJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId); - ~GetAvatarUrlJob() override; // Result properties @@ -123,36 +118,35 @@ private: QScopedPointer<Private> d; }; -/// Get this user's profile information. -/*! +/*! \brief Get this user's profile information. + * * Get the combined profile information for this user. This API may be used * to fetch the user's own profile information or other users; either * locally or on remote homeservers. This API may return keys which are not * limited to ``displayname`` or ``avatar_url``. */ -class GetUserProfileJob : public BaseJob -{ +class GetUserProfileJob : public BaseJob { public: - /*! Get this user's profile information. + /*! \brief Get this user's profile information. + * * \param userId * The user whose profile information to get. */ explicit GetUserProfileJob(const QString& userId); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetUserProfileJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetUserProfileJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId); - ~GetUserProfileJob() override; // Result properties /// The user's avatar URL if they have set one, otherwise not present. const QString& avatarUrl() const; + /// The user's display name if they have set one, otherwise not present. const QString& displayname() const; diff --git a/lib/csapi/pusher.cpp b/lib/csapi/pusher.cpp index 90877a95..ad51b901 100644 --- a/lib/csapi/pusher.cpp +++ b/lib/csapi/pusher.cpp @@ -13,12 +13,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter<GetPushersJob::PusherData> -{ +struct JsonObjectConverter<GetPushersJob::PusherData> { static void fillFrom(const QJsonObject& jo, GetPushersJob::PusherData& result) { @@ -28,8 +26,7 @@ struct JsonObjectConverter<GetPushersJob::PusherData> }; template <> -struct JsonObjectConverter<GetPushersJob::Pusher> -{ +struct JsonObjectConverter<GetPushersJob::Pusher> { static void fillFrom(const QJsonObject& jo, GetPushersJob::Pusher& result) { fromJson(jo.value("pushkey"_ls), result.pushkey); @@ -45,8 +42,7 @@ struct JsonObjectConverter<GetPushersJob::Pusher> } // namespace Quotient -class GetPushersJob::Private -{ +class GetPushersJob::Private { public: QVector<Pusher> pushers; }; @@ -56,10 +52,9 @@ QUrl GetPushersJob::makeRequestUrl(QUrl baseUrl) return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/pushers"); } -static const auto GetPushersJobName = QStringLiteral("GetPushersJob"); - GetPushersJob::GetPushersJob() - : BaseJob(HttpVerb::Get, GetPushersJobName, basePath % "/pushers") + : BaseJob(HttpVerb::Get, QStringLiteral("GetPushersJob"), + basePath % "/pushers") , d(new Private) {} @@ -79,12 +74,10 @@ BaseJob::Status GetPushersJob::parseJson(const QJsonDocument& data) } // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter<PostPusherJob::PusherData> -{ +struct JsonObjectConverter<PostPusherJob::PusherData> { static void dumpTo(QJsonObject& jo, const PostPusherJob::PusherData& pod) { addParam<IfNotEmpty>(jo, QStringLiteral("url"), pod.url); @@ -94,14 +87,13 @@ struct JsonObjectConverter<PostPusherJob::PusherData> } // namespace Quotient -static const auto PostPusherJobName = QStringLiteral("PostPusherJob"); - PostPusherJob::PostPusherJob(const QString& pushkey, const QString& kind, const QString& appId, const QString& appDisplayName, const QString& deviceDisplayName, const QString& lang, const PusherData& data, const QString& profileTag, Omittable<bool> append) - : BaseJob(HttpVerb::Post, PostPusherJobName, basePath % "/pushers/set") + : BaseJob(HttpVerb::Post, QStringLiteral("PostPusherJob"), + basePath % "/pushers/set") { QJsonObject _data; addParam<>(_data, QStringLiteral("pushkey"), pushkey); diff --git a/lib/csapi/pusher.h b/lib/csapi/pusher.h index 65f8aa15..d60a2b56 100644 --- a/lib/csapi/pusher.h +++ b/lib/csapi/pusher.h @@ -10,69 +10,69 @@ #include <QtCore/QVector> -namespace Quotient -{ +namespace Quotient { // Operations -/// Gets the current pushers for the authenticated user -/*! +/*! \brief Gets the current pushers for the authenticated user + * * Gets all currently active pushers for the authenticated user. */ -class GetPushersJob : public BaseJob -{ +class GetPushersJob : public BaseJob { public: // Inner data structures - /// A dictionary of information for the pusher implementationitself. - struct PusherData - { - /// Required if ``kind`` is ``http``. The URL to use to - /// sendnotifications to. + /// A dictionary of information for the pusher implementation + /// itself. + struct PusherData { + /// Required if ``kind`` is ``http``. The URL to use to send + /// notifications to. QString url; - /// The format to use when sending notifications to the PushGateway. + /// The format to use when sending notifications to the Push + /// Gateway. QString format; }; /// Gets all currently active pushers for the authenticated user. - struct Pusher - { - /// This is a unique identifier for this pusher. See ``/set`` formore - /// detail.Max length, 512 bytes. + struct Pusher { + /// This is a unique identifier for this pusher. See ``/set`` for + /// more detail. + /// Max length, 512 bytes. QString pushkey; - /// The kind of pusher. ``"http"`` is a pusher thatsends HTTP pokes. + /// The kind of pusher. ``"http"`` is a pusher that + /// sends HTTP pokes. QString kind; - /// This is a reverse-DNS style identifier for the application.Max - /// length, 64 chars. + /// This is a reverse-DNS style identifier for the application. + /// Max length, 64 chars. QString appId; - /// A string that will allow the user to identify what applicationowns - /// this pusher. + /// A string that will allow the user to identify what application + /// owns this pusher. QString appDisplayName; - /// A string that will allow the user to identify what device ownsthis - /// pusher. + /// A string that will allow the user to identify what device owns + /// this pusher. QString deviceDisplayName; - /// This string determines which set of device specific rules thispusher - /// executes. + /// This string determines which set of device specific rules this + /// pusher executes. QString profileTag; - /// The preferred language for receiving notifications (e.g. 'en'or - /// 'en-US') + /// The preferred language for receiving notifications (e.g. 'en' + /// or 'en-US') QString lang; - /// A dictionary of information for the pusher implementationitself. + /// A dictionary of information for the pusher implementation + /// itself. PusherData data; }; // Construction/destruction + /// Gets the current pushers for the authenticated user explicit GetPushersJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetPushersJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetPushersJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetPushersJob() override; // Result properties @@ -88,35 +88,36 @@ private: QScopedPointer<Private> d; }; -/// Modify a pusher for this user on the homeserver. -/*! +/*! \brief Modify a pusher for this user on the homeserver. + * * This endpoint allows the creation, modification and deletion of `pushers`_ * for this user ID. The behaviour of this endpoint varies depending on the * values in the JSON body. */ -class PostPusherJob : public BaseJob -{ +class PostPusherJob : public BaseJob { public: // Inner data structures - /// A dictionary of information for the pusher implementationitself. If - /// ``kind`` is ``http``, this should contain ``url``which is the URL to use - /// to send notifications to. - struct PusherData - { - /// Required if ``kind`` is ``http``. The URL to use to sendnotifications - /// to. MUST be an HTTPS URL with a path of ``/_matrix/push/v1/notify``. + /// A dictionary of information for the pusher implementation + /// itself. If ``kind`` is ``http``, this should contain ``url`` + /// which is the URL to use to send notifications to. + struct PusherData { + /// Required if ``kind`` is ``http``. The URL to use to send + /// notifications to. MUST be an HTTPS URL with a path of + /// ``/_matrix/push/v1/notify``. QString url; - /// The format to send notifications in to Push Gateways if the``kind`` - /// is ``http``. The details about what fields thehomeserver should send - /// to the push gateway are defined in the`Push Gateway Specification`_. - /// Currently the only formatavailable is 'event_id_only'. + /// The format to send notifications in to Push Gateways if the + /// ``kind`` is ``http``. The details about what fields the + /// homeserver should send to the push gateway are defined in the + /// `Push Gateway Specification`_. Currently the only format + /// available is 'event_id_only'. QString format; }; // Construction/destruction - /*! Modify a pusher for this user on the homeserver. + /*! \brief Modify a pusher for this user on the homeserver. + * * \param pushkey * This is a unique identifier for this pusher. The value you * should use for this is the routing or destination address diff --git a/lib/csapi/pushrules.cpp b/lib/csapi/pushrules.cpp index eae5445f..cd0fb02d 100644 --- a/lib/csapi/pushrules.cpp +++ b/lib/csapi/pushrules.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class GetPushRulesJob::Private -{ +class GetPushRulesJob::Private { public: PushRuleset global; }; @@ -23,10 +22,9 @@ QUrl GetPushRulesJob::makeRequestUrl(QUrl baseUrl) return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/pushrules"); } -static const auto GetPushRulesJobName = QStringLiteral("GetPushRulesJob"); - GetPushRulesJob::GetPushRulesJob() - : BaseJob(HttpVerb::Get, GetPushRulesJobName, basePath % "/pushrules") + : BaseJob(HttpVerb::Get, QStringLiteral("GetPushRulesJob"), + basePath % "/pushrules") , d(new Private) {} @@ -45,8 +43,7 @@ BaseJob::Status GetPushRulesJob::parseJson(const QJsonDocument& data) return Success; } -class GetPushRuleJob::Private -{ +class GetPushRuleJob::Private { public: PushRule data; }; @@ -59,11 +56,9 @@ QUrl GetPushRuleJob::makeRequestUrl(QUrl baseUrl, const QString& scope, % "/" % ruleId); } -static const auto GetPushRuleJobName = QStringLiteral("GetPushRuleJob"); - GetPushRuleJob::GetPushRuleJob(const QString& scope, const QString& kind, const QString& ruleId) - : BaseJob(HttpVerb::Get, GetPushRuleJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetPushRuleJob"), basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId) , d(new Private) {} @@ -75,6 +70,7 @@ const PushRule& GetPushRuleJob::data() const { return d->data; } BaseJob::Status GetPushRuleJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } @@ -87,11 +83,9 @@ QUrl DeletePushRuleJob::makeRequestUrl(QUrl baseUrl, const QString& scope, % "/" % ruleId); } -static const auto DeletePushRuleJobName = QStringLiteral("DeletePushRuleJob"); - DeletePushRuleJob::DeletePushRuleJob(const QString& scope, const QString& kind, const QString& ruleId) - : BaseJob(HttpVerb::Delete, DeletePushRuleJobName, + : BaseJob(HttpVerb::Delete, QStringLiteral("DeletePushRuleJob"), basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId) {} @@ -103,14 +97,12 @@ BaseJob::Query queryToSetPushRule(const QString& before, const QString& after) return _q; } -static const auto SetPushRuleJobName = QStringLiteral("SetPushRuleJob"); - SetPushRuleJob::SetPushRuleJob(const QString& scope, const QString& kind, const QString& ruleId, const QStringList& actions, const QString& before, const QString& after, const QVector<PushCondition>& conditions, const QString& pattern) - : BaseJob(HttpVerb::Put, SetPushRuleJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SetPushRuleJob"), basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId, queryToSetPushRule(before, after)) { @@ -121,8 +113,7 @@ SetPushRuleJob::SetPushRuleJob(const QString& scope, const QString& kind, setRequestData(_data); } -class IsPushRuleEnabledJob::Private -{ +class IsPushRuleEnabledJob::Private { public: bool enabled; }; @@ -136,13 +127,10 @@ QUrl IsPushRuleEnabledJob::makeRequestUrl(QUrl baseUrl, const QString& scope, % "/" % ruleId % "/enabled"); } -static const auto IsPushRuleEnabledJobName = - QStringLiteral("IsPushRuleEnabledJob"); - IsPushRuleEnabledJob::IsPushRuleEnabledJob(const QString& scope, const QString& kind, const QString& ruleId) - : BaseJob(HttpVerb::Get, IsPushRuleEnabledJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("IsPushRuleEnabledJob"), basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId % "/enabled") , d(new Private) @@ -163,13 +151,10 @@ BaseJob::Status IsPushRuleEnabledJob::parseJson(const QJsonDocument& data) return Success; } -static const auto SetPushRuleEnabledJobName = - QStringLiteral("SetPushRuleEnabledJob"); - SetPushRuleEnabledJob::SetPushRuleEnabledJob(const QString& scope, const QString& kind, const QString& ruleId, bool enabled) - : BaseJob(HttpVerb::Put, SetPushRuleEnabledJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SetPushRuleEnabledJob"), basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId % "/enabled") { @@ -178,8 +163,7 @@ SetPushRuleEnabledJob::SetPushRuleEnabledJob(const QString& scope, setRequestData(_data); } -class GetPushRuleActionsJob::Private -{ +class GetPushRuleActionsJob::Private { public: QStringList actions; }; @@ -193,13 +177,10 @@ QUrl GetPushRuleActionsJob::makeRequestUrl(QUrl baseUrl, const QString& scope, % "/" % ruleId % "/actions"); } -static const auto GetPushRuleActionsJobName = - QStringLiteral("GetPushRuleActionsJob"); - GetPushRuleActionsJob::GetPushRuleActionsJob(const QString& scope, const QString& kind, const QString& ruleId) - : BaseJob(HttpVerb::Get, GetPushRuleActionsJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetPushRuleActionsJob"), basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId % "/actions") , d(new Private) @@ -220,14 +201,11 @@ BaseJob::Status GetPushRuleActionsJob::parseJson(const QJsonDocument& data) return Success; } -static const auto SetPushRuleActionsJobName = - QStringLiteral("SetPushRuleActionsJob"); - SetPushRuleActionsJob::SetPushRuleActionsJob(const QString& scope, const QString& kind, const QString& ruleId, const QStringList& actions) - : BaseJob(HttpVerb::Put, SetPushRuleActionsJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SetPushRuleActionsJob"), basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId % "/actions") { diff --git a/lib/csapi/pushrules.h b/lib/csapi/pushrules.h index cb94fe7b..a9169151 100644 --- a/lib/csapi/pushrules.h +++ b/lib/csapi/pushrules.h @@ -14,31 +14,28 @@ #include <QtCore/QVector> -namespace Quotient -{ +namespace Quotient { // Operations -/// Retrieve all push rulesets. -/*! +/*! \brief Retrieve all push rulesets. + * * Retrieve all push rulesets for this user. Clients can "drill-down" on * the rulesets by suffixing a ``scope`` to this path e.g. * ``/pushrules/global/``. This will return a subset of this data under the * specified key e.g. the ``global`` key. */ -class GetPushRulesJob : public BaseJob -{ +class GetPushRulesJob : public BaseJob { public: + /// Retrieve all push rulesets. explicit GetPushRulesJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetPushRulesJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetPushRulesJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetPushRulesJob() override; // Result properties @@ -54,14 +51,14 @@ private: QScopedPointer<Private> d; }; -/// Retrieve a push rule. -/*! +/*! \brief Retrieve a push rule. + * * Retrieve a single specified push rule. */ -class GetPushRuleJob : public BaseJob -{ +class GetPushRuleJob : public BaseJob { public: - /*! Retrieve a push rule. + /*! \brief Retrieve a push rule. + * * \param scope * ``global`` to specify global rules. * \param kind @@ -72,15 +69,13 @@ public: explicit GetPushRuleJob(const QString& scope, const QString& kind, const QString& ruleId); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetPushRuleJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetPushRuleJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& scope, const QString& kind, const QString& ruleId); - ~GetPushRuleJob() override; // Result properties @@ -96,14 +91,14 @@ private: QScopedPointer<Private> d; }; -/// Delete a push rule. -/*! +/*! \brief Delete a push rule. + * * This endpoint removes the push rule defined in the path. */ -class DeletePushRuleJob : public BaseJob -{ +class DeletePushRuleJob : public BaseJob { public: - /*! Delete a push rule. + /*! \brief Delete a push rule. + * * \param scope * ``global`` to specify global rules. * \param kind @@ -114,28 +109,27 @@ public: explicit DeletePushRuleJob(const QString& scope, const QString& kind, const QString& ruleId); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * DeletePushRuleJob is necessary but the job - * itself isn't. + * This function can be used when a URL for DeletePushRuleJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& scope, const QString& kind, const QString& ruleId); }; -/// Add or change a push rule. -/*! +/*! \brief Add or change a push rule. + * * This endpoint allows the creation, modification and deletion of pushers * for this user ID. The behaviour of this endpoint varies depending on the * values in the JSON body. * * When creating push rules, they MUST be enabled by default. */ -class SetPushRuleJob : public BaseJob -{ +class SetPushRuleJob : public BaseJob { public: - /*! Add or change a push rule. + /*! \brief Add or change a push rule. + * * \param scope * ``global`` to specify global rules. * \param kind @@ -167,14 +161,14 @@ public: const QString& pattern = {}); }; -/// Get whether a push rule is enabled -/*! +/*! \brief Get whether a push rule is enabled + * * This endpoint gets whether the specified push rule is enabled. */ -class IsPushRuleEnabledJob : public BaseJob -{ +class IsPushRuleEnabledJob : public BaseJob { public: - /*! Get whether a push rule is enabled + /*! \brief Get whether a push rule is enabled + * * \param scope * Either ``global`` or ``device/<profile_tag>`` to specify global * rules or device rules for the given ``profile_tag``. @@ -186,15 +180,13 @@ public: explicit IsPushRuleEnabledJob(const QString& scope, const QString& kind, const QString& ruleId); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * IsPushRuleEnabledJob is necessary but the job - * itself isn't. + * This function can be used when a URL for IsPushRuleEnabledJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& scope, const QString& kind, const QString& ruleId); - ~IsPushRuleEnabledJob() override; // Result properties @@ -210,14 +202,14 @@ private: QScopedPointer<Private> d; }; -/// Enable or disable a push rule. -/*! +/*! \brief Enable or disable a push rule. + * * This endpoint allows clients to enable or disable the specified push rule. */ -class SetPushRuleEnabledJob : public BaseJob -{ +class SetPushRuleEnabledJob : public BaseJob { public: - /*! Enable or disable a push rule. + /*! \brief Enable or disable a push rule. + * * \param scope * ``global`` to specify global rules. * \param kind @@ -231,14 +223,14 @@ public: const QString& ruleId, bool enabled); }; -/// The actions for a push rule -/*! +/*! \brief The actions for a push rule + * * This endpoint get the actions for the specified push rule. */ -class GetPushRuleActionsJob : public BaseJob -{ +class GetPushRuleActionsJob : public BaseJob { public: - /*! The actions for a push rule + /*! \brief The actions for a push rule + * * \param scope * Either ``global`` or ``device/<profile_tag>`` to specify global * rules or device rules for the given ``profile_tag``. @@ -250,15 +242,13 @@ public: explicit GetPushRuleActionsJob(const QString& scope, const QString& kind, const QString& ruleId); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetPushRuleActionsJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetPushRuleActionsJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& scope, const QString& kind, const QString& ruleId); - ~GetPushRuleActionsJob() override; // Result properties @@ -274,15 +264,15 @@ private: QScopedPointer<Private> d; }; -/// Set the actions for a push rule. -/*! +/*! \brief Set the actions for a push rule. + * * This endpoint allows clients to change the actions of a push rule. * This can be used to change the actions of builtin rules. */ -class SetPushRuleActionsJob : public BaseJob -{ +class SetPushRuleActionsJob : public BaseJob { public: - /*! Set the actions for a push rule. + /*! \brief Set the actions for a push rule. + * * \param scope * ``global`` to specify global rules. * \param kind diff --git a/lib/csapi/read_markers.cpp b/lib/csapi/read_markers.cpp index a07d09ce..76145808 100644 --- a/lib/csapi/read_markers.cpp +++ b/lib/csapi/read_markers.cpp @@ -12,12 +12,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -static const auto SetReadMarkerJobName = QStringLiteral("SetReadMarkerJob"); - SetReadMarkerJob::SetReadMarkerJob(const QString& roomId, const QString& mFullyRead, const QString& mRead) - : BaseJob(HttpVerb::Post, SetReadMarkerJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("SetReadMarkerJob"), basePath % "/rooms/" % roomId % "/read_markers") { QJsonObject _data; diff --git a/lib/csapi/read_markers.h b/lib/csapi/read_markers.h index 35c428b2..539aa5e4 100644 --- a/lib/csapi/read_markers.h +++ b/lib/csapi/read_markers.h @@ -6,20 +6,19 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Set the position of the read marker for a room. -/*! +/*! \brief Set the position of the read marker for a room. + * * Sets the position of the read marker for a given room, and optionally * the read receipt's location. */ -class SetReadMarkerJob : public BaseJob -{ +class SetReadMarkerJob : public BaseJob { public: - /*! Set the position of the read marker for a room. + /*! \brief Set the position of the read marker for a room. + * * \param roomId * The room ID to set the read marker in for the user. * \param mFullyRead diff --git a/lib/csapi/receipts.cpp b/lib/csapi/receipts.cpp index f9a45912..87264074 100644 --- a/lib/csapi/receipts.cpp +++ b/lib/csapi/receipts.cpp @@ -12,12 +12,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -static const auto PostReceiptJobName = QStringLiteral("PostReceiptJob"); - PostReceiptJob::PostReceiptJob(const QString& roomId, const QString& receiptType, const QString& eventId, const QJsonObject& receipt) - : BaseJob(HttpVerb::Post, PostReceiptJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("PostReceiptJob"), basePath % "/rooms/" % roomId % "/receipt/" % receiptType % "/" % eventId) { diff --git a/lib/csapi/receipts.h b/lib/csapi/receipts.h index 376d4006..eb82fc28 100644 --- a/lib/csapi/receipts.h +++ b/lib/csapi/receipts.h @@ -8,20 +8,19 @@ #include <QtCore/QJsonObject> -namespace Quotient -{ +namespace Quotient { // Operations -/// Send a receipt for the given event ID. -/*! +/*! \brief Send a receipt for the given event ID. + * * This API updates the marker for the given receipt type to the event ID * specified. */ -class PostReceiptJob : public BaseJob -{ +class PostReceiptJob : public BaseJob { public: - /*! Send a receipt for the given event ID. + /*! \brief Send a receipt for the given event ID. + * * \param roomId * The room in which to send the event. * \param receiptType diff --git a/lib/csapi/redaction.cpp b/lib/csapi/redaction.cpp index d2dbe19b..2b6417ea 100644 --- a/lib/csapi/redaction.cpp +++ b/lib/csapi/redaction.cpp @@ -12,17 +12,14 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class RedactEventJob::Private -{ +class RedactEventJob::Private { public: QString eventId; }; -static const auto RedactEventJobName = QStringLiteral("RedactEventJob"); - RedactEventJob::RedactEventJob(const QString& roomId, const QString& eventId, const QString& txnId, const QString& reason) - : BaseJob(HttpVerb::Put, RedactEventJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("RedactEventJob"), basePath % "/rooms/" % roomId % "/redact/" % eventId % "/" % txnId) , d(new Private) { diff --git a/lib/csapi/redaction.h b/lib/csapi/redaction.h index 42022930..0e9095d1 100644 --- a/lib/csapi/redaction.h +++ b/lib/csapi/redaction.h @@ -6,13 +6,12 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Strips all non-integrity-critical information out of an event. -/*! +/*! \brief Strips all non-integrity-critical information out of an event. + * * Strips all information out of an event which isn't critical to the * integrity of the server-side representation of the room. * @@ -22,10 +21,10 @@ namespace Quotient * greater than or equal to the `redact` power level of the room may * redact events there. */ -class RedactEventJob : public BaseJob -{ +class RedactEventJob : public BaseJob { public: - /*! Strips all non-integrity-critical information out of an event. + /*! \brief Strips all non-integrity-critical information out of an event. + * * \param roomId * The room from which to redact the event. * \param eventId diff --git a/lib/csapi/registration.cpp b/lib/csapi/registration.cpp index 270011e1..768617cc 100644 --- a/lib/csapi/registration.cpp +++ b/lib/csapi/registration.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class RegisterJob::Private -{ +class RegisterJob::Private { public: QString userId; QString accessToken; @@ -28,16 +27,14 @@ BaseJob::Query queryToRegister(const QString& kind) return _q; } -static const auto RegisterJobName = QStringLiteral("RegisterJob"); - RegisterJob::RegisterJob(const QString& kind, const Omittable<AuthenticationData>& auth, Omittable<bool> bindEmail, const QString& username, const QString& password, const QString& deviceId, const QString& initialDeviceDisplayName, Omittable<bool> inhibitLogin) - : BaseJob(HttpVerb::Post, RegisterJobName, basePath % "/register", - queryToRegister(kind), {}, false) + : BaseJob(HttpVerb::Post, QStringLiteral("RegisterJob"), + basePath % "/register", queryToRegister(kind), {}, false) , d(new Private) { QJsonObject _data; @@ -76,19 +73,15 @@ BaseJob::Status RegisterJob::parseJson(const QJsonDocument& data) return Success; } -class RequestTokenToRegisterEmailJob::Private -{ +class RequestTokenToRegisterEmailJob::Private { public: Sid data; }; -static const auto RequestTokenToRegisterEmailJobName = - QStringLiteral("RequestTokenToRegisterEmailJob"); - RequestTokenToRegisterEmailJob::RequestTokenToRegisterEmailJob( const QString& clientSecret, const QString& email, int sendAttempt, const QString& idServer, const QString& nextLink) - : BaseJob(HttpVerb::Post, RequestTokenToRegisterEmailJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToRegisterEmailJob"), basePath % "/register/email/requestToken", false) , d(new Private) { @@ -109,23 +102,20 @@ BaseJob::Status RequestTokenToRegisterEmailJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } -class RequestTokenToRegisterMSISDNJob::Private -{ +class RequestTokenToRegisterMSISDNJob::Private { public: Sid data; }; -static const auto RequestTokenToRegisterMSISDNJobName = - QStringLiteral("RequestTokenToRegisterMSISDNJob"); - RequestTokenToRegisterMSISDNJob::RequestTokenToRegisterMSISDNJob( const QString& clientSecret, const QString& country, const QString& phoneNumber, int sendAttempt, const QString& idServer, const QString& nextLink) - : BaseJob(HttpVerb::Post, RequestTokenToRegisterMSISDNJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToRegisterMSISDNJob"), basePath % "/register/msisdn/requestToken", false) , d(new Private) { @@ -147,14 +137,13 @@ BaseJob::Status RequestTokenToRegisterMSISDNJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } -static const auto ChangePasswordJobName = QStringLiteral("ChangePasswordJob"); - ChangePasswordJob::ChangePasswordJob(const QString& newPassword, const Omittable<AuthenticationData>& auth) - : BaseJob(HttpVerb::Post, ChangePasswordJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("ChangePasswordJob"), basePath % "/account/password") { QJsonObject _data; @@ -163,19 +152,16 @@ ChangePasswordJob::ChangePasswordJob(const QString& newPassword, setRequestData(_data); } -class RequestTokenToResetPasswordEmailJob::Private -{ +class RequestTokenToResetPasswordEmailJob::Private { public: Sid data; }; -static const auto RequestTokenToResetPasswordEmailJobName = - QStringLiteral("RequestTokenToResetPasswordEmailJob"); - RequestTokenToResetPasswordEmailJob::RequestTokenToResetPasswordEmailJob( const QString& clientSecret, const QString& email, int sendAttempt, const QString& idServer, const QString& nextLink) - : BaseJob(HttpVerb::Post, RequestTokenToResetPasswordEmailJobName, + : BaseJob(HttpVerb::Post, + QStringLiteral("RequestTokenToResetPasswordEmailJob"), basePath % "/account/password/email/requestToken", false) , d(new Private) { @@ -197,23 +183,21 @@ BaseJob::Status RequestTokenToResetPasswordEmailJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } -class RequestTokenToResetPasswordMSISDNJob::Private -{ +class RequestTokenToResetPasswordMSISDNJob::Private { public: Sid data; }; -static const auto RequestTokenToResetPasswordMSISDNJobName = - QStringLiteral("RequestTokenToResetPasswordMSISDNJob"); - RequestTokenToResetPasswordMSISDNJob::RequestTokenToResetPasswordMSISDNJob( const QString& clientSecret, const QString& country, const QString& phoneNumber, int sendAttempt, const QString& idServer, const QString& nextLink) - : BaseJob(HttpVerb::Post, RequestTokenToResetPasswordMSISDNJobName, + : BaseJob(HttpVerb::Post, + QStringLiteral("RequestTokenToResetPasswordMSISDNJob"), basePath % "/account/password/msisdn/requestToken", false) , d(new Private) { @@ -239,15 +223,13 @@ BaseJob::Status RequestTokenToResetPasswordMSISDNJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } -static const auto DeactivateAccountJobName = - QStringLiteral("DeactivateAccountJob"); - DeactivateAccountJob::DeactivateAccountJob( const Omittable<AuthenticationData>& auth) - : BaseJob(HttpVerb::Post, DeactivateAccountJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("DeactivateAccountJob"), basePath % "/account/deactivate") { QJsonObject _data; @@ -255,8 +237,7 @@ DeactivateAccountJob::DeactivateAccountJob( setRequestData(_data); } -class CheckUsernameAvailabilityJob::Private -{ +class CheckUsernameAvailabilityJob::Private { public: Omittable<bool> available; }; @@ -276,11 +257,8 @@ QUrl CheckUsernameAvailabilityJob::makeRequestUrl(QUrl baseUrl, queryToCheckUsernameAvailability(username)); } -static const auto CheckUsernameAvailabilityJobName = - QStringLiteral("CheckUsernameAvailabilityJob"); - CheckUsernameAvailabilityJob::CheckUsernameAvailabilityJob(const QString& username) - : BaseJob(HttpVerb::Get, CheckUsernameAvailabilityJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("CheckUsernameAvailabilityJob"), basePath % "/register/available", queryToCheckUsernameAvailability(username), {}, false) , d(new Private) diff --git a/lib/csapi/registration.h b/lib/csapi/registration.h index 89aecb80..2619dd87 100644 --- a/lib/csapi/registration.h +++ b/lib/csapi/registration.h @@ -11,13 +11,12 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Register for an account on this homeserver. -/*! +/*! \brief Register for an account on this homeserver. + * * This API endpoint uses the `User-Interactive Authentication API`_. * * Register for an account on this homeserver. @@ -51,10 +50,10 @@ namespace Quotient * invalidate any access token previously associated with that device. See * `Relationship between access tokens and devices`_. */ -class RegisterJob : public BaseJob -{ +class RegisterJob : public BaseJob { public: - /*! Register for an account on this homeserver. + /*! \brief Register for an account on this homeserver. + * * \param kind * The kind of account to register. Defaults to `user`. * \param auth @@ -104,10 +103,12 @@ public: /// the `Matrix specification /// <https://matrix.org/docs/spec/appendices.html#user-identifiers>`_. const QString& userId() const; + /// An access token for the account. /// This access token can then be used to authorize other requests. /// Required if the ``inhibit_login`` option is false. const QString& accessToken() const; + /// The server_name of the homeserver on which the account has /// been registered. /// @@ -115,6 +116,7 @@ public: /// ``user_id`` (by splitting at the first colon) if they require /// it. Note also that ``homeserver`` is not spelt this way. const QString& homeServer() const; + /// ID of the registered device. Will be the same as the /// corresponding parameter in the request, if one was specified. /// Required if the ``inhibit_login`` option is false. @@ -128,20 +130,22 @@ private: QScopedPointer<Private> d; }; -/// Begins the validation process for an email to be used during registration. -/*! +/*! \brief Begins the validation process for an email to be used during + * registration. + * * Proxies the Identity Service API ``validate/email/requestToken``, but * first checks that the given email address is not already associated * with an account on this homeserver. See the Identity Service API for * further information. */ -class RequestTokenToRegisterEmailJob : public BaseJob -{ +class RequestTokenToRegisterEmailJob : public BaseJob { public: - /*! Begins the validation process for an email to be used during - * registration. \param clientSecret A unique string generated by the - * client, and used to identify the validation attempt. It must be a string - * consisting of the characters + /*! \brief Begins the validation process for an email to be used during + * registration. + * + * \param clientSecret + * A unique string generated by the client, and used to identify the + * validation attempt. It must be a string consisting of the characters * ``[0-9a-zA-Z.=_-]``. Its length must not exceed 255 characters and it * must not be empty. * \param email @@ -184,21 +188,22 @@ private: QScopedPointer<Private> d; }; -/// Requests a validation token be sent to the given phone number for the -/// purpose of registering an account -/*! +/*! \brief Requests a validation token be sent to the given phone number for the + * purpose of registering an account + * * Proxies the Identity Service API ``validate/msisdn/requestToken``, but * first checks that the given phone number is not already associated * with an account on this homeserver. See the Identity Service API for * further information. */ -class RequestTokenToRegisterMSISDNJob : public BaseJob -{ +class RequestTokenToRegisterMSISDNJob : public BaseJob { public: - /*! Requests a validation token be sent to the given phone number for the - * purpose of registering an account \param clientSecret A unique string - * generated by the client, and used to identify the validation attempt. It - * must be a string consisting of the characters + /*! \brief Requests a validation token be sent to the given phone number for + * the purpose of registering an account + * + * \param clientSecret + * A unique string generated by the client, and used to identify the + * validation attempt. It must be a string consisting of the characters * ``[0-9a-zA-Z.=_-]``. Its length must not exceed 255 characters and it * must not be empty. * \param country @@ -245,8 +250,8 @@ private: QScopedPointer<Private> d; }; -/// Changes a user's password. -/*! +/*! \brief Changes a user's password. + * * Changes the password for an account on this homeserver. * * This API endpoint uses the `User-Interactive Authentication API`_. @@ -257,10 +262,10 @@ private: * The homeserver may change the flows available depending on whether a * valid access token is provided. */ -class ChangePasswordJob : public BaseJob -{ +class ChangePasswordJob : public BaseJob { public: - /*! Changes a user's password. + /*! \brief Changes a user's password. + * * \param newPassword * The new password for the account. * \param auth @@ -271,9 +276,9 @@ public: const Omittable<AuthenticationData>& auth = none); }; -/// Requests a validation token be sent to the given email address for the -/// purpose of resetting a user's password -/*! +/*! \brief Requests a validation token be sent to the given email address for + * the purpose of resetting a user's password + * * Proxies the Identity Service API ``validate/email/requestToken``, but * first checks that the given email address **is** associated with an account * on this homeserver. This API should be used to request @@ -290,13 +295,14 @@ public: * .. _/register/email/requestToken: * #post-matrix-client-r0-register-email-requesttoken */ -class RequestTokenToResetPasswordEmailJob : public BaseJob -{ +class RequestTokenToResetPasswordEmailJob : public BaseJob { public: - /*! Requests a validation token be sent to the given email address for the - * purpose of resetting a user's password \param clientSecret A unique - * string generated by the client, and used to identify the validation - * attempt. It must be a string consisting of the characters + /*! \brief Requests a validation token be sent to the given email address + * for the purpose of resetting a user's password + * + * \param clientSecret + * A unique string generated by the client, and used to identify the + * validation attempt. It must be a string consisting of the characters * ``[0-9a-zA-Z.=_-]``. Its length must not exceed 255 characters and it * must not be empty. * \param email @@ -337,9 +343,9 @@ private: QScopedPointer<Private> d; }; -/// Requests a validation token be sent to the given phone number for the -/// purpose of resetting a user's password. -/*! +/*! \brief Requests a validation token be sent to the given phone number for the + * purpose of resetting a user's password. + * * Proxies the Identity Service API ``validate/msisdn/requestToken``, but * first checks that the given phone number **is** associated with an account * on this homeserver. This API should be used to request @@ -356,13 +362,14 @@ private: * .. _/register/msisdn/requestToken: * #post-matrix-client-r0-register-email-requesttoken */ -class RequestTokenToResetPasswordMSISDNJob : public BaseJob -{ +class RequestTokenToResetPasswordMSISDNJob : public BaseJob { public: - /*! Requests a validation token be sent to the given phone number for the - * purpose of resetting a user's password. \param clientSecret A unique - * string generated by the client, and used to identify the validation - * attempt. It must be a string consisting of the characters + /*! \brief Requests a validation token be sent to the given phone number for + * the purpose of resetting a user's password. + * + * \param clientSecret + * A unique string generated by the client, and used to identify the + * validation attempt. It must be a string consisting of the characters * ``[0-9a-zA-Z.=_-]``. Its length must not exceed 255 characters and it * must not be empty. * \param country @@ -407,8 +414,8 @@ private: QScopedPointer<Private> d; }; -/// Deactivate a user's account. -/*! +/*! \brief Deactivate a user's account. + * * Deactivate the user's account, removing all ability for the user to * login again. * @@ -420,10 +427,10 @@ private: * The homeserver may change the flows available depending on whether a * valid access token is provided. */ -class DeactivateAccountJob : public BaseJob -{ +class DeactivateAccountJob : public BaseJob { public: - /*! Deactivate a user's account. + /*! \brief Deactivate a user's account. + * * \param auth * Additional authentication information for the user-interactive * authentication API. @@ -432,8 +439,8 @@ public: const Omittable<AuthenticationData>& auth = none); }; -/// Checks to see if a username is available on the server. -/*! +/*! \brief Checks to see if a username is available on the server. + * * Checks to see if a username is available, and valid, for the server. * * The server should check to ensure that, at the time of the request, the @@ -447,23 +454,21 @@ public: * reserve the username. This can mean that the username becomes unavailable * between checking its availability and attempting to register it. */ -class CheckUsernameAvailabilityJob : public BaseJob -{ +class CheckUsernameAvailabilityJob : public BaseJob { public: - /*! Checks to see if a username is available on the server. + /*! \brief Checks to see if a username is available on the server. + * * \param username * The username to check the availability of. */ explicit CheckUsernameAvailabilityJob(const QString& username); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * CheckUsernameAvailabilityJob is necessary but the job - * itself isn't. + * This function can be used when a URL for CheckUsernameAvailabilityJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& username); - ~CheckUsernameAvailabilityJob() override; // Result properties diff --git a/lib/csapi/report_content.cpp b/lib/csapi/report_content.cpp index 352f52c9..f38b7a9a 100644 --- a/lib/csapi/report_content.cpp +++ b/lib/csapi/report_content.cpp @@ -12,11 +12,9 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -static const auto ReportContentJobName = QStringLiteral("ReportContentJob"); - ReportContentJob::ReportContentJob(const QString& roomId, const QString& eventId, int score, const QString& reason) - : BaseJob(HttpVerb::Post, ReportContentJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("ReportContentJob"), basePath % "/rooms/" % roomId % "/report/" % eventId) { QJsonObject _data; diff --git a/lib/csapi/report_content.h b/lib/csapi/report_content.h index c86a4301..0f3cc3d5 100644 --- a/lib/csapi/report_content.h +++ b/lib/csapi/report_content.h @@ -8,20 +8,19 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Reports an event as inappropriate. -/*! +/*! \brief Reports an event as inappropriate. + * * Reports an event as inappropriate to the server, which may then notify * the appropriate people. */ -class ReportContentJob : public BaseJob -{ +class ReportContentJob : public BaseJob { public: - /*! Reports an event as inappropriate. + /*! \brief Reports an event as inappropriate. + * * \param roomId * The room in which the event being reported is located. * \param eventId diff --git a/lib/csapi/room_send.cpp b/lib/csapi/room_send.cpp index 5e970d65..d278433b 100644 --- a/lib/csapi/room_send.cpp +++ b/lib/csapi/room_send.cpp @@ -12,17 +12,14 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class SendMessageJob::Private -{ +class SendMessageJob::Private { public: QString eventId; }; -static const auto SendMessageJobName = QStringLiteral("SendMessageJob"); - SendMessageJob::SendMessageJob(const QString& roomId, const QString& eventType, const QString& txnId, const QJsonObject& body) - : BaseJob(HttpVerb::Put, SendMessageJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SendMessageJob"), basePath % "/rooms/" % roomId % "/send/" % eventType % "/" % txnId) , d(new Private) { diff --git a/lib/csapi/room_send.h b/lib/csapi/room_send.h index 110fc83b..96b111ff 100644 --- a/lib/csapi/room_send.h +++ b/lib/csapi/room_send.h @@ -8,13 +8,12 @@ #include <QtCore/QJsonObject> -namespace Quotient -{ +namespace Quotient { // Operations -/// Send a message event to the given room. -/*! +/*! \brief Send a message event to the given room. + * * This endpoint is used to send a message event to a room. Message events * allow access to historical events and pagination, making them suited * for "once-off" activity in a room. @@ -23,10 +22,10 @@ namespace Quotient * fields in this object will vary depending on the type of event. See * `Room Events`_ for the m. event specification. */ -class SendMessageJob : public BaseJob -{ +class SendMessageJob : public BaseJob { public: - /*! Send a message event to the given room. + /*! \brief Send a message event to the given room. + * * \param roomId * The room to send the event to. * \param eventType diff --git a/lib/csapi/room_state.cpp b/lib/csapi/room_state.cpp index bfcd6e17..5973b06b 100644 --- a/lib/csapi/room_state.cpp +++ b/lib/csapi/room_state.cpp @@ -12,20 +12,16 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class SetRoomStateWithKeyJob::Private -{ +class SetRoomStateWithKeyJob::Private { public: QString eventId; }; -static const auto SetRoomStateWithKeyJobName = - QStringLiteral("SetRoomStateWithKeyJob"); - SetRoomStateWithKeyJob::SetRoomStateWithKeyJob(const QString& roomId, const QString& eventType, const QString& stateKey, const QJsonObject& body) - : BaseJob(HttpVerb::Put, SetRoomStateWithKeyJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomStateWithKeyJob"), basePath % "/rooms/" % roomId % "/state/" % eventType % "/" % stateKey) , d(new Private) @@ -45,17 +41,14 @@ BaseJob::Status SetRoomStateWithKeyJob::parseJson(const QJsonDocument& data) return Success; } -class SetRoomStateJob::Private -{ +class SetRoomStateJob::Private { public: QString eventId; }; -static const auto SetRoomStateJobName = QStringLiteral("SetRoomStateJob"); - SetRoomStateJob::SetRoomStateJob(const QString& roomId, const QString& eventType, const QJsonObject& body) - : BaseJob(HttpVerb::Put, SetRoomStateJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomStateJob"), basePath % "/rooms/" % roomId % "/state/" % eventType) , d(new Private) { diff --git a/lib/csapi/room_state.h b/lib/csapi/room_state.h index 80619d63..7843cff4 100644 --- a/lib/csapi/room_state.h +++ b/lib/csapi/room_state.h @@ -8,13 +8,12 @@ #include <QtCore/QJsonObject> -namespace Quotient -{ +namespace Quotient { // Operations -/// Send a state event to the given room. -/*! +/*! \brief Send a state event to the given room. + * * State events can be sent using this endpoint. These events will be * overwritten if ``<room id>``, ``<event type>`` and ``<state key>`` all * match. @@ -27,10 +26,10 @@ namespace Quotient * fields in this object will vary depending on the type of event. See * `Room Events`_ for the ``m.`` event specification. */ -class SetRoomStateWithKeyJob : public BaseJob -{ +class SetRoomStateWithKeyJob : public BaseJob { public: - /*! Send a state event to the given room. + /*! \brief Send a state event to the given room. + * * \param roomId * The room to set the state in * \param eventType @@ -70,8 +69,8 @@ private: QScopedPointer<Private> d; }; -/// Send a state event to the given room. -/*! +/*! \brief Send a state event to the given room. + * * State events can be sent using this endpoint. This endpoint is * equivalent to calling `/rooms/{roomId}/state/{eventType}/{stateKey}` * with an empty `stateKey`. Previous state events with matching @@ -85,10 +84,10 @@ private: * fields in this object will vary depending on the type of event. See * `Room Events`_ for the ``m.`` event specification. */ -class SetRoomStateJob : public BaseJob -{ +class SetRoomStateJob : public BaseJob { public: - /*! Send a state event to the given room. + /*! \brief Send a state event to the given room. + * * \param roomId * The room to set the state in * \param eventType diff --git a/lib/csapi/room_upgrades.cpp b/lib/csapi/room_upgrades.cpp index 1d6006ef..244f5b74 100644 --- a/lib/csapi/room_upgrades.cpp +++ b/lib/csapi/room_upgrades.cpp @@ -12,16 +12,13 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class UpgradeRoomJob::Private -{ +class UpgradeRoomJob::Private { public: QString replacementRoom; }; -static const auto UpgradeRoomJobName = QStringLiteral("UpgradeRoomJob"); - UpgradeRoomJob::UpgradeRoomJob(const QString& roomId, const QString& newVersion) - : BaseJob(HttpVerb::Post, UpgradeRoomJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("UpgradeRoomJob"), basePath % "/rooms/" % roomId % "/upgrade") , d(new Private) { diff --git a/lib/csapi/room_upgrades.h b/lib/csapi/room_upgrades.h index 5f9262f1..f13a9af4 100644 --- a/lib/csapi/room_upgrades.h +++ b/lib/csapi/room_upgrades.h @@ -6,19 +6,18 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Upgrades a room to a new room version. -/*! +/*! \brief Upgrades a room to a new room version. + * * Upgrades the given room to a particular room version. */ -class UpgradeRoomJob : public BaseJob -{ +class UpgradeRoomJob : public BaseJob { public: - /*! Upgrades a room to a new room version. + /*! \brief Upgrades a room to a new room version. + * * \param roomId * The ID of the room to upgrade. * \param newVersion diff --git a/lib/csapi/rooms.cpp b/lib/csapi/rooms.cpp index 5bfbe44d..234e33df 100644 --- a/lib/csapi/rooms.cpp +++ b/lib/csapi/rooms.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class GetOneRoomEventJob::Private -{ +class GetOneRoomEventJob::Private { public: EventPtr data; }; @@ -26,11 +25,9 @@ QUrl GetOneRoomEventJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, % eventId); } -static const auto GetOneRoomEventJobName = QStringLiteral("GetOneRoomEventJob"); - GetOneRoomEventJob::GetOneRoomEventJob(const QString& roomId, const QString& eventId) - : BaseJob(HttpVerb::Get, GetOneRoomEventJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetOneRoomEventJob"), basePath % "/rooms/" % roomId % "/event/" % eventId) , d(new Private) {} @@ -42,6 +39,7 @@ EventPtr&& GetOneRoomEventJob::data() { return std::move(d->data); } BaseJob::Status GetOneRoomEventJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } @@ -54,13 +52,10 @@ QUrl GetRoomStateWithKeyJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, % eventType % "/" % stateKey); } -static const auto GetRoomStateWithKeyJobName = - QStringLiteral("GetRoomStateWithKeyJob"); - GetRoomStateWithKeyJob::GetRoomStateWithKeyJob(const QString& roomId, const QString& eventType, const QString& stateKey) - : BaseJob(HttpVerb::Get, GetRoomStateWithKeyJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomStateWithKeyJob"), basePath % "/rooms/" % roomId % "/state/" % eventType % "/" % stateKey) {} @@ -73,17 +68,13 @@ QUrl GetRoomStateByTypeJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, % eventType); } -static const auto GetRoomStateByTypeJobName = - QStringLiteral("GetRoomStateByTypeJob"); - GetRoomStateByTypeJob::GetRoomStateByTypeJob(const QString& roomId, const QString& eventType) - : BaseJob(HttpVerb::Get, GetRoomStateByTypeJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomStateByTypeJob"), basePath % "/rooms/" % roomId % "/state/" % eventType) {} -class GetRoomStateJob::Private -{ +class GetRoomStateJob::Private { public: StateEvents data; }; @@ -94,10 +85,8 @@ QUrl GetRoomStateJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) basePath % "/rooms/" % roomId % "/state"); } -static const auto GetRoomStateJobName = QStringLiteral("GetRoomStateJob"); - GetRoomStateJob::GetRoomStateJob(const QString& roomId) - : BaseJob(HttpVerb::Get, GetRoomStateJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomStateJob"), basePath % "/rooms/" % roomId % "/state") , d(new Private) {} @@ -109,11 +98,11 @@ StateEvents&& GetRoomStateJob::data() { return std::move(d->data); } BaseJob::Status GetRoomStateJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } -class GetMembersByRoomJob::Private -{ +class GetMembersByRoomJob::Private { public: EventsArray<RoomMemberEvent> chunk; }; @@ -134,19 +123,17 @@ QUrl GetMembersByRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& membership, const QString& notMembership) { - return BaseJob::makeRequestUrl( - std::move(baseUrl), basePath % "/rooms/" % roomId % "/members", - queryToGetMembersByRoom(at, membership, notMembership)); + return BaseJob::makeRequestUrl(std::move(baseUrl), + basePath % "/rooms/" % roomId % "/members", + queryToGetMembersByRoom(at, membership, + notMembership)); } -static const auto GetMembersByRoomJobName = - QStringLiteral("GetMembersByRoomJob"); - GetMembersByRoomJob::GetMembersByRoomJob(const QString& roomId, const QString& at, const QString& membership, const QString& notMembership) - : BaseJob(HttpVerb::Get, GetMembersByRoomJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetMembersByRoomJob"), basePath % "/rooms/" % roomId % "/members", queryToGetMembersByRoom(at, membership, notMembership)) , d(new Private) @@ -168,12 +155,10 @@ BaseJob::Status GetMembersByRoomJob::parseJson(const QJsonDocument& data) } // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter<GetJoinedMembersByRoomJob::RoomMember> -{ +struct JsonObjectConverter<GetJoinedMembersByRoomJob::RoomMember> { static void fillFrom(const QJsonObject& jo, GetJoinedMembersByRoomJob::RoomMember& result) { @@ -184,8 +169,7 @@ struct JsonObjectConverter<GetJoinedMembersByRoomJob::RoomMember> } // namespace Quotient -class GetJoinedMembersByRoomJob::Private -{ +class GetJoinedMembersByRoomJob::Private { public: QHash<QString, RoomMember> joined; }; @@ -193,15 +177,13 @@ public: QUrl GetJoinedMembersByRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) { - return BaseJob::makeRequestUrl( - std::move(baseUrl), basePath % "/rooms/" % roomId % "/joined_members"); + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/rooms/" + % roomId + % "/joined_members"); } -static const auto GetJoinedMembersByRoomJobName = - QStringLiteral("GetJoinedMembersByRoomJob"); - GetJoinedMembersByRoomJob::GetJoinedMembersByRoomJob(const QString& roomId) - : BaseJob(HttpVerb::Get, GetJoinedMembersByRoomJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetJoinedMembersByRoomJob"), basePath % "/rooms/" % roomId % "/joined_members") , d(new Private) {} diff --git a/lib/csapi/rooms.h b/lib/csapi/rooms.h index 1020fdb1..05c5b82a 100644 --- a/lib/csapi/rooms.h +++ b/lib/csapi/rooms.h @@ -12,20 +12,19 @@ #include <QtCore/QHash> -namespace Quotient -{ +namespace Quotient { // Operations -/// Get a single event by event ID. -/*! +/*! \brief Get a single event by event ID. + * * Get a single event based on ``roomId/eventId``. You must have permission to * retrieve this event e.g. by being a member in the room for this event. */ -class GetOneRoomEventJob : public BaseJob -{ +class GetOneRoomEventJob : public BaseJob { public: - /*! Get a single event by event ID. + /*! \brief Get a single event by event ID. + * * \param roomId * The ID of the room the event is in. * \param eventId @@ -33,15 +32,13 @@ public: */ explicit GetOneRoomEventJob(const QString& roomId, const QString& eventId); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetOneRoomEventJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetOneRoomEventJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& eventId); - ~GetOneRoomEventJob() override; // Result properties @@ -57,17 +54,17 @@ private: QScopedPointer<Private> d; }; -/// Get the state identified by the type and key. -/*! +/*! \brief Get the state identified by the type and key. + * * Looks up the contents of a state event in a room. If the user is * joined to the room then the state is taken from the current * state of the room. If the user has left the room then the state is * taken from the state of the room when they left. */ -class GetRoomStateWithKeyJob : public BaseJob -{ +class GetRoomStateWithKeyJob : public BaseJob { public: - /*! Get the state identified by the type and key. + /*! \brief Get the state identified by the type and key. + * * \param roomId * The room to look up the state in. * \param eventType @@ -79,19 +76,18 @@ public: const QString& eventType, const QString& stateKey); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetRoomStateWithKeyJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetRoomStateWithKeyJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& eventType, const QString& stateKey); }; -/// Get the state identified by the type, with the empty state key. -/*! +/*! \brief Get the state identified by the type, with the empty state key. + * * Looks up the contents of a state event in a room. If the user is * joined to the room then the state is taken from the current * state of the room. If the user has left the room then the state is @@ -99,10 +95,10 @@ public: * * This looks up the state event with the empty state key. */ -class GetRoomStateByTypeJob : public BaseJob -{ +class GetRoomStateByTypeJob : public BaseJob { public: - /*! Get the state identified by the type, with the empty state key. + /*! \brief Get the state identified by the type, with the empty state key. + * * \param roomId * The room to look up the state in. * \param eventType @@ -111,37 +107,34 @@ public: explicit GetRoomStateByTypeJob(const QString& roomId, const QString& eventType); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetRoomStateByTypeJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetRoomStateByTypeJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& eventType); }; -/// Get all state events in the current state of a room. -/*! +/*! \brief Get all state events in the current state of a room. + * * Get the state events for the current state of a room. */ -class GetRoomStateJob : public BaseJob -{ +class GetRoomStateJob : public BaseJob { public: - /*! Get all state events in the current state of a room. + /*! \brief Get all state events in the current state of a room. + * * \param roomId * The room to look up the state for. */ explicit GetRoomStateJob(const QString& roomId); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetRoomStateJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetRoomStateJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId); - ~GetRoomStateJob() override; // Result properties @@ -160,14 +153,14 @@ private: QScopedPointer<Private> d; }; -/// Get the m.room.member events for the room. -/*! +/*! \brief Get the m.room.member events for the room. + * * Get the list of members for this room. */ -class GetMembersByRoomJob : public BaseJob -{ +class GetMembersByRoomJob : public BaseJob { public: - /*! Get the m.room.member events for the room. + /*! \brief Get the m.room.member events for the room. + * * \param roomId * The room to get the member events for. * \param at @@ -184,17 +177,15 @@ public: const QString& membership = {}, const QString& notMembership = {}); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetMembersByRoomJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetMembersByRoomJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& at = {}, const QString& membership = {}, const QString& notMembership = {}); - ~GetMembersByRoomJob() override; // Result properties @@ -210,8 +201,8 @@ private: QScopedPointer<Private> d; }; -/// Gets the list of currently joined users and their profile data. -/*! +/*! \brief Gets the list of currently joined users and their profile data. + * * This API returns a map of MXIDs to member info objects for members of the * room. The current user must be in the room for it to work, unless it is an * Application Service in which case any of the AS's users must be in the room. @@ -219,8 +210,7 @@ private: * respond than ``/members`` as it can be implemented more efficiently on the * server. */ -class GetJoinedMembersByRoomJob : public BaseJob -{ +class GetJoinedMembersByRoomJob : public BaseJob { public: // Inner data structures @@ -230,8 +220,7 @@ public: /// the room. This API is primarily for Application Services and should be /// faster to respond than ``/members`` as it can be implemented more /// efficiently on the server. - struct RoomMember - { + struct RoomMember { /// The display name of the user this object is representing. QString displayName; /// The mxc avatar url of the user this object is representing. @@ -240,20 +229,19 @@ public: // Construction/destruction - /*! Gets the list of currently joined users and their profile data. + /*! \brief Gets the list of currently joined users and their profile data. + * * \param roomId * The room to get the members of. */ explicit GetJoinedMembersByRoomJob(const QString& roomId); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetJoinedMembersByRoomJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetJoinedMembersByRoomJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId); - ~GetJoinedMembersByRoomJob() override; // Result properties diff --git a/lib/csapi/sso_login_redirect.cpp b/lib/csapi/sso_login_redirect.cpp index c2cc81cf..21fe646e 100644 --- a/lib/csapi/sso_login_redirect.cpp +++ b/lib/csapi/sso_login_redirect.cpp @@ -26,10 +26,9 @@ QUrl RedirectToSSOJob::makeRequestUrl(QUrl baseUrl, const QString& redirectUrl) queryToRedirectToSSO(redirectUrl)); } -static const auto RedirectToSSOJobName = QStringLiteral("RedirectToSSOJob"); - RedirectToSSOJob::RedirectToSSOJob(const QString& redirectUrl) - : BaseJob(HttpVerb::Get, RedirectToSSOJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("RedirectToSSOJob"), basePath % "/login/sso/redirect", queryToRedirectToSSO(redirectUrl), {}, false) + {} diff --git a/lib/csapi/sso_login_redirect.h b/lib/csapi/sso_login_redirect.h index b932a15e..8978c7f7 100644 --- a/lib/csapi/sso_login_redirect.h +++ b/lib/csapi/sso_login_redirect.h @@ -6,33 +6,31 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Redirect the user's browser to the SSO interface. -/*! +/*! \brief Redirect the user's browser to the SSO interface. + * * A web-based Matrix client should instruct the user's browser to * navigate to this endpoint in order to log in via SSO. * * The server MUST respond with an HTTP redirect to the SSO interface. */ -class RedirectToSSOJob : public BaseJob -{ +class RedirectToSSOJob : public BaseJob { public: - /*! Redirect the user's browser to the SSO interface. + /*! \brief Redirect the user's browser to the SSO interface. + * * \param redirectUrl * URI to which the user will be redirected after the homeserver has * authenticated the user with SSO. */ explicit RedirectToSSOJob(const QString& redirectUrl); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * RedirectToSSOJob is necessary but the job - * itself isn't. + * This function can be used when a URL for RedirectToSSOJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& redirectUrl); }; diff --git a/lib/csapi/tags.cpp b/lib/csapi/tags.cpp index 3df38074..0e2d122a 100644 --- a/lib/csapi/tags.cpp +++ b/lib/csapi/tags.cpp @@ -13,12 +13,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter<GetRoomTagsJob::Tag> -{ +struct JsonObjectConverter<GetRoomTagsJob::Tag> { static void fillFrom(QJsonObject jo, GetRoomTagsJob::Tag& result) { fromJson(jo.take("order"_ls), result.order); @@ -28,8 +26,7 @@ struct JsonObjectConverter<GetRoomTagsJob::Tag> } // namespace Quotient -class GetRoomTagsJob::Private -{ +class GetRoomTagsJob::Private { public: QHash<QString, Tag> tags; }; @@ -42,10 +39,8 @@ QUrl GetRoomTagsJob::makeRequestUrl(QUrl baseUrl, const QString& userId, % roomId % "/tags"); } -static const auto GetRoomTagsJobName = QStringLiteral("GetRoomTagsJob"); - GetRoomTagsJob::GetRoomTagsJob(const QString& userId, const QString& roomId) - : BaseJob(HttpVerb::Get, GetRoomTagsJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomTagsJob"), basePath % "/user/" % userId % "/rooms/" % roomId % "/tags") , d(new Private) {} @@ -65,11 +60,9 @@ BaseJob::Status GetRoomTagsJob::parseJson(const QJsonDocument& data) return Success; } -static const auto SetRoomTagJobName = QStringLiteral("SetRoomTagJob"); - SetRoomTagJob::SetRoomTagJob(const QString& userId, const QString& roomId, const QString& tag, Omittable<float> order) - : BaseJob(HttpVerb::Put, SetRoomTagJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomTagJob"), basePath % "/user/" % userId % "/rooms/" % roomId % "/tags/" % tag) { QJsonObject _data; @@ -85,10 +78,8 @@ QUrl DeleteRoomTagJob::makeRequestUrl(QUrl baseUrl, const QString& userId, % roomId % "/tags/" % tag); } -static const auto DeleteRoomTagJobName = QStringLiteral("DeleteRoomTagJob"); - DeleteRoomTagJob::DeleteRoomTagJob(const QString& userId, const QString& roomId, const QString& tag) - : BaseJob(HttpVerb::Delete, DeleteRoomTagJobName, + : BaseJob(HttpVerb::Delete, QStringLiteral("DeleteRoomTagJob"), basePath % "/user/" % userId % "/rooms/" % roomId % "/tags/" % tag) {} diff --git a/lib/csapi/tags.h b/lib/csapi/tags.h index 8ddebd6b..1ffb0f81 100644 --- a/lib/csapi/tags.h +++ b/lib/csapi/tags.h @@ -11,34 +11,31 @@ #include <QtCore/QHash> #include <QtCore/QVariant> -namespace Quotient -{ +namespace Quotient { // Operations -/// List the tags for a room. -/*! +/*! \brief List the tags for a room. + * * List the tags set by a user on a room. */ -class GetRoomTagsJob : public BaseJob -{ +class GetRoomTagsJob : public BaseJob { public: // Inner data structures /// List the tags set by a user on a room. - struct Tag - { - /// A number in a range ``[0,1]`` describing a relativeposition of the - /// room under the given tag. + struct Tag { + /// A number in a range ``[0,1]`` describing a relative + /// position of the room under the given tag. Omittable<float> order; - /// List the tags set by a user on a room. QVariantHash additionalProperties; }; // Construction/destruction - /*! List the tags for a room. + /*! \brief List the tags for a room. + * * \param userId * The id of the user to get tags for. The access token must be * authorized to make requests for this user ID. @@ -47,15 +44,13 @@ public: */ explicit GetRoomTagsJob(const QString& userId, const QString& roomId); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetRoomTagsJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetRoomTagsJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& roomId); - ~GetRoomTagsJob() override; // Result properties @@ -71,14 +66,14 @@ private: QScopedPointer<Private> d; }; -/// Add a tag to a room. -/*! +/*! \brief Add a tag to a room. + * * Add a tag to the room. */ -class SetRoomTagJob : public BaseJob -{ +class SetRoomTagJob : public BaseJob { public: - /*! Add a tag to a room. + /*! \brief Add a tag to a room. + * * \param userId * The id of the user to add a tag for. The access token must be * authorized to make requests for this user ID. @@ -94,14 +89,14 @@ public: const QString& tag, Omittable<float> order = none); }; -/// Remove a tag from the room. -/*! +/*! \brief Remove a tag from the room. + * * Remove a tag from the room. */ -class DeleteRoomTagJob : public BaseJob -{ +class DeleteRoomTagJob : public BaseJob { public: - /*! Remove a tag from the room. + /*! \brief Remove a tag from the room. + * * \param userId * The id of the user to remove a tag for. The access token must be * authorized to make requests for this user ID. @@ -113,11 +108,10 @@ public: explicit DeleteRoomTagJob(const QString& userId, const QString& roomId, const QString& tag); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * DeleteRoomTagJob is necessary but the job - * itself isn't. + * This function can be used when a URL for DeleteRoomTagJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& roomId, const QString& tag); diff --git a/lib/csapi/third_party_lookup.cpp b/lib/csapi/third_party_lookup.cpp index 678f6b3c..9d92e407 100644 --- a/lib/csapi/third_party_lookup.cpp +++ b/lib/csapi/third_party_lookup.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class GetProtocolsJob::Private -{ +class GetProtocolsJob::Private { public: QHash<QString, ThirdPartyProtocol> data; }; @@ -24,10 +23,8 @@ QUrl GetProtocolsJob::makeRequestUrl(QUrl baseUrl) basePath % "/thirdparty/protocols"); } -static const auto GetProtocolsJobName = QStringLiteral("GetProtocolsJob"); - GetProtocolsJob::GetProtocolsJob() - : BaseJob(HttpVerb::Get, GetProtocolsJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetProtocolsJob"), basePath % "/thirdparty/protocols") , d(new Private) {} @@ -42,11 +39,11 @@ const QHash<QString, ThirdPartyProtocol>& GetProtocolsJob::data() const BaseJob::Status GetProtocolsJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } -class GetProtocolMetadataJob::Private -{ +class GetProtocolMetadataJob::Private { public: ThirdPartyProtocol data; }; @@ -54,15 +51,12 @@ public: QUrl GetProtocolMetadataJob::makeRequestUrl(QUrl baseUrl, const QString& protocol) { - return BaseJob::makeRequestUrl( - std::move(baseUrl), basePath % "/thirdparty/protocol/" % protocol); + return BaseJob::makeRequestUrl(std::move(baseUrl), + basePath % "/thirdparty/protocol/" % protocol); } -static const auto GetProtocolMetadataJobName = - QStringLiteral("GetProtocolMetadataJob"); - GetProtocolMetadataJob::GetProtocolMetadataJob(const QString& protocol) - : BaseJob(HttpVerb::Get, GetProtocolMetadataJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetProtocolMetadataJob"), basePath % "/thirdparty/protocol/" % protocol) , d(new Private) {} @@ -77,11 +71,11 @@ const ThirdPartyProtocol& GetProtocolMetadataJob::data() const BaseJob::Status GetProtocolMetadataJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } -class QueryLocationByProtocolJob::Private -{ +class QueryLocationByProtocolJob::Private { public: QVector<ThirdPartyLocation> data; }; @@ -102,12 +96,9 @@ QUrl QueryLocationByProtocolJob::makeRequestUrl(QUrl baseUrl, queryToQueryLocationByProtocol(searchFields)); } -static const auto QueryLocationByProtocolJobName = - QStringLiteral("QueryLocationByProtocolJob"); - QueryLocationByProtocolJob::QueryLocationByProtocolJob( const QString& protocol, const QString& searchFields) - : BaseJob(HttpVerb::Get, QueryLocationByProtocolJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("QueryLocationByProtocolJob"), basePath % "/thirdparty/location/" % protocol, queryToQueryLocationByProtocol(searchFields)) , d(new Private) @@ -123,11 +114,11 @@ const QVector<ThirdPartyLocation>& QueryLocationByProtocolJob::data() const BaseJob::Status QueryLocationByProtocolJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } -class QueryUserByProtocolJob::Private -{ +class QueryUserByProtocolJob::Private { public: QVector<ThirdPartyUser> data; }; @@ -148,12 +139,9 @@ QUrl QueryUserByProtocolJob::makeRequestUrl(QUrl baseUrl, queryToQueryUserByProtocol(fields)); } -static const auto QueryUserByProtocolJobName = - QStringLiteral("QueryUserByProtocolJob"); - QueryUserByProtocolJob::QueryUserByProtocolJob(const QString& protocol, const QString& fields) - : BaseJob(HttpVerb::Get, QueryUserByProtocolJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("QueryUserByProtocolJob"), basePath % "/thirdparty/user/" % protocol, queryToQueryUserByProtocol(fields)) , d(new Private) @@ -169,11 +157,11 @@ const QVector<ThirdPartyUser>& QueryUserByProtocolJob::data() const BaseJob::Status QueryUserByProtocolJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } -class QueryLocationByAliasJob::Private -{ +class QueryLocationByAliasJob::Private { public: QVector<ThirdPartyLocation> data; }; @@ -192,11 +180,8 @@ QUrl QueryLocationByAliasJob::makeRequestUrl(QUrl baseUrl, const QString& alias) queryToQueryLocationByAlias(alias)); } -static const auto QueryLocationByAliasJobName = - QStringLiteral("QueryLocationByAliasJob"); - QueryLocationByAliasJob::QueryLocationByAliasJob(const QString& alias) - : BaseJob(HttpVerb::Get, QueryLocationByAliasJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("QueryLocationByAliasJob"), basePath % "/thirdparty/location", queryToQueryLocationByAlias(alias)) , d(new Private) @@ -212,11 +197,11 @@ const QVector<ThirdPartyLocation>& QueryLocationByAliasJob::data() const BaseJob::Status QueryLocationByAliasJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } -class QueryUserByIDJob::Private -{ +class QueryUserByIDJob::Private { public: QVector<ThirdPartyUser> data; }; @@ -235,10 +220,8 @@ QUrl QueryUserByIDJob::makeRequestUrl(QUrl baseUrl, const QString& userid) queryToQueryUserByID(userid)); } -static const auto QueryUserByIDJobName = QStringLiteral("QueryUserByIDJob"); - QueryUserByIDJob::QueryUserByIDJob(const QString& userid) - : BaseJob(HttpVerb::Get, QueryUserByIDJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("QueryUserByIDJob"), basePath % "/thirdparty/user", queryToQueryUserByID(userid)) , d(new Private) {} @@ -253,5 +236,6 @@ const QVector<ThirdPartyUser>& QueryUserByIDJob::data() const BaseJob::Status QueryUserByIDJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } diff --git a/lib/csapi/third_party_lookup.h b/lib/csapi/third_party_lookup.h index 63607549..c8ca8cbb 100644 --- a/lib/csapi/third_party_lookup.h +++ b/lib/csapi/third_party_lookup.h @@ -15,30 +15,27 @@ #include <QtCore/QHash> #include <QtCore/QVector> -namespace Quotient -{ +namespace Quotient { // Operations -/// Retrieve metadata about all protocols that a homeserver supports. -/*! +/*! \brief Retrieve metadata about all protocols that a homeserver supports. + * * Fetches the overall metadata about protocols supported by the * homeserver. Includes both the available protocols and all fields * required for queries against each protocol. */ -class GetProtocolsJob : public BaseJob -{ +class GetProtocolsJob : public BaseJob { public: + /// Retrieve metadata about all protocols that a homeserver supports. explicit GetProtocolsJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetProtocolsJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetProtocolsJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetProtocolsJob() override; // Result properties @@ -54,27 +51,28 @@ private: QScopedPointer<Private> d; }; -/// Retrieve metadata about a specific protocol that the homeserver supports. -/*! +/*! \brief Retrieve metadata about a specific protocol that the homeserver + * supports. + * * Fetches the metadata from the homeserver about a particular third party * protocol. */ -class GetProtocolMetadataJob : public BaseJob -{ +class GetProtocolMetadataJob : public BaseJob { public: - /*! Retrieve metadata about a specific protocol that the homeserver - * supports. \param protocol The name of the protocol. + /*! \brief Retrieve metadata about a specific protocol that the homeserver + * supports. + * + * \param protocol + * The name of the protocol. */ explicit GetProtocolMetadataJob(const QString& protocol); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetProtocolMetadataJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetProtocolMetadataJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& protocol); - ~GetProtocolMetadataJob() override; // Result properties @@ -90,8 +88,8 @@ private: QScopedPointer<Private> d; }; -/// Retrieve Matrix-side portals rooms leading to a third party location. -/*! +/*! \brief Retrieve Matrix-side portals rooms leading to a third party location. + * * Requesting this endpoint with a valid protocol name results in a list * of successful mapping results in a JSON array. Each result contains * objects to represent the Matrix room or rooms that represent a portal @@ -101,10 +99,11 @@ private: * identifier. It should attempt to canonicalise the identifier as much * as reasonably possible given the network type. */ -class QueryLocationByProtocolJob : public BaseJob -{ +class QueryLocationByProtocolJob : public BaseJob { public: - /*! Retrieve Matrix-side portals rooms leading to a third party location. + /*! \brief Retrieve Matrix-side portals rooms leading to a third party + * location. + * * \param protocol * The protocol used to communicate to the third party network. * \param searchFields @@ -114,15 +113,13 @@ public: explicit QueryLocationByProtocolJob(const QString& protocol, const QString& searchFields = {}); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * QueryLocationByProtocolJob is necessary but the job - * itself isn't. + * This function can be used when a URL for QueryLocationByProtocolJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& protocol, const QString& searchFields = {}); - ~QueryLocationByProtocolJob() override; // Result properties @@ -138,15 +135,15 @@ private: QScopedPointer<Private> d; }; -/// Retrieve the Matrix User ID of a corresponding third party user. -/*! +/*! \brief Retrieve the Matrix User ID of a corresponding third party user. + * * Retrieve a Matrix User ID linked to a user on the third party service, given * a set of user parameters. */ -class QueryUserByProtocolJob : public BaseJob -{ +class QueryUserByProtocolJob : public BaseJob { public: - /*! Retrieve the Matrix User ID of a corresponding third party user. + /*! \brief Retrieve the Matrix User ID of a corresponding third party user. + * * \param protocol * The name of the protocol. * \param fields @@ -156,15 +153,13 @@ public: explicit QueryUserByProtocolJob(const QString& protocol, const QString& fields = {}); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * QueryUserByProtocolJob is necessary but the job - * itself isn't. + * This function can be used when a URL for QueryUserByProtocolJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& protocol, const QString& fields = {}); - ~QueryUserByProtocolJob() override; // Result properties @@ -180,28 +175,26 @@ private: QScopedPointer<Private> d; }; -/// Reverse-lookup third party locations given a Matrix room alias. -/*! +/*! \brief Reverse-lookup third party locations given a Matrix room alias. + * * Retrieve an array of third party network locations from a Matrix room * alias. */ -class QueryLocationByAliasJob : public BaseJob -{ +class QueryLocationByAliasJob : public BaseJob { public: - /*! Reverse-lookup third party locations given a Matrix room alias. + /*! \brief Reverse-lookup third party locations given a Matrix room alias. + * * \param alias * The Matrix room alias to look up. */ explicit QueryLocationByAliasJob(const QString& alias); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * QueryLocationByAliasJob is necessary but the job - * itself isn't. + * This function can be used when a URL for QueryLocationByAliasJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& alias); - ~QueryLocationByAliasJob() override; // Result properties @@ -217,27 +210,25 @@ private: QScopedPointer<Private> d; }; -/// Reverse-lookup third party users given a Matrix User ID. -/*! +/*! \brief Reverse-lookup third party users given a Matrix User ID. + * * Retrieve an array of third party users from a Matrix User ID. */ -class QueryUserByIDJob : public BaseJob -{ +class QueryUserByIDJob : public BaseJob { public: - /*! Reverse-lookup third party users given a Matrix User ID. + /*! \brief Reverse-lookup third party users given a Matrix User ID. + * * \param userid * The Matrix User ID to look up. */ explicit QueryUserByIDJob(const QString& userid); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * QueryUserByIDJob is necessary but the job - * itself isn't. + * This function can be used when a URL for QueryUserByIDJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userid); - ~QueryUserByIDJob() override; // Result properties diff --git a/lib/csapi/third_party_membership.cpp b/lib/csapi/third_party_membership.cpp index 7e401163..15da6b3c 100644 --- a/lib/csapi/third_party_membership.cpp +++ b/lib/csapi/third_party_membership.cpp @@ -12,11 +12,9 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -static const auto InviteBy3PIDJobName = QStringLiteral("InviteBy3PIDJob"); - InviteBy3PIDJob::InviteBy3PIDJob(const QString& roomId, const QString& idServer, const QString& medium, const QString& address) - : BaseJob(HttpVerb::Post, InviteBy3PIDJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("InviteBy3PIDJob"), basePath % "/rooms/" % roomId % "/invite") { QJsonObject _data; diff --git a/lib/csapi/third_party_membership.h b/lib/csapi/third_party_membership.h index bd4c6896..c85e8ab4 100644 --- a/lib/csapi/third_party_membership.h +++ b/lib/csapi/third_party_membership.h @@ -6,13 +6,12 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Invite a user to participate in a particular room. -/*! +/*! \brief Invite a user to participate in a particular room. + * * .. _invite-by-third-party-id-endpoint: * * *Note that there are two forms of this API, which are documented separately. @@ -58,10 +57,10 @@ namespace Quotient * * .. _joining rooms section: `invite-by-user-id-endpoint`_ */ -class InviteBy3PIDJob : public BaseJob -{ +class InviteBy3PIDJob : public BaseJob { public: - /*! Invite a user to participate in a particular room. + /*! \brief Invite a user to participate in a particular room. + * * \param roomId * The room identifier (not alias) to which to invite the user. * \param idServer diff --git a/lib/csapi/to_device.cpp b/lib/csapi/to_device.cpp index 3f6e8097..e277503c 100644 --- a/lib/csapi/to_device.cpp +++ b/lib/csapi/to_device.cpp @@ -12,12 +12,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -static const auto SendToDeviceJobName = QStringLiteral("SendToDeviceJob"); - SendToDeviceJob::SendToDeviceJob( const QString& eventType, const QString& txnId, const QHash<QString, QHash<QString, QJsonObject>>& messages) - : BaseJob(HttpVerb::Put, SendToDeviceJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SendToDeviceJob"), basePath % "/sendToDevice/" % eventType % "/" % txnId) { QJsonObject _data; diff --git a/lib/csapi/to_device.h b/lib/csapi/to_device.h index 14445439..48f0ec83 100644 --- a/lib/csapi/to_device.h +++ b/lib/csapi/to_device.h @@ -9,20 +9,19 @@ #include <QtCore/QHash> #include <QtCore/QJsonObject> -namespace Quotient -{ +namespace Quotient { // Operations -/// Send an event to a given set of devices. -/*! +/*! \brief Send an event to a given set of devices. + * * This endpoint is used to send send-to-device events to a set of * client devices. */ -class SendToDeviceJob : public BaseJob -{ +class SendToDeviceJob : public BaseJob { public: - /*! Send an event to a given set of devices. + /*! \brief Send an event to a given set of devices. + * * \param eventType * The type of event to send. * \param txnId diff --git a/lib/csapi/typing.cpp b/lib/csapi/typing.cpp index 064ebe39..261622c4 100644 --- a/lib/csapi/typing.cpp +++ b/lib/csapi/typing.cpp @@ -12,11 +12,9 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -static const auto SetTypingJobName = QStringLiteral("SetTypingJob"); - SetTypingJob::SetTypingJob(const QString& userId, const QString& roomId, bool typing, Omittable<int> timeout) - : BaseJob(HttpVerb::Put, SetTypingJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SetTypingJob"), basePath % "/rooms/" % roomId % "/typing/" % userId) { QJsonObject _data; diff --git a/lib/csapi/typing.h b/lib/csapi/typing.h index 350c209d..dbf17a3e 100644 --- a/lib/csapi/typing.h +++ b/lib/csapi/typing.h @@ -8,22 +8,21 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Informs the server that the user has started or stopped typing. -/*! +/*! \brief Informs the server that the user has started or stopped typing. + * * This tells the server that the user is typing for the next N * milliseconds where N is the value specified in the ``timeout`` key. * Alternatively, if ``typing`` is ``false``, it tells the server that the * user has stopped typing. */ -class SetTypingJob : public BaseJob -{ +class SetTypingJob : public BaseJob { public: - /*! Informs the server that the user has started or stopped typing. + /*! \brief Informs the server that the user has started or stopped typing. + * * \param userId * The user who has started to type. * \param roomId diff --git a/lib/csapi/users.cpp b/lib/csapi/users.cpp index 77c297dd..5d2a6133 100644 --- a/lib/csapi/users.cpp +++ b/lib/csapi/users.cpp @@ -13,12 +13,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter<SearchUserDirectoryJob::User> -{ +struct JsonObjectConverter<SearchUserDirectoryJob::User> { static void fillFrom(const QJsonObject& jo, SearchUserDirectoryJob::User& result) { @@ -30,19 +28,15 @@ struct JsonObjectConverter<SearchUserDirectoryJob::User> } // namespace Quotient -class SearchUserDirectoryJob::Private -{ +class SearchUserDirectoryJob::Private { public: QVector<User> results; bool limited; }; -static const auto SearchUserDirectoryJobName = - QStringLiteral("SearchUserDirectoryJob"); - SearchUserDirectoryJob::SearchUserDirectoryJob(const QString& searchTerm, Omittable<int> limit) - : BaseJob(HttpVerb::Post, SearchUserDirectoryJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("SearchUserDirectoryJob"), basePath % "/user_directory/search") , d(new Private) { diff --git a/lib/csapi/users.h b/lib/csapi/users.h index d9a16a9d..de4eb529 100644 --- a/lib/csapi/users.h +++ b/lib/csapi/users.h @@ -10,13 +10,12 @@ #include <QtCore/QVector> -namespace Quotient -{ +namespace Quotient { // Operations -/// Searches the user directory. -/*! +/*! \brief Searches the user directory. + * * Performs a search for users on the homeserver. The homeserver may * determine which subset of users are searched, however the homeserver * MUST at a minimum consider the users the requesting user shares a @@ -28,22 +27,21 @@ namespace Quotient * names preferably using a collation determined based upon the * ``Accept-Language`` header provided in the request, if present. */ -class SearchUserDirectoryJob : public BaseJob -{ +class SearchUserDirectoryJob : public BaseJob { public: // Inner data structures - /// Performs a search for users on the homeserver. The homeserver - /// maydetermine which subset of users are searched, however the - /// homeserverMUST at a minimum consider the users the requesting user - /// shares aroom with and those who reside in public rooms (known to the - /// homeserver).The search MUST consider local users to the homeserver, and - /// SHOULDquery remote users as part of the search.The search is performed - /// case-insensitively on user IDs and displaynames preferably using a - /// collation determined based upon the ``Accept-Language`` header provided - /// in the request, if present. - struct User - { + /// Performs a search for users on the homeserver. The homeserver may + /// determine which subset of users are searched, however the homeserver + /// MUST at a minimum consider the users the requesting user shares a + /// room with and those who reside in public rooms (known to the + /// homeserver). The search MUST consider local users to the homeserver, and + /// SHOULD query remote users as part of the search. + /// + /// The search is performed case-insensitively on user IDs and display + /// names preferably using a collation determined based upon the + /// ``Accept-Language`` header provided in the request, if present. + struct User { /// The user's matrix user ID. QString userId; /// The display name of the user, if one exists. @@ -54,7 +52,8 @@ public: // Construction/destruction - /*! Searches the user directory. + /*! \brief Searches the user directory. + * * \param searchTerm * The term to search for * \param limit @@ -69,6 +68,7 @@ public: /// Ordered by rank and then whether or not profile info is available. const QVector<User>& results() const; + /// Indicates if the result list has been truncated by the limit. bool limited() const; diff --git a/lib/csapi/versions.cpp b/lib/csapi/versions.cpp index 9607a1b6..8cce03b9 100644 --- a/lib/csapi/versions.cpp +++ b/lib/csapi/versions.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client"); -class GetVersionsJob::Private -{ +class GetVersionsJob::Private { public: QStringList versions; QHash<QString, bool> unstableFeatures; @@ -24,10 +23,9 @@ QUrl GetVersionsJob::makeRequestUrl(QUrl baseUrl) return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/versions"); } -static const auto GetVersionsJobName = QStringLiteral("GetVersionsJob"); - GetVersionsJob::GetVersionsJob() - : BaseJob(HttpVerb::Get, GetVersionsJobName, basePath % "/versions", false) + : BaseJob(HttpVerb::Get, QStringLiteral("GetVersionsJob"), + basePath % "/versions", false) , d(new Private) {} diff --git a/lib/csapi/versions.h b/lib/csapi/versions.h index aa8cbac6..4c4f8109 100644 --- a/lib/csapi/versions.h +++ b/lib/csapi/versions.h @@ -10,13 +10,12 @@ #include <QtCore/QHash> -namespace Quotient -{ +namespace Quotient { // Operations -/// Gets the versions of the specification supported by the server. -/*! +/*! \brief Gets the versions of the specification supported by the server. + * * Gets the versions of the specification supported by the server. * * Values will take the form ``rX.Y.Z``. @@ -38,25 +37,24 @@ namespace Quotient * upgrade appropriately. Additionally, clients should avoid using unstable * features in their stable releases. */ -class GetVersionsJob : public BaseJob -{ +class GetVersionsJob : public BaseJob { public: + /// Gets the versions of the specification supported by the server. explicit GetVersionsJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetVersionsJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetVersionsJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetVersionsJob() override; // Result properties /// The supported versions. const QStringList& versions() const; + /// Experimental features the server supports. Features not listed here, /// or the lack of this property all together, indicate that a feature is /// not supported. diff --git a/lib/csapi/voip.cpp b/lib/csapi/voip.cpp index c95afe16..c98824b3 100644 --- a/lib/csapi/voip.cpp +++ b/lib/csapi/voip.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class GetTurnServerJob::Private -{ +class GetTurnServerJob::Private { public: QJsonObject data; }; @@ -24,10 +23,9 @@ QUrl GetTurnServerJob::makeRequestUrl(QUrl baseUrl) basePath % "/voip/turnServer"); } -static const auto GetTurnServerJobName = QStringLiteral("GetTurnServerJob"); - GetTurnServerJob::GetTurnServerJob() - : BaseJob(HttpVerb::Get, GetTurnServerJobName, basePath % "/voip/turnServer") + : BaseJob(HttpVerb::Get, QStringLiteral("GetTurnServerJob"), + basePath % "/voip/turnServer") , d(new Private) {} @@ -38,5 +36,6 @@ const QJsonObject& GetTurnServerJob::data() const { return d->data; } BaseJob::Status GetTurnServerJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } diff --git a/lib/csapi/voip.h b/lib/csapi/voip.h index 38abfa27..d3eb3c4b 100644 --- a/lib/csapi/voip.h +++ b/lib/csapi/voip.h @@ -8,29 +8,26 @@ #include <QtCore/QJsonObject> -namespace Quotient -{ +namespace Quotient { // Operations -/// Obtain TURN server credentials. -/*! +/*! \brief Obtain TURN server credentials. + * * This API provides credentials for the client to use when initiating * calls. */ -class GetTurnServerJob : public BaseJob -{ +class GetTurnServerJob : public BaseJob { public: + /// Obtain TURN server credentials. explicit GetTurnServerJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetTurnServerJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetTurnServerJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetTurnServerJob() override; // Result properties diff --git a/lib/csapi/wellknown.cpp b/lib/csapi/wellknown.cpp index 9a52a2a5..464068e7 100644 --- a/lib/csapi/wellknown.cpp +++ b/lib/csapi/wellknown.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/.well-known"); -class GetWellknownJob::Private -{ +class GetWellknownJob::Private { public: DiscoveryInformation data; }; @@ -24,11 +23,9 @@ QUrl GetWellknownJob::makeRequestUrl(QUrl baseUrl) basePath % "/matrix/client"); } -static const auto GetWellknownJobName = QStringLiteral("GetWellknownJob"); - GetWellknownJob::GetWellknownJob() - : BaseJob(HttpVerb::Get, GetWellknownJobName, basePath % "/matrix/client", - false) + : BaseJob(HttpVerb::Get, QStringLiteral("GetWellknownJob"), + basePath % "/matrix/client", false) , d(new Private) {} @@ -39,5 +36,6 @@ const DiscoveryInformation& GetWellknownJob::data() const { return d->data; } BaseJob::Status GetWellknownJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } diff --git a/lib/csapi/wellknown.h b/lib/csapi/wellknown.h index bce67d00..94d3631c 100644 --- a/lib/csapi/wellknown.h +++ b/lib/csapi/wellknown.h @@ -10,13 +10,12 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Gets Matrix server discovery information about the domain. -/*! +/*! \brief Gets Matrix server discovery information about the domain. + * * Gets discovery information about the domain. The file may include * additional keys, which MUST follow the Java package naming convention, * e.g. ``com.example.myapp.property``. This ensures property names are @@ -26,19 +25,17 @@ namespace Quotient * Note that this endpoint is not necessarily handled by the homeserver, * but by another webserver, to be used for discovering the homeserver URL. */ -class GetWellknownJob : public BaseJob -{ +class GetWellknownJob : public BaseJob { public: + /// Gets Matrix server discovery information about the domain. explicit GetWellknownJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetWellknownJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetWellknownJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetWellknownJob() override; // Result properties diff --git a/lib/csapi/whoami.cpp b/lib/csapi/whoami.cpp index fb7f54dc..8d4681e4 100644 --- a/lib/csapi/whoami.cpp +++ b/lib/csapi/whoami.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class GetTokenOwnerJob::Private -{ +class GetTokenOwnerJob::Private { public: QString userId; }; @@ -24,10 +23,9 @@ QUrl GetTokenOwnerJob::makeRequestUrl(QUrl baseUrl) basePath % "/account/whoami"); } -static const auto GetTokenOwnerJobName = QStringLiteral("GetTokenOwnerJob"); - GetTokenOwnerJob::GetTokenOwnerJob() - : BaseJob(HttpVerb::Get, GetTokenOwnerJobName, basePath % "/account/whoami") + : BaseJob(HttpVerb::Get, QStringLiteral("GetTokenOwnerJob"), + basePath % "/account/whoami") , d(new Private) {} diff --git a/lib/csapi/whoami.h b/lib/csapi/whoami.h index bbbb3899..dda8d8c8 100644 --- a/lib/csapi/whoami.h +++ b/lib/csapi/whoami.h @@ -6,13 +6,12 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Gets information about the owner of an access token. -/*! +/*! \brief Gets information about the owner of an access token. + * * Gets information about the owner of a given access token. * * Note that, as with the rest of the Client-Server API, @@ -22,19 +21,17 @@ namespace Quotient * is registered by the appservice, and return it in the response * body. */ -class GetTokenOwnerJob : public BaseJob -{ +class GetTokenOwnerJob : public BaseJob { public: + /// Gets information about the owner of an access token. explicit GetTokenOwnerJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetTokenOwnerJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetTokenOwnerJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetTokenOwnerJob() override; // Result properties |