1 #include <QtCore/QTextStream>
2 #include <QtGui/QApplication>
3 #include <QtCore/QTimer>
5 #include <kaboutdata.h>
6 #include <kcomponentdata.h>
7 #include <kcmdlineargs.h>
10 #include <kstandarddirs.h>
12 #include <QtDBus/QDBusConnectionInterface>
13 #include <QtDBus/QDBusConnection>
14 #include <QtDBus/QDBusReply>
16 #include "kwallettest.h"
18 static QTextStream
_out( stdout
, QIODevice::WriteOnly
);
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
);
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();
36 _out
<< "Timed out!" << endl
;
38 _out
<< "Success!" << endl
;
41 void WalletReceiver::walletOpened( bool got
)
43 _out
<< "Got async wallet: " << got
<< endl
;
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
;
68 // vim: set noet ts=4 sts=4 sw=4: