diff options
| author | Michele Calgaro <michele.calgaro@yahoo.it> | 2025-03-02 18:37:22 +0900 |
|---|---|---|
| committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2025-03-06 12:43:06 +0900 |
| commit | bb099158e6c9fd0f1c2771cb9350d3b0a0b51a27 (patch) | |
| tree | 598156ab1f71ee857c8e1f233f0292e13f36fa28 /src/plugins/rssfeed/rss/testlibrss.cpp | |
| parent | 7271fa27ac1881beb5326ca8c9c83471695d8487 (diff) | |
| download | ktorrent-bb099158.tar.gz ktorrent-bb099158.zip | |
Restructure source files into 'src' subfolder
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
(cherry picked from commit 44ef0bd5fe47a43e47aec5f7981b6c1d728dd9a8)
Diffstat (limited to 'src/plugins/rssfeed/rss/testlibrss.cpp')
| -rw-r--r-- | src/plugins/rssfeed/rss/testlibrss.cpp | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/plugins/rssfeed/rss/testlibrss.cpp b/src/plugins/rssfeed/rss/testlibrss.cpp new file mode 100644 index 0000000..4515cf7 --- /dev/null +++ b/src/plugins/rssfeed/rss/testlibrss.cpp @@ -0,0 +1,75 @@ +#include "testlibrss.h" + +#include "image.h" + +#include <tdeaboutdata.h> +#include <tdecmdlineargs.h> +#include <tdeapplication.h> +#include <kdebug.h> + +using namespace RSS; + +static const TDECmdLineOptions options[] = +{ + { "+url", I18N_NOOP("URL of feed"), 0 }, + TDECmdLineLastOption +}; + + +void Tester::test( const TQString &url ) +{ + Loader *loader = Loader::create(); + connect( loader, TQ_SIGNAL( loadingComplete( Loader *, Document, Status ) ), + this, TQ_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" |
