bool NetworkJob::handleFTPHeader(const String& header) { size_t spacePos = header.find(' '); if (spacePos == notFound) return false; String statusCode = header.left(spacePos); switch (statusCode.toInt()) { case 213: m_isFTPDir = false; break; case 530: purgeCredentials(); sendRequestWithCredentials(ProtectionSpaceServerFTP, ProtectionSpaceAuthenticationSchemeDefault, "ftp"); break; case 230: storeCredentials(); break; case 550: // The user might have entered an URL which point to a directory but forgot type '/', // e.g., ftp://ftp.trolltech.com/qt/source where 'source' is a directory. We need to // added '/' and try again. if (m_handle && !m_handle->firstRequest().url().path().endsWith("/")) m_needsRetryAsFTPDirectory = true; break; } return true; }
void XTelepathyPasswordAuthOperation::onDialogFinished(int result) { switch (result) { case QDialog::Rejected: qDebug() << "Authentication cancelled"; m_saslIface->AbortSASL(Tp::SASLAbortReasonUserAbort, i18n("User cancelled auth")); setFinished(); if (!m_dialog.isNull()) { m_dialog.data()->deleteLater(); } return; case QDialog::Accepted: // save password in kwallet if necessary... if (!m_dialog.isNull()) { if (m_dialog.data()->savePassword()) { qDebug() << "Saving password in SSO"; m_canFinish = false; storeCredentials(m_dialog.data()->password()); } else { m_canFinish = true; } m_dialog.data()->deleteLater(); m_saslIface->StartMechanismWithData(QLatin1String("X-TELEPATHY-PASSWORD"), m_dialog.data()->password().toUtf8()); } } }
void NetworkJob::handleNotifyClose(int status) { #ifndef NDEBUG m_isRunning = false; #endif if (!m_cancelled) { if (!m_statusReceived) { // Connection failed before sending notifyStatusReceived: use generic NetworkError. notifyStatusReceived(BlackBerry::Platform::FilterStream::StatusNetworkError, 0); } // If an HTTP authentication-enabled request is successful, save // the credentials for later reuse. If the request fails, delete // the saved credentials. if (!isError(m_extendedStatusCode)) storeCredentials(); else if (isUnauthorized(m_extendedStatusCode)) purgeCredentials(); if (shouldNotifyClientFinished()) { if (isRedirect(m_extendedStatusCode) && (m_redirectCount >= s_redirectMaximum)) m_extendedStatusCode = BlackBerry::Platform::FilterStream::StatusTooManyRedirects; sendResponseIfNeeded(); if (isClientAvailable()) { RecursionGuard guard(m_callingClient); if (isError(m_extendedStatusCode) && !m_dataReceived) { String domain = m_extendedStatusCode < 0 ? ResourceError::platformErrorDomain : ResourceError::httpErrorDomain; ResourceError error(domain, m_extendedStatusCode, m_response.url().string(), m_response.httpStatusText()); m_handle->client()->didFail(m_handle.get(), error); } else m_handle->client()->didFinishLoading(m_handle.get(), 0); } } } // Whoever called notifyClose still have a reference to the job, so // schedule the deletion with a timer. m_deleteJobTimer.startOneShot(0); // Detach from the ResourceHandle in any case. m_handle = 0; m_multipartResponse = nullptr; }