akregator/src/librss

#include <loader.h>

Inherits TQObject.

Signals

void loadingComplete (Loader *loader, Document doc, Status status)
 

Public Member Functions

void loadFrom (const KURL &url, DataRetriever *retriever)
 
int errorCode () const
 
const KURL & discoveredFeedURL () const
 
void abort ()
 

Static Public Member Functions

static Loadercreate ()
 
static Loadercreate (TQObject *object, const char *slot)
 

Friends

class someClassWhichDoesNotExist
 

Detailed Description

This class is the preferred way of loading RSS files.

Usage is very straightforward:

Loader *loader = Loader::create();
connect(loader, TQ_SIGNAL(loadingComplete(Loader *, Document, Status)),
this, TQ_SLOT(slotLoadingComplete(Loader *, Document, Status)));
loader->loadFrom("http://www.blah.org/foobar.rdf", new FileRetriever);
void loadingComplete(Loader *loader, Document doc, Status status)
This signal gets emitted when the loading process triggered by calling loadFrom() finished.
static Loader * create()
Constructs a Loader instance.
Definition: loader.cpp:263

This creates a Loader object, connects it's loadingComplete() signal to your custom slot and then makes it load the file 'http://www.blah.org/foobar.rdf' using the FileRetriever. You could've done something like this as well:

// create the Loader, connect it's signal...
loader->loadFrom("/home/myself/some-script.py", new OutputRetriever);

That'd make the Loader use another algorithm for retrieving the RSS data; 'OutputRetriever' will make it execute the script '/home/myself/some-script.py' and assume whatever that script prints to stdout is RSS markup. This is e.g. handy for conversion scripts, which download an HTML file and convert it's contents into RSS markup.

No matter what kind of retrieval algorithm you employ, your 'slotLoadingComplete' method might look like this:

void MyClass::slotLoadingComplete(Loader *loader, Document doc, Status status)
{
// Note that Loader::~Loader() is private, so you cannot delete Loader instances.
// You don't need to do that anyway since Loader instances delete themselves.
if (status != RSS::Success)
return;
TQString title = doc.title();
// do whatever you want with the information.
}
Note
You have to create a copy of the passed Document instance in case you want/need to use it after the slot attached to the loadingComplete signal goes out of scope. This is e.g. the case if you intend to call getPixmap() on Document::image()!

Definition at line 257 of file loader.h.

Member Function Documentation

◆ create() [1/2]

Loader * Loader::create ( )
static

Constructs a Loader instance.

This is pretty much what the default constructor would do, except that it ensures that all Loader instances have been allocated on the heap (this is required so that Loader's can delete themselves safely after they emitted the loadingComplete() signal.).

Returns
A pointer to a new Loader instance.

Definition at line 263 of file loader.cpp.

◆ create() [2/2]

Loader * Loader::create ( TQObject *  object,
const char *  slot 
)
static

Convenience method.

Does the same as the above method except that it also does the job of connecting the loadingComplete() signal to the given slot for you.

Parameters
objectA TQObject which features the specified slot
slotWhich slot to connect to.

Definition at line 268 of file loader.cpp.

◆ errorCode()

int Loader::errorCode ( ) const

Retrieves the error code of the last loading process (if any), as reported by the employed data retrever.

Definition at line 299 of file loader.cpp.

◆ loadFrom()

void Loader::loadFrom ( const KURL &  url,
DataRetriever retriever 
)

Loads the RSS file referenced by the given URL using the specified retrieval algorithm.

Make sure that you connected to the loadingComplete() signal before calling this method so that you're guaranteed to get notified when the loading finished.

Note
A Loader object cannot load from multiple URLs simultaneously; consequently, subsequent calls to loadFrom will be discarded silently, only the first loadFrom request will be executed.
Parameters
urlAn URL referencing the input file.
retrieverA subclass of DataRetriever which implements a specialized retrieval behaviour. Note that the ownership of the retriever is transferred to the Loader, i.e. the Loader will delete it when it doesn't need it anymore.
See also
DataRetriever, Loader::loadingComplete()

Definition at line 285 of file loader.cpp.

◆ loadingComplete

void RSS::Loader::loadingComplete ( Loader loader,
Document  doc,
Status  status 
)
signal

This signal gets emitted when the loading process triggered by calling loadFrom() finished.

Parameters
loaderA pointer pointing to the loader object which emitted this signal; this is handy in case you connect multiple loaders to a single slot.
docIn case status is Success, this parameter holds the parsed RSS file. In case it's RetrieveError, you should query loader->errorCode() for the actual error code. Note that you have to create a copy of the passed Document instance in case you want/need to use it after the slot attached to the loadingComplete signal goes out of scope. This is e.g. the case if you intend to call getPixmap() on Document::image()!
statusA status byte telling whether there were any problems while retrieving or parsing the data.
See also
Document, Status

The documentation for this class was generated from the following files: