File indexing completed on 2024-04-21 15:07:29

0001 /*
0002     SPDX-FileCopyrightText: 2001, 2002, 2003 Frerich Raabe <raabe@kde.org>
0003 
0004     SPDX-License-Identifier: BSD-2-Clause
0005 */
0006 
0007 #ifndef SYNDICATION_DATARETRIEVER_H
0008 #define SYNDICATION_DATARETRIEVER_H
0009 
0010 #include "syndication_export.h"
0011 
0012 #include <QObject>
0013 
0014 class QUrl;
0015 
0016 class QByteArray;
0017 
0018 namespace Syndication
0019 {
0020 /**
0021  * Abstract baseclass for all data retriever classes. Subclass this to add
0022  * a new retrieval algorithm which can then be plugged into the RSS loader.
0023  * @see Loader, FileRetriever, OutputRetriever
0024  */
0025 class SYNDICATION_EXPORT DataRetriever : public QObject
0026 {
0027     Q_OBJECT
0028 public:
0029     /**
0030      * Default constructor.
0031      */
0032     DataRetriever();
0033 
0034     /**
0035      * Destructor.
0036      */
0037     ~DataRetriever() override;
0038 
0039     /**
0040      * Retrieve data from the given URL. This method is supposed to get
0041      * reimplemented by subclasses. It will be called by the Loader
0042      * class in case it needs to retrieve the data.
0043      *
0044      * @param url the URL to retrieve data from
0045      *
0046      * @see Loader::loadFrom()
0047      */
0048     virtual void retrieveData(const QUrl &url) = 0;
0049 
0050     /**
0051      * @return An error code which might give a more precise information
0052      * about what went wrong in case the 'success' flag returned with
0053      * the dataRetrieved() signal was 'false'. Note that the meaning of
0054      * the returned integer depends on the actual data retriever.
0055      */
0056     virtual int errorCode() const = 0;
0057 
0058     /**
0059      * aborts the retrieval process.
0060      */
0061     virtual void abort() = 0;
0062 
0063 Q_SIGNALS:
0064     /**
0065      * Emit this signal to tell the Loader class that the retrieval
0066      * process was finished.
0067      * @param data Should contain the retrieved data and will get
0068      * parsed by the Loader class.
0069      * @param success Indicates whether there were any problems during
0070      * the retrieval process. Pass 'true' to indicate that everything
0071      * went seamlessy, 'false' to tell the Loader that something went
0072      * wrong and that the data parameter might contain no or invalid
0073      * data.
0074      */
0075 
0076     void dataRetrieved(const QByteArray &data, bool success);
0077 
0078 private:
0079     DataRetriever(const DataRetriever &other);
0080     DataRetriever &operator=(const DataRetriever &other);
0081 };
0082 
0083 } // namespace Syndication
0084 
0085 #endif // SYNDICATION_DATARETRIEVER_H