summaryrefslogtreecommitdiffstats
path: root/tdewallet/client
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-26 13:17:21 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-26 13:17:21 -0600
commitdfe289850f068f19ba4a83ab4e7e22a7e09c13c9 (patch)
treec297348a55df66c571de4525646e0b9762427353 /tdewallet/client
parentb7658a0d5eca24a9d37c6e04f88298ef02389db0 (diff)
downloadtdelibs-dfe289850f068f19ba4a83ab4e7e22a7e09c13c9.tar.gz
tdelibs-dfe289850f068f19ba4a83ab4e7e22a7e09c13c9.zip
Rename a number of libraries and executables to avoid conflicts with KDE4
Diffstat (limited to 'tdewallet/client')
-rw-r--r--tdewallet/client/CMakeLists.txt46
-rw-r--r--tdewallet/client/Makefile.am14
-rw-r--r--tdewallet/client/tdewallet.cc713
-rw-r--r--tdewallet/client/tdewallet.h525
-rw-r--r--tdewallet/client/tdewallettypes.h32
5 files changed, 1330 insertions, 0 deletions
diff --git a/tdewallet/client/CMakeLists.txt b/tdewallet/client/CMakeLists.txt
new file mode 100644
index 000000000..f222f8bde
--- /dev/null
+++ b/tdewallet/client/CMakeLists.txt
@@ -0,0 +1,46 @@
+#################################################
+#
+# (C) 2010 Serghei Amelian
+# serghei (DOT) amelian (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+include_directories(
+ ${TQT_INCLUDE_DIRS}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}/tdecore
+ ${CMAKE_SOURCE_DIR}/dcop
+ ${CMAKE_SOURCE_DIR}/tdecore
+)
+
+link_directories(
+ ${TQT_LIBRARY_DIRS}
+)
+
+
+##### headers ###################################
+
+install( FILES
+ tdewallet.h tdewallettypes.h
+ DESTINATION ${INCLUDE_INSTALL_DIR} )
+
+
+##### libtdewalletclient ##############################
+
+set( target tdewalletclient )
+
+set( ${target}_SRCS
+ tdewallet.skel tdewallet.cc
+)
+
+tde_add_library( ${target} SHARED AUTOMOC
+ SOURCES ${${target}_SRCS}
+ VERSION 1.0.1
+ LINK tdecore-shared
+ DEPENDENCIES dcopidl
+ DESTINATION ${LIB_INSTALL_DIR}
+)
diff --git a/tdewallet/client/Makefile.am b/tdewallet/client/Makefile.am
new file mode 100644
index 000000000..d10938a4f
--- /dev/null
+++ b/tdewallet/client/Makefile.am
@@ -0,0 +1,14 @@
+
+INCLUDES= -I$(srcdir) $(all_includes)
+
+lib_LTLIBRARIES = libtdewalletclient.la
+
+libtdewalletclient_la_LDFLAGS = $(KDE_RPATH) $(all_libraries) -version-info 1:1 -no-undefined
+libtdewalletclient_la_LIBADD = $(LIB_TDECORE) $(LIB_QT) $(top_builddir)/dcop/libDCOP.la
+libtdewalletclient_la_SOURCES = tdewallet.skel \
+ tdewallet.cc
+
+libtdewalletclient_la_METASOURCES = AUTO
+
+include_HEADERS = tdewallet.h tdewallettypes.h
+
diff --git a/tdewallet/client/tdewallet.cc b/tdewallet/client/tdewallet.cc
new file mode 100644
index 000000000..73b423cbc
--- /dev/null
+++ b/tdewallet/client/tdewallet.cc
@@ -0,0 +1,713 @@
+/* This file is part of the KDE project
+ *
+ * Copyright (C) 2002-2004 George Staikos <staikos@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "tdewallettypes.h"
+#include "tdewallet.h"
+#include <kconfig.h>
+#include <kdebug.h>
+#include <tdeversion.h>
+#include <dcopclient.h>
+#include <dcopref.h>
+#include <tqpopupmenu.h>
+#include <tqapplication.h>
+
+#include <assert.h>
+
+using namespace KWallet;
+
+
+const TQString Wallet::LocalWallet() {
+ TDEConfig cfg("tdewalletrc", true);
+ cfg.setGroup("Wallet");
+ if (!cfg.readBoolEntry("Use One Wallet", true)) {
+ TQString tmp = cfg.readEntry("Local Wallet", "localwallet");
+ if (tmp.isEmpty()) {
+ return "localwallet";
+ }
+ return tmp;
+ }
+
+ TQString tmp = cfg.readEntry("Default Wallet", "kdewallet");
+ if (tmp.isEmpty()) {
+ return "kdewallet";
+ }
+ return tmp;
+}
+
+const TQString Wallet::NetworkWallet() {
+ TDEConfig cfg("tdewalletrc", true);
+ cfg.setGroup("Wallet");
+
+ TQString tmp = cfg.readEntry("Default Wallet", "kdewallet");
+ if (tmp.isEmpty()) {
+ return "kdewallet";
+ }
+ return tmp;
+}
+
+const TQString Wallet::PasswordFolder() {
+ return "Passwords";
+}
+
+const TQString Wallet::FormDataFolder() {
+ return "Form Data";
+}
+
+
+
+Wallet::Wallet(int handle, const TQString& name)
+: TQObject(0L), DCOPObject(), d(0L), _name(name), _handle(handle) {
+
+ _dcopRef = new DCOPRef("kded", "tdewalletd");
+
+ _dcopRef->dcopClient()->setNotifications(true);
+ connect(_dcopRef->dcopClient(),
+ TQT_SIGNAL(applicationRemoved(const TQCString&)),
+ this,
+ TQT_SLOT(slotAppUnregistered(const TQCString&)));
+
+ connectDCOPSignal(_dcopRef->app(), _dcopRef->obj(), "walletClosed(int)", "slotWalletClosed(int)", false);
+ connectDCOPSignal(_dcopRef->app(), _dcopRef->obj(), "folderListUpdated(TQString)", "slotFolderListUpdated(TQString)", false);
+ connectDCOPSignal(_dcopRef->app(), _dcopRef->obj(), "folderUpdated(TQString, TQString)", "slotFolderUpdated(TQString, TQString)", false);
+ connectDCOPSignal(_dcopRef->app(), _dcopRef->obj(), "applicationDisconnected(TQString, TQCString)", "slotApplicationDisconnected(TQString, TQCString)", false);
+
+ // Verify that the wallet is still open
+ if (_handle != -1) {
+ DCOPReply r = _dcopRef->call("isOpen", _handle);
+ if (r.isValid()) {
+ bool rc = false;
+ r.get(rc);
+ if (!rc) {
+ _handle = -1;
+ _name = TQString::null;
+ }
+ }
+ }
+}
+
+
+Wallet::~Wallet() {
+ if (_handle != -1) {
+ _dcopRef->call("close", _handle, false);
+ _handle = -1;
+ _folder = TQString::null;
+ _name = TQString::null;
+ }
+
+ delete _dcopRef;
+ _dcopRef = 0L;
+}
+
+
+TQStringList Wallet::walletList() {
+ DCOPReply r = DCOPRef("kded", "tdewalletd").call("wallets");
+ TQStringList rc;
+ if (r.isValid()) {
+ r.get(rc);
+ }
+ return rc;
+}
+
+
+void Wallet::changePassword(const TQString& name, WId w) {
+ DCOPRef("kded", "tdewalletd").send("changePassword", name, uint(w));
+}
+
+
+bool Wallet::isEnabled() {
+ DCOPReply r = DCOPRef("kded", "tdewalletd").call("isEnabled");
+ bool rc = false;
+ if (r.isValid()) {
+ r.get(rc);
+ }
+ return rc;
+}
+
+
+bool Wallet::isOpen(const TQString& name) {
+ DCOPReply r = DCOPRef("kded", "tdewalletd").call("isOpen", name);
+ bool rc = false;
+ if (r.isValid()) {
+ r.get(rc);
+ }
+ return rc;
+}
+
+
+int Wallet::closeWallet(const TQString& name, bool force) {
+ DCOPReply r = DCOPRef("kded", "tdewalletd").call("close", name, force);
+ int rc = -1;
+ if (r.isValid()) {
+ r.get(rc);
+ }
+ return rc;
+}
+
+
+int Wallet::deleteWallet(const TQString& name) {
+ DCOPReply r = DCOPRef("kded", "tdewalletd").call("deleteWallet", name);
+ int rc = -1;
+ if (r.isValid()) {
+ r.get(rc);
+ }
+ return rc;
+}
+
+
+Wallet *Wallet::openWallet(const TQString& name, WId w, OpenType ot) {
+ if (ot == Asynchronous) {
+ Wallet *wallet = new Wallet(-1, name);
+ DCOPRef("kded", "tdewalletd").send("openAsynchronous", name, wallet->objId(), uint(w));
+ return wallet;
+ }
+
+ // avoid deadlock if the app has some popup open (#65978/#71048)
+ while( TQWidget* widget = TQT_TQWIDGET(tqApp->activePopupWidget()))
+ widget->close();
+
+ bool isPath = ot == Path;
+ DCOPReply r;
+
+ if (isPath) {
+ r = DCOPRef("kded", "tdewalletd").call("openPath", name, uint(w));
+ } else {
+ r = DCOPRef("kded", "tdewalletd").call("open", name, uint(w));
+ }
+
+ if (r.isValid()) {
+ int drc = -1;
+ r.get(drc);
+ if (drc != -1) {
+ return new Wallet(drc, name);
+ }
+ }
+
+ return 0;
+}
+
+
+bool Wallet::disconnectApplication(const TQString& wallet, const TQCString& app) {
+ DCOPReply r = DCOPRef("kded", "tdewalletd").call("disconnectApplication", wallet, app);
+ bool rc = false;
+ if (r.isValid()) {
+ r.get(rc);
+ }
+ return rc;
+}
+
+
+TQStringList Wallet::users(const TQString& name) {
+ DCOPReply r = DCOPRef("kded", "tdewalletd").call("users", name);
+ TQStringList drc;
+ if (r.isValid()) {
+ r.get(drc);
+ }
+ return drc;
+}
+
+
+int Wallet::sync() {
+ if (_handle == -1) {
+ return -1;
+ }
+
+ _dcopRef->call("sync", _handle);
+ return 0;
+}
+
+
+int Wallet::lockWallet() {
+ if (_handle == -1) {
+ return -1;
+ }
+
+ DCOPReply r = _dcopRef->call("close", _handle, true);
+ _handle = -1;
+ _folder = TQString::null;
+ _name = TQString::null;
+ if (r.isValid()) {
+ int drc = -1;
+ r.get(drc);
+ return drc;
+ }
+ return -1;
+}
+
+
+const TQString& Wallet::walletName() const {
+ return _name;
+}
+
+
+bool Wallet::isOpen() const {
+ return _handle != -1;
+}
+
+
+void Wallet::requestChangePassword(WId w) {
+ if (_handle == -1) {
+ return;
+ }
+
+ _dcopRef->send("changePassword", _name, uint(w));
+}
+
+
+void Wallet::slotWalletClosed(int handle) {
+ if (_handle == handle) {
+ _handle = -1;
+ _folder = TQString::null;
+ _name = TQString::null;
+ emit walletClosed();
+ }
+}
+
+
+TQStringList Wallet::folderList() {
+ TQStringList rc;
+
+ if (_handle == -1) {
+ return rc;
+ }
+
+ DCOPReply r = _dcopRef->call("folderList", _handle);
+ if (r.isValid()) {
+ r.get(rc);
+ }
+
+ return rc;
+}
+
+
+TQStringList Wallet::entryList() {
+ TQStringList rc;
+
+ if (_handle == -1) {
+ return rc;
+ }
+
+ DCOPReply r = _dcopRef->call("entryList", _handle, _folder);
+ if (r.isValid()) {
+ r.get(rc);
+ }
+
+ return rc;
+}
+
+
+bool Wallet::hasFolder(const TQString& f) {
+ bool rc = false;
+
+ if (_handle == -1) {
+ return rc;
+ }
+
+ DCOPReply r = _dcopRef->call("hasFolder", _handle, f);
+ if (r.isValid()) {
+ r.get(rc);
+ }
+
+ return rc;
+}
+
+
+bool Wallet::createFolder(const TQString& f) {
+ bool rc = true;
+
+ if (_handle == -1) {
+ return false;
+ }
+
+ if (!hasFolder(f)) {
+ DCOPReply r = _dcopRef->call("createFolder", _handle, f);
+ if (r.isValid()) {
+ r.get(rc);
+ }
+ }
+
+ return rc;
+}
+
+
+bool Wallet::setFolder(const TQString& f) {
+ bool rc = false;
+
+ if (_handle == -1) {
+ return rc;
+ }
+
+ // Don't do this - the folder could have disappeared?
+#if 0
+ if (f == _folder) {
+ return true;
+ }
+#endif
+
+ if (hasFolder(f)) {
+ _folder = f;
+ rc = true;
+ }
+
+ return rc;
+}
+
+
+bool Wallet::removeFolder(const TQString& f) {
+ bool rc = false;
+
+ if (_handle == -1) {
+ return rc;
+ }
+
+ DCOPReply r = _dcopRef->call("removeFolder", _handle, f);
+ if (r.isValid()) {
+ r.get(rc);
+ }
+
+ if (_folder == f) {
+ setFolder(TQString::null);
+ }
+
+ return rc;
+}
+
+
+const TQString& Wallet::currentFolder() const {
+ return _folder;
+}
+
+
+int Wallet::readEntry(const TQString& key, TQByteArray& value) {
+ int rc = -1;
+
+ if (_handle == -1) {
+ return rc;
+ }
+
+ DCOPReply r = _dcopRef->call("readEntry", _handle, _folder, key);
+ if (r.isValid()) {
+ r.get(value);
+ rc = 0;
+ }
+
+ return rc;
+}
+
+
+int Wallet::readEntryList(const TQString& key, TQMap<TQString, TQByteArray>& value) {
+ int rc = -1;
+
+ if (_handle == -1) {
+ return rc;
+ }
+
+ DCOPReply r = _dcopRef->call("readEntryList", _handle, _folder, key);
+ if (r.isValid()) {
+ r.get(value);
+ rc = 0;
+ }
+
+ return rc;
+}
+
+
+int Wallet::renameEntry(const TQString& oldName, const TQString& newName) {
+ int rc = -1;
+
+ if (_handle == -1) {
+ return rc;
+ }
+
+ DCOPReply r = _dcopRef->call("renameEntry", _handle, _folder, oldName, newName);
+ if (r.isValid()) {
+ r.get(rc);
+ }
+
+ return rc;
+}
+
+
+int Wallet::readMap(const TQString& key, TQMap<TQString,TQString>& value) {
+ int rc = -1;
+
+ if (_handle == -1) {
+ return rc;
+ }
+
+ DCOPReply r = _dcopRef->call("readMap", _handle, _folder, key);
+ if (r.isValid()) {
+ TQByteArray v;
+ r.get(v);
+ if (!v.isEmpty()) {
+ TQDataStream ds(v, IO_ReadOnly);
+ ds >> value;
+ }
+ rc = 0;
+ }
+
+ return rc;
+}
+
+
+int Wallet::readMapList(const TQString& key, TQMap<TQString, TQMap<TQString, TQString> >& value) {
+ int rc = -1;
+
+ if (_handle == -1) {
+ return rc;
+ }
+
+ DCOPReply r = _dcopRef->call("readMapList", _handle, _folder, key);
+ if (r.isValid()) {
+ TQMap<TQString,TQByteArray> unparsed;
+ r.get(unparsed);
+ for (TQMap<TQString,TQByteArray>::ConstIterator i = unparsed.begin(); i != unparsed.end(); ++i) {
+ if (!i.data().isEmpty()) {
+ TQDataStream ds(i.data(), IO_ReadOnly);
+ TQMap<TQString,TQString> v;
+ ds >> v;
+ value.insert(i.key(), v);
+ }
+ }
+ rc = 0;
+ }
+
+ return rc;
+}
+
+
+int Wallet::readPassword(const TQString& key, TQString& value) {
+ int rc = -1;
+
+ if (_handle == -1) {
+ return rc;
+ }
+
+ DCOPReply r = _dcopRef->call("readPassword", _handle, _folder, key);
+ if (r.isValid()) {
+ r.get(value);
+ rc = 0;
+ }
+
+ return rc;
+}
+
+
+int Wallet::readPasswordList(const TQString& key, TQMap<TQString, TQString>& value) {
+ int rc = -1;
+
+ if (_handle == -1) {
+ return rc;
+ }
+
+ DCOPReply r = _dcopRef->call("readPasswordList", _handle, _folder, key);
+ if (r.isValid()) {
+ r.get(value);
+ rc = 0;
+ }
+
+ return rc;
+}
+
+
+int Wallet::writeEntry(const TQString& key, const TQByteArray& value, EntryType entryType) {
+ int rc = -1;
+
+ if (_handle == -1) {
+ return rc;
+ }
+
+ DCOPReply r = _dcopRef->call("writeEntry", _handle, _folder, key, value, int(entryType));
+ if (r.isValid()) {
+ r.get(rc);
+ }
+
+ return rc;
+}
+
+
+int Wallet::writeEntry(const TQString& key, const TQByteArray& value) {
+ int rc = -1;
+
+ if (_handle == -1) {
+ return rc;
+ }
+
+ DCOPReply r = _dcopRef->call("writeEntry", _handle, _folder, key, value);
+ if (r.isValid()) {
+ r.get(rc);
+ }
+
+ return rc;
+}
+
+
+int Wallet::writeMap(const TQString& key, const TQMap<TQString,TQString>& value) {
+ int rc = -1;
+
+ if (_handle == -1) {
+ return rc;
+ }
+
+ TQByteArray a;
+ TQDataStream ds(a, IO_WriteOnly);
+ ds << value;
+ DCOPReply r = _dcopRef->call("writeMap", _handle, _folder, key, a);
+ if (r.isValid()) {
+ r.get(rc);
+ }
+
+ return rc;
+}
+
+
+int Wallet::writePassword(const TQString& key, const TQString& value) {
+ int rc = -1;
+
+ if (_handle == -1) {
+ return rc;
+ }
+
+ DCOPReply r = _dcopRef->call("writePassword", _handle, _folder, key, value);
+ if (r.isValid()) {
+ r.get(rc);
+ }
+
+ return rc;
+}
+
+
+bool Wallet::hasEntry(const TQString& key) {
+ bool rc = false;
+
+ if (_handle == -1) {
+ return rc;
+ }
+
+ DCOPReply r = _dcopRef->call("hasEntry", _handle, _folder, key);
+ if (r.isValid()) {
+ r.get(rc);
+ }
+
+ return rc;
+}
+
+
+int Wallet::removeEntry(const TQString& key) {
+ int rc = -1;
+
+ if (_handle == -1) {
+ return rc;
+ }
+
+ DCOPReply r = _dcopRef->call("removeEntry", _handle, _folder, key);
+ if (r.isValid()) {
+ r.get(rc);
+ }
+
+ return rc;
+}
+
+
+Wallet::EntryType Wallet::entryType(const TQString& key) {
+ int rc = 0;
+
+ if (_handle == -1) {
+ return Wallet::Unknown;
+ }
+
+ DCOPReply r = _dcopRef->call("entryType", _handle, _folder, key);
+ if (r.isValid()) {
+ r.get(rc);
+ }
+
+ return static_cast<EntryType>(rc);
+}
+
+
+void Wallet::slotAppUnregistered(const TQCString& app) {
+ if (_handle >= 0 && app == "kded") {
+ slotWalletClosed(_handle);
+ }
+}
+
+
+void Wallet::slotFolderUpdated(const TQString& wallet, const TQString& folder) {
+ if (_name == wallet) {
+ emit folderUpdated(folder);
+ }
+}
+
+
+void Wallet::slotFolderListUpdated(const TQString& wallet) {
+ if (_name == wallet) {
+ emit folderListUpdated();
+ }
+}
+
+
+void Wallet::slotApplicationDisconnected(const TQString& wallet, const TQCString& application) {
+ if (_handle >= 0
+ && _name == wallet
+ && application == _dcopRef->dcopClient()->appId()) {
+ slotWalletClosed(_handle);
+ }
+}
+
+
+void Wallet::walletOpenResult(int id) {
+ if (_handle != -1) {
+ // This is BAD.
+ return;
+ }
+
+ if (id > 0) {
+ _handle = id;
+ emit walletOpened(true);
+ } else if (id < 0) {
+ emit walletOpened(false);
+ } // id == 0 => wait
+}
+
+
+bool Wallet::folderDoesNotExist(const TQString& wallet, const TQString& folder) {
+DCOPReply r = DCOPRef("kded", "tdewalletd").call("folderDoesNotExist", wallet, folder);
+bool rc = true;
+ if (r.isValid()) {
+ r.get(rc);
+ }
+return rc;
+}
+
+
+bool Wallet::keyDoesNotExist(const TQString& wallet, const TQString& folder, const TQString& key) {
+DCOPReply r = DCOPRef("kded", "tdewalletd").call("keyDoesNotExist", wallet, folder, key);
+bool rc = true;
+ if (r.isValid()) {
+ r.get(rc);
+ }
+return rc;
+}
+
+
+void Wallet::virtual_hook(int, void*) {
+ //BASE::virtual_hook( id, data );
+}
+
+#include "tdewallet.moc"
diff --git a/tdewallet/client/tdewallet.h b/tdewallet/client/tdewallet.h
new file mode 100644
index 000000000..fa5dbcbb2
--- /dev/null
+++ b/tdewallet/client/tdewallet.h
@@ -0,0 +1,525 @@
+/* This file is part of the KDE project
+ *
+ * Copyright (C) 2002-2004 George Staikos <staikos@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+
+#ifndef _KWALLET_H
+#define _KWALLET_H
+
+#include <tqglobal.h>
+
+#ifdef Q_MOC_RUN
+#define Q_OS_UNIX
+#endif // Q_MOC_RUN
+
+#ifdef Q_OS_UNIX
+
+#include <tqstring.h>
+#include <tqstringlist.h>
+#include <tqobject.h>
+#include <dcopobject.h>
+
+class DCOPRef;
+
+/** Namespace collecting all the Wallet-related classes. */
+namespace KWallet {
+
+/**
+ * KDE Wallet
+ *
+ * This class implements a generic system-wide Wallet for KDE. This is the
+ * ONLY public interface. The DCOP client is unsupported and considered to be
+ * private.
+ *
+ * @author George Staikos <staikos@kde.org>
+ * @short KDE Wallet Class
+ */
+class TDEIO_EXPORT Wallet : public TQObject, public DCOPObject {
+ K_DCOP
+ Q_OBJECT
+ protected:
+ /**
+ * Construct a KWallet object.
+ * @internal
+ * @param handle The handle for the wallet.
+ * @param name The name of the wallet.
+ */
+ Wallet(int handle, const TQString& name);
+ /**
+ * Copy a KWallet object.
+ * @internal
+ */
+ Wallet(const Wallet&);
+
+ public:
+ enum EntryType { Unknown=0, Password, Stream, Map, Unused=0xffff };
+
+ /**
+ * Destroy a KWallet object. Closes the wallet.
+ */
+ virtual ~Wallet();
+
+ /**
+ * List all the wallets available.
+ * @return Returns a list of the names of all wallets that are
+ * open.
+ */
+ static TQStringList walletList();
+
+ /**
+ * Determine if the KDE wallet is enabled. Normally you do
+ * not need to use this because open() will just fail.
+ * @return Returns true if the wallet enabled, else false.
+ */
+ static bool isEnabled();
+
+ /**
+ * Determine if the wallet @p name is open by any application.
+ * @param name The name of the wallet to check.
+ * @return Returns true if the wallet is open, else false.
+ */
+ static bool isOpen(const TQString& name);
+
+ /**
+ * Close the wallet @p name. The wallet will only be closed
+ * if it is open but not in use (rare), or if it is forced
+ * closed.
+ * @param name The name of the wallet to close.
+ * @param force Set true to force the wallet closed even if it
+ * is in use by others.
+ * @return Returns 0 on success, non-zero on error.
+ */
+ static int closeWallet(const TQString& name, bool force);
+
+ /**
+ * Delete the wallet @p name. The wallet will be forced closed
+ * first.
+ * @param name The name of the wallet to delete.
+ * @return Returns 0 on success, non-zero on error.
+ */
+ static int deleteWallet(const TQString& name);
+
+ /**
+ * Disconnect the application @p app from @p wallet.
+ * @param wallet The name of the wallet to disconnect.
+ * @param app The name of the application to disconnect.
+ * @return Returns true on success, false on error.
+ */
+ static bool disconnectApplication(const TQString& wallet, const TQCString& app);
+
+ enum OpenType { Synchronous=0, Asynchronous, Path, OpenTypeUnused=0xff };
+
+ /**
+ * Open the wallet @p name. The user will be prompted to
+ * allow your application to open the wallet, and may be
+ * prompted for a password. You are responsible for deleting
+ * this object when you are done with it.
+ * @param name The name of the wallet to open.
+ * @param ot If Asynchronous, the call will return
+ * immediately with a non-null pointer to an
+ * invalid wallet. You must immediately connect
+ * the walletOpened() signal to a slot so that
+ * you will know when it is opened, or when it
+ * fails.
+ * @param w The window id to associate any dialogs with.
+ * @return Returns a pointer to the wallet if successful,
+ * or a null pointer on error or if rejected.
+ */
+ static Wallet* openWallet(const TQString& name, WId w = 0, OpenType ot = Synchronous);
+
+ /**
+ * List the applications that are using the wallet @p wallet.
+ * @param wallet The wallet to query.
+ * @return Returns a list of all DCOP application IDs using
+ * the wallet.
+ */
+ static TQStringList users(const TQString& wallet);
+
+ /**
+ * The name of the wallet used to store local passwords.
+ */
+ static const TQString LocalWallet();
+
+ /**
+ * The name of the wallet used to store network passwords.
+ */
+ static const TQString NetworkWallet();
+
+ /**
+ * The standardized name of the password folder.
+ * It is automatically created when a wallet is created, but
+ * the user may still delete it so you should check for its
+ * existence and recreate it if necessary and desired.
+ */
+ static const TQString PasswordFolder();
+
+ /**
+ * The standardized name of the form data folder.
+ * It is automatically created when a wallet is created, but
+ * the user may still delete it so you should check for its
+ * existence and recreate it if necessary and desired.
+ */
+ static const TQString FormDataFolder();
+
+ /**
+ * Request to the wallet service to change the password of
+ * the wallet @p name.
+ * @param name The the wallet to change the password of.
+ * @param w The window id to associate any dialogs with.
+ */
+ static void changePassword(const TQString& name, WId w = 0);
+
+ /**
+ * This syncs the wallet file on disk with what is in memory.
+ * You don't normally need to use this. It happens
+ * automatically on close.
+ * @return Returns 0 on success, non-zero on error.
+ */
+ virtual int sync();
+
+ /**
+ * This closes and locks the current wallet. It will
+ * disconnect all applications using the wallet.
+ * @return Returns 0 on success, non-zero on error.
+ */
+ virtual int lockWallet();
+
+ /**
+ * The name of the current wallet.
+ */
+ virtual const TQString& walletName() const;
+
+ /**
+ * Determine if the current wallet is open, and is a valid
+ * wallet handle.
+ * @return Returns true if the wallet handle is valid and open.
+ */
+ virtual bool isOpen() const;
+
+ /**
+ * Request to the wallet service to change the password of
+ * the current wallet.
+ * @param w The window id to associate any dialogs with.
+ */
+ virtual void requestChangePassword(WId w = 0);
+
+ /**
+ * Obtain the list of all folders contained in the wallet.
+ * @return Returns an empty list if the wallet is not open.
+ */
+ virtual TQStringList folderList();
+
+ /**
+ * Determine if the folder @p f exists in the wallet.
+ * @param f the name of the folder to check for
+ * @return Returns true if the folder exists in the wallet.
+ */
+ virtual bool hasFolder(const TQString& f);
+
+ /**
+ * Set the current working folder to @p f. The folder must
+ * exist, or this call will fail. Create a folder with
+ * createFolder().
+ * @param f the name of the folder to make the working folder
+ * @return Returns true if the folder was successfully set.
+ */
+ virtual bool setFolder(const TQString& f);
+
+ /**
+ * Remove the folder @p f and all its entries from the wallet.
+ * @param f the name of the folder to remove
+ * @return Returns true if the folder was successfully removed.
+ */
+ virtual bool removeFolder(const TQString& f);
+
+ /**
+ * Created the folder @p f.
+ * @param f the name of the folder to create
+ * @return Returns true if the folder was successfully created.
+ */
+ virtual bool createFolder(const TQString& f);
+
+ /**
+ * Determine the current working folder in the wallet.
+ * If the folder name is empty, it is working in the global
+ * folder, which is valid but discouraged.
+ * @return Returns the current working folder.
+ */
+ virtual const TQString& currentFolder() const;
+
+ /**
+ * Return the list of keys of all entries in this folder.
+ * @return Returns an empty list if the wallet is not open, or
+ * if the folder is empty.
+ */
+ virtual TQStringList entryList();
+
+ /**
+ * Rename the entry @p oldName to @p newName.
+ * @param oldName The original key of the entry.
+ * @param newName The new key of the entry.
+ * @return Returns 0 on success, non-zero on error.
+ */
+ virtual int renameEntry(const TQString& oldName, const TQString& newName);
+
+ /**
+ * Read the entry @p key from the current folder.
+ * The entry format is unknown except that it is either a
+ * TQByteArray or a TQDataStream, which effectively means that
+ * it is anything.
+ * @param key The key of the entry to read.
+ * @param value A buffer to fill with the value.
+ * @return Returns 0 on success, non-zero on error.
+ */
+ virtual int readEntry(const TQString& key, TQByteArray& value);
+
+ /**
+ * Read the map entry @p key from the current folder.
+ * @param key The key of the entry to read.
+ * @param value A map buffer to fill with the value.
+ * @return Returns 0 on success, non-zero on error. Will
+ * return an error if the key was not originally
+ * written as a map.
+ */
+ virtual int readMap(const TQString& key, TQMap<TQString,TQString>& value);
+
+ /**
+ * Read the password entry @p key from the current folder.
+ * @param key The key of the entry to read.
+ * @param value A password buffer to fill with the value.
+ * @return Returns 0 on success, non-zero on error. Will
+ * return an error if the key was not originally
+ * written as a password.
+ */
+ virtual int readPassword(const TQString& key, TQString& value);
+
+ /**
+ * Read the entries matching @p key from the current folder.
+ * The entry format is unknown except that it is either a
+ * TQByteArray or a TQDataStream, which effectively means that
+ * it is anything.
+ * @param key The key of the entry to read. Wildcards
+ * are supported.
+ * @param value A buffer to fill with the value. The key in
+ * the map is the entry key.
+ * @return Returns 0 on success, non-zero on error.
+ * @since 3.4
+ */
+ int readEntryList(const TQString& key, TQMap<TQString, TQByteArray>& value);
+
+ /**
+ * Read the map entry @p key from the current folder.
+ * @param key The key of the entry to read. Wildcards
+ * are supported.
+ * @param value A buffer to fill with the value. The key in
+ * the map is the entry key.
+ * @return Returns 0 on success, non-zero on error. Will
+ * return an error if the key was not originally
+ * written as a map.
+ * @since 3.4
+ */
+ int readMapList(const TQString& key, TQMap<TQString, TQMap<TQString, TQString> >& value);
+
+ /**
+ * Read the password entry @p key from the current folder.
+ * @param key The key of the entry to read. Wildcards
+ * are supported.
+ * @param value A buffer to fill with the value. The key in
+ * the map is the entry key.
+ * @return Returns 0 on success, non-zero on error. Will
+ * return an error if the key was not originally
+ * written as a password.
+ * @since 3.4
+ */
+ int readPasswordList(const TQString& key, TQMap<TQString, TQString>& value);
+
+ /**
+ * Write @p key = @p value as a binary entry to the current
+ * folder. Be careful with this, it could cause inconsistency
+ * in the future since you can put an arbitrary entry type in
+ * place.
+ * @param key The key of the new entry.
+ * @param value The value of the entry.
+ * @param entryType The type of the entry.
+ * @return Returns 0 on success, non-zero on error.
+ */
+ virtual int writeEntry(const TQString& key, const TQByteArray& value, EntryType entryType);
+
+ /**
+ * Write @p key = @p value as a binary entry to the current
+ * folder.
+ * @param key The key of the new entry.
+ * @param value The value of the entry.
+ * @return Returns 0 on success, non-zero on error.
+ */
+ virtual int writeEntry(const TQString& key, const TQByteArray& value);
+
+ /**
+ * Write @p key = @p value as a map to the current folder.
+ * @param key The key of the new entry.
+ * @param value The value of the map.
+ * @return Returns 0 on success, non-zero on error.
+ */
+ virtual int writeMap(const TQString& key, const TQMap<TQString,TQString>& value);
+
+ /**
+ * Write @p key = @p value as a password to the current folder.
+ * @param key The key of the new entry.
+ * @param value The value of the password.
+ * @return Returns 0 on success, non-zero on error.
+ */
+ virtual int writePassword(const TQString& key, const TQString& value);
+
+ /**
+ * Determine if the current folder has they entry @p key.
+ * @param key The key to search for.
+ * @return Returns true if the folder contains @p key.
+ */
+ virtual bool hasEntry(const TQString& key);
+
+ /**
+ * Remove the entry @p key from the current folder.
+ * @param key The key to remove.
+ * @return Returns 0 on success, non-zero on error.
+ */
+ virtual int removeEntry(const TQString& key);
+
+ /**
+ * Determine the type of the entry @p key in this folder.
+ * @param key The key to look up.
+ * @return Returns an enumerated type representing the type
+ * of the entry.
+ */
+ virtual EntryType entryType(const TQString& key);
+
+ /**
+ * Determine if a folder does not exist in a wallet. This
+ * does not require decryption of the wallet.
+ * This is a handy optimization to avoid prompting the user
+ * if your data is certainly not in the wallet.
+ * @param wallet The wallet to look in.
+ * @param folder The folder to look up.
+ * @return Returns true if the folder does NOT exist in the
+ * wallet, or the wallet does not exist.
+ */
+ static bool folderDoesNotExist(const TQString& wallet, const TQString& folder);
+
+ /**
+ * Determine if an entry in a folder does not exist in a
+ * wallet. This does not require decryption of the wallet.
+ * This is a handy optimization to avoid prompting the user
+ * if your data is certainly not in the wallet.
+ * @param wallet The wallet to look in.
+ * @param folder The folder to look in.
+ * @param key The key to look up.
+ * @return Returns true if the key does NOT exist in the
+ * wallet, or the folder or wallet does not exist.
+ */
+ static bool keyDoesNotExist(const TQString& wallet, const TQString& folder,
+ const TQString& key);
+
+ signals:
+ /**
+ * Emitted when this wallet is closed.
+ */
+ void walletClosed();
+
+ /**
+ * Emitted when a folder in this wallet is updated.
+ * @param folder The folder that was updated.
+ */
+ void folderUpdated(const TQString& folder);
+
+ /**
+ * Emitted when the folder list is changed in this wallet.
+ */
+ void folderListUpdated();
+
+ /**
+ * Emitted when a folder in this wallet is removed.
+ * @param folder The folder that was removed.
+ */
+ void folderRemoved(const TQString& folder);
+
+ /**
+ * Emitted when a wallet is opened in asynchronous mode.
+ * @param success True if the wallet was opened successfully.
+ */
+ void walletOpened(bool success);
+
+ private:
+ k_dcop:
+ /**
+ * @internal
+ * DCOP slot for signals emitted by the wallet service.
+ */
+ ASYNC slotWalletClosed(int handle);
+
+ /**
+ * @internal
+ * DCOP slot for signals emitted by the wallet service.
+ */
+ ASYNC slotFolderUpdated(const TQString& wallet, const TQString& folder);
+
+ /**
+ * @internal
+ * DCOP slot for signals emitted by the wallet service.
+ */
+ ASYNC slotFolderListUpdated(const TQString& wallet);
+
+ /**
+ * @internal
+ * DCOP slot for signals emitted by the wallet service.
+ */
+ ASYNC slotApplicationDisconnected(const TQString& wallet, const TQCString& application);
+
+ /**
+ * @internal
+ * Callback for tdewalletd
+ */
+ ASYNC walletOpenResult(int rc);
+
+ private slots:
+ /**
+ * @internal
+ * Used to detect when the wallet service dies.
+ */
+ void slotAppUnregistered(const TQCString&);
+
+ private:
+ class WalletPrivate;
+ WalletPrivate *d;
+ TQString _name;
+ TQString _folder;
+ int _handle;
+ DCOPRef *_dcopRef;
+
+ protected:
+ /**
+ * @internal
+ */
+ virtual void virtual_hook(int id, void *data);
+};
+
+}
+
+#endif //Q_OS_UNIX
+
+#endif //_KWALLET_H
+
diff --git a/tdewallet/client/tdewallettypes.h b/tdewallet/client/tdewallettypes.h
new file mode 100644
index 000000000..918dc0a3f
--- /dev/null
+++ b/tdewallet/client/tdewallettypes.h
@@ -0,0 +1,32 @@
+/* This file is part of the KDE project
+ *
+ * Copyright (C) 2004 George Staikos <staikos@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KWALLET_TYPES_H
+#define KWALLET_TYPES_H
+
+#include <tqmap.h>
+
+class TQString;
+
+inline const char* dcopTypeName(const TQByteArray&) { return "TQByteArray"; }
+inline const char* dcopTypeName(const TQMap<TQString,TQString>&) { return "TQMap<TQString,TQString>"; }
+inline const char* dcopTypeName(const TQMap<TQString,TQByteArray>&) { return "TQMap<TQString,TQByteArray>"; }
+
+#endif