summaryrefslogtreecommitdiff
path: root/src/dbus/server/dbus-sync.cpp
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2012-05-29 18:14:13 +0200
committerPatrick Ohly <patrick.ohly@intel.com>2012-05-30 09:09:00 +0200
commit8da86205df7f993a83fd38fb76681fa6b789c297 (patch)
treea1f8ca36e3e00457780a0b3c8d2113ebed8affb7 /src/dbus/server/dbus-sync.cpp
parentd2fd4806c84d119d6dfb280b1847db661e40c661 (diff)
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked KDE_FULL_SESSION to determine whether it should use KWallet instead of GNOME Keyring. That did not work, because the env variable was not set for D-Bus daemons. Automatically detecting KDE users is not possible at the moment. Instead KDE users have to manually set the new "keyring" global config property to "KDE" (case insensitive) if the SyncEvolution installation supports both, because GNOME Keyring is the default to avoid surprises for traditional users. If only KWallet support is enabled, then this is not necessary. "GNOME" and "true/false/1/0/yes/no" can also be set. This has the advantage that keyring usage can be enabled permanently for the command line in --daemon=no mode; normally keyrings are not used in that mode because accessing them can bring up UI dialogs. It also becomes possible to disable keyring usage in syncevo-dbus-server, something which couldn't be done before. The --keyring command line option is still supported, as an alias for "[--sync-property] keyring=<value>". The default value for --keyring is true, to match the traditional behavior. In contrast to other sync properties, setting "keyring" does not require an explicit --run parameter. Again this is done to mirror traditional usage. Reading a password also (unintentionally) checked all supported storages while searching for the password. Now it uses exactly one storage and falls back to asking for the password directly. The commit itself also cleans up the code a bit (reformatted, fixed comments). Choosing the right slot in the password signals is done via a new InitStateTri parameter which contains the "keyring" setting. Error checking (unsupported keyring string, --keyring=yes and no keyring enabled) is done in additional slots which run after all the regular ones. Parameter parsing for --sync and --keyring were unified. However, there is the difference that --keyring has an implicit default value ("yes") and never has an additional parameter, in contrast to --sync, which always is followed by one. The new CmdlineTest::testKeyring covers different ways of using --keyring. It relies on actually invoking keyring backends, something not done by the default SyncContext UI. Therefore CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution, to be used by CmdlineTest.
Diffstat (limited to 'src/dbus/server/dbus-sync.cpp')
-rw-r--r--src/dbus/server/dbus-sync.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/dbus/server/dbus-sync.cpp b/src/dbus/server/dbus-sync.cpp
index c32ab8bb..928d7341 100644
--- a/src/dbus/server/dbus-sync.cpp
+++ b/src/dbus/server/dbus-sync.cpp
@@ -196,7 +196,9 @@ string DBusSync::askPassword(const string &passwordName,
return password;
}
-void DBusSync::askPasswordAsync(const std::string &passwordName, const std::string &descr, const ConfigPasswordKey &key,
+void DBusSync::askPasswordAsync(const std::string &passwordName,
+ const std::string &descr,
+ const ConfigPasswordKey &key,
const boost::function<void (const std::string &)> &success,
const boost::function<void ()> &failureException)
{
@@ -205,8 +207,9 @@ void DBusSync::askPasswordAsync(const std::string &passwordName, const std::stri
m_passwordFailure.clear();
m_passwordDescr = descr;
- string password;
- if (GetLoadPasswordSignal()(passwordName, descr, key, password)) {
+ InitStateString password;
+ if (GetLoadPasswordSignal()(getKeyring(), passwordName, descr, key, password) &&
+ password.wasSet()) {
// handled
success(password);
return;
@@ -279,9 +282,11 @@ void DBusSync::suspendFlagsChanged(SuspendFlags &flags)
}
}
-bool DBusSync::savePassword(const std::string &passwordName, const std::string &password, const ConfigPasswordKey &key)
+bool DBusSync::savePassword(const std::string &passwordName,
+ const std::string &password,
+ const ConfigPasswordKey &key)
{
- if (GetSavePasswordSignal()(passwordName, password, key)) {
+ if (GetSavePasswordSignal()(getKeyring(), passwordName, password, key)) {
return true;
}