1 #include <QtCore/QTextStream>
2 #include <QtCore/QTimer>
4 #include <QtGui/QApplication>
6 #include <kaboutdata.h>
7 #include <kcomponentdata.h>
8 #include <kcmdlineargs.h>
11 #include <kstandarddirs.h>
13 #include <QtDBus/QDBusConnectionInterface>
14 #include <QtDBus/QDBusConnection>
15 #include <QtDBus/QDBusReply>
17 #include "kwallettest.h"
19 static QTextStream
_out( stdout
, QIODevice::WriteOnly
);
23 _out
<< "About to ask for wallet async" << endl
;
25 // we have no wallet: ask for one.
26 KWallet::Wallet
*wallet
= KWallet::Wallet::openWallet( KWallet::Wallet::NetworkWallet(), 0, KWallet::Wallet::Asynchronous
);
29 r
.connect( wallet
, SIGNAL( walletOpened(bool) ), SLOT( walletOpened(bool) ) );
31 _out
<< "About to ask for wallet sync" << endl
;
33 wallet
= KWallet::Wallet::openWallet( KWallet::Wallet::NetworkWallet(), 0, KWallet::Wallet::Synchronous
);
35 _out
<< "Got sync wallet: " << (wallet
!= 0) << endl
;
36 _out
<< "About to start 30 second event loop" << endl
;
38 QTimer::singleShot( 30000, qApp
, SLOT( quit() ) );
39 int ret
= qApp
->exec();
43 _out
<< "Timed out!" << endl
;
45 _out
<< "Success!" << endl
;
47 QMap
<QString
,QString
> p
;
48 ret
= wallet
->readPasswordList("*", p
);
49 _out
<< "readPasswordList returned: " << ret
<< endl
;
50 _out
<< "readPasswordList returned " << p
.keys().count() << " entries" << endl
;
51 QMap
<QString
, QMap
<QString
, QString
> > q
;
52 ret
= wallet
->readMapList("*", q
);
53 _out
<< "readMapList returned: " << ret
<< endl
;
54 _out
<< "readMapList returned " << q
.keys().count() << " entries" << endl
;
56 QMap
<QString
, QByteArray
> s
;
57 ret
= wallet
->readEntryList("*", s
);
58 _out
<< "readEntryList returned: " << ret
<< endl
;
59 _out
<< "readEntryList returned " << s
.keys().count() << " entries" << endl
;
64 void WalletReceiver::walletOpened( bool got
)
66 _out
<< "Got async wallet: " << got
<< endl
;
70 int main( int argc
, char *argv
[] )
72 KAboutData
aboutData("kwalletboth", 0, ki18n("kwalletboth"), "version");
73 KComponentData
componentData(&aboutData
);
74 QApplication
app( argc
, argv
);
76 // force name with D-BUS
77 QDBusReply
<QDBusConnectionInterface::RegisterServiceReply
> reply
78 = QDBusConnection::sessionBus().interface()->registerService( "org.kde.kwalletboth",
79 QDBusConnectionInterface::ReplaceExistingService
);
81 if ( !reply
.isValid() )
83 _out
<< "D-BUS name request returned " << reply
.error().name() << endl
;
91 // vim: set noet ts=4 sts=4 sw=4: