Line data Source code
1 : #ifndef PARSERINTERFACE_H
2 : #define PARSERINTERFACE_H
3 :
4 : #include <QObject>
5 : #include <QUrl>
6 :
7 : #include "RawFeed.h"
8 :
9 : #include "../FangObject.h"
10 :
11 : /*!
12 : \brief Interface for RSS/Atom parser.
13 : */
14 : class ParserInterface : public FangObject
15 : {
16 : Q_OBJECT
17 :
18 : public:
19 : enum ParseResult { OK, NETWORK_ERROR, FILE_ERROR, PARSE_ERROR, EMPTY_DOCUMENT, IN_PROGRESS, NOT_MODIFIED };
20 2 : Q_ENUM(ParseResult)
21 :
22 : explicit ParserInterface(QObject *parent = nullptr);
23 200 : virtual ~ParserInterface() {}
24 :
25 : signals:
26 : // Call getResult() and getFeed() now, yo!
27 : void done();
28 :
29 : public slots:
30 :
31 : /*!
32 : \brief Contacts URL and parses the RSS/Atom feed, if it exists.
33 : \param url The URL
34 : \param noParseIfCached If true, this won't bother with the
35 : parse if the content was cached.
36 : */
37 : virtual void parse(const QUrl& url, bool noParseIfCached = false,
38 : const QString& ifNoneMatch = QString(),
39 : const QString& ifModifiedSince = QString()) =0;
40 :
41 : virtual ParserInterface::ParseResult getResult() =0;
42 : virtual RawFeed* getFeed() =0;
43 : virtual QUrl getURL() =0;
44 :
45 : // Whether or not the response was cached.
46 : virtual bool isFromCache() =0;
47 :
48 : // Conditional request response headers.
49 0 : virtual QString responseEtag() { return QString(); }
50 0 : virtual QString responseLastModified() { return QString(); }
51 :
52 : };
53 :
54 : #endif // PARSERINTERFACE_H
|