akregator/src/librss

loader.h

00001 /*
00002  * loader.h
00003  *
00004  * Copyright (c) 2001, 2002, 2003 Frerich Raabe <raabe@kde.org>
00005  *
00006  * This program is distributed in the hope that it will be useful, but WITHOUT
00007  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00008  * FOR A PARTICULAR PURPOSE. For licensing and distribution details, check the
00009  * accompanying file 'COPYING'.
00010  */
00011 #ifndef LIBRSS_LOADER_H
00012 #define LIBRSS_LOADER_H
00013 
00014 #include "global.h"
00015 
00016 class KURL;
00017 
00018 #include <qobject.h>
00019 
00020 namespace KIO
00021 {
00022     class Job;
00023 }
00024 class KProcess;
00025 
00026 namespace RSS
00027 {
00028     class Document;
00029 
00035     class KDE_EXPORT DataRetriever : public QObject
00036     {
00037         Q_OBJECT
00038         public:
00042             DataRetriever();
00043 
00047             virtual ~DataRetriever();
00048 
00055             virtual void retrieveData(const KURL &url) = 0;
00056 
00063             virtual int errorCode() const = 0;
00064 
00065             virtual void abort() = 0;
00066         signals:
00078             void dataRetrieved(const QByteArray &data, bool success);
00079 
00080         private:
00081             DataRetriever(const DataRetriever &other);
00082             DataRetriever &operator=(const DataRetriever &other);
00083     };
00084 
00089     class KDE_EXPORT FileRetriever : public DataRetriever
00090     {
00091         Q_OBJECT
00092         public:
00096             FileRetriever();
00097 
00101             virtual ~FileRetriever();
00102 
00110             virtual void retrieveData(const KURL &url);
00111 
00118             virtual int errorCode() const;
00119 
00120             virtual void abort();
00121 
00122             static void setUseCache(bool enabled);
00123             static void setUserAgent(const QString &ua);
00124                         static QString userAgent();
00125 
00126         signals:
00134             void permanentRedirection(const KURL &url);
00135 
00136         protected slots:
00137             void slotTimeout();
00138 
00139         private slots:
00140             void slotData(KIO::Job *job, const QByteArray &data);
00141             void slotResult(KIO::Job *job);
00142             void slotPermanentRedirection(KIO::Job *job, const KURL &fromUrl,
00143                                                          const KURL &toUrl);
00144 
00145         private:
00146             static bool m_useCache;
00147 
00148             FileRetriever(const FileRetriever &other);
00149             FileRetriever &operator=(const FileRetriever &other);
00150 
00151             struct Private;
00152             Private *d;
00153     };
00154 
00160     class OutputRetriever : public DataRetriever
00161     {
00162         Q_OBJECT
00163         public:
00167             OutputRetriever();
00168 
00172             virtual ~OutputRetriever();
00173 
00181             virtual void retrieveData(const KURL &url);
00182 
00189             virtual int errorCode() const;
00190 
00191             virtual void abort() {}
00192 
00193         private slots:
00194             void slotOutput(KProcess *process, char *data, int length);
00195             void slotExited(KProcess *process);
00196 
00197         private:
00198             OutputRetriever(const OutputRetriever &other);
00199             OutputRetriever &operator=(const OutputRetriever &other);
00200 
00201             struct Private;
00202             Private *d;
00203     };
00204 
00254     class KDE_EXPORT Loader : public QObject
00255     {
00256         Q_OBJECT
00257         friend class someClassWhichDoesNotExist;
00258         public:
00267             static Loader *create();
00268 
00276             static Loader *create(QObject *object, const char *slot);
00277 
00293             void loadFrom(const KURL &url, DataRetriever *retriever);
00294 
00299             int errorCode() const;
00300 
00301             const KURL &discoveredFeedURL() const;
00302 
00303             void abort();
00304 
00305         signals:
00323             void loadingComplete(Loader *loader, Document doc, Status status);
00324 
00325         private slots:
00326             void slotRetrieverDone(const QByteArray &data, bool success);
00327 
00328         private:
00329             Loader();
00330             Loader(const Loader &other);
00331             Loader &operator=(const Loader &other);
00332             ~Loader();
00333             void discoverFeeds(const QByteArray &data);
00334 
00335             struct Private;
00336             Private *d;
00337     };
00338 }
00339 
00340 #endif // LIBRSS_LOADER_H
00341 // vim: noet:ts=4
KDE Home | KDE Accessibility Home | Description of Access Keys