diff --git a/3rdparty/keychain/default_keychain.cpp b/3rdparty/keychain/default_keychain.cpp index a50f5aac0..ae6d4708d 100644 --- a/3rdparty/keychain/default_keychain.cpp +++ b/3rdparty/keychain/default_keychain.cpp @@ -3,12 +3,12 @@ const QString DefaultKeychain::kImplementationName = "Default"; const QString DefaultKeychain::getPassword(const QString& account) { - Q_UNUSED(account); - return password_; + Q_UNUSED(account); + return password_; } bool DefaultKeychain::setPassword(const QString& account, const QString& password) { - Q_UNUSED(account); - password_ = password; - return true; + Q_UNUSED(account); + password_ = password; + return true; } diff --git a/3rdparty/keychain/default_keychain.h b/3rdparty/keychain/default_keychain.h index ddfb3ab98..755adb90e 100644 --- a/3rdparty/keychain/default_keychain.h +++ b/3rdparty/keychain/default_keychain.h @@ -5,15 +5,15 @@ class DefaultKeychain : public Keychain { public: - virtual ~DefaultKeychain() {} - virtual bool isAvailable() { return true; } + virtual ~DefaultKeychain() {} + virtual bool isAvailable() { return true; } - virtual const QString getPassword(const QString& account); - virtual bool setPassword(const QString& account, const QString& password); + virtual const QString getPassword(const QString& account); + virtual bool setPassword(const QString& account, const QString& password); - virtual const QString& implementationName() const { return kImplementationName; } + virtual const QString& implementationName() const { return kImplementationName; } - static const QString kImplementationName; + static const QString kImplementationName; private: QString password_; }; diff --git a/3rdparty/keychain/gnome_keychain.cpp b/3rdparty/keychain/gnome_keychain.cpp index a4aeea7f4..687dd2b46 100644 --- a/3rdparty/keychain/gnome_keychain.cpp +++ b/3rdparty/keychain/gnome_keychain.cpp @@ -8,51 +8,51 @@ const QString GnomeKeychain::kImplementationName = "Gnome Keyring"; const GnomeKeyringPasswordSchema GnomeKeychain::kOurSchema = { - GNOME_KEYRING_ITEM_GENERIC_SECRET, - { - { "username", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, - { "service", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, - { NULL }, - }, + GNOME_KEYRING_ITEM_GENERIC_SECRET, + { + { "username", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, + { "service", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, + { NULL }, + }, }; bool GnomeKeychain::isAvailable() { - return gnome_keyring_is_available(); + return gnome_keyring_is_available(); } const QString GnomeKeychain::getPassword(const QString& account) { - Q_ASSERT(isAvailable()); - char* password; - GnomeKeyringResult result = gnome_keyring_find_password_sync( - &kOurSchema, - &password, + Q_ASSERT(isAvailable()); + char* password; + GnomeKeyringResult result = gnome_keyring_find_password_sync( + &kOurSchema, + &password, "username", account.toUtf8().constData(), "service", kServiceName.toUtf8().constData(), - NULL); - - if (result == GNOME_KEYRING_RESULT_OK) { - QString pass(password); - gnome_keyring_free_password(password); - return pass; - } + NULL); + + if (result == GNOME_KEYRING_RESULT_OK) { + QString pass(password); + gnome_keyring_free_password(password); + return pass; + } qWarning() << "Failed to get password from keychain for account" << account; - return QString::null; + return QString::null; } bool GnomeKeychain::setPassword(const QString& account, const QString& password) { - Q_ASSERT(isAvailable()); + Q_ASSERT(isAvailable()); QString displayName = QString("%1 account for %2").arg( QCoreApplication::applicationName(), account); - GnomeKeyringResult result = gnome_keyring_store_password_sync( - &kOurSchema, - NULL, + GnomeKeyringResult result = gnome_keyring_store_password_sync( + &kOurSchema, + NULL, displayName.toUtf8().constData(), password.toUtf8().constData(), "username", account.toUtf8().constData(), "service", kServiceName.toUtf8().constData(), - NULL); - - return result == GNOME_KEYRING_RESULT_OK; + NULL); + + return result == GNOME_KEYRING_RESULT_OK; } diff --git a/3rdparty/keychain/gnome_keychain.h b/3rdparty/keychain/gnome_keychain.h index adfd7e8af..4f74aa2e0 100644 --- a/3rdparty/keychain/gnome_keychain.h +++ b/3rdparty/keychain/gnome_keychain.h @@ -9,16 +9,16 @@ extern "C" { class GnomeKeychain : public Keychain { public: - virtual ~GnomeKeychain() {} - virtual bool isAvailable(); - virtual const QString getPassword(const QString& account); - virtual bool setPassword(const QString& account, const QString& password); + virtual ~GnomeKeychain() {} + virtual bool isAvailable(); + virtual const QString getPassword(const QString& account); + virtual bool setPassword(const QString& account, const QString& password); - virtual const QString& implementationName() const { return kImplementationName; } + virtual const QString& implementationName() const { return kImplementationName; } - static const QString kImplementationName; + static const QString kImplementationName; private: - static const GnomeKeyringPasswordSchema kOurSchema; + static const GnomeKeyringPasswordSchema kOurSchema; }; #endif diff --git a/3rdparty/keychain/kwallet_keychain.cpp b/3rdparty/keychain/kwallet_keychain.cpp index aac3e7db4..615a55cfe 100644 --- a/3rdparty/keychain/kwallet_keychain.cpp +++ b/3rdparty/keychain/kwallet_keychain.cpp @@ -9,51 +9,52 @@ const QString KWalletKeychain::kKWalletPath = "/modules/kwalletd"; const QString KWalletKeychain::kKWalletFolder = "Passwords"; KWalletKeychain::KWalletKeychain() - : kwallet_(kKWalletServiceName, kKWalletPath, QDBusConnection::sessionBus()) { - if (isAvailable()) { - QDBusPendingReply wallet_name = kwallet_.networkWallet(); - wallet_name.waitForFinished(); - if (wallet_name.isValid()) { - wallet_name_ = wallet_name.value(); - QDBusPendingReply open_request = kwallet_.open(wallet_name_, 0, kServiceName); - open_request.waitForFinished(); - if (open_request.isValid()) { - handle_ = open_request.value(); - } - } - } + : kwallet_(kKWalletServiceName, kKWalletPath, QDBusConnection::sessionBus()) +{ + if (isAvailable()) { + QDBusPendingReply wallet_name = kwallet_.networkWallet(); + wallet_name.waitForFinished(); + if (wallet_name.isValid()) { + wallet_name_ = wallet_name.value(); + QDBusPendingReply open_request = kwallet_.open(wallet_name_, 0, kServiceName); + open_request.waitForFinished(); + if (open_request.isValid()) { + handle_ = open_request.value(); + } + } + } } KWalletKeychain::~KWalletKeychain() { } bool KWalletKeychain::isAvailable() { - if(!kwallet_.isValid()) - return false; - - QDBusPendingReply check = kwallet_.isEnabled(); - check.waitForFinished(); - return check.isValid() && check.value(); + if(!kwallet_.isValid()) + return false; + + QDBusPendingReply check = kwallet_.isEnabled(); + check.waitForFinished(); + return check.isValid() && check.value(); } const QString KWalletKeychain::getPassword(const QString& account) { - QDBusPendingReply password = - kwallet_.readPassword(handle_, kKWalletFolder, account, kServiceName); - password.waitForFinished(); - if (password.isValid()) { - return password.value(); - } + QDBusPendingReply password = + kwallet_.readPassword(handle_, kKWalletFolder, account, kServiceName); + password.waitForFinished(); + if (password.isValid()) { + return password.value(); + } - return QString::null; + return QString::null; } bool KWalletKeychain::setPassword(const QString& account, const QString& password) { - QDBusPendingReply ret = - kwallet_.writePassword(handle_, kKWalletFolder, account, password, kServiceName); - ret.waitForFinished(); - if (ret.isValid() && ret.value() == 0) { - return true; - } + QDBusPendingReply ret = + kwallet_.writePassword(handle_, kKWalletFolder, account, password, kServiceName); + ret.waitForFinished(); + if (ret.isValid() && ret.value() == 0) { + return true; + } - return false; + return false; } diff --git a/3rdparty/keychain/kwallet_keychain.h b/3rdparty/keychain/kwallet_keychain.h index 435173ded..04028a19c 100644 --- a/3rdparty/keychain/kwallet_keychain.h +++ b/3rdparty/keychain/kwallet_keychain.h @@ -7,25 +7,25 @@ class KWalletKeychain : public Keychain { public: - KWalletKeychain(); - virtual ~KWalletKeychain(); + KWalletKeychain(); + virtual ~KWalletKeychain(); - virtual const QString getPassword(const QString& account); - virtual bool setPassword(const QString& account, const QString& password); + virtual const QString getPassword(const QString& account); + virtual bool setPassword(const QString& account, const QString& password); - virtual bool isAvailable(); + virtual bool isAvailable(); - virtual const QString& implementationName() const { return kImplementationName; } + virtual const QString& implementationName() const { return kImplementationName; } - static const QString kImplementationName; + static const QString kImplementationName; private: - org::kde::KWallet kwallet_; - QString wallet_name_; - int handle_; + org::kde::KWallet kwallet_; + QString wallet_name_; + int handle_; - static const QString kKWalletServiceName; - static const QString kKWalletPath; - static const QString kKWalletFolder; + static const QString kKWalletServiceName; + static const QString kKWalletPath; + static const QString kKWalletFolder; }; #endif diff --git a/3rdparty/keychain/mac_keychain.h b/3rdparty/keychain/mac_keychain.h index 820889788..6157fd17d 100644 --- a/3rdparty/keychain/mac_keychain.h +++ b/3rdparty/keychain/mac_keychain.h @@ -5,15 +5,15 @@ class MacKeychain : public Keychain { public: - virtual ~MacKeychain() {} - virtual bool isAvailable(); + virtual ~MacKeychain() {} + virtual bool isAvailable(); - virtual const QString getPassword(const QString& account); - virtual bool setPassword(const QString& account, const QString& password); + virtual const QString getPassword(const QString& account); + virtual bool setPassword(const QString& account, const QString& password); - virtual const QString& implementationName() const { return kImplementationName; } + virtual const QString& implementationName() const { return kImplementationName; } - static const QString kImplementationName; + static const QString kImplementationName; }; #endif