diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index ae38f43..b9e84e9 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -1,280 +1,278 @@ # SPDX-FileCopyrightText: 2023 g10 code GmbH # SPDX-Contributor: Carl Schwan # SPDX-License-Identifier: BSD-2-Clause add_library(gpgol-client-static STATIC) target_sources(gpgol-client-static PRIVATE websocketclient.cpp websocketclient.h webserver.h webserver.cpp # Identity identity/addressvalidationjob.cpp identity/addressvalidationjob.h identity/identitymanager.cpp identity/identitymanager.h identity/identitydialog.cpp identity/identitydialog.h identity/identity.cpp identity/identity.h identity/signature.h identity/signature.cpp identity/signatureconfigurator.cpp identity/signatureconfigurator.h identity/signaturerichtexteditor.cpp identity/signaturerichtexteditor_p.h # HTTP Controller controllers/emailcontroller.cpp controllers/emailcontroller.h - controllers/registrationcontroller.cpp - controllers/registrationcontroller.h # Draft draft/draft.cpp draft/draft.h draft/draftmanager.cpp draft/draftmanager.h # EWS integration ews/ewsattachment.cpp ews/ewsattachment.h ews/ewsattendee.cpp ews/ewsattendee.h ews/ewsclient_debug.cpp ews/ewsclient_debug.h ews/ewsid.cpp ews/ewsid.h ews/ewsitem.cpp ews/ewsitem.h ews/ewsitembase.cpp ews/ewsitembase.h ews/ewsitembase_p.h ews/ewsmailbox.cpp ews/ewsmailbox.h ews/ewsmailfactory.cpp ews/ewsmailfactory.h ews/ewsoccurrence.cpp ews/ewsoccurrence.h ews/ewspropertyfield.cpp ews/ewspropertyfield.h ews/ewsrecurrence.cpp ews/ewsrecurrence.h ews/ewsserverversion.cpp ews/ewsserverversion.h ews/ewstypes.cpp ews/ewstypes.h ews/ewsxml.cpp ews/ewsxml.h # Editor editor/addresseelineedit.cpp editor/addresseelineedit.h editor/addresseelineeditmanager.cpp editor/addresseelineeditmanager.h editor/composer.cpp editor/composer.h editor/composerviewbase.cpp editor/composerviewbase.h editor/composerwindow.cpp editor/composerwindow.h editor/composerwindowfactory.cpp editor/composerwindowfactory.h editor/cryptostateindicatorwidget.cpp editor/cryptostateindicatorwidget.h editor/kmcomposerglobalaction.cpp editor/kmcomposerglobalaction.h editor/nearexpirywarning.cpp editor/nearexpirywarning.h editor/mailtemplates.cpp editor/mailtemplates.h editor/recipient.cpp editor/recipient.h editor/recipientline.cpp editor/recipientline.h editor/recipientseditor.cpp editor/recipientseditor.h editor/util.h editor/util.cpp editor/kmailcompletion.cpp editor/kmailcompletion.h editor/richtextcomposerng.cpp editor/richtextcomposerng.h editor/richtextcomposersignatures.cpp editor/richtextcomposersignatures.h editor/nodehelper.cpp editor/nodehelper.h editor/signaturecontroller.cpp editor/signaturecontroller.h editor/spellcheckerconfigdialog.cpp editor/spellcheckerconfigdialog.h # Editor job editor/job/abstractencryptjob.h editor/job/autocryptheadersjob.h editor/job/contentjobbase.h editor/job/contentjobbase_p.h editor/job/encryptjob.h editor/job/inserttextfilejob.h editor/job/itipjob.h editor/job/jobbase.h editor/job/jobbase_p.h editor/job/maintextjob.h editor/job/multipartjob.h editor/job/protectedheadersjob.h editor/job/signencryptjob.h editor/job/signjob.h editor/job/singlepartjob.h editor/job/skeletonmessagejob.h editor/job/transparentjob.h editor/job/autocryptheadersjob.cpp editor/job/contentjobbase.cpp editor/job/encryptjob.cpp editor/job/inserttextfilejob.cpp editor/job/itipjob.cpp editor/job/jobbase.cpp editor/job/maintextjob.cpp editor/job/multipartjob.cpp editor/job/protectedheadersjob.cpp editor/job/saveasfilejob.cpp editor/job/saveasfilejob.h editor/job/signencryptjob.cpp editor/job/signjob.cpp editor/job/singlepartjob.cpp editor/job/skeletonmessagejob.cpp editor/job/transparentjob.cpp ## Editor Part editor/part/globalpart.h editor/part/infopart.h editor/part/itippart.h editor/part/messagepart.h editor/part/textpart.h editor/part/globalpart.cpp editor/part/infopart.cpp editor/part/itippart.cpp editor/part/messagepart.cpp editor/part/textpart.cpp ## Attachment editor/attachment/attachmentjob.cpp editor/attachment/attachmentjob.h editor/attachment/attachmentclipboardjob.cpp editor/attachment/attachmentclipboardjob.h editor/attachment/attachmentcompressjob.cpp editor/attachment/attachmentcompressjob.h editor/attachment/attachmentcontroller.cpp editor/attachment/attachmentcontroller.h editor/attachment/attachmentcontrollerbase.cpp editor/attachment/attachmentcontrollerbase.h editor/attachment/attachmentfromfolderjob.cpp editor/attachment/attachmentfromfolderjob.h editor/attachment/attachmentfrommimecontentjob.cpp editor/attachment/attachmentfrommimecontentjob.h editor/attachment/attachmentfromurlbasejob.cpp editor/attachment/attachmentfromurlbasejob.h editor/attachment/attachmentfromurljob.cpp editor/attachment/attachmentfromurljob.h editor/attachment/attachmentfromurlutils.cpp editor/attachment/attachmentfromurlutils.h editor/attachment/attachmentfrompublickeyjob.cpp editor/attachment/attachmentfrompublickeyjob.h editor/attachment/attachmentloadjob.cpp editor/attachment/attachmentloadjob.h editor/attachment/attachmentmodel.cpp editor/attachment/attachmentmodel.h editor/attachment/attachmentpart.cpp editor/attachment/attachmentpart.h editor/attachment/attachmentpropertiesdialog.cpp editor/attachment/attachmentpropertiesdialog.h editor/attachment/attachmentupdatejob.cpp editor/attachment/attachmentupdatejob.h editor/attachment/attachmentview.cpp editor/attachment/attachmentview.h ) ki18n_wrap_ui(gpgol-client-static editor/attachment/ui/attachmentpropertiesdialog.ui editor/attachment/ui/attachmentpropertiesdialog_readonly.ui ) ecm_qt_declare_logging_category(gpgol-client-static_SRCS HEADER websocket_debug.h IDENTIFIER WEBSOCKET_LOG CATEGORY_NAME org.gpgol.client.websocket DESCRIPTION "Websocket connection in the client" EXPORT GPGOL ) ecm_qt_declare_logging_category(gpgol-client-static_SRCS HEADER ewsresource_debug.h IDENTIFIER EWSRES_LOG CATEGORY_NAME org.gpgol.ews DESCRIPTION "Ews mail client" EXPORT GPGOL ) ecm_qt_declare_logging_category(gpgol-client-static_SRCS HEADER ewscli_debug.h IDENTIFIER EWSCLI_LOG CATEGORY_NAME org.gpgol.ews.client DESCRIPTION "ews client (gpgol-client)" EXPORT GPGOL ) ecm_qt_declare_logging_category(gpgol-client-static_SRCS HEADER editor_debug.h IDENTIFIER EDITOR_LOG CATEGORY_NAME org.gpgol.editor DESCRIPTION "mail composer" EXPORT GPGOL ) set(WARN_TOOMANY_RECIPIENTS_DEFAULT true) set(ALLOW_SEMICOLON_AS_ADDRESS_SEPARATOR_DEFAULT true) configure_file(editor/settings/messagecomposer.kcfg.in ${CMAKE_CURRENT_BINARY_DIR}/messagecomposer.kcfg) kconfig_add_kcfg_files(gpgol-client-static editor/settings/messagecomposersettings.kcfgc) install(FILES composerui.rc DESTINATION ${KDE_INSTALL_KXMLGUIDIR}/gpgol-client) target_sources(gpgol-client-static PUBLIC ${gpgol-client-static_SRCS}) target_link_libraries(gpgol-client-static PUBLIC common Qt6::HttpServer Qt6::Widgets Qt6::PrintSupport KF6::JobWidgets KF6::CalendarCore KF6::ConfigCore KF6::ConfigGui KF6::Contacts KF6::Completion KF6::CoreAddons KF6::ColorScheme KF6::Codecs KF6::GuiAddons KF6::SonnetUi KF6::WidgetsAddons KF6::XmlGui KF6::Archive KF6::TextAutoCorrectionCore KPim6::MimeTreeParserWidgets KPim6::Libkleo KPim6::Libkdepim KPim6::PimTextEdit ) add_executable(gpgol-client main.cpp) target_link_libraries(gpgol-client PRIVATE gpgol-client-static) if (BUILD_TESTING) add_subdirectory(autotests) endif() diff --git a/client/autotests/emailcontrollertest.cpp b/client/autotests/emailcontrollertest.cpp index 62956e5..6503d39 100644 --- a/client/autotests/emailcontrollertest.cpp +++ b/client/autotests/emailcontrollertest.cpp @@ -1,155 +1,154 @@ // SPDX-FileCopyrightText: 2023 g10 code GmbH // SPDX-Contributor: Carl Schwan // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include #include #include #include #include #include #include #include #include #include #include "../webserver.h" #include "../websocketclient.h" #include "../draft/draftmanager.h" #include "../editor/composerwindow.h" #include "../editor/recipientseditor.h" #include #include #include using namespace Qt::Literals::StringLiterals; class EmailControllerTest : public QObject { Q_OBJECT private Q_SLOTS: void initTestCase() { DraftManager::self(true); QCoreApplication::setApplicationName(u"gpgol-server"_s); KLocalizedString::setApplicationDomain(QByteArrayLiteral("gpgol")); - m_webServer = new WebServer(u"TestId"_s); + m_webServer = new WebServer; m_webServer->run(); auto webSocketServer = new QWebSocketServer(QStringLiteral("SSL Server"), QWebSocketServer::NonSecureMode); - if (webSocketServer->listen(QHostAddress::Any, 5657)) { } } void testInfoEmailAction() { QFile file(QStringLiteral(DATA_DIR) + u"/encrypted.mbox"_s); QVERIFY(file.open(QIODeviceBase::ReadOnly)); QNetworkRequest request(QUrl(u"http://127.0.0.1:%1/info"_s.arg(m_webServer->port()))); auto reply = m_qnam.post(request, file.readAll()); QSignalSpy spy(reply, &QNetworkReply::finished); spy.wait(); QVERIFY(reply->error() == QNetworkReply::NoError); const auto doc = QJsonDocument::fromJson(reply->readAll()); QVERIFY(!doc.isNull() && doc.isObject()); const auto object = doc.object(); QVERIFY(object["drafts"_L1].toArray().isEmpty()); QVERIFY(object["encrypted"_L1].toBool()); QVERIFY(!object["signed"_L1].toBool()); } void testViewEmailAction() { QFile file(QStringLiteral(DATA_DIR) + u"/plaintext.mbox"_s); QVERIFY(file.open(QIODeviceBase::ReadOnly)); QNetworkRequest request(QUrl(u"http://127.0.0.1:%1/view"_s.arg(m_webServer->port()))); auto reply = m_qnam.post(request, file.readAll()); QSignalSpy spy(reply, &QNetworkReply::finished); spy.wait(); QVERIFY(reply->error() == QNetworkReply::NoError); const auto widgets = qApp->topLevelWidgets(); QVERIFY(!widgets.isEmpty()); MimeTreeParser::Widgets::MessageViewerDialog *dialog = nullptr; for (auto widget : widgets) { if (!widget->isHidden()) { if (const auto messageViewer = qobject_cast(widget)) { dialog = messageViewer; break; } } } QVERIFY(dialog); WebsocketClient::self(QUrl(u"ws://127.0.0.1"_s), 5656); const auto toolBar = dialog->toolBar(); QVERIFY(toolBar->isVisible()); const auto actions = toolBar->actions(); QCOMPARE(actions.count(), 3); qWarning() << actions; QCOMPARE(actions[1]->icon().name(), u"mail-reply-sender-symbolic"_s); actions[1]->trigger(); const auto widgets2 = qApp->topLevelWidgets(); QVERIFY(!widgets2.isEmpty()); ComposerWindow *composer = nullptr; for (auto widget : widgets2) { if (!widget->isHidden()) { if (const auto composerWindow = qobject_cast(widget)) { composer = composerWindow; break; } } } QVERIFY(composer); QSignalSpy spyInit(composer, &ComposerWindow::initialized); spyInit.wait(); QCOMPARE(composer->subject(), u"RE: A random subject with alternative contenttype"_s); const auto recipients = composer->recipientsEditor()->recipients(); QCOMPARE(recipients.count(), 2); QCOMPARE(recipients[0]->email(), u"konqi@example.org"_s); QCOMPARE(recipients[0]->name(), u"Konqi"_s); QCOMPARE(recipients[1]->email(), u"konqi@kde.org"_s); QVERIFY(recipients[1]->name().isEmpty()); } void cleanupTestCase() { m_webServer->deleteLater(); } private: QThread *m_thread = nullptr; WebServer *m_webServer = nullptr; QWebSocketServer *m_webSocketServer = nullptr; QNetworkAccessManager m_qnam; }; QTEST_MAIN(EmailControllerTest) #include "emailcontrollertest.moc" diff --git a/client/controllers/registrationcontroller.cpp b/client/controllers/registrationcontroller.cpp deleted file mode 100644 index e8a824f..0000000 --- a/client/controllers/registrationcontroller.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// SPDX-FileCopyrightText: 2023 g10 code GmbH -// SPDX-Contributor: Carl Schwan -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "registrationcontroller.h" - -#include -#include - -using namespace Qt::Literals::StringLiterals; - -QHttpServerResponse RegistrationController::confirmRegistrationAction(const QHttpServerRequest &request, const QString &clientId) -{ - const auto json = QJsonDocument::fromJson(request.body()); - if (json.isNull() || !json.isObject()) { - return QHttpServerResponse(QJsonObject { - { "status"_L1, "500"_L1 }, - { "error"_L1, "Invalid json"_L1 }, - }); - } - - const auto obj = json.object(); - const auto token = obj["token"_L1].toString(); - - if (token.isEmpty()) { - return QHttpServerResponse(QJsonObject { - { "status"_L1, "500"_L1 }, - { "error"_L1, "Empty token"_L1 }, - }); - } - - const auto hash = QCryptographicHash::hash((token + clientId).toUtf8(), QCryptographicHash::Sha256).toHex(); - - return QHttpServerResponse(QJsonObject { - { "hash"_L1, QString::fromUtf8(hash) } - }); -} diff --git a/client/controllers/registrationcontroller.h b/client/controllers/registrationcontroller.h deleted file mode 100644 index 873a92d..0000000 --- a/client/controllers/registrationcontroller.h +++ /dev/null @@ -1,13 +0,0 @@ -// SPDX-FileCopyrightText: 2023 g10 code GmbH -// SPDX-Contributor: Carl Schwan -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include -#include - -namespace RegistrationController -{ - QHttpServerResponse confirmRegistrationAction(const QHttpServerRequest &request, const QString &clientId); -} diff --git a/client/main.cpp b/client/main.cpp index 66cde30..c7e65fe 100644 --- a/client/main.cpp +++ b/client/main.cpp @@ -1,52 +1,52 @@ // SPDX-FileCopyrightText: 2023 g10 code Gmbh // SPDX-Contributor: Carl Schwan // SPDX-License-Identifier: GPL-2.0-or-later #include "controllers/emailcontroller.h" #include #include #include #include #include #include #include #include #include #include #include #include "websocketclient.h" #include "webserver.h" #include "qnam.h" using namespace Qt::Literals::StringLiterals; using namespace std::chrono; int main(int argc, char *argv[]) { QApplication app(argc, argv); app.setQuitOnLastWindowClosed(false); KLocalizedString::setApplicationDomain(QByteArrayLiteral("gpgol")); QObject::connect(qnam, &QNetworkAccessManager::sslErrors, qnam, [](QNetworkReply *reply, const QList &) { reply->ignoreSslErrors(); }); const auto clientId = QUuid::createUuid().toString(QUuid::WithoutBraces); - WebServer server(clientId); + WebServer server; server.run(); if (!server.running()) { qWarning() << "Server failed to listen on a port."; return 1; } const auto port = server.port(); WebsocketClient::self(QUrl(u"wss://localhost:5657/"_s), port, clientId); auto keyCache = Kleo::KeyCache::mutableInstance(); keyCache->startKeyListing(); return app.exec(); } diff --git a/client/webserver.cpp b/client/webserver.cpp index cdc1ac0..29206eb 100644 --- a/client/webserver.cpp +++ b/client/webserver.cpp @@ -1,53 +1,48 @@ // SPDX-FileCopyrightText: 2024 g10 code Gmbh // SPDX-Contributor: Carl Schwan // SPDX-License-Identifier: GPL-2.0-or-later #include "webserver.h" #include "controllers/emailcontroller.h" -#include "controllers/registrationcontroller.h" #include #include using namespace Qt::Literals::StringLiterals; -WebServer::WebServer(const QString &clientId, QObject *parent) +WebServer::WebServer(QObject *parent) : QObject(parent) - , m_clientId(clientId) { m_server.route(u"/view"_s, &EmailController::viewEmailAction); m_server.route(u"/info"_s, &EmailController::infoEmailAction); m_server.route(u"/new"_s, &EmailController::newEmailAction); m_server.route(u"/forward"_s, &EmailController::forwardEmailAction); m_server.route(u"/reply"_s, &EmailController::replyEmailAction); m_server.route(u"/draft/"_s, &EmailController::draftAction); - m_server.route(u"/confirm-registration"_s, [this](const QHttpServerRequest &request) { - return RegistrationController::confirmRegistrationAction(request, m_clientId); - }); m_server.afterRequest([](QHttpServerResponse &&resp) { resp.setHeader("Access-Control-Allow-Origin", "*"); return std::move(resp); }); } void WebServer::run() { m_port = m_server.listen(); if (!m_port) { qWarning() << "Server failed to listen on a port."; m_running = false; return; } qWarning() << u"Running on http://127.0.0.1:%1/ (Press CTRL+C to quit)"_s.arg(m_port); m_running = true; } int WebServer::port() const { return m_port; } bool WebServer::running() const { return m_running; } diff --git a/client/webserver.h b/client/webserver.h index 61e2572..44aeab8 100644 --- a/client/webserver.h +++ b/client/webserver.h @@ -1,34 +1,33 @@ // SPDX-FileCopyrightText: 2024 g10 code Gmbh // SPDX-Contributor: Carl Schwan // SPDX-License-Identifier: GPL-2.0-or-later #include #include /// The webserver of the native client /// /// This webserver will receive webrequests from the outlook web client via /// the broker. class WebServer : public QObject { Q_OBJECT public: /// Default contructor. - WebServer(const QString &clientId, QObject *parent = nullptr); + WebServer(QObject *parent = nullptr); /// Start webserver. void run(); /// \return the port of the webserver. Qt will randomly assign a free port to this /// process. int port() const; /// \return whether the webserver is running. bool running() const; private: int m_port; bool m_running = false; QHttpServer m_server; - QString m_clientId; }; diff --git a/server/controllers/abstractcontroller.cpp b/server/controllers/abstractcontroller.cpp index c8ea38f..8a901a9 100644 --- a/server/controllers/abstractcontroller.cpp +++ b/server/controllers/abstractcontroller.cpp @@ -1,53 +1,46 @@ // SPDX-FileCopyrightText: 2023 g10 code GmbH // SPDX-Contributor: Carl Schwan // SPDX-License-Identifier: GPL-2.0-or-later #include "abstractcontroller.h" #include "../model/serverstate.h" #include #include #include using namespace Qt::Literals::StringLiterals; QHttpServerResponse AbstractController::badRequest(const QString &reason) { if (reason.isEmpty()) { return QHttpServerResponse(QJsonObject { { "errorMessage"_L1, "Invalid request"_L1 } }, QHttpServerResponse::StatusCode::BadRequest); } else { return QHttpServerResponse(QJsonObject { { "errorMessage"_L1, QJsonValue("Invalid request: "_L1 + reason) } }, QHttpServerResponse::StatusCode::BadRequest); } } QHttpServerResponse AbstractController::forbidden() { return QHttpServerResponse(QJsonObject { { "errorMessage"_L1, "Unable to authentificate"_L1 } }, QHttpServerResponse::StatusCode::Forbidden); } std::optional AbstractController::checkAuthentification(const QHttpServerRequest &request) { const auto &state = ServerState::instance(); const auto email = QString::fromUtf8(Utils::findHeader(request.headers(), "X-EMAIL")); if (email.isEmpty() || !state.clients.contains(email)) { qWarning() << "no email found" << email; return std::nullopt; } - auto client = state.clients[email]; - - if (!client.trusted) { - qWarning() << "Client is not trusted" << email; - return std::nullopt; - } - return state.clients[email]; } diff --git a/server/controllers/registrationcontroller.cpp b/server/controllers/registrationcontroller.cpp index 77f13f6..4db20ed 100644 --- a/server/controllers/registrationcontroller.cpp +++ b/server/controllers/registrationcontroller.cpp @@ -1,73 +1,44 @@ // SPDX-FileCopyrightText: 2023 g10 code GmbH // SPDX-Contributor: Carl Schwan // SPDX-License-Identifier: GPL-2.0-or-later #include "registrationcontroller.h" #include #include #include #include #include #include #include "../model/serverstate.h" using namespace Qt::Literals::StringLiterals; QHttpServerResponse RegistrationController::registerAction(const QHttpServerRequest &request) { const auto json = QJsonDocument::fromJson(request.body()); if (json.isEmpty() || !json.isObject()) { return badRequest(); } const auto object = json.object(); if (object.isEmpty() || !object.contains("port"_L1) || !object.contains("emails"_L1)) { return badRequest(); } const auto emails = object["emails"_L1].toArray(); const Client::Id clientId = object["clientId"_L1].toString(); const auto port = object["port"_L1].toInt(); for (const auto email : emails) { ServerState::instance().clients[email.toString().toLower()] = Client { clientId, port, - false, }; - qDebug() << "Registration of email" << email.toString() << "on port" << object["port"_L1].toInt() << "with clientId" << clientId; + qInfo() << "Registration of email" << email.toString() << "on port" << object["port"_L1].toInt() << "with clientId" << clientId; } - const QString token = QUuid::createUuid().toString(QUuid::WithoutBraces); - QNetworkRequest confirmationRequest(QUrl(u"http://127.0.0.1:"_s + QString::number(port) + u"/confirm-registration")); - - auto reply = ServerState::instance().qnam.post(confirmationRequest, QJsonDocument(QJsonObject{ - { "token"_L1, token }, - }).toJson()); - - qWarning() << QJsonDocument(QJsonObject{ - { "token"_L1, token }, - }); - - QObject::connect(reply, &QNetworkReply::finished, reply, [token, reply, clientId]() { - const auto hash = QCryptographicHash::hash((token + clientId).toUtf8(), QCryptographicHash::Sha256).toHex(); - - const auto json = QJsonDocument::fromJson(reply->readAll()); - if (json.isNull() || !json.isObject()) { - qWarning() << "Invalid json"; - return; - } - - const auto obj = json.object(); - if (hash == obj["hash"_L1].toString().toUtf8()) { - ServerState::instance().trustClientWithId(clientId); - } else { - qWarning() << "Not trusting" << clientId << hash << obj["hash"_L1].toString().toUtf8(); - } - }); - return QHttpServerResponse("text/plain", "Server added\n"); } diff --git a/server/model/serverstate.cpp b/server/model/serverstate.cpp index b491fb9..f3601fa 100644 --- a/server/model/serverstate.cpp +++ b/server/model/serverstate.cpp @@ -1,29 +1,14 @@ // SPDX-FileCopyrightText: 2023 g10 code Gmbh // SPDX-Contributor: Carl Schwan // SPDX-License-Identifier: GPL-2.0-or-later #include "serverstate.h" ServerState::ServerState() {} ServerState &ServerState::instance() { static ServerState s; return s; } - -void ServerState::trustClientWithId(const Client::Id &id) -{ - // iterate over const copy as we mutate the list while iterating it - const auto c = clients; - for (const auto &[email, client] : c.asKeyValueRange()) { - if (client.id == id) { - auto newClient = client; - newClient.trusted = true; - clients[email] = newClient; - } - } - - qWarning() << "trusting client with id" << id; -} diff --git a/server/model/serverstate.h b/server/model/serverstate.h index f23f8be..8701691 100644 --- a/server/model/serverstate.h +++ b/server/model/serverstate.h @@ -1,38 +1,35 @@ // SPDX-FileCopyrightText: 2023 g10 code Gmbh // SPDX-Contributor: Carl Schwan // SPDX-License-Identifier: GPL-2.0-or-later #pragma once #include #include #include using Token = QByteArray; using ClientId = QString; using Email = QString; using Port = int; struct Client { using Id = QString; Id id; Port port; - bool trusted; }; class ServerState { public: static ServerState &instance(); QHash clients; - void trustClientWithId(const Client::Id &id); - QNetworkAccessManager qnam; QHash composerRequest; private: ServerState(); };