summaryrefslogtreecommitdiffstats
path: root/kio/misc/kwalletd
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-02 21:21:15 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-02 21:21:15 +0000
commit96900dbce3aaa1fcac74a07a71482c5c6fcd3cab (patch)
treebf3fc68d0dcc660fce0e21171373a2d4e2395707 /kio/misc/kwalletd
parent5f99bff82d3413803bcc652999f4f631058179d6 (diff)
downloadtdelibs-96900dbce3aaa1fcac74a07a71482c5c6fcd3cab.tar.gz
tdelibs-96900dbce3aaa1fcac74a07a71482c5c6fcd3cab.zip
* 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
Diffstat (limited to 'kio/misc/kwalletd')
-rw-r--r--kio/misc/kwalletd/kwalletd.cpp38
-rw-r--r--kio/misc/kwalletd/kwalletd.h6
2 files changed, 43 insertions, 1 deletions
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 <tqintdict.h>
#include <tqstring.h>
#include <tqwidget.h>
+#include <tqtimer.h>
#include <tqguardedptr.h>
#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<TQString,TQStringList> _implicitAllowMap, _implicitDenyMap;
KTimeout *_timeouts;
+ TQTimer _tryOpenBlocked;
TQPtrList<KWalletTransaction> _transactions;
TQGuardedPtr< TQWidget > activeDialog;