Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Quotient/application-service/definitions/location.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

namespace Quotient {

struct QUOTIENT_API ThirdPartyLocation {
struct QUOTIENT_API ThirdPartyLocation
{
//! An alias for a matrix room.
QString alias;

Expand All @@ -18,14 +19,15 @@ struct QUOTIENT_API ThirdPartyLocation {
};

template <>
struct JsonObjectConverter<ThirdPartyLocation> {
static void dumpTo(QJsonObject& jo, const ThirdPartyLocation& pod)
struct JsonObjectConverter<ThirdPartyLocation>
{
static void dumpTo(QJsonObject &jo, const ThirdPartyLocation &pod)
{
addParam(jo, "alias"_L1, pod.alias);
addParam(jo, "protocol"_L1, pod.protocol);
addParam(jo, "fields"_L1, pod.fields);
}
static void fillFrom(const QJsonObject& jo, ThirdPartyLocation& pod)
static void fillFrom(const QJsonObject &jo, ThirdPartyLocation &pod)
{
fillFromJson(jo.value("alias"_L1), pod.alias);
fillFromJson(jo.value("protocol"_L1), pod.protocol);
Expand Down
35 changes: 35 additions & 0 deletions Quotient/application-service/definitions/protocol_base.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN

#pragma once

#include <Quotient/converters.h>

namespace Quotient {
//! Definition of valid values for a field.
struct QUOTIENT_API FieldType
{
//! A regular expression for validation of a field's value. This may be relatively
//! coarse to verify the value as the application service providing this protocol
//! may apply additional validation or filtering.
QString regexp;

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

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

} // namespace Quotient
10 changes: 6 additions & 4 deletions Quotient/application-service/definitions/user.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

namespace Quotient {

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

Expand All @@ -18,14 +19,15 @@ struct QUOTIENT_API ThirdPartyUser {
};

template <>
struct JsonObjectConverter<ThirdPartyUser> {
static void dumpTo(QJsonObject& jo, const ThirdPartyUser& pod)
struct JsonObjectConverter<ThirdPartyUser>
{
static void dumpTo(QJsonObject &jo, const ThirdPartyUser &pod)
{
addParam(jo, "userid"_L1, pod.userid);
addParam(jo, "protocol"_L1, pod.protocol);
addParam(jo, "fields"_L1, pod.fields);
}
static void fillFrom(const QJsonObject& jo, ThirdPartyUser& pod)
static void fillFrom(const QJsonObject &jo, ThirdPartyUser &pod)
{
fillFromJson(jo.value("userid"_L1), pod.userid);
fillFromJson(jo.value("protocol"_L1), pod.protocol);
Expand Down
8 changes: 4 additions & 4 deletions Quotient/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -794,10 +794,10 @@ JobHandle<DownloadFileJob> Connection::downloadFile(const QUrl& url,
}

JobHandle<CreateRoomJob> Connection::createRoom(
RoomVisibility visibility, const QString& alias, const QString& name, const QString& topic,
QStringList invites, const QString& presetName, const QString& roomVersion, bool isDirect,
const QVector<CreateRoomJob::StateEvent>& initialState,
const QVector<CreateRoomJob::Invite3pid>& invite3pids, const QJsonObject& creationContent)
RoomVisibility visibility, const QString &alias, const QString &name, const QString &topic,
QStringList invites, const QString &presetName, const QString &roomVersion, bool isDirect,
const QVector<CreateRoomJob::StateEvent> &initialState, const QVector<Invite3pid> &invite3pids,
const QJsonObject &creationContent)
{
invites.removeOne(userId()); // The creator is by definition in the room
return callApi<CreateRoomJob>(visibility == PublishRoom ? u"public"_s : u"private"_s,
Expand Down
14 changes: 7 additions & 7 deletions Quotient/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -742,13 +742,13 @@ public Q_SLOTS:
//!
//! This method allows to customize room entirely to your liking,
//! providing all the attributes the original CS API provides.
JobHandle<CreateRoomJob> createRoom(RoomVisibility visibility, const QString& alias,
const QString& name, const QString& topic, QStringList invites,
const QString& presetName = {}, const QString& roomVersion = {},
bool isDirect = false,
const QVector<CreateRoomJob::StateEvent>& initialState = {},
const QVector<CreateRoomJob::Invite3pid>& invite3pids = {},
const QJsonObject& creationContent = {});
JobHandle<CreateRoomJob> createRoom(RoomVisibility visibility, const QString &alias,
const QString &name, const QString &topic,
QStringList invites, const QString &presetName = {},
const QString &roomVersion = {}, bool isDirect = false,
const QVector<CreateRoomJob::StateEvent> &initialState = {},
const QVector<Invite3pid> &invite3pids = {},
const QJsonObject &creationContent = {});

//! \brief Get a direct chat with a single user
//!
Expand Down
26 changes: 13 additions & 13 deletions Quotient/csapi/account-data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,44 @@

using namespace Quotient;

SetAccountDataJob::SetAccountDataJob(const QString& userId, const QString& type,
const QJsonObject& content)
SetAccountDataJob::SetAccountDataJob(const QString &userId, const QString &type,
const QJsonObject &content)
: BaseJob(HttpVerb::Put, u"SetAccountDataJob"_s,
makePath("/_matrix/client/v3", "/user/", userId, "/account_data/", type))
{
setRequestData({ toJson(content) });
setRequestData({toJson(content)});
}

QUrl GetAccountDataJob::makeRequestUrl(const HomeserverData& hsData, const QString& userId,
const QString& type)
QUrl GetAccountDataJob::makeRequestUrl(const HomeserverData &hsData, const QString &userId,
const QString &type)
{
return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/user/", userId,
"/account_data/", type));
}

GetAccountDataJob::GetAccountDataJob(const QString& userId, const QString& type)
GetAccountDataJob::GetAccountDataJob(const QString &userId, const QString &type)
: BaseJob(HttpVerb::Get, u"GetAccountDataJob"_s,
makePath("/_matrix/client/v3", "/user/", userId, "/account_data/", type))
{}

SetAccountDataPerRoomJob::SetAccountDataPerRoomJob(const QString& userId, const QString& roomId,
const QString& type, const QJsonObject& content)
SetAccountDataPerRoomJob::SetAccountDataPerRoomJob(const QString &userId, const QString &roomId,
const QString &type, const QJsonObject &content)
: BaseJob(HttpVerb::Put, u"SetAccountDataPerRoomJob"_s,
makePath("/_matrix/client/v3", "/user/", userId, "/rooms/", roomId, "/account_data/",
type))
{
setRequestData({ toJson(content) });
setRequestData({toJson(content)});
}

QUrl GetAccountDataPerRoomJob::makeRequestUrl(const HomeserverData& hsData, const QString& userId,
const QString& roomId, const QString& type)
QUrl GetAccountDataPerRoomJob::makeRequestUrl(const HomeserverData &hsData, const QString &userId,
const QString &roomId, const QString &type)
{
return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/user/", userId,
"/rooms/", roomId, "/account_data/", type));
}

GetAccountDataPerRoomJob::GetAccountDataPerRoomJob(const QString& userId, const QString& roomId,
const QString& type)
GetAccountDataPerRoomJob::GetAccountDataPerRoomJob(const QString &userId, const QString &roomId,
const QString &type)
: BaseJob(HttpVerb::Get, u"GetAccountDataPerRoomJob"_s,
makePath("/_matrix/client/v3", "/user/", userId, "/rooms/", roomId, "/account_data/",
type))
Expand Down
42 changes: 23 additions & 19 deletions Quotient/csapi/account-data.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ namespace Quotient {
//! Set some account data for the client. This config is only visible to the user
//! that set the account data. The config will be available to clients through the
//! top-level `account_data` field in the homeserver response to
//! [/sync](#get_matrixclientv3sync).
class QUOTIENT_API SetAccountDataJob : public BaseJob {
//! [/sync](/client-server-api/#get_matrixclientv3sync).
class QUOTIENT_API SetAccountDataJob : public BaseJob
{
public:
//! \param userId
//! The ID of the user to set account data for. The access token must be
Expand All @@ -24,15 +25,16 @@ class QUOTIENT_API SetAccountDataJob : public BaseJob {
//!
//! \param content
//! The content of the account data.
explicit SetAccountDataJob(const QString& userId, const QString& type,
const QJsonObject& content = {});
explicit SetAccountDataJob(const QString &userId, const QString &type,
const QJsonObject &content = {});
};

//! \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 QUOTIENT_API GetAccountDataJob : public BaseJob {
class QUOTIENT_API GetAccountDataJob : public BaseJob
{
public:
//! \param userId
//! The ID of the user to get account data for. The access token must be
Expand All @@ -41,29 +43,30 @@ class QUOTIENT_API GetAccountDataJob : public BaseJob {
//! \param type
//! The event type of the account data to get. Custom types should be
//! namespaced to avoid clashes.
explicit GetAccountDataJob(const QString& userId, const QString& type);
explicit GetAccountDataJob(const QString &userId, const QString &type);

//! \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.
static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& userId,
const QString& type);
static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &userId,
const QString &type);

// Result properties

//! The account data content for the given type.
QJsonObject data() const { return fromJson<QJsonObject>(jsonData()); }
};

inline auto collectResponse(const GetAccountDataJob* job) { return job->data(); }
inline auto collectResponse(const GetAccountDataJob *job) { return job->data(); }

//! \brief Set some account data for the user that is specific to a room.
//!
//! 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 delivered to
//! clients in the per-room entries via [/sync](#get_matrixclientv3sync).
class QUOTIENT_API SetAccountDataPerRoomJob : public BaseJob {
//! clients in the per-room entries via [/sync](/client-server-api/#get_matrixclientv3sync).
class QUOTIENT_API SetAccountDataPerRoomJob : public BaseJob
{
public:
//! \param userId
//! The ID of the user to set account data for. The access token must be
Expand All @@ -78,15 +81,16 @@ class QUOTIENT_API SetAccountDataPerRoomJob : public BaseJob {
//!
//! \param content
//! The content of the account data.
explicit SetAccountDataPerRoomJob(const QString& userId, const QString& roomId,
const QString& type, const QJsonObject& content = {});
explicit SetAccountDataPerRoomJob(const QString &userId, const QString &roomId,
const QString &type, const QJsonObject &content = {});
};

//! \brief Get some account data for the user that is specific to a room.
//!
//! 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 QUOTIENT_API GetAccountDataPerRoomJob : public BaseJob {
class QUOTIENT_API GetAccountDataPerRoomJob : public BaseJob
{
public:
//! \param userId
//! The ID of the user to get account data for. The access token must be
Expand All @@ -98,22 +102,22 @@ class QUOTIENT_API GetAccountDataPerRoomJob : public BaseJob {
//! \param type
//! The event type of the account data to get. Custom types should be
//! namespaced to avoid clashes.
explicit GetAccountDataPerRoomJob(const QString& userId, const QString& roomId,
const QString& type);
explicit GetAccountDataPerRoomJob(const QString &userId, const QString &roomId,
const QString &type);

//! \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.
static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& userId,
const QString& roomId, const QString& type);
static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &userId,
const QString &roomId, const QString &type);

// Result properties

//! The account data content for the given type.
QJsonObject data() const { return fromJson<QJsonObject>(jsonData()); }
};

inline auto collectResponse(const GetAccountDataPerRoomJob* job) { return job->data(); }
inline auto collectResponse(const GetAccountDataPerRoomJob *job) { return job->data(); }

} // namespace Quotient
4 changes: 2 additions & 2 deletions Quotient/csapi/admin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

using namespace Quotient;

QUrl GetWhoIsJob::makeRequestUrl(const HomeserverData& hsData, const QString& userId)
QUrl GetWhoIsJob::makeRequestUrl(const HomeserverData &hsData, const QString &userId)
{
return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/admin/whois/", userId));
}

GetWhoIsJob::GetWhoIsJob(const QString& userId)
GetWhoIsJob::GetWhoIsJob(const QString &userId)
: BaseJob(HttpVerb::Get, u"GetWhoIsJob"_s,
makePath("/_matrix/client/v3", "/admin/whois/", userId))
{}
Loading