1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-18 12:28:31 +01:00

Fix compilation of the gnome keychain

This commit is contained in:
David Sansome 2011-02-18 20:13:52 +00:00
parent ff66bc0ade
commit 43f55a7bcd
6 changed files with 13 additions and 24 deletions

View File

@ -13,8 +13,6 @@ public:
virtual const QString& implementationName() const { return kImplementationName; }
static void init() {}
static const QString kImplementationName;
private:
QString password_;

View File

@ -1,8 +1,10 @@
#include "config.h"
#include "gnome_keychain.h"
#include <glib.h>
#include <QCoreApplication>
#include <QtDebug>
const QString GnomeKeychain::kImplementationName = "Gnome Keyring";
const GnomeKeyringPasswordSchema GnomeKeychain::kOurSchema = {
@ -24,8 +26,8 @@ const QString GnomeKeychain::getPassword(const QString& account) {
GnomeKeyringResult result = gnome_keyring_find_password_sync(
&kOurSchema,
&password,
"username", account.toStdString().c_str(),
"service", kServiceName.toStdString().c_str(),
"username", account.toUtf8().constData(),
"service", kServiceName.toUtf8().constData(),
NULL);
if (result == GNOME_KEYRING_RESULT_OK) {
@ -34,27 +36,23 @@ const QString GnomeKeychain::getPassword(const QString& account) {
return pass;
}
qWarning() << "Failed to get password from keychain for account" << account;
return QString::null;
}
bool GnomeKeychain::setPassword(const QString& account, const QString& password) {
Q_ASSERT(isAvailable());
QString displayName = "%1 Google Reader account for %2";
displayName.arg(TITLE);
displayName.arg(account);
QString displayName = QString("%1 account for %2").arg(
QCoreApplication::applicationName(), account);
GnomeKeyringResult result = gnome_keyring_store_password_sync(
&kOurSchema,
NULL,
displayName.toStdString().c_str(),
password.toStdString().c_str(),
"username", account.toStdString().c_str(),
"service", kServiceName.toStdString().c_str(),
displayName.toUtf8().constData(),
password.toUtf8().constData(),
"username", account.toUtf8().constData(),
"service", kServiceName.toUtf8().constData(),
NULL);
return result == GNOME_KEYRING_RESULT_OK;
}
void GnomeKeychain::init() {
g_set_application_name("PurpleHatstands");
}

View File

@ -16,8 +16,6 @@ public:
virtual const QString& implementationName() const { return kImplementationName; }
static void init();
static const QString kImplementationName;
private:
static const GnomeKeyringPasswordSchema kOurSchema;

View File

@ -17,7 +17,6 @@ public:
static Keychain* getDefault();
static void init();
protected:
static const QString kServiceName;
@ -33,7 +32,7 @@ private:
};
template<typename T>
struct KeychainImpl : public KeychainDefinition {
KeychainImpl() : KeychainDefinition(T::kImplementationName) { T::init(); }
KeychainImpl() : KeychainDefinition(T::kImplementationName) { }
virtual Keychain* getInstance() const {
return new T();
}

View File

@ -17,8 +17,6 @@ public:
virtual const QString& implementationName() const { return kImplementationName; }
static void init() {}
static const QString kImplementationName;
private:
org::kde::KWallet kwallet_;

View File

@ -14,8 +14,6 @@ public:
virtual const QString& implementationName() const { return kImplementationName; }
static const QString kImplementationName;
static void init() {}
};
#endif