akregator/src/librss

loader.h
1 /*
2  * loader.h
3  *
4  * Copyright (c) 2001, 2002, 2003 Frerich Raabe <raabe@kde.org>
5  *
6  * This program is distributed in the hope that it will be useful, but WITHOUT
7  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
8  * FOR A PARTICULAR PURPOSE. For licensing and distribution details, check the
9  * accompanying file 'COPYING'.
10  */
11 #ifndef LIBRSS_LOADER_H
12 #define LIBRSS_LOADER_H
13 
14 #include "global.h"
15 
16 class KURL;
17 
18 #include <tqobject.h>
19 
20 namespace TDEIO
21 {
22  class Job;
23 }
24 class TDEProcess;
25 
26 namespace RSS
27 {
28  class Document;
29 
35  class TDE_EXPORT DataRetriever : public TQObject
36  {
37  TQ_OBJECT
38 
39  public:
43  DataRetriever();
44 
48  virtual ~DataRetriever();
49 
56  virtual void retrieveData(const KURL &url) = 0;
57 
64  virtual int errorCode() const = 0;
65 
66  virtual void abort() = 0;
67  signals:
79  void dataRetrieved(const TQByteArray &data, bool success);
80 
81  private:
82  DataRetriever(const DataRetriever &other);
83  DataRetriever &operator=(const DataRetriever &other);
84  };
85 
90  class TDE_EXPORT FileRetriever : public DataRetriever
91  {
92  TQ_OBJECT
93 
94  public:
98  FileRetriever();
99 
103  virtual ~FileRetriever();
104 
112  virtual void retrieveData(const KURL &url);
113 
120  virtual int errorCode() const;
121 
122  virtual void abort();
123 
124  static void setUseCache(bool enabled);
125  static void setUserAgent(const TQString &ua);
126  static TQString userAgent();
127 
128  signals:
136  void permanentRedirection(const KURL &url);
137 
138  protected slots:
139  void slotTimeout();
140 
141  private slots:
142  void slotData(TDEIO::Job *job, const TQByteArray &data);
143  void slotResult(TDEIO::Job *job);
144  void slotPermanentRedirection(TDEIO::Job *job, const KURL &fromUrl,
145  const KURL &toUrl);
146 
147  private:
148  static bool m_useCache;
149 
150  FileRetriever(const FileRetriever &other);
151  FileRetriever &operator=(const FileRetriever &other);
152 
153  struct Private;
154  Private *d;
155  };
156 
163  {
164  TQ_OBJECT
165 
166  public:
170  OutputRetriever();
171 
175  virtual ~OutputRetriever();
176 
184  virtual void retrieveData(const KURL &url);
185 
192  virtual int errorCode() const;
193 
194  virtual void abort() {}
195 
196  private slots:
197  void slotOutput(TDEProcess *process, char *data, int length);
198  void slotExited(TDEProcess *process);
199 
200  private:
201  OutputRetriever(const OutputRetriever &other);
202  OutputRetriever &operator=(const OutputRetriever &other);
203 
204  struct Private;
205  Private *d;
206  };
207 
257  class TDE_EXPORT Loader : public TQObject
258  {
259  TQ_OBJECT
260 
261  friend class someClassWhichDoesNotExist;
262  public:
271  static Loader *create();
272 
280  static Loader *create(TQObject *object, const char *slot);
281 
297  void loadFrom(const KURL &url, DataRetriever *retriever);
298 
303  int errorCode() const;
304 
305  const KURL &discoveredFeedURL() const;
306 
307  void abort();
308 
309  signals:
327  void loadingComplete(Loader *loader, Document doc, Status status);
328 
329  private slots:
330  void slotRetrieverDone(const TQByteArray &data, bool success);
331 
332  private:
333  Loader();
334  Loader(const Loader &other);
335  Loader &operator=(const Loader &other);
336  ~Loader();
337  void discoverFeeds(const TQByteArray &data);
338 
339  struct Private;
340  Private *d;
341  };
342 }
343 
344 #endif // LIBRSS_LOADER_H
Abstract baseclass for all data retriever classes.
Definition: loader.h:36
virtual int errorCode() const =0
virtual void retrieveData(const KURL &url)=0
Retrieve data from the given URL.
void dataRetrieved(const TQByteArray &data, bool success)
Emit this signal to tell the Loader class that the retrieval process was finished.
Represents a RSS document and provides all the features and properties as stored in it.
Definition: document.h:32
Implements a file retriever, to be used with Loader::loadFrom().
Definition: loader.h:91
void permanentRedirection(const KURL &url)
Signals a permanent redirection.
This class is the preferred way of loading RSS files.
Definition: loader.h:258
void loadingComplete(Loader *loader, Document doc, Status status)
This signal gets emitted when the loading process triggered by calling loadFrom() finished.
Implements a data retriever which executes a program and stores returned by the program on stdout.
Definition: loader.h:163
virtual ~OutputRetriever()
Destructor.
Definition: loader.cpp:195
virtual void retrieveData(const KURL &url)
Executes the program referenced by the given URL and retrieves the data which the program prints to s...
Definition: loader.cpp:200
OutputRetriever()
Default constructor.
Definition: loader.cpp:190
virtual int errorCode() const
Definition: loader.cpp:218