From ee2e782748985ab7f4c3fc469d3f426efd4654be Mon Sep 17 00:00:00 2001 From: Alexander Lohnau Date: Fri, 4 Aug 2023 16:46:12 +0200 Subject: [PATCH] CompositeUploadJob: Use lambda connect, log errors --- core/backends/lan/compositeuploadjob.cpp | 64 ++++++++++-------------- core/backends/lan/compositeuploadjob.h | 4 -- 2 files changed, 27 insertions(+), 41 deletions(-) diff --git a/core/backends/lan/compositeuploadjob.cpp b/core/backends/lan/compositeuploadjob.cpp index 62044b20e..1c66a32a3 100644 --- a/core/backends/lan/compositeuploadjob.cpp +++ b/core/backends/lan/compositeuploadjob.cpp @@ -131,49 +131,39 @@ void CompositeUploadJob::newConnection() m_currentJob->setSocket(m_socket); - connect(m_socket, &QSslSocket::disconnected, this, &CompositeUploadJob::socketDisconnected); - connect(m_socket, &QAbstractSocket::errorOccurred, this, &CompositeUploadJob::socketError); - connect(m_socket, &QSslSocket::sslErrors, this, &CompositeUploadJob::sslError); - connect(m_socket, &QSslSocket::encrypted, this, &CompositeUploadJob::encrypted); + connect(m_socket, &QSslSocket::disconnected, this, [this]() { + m_socket->close(); + }); + connect(m_socket, &QAbstractSocket::errorOccurred, this, [this](QAbstractSocket::SocketError error) { + qCDebug(KDECONNECT_CORE) << "Error in socket occurred" << error; + // Do not close the socket because when android closes the socket (share is cancelled) closing the socket leads to a cyclic socketError and eventually a + // segv + setError(SocketError); + emitResult(); + + m_running = false; + }); + connect(m_socket, &QSslSocket::sslErrors, this, [this](const QList &errors) { + qCDebug(KDECONNECT_CORE) << "Received ssl errors" << errors; + m_socket->close(); + setError(SslError); + emitResult(); + + m_running = false; + }); + connect(m_socket, &QSslSocket::encrypted, this, [this]() { + if (!m_timer.isValid()) { + m_timer.start(); + } + + m_currentJob->start(); + }); LanLinkProvider::configureSslSocket(m_socket, m_deviceId, true); m_socket->startServerEncryption(); } -void CompositeUploadJob::socketDisconnected() -{ - m_socket->close(); -} - -void CompositeUploadJob::socketError() -{ - // Do not close the socket because when android closes the socket (share is cancelled) closing the socket leads to a cyclic socketError and eventually a - // segv - setError(SocketError); - emitResult(); - - m_running = false; -} - -void CompositeUploadJob::sslError() -{ - m_socket->close(); - setError(SslError); - emitResult(); - - m_running = false; -} - -void CompositeUploadJob::encrypted() -{ - if (!m_timer.isValid()) { - m_timer.start(); - } - - m_currentJob->start(); -} - bool CompositeUploadJob::addSubjob(KJob *job) { if (UploadJob *uploadJob = qobject_cast(job)) { diff --git a/core/backends/lan/compositeuploadjob.h b/core/backends/lan/compositeuploadjob.h index 0e066a4c6..bdf9473ee 100644 --- a/core/backends/lan/compositeuploadjob.h +++ b/core/backends/lan/compositeuploadjob.h @@ -54,10 +54,6 @@ private: private Q_SLOTS: void newConnection(); - void socketDisconnected(); - void socketError(); - void sslError(); - void encrypted(); void slotProcessedAmount(KJob *job, KJob::Unit unit, qulonglong amount); void slotResult(KJob *job) override; void startNextSubJob();