Ejemplo n.º 1
0
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 );
}
Ejemplo n.º 2
0
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);
}
Ejemplo n.º 3
0
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);
  }
}
Ejemplo n.º 4
0
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);
}