From 96900dbce3aaa1fcac74a07a71482c5c6fcd3cab Mon Sep 17 00:00:00 2001 From: tpearson Date: Thu, 2 Sep 2010 21:21:15 +0000 Subject: * Large set of SuSE patches to fix bugs and add functionality * kdemm is included but not used by knotify as it does not work out of the box git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1171141 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kio/misc/kwalletd/kwalletd.cpp | 38 ++++++++++++++++++++++++++++++++++++++ kio/misc/kwalletd/kwalletd.h | 6 +++++- 2 files changed, 43 insertions(+), 1 deletion(-) (limited to 'kio/misc') diff --git a/kio/misc/kwalletd/kwalletd.cpp b/kio/misc/kwalletd/kwalletd.cpp index fd39f8487..069575710 100644 --- a/kio/misc/kwalletd/kwalletd.cpp +++ b/kio/misc/kwalletd/kwalletd.cpp @@ -355,6 +355,44 @@ int KWalletD::doTransactionOpen(const TQCString& appid, const TQString& wallet, return rc; } +int KWalletD::tryOpen(const TQString& wallet, const TQCString& password) +{ + if (isOpen(wallet)) + return 0; + + if (_tryOpenBlocked.isActive()) { + kdDebug() << "tryOpen is active.." << endl; + return -1; + } + + if (!KWallet::Backend::exists(wallet)) + return -2; + + KWallet::Backend *b = new KWallet::Backend(wallet, false /*isPath*/); + int rc = b->open(TQByteArray().duplicate(password, strlen(password))); + if (rc == 0) { + _wallets.insert(rc = generateHandle(), b); + _passwords[wallet] = password; + b->ref(); + _tryOpenBlocked.stop(); + TQByteArray data; + TQDataStream ds(data, IO_WriteOnly); + ds << wallet; + emitDCOPSignal("walletOpened(TQString)", data); + } + else { + delete b; + // make sure that we're not bombed with a dictionary attack + _tryOpenBlocked.start (30 * 1000, true /*single shot*/); + if (++_failed > 5) { + _failed = 0; + TQTimer::singleShot(0, this, TQT_SLOT(notifyFailures())); + } + + rc = -1; + } + return rc; +} int KWalletD::internalOpen(const TQCString& appid, const TQString& wallet, bool isPath, WId w, bool modal) { int rc = -1; diff --git a/kio/misc/kwalletd/kwalletd.h b/kio/misc/kwalletd/kwalletd.h index b426e7d5a..2aea371ba 100644 --- a/kio/misc/kwalletd/kwalletd.h +++ b/kio/misc/kwalletd/kwalletd.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include "kwalletbackend.h" @@ -51,8 +52,10 @@ class KWalletD : public KDEDModule { // Open and unlock the wallet virtual int open(const TQString& wallet, uint wId); - + // Open and unlock the wallet + virtual int tryOpen(const TQString& wallet, const TQCString& passwd); // Open and unlock the wallet with this path + virtual int openPath(const TQString& path, uint wId); // Asynchronous open - must give the object to return the handle @@ -186,6 +189,7 @@ class KWalletD : public KDEDModule { int _idleTime; TQMap _implicitAllowMap, _implicitDenyMap; KTimeout *_timeouts; + TQTimer _tryOpenBlocked; TQPtrList _transactions; TQGuardedPtr< TQWidget > activeDialog; -- cgit v1.2.1