diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-08-25 01:01:14 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-09-15 16:14:19 +0200 |
commit | b1b128bb35c91c3a8fe3c36a31ba4676ff0cd54e (patch) | |
tree | afef3b48688c4085545d38e1563414e79593cf14 /examples/imapresource/imapserverproxy.cpp | |
parent | 05d54cffc3bd8a50fad195f38a7963a48df779e5 (diff) | |
download | sink-b1b128bb35c91c3a8fe3c36a31ba4676ff0cd54e.tar.gz sink-b1b128bb35c91c3a8fe3c36a31ba4676ff0cd54e.zip |
The ping is no longer necessary
Diffstat (limited to 'examples/imapresource/imapserverproxy.cpp')
-rw-r--r-- | examples/imapresource/imapserverproxy.cpp | 37 |
1 files changed, 1 insertions, 36 deletions
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( | |||
104 | } | 104 | } |
105 | } | 105 | } |
106 | 106 | ||
107 | KAsync::Job<void> ImapServerProxy::ping() | ||
108 | { | ||
109 | auto hostname = mSession->hostName(); | ||
110 | auto port = mSession->port(); | ||
111 | auto timeout = mSession->timeout() * 1000; | ||
112 | return KAsync::start<void>([=](KAsync::Future<void> &future) { | ||
113 | SinkTrace() << "Starting ping" << timeout; | ||
114 | auto guard = QPointer<QObject>(new QObject); | ||
115 | auto socket = QSharedPointer<QTcpSocket>::create(); | ||
116 | QObject::connect(socket.data(), &QTcpSocket::hostFound, guard, [guard, &future, socket]() { | ||
117 | SinkTrace() << "Ping succeeded"; | ||
118 | delete guard; | ||
119 | future.setFinished(); | ||
120 | }); | ||
121 | QObject::connect(socket.data(), static_cast<void(QTcpSocket::*)(QTcpSocket::SocketError)>(&QTcpSocket::error), guard, [guard, &future, socket](QTcpSocket::SocketError) { | ||
122 | SinkWarning() << "Ping failed: "; | ||
123 | delete guard; | ||
124 | future.setError(1, "Error during connect"); | ||
125 | }); | ||
126 | if (!guard) { | ||
127 | return; | ||
128 | } | ||
129 | socket->connectToHost(hostname, port); | ||
130 | QTimer::singleShot(timeout, guard, [guard, &future, hostname, port, socket]() { | ||
131 | if (guard) { | ||
132 | SinkWarning() << "Ping failed: " << hostname << port; | ||
133 | delete guard; | ||
134 | future.setError(1, "Couldn't lookup host"); | ||
135 | } | ||
136 | }); | ||
137 | }); | ||
138 | |||
139 | } | ||
140 | |||
141 | KAsync::Job<void> ImapServerProxy::login(const QString &username, const QString &password) | 107 | KAsync::Job<void> ImapServerProxy::login(const QString &username, const QString &password) |
142 | { | 108 | { |
143 | auto loginJob = new KIMAP::LoginJob(mSession); | 109 | auto loginJob = new KIMAP::LoginJob(mSession); |
@@ -156,8 +122,7 @@ KAsync::Job<void> ImapServerProxy::login(const QString &username, const QString | |||
156 | }); | 122 | }); |
157 | auto namespaceJob = new KIMAP::NamespaceJob(mSession); | 123 | auto namespaceJob = new KIMAP::NamespaceJob(mSession); |
158 | 124 | ||
159 | //FIXME The ping is only required because the login job doesn't fail after the configured timeout | 125 | return runJob(loginJob).then(runJob(capabilitiesJob)).syncThen<void>([this](){ |
160 | return ping().then(runJob(loginJob)).then(runJob(capabilitiesJob)).syncThen<void>([this](){ | ||
161 | SinkTrace() << "Supported capabilities: " << mCapabilities; | 126 | SinkTrace() << "Supported capabilities: " << mCapabilities; |
162 | QStringList requiredExtensions = QStringList() << "UIDPLUS" << "NAMESPACE"; | 127 | QStringList requiredExtensions = QStringList() << "UIDPLUS" << "NAMESPACE"; |
163 | for (const auto &requiredExtension : requiredExtensions) { | 128 | for (const auto &requiredExtension : requiredExtensions) { |