add more spacing
[personal-kdebase.git] / runtime / kwalletd / tests / kwalletasync.cpp
blob9e794135135f4c349ca1f50fa3ae68db8656d243
1 #include <QtCore/QTextStream>
2 #include <QtGui/QApplication>
3 #include <QtCore/QTimer>
5 #include <kaboutdata.h>
6 #include <kcomponentdata.h>
7 #include <kcmdlineargs.h>
8 #include <kdebug.h>
9 #include <kglobal.h>
10 #include <kstandarddirs.h>
11 #include <kwallet.h>
12 #include <QtDBus/QDBusConnectionInterface>
13 #include <QtDBus/QDBusConnection>
14 #include <QtDBus/QDBusReply>
16 #include "kwallettest.h"
18 static QTextStream _out( stdout, QIODevice::WriteOnly );
20 void openWallet()
22 _out << "About to ask for wallet async" << endl;
24 // we have no wallet: ask for one.
25 KWallet::Wallet *wallet = KWallet::Wallet::openWallet( KWallet::Wallet::NetworkWallet(), 0, KWallet::Wallet::Asynchronous );
27 WalletReceiver r;
28 r.connect( wallet, SIGNAL( walletOpened(bool) ), SLOT( walletOpened(bool) ) );
30 _out << "About to start 30 second event loop" << endl;
32 QTimer::singleShot( 30000, qApp, SLOT( quit() ) );
33 int ret = qApp->exec();
35 if ( ret == 0 )
36 _out << "Timed out!" << endl;
37 else
38 _out << "Success!" << endl;
41 void WalletReceiver::walletOpened( bool got )
43 _out << "Got async wallet: " << got << endl;
44 qApp->exit( 1 );
47 int main( int argc, char *argv[] )
49 KAboutData aboutData("kwalletasync", 0, ki18n("kwalletasync"), "version");
50 KComponentData componentData(&aboutData);
51 QApplication app( argc, argv );
53 // force name with D-BUS
54 QDBusReply<QDBusConnectionInterface::RegisterServiceReply> reply
55 = QDBusConnection::sessionBus().interface()->registerService( "org.kde.kwalletasync",
56 QDBusConnectionInterface::ReplaceExistingService );
58 if ( !reply.isValid() )
60 _out << "D-BUS name request returned " << reply.error().name() << endl;
63 openWallet();
65 return 0;
68 // vim: set noet ts=4 sts=4 sw=4: