8#include "asynchttplookup.h"
11#include <KIO/TransferJob>
15 AsyncHTTPLookup::AsyncHTTPLookup()
21 AsyncHTTPLookup::~AsyncHTTPLookup()
27 AsyncHTTPLookup::lookup
31 const TrackOffsetList & trackOffsetList
34 trackOffsetList_ = trackOffsetList;
36 connect(
this, &HTTPLookup::queryReady,
this, &AsyncHTTPLookup::slotQueryReady );
37 connect(
this, &HTTPLookup::readReady,
this, &AsyncHTTPLookup::requestCDInfoForMatch );
39 initURL( hostName, port );
48 AsyncHTTPLookup::runQuery()
51 state_ = WaitingForQueryResponse;
53 result_ = sendQuery();
59 AsyncHTTPLookup::slotQueryReady()
61 qCDebug(LIBKCDDB) <<
"Matches Found: " << matchList_.count();
63 if ( Success != result_ )
65 Q_EMIT finished( result_ );
69 requestCDInfoForMatch();
73 AsyncHTTPLookup::requestCDInfoForMatch()
75 if ( matchList_.isEmpty() )
77 result_ = cdInfoList_.isEmpty()? NoRecordFound :
Success;
78 Q_EMIT finished( result_ );
82 CDDBMatch
match = matchList_.takeFirst();
85 state_ = WaitingForReadResponse;
87 result_ = sendRead( match );
89 if ( Success != result_ )
90 Q_EMIT finished( result_ );
101 AsyncHTTPLookup::slotResult(
KJob *job )
103 if ( 0 != job->
error() )
105 result_ = ServerError;
115 AsyncHTTPLookup::fetchURL()
117 qCDebug(LIBKCDDB) <<
"About to fetch: " << cgiURL_.url();
121 if (
nullptr == job )
125 this, &AsyncHTTPLookup::slotData );
127 this, &AsyncHTTPLookup::slotResult );
134#include "moc_asynchttplookup.cpp"
void data(KIO::Job *job, const QByteArray &data)
KCOREADDONS_EXPORT Result match(QStringView pattern, QStringView str)
KIOCORE_EXPORT TransferJob * get(const QUrl &url, LoadType reload=NoReload, JobFlags flags=DefaultFlags)
qsizetype size() const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)