summaryrefslogtreecommitdiffstats
path: root/akregator/src/librss/testlibrss.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch)
tree67208f7c145782a7e90b123b982ca78d88cc2c87 /akregator/src/librss/testlibrss.cpp
downloadtdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz
tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'akregator/src/librss/testlibrss.cpp')
-rw-r--r--akregator/src/librss/testlibrss.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/akregator/src/librss/testlibrss.cpp b/akregator/src/librss/testlibrss.cpp
new file mode 100644
index 000000000..5d98bba46
--- /dev/null
+++ b/akregator/src/librss/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"