summaryrefslogtreecommitdiffstats
path: root/kwallet
diff options
context:
space:
mode:
Diffstat (limited to 'kwallet')
-rw-r--r--kwallet/Makefile.am26
-rw-r--r--kwallet/TODO13
-rw-r--r--kwallet/allyourbase.cpp733
-rw-r--r--kwallet/allyourbase.h178
-rw-r--r--kwallet/hi128-app-kwalletmanager.pngbin0 -> 24094 bytes
-rw-r--r--kwallet/hi128-app-kwalletmanager2.pngbin0 -> 28434 bytes
-rw-r--r--kwallet/hi16-app-kwalletmanager.pngbin0 -> 1209 bytes
-rw-r--r--kwallet/hi16-app-kwalletmanager2.pngbin0 -> 1139 bytes
-rw-r--r--kwallet/hi22-app-kwalletmanager.pngbin0 -> 1601 bytes
-rw-r--r--kwallet/hi32-app-kwalletmanager.pngbin0 -> 3273 bytes
-rw-r--r--kwallet/hi32-app-kwalletmanager2.pngbin0 -> 3225 bytes
-rw-r--r--kwallet/hi48-app-kwalletmanager.pngbin0 -> 6355 bytes
-rw-r--r--kwallet/hi48-app-kwalletmanager2.pngbin0 -> 6332 bytes
-rw-r--r--kwallet/hi64-app-kwalletmanager.pngbin0 -> 9728 bytes
-rw-r--r--kwallet/hi64-app-kwalletmanager2.pngbin0 -> 9702 bytes
-rw-r--r--kwallet/icons/Makefile.am5
-rw-r--r--kwallet/icons/cr22-action-folder_closed.pngbin0 -> 1149 bytes
-rw-r--r--kwallet/icons/cr22-action-folder_open.pngbin0 -> 1349 bytes
-rw-r--r--kwallet/icons/cr22-action-wallet_closed.pngbin0 -> 997 bytes
-rw-r--r--kwallet/icons/cr22-action-wallet_open.pngbin0 -> 1098 bytes
-rw-r--r--kwallet/kbetterthankdialogbase.ui154
-rw-r--r--kwallet/kbetterthankdialogbase.ui.h50
-rw-r--r--kwallet/konfigurator/Makefile.am15
-rw-r--r--kwallet/konfigurator/konfigurator.cpp323
-rw-r--r--kwallet/konfigurator/konfigurator.h57
-rw-r--r--kwallet/konfigurator/kwallet_config.desktop47
-rw-r--r--kwallet/konfigurator/kwalletconfig.desktop152
-rw-r--r--kwallet/konfigurator/kwalletmanager_show.desktop60
-rw-r--r--kwallet/konfigurator/walletconfigwidget.ui499
-rw-r--r--kwallet/kwalleteditor.cpp1143
-rw-r--r--kwallet/kwalleteditor.h110
-rw-r--r--kwallet/kwalleteditor.rc17
-rw-r--r--kwallet/kwalletmanager-kwalletd.desktop60
-rw-r--r--kwallet/kwalletmanager.cpp423
-rw-r--r--kwallet/kwalletmanager.desktop63
-rw-r--r--kwallet/kwalletmanager.h84
-rw-r--r--kwallet/kwalletmanager.rc14
-rw-r--r--kwallet/kwalletpopup.cpp110
-rw-r--r--kwallet/kwalletpopup.h54
-rw-r--r--kwallet/kwmapeditor.cpp187
-rw-r--r--kwallet/kwmapeditor.h61
-rw-r--r--kwallet/main.cpp100
-rw-r--r--kwallet/walletwidget.ui416
43 files changed, 5154 insertions, 0 deletions
diff --git a/kwallet/Makefile.am b/kwallet/Makefile.am
new file mode 100644
index 0000000..5c5fe28
--- /dev/null
+++ b/kwallet/Makefile.am
@@ -0,0 +1,26 @@
+INCLUDES= $(all_includes)
+
+SUBDIRS=. icons konfigurator
+
+bin_PROGRAMS = kwalletmanager
+kwalletmanager_SOURCES = walletwidget.ui kwalletmanager.cpp \
+ kwalletmanager.skel main.cpp kwalletpopup.cpp \
+ kwalleteditor.cpp kwmapeditor.cpp allyourbase.cpp \
+ kbetterthankdialogbase.ui
+kwalletmanager_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+kwalletmanager_LDADD = $(LIB_KIO) -lkwalletclient
+METASOURCES = AUTO
+noinst_HEADERS = kwalletmanager.h kwalletpopup.h walletwidget.h kwalleteditor.h\
+ allyourbase.h kwmapeditor.h
+
+xdg_apps_DATA = kwalletmanager.desktop kwalletmanager-kwalletd.desktop
+
+KDE_ICON = kwalletmanager
+
+rc_DATA = kwalletmanager.rc kwalleteditor.rc
+rcdir = $(kde_datadir)/kwalletmanager
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp -o $(podir)/kwalletmanager.pot
+
+kbetterthankdialogbase.lo: kbetterthankdialogbase.ui kbetterthankdialogbase.ui.h
diff --git a/kwallet/TODO b/kwallet/TODO
new file mode 100644
index 0000000..145fa7b
--- /dev/null
+++ b/kwallet/TODO
@@ -0,0 +1,13 @@
+Things left:
+
+Backend:
+- test 64 bit, zSeries
+- refactor the hashes to make it efficient
+
+Integration:
+- Cookie jar
+- KMail
+
+Future ideas:
+- Make it a kpart
+
diff --git a/kwallet/allyourbase.cpp b/kwallet/allyourbase.cpp
new file mode 100644
index 0000000..add178b
--- /dev/null
+++ b/kwallet/allyourbase.cpp
@@ -0,0 +1,733 @@
+/*
+ Copyright (C) 2003-2005 George Staikos <staikos@kde.org>
+ Copyright (C) 2005 Isaac Clerencia <isaac@warp.es>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "allyourbase.h"
+
+#include <kapplication.h>
+#include <kdebug.h>
+#include <kglobal.h>
+#include <kio/netaccess.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kstandarddirs.h>
+#include <kurl.h>
+#include <kurldrag.h>
+#include <kwallet.h>
+
+#include <qdragobject.h>
+#include <qfile.h>
+#include <qptrlist.h>
+
+/****************
+ * KWalletFolderItem - ListView items to represent kwallet folders
+ */
+KWalletFolderItem::KWalletFolderItem(KWallet::Wallet *w, QListView* parent, const QString &name, int entries)
+: KListViewItem(parent),_wallet(w),_name(name),_entries(entries) {
+ setText(0, QString("%1 (%2)").arg(_name).arg(_entries));
+ setRenameEnabled(0, false);
+ setDragEnabled(true);
+ setDropEnabled(true);
+
+ QPixmap pix = getFolderIcon(KIcon::Small);
+
+ setPixmap(0,pix);
+}
+
+QPixmap KWalletFolderItem::getFolderIcon(KIcon::Group group){
+ KIconLoader *loader = KGlobal::instance()->iconLoader();
+ QPixmap pix = loader->loadIcon( _name, group, 0,
+ KIcon::DefaultState, 0, true );
+ if (pix.isNull())
+ pix = loader->loadIcon( _name.lower(), group, 0,
+ KIcon::DefaultState, 0, true);
+ if (pix.isNull())
+ pix = loader->loadIcon( "folder_red", group, 0,
+ KIcon::DefaultState, 0, true);
+ return pix;
+}
+
+void KWalletFolderItem::refresh() {
+ QString saveFolder = _wallet->currentFolder();
+ _wallet->setFolder(_name);
+ setText(0, QString("%1 (%2)").arg(_name).arg(_wallet->entryList().count()));
+ _wallet->setFolder(saveFolder);
+}
+
+KWalletContainerItem* KWalletFolderItem::getContainer(KWallet::Wallet::EntryType type) {
+ for (QListViewItem *i = firstChild(); i; i = i->nextSibling()) {
+ KWalletContainerItem *ci = dynamic_cast<KWalletContainerItem *>(i);
+ if (!ci) {
+ continue;
+ }
+ if (ci->type() == type) {
+ return ci;
+ }
+ }
+ return 0;
+}
+
+bool KWalletFolderItem::contains(const QString& key) {
+ return (getItem(key) != 0);
+}
+
+QListViewItem* KWalletFolderItem::getItem(const QString& key) {
+ for (QListViewItem *i = firstChild(); i; i = i->nextSibling()) {
+ KWalletContainerItem *ci = dynamic_cast<KWalletContainerItem *>(i);
+ if (!ci) {
+ continue;
+ }
+ QListViewItem *tmp = ci->getItem(key);
+ if (tmp) {
+ return tmp;
+ }
+ }
+ return 0;
+}
+
+bool KWalletFolderItem::acceptDrop(const QMimeSource *mime) const {
+ return mime->provides("application/x-kwallet-entry") ||
+ mime->provides("text/uri-list");
+}
+
+int KWalletFolderItem::rtti() const {
+ return KWalletFolderItemClass;
+}
+
+QString KWalletFolderItem::name() const {
+ return _name;
+}
+
+KWalletFolderItem::~KWalletFolderItem() {
+}
+
+/****************
+ * KWalletContainerItem - ListView items to represent kwallet containers, i.e.
+ * passwords, maps, ...
+ */
+KWalletContainerItem::KWalletContainerItem(QListViewItem* parent, const QString &name, KWallet::Wallet::EntryType type)
+: KListViewItem(parent, name), _type(type) {
+ setRenameEnabled(0, false);
+ setDragEnabled(true);
+}
+
+KWalletContainerItem::~KWalletContainerItem() {
+}
+
+int KWalletContainerItem::rtti() const {
+ return KWalletContainerItemClass;
+}
+
+KWallet::Wallet::EntryType KWalletContainerItem::type() {
+ return _type;
+}
+
+bool KWalletContainerItem::contains(const QString& key) {
+ return getItem(key) != 0;
+}
+
+QListViewItem *KWalletContainerItem::getItem(const QString& key) {
+ for (QListViewItem *i = firstChild(); i; i = i->nextSibling()) {
+ if (i->text(0) == key) {
+ return i;
+ }
+ }
+ return 0;
+}
+
+/****************
+ * KWalletEntryItem - ListView items to represent kwallet entries
+ */
+KWalletEntryItem::KWalletEntryItem(KWallet::Wallet *w, QListViewItem* parent, const QString& ename)
+: KListViewItem(parent, ename), _wallet(w), _oldName(ename) {
+ setRenameEnabled(0, true);
+ setDragEnabled(true);
+}
+
+int KWalletEntryItem::rtti() const {
+ return KWalletEntryItemClass;
+}
+
+KWalletEntryItem::~KWalletEntryItem() {
+}
+
+/****************
+ * KWalletItem - IconView items to represent wallets
+ */
+KWalletItem::KWalletItem(QIconView *parent, const QString& walletName)
+: QIconViewItem(parent, walletName, DesktopIcon("kwalletmanager")) {
+}
+
+KWalletItem::~KWalletItem() {
+}
+
+bool KWalletItem::acceptDrop(const QMimeSource *mime) const {
+ return mime->provides("application/x-kwallet-folder") ||
+ mime->provides("text/uri-list");
+}
+
+static bool decodeEntry(KWallet::Wallet *_wallet, QDataStream& ds) {
+ Q_UINT32 magic;
+ ds >> magic;
+ if (magic != KWALLETENTRYMAGIC) {
+ kdDebug() << "bad magic" << endl;
+ return false;
+ }
+ QString name;
+ QByteArray value;
+ KWallet::Wallet::EntryType et;
+ ds >> name;
+ if (_wallet->hasEntry(name)) {
+ int rc = KMessageBox::warningContinueCancel(0L, i18n("An entry by the name '%1' already exists. Would you like to continue?").arg(name));
+ if (rc == KMessageBox::Cancel) {
+ return false;
+ }
+ }
+ long l;
+ ds >> l;
+ et = KWallet::Wallet::EntryType(l);
+ ds >> value;
+ _wallet->writeEntry(name, value, et);
+ return true;
+}
+
+static bool decodeFolder(KWallet::Wallet *_wallet, QDataStream& ds) {
+ Q_UINT32 magic;
+ ds >> magic;
+ if (magic != KWALLETFOLDERMAGIC) {
+ kdDebug() << "bad magic" << endl;
+ return false;
+ }
+ QString folder;
+ ds >> folder;
+ if (_wallet->hasFolder(folder)) {
+ int rc = KMessageBox::warningYesNoCancel(0L, i18n("A folder by the name '%1' already exists. What would you like to do?").arg(folder), QString::null, KStdGuiItem::cont(), i18n("Replace"));
+ if (rc == KMessageBox::Cancel) {
+ return false;
+ }
+ if (rc == KMessageBox::No) {
+ _wallet->removeFolder(folder);
+ _wallet->createFolder(folder);
+ }
+ } else {
+ _wallet->createFolder(folder);
+ }
+
+ _wallet->setFolder(folder);
+ while (!ds.atEnd()) {
+ QString name;
+ QByteArray value;
+ KWallet::Wallet::EntryType et;
+ ds >> name;
+ long l;
+ ds >> l;
+ et = KWallet::Wallet::EntryType(l);
+ ds >> value;
+ _wallet->writeEntry(name, value, et);
+ }
+ return true;
+}
+
+void KWalletItem::dropped(QDropEvent *e, const QValueList<QIconDragItem>& lst) {
+ Q_UNUSED(lst);
+ if (e->provides("application/x-kwallet-folder") ||
+ e->provides("text/uri-list")) {
+
+ // FIXME: don't allow the drop if the wallet name is the same
+
+ KWallet::Wallet *_wallet = KWallet::Wallet::openWallet(text());
+ if (!_wallet) {
+ e->ignore();
+ return;
+ }
+
+ QString saveFolder = _wallet->currentFolder();
+
+ QFile file;
+ QDataStream *ds = 0L;
+
+ if (e->provides("application/x-kwallet-folder")) {
+ QByteArray edata = e->encodedData("application/x-kwallet-folder");
+ if (!edata.isEmpty()) {
+ ds = new QDataStream(edata, IO_ReadOnly);
+ }
+ } else { // text/uri-list
+ QStrList urls;
+ QUriDrag::decode(e, urls);
+
+ if (urls.isEmpty()) {
+ e->ignore();
+ return;
+ }
+
+ KURL u(urls.first());
+ if (u.fileName().isEmpty()) {
+ e->ignore();
+ return;
+ }
+ QString tmpFile;
+ if (KIO::NetAccess::download(u, tmpFile, 0L)) {
+ file.setName(tmpFile);
+ file.open(IO_ReadOnly);
+ ds = new QDataStream(&file);
+ KIO::NetAccess::removeTempFile(tmpFile);
+ } else {
+ KMessageBox::error(iconView(), KIO::NetAccess::lastErrorString());
+ }
+ }
+ if (ds) {
+ decodeFolder(_wallet, *ds);
+ delete ds;
+ }
+ _wallet->setFolder(saveFolder);
+ delete _wallet;
+
+ //delete the folder from the source if we were moving
+ Qt::ButtonState state = kapp->keyboardMouseState();
+ if (e->source() && e->source()->parent() &&
+ !strcmp(e->source()->parent()->className(), "KWalletEntryList") &&
+ !(state & Qt::ControlButton)) {
+
+ KWalletEntryList *el =
+ dynamic_cast<KWalletEntryList*>(e->source()->parent());
+ if (el) {
+ KWalletFolderItem *fi =
+ dynamic_cast<KWalletFolderItem*>(el->selectedItem());
+ if (fi) {
+ el->_wallet->removeFolder(fi->name());
+ }
+ }
+ }
+ e->accept();
+ } else {
+ e->ignore();
+ return;
+ }
+}
+
+/****************
+ * KWalletEntryDrag - Stores data for wallet entry drags
+ */
+class KWalletEntryDrag : public QStoredDrag {
+ public:
+ KWalletEntryDrag(QWidget *dragSource, const char *name = 0L)
+ : QStoredDrag("application/x-kwallet-entry", dragSource, name) {
+ }
+
+ virtual ~KWalletEntryDrag() {}
+};
+
+/****************
+ * KWalletFolderDrag - Stores data for wallet folder drags
+ */
+class KWalletFolderDrag : public QStoredDrag {
+ public:
+ KWalletFolderDrag(QWidget *dragSource, const char *name = 0L)
+ : QStoredDrag("application/x-kwallet-folder", dragSource, name) {
+ }
+
+ virtual ~KWalletFolderDrag() {}
+};
+
+/****************
+ * KWalletEntryList - A listview to store wallet entries
+ */
+KWalletEntryList::KWalletEntryList(QWidget *parent, const char *name)
+: KListView(parent, name) {
+ addColumn(i18n("Folders"));
+ setRootIsDecorated(true);
+ setDefaultRenameAction(Reject);
+ setAcceptDrops(true);
+ setItemsMovable(false);
+ setDropVisualizer(false);
+ viewport()->setAcceptDrops(true);
+}
+
+KWalletEntryList::~KWalletEntryList() {
+}
+
+bool KWalletEntryList::acceptDrag(QDropEvent* e) const {
+ QListViewItem *i = itemAt(contentsToViewport(e->pos()));
+ if (i) {
+ if (e->provides("application/x-kwallet-entry") ||
+ e->provides("text/uri-list")) {
+ return true;
+ }
+ }
+ if ((e->provides("application/x-kwallet-folder") &&
+ e->source() != viewport()) ||
+ e->provides("text/uri-list")) {
+ return true;
+ }
+ return false;
+}
+
+//returns true if the item has been dropped successfully
+void KWalletEntryList::itemDropped(QDropEvent *e, QListViewItem *item) {
+ bool ok = true;
+ bool isEntry;
+ QFile file;
+ QDataStream *ds;
+
+ KWalletEntryList *el = 0L;
+ QListViewItem *sel = 0L;
+
+ //detect if we are dragging from kwallet itself
+ if (e->source() && e->source()->parent() &&
+ !strcmp(e->source()->parent()->className(), "KWalletEntryList")) {
+
+ el = dynamic_cast<KWalletEntryList*>(e->source()->parent());
+ if (!el) {
+ KMessageBox::error(this, i18n("An unexpected error occurred trying to drop the item"));
+ } else
+ sel = el->selectedItem();
+ }
+
+ if (e->provides("application/x-kwallet-entry")) {
+ //do nothing if we are in the same folder
+ if (sel && sel->parent()->parent() ==
+ KWalletEntryList::getItemFolder(item)) {
+ e->ignore();
+ return;
+ }
+ isEntry = true;
+ QByteArray data = e->encodedData("application/x-kwallet-entry");
+ if (data.isEmpty()) {
+ e->ignore();
+ return;
+ }
+ ds = new QDataStream(data, IO_ReadOnly);
+ } else if (e->provides("application/x-kwallet-folder")) {
+ //do nothing if we are in the same wallet
+ if (this == el) {
+ e->ignore();
+ return;
+ }
+ isEntry = false;
+ QByteArray data = e->encodedData("application/x-kwallet-folder");
+ if (data.isEmpty()) {
+ e->ignore();
+ return;
+ }
+ ds = new QDataStream(data, IO_ReadOnly);
+ } else if (e->provides("text/uri-list")) {
+ QStrList urls;
+ QUriDrag::decode(e, urls);
+ if (urls.isEmpty()) {
+ e->ignore();
+ return;
+ }
+ KURL u(urls.first());
+ if (u.fileName().isEmpty()) {
+ e->ignore();
+ return;
+ }
+ QString tmpFile;
+ if (KIO::NetAccess::download(u, tmpFile, 0L)) {
+ file.setName(tmpFile);
+ file.open(IO_ReadOnly);
+ ds = new QDataStream(&file);
+ //check magic to discover mime type
+ Q_UINT32 magic;
+ (*ds) >> magic;
+ if (magic == KWALLETENTRYMAGIC) {
+ isEntry = true;
+ } else if (magic == KWALLETFOLDERMAGIC) {
+ isEntry = false;
+ } else {
+ kdDebug() << "bad magic" << endl;
+ e->ignore();
+ return;
+ }
+ delete ds;
+ //set the file back to the beginning
+ file.reset();
+ ds = new QDataStream(&file);
+ KIO::NetAccess::removeTempFile(tmpFile);
+ } else {
+ KMessageBox::error(this, KIO::NetAccess::lastErrorString());
+ return;
+ }
+ } else {
+ e->ignore();
+ return;
+ }
+ Qt::ButtonState state = kapp->keyboardMouseState();
+ if (isEntry) {
+ if (!item) {
+ e->ignore();
+ return;
+ }
+ KWalletFolderItem *fi = KWalletEntryList::getItemFolder(item);
+ if (!fi) {
+ KMessageBox::error(this, i18n("An unexpected error occurred trying to drop the entry"));
+ delete(ds);
+ e->accept();
+ return;
+ }
+ QString saveFolder = _wallet->currentFolder();
+ _wallet->setFolder(fi->name());
+ ok = decodeEntry(_wallet, *ds);
+ _wallet->setFolder(saveFolder);
+ fi->refresh();
+ delete(ds);
+ //delete source if we were moving, i.e., we are dragging
+ //from kwalletmanager and Control is not pressed
+ if (ok && el && !(state & Qt::ControlButton) && sel) {
+ el->_wallet->removeEntry(sel->text(0));
+ delete sel;
+ }
+ e->accept();
+ } else {
+ ok = decodeFolder(_wallet, *ds);
+ delete ds;
+ //delete source if we were moving, i.e., we are dragging
+ //from kwalletmanager and Control is not pressed
+ if (ok && el && !(state & Qt::ControlButton) && sel) {
+ KWalletFolderItem *fi = dynamic_cast<KWalletFolderItem *>(sel);
+ if (fi) {
+ el->_wallet->removeFolder(fi->name());
+ delete sel;
+ } else {
+ KMessageBox::error(this, i18n("An unexpected error occurred trying to delete the original folder, but the folder has been copied successfully"));
+ }
+ }
+ e->accept();
+ }
+}
+
+void KWalletEntryList::setWallet(KWallet::Wallet *w) {
+ _wallet = w;
+}
+
+bool KWalletEntryList::existsFolder(const QString& name) {
+ for (QListViewItem *vi = firstChild(); vi; vi = vi->nextSibling()) {
+ KWalletFolderItem *fi = dynamic_cast<KWalletFolderItem *>(vi);
+ if (!fi) {
+ continue;
+ }
+ if (name == fi->name()) {
+ return true;
+ }
+ }
+ return false;
+}
+
+void KWalletEntryList::contentsDropEvent(QDropEvent *e) {
+ QListViewItem *i = itemAt(contentsToViewport(e->pos()));
+ itemDropped(e, i);
+}
+
+void KWalletEntryList::contentsDragEnterEvent(QDragEnterEvent *e) {
+ if (e->provides("application/x-kwallet-entry") ||
+ e->provides("application/x-kwallet-folder") ||
+ e->provides("application/uri-list")) {
+ e->accept();
+ } else {
+ e->ignore();
+ }
+}
+
+KWalletFolderItem* KWalletEntryList::getFolder(const QString& name) {
+ for (QListViewItem *vi = firstChild(); vi; vi = vi->nextSibling()) {
+ KWalletFolderItem *fi = dynamic_cast<KWalletFolderItem *>(vi);
+ if (!fi) {
+ continue;
+ }
+ if (name == fi->name()) {
+ return fi;
+ }
+ }
+ return 0;
+}
+
+KWalletFolderItem *KWalletEntryList::getItemFolder(QListViewItem *item) {
+ switch (item->rtti()) {
+ case KWalletFolderItemClass:
+ return dynamic_cast<KWalletFolderItem *>(item);
+ case KWalletContainerItemClass:
+ return dynamic_cast<KWalletFolderItem *>(item->parent());
+ case KWalletEntryItemClass:
+ return dynamic_cast<KWalletFolderItem *>(item->parent()->parent());
+ }
+ return 0;
+}
+
+/****************
+ * KWalletIconDrag - Stores the data for wallet drags
+ */
+class KWalletIconDrag : public QIconDrag {
+ public:
+ KWalletIconDrag(QWidget *dragSource, const char *name = 0L)
+ : QIconDrag(dragSource, name) {
+ }
+
+ virtual ~KWalletIconDrag() {}
+
+ virtual const char *format(int i = 0) const {
+ if (i == 0) {
+ return "application/x-qiconlist";
+ } else if (i == 1) {
+ return "text/uri-list";
+ }
+ return 0L;
+ }
+
+ QByteArray encodedData(const char *mime) const {
+ QByteArray a;
+ QCString mimetype(mime);
+ if (mimetype == "application/x-qiconlist") {
+ return QIconDrag::encodedData(mime);
+ } else if (mimetype == "text/uri-list") {
+ QCString s = _urls.join("\r\n").latin1();
+ if (_urls.count() > 0) {
+ s.append("\r\n");
+ }
+ a.resize(s.length() + 1);
+ memcpy(a.data(), s.data(), s.length() + 1);
+ }
+ return a;
+ }
+
+ void append(const QIconDragItem &item, const QRect &pr,
+ const QRect &tr, const QString &url) {
+ QIconDrag::append(item, pr, tr);
+ _urls.append(url);
+ }
+
+ private:
+ QStringList _urls;
+};
+
+/****************
+* * KWalletIconView - An iconview to store wallets
+* */
+KWalletIconView::KWalletIconView(QWidget *parent, const char *name)
+: KIconView(parent, name) {
+ KGlobal::dirs()->addResourceType("kwallet", "share/apps/kwallet");
+ connect(this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)), SLOT(slotDropped(QDropEvent*, const QValueList<QIconDragItem>&)));
+}
+
+KWalletIconView::~KWalletIconView() {
+}
+
+void KWalletIconView::slotDropped(QDropEvent *e, const QValueList<QIconDragItem>& /*lst*/) {
+ if (e->source() == viewport()) {
+ e->ignore();
+ return;
+ }
+
+ if (!e->provides("text/uri-list")) {
+ e->ignore();
+ return;
+ }
+
+ QByteArray edata = e->encodedData("text/uri-list");
+ QCString urls = edata.data();
+
+ QStringList ul = QStringList::split("\r\n", urls);
+ if (ul.isEmpty() || ul.first().isEmpty()) {
+ e->ignore();
+ return;
+ }
+
+ KURL u(ul.first());
+
+ if (u.fileName().isEmpty()) {
+ e->ignore();
+ return;
+ }
+
+ QString dest = KGlobal::dirs()->saveLocation("kwallet") + u.fileName();
+ if (QFile::exists(dest)) {
+ KMessageBox::sorry(viewport(), i18n("That wallet file already exists. You cannot overwrite wallets."));
+ e->ignore();
+ return;
+ }
+
+ // FIXME: verify that it is a real wallet file first
+ KIO::NetAccess::file_copy(u, KURL::fromPathOrURL(dest));
+ e->accept();
+}
+
+void KWalletIconView::contentsMousePressEvent(QMouseEvent *e) {
+ _mousePos = e->pos();
+ if (!findItem(_mousePos)) {
+ clearSelection();
+ }
+ KIconView::contentsMousePressEvent( e );
+}
+
+QDragObject *KWalletIconView::dragObject() {
+ KWalletIconDrag* id = new KWalletIconDrag(viewport(), "KWallet Drag");
+ QString path = "file:" + KGlobal::dirs()->saveLocation("kwallet");
+ QPoint pos = _mousePos;
+ for (QIconViewItem *item = firstItem(); item; item = item->nextItem()) {
+ if (item->isSelected()) {
+ QString url = path + item->text() + ".kwl";
+ QIconDragItem idi;
+ idi.setData(url.local8Bit());
+ id->append(idi,
+ QRect(item->pixmapRect(false).topLeft() - pos,
+ item->pixmapRect(false).size()),
+ QRect(item->textRect(false).topLeft() - pos,
+ item->textRect(false).size()),
+ url);
+ }
+ }
+
+ id->setPixmap(*currentItem()->pixmap(),
+ pos - currentItem()->pixmapRect(false).topLeft());
+
+ return id;
+}
+
+QDragObject *KWalletEntryList::dragObject() {
+ QListViewItem *i = currentItem();
+
+ QStoredDrag *sd = 0L;
+
+ if (i->rtti() == KWalletEntryItemClass) {
+ KWalletEntryItem *ei = dynamic_cast<KWalletEntryItem*>(i);
+ if (!ei) {
+ return 0L;
+ }
+ sd = new KWalletEntryDrag(viewport(), "KWallet Entry Drag");
+ QByteArray a;
+ QDataStream ds(a, IO_WriteOnly);
+ ds << KWALLETENTRYMAGIC;
+ ds << *ei;
+ sd->setEncodedData(a);
+ } else if (i->rtti() == KWalletFolderItemClass) {
+ KWalletFolderItem *fi = dynamic_cast<KWalletFolderItem*>(i);
+ if (!fi) {
+ return 0L;
+ }
+ sd = new KWalletFolderDrag(viewport(), "KWallet Folder Drag");
+ QByteArray a;
+ QDataStream ds(a, IO_WriteOnly);
+
+ ds << KWALLETFOLDERMAGIC;
+ ds << *fi;
+ sd->setEncodedData(a);
+ }
+ return sd;
+}
+
+#include "allyourbase.moc"
diff --git a/kwallet/allyourbase.h b/kwallet/allyourbase.h
new file mode 100644
index 0000000..7f5ae92
--- /dev/null
+++ b/kwallet/allyourbase.h
@@ -0,0 +1,178 @@
+/*
+ Copyright (C) 2003-2005 George Staikos <staikos@kde.org>
+ Copyright (C) 2005 Isaac Clerencia <isaac@warp.es>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef ALLYOURBASE_H
+#define ALLYOURBASE_H
+
+#include <kiconview.h>
+#include <klistview.h>
+#include <kwallet.h>
+#include <kiconloader.h>
+#include <kicontheme.h>
+
+#define KWALLETENTRYMAGIC ((Q_UINT32) 0x6B776C65)
+#define KWALLETFOLDERMAGIC ((Q_UINT32) 0x6B776C66)
+
+enum KWalletListItemClasses {
+ KWalletFolderItemClass = 1000,
+ KWalletContainerItemClass,
+ KWalletEntryItemClass,
+ KWalletUnknownClass = 2000
+};
+
+class KWalletEntryItem : public KListViewItem {
+ public:
+ KWalletEntryItem(KWallet::Wallet *w, QListViewItem* parent, const QString& ename);
+ virtual ~KWalletEntryItem();
+
+ const QString& oldName() { return _oldName; }
+ QString currentName() { return text(0); }
+
+ void clearOldName() { _oldName = text(0); }
+ virtual int rtti() const;
+
+ public:
+ KWallet::Wallet *_wallet;
+
+ private:
+ QString _oldName;
+};
+
+class KWalletContainerItem : public KListViewItem {
+ public:
+ KWalletContainerItem(QListViewItem* parent, const QString& name,
+ KWallet::Wallet::EntryType type);
+ virtual ~KWalletContainerItem();
+
+ public:
+ virtual int rtti() const;
+ KWallet::Wallet::EntryType type();
+ bool contains(const QString& itemKey);
+ QListViewItem* getItem(const QString& itemKey);
+
+ private:
+ KWallet::Wallet::EntryType _type;
+};
+
+class KWalletFolderItem : public KListViewItem {
+ public:
+ KWalletFolderItem(KWallet::Wallet *w, QListView* parent,
+ const QString& name, int entries);
+ virtual ~KWalletFolderItem();
+
+ virtual bool acceptDrop(const QMimeSource *mime) const;
+ virtual int rtti() const;
+
+ QString name() const;
+ void refresh();
+ KWalletContainerItem* getContainer(KWallet::Wallet::EntryType type);
+ QPixmap getFolderIcon(KIcon::Group group);
+ bool contains(const QString& itemKey);
+ QListViewItem* getItem(const QString& itemKey);
+
+ public:
+ KWallet::Wallet *_wallet;
+
+ private:
+ QString _name;
+ int _entries;
+};
+
+class KWalletEntryList : public KListView {
+ Q_OBJECT
+ public:
+ KWalletEntryList(QWidget *parent, const char *name = 0L);
+ virtual ~KWalletEntryList();
+
+ bool existsFolder(const QString& name);
+ KWalletFolderItem* getFolder(const QString& name);
+ void contentsDropEvent(QDropEvent *e);
+ void contentsDragEnterEvent(QDragEnterEvent *e);
+ void setWallet(KWallet::Wallet *w);
+
+ protected:
+ void itemDropped(QDropEvent *e, QListViewItem *item);
+ virtual QDragObject *dragObject();
+ virtual bool acceptDrag (QDropEvent* event) const;
+
+ private:
+ static KWalletFolderItem *getItemFolder(QListViewItem *item);
+
+ public:
+ KWallet::Wallet *_wallet;
+};
+
+class KWalletItem : public QIconViewItem {
+ public:
+ KWalletItem(QIconView *parent, const QString& walletName);
+ virtual ~KWalletItem();
+
+ virtual bool acceptDrop(const QMimeSource *mime) const;
+
+ protected:
+ virtual void dropped(QDropEvent *e, const QValueList<QIconDragItem>& lst);
+};
+
+
+class KWalletIconView : public KIconView {
+ Q_OBJECT
+ public:
+ KWalletIconView(QWidget *parent, const char *name = 0L);
+ virtual ~KWalletIconView();
+
+ protected slots:
+ virtual void slotDropped(QDropEvent *e, const QValueList<QIconDragItem>& lst);
+
+ protected:
+ virtual QDragObject *dragObject();
+ virtual void contentsMousePressEvent(QMouseEvent *e);
+ QPoint _mousePos;
+};
+
+
+inline QDataStream& operator<<(QDataStream& str, const KWalletEntryItem& w) {
+ QString name = w.text(0);
+ str << name;
+ KWallet::Wallet::EntryType et = w._wallet->entryType(name);
+ str << long(et);
+ QByteArray a;
+ w._wallet->readEntry(name, a);
+ str << a;
+ return str;
+}
+
+inline QDataStream& operator<<(QDataStream& str, const KWalletFolderItem& w) {
+ QString oldFolder = w._wallet->currentFolder();
+ str << w.name();
+ w._wallet->setFolder(w.name());
+ QStringList entries = w._wallet->entryList();
+ for (QStringList::Iterator it = entries.begin(); it != entries.end(); ++it) {
+ str << *it;
+ KWallet::Wallet::EntryType et = w._wallet->entryType(*it);
+ str << long(et);
+ QByteArray a;
+ w._wallet->readEntry(*it, a);
+ str << a;
+ }
+ w._wallet->setFolder(oldFolder);
+ return str;
+}
+
+#endif
diff --git a/kwallet/hi128-app-kwalletmanager.png b/kwallet/hi128-app-kwalletmanager.png
new file mode 100644
index 0000000..ccdd7c9
--- /dev/null
+++ b/kwallet/hi128-app-kwalletmanager.png
Binary files differ
diff --git a/kwallet/hi128-app-kwalletmanager2.png b/kwallet/hi128-app-kwalletmanager2.png
new file mode 100644
index 0000000..e3937db
--- /dev/null
+++ b/kwallet/hi128-app-kwalletmanager2.png
Binary files differ
diff --git a/kwallet/hi16-app-kwalletmanager.png b/kwallet/hi16-app-kwalletmanager.png
new file mode 100644
index 0000000..4f9f4fd
--- /dev/null
+++ b/kwallet/hi16-app-kwalletmanager.png
Binary files differ
diff --git a/kwallet/hi16-app-kwalletmanager2.png b/kwallet/hi16-app-kwalletmanager2.png
new file mode 100644
index 0000000..b2f9004
--- /dev/null
+++ b/kwallet/hi16-app-kwalletmanager2.png
Binary files differ
diff --git a/kwallet/hi22-app-kwalletmanager.png b/kwallet/hi22-app-kwalletmanager.png
new file mode 100644
index 0000000..8bc4cdb
--- /dev/null
+++ b/kwallet/hi22-app-kwalletmanager.png
Binary files differ
diff --git a/kwallet/hi32-app-kwalletmanager.png b/kwallet/hi32-app-kwalletmanager.png
new file mode 100644
index 0000000..69a7c1e
--- /dev/null
+++ b/kwallet/hi32-app-kwalletmanager.png
Binary files differ
diff --git a/kwallet/hi32-app-kwalletmanager2.png b/kwallet/hi32-app-kwalletmanager2.png
new file mode 100644
index 0000000..3cfc4e2
--- /dev/null
+++ b/kwallet/hi32-app-kwalletmanager2.png
Binary files differ
diff --git a/kwallet/hi48-app-kwalletmanager.png b/kwallet/hi48-app-kwalletmanager.png
new file mode 100644
index 0000000..5b46a87
--- /dev/null
+++ b/kwallet/hi48-app-kwalletmanager.png
Binary files differ
diff --git a/kwallet/hi48-app-kwalletmanager2.png b/kwallet/hi48-app-kwalletmanager2.png
new file mode 100644
index 0000000..3ae286d
--- /dev/null
+++ b/kwallet/hi48-app-kwalletmanager2.png
Binary files differ
diff --git a/kwallet/hi64-app-kwalletmanager.png b/kwallet/hi64-app-kwalletmanager.png
new file mode 100644
index 0000000..38a581c
--- /dev/null
+++ b/kwallet/hi64-app-kwalletmanager.png
Binary files differ
diff --git a/kwallet/hi64-app-kwalletmanager2.png b/kwallet/hi64-app-kwalletmanager2.png
new file mode 100644
index 0000000..2e5be4b
--- /dev/null
+++ b/kwallet/hi64-app-kwalletmanager2.png
Binary files differ
diff --git a/kwallet/icons/Makefile.am b/kwallet/icons/Makefile.am
new file mode 100644
index 0000000..8bad46c
--- /dev/null
+++ b/kwallet/icons/Makefile.am
@@ -0,0 +1,5 @@
+KDE_ICON = kwalletmanager
+
+pics_ICON = AUTO
+picsdir = $(kde_datadir)/kwalletmanager/icons
+
diff --git a/kwallet/icons/cr22-action-folder_closed.png b/kwallet/icons/cr22-action-folder_closed.png
new file mode 100644
index 0000000..e3ebad3
--- /dev/null
+++ b/kwallet/icons/cr22-action-folder_closed.png
Binary files differ
diff --git a/kwallet/icons/cr22-action-folder_open.png b/kwallet/icons/cr22-action-folder_open.png
new file mode 100644
index 0000000..ea175b7
--- /dev/null
+++ b/kwallet/icons/cr22-action-folder_open.png
Binary files differ
diff --git a/kwallet/icons/cr22-action-wallet_closed.png b/kwallet/icons/cr22-action-wallet_closed.png
new file mode 100644
index 0000000..57558ac
--- /dev/null
+++ b/kwallet/icons/cr22-action-wallet_closed.png
Binary files differ
diff --git a/kwallet/icons/cr22-action-wallet_open.png b/kwallet/icons/cr22-action-wallet_open.png
new file mode 100644
index 0000000..55a447f
--- /dev/null
+++ b/kwallet/icons/cr22-action-wallet_open.png
Binary files differ
diff --git a/kwallet/kbetterthankdialogbase.ui b/kwallet/kbetterthankdialogbase.ui
new file mode 100644
index 0000000..30d2d93
--- /dev/null
+++ b/kwallet/kbetterthankdialogbase.ui
@@ -0,0 +1,154 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>KBetterThanKDialogBase</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>KBetterThanKDialogBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>479</width>
+ <height>109</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string></string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="resizeMode">
+ <enum>Fixed</enum>
+ </property>
+ <widget class="KActiveLabel" row="0" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>_label</cstring>
+ </property>
+ </widget>
+ <spacer row="1" column="2">
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>41</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLayoutWidget" row="1" column="1">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>_allowOnce</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Replace</string>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>_allowAlways</cstring>
+ </property>
+ <property name="text">
+ <string>Replace &amp;All</string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>_deny</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Skip</string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>_denyForever</cstring>
+ </property>
+ <property name="text">
+ <string>Skip A&amp;ll</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>61</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+</widget>
+<customwidgets>
+</customwidgets>
+<connections>
+ <connection>
+ <sender>_allowOnce</sender>
+ <signal>clicked()</signal>
+ <receiver>KBetterThanKDialogBase</receiver>
+ <slot>clicked()</slot>
+ </connection>
+ <connection>
+ <sender>_allowAlways</sender>
+ <signal>clicked()</signal>
+ <receiver>KBetterThanKDialogBase</receiver>
+ <slot>clicked()</slot>
+ </connection>
+ <connection>
+ <sender>_deny</sender>
+ <signal>clicked()</signal>
+ <receiver>KBetterThanKDialogBase</receiver>
+ <slot>clicked()</slot>
+ </connection>
+ <connection>
+ <sender>_denyForever</sender>
+ <signal>clicked()</signal>
+ <receiver>KBetterThanKDialogBase</receiver>
+ <slot>clicked()</slot>
+ </connection>
+</connections>
+<includes>
+ <include location="global" impldecl="in declaration">kactivelabel.h</include>
+ <include location="local" impldecl="in implementation">kbetterthankdialogbase.ui.h</include>
+</includes>
+<slots>
+ <slot access="private">clicked()</slot>
+ <slot>setLabel( const QString &amp; label )</slot>
+ <slot access="private">init()</slot>
+ <slot access="protected">accept()</slot>
+ <slot access="protected">reject()</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kactivelabel.h</includehint>
+</includehints>
+</UI>
diff --git a/kwallet/kbetterthankdialogbase.ui.h b/kwallet/kbetterthankdialogbase.ui.h
new file mode 100644
index 0000000..3937746
--- /dev/null
+++ b/kwallet/kbetterthankdialogbase.ui.h
@@ -0,0 +1,50 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you want to add, delete, or rename functions or slots, use
+** Qt Designer to update this file, preserving your code.
+**
+** You should not define a constructor or destructor in this file.
+** Instead, write your code in functions called init() and destroy().
+** These will automatically be called by the form's constructor and
+** destructor.
+*****************************************************************************/
+
+
+void KBetterThanKDialogBase::clicked()
+{
+ if (sender() == _allowOnce) {
+ done(3);
+ } else if (sender() == _allowAlways) {
+ done(1);
+ } else if (sender() == _deny) {
+ done(4);
+ } else if (sender() == _denyForever) {
+ done(2);
+ }
+}
+
+
+void KBetterThanKDialogBase::setLabel( const QString & label )
+{
+ _label->setText(label);
+}
+
+
+void KBetterThanKDialogBase::init()
+{
+ _allowOnce->setFocus();
+}
+
+
+void KBetterThanKDialogBase::accept()
+{
+ setResult(3);
+}
+
+
+void KBetterThanKDialogBase::reject()
+{
+ QDialog::reject();
+ setResult(4);
+}
diff --git a/kwallet/konfigurator/Makefile.am b/kwallet/konfigurator/Makefile.am
new file mode 100644
index 0000000..fab7551
--- /dev/null
+++ b/kwallet/konfigurator/Makefile.am
@@ -0,0 +1,15 @@
+INCLUDES = $(all_includes)
+METASOURCES = AUTO
+
+kde_module_LTLIBRARIES = kcm_kwallet.la
+kcm_kwallet_la_SOURCES = walletconfigwidget.ui konfigurator.cpp
+kcm_kwallet_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined
+kcm_kwallet_la_LIBADD = $(LIB_KDEUI) -lkwalletclient
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp -o $(podir)/kcmkwallet.pot
+
+xdg_apps_DATA = kwalletconfig.desktop
+
+kde_services_DATA = kwallet_config.desktop kwalletmanager_show.desktop
+
diff --git a/kwallet/konfigurator/konfigurator.cpp b/kwallet/konfigurator/konfigurator.cpp
new file mode 100644
index 0000000..a5fc336
--- /dev/null
+++ b/kwallet/konfigurator/konfigurator.cpp
@@ -0,0 +1,323 @@
+/*
+ Copyright (C) 2003 George Staikos <staikos@kde.org>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#include "konfigurator.h"
+#include "walletconfigwidget.h"
+#include <dcopclient.h>
+#include <dcopref.h>
+#include <kaboutdata.h>
+#include <kapplication.h>
+#include <kconfig.h>
+#include <kdialog.h>
+#include <kgenericfactory.h>
+#include <kinputdialog.h>
+#include <kpopupmenu.h>
+#include <kwallet.h>
+
+#include <qcheckbox.h>
+#include <qcombobox.h>
+#include <qlayout.h>
+#include <qlistview.h>
+#include <qpushbutton.h>
+#include <qspinbox.h>
+
+typedef KGenericFactory<KWalletConfig, QWidget> KWalletFactory;
+K_EXPORT_COMPONENT_FACTORY(kcm_kwallet, KWalletFactory("kcmkwallet"))
+
+KWalletConfig::KWalletConfig(QWidget *parent, const char *name, const QStringList&)
+: KCModule(KWalletFactory::instance(), parent, name) {
+
+ KAboutData *about =
+ new KAboutData(I18N_NOOP("kcmkwallet"),
+ I18N_NOOP("KDE Wallet Control Module"),
+ 0, 0, KAboutData::License_GPL,
+ I18N_NOOP("(c) 2003 George Staikos"));
+ about->addAuthor("George Staikos", 0, "staikos@kde.org");
+ setAboutData( about );
+
+ _cfg = new KConfig("kwalletrc", false, false);
+
+ QVBoxLayout *vbox = new QVBoxLayout(this, 0, KDialog::spacingHint());
+ vbox->add(_wcw = new WalletConfigWidget(this));
+
+ connect(_wcw->_enabled, SIGNAL(clicked()), this, SLOT(configChanged()));
+ connect(_wcw->_launchManager, SIGNAL(clicked()), this, SLOT(configChanged()));
+ connect(_wcw->_autocloseManager, SIGNAL(clicked()), this, SLOT(configChanged()));
+ connect(_wcw->_autoclose, SIGNAL(clicked()), this, SLOT(configChanged()));
+ connect(_wcw->_closeIdle, SIGNAL(clicked()), this, SLOT(configChanged()));
+ connect(_wcw->_openPrompt, SIGNAL(clicked()), this, SLOT(configChanged()));
+ connect(_wcw->_screensaverLock, SIGNAL(clicked()), this, SLOT(configChanged()));
+ connect(_wcw->_localWalletSelected, SIGNAL(clicked()), this, SLOT(configChanged()));
+ connect(_wcw->_idleTime, SIGNAL(valueChanged(int)), this, SLOT(configChanged()));
+ connect(_wcw->_launch, SIGNAL(clicked()), this, SLOT(launchManager()));
+ connect(_wcw->_newWallet, SIGNAL(clicked()), this, SLOT(newNetworkWallet()));
+ connect(_wcw->_newLocalWallet, SIGNAL(clicked()), this, SLOT(newLocalWallet()));
+ connect(_wcw->_localWallet, SIGNAL(activated(int)), this, SLOT(configChanged()));
+ connect(_wcw->_defaultWallet, SIGNAL(activated(int)), this, SLOT(configChanged()));
+ connect(_wcw->_accessList, SIGNAL(contextMenuRequested(QListViewItem*, const QPoint&, int)), this, SLOT(contextMenuRequested(QListViewItem*, const QPoint&, int)));
+
+ _wcw->_accessList->setAllColumnsShowFocus(true);
+ updateWalletLists();
+ load();
+
+ if (DCOPClient::mainClient()->isApplicationRegistered("kwalletmanager")) {
+ _wcw->_launch->hide();
+ }
+
+}
+
+
+KWalletConfig::~KWalletConfig() {
+ delete _cfg;
+ _cfg = 0L;
+}
+
+
+void KWalletConfig::updateWalletLists() {
+ QString p1, p2;
+ p1 = _wcw->_localWallet->currentText();
+ p2 = _wcw->_defaultWallet->currentText();
+
+ _wcw->_localWallet->clear();
+ _wcw->_defaultWallet->clear();
+
+ QStringList wl = KWallet::Wallet::walletList();
+ _wcw->_localWallet->insertStringList(wl);
+ _wcw->_defaultWallet->insertStringList(wl);
+
+ if (wl.contains(p1)) {
+ _wcw->_localWallet->setCurrentText(p1);
+ }
+
+ if (wl.contains(p2)) {
+ _wcw->_defaultWallet->setCurrentText(p2);
+ }
+}
+
+
+QString KWalletConfig::newWallet() {
+ bool ok;
+
+ QString n = KInputDialog::getText(i18n("New Wallet"),
+ i18n("Please choose a name for the new wallet:"),
+ QString::null,
+ &ok,
+ this);
+
+ if (!ok) {
+ return QString::null;
+ }
+
+ KWallet::Wallet *w = KWallet::Wallet::openWallet(n);
+ if (!w) {
+ return QString::null;
+ }
+
+ delete w;
+ return n;
+}
+
+
+void KWalletConfig::newLocalWallet() {
+ QString n = newWallet();
+ if (n.isEmpty()) {
+ return;
+ }
+
+ updateWalletLists();
+
+ _wcw->_localWallet->setCurrentText(n);
+
+ emit changed(true);
+}
+
+
+void KWalletConfig::newNetworkWallet() {
+ QString n = newWallet();
+ if (n.isEmpty()) {
+ return;
+ }
+
+ updateWalletLists();
+
+ _wcw->_defaultWallet->setCurrentText(n);
+
+ emit changed(true);
+}
+
+
+void KWalletConfig::launchManager() {
+ if (!DCOPClient::mainClient()->isApplicationRegistered("kwalletmanager")) {
+ KApplication::startServiceByDesktopName("kwalletmanager_show");
+ } else {
+ DCOPRef r("kwalletmanager", "kwalletmanager-mainwindow#1");
+ r.send("show");
+ r.send("raise");
+ }
+}
+
+
+void KWalletConfig::configChanged() {
+ emit changed(true);
+}
+
+void KWalletConfig::load() {
+ load( false );
+}
+
+void KWalletConfig::load(bool useDefaults) {
+ KConfigGroup config(_cfg, "Wallet");
+ config.setReadDefaults( useDefaults );
+ _wcw->_enabled->setChecked(config.readBoolEntry("Enabled", true));
+ _wcw->_openPrompt->setChecked(config.readBoolEntry("Prompt on Open", true));
+ _wcw->_launchManager->setChecked(config.readBoolEntry("Launch Manager", true));
+ _wcw->_autocloseManager->setChecked(! config.readBoolEntry("Leave Manager Open", false));
+ _wcw->_screensaverLock->setChecked(config.readBoolEntry("Close on Screensaver", false));
+ _wcw->_autoclose->setChecked(!config.readBoolEntry("Leave Open", false));
+ _wcw->_closeIdle->setChecked(config.readBoolEntry("Close When Idle", false));
+ _wcw->_idleTime->setValue(config.readNumEntry("Idle Timeout", 10));
+ if (config.hasKey("Default Wallet")) {
+ _wcw->_defaultWallet->setCurrentText(config.readEntry("Default Wallet"));
+ } else {
+ _wcw->_defaultWallet->setCurrentItem(0);
+ }
+ if (config.hasKey("Local Wallet")) {
+ _wcw->_localWalletSelected->setChecked( !config.readBoolEntry("Use One Wallet") );
+ _wcw->_localWallet->setCurrentText(config.readEntry("Local Wallet"));
+ } else {
+ _wcw->_localWalletSelected->setChecked(false);
+ }
+ _wcw->_accessList->clear();
+ _cfg->setGroup("Auto Deny");
+ QStringList denykeys = _cfg->entryMap("Auto Deny").keys();
+ _cfg->setGroup("Auto Allow");
+ QStringList keys = _cfg->entryMap("Auto Allow").keys();
+ for (QStringList::Iterator i = keys.begin(); i != keys.end(); ++i) {
+ _cfg->setGroup("Auto Allow");
+ QStringList apps = _cfg->readListEntry(*i);
+ _cfg->setGroup("Auto Deny");
+ QStringList denyapps = _cfg->readListEntry(*i);
+ denykeys.remove(*i);
+ QListViewItem *lvi = new QListViewItem(_wcw->_accessList, *i);
+ for (QStringList::Iterator j = apps.begin(); j != apps.end(); ++j) {
+ new QListViewItem(lvi, QString::null, *j, i18n("Always Allow"));
+ }
+ for (QStringList::Iterator j = denyapps.begin(); j != denyapps.end(); ++j) {
+ new QListViewItem(lvi, QString::null, *j, i18n("Always Deny"));
+ }
+ }
+ _cfg->setGroup("Auto Deny");
+ for (QStringList::Iterator i = denykeys.begin(); i != denykeys.end(); ++i) {
+ QStringList denyapps = _cfg->readListEntry(*i);
+ QListViewItem *lvi = new QListViewItem(_wcw->_accessList, *i);
+ for (QStringList::Iterator j = denyapps.begin(); j != denyapps.end(); ++j) {
+ new QListViewItem(lvi, QString::null, *j, i18n("Always Deny"));
+ }
+ }
+ emit changed(useDefaults);
+}
+
+
+void KWalletConfig::save() {
+ KConfigGroup config(_cfg, "Wallet");
+ config.writeEntry("Enabled", _wcw->_enabled->isChecked());
+ config.writeEntry("Launch Manager", _wcw->_launchManager->isChecked());
+ config.writeEntry("Leave Manager Open", !_wcw->_autocloseManager->isChecked());
+ config.writeEntry("Leave Open", !_wcw->_autoclose->isChecked());
+ config.writeEntry("Close When Idle", _wcw->_closeIdle->isChecked());
+ config.writeEntry("Idle Timeout", _wcw->_idleTime->value());
+ config.writeEntry("Prompt on Open", _wcw->_openPrompt->isChecked());
+ config.writeEntry("Close on Screensaver", _wcw->_screensaverLock->isChecked());
+
+ config.writeEntry("Use One Wallet", !_wcw->_localWalletSelected->isChecked());
+ if (_wcw->_localWalletSelected->isChecked()) {
+ config.writeEntry("Local Wallet", _wcw->_localWallet->currentText());
+ } else {
+ config.deleteEntry("Local Wallet");
+ }
+
+ if (_wcw->_defaultWallet->currentItem() != -1) {
+ config.writeEntry("Default Wallet", _wcw->_defaultWallet->currentText());
+ } else {
+ config.deleteEntry("Default Wallet");
+ }
+
+ // FIXME: won't survive a language change
+ _cfg->deleteGroup("Auto Allow");
+ _cfg->deleteGroup("Auto Deny");
+ _cfg->setGroup("Auto Allow");
+ for (QListViewItem *i = _wcw->_accessList->firstChild(); i; i = i->nextSibling()) {
+ QStringList al;
+ for (QListViewItem *j = i->firstChild(); j; j = j->nextSibling()) {
+ if (j->text(2) == i18n("Always Allow")) {
+ al << j->text(1);
+ }
+ }
+ _cfg->writeEntry(i->text(0), al);
+ }
+
+ _cfg->setGroup("Auto Deny");
+ for (QListViewItem *i = _wcw->_accessList->firstChild(); i; i = i->nextSibling()) {
+ QStringList al;
+ for (QListViewItem *j = i->firstChild(); j; j = j->nextSibling()) {
+ if (j->text(2) == i18n("Always Deny")) {
+ al << j->text(1);
+ }
+ }
+ _cfg->writeEntry(i->text(0), al);
+ }
+
+ _cfg->sync();
+ DCOPRef("kded", "kwalletd").call("reconfigure()");
+
+ emit changed(false);
+}
+
+
+void KWalletConfig::defaults() {
+ load( true );
+}
+
+
+QString KWalletConfig::quickHelp() const {
+ return i18n("This configuration module allows you to configure the KDE wallet system.");
+}
+
+
+void KWalletConfig::contextMenuRequested(QListViewItem *item, const QPoint& pos, int col) {
+ Q_UNUSED(col)
+ if (item && item->parent()) {
+ KPopupMenu *m = new KPopupMenu(this);
+ m->insertTitle(item->parent()->text(0));
+ m->insertItem(i18n("&Delete"), this, SLOT(deleteEntry()), Key_Delete);
+ m->popup(pos);
+ }
+}
+
+
+void KWalletConfig::deleteEntry() {
+ QListViewItem *item = _wcw->_accessList->selectedItem();
+ if (item) {
+ delete item;
+ emit changed(true);
+ }
+}
+
+#include "konfigurator.moc"
+
diff --git a/kwallet/konfigurator/konfigurator.h b/kwallet/konfigurator/konfigurator.h
new file mode 100644
index 0000000..e12ebfc
--- /dev/null
+++ b/kwallet/konfigurator/konfigurator.h
@@ -0,0 +1,57 @@
+/*
+ Copyright (C) 2003 George Staikos <staikos@kde.org>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _KWALLETKONFIGURATOR_H
+#define _KWALLETKONFIGURATOR_H
+
+#include <kcmodule.h>
+
+class KConfig;
+class WalletConfigWidget;
+class QListViewItem;
+
+class KWalletConfig : public KCModule {
+ Q_OBJECT
+ public:
+ KWalletConfig(QWidget *parent = 0L, const char *name = 0L, const QStringList& = QStringList());
+ virtual ~KWalletConfig();
+
+ void load();
+ void load( bool useDefaults );
+ void save();
+ void defaults();
+
+ QString quickHelp() const;
+
+ public slots:
+ void configChanged();
+ void launchManager();
+ void newLocalWallet();
+ void newNetworkWallet();
+ void updateWalletLists();
+ QString newWallet();
+ void deleteEntry();
+ void contextMenuRequested(QListViewItem *item, const QPoint& pos, int col);
+
+ private:
+ WalletConfigWidget *_wcw;
+ KConfig *_cfg;
+};
+
+#endif
diff --git a/kwallet/konfigurator/kwallet_config.desktop b/kwallet/konfigurator/kwallet_config.desktop
new file mode 100644
index 0000000..d8c59ba
--- /dev/null
+++ b/kwallet/konfigurator/kwallet_config.desktop
@@ -0,0 +1,47 @@
+[Desktop Entry]
+Type=Service
+Exec=kcmshell --caption %c kwalletconfig
+Icon=kwalletmanager
+DocPath=kwallet/index.html
+Name=KDE Wallet
+Name[ar]=محفظة كدى
+Name[bg]=Портфейл
+Name[br]=Doug-paperoù KDE
+Name[bs]=KDE novčanik
+Name[cs]=Úschovna KDE
+Name[cy]=Waled KDE
+Name[da]=KDE's tegnebog
+Name[de]=Digitale Brieftasche
+Name[el]=Πορτοφόλι του KDE
+Name[es]=Cartera de KDE
+Name[et]=KDE turvalaegas
+Name[eu]=KDE Kartera
+Name[fi]=Lompakko
+Name[fr]=Gestionnaire de comptes de KDE
+Name[hi]=केडीई वॉलेट
+Name[hu]=Digitális noteszek
+Name[is]=KDE veskið
+Name[it]=Portafogli di KDE
+Name[ja]=KDE ウォレット
+Name[kk]=KDE әмияні
+Name[km]=កាបូប KDE
+Name[lt]=KDE slaptažodinės
+Name[mk]=KDE Паричник
+Name[nds]=KDE-Knipp
+Name[ne]=KDE वालेट
+Name[pa]=KDE ਵਾਲਿਟ
+Name[pl]=Portfel KDE
+Name[pt]=Carteira KDE
+Name[pt_BR]=Carteira do KDE
+Name[ro]=Portofel KDE
+Name[ru]=Бумажник
+Name[sl]=Listnica za KDE
+Name[sv]=KDE-plånbok
+Name[ta]= கேடிஇ வாலட்
+Name[tg]=KDE Ҳамён
+Name[tr]=KDE Cüzdan
+Name[uk]=Торбинки KDE
+Name[uz]=KDE qopchiq
+Name[uz@cyrillic]=KDE қопчиқ
+Name[zh_CN]=KDE 钱包
+Name[zh_TW]=KDE 錢包
diff --git a/kwallet/konfigurator/kwalletconfig.desktop b/kwallet/konfigurator/kwalletconfig.desktop
new file mode 100644
index 0000000..0c60eef
--- /dev/null
+++ b/kwallet/konfigurator/kwalletconfig.desktop
@@ -0,0 +1,152 @@
+[Desktop Entry]
+Icon=kwalletmanager
+Type=Application
+Exec=kcmshell kwalletconfig
+DocPath=kwallet/index.html
+X-KDE-ModuleType=Library
+X-KDE-Library=kwallet
+X-KDE-ParentApp=kcontrol
+
+Name=KDE Wallet
+Name[ar]=محفظة كدى
+Name[bg]=Портфейл
+Name[br]=Doug-paperoù KDE
+Name[bs]=KDE novčanik
+Name[cs]=Úschovna KDE
+Name[cy]=Waled KDE
+Name[da]=KDE's tegnebog
+Name[de]=Digitale Brieftasche
+Name[el]=Πορτοφόλι του KDE
+Name[es]=Cartera de KDE
+Name[et]=KDE turvalaegas
+Name[eu]=KDE Kartera
+Name[fi]=Lompakko
+Name[fr]=Gestionnaire de comptes de KDE
+Name[hi]=केडीई वॉलेट
+Name[hu]=Digitális noteszek
+Name[is]=KDE veskið
+Name[it]=Portafogli di KDE
+Name[ja]=KDE ウォレット
+Name[kk]=KDE әмияні
+Name[km]=កាបូប KDE
+Name[lt]=KDE slaptažodinės
+Name[mk]=KDE Паричник
+Name[nds]=KDE-Knipp
+Name[ne]=KDE वालेट
+Name[pa]=KDE ਵਾਲਿਟ
+Name[pl]=Portfel KDE
+Name[pt]=Carteira KDE
+Name[pt_BR]=Carteira do KDE
+Name[ro]=Portofel KDE
+Name[ru]=Бумажник
+Name[sl]=Listnica za KDE
+Name[sv]=KDE-plånbok
+Name[ta]= கேடிஇ வாலட்
+Name[tg]=KDE Ҳамён
+Name[tr]=KDE Cüzdan
+Name[uk]=Торбинки KDE
+Name[uz]=KDE qopchiq
+Name[uz@cyrillic]=KDE қопчиқ
+Name[zh_CN]=KDE 钱包
+Name[zh_TW]=KDE 錢包
+Comment=KDE Wallet Configuration
+Comment[ar]=إعداد محفظة كدى
+Comment[bg]=Настройване на системата Портфейл
+Comment[br]=Kefluniadur Doug-paperoù KDE
+Comment[bs]=Podešavanje KDE novčanika
+Comment[ca]=Configuració de carteres KDE
+Comment[cs]=Nastavení úschovny KDE
+Comment[cy]=Ffurfweddiad Waled KDE
+Comment[da]=KDE's indstilling af tegnebog
+Comment[de]=Einrichten der "digitalen Brieftasche" (KWallet)
+Comment[el]=Ρύθμιση του πορτοφολιού του KDE
+Comment[es]=Configuración de la cartera de KDE
+Comment[et]=KDE turvalaeka seadistamine
+Comment[eu]=KDE Karteraren Konfigurazioa
+Comment[fa]=KDE Wallet پیکربندی
+Comment[fi]=KDE-lompakon asetukset
+Comment[fr]=Configuration du gestionnaire de comptes de KDE
+Comment[ga]=Cumraíocht KDE Wallet
+Comment[he]=KDE Wallet הגדרות
+Comment[hi]=केडीई वॉलेट कॉन्फ़िगरेशन
+Comment[hu]=A KDE digitális noteszeinek beállításai
+Comment[is]=Stillingar veskisins
+Comment[it]=Configurazione portafogli di KDE
+Comment[ja]=KDE ウォレットの設定
+Comment[ka]=KDE Wallet-ის კონფიგურაცია
+Comment[kk]=KDE әмияннің баптауы
+Comment[km]=ការកំណត់​រចនា​សម្ព័ន្ធ​កាបូប KDE
+Comment[lt]=KDE slaptažodinių konfigūravimas
+Comment[mk]=Конфигурација на паричник во KDE
+Comment[nb]=Oppsett av KDE Wallet
+Comment[nds]=KDE-Knipp instellen
+Comment[ne]=KDE वालेट कन्फिगरेसन
+Comment[nl]=KDE portefeuille-instellingen
+Comment[nn]=Oppsett av KDE Wallet
+Comment[pa]=KDE ਵਾਲਿਟ ਸੰਰਚਨਾ
+Comment[pl]=Konfiguracja Portfela KDE
+Comment[pt]=Configuração da Carteira do KDE
+Comment[pt_BR]=Configuração da Carteira do KDE
+Comment[ro]=Configurează portofelul KDE
+Comment[ru]=Параметры бумажника
+Comment[sk]=Konfigurácia KDE Wallet
+Comment[sl]=Nastavitve Listnice za KDE
+Comment[sr]=Подешавање KDE Wallet-а
+Comment[sr@Latn]=Podešavanje KDE Wallet-a
+Comment[sv]=Inställning av KDE-plånbok
+Comment[ta]=கேடிஇ வாலட் வடிவமைப்பு
+Comment[tg]=KDE Танзими Ҳамён
+Comment[tr]=KDE Cüzdan Ayarı
+Comment[uk]=Налаштування KWallet
+Comment[uz]=KDE qopchiq xizmatini moslash
+Comment[uz@cyrillic]=KDE қопчиқ хизматини мослаш
+Comment[zh_CN]=KDE 钱包配置
+Comment[zh_TW]=KDE 錢包設定
+Keywords=Wallet,Form Fill,Passwords,Form Data
+Keywords[ar]=محفظة،ملأ نموذج،كلمات السرّ،بيانات نموذج
+Keywords[bg]=портфейл, форми, форма, попълване, данни, парола, пароли, Wallet, Form Fill, Passwords, Form Data
+Keywords[bs]=Wallet,Form Fill,Passwords,Form Data,novčanik,formulari,popunjavanje formulara,šifre
+Keywords[ca]=Cartera,Ompliment de formularis,Contrasentes,Dades de formularis
+Keywords[cs]=úschovna,vyplnění formuláře,hesla,data formuláře
+Keywords[cy]=Waled,Llenwi Ffurflen,Cyfrineiriau,Data Ffurflenni
+Keywords[da]=Tegnebog,Formularudfyldning,Kodeord,Formular-data
+Keywords[de]=Geheimfach,Formular,Passwort,Brieftasche,digitale Brieftasche
+Keywords[el]=Πορτοφόλι,Συμπλήρωση φόρμας,Κωδικοί πρόσβασης,Δεδομένα φόρμας
+Keywords[es]=Cartera,Rellenar formulario,Contraseña,Datos de formulario
+Keywords[et]=Turvalaegas,Vormi täitmine,Paroolid,Vormiandmed
+Keywords[eu]=Kartera,Formularioa Bete,Pasahitzak,Formulario Datuak
+Keywords[fa]=Wallet، پر کردن برگه، اسم رمزها، دادۀ برگه
+Keywords[fi]=Lompakko,Lomakkeen täyttö,Salasanat,Lomaketiedot
+Keywords[fr]=gestionnaire de comptes,remplissage de formulaire,Mots de passe,Données de formulaire
+Keywords[ga]=Wallet,Líonadh Foirmeacha,Focal Faire,Sonraí foirme
+Keywords[hi]=बटुआ,फ़ॉर्म फिल,पासवर्ड,फ़ॉर्म डाटा
+Keywords[hu]=digitális notesz,űrlapkitöltés,jelszavak,űrlapadatok
+Keywords[it]=portafogli,wallet,riempimento moduli,moduli,form,password,dati moduli
+Keywords[ja]=ウォレット,フォームフィル,パスワード,フォームデータ
+Keywords[ka]=Wallet,ფორმის შევსება,პაროლები,ფორმათა მონაცემები
+Keywords[km]=កាបូប,ការបំពេញ​សំណុំ​បែបបទ,ពាក្យ​សម្ងាត់,ទិន្នន័យ​សំណុំ​បែបបទ
+Keywords[lt]=Wallet, slaptažodinė,Form Fill,Passwords,Form Data,formų pildymas,slaptažodžiai,formų duomenys
+Keywords[mk]=Wallet,Form Fill,Passwords,Form Data, Паричник, формулар, лозинки
+Keywords[nb]=Wallet,Skjemautfylling,Passord,Skjema
+Keywords[nds]=Knipp,Formulor,Passwöör,Formulordaten
+Keywords[ne]=वालेट,फारम भराइ,पासवर्ड,फारम डेटा
+Keywords[nl]=Wallet,gegevens,portefeuille,wachtwoorden,veilig bewaren van wachtwoorden,invulgegevens,formulieren
+Keywords[nn]=wallet,skjemautfylling,passord,skjema
+Keywords[pa]=Wallet,Form Fill,ਗੁਪਤ-ਕੋਡ,ਫਾਰਮ ਡਾਟਾ
+Keywords[pl]=portfel,wypełnianie formularzy,uzupełnianie formularzy, hasła, hasło,dane formularzy, formularze
+Keywords[pt]=Carteira,Preenchimento de Formulários,Senhas,Dados do Formulário
+Keywords[pt_BR]=carteira,preenchimento de formulário,senhas,dados de formulário
+Keywords[ro]=portofel,completare formulare,parole,date formular,formular
+Keywords[ru]=Wallet,Form Fill,Passwords,Form Data,Бумажник,Пароли,Формы
+Keywords[sk]=wallet,formuláre,heslá,dáta z formulárov,schránka,peňaženka
+Keywords[sl]=waller,denarnica,gesla,obrazec,podatki,geslo,listnica
+Keywords[sr]=Wallet,Form Fill,Passwords,Form Data,лозинке,новчаник
+Keywords[sr@Latn]=Wallet,Form Fill,Passwords,Form Data,lozinke,novčanik
+Keywords[sv]=Plånbok,fyll i formulär,lösenord,formulärdata
+Keywords[ta]=வாலட், படிவ நிரப்பு, கடவுச் சொற்கள், படிவ தகவல்
+Keywords[tg]=Ҳамён,Пуркунии Варақа,Гузарвожаҳо,Варақаи Додаҳо
+Keywords[tr]=Cüzdan,Form Doldur,Şifreler,Form Verisi
+Keywords[uk]=Торбинка,Заповнення форм,Паролі,Дані форм
+Keywords[zh_CN]=Wallet,Form Fill,Passwords,Form Data,钱包,填充表单,密码,表单数据
+
+Categories=Qt;KDE;X-KDE-settings-security;
diff --git a/kwallet/konfigurator/kwalletmanager_show.desktop b/kwallet/konfigurator/kwalletmanager_show.desktop
new file mode 100644
index 0000000..91b7368
--- /dev/null
+++ b/kwallet/konfigurator/kwalletmanager_show.desktop
@@ -0,0 +1,60 @@
+[Desktop Entry]
+Name=Wallet Management Tool
+Name[ar]=أداة إدارة المحفظة
+Name[bg]=Портфейл
+Name[br]=Merour an doug-paperoù
+Name[bs]=Alat za upravljanje novčanikom
+Name[ca]=Eina de gestió de carteres
+Name[cs]=Nástroj pro správu úschovny
+Name[cy]=Erfyn Rheoli Waled
+Name[da]=Håndteringsværktøj for tegnebog
+Name[de]=Verwaltung für digitale Brieftasche
+Name[el]=Εργαλείο διαχείρισης πορτοφολιού
+Name[es]=Herramienta de gestión de cartera
+Name[et]=Turvalaeka haldur
+Name[eu]=Kartera Kudeatzeko Tresna
+Name[fa]=ابزار مدیریت Wallet
+Name[fi]=Lompakon hallintatyökalu
+Name[fr]=Outil de gestion de comptes
+Name[ga]=Uirlis Bhainisteoireachta Wallet
+Name[he]=כלי לניהול הארנק של KDE
+Name[hi]= बटुआ प्रबंधन औज़ार
+Name[hu]=Kezelőprogram a KDE digitális noteszeihez
+Name[is]=Tól til að stýra eiginleikum veskisins
+Name[it]=Strumento per la gestione dei portafogli
+Name[ja]=ウォレット管理ツール
+Name[ka]=Wallet-ის მმართველი მოწყობილობა
+Name[kk]=Әмиянін басқару құралы
+Name[km]=ឧបករណ៍​គ្រប់គ្រង​កាបូប
+Name[lt]=Spatažodinių tvarkymo įrankis
+Name[mk]=Алатка за менаџирање на паричници
+Name[nb]=Wallet administrasjonsverktøy
+Name[nds]=Knipp-Pleger
+Name[ne]=वालेट व्यवस्थापन उपकरण
+Name[nl]=Portefeuillebeheer
+Name[nn]=Wallet-administrasjonsverktøy
+Name[pa]=ਵਾਲਿਟ ਪਰਬੰਧਨ ਸੰਦ
+Name[pl]=Narzędzie do zarządzania Portfelem
+Name[pt]=Ferramenta de Gestão da Carteira
+Name[pt_BR]=Ferramenta de Gerenciamento da Carteira
+Name[ro]=Administrare portofel
+Name[ru]=Управление паролями
+Name[sk]=Nástroj na správu KWallet
+Name[sl]=Orodje za upravljanje z listnicami
+Name[sr]=Алат за управљање новчаником
+Name[sr@Latn]=Alat za upravljanje novčanikom
+Name[sv]=Hanteringsverktyg för plånbok
+Name[ta]=வாலட் மேலாண்மை கருவி
+Name[tg]=Асбоби Идоракунии Ҳамён
+Name[tr]=Cüzdan Yönetim Aracı
+Name[uk]=Засіб керування торбинками
+Name[uz]=Qopchiq boshqarish vositasi
+Name[uz@cyrillic]=Қопчиқ бошқариш воситаси
+Name[zh_CN]=钱包管理工具
+Name[zh_TW]=錢包管理工具
+Exec=kwalletmanager --show %u
+MimeType=application/x-kde-wallet
+InitialPreference=6
+Icon=kwalletmanager
+Type=Service
+X-KDE-StartupNotify=true
diff --git a/kwallet/konfigurator/walletconfigwidget.ui b/kwallet/konfigurator/walletconfigwidget.ui
new file mode 100644
index 0000000..797d569
--- /dev/null
+++ b/kwallet/konfigurator/walletconfigwidget.ui
@@ -0,0 +1,499 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>WalletConfigWidget</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>WalletConfigWidget</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>585</width>
+ <height>450</height>
+ </rect>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QTabWidget" row="0" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>tabWidget2</cstring>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Wallet Preferences</string>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>_enabled</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Enable the KDE wallet subsystem</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;p&gt;The wallet subsytem allows a convenient and secure way to manage all your passwords. You can decide if you want to use this system with this option.&lt;/p&gt;</string>
+ </property>
+ </widget>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox2</cstring>
+ </property>
+ <property name="title">
+ <string>Close Wallet</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>It is best to close your wallets when you are not using them to prevent others from viewing or using them.</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>_closeIdle</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>2</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Close when unused for:</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;p&gt;&lt;b&gt;Close wallet after a period of inactivity&lt;/b&gt;&lt;br&gt;When a wallet is closed the password is needed to access it again.&lt;/p&gt;</string>
+ </property>
+ </widget>
+ <widget class="QSpinBox">
+ <property name="name">
+ <cstring>_idleTime</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="suffix">
+ <string> min</string>
+ </property>
+ <property name="maxValue">
+ <number>999</number>
+ </property>
+ <property name="minValue">
+ <number>1</number>
+ </property>
+ <property name="lineStep">
+ <number>5</number>
+ </property>
+ <property name="value">
+ <number>10</number>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;p&gt;&lt;b&gt;Close wallet after a period of inactivity&lt;/b&gt;&lt;br&gt;When a wallet is closed the password is needed to access it again.&lt;/p&gt;</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer12</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>_screensaverLock</cstring>
+ </property>
+ <property name="text">
+ <string>Close when screensaver starts</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;p&gt;&lt;b&gt;Close wallet as soon as the screensaver starts.&lt;/b&gt;&lt;br&gt;When a wallet is closed the password is needed to access it again.&lt;/p&gt;</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>_autoclose</cstring>
+ </property>
+ <property name="text">
+ <string>Close when last application stops using it</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;p&gt;&lt;b&gt;Close wallet as soon as applications that use it have stopped.&lt;/b&gt;&lt;br&gt;Note that your wallets will only be closed when all applications that use it have stopped.&lt;br&gt;When a wallet is closed the password is needed to access it again.&lt;/p&gt;</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox4</cstring>
+ </property>
+ <property name="title">
+ <string>Automatic Wallet Selection</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="0" column="1" rowspan="2" colspan="1">
+ <property name="name">
+ <cstring>spacer7</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1_2</cstring>
+ </property>
+ <property name="text">
+ <string>Select wallet to use as default:</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="1" column="0">
+ <property name="name">
+ <cstring>_localWalletSelected</cstring>
+ </property>
+ <property name="text">
+ <string>Different wallet for local passwords:</string>
+ </property>
+ </widget>
+ <widget class="QComboBox" row="0" column="2">
+ <property name="name">
+ <cstring>_defaultWallet</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget class="QComboBox" row="1" column="2">
+ <property name="name">
+ <cstring>_localWallet</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="1" column="3">
+ <property name="name">
+ <cstring>_newLocalWallet</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>New...</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="0" column="3">
+ <property name="name">
+ <cstring>_newWallet</cstring>
+ </property>
+ <property name="text">
+ <string>New...</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox3</cstring>
+ </property>
+ <property name="title">
+ <string>Wallet Manager</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer6</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Fixed</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QCheckBox" row="0" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>_launchManager</cstring>
+ </property>
+ <property name="text">
+ <string>Show manager in system tray</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="1" column="1">
+ <property name="name">
+ <cstring>_autocloseManager</cstring>
+ </property>
+ <property name="text">
+ <string>Hide system tray icon when last wallet closes</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer4</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>31</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Access Control</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox" row="0" column="0">
+ <property name="name">
+ <cstring>_openPrompt</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Prompt when an application accesses an open wallet</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QListView" row="1" column="0">
+ <column>
+ <property name="text">
+ <string>Wallet</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Application</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Policy</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>_accessList</cstring>
+ </property>
+ <property name="rootIsDecorated">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </widget>
+ <widget class="QPushButton" row="1" column="1">
+ <property name="name">
+ <cstring>_launch</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Launch Wallet Manager</string>
+ </property>
+ </widget>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>369</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>_localWalletSelected</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>_newLocalWallet</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>_localWalletSelected</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>_localWallet</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>_closeIdle</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>_idleTime</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>_enabled</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>groupBox2</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>_enabled</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>groupBox4</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>_enabled</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>groupBox3</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>_closeIdle</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>_idleTime</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>_launchManager</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>_autocloseManager</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>_enabled</tabstop>
+ <tabstop>_closeIdle</tabstop>
+ <tabstop>_idleTime</tabstop>
+ <tabstop>_screensaverLock</tabstop>
+ <tabstop>_autoclose</tabstop>
+ <tabstop>_defaultWallet</tabstop>
+ <tabstop>_newWallet</tabstop>
+ <tabstop>_localWalletSelected</tabstop>
+ <tabstop>_localWallet</tabstop>
+ <tabstop>_newLocalWallet</tabstop>
+ <tabstop>_launchManager</tabstop>
+ <tabstop>_autocloseManager</tabstop>
+ <tabstop>tabWidget2</tabstop>
+ <tabstop>_openPrompt</tabstop>
+ <tabstop>_accessList</tabstop>
+ <tabstop>_launch</tabstop>
+</tabstops>
+<slots>
+ <slot>_storeTogether_toggled(bool)</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/kwallet/kwalleteditor.cpp b/kwallet/kwalleteditor.cpp
new file mode 100644
index 0000000..d9e49d0
--- /dev/null
+++ b/kwallet/kwalleteditor.cpp
@@ -0,0 +1,1143 @@
+/*
+ Copyright (C) 2003-2005 George Staikos <staikos@kde.org>
+ Copyright (C) 2005 Isaac Clerencia <isaac@warp.es>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+
+#include "kbetterthankdialogbase.h"
+#include "kwalleteditor.h"
+#include "kwmapeditor.h"
+#include "allyourbase.h"
+
+#include <dcopclient.h>
+#include <dcopref.h>
+#include <kaction.h>
+#include <kapplication.h>
+#include <kdebug.h>
+#include <kdialog.h>
+#include <kfiledialog.h>
+#include <kiconview.h>
+#include <kinputdialog.h>
+#include <kio/netaccess.h>
+#include <klistviewsearchline.h>
+#include <klocale.h>
+#include <kmdcodec.h>
+#include <kmessagebox.h>
+#include <kpopupmenu.h>
+#include <ksqueezedtextlabel.h>
+#include <kstandarddirs.h>
+#include <kstdaction.h>
+#include <kstringhandler.h>
+#include <ktempfile.h>
+
+#include <qcheckbox.h>
+#include <qcombobox.h>
+#include <qclipboard.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qlistview.h>
+#include <qptrstack.h>
+#include <qpushbutton.h>
+#include <qstylesheet.h>
+#include <qtextedit.h>
+#include <qtimer.h>
+#include <qwidgetstack.h>
+
+#include <assert.h>
+#include <stdlib.h>
+
+KWalletEditor::KWalletEditor(const QString& wallet, bool isPath, QWidget *parent, const char *name)
+: KMainWindow(parent, name), _walletName(wallet), _nonLocal(isPath) {
+ _newWallet = false;
+ _ww = new WalletWidget(this, "Wallet Widget");
+ _copyPassAction = KStdAction::copy(this, SLOT(copyPassword()), actionCollection());
+
+ QVBoxLayout *box = new QVBoxLayout(_ww->_entryListFrame);
+ box->setSpacing( KDialog::spacingHint() );
+ box->setMargin( KDialog::marginHint() );
+ _entryList = new KWalletEntryList(_ww->_entryListFrame, "Wallet Entry List");
+ box->addWidget(new KListViewSearchLineWidget(_entryList, _ww->_entryListFrame));
+ box->addWidget(_entryList);
+
+ _ww->_entryStack->setEnabled(true);
+
+ box = new QVBoxLayout(_ww->_entryStack->widget(2));
+ _mapEditorShowHide = new QCheckBox(i18n("&Show values"), _ww->_entryStack->widget(2));
+ connect(_mapEditorShowHide, SIGNAL(toggled(bool)), this, SLOT(showHideMapEditorValue(bool)));
+ _mapEditor = new KWMapEditor(_currentMap, _ww->_entryStack->widget(2));
+ box->addWidget(_mapEditorShowHide);
+ box->addWidget(_mapEditor);
+
+ setCentralWidget(_ww);
+
+ resize(600, 400);
+
+ connect(_entryList, SIGNAL(selectionChanged(QListViewItem*)),
+ this, SLOT(entrySelectionChanged(QListViewItem*)));
+ connect(_entryList,
+ SIGNAL(contextMenuRequested(QListViewItem*,const QPoint&,int)),
+ this,
+ SLOT(listContextMenuRequested(QListViewItem*,const QPoint&,int)));
+ connect(_entryList,
+ SIGNAL(itemRenamed(QListViewItem*, int, const QString&)),
+ this,
+ SLOT(listItemRenamed(QListViewItem*, int, const QString&)));
+
+ connect(_ww->_passwordValue, SIGNAL(textChanged()),
+ this, SLOT(entryEditted()));
+ connect(_mapEditor, SIGNAL(dirty()),
+ this, SLOT(entryEditted()));
+
+ connect(_ww->_undoChanges, SIGNAL(clicked()),
+ this, SLOT(restoreEntry()));
+ connect(_ww->_saveChanges, SIGNAL(clicked()),
+ this, SLOT(saveEntry()));
+
+ connect(_ww->_showContents, SIGNAL(clicked()),
+ this, SLOT(showPasswordContents()));
+ connect(_ww->_hideContents, SIGNAL(clicked()),
+ this, SLOT(hidePasswordContents()));
+
+ _walletIsOpen = false;
+
+ _w = KWallet::Wallet::openWallet(wallet, winId(), isPath ? KWallet::Wallet::Path : KWallet::Wallet::Asynchronous);
+ if (_w) {
+ connect(_w, SIGNAL(walletOpened(bool)), this, SLOT(walletOpened(bool)));
+ connect(_w, SIGNAL(walletClosed()), this, SLOT(walletClosed()));
+ connect(_w, SIGNAL(folderUpdated(const QString&)), this, SLOT(updateEntries(const QString&)));
+ connect(_w, SIGNAL(folderListUpdated()), this, SLOT(updateFolderList()));
+ updateFolderList();
+ } else {
+ kdDebug(2300) << "Wallet open failed!" << endl;
+ }
+
+ createActions();
+ createGUI("kwalleteditor.rc");
+ delete toolBar();
+
+ setCaption(wallet);
+
+ QTimer::singleShot(0, this, SLOT(layout()));
+}
+
+KWalletEditor::~KWalletEditor() {
+ emit editorClosed(this);
+ delete _newFolderAction;
+ _newFolderAction = 0L;
+ delete _deleteFolderAction;
+ _deleteFolderAction = 0L;
+ delete _w;
+ _w = 0L;
+ if (_nonLocal) {
+ KWallet::Wallet::closeWallet(_walletName, true);
+ }
+}
+
+void KWalletEditor::layout() {
+ QValueList<int> sz = _ww->_splitter->sizes();
+ int sum = sz[0] + sz[1];
+ sz[0] = sum/2;
+ sz[1] = sum/2;
+ _ww->_splitter->setSizes(sz);
+}
+
+void KWalletEditor::createActions() {
+ _newFolderAction = new KAction(i18n("&New Folder..."), "folder_new",
+ 0, this, SLOT(createFolder()), actionCollection(),
+ "create_folder");
+ connect(this, SIGNAL(enableFolderActions(bool)),
+ _newFolderAction, SLOT(setEnabled(bool)));
+
+ _deleteFolderAction = new KAction(i18n("&Delete Folder"), 0, 0,
+ this, SLOT(deleteFolder()), actionCollection(),
+ "delete_folder");
+ connect(this, SIGNAL(enableContextFolderActions(bool)),
+ _deleteFolderAction, SLOT(setEnabled(bool)));
+ connect(this, SIGNAL(enableFolderActions(bool)),
+ _deleteFolderAction, SLOT(setEnabled(bool)));
+
+ _passwordAction = new KAction(i18n("Change &Password..."), 0, 0, this,
+ SLOT(changePassword()), actionCollection(),
+ "change_password");
+ connect(this, SIGNAL(enableWalletActions(bool)),
+ _passwordAction, SLOT(setEnabled(bool)));
+
+ _mergeAction = new KAction(i18n("&Merge Wallet..."), 0, 0, this,
+ SLOT(importWallet()), actionCollection(),
+ "merge");
+ connect(this, SIGNAL(enableWalletActions(bool)),
+ _mergeAction, SLOT(setEnabled(bool)));
+
+ _importAction = new KAction(i18n("&Import XML..."), 0, 0, this,
+ SLOT(importXML()), actionCollection(),
+ "import");
+ connect(this, SIGNAL(enableWalletActions(bool)),
+ _importAction, SLOT(setEnabled(bool)));
+
+ _exportAction = new KAction(i18n("&Export..."), 0, 0, this,
+ SLOT(exportXML()), actionCollection(),
+ "export");
+ connect(this, SIGNAL(enableWalletActions(bool)),
+ _exportAction, SLOT(setEnabled(bool)));
+
+ _saveAsAction = KStdAction::saveAs(this, SLOT(saveAs()), actionCollection());
+ connect(this, SIGNAL(enableWalletActions(bool)),
+ _saveAsAction, SLOT(setEnabled(bool)));
+
+ KStdAction::quit(this, SLOT(close()), actionCollection());
+ KStdAction::keyBindings(guiFactory(), SLOT(configureShortcuts()),
+actionCollection());
+ emit enableWalletActions(false);
+ emit enableFolderActions(false);
+ emit enableContextFolderActions(false);
+}
+
+
+void KWalletEditor::walletClosed() {
+ delete _w;
+ _walletIsOpen = false;
+ _w = 0L;
+ _ww->setEnabled(false);
+ emit enableWalletActions(false);
+ emit enableFolderActions(false);
+ KMessageBox::sorry(this, i18n("This wallet was forced closed. You must reopen it to continue working with it."));
+ deleteLater();
+}
+
+
+void KWalletEditor::updateFolderList(bool checkEntries) {
+ QStringList fl = _w->folderList();
+ QPtrStack<QListViewItem> trash;
+
+ for (QListViewItem *i = _entryList->firstChild(); i; i = i->nextSibling()) {
+ KWalletFolderItem *fi = dynamic_cast<KWalletFolderItem *>(i);
+ if (!fi) {
+ continue;
+ }
+ if (!fl.contains(fi->name())) {
+ trash.push(i);
+ }
+ }
+
+ trash.setAutoDelete(true);
+ trash.clear();
+
+ for (QStringList::Iterator i = fl.begin(); i != fl.end(); ++i) {
+ if (_entryList->existsFolder(*i)) {
+ if (checkEntries) {
+ updateEntries(*i);
+ }
+ continue;
+ }
+
+ _w->setFolder(*i);
+ QStringList entries = _w->entryList();
+ KWalletFolderItem *item = new KWalletFolderItem(_w,_entryList,
+ *i, entries.count());
+
+ KWalletContainerItem *pi = new KWalletContainerItem(item, i18n("Passwords"),KWallet::Wallet::Password);
+ KWalletContainerItem *mi = new KWalletContainerItem(item, i18n("Maps"),KWallet::Wallet::Map);
+ KWalletContainerItem *bi = new KWalletContainerItem(item, i18n("Binary Data"),KWallet::Wallet::Stream);
+ KWalletContainerItem *ui = new KWalletContainerItem(item, i18n("Unknown"),KWallet::Wallet::Unknown);
+
+ for (QStringList::Iterator j = entries.begin(); j != entries.end(); ++j) {
+ switch (_w->entryType(*j)) {
+ case KWallet::Wallet::Password:
+ new KWalletEntryItem(_w, pi, *j);
+ break;
+ case KWallet::Wallet::Stream:
+ new KWalletEntryItem(_w, bi, *j);
+ break;
+ case KWallet::Wallet::Map:
+ new KWalletEntryItem(_w, mi, *j);
+ break;
+ case KWallet::Wallet::Unknown:
+ default:
+ new QListViewItem(ui, *j);
+ break;
+ }
+ }
+ _entryList->setEnabled(true);
+ }
+
+ //check if the current folder has been removed
+ if (!fl.contains(_currentFolder)) {
+ _currentFolder = "";
+ _ww->_entryTitle->clear();
+ _ww->_iconTitle->clear();
+ }
+}
+
+void KWalletEditor::deleteFolder() {
+ if (_w) {
+ QListViewItem *i = _entryList->currentItem();
+ if (i) {
+ KWalletFolderItem *fi = dynamic_cast<KWalletFolderItem *>(i);
+ if (!fi) {
+ return;
+ }
+
+ int rc = KMessageBox::warningContinueCancel(this, i18n("Are you sure you wish to delete the folder '%1' from the wallet?").arg(fi->name()),"",KStdGuiItem::del());
+ if (rc == KMessageBox::Continue) {
+ bool rc = _w->removeFolder(fi->name());
+ if (!rc) {
+ KMessageBox::sorry(this, i18n("Error deleting folder."));
+ return;
+ }
+ _currentFolder = "";
+ _ww->_entryTitle->clear();
+ _ww->_iconTitle->clear();
+ updateFolderList();
+ }
+ }
+ }
+}
+
+
+void KWalletEditor::createFolder() {
+ if (_w) {
+ QString n;
+ bool ok;
+
+ do {
+ n = KInputDialog::getText(i18n("New Folder"),
+ i18n("Please choose a name for the new folder:"),
+ QString::null,
+ &ok,
+ this);
+
+ if (!ok) {
+ return;
+ }
+
+ if (_entryList->existsFolder(n)) {
+ int rc = KMessageBox::questionYesNo(this, i18n("Sorry, that folder name is in use. Try again?"), QString::null, i18n("Try Again"), i18n("Do Not Try"));
+ if (rc == KMessageBox::Yes) {
+ continue;
+ }
+ n = QString::null;
+ }
+ break;
+ } while (true);
+
+ _w->createFolder(n);
+ updateFolderList();
+ }
+}
+
+
+void KWalletEditor::saveEntry() {
+ int rc = 1;
+ QListViewItem *item = _entryList->currentItem();
+ _ww->_saveChanges->setEnabled(false);
+ _ww->_undoChanges->setEnabled(false);
+
+ if (item && _w && item->parent()) {
+ KWalletContainerItem *ci = dynamic_cast<KWalletContainerItem*>(item->parent());
+ if (ci) {
+ if (ci->type() == KWallet::Wallet::Password) {
+ rc = _w->writePassword(item->text(0), _ww->_passwordValue->text());
+ } else if (ci->type() == KWallet::Wallet::Map) {
+ _mapEditor->saveMap();
+ rc = _w->writeMap(item->text(0), _currentMap);
+ } else {
+ return;
+ }
+
+ if (rc == 0) {
+ return;
+ }
+ }
+ }
+
+ KMessageBox::sorry(this, i18n("Error saving entry. Error code: %1").arg(rc));
+}
+
+
+void KWalletEditor::restoreEntry() {
+ entrySelectionChanged(_entryList->currentItem());
+}
+
+
+void KWalletEditor::entryEditted() {
+ _ww->_saveChanges->setEnabled(true);
+ _ww->_undoChanges->setEnabled(true);
+}
+
+
+void KWalletEditor::entrySelectionChanged(QListViewItem *item) {
+ KWalletContainerItem *ci = 0L;
+ KWalletFolderItem *fi = 0L;
+
+ switch (item->rtti()) {
+ case KWalletEntryItemClass:
+ ci = dynamic_cast<KWalletContainerItem*>(item->parent());
+ if (!ci) {
+ return;
+ }
+ fi = dynamic_cast<KWalletFolderItem*>(ci->parent());
+ if (!fi) {
+ return;
+ }
+ _w->setFolder(fi->name());
+ _deleteFolderAction->setEnabled(false);
+ if (ci->type() == KWallet::Wallet::Password) {
+ QString pass;
+ if (_w->readPassword(item->text(0), pass) == 0) {
+ _ww->_entryStack->raiseWidget(int(4));
+ _ww->_entryName->setText(i18n("Password: %1")
+ .arg(item->text(0)));
+ _ww->_passwordValue->setText(pass);
+ _ww->_saveChanges->setEnabled(false);
+ _ww->_undoChanges->setEnabled(false);
+ }
+ } else if (ci->type() == KWallet::Wallet::Map) {
+ _ww->_entryStack->raiseWidget(int(2));
+ _mapEditorShowHide->setChecked(false);
+ showHideMapEditorValue(false);
+ if (_w->readMap(item->text(0), _currentMap) == 0) {
+ _mapEditor->reload();
+ _ww->_entryName->setText(i18n("Name-Value Map: %1").arg(item->text(0)));
+ _ww->_saveChanges->setEnabled(false);
+ _ww->_undoChanges->setEnabled(false);
+ }
+ } else if (ci->type() == KWallet::Wallet::Stream) {
+ _ww->_entryStack->raiseWidget(int(3));
+ QByteArray ba;
+ if (_w->readEntry(item->text(0), ba) == 0) {
+ _ww->_entryName->setText(i18n("Binary Data: %1")
+ .arg(item->text(0)));
+ _ww->_saveChanges->setEnabled(false);
+ _ww->_undoChanges->setEnabled(false);
+ }
+ }
+ break;
+
+ case KWalletContainerItemClass:
+ fi = dynamic_cast<KWalletFolderItem*>(item->parent());
+ if (!fi) {
+ return;
+ }
+ _w->setFolder(fi->name());
+ _deleteFolderAction->setEnabled(false);
+ _ww->_entryName->clear();
+ _ww->_entryStack->raiseWidget(int(0));
+ break;
+
+ case KWalletFolderItemClass:
+ fi = dynamic_cast<KWalletFolderItem*>(item);
+ if (!fi) {
+ return;
+ }
+ _w->setFolder(fi->name());
+ _deleteFolderAction->setEnabled(true);
+ _ww->_entryName->clear();
+ _ww->_entryStack->raiseWidget(int(0));
+ break;
+ }
+
+ if (fi) {
+ _currentFolder = fi->name();
+ _ww->_entryTitle->setText(QString("<font size=\"+1\">%1</font>").arg(fi->text(0)));
+ _ww->_iconTitle->setPixmap(fi->getFolderIcon(KIcon::Toolbar));
+ }
+}
+
+void KWalletEditor::updateEntries(const QString& folder) {
+ QPtrStack<QListViewItem> trash;
+
+ _w->setFolder(folder);
+ QStringList entries = _w->entryList();
+
+ KWalletFolderItem *fi = _entryList->getFolder(folder);
+
+ if (!fi) {
+ return;
+ }
+
+ KWalletContainerItem *pi = fi->getContainer(KWallet::Wallet::Password);
+ KWalletContainerItem *mi = fi->getContainer(KWallet::Wallet::Map);
+ KWalletContainerItem *bi = fi->getContainer(KWallet::Wallet::Stream);
+ KWalletContainerItem *ui = fi->getContainer(KWallet::Wallet::Unknown);
+
+ // Remove deleted entries
+ for (QListViewItem *i = pi->firstChild(); i; i = i->nextSibling()) {
+ if (!entries.contains(i->text(0))) {
+ if (i == _entryList->currentItem()) {
+ entrySelectionChanged(0L);
+ }
+ trash.push(i);
+ }
+ }
+
+ for (QListViewItem *i = mi->firstChild(); i; i = i->nextSibling()) {
+ if (!entries.contains(i->text(0))) {
+ if (i == _entryList->currentItem()) {
+ entrySelectionChanged(0L);
+ }
+ trash.push(i);
+ }
+ }
+
+ for (QListViewItem *i = bi->firstChild(); i; i = i->nextSibling()) {
+ if (!entries.contains(i->text(0))) {
+ if (i == _entryList->currentItem()) {
+ entrySelectionChanged(0L);
+ }
+ trash.push(i);
+ }
+ }
+
+ for (QListViewItem *i = ui->firstChild(); i; i = i->nextSibling()) {
+ if (!entries.contains(i->text(0))) {
+ if (i == _entryList->currentItem()) {
+ entrySelectionChanged(0L);
+ }
+ trash.push(i);
+ }
+ }
+
+ trash.setAutoDelete(true);
+ trash.clear();
+
+ // Add new entries
+ for (QStringList::Iterator i = entries.begin(); i != entries.end(); ++i) {
+ if (fi->contains(*i)){
+ continue;
+ }
+
+ switch (_w->entryType(*i)) {
+ case KWallet::Wallet::Password:
+ new KWalletEntryItem(_w, pi, *i);
+ break;
+ case KWallet::Wallet::Stream:
+ new KWalletEntryItem(_w, bi, *i);
+ break;
+ case KWallet::Wallet::Map:
+ new KWalletEntryItem(_w, mi, *i);
+ break;
+ case KWallet::Wallet::Unknown:
+ default:
+ new QListViewItem(ui, *i);
+ break;
+ }
+ }
+ fi->refresh();
+ if (fi->name() == _currentFolder) {
+ _ww->_entryTitle->setText(QString("<font size=\"+1\">%1</font>").arg(fi->text(0)));
+ }
+ if (!_entryList->selectedItem()) {
+ _ww->_entryName->clear();
+ _ww->_entryStack->raiseWidget(int(0));
+ }
+}
+
+void KWalletEditor::listContextMenuRequested(QListViewItem *item, const QPoint& pos, int col) {
+ Q_UNUSED(col)
+
+ if (!_walletIsOpen) {
+ return;
+ }
+
+ KWalletListItemClasses menuClass = KWalletUnknownClass;
+ KWalletContainerItem *ci = 0L;
+
+ if (item) {
+ if (item->rtti() == KWalletEntryItemClass) {
+ ci = dynamic_cast<KWalletContainerItem *>(item->parent());
+ if (!ci) {
+ return;
+ }
+ } else if (item->rtti() == KWalletContainerItemClass) {
+ ci = dynamic_cast<KWalletContainerItem *>(item);
+ if (!ci) {
+ return;
+ }
+ }
+
+ if (ci && ci->type() == KWallet::Wallet::Unknown) {
+ return;
+ }
+ menuClass = static_cast<KWalletListItemClasses>(item->rtti());
+ }
+
+ KPopupMenu *m = new KPopupMenu(this);
+ if (item) {
+ QString title = item->text(0);
+ // I think 200 pixels is wide enough for a title
+ title = KStringHandler::cPixelSqueeze(title, m->fontMetrics(), 200);
+ m->insertTitle(title);
+ switch (menuClass) {
+ case KWalletEntryItemClass:
+ m->insertItem(i18n("&New..." ), this, SLOT(newEntry()), Key_Insert);
+ m->insertItem(i18n( "&Rename" ), this, SLOT(renameEntry()), Key_F2);
+ m->insertItem(i18n( "&Delete" ), this, SLOT(deleteEntry()), Key_Delete);
+ if (ci && ci->type() == KWallet::Wallet::Password) {
+ m->insertSeparator();
+ _copyPassAction->plug(m);
+ }
+ break;
+
+ case KWalletContainerItemClass:
+ m->insertItem(i18n( "&New..." ), this, SLOT(newEntry()), Key_Insert);
+ break;
+
+ case KWalletFolderItemClass:
+ _newFolderAction->plug(m);
+ _deleteFolderAction->plug(m);
+ break;
+ default:
+ abort();
+ }
+ } else {
+ _newFolderAction->plug(m);
+ }
+ m->popup(pos);
+}
+
+
+void KWalletEditor::copyPassword() {
+ QListViewItem *item = _entryList->selectedItem();
+ if (_w && item) {
+ QString pass;
+ if (_w->readPassword(item->text(0), pass) == 0) {
+ QApplication::clipboard()->setText(pass);
+ }
+ }
+}
+
+
+void KWalletEditor::newEntry() {
+ QListViewItem *item = _entryList->selectedItem();
+ QString n;
+ bool ok;
+
+ QListViewItem *p;
+ KWalletFolderItem *fi;
+
+ //set the folder where we're trying to create the new entry
+ if (_w && item) {
+ p = item;
+ if (p->rtti() == KWalletEntryItemClass) {
+ p = item->parent();
+ }
+ fi = dynamic_cast<KWalletFolderItem *>(p->parent());
+ if (!fi) {
+ return;
+ }
+ _w->setFolder(fi->name());
+ } else {
+ return;
+ }
+
+ do {
+ n = KInputDialog::getText(i18n("New Entry"),
+ i18n("Please choose a name for the new entry:"),
+ QString::null,
+ &ok,
+ this);
+
+ if (!ok) {
+ return;
+ }
+
+ // FIXME: prohibits the use of the subheadings
+ if (fi->contains(n)) {
+ int rc = KMessageBox::questionYesNo(this, i18n("Sorry, that entry already exists. Try again?"), QString::null, i18n("Try Again"), i18n("Do Not Try"));
+ if (rc == KMessageBox::Yes) {
+ continue;
+ }
+ n = QString::null;
+ }
+ break;
+ } while (true);
+
+ if (_w && item && !n.isEmpty()) {
+ QListViewItem *p = item;
+ if (p->rtti() == KWalletEntryItemClass) {
+ p = item->parent();
+ }
+
+ KWalletFolderItem *fi = dynamic_cast<KWalletFolderItem *>(p->parent());
+ if (!fi) {
+ KMessageBox::error(this, i18n("An unexpected error occurred trying to add the new entry"));
+ return;
+ }
+ _w->setFolder(fi->name());
+
+ KWalletEntryItem *ni = new KWalletEntryItem(_w, p, n);
+ _entryList->setSelected(ni,true);
+ _entryList->ensureItemVisible(ni);
+
+ KWalletContainerItem *ci = dynamic_cast<KWalletContainerItem*>(p);
+ if (!ci) {
+ KMessageBox::error(this, i18n("An unexpected error occurred trying to add the new entry"));
+ return;
+ }
+ if (ci->type() == KWallet::Wallet::Password) {
+ _w->writePassword(n, QString::null);
+ } else if (ci->type() == KWallet::Wallet::Map) {
+ _w->writeMap(n, QMap<QString,QString>());
+ } else if (ci->type() == KWallet::Wallet::Stream) {
+ _w->writeEntry(n, QByteArray());
+ } else {
+ abort();
+ }
+ fi->refresh();
+ _ww->_entryTitle->setText(QString("<font size=\"+1\">%1</font>").arg(fi->text(0)));
+ }
+}
+
+
+void KWalletEditor::renameEntry() {
+ QListViewItem *item = _entryList->selectedItem();
+ if (_w && item) {
+ item->startRename(0);
+ }
+}
+
+
+// Only supports renaming of KWalletEntryItem derived classes.
+void KWalletEditor::listItemRenamed(QListViewItem* item, int, const QString& t) {
+ if (item) {
+ KWalletEntryItem *i = dynamic_cast<KWalletEntryItem*>(item);
+ if (!i) {
+ return;
+ }
+
+ if (!_w || t.isEmpty()) {
+ i->setText(0, i->oldName());
+ return;
+ }
+
+ if (_w->renameEntry(i->oldName(), t) == 0) {
+ i->clearOldName();
+ KWalletContainerItem *ci = dynamic_cast<KWalletContainerItem*>(item->parent());
+ if (!ci) {
+ KMessageBox::error(this, i18n("An unexpected error occurred trying to rename the entry"));
+ return;
+ }
+ if (ci->type() == KWallet::Wallet::Password) {
+ _ww->_entryName->setText(i18n("Password: %1").arg(item->text(0)));
+ } else if (ci->type() == KWallet::Wallet::Map) {
+ _ww->_entryName->setText(i18n("Name-Value Map: %1").arg(item->text(0)));
+ } else if (ci->type() == KWallet::Wallet::Stream) {
+ _ww->_entryName->setText(i18n("Binary Data: %1").arg(item->text(0)));
+ }
+ } else {
+ i->setText(0, i->oldName());
+ }
+ }
+}
+
+
+void KWalletEditor::deleteEntry() {
+ QListViewItem *item = _entryList->selectedItem();
+ if (_w && item) {
+ int rc = KMessageBox::warningContinueCancel(this, i18n("Are you sure you wish to delete the item '%1'?").arg(item->text(0)),"",KStdGuiItem::del());
+ if (rc == KMessageBox::Continue) {
+ KWalletFolderItem *fi = dynamic_cast<KWalletFolderItem *>(item->parent()->parent());
+ if (!fi) {
+ KMessageBox::error(this, i18n("An unexpected error occurred trying to delete the entry"));
+ return;
+ }
+ _w->removeEntry(item->text(0));
+ delete item;
+ entrySelectionChanged(_entryList->currentItem());
+ fi->refresh();
+ _ww->_entryTitle->setText(QString("<font size=\"+1\">%1</font>").arg(fi->text(0)));
+ }
+ }
+}
+
+void KWalletEditor::changePassword() {
+ KWallet::Wallet::changePassword(_walletName);
+}
+
+
+void KWalletEditor::walletOpened(bool success) {
+ if (success) {
+ emit enableFolderActions(true);
+ emit enableContextFolderActions(false);
+ emit enableWalletActions(true);
+ updateFolderList();
+ show();
+ _entryList->setWallet(_w);
+ _walletIsOpen = true;
+ } else {
+ if (!_newWallet) {
+ KMessageBox::sorry(this, i18n("Unable to open the requested wallet."));
+ }
+ close();
+ }
+}
+
+
+void KWalletEditor::hidePasswordContents() {
+ _ww->_entryStack->raiseWidget(int(4));
+}
+
+
+void KWalletEditor::showPasswordContents() {
+ _ww->_entryStack->raiseWidget(int(1));
+}
+
+
+void KWalletEditor::showHideMapEditorValue(bool show) {
+ if (show) {
+ _mapEditor->showColumn(2);
+ } else {
+ _mapEditor->hideColumn(2);
+ }
+}
+
+
+enum MergePlan { Prompt = 0, Always = 1, Never = 2, Yes = 3, No = 4 };
+
+void KWalletEditor::importWallet() {
+ KURL url = KFileDialog::getOpenURL(QString::null, "*.kwl", this);
+ if (url.isEmpty()) {
+ return;
+ }
+
+ QString tmpFile;
+ if (!KIO::NetAccess::download(url, tmpFile, this)) {
+ KMessageBox::sorry(this, i18n("Unable to access wallet '<b>%1</b>'.").arg(url.prettyURL()));
+ return;
+ }
+
+ KWallet::Wallet *w = KWallet::Wallet::openWallet(tmpFile, winId(), KWallet::Wallet::Path);
+ if (w && w->isOpen()) {
+ MergePlan mp = Prompt;
+ QStringList fl = w->folderList();
+ for (QStringList::ConstIterator f = fl.constBegin(); f != fl.constEnd(); ++f) {
+ if (!w->setFolder(*f)) {
+ continue;
+ }
+
+ if (!_w->hasFolder(*f)) {
+ _w->createFolder(*f);
+ }
+
+ _w->setFolder(*f);
+
+ QMap<QString, QMap<QString, QString> > map;
+ int rc;
+ rc = w->readMapList("*", map);
+ if (rc == 0) {
+ QMap<QString, QMap<QString, QString> >::ConstIterator me;
+ for (me = map.constBegin(); me != map.constEnd(); ++me) {
+ bool hasEntry = _w->hasEntry(me.key());
+ if (hasEntry && mp == Prompt) {
+ KBetterThanKDialogBase *bd;
+ bd = new KBetterThanKDialogBase(this);
+ bd->setLabel(i18n("Folder '<b>%1</b>' already contains an entry '<b>%2</b>'. Do you wish to replace it?").arg(QStyleSheet::escape(*f)).arg(QStyleSheet::escape(me.key())));
+ mp = (MergePlan)bd->exec();
+ delete bd;
+ bool ok = false;
+ if (mp == Always || mp == Yes) {
+ ok = true;
+ }
+ if (mp == Yes || mp == No) {
+ // reset mp
+ mp = Prompt;
+ }
+ if (!ok) {
+ continue;
+ }
+ } else if (hasEntry && mp == Never) {
+ continue;
+ }
+ _w->writeMap(me.key(), me.data());
+ }
+ }
+
+ QMap<QString, QString> pwd;
+ rc = w->readPasswordList("*", pwd);
+ if (rc == 0) {
+ QMap<QString, QString>::ConstIterator pe;
+ for (pe = pwd.constBegin(); pe != pwd.constEnd(); ++pe) {
+ bool hasEntry = _w->hasEntry(pe.key());
+ if (hasEntry && mp == Prompt) {
+ KBetterThanKDialogBase *bd;
+ bd = new KBetterThanKDialogBase(this);
+ bd->setLabel(i18n("Folder '<b>%1</b>' already contains an entry '<b>%2</b>'. Do you wish to replace it?").arg(QStyleSheet::escape(*f)).arg(QStyleSheet::escape(pe.key())));
+ mp = (MergePlan)bd->exec();
+ delete bd;
+ bool ok = false;
+ if (mp == Always || mp == Yes) {
+ ok = true;
+ }
+ if (mp == Yes || mp == No) {
+ // reset mp
+ mp = Prompt;
+ }
+ if (!ok) {
+ continue;
+ }
+ } else if (hasEntry && mp == Never) {
+ continue;
+ }
+ _w->writePassword(pe.key(), pe.data());
+ }
+ }
+
+ QMap<QString, QByteArray> ent;
+ rc = w->readEntryList("*", ent);
+ if (rc == 0) {
+ QMap<QString, QByteArray>::ConstIterator ee;
+ for (ee = ent.constBegin(); ee != ent.constEnd(); ++ee) {
+ bool hasEntry = _w->hasEntry(ee.key());
+ if (hasEntry && mp == Prompt) {
+ KBetterThanKDialogBase *bd;
+ bd = new KBetterThanKDialogBase(this);
+ bd->setLabel(i18n("Folder '<b>%1</b>' already contains an entry '<b>%2</b>'. Do you wish to replace it?").arg(QStyleSheet::escape(*f)).arg(QStyleSheet::escape(ee.key())));
+ mp = (MergePlan)bd->exec();
+ delete bd;
+ bool ok = false;
+ if (mp == Always || mp == Yes) {
+ ok = true;
+ }
+ if (mp == Yes || mp == No) {
+ // reset mp
+ mp = Prompt;
+ }
+ if (!ok) {
+ continue;
+ }
+ } else if (hasEntry && mp == Never) {
+ continue;
+ }
+ _w->writeEntry(ee.key(), ee.data());
+ }
+ }
+ }
+ }
+
+ delete w;
+
+ KIO::NetAccess::removeTempFile(tmpFile);
+ updateFolderList(true);
+ restoreEntry();
+}
+
+
+void KWalletEditor::importXML() {
+ KURL url = KFileDialog::getOpenURL(QString::null, "*.xml", this);
+ if (url.isEmpty()) {
+ return;
+ }
+
+ QString tmpFile;
+ if (!KIO::NetAccess::download(url, tmpFile, this)) {
+ KMessageBox::sorry(this, i18n("Unable to access XML file '<b>%1</b>'.").arg(url.prettyURL()));
+ return;
+ }
+
+ QFile qf(tmpFile);
+ if (!qf.open(IO_ReadOnly)) {
+ KMessageBox::sorry(this, i18n("Error opening XML file '<b>%1</b>' for input.").arg(url.prettyURL()));
+ KIO::NetAccess::removeTempFile(tmpFile);
+ return;
+ }
+
+ QDomDocument doc(tmpFile);
+ if (!doc.setContent(&qf)) {
+ KMessageBox::sorry(this, i18n("Error reading XML file '<b>%1</b>' for input.").arg(url.prettyURL()));
+ KIO::NetAccess::removeTempFile(tmpFile);
+ return;
+ }
+
+ QDomElement top = doc.documentElement();
+ if (top.tagName().lower() != "wallet") {
+ KMessageBox::sorry(this, i18n("Error: XML file does not contain a wallet."));
+ KIO::NetAccess::removeTempFile(tmpFile);
+ return;
+ }
+
+ QDomNode n = top.firstChild();
+ MergePlan mp = Prompt;
+ while (!n.isNull()) {
+ QDomElement e = n.toElement();
+ if (e.tagName().lower() != "folder") {
+ n = n.nextSibling();
+ continue;
+ }
+
+ QString fname = e.attribute("name");
+ if (fname.isEmpty()) {
+ n = n.nextSibling();
+ continue;
+ }
+ if (!_w->hasFolder(fname)) {
+ _w->createFolder(fname);
+ }
+ _w->setFolder(fname);
+ QDomNode enode = e.firstChild();
+ while (!enode.isNull()) {
+ e = enode.toElement();
+ QString type = e.tagName().lower();
+ QString ename = e.attribute("name");
+ bool hasEntry = _w->hasEntry(ename);
+ if (hasEntry && mp == Prompt) {
+ KBetterThanKDialogBase *bd;
+ bd = new KBetterThanKDialogBase(this);
+ bd->setLabel(i18n("Folder '<b>%1</b>' already contains an entry '<b>%2</b>'. Do you wish to replace it?").arg(QStyleSheet::escape(fname)).arg(QStyleSheet::escape(ename)));
+ mp = (MergePlan)bd->exec();
+ delete bd;
+ bool ok = false;
+ if (mp == Always || mp == Yes) {
+ ok = true;
+ }
+ if (mp == Yes || mp == No) { // reset mp
+ mp = Prompt;
+ }
+ if (!ok) {
+ enode = enode.nextSibling();
+ continue;
+ }
+ } else if (hasEntry && mp == Never) {
+ enode = enode.nextSibling();
+ continue;
+ }
+
+ if (type == "password") {
+ _w->writePassword(ename, e.text());
+ } else if (type == "stream") {
+ _w->writeEntry(ename, KCodecs::base64Decode(e.text().latin1()));
+ } else if (type == "map") {
+ QMap<QString,QString> map;
+ QDomNode mapNode = e.firstChild();
+ while (!mapNode.isNull()) {
+ QDomElement mape = mapNode.toElement();
+ if (mape.tagName().lower() == "mapentry") {
+ map[mape.attribute("name")] = mape.text();
+ }
+ mapNode = mapNode.nextSibling();
+ }
+ _w->writeMap(ename, map);
+ }
+ enode = enode.nextSibling();
+ }
+ n = n.nextSibling();
+ }
+
+ KIO::NetAccess::removeTempFile(tmpFile);
+ updateFolderList(true);
+ restoreEntry();
+}
+
+
+void KWalletEditor::exportXML() {
+ KTempFile tf;
+ tf.setAutoDelete(true);
+ QTextStream& ts(*tf.textStream());
+ QStringList fl = _w->folderList();
+
+ ts << "<wallet name=\"" << _walletName << "\">" << endl;
+ for (QStringList::Iterator i = fl.begin(); i != fl.end(); ++i) {
+ ts << " <folder name=\"" << *i << "\">" << endl;
+ _w->setFolder(*i);
+ QStringList entries = _w->entryList();
+ for (QStringList::Iterator j = entries.begin(); j != entries.end(); ++j) {
+ switch (_w->entryType(*j)) {
+ case KWallet::Wallet::Password:
+ {
+ QString pass;
+ if (_w->readPassword(*j, pass) == 0) {
+ ts << " <password name=\"" << QStyleSheet::escape(*j) << "\">";
+ ts << QStyleSheet::escape(pass);
+ ts << "</password>" << endl;
+ }
+ break;
+ }
+ case KWallet::Wallet::Stream:
+ {
+ QByteArray ba;
+ if (_w->readEntry(*j, ba) == 0) {
+ ts << " <stream name=\"" << QStyleSheet::escape(*j) << "\">";
+ ts << KCodecs::base64Encode(ba);
+
+ ts << "</stream>" << endl;
+ }
+ break;
+ }
+ case KWallet::Wallet::Map:
+ {
+ QMap<QString,QString> map;
+ if (_w->readMap(*j, map) == 0) {
+ ts << " <map name=\"" << QStyleSheet::escape(*j) << "\">" << endl;
+ for (QMap<QString,QString>::ConstIterator k = map.begin(); k != map.end(); ++k) {
+ ts << " <mapentry name=\"" << QStyleSheet::escape(k.key()) << "\">" << QStyleSheet::escape(k.data()) << "</mapentry>" << endl;
+ }
+ ts << " </map>" << endl;
+ }
+ break;
+ }
+ case KWallet::Wallet::Unknown:
+ default:
+ break;
+ }
+ }
+ ts << " </folder>" << endl;
+ }
+
+ ts << "</wallet>" << endl;
+ tf.close();
+
+ KURL url = KFileDialog::getSaveURL(QString::null, "*.xml", this);
+
+ if (!url.isEmpty()) {
+ bool ok = true;
+ if (KIO::NetAccess::exists(url, false, this)) {
+ int rc = KMessageBox::warningContinueCancel(this, i18n("The file '%1' already exists. Would you like to overwrite this file?").arg(url.prettyURL()), i18n("Overwrite"));
+ if (rc == KMessageBox::Cancel) {
+ ok = false;
+ }
+ }
+ if (ok) {
+ KURL tfURL; tfURL.setPath(tf.name());
+ KIO::NetAccess::file_copy(tfURL, url, 0600, true, false, this);
+ }
+ }
+}
+
+
+void KWalletEditor::setNewWallet(bool x) {
+ _newWallet = x;
+}
+
+
+void KWalletEditor::saveAs() {
+ KURL url = KFileDialog::getSaveURL(QString::null, "*.kwl", this);
+ if (!url.isEmpty()) {
+ // Sync() kwalletd
+ if (_nonLocal) {
+ KIO::NetAccess::file_copy(KURL(_walletName), url, 0600, false, false, this);
+ } else {
+ QString path = KGlobal::dirs()->saveLocation("kwallet") + "/" + _walletName + ".kwl";
+ KURL destURL; destURL.setPath(path);
+ KIO::NetAccess::file_copy(destURL, url, 0600, false, false, this);
+ }
+ }
+}
+
+
+#include "kwalleteditor.moc"
+
diff --git a/kwallet/kwalleteditor.h b/kwallet/kwalleteditor.h
new file mode 100644
index 0000000..2a3c9ef
--- /dev/null
+++ b/kwallet/kwalleteditor.h
@@ -0,0 +1,110 @@
+/*
+ Copyright (C) 2003-2005 George Staikos <staikos@kde.org>
+ Copyright (C) 2005 Isaac Clerencia <isaac@warp.es>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef KWALLETEDITOR_H
+#define KWALLETEDITOR_H
+
+#include "walletwidget.h"
+#include <kwallet.h>
+#include <kmainwindow.h>
+#include <qstringlist.h>
+
+class KAction;
+class QIconViewItem;
+class QListViewItem;
+class QCheckBox;
+class KWalletFolderIconView;
+class KWalletEntryList;
+class KWMapEditor;
+
+class KWalletEditor : public KMainWindow {
+ Q_OBJECT
+
+ public:
+ KWalletEditor(const QString& wallet, bool isPath, QWidget *parent = 0, const char* name = 0);
+ virtual ~KWalletEditor();
+
+ bool isOpen() const { return _w != 0L; }
+
+ void setNewWallet(bool newWallet);
+
+ public slots:
+ void walletClosed();
+ void createFolder();
+ void deleteFolder();
+
+ private slots:
+ void layout();
+ void updateFolderList(bool checkEntries = false);
+ void entrySelectionChanged(QListViewItem *item);
+ void listItemRenamed(QListViewItem *, int, const QString&);
+ void listContextMenuRequested(QListViewItem *item, const QPoint& pos, int col);
+ void updateEntries(const QString& folder);
+
+ void newEntry();
+ void renameEntry();
+ void deleteEntry();
+ void entryEditted();
+ void restoreEntry();
+ void saveEntry();
+
+ void changePassword();
+
+ void walletOpened(bool success);
+ void hidePasswordContents();
+ void showPasswordContents();
+ void showHideMapEditorValue(bool show);
+
+ void saveAs();
+ void exportXML();
+ void importXML();
+ void importWallet();
+
+ void copyPassword();
+
+ signals:
+ void enableWalletActions(bool enable);
+ void enableFolderActions(bool enable);
+ void enableContextFolderActions(bool enable);
+ void editorClosed(KMainWindow*);
+
+ public:
+ QString _walletName;
+
+ private:
+ void createActions();
+ bool _nonLocal;
+ KWallet::Wallet *_w;
+ WalletWidget *_ww;
+ KWalletEntryList *_entryList;
+ bool _walletIsOpen;
+ KAction *_newFolderAction, *_deleteFolderAction;
+ KAction *_passwordAction, *_exportAction, *_saveAsAction, *_mergeAction, *_importAction;
+ KAction *_copyPassAction;
+ QLabel*_details;
+ QString _currentFolder;
+ QMap<QString,QString> _currentMap; // save memory by storing
+ // only the most recent map.
+ KWMapEditor *_mapEditor;
+ QCheckBox *_mapEditorShowHide;
+ bool _newWallet;
+};
+
+#endif
diff --git a/kwallet/kwalleteditor.rc b/kwallet/kwalleteditor.rc
new file mode 100644
index 0000000..9c4faf5
--- /dev/null
+++ b/kwallet/kwalleteditor.rc
@@ -0,0 +1,17 @@
+<!DOCTYPE kpartgui>
+<kpartgui name="kwalleteditor" version="2">
+ <MenuBar>
+ <Menu name="file"><text>&amp;File</text>
+ <Action name="create_folder"/>
+ <Action name="delete_folder"/>
+ <Separator/>
+ <Action name="change_password"/>
+ <Separator/>
+ <Action name="merge"/>
+ <Action name="import"/>
+ <Action name="export"/>
+ </Menu>
+ <Menu name="help"><text>&amp;Help</text>
+ </Menu>
+ </MenuBar>
+</kpartgui>
diff --git a/kwallet/kwalletmanager-kwalletd.desktop b/kwallet/kwalletmanager-kwalletd.desktop
new file mode 100644
index 0000000..e9d38ac
--- /dev/null
+++ b/kwallet/kwalletmanager-kwalletd.desktop
@@ -0,0 +1,60 @@
+[Desktop Entry]
+Name=Wallet Management Tool
+Name[ar]=أداة إدارة المحفظة
+Name[bg]=Портфейл
+Name[br]=Merour an doug-paperoù
+Name[bs]=Alat za upravljanje novčanikom
+Name[ca]=Eina de gestió de carteres
+Name[cs]=Nástroj pro správu úschovny
+Name[cy]=Erfyn Rheoli Waled
+Name[da]=Håndteringsværktøj for tegnebog
+Name[de]=Verwaltung für digitale Brieftasche
+Name[el]=Εργαλείο διαχείρισης πορτοφολιού
+Name[es]=Herramienta de gestión de cartera
+Name[et]=Turvalaeka haldur
+Name[eu]=Kartera Kudeatzeko Tresna
+Name[fa]=ابزار مدیریت Wallet
+Name[fi]=Lompakon hallintatyökalu
+Name[fr]=Outil de gestion de comptes
+Name[ga]=Uirlis Bhainisteoireachta Wallet
+Name[he]=כלי לניהול הארנק של KDE
+Name[hi]= बटुआ प्रबंधन औज़ार
+Name[hu]=Kezelőprogram a KDE digitális noteszeihez
+Name[is]=Tól til að stýra eiginleikum veskisins
+Name[it]=Strumento per la gestione dei portafogli
+Name[ja]=ウォレット管理ツール
+Name[ka]=Wallet-ის მმართველი მოწყობილობა
+Name[kk]=Әмиянін басқару құралы
+Name[km]=ឧបករណ៍​គ្រប់គ្រង​កាបូប
+Name[lt]=Spatažodinių tvarkymo įrankis
+Name[mk]=Алатка за менаџирање на паричници
+Name[nb]=Wallet administrasjonsverktøy
+Name[nds]=Knipp-Pleger
+Name[ne]=वालेट व्यवस्थापन उपकरण
+Name[nl]=Portefeuillebeheer
+Name[nn]=Wallet-administrasjonsverktøy
+Name[pa]=ਵਾਲਿਟ ਪਰਬੰਧਨ ਸੰਦ
+Name[pl]=Narzędzie do zarządzania Portfelem
+Name[pt]=Ferramenta de Gestão da Carteira
+Name[pt_BR]=Ferramenta de Gerenciamento da Carteira
+Name[ro]=Administrare portofel
+Name[ru]=Управление паролями
+Name[sk]=Nástroj na správu KWallet
+Name[sl]=Orodje za upravljanje z listnicami
+Name[sr]=Алат за управљање новчаником
+Name[sr@Latn]=Alat za upravljanje novčanikom
+Name[sv]=Hanteringsverktyg för plånbok
+Name[ta]=வாலட் மேலாண்மை கருவி
+Name[tg]=Асбоби Идоракунии Ҳамён
+Name[tr]=Cüzdan Yönetim Aracı
+Name[uk]=Засіб керування торбинками
+Name[uz]=Qopchiq boshqarish vositasi
+Name[uz@cyrillic]=Қопчиқ бошқариш воситаси
+Name[zh_CN]=钱包管理工具
+Name[zh_TW]=錢包管理工具
+Exec=kwalletmanager --kwalletd
+Icon=kwalletmanager
+Type=Application
+Terminal=false
+X-KDE-StartupNotify=false
+NoDisplay=true
diff --git a/kwallet/kwalletmanager.cpp b/kwallet/kwalletmanager.cpp
new file mode 100644
index 0000000..a4fe6cf
--- /dev/null
+++ b/kwallet/kwalletmanager.cpp
@@ -0,0 +1,423 @@
+/*
+ Copyright (C) 2003,2004 George Staikos <staikos@kde.org>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+
+#include "kwalletmanager.h"
+#include "kwalletpopup.h"
+#include "kwalleteditor.h"
+#include "allyourbase.h"
+
+#include <dcopclient.h>
+#include <dcopref.h>
+#include <kaction.h>
+#include <kapplication.h>
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kiconloader.h>
+#include <kiconview.h>
+#include <kinputdialog.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kstandarddirs.h>
+#include <kstdaction.h>
+#include <ksystemtray.h>
+#include <kwallet.h>
+
+#include <qaccel.h>
+#include <qguardedptr.h>
+#include <qptrstack.h>
+#include <qregexp.h>
+#include <qtimer.h>
+#include <qtooltip.h>
+
+KWalletManager::KWalletManager(QWidget *parent, const char *name, WFlags f)
+: KMainWindow(parent, name, f), DCOPObject("KWalletManager") {
+ KGlobal::dirs()->addResourceType("kwallet", "share/apps/kwallet");
+ _kwalletdLaunch = false;
+ QAccel *accel = new QAccel(this, "kwalletmanager");
+
+ KApplication::dcopClient()->setQtBridgeEnabled(false);
+ _shuttingDown = false;
+ KConfig cfg("kwalletrc"); // not sure why this setting isn't in kwalletmanagerrc...
+ KConfigGroup walletConfigGroup(&cfg, "Wallet");
+ _dcopRef = 0L;
+ if (walletConfigGroup.readBoolEntry("Launch Manager", true)) {
+ _tray = new KSystemTray(this, "kwalletmanager tray");
+ _tray->setPixmap(loadSystemTrayIcon("wallet_closed"));
+ QToolTip::add(_tray, i18n("KDE Wallet: No wallets open."));
+ connect(_tray, SIGNAL(quitSelected()), SLOT(shuttingDown()));
+ QStringList wl = KWallet::Wallet::walletList();
+ bool isOpen = false;
+ for (QStringList::Iterator it = wl.begin(); it != wl.end(); ++it) {
+ if (KWallet::Wallet::isOpen(*it)) {
+ _tray->setPixmap(loadSystemTrayIcon("wallet_open"));
+ QToolTip::remove(_tray);
+ QToolTip::add(_tray, i18n("KDE Wallet: A wallet is open."));
+ isOpen = true;
+ break;
+ }
+ }
+ if (!isOpen && kapp->isRestored()) {
+ delete _tray;
+ _tray = 0L;
+ QTimer::singleShot( 0, kapp, SLOT( quit()));
+ return;
+ }
+ } else {
+ _tray = 0L;
+ }
+
+ _iconView = new KWalletIconView(this, "kwalletmanager icon view");
+ connect(_iconView, SIGNAL(executed(QIconViewItem*)), this, SLOT(openWallet(QIconViewItem*)));
+ connect(_iconView, SIGNAL(contextMenuRequested(QIconViewItem*, const QPoint&)), this, SLOT(contextMenu(QIconViewItem*, const QPoint&)));
+
+ updateWalletDisplay();
+ setCentralWidget(_iconView);
+ _iconView->setMinimumSize(320, 200);
+
+ _dcopRef = new DCOPRef("kded", "kwalletd");
+ _dcopRef->dcopClient()->setNotifications(true);
+ connect(_dcopRef->dcopClient(),
+ SIGNAL(applicationRemoved(const QCString&)),
+ this,
+ SLOT(possiblyRescan(const QCString&)));
+ connect(_dcopRef->dcopClient(),
+ SIGNAL(applicationRegistered(const QCString&)),
+ this,
+ SLOT(possiblyRescan(const QCString&)));
+
+ connectDCOPSignal(_dcopRef->app(), _dcopRef->obj(), "allWalletsClosed()", "allWalletsClosed()", false);
+ connectDCOPSignal(_dcopRef->app(), _dcopRef->obj(), "walletClosed(QString)", "updateWalletDisplay()", false);
+ connectDCOPSignal(_dcopRef->app(), _dcopRef->obj(), "walletOpened(QString)", "aWalletWasOpened()", false);
+ connectDCOPSignal(_dcopRef->app(), _dcopRef->obj(), "walletDeleted(QString)", "updateWalletDisplay()", false);
+ connectDCOPSignal(_dcopRef->app(), _dcopRef->obj(), "walletListDirty()", "updateWalletDisplay()", false);
+
+ // FIXME: slight race - a wallet can open, then we get launched, but the
+ // wallet closes before we are done opening. We will then stay
+ // open. Must check that a wallet is still open here.
+
+ new KAction(i18n("&New Wallet..."), "kwalletmanager", 0, this,
+ SLOT(createWallet()), actionCollection(),
+ "wallet_create");
+ KAction *act = new KAction(i18n("Configure &Wallet..."), "configure",
+ 0, this, SLOT(setupWallet()), actionCollection(),
+ "wallet_settings");
+ if (_tray) {
+ act->plug(_tray->contextMenu());
+ }
+ act = new KAction(i18n("Close &All Wallets"), 0, 0, this,
+ SLOT(closeAllWallets()), actionCollection(),
+ "close_all_wallets");
+ if (_tray) {
+ act->plug(_tray->contextMenu());
+ }
+ KStdAction::quit(this, SLOT(shuttingDown()), actionCollection());
+ KStdAction::keyBindings(guiFactory(), SLOT(configureShortcuts()),
+actionCollection());
+
+ createGUI("kwalletmanager.rc");
+ accel->connectItem(accel->insertItem(Key_Return), this, SLOT(openWallet()));
+ accel->connectItem(accel->insertItem(Key_Delete), this, SLOT(deleteWallet()));
+
+ if (_tray) {
+ _tray->show();
+ } else {
+ show();
+ }
+
+ kapp->setName("kwallet"); // hack to fix docs
+}
+
+
+KWalletManager::~KWalletManager() {
+ _tray = 0L;
+ delete _dcopRef;
+ _dcopRef = 0L;
+}
+
+
+void KWalletManager::kwalletdLaunch() {
+ _kwalletdLaunch = true;
+}
+
+
+bool KWalletManager::queryClose() {
+ if (!_shuttingDown && !kapp->sessionSaving()) {
+ if (!_tray) {
+ kapp->quit();
+ } else {
+ hide();
+ }
+ return false;
+ }
+ return true;
+}
+
+
+void KWalletManager::aWalletWasOpened() {
+ if (_tray) {
+ _tray->setPixmap(loadSystemTrayIcon("wallet_open"));
+ QToolTip::remove(_tray);
+ QToolTip::add(_tray, i18n("KDE Wallet: A wallet is open."));
+ }
+ updateWalletDisplay();
+}
+
+
+void KWalletManager::updateWalletDisplay() {
+QStringList wl = KWallet::Wallet::walletList();
+QPtrStack<QIconViewItem> trash;
+
+ for (QIconViewItem *item = _iconView->firstItem(); item; item = item->nextItem()) {
+ if (!wl.contains(item->text())) {
+ trash.push(item);
+ }
+ }
+
+ trash.setAutoDelete(true);
+ trash.clear();
+
+ for (QStringList::Iterator i = wl.begin(); i != wl.end(); ++i) {
+ if (!_iconView->findItem(*i)) {
+ // FIXME: if KWallet::Wallet::isOpen(*i) then show
+ // a different icon!
+ new KWalletItem(_iconView, *i);
+ } else {
+ // FIXME: See if icon needs to be updated
+ }
+ }
+}
+
+
+void KWalletManager::contextMenu(QIconViewItem *item, const QPoint& pos) {
+ if (item) {
+ QGuardedPtr<KWalletPopup> popupMenu = new KWalletPopup(item->text(), this);
+ connect(popupMenu, SIGNAL(walletOpened(const QString&)), this, SLOT(openWallet(const QString&)));
+ connect(popupMenu, SIGNAL(walletClosed(const QString&)), this, SLOT(closeWallet(const QString&)));
+ connect(popupMenu, SIGNAL(walletDeleted(const QString&)), this, SLOT(deleteWallet(const QString&)));
+ connect(popupMenu, SIGNAL(walletChangePassword(const QString&)), this, SLOT(changeWalletPassword(const QString&)));
+ connect(popupMenu, SIGNAL(walletCreated()), this, SLOT(createWallet()));
+ popupMenu->exec(pos);
+ delete popupMenu;
+ }
+}
+
+
+void KWalletManager::deleteWallet(const QString& walletName) {
+ int rc = KMessageBox::warningContinueCancel(this, i18n("Are you sure you wish to delete the wallet '%1'?").arg(walletName),"",KStdGuiItem::del());
+ if (rc != KMessageBox::Continue) {
+ return;
+ }
+ rc = KWallet::Wallet::deleteWallet(walletName);
+ if (rc != 0) {
+ KMessageBox::sorry(this, i18n("Unable to delete the wallet. Error code was %1.").arg(rc));
+ }
+ updateWalletDisplay();
+}
+
+
+void KWalletManager::closeWallet(const QString& walletName) {
+ int rc = KWallet::Wallet::closeWallet(walletName, false);
+ if (rc != 0) {
+ rc = KMessageBox::warningYesNo(this, i18n("Unable to close wallet cleanly. It is probably in use by other applications. Do you wish to force it closed?"), QString::null, i18n("Force Closure"), i18n("Do Not Force"));
+ if (rc == KMessageBox::Yes) {
+ rc = KWallet::Wallet::closeWallet(walletName, true);
+ if (rc != 0) {
+ KMessageBox::sorry(this, i18n("Unable to force the wallet closed. Error code was %1.").arg(rc));
+ }
+ }
+ }
+
+ updateWalletDisplay();
+}
+
+
+void KWalletManager::changeWalletPassword(const QString& walletName) {
+ KWallet::Wallet::changePassword(walletName);
+}
+
+
+void KWalletManager::openWalletFile(const QString& path) {
+ KWalletEditor *we = new KWalletEditor(path, true, this, "Wallet Editor");
+ if (we->isOpen()) {
+ connect(we, SIGNAL(editorClosed(KMainWindow*)),
+ this, SLOT(editorClosed(KMainWindow*)));
+ we->show();
+ } else {
+ KMessageBox::sorry(this, i18n("Error opening wallet %1.").arg(path));
+ delete we;
+ }
+}
+
+
+void KWalletManager::openWallet() {
+ QIconViewItem *item = _iconView->currentItem();
+ openWallet(item);
+}
+
+void KWalletManager::deleteWallet() {
+ QIconViewItem *item = _iconView->currentItem();
+ if (item) {
+ deleteWallet(item->text());
+ }
+}
+
+
+void KWalletManager::openWallet(const QString& walletName) {
+ openWallet(walletName, false);
+}
+
+
+void KWalletManager::openWallet(const QString& walletName, bool newWallet) {
+ // Don't allow a wallet to open in two windows
+ for (KMainWindow *w = _windows.first(); w; w = _windows.next()) {
+ KWalletEditor *e = static_cast<KWalletEditor*>(w);
+ if (e->isOpen() && e->_walletName == walletName) {
+ w->raise();
+ return;
+ }
+ }
+
+ KWalletEditor *we = new KWalletEditor(walletName, false, this, "Wallet Editor");
+ we->setNewWallet(newWallet);
+ if (we->isOpen()) {
+ connect(we, SIGNAL(editorClosed(KMainWindow*)),
+ this, SLOT(editorClosed(KMainWindow*)));
+ we->show();
+ _windows.append(we);
+ } else if (!newWallet) {
+ KMessageBox::sorry(this, i18n("Error opening wallet %1.").arg(walletName));
+ delete we;
+ }
+}
+
+
+void KWalletManager::openWallet(QIconViewItem *item) {
+ if (item) {
+ openWallet(item->text());
+ }
+}
+
+
+void KWalletManager::allWalletsClosed() {
+ if (_tray) {
+ _tray->setPixmap(loadSystemTrayIcon("wallet_closed"));
+ QToolTip::remove(_tray);
+ QToolTip::add(_tray, i18n("KDE Wallet: No wallets open."));
+ }
+ possiblyQuit();
+}
+
+
+void KWalletManager::possiblyQuit() {
+ KConfig cfg("kwalletrc");
+ cfg.setGroup("Wallet");
+ if (_windows.isEmpty() &&
+ !isVisible() &&
+ !cfg.readBoolEntry("Leave Manager Open", false) &&
+ _kwalletdLaunch) {
+ kapp->quit();
+ }
+}
+
+
+void KWalletManager::editorClosed(KMainWindow* e) {
+ _windows.remove(e);
+}
+
+
+void KWalletManager::possiblyRescan(const QCString& app) {
+ if (app == "kded") {
+ updateWalletDisplay();
+ }
+}
+
+
+void KWalletManager::createWallet() {
+ QString n;
+ bool ok;
+ // FIXME: support international names
+ QRegExp regexp("^[A-Za-z0-9]+[A-Za-z0-9_\\s\\-]*$");
+ QString txt = i18n("Please choose a name for the new wallet:");
+
+ if (!KWallet::Wallet::isEnabled()) {
+ // FIXME: KMessageBox::warningYesNo(this, i1_8n("KWallet is not enabled. Do you want to enable it?"), QString::null, i18n("Enable"), i18n("Keep Disabled"));
+ return;
+ }
+
+ do {
+ n = KInputDialog::getText(i18n("New Wallet"),
+ txt,
+ QString::null,
+ &ok,
+ this);
+
+ if (!ok) {
+ return;
+ }
+
+ if (_iconView->findItem(n)) {
+ int rc = KMessageBox::questionYesNo(this, i18n("Sorry, that wallet already exists. Try a new name?"), QString::null, i18n("Try New"), i18n("Do Not Try"));
+ if (rc == KMessageBox::Yes) {
+ continue;
+ }
+ n = QString::null;
+ } else if (regexp.exactMatch(n)) {
+ break;
+ } else {
+ txt = i18n("Please choose a name that contains only alphanumeric characters:");
+ }
+ } while (true);
+
+ // Small race here - the wallet could be created on us already.
+ if (!n.isEmpty()) {
+ openWallet(n, true);
+ }
+}
+
+
+void KWalletManager::shuttingDown() {
+ _shuttingDown = true;
+ kapp->quit();
+}
+
+
+void KWalletManager::setupWallet() {
+ KApplication::startServiceByDesktopName("kwallet_config");
+}
+
+
+void KWalletManager::closeAllWallets() {
+ _dcopRef->call("closeAllWallets");
+}
+
+
+QPixmap KWalletManager::loadSystemTrayIcon(const QString &icon) {
+#if KDE_IS_VERSION(3, 1, 90)
+ return KSystemTray::loadIcon(icon);
+#else
+ KConfig *appCfg = kapp->config();
+ KConfigGroupSaver configSaver(appCfg, "System Tray");
+ int iconWidth = appCfg->readNumEntry("systrayIconWidth", 22);
+ return kapp->iconLoader()->loadIcon( icon, KIcon::Panel, iconWidth );
+#endif
+}
+
+
+#include "kwalletmanager.moc"
diff --git a/kwallet/kwalletmanager.desktop b/kwallet/kwalletmanager.desktop
new file mode 100644
index 0000000..7884977
--- /dev/null
+++ b/kwallet/kwalletmanager.desktop
@@ -0,0 +1,63 @@
+[Desktop Entry]
+Name=Wallet Management Tool
+Name[ar]=أداة إدارة المحفظة
+Name[bg]=Портфейл
+Name[br]=Merour an doug-paperoù
+Name[bs]=Alat za upravljanje novčanikom
+Name[ca]=Eina de gestió de carteres
+Name[cs]=Nástroj pro správu úschovny
+Name[cy]=Erfyn Rheoli Waled
+Name[da]=Håndteringsværktøj for tegnebog
+Name[de]=Verwaltung für digitale Brieftasche
+Name[el]=Εργαλείο διαχείρισης πορτοφολιού
+Name[es]=Herramienta de gestión de cartera
+Name[et]=Turvalaeka haldur
+Name[eu]=Kartera Kudeatzeko Tresna
+Name[fa]=ابزار مدیریت Wallet
+Name[fi]=Lompakon hallintatyökalu
+Name[fr]=Outil de gestion de comptes
+Name[ga]=Uirlis Bhainisteoireachta Wallet
+Name[he]=כלי לניהול הארנק של KDE
+Name[hi]= बटुआ प्रबंधन औज़ार
+Name[hu]=Kezelőprogram a KDE digitális noteszeihez
+Name[is]=Tól til að stýra eiginleikum veskisins
+Name[it]=Strumento per la gestione dei portafogli
+Name[ja]=ウォレット管理ツール
+Name[ka]=Wallet-ის მმართველი მოწყობილობა
+Name[kk]=Әмиянін басқару құралы
+Name[km]=ឧបករណ៍​គ្រប់គ្រង​កាបូប
+Name[lt]=Spatažodinių tvarkymo įrankis
+Name[mk]=Алатка за менаџирање на паричници
+Name[nb]=Wallet administrasjonsverktøy
+Name[nds]=Knipp-Pleger
+Name[ne]=वालेट व्यवस्थापन उपकरण
+Name[nl]=Portefeuillebeheer
+Name[nn]=Wallet-administrasjonsverktøy
+Name[pa]=ਵਾਲਿਟ ਪਰਬੰਧਨ ਸੰਦ
+Name[pl]=Narzędzie do zarządzania Portfelem
+Name[pt]=Ferramenta de Gestão da Carteira
+Name[pt_BR]=Ferramenta de Gerenciamento da Carteira
+Name[ro]=Administrare portofel
+Name[ru]=Управление паролями
+Name[sk]=Nástroj na správu KWallet
+Name[sl]=Orodje za upravljanje z listnicami
+Name[sr]=Алат за управљање новчаником
+Name[sr@Latn]=Alat za upravljanje novčanikom
+Name[sv]=Hanteringsverktyg för plånbok
+Name[ta]=வாலட் மேலாண்மை கருவி
+Name[tg]=Асбоби Идоракунии Ҳамён
+Name[tr]=Cüzdan Yönetim Aracı
+Name[uk]=Засіб керування торбинками
+Name[uz]=Qopchiq boshqarish vositasi
+Name[uz@cyrillic]=Қопчиқ бошқариш воситаси
+Name[zh_CN]=钱包管理工具
+Name[zh_TW]=錢包管理工具
+Exec=kwalletmanager %u
+MimeType=application/x-kde-wallet;
+InitialPreference=6
+Icon=kwalletmanager
+Type=Application
+Terminal=false
+X-KDE-StartupNotify=false
+Categories=Qt;KDE;Settings;
+DocPath=kwallet/index.html
diff --git a/kwallet/kwalletmanager.h b/kwallet/kwalletmanager.h
new file mode 100644
index 0000000..0c28839
--- /dev/null
+++ b/kwallet/kwalletmanager.h
@@ -0,0 +1,84 @@
+/*
+ Copyright (C) 2003,2004 George Staikos <staikos@kde.org>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef KWALLETMANAGER_H
+#define KWALLETMANAGER_H
+
+#include <kmainwindow.h>
+#include <dcopobject.h>
+#include <qptrlist.h>
+
+class KSystemTray;
+class KWalletIconView;
+class QIconViewItem;
+class DCOPRef;
+
+
+class KWalletManager : public KMainWindow, public DCOPObject {
+ Q_OBJECT
+ K_DCOP
+
+ public:
+ KWalletManager(QWidget *parent = 0, const char* name = 0, WFlags f = 0);
+ virtual ~KWalletManager();
+
+ QPixmap loadSystemTrayIcon(const QString &icon);
+
+ void kwalletdLaunch();
+
+ public slots:
+ void createWallet();
+ void deleteWallet(const QString& walletName);
+ void closeWallet(const QString& walletName);
+ void changeWalletPassword(const QString& walletName);
+ void openWallet(const QString& walletName);
+ void openWallet(const QString& walletName, bool newWallet);
+ void openWalletFile(const QString& path);
+ void openWallet(QIconViewItem *item);
+ void contextMenu(QIconViewItem *item, const QPoint& pos);
+
+ protected:
+ virtual bool queryClose();
+
+ private:
+ k_dcop:
+ ASYNC allWalletsClosed();
+ ASYNC updateWalletDisplay();
+ ASYNC aWalletWasOpened();
+
+ private slots:
+ void shuttingDown();
+ void possiblyQuit();
+ void editorClosed(KMainWindow* e);
+ void possiblyRescan(const QCString& app);
+ void setupWallet();
+ void openWallet();
+ void deleteWallet();
+ void closeAllWallets();
+
+ private:
+ KSystemTray *_tray;
+ bool _shuttingDown;
+ KWalletIconView *_iconView;
+ DCOPRef *_dcopRef;
+ QPtrList<KMainWindow> _windows;
+ bool _kwalletdLaunch;
+};
+
+#endif
diff --git a/kwallet/kwalletmanager.rc b/kwallet/kwalletmanager.rc
new file mode 100644
index 0000000..a1fd2c8
--- /dev/null
+++ b/kwallet/kwalletmanager.rc
@@ -0,0 +1,14 @@
+<!DOCTYPE kpartgui>
+<kpartgui name="kwalletmanager" version="3">
+ <MenuBar>
+ <Menu name="file"><text>&amp;File</text>
+ <Action name="wallet_create"/>
+ <Action name="close_all_wallets"/>
+ </Menu>
+ <Menu name="settings"><text>&amp;Settings</text>
+ <Action name="wallet_settings" append="configure_merge"/>
+ </Menu>
+ <Menu name="help"><text>&amp;Help</text>
+ </Menu>
+ </MenuBar>
+</kpartgui>
diff --git a/kwallet/kwalletpopup.cpp b/kwallet/kwalletpopup.cpp
new file mode 100644
index 0000000..3f2082e
--- /dev/null
+++ b/kwallet/kwalletpopup.cpp
@@ -0,0 +1,110 @@
+/*
+ Copyright (C) 2003 George Staikos <staikos@kde.org>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+
+#include "kwalletpopup.h"
+
+#include <kaction.h>
+#include <kdebug.h>
+#include <kiconview.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kwallet.h>
+#include <kstdguiitem.h>
+
+KWalletPopup::KWalletPopup(const QString& wallet, QWidget *parent, const char *name)
+: KPopupMenu(parent, name), _walletName(wallet) {
+ insertTitle(wallet);
+ KActionCollection *ac = new KActionCollection(this, "kwallet context actions");
+ KAction *act;
+
+ act = new KAction(i18n("&New Wallet..."), 0, 0, this,
+ SLOT(createWallet()), ac, "wallet_create");
+ act->plug(this);
+
+ act = new KAction(i18n("&Open..."), 0, Key_Return, this,
+ SLOT(openWallet()), ac, "wallet_open");
+ act->plug(this);
+
+ act = new KAction(i18n("Change &Password..."), 0, 0, this,
+ SLOT(changeWalletPassword()), ac, "wallet_password");
+ act->plug(this);
+
+ QStringList ul = KWallet::Wallet::users(wallet);
+ if (!ul.isEmpty()) {
+ KPopupMenu *pm = new KPopupMenu(this, "Disconnect Apps");
+ int id = 7000;
+ for (QStringList::Iterator it = ul.begin(); it != ul.end(); ++it) {
+ _appMap[id] = *it;
+ pm->insertItem(*it, this, SLOT(disconnectApp(int)), 0, id);
+ pm->setItemParameter(id, id);
+ id++;
+ }
+
+ insertItem(i18n("Disconnec&t"), pm);
+ }
+
+ act = KStdAction::close( this,
+ SLOT(closeWallet()), ac, "wallet_close");
+ // FIXME: let's track this inside the manager so we don't need a dcop
+ // roundtrip here.
+ act->setEnabled(KWallet::Wallet::isOpen(wallet));
+ act->plug(this);
+
+ act = new KAction(i18n("&Delete"), 0, Key_Delete, this,
+ SLOT(deleteWallet()), ac, "wallet_delete");
+ act->plug(this);
+}
+
+
+KWalletPopup::~KWalletPopup() {
+}
+
+
+void KWalletPopup::openWallet() {
+ emit walletOpened(_walletName);
+}
+
+
+void KWalletPopup::deleteWallet() {
+ emit walletDeleted(_walletName);
+}
+
+
+void KWalletPopup::closeWallet() {
+ emit walletClosed(_walletName);
+}
+
+
+void KWalletPopup::changeWalletPassword() {
+ emit walletChangePassword(_walletName);
+}
+
+
+void KWalletPopup::createWallet() {
+ emit walletCreated();
+}
+
+
+void KWalletPopup::disconnectApp(int id) {
+ KWallet::Wallet::disconnectApplication(_walletName, _appMap[id].latin1());
+}
+
+#include "kwalletpopup.moc"
+
diff --git a/kwallet/kwalletpopup.h b/kwallet/kwalletpopup.h
new file mode 100644
index 0000000..c704d69
--- /dev/null
+++ b/kwallet/kwalletpopup.h
@@ -0,0 +1,54 @@
+/*
+ Copyright (C) 2003 George Staikos <staikos@kde.org>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef KWALLETPOPUP_H
+#define KWALLETPOPUP_H
+
+#include <kpopupmenu.h>
+#include <qmap.h>
+#include <qstring.h>
+
+class KWalletPopup : public KPopupMenu {
+ Q_OBJECT
+
+ public:
+ KWalletPopup(const QString& wallet, QWidget *parent = 0, const char* name = 0);
+ virtual ~KWalletPopup();
+
+ public slots:
+ void openWallet();
+ void deleteWallet();
+ void closeWallet();
+ void createWallet();
+ void changeWalletPassword();
+ void disconnectApp(int);
+
+ signals:
+ void walletOpened(const QString& walletName);
+ void walletClosed(const QString& walletName);
+ void walletDeleted(const QString& walletName);
+ void walletCreated();
+ void walletChangePassword(const QString& walletName);
+
+ private:
+ QString _walletName;
+ QMap<int,QString> _appMap;
+};
+
+#endif
diff --git a/kwallet/kwmapeditor.cpp b/kwallet/kwmapeditor.cpp
new file mode 100644
index 0000000..a15b9c9
--- /dev/null
+++ b/kwallet/kwmapeditor.cpp
@@ -0,0 +1,187 @@
+/*
+ Copyright (C) 2003,2004 George Staikos <staikos@kde.org>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "kwmapeditor.h"
+
+#include <kaction.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kpopupmenu.h>
+#include <kstdaction.h>
+#include <kwin.h>
+
+#include <qapplication.h>
+#include <qclipboard.h>
+#include <qpushbutton.h>
+#include <qtextedit.h>
+
+KWMapEditor::KWMapEditor(QMap<QString,QString>& map, QWidget *parent, const char *name)
+: QTable(0, 3, parent, name), _map(map) {
+ _ac = new KActionCollection(this);
+ _copyAct = KStdAction::copy(this, SLOT(copy()), _ac);
+ connect(this, SIGNAL(valueChanged(int,int)), this, SIGNAL(dirty()));
+ connect(this, SIGNAL(contextMenuRequested(int,int,const QPoint&)),
+ this, SLOT(contextMenu(int,int,const QPoint&)));
+ setSelectionMode(QTable::NoSelection);
+ horizontalHeader()->setLabel(0, QString::null);
+ horizontalHeader()->setLabel(1, i18n("Key"));
+ horizontalHeader()->setLabel(2, i18n("Value"));
+ setColumnWidth(0, 20); // FIXME: this is arbitrary
+ reload();
+}
+
+void KWMapEditor::reload() {
+ unsigned row = 0;
+
+ while ((row = numRows()) > _map.count()) {
+ removeRow(row - 1);
+ }
+
+ if ((row = numRows()) < _map.count()) {
+ insertRows(row, _map.count() - row);
+ for (int x = row; x < numRows(); ++x) {
+ QPushButton *b = new QPushButton("X", this);
+ connect(b, SIGNAL(clicked()), this, SLOT(erase()));
+ setCellWidget(x, 0, b);
+ }
+ }
+
+ row = 0;
+ for (QMap<QString,QString>::Iterator it = _map.begin(); it != _map.end(); ++it) {
+ setText(row, 1, it.key());
+ setText(row, 2, it.data());
+ row++;
+ }
+}
+
+
+KWMapEditor::~KWMapEditor() {
+}
+
+
+void KWMapEditor::erase() {
+ const QObject *o = sender();
+ for (int i = 0; i < numRows(); i++) {
+ if (cellWidget(i, 0) == o) {
+ removeRow(i);
+ break;
+ }
+ }
+
+ emit dirty();
+}
+
+
+void KWMapEditor::saveMap() {
+ _map.clear();
+
+ for (int i = 0; i < numRows(); i++) {
+ _map[text(i, 1)] = text(i, 2);
+ }
+}
+
+
+void KWMapEditor::addEntry() {
+ int x = numRows();
+ insertRows(x, 1);
+ QPushButton *b = new QPushButton("X", this);
+ connect(b, SIGNAL(clicked()), this, SLOT(erase()));
+ setCellWidget(x, 0, b);
+ ensureCellVisible(x, 1);
+ setCurrentCell(x, 1);
+ emit dirty();
+}
+
+
+void KWMapEditor::emitDirty() {
+ emit dirty();
+}
+
+
+void KWMapEditor::contextMenu(int row, int col, const QPoint& pos) {
+ _contextRow = row;
+ _contextCol = col;
+ KPopupMenu *m = new KPopupMenu(this);
+ m->insertItem(i18n("&New Entry"), this, SLOT(addEntry()));
+ _copyAct->plug(m);
+ m->popup(pos);
+}
+
+
+void KWMapEditor::copy() {
+ QApplication::clipboard()->setText(text(_contextRow, 2));
+}
+
+
+class InlineEditor : public QTextEdit {
+ public:
+ InlineEditor(KWMapEditor *p, int row, int col)
+ : QTextEdit(), _p(p), row(row), col(col) {
+ setWFlags(WStyle_NoBorder | WDestructiveClose);
+ KWin::setType(winId(), NET::Override);
+ connect(p, SIGNAL(destroyed()), SLOT(close()));
+ }
+ virtual ~InlineEditor() { if (!_p) return; _p->setText(row, col, text()); _p->emitDirty(); }
+
+ protected:
+ virtual void focusOutEvent(QFocusEvent*) {
+ if (QFocusEvent::reason() == QFocusEvent::Popup) {
+ QWidget *focusW = qApp->focusWidget();
+ if (focusW && focusW == popup) {
+ return;
+ }
+ }
+ close();
+ }
+ virtual void keyPressEvent(QKeyEvent *e) {
+ if (e->key() == Qt::Key_Escape) {
+ e->accept();
+ close();
+ } else {
+ e->ignore();
+ QTextEdit::keyPressEvent(e);
+ }
+ }
+ virtual QPopupMenu *createPopupMenu(const QPoint &p) {
+ popup = QTextEdit::createPopupMenu(p);
+ return popup;
+ }
+ QGuardedPtr<KWMapEditor> _p;
+ int row, col;
+ QGuardedPtr<QPopupMenu> popup;
+};
+
+
+QWidget *KWMapEditor::beginEdit(int row, int col, bool replace) {
+ //kdDebug(2300) << "EDIT COLUMN " << col << endl;
+ if (col != 2) {
+ return QTable::beginEdit(row, col, replace);
+ }
+
+ QRect geo = cellGeometry(row, col);
+ QTextEdit *e = new InlineEditor(this, row, col);
+ e->setText(text(row, col));
+ e->move(mapToGlobal(geo.topLeft()));
+ e->resize(geo.width() * 2, geo.height() * 3);
+ e->show();
+ return e;
+}
+
+
+#include "kwmapeditor.moc"
diff --git a/kwallet/kwmapeditor.h b/kwallet/kwmapeditor.h
new file mode 100644
index 0000000..8322a91
--- /dev/null
+++ b/kwallet/kwmapeditor.h
@@ -0,0 +1,61 @@
+/*
+ Copyright (C) 2003,2004 George Staikos <staikos@kde.org>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef KWMAPEDITOR_H
+#define KWMAPEDITOR_H
+
+#include <qmap.h>
+#include <qstring.h>
+#include <qtable.h>
+
+class KAction;
+class KActionCollection;
+
+class KWMapEditor : public QTable {
+ Q_OBJECT
+
+ public:
+ KWMapEditor(QMap<QString,QString>& map, QWidget *parent = 0, const char *name = 0);
+ virtual ~KWMapEditor();
+
+ public slots:
+ void reload();
+ void saveMap();
+ void erase();
+ void contextMenu(int row, int col, const QPoint& pos);
+ void addEntry();
+ void emitDirty();
+
+ private slots:
+ void copy();
+
+ protected:
+ virtual QWidget *beginEdit(int row, int col, bool replace);
+
+ signals:
+ void dirty();
+
+ private:
+ QMap<QString,QString>& _map;
+ int _contextRow, _contextCol;
+ KActionCollection *_ac;
+ KAction *_copyAct;
+};
+
+#endif
diff --git a/kwallet/main.cpp b/kwallet/main.cpp
new file mode 100644
index 0000000..08f5b74
--- /dev/null
+++ b/kwallet/main.cpp
@@ -0,0 +1,100 @@
+/*
+ Copyright (C) 2003-2005 George Staikos <staikos@kde.org>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#include <kaboutdata.h>
+#include <kcmdlineargs.h>
+#include <kdebug.h>
+#include <kglobal.h>
+#include <klocale.h>
+#include <kmimetype.h>
+#include <kstandarddirs.h>
+#include <kuniqueapplication.h>
+
+#include <qfile.h>
+#include <qfileinfo.h>
+
+#include "kwalletmanager.h"
+
+
+class MyApp : public KUniqueApplication {
+ public:
+ MyApp() : KUniqueApplication() { ref(); }
+ virtual ~MyApp() {}
+
+ virtual int newInstance() { return 0; }
+};
+
+int main(int argc, char **argv) {
+ static KCmdLineOptions options[] = {
+ {"show", I18N_NOOP("Show window on startup"), 0},
+ {"kwalletd", I18N_NOOP("For use by kwalletd only"), 0},
+ {"+name", I18N_NOOP("A wallet name"), 0},
+ KCmdLineLastOption
+ };
+
+ KAboutData about("kwalletmanager", I18N_NOOP("KDE Wallet Manager"), "1.1",
+ I18N_NOOP("KDE Wallet Management Tool"),
+ KAboutData::License_GPL,
+ I18N_NOOP("(c) 2003,2004 George Staikos"), 0,
+ "http://www.kde.org/");
+
+ about.addAuthor("George Staikos", I18N_NOOP("Primary author and maintainer"), "staikos@kde.org");
+ about.addAuthor("Isaac Clerencia", I18N_NOOP("Developer"), "isaac@warp.es");
+
+ KCmdLineArgs::init(argc, argv, &about);
+ KCmdLineArgs::addCmdLineOptions(options);
+
+ if (!KUniqueApplication::start()) {
+ return 0;
+ }
+
+ MyApp a;
+
+ KWalletManager wm;
+ wm.setCaption(i18n("KDE Wallet Manager"));
+
+ a.setMainWidget(&wm);
+
+ KGlobal::dirs()->addResourceType("kwallet", "share/apps/kwallet");
+
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+
+ if (args->isSet("show")) {
+ wm.show();
+ }
+
+ if (args->isSet("kwalletd")) {
+ wm.kwalletdLaunch();
+ }
+
+ for (int i = 0; i < args->count(); ++i) {
+ QString fn = QFileInfo(args->arg(i)).absFilePath();
+ KMimeType::Ptr ptr;
+ if (QFile::exists(fn) &&
+ (ptr = KMimeType::findByFileContent(fn)) &&
+ ptr->is("application/x-kde-wallet")) {
+ wm.openWalletFile(fn);
+ } else {
+ wm.openWallet(args->arg(i));
+ }
+ }
+ args->clear();
+ return a.exec();
+}
+
diff --git a/kwallet/walletwidget.ui b/kwallet/walletwidget.ui
new file mode 100644
index 0000000..13c6f71
--- /dev/null
+++ b/kwallet/walletwidget.ui
@@ -0,0 +1,416 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>WalletWidget</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>WalletWidget</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>614</width>
+ <height>507</height>
+ </rect>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QSplitter" row="0" column="0">
+ <property name="name">
+ <cstring>_splitter</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <widget class="QFrame">
+ <property name="name">
+ <cstring>_entryListFrame</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout3</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KSqueezedTextLabel" row="1" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>_entryName</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="textFormat">
+ <enum>PlainText</enum>
+ </property>
+ </widget>
+ <spacer row="3" column="0">
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>227</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QPushButton" row="3" column="1">
+ <property name="name">
+ <cstring>_undoChanges</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Undo</string>
+ </property>
+ <property name="iconSet">
+ <iconset>"undo"</iconset>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="0" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>_iconTitle</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>_entryTitle</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="font">
+ <font>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="textFormat">
+ <enum>RichText</enum>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter</set>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QPushButton" row="3" column="2">
+ <property name="name">
+ <cstring>_saveChanges</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Save</string>
+ </property>
+ <property name="iconSet">
+ <iconset>"filesave"</iconset>
+ </property>
+ </widget>
+ <widget class="QWidgetStack" row="2" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>_entryStack</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>1</verstretch>
+ </sizepolicy>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>page</cstring>
+ </property>
+ <attribute name="id">
+ <number>0</number>
+ </attribute>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>page</cstring>
+ </property>
+ <attribute name="id">
+ <number>1</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QTextEdit" row="1" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>_passwordValue</cstring>
+ </property>
+ <property name="textFormat">
+ <enum>PlainText</enum>
+ </property>
+ </widget>
+ <spacer row="0" column="1">
+ <property name="name">
+ <cstring>spacer8</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>271</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>_hideContents</cstring>
+ </property>
+ <property name="text">
+ <string>Hide &amp;Contents</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>page</cstring>
+ </property>
+ <attribute name="id">
+ <number>2</number>
+ </attribute>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>page</cstring>
+ </property>
+ <attribute name="id">
+ <number>3</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QLabel" row="1" column="1">
+ <property name="name">
+ <cstring>textLabel1_2</cstring>
+ </property>
+ <property name="text">
+ <string>This is a binary data entry. It cannot be editted as its format is unknown and application specific.</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignVCenter</set>
+ </property>
+ </widget>
+ <spacer row="0" column="1">
+ <property name="name">
+ <cstring>spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>31</width>
+ <height>41</height>
+ </size>
+ </property>
+ </spacer>
+ <spacer row="2" column="1">
+ <property name="name">
+ <cstring>spacer4</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>31</width>
+ <height>41</height>
+ </size>
+ </property>
+ </spacer>
+ <spacer row="1" column="2">
+ <property name="name">
+ <cstring>spacer5</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>61</width>
+ <height>41</height>
+ </size>
+ </property>
+ </spacer>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer6</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>41</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>page</cstring>
+ </property>
+ <attribute name="id">
+ <number>4</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <spacer row="0" column="1">
+ <property name="name">
+ <cstring>spacer7</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>236</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer6_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>31</width>
+ <height>358</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>_showContents</cstring>
+ </property>
+ <property name="text">
+ <string>Show &amp;Contents</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </widget>
+ </grid>
+ </widget>
+ </widget>
+ </grid>
+</widget>
+<includes>
+ <include location="global" impldecl="in implementation">kdialog.h</include>
+ <include location="global" impldecl="in implementation">kiconloader.h</include>
+</includes>
+<pixmapfunction>SmallIconSet</pixmapfunction>
+<layoutdefaults spacing="6" margin="11"/>
+<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
+</UI>