diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 73693849c..d207725df 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -126,6 +126,12 @@ add_library(neochat STATIC registration.cpp neochatconnection.cpp neochatconnection.h + jobs/neochatdeactivateaccountjob.cpp + jobs/neochatdeactivateaccountjob.h + jobs/neochatdeletedevicejob.cpp + jobs/neochatdeletedevicejob.h + jobs/neochatchangepasswordjob.cpp + jobs/neochatchangepasswordjob.h ) ecm_qt_declare_logging_category(neochat diff --git a/src/controller.cpp b/src/controller.cpp index 2af1a92f8..e3c037dd1 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -297,24 +297,6 @@ bool Controller::supportSystemTray() const #endif } -NeochatChangePasswordJob::NeochatChangePasswordJob(const QString &newPassword, bool logoutDevices, const Omittable &auth) - : BaseJob(HttpVerb::Post, QStringLiteral("ChangePasswordJob"), "/_matrix/client/r0/account/password") -{ - QJsonObject _data; - addParam<>(_data, QStringLiteral("new_password"), newPassword); - addParam(_data, QStringLiteral("logout_devices"), logoutDevices); - addParam(_data, QStringLiteral("auth"), auth); - setRequestData(_data); -} - -NeoChatDeactivateAccountJob::NeoChatDeactivateAccountJob(const Quotient::Omittable &auth) - : BaseJob(HttpVerb::Post, QStringLiteral("DisableDeviceJob"), "_matrix/client/v3/account/deactivate") -{ - QJsonObject data; - addParam(data, QStringLiteral("auth"), auth); - setRequestData(data); -} - int Controller::accountCount() const { return m_accountRegistry.count(); @@ -397,14 +379,6 @@ void Controller::saveWindowGeometry() WindowController::instance().saveGeometry(); } -NeochatDeleteDeviceJob::NeochatDeleteDeviceJob(const QString &deviceId, const Omittable &auth) - : Quotient::BaseJob(HttpVerb::Delete, QStringLiteral("DeleteDeviceJob"), QStringLiteral("/_matrix/client/r0/devices/%1").arg(deviceId).toLatin1()) -{ - QJsonObject _data; - addParam(_data, QStringLiteral("auth"), auth); - setRequestData(std::move(_data)); -} - void Controller::createRoom(const QString &name, const QString &topic) { auto createRoomJob = m_connection->createRoom(Connection::PublishRoom, QString(), name, topic, QStringList()); diff --git a/src/controller.h b/src/controller.h index 72bb232c1..e3a08a440 100644 --- a/src/controller.h +++ b/src/controller.h @@ -236,22 +236,3 @@ Q_SIGNALS: public Q_SLOTS: void saveWindowGeometry(); }; - -// TODO libQuotient 0.7: Drop -class NeochatChangePasswordJob : public Quotient::BaseJob -{ -public: - explicit NeochatChangePasswordJob(const QString &newPassword, bool logoutDevices, const Quotient::Omittable &auth = Quotient::none); -}; - -class NeochatDeleteDeviceJob : public Quotient::BaseJob -{ -public: - explicit NeochatDeleteDeviceJob(const QString &deviceId, const Quotient::Omittable &auth = Quotient::none); -}; - -class NeoChatDeactivateAccountJob : public Quotient::BaseJob -{ -public: - explicit NeoChatDeactivateAccountJob(const Quotient::Omittable &auth = Quotient::none); -}; diff --git a/src/jobs/neochatchangepasswordjob.cpp b/src/jobs/neochatchangepasswordjob.cpp new file mode 100644 index 000000000..dec09ef8f --- /dev/null +++ b/src/jobs/neochatchangepasswordjob.cpp @@ -0,0 +1,16 @@ +// SPDX-FileCopyrightText: 2023 Tobias Fella +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "neochatchangepasswordjob.h" + +using namespace Quotient; + +NeochatChangePasswordJob::NeochatChangePasswordJob(const QString &newPassword, bool logoutDevices, const Omittable &auth) + : BaseJob(HttpVerb::Post, QStringLiteral("ChangePasswordJob"), "/_matrix/client/r0/account/password") +{ + QJsonObject _data; + addParam<>(_data, QStringLiteral("new_password"), newPassword); + addParam(_data, QStringLiteral("logout_devices"), logoutDevices); + addParam(_data, QStringLiteral("auth"), auth); + setRequestData(_data); +} diff --git a/src/jobs/neochatchangepasswordjob.h b/src/jobs/neochatchangepasswordjob.h new file mode 100644 index 000000000..ac4d76d25 --- /dev/null +++ b/src/jobs/neochatchangepasswordjob.h @@ -0,0 +1,13 @@ +// SPDX-FileCopyrightText: 2023 Tobias Fella +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include +#include + +class NeochatChangePasswordJob : public Quotient::BaseJob +{ +public: + explicit NeochatChangePasswordJob(const QString &newPassword, bool logoutDevices, const Quotient::Omittable &auth = Quotient::none); +}; diff --git a/src/jobs/neochatdeactivateaccountjob.cpp b/src/jobs/neochatdeactivateaccountjob.cpp new file mode 100644 index 000000000..398a7df72 --- /dev/null +++ b/src/jobs/neochatdeactivateaccountjob.cpp @@ -0,0 +1,14 @@ +// SPDX-FileCopyrightText: 2023 Tobias Fella +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "neochatdeactivateaccountjob.h" + +using namespace Quotient; + +NeoChatDeactivateAccountJob::NeoChatDeactivateAccountJob(const Omittable &auth) + : BaseJob(HttpVerb::Post, QStringLiteral("DisableDeviceJob"), "_matrix/client/v3/account/deactivate") +{ + QJsonObject data; + addParam(data, QStringLiteral("auth"), auth); + setRequestData(data); +} diff --git a/src/jobs/neochatdeactivateaccountjob.h b/src/jobs/neochatdeactivateaccountjob.h new file mode 100644 index 000000000..ff2e9f4ec --- /dev/null +++ b/src/jobs/neochatdeactivateaccountjob.h @@ -0,0 +1,13 @@ +// SPDX-FileCopyrightText: 2023 Tobias Fella +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include +#include + +class NeoChatDeactivateAccountJob : public Quotient::BaseJob +{ +public: + explicit NeoChatDeactivateAccountJob(const Quotient::Omittable &auth = Quotient::none); +}; diff --git a/src/jobs/neochatdeletedevicejob.cpp b/src/jobs/neochatdeletedevicejob.cpp new file mode 100644 index 000000000..0283d41f2 --- /dev/null +++ b/src/jobs/neochatdeletedevicejob.cpp @@ -0,0 +1,14 @@ +// SPDX-FileCopyrightText: 2023 Tobias Fella +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "neochatdeletedevicejob.h" + +using namespace Quotient; + +NeochatDeleteDeviceJob::NeochatDeleteDeviceJob(const QString &deviceId, const Omittable &auth) + : BaseJob(HttpVerb::Delete, QStringLiteral("DeleteDeviceJob"), QStringLiteral("/_matrix/client/r0/devices/%1").arg(deviceId).toLatin1()) +{ + QJsonObject _data; + addParam(_data, QStringLiteral("auth"), auth); + setRequestData(std::move(_data)); +} diff --git a/src/jobs/neochatdeletedevicejob.h b/src/jobs/neochatdeletedevicejob.h new file mode 100644 index 000000000..9b9e72e07 --- /dev/null +++ b/src/jobs/neochatdeletedevicejob.h @@ -0,0 +1,13 @@ +// SPDX-FileCopyrightText: 2023 Tobias Fella +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include +#include + +class NeochatDeleteDeviceJob : public Quotient::BaseJob +{ +public: + explicit NeochatDeleteDeviceJob(const QString &deviceId, const Quotient::Omittable &auth = Quotient::none); +}; diff --git a/src/models/devicesmodel.cpp b/src/models/devicesmodel.cpp index 4d63670ad..90514cefb 100644 --- a/src/models/devicesmodel.cpp +++ b/src/models/devicesmodel.cpp @@ -4,6 +4,7 @@ #include "devicesmodel.h" #include "controller.h" +#include "jobs/neochatdeletedevicejob.h" #include #include diff --git a/src/neochatconnection.cpp b/src/neochatconnection.cpp index 340011b6f..c611e7c8b 100644 --- a/src/neochatconnection.cpp +++ b/src/neochatconnection.cpp @@ -6,6 +6,8 @@ #include #include "controller.h" +#include "jobs/neochatchangepasswordjob.h" +#include "jobs/neochatdeactivateaccountjob.h" #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #include