summaryrefslogtreecommitdiffstats
path: root/opensuse/core/tdelibs.old/kwalletd-try-open.diff
diff options
context:
space:
mode:
authorRobert Xu <robxu9@gmail.com>2012-03-31 14:28:06 -0400
committerRobert Xu <robxu9@gmail.com>2012-03-31 14:28:06 -0400
commit59dd46ef985a719579132efa6a9aa49bfeeae112 (patch)
tree93d8c721ff263e67aaf59e364496862872ded8fb /opensuse/core/tdelibs.old/kwalletd-try-open.diff
parentc141f0bc29b6e2eeda5ca08a043d26546a1427f9 (diff)
downloadtde-packaging-59dd46ef985a719579132efa6a9aa49bfeeae112.tar.gz
tde-packaging-59dd46ef985a719579132efa6a9aa49bfeeae112.zip
better late than never, hm...
Diffstat (limited to 'opensuse/core/tdelibs.old/kwalletd-try-open.diff')
-rw-r--r--opensuse/core/tdelibs.old/kwalletd-try-open.diff81
1 files changed, 81 insertions, 0 deletions
diff --git a/opensuse/core/tdelibs.old/kwalletd-try-open.diff b/opensuse/core/tdelibs.old/kwalletd-try-open.diff
new file mode 100644
index 000000000..547f8192d
--- /dev/null
+++ b/opensuse/core/tdelibs.old/kwalletd-try-open.diff
@@ -0,0 +1,81 @@
+Index: kio/misc/kwalletd/kwalletd.cpp
+===================================================================
+--- kio/misc/kwalletd/kwalletd.cpp.orig
++++ kio/misc/kwalletd/kwalletd.cpp
+@@ -355,6 +355,44 @@ int KWalletD::doTransactionOpen(const QC
+ return rc;
+ }
+
++int KWalletD::tryOpen(const QString& wallet, const QCString& 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(QByteArray().duplicate(password, strlen(password)));
++ if (rc == 0) {
++ _wallets.insert(rc = generateHandle(), b);
++ _passwords[wallet] = password;
++ b->ref();
++ _tryOpenBlocked.stop();
++ QByteArray data;
++ QDataStream ds(data, IO_WriteOnly);
++ ds << wallet;
++ emitDCOPSignal("walletOpened(QString)", 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;
++ QTimer::singleShot(0, this, SLOT(notifyFailures()));
++ }
++
++ rc = -1;
++ }
++ return rc;
++}
+
+ int KWalletD::internalOpen(const QCString& appid, const QString& wallet, bool isPath, WId w, bool modal) {
+ int rc = -1;
+Index: kio/misc/kwalletd/kwalletd.h
+===================================================================
+--- kio/misc/kwalletd/kwalletd.h.orig
++++ kio/misc/kwalletd/kwalletd.h
+@@ -26,6 +26,7 @@
+ #include <qintdict.h>
+ #include <qstring.h>
+ #include <qwidget.h>
++#include <qtimer.h>
+ #include <qguardedptr.h>
+ #include "kwalletbackend.h"
+
+@@ -51,8 +52,10 @@ class KWalletD : public KDEDModule {
+
+ // Open and unlock the wallet
+ virtual int open(const QString& wallet, uint wId);
+-
++ // Open and unlock the wallet
++ virtual int tryOpen(const QString& wallet, const QCString& passwd);
+ // Open and unlock the wallet with this path
++
+ virtual int openPath(const QString& path, uint wId);
+
+ // Asynchronous open - must give the object to return the handle
+@@ -186,6 +189,7 @@ class KWalletD : public KDEDModule {
+ int _idleTime;
+ QMap<QString,QStringList> _implicitAllowMap, _implicitDenyMap;
+ KTimeout *_timeouts;
++ QTimer _tryOpenBlocked;
+
+ QPtrList<KWalletTransaction> _transactions;
+ QGuardedPtr< QWidget > activeDialog;