From b1b128bb35c91c3a8fe3c36a31ba4676ff0cd54e Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 25 Aug 2016 01:01:14 +0200 Subject: The ping is no longer necessary --- examples/imapresource/imapserverproxy.cpp | 37 +------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-) (limited to 'examples/imapresource/imapserverproxy.cpp') diff --git a/examples/imapresource/imapserverproxy.cpp b/examples/imapresource/imapserverproxy.cpp index 82a68cd..921eeff 100644 --- a/examples/imapresource/imapserverproxy.cpp +++ b/examples/imapresource/imapserverproxy.cpp @@ -104,40 +104,6 @@ ImapServerProxy::ImapServerProxy(const QString &serverUrl, int port) : mSession( } } -KAsync::Job ImapServerProxy::ping() -{ - auto hostname = mSession->hostName(); - auto port = mSession->port(); - auto timeout = mSession->timeout() * 1000; - return KAsync::start([=](KAsync::Future &future) { - SinkTrace() << "Starting ping" << timeout; - auto guard = QPointer(new QObject); - auto socket = QSharedPointer::create(); - QObject::connect(socket.data(), &QTcpSocket::hostFound, guard, [guard, &future, socket]() { - SinkTrace() << "Ping succeeded"; - delete guard; - future.setFinished(); - }); - QObject::connect(socket.data(), static_cast(&QTcpSocket::error), guard, [guard, &future, socket](QTcpSocket::SocketError) { - SinkWarning() << "Ping failed: "; - delete guard; - future.setError(1, "Error during connect"); - }); - if (!guard) { - return; - } - socket->connectToHost(hostname, port); - QTimer::singleShot(timeout, guard, [guard, &future, hostname, port, socket]() { - if (guard) { - SinkWarning() << "Ping failed: " << hostname << port; - delete guard; - future.setError(1, "Couldn't lookup host"); - } - }); - }); - -} - KAsync::Job ImapServerProxy::login(const QString &username, const QString &password) { auto loginJob = new KIMAP::LoginJob(mSession); @@ -156,8 +122,7 @@ KAsync::Job ImapServerProxy::login(const QString &username, const QString }); auto namespaceJob = new KIMAP::NamespaceJob(mSession); - //FIXME The ping is only required because the login job doesn't fail after the configured timeout - return ping().then(runJob(loginJob)).then(runJob(capabilitiesJob)).syncThen([this](){ + return runJob(loginJob).then(runJob(capabilitiesJob)).syncThen([this](){ SinkTrace() << "Supported capabilities: " << mCapabilities; QStringList requiredExtensions = QStringList() << "UIDPLUS" << "NAMESPACE"; for (const auto &requiredExtension : requiredExtensions) { -- cgit v1.2.3