void SmtpClient::newConnection() { qMailLog(SMTP) << "newConnection" << flush; #ifdef USE_ACCOUNTS_QT loginFailed = false; #endif if (sending) { operationFailed(QMailServiceAction::Status::ErrConnectionInUse, tr("Cannot send message; transport in use")); return; } if (!config.id().isValid()) { status = Done; operationFailed(QMailServiceAction::Status::ErrConfiguration, tr("Cannot send message without account configuration")); return; } // Load the current configuration for this account // Reload the account configuration whenever a new SMTP // connection is created, in order to ensure the changes // in the account settings are being managed properly. config = QMailAccountConfiguration(config.id()); SmtpConfiguration smtpCfg(config); if ( smtpCfg.smtpServer().isEmpty() ) { status = Done; operationFailed(QMailServiceAction::Status::ErrConfiguration, tr("Cannot send message without SMTP server configuration")); return; } // Calculate the total indicative size of the messages we're sending totalSendSize = 0; foreach (uint size, sendSize.values()) totalSendSize += size; progressSendSize = 0; emit progressChanged(progressSendSize, totalSendSize); status = Init; sending = true; domainName = QByteArray(); outstandingResponses = 0; if (!transport) { // Set up the transport transport = new QMailTransport("SMTP"); connect(transport, SIGNAL(readyRead()), this, SLOT(readyRead())); connect(transport, SIGNAL(connected(QMailTransport::EncryptType)), this, SLOT(connected(QMailTransport::EncryptType))); connect(transport, SIGNAL(bytesWritten(qint64)), this, SLOT(sent(qint64))); connect(transport, SIGNAL(updateStatus(QString)), this, SIGNAL(updateStatus(QString))); connect(transport, SIGNAL(errorOccurred(int,QString)), this, SLOT(transportError(int,QString))); #ifndef QT_NO_OPENSSL connect(transport, SIGNAL(sslErrorOccured(QMailServiceAction::Status::ErrorCode,QString)), this, SIGNAL(connectionError(QMailServiceAction::Status::ErrorCode,QString))); #endif }
bool WebDavCommandEntity::startWork() { if (!CommandEntity::startWork()) { abortWork(); return false; } if (!this->m_client) { qWarning() << "No valid client object available, aborting"; abortWork(); return false; } if (this->m_reply) { QObject::connect(this->m_reply, &QNetworkReply::destroyed, this, [=](){ QObject::disconnect(this->m_reply, 0, 0, 0); this->m_reply = Q_NULLPTR; }); QObject::connect(this->m_reply, static_cast<void(QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error), this, [=](QNetworkReply::NetworkError error) { qWarning() << "Aborting due to network error:" << error; // TODO: stale files when aborting? // Aborting due to network error: QNetworkReply::ContentNotFoundError // abortWork(); Q_EMIT aborted(); }); QObject::connect(this->m_reply, &QNetworkReply::finished, this, [=]() { qDebug() << "WebDav request complete:" << this->m_reply->url().toString(); qDebug() << this->m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); if (this->m_reply->error() != QNetworkReply::NoError) return; Q_EMIT done(); }); QObject::connect(this->m_reply, &QNetworkReply::downloadProgress, this, [=](qint64 bytesReceived, qint64 bytesTotal) { if (bytesTotal < 1) return; const qreal newProgress = ((qreal)bytesReceived/(qreal)bytesTotal); setProgress(newProgress); }); QObject::connect(this->m_reply, &QNetworkReply::uploadProgress, this, [=](qint64 bytesSent, qint64 bytesTotal) { if (bytesTotal < 1) return; const qreal newProgress = ((qreal)bytesSent/(qreal)bytesTotal); setProgress(newProgress); }); } QObject::connect(this->m_client, &QWebdav::checkSslCertifcate, this, [=](const QList<QSslError> &errors) { qWarning() << "SSL error occured"; if (errors.length() > 0) { QSslCertificate sslcert = errors[0].certificate(); const QString md5Digest = sslcert.digest(QCryptographicHash::Md5); const QString sha1Digest = sslcert.digest(QCryptographicHash::Sha1); Q_EMIT sslErrorOccured(md5Digest, sha1Digest); } abortWork(); }); return true; }