1 // -*- indent-tabs-mode: t; tab-width: 4; c-basic-offset: 4; -*-
3 This file is part of the KDE libraries
5 Copyright (c) 2008 Michael Leupold <lemma@confuego.org>
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
24 #include <QTextStream>
28 #include <KApplication>
29 #include <KCmdLineArgs>
30 #include <KWallet/Wallet>
32 #include "kwalletmany.h"
36 using namespace KWallet
;
38 static QTextStream
_out(stdout
, QIODevice::WriteOnly
);
40 KWalletMany::KWalletMany() : QObject(), _pending(10)
44 KWalletMany::~KWalletMany()
48 void KWalletMany::walletOpened(bool open
)
50 _out
<< "Got async wallet: " << (open
) << endl
;
57 void KWalletMany::quit()
60 _out
<< "Success!" << endl
;
62 _out
<< "Failed: " << _pending
<< " requests were not handled!" << endl
;
67 void KWalletMany::openWallet()
71 // open plenty of wallets in synchronous and asynchronous mode
72 for (int i
= 0; i
< NUMWALLETS
; ++i
) {
73 // request asynchronous wallet
74 _out
<< "About to ask for wallet async" << endl
;
76 wallet
= Wallet::openWallet(Wallet::NetworkWallet(), 0, Wallet::Asynchronous
);
77 connect(wallet
, SIGNAL(walletOpened(bool)), SLOT(walletOpened(bool)));
78 _wallets
.append(wallet
);
80 QTimer::singleShot(500, &waitLoop
, SLOT(quit()));
85 while (!_wallets
.isEmpty()) {
86 delete _wallets
.takeFirst();
90 int main(int argc
, char *argv
[])
92 KAboutData
aboutData("kwalletmany", 0, ki18n("kwalletmany"), "version");
93 KCmdLineArgs::init(argc
, argv
, &aboutData
);
97 QTimer::singleShot(0, &m
, SLOT(openWallet()));
98 QTimer::singleShot(30000, &m
, SLOT(quit()));
103 #include "kwalletmany.moc"