Skip to content

Commit

Permalink
Regenerate API files
Browse files Browse the repository at this point in the history
  • Loading branch information
KitsuneRal committed Sep 20, 2024
1 parent 7d68540 commit 6e29644
Show file tree
Hide file tree
Showing 17 changed files with 310 additions and 131 deletions.
8 changes: 4 additions & 4 deletions Quotient/application-service/definitions/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct QUOTIENT_API FieldType {
//! may apply additional validation or filtering.
QString regexp;

//! An placeholder serving as a valid example of the field value.
//! A placeholder serving as a valid example of the field value.
QString placeholder;
};

Expand Down Expand Up @@ -79,9 +79,9 @@ struct QUOTIENT_API ThirdPartyProtocol {
//! A content URI representing an icon for the third-party protocol.
QString icon;

//! The type definitions for the fields defined in the `user_fields` and
//! `location_fields`. Each entry in those arrays MUST have an entry here. The
//! `string` key for this object is field name itself.
//! The type definitions for the fields defined in `user_fields` and
//! `location_fields`. Each entry in those arrays MUST have an entry here.
//! The `string` key for this object is the field name itself.
//!
//! May be an empty object if no fields are defined.
QHash<QString, FieldType> fieldTypes;
Expand Down
2 changes: 1 addition & 1 deletion Quotient/application-service/definitions/user.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace Quotient {

struct QUOTIENT_API ThirdPartyUser {
//! A Matrix User ID represting a third-party user.
//! A Matrix User ID representing a third-party user.
QString userid;

//! The protocol ID that the third-party location is a part of.
Expand Down
74 changes: 71 additions & 3 deletions Quotient/csapi/authed-content-repo.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,41 @@ class QUOTIENT_API GetContentAuthedJob : public BaseJob {
// Result properties

//! The content type of the file that was previously uploaded.
//!
//! The server MUST return a `Content-Type` which is either exactly the same
//! as the original upload, or reasonably close. The bounds of "reasonable"
//! are:
//!
//! * Adding a charset to `text/*` content types.
//! * Detecting HTML and using `text/html` instead of `text/plain`.
//! * Using `application/octet-stream` when the server determines the
//! content type is obviously wrong. For example, an encrypted file being
//! claimed as `image/png`.
//! * Returning `application/octet-stream` when the media has an
//! unknown/unprovided `Content-Type`. For example, being uploaded before
//! the server tracked content types or when the remote server is
//! non-compliantly omitting the header entirely.
//!
//! Actions not in the spirit of the above are not considered "reasonable".
QString contentType() const { return QString::fromUtf8(reply()->rawHeader("Content-Type")); }

//! The name of the file that was previously uploaded, if set.
//! The
//! [disposition](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition)
//! of the returned content. MUST be one of `inline` or `attachment`,
//! and SHOULD contain a file name.
//!
//! If the `Content-Type` is allowed in the [restrictions for serving
//! inline content](/client-server-api/#serving-inline-content),
//! servers SHOULD use `inline`, otherwise they SHOULD use
//! `attachment`.
//!
//! If the upload was made with a `filename`, this header MUST
//! contain the same `filename`. Otherwise, `filename` is excluded
//! from the header. If the media being downloaded is remote, the
//! remote server's `filename` in the `Content-Disposition` header
//! is used as the `filename` instead. When the header is not
//! supplied, or does not supply a `filename`, the local download
//! response does not include a `filename`.
QString contentDisposition() const
{
return QString::fromUtf8(reply()->rawHeader("Content-Disposition"));
Expand Down Expand Up @@ -103,10 +135,33 @@ class QUOTIENT_API GetContentOverrideNameAuthedJob : public BaseJob {
// Result properties

//! The content type of the file that was previously uploaded.
//!
//! The server MUST return a `Content-Type` which is either exactly the same
//! as the original upload, or reasonably close. The bounds of "reasonable"
//! are:
//!
//! * Adding a charset to `text/*` content types.
//! * Detecting HTML and using `text/html` instead of `text/plain`.
//! * Using `application/octet-stream` when the server determines the
//! content type is obviously wrong. For example, an encrypted file being
//! claimed as `image/png`.
//! * Returning `application/octet-stream` when the media has an
//! unknown/unprovided `Content-Type`. For example, being uploaded before
//! the server tracked content types or when the remote server is
//! non-compliantly omitting the header entirely.
//!
//! Actions not in the spirit of the above are not considered "reasonable".
QString contentType() const { return QString::fromUtf8(reply()->rawHeader("Content-Type")); }

//! The `fileName` requested or the name of the file that was previously
//! uploaded, if set.
//! The
//! [disposition](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition)
//! of the returned content. MUST be one of `inline` or `attachment`,
//! and MUST contain the file name requested in the path.
//!
//! If the `Content-Type` is allowed in the [restrictions for serving
//! inline content](/client-server-api/#serving-inline-content),
//! servers SHOULD use `inline`, otherwise they SHOULD use
//! `attachment`.
QString contentDisposition() const
{
return QString::fromUtf8(reply()->rawHeader("Content-Disposition"));
Expand Down Expand Up @@ -187,6 +242,19 @@ class QUOTIENT_API GetContentThumbnailAuthedJob : public BaseJob {

// Result properties

//! The
//! [disposition](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition)
//! of the returned content. MUST be `inline`, and SHOULD contain a file name (e.g.
//! `thumbnail.png`).
//!
//! Servers should note the [Content-Type restrictions for serving inline
//! content](/client-server-api/#serving-inline-content), as these limitations imply which
//! formats should be used for thumbnail generation.
QString contentDisposition() const
{
return QString::fromUtf8(reply()->rawHeader("Content-Disposition"));
}

//! The content type of the thumbnail.
QString contentType() const { return QString::fromUtf8(reply()->rawHeader("Content-Type")); }

Expand Down
55 changes: 39 additions & 16 deletions Quotient/csapi/capabilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@

namespace Quotient {

struct QUOTIENT_API BooleanCapability {
//! True if the user can perform the action, false otherwise.
bool enabled;
};

template <>
struct JsonObjectConverter<BooleanCapability> {
static void dumpTo(QJsonObject& jo, const BooleanCapability& pod)
{
addParam<>(jo, "enabled"_L1, pod.enabled);
}
static void fillFrom(const QJsonObject& jo, BooleanCapability& pod)
{
fillFromJson(jo.value("enabled"_L1), pod.enabled);
}
};

//! \brief Gets information about the server's capabilities.
//!
//! Gets information about the server's supported feature set
Expand All @@ -14,12 +31,6 @@ class QUOTIENT_API GetCapabilitiesJob : public BaseJob {
public:
// Inner data structures

//! Capability to indicate if the user can change their password.
struct QUOTIENT_API ChangePasswordCapability {
//! True if the user can change their password, false otherwise.
bool enabled;
};

//! The room versions the server supports.
struct QUOTIENT_API RoomVersionsCapability {
//! The default room version the server is using for new rooms.
Expand All @@ -33,12 +44,28 @@ class QUOTIENT_API GetCapabilitiesJob : public BaseJob {
//! Java package naming convention.
struct QUOTIENT_API Capabilities {
//! Capability to indicate if the user can change their password.
std::optional<ChangePasswordCapability> changePassword{};
std::optional<BooleanCapability> changePassword{};

//! The room versions the server supports.
std::optional<RoomVersionsCapability> roomVersions{};

QHash<QString, QJsonObject> additionalProperties{};
//! Capability to indicate if the user can change their display name.
std::optional<BooleanCapability> setDisplayname{};

//! Capability to indicate if the user can change their avatar.
std::optional<BooleanCapability> setAvatarUrl{};

//! Capability to indicate if the user can change 3PID associations on their account.
std::optional<BooleanCapability> thirdPartyIdChanges{};

//! Capability to indicate if the user can generate tokens to log further clients into their
//! account.
std::optional<BooleanCapability> getLoginToken{};

//! Application-dependent keys using the
//! [Common Namespaced Identifier
//! Grammar](/appendices/#common-namespaced-identifier-grammar).
QVariantHash additionalProperties{};
};

// Construction/destruction
Expand All @@ -60,14 +87,6 @@ class QUOTIENT_API GetCapabilitiesJob : public BaseJob {

inline auto collectResponse(const GetCapabilitiesJob* job) { return job->capabilities(); }

template <>
struct QUOTIENT_API JsonObjectConverter<GetCapabilitiesJob::ChangePasswordCapability> {
static void fillFrom(const QJsonObject& jo, GetCapabilitiesJob::ChangePasswordCapability& result)
{
fillFromJson(jo.value("enabled"_L1), result.enabled);
}
};

template <>
struct QUOTIENT_API JsonObjectConverter<GetCapabilitiesJob::RoomVersionsCapability> {
static void fillFrom(const QJsonObject& jo, GetCapabilitiesJob::RoomVersionsCapability& result)
Expand All @@ -83,6 +102,10 @@ struct QUOTIENT_API JsonObjectConverter<GetCapabilitiesJob::Capabilities> {
{
fillFromJson(jo.take("m.change_password"_L1), result.changePassword);
fillFromJson(jo.take("m.room_versions"_L1), result.roomVersions);
fillFromJson(jo.take("m.set_displayname"_L1), result.setDisplayname);
fillFromJson(jo.take("m.set_avatar_url"_L1), result.setAvatarUrl);
fillFromJson(jo.take("m.3pid_changes"_L1), result.thirdPartyIdChanges);
fillFromJson(jo.take("m.get_login_token"_L1), result.getLoginToken);
fromJson(jo, result.additionalProperties);
}
};
Expand Down
86 changes: 81 additions & 5 deletions Quotient/csapi/content-repo.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ class QUOTIENT_API UploadContentJob : public BaseJob {
//! The name of the file being uploaded
//!
//! \param contentType
//! The content type of the file being uploaded
//! **Optional.** The content type of the file being uploaded.
//!
//! Clients SHOULD always supply this header.
//!
//! Defaults to `application/octet-stream` if it is not set.
explicit UploadContentJob(QIODevice* content, const QString& filename = {},
const QString& contentType = {});

Expand Down Expand Up @@ -46,7 +50,11 @@ class QUOTIENT_API UploadContentToMXCJob : public BaseJob {
//! The name of the file being uploaded
//!
//! \param contentType
//! The content type of the file being uploaded
//! **Optional.** The content type of the file being uploaded.
//!
//! Clients SHOULD always supply this header.
//!
//! Defaults to `application/octet-stream` if it is not set.
explicit UploadContentToMXCJob(const QString& serverName, const QString& mediaId,
QIODevice* content, const QString& filename = {},
const QString& contentType = {});
Expand Down Expand Up @@ -166,9 +174,41 @@ class [[deprecated("Check the documentation for details")]] QUOTIENT_API GetCont
// Result properties

//! The content type of the file that was previously uploaded.
//!
//! The server MUST return a `Content-Type` which is either exactly the same
//! as the original upload, or reasonably close. The bounds of "reasonable"
//! are:
//!
//! * Adding a charset to `text/*` content types.
//! * Detecting HTML and using `text/html` instead of `text/plain`.
//! * Using `application/octet-stream` when the server determines the
//! content type is obviously wrong. For example, an encrypted file being
//! claimed as `image/png`.
//! * Returning `application/octet-stream` when the media has an
//! unknown/unprovided `Content-Type`. For example, being uploaded before
//! the server tracked content types or when the remote server is
//! non-compliantly omitting the header entirely.
//!
//! Actions not in the spirit of the above are not considered "reasonable".
QString contentType() const { return QString::fromUtf8(reply()->rawHeader("Content-Type")); }

//! The name of the file that was previously uploaded, if set.
//! The
//! [disposition](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition)
//! of the returned content. MUST be one of `inline` or `attachment`,
//! and SHOULD contain a file name.
//!
//! If the `Content-Type` is allowed in the [restrictions for serving
//! inline content](/client-server-api/#serving-inline-content),
//! servers SHOULD use `inline`, otherwise they SHOULD use
//! `attachment`.
//!
//! If the upload was made with a `filename`, this header MUST
//! contain the same `filename`. Otherwise, `filename` is excluded
//! from the header. If the media being downloaded is remote, the
//! remote server's `filename` in the `Content-Disposition` header
//! is used as the `filename` instead. When the header is not
//! supplied, or does not supply a `filename`, the local download
//! response does not include a `filename`.
QString contentDisposition() const
{
return QString::fromUtf8(reply()->rawHeader("Content-Disposition"));
Expand Down Expand Up @@ -240,10 +280,33 @@ class [[deprecated("Check the documentation for details")]] QUOTIENT_API GetCont
// Result properties

//! The content type of the file that was previously uploaded.
//!
//! The server MUST return a `Content-Type` which is either exactly the same
//! as the original upload, or reasonably close. The bounds of "reasonable"
//! are:
//!
//! * Adding a charset to `text/*` content types.
//! * Detecting HTML and using `text/html` instead of `text/plain`.
//! * Using `application/octet-stream` when the server determines the
//! content type is obviously wrong. For example, an encrypted file being
//! claimed as `image/png`.
//! * Returning `application/octet-stream` when the media has an
//! unknown/unprovided `Content-Type`. For example, being uploaded before
//! the server tracked content types or when the remote server is
//! non-compliantly omitting the header entirely.
//!
//! Actions not in the spirit of the above are not considered "reasonable".
QString contentType() const { return QString::fromUtf8(reply()->rawHeader("Content-Type")); }

//! The `fileName` requested or the name of the file that was previously
//! uploaded, if set.
//! The
//! [disposition](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition)
//! of the returned content. MUST be one of `inline` or `attachment`,
//! and MUST contain the file name requested in the path.
//!
//! If the `Content-Type` is allowed in the [restrictions for serving
//! inline content](/client-server-api/#serving-inline-content),
//! servers SHOULD use `inline`, otherwise they SHOULD use
//! `attachment`.
QString contentDisposition() const
{
return QString::fromUtf8(reply()->rawHeader("Content-Disposition"));
Expand Down Expand Up @@ -340,6 +403,19 @@ class [[deprecated("Check the documentation for details")]] QUOTIENT_API GetCont

// Result properties

//! The
//! [disposition](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition)
//! of the returned content. MUST be `inline`, and SHOULD contain a file name (e.g.
//! `thumbnail.png`).
//!
//! Servers should note the [Content-Type restrictions for serving inline
//! content](/client-server-api/#serving-inline-content), as these limitations imply which
//! formats should be used for thumbnail generation.
QString contentDisposition() const
{
return QString::fromUtf8(reply()->rawHeader("Content-Disposition"));
}

//! The content type of the thumbnail.
QString contentType() const { return QString::fromUtf8(reply()->rawHeader("Content-Type")); }

Expand Down
3 changes: 2 additions & 1 deletion Quotient/csapi/definitions/user_identifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
namespace Quotient {
//! Identification information for a user
struct QUOTIENT_API UserIdentifier {
//! The type of identification. See [Identifier types](/client-server-api/#identifier-types)
//! The type of identification. See [Identifier types](/client-server-api/#identifier-types)
//! for supported values and additional property descriptions.
QString type;

//! Keys dependent on the identification type.
QVariantHash additionalProperties{};
};

Expand Down
2 changes: 1 addition & 1 deletion Quotient/csapi/definitions/wellknown/full.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct QUOTIENT_API DiscoveryInformation {
std::optional<IdentityServerInformation> identityServer{};

//! Application-dependent keys using Java package naming convention.
QHash<QString, QJsonObject> additionalProperties{};
QVariantHash additionalProperties{};
};

template <>
Expand Down
7 changes: 5 additions & 2 deletions Quotient/csapi/joining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,21 @@ JoinRoomByIdJob::JoinRoomByIdJob(const QString& roomId,
addExpectedKey(u"room_id"_s);
}

auto queryToJoinRoom(const QStringList& serverName)
auto queryToJoinRoom(const QStringList& serverName, const QStringList& via)
{
QUrlQuery _q;
addParam<IfNotEmpty>(_q, u"server_name"_s, serverName);
addParam<IfNotEmpty>(_q, u"via"_s, via);
return _q;
}

JoinRoomJob::JoinRoomJob(const QString& roomIdOrAlias, const QStringList& serverName,
const QStringList& via,
const std::optional<ThirdPartySigned>& thirdPartySigned,
const QString& reason)
: BaseJob(HttpVerb::Post, u"JoinRoomJob"_s,
makePath("/_matrix/client/v3", "/join/", roomIdOrAlias), queryToJoinRoom(serverName))
makePath("/_matrix/client/v3", "/join/", roomIdOrAlias),
queryToJoinRoom(serverName, via))
{
QJsonObject _dataJson;
addParam<IfNotEmpty>(_dataJson, "third_party_signed"_L1, thirdPartySigned);
Expand Down
Loading

0 comments on commit 6e29644

Please sign in to comment.