Skip to content

Commit

Permalink
Backends: Fall back on libsecret if kwallet is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
ckamm committed Jun 14, 2018
1 parent ed2ff1b commit 4dfde7a
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions keychain_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,25 @@ static DesktopEnvironment detectDesktopEnvironment() {
return DesktopEnv_Other;
}

static bool isKwallet5Available()
{
if (!QDBusConnection::sessionBus().isConnected())
return false;

org::kde::KWallet iface(
QLatin1String("org.kde.kwalletd5"),
QLatin1String("/modules/kwalletd5"),
QDBusConnection::sessionBus());

// At this point iface.isValid() can return false even though the
// interface is activatable by making in call. Hence we see whether
// a wallet can be opened.

iface.setTimeout(500);
QDBusMessage reply = iface.call(QStringLiteral("networkWallet"));
return reply.type() == QDBusMessage::ReplyMessage;
}

static KeyringBackend detectKeyringBackend()
{
/* The secret service dbus api, accessible through libsecret, is supposed
Expand All @@ -95,12 +114,12 @@ static KeyringBackend detectKeyringBackend()
switch (detectDesktopEnvironment()) {
case DesktopEnv_Kde4:
return Backend_Kwallet4;
break;
case DesktopEnv_Plasma5:
return Backend_Kwallet5;
break;

// fall through
case DesktopEnv_Plasma5:
if (isKwallet5Available()) {
return Backend_Kwallet5;
}
// fallthrough
case DesktopEnv_Gnome:
case DesktopEnv_Unity:
case DesktopEnv_Xfce:
Expand Down

0 comments on commit 4dfde7a

Please sign in to comment.