CompositeUploadJob: Use lambda connect, log errors
This commit is contained in:
parent
405f61bf85
commit
ee2e782748
2 changed files with 27 additions and 41 deletions
|
@ -131,49 +131,39 @@ void CompositeUploadJob::newConnection()
|
||||||
|
|
||||||
m_currentJob->setSocket(m_socket);
|
m_currentJob->setSocket(m_socket);
|
||||||
|
|
||||||
connect(m_socket, &QSslSocket::disconnected, this, &CompositeUploadJob::socketDisconnected);
|
connect(m_socket, &QSslSocket::disconnected, this, [this]() {
|
||||||
connect(m_socket, &QAbstractSocket::errorOccurred, this, &CompositeUploadJob::socketError);
|
m_socket->close();
|
||||||
connect(m_socket, &QSslSocket::sslErrors, this, &CompositeUploadJob::sslError);
|
});
|
||||||
connect(m_socket, &QSslSocket::encrypted, this, &CompositeUploadJob::encrypted);
|
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);
|
LanLinkProvider::configureSslSocket(m_socket, m_deviceId, true);
|
||||||
|
|
||||||
m_socket->startServerEncryption();
|
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)
|
bool CompositeUploadJob::addSubjob(KJob *job)
|
||||||
{
|
{
|
||||||
if (UploadJob *uploadJob = qobject_cast<UploadJob *>(job)) {
|
if (UploadJob *uploadJob = qobject_cast<UploadJob *>(job)) {
|
||||||
|
|
|
@ -54,10 +54,6 @@ private:
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void newConnection();
|
void newConnection();
|
||||||
void socketDisconnected();
|
|
||||||
void socketError();
|
|
||||||
void sslError();
|
|
||||||
void encrypted();
|
|
||||||
void slotProcessedAmount(KJob *job, KJob::Unit unit, qulonglong amount);
|
void slotProcessedAmount(KJob *job, KJob::Unit unit, qulonglong amount);
|
||||||
void slotResult(KJob *job) override;
|
void slotResult(KJob *job) override;
|
||||||
void startNextSubJob();
|
void startNextSubJob();
|
||||||
|
|
Loading…
Reference in a new issue