CompositeUploadJob: Use lambda connect, log errors

This commit is contained in:
Alexander Lohnau 2023-08-04 16:46:12 +02:00 committed by Albert Vaca Cintora
parent 405f61bf85
commit ee2e782748
2 changed files with 27 additions and 41 deletions

View file

@ -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<QSslError> &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<UploadJob *>(job)) {

View file

@ -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();