summaryrefslogtreecommitdiffstats
path: root/kio/misc
diff options
context:
space:
mode:
Diffstat (limited to 'kio/misc')
-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;