1 | /* |
2 | SPDX-FileCopyrightText: 2001, 2002, 2003 Frerich Raabe <raabe@kde.org> |
3 | |
4 | SPDX-License-Identifier: BSD-2-Clause |
5 | */ |
6 | |
7 | #ifndef SYNDICATION_DATARETRIEVER_H |
8 | #define SYNDICATION_DATARETRIEVER_H |
9 | |
10 | #include "syndication_export.h" |
11 | |
12 | #include <QObject> |
13 | |
14 | class QUrl; |
15 | |
16 | class QByteArray; |
17 | |
18 | namespace Syndication |
19 | { |
20 | /*! |
21 | * \class Syndication::DataRetriever |
22 | * \inmodule Syndication |
23 | * \inheaderfile Syndication/DataRetriever |
24 | * |
25 | * \brief Abstract baseclass for all data retriever classes. |
26 | * |
27 | * Subclass this to add |
28 | * a new retrieval algorithm which can then be plugged into the RSS loader. |
29 | * \sa Loader |
30 | */ |
31 | class SYNDICATION_EXPORT DataRetriever : public QObject |
32 | { |
33 | Q_OBJECT |
34 | public: |
35 | /*! |
36 | * Default constructor. |
37 | */ |
38 | DataRetriever(); |
39 | |
40 | ~DataRetriever() override; |
41 | |
42 | /*! |
43 | * Retrieve data from the given URL. |
44 | * |
45 | * This method is supposed to get |
46 | * reimplemented by subclasses. It will be called by the Loader |
47 | * class in case it needs to retrieve the data. |
48 | * |
49 | * \a url the URL to retrieve data from |
50 | * |
51 | * \sa Loader::loadFrom() |
52 | */ |
53 | virtual void retrieveData(const QUrl &url) = 0; |
54 | |
55 | /*! |
56 | * Returns an error code which might give a more precise information |
57 | * about what went wrong in case the 'success' flag returned with |
58 | * the dataRetrieved() signal was 'false'. |
59 | * |
60 | * Note that the meaning of |
61 | * the returned integer depends on the actual data retriever. |
62 | */ |
63 | virtual int errorCode() const = 0; |
64 | |
65 | /*! |
66 | * aborts the retrieval process. |
67 | */ |
68 | virtual void abort() = 0; |
69 | |
70 | Q_SIGNALS: |
71 | /*! |
72 | * Emit this signal to tell the Loader class that the retrieval |
73 | * process was finished. |
74 | * |
75 | * \a data Should contain the retrieved data and will get |
76 | * parsed by the Loader class. |
77 | * |
78 | * \a success Indicates whether there were any problems during |
79 | * the retrieval process. Pass 'true' to indicate that everything |
80 | * went seamlessy, 'false' to tell the Loader that something went |
81 | * wrong and that the data parameter might contain no or invalid |
82 | * data. |
83 | */ |
84 | void dataRetrieved(const QByteArray &data, bool success); |
85 | |
86 | private: |
87 | DataRetriever(const DataRetriever &other); |
88 | DataRetriever &operator=(const DataRetriever &other); |
89 | }; |
90 | |
91 | } // namespace Syndication |
92 | |
93 | #endif // SYNDICATION_DATARETRIEVER_H |
94 | |