You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ktorrent/plugins/rssfeed/rss/testlibrss.cpp

76 lines
1.9 KiB

#include "testlibrss.h"
#include "image.h"
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kapplication.h>
#include <kdebug.h>
using namespace RSS;
static const KCmdLineOptions options[] =
{
{ "+url", I18N_NOOP("URL of feed"), 0 },
KCmdLineLastOption
};
void Tester::test( const TQString &url )
{
Loader *loader = Loader::create();
connect( loader, TQT_SIGNAL( loadingComplete( Loader *, Document, Status ) ),
this, TQT_SLOT( slotLoadingComplete( Loader *, Document, Status ) ) );
loader->loadFrom( url, new FileRetriever );
}
void Tester::slotLoadingComplete( Loader *loader, Document doc, Status status )
{
if ( status == Success )
{
kdDebug() << "Successfully retrieved '" << doc.title() << "'" << endl;
kdDebug() << doc.description() << endl;
if ( doc.image() ) {
kdDebug() << "Image: ";
kdDebug() << " Title: " << doc.image()->title() << endl;
kdDebug() << " URL: " << doc.image()->url() << endl;
kdDebug() << " Link: " << doc.image()->link() << endl;
}
kdDebug() << "Articles:" << endl;
Article::List list = doc.articles();
Article::List::ConstIterator it;
Article::List::ConstIterator en=list.end();
for (it = list.begin(); it != en; ++it)
{
kdDebug() << "\tTitle: " << (*it).title() << endl;
kdDebug() << "\tText: " << (*it).description() << endl;
}
}
if ( status != Success )
kdDebug() << "ERROR " << loader->errorCode() << endl;
kapp->quit();
}
int main( int argc, char **argv )
{
TDEAboutData aboutData( "testlibrss", "testlibrss", "0.1" );
TDECmdLineArgs::init( argc, argv, &aboutData );
TDECmdLineArgs::addCmdLineOptions( options );
TDEApplication app;
TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
if ( args->count() != 1 ) args->usage();
Tester tester;
tester.test( args->arg( 0 ) );
return app.exec();
}
#include "testlibrss.moc"