summaryrefslogtreecommitdiffstats
path: root/plugins/rssfeed/rss/testlibrss.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 02:37:40 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 02:37:40 +0000
commit9ad5c7b5e23b4940e7a3ea3ca3a6fb77e6a8fab0 (patch)
treed088b5210e77d9fa91d954d8550e00e372b47378 /plugins/rssfeed/rss/testlibrss.cpp
downloadktorrent-9ad5c7b5e23b4940e7a3ea3ca3a6fb77e6a8fab0.tar.gz
ktorrent-9ad5c7b5e23b4940e7a3ea3ca3a6fb77e6a8fab0.zip
Updated to final KDE3 ktorrent release (2.2.6)
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/ktorrent@1077377 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'plugins/rssfeed/rss/testlibrss.cpp')
-rw-r--r--plugins/rssfeed/rss/testlibrss.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/plugins/rssfeed/rss/testlibrss.cpp b/plugins/rssfeed/rss/testlibrss.cpp
new file mode 100644
index 0000000..5d98bba
--- /dev/null
+++ b/plugins/rssfeed/rss/testlibrss.cpp
@@ -0,0 +1,75 @@
+#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 QString &url )
+{
+ Loader *loader = Loader::create();
+ connect( loader, SIGNAL( loadingComplete( Loader *, Document, Status ) ),
+ this, 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 )
+{
+ KAboutData aboutData( "testlibrss", "testlibrss", "0.1" );
+ KCmdLineArgs::init( argc, argv, &aboutData );
+ KCmdLineArgs::addCmdLineOptions( options );
+ KApplication app;
+
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+ if ( args->count() != 1 ) args->usage();
+
+ Tester tester;
+ tester.test( args->arg( 0 ) );
+
+ return app.exec();
+}
+
+#include "testlibrss.moc"