File indexing completed on 2023-05-30 09:09:56
0001 /* This file is part of the KDE project 0002 * 0003 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 0004 * 1999-2001 Lars Knoll <knoll@kde.org> 0005 * 1999-2001 Antti Koivisto <koivisto@kde.org> 0006 * 2000-2001 Simon Hausmann <hausmann@kde.org> 0007 * 2000-2001 Dirk Mueller <mueller@kde.org> 0008 * 2000 Stefan Schimanski <1Stein@gmx.de> 0009 * 2001-2003 George Staikos <staikos@kde.org> 0010 * 0011 * This library is free software; you can redistribute it and/or 0012 * modify it under the terms of the GNU Library General Public 0013 * License as published by the Free Software Foundation; either 0014 * version 2 of the License, or (at your option) any later version. 0015 * 0016 * This library is distributed in the hope that it will be useful, 0017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0019 * Library General Public License for more details. 0020 * 0021 * You should have received a copy of the GNU Library General Public License 0022 * along with this library; see the file COPYING.LIB. If not, write to 0023 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0024 * Boston, MA 02110-1301, USA. 0025 */ 0026 #if !defined khtml_wallet_p_h && !defined KHTML_NO_WALLET 0027 #define khtml_wallet_p_h 0028 0029 #include <kcursor.h> 0030 #include <kxmlguifactory.h> 0031 #include <kparts/partmanager.h> 0032 #include <kparts/statusbarextension.h> 0033 #include <kparts/browserextension.h> 0034 #include <kwallet.h> 0035 0036 #include <QPointer> 0037 #include <QMap> 0038 #include <QTimer> 0039 0040 class KHTMLWalletQueue : public QObject 0041 { 0042 Q_OBJECT 0043 public: 0044 KHTMLWalletQueue(QObject *parent) : QObject(parent) 0045 { 0046 wallet = nullptr; 0047 } 0048 0049 virtual ~KHTMLWalletQueue() 0050 { 0051 delete wallet; 0052 wallet = nullptr; 0053 } 0054 0055 KWallet::Wallet *wallet; 0056 typedef QPair<DOM::HTMLFormElementImpl *, QPointer<DOM::DocumentImpl> > Caller; 0057 typedef QList<Caller> CallerList; 0058 CallerList callers; 0059 QList<QPair<QString, QMap<QString, QString> > > savers; 0060 0061 Q_SIGNALS: 0062 void walletOpened(KWallet::Wallet *); 0063 0064 public Q_SLOTS: 0065 void walletOpened(bool success) 0066 { 0067 if (!success) { 0068 delete wallet; 0069 wallet = nullptr; 0070 } 0071 emit walletOpened(wallet); 0072 if (wallet) { 0073 if (!wallet->hasFolder(KWallet::Wallet::FormDataFolder())) { 0074 wallet->createFolder(KWallet::Wallet::FormDataFolder()); 0075 } 0076 for (CallerList::Iterator i = callers.begin(); i != callers.end(); ++i) { 0077 if ((*i).first && (*i).second) { 0078 (*i).first->walletOpened(wallet); 0079 } 0080 } 0081 wallet->setFolder(KWallet::Wallet::FormDataFolder()); 0082 for (QList<QPair<QString, QMap<QString, QString> > >::Iterator i = savers.begin(); i != savers.end(); ++i) { 0083 wallet->writeMap((*i).first, (*i).second); 0084 } 0085 } 0086 callers.clear(); 0087 savers.clear(); 0088 wallet = nullptr; // gave it away 0089 } 0090 }; 0091 0092 #endif