-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
csapi/: generate key_backup.* and dependencies
- Loading branch information
1 parent
772ff8d
commit 25873cf
Showing
4 changed files
with
860 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/****************************************************************************** | ||
* THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <Quotient/converters.h> | ||
|
||
namespace Quotient { | ||
/// The key data | ||
struct KeyBackupData { | ||
/// The index of the first message in the session that the key can decrypt. | ||
int firstMessageIndex; | ||
|
||
/// The number of times this key has been forwarded via key-sharing between | ||
/// devices. | ||
int forwardedCount; | ||
|
||
/// Whether the device backing up the key verified the device that the key | ||
/// is from. | ||
bool isVerified; | ||
|
||
/// Algorithm-dependent data. See the documentation for the backup | ||
/// algorithms in [Server-side key | ||
/// backups](/client-server-api/#server-side-key-backups) for more | ||
/// information on the expected format of the data. | ||
QJsonObject sessionData; | ||
}; | ||
|
||
template <> | ||
struct JsonObjectConverter<KeyBackupData> { | ||
static void dumpTo(QJsonObject& jo, const KeyBackupData& pod) | ||
{ | ||
addParam<>(jo, QStringLiteral("first_message_index"), | ||
pod.firstMessageIndex); | ||
addParam<>(jo, QStringLiteral("forwarded_count"), pod.forwardedCount); | ||
addParam<>(jo, QStringLiteral("is_verified"), pod.isVerified); | ||
addParam<>(jo, QStringLiteral("session_data"), pod.sessionData); | ||
} | ||
static void fillFrom(const QJsonObject& jo, KeyBackupData& pod) | ||
{ | ||
fillFromJson(jo.value("first_message_index"_ls), pod.firstMessageIndex); | ||
fillFromJson(jo.value("forwarded_count"_ls), pod.forwardedCount); | ||
fillFromJson(jo.value("is_verified"_ls), pod.isVerified); | ||
fillFromJson(jo.value("session_data"_ls), pod.sessionData); | ||
} | ||
}; | ||
|
||
} // namespace Quotient |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/****************************************************************************** | ||
* THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <Quotient/csapi/definitions/key_backup_data.h> | ||
|
||
#include <Quotient/converters.h> | ||
|
||
namespace Quotient { | ||
/// The backed up keys for a room. | ||
struct RoomKeyBackup { | ||
/// A map of session IDs to key data. | ||
QHash<QString, KeyBackupData> sessions; | ||
}; | ||
|
||
template <> | ||
struct JsonObjectConverter<RoomKeyBackup> { | ||
static void dumpTo(QJsonObject& jo, const RoomKeyBackup& pod) | ||
{ | ||
addParam<>(jo, QStringLiteral("sessions"), pod.sessions); | ||
} | ||
static void fillFrom(const QJsonObject& jo, RoomKeyBackup& pod) | ||
{ | ||
fillFromJson(jo.value("sessions"_ls), pod.sessions); | ||
} | ||
}; | ||
|
||
} // namespace Quotient |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,295 @@ | ||
/****************************************************************************** | ||
* THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN | ||
*/ | ||
|
||
#include "key_backup.h" | ||
|
||
using namespace Quotient; | ||
|
||
PostRoomKeysVersionJob::PostRoomKeysVersionJob(const QString& algorithm, | ||
const QJsonObject& authData) | ||
: BaseJob(HttpVerb::Post, QStringLiteral("PostRoomKeysVersionJob"), | ||
makePath("/_matrix/client/v3", "/room_keys/version")) | ||
{ | ||
QJsonObject _dataJson; | ||
addParam<>(_dataJson, QStringLiteral("algorithm"), algorithm); | ||
addParam<>(_dataJson, QStringLiteral("auth_data"), authData); | ||
setRequestData({ _dataJson }); | ||
addExpectedKey("version"); | ||
} | ||
|
||
QUrl GetRoomKeysVersionCurrentJob::makeRequestUrl(QUrl baseUrl) | ||
{ | ||
return BaseJob::makeRequestUrl(std::move(baseUrl), | ||
makePath("/_matrix/client/v3", | ||
"/room_keys/version")); | ||
} | ||
|
||
GetRoomKeysVersionCurrentJob::GetRoomKeysVersionCurrentJob() | ||
: BaseJob(HttpVerb::Get, QStringLiteral("GetRoomKeysVersionCurrentJob"), | ||
makePath("/_matrix/client/v3", "/room_keys/version")) | ||
{ | ||
addExpectedKey("algorithm"); | ||
addExpectedKey("auth_data"); | ||
addExpectedKey("count"); | ||
addExpectedKey("etag"); | ||
addExpectedKey("version"); | ||
} | ||
|
||
QUrl GetRoomKeysVersionJob::makeRequestUrl(QUrl baseUrl, const QString& version) | ||
{ | ||
return BaseJob::makeRequestUrl(std::move(baseUrl), | ||
makePath("/_matrix/client/v3", | ||
"/room_keys/version/", version)); | ||
} | ||
|
||
GetRoomKeysVersionJob::GetRoomKeysVersionJob(const QString& version) | ||
: BaseJob(HttpVerb::Get, QStringLiteral("GetRoomKeysVersionJob"), | ||
makePath("/_matrix/client/v3", "/room_keys/version/", version)) | ||
{ | ||
addExpectedKey("algorithm"); | ||
addExpectedKey("auth_data"); | ||
addExpectedKey("count"); | ||
addExpectedKey("etag"); | ||
addExpectedKey("version"); | ||
} | ||
|
||
PutRoomKeysVersionJob::PutRoomKeysVersionJob(const QString& version, | ||
const QString& algorithm, | ||
const QJsonObject& authData) | ||
: BaseJob(HttpVerb::Put, QStringLiteral("PutRoomKeysVersionJob"), | ||
makePath("/_matrix/client/v3", "/room_keys/version/", version)) | ||
{ | ||
QJsonObject _dataJson; | ||
addParam<>(_dataJson, QStringLiteral("algorithm"), algorithm); | ||
addParam<>(_dataJson, QStringLiteral("auth_data"), authData); | ||
setRequestData({ _dataJson }); | ||
} | ||
|
||
QUrl DeleteRoomKeysVersionJob::makeRequestUrl(QUrl baseUrl, | ||
const QString& version) | ||
{ | ||
return BaseJob::makeRequestUrl(std::move(baseUrl), | ||
makePath("/_matrix/client/v3", | ||
"/room_keys/version/", version)); | ||
} | ||
|
||
DeleteRoomKeysVersionJob::DeleteRoomKeysVersionJob(const QString& version) | ||
: BaseJob(HttpVerb::Delete, QStringLiteral("DeleteRoomKeysVersionJob"), | ||
makePath("/_matrix/client/v3", "/room_keys/version/", version)) | ||
{} | ||
|
||
auto queryToPutRoomKeyBySessionId(const QString& version) | ||
{ | ||
QUrlQuery _q; | ||
addParam<>(_q, QStringLiteral("version"), version); | ||
return _q; | ||
} | ||
|
||
PutRoomKeyBySessionIdJob::PutRoomKeyBySessionIdJob(const QString& roomId, | ||
const QString& sessionId, | ||
const QString& version, | ||
const KeyBackupData& data) | ||
: BaseJob(HttpVerb::Put, QStringLiteral("PutRoomKeyBySessionIdJob"), | ||
makePath("/_matrix/client/v3", "/room_keys/keys/", roomId, "/", | ||
sessionId), | ||
queryToPutRoomKeyBySessionId(version)) | ||
{ | ||
setRequestData({ toJson(data) }); | ||
addExpectedKey("etag"); | ||
addExpectedKey("count"); | ||
} | ||
|
||
auto queryToGetRoomKeyBySessionId(const QString& version) | ||
{ | ||
QUrlQuery _q; | ||
addParam<>(_q, QStringLiteral("version"), version); | ||
return _q; | ||
} | ||
|
||
QUrl GetRoomKeyBySessionIdJob::makeRequestUrl(QUrl baseUrl, | ||
const QString& roomId, | ||
const QString& sessionId, | ||
const QString& version) | ||
{ | ||
return BaseJob::makeRequestUrl(std::move(baseUrl), | ||
makePath("/_matrix/client/v3", | ||
"/room_keys/keys/", roomId, "/", | ||
sessionId), | ||
queryToGetRoomKeyBySessionId(version)); | ||
} | ||
|
||
GetRoomKeyBySessionIdJob::GetRoomKeyBySessionIdJob(const QString& roomId, | ||
const QString& sessionId, | ||
const QString& version) | ||
: BaseJob(HttpVerb::Get, QStringLiteral("GetRoomKeyBySessionIdJob"), | ||
makePath("/_matrix/client/v3", "/room_keys/keys/", roomId, "/", | ||
sessionId), | ||
queryToGetRoomKeyBySessionId(version)) | ||
{} | ||
|
||
auto queryToDeleteRoomKeyBySessionId(const QString& version) | ||
{ | ||
QUrlQuery _q; | ||
addParam<>(_q, QStringLiteral("version"), version); | ||
return _q; | ||
} | ||
|
||
QUrl DeleteRoomKeyBySessionIdJob::makeRequestUrl(QUrl baseUrl, | ||
const QString& roomId, | ||
const QString& sessionId, | ||
const QString& version) | ||
{ | ||
return BaseJob::makeRequestUrl(std::move(baseUrl), | ||
makePath("/_matrix/client/v3", | ||
"/room_keys/keys/", roomId, "/", | ||
sessionId), | ||
queryToDeleteRoomKeyBySessionId(version)); | ||
} | ||
|
||
DeleteRoomKeyBySessionIdJob::DeleteRoomKeyBySessionIdJob( | ||
const QString& roomId, const QString& sessionId, const QString& version) | ||
: BaseJob(HttpVerb::Delete, QStringLiteral("DeleteRoomKeyBySessionIdJob"), | ||
makePath("/_matrix/client/v3", "/room_keys/keys/", roomId, "/", | ||
sessionId), | ||
queryToDeleteRoomKeyBySessionId(version)) | ||
{ | ||
addExpectedKey("etag"); | ||
addExpectedKey("count"); | ||
} | ||
|
||
auto queryToPutRoomKeysByRoomId(const QString& version) | ||
{ | ||
QUrlQuery _q; | ||
addParam<>(_q, QStringLiteral("version"), version); | ||
return _q; | ||
} | ||
|
||
PutRoomKeysByRoomIdJob::PutRoomKeysByRoomIdJob(const QString& roomId, | ||
const QString& version, | ||
const RoomKeyBackup& backupData) | ||
: BaseJob(HttpVerb::Put, QStringLiteral("PutRoomKeysByRoomIdJob"), | ||
makePath("/_matrix/client/v3", "/room_keys/keys/", roomId), | ||
queryToPutRoomKeysByRoomId(version)) | ||
{ | ||
setRequestData({ toJson(backupData) }); | ||
addExpectedKey("etag"); | ||
addExpectedKey("count"); | ||
} | ||
|
||
auto queryToGetRoomKeysByRoomId(const QString& version) | ||
{ | ||
QUrlQuery _q; | ||
addParam<>(_q, QStringLiteral("version"), version); | ||
return _q; | ||
} | ||
|
||
QUrl GetRoomKeysByRoomIdJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, | ||
const QString& version) | ||
{ | ||
return BaseJob::makeRequestUrl(std::move(baseUrl), | ||
makePath("/_matrix/client/v3", | ||
"/room_keys/keys/", roomId), | ||
queryToGetRoomKeysByRoomId(version)); | ||
} | ||
|
||
GetRoomKeysByRoomIdJob::GetRoomKeysByRoomIdJob(const QString& roomId, | ||
const QString& version) | ||
: BaseJob(HttpVerb::Get, QStringLiteral("GetRoomKeysByRoomIdJob"), | ||
makePath("/_matrix/client/v3", "/room_keys/keys/", roomId), | ||
queryToGetRoomKeysByRoomId(version)) | ||
{} | ||
|
||
auto queryToDeleteRoomKeysByRoomId(const QString& version) | ||
{ | ||
QUrlQuery _q; | ||
addParam<>(_q, QStringLiteral("version"), version); | ||
return _q; | ||
} | ||
|
||
QUrl DeleteRoomKeysByRoomIdJob::makeRequestUrl(QUrl baseUrl, | ||
const QString& roomId, | ||
const QString& version) | ||
{ | ||
return BaseJob::makeRequestUrl(std::move(baseUrl), | ||
makePath("/_matrix/client/v3", | ||
"/room_keys/keys/", roomId), | ||
queryToDeleteRoomKeysByRoomId(version)); | ||
} | ||
|
||
DeleteRoomKeysByRoomIdJob::DeleteRoomKeysByRoomIdJob(const QString& roomId, | ||
const QString& version) | ||
: BaseJob(HttpVerb::Delete, QStringLiteral("DeleteRoomKeysByRoomIdJob"), | ||
makePath("/_matrix/client/v3", "/room_keys/keys/", roomId), | ||
queryToDeleteRoomKeysByRoomId(version)) | ||
{ | ||
addExpectedKey("etag"); | ||
addExpectedKey("count"); | ||
} | ||
|
||
auto queryToPutRoomKeys(const QString& version) | ||
{ | ||
QUrlQuery _q; | ||
addParam<>(_q, QStringLiteral("version"), version); | ||
return _q; | ||
} | ||
|
||
PutRoomKeysJob::PutRoomKeysJob(const QString& version, | ||
const QHash<QString, RoomKeyBackup>& rooms) | ||
: BaseJob(HttpVerb::Put, QStringLiteral("PutRoomKeysJob"), | ||
makePath("/_matrix/client/v3", "/room_keys/keys"), | ||
queryToPutRoomKeys(version)) | ||
{ | ||
QJsonObject _dataJson; | ||
addParam<>(_dataJson, QStringLiteral("rooms"), rooms); | ||
setRequestData({ _dataJson }); | ||
addExpectedKey("etag"); | ||
addExpectedKey("count"); | ||
} | ||
|
||
auto queryToGetRoomKeys(const QString& version) | ||
{ | ||
QUrlQuery _q; | ||
addParam<>(_q, QStringLiteral("version"), version); | ||
return _q; | ||
} | ||
|
||
QUrl GetRoomKeysJob::makeRequestUrl(QUrl baseUrl, const QString& version) | ||
{ | ||
return BaseJob::makeRequestUrl(std::move(baseUrl), | ||
makePath("/_matrix/client/v3", | ||
"/room_keys/keys"), | ||
queryToGetRoomKeys(version)); | ||
} | ||
|
||
GetRoomKeysJob::GetRoomKeysJob(const QString& version) | ||
: BaseJob(HttpVerb::Get, QStringLiteral("GetRoomKeysJob"), | ||
makePath("/_matrix/client/v3", "/room_keys/keys"), | ||
queryToGetRoomKeys(version)) | ||
{ | ||
addExpectedKey("rooms"); | ||
} | ||
|
||
auto queryToDeleteRoomKeys(const QString& version) | ||
{ | ||
QUrlQuery _q; | ||
addParam<>(_q, QStringLiteral("version"), version); | ||
return _q; | ||
} | ||
|
||
QUrl DeleteRoomKeysJob::makeRequestUrl(QUrl baseUrl, const QString& version) | ||
{ | ||
return BaseJob::makeRequestUrl(std::move(baseUrl), | ||
makePath("/_matrix/client/v3", | ||
"/room_keys/keys"), | ||
queryToDeleteRoomKeys(version)); | ||
} | ||
|
||
DeleteRoomKeysJob::DeleteRoomKeysJob(const QString& version) | ||
: BaseJob(HttpVerb::Delete, QStringLiteral("DeleteRoomKeysJob"), | ||
makePath("/_matrix/client/v3", "/room_keys/keys"), | ||
queryToDeleteRoomKeys(version)) | ||
{ | ||
addExpectedKey("etag"); | ||
addExpectedKey("count"); | ||
} |
Oops, something went wrong.