void FBRequestEnvelope::onRequestCallback(QByteArray resp) { disconnect(Facebook::instance()->getRequestManager(), SIGNAL(requestReady(QByteArray)), this, SLOT(onRequestCallback(QByteArray))); if(resp.isEmpty()) { //error need to tell the UI emit requestError(0x0); return; } response->parse(resp); if(response->getType() == FBApiResponseObjectFactory::Empty) { emit requestComplete(NULL); } else if(response->getResponse() != NULL) { if(param1 == NULL) { emit requestComplete(response->getResponse()); } else { emit requestComplete(param1, response->getResponse()); } } else { emit requestError(response->getMeta()); } }
int getSize(int fd) { //stats.req_arrival = id.req_arrival; int is_static; struct stat sbuf; char buf[MAXLINE], method[MAXLINE], uri[MAXLINE], version[MAXLINE]; char filename[MAXLINE], cgiargs[MAXLINE]; rio_t rio; //stats.size = -1; Rio_readinitb(&rio, fd); Rio_readlineb(&rio, buf, MAXLINE); sscanf(buf, "%s %s %s", method, uri, version); //close(fd); printf("%s %s %s\n", method, uri, version); if (strcasecmp(method, "GET")) { requestError(fd, method, "501", "Not Implemented", "CS537 Server does not implement this method"); return 0; } requestReadhdrs(&rio); is_static = requestParseURI(uri, filename, cgiargs); if (stat(filename, &sbuf) < 0) { requestError(fd, filename, "404", "Not found", "CS537 Server could not find this file"); return 0; } return sbuf.st_size; }
request_t requestParse(request_t request) { int fd = request.connfd; int is_static; struct stat stat_buf; char buf[MAXLINE], method[MAXLINE], uri[MAXLINE], version[MAXLINE]; char filename[MAXLINE], cgiargs[MAXLINE]; rio_t rio; Rio_readinitb(&rio, fd); Rio_readlineb(&rio, buf, MAXLINE); sscanf(buf, "%s %s %s", method, uri, version); printf("%s %s %s\n", method, uri, version); if (strcasecmp(method, "GET")) { requestError(fd, method, "501", "Not Implemented", "CS537 Server does not implement this method"); request.is_static = -1; return request; } requestReadhdrs(&rio); is_static = requestParseURI(uri, filename, cgiargs); if (stat(filename, &stat_buf) < 0) { requestError(fd, filename, "404", "Not found", "CS537 Server could not find this file"); request.is_static = -1; return request; } if (is_static) { if (!(S_ISREG(stat_buf.st_mode)) || !(S_IRUSR & stat_buf.st_mode)) { requestError(fd, filename, "403", "Forbidden", "CS537 Server could not read this file"); request.is_static = -1; return request; } } else { if (!(S_ISREG(stat_buf.st_mode)) || !(S_IXUSR & stat_buf.st_mode)) { requestError(fd, filename, "403", "Forbidden", "CS537 Server could not run this CGI program"); request.is_static = -1; return request; } } // save relevant information for handling the request later strcpy(request.filename, filename); strcpy(request.cgiargs, cgiargs); request.stat_buf = stat_buf; request.is_static = is_static; request.file_size = stat_buf.st_size; return request; }
// handle a request void requestHandle(server_request stats) { int is_static; struct stat sbuf; char buf[MAXLINE], method[MAXLINE], uri[MAXLINE], version[MAXLINE]; char filename[MAXLINE], cgiargs[MAXLINE]; is_static = stats.is_static; sbuf = stats.sbuf; memcpy (buf,stats.buf,MAXLINE); memcpy (method, stats.method,MAXLINE); memcpy (uri,stats.uri,MAXLINE); memcpy (version, stats.version,MAXLINE); memcpy (filename, stats.filename,MAXLINE); memcpy (cgiargs, stats.cgiargs,MAXLINE); int fd = stats.connValue; //rio_t rio=stats.rio; /* rio_t rio; Rio_readinitb(&rio, fd); Rio_readlineb(&rio, buf, MAXLINE); sscanf(buf, "%s %s %s", method, uri, version); printf("%s %s %s\n", method, uri, version); if (strcasecmp(method, "GET")) { requestError(fd, method, "501", "Not Implemented", "CS537 Server does not implement this method"); return; } requestReadhdrs(&rio); is_static = requestParseURI(uri, filename, cgiargs); if (stat(filename, &sbuf) < 0) { requestError(fd, filename, "404", "Not found", "CS537 Server could not find this file"); return; } */ if (is_static) { if (!(S_ISREG(sbuf.st_mode)) || !(S_IRUSR & sbuf.st_mode)) { requestError(fd, filename, "403", "Forbidden", "CS537 Server could not read this file"); return; } requestServeStatic(fd, filename, sbuf.st_size); } else { if (!(S_ISREG(sbuf.st_mode)) || !(S_IXUSR & sbuf.st_mode)) { requestError(fd, filename, "403", "Forbidden", "CS537 Server could not run this CGI program"); return; } requestServeDynamic(fd, filename, cgiargs); } }
void preRequestHandle(request* req) { int fd = req->fd; int is_static; struct stat sbuf; char buf[MAXLINE], method[MAXLINE], uri[MAXLINE], version[MAXLINE]; char filename[MAXLINE], cgiargs[MAXLINE]; rio_t rio; Rio_readinitb(&rio, fd); Rio_readlineb(&rio, buf, MAXLINE); sscanf(buf, "%s %s %s", method, uri, version); printf("%s %s %s\n", method, uri, version); if(strcasecmp(method, "GET")) { requestError( fd, method, "501", "Not Implemented", "CS537 Server does not implement this method" ); return; } requestReadhdrs(&rio); is_static = requestParseURI(uri, filename, cgiargs); if(stat(filename, &sbuf) < 0) { requestError( fd, filename, "404", "Not found", "CS537 Server could not find this file" ); return; } req->ready = 1; req->sbuf = sbuf; req->is_static = is_static; req->cgiargs = cgiargs; /* TODO: Free req->filename in worker thread */ req->filename = malloc(sizeof(char)*MAXLINE); strncpy(req->filename, filename, MAXLINE); }
void ReadabilityArticle::tryLoad() { if (!m_api) { m_error = "Cannot access article content (Invalid API Configuration)"; } else if (!m_url.isValid()) { m_error = "Cannot access article content (Invalid URL)"; } else { m_error.clear(); if (m_request) { disconnect(m_request); m_request->disconnect(this); m_request->cancel(); m_request->deleteLater(); } m_request = m_api->getParseRequest(m_url); connect(m_request, SIGNAL(responseReady(QJsonObject)), this, SLOT(onResponseReceived(QJsonObject))); connect(m_request, SIGNAL(requestError(QNetworkReply::NetworkError,QString)), this, SLOT(onRequestError(QNetworkReply::NetworkError,QString))); m_request->send(); emit startedLoading(); } emit loadingChanged(); emit errorChanged(m_error); }
int JsonDbPartition::create(const QJSValue &object, const QJSValue &options, const QJSValue &callback) { QJSValue actualOptions = options; QJSValue actualCallback = callback; if (options.isCallable()) { if (!callback.isUndefined()) { qWarning() << "Callback should be the last parameter."; return -1; } actualCallback = actualOptions; actualOptions = QJSValue(QJSValue::UndefinedValue); } //#TODO ADD options QVariant obj = qjsvalue_to_qvariant(object); QJsonDbWriteRequest *request(0); if (obj.type() == QVariant::List) { request = new QJsonDbCreateRequest(qvariantlist_to_qjsonobject_list(obj.toList())); } else { request = new QJsonDbCreateRequest(QJsonObject::fromVariantMap(obj.toMap())); } request->setPartition(_name); connect(request, SIGNAL(finished()), this, SLOT(requestFinished())); connect(request, SIGNAL(finished()), request, SLOT(deleteLater())); connect(request, SIGNAL(error(QtJsonDb::QJsonDbRequest::ErrorCode,QString)), this, SLOT(requestError(QtJsonDb::QJsonDbRequest::ErrorCode,QString))); connect(request, SIGNAL(error(QtJsonDb::QJsonDbRequest::ErrorCode,QString)), request, SLOT(deleteLater())); JsonDatabase::sharedConnection().send(request); writeCallbacks.insert(request, actualCallback); return request->property("requestId").toInt(); }
BOOST_FOREACH(const CMap::value_type &vt, keep_columns) { string field_name(vt.first.substr(2)); string output_field_xml; if (prefixequal(vt.first, "a.") && a_name_to_val_pos.exists(field_name)) { // case 1 TINVARIANT(a_series.getTypePtr()->hasColumn(field_name)); output_field_xml = renameField(a_series.getTypePtr(), field_name, vt.second); extractors.push_back (ExtractorValue::make(vt.second, a_name_to_val_pos[field_name])); } else if (prefixequal(vt.first, "a.") && eq_columns.find(field_name) != eq_columns.end()) { // case 2a const string b_field_name(eq_columns.find(field_name)->second); TINVARIANT(b_series.getTypePtr()->hasColumn(b_field_name)); output_field_xml = renameField(a_series.getTypePtr(), field_name, vt.second); GeneralField::Ptr b_field(GeneralField::make(b_series, b_field_name)); extractors.push_back(ExtractorField::make(vt.second, b_field)); } else if (prefixequal(vt.first, "b.") && b_series.getTypePtr()->hasColumn(field_name)) { // case 2b output_field_xml = renameField(b_series.getTypePtr(), field_name, vt.second); GeneralField::Ptr b_field(GeneralField::make(b_series, field_name)); extractors.push_back(ExtractorField::make(vt.second, b_field)); } else { requestError("invalid extraction"); } output_xml.append(output_field_xml); }
void firstExtent(const Extent &b_e) { ExtentSeries a_series; a_series.setExtent(a_input.getSharedExtent()); b_series.setType(b_e.getTypePtr()); if (a_series.getSharedExtent() == NULL) { requestError("a_table is empty?"); } // Three possible sources for values in the output: // // 1) the a value fields, so from the hash-map // 2a) the b fields, as one of the a eq fields. // 2b) the b fields, as one of the b values or eq fields // // We do not try to optimize the extraction and just create a new general field for each // extraction so if the hash-map has duplicate columns, there will be duplicate fields. vector<GeneralField::Ptr> a_eq_fields; HashUnique<string> known_a_eq_fields; BOOST_FOREACH(const CMap::value_type &vt, eq_columns) { SINVARIANT(a_series.getTypePtr()->getFieldType(vt.first) == b_series.getTypePtr()->getFieldType(vt.second)); a_eq_fields.push_back(GeneralField::make(a_series, vt.first)); b_eq_fields.push_back(GeneralField::make(b_series, vt.second)); known_a_eq_fields.add(vt.first); }
void NetworkReply::readTimeout() { // qDebug() << "HTTP read timeout" << networkReply->url(); networkReply->disconnect(); networkReply->abort(); QNetworkReply *retryReply = The::http()->simpleGet(networkReply->url(), networkReply->operation()); setParent(retryReply); networkReply->deleteLater(); networkReply = retryReply; // when the request is finished we'll invoke the target method connect(networkReply, SIGNAL(finished()), this, SLOT(finished()), Qt::UniqueConnection); // monitor downloadProgress to impl timeout connect(networkReply, SIGNAL(downloadProgress(qint64,qint64)), SLOT(downloadProgress(qint64,qint64)), Qt::UniqueConnection); readTimeoutTimer->start(); // error signal connect(networkReply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(requestError(QNetworkReply::NetworkError))); // emit error(networkReply); }
/* handle a request */ void requestHandle(request* req) { /* set the request's dispatch time */ long t; t = getTime(); req->req_dispatch = t - req->req_arrival; if(req->is_static) { if(!(S_ISREG(req->sbuf.st_mode)) || !(S_IRUSR & req->sbuf.st_mode)) { requestError( req->fd, req->filename, "403", "Forbidden", "CS537 Server could not read this file" ); return; } requestServeStatic( req->fd, req->filename, req->sbuf.st_size, req ); } else { if(!(S_ISREG(req->sbuf.st_mode)) || !(S_IXUSR & req->sbuf.st_mode)) { requestError( req->fd, req->filename, "403", "Forbidden", "CS537 Server could not run this CGI program" ); return; } requestServeDynamic( req->fd, req->filename, req->cgiargs, req ); } }
void BSClient::loadSeriesGenres() { qDebug() << "BSClient::loadSeries()"; QNetworkRequest request(QUrl("http://bs.to/api/series:genre")); m_reply = m_manager->get(request); connect(m_reply, SIGNAL(finished()), this, SLOT(replySeriesGenresFinished())); connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(requestError(QNetworkReply::NetworkError))); }
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))); }
// handle a request void requestHandle(int fd, char method[MAXLINE], char uri[MAXLINE], char version[MAXLINE]) { int is_static; struct stat sbuf; // char buf[MAXLINE], method[MAXLINE], uri[MAXLINE], version[MAXLINE]; char filename[MAXLINE], cgiargs[MAXLINE]; // rio_t rio = req->rio; // int fd = rio->rio_fd; // Rio_readinitb(&rio, fd); // printf("rio.fd: %d\n", rio->rio_fd); //Rio_readlineb(rio, buf, MAXLINE); //sscanf(buf, "%s %s %s", method, uri, version); //printf("readlineb\n"); if (strcasecmp(method, "GET")) { requestError(fd, method, "501", "Not Implemented", "CS537 Server does not implement this method"); return; } // requestReadhdrs(rio); is_static = requestParseURI(uri, filename, cgiargs); if (stat(filename, &sbuf) < 0) { requestError(fd, filename, "404", "Not found", "CS537 Server could not find this file"); return; } if (is_static) { if (!(S_ISREG(sbuf.st_mode)) || !(S_IRUSR & sbuf.st_mode)) { requestError(fd, filename, "403", "Forbidden", "CS537 Server could not read this file"); return; } requestServeStatic(fd, filename, sbuf.st_size); } else { if (!(S_ISREG(sbuf.st_mode)) || !(S_IXUSR & sbuf.st_mode)) { requestError(fd, filename, "403", "Forbidden", "CS537 Server could not run this CGI program"); return; } requestServeDynamic(fd, filename, cgiargs); } }
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))); }
void GPodderSearchPage::SearchClicked() { emit Busy(true); mygpo::PodcastListPtr list(api_->search(ui_->query->text())); NewClosure(list, SIGNAL(finished()), this, SLOT(SearchFinished(mygpo::PodcastListPtr)), list); NewClosure(list, SIGNAL(parseError()), this, SLOT(SearchFailed(mygpo::PodcastListPtr)), list); NewClosure(list, SIGNAL(requestError(QNetworkReply::NetworkError)), this, SLOT(SearchFailed(mygpo::PodcastListPtr)), list); }
void BSClient::loadUrl(const QString &id) { qDebug() << "BSClient::loadUrl()" << id; m_urlId = id; QNetworkRequest request(QUrl(QString("http://bs.to/api/watch/%1").arg(id))); m_reply = m_manager->get(request); connect(m_reply, SIGNAL(finished()), this, SLOT(replyUrlFinished())); connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(requestError(QNetworkReply::NetworkError))); }
void BSClient::loadLinks(const QString &id) { qDebug() << "BSClient::loadLinks()" << id; m_episodeId = id; QNetworkRequest request(QUrl(QString("http://bs.to/api/series/%0").arg(id))); m_reply = m_manager->get(request); connect(m_reply, SIGNAL(finished()), this, SLOT(replyLinksFinished())); connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(requestError(QNetworkReply::NetworkError))); }
void PictureDownloader::downloadTrackPicture(const QString & picId) { if(_downloadManagaer.values().contains(picId)) return; QNetworkRequest request(QString(TYM_PICTURE_URL_DOWNLOAD).arg(picId)); QNetworkReply *reply = _manager->get(request); _downloadManagaer.insert(reply, picId); connect(reply, SIGNAL(readyRead()), this, SLOT(writeTrackPicture())); connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(requestError(QNetworkReply::NetworkError))); connect(reply, SIGNAL(finished()), this, SLOT(sendFinalNotification())); }
//For getting file information, needed to modify request.h for this to work server_request getFileStat(int fd){ server_request stats; int is_static; struct stat sbuf; char buf[MAXLINE], method[MAXLINE], uri[MAXLINE], version[MAXLINE]; char filename[MAXLINE], cgiargs[MAXLINE]; rio_t rio; Rio_readinitb(&rio, fd); Rio_readlineb(&rio, buf, MAXLINE); sscanf(buf, "%s %s %s", method, uri, version); printf("%s %s %s\n", method, uri, version); if (strcasecmp(method, "GET")) { requestError(fd, method, "501", "Not Implemented", "CS537 Server does not implement this method"); return stats; } requestReadhdrs(&rio); is_static = requestParseURI(uri, filename, cgiargs); if (stat(filename, &sbuf) < 0) { requestError(fd, filename, "404", "Not found", "CS537 Server could not find this file"); return stats; } stats.is_static = is_static; stats.sbuf =sbuf; memcpy (stats.buf,buf,MAXLINE); memcpy (stats.method, method,MAXLINE); memcpy (stats.uri,uri,MAXLINE); memcpy (stats.version,version,MAXLINE); memcpy (stats.filename,filename,MAXLINE); memcpy (stats.cgiargs,cgiargs,MAXLINE); stats.rio=rio; return stats; }
// handle a request void requestHandle(int fd, char*buf) { int is_static; struct stat sbuf; char method[MAXLINE], uri[MAXLINE], version[MAXLINE]; char filename[MAXLINE], cgiargs[MAXLINE]; sscanf(buf, "%s %s %s", method, uri, version); printf("%s %s %s\n", method, uri, version); if (strcasecmp(method, "GET")) { requestError(fd, method, "501", "Not Implemented", "CS537 Server does not implement this method"); return; } is_static = requestParseURI(uri, filename, cgiargs); if (stat(filename, &sbuf) < 0) { requestError(fd, filename, "404", "Not found", "CS537 Server could not find this file"); return; } if (is_static) { if (!(S_ISREG(sbuf.st_mode)) || !(S_IRUSR & sbuf.st_mode)) { requestError(fd, filename, "403", "Forbidden", "CS537 Server could not read this file"); return; } requestServeStatic(fd, filename, sbuf.st_size); } else { if (!(S_ISREG(sbuf.st_mode)) || !(S_IXUSR & sbuf.st_mode)) { requestError(fd, filename, "403", "Forbidden", "CS537 Server could not run this CGI program"); return; } requestServeDynamic(fd, filename, cgiargs); } }
void Dialog::on_requestlicense_clicked() { ui->requestlicense->setEnabled(false); QUrl url("http://localhost/request-license.php"); url.addQueryItem("username", ui->username->text()); url.addQueryItem("password", ba2str(QCryptographicHash::hash(ui->password->text().toUtf8(), QCryptographicHash::Sha1))); url.addQueryItem("mac_address", ui->mac->currentText()); QNetworkRequest r(url); QNetworkReply* rep = http_->get(r); connect(rep, SIGNAL(finished()), this, SLOT(requestFinished())); connect(rep, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(requestError(QNetworkReply::NetworkError))); }
void MapNetwork::loadImage(const QString& host, const QString& query) { QUrl url = QString("http://%1/%2").arg(host).arg(query); QNetworkRequest req(url); QNetworkReply *rep; Tools::fixupRequest(&req); rep = nm->get(req); connect(rep, SIGNAL(finished()), this, SLOT(requestFinished())); connect(rep, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(requestError(QNetworkReply::NetworkError))); loadingMap[rep] = query; }
NetworkReply* NetworkAccess::get(const QUrl url) { QNetworkReply *networkReply = simpleGet(url); NetworkReply *reply = new NetworkReply(networkReply); // error signal connect(networkReply, SIGNAL(error(QNetworkReply::NetworkError)), reply, SLOT(requestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); // when the request is finished we'll invoke the target method connect(networkReply, SIGNAL(finished()), reply, SLOT(finished()), Qt::QueuedConnection); return reply; }
void HttpCore::readResponseHeader(const QHttpResponseHeader &responseHeader){ switch (responseHeader.statusCode()) { case 200: // Ok case 301: // Moved Permanently case 303: // See Other case 307: // Temporary Redirect // these are not error conditions break; default: emit(requestError(tr("Download failed: %1.").arg(responseHeader.reasonPhrase())));; this->aborted=true; http->abort(); } return; }
NetworkReply* NetworkAccess::head(const QUrl url) { QNetworkReply *networkReply = simpleGet(url, QNetworkAccessManager::HeadOperation); NetworkReply *reply = new NetworkReply(networkReply); reply->followRedirects = false; // error signal connect(networkReply, SIGNAL(error(QNetworkReply::NetworkError)), reply, SLOT(requestError(QNetworkReply::NetworkError)), Qt::QueuedConnection); // when the request is finished we'll invoke the target method connect(networkReply, SIGNAL(finished()), reply, SLOT(finished()), Qt::QueuedConnection); return reply; }
void NetworkReply::finished() { // qDebug() << "Finished" << networkReply->url(); QUrl redirection = networkReply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl(); if (redirection.isValid()) { // qDebug() << "Redirect!"; // << redirection; QNetworkReply *redirectReply = The::http()->simpleGet(redirection, networkReply->operation()); setParent(redirectReply); networkReply->deleteLater(); networkReply = redirectReply; // when the request is finished we'll invoke the target method connect(networkReply, SIGNAL(finished()), this, SLOT(finished()), Qt::UniqueConnection); // monitor downloadProgress to impl timeout connect(networkReply, SIGNAL(downloadProgress(qint64,qint64)), SLOT(downloadProgress(qint64,qint64)), Qt::UniqueConnection); readTimeoutTimer->start(); // error signal connect(networkReply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(requestError(QNetworkReply::NetworkError)), Qt::UniqueConnection); connect(readTimeoutTimer, SIGNAL(timeout()), SLOT(readTimeout()), Qt::UniqueConnection); readTimeoutTimer->start(); return; } emit data(networkReply->readAll()); emit finished(networkReply); #ifndef QT_NO_DEBUG_OUTPUT if (!networkReply->attribute(QNetworkRequest::SourceIsFromCacheAttribute).toBool()) { qDebug() << networkReply->url().toEncoded(); } #endif // bye bye my reply // this will also delete this NetworkReply as the QNetworkReply is its parent networkReply->deleteLater(); }
void SearchProvider::beatportIdsBasedSearch(QMap<QString, QString> * uid_Bpid_Map) { O1Beatport * oauthManager = O1Beatport::instance(); O1Requestor requestManager(_manager, oauthManager); if(!oauthManager->linked()) { LOG_ERROR("Unable to perform a search from IDs, Beatport OAuth is not linked"); // TODO: emit an error signal per request return; } QUrl requestUrl(TYM_BEATPORT_API_URL + _tracksPath); QList<QMap<QString, QString> *> splittedMaps; int i = 0; for (auto it = uid_Bpid_Map->begin() ; it != uid_Bpid_Map->end() ; ++it, ++i) { int listIndex = i / 10; if(splittedMaps.size() == listIndex) { splittedMaps.append(new QMap<QString, QString>()); } splittedMaps.value(listIndex)->insert(it.key(), it.value()); } for(auto tempMap : splittedMaps) { QString idsList = QStringList(tempMap->values()).join(","); QList<O1RequestParameter> params; params << O1RequestParameter("ids", idsList.toLatin1()); requestUrl.setQuery(QUrlQuery(O1::createQueryParams(params))); QNetworkRequest request(requestUrl); QNetworkReply *reply = requestManager.get(request, params); connect(reply, SIGNAL(finished()), this, SLOT(bpidSearchParseResponce())); connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(requestError(QNetworkReply::NetworkError))); LOG_DEBUG(QString("Request sent for IDs %1").arg(idsList)); _replyMap.insert(reply, tempMap); } delete uid_Bpid_Map; }
void QTCyberSerpent::Delete() { disconnect(updater.get(), SIGNAL(requestNewImage(QImage)), this, SLOT(UI_CB_UpdateImage(QImage))); disconnect(updater.get(), SIGNAL(requestError(QString)), this, SLOT(UI_CB_CreateError(QString))); disconnect(updater.get(), SIGNAL(requestListMessage()), this, SLOT(UI_CB_AddMessageInList())); disconnect(updater.get(), SIGNAL(requestAfficherOptions()), this, SLOT(UI_CB_UpdateAfficherOptions())); disconnect(updater.get(), SIGNAL(requestAfficherGameplay()), this, SLOT(UI_CB_UpdateAfficherGameplay())); disconnect(updater.get(), SIGNAL(requestAfficherWin()), this, SLOT(UI_CB_UpdateAfficherWin())); disconnect(updater.get(), SIGNAL(requestAfficherLose()), this, SLOT(UI_CB_UpdateAfficherLose())); disconnect(ui.actionNouvellePartie, SIGNAL(triggered()), this, SLOT(bttn_CommencerPartie())); disconnect(ui.actionQuitter, SIGNAL(triggered()), this, SLOT(bttn_Quitter())); disconnect(ui.pushButton_ValiderInfos, SIGNAL(triggered()), this, SLOT(bttn_Valider())); m_Game->m_QTApplication.processEvents(); qthread->terminate(); while (qthread->isRunning()); }
/* FIXME: Some requests never receive response Need more tests. When searching automatically AND manually on the same track (same libId), sometimes one of the responses does not call the slot. Therefore, it should because the requests and associated QNetworkReply are totally different objects and should not be in conflict. Maybe related to QNetworkSignalMapper. Also, what is the benefit of having a mapper here ? A simple QMap<QReply, QString> should be sufficient */ void SearchProvider::naturalSearch(QMap<QString, QString> *id_SearchText_Map) { O1Beatport * oauthManager = O1Beatport::instance(); O1Requestor requestManager(_manager, oauthManager); if(!oauthManager->linked()) { LOG_ERROR("Unable to perform a search from text, Beatport OAuth is not linked"); // TODO: emit an error signal return; } QUrl requestUrl(TYM_BEATPORT_API_URL + _searchPath); QMapIterator<QString, QString> searchList(*id_SearchText_Map); while(searchList.hasNext()) { searchList.next(); QString libId = searchList.key(); QString text = searchList.value(); if(text.isEmpty()) return; // Replace underscores by spaces (and prevent multiple spaces) Utils::instance()->simplifySpaces(text.replace('_', ' ')); QList<O1RequestParameter> params; params << O1RequestParameter("query", text.toLatin1()); params << O1RequestParameter("facets", "fieldType:track"); requestUrl.setQuery(QUrlQuery(O1::createQueryParams(params))); QNetworkRequest request(requestUrl); QNetworkReply *reply = requestManager.get(request, params); _naturalSearchMapper->setMapping(reply, libId); connect(reply, SIGNAL(finished()), _naturalSearchMapper, SLOT(map())); connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(requestError(QNetworkReply::NetworkError))); LOG_DEBUG(QString("Request sent for search \"%1\"").arg(text)); } delete id_SearchText_Map; }