Syndication
9 #include "dataretriever.h"
10 #include "documentsource.h"
13 #include "loaderutil_p.h"
14 #include "parsercollection.h"
19 #include <syndication_debug.h>
23 struct SYNDICATION_NO_EXPORT Loader::LoaderPrivate {
33 DataRetriever *retriever =
nullptr;
35 int retrieverError = 0;
36 QUrl discoveredFeedURL;
40 Loader *Loader::create()
45 Loader *Loader::create(
QObject *
object,
const char *slot)
48 connect(loader, SIGNAL(loadingComplete(Syndication::Loader *, Syndication::FeedPtr,
Syndication::ErrorCode)),
object, slot);
53 : d(new LoaderPrivate)
57 Loader::~Loader() =
default;
59 void Loader::loadFrom(
const QUrl &url, DataRetriever *retriever)
61 if (d->retriever !=
nullptr) {
66 d->retriever = retriever;
70 d->retriever->retrieveData(url);
73 int Loader::retrieverError()
const
75 return d->retrieverError;
85 if (d && d->retriever) {
86 d->retriever->abort();
88 d->retriever =
nullptr;
91 Q_EMIT loadingComplete(
this, FeedPtr(),
Aborted);
95 QUrl Loader::discoveredFeedURL()
const
97 return d->discoveredFeedURL;
100 void Loader::slotRetrieverDone(
const QByteArray &data,
bool success)
102 d->retrieverError = d->retriever->errorCode();
106 d->retriever =
nullptr;
109 DocumentSource src(data, d->url.url());
117 qCDebug(SYNDICATION_LOG) <<
"Retriever error:" << d->retrieverError;
122 Q_EMIT loadingComplete(
this, feed,
status);
127 void Loader::discoverFeeds(
const QByteArray &data)
129 const QUrl url = LoaderUtil::parseFeed(data, d->url);
131 d->discoveredFeedURL = url;
bool isEmpty() const const
Q_SCRIPTABLE CaptureState status()
QAction * create(StandardGameAction id, const QObject *recvr, const char *slot, QObject *parent)
@ OtherRetrieverError
retriever error not covered by the error codes above.
@ Aborted
file downloading/parsing was aborted by the user
ErrorCode
error code indicating fetching or parsing errors
Q_SCRIPTABLE Q_NOREPLY void abort()
ParserCollection< Feed > * parserCollection()
The default ParserCollection instance parsing a DocumentSource into a Feed object.
void dataRetrieved(const QByteArray &data, bool success)
Emit this signal to tell the Loader class that the retrieval process was finished.
@ Success
No error occurred, feed was fetched and parsed successfully.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Jun 6 2023 03:56:27 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.