// Request methods void CommunicationDescriptionGateway::setupRequestConnections() { // this->disconnect(); connect(networkRequest, SIGNAL(responseDownloaded(QByteArray)), this, SLOT(requestReceived(QByteArray))); connect(networkRequest, SIGNAL(finished()), this, SLOT(requestFinished())); connect(networkRequest, SIGNAL(authenticationChallenge()), this, SLOT(authenticationChallenge())); // failed connections connect(networkRequest, SIGNAL(failedToSendRequest()), this, SLOT(requestFailed())); connect(networkRequest, SIGNAL(noNetworkConnection()), this, SLOT(requestFailed())); connect(networkRequest, SIGNAL(requestTimedOut()), this, SLOT(requestFailed())); }
void SeafileApiClient::httpRequestFinished() { int code = reply_->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); if (code == 0 && reply_->error() != QNetworkReply::NoError) { if (!shouldIgnoreRequestError(reply_)) { qDebug("[api] network error: %s\n", reply_->errorString().toUtf8().data()); } emit networkError(reply_->error(), reply_->errorString()); return; } if (handleHttpRedirect()) { return; } if ((code / 100) == 4 || (code / 100) == 5) { if (!shouldIgnoreRequestError(reply_)) { qDebug("request failed for %s: status code %d\n", reply_->url().toString().toUtf8().data(), code); } emit requestFailed(code); return; } emit requestSuccess(*reply_); }
/*! \internal */ QPhoneCall DialerControl::createCall( const QString& callType ) { QPhoneCall c = mCallManager->create(callType); c.connectStateChanged( this, SLOT(callStateChanged(QPhoneCall)) ); c.connectPendingTonesChanged( this, SIGNAL(pendingTonesChanged(QPhoneCall)) ); c.connectRequestFailed( this, SIGNAL(requestFailed(QPhoneCall,QPhoneCall::Request)) ); return c; }
void FluushOption::showEvent(QShowEvent *e) { Q_UNUSED(e) FluushRequestHistory *histRequest = new FluushRequestHistory(ui->apiKey->text(), net); net->sendMessage(histRequest); connect(histRequest, SIGNAL(FileListSent(QList<FluushFileInfo>&)), this, SLOT(FileListSent(QList<FluushFileInfo>&))); connect(histRequest, SIGNAL(requestFailed(QString)), this, SLOT(requestError(QString))); }
void FluushOption::imageCaptured(QPixmap p) { QString savePath = QDir::tempPath() + "/" + QDateTime::currentDateTime().toString("dd_MM_yyyy_hh_mm_ss") + ".png"; p.save(savePath); FluushRequestUpload *upRequest = new FluushRequestUpload(savePath, ui->apiKey->text(), net); net->sendMessage(upRequest); connect(upRequest, SIGNAL(uploadSuccess(QString)), this, SLOT(uploadComplete(QString))); connect(upRequest, SIGNAL(requestFailed(QString)), this, SLOT(requestError(QString))); }
// Return true if the request is redirected and request is resended. bool SeafileApiClient::handleHttpRedirect() { QVariant redirect_attr = reply_->attribute(QNetworkRequest::RedirectionTargetAttribute); if (redirect_attr.isNull()) { return false; } QUrl redirect_url = redirect_attr.toUrl(); if (redirect_url.isRelative()) { redirect_url = reply_->url().resolved(redirect_url); } // printf("redirect to %s (from %s)\n", redirect_url.toString().toUtf8().data(), // reply_->url().toString().toUtf8().data()); if (reply_->operation() == QNetworkAccessManager::PostOperation) { // XXX: Special case for rename/move file api, which returns 301 on // success. We need to distinguish that from a normal 301 redirect. // (In contrast, Rename/move dir api returns 200 on success). if (redirect_url.path().contains(QRegExp("/api2/repos/[^/]+/file/"))) { QString old_name = getQueryValue(reply_->url(), "p"); QString new_name = getQueryValue(redirect_url, "p"); // Only treat it as a rename file success when old and new are different if (!old_name.isEmpty() && !new_name.isEmpty() && old_name != new_name) { // printf ("get 301 rename file success, old_name: %s, new_name: %s\n", // toCStr(old_name), toCStr(new_name)); return false; } } } if (redirect_count_++ > kMaxRedirects) { // simply treat too many redirects as server side error emit requestFailed(500); qWarning("too many redirects for %s\n", reply_->url().toString().toUtf8().data()); return true; } resendRequest(redirect_url); return true; }
/*! Constructor */ FacebookConnection::FacebookConnection(QObject *parent) : SocialConnection(parent), m_facebook(new Facebook(this)), m_manager(new FacebookDataManager(this)), m_apiCall(Undefined) { connect(m_facebook, SIGNAL(requestCompleted(QVariant,QByteArray)), this, SLOT(onRequestCompleted(QVariant,QByteArray))); connect(m_facebook, SIGNAL(requestFailed(QVariant,QString)), this, SLOT(onRequestFailed(QVariant,QString))); connect(m_facebook, SIGNAL(clientIdChanged(QString)), this, SIGNAL(clientIdChanged(QString))); connect(m_facebook, SIGNAL(accessTokenChanged(QString)), this, SIGNAL(accessTokenChanged(QString))); connect(m_facebook, SIGNAL(authorizedChanged(bool)), this, SLOT(onAuthenticationChanged(bool))); connect(m_facebook, SIGNAL(screenNameChanged(QString)), this, SLOT(onNameChanged(QString))); }
void SeafileApiClient::httpRequestFinished() { int code = reply_->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); if (code == 0 && reply_->error() != QNetworkReply::NoError) { if (NetworkManager::instance()->shouldRetry(reply_->error())) { qWarning("[api] network proxy error, retrying\n"); resendRequest(reply_->url()); return; } if (!shouldIgnoreRequestError(reply_)) { qWarning("[api] network error for %s: %s\n", toCStr(reply_->url().toString()), reply_->errorString().toUtf8().data()); } emit networkError(reply_->error(), reply_->errorString()); return; } if (handleHttpRedirect()) { return; } if ((code / 100) == 4 || (code / 100) == 5) { if (!shouldIgnoreRequestError(reply_)) { QByteArray content = reply_->readAll(); qWarning("request failed for %s: %s\n", reply_->url().toString().toUtf8().data(), content.left(kMaxHttpErrorLogLen).data()); if (content.length() > kMaxHttpErrorLogLen) { qDebug("request failed for %s: %s\n", reply_->url().toString().toUtf8().data(), content.data()); } } emit requestFailed(code); return; } emit requestSuccess(*reply_); }
void YoutubeApi::broadcastRequestFinished(int id, QNetworkReply::NetworkError error, QByteArray data) { (void)(id); if (error != QNetworkReply::NetworkError::NoError) { emit requestFailed(error,data); broadcastModel_->clearBroadcasts(); emit broadcastModelChanged(); return; } QJsonDocument jsonResponse = QJsonDocument::fromJson(data); QVariantMap variantData = jsonResponse.toVariant().toMap(); /*foreach (const QVariant &v, variantData.keys()) { qWarning() << v.toString() << " : " << variantData[v.toString()]; }*/ auto broadcastsData = variantData["items"].toList(); foreach (const QVariant &v, broadcastsData) { auto broadcastData = v.toMap(); broadcastModel_->addBroadcast(broadcastData); }
bool SeafileApiClient::handleHttpRedirect() { QVariant redirect_attr = reply_->attribute(QNetworkRequest::RedirectionTargetAttribute); if (redirect_attr.isNull()) { return false; } if (redirect_count_++ > kMaxRedirects) { // simply treat too many redirects as server side error emit requestFailed(500); qDebug("too many redirects for %s\n", reply_->url().toString().toUtf8().data()); return true; } reply_->deleteLater(); QUrl redirect_url = redirect_attr.toUrl(); if (redirect_url.isRelative()) { redirect_url = reply_->url().resolved(redirect_url); } // qDebug("redirect to %s (from %s)\n", redirect_url.toString().toUtf8().data(), // reply_->url().toString().toUtf8().data()); switch (reply_->operation()) { case QNetworkAccessManager::GetOperation: get(redirect_url); break; case QNetworkAccessManager::PostOperation: post(redirect_url, encoded_params_); break; } return true; }
/*! \internal This slot handles FacebookRequest reply. */ void Facebook::onRequestFinished(FacebookRequest *request, FacebookReply *reply) { if (reply->error()) { if (reply->errorCode() == FacebookReply::OAuthAuthError) { qDebug() << "Error. Authentication needed."; emit authorizedChanged(false); } emit requestFailed(request->requestId(), reply->errorString()); } else { emit requestCompleted(request->requestId(), reply->responseData()); } for (int i = 0; i < m_activeRequests.count(); i++) { if (m_activeRequests.at(i) == request) { m_activeRequests.removeAt(i); break; } } request->deleteLater(); reply->deleteLater(); }
void TestPhoneCallImpl::join( bool ) { // Joins are not supported in this implementation. emit requestFailed( QPhoneCall::JoinFailed ); }
void QPhoneCallDummy::hold() { // Not supported. emit requestFailed( QPhoneCall::HoldFailed ); }