1/* This file is part of the KDE project
2 *
3 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
4 * 1999-2001 Lars Knoll <knoll@kde.org>
5 * 1999-2001 Antti Koivisto <koivisto@kde.org>
6 * 2000-2001 Simon Hausmann <hausmann@kde.org>
7 * 2000-2001 Dirk Mueller <mueller@kde.org>
8 * 2000 Stefan Schimanski <1Stein@gmx.de>
9 * 2001-2003 George Staikos <staikos@kde.org>
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details.
20 *
21 * You should have received a copy of the GNU Library General Public License
22 * along with this library; see the file COPYING.LIB. If not, write to
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301, USA.
25 */
26#if !defined khtml_wallet_p_h && !defined KHTML_NO_WALLET
27#define khtml_wallet_p_h
28
29#include <kcursor.h>
30#include <kxmlguifactory.h>
31#include <kaction.h>
32#include <kparts/partmanager.h>
33#include <kparts/statusbarextension.h>
34#include <kparts/browserextension.h>
35#include <kwallet.h>
36
37#include <QtCore/QPointer>
38#include <QtCore/QMap>
39#include <QtCore/QTimer>
40
41class KHTMLWalletQueue : public QObject
42{
43 Q_OBJECT
44 public:
45 KHTMLWalletQueue(QObject *parent) : QObject(parent) {
46 wallet = 0L;
47 }
48
49 virtual ~KHTMLWalletQueue() {
50 delete wallet;
51 wallet = 0L;
52 }
53
54 KWallet::Wallet *wallet;
55 typedef QPair<DOM::HTMLFormElementImpl*, QPointer<DOM::DocumentImpl> > Caller;
56 typedef QList<Caller> CallerList;
57 CallerList callers;
58 QList<QPair<QString, QMap<QString, QString> > > savers;
59
60 Q_SIGNALS:
61 void walletOpened(KWallet::Wallet*);
62
63 public Q_SLOTS:
64 void walletOpened(bool success) {
65 if (!success) {
66 delete wallet;
67 wallet = 0L;
68 }
69 emit walletOpened(wallet);
70 if (wallet) {
71 if (!wallet->hasFolder(KWallet::Wallet::FormDataFolder())) {
72 wallet->createFolder(KWallet::Wallet::FormDataFolder());
73 }
74 for (CallerList::Iterator i = callers.begin(); i != callers.end(); ++i) {
75 if ((*i).first && (*i).second) {
76 (*i).first->walletOpened(wallet);
77 }
78 }
79 wallet->setFolder(KWallet::Wallet::FormDataFolder());
80 for (QList<QPair<QString, QMap<QString, QString> > >::Iterator i = savers.begin(); i != savers.end(); ++i) {
81 wallet->writeMap((*i).first, (*i).second);
82 }
83 }
84 callers.clear();
85 savers.clear();
86 wallet = 0L; // gave it away
87 }
88};
89
90#endif
91