summaryrefslogtreecommitdiffstats
path: root/kopete/libkopete/tests/kopetewallettest_program.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
commitbcb704366cb5e333a626c18c308c7e0448a8e69f (patch)
treef0d6ab7d78ecdd9207cf46536376b44b91a1ca71 /kopete/libkopete/tests/kopetewallettest_program.cpp
downloadtdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.tar.gz
tdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.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/kdenetwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kopete/libkopete/tests/kopetewallettest_program.cpp')
-rw-r--r--kopete/libkopete/tests/kopetewallettest_program.cpp98
1 files changed, 98 insertions, 0 deletions
diff --git a/kopete/libkopete/tests/kopetewallettest_program.cpp b/kopete/libkopete/tests/kopetewallettest_program.cpp
new file mode 100644
index 00000000..29de1edc
--- /dev/null
+++ b/kopete/libkopete/tests/kopetewallettest_program.cpp
@@ -0,0 +1,98 @@
+/*
+ Tests for the wallet manager
+
+ Copyright (c) 2003 by Richard Smith <kde@metafoo.co.uk>
+ Kopete (c) 2002-2003 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#include <qtextstream.h>
+#include <qtimer.h>
+
+#include <kaboutdata.h>
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+#include <kdebug.h>
+#include <kglobal.h>
+#include <kstandarddirs.h>
+#include <dcopclient.h>
+#include <kwallet.h>
+
+#include "kopetewalletmanager.h"
+#include "kopetewallettest_program.h"
+
+static QTextStream _out( stdout, IO_WriteOnly );
+
+void closeWallet()
+{
+ Kopete::WalletManager::self()->closeWallet();
+}
+
+void delay()
+{
+ QTimer::singleShot( 3000, qApp, SLOT( quit() ) );
+ qApp->exec();
+}
+
+void openWalletAsync()
+{
+ WalletReciever *r = new WalletReciever;
+ _out << "[ASYNC] About to open wallet, receiver: " << r << endl;
+ Kopete::WalletManager::self()->openWallet( r, SLOT( gotWallet( KWallet::Wallet* ) ) );
+}
+
+void WalletReciever::gotWallet( KWallet::Wallet *w )
+{
+ _out << "[ASYNC] Received wallet pointer: " << w << " for receiver: " << this << endl;
+}
+
+void WalletReciever::timer()
+{
+ _out << "Timer..." << endl;
+}
+
+int main( int argc, char *argv[] )
+{
+ KAboutData aboutData( "kopetewallettest", "kopetewallettest", "version" );
+ KCmdLineArgs::init( argc, argv, &aboutData );
+ KCmdLineOptions opts[] = { {"+action",0,0}, KCmdLineLastOption };
+ KCmdLineArgs::addCmdLineOptions( opts );
+ KApplication app( "kopetewallettest" );
+
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+
+ // must register with DCOP or async callbacks will fail
+ _out << "DCOP registration returned " << app.dcopClient()->registerAs(app.name()) << endl;
+
+ for( int i = 0; i < args->count(); ++i )
+ {
+ QString arg = args->arg( i );
+ _out << "Processing " << arg << endl;
+ if( arg == QString::fromLatin1( "open" ) ) openWalletAsync();
+ if( arg == QString::fromLatin1( "close" ) ) closeWallet();
+ if( arg == QString::fromLatin1( "delay" ) ) delay();
+ _out << "Done." << endl;
+ }
+
+ WalletReciever *r = new WalletReciever;
+
+ QTimer timer;
+ r->connect( &timer, SIGNAL( timeout() ), SLOT( timer() ) );
+ timer.start( 1000 );
+
+ _out << "About to start 30 second event loop" << endl;
+ QTimer::singleShot( 30000, qApp, SLOT( quit() ) );
+ return qApp->exec();
+}
+
+#include "kopetewallettest_program.moc"
+
+// vim: set noet ts=4 sts=4 sw=4: