aboutsummaryrefslogtreecommitdiffstats
path: root/subversion/libsvn_auth_kwallet/kwallet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'subversion/libsvn_auth_kwallet/kwallet.cpp')
-rw-r--r--subversion/libsvn_auth_kwallet/kwallet.cpp65
1 files changed, 26 insertions, 39 deletions
diff --git a/subversion/libsvn_auth_kwallet/kwallet.cpp b/subversion/libsvn_auth_kwallet/kwallet.cpp
index e1a345e7d45c..74e4eaf846ff 100644
--- a/subversion/libsvn_auth_kwallet/kwallet.cpp
+++ b/subversion/libsvn_auth_kwallet/kwallet.cpp
@@ -47,6 +47,7 @@
#include "svn_auth.h"
#include "svn_config.h"
#include "svn_error.h"
+#include "svn_hash.h"
#include "svn_io.h"
#include "svn_pools.h"
#include "svn_string.h"
@@ -135,34 +136,36 @@ get_wid(void)
return wid;
}
+/* Forward definition */
+static apr_status_t
+kwallet_terminate(void *data);
+
static KWallet::Wallet *
get_wallet(QString wallet_name,
apr_hash_t *parameters)
{
KWallet::Wallet *wallet =
- static_cast<KWallet::Wallet *> (apr_hash_get(parameters,
- "kwallet-wallet",
- APR_HASH_KEY_STRING));
- if (! wallet && ! apr_hash_get(parameters,
- "kwallet-opening-failed",
- APR_HASH_KEY_STRING))
+ static_cast<KWallet::Wallet *> (svn_hash_gets(parameters,
+ "kwallet-wallet"));
+ if (! wallet && ! svn_hash_gets(parameters, "kwallet-opening-failed"))
{
wallet = KWallet::Wallet::openWallet(wallet_name, get_wid(),
KWallet::Wallet::Synchronous);
- }
- if (wallet)
- {
- apr_hash_set(parameters,
- "kwallet-wallet",
- APR_HASH_KEY_STRING,
- wallet);
- }
- else
- {
- apr_hash_set(parameters,
- "kwallet-opening-failed",
- APR_HASH_KEY_STRING,
- "");
+
+ if (wallet)
+ {
+ svn_hash_sets(parameters, "kwallet-wallet", wallet);
+
+ apr_pool_cleanup_register(apr_hash_pool_get(parameters),
+ parameters, kwallet_terminate,
+ apr_pool_cleanup_null);
+
+ svn_hash_sets(parameters, "kwallet-initialized", "");
+ }
+ else
+ {
+ svn_hash_sets(parameters, "kwallet-opening-failed", "");
+ }
}
return wallet;
}
@@ -171,14 +174,12 @@ static apr_status_t
kwallet_terminate(void *data)
{
apr_hash_t *parameters = static_cast<apr_hash_t *> (data);
- if (apr_hash_get(parameters, "kwallet-initialized", APR_HASH_KEY_STRING))
+ if (svn_hash_gets(parameters, "kwallet-initialized"))
{
KWallet::Wallet *wallet = get_wallet(NULL, parameters);
delete wallet;
- apr_hash_set(parameters,
- "kwallet-initialized",
- APR_HASH_KEY_STRING,
- NULL);
+ svn_hash_sets(parameters, "kwallet-wallet", NULL);
+ svn_hash_sets(parameters, "kwallet-initialized", NULL);
}
return APR_SUCCESS;
}
@@ -236,10 +237,6 @@ kwallet_password_get(svn_boolean_t *done,
KWallet::Wallet *wallet = get_wallet(wallet_name, parameters);
if (wallet)
{
- apr_hash_set(parameters,
- "kwallet-initialized",
- APR_HASH_KEY_STRING,
- "");
if (wallet->setFolder(folder))
{
QString q_password;
@@ -254,9 +251,6 @@ kwallet_password_get(svn_boolean_t *done,
}
}
- apr_pool_cleanup_register(pool, parameters, kwallet_terminate,
- apr_pool_cleanup_null);
-
return SVN_NO_ERROR;
}
@@ -310,10 +304,6 @@ kwallet_password_set(svn_boolean_t *done,
KWallet::Wallet *wallet = get_wallet(wallet_name, parameters);
if (wallet)
{
- apr_hash_set(parameters,
- "kwallet-initialized",
- APR_HASH_KEY_STRING,
- "");
if (! wallet->hasFolder(folder))
{
wallet->createFolder(folder);
@@ -329,9 +319,6 @@ kwallet_password_set(svn_boolean_t *done,
}
}
- apr_pool_cleanup_register(pool, parameters, kwallet_terminate,
- apr_pool_cleanup_null);
-
return SVN_NO_ERROR;
}