From 79fd2b2bbd9f842ce3c84c67e3314033a9cceea4 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sat, 26 Jan 2013 13:18:06 -0600 Subject: Rename a number of libraries and executables to avoid conflicts with KDE4 --- tdewallet/CMakeLists.txt | 55 + tdewallet/Makefile.am | 26 + tdewallet/TODO | 13 + tdewallet/allyourbase.cpp | 733 +++++++++++++ tdewallet/allyourbase.h | 180 +++ tdewallet/hi128-app-tdewalletmanager.png | Bin 0 -> 24094 bytes tdewallet/hi128-app-tdewalletmanager2.png | Bin 0 -> 28434 bytes tdewallet/hi16-app-tdewalletmanager.png | Bin 0 -> 1209 bytes tdewallet/hi16-app-tdewalletmanager2.png | Bin 0 -> 1139 bytes tdewallet/hi22-app-tdewalletmanager.png | Bin 0 -> 1601 bytes tdewallet/hi32-app-tdewalletmanager.png | Bin 0 -> 3273 bytes tdewallet/hi32-app-tdewalletmanager2.png | Bin 0 -> 3225 bytes tdewallet/hi48-app-tdewalletmanager.png | Bin 0 -> 6355 bytes tdewallet/hi48-app-tdewalletmanager2.png | Bin 0 -> 6332 bytes tdewallet/hi64-app-tdewalletmanager.png | Bin 0 -> 9728 bytes tdewallet/hi64-app-tdewalletmanager2.png | Bin 0 -> 9702 bytes tdewallet/icons/CMakeLists.txt | 16 + tdewallet/icons/Makefile.am | 5 + tdewallet/icons/cr22-action-folder_closed.png | Bin 0 -> 1149 bytes tdewallet/icons/cr22-action-folder_open.png | Bin 0 -> 1349 bytes tdewallet/icons/cr22-action-wallet_closed.png | Bin 0 -> 997 bytes tdewallet/icons/cr22-action-wallet_open.png | Bin 0 -> 1098 bytes tdewallet/kbetterthankdialogbase.ui | 154 +++ tdewallet/kbetterthankdialogbase.ui.h | 50 + tdewallet/konfigurator/CMakeLists.txt | 45 + tdewallet/konfigurator/Makefile.am | 15 + tdewallet/konfigurator/konfigurator.cpp | 323 ++++++ tdewallet/konfigurator/konfigurator.h | 58 + tdewallet/konfigurator/tdewallet_config.desktop | 47 + tdewallet/konfigurator/tdewalletconfig.desktop | 152 +++ .../konfigurator/tdewalletmanager_show.desktop | 60 + tdewallet/konfigurator/walletconfigwidget.ui | 499 +++++++++ tdewallet/kwalletmanager-tdewalletd.desktop | 60 + tdewallet/kwmapeditor.cpp | 187 ++++ tdewallet/kwmapeditor.h | 62 ++ tdewallet/main.cpp | 100 ++ tdewallet/tdewalleteditor.cpp | 1143 ++++++++++++++++++++ tdewallet/tdewalleteditor.h | 111 ++ tdewallet/tdewalleteditor.rc | 17 + tdewallet/tdewalletmanager.cpp | 423 ++++++++ tdewallet/tdewalletmanager.desktop | 63 ++ tdewallet/tdewalletmanager.h | 85 ++ tdewallet/tdewalletmanager.rc | 14 + tdewallet/tdewalletpopup.cpp | 110 ++ tdewallet/tdewalletpopup.h | 55 + tdewallet/walletwidget.ui | 416 +++++++ 46 files changed, 5277 insertions(+) create mode 100644 tdewallet/CMakeLists.txt create mode 100644 tdewallet/Makefile.am create mode 100644 tdewallet/TODO create mode 100644 tdewallet/allyourbase.cpp create mode 100644 tdewallet/allyourbase.h create mode 100644 tdewallet/hi128-app-tdewalletmanager.png create mode 100644 tdewallet/hi128-app-tdewalletmanager2.png create mode 100644 tdewallet/hi16-app-tdewalletmanager.png create mode 100644 tdewallet/hi16-app-tdewalletmanager2.png create mode 100644 tdewallet/hi22-app-tdewalletmanager.png create mode 100644 tdewallet/hi32-app-tdewalletmanager.png create mode 100644 tdewallet/hi32-app-tdewalletmanager2.png create mode 100644 tdewallet/hi48-app-tdewalletmanager.png create mode 100644 tdewallet/hi48-app-tdewalletmanager2.png create mode 100644 tdewallet/hi64-app-tdewalletmanager.png create mode 100644 tdewallet/hi64-app-tdewalletmanager2.png create mode 100644 tdewallet/icons/CMakeLists.txt create mode 100644 tdewallet/icons/Makefile.am create mode 100644 tdewallet/icons/cr22-action-folder_closed.png create mode 100644 tdewallet/icons/cr22-action-folder_open.png create mode 100644 tdewallet/icons/cr22-action-wallet_closed.png create mode 100644 tdewallet/icons/cr22-action-wallet_open.png create mode 100644 tdewallet/kbetterthankdialogbase.ui create mode 100644 tdewallet/kbetterthankdialogbase.ui.h create mode 100644 tdewallet/konfigurator/CMakeLists.txt create mode 100644 tdewallet/konfigurator/Makefile.am create mode 100644 tdewallet/konfigurator/konfigurator.cpp create mode 100644 tdewallet/konfigurator/konfigurator.h create mode 100644 tdewallet/konfigurator/tdewallet_config.desktop create mode 100644 tdewallet/konfigurator/tdewalletconfig.desktop create mode 100644 tdewallet/konfigurator/tdewalletmanager_show.desktop create mode 100644 tdewallet/konfigurator/walletconfigwidget.ui create mode 100644 tdewallet/kwalletmanager-tdewalletd.desktop create mode 100644 tdewallet/kwmapeditor.cpp create mode 100644 tdewallet/kwmapeditor.h create mode 100644 tdewallet/main.cpp create mode 100644 tdewallet/tdewalleteditor.cpp create mode 100644 tdewallet/tdewalleteditor.h create mode 100644 tdewallet/tdewalleteditor.rc create mode 100644 tdewallet/tdewalletmanager.cpp create mode 100644 tdewallet/tdewalletmanager.desktop create mode 100644 tdewallet/tdewalletmanager.h create mode 100644 tdewallet/tdewalletmanager.rc create mode 100644 tdewallet/tdewalletpopup.cpp create mode 100644 tdewallet/tdewalletpopup.h create mode 100644 tdewallet/walletwidget.ui (limited to 'tdewallet') diff --git a/tdewallet/CMakeLists.txt b/tdewallet/CMakeLists.txt new file mode 100644 index 0000000..e4cedbe --- /dev/null +++ b/tdewallet/CMakeLists.txt @@ -0,0 +1,55 @@ +################################################# +# +# (C) 2012 Golubev Alexander +# fatzer2 (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +add_subdirectory( icons ) +add_subdirectory( konfigurator ) + +include_directories( + ${CMAKE_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### tdewalletmanager (executable) ############### + +tde_add_executable( tdewalletmanager AUTOMOC + SOURCES walletwidget.ui tdewalletmanager.cpp + tdewalletmanager.skel main.cpp tdewalletpopup.cpp + tdewalleteditor.cpp kwmapeditor.cpp + allyourbase.cpp kbetterthankdialogbase.ui + LINK kio-shared + DESTINATION ${BIN_INSTALL_DIR} +) + + +##### icons ##################################### + +tde_install_icons( tdewalletmanager) + + +##### other data ################################ + +install( FILES tdewalletmanager.rc tdewalleteditor.rc + DESTINATION ${DATA_INSTALL_DIR}/tdewalletmanager +) + +install( FILES tdewalletmanager.desktop + tdewalletmanager-tdewalletd.desktop + DESTINATION ${XDG_APPS_INSTALL_DIR} +) + diff --git a/tdewallet/Makefile.am b/tdewallet/Makefile.am new file mode 100644 index 0000000..d3d62cd --- /dev/null +++ b/tdewallet/Makefile.am @@ -0,0 +1,26 @@ +INCLUDES= $(all_includes) + +SUBDIRS=. icons konfigurator + +bin_PROGRAMS = tdewalletmanager +tdewalletmanager_SOURCES = walletwidget.ui tdewalletmanager.cpp \ + tdewalletmanager.skel main.cpp tdewalletpopup.cpp \ + tdewalleteditor.cpp kwmapeditor.cpp allyourbase.cpp \ + kbetterthankdialogbase.ui +tdewalletmanager_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +tdewalletmanager_LDADD = $(LIB_KIO) -ltdewalletclient +METASOURCES = AUTO +noinst_HEADERS = tdewalletmanager.h tdewalletpopup.h walletwidget.h tdewalleteditor.h\ + allyourbase.h kwmapeditor.h + +xdg_apps_DATA = tdewalletmanager.desktop tdewalletmanager-tdewalletd.desktop + +KDE_ICON = tdewalletmanager + +rc_DATA = tdewalletmanager.rc tdewalleteditor.rc +rcdir = $(kde_datadir)/tdewalletmanager + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/tdewalletmanager.pot + +kbetterthankdialogbase.lo: kbetterthankdialogbase.ui kbetterthankdialogbase.ui.h diff --git a/tdewallet/TODO b/tdewallet/TODO new file mode 100644 index 0000000..145fa7b --- /dev/null +++ b/tdewallet/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/tdewallet/allyourbase.cpp b/tdewallet/allyourbase.cpp new file mode 100644 index 0000000..97b55d8 --- /dev/null +++ b/tdewallet/allyourbase.cpp @@ -0,0 +1,733 @@ +/* + Copyright (C) 2003-2005 George Staikos + Copyright (C) 2005 Isaac Clerencia + + 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +/**************** + * KWalletFolderItem - ListView items to represent tdewallet folders + */ +KWalletFolderItem::KWalletFolderItem(KWallet::Wallet *w, TQListView* parent, const TQString &name, int entries) +: KListViewItem(parent),_wallet(w),_name(name),_entries(entries) { + setText(0, TQString("%1 (%2)").arg(_name).arg(_entries)); + setRenameEnabled(0, false); + setDragEnabled(true); + setDropEnabled(true); + + TQPixmap pix = getFolderIcon(KIcon::Small); + + setPixmap(0,pix); +} + +TQPixmap KWalletFolderItem::getFolderIcon(KIcon::Group group){ + KIconLoader *loader = TDEGlobal::instance()->iconLoader(); + TQPixmap 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() { + TQString saveFolder = _wallet->currentFolder(); + _wallet->setFolder(_name); + setText(0, TQString("%1 (%2)").arg(_name).arg(_wallet->entryList().count())); + _wallet->setFolder(saveFolder); +} + +KWalletContainerItem* KWalletFolderItem::getContainer(KWallet::Wallet::EntryType type) { + for (TQListViewItem *i = firstChild(); i; i = i->nextSibling()) { + KWalletContainerItem *ci = dynamic_cast(i); + if (!ci) { + continue; + } + if (ci->type() == type) { + return ci; + } + } + return 0; +} + +bool KWalletFolderItem::contains(const TQString& key) { + return (getItem(key) != 0); +} + +TQListViewItem* KWalletFolderItem::getItem(const TQString& key) { + for (TQListViewItem *i = firstChild(); i; i = i->nextSibling()) { + KWalletContainerItem *ci = dynamic_cast(i); + if (!ci) { + continue; + } + TQListViewItem *tmp = ci->getItem(key); + if (tmp) { + return tmp; + } + } + return 0; +} + +bool KWalletFolderItem::acceptDrop(const TQMimeSource *mime) const { + return mime->provides("application/x-tdewallet-entry") || + mime->provides("text/uri-list"); +} + +int KWalletFolderItem::rtti() const { + return KWalletFolderItemClass; +} + +TQString KWalletFolderItem::name() const { + return _name; +} + +KWalletFolderItem::~KWalletFolderItem() { +} + +/**************** + * KWalletContainerItem - ListView items to represent tdewallet containers, i.e. + * passwords, maps, ... + */ +KWalletContainerItem::KWalletContainerItem(TQListViewItem* parent, const TQString &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 TQString& key) { + return getItem(key) != 0; +} + +TQListViewItem *KWalletContainerItem::getItem(const TQString& key) { + for (TQListViewItem *i = firstChild(); i; i = i->nextSibling()) { + if (i->text(0) == key) { + return i; + } + } + return 0; +} + +/**************** + * KWalletEntryItem - ListView items to represent tdewallet entries + */ +KWalletEntryItem::KWalletEntryItem(KWallet::Wallet *w, TQListViewItem* parent, const TQString& 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(TQIconView *parent, const TQString& walletName) +: TQIconViewItem(parent, walletName, DesktopIcon("tdewalletmanager")) { +} + +KWalletItem::~KWalletItem() { +} + +bool KWalletItem::acceptDrop(const TQMimeSource *mime) const { + return mime->provides("application/x-tdewallet-folder") || + mime->provides("text/uri-list"); +} + +static bool decodeEntry(KWallet::Wallet *_wallet, TQDataStream& ds) { + TQ_UINT32 magic; + ds >> magic; + if (magic != KWALLETENTRYMAGIC) { + kdDebug() << "bad magic" << endl; + return false; + } + TQString name; + TQByteArray 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, TQDataStream& ds) { + TQ_UINT32 magic; + ds >> magic; + if (magic != KWALLETFOLDERMAGIC) { + kdDebug() << "bad magic" << endl; + return false; + } + TQString 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), TQString(), 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()) { + TQString name; + TQByteArray 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(TQDropEvent *e, const TQValueList& lst) { + Q_UNUSED(lst); + if (e->provides("application/x-tdewallet-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; + } + + TQString saveFolder = _wallet->currentFolder(); + + TQFile file; + TQDataStream *ds = 0L; + + if (e->provides("application/x-tdewallet-folder")) { + TQByteArray edata = e->encodedData("application/x-tdewallet-folder"); + if (!edata.isEmpty()) { + ds = new TQDataStream(edata, IO_ReadOnly); + } + } else { // text/uri-list + TQStrList urls; + TQUriDrag::decode(e, urls); + + if (urls.isEmpty()) { + e->ignore(); + return; + } + + KURL u(urls.first()); + if (u.fileName().isEmpty()) { + e->ignore(); + return; + } + TQString tmpFile; + if (TDEIO::NetAccess::download(u, tmpFile, 0L)) { + file.setName(tmpFile); + file.open(IO_ReadOnly); + ds = new TQDataStream(&file); + TDEIO::NetAccess::removeTempFile(tmpFile); + } else { + KMessageBox::error(iconView(), TDEIO::NetAccess::lastErrorString()); + } + } + if (ds) { + decodeFolder(_wallet, *ds); + delete ds; + } + _wallet->setFolder(saveFolder); + delete _wallet; + + //delete the folder from the source if we were moving + TQt::ButtonState state = kapp->keyboardMouseState(); + if (e->source() && e->source()->parent() && + !strcmp(e->source()->parent()->className(), "KWalletEntryList") && + !(state & TQt::ControlButton)) { + + KWalletEntryList *el = + dynamic_cast(e->source()->parent()); + if (el) { + KWalletFolderItem *fi = + dynamic_cast(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 TQStoredDrag { + public: + KWalletEntryDrag(TQWidget *dragSource, const char *name = 0L) + : TQStoredDrag("application/x-tdewallet-entry", dragSource, name) { + } + + virtual ~KWalletEntryDrag() {} +}; + +/**************** + * KWalletFolderDrag - Stores data for wallet folder drags + */ +class KWalletFolderDrag : public TQStoredDrag { + public: + KWalletFolderDrag(TQWidget *dragSource, const char *name = 0L) + : TQStoredDrag("application/x-tdewallet-folder", dragSource, name) { + } + + virtual ~KWalletFolderDrag() {} +}; + +/**************** + * KWalletEntryList - A listview to store wallet entries + */ +KWalletEntryList::KWalletEntryList(TQWidget *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(TQDropEvent* e) const { + TQListViewItem *i = itemAt(contentsToViewport(e->pos())); + if (i) { + if (e->provides("application/x-tdewallet-entry") || + e->provides("text/uri-list")) { + return true; + } + } + if ((e->provides("application/x-tdewallet-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(TQDropEvent *e, TQListViewItem *item) { + bool ok = true; + bool isEntry; + TQFile file; + TQDataStream *ds; + + KWalletEntryList *el = 0L; + TQListViewItem *sel = 0L; + + //detect if we are dragging from tdewallet itself + if (e->source() && e->source()->parent() && + !strcmp(e->source()->parent()->className(), "KWalletEntryList")) { + + el = dynamic_cast(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-tdewallet-entry")) { + //do nothing if we are in the same folder + if (sel && sel->parent()->parent() == + KWalletEntryList::getItemFolder(item)) { + e->ignore(); + return; + } + isEntry = true; + TQByteArray data = e->encodedData("application/x-tdewallet-entry"); + if (data.isEmpty()) { + e->ignore(); + return; + } + ds = new TQDataStream(data, IO_ReadOnly); + } else if (e->provides("application/x-tdewallet-folder")) { + //do nothing if we are in the same wallet + if (this == el) { + e->ignore(); + return; + } + isEntry = false; + TQByteArray data = e->encodedData("application/x-tdewallet-folder"); + if (data.isEmpty()) { + e->ignore(); + return; + } + ds = new TQDataStream(data, IO_ReadOnly); + } else if (e->provides("text/uri-list")) { + TQStrList urls; + TQUriDrag::decode(e, urls); + if (urls.isEmpty()) { + e->ignore(); + return; + } + KURL u(urls.first()); + if (u.fileName().isEmpty()) { + e->ignore(); + return; + } + TQString tmpFile; + if (TDEIO::NetAccess::download(u, tmpFile, 0L)) { + file.setName(tmpFile); + file.open(IO_ReadOnly); + ds = new TQDataStream(&file); + //check magic to discover mime type + TQ_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 TQDataStream(&file); + TDEIO::NetAccess::removeTempFile(tmpFile); + } else { + KMessageBox::error(this, TDEIO::NetAccess::lastErrorString()); + return; + } + } else { + e->ignore(); + return; + } + TQt::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; + } + TQString 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 tdewalletmanager and Control is not pressed + if (ok && el && !(state & TQt::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 tdewalletmanager and Control is not pressed + if (ok && el && !(state & TQt::ControlButton) && sel) { + KWalletFolderItem *fi = dynamic_cast(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 TQString& name) { + for (TQListViewItem *vi = firstChild(); vi; vi = vi->nextSibling()) { + KWalletFolderItem *fi = dynamic_cast(vi); + if (!fi) { + continue; + } + if (name == fi->name()) { + return true; + } + } + return false; +} + +void KWalletEntryList::contentsDropEvent(TQDropEvent *e) { + TQListViewItem *i = itemAt(contentsToViewport(e->pos())); + itemDropped(e, i); +} + +void KWalletEntryList::contentsDragEnterEvent(TQDragEnterEvent *e) { + if (e->provides("application/x-tdewallet-entry") || + e->provides("application/x-tdewallet-folder") || + e->provides("application/uri-list")) { + e->accept(); + } else { + e->ignore(); + } +} + +KWalletFolderItem* KWalletEntryList::getFolder(const TQString& name) { + for (TQListViewItem *vi = firstChild(); vi; vi = vi->nextSibling()) { + KWalletFolderItem *fi = dynamic_cast(vi); + if (!fi) { + continue; + } + if (name == fi->name()) { + return fi; + } + } + return 0; +} + +KWalletFolderItem *KWalletEntryList::getItemFolder(TQListViewItem *item) { + switch (item->rtti()) { + case KWalletFolderItemClass: + return dynamic_cast(item); + case KWalletContainerItemClass: + return dynamic_cast(item->parent()); + case KWalletEntryItemClass: + return dynamic_cast(item->parent()->parent()); + } + return 0; +} + +/**************** + * KWalletIconDrag - Stores the data for wallet drags + */ +class KWalletIconDrag : public TQIconDrag { + public: + KWalletIconDrag(TQWidget *dragSource, const char *name = 0L) + : TQIconDrag(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; + } + + TQByteArray encodedData(const char *mime) const { + TQByteArray a; + TQCString mimetype(mime); + if (mimetype == "application/x-qiconlist") { + return TQIconDrag::encodedData(mime); + } else if (mimetype == "text/uri-list") { + TQCString 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 TQIconDragItem &item, const TQRect &pr, + const TQRect &tr, const TQString &url) { + TQIconDrag::append(item, pr, tr); + _urls.append(url); + } + + private: + TQStringList _urls; +}; + +/**************** +* * KWalletIconView - An iconview to store wallets +* */ +KWalletIconView::KWalletIconView(TQWidget *parent, const char *name) +: KIconView(parent, name) { + TDEGlobal::dirs()->addResourceType("tdewallet", "share/apps/tdewallet"); + connect(this, TQT_SIGNAL(dropped(TQDropEvent*, const TQValueList&)), TQT_SLOT(slotDropped(TQDropEvent*, const TQValueList&))); +} + +KWalletIconView::~KWalletIconView() { +} + +void KWalletIconView::slotDropped(TQDropEvent *e, const TQValueList& /*lst*/) { + if (e->source() == viewport()) { + e->ignore(); + return; + } + + if (!e->provides("text/uri-list")) { + e->ignore(); + return; + } + + TQByteArray edata = e->encodedData("text/uri-list"); + TQCString urls = edata.data(); + + TQStringList ul = TQStringList::split("\r\n", urls); + if (ul.isEmpty() || ul.first().isEmpty()) { + e->ignore(); + return; + } + + KURL u(ul.first()); + + if (u.fileName().isEmpty()) { + e->ignore(); + return; + } + + TQString dest = TDEGlobal::dirs()->saveLocation("tdewallet") + u.fileName(); + if (TQFile::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 + TDEIO::NetAccess::file_copy(u, KURL::fromPathOrURL(dest)); + e->accept(); +} + +void KWalletIconView::contentsMousePressEvent(TQMouseEvent *e) { + _mousePos = e->pos(); + if (!findItem(_mousePos)) { + clearSelection(); + } + KIconView::contentsMousePressEvent( e ); +} + +TQDragObject *KWalletIconView::dragObject() { + KWalletIconDrag* id = new KWalletIconDrag(viewport(), "KWallet Drag"); + TQString path = "file:" + TDEGlobal::dirs()->saveLocation("tdewallet"); + TQPoint pos = _mousePos; + for (TQIconViewItem *item = firstItem(); item; item = item->nextItem()) { + if (item->isSelected()) { + TQString url = path + item->text() + ".kwl"; + TQIconDragItem idi; + idi.setData(url.local8Bit()); + id->append(idi, + TQRect(item->pixmapRect(false).topLeft() - pos, + item->pixmapRect(false).size()), + TQRect(item->textRect(false).topLeft() - pos, + item->textRect(false).size()), + url); + } + } + + id->setPixmap(*currentItem()->pixmap(), + pos - currentItem()->pixmapRect(false).topLeft()); + + return id; +} + +TQDragObject *KWalletEntryList::dragObject() { + TQListViewItem *i = currentItem(); + + TQStoredDrag *sd = 0L; + + if (i->rtti() == KWalletEntryItemClass) { + KWalletEntryItem *ei = dynamic_cast(i); + if (!ei) { + return 0L; + } + sd = new KWalletEntryDrag(viewport(), "KWallet Entry Drag"); + TQByteArray a; + TQDataStream ds(a, IO_WriteOnly); + ds << KWALLETENTRYMAGIC; + ds << *ei; + sd->setEncodedData(a); + } else if (i->rtti() == KWalletFolderItemClass) { + KWalletFolderItem *fi = dynamic_cast(i); + if (!fi) { + return 0L; + } + sd = new KWalletFolderDrag(viewport(), "KWallet Folder Drag"); + TQByteArray a; + TQDataStream ds(a, IO_WriteOnly); + + ds << KWALLETFOLDERMAGIC; + ds << *fi; + sd->setEncodedData(a); + } + return sd; +} + +#include "allyourbase.moc" diff --git a/tdewallet/allyourbase.h b/tdewallet/allyourbase.h new file mode 100644 index 0000000..fe9bd05 --- /dev/null +++ b/tdewallet/allyourbase.h @@ -0,0 +1,180 @@ +/* + Copyright (C) 2003-2005 George Staikos + Copyright (C) 2005 Isaac Clerencia + + 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 +#include +#include +#include +#include + +#define KWALLETENTRYMAGIC ((TQ_UINT32) 0x6B776C65) +#define KWALLETFOLDERMAGIC ((TQ_UINT32) 0x6B776C66) + +enum KWalletListItemClasses { + KWalletFolderItemClass = 1000, + KWalletContainerItemClass, + KWalletEntryItemClass, + KWalletUnknownClass = 2000 +}; + +class KWalletEntryItem : public KListViewItem { + public: + KWalletEntryItem(KWallet::Wallet *w, TQListViewItem* parent, const TQString& ename); + virtual ~KWalletEntryItem(); + + const TQString& oldName() { return _oldName; } + TQString currentName() { return text(0); } + + void clearOldName() { _oldName = text(0); } + virtual int rtti() const; + + public: + KWallet::Wallet *_wallet; + + private: + TQString _oldName; +}; + +class KWalletContainerItem : public KListViewItem { + public: + KWalletContainerItem(TQListViewItem* parent, const TQString& name, + KWallet::Wallet::EntryType type); + virtual ~KWalletContainerItem(); + + public: + virtual int rtti() const; + KWallet::Wallet::EntryType type(); + bool contains(const TQString& itemKey); + TQListViewItem* getItem(const TQString& itemKey); + + private: + KWallet::Wallet::EntryType _type; +}; + +class KWalletFolderItem : public KListViewItem { + public: + KWalletFolderItem(KWallet::Wallet *w, TQListView* parent, + const TQString& name, int entries); + virtual ~KWalletFolderItem(); + + virtual bool acceptDrop(const TQMimeSource *mime) const; + virtual int rtti() const; + + TQString name() const; + void refresh(); + KWalletContainerItem* getContainer(KWallet::Wallet::EntryType type); + TQPixmap getFolderIcon(KIcon::Group group); + bool contains(const TQString& itemKey); + TQListViewItem* getItem(const TQString& itemKey); + + public: + KWallet::Wallet *_wallet; + + private: + TQString _name; + int _entries; +}; + +class KWalletEntryList : public KListView { + Q_OBJECT + + public: + KWalletEntryList(TQWidget *parent, const char *name = 0L); + virtual ~KWalletEntryList(); + + bool existsFolder(const TQString& name); + KWalletFolderItem* getFolder(const TQString& name); + void contentsDropEvent(TQDropEvent *e); + void contentsDragEnterEvent(TQDragEnterEvent *e); + void setWallet(KWallet::Wallet *w); + + protected: + void itemDropped(TQDropEvent *e, TQListViewItem *item); + virtual TQDragObject *dragObject(); + virtual bool acceptDrag (TQDropEvent* event) const; + + private: + static KWalletFolderItem *getItemFolder(TQListViewItem *item); + + public: + KWallet::Wallet *_wallet; +}; + +class KWalletItem : public TQIconViewItem { + public: + KWalletItem(TQIconView *parent, const TQString& walletName); + virtual ~KWalletItem(); + + virtual bool acceptDrop(const TQMimeSource *mime) const; + + protected: + virtual void dropped(TQDropEvent *e, const TQValueList& lst); +}; + + +class KWalletIconView : public KIconView { + Q_OBJECT + + public: + KWalletIconView(TQWidget *parent, const char *name = 0L); + virtual ~KWalletIconView(); + + protected slots: + virtual void slotDropped(TQDropEvent *e, const TQValueList& lst); + + protected: + virtual TQDragObject *dragObject(); + virtual void contentsMousePressEvent(TQMouseEvent *e); + TQPoint _mousePos; +}; + + +inline TQDataStream& operator<<(TQDataStream& str, const KWalletEntryItem& w) { + TQString name = w.text(0); + str << name; + KWallet::Wallet::EntryType et = w._wallet->entryType(name); + str << long(et); + TQByteArray a; + w._wallet->readEntry(name, a); + str << a; + return str; +} + +inline TQDataStream& operator<<(TQDataStream& str, const KWalletFolderItem& w) { + TQString oldFolder = w._wallet->currentFolder(); + str << w.name(); + w._wallet->setFolder(w.name()); + TQStringList entries = w._wallet->entryList(); + for (TQStringList::Iterator it = entries.begin(); it != entries.end(); ++it) { + str << *it; + KWallet::Wallet::EntryType et = w._wallet->entryType(*it); + str << long(et); + TQByteArray a; + w._wallet->readEntry(*it, a); + str << a; + } + w._wallet->setFolder(oldFolder); + return str; +} + +#endif diff --git a/tdewallet/hi128-app-tdewalletmanager.png b/tdewallet/hi128-app-tdewalletmanager.png new file mode 100644 index 0000000..ccdd7c9 Binary files /dev/null and b/tdewallet/hi128-app-tdewalletmanager.png differ diff --git a/tdewallet/hi128-app-tdewalletmanager2.png b/tdewallet/hi128-app-tdewalletmanager2.png new file mode 100644 index 0000000..e3937db Binary files /dev/null and b/tdewallet/hi128-app-tdewalletmanager2.png differ diff --git a/tdewallet/hi16-app-tdewalletmanager.png b/tdewallet/hi16-app-tdewalletmanager.png new file mode 100644 index 0000000..4f9f4fd Binary files /dev/null and b/tdewallet/hi16-app-tdewalletmanager.png differ diff --git a/tdewallet/hi16-app-tdewalletmanager2.png b/tdewallet/hi16-app-tdewalletmanager2.png new file mode 100644 index 0000000..b2f9004 Binary files /dev/null and b/tdewallet/hi16-app-tdewalletmanager2.png differ diff --git a/tdewallet/hi22-app-tdewalletmanager.png b/tdewallet/hi22-app-tdewalletmanager.png new file mode 100644 index 0000000..8bc4cdb Binary files /dev/null and b/tdewallet/hi22-app-tdewalletmanager.png differ diff --git a/tdewallet/hi32-app-tdewalletmanager.png b/tdewallet/hi32-app-tdewalletmanager.png new file mode 100644 index 0000000..69a7c1e Binary files /dev/null and b/tdewallet/hi32-app-tdewalletmanager.png differ diff --git a/tdewallet/hi32-app-tdewalletmanager2.png b/tdewallet/hi32-app-tdewalletmanager2.png new file mode 100644 index 0000000..3cfc4e2 Binary files /dev/null and b/tdewallet/hi32-app-tdewalletmanager2.png differ diff --git a/tdewallet/hi48-app-tdewalletmanager.png b/tdewallet/hi48-app-tdewalletmanager.png new file mode 100644 index 0000000..5b46a87 Binary files /dev/null and b/tdewallet/hi48-app-tdewalletmanager.png differ diff --git a/tdewallet/hi48-app-tdewalletmanager2.png b/tdewallet/hi48-app-tdewalletmanager2.png new file mode 100644 index 0000000..3ae286d Binary files /dev/null and b/tdewallet/hi48-app-tdewalletmanager2.png differ diff --git a/tdewallet/hi64-app-tdewalletmanager.png b/tdewallet/hi64-app-tdewalletmanager.png new file mode 100644 index 0000000..38a581c Binary files /dev/null and b/tdewallet/hi64-app-tdewalletmanager.png differ diff --git a/tdewallet/hi64-app-tdewalletmanager2.png b/tdewallet/hi64-app-tdewalletmanager2.png new file mode 100644 index 0000000..2e5be4b Binary files /dev/null and b/tdewallet/hi64-app-tdewalletmanager2.png differ diff --git a/tdewallet/icons/CMakeLists.txt b/tdewallet/icons/CMakeLists.txt new file mode 100644 index 0000000..68f67e2 --- /dev/null +++ b/tdewallet/icons/CMakeLists.txt @@ -0,0 +1,16 @@ +################################################# +# +# (C) 2012 Golubev Alexander +# fatzer2 (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +tde_install_icons( tdewalletmanager) + +tde_install_icons( + DESTINATION ${DATA_INSTALL_DIR}/tdewalletmanager/icons +) diff --git a/tdewallet/icons/Makefile.am b/tdewallet/icons/Makefile.am new file mode 100644 index 0000000..65d4236 --- /dev/null +++ b/tdewallet/icons/Makefile.am @@ -0,0 +1,5 @@ +KDE_ICON = tdewalletmanager + +pics_ICON = AUTO +picsdir = $(kde_datadir)/tdewalletmanager/icons + diff --git a/tdewallet/icons/cr22-action-folder_closed.png b/tdewallet/icons/cr22-action-folder_closed.png new file mode 100644 index 0000000..e3ebad3 Binary files /dev/null and b/tdewallet/icons/cr22-action-folder_closed.png differ diff --git a/tdewallet/icons/cr22-action-folder_open.png b/tdewallet/icons/cr22-action-folder_open.png new file mode 100644 index 0000000..ea175b7 Binary files /dev/null and b/tdewallet/icons/cr22-action-folder_open.png differ diff --git a/tdewallet/icons/cr22-action-wallet_closed.png b/tdewallet/icons/cr22-action-wallet_closed.png new file mode 100644 index 0000000..57558ac Binary files /dev/null and b/tdewallet/icons/cr22-action-wallet_closed.png differ diff --git a/tdewallet/icons/cr22-action-wallet_open.png b/tdewallet/icons/cr22-action-wallet_open.png new file mode 100644 index 0000000..55a447f Binary files /dev/null and b/tdewallet/icons/cr22-action-wallet_open.png differ diff --git a/tdewallet/kbetterthankdialogbase.ui b/tdewallet/kbetterthankdialogbase.ui new file mode 100644 index 0000000..65d8b5a --- /dev/null +++ b/tdewallet/kbetterthankdialogbase.ui @@ -0,0 +1,154 @@ + +KBetterThanKDialogBase + + + KBetterThanKDialogBase + + + + 0 + 0 + 479 + 109 + + + + + + + + unnamed + + + Fixed + + + + _label + + + + + spacer1 + + + Horizontal + + + Expanding + + + + 41 + 21 + + + + + + layout1 + + + + unnamed + + + + _allowOnce + + + &Replace + + + true + + + + + _allowAlways + + + Replace &All + + + + + _deny + + + &Skip + + + + + _denyForever + + + Skip A&ll + + + + + + + spacer2 + + + Horizontal + + + Expanding + + + + 61 + 21 + + + + + + + + + + _allowOnce + clicked() + KBetterThanKDialogBase + clicked() + + + _allowAlways + clicked() + KBetterThanKDialogBase + clicked() + + + _deny + clicked() + KBetterThanKDialogBase + clicked() + + + _denyForever + clicked() + KBetterThanKDialogBase + clicked() + + + + kactivelabel.h + kbetterthankdialogbase.ui.h + + + clicked() + setLabel( const TQString & label ) + init() + accept() + reject() + + + + kactivelabel.h + + diff --git a/tdewallet/kbetterthankdialogbase.ui.h b/tdewallet/kbetterthankdialogbase.ui.h new file mode 100644 index 0000000..e97ffd1 --- /dev/null +++ b/tdewallet/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 +** TQt 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 TQString & label ) +{ + _label->setText(label); +} + + +void KBetterThanKDialogBase::init() +{ + _allowOnce->setFocus(); +} + + +void KBetterThanKDialogBase::accept() +{ + setResult(3); +} + + +void KBetterThanKDialogBase::reject() +{ + TQDialog::reject(); + setResult(4); +} diff --git a/tdewallet/konfigurator/CMakeLists.txt b/tdewallet/konfigurator/CMakeLists.txt new file mode 100644 index 0000000..d9283f8 --- /dev/null +++ b/tdewallet/konfigurator/CMakeLists.txt @@ -0,0 +1,45 @@ +################################################# +# +# (C) 2012 Golubev Alexander +# fatzer2 (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${CMAKE_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### kcm_tdewallet (kpart) ####################### + +tde_add_kpart( kcm_tdewallet AUTOMOC + SOURCES walletconfigwidget.ui konfigurator.cpp + LINK tdeui-shared tdewalletclient-shared + DESTINATION ${PLUGIN_INSTALL_DIR} +) + + +##### other data ################################ + +install( FILES tdewalletconfig.desktop + DESTINATION ${XDG_APPS_INSTALL_DIR} +) + +install( + FILES + tdewallet_config.desktop + tdewalletmanager_show.desktop + DESTINATION ${SERVICES_INSTALL_DIR} +) diff --git a/tdewallet/konfigurator/Makefile.am b/tdewallet/konfigurator/Makefile.am new file mode 100644 index 0000000..b7fa556 --- /dev/null +++ b/tdewallet/konfigurator/Makefile.am @@ -0,0 +1,15 @@ +INCLUDES = $(all_includes) +METASOURCES = AUTO + +kde_module_LTLIBRARIES = kcm_tdewallet.la +kcm_tdewallet_la_SOURCES = walletconfigwidget.ui konfigurator.cpp +kcm_tdewallet_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined +kcm_tdewallet_la_LIBADD = $(LIB_TDEUI) -ltdewalletclient + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/kcmtdewallet.pot + +xdg_apps_DATA = tdewalletconfig.desktop + +kde_services_DATA = tdewallet_config.desktop tdewalletmanager_show.desktop + diff --git a/tdewallet/konfigurator/konfigurator.cpp b/tdewallet/konfigurator/konfigurator.cpp new file mode 100644 index 0000000..230b4c9 --- /dev/null +++ b/tdewallet/konfigurator/konfigurator.cpp @@ -0,0 +1,323 @@ +/* + Copyright (C) 2003 George Staikos + + 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +typedef KGenericFactory KWalletFactory; +K_EXPORT_COMPONENT_FACTORY(kcm_tdewallet, KWalletFactory("kcmtdewallet")) + +KWalletConfig::KWalletConfig(TQWidget *parent, const char *name, const TQStringList&) +: TDECModule(KWalletFactory::instance(), parent, name) { + + TDEAboutData *about = + new TDEAboutData(I18N_NOOP("kcmtdewallet"), + I18N_NOOP("TDE Wallet Control Module"), + 0, 0, TDEAboutData::License_GPL, + I18N_NOOP("(c) 2003 George Staikos")); + about->addAuthor("George Staikos", 0, "staikos@kde.org"); + setAboutData( about ); + + _cfg = new TDEConfig("tdewalletrc", false, false); + + TQVBoxLayout *vbox = new TQVBoxLayout(this, 0, KDialog::spacingHint()); + vbox->add(_wcw = new WalletConfigWidget(this)); + + connect(_wcw->_enabled, TQT_SIGNAL(clicked()), this, TQT_SLOT(configChanged())); + connect(_wcw->_launchManager, TQT_SIGNAL(clicked()), this, TQT_SLOT(configChanged())); + connect(_wcw->_autocloseManager, TQT_SIGNAL(clicked()), this, TQT_SLOT(configChanged())); + connect(_wcw->_autoclose, TQT_SIGNAL(clicked()), this, TQT_SLOT(configChanged())); + connect(_wcw->_closeIdle, TQT_SIGNAL(clicked()), this, TQT_SLOT(configChanged())); + connect(_wcw->_openPrompt, TQT_SIGNAL(clicked()), this, TQT_SLOT(configChanged())); + connect(_wcw->_screensaverLock, TQT_SIGNAL(clicked()), this, TQT_SLOT(configChanged())); + connect(_wcw->_localWalletSelected, TQT_SIGNAL(clicked()), this, TQT_SLOT(configChanged())); + connect(_wcw->_idleTime, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(configChanged())); + connect(_wcw->_launch, TQT_SIGNAL(clicked()), this, TQT_SLOT(launchManager())); + connect(_wcw->_newWallet, TQT_SIGNAL(clicked()), this, TQT_SLOT(newNetworkWallet())); + connect(_wcw->_newLocalWallet, TQT_SIGNAL(clicked()), this, TQT_SLOT(newLocalWallet())); + connect(_wcw->_localWallet, TQT_SIGNAL(activated(int)), this, TQT_SLOT(configChanged())); + connect(_wcw->_defaultWallet, TQT_SIGNAL(activated(int)), this, TQT_SLOT(configChanged())); + connect(_wcw->_accessList, TQT_SIGNAL(contextMenuRequested(TQListViewItem*, const TQPoint&, int)), this, TQT_SLOT(contextMenuRequested(TQListViewItem*, const TQPoint&, int))); + + _wcw->_accessList->setAllColumnsShowFocus(true); + updateWalletLists(); + load(); + + if (DCOPClient::mainClient()->isApplicationRegistered("tdewalletmanager")) { + _wcw->_launch->hide(); + } + +} + + +KWalletConfig::~KWalletConfig() { + delete _cfg; + _cfg = 0L; +} + + +void KWalletConfig::updateWalletLists() { + TQString p1, p2; + p1 = _wcw->_localWallet->currentText(); + p2 = _wcw->_defaultWallet->currentText(); + + _wcw->_localWallet->clear(); + _wcw->_defaultWallet->clear(); + + TQStringList 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); + } +} + + +TQString KWalletConfig::newWallet() { + bool ok; + + TQString n = KInputDialog::getText(i18n("New Wallet"), + i18n("Please choose a name for the new wallet:"), + TQString(), + &ok, + this); + + if (!ok) { + return TQString(); + } + + KWallet::Wallet *w = KWallet::Wallet::openWallet(n); + if (!w) { + return TQString(); + } + + delete w; + return n; +} + + +void KWalletConfig::newLocalWallet() { + TQString n = newWallet(); + if (n.isEmpty()) { + return; + } + + updateWalletLists(); + + _wcw->_localWallet->setCurrentText(n); + + emit changed(true); +} + + +void KWalletConfig::newNetworkWallet() { + TQString n = newWallet(); + if (n.isEmpty()) { + return; + } + + updateWalletLists(); + + _wcw->_defaultWallet->setCurrentText(n); + + emit changed(true); +} + + +void KWalletConfig::launchManager() { + if (!DCOPClient::mainClient()->isApplicationRegistered("tdewalletmanager")) { + TDEApplication::startServiceByDesktopName("tdewalletmanager_show"); + } else { + DCOPRef r("tdewalletmanager", "tdewalletmanager-mainwindow#1"); + r.send("show"); + r.send("raise"); + } +} + + +void KWalletConfig::configChanged() { + emit changed(true); +} + +void KWalletConfig::load() { + load( false ); +} + +void KWalletConfig::load(bool useDefaults) { + TDEConfigGroup 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"); + TQStringList denykeys = _cfg->entryMap("Auto Deny").keys(); + _cfg->setGroup("Auto Allow"); + TQStringList keys = _cfg->entryMap("Auto Allow").keys(); + for (TQStringList::Iterator i = keys.begin(); i != keys.end(); ++i) { + _cfg->setGroup("Auto Allow"); + TQStringList apps = _cfg->readListEntry(*i); + _cfg->setGroup("Auto Deny"); + TQStringList denyapps = _cfg->readListEntry(*i); + denykeys.remove(*i); + TQListViewItem *lvi = new TQListViewItem(_wcw->_accessList, *i); + for (TQStringList::Iterator j = apps.begin(); j != apps.end(); ++j) { + new TQListViewItem(lvi, TQString(), *j, i18n("Always Allow")); + } + for (TQStringList::Iterator j = denyapps.begin(); j != denyapps.end(); ++j) { + new TQListViewItem(lvi, TQString(), *j, i18n("Always Deny")); + } + } + _cfg->setGroup("Auto Deny"); + for (TQStringList::Iterator i = denykeys.begin(); i != denykeys.end(); ++i) { + TQStringList denyapps = _cfg->readListEntry(*i); + TQListViewItem *lvi = new TQListViewItem(_wcw->_accessList, *i); + for (TQStringList::Iterator j = denyapps.begin(); j != denyapps.end(); ++j) { + new TQListViewItem(lvi, TQString(), *j, i18n("Always Deny")); + } + } + emit changed(useDefaults); +} + + +void KWalletConfig::save() { + TDEConfigGroup 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 (TQListViewItem *i = _wcw->_accessList->firstChild(); i; i = i->nextSibling()) { + TQStringList al; + for (TQListViewItem *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 (TQListViewItem *i = _wcw->_accessList->firstChild(); i; i = i->nextSibling()) { + TQStringList al; + for (TQListViewItem *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", "tdewalletd").call("reconfigure()"); + + emit changed(false); +} + + +void KWalletConfig::defaults() { + load( true ); +} + + +TQString KWalletConfig::quickHelp() const { + return i18n("This configuration module allows you to configure the KDE wallet system."); +} + + +void KWalletConfig::contextMenuRequested(TQListViewItem *item, const TQPoint& 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, TQT_SLOT(deleteEntry()), Key_Delete); + m->popup(pos); + } +} + + +void KWalletConfig::deleteEntry() { + TQListViewItem *item = _wcw->_accessList->selectedItem(); + if (item) { + delete item; + emit changed(true); + } +} + +#include "konfigurator.moc" + diff --git a/tdewallet/konfigurator/konfigurator.h b/tdewallet/konfigurator/konfigurator.h new file mode 100644 index 0000000..418d2e5 --- /dev/null +++ b/tdewallet/konfigurator/konfigurator.h @@ -0,0 +1,58 @@ +/* + Copyright (C) 2003 George Staikos + + 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 + +class TDEConfig; +class WalletConfigWidget; +class TQListViewItem; + +class KWalletConfig : public TDECModule { + Q_OBJECT + + public: + KWalletConfig(TQWidget *parent = 0L, const char *name = 0L, const TQStringList& = TQStringList()); + virtual ~KWalletConfig(); + + void load(); + void load( bool useDefaults ); + void save(); + void defaults(); + + TQString quickHelp() const; + + public slots: + void configChanged(); + void launchManager(); + void newLocalWallet(); + void newNetworkWallet(); + void updateWalletLists(); + TQString newWallet(); + void deleteEntry(); + void contextMenuRequested(TQListViewItem *item, const TQPoint& pos, int col); + + private: + WalletConfigWidget *_wcw; + TDEConfig *_cfg; +}; + +#endif diff --git a/tdewallet/konfigurator/tdewallet_config.desktop b/tdewallet/konfigurator/tdewallet_config.desktop new file mode 100644 index 0000000..a30297b --- /dev/null +++ b/tdewallet/konfigurator/tdewallet_config.desktop @@ -0,0 +1,47 @@ +[Desktop Entry] +Type=Service +Exec=kcmshell --caption %c tdewalletconfig +Icon=tdewalletmanager +DocPath=tdewallet/index.html +Name=TDE Wallet +Name[ar]=محفظة كدى +Name[bg]=Портфейл +Name[br]=Doug-paperoù TDE +Name[bs]=TDE novčanik +Name[cs]=Úschovna TDE +Name[cy]=Waled TDE +Name[da]=TDE's tegnebog +Name[de]=Digitale Brieftasche +Name[el]=Πορτοφόλι του TDE +Name[es]=Cartera de TDE +Name[et]=TDE turvalaegas +Name[eu]=TDE Kartera +Name[fi]=Lompakko +Name[fr]=Gestionnaire de comptes de TDE +Name[hi]=केडीई वॉलेट +Name[hu]=Digitális noteszek +Name[is]=TDE veskið +Name[it]=Portafogli di TDE +Name[ja]=TDE ウォレット +Name[kk]=TDE әмияні +Name[km]=កាបូប TDE +Name[lt]=TDE slaptažodinės +Name[mk]=TDE Паричник +Name[nds]=TDE-Knipp +Name[ne]=TDE वालेट +Name[pa]=TDE ਵਾਲਿਟ +Name[pl]=Portfel TDE +Name[pt]=Carteira TDE +Name[pt_BR]=Carteira do TDE +Name[ro]=Portofel TDE +Name[ru]=Бумажник +Name[sl]=Listnica za TDE +Name[sv]=TDE-plånbok +Name[ta]= கேடிஇ வாலட் +Name[tg]=TDE Ҳамён +Name[tr]=TDE Cüzdan +Name[uk]=Торбинки TDE +Name[uz]=TDE qopchiq +Name[uz@cyrillic]=TDE қопчиқ +Name[zh_CN]=TDE 钱包 +Name[zh_TW]=TDE 錢包 diff --git a/tdewallet/konfigurator/tdewalletconfig.desktop b/tdewallet/konfigurator/tdewalletconfig.desktop new file mode 100644 index 0000000..ccae543 --- /dev/null +++ b/tdewallet/konfigurator/tdewalletconfig.desktop @@ -0,0 +1,152 @@ +[Desktop Entry] +Icon=tdewalletmanager +Type=Application +Exec=kcmshell tdewalletconfig +DocPath=tdewallet/index.html +X-TDE-ModuleType=Library +X-TDE-Library=tdewallet +X-TDE-ParentApp=kcontrol + +Name=TDE Wallet +Name[ar]=محفظة كدى +Name[bg]=Портфейл +Name[br]=Doug-paperoù TDE +Name[bs]=TDE novčanik +Name[cs]=Úschovna TDE +Name[cy]=Waled TDE +Name[da]=TDE's tegnebog +Name[de]=Digitale Brieftasche +Name[el]=Πορτοφόλι του TDE +Name[es]=Cartera de TDE +Name[et]=TDE turvalaegas +Name[eu]=TDE Kartera +Name[fi]=Lompakko +Name[fr]=Gestionnaire de comptes de TDE +Name[hi]=केडीई वॉलेट +Name[hu]=Digitális noteszek +Name[is]=TDE veskið +Name[it]=Portafogli di TDE +Name[ja]=TDE ウォレット +Name[kk]=TDE әмияні +Name[km]=កាបូប TDE +Name[lt]=TDE slaptažodinės +Name[mk]=TDE Паричник +Name[nds]=TDE-Knipp +Name[ne]=TDE वालेट +Name[pa]=TDE ਵਾਲਿਟ +Name[pl]=Portfel TDE +Name[pt]=Carteira TDE +Name[pt_BR]=Carteira do TDE +Name[ro]=Portofel TDE +Name[ru]=Бумажник +Name[sl]=Listnica za TDE +Name[sv]=TDE-plånbok +Name[ta]= கேடிஇ வாலட் +Name[tg]=TDE Ҳамён +Name[tr]=TDE Cüzdan +Name[uk]=Торбинки TDE +Name[uz]=TDE qopchiq +Name[uz@cyrillic]=TDE қопчиқ +Name[zh_CN]=TDE 钱包 +Name[zh_TW]=TDE 錢包 +Comment=TDE Wallet Configuration +Comment[ar]=إعداد محفظة كدى +Comment[bg]=Настройване на системата Портфейл +Comment[br]=Kefluniadur Doug-paperoù TDE +Comment[bs]=Podešavanje TDE novčanika +Comment[ca]=Configuració de carteres TDE +Comment[cs]=Nastavení úschovny TDE +Comment[cy]=Ffurfweddiad Waled TDE +Comment[da]=TDE's indstilling af tegnebog +Comment[de]=Einrichten der "digitalen Brieftasche" (KWallet) +Comment[el]=Ρύθμιση του πορτοφολιού του TDE +Comment[es]=Configuración de la cartera de TDE +Comment[et]=TDE turvalaeka seadistamine +Comment[eu]=TDE Karteraren Konfigurazioa +Comment[fa]=TDE Wallet پیکربندی +Comment[fi]=TDE-lompakon asetukset +Comment[fr]=Configuration du gestionnaire de comptes de TDE +Comment[ga]=Cumraíocht TDE Wallet +Comment[he]=TDE Wallet הגדרות +Comment[hi]=केडीई वॉलेट कॉन्फ़िगरेशन +Comment[hu]=A TDE digitális noteszeinek beállításai +Comment[is]=Stillingar veskisins +Comment[it]=Configurazione portafogli di TDE +Comment[ja]=TDE ウォレットの設定 +Comment[ka]=TDE Wallet-ის კონფიგურაცია +Comment[kk]=TDE әмияннің баптауы +Comment[km]=ការកំណត់​រចនា​សម្ព័ន្ធ​កាបូប TDE +Comment[lt]=TDE slaptažodinių konfigūravimas +Comment[mk]=Конфигурација на паричник во TDE +Comment[nb]=Oppsett av TDE Wallet +Comment[nds]=TDE-Knipp instellen +Comment[ne]=TDE वालेट कन्फिगरेसन +Comment[nl]=TDE portefeuille-instellingen +Comment[nn]=Oppsett av TDE Wallet +Comment[pa]=TDE ਵਾਲਿਟ ਸੰਰਚਨਾ +Comment[pl]=Konfiguracja Portfela TDE +Comment[pt]=Configuração da Carteira do TDE +Comment[pt_BR]=Configuração da Carteira do TDE +Comment[ro]=Configurează portofelul TDE +Comment[ru]=Параметры бумажника +Comment[sk]=Konfigurácia TDE Wallet +Comment[sl]=Nastavitve Listnice za TDE +Comment[sr]=Подешавање TDE Wallet-а +Comment[sr@Latn]=Podešavanje TDE Wallet-a +Comment[sv]=Inställning av TDE-plånbok +Comment[ta]=கேடிஇ வாலட் வடிவமைப்பு +Comment[tg]=TDE Танзими Ҳамён +Comment[tr]=TDE Cüzdan Ayarı +Comment[uk]=Налаштування KWallet +Comment[uz]=TDE qopchiq xizmatini moslash +Comment[uz@cyrillic]=TDE қопчиқ хизматини мослаш +Comment[zh_CN]=TDE 钱包配置 +Comment[zh_TW]=TDE 錢包設定 +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;TDE;X-TDE-settings-security; diff --git a/tdewallet/konfigurator/tdewalletmanager_show.desktop b/tdewallet/konfigurator/tdewalletmanager_show.desktop new file mode 100644 index 0000000..3de02d0 --- /dev/null +++ b/tdewallet/konfigurator/tdewalletmanager_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]=כלי לניהול הארנק של TDE +Name[hi]= बटुआ प्रबंधन औज़ार +Name[hu]=Kezelőprogram a TDE 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=tdewalletmanager --show %u +MimeType=application/x-kde-wallet +InitialPreference=6 +Icon=tdewalletmanager +Type=Service +X-TDE-StartupNotify=true diff --git a/tdewallet/konfigurator/walletconfigwidget.ui b/tdewallet/konfigurator/walletconfigwidget.ui new file mode 100644 index 0000000..5f51713 --- /dev/null +++ b/tdewallet/konfigurator/walletconfigwidget.ui @@ -0,0 +1,499 @@ + +WalletConfigWidget + + + WalletConfigWidget + + + + 0 + 0 + 585 + 450 + + + + + unnamed + + + 0 + + + + tabWidget2 + + + + tab + + + Wallet Preferences + + + + unnamed + + + + _enabled + + + &Enable the TDE wallet subsystem + + + true + + + <p>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.</p> + + + + + groupBox2 + + + Close Wallet + + + It is best to close your wallets when you are not using them to prevent others from viewing or using them. + + + + unnamed + + + + layout1 + + + + unnamed + + + + _closeIdle + + + + 1 + 0 + 2 + 0 + + + + Close when unused for: + + + <p><b>Close wallet after a period of inactivity</b><br>When a wallet is closed the password is needed to access it again.</p> + + + + + _idleTime + + + false + + + + 1 + 0 + 0 + 0 + + + + min + + + 999 + + + 1 + + + 5 + + + 10 + + + <p><b>Close wallet after a period of inactivity</b><br>When a wallet is closed the password is needed to access it again.</p> + + + + + spacer12 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + + + _screensaverLock + + + Close when screensaver starts + + + <p><b>Close wallet as soon as the screensaver starts.</b><br>When a wallet is closed the password is needed to access it again.</p> + + + + + _autoclose + + + Close when last application stops using it + + + <p><b>Close wallet as soon as applications that use it have stopped.</b><br>Note that your wallets will only be closed when all applications that use it have stopped.<br>When a wallet is closed the password is needed to access it again.</p> + + + + + + + groupBox4 + + + Automatic Wallet Selection + + + + unnamed + + + + spacer7 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + textLabel1_2 + + + Select wallet to use as default: + + + + + _localWalletSelected + + + Different wallet for local passwords: + + + + + _defaultWallet + + + + 1 + 0 + 1 + 0 + + + + + + _localWallet + + + false + + + + 1 + 0 + 1 + 0 + + + + + + _newLocalWallet + + + false + + + New... + + + + + _newWallet + + + New... + + + + + + + groupBox3 + + + Wallet Manager + + + + unnamed + + + + spacer6 + + + Horizontal + + + Fixed + + + + 20 + 20 + + + + + + _launchManager + + + Show manager in system tray + + + true + + + + + _autocloseManager + + + Hide system tray icon when last wallet closes + + + + + + + spacer4 + + + Vertical + + + Expanding + + + + 31 + 16 + + + + + + + + tab + + + Access Control + + + + unnamed + + + + _openPrompt + + + &Prompt when an application accesses an open wallet + + + true + + + + + + Wallet + + + true + + + true + + + true + + + + + Application + + + true + + + true + + + + + Policy + + + true + + + true + + + + _accessList + + + true + + + + + + + + _launch + + + &Launch Wallet Manager + + + + + spacer2 + + + Horizontal + + + Expanding + + + + 369 + 21 + + + + + + + + _localWalletSelected + toggled(bool) + _newLocalWallet + setEnabled(bool) + + + _localWalletSelected + toggled(bool) + _localWallet + setEnabled(bool) + + + _closeIdle + toggled(bool) + _idleTime + setEnabled(bool) + + + _enabled + toggled(bool) + groupBox2 + setEnabled(bool) + + + _enabled + toggled(bool) + groupBox4 + setEnabled(bool) + + + _enabled + toggled(bool) + groupBox3 + setEnabled(bool) + + + _closeIdle + toggled(bool) + _idleTime + setEnabled(bool) + + + _launchManager + toggled(bool) + _autocloseManager + setEnabled(bool) + + + + _enabled + _closeIdle + _idleTime + _screensaverLock + _autoclose + _defaultWallet + _newWallet + _localWalletSelected + _localWallet + _newLocalWallet + _launchManager + _autocloseManager + tabWidget2 + _openPrompt + _accessList + _launch + + + _storeTogether_toggled(bool) + + + diff --git a/tdewallet/kwalletmanager-tdewalletd.desktop b/tdewallet/kwalletmanager-tdewalletd.desktop new file mode 100644 index 0000000..d4f9706 --- /dev/null +++ b/tdewallet/kwalletmanager-tdewalletd.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]=כלי לניהול הארנק של TDE +Name[hi]= बटुआ प्रबंधन औज़ार +Name[hu]=Kezelőprogram a TDE 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=tdewalletmanager --tdewalletd +Icon=tdewalletmanager +Type=Application +Terminal=false +X-TDE-StartupNotify=false +NoDisplay=true diff --git a/tdewallet/kwmapeditor.cpp b/tdewallet/kwmapeditor.cpp new file mode 100644 index 0000000..2a9e332 --- /dev/null +++ b/tdewallet/kwmapeditor.cpp @@ -0,0 +1,187 @@ +/* + Copyright (C) 2003,2004 George Staikos + + 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 +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +KWMapEditor::KWMapEditor(TQMap& map, TQWidget *parent, const char *name) +: TQTable(0, 3, parent, name), _map(map) { + _ac = new KActionCollection(this); + _copyAct = KStdAction::copy(TQT_TQOBJECT(this), TQT_SLOT(copy()), _ac); + connect(this, TQT_SIGNAL(valueChanged(int,int)), this, TQT_SIGNAL(dirty())); + connect(this, TQT_SIGNAL(contextMenuRequested(int,int,const TQPoint&)), + this, TQT_SLOT(contextMenu(int,int,const TQPoint&))); + setSelectionMode(TQTable::NoSelection); + horizontalHeader()->setLabel(0, TQString()); + 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) { + TQPushButton *b = new TQPushButton("X", this); + connect(b, TQT_SIGNAL(clicked()), this, TQT_SLOT(erase())); + setCellWidget(x, 0, b); + } + } + + row = 0; + for (TQMap::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 TQObject *o = TQT_TQOBJECT(const_cast(sender())); + for (int i = 0; i < numRows(); i++) { + if (TQT_BASE_OBJECT_CONST(cellWidget(i, 0)) == TQT_BASE_OBJECT_CONST(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); + TQPushButton *b = new TQPushButton("X", this); + connect(b, TQT_SIGNAL(clicked()), this, TQT_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 TQPoint& pos) { + _contextRow = row; + _contextCol = col; + KPopupMenu *m = new KPopupMenu(this); + m->insertItem(i18n("&New Entry"), this, TQT_SLOT(addEntry())); + _copyAct->plug(m); + m->popup(pos); +} + + +void KWMapEditor::copy() { + TQApplication::clipboard()->setText(text(_contextRow, 2)); +} + + +class InlineEditor : public TQTextEdit { + public: + InlineEditor(KWMapEditor *p, int row, int col) + : TQTextEdit(), _p(p), row(row), col(col) { + setWFlags(WStyle_NoBorder | WDestructiveClose); + KWin::setType(winId(), NET::Override); + connect(p, TQT_SIGNAL(destroyed()), TQT_SLOT(close())); + } + virtual ~InlineEditor() { if (!_p) return; _p->setText(row, col, text()); _p->emitDirty(); } + + protected: + virtual void focusOutEvent(TQFocusEvent* fe) { + if (fe->reason() == TQFocusEvent::Popup) { + TQWidget *focusW = tqApp->focusWidget(); + if (focusW && focusW == popup) { + return; + } + } + close(); + } + virtual void keyPressEvent(TQKeyEvent *e) { + if (e->key() == TQt::Key_Escape) { + e->accept(); + close(); + } else { + e->ignore(); + TQTextEdit::keyPressEvent(e); + } + } + virtual TQPopupMenu *createPopupMenu(const TQPoint &p) { + popup = TQTextEdit::createPopupMenu(p); + return popup; + } + TQGuardedPtr _p; + int row, col; + TQGuardedPtr popup; +}; + + +TQWidget *KWMapEditor::beginEdit(int row, int col, bool replace) { + //kdDebug(2300) << "EDIT COLUMN " << col << endl; + if (col != 2) { + return TQTable::beginEdit(row, col, replace); + } + + TQRect geo = cellGeometry(row, col); + TQTextEdit *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/tdewallet/kwmapeditor.h b/tdewallet/kwmapeditor.h new file mode 100644 index 0000000..0fade7b --- /dev/null +++ b/tdewallet/kwmapeditor.h @@ -0,0 +1,62 @@ +/* + Copyright (C) 2003,2004 George Staikos + + 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 +#include +#include + +class KAction; +class KActionCollection; + +class KWMapEditor : public TQTable { + Q_OBJECT + + + public: + KWMapEditor(TQMap& map, TQWidget *parent = 0, const char *name = 0); + virtual ~KWMapEditor(); + + public slots: + void reload(); + void saveMap(); + void erase(); + void contextMenu(int row, int col, const TQPoint& pos); + void addEntry(); + void emitDirty(); + + private slots: + void copy(); + + protected: + virtual TQWidget *beginEdit(int row, int col, bool replace); + + signals: + void dirty(); + + private: + TQMap& _map; + int _contextRow, _contextCol; + KActionCollection *_ac; + KAction *_copyAct; +}; + +#endif diff --git a/tdewallet/main.cpp b/tdewallet/main.cpp new file mode 100644 index 0000000..2279783 --- /dev/null +++ b/tdewallet/main.cpp @@ -0,0 +1,100 @@ +/* + Copyright (C) 2003-2005 George Staikos + + 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 +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "tdewalletmanager.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}, + {"tdewalletd", I18N_NOOP("For use by tdewalletd only"), 0}, + {"+name", I18N_NOOP("A wallet name"), 0}, + KCmdLineLastOption + }; + + TDEAboutData about("tdewalletmanager", I18N_NOOP("TDE Wallet Manager"), "1.1", + I18N_NOOP("TDE Wallet Management Tool"), + TDEAboutData::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"); + + TDECmdLineArgs::init(argc, argv, &about); + TDECmdLineArgs::addCmdLineOptions(options); + + if (!KUniqueApplication::start()) { + return 0; + } + + MyApp a; + + KWalletManager wm; + wm.setCaption(i18n("TDE Wallet Manager")); + + a.setMainWidget(&wm); + + TDEGlobal::dirs()->addResourceType("tdewallet", "share/apps/tdewallet"); + + TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); + + if (args->isSet("show")) { + wm.show(); + } + + if (args->isSet("tdewalletd")) { + wm.tdewalletdLaunch(); + } + + for (int i = 0; i < args->count(); ++i) { + TQString fn = TQFileInfo(args->arg(i)).absFilePath(); + KMimeType::Ptr ptr; + if (TQFile::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/tdewallet/tdewalleteditor.cpp b/tdewallet/tdewalleteditor.cpp new file mode 100644 index 0000000..f85294f --- /dev/null +++ b/tdewallet/tdewalleteditor.cpp @@ -0,0 +1,1143 @@ +/* + Copyright (C) 2003-2005 George Staikos + Copyright (C) 2005 Isaac Clerencia + + 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 "tdewalleteditor.h" +#include "kwmapeditor.h" +#include "allyourbase.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +KWalletEditor::KWalletEditor(const TQString& wallet, bool isPath, TQWidget *parent, const char *name) +: KMainWindow(parent, name), _walletName(wallet), _nonLocal(isPath) { + _newWallet = false; + _ww = new WalletWidget(this, "Wallet Widget"); + _copyPassAction = KStdAction::copy(TQT_TQOBJECT(this), TQT_SLOT(copyPassword()), actionCollection()); + + TQVBoxLayout *box = new TQVBoxLayout(_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 TQVBoxLayout(_ww->_entryStack->widget(2)); + _mapEditorShowHide = new TQCheckBox(i18n("&Show values"), _ww->_entryStack->widget(2)); + connect(_mapEditorShowHide, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(showHideMapEditorValue(bool))); + _mapEditor = new KWMapEditor(_currentMap, _ww->_entryStack->widget(2)); + box->addWidget(_mapEditorShowHide); + box->addWidget(_mapEditor); + + setCentralWidget(_ww); + + resize(600, 400); + + connect(_entryList, TQT_SIGNAL(selectionChanged(TQListViewItem*)), + this, TQT_SLOT(entrySelectionChanged(TQListViewItem*))); + connect(_entryList, + TQT_SIGNAL(contextMenuRequested(TQListViewItem*,const TQPoint&,int)), + this, + TQT_SLOT(listContextMenuRequested(TQListViewItem*,const TQPoint&,int))); + connect(_entryList, + TQT_SIGNAL(itemRenamed(TQListViewItem*, int, const TQString&)), + this, + TQT_SLOT(listItemRenamed(TQListViewItem*, int, const TQString&))); + + connect(_ww->_passwordValue, TQT_SIGNAL(textChanged()), + this, TQT_SLOT(entryEditted())); + connect(_mapEditor, TQT_SIGNAL(dirty()), + this, TQT_SLOT(entryEditted())); + + connect(_ww->_undoChanges, TQT_SIGNAL(clicked()), + this, TQT_SLOT(restoreEntry())); + connect(_ww->_saveChanges, TQT_SIGNAL(clicked()), + this, TQT_SLOT(saveEntry())); + + connect(_ww->_showContents, TQT_SIGNAL(clicked()), + this, TQT_SLOT(showPasswordContents())); + connect(_ww->_hideContents, TQT_SIGNAL(clicked()), + this, TQT_SLOT(hidePasswordContents())); + + _walletIsOpen = false; + + _w = KWallet::Wallet::openWallet(wallet, winId(), isPath ? KWallet::Wallet::Path : KWallet::Wallet::Asynchronous); + if (_w) { + connect(_w, TQT_SIGNAL(walletOpened(bool)), this, TQT_SLOT(walletOpened(bool))); + connect(_w, TQT_SIGNAL(walletClosed()), this, TQT_SLOT(walletClosed())); + connect(_w, TQT_SIGNAL(folderUpdated(const TQString&)), this, TQT_SLOT(updateEntries(const TQString&))); + connect(_w, TQT_SIGNAL(folderListUpdated()), this, TQT_SLOT(updateFolderList())); + updateFolderList(); + } else { + kdDebug(2300) << "Wallet open failed!" << endl; + } + + createActions(); + createGUI("tdewalleteditor.rc"); + delete toolBar(); + + setCaption(wallet); + + TQTimer::singleShot(0, this, TQT_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() { + TQValueList 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, TQT_TQOBJECT(this), TQT_SLOT(createFolder()), actionCollection(), + "create_folder"); + connect(this, TQT_SIGNAL(enableFolderActions(bool)), + _newFolderAction, TQT_SLOT(setEnabled(bool))); + + _deleteFolderAction = new KAction(i18n("&Delete Folder"), 0, 0, + TQT_TQOBJECT(this), TQT_SLOT(deleteFolder()), actionCollection(), + "delete_folder"); + connect(this, TQT_SIGNAL(enableContextFolderActions(bool)), + _deleteFolderAction, TQT_SLOT(setEnabled(bool))); + connect(this, TQT_SIGNAL(enableFolderActions(bool)), + _deleteFolderAction, TQT_SLOT(setEnabled(bool))); + + _passwordAction = new KAction(i18n("Change &Password..."), 0, 0, TQT_TQOBJECT(this), + TQT_SLOT(changePassword()), actionCollection(), + "change_password"); + connect(this, TQT_SIGNAL(enableWalletActions(bool)), + _passwordAction, TQT_SLOT(setEnabled(bool))); + + _mergeAction = new KAction(i18n("&Merge Wallet..."), 0, 0, TQT_TQOBJECT(this), + TQT_SLOT(importWallet()), actionCollection(), + "merge"); + connect(this, TQT_SIGNAL(enableWalletActions(bool)), + _mergeAction, TQT_SLOT(setEnabled(bool))); + + _importAction = new KAction(i18n("&Import XML..."), 0, 0, TQT_TQOBJECT(this), + TQT_SLOT(importXML()), actionCollection(), + "import"); + connect(this, TQT_SIGNAL(enableWalletActions(bool)), + _importAction, TQT_SLOT(setEnabled(bool))); + + _exportAction = new KAction(i18n("&Export..."), 0, 0, TQT_TQOBJECT(this), + TQT_SLOT(exportXML()), actionCollection(), + "export"); + connect(this, TQT_SIGNAL(enableWalletActions(bool)), + _exportAction, TQT_SLOT(setEnabled(bool))); + + _saveAsAction = KStdAction::saveAs(TQT_TQOBJECT(this), TQT_SLOT(saveAs()), actionCollection()); + connect(this, TQT_SIGNAL(enableWalletActions(bool)), + _saveAsAction, TQT_SLOT(setEnabled(bool))); + + KStdAction::quit(TQT_TQOBJECT(this), TQT_SLOT(close()), actionCollection()); + KStdAction::keyBindings(guiFactory(), TQT_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) { + TQStringList fl = _w->folderList(); + TQPtrStack trash; + + for (TQListViewItem *i = _entryList->firstChild(); i; i = i->nextSibling()) { + KWalletFolderItem *fi = dynamic_cast(i); + if (!fi) { + continue; + } + if (!fl.contains(fi->name())) { + trash.push(i); + } + } + + trash.setAutoDelete(true); + trash.clear(); + + for (TQStringList::Iterator i = fl.begin(); i != fl.end(); ++i) { + if (_entryList->existsFolder(*i)) { + if (checkEntries) { + updateEntries(*i); + } + continue; + } + + _w->setFolder(*i); + TQStringList 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 (TQStringList::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 TQListViewItem(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) { + TQListViewItem *i = _entryList->currentItem(); + if (i) { + KWalletFolderItem *fi = dynamic_cast(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) { + TQString n; + bool ok; + + do { + n = KInputDialog::getText(i18n("New Folder"), + i18n("Please choose a name for the new folder:"), + TQString(), + &ok, + this); + + if (!ok) { + return; + } + + if (_entryList->existsFolder(n)) { + int rc = KMessageBox::questionYesNo(this, i18n("Sorry, that folder name is in use. Try again?"), TQString(), i18n("Try Again"), i18n("Do Not Try")); + if (rc == KMessageBox::Yes) { + continue; + } + n = TQString(); + } + break; + } while (true); + + _w->createFolder(n); + updateFolderList(); + } +} + + +void KWalletEditor::saveEntry() { + int rc = 1; + TQListViewItem *item = _entryList->currentItem(); + _ww->_saveChanges->setEnabled(false); + _ww->_undoChanges->setEnabled(false); + + if (item && _w && item->parent()) { + KWalletContainerItem *ci = dynamic_cast(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(TQListViewItem *item) { + KWalletContainerItem *ci = 0L; + KWalletFolderItem *fi = 0L; + + switch (item->rtti()) { + case KWalletEntryItemClass: + ci = dynamic_cast(item->parent()); + if (!ci) { + return; + } + fi = dynamic_cast(ci->parent()); + if (!fi) { + return; + } + _w->setFolder(fi->name()); + _deleteFolderAction->setEnabled(false); + if (ci->type() == KWallet::Wallet::Password) { + TQString 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)); + TQByteArray 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(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(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(TQString("%1").arg(fi->text(0))); + _ww->_iconTitle->setPixmap(fi->getFolderIcon(KIcon::Toolbar)); + } +} + +void KWalletEditor::updateEntries(const TQString& folder) { + TQPtrStack trash; + + _w->setFolder(folder); + TQStringList 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 (TQListViewItem *i = pi->firstChild(); i; i = i->nextSibling()) { + if (!entries.contains(i->text(0))) { + if (i == _entryList->currentItem()) { + entrySelectionChanged(0L); + } + trash.push(i); + } + } + + for (TQListViewItem *i = mi->firstChild(); i; i = i->nextSibling()) { + if (!entries.contains(i->text(0))) { + if (i == _entryList->currentItem()) { + entrySelectionChanged(0L); + } + trash.push(i); + } + } + + for (TQListViewItem *i = bi->firstChild(); i; i = i->nextSibling()) { + if (!entries.contains(i->text(0))) { + if (i == _entryList->currentItem()) { + entrySelectionChanged(0L); + } + trash.push(i); + } + } + + for (TQListViewItem *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 (TQStringList::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 TQListViewItem(ui, *i); + break; + } + } + fi->refresh(); + if (fi->name() == _currentFolder) { + _ww->_entryTitle->setText(TQString("%1").arg(fi->text(0))); + } + if (!_entryList->selectedItem()) { + _ww->_entryName->clear(); + _ww->_entryStack->raiseWidget(int(0)); + } +} + +void KWalletEditor::listContextMenuRequested(TQListViewItem *item, const TQPoint& pos, int col) { + Q_UNUSED(col) + + if (!_walletIsOpen) { + return; + } + + KWalletListItemClasses menuClass = KWalletUnknownClass; + KWalletContainerItem *ci = 0L; + + if (item) { + if (item->rtti() == KWalletEntryItemClass) { + ci = dynamic_cast(item->parent()); + if (!ci) { + return; + } + } else if (item->rtti() == KWalletContainerItemClass) { + ci = dynamic_cast(item); + if (!ci) { + return; + } + } + + if (ci && ci->type() == KWallet::Wallet::Unknown) { + return; + } + menuClass = static_cast(item->rtti()); + } + + KPopupMenu *m = new KPopupMenu(this); + if (item) { + TQString 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, TQT_SLOT(newEntry()), Key_Insert); + m->insertItem(i18n( "&Rename" ), this, TQT_SLOT(renameEntry()), Key_F2); + m->insertItem(i18n( "&Delete" ), this, TQT_SLOT(deleteEntry()), Key_Delete); + if (ci && ci->type() == KWallet::Wallet::Password) { + m->insertSeparator(); + _copyPassAction->plug(m); + } + break; + + case KWalletContainerItemClass: + m->insertItem(i18n( "&New..." ), this, TQT_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() { + TQListViewItem *item = _entryList->selectedItem(); + if (_w && item) { + TQString pass; + if (_w->readPassword(item->text(0), pass) == 0) { + TQApplication::clipboard()->setText(pass); + } + } +} + + +void KWalletEditor::newEntry() { + TQListViewItem *item = _entryList->selectedItem(); + TQString n; + bool ok; + + TQListViewItem *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(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:"), + TQString(), + &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?"), TQString(), i18n("Try Again"), i18n("Do Not Try")); + if (rc == KMessageBox::Yes) { + continue; + } + n = TQString(); + } + break; + } while (true); + + if (_w && item && !n.isEmpty()) { + TQListViewItem *p = item; + if (p->rtti() == KWalletEntryItemClass) { + p = item->parent(); + } + + KWalletFolderItem *fi = dynamic_cast(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(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, TQString()); + } else if (ci->type() == KWallet::Wallet::Map) { + _w->writeMap(n, TQMap()); + } else if (ci->type() == KWallet::Wallet::Stream) { + _w->writeEntry(n, TQByteArray()); + } else { + abort(); + } + fi->refresh(); + _ww->_entryTitle->setText(TQString("%1").arg(fi->text(0))); + } +} + + +void KWalletEditor::renameEntry() { + TQListViewItem *item = _entryList->selectedItem(); + if (_w && item) { + item->startRename(0); + } +} + + +// Only supports renaming of KWalletEntryItem derived classes. +void KWalletEditor::listItemRenamed(TQListViewItem* item, int, const TQString& t) { + if (item) { + KWalletEntryItem *i = dynamic_cast(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(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() { + TQListViewItem *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(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(TQString("%1").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(TQString(), "*.kwl", this); + if (url.isEmpty()) { + return; + } + + TQString tmpFile; + if (!TDEIO::NetAccess::download(url, tmpFile, this)) { + KMessageBox::sorry(this, i18n("Unable to access wallet '%1'.").arg(url.prettyURL())); + return; + } + + KWallet::Wallet *w = KWallet::Wallet::openWallet(tmpFile, winId(), KWallet::Wallet::Path); + if (w && w->isOpen()) { + MergePlan mp = Prompt; + TQStringList fl = w->folderList(); + for (TQStringList::ConstIterator f = fl.constBegin(); f != fl.constEnd(); ++f) { + if (!w->setFolder(*f)) { + continue; + } + + if (!_w->hasFolder(*f)) { + _w->createFolder(*f); + } + + _w->setFolder(*f); + + TQMap > map; + int rc; + rc = w->readMapList("*", map); + if (rc == 0) { + TQMap >::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 '%1' already contains an entry '%2'. Do you wish to replace it?").arg(TQStyleSheet::escape(*f)).arg(TQStyleSheet::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()); + } + } + + TQMap pwd; + rc = w->readPasswordList("*", pwd); + if (rc == 0) { + TQMap::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 '%1' already contains an entry '%2'. Do you wish to replace it?").arg(TQStyleSheet::escape(*f)).arg(TQStyleSheet::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()); + } + } + + TQMap ent; + rc = w->readEntryList("*", ent); + if (rc == 0) { + TQMap::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 '%1' already contains an entry '%2'. Do you wish to replace it?").arg(TQStyleSheet::escape(*f)).arg(TQStyleSheet::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; + + TDEIO::NetAccess::removeTempFile(tmpFile); + updateFolderList(true); + restoreEntry(); +} + + +void KWalletEditor::importXML() { + KURL url = KFileDialog::getOpenURL(TQString(), "*.xml", this); + if (url.isEmpty()) { + return; + } + + TQString tmpFile; + if (!TDEIO::NetAccess::download(url, tmpFile, this)) { + KMessageBox::sorry(this, i18n("Unable to access XML file '%1'.").arg(url.prettyURL())); + return; + } + + TQFile qf(tmpFile); + if (!qf.open(IO_ReadOnly)) { + KMessageBox::sorry(this, i18n("Error opening XML file '%1' for input.").arg(url.prettyURL())); + TDEIO::NetAccess::removeTempFile(tmpFile); + return; + } + + TQDomDocument doc(tmpFile); + if (!doc.setContent(&qf)) { + KMessageBox::sorry(this, i18n("Error reading XML file '%1' for input.").arg(url.prettyURL())); + TDEIO::NetAccess::removeTempFile(tmpFile); + return; + } + + TQDomElement top = doc.documentElement(); + if (top.tagName().lower() != "wallet") { + KMessageBox::sorry(this, i18n("Error: XML file does not contain a wallet.")); + TDEIO::NetAccess::removeTempFile(tmpFile); + return; + } + + TQDomNode n = top.firstChild(); + MergePlan mp = Prompt; + while (!n.isNull()) { + TQDomElement e = n.toElement(); + if (e.tagName().lower() != "folder") { + n = n.nextSibling(); + continue; + } + + TQString fname = e.attribute("name"); + if (fname.isEmpty()) { + n = n.nextSibling(); + continue; + } + if (!_w->hasFolder(fname)) { + _w->createFolder(fname); + } + _w->setFolder(fname); + TQDomNode enode = e.firstChild(); + while (!enode.isNull()) { + e = enode.toElement(); + TQString type = e.tagName().lower(); + TQString ename = e.attribute("name"); + bool hasEntry = _w->hasEntry(ename); + if (hasEntry && mp == Prompt) { + KBetterThanKDialogBase *bd; + bd = new KBetterThanKDialogBase(this); + bd->setLabel(i18n("Folder '%1' already contains an entry '%2'. Do you wish to replace it?").arg(TQStyleSheet::escape(fname)).arg(TQStyleSheet::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(TQCString(e.text().latin1()))); + } else if (type == "map") { + TQMap map; + TQDomNode mapNode = e.firstChild(); + while (!mapNode.isNull()) { + TQDomElement 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(); + } + + TDEIO::NetAccess::removeTempFile(tmpFile); + updateFolderList(true); + restoreEntry(); +} + + +void KWalletEditor::exportXML() { + KTempFile tf; + tf.setAutoDelete(true); + TQTextStream& ts(*tf.textStream()); + TQStringList fl = _w->folderList(); + + ts << "" << endl; + for (TQStringList::Iterator i = fl.begin(); i != fl.end(); ++i) { + ts << " " << endl; + _w->setFolder(*i); + TQStringList entries = _w->entryList(); + for (TQStringList::Iterator j = entries.begin(); j != entries.end(); ++j) { + switch (_w->entryType(*j)) { + case KWallet::Wallet::Password: + { + TQString pass; + if (_w->readPassword(*j, pass) == 0) { + ts << " "; + ts << TQStyleSheet::escape(pass); + ts << "" << endl; + } + break; + } + case KWallet::Wallet::Stream: + { + TQByteArray ba; + if (_w->readEntry(*j, ba) == 0) { + ts << " "; + ts << KCodecs::base64Encode(ba); + + ts << "" << endl; + } + break; + } + case KWallet::Wallet::Map: + { + TQMap map; + if (_w->readMap(*j, map) == 0) { + ts << " " << endl; + for (TQMap::ConstIterator k = map.begin(); k != map.end(); ++k) { + ts << " " << TQStyleSheet::escape(k.data()) << "" << endl; + } + ts << " " << endl; + } + break; + } + case KWallet::Wallet::Unknown: + default: + break; + } + } + ts << " " << endl; + } + + ts << "" << endl; + tf.close(); + + KURL url = KFileDialog::getSaveURL(TQString(), "*.xml", this); + + if (!url.isEmpty()) { + bool ok = true; + if (TDEIO::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()); + TDEIO::NetAccess::file_copy(tfURL, url, 0600, true, false, this); + } + } +} + + +void KWalletEditor::setNewWallet(bool x) { + _newWallet = x; +} + + +void KWalletEditor::saveAs() { + KURL url = KFileDialog::getSaveURL(TQString(), "*.kwl", this); + if (!url.isEmpty()) { + // Sync() tdewalletd + if (_nonLocal) { + TDEIO::NetAccess::file_copy(KURL(_walletName), url, 0600, false, false, this); + } else { + TQString path = TDEGlobal::dirs()->saveLocation("tdewallet") + "/" + _walletName + ".kwl"; + KURL destURL; destURL.setPath(path); + TDEIO::NetAccess::file_copy(destURL, url, 0600, false, false, this); + } + } +} + + +#include "tdewalleteditor.moc" + diff --git a/tdewallet/tdewalleteditor.h b/tdewallet/tdewalleteditor.h new file mode 100644 index 0000000..fa7ea25 --- /dev/null +++ b/tdewallet/tdewalleteditor.h @@ -0,0 +1,111 @@ +/* + Copyright (C) 2003-2005 George Staikos + Copyright (C) 2005 Isaac Clerencia + + 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 +#include +#include + +class KAction; +class TQIconViewItem; +class TQListViewItem; +class TQCheckBox; +class KWalletFolderIconView; +class KWalletEntryList; +class KWMapEditor; + +class KWalletEditor : public KMainWindow { + Q_OBJECT + + + public: + KWalletEditor(const TQString& wallet, bool isPath, TQWidget *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(TQListViewItem *item); + void listItemRenamed(TQListViewItem *, int, const TQString&); + void listContextMenuRequested(TQListViewItem *item, const TQPoint& pos, int col); + void updateEntries(const TQString& 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: + TQString _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; + TQLabel*_details; + TQString _currentFolder; + TQMap _currentMap; // save memory by storing + // only the most recent map. + KWMapEditor *_mapEditor; + TQCheckBox *_mapEditorShowHide; + bool _newWallet; +}; + +#endif diff --git a/tdewallet/tdewalleteditor.rc b/tdewallet/tdewalleteditor.rc new file mode 100644 index 0000000..76bd319 --- /dev/null +++ b/tdewallet/tdewalleteditor.rc @@ -0,0 +1,17 @@ + + + + &File + + + + + + + + + + &Help + + + diff --git a/tdewallet/tdewalletmanager.cpp b/tdewallet/tdewalletmanager.cpp new file mode 100644 index 0000000..9e16b74 --- /dev/null +++ b/tdewallet/tdewalletmanager.cpp @@ -0,0 +1,423 @@ +/* + Copyright (C) 2003,2004 George Staikos + + 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 "tdewalletmanager.h" +#include "tdewalletpopup.h" +#include "tdewalleteditor.h" +#include "allyourbase.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +KWalletManager::KWalletManager(TQWidget *parent, const char *name, WFlags f) +: KMainWindow(parent, name, f), DCOPObject("KWalletManager") { + TDEGlobal::dirs()->addResourceType("tdewallet", "share/apps/tdewallet"); + _tdewalletdLaunch = false; + TQAccel *accel = new TQAccel(this, "tdewalletmanager"); + + TDEApplication::dcopClient()->setQtBridgeEnabled(false); + _shuttingDown = false; + TDEConfig cfg("tdewalletrc"); // not sure why this setting isn't in tdewalletmanagerrc... + TDEConfigGroup walletConfigGroup(&cfg, "Wallet"); + _dcopRef = 0L; + if (walletConfigGroup.readBoolEntry("Launch Manager", true)) { + _tray = new KSystemTray(this, "tdewalletmanager tray"); + _tray->setPixmap(loadSystemTrayIcon("wallet_closed")); + TQToolTip::add(_tray, i18n("TDE Wallet: No wallets open.")); + connect(_tray, TQT_SIGNAL(quitSelected()), TQT_SLOT(shuttingDown())); + TQStringList wl = KWallet::Wallet::walletList(); + bool isOpen = false; + for (TQStringList::Iterator it = wl.begin(); it != wl.end(); ++it) { + if (KWallet::Wallet::isOpen(*it)) { + _tray->setPixmap(loadSystemTrayIcon("wallet_open")); + TQToolTip::remove(_tray); + TQToolTip::add(_tray, i18n("TDE Wallet: A wallet is open.")); + isOpen = true; + break; + } + } + if (!isOpen && kapp->isRestored()) { + delete _tray; + _tray = 0L; + TQTimer::singleShot( 0, kapp, TQT_SLOT( quit())); + return; + } + } else { + _tray = 0L; + } + + _iconView = new KWalletIconView(this, "tdewalletmanager icon view"); + connect(_iconView, TQT_SIGNAL(executed(TQIconViewItem*)), TQT_TQOBJECT(this), TQT_SLOT(openWallet(TQIconViewItem*))); + connect(_iconView, TQT_SIGNAL(contextMenuRequested(TQIconViewItem*, const TQPoint&)), TQT_TQOBJECT(this), TQT_SLOT(contextMenu(TQIconViewItem*, const TQPoint&))); + + updateWalletDisplay(); + setCentralWidget(_iconView); + _iconView->setMinimumSize(320, 200); + + _dcopRef = new DCOPRef("kded", "tdewalletd"); + _dcopRef->dcopClient()->setNotifications(true); + connect(_dcopRef->dcopClient(), + TQT_SIGNAL(applicationRemoved(const TQCString&)), + this, + TQT_SLOT(possiblyRescan(const TQCString&))); + connect(_dcopRef->dcopClient(), + TQT_SIGNAL(applicationRegistered(const TQCString&)), + this, + TQT_SLOT(possiblyRescan(const TQCString&))); + + connectDCOPSignal(_dcopRef->app(), _dcopRef->obj(), "allWalletsClosed()", "allWalletsClosed()", false); + connectDCOPSignal(_dcopRef->app(), _dcopRef->obj(), "walletClosed(TQString)", "updateWalletDisplay()", false); + connectDCOPSignal(_dcopRef->app(), _dcopRef->obj(), "walletOpened(TQString)", "aWalletWasOpened()", false); + connectDCOPSignal(_dcopRef->app(), _dcopRef->obj(), "walletDeleted(TQString)", "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..."), "tdewalletmanager", 0, TQT_TQOBJECT(this), + TQT_SLOT(createWallet()), actionCollection(), + "wallet_create"); + KAction *act = new KAction(i18n("Configure &Wallet..."), "configure", + 0, TQT_TQOBJECT(this), TQT_SLOT(setupWallet()), actionCollection(), + "wallet_settings"); + if (_tray) { + act->plug(_tray->contextMenu()); + } + act = new KAction(i18n("Close &All Wallets"), 0, 0, TQT_TQOBJECT(this), + TQT_SLOT(closeAllWallets()), actionCollection(), + "close_all_wallets"); + if (_tray) { + act->plug(_tray->contextMenu()); + } + KStdAction::quit(TQT_TQOBJECT(this), TQT_SLOT(shuttingDown()), actionCollection()); + KStdAction::keyBindings(guiFactory(), TQT_SLOT(configureShortcuts()), +actionCollection()); + + createGUI("tdewalletmanager.rc"); + accel->connectItem(accel->insertItem(Key_Return), TQT_TQOBJECT(this), TQT_SLOT(openWallet())); + accel->connectItem(accel->insertItem(Key_Delete), TQT_TQOBJECT(this), TQT_SLOT(deleteWallet())); + + if (_tray) { + _tray->show(); + } else { + show(); + } + + kapp->setName("tdewallet"); // hack to fix docs +} + + +KWalletManager::~KWalletManager() { + _tray = 0L; + delete _dcopRef; + _dcopRef = 0L; +} + + +void KWalletManager::tdewalletdLaunch() { + _tdewalletdLaunch = 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")); + TQToolTip::remove(_tray); + TQToolTip::add(_tray, i18n("TDE Wallet: A wallet is open.")); + } + updateWalletDisplay(); +} + + +void KWalletManager::updateWalletDisplay() { +TQStringList wl = KWallet::Wallet::walletList(); +TQPtrStack trash; + + for (TQIconViewItem *item = _iconView->firstItem(); item; item = item->nextItem()) { + if (!wl.contains(item->text())) { + trash.push(item); + } + } + + trash.setAutoDelete(true); + trash.clear(); + + for (TQStringList::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(TQIconViewItem *item, const TQPoint& pos) { + if (item) { + TQGuardedPtr popupMenu = new KWalletPopup(item->text(), this); + connect(popupMenu, TQT_SIGNAL(walletOpened(const TQString&)), TQT_TQOBJECT(this), TQT_SLOT(openWallet(const TQString&))); + connect(popupMenu, TQT_SIGNAL(walletClosed(const TQString&)), TQT_TQOBJECT(this), TQT_SLOT(closeWallet(const TQString&))); + connect(popupMenu, TQT_SIGNAL(walletDeleted(const TQString&)), TQT_TQOBJECT(this), TQT_SLOT(deleteWallet(const TQString&))); + connect(popupMenu, TQT_SIGNAL(walletChangePassword(const TQString&)), TQT_TQOBJECT(this), TQT_SLOT(changeWalletPassword(const TQString&))); + connect(popupMenu, TQT_SIGNAL(walletCreated()), TQT_TQOBJECT(this), TQT_SLOT(createWallet())); + popupMenu->exec(pos); + delete popupMenu; + } +} + + +void KWalletManager::deleteWallet(const TQString& 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 TQString& 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?"), TQString(), 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 TQString& walletName) { + KWallet::Wallet::changePassword(walletName); +} + + +void KWalletManager::openWalletFile(const TQString& path) { + KWalletEditor *we = new KWalletEditor(path, true, this, "Wallet Editor"); + if (we->isOpen()) { + connect(we, TQT_SIGNAL(editorClosed(KMainWindow*)), + this, TQT_SLOT(editorClosed(KMainWindow*))); + we->show(); + } else { + KMessageBox::sorry(this, i18n("Error opening wallet %1.").arg(path)); + delete we; + } +} + + +void KWalletManager::openWallet() { + TQIconViewItem *item = _iconView->currentItem(); + openWallet(item); +} + +void KWalletManager::deleteWallet() { + TQIconViewItem *item = _iconView->currentItem(); + if (item) { + deleteWallet(item->text()); + } +} + + +void KWalletManager::openWallet(const TQString& walletName) { + openWallet(walletName, false); +} + + +void KWalletManager::openWallet(const TQString& 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(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, TQT_SIGNAL(editorClosed(KMainWindow*)), + this, TQT_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(TQIconViewItem *item) { + if (item) { + openWallet(item->text()); + } +} + + +void KWalletManager::allWalletsClosed() { + if (_tray) { + _tray->setPixmap(loadSystemTrayIcon("wallet_closed")); + TQToolTip::remove(_tray); + TQToolTip::add(_tray, i18n("TDE Wallet: No wallets open.")); + } + possiblyQuit(); +} + + +void KWalletManager::possiblyQuit() { + TDEConfig cfg("tdewalletrc"); + cfg.setGroup("Wallet"); + if (_windows.isEmpty() && + !isVisible() && + !cfg.readBoolEntry("Leave Manager Open", false) && + _tdewalletdLaunch) { + kapp->quit(); + } +} + + +void KWalletManager::editorClosed(KMainWindow* e) { + _windows.remove(e); +} + + +void KWalletManager::possiblyRescan(const TQCString& app) { + if (app == "kded") { + updateWalletDisplay(); + } +} + + +void KWalletManager::createWallet() { + TQString n; + bool ok; + // FIXME: support international names + TQRegExp regexp("^[A-Za-z0-9]+[A-Za-z0-9_\\s\\-]*$"); + TQString 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?"), TQString(), i18n("Enable"), i18n("Keep Disabled")); + return; + } + + do { + n = KInputDialog::getText(i18n("New Wallet"), + txt, + TQString(), + &ok, + this); + + if (!ok) { + return; + } + + if (_iconView->findItem(n)) { + int rc = KMessageBox::questionYesNo(this, i18n("Sorry, that wallet already exists. Try a new name?"), TQString(), i18n("Try New"), i18n("Do Not Try")); + if (rc == KMessageBox::Yes) { + continue; + } + n = TQString(); + } 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() { + TDEApplication::startServiceByDesktopName("tdewallet_config"); +} + + +void KWalletManager::closeAllWallets() { + _dcopRef->call("closeAllWallets"); +} + + +TQPixmap KWalletManager::loadSystemTrayIcon(const TQString &icon) { +#if KDE_IS_VERSION(3, 1, 90) + return KSystemTray::loadIcon(icon); +#else + TDEConfig *appCfg = kapp->config(); + TDEConfigGroupSaver configSaver(appCfg, "System Tray"); + int iconWidth = appCfg->readNumEntry("systrayIconWidth", 22); + return kapp->iconLoader()->loadIcon( icon, KIcon::Panel, iconWidth ); +#endif +} + + +#include "tdewalletmanager.moc" diff --git a/tdewallet/tdewalletmanager.desktop b/tdewallet/tdewalletmanager.desktop new file mode 100644 index 0000000..915a341 --- /dev/null +++ b/tdewallet/tdewalletmanager.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]=כלי לניהול הארנק של TDE +Name[hi]= बटुआ प्रबंधन औज़ार +Name[hu]=Kezelőprogram a TDE 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=tdewalletmanager %u +MimeType=application/x-kde-wallet; +InitialPreference=6 +Icon=tdewalletmanager +Type=Application +Terminal=false +X-TDE-StartupNotify=false +Categories=Qt;TDE;Settings; +DocPath=tdewallet/index.html diff --git a/tdewallet/tdewalletmanager.h b/tdewallet/tdewalletmanager.h new file mode 100644 index 0000000..23103d5 --- /dev/null +++ b/tdewallet/tdewalletmanager.h @@ -0,0 +1,85 @@ +/* + Copyright (C) 2003,2004 George Staikos + + 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 +#include +#include + +class KSystemTray; +class KWalletIconView; +class TQIconViewItem; +class DCOPRef; + + +class KWalletManager : public KMainWindow, public DCOPObject { + Q_OBJECT +// + K_DCOP + + public: + KWalletManager(TQWidget *parent = 0, const char* name = 0, WFlags f = 0); + virtual ~KWalletManager(); + + TQPixmap loadSystemTrayIcon(const TQString &icon); + + void tdewalletdLaunch(); + + public slots: + void createWallet(); + void deleteWallet(const TQString& walletName); + void closeWallet(const TQString& walletName); + void changeWalletPassword(const TQString& walletName); + void openWallet(const TQString& walletName); + void openWallet(const TQString& walletName, bool newWallet); + void openWalletFile(const TQString& path); + void openWallet(TQIconViewItem *item); + void contextMenu(TQIconViewItem *item, const TQPoint& 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 TQCString& app); + void setupWallet(); + void openWallet(); + void deleteWallet(); + void closeAllWallets(); + + private: + KSystemTray *_tray; + bool _shuttingDown; + KWalletIconView *_iconView; + DCOPRef *_dcopRef; + TQPtrList _windows; + bool _tdewalletdLaunch; +}; + +#endif diff --git a/tdewallet/tdewalletmanager.rc b/tdewallet/tdewalletmanager.rc new file mode 100644 index 0000000..509e4b0 --- /dev/null +++ b/tdewallet/tdewalletmanager.rc @@ -0,0 +1,14 @@ + + + + &File + + + + &Settings + + + &Help + + + diff --git a/tdewallet/tdewalletpopup.cpp b/tdewallet/tdewalletpopup.cpp new file mode 100644 index 0000000..05f142d --- /dev/null +++ b/tdewallet/tdewalletpopup.cpp @@ -0,0 +1,110 @@ +/* + Copyright (C) 2003 George Staikos + + 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 "tdewalletpopup.h" + +#include +#include +#include +#include +#include +#include +#include + +KWalletPopup::KWalletPopup(const TQString& wallet, TQWidget *parent, const char *name) +: KPopupMenu(parent, name), _walletName(wallet) { + insertTitle(wallet); + KActionCollection *ac = new KActionCollection(this, "tdewallet context actions"); + KAction *act; + + act = new KAction(i18n("&New Wallet..."), 0, 0, TQT_TQOBJECT(this), + TQT_SLOT(createWallet()), ac, "wallet_create"); + act->plug(this); + + act = new KAction(i18n("&Open..."), 0, Key_Return, TQT_TQOBJECT(this), + TQT_SLOT(openWallet()), ac, "wallet_open"); + act->plug(this); + + act = new KAction(i18n("Change &Password..."), 0, 0, TQT_TQOBJECT(this), + TQT_SLOT(changeWalletPassword()), ac, "wallet_password"); + act->plug(this); + + TQStringList ul = KWallet::Wallet::users(wallet); + if (!ul.isEmpty()) { + KPopupMenu *pm = new KPopupMenu(this, "Disconnect Apps"); + int id = 7000; + for (TQStringList::Iterator it = ul.begin(); it != ul.end(); ++it) { + _appMap[id] = *it; + pm->insertItem(*it, this, TQT_SLOT(disconnectApp(int)), 0, id); + pm->setItemParameter(id, id); + id++; + } + + insertItem(i18n("Disconnec&t"), pm); + } + + act = KStdAction::close( TQT_TQOBJECT(this), + TQT_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, TQT_TQOBJECT(this), + TQT_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 "tdewalletpopup.moc" + diff --git a/tdewallet/tdewalletpopup.h b/tdewallet/tdewalletpopup.h new file mode 100644 index 0000000..8ef78b0 --- /dev/null +++ b/tdewallet/tdewalletpopup.h @@ -0,0 +1,55 @@ +/* + Copyright (C) 2003 George Staikos + + 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 +#include +#include + +class KWalletPopup : public KPopupMenu { + Q_OBJECT + + + public: + KWalletPopup(const TQString& wallet, TQWidget *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 TQString& walletName); + void walletClosed(const TQString& walletName); + void walletDeleted(const TQString& walletName); + void walletCreated(); + void walletChangePassword(const TQString& walletName); + + private: + TQString _walletName; + TQMap _appMap; +}; + +#endif diff --git a/tdewallet/walletwidget.ui b/tdewallet/walletwidget.ui new file mode 100644 index 0000000..9979097 --- /dev/null +++ b/tdewallet/walletwidget.ui @@ -0,0 +1,416 @@ + +WalletWidget + + + WalletWidget + + + + 0 + 0 + 614 + 507 + + + + + unnamed + + + 0 + + + + _splitter + + + Horizontal + + + + _entryListFrame + + + + 5 + 5 + 0 + 0 + + + + NoFrame + + + Plain + + + + + layout3 + + + + unnamed + + + + _entryName + + + + 5 + 1 + 0 + 0 + + + + + + + PlainText + + + + + spacer1 + + + Horizontal + + + Expanding + + + + 227 + 21 + + + + + + _undoChanges + + + false + + + &Undo + + + "undo" + + + + + layout2 + + + + unnamed + + + + _iconTitle + + + + 1 + 1 + 0 + 0 + + + + + + + + + _entryTitle + + + + 7 + 1 + 0 + 0 + + + + + 1 + + + + + + + RichText + + + AlignVCenter + + + + + + + _saveChanges + + + false + + + &Save + + + "filesave" + + + + + _entryStack + + + + 5 + 5 + 0 + 1 + + + + + page + + + 0 + + + + + page + + + 1 + + + + unnamed + + + 0 + + + + _passwordValue + + + PlainText + + + + + spacer8 + + + Horizontal + + + Expanding + + + + 271 + 20 + + + + + + _hideContents + + + Hide &Contents + + + + + + + page + + + 2 + + + + + page + + + 3 + + + + unnamed + + + 0 + + + + textLabel1_2 + + + This is a binary data entry. It cannot be editted as its format is unknown and application specific. + + + WordBreak|AlignVCenter + + + + + spacer3 + + + Vertical + + + Expanding + + + + 31 + 41 + + + + + + spacer4 + + + Vertical + + + Expanding + + + + 31 + 41 + + + + + + spacer5 + + + Horizontal + + + Expanding + + + + 61 + 41 + + + + + + spacer6 + + + Horizontal + + + Expanding + + + + 41 + 21 + + + + + + + + page + + + 4 + + + + unnamed + + + 0 + + + + spacer7 + + + Horizontal + + + Expanding + + + + 236 + 21 + + + + + + spacer6_2 + + + Vertical + + + Expanding + + + + 31 + 358 + + + + + + _showContents + + + Show &Contents + + + + + + + + + + + + kdialog.h + kiconloader.h + +SmallIconSet + + + -- cgit v1.2.1