Remove uses of Quotient:Omittable

Note this technically won't build for now because of the lack of RoomMember support but I'll push that at the quotient-next branch next. 

This is needed as well to get a branch that builds on dev.
This commit is contained in:
James Graham
2024-05-05 15:34:28 +00:00
committed by Tobias Fella
parent c6a4057659
commit 58d727350d
12 changed files with 30 additions and 26 deletions

View File

@@ -254,7 +254,7 @@ QString EventHandler::rawMessageBody(const Quotient::RoomMessageEvent &event)
QString body;
if (event.hasTextContent() && event.content()) {
body = static_cast<const MessageEventContent::TextContent *>(event.content())->body;
body = static_cast<const EventContent::TextContent *>(event.content())->body;
} else {
body = event.plainBody();
}
@@ -478,7 +478,7 @@ QString EventHandler::getMessageBody(const RoomMessageEvent &event, Qt::TextForm
QString body;
if (event.hasTextContent() && event.content()) {
body = static_cast<const MessageEventContent::TextContent *>(event.content())->body;
body = static_cast<const EventContent::TextContent *>(event.content())->body;
} else {
body = event.plainBody();
}

View File

@@ -3,6 +3,7 @@
#include "imagepackevent.h"
#include <QJsonObject>
#include <Quotient/omittable.h>
using namespace Quotient;
@@ -16,16 +17,16 @@ ImagePackEventContent::ImagePackEventContent(const QJsonObject &json)
fromJson<Omittable<QString>>(json["pack"_ls].toObject()["attribution"_ls]),
};
} else {
pack = none;
pack = std::nullopt;
}
const auto &keys = json["images"_ls].toObject().keys();
for (const auto &k : keys) {
Omittable<EventContent::ImageInfo> info;
std::optional<EventContent::ImageInfo> info;
if (json["images"_ls][k].toObject().contains(QStringLiteral("info"))) {
info = EventContent::ImageInfo(QUrl(json["images"_ls][k]["url"_ls].toString()), json["images"_ls][k]["info"_ls].toObject(), k);
} else {
info = none;
info = std::nullopt;
}
images += ImagePackImage{
k,

View File

@@ -26,10 +26,10 @@ public:
* @brief Defines the properties of an image pack.
*/
struct Pack {
Quotient::Omittable<QString> displayName; /**< The display name of the pack. */
Quotient::Omittable<QUrl> avatarUrl; /**< The source mxc URL for the pack avatar. */
Quotient::Omittable<QStringList> usage; /**< An array of the usages for this pack. Possible usages are "emoticon" and "sticker". */
Quotient::Omittable<QString> attribution; /**< The attribution for the pack author(s). */
std::optional<QString> displayName; /**< The display name of the pack. */
std::optional<QUrl> avatarUrl; /**< The source mxc URL for the pack avatar. */
std::optional<QStringList> usage; /**< An array of the usages for this pack. Possible usages are "emoticon" and "sticker". */
std::optional<QString> attribution; /**< The attribution for the pack author(s). */
};
/**
@@ -38,14 +38,14 @@ public:
struct ImagePackImage {
QString shortcode; /**< The shortcode for the image. */
QUrl url; /**< The mxc URL for this image. */
Quotient::Omittable<QString> body; /**< An optional text body for this image. */
Quotient::Omittable<Quotient::EventContent::ImageInfo> info; /**< The ImageInfo object used for the info block of m.sticker events. */
std::optional<QString> body; /**< An optional text body for this image. */
std::optional<Quotient::EventContent::ImageInfo> info; /**< The ImageInfo object used for the info block of m.sticker events. */
/**
* @brief An array of the usages for this image.
*
* The possible values match those of the usage key of a pack object.
*/
Quotient::Omittable<QStringList> usage;
std::optional<QStringList> usage;
};
/**
@@ -53,7 +53,7 @@ public:
*
* @sa Pack
*/
Quotient::Omittable<Pack> pack;
std::optional<Pack> pack;
/**
* @brief Return a vector of images in the pack.

View File

@@ -9,5 +9,5 @@
class NeochatAdd3PIdJob : public Quotient::BaseJob
{
public:
explicit NeochatAdd3PIdJob(const QString &clientSecret, const QString &sid, const Quotient::Omittable<QJsonObject> &auth = Quotient::none);
explicit NeochatAdd3PIdJob(const QString &clientSecret, const QString &sid, const Quotient::Omittable<QJsonObject> &auth = {});
};

View File

@@ -4,10 +4,11 @@
#pragma once
#include <Quotient/jobs/basejob.h>
#include <Quotient/omittable.h>
class NeochatChangePasswordJob : public Quotient::BaseJob
{
public:
explicit NeochatChangePasswordJob(const QString &newPassword, bool logoutDevices, const Quotient::Omittable<QJsonObject> &auth = Quotient::none);
explicit NeochatChangePasswordJob(const QString &newPassword, bool logoutDevices, const Quotient::Omittable<QJsonObject> &auth = {});
};

View File

@@ -9,5 +9,5 @@
class NeoChatDeactivateAccountJob : public Quotient::BaseJob
{
public:
explicit NeoChatDeactivateAccountJob(const Quotient::Omittable<QJsonObject> &auth = Quotient::none);
explicit NeoChatDeactivateAccountJob(const Quotient::Omittable<QJsonObject> &auth = {});
};

View File

@@ -9,5 +9,5 @@
class NeochatDeleteDeviceJob : public Quotient::BaseJob
{
public:
explicit NeochatDeleteDeviceJob(const QString &deviceId, const Quotient::Omittable<QJsonObject> &auth = Quotient::none);
explicit NeochatDeleteDeviceJob(const QString &deviceId, const Quotient::Omittable<QJsonObject> &auth = {});
};

View File

@@ -44,7 +44,7 @@ void SearchModel::search()
}
RoomEventFilter filter;
filter.unreadThreadNotifications = none;
filter.unreadThreadNotifications = std::nullopt;
filter.lazyLoadMembers = true;
filter.includeRedundantMembers = false;
filter.notRooms = QStringList();
@@ -58,7 +58,7 @@ void SearchModel::search()
.orderBy = "recent"_ls,
.eventContext = SearchJob::IncludeEventContext{3, 3, true},
.includeState = false,
.groupings = none,
.groupings = std::nullopt,
};

View File

@@ -87,7 +87,7 @@ void SpaceChildrenModel::refreshModel()
m_rootItem =
new SpaceTreeItem(dynamic_cast<NeoChatConnection *>(m_space->connection()), nullptr, m_space->id(), m_space->displayName(), m_space->canonicalAlias());
endResetModel();
auto job = m_space->connection()->callApi<Quotient::GetSpaceHierarchyJob>(m_space->id(), Quotient::none, Quotient::none, 1);
auto job = m_space->connection()->callApi<Quotient::GetSpaceHierarchyJob>(m_space->id(), std::nullopt, std::nullopt, 1);
m_currentJobs.append(job);
connect(job, &Quotient::BaseJob::success, this, [this, job]() {
insertChildren(job->rooms());
@@ -136,7 +136,7 @@ void SpaceChildrenModel::insertChildren(std::vector<Quotient::GetSpaceHierarchyJ
}
}
if (children[i].childrenState.size() > 0) {
auto job = m_space->connection()->callApi<Quotient::GetSpaceHierarchyJob>(children[i].roomId, Quotient::none, Quotient::none, 1);
auto job = m_space->connection()->callApi<Quotient::GetSpaceHierarchyJob>(children[i].roomId, std::nullopt, std::nullopt, 1);
m_currentJobs.append(job);
connect(job, &Quotient::BaseJob::success, this, [this, parent, insertRow, job]() {
insertChildren(job->rooms(), index(insertRow, 0, parent));

View File

@@ -63,7 +63,7 @@ QString Registration::recaptchaSiteKey() const
void Registration::registerAccount()
{
setStatus(Working);
Omittable<QJsonObject> authData = none;
Omittable<QJsonObject> authData;
if (nextStep() == "m.login.recaptcha"_ls) {
authData = QJsonObject{
{"type"_ls, "m.login.recaptcha"_ls},
@@ -186,6 +186,7 @@ void Registration::testHomeserver()
delete m_testServerJob;
}
m_testServerJob = m_connection->callApi<NeoChatRegisterJob>("user"_ls, none, "user"_ls, QString(), QString(), QString(), false);
connect(m_testServerJob.data(), &BaseJob::finished, this, [this]() {
if (m_testServerJob->error() == BaseJob::StatusCode::ContentAccessError) {
setStatus(ServerNoRegistration);

View File

@@ -12,6 +12,7 @@
#include <QVariantMap>
#include <Quotient/csapi/registration.h>
#include <Quotient/omittable.h>
#include <Quotient/jobs/basejob.h>
#include <Quotient/util.h>
@@ -27,12 +28,12 @@ class NeoChatRegisterJob : public Quotient::BaseJob
{
public:
explicit NeoChatRegisterJob(const QString &kind = QStringLiteral("user"),
const Quotient::Omittable<QJsonObject> &auth = Quotient::none,
const Quotient::Omittable<QJsonObject> &auth = {},
const QString &username = {},
const QString &password = {},
const QString &deviceId = {},
const QString &initialDeviceDisplayName = {},
Quotient::Omittable<bool> inhibitLogin = Quotient::none);
Quotient::Omittable<bool> inhibitLogin = {});
QString userId() const
{

View File

@@ -62,7 +62,7 @@ void SpaceHierarchyCache::populateSpaceHierarchy(const QString &spaceId)
}
m_nextBatchTokens[spaceId] = QString();
auto job = m_connection->callApi<GetSpaceHierarchyJob>(spaceId, none, none, none, *m_nextBatchTokens[spaceId]);
auto job = m_connection->callApi<GetSpaceHierarchyJob>(spaceId, std::nullopt, std::nullopt, std::nullopt, *m_nextBatchTokens[spaceId]);
auto group = KConfigGroup(KSharedConfig::openStateConfig("SpaceHierarchy"_ls), "Cache"_ls);
m_spaceHierarchy.insert(spaceId, group.readEntry(spaceId, QStringList()));
@@ -91,7 +91,7 @@ void SpaceHierarchyCache::addBatch(const QString &spaceId, Quotient::GetSpaceHie
const auto nextBatchToken = job->nextBatch();
if (!nextBatchToken.isEmpty() && nextBatchToken != *m_nextBatchTokens[spaceId]) {
*m_nextBatchTokens[spaceId] = nextBatchToken;
auto nextJob = m_connection->callApi<GetSpaceHierarchyJob>(spaceId, none, none, none, *m_nextBatchTokens[spaceId]);
auto nextJob = m_connection->callApi<GetSpaceHierarchyJob>(spaceId, std::nullopt, std::nullopt, std::nullopt, *m_nextBatchTokens[spaceId]);
connect(nextJob, &BaseJob::success, this, [this, nextJob, spaceId]() {
addBatch(spaceId, nextJob);
});