mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-18 04:19:55 +01:00
Tabs to spaces in the keychain source
This commit is contained in:
parent
43f55a7bcd
commit
6b9f41d6ae
10
3rdparty/keychain/default_keychain.cpp
vendored
10
3rdparty/keychain/default_keychain.cpp
vendored
@ -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;
|
||||
}
|
||||
|
12
3rdparty/keychain/default_keychain.h
vendored
12
3rdparty/keychain/default_keychain.h
vendored
@ -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_;
|
||||
};
|
||||
|
54
3rdparty/keychain/gnome_keychain.cpp
vendored
54
3rdparty/keychain/gnome_keychain.cpp
vendored
@ -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;
|
||||
}
|
||||
|
14
3rdparty/keychain/gnome_keychain.h
vendored
14
3rdparty/keychain/gnome_keychain.h
vendored
@ -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
|
||||
|
67
3rdparty/keychain/kwallet_keychain.cpp
vendored
67
3rdparty/keychain/kwallet_keychain.cpp
vendored
@ -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<QString> wallet_name = kwallet_.networkWallet();
|
||||
wallet_name.waitForFinished();
|
||||
if (wallet_name.isValid()) {
|
||||
wallet_name_ = wallet_name.value();
|
||||
QDBusPendingReply<int> 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<QString> wallet_name = kwallet_.networkWallet();
|
||||
wallet_name.waitForFinished();
|
||||
if (wallet_name.isValid()) {
|
||||
wallet_name_ = wallet_name.value();
|
||||
QDBusPendingReply<int> 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<bool> check = kwallet_.isEnabled();
|
||||
check.waitForFinished();
|
||||
return check.isValid() && check.value();
|
||||
if(!kwallet_.isValid())
|
||||
return false;
|
||||
|
||||
QDBusPendingReply<bool> check = kwallet_.isEnabled();
|
||||
check.waitForFinished();
|
||||
return check.isValid() && check.value();
|
||||
}
|
||||
|
||||
const QString KWalletKeychain::getPassword(const QString& account) {
|
||||
QDBusPendingReply<QString> password =
|
||||
kwallet_.readPassword(handle_, kKWalletFolder, account, kServiceName);
|
||||
password.waitForFinished();
|
||||
if (password.isValid()) {
|
||||
return password.value();
|
||||
}
|
||||
QDBusPendingReply<QString> 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<int> ret =
|
||||
kwallet_.writePassword(handle_, kKWalletFolder, account, password, kServiceName);
|
||||
ret.waitForFinished();
|
||||
if (ret.isValid() && ret.value() == 0) {
|
||||
return true;
|
||||
}
|
||||
QDBusPendingReply<int> ret =
|
||||
kwallet_.writePassword(handle_, kKWalletFolder, account, password, kServiceName);
|
||||
ret.waitForFinished();
|
||||
if (ret.isValid() && ret.value() == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
26
3rdparty/keychain/kwallet_keychain.h
vendored
26
3rdparty/keychain/kwallet_keychain.h
vendored
@ -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
|
||||
|
12
3rdparty/keychain/mac_keychain.h
vendored
12
3rdparty/keychain/mac_keychain.h
vendored
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user