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 };
20 0 : Q_ENUM(ParseResult)
21 :
22 : explicit ParserInterface(QObject *parent = nullptr);
23 138 : 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) =0;
38 :
39 : virtual ParserInterface::ParseResult getResult() =0;
40 : virtual RawFeed* getFeed() =0;
41 : virtual QUrl getURL() =0;
42 :
43 : // Whether or not the response was cached.
44 : virtual bool isFromCache() =0;
45 :
46 : };
47 :
48 : #endif // PARSERINTERFACE_H
|