void LaconicaSearch::searchResultsReturned(KJob* job) { kDebug(); if( job == 0 ) { kDebug() << "job is a null pointer"; emit error( i18n( "Unable to fetch search results." ) ); return; } SearchInfo info = mSearchJobs.take(job); if( job->error() ) { kError() << "Error: " << job->errorString(); emit error( i18n( "Unable to fetch search results: %1", job->errorString() ) ); return; } KIO::StoredTransferJob *jj = qobject_cast<KIO::StoredTransferJob *>( job ); QList<Choqok::Post*> postsList; if(info.option == ReferenceHashtag) postsList = parseAtom( jj->data() ); else postsList = parseRss( jj->data() ); kDebug()<<"Emiting searchResultsReceived()"; emit searchResultsReceived( info, postsList ); }
void Dispatcher::parseArrivedSearchResult(QByteArray &datagram, QHostAddress senderHost) { if (datagram.length() <= 40) { emit invalidPacketReceived(); return; } datagram.remove(0, 2); QHostAddress allegedSenderHost(getQuint32FromByteArray(&datagram)); //if (senderHost != allegedSenderHost) // return; quint64 searchID = getQuint64FromByteArray(&datagram); QByteArray senderCID = datagram.mid(0, 24); datagram.remove(0, 24); int searchResultLength = getQuint16FromByteArray(&datagram); QByteArray searchResult = datagram.mid(0, searchResultLength); QByteArray bucket = datagram.mid(searchResultLength); if (searchResult.length() > 0) emit searchResultsReceived(senderHost, senderCID, searchID, searchResult); if (bucket.length() > 0) emit bucketContentsArrived(bucket, senderHost); }
void SearchModel::downloadFinished(Job *job, const QByteArray & data) { if (job == searchJob) { searchResultsReceived(data); searchJob = NULL; } if (bannersJobs.contains(job)) { QtTvDB::Show *show = bannersJobs.take(job); bannerReceived(show, data); } }
void TwitterSearch::searchResultsReturned(KJob *job) { qCDebug(CHOQOK); if (!job) { qCDebug(CHOQOK) << "job is a null pointer"; Q_EMIT error(i18n("Unable to fetch search results.")); return; } const SearchInfo info = mSearchJobs.take(job); QList<Choqok::Post *> postsList; if (job->error()) { qCCritical(CHOQOK) << "Error:" << job->errorString(); Q_EMIT error(i18n("Unable to fetch search results: %1", job->errorString())); } else { KIO::StoredTransferJob *jj = qobject_cast<KIO::StoredTransferJob *>(job); const QJsonDocument json = QJsonDocument::fromJson(jj->data()); if (!json.isNull()) { if (info.option == TwitterSearch::FromUser) { for (const QVariant elem: json.toVariant().toList()) { postsList.prepend(readStatusesFromJsonMap(elem.toMap())); } } else { const QVariantMap map = json.toVariant().toMap(); if (map.contains(QLatin1String("statuses"))) { for (const QVariant elem: map[QLatin1String("statuses")].toList()) { postsList.prepend(readStatusesFromJsonMap(elem.toMap())); } } } } } Q_EMIT searchResultsReceived(info, postsList); }