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 <tqobject.h> 00019 00020 namespace TDEIO 00021 { 00022 class Job; 00023 } 00024 class TDEProcess; 00025 00026 namespace RSS 00027 { 00028 class Document; 00029 00035 class KDE_EXPORT DataRetriever : public TQObject 00036 { 00037 Q_OBJECT 00038 00039 public: 00043 DataRetriever(); 00044 00048 virtual ~DataRetriever(); 00049 00056 virtual void retrieveData(const KURL &url) = 0; 00057 00064 virtual int errorCode() const = 0; 00065 00066 virtual void abort() = 0; 00067 signals: 00079 void dataRetrieved(const TQByteArray &data, bool success); 00080 00081 private: 00082 DataRetriever(const DataRetriever &other); 00083 DataRetriever &operator=(const DataRetriever &other); 00084 }; 00085 00090 class KDE_EXPORT FileRetriever : public DataRetriever 00091 { 00092 Q_OBJECT 00093 00094 public: 00098 FileRetriever(); 00099 00103 virtual ~FileRetriever(); 00104 00112 virtual void retrieveData(const KURL &url); 00113 00120 virtual int errorCode() const; 00121 00122 virtual void abort(); 00123 00124 static void setUseCache(bool enabled); 00125 static void setUserAgent(const TQString &ua); 00126 static TQString userAgent(); 00127 00128 signals: 00136 void permanentRedirection(const KURL &url); 00137 00138 protected slots: 00139 void slotTimeout(); 00140 00141 private slots: 00142 void slotData(TDEIO::Job *job, const TQByteArray &data); 00143 void slotResult(TDEIO::Job *job); 00144 void slotPermanentRedirection(TDEIO::Job *job, const KURL &fromUrl, 00145 const KURL &toUrl); 00146 00147 private: 00148 static bool m_useCache; 00149 00150 FileRetriever(const FileRetriever &other); 00151 FileRetriever &operator=(const FileRetriever &other); 00152 00153 struct Private; 00154 Private *d; 00155 }; 00156 00162 class OutputRetriever : public DataRetriever 00163 { 00164 Q_OBJECT 00165 00166 public: 00170 OutputRetriever(); 00171 00175 virtual ~OutputRetriever(); 00176 00184 virtual void retrieveData(const KURL &url); 00185 00192 virtual int errorCode() const; 00193 00194 virtual void abort() {} 00195 00196 private slots: 00197 void slotOutput(TDEProcess *process, char *data, int length); 00198 void slotExited(TDEProcess *process); 00199 00200 private: 00201 OutputRetriever(const OutputRetriever &other); 00202 OutputRetriever &operator=(const OutputRetriever &other); 00203 00204 struct Private; 00205 Private *d; 00206 }; 00207 00257 class KDE_EXPORT Loader : public TQObject 00258 { 00259 Q_OBJECT 00260 00261 friend class someClassWhichDoesNotExist; 00262 public: 00271 static Loader *create(); 00272 00280 static Loader *create(TQObject *object, const char *slot); 00281 00297 void loadFrom(const KURL &url, DataRetriever *retriever); 00298 00303 int errorCode() const; 00304 00305 const KURL &discoveredFeedURL() const; 00306 00307 void abort(); 00308 00309 signals: 00327 void loadingComplete(Loader *loader, Document doc, Status status); 00328 00329 private slots: 00330 void slotRetrieverDone(const TQByteArray &data, bool success); 00331 00332 private: 00333 Loader(); 00334 Loader(const Loader &other); 00335 Loader &operator=(const Loader &other); 00336 ~Loader(); 00337 void discoverFeeds(const TQByteArray &data); 00338 00339 struct Private; 00340 Private *d; 00341 }; 00342 } 00343 00344 #endif // LIBRSS_LOADER_H 00345 // vim: noet:ts=4