Commit eaf76c26 authored by Thomas Perl's avatar Thomas Perl

Merge pull request #26 from kananoja/store_credentials_api

[ssu] Expose new dbus API for updating the store credentials.
parents 4b4afe97 38a30520
......@@ -88,6 +88,10 @@
</method>
<method name="updateRepos">
</method>
<method name="updateStoreCredentials">
<arg direction="in" type="s" name="userName" />
<arg direction="in" type="s" name="accessToken" />
</method>
<method name="error">
<arg direction="out" type="b" name="status"/>
......
......@@ -609,23 +609,13 @@ void Ssu::updateCredentials(bool force){
manager->get(request);
}
void Ssu::updateStoreCredentials(){
QDBusMessage message = QDBusMessage::createMethodCall("com.jolla.jollastore",
"/StoreClient",
"com.jolla.jollastore",
"storeCredentials");
QDBusPendingReply<QString, QString> reply = QDBusConnection::sessionBus().asyncCall(message);
reply.waitForFinished();
if (reply.isError()) {
setError(QString("Store credentials not received. %1").arg(reply.error().message()));
} else {
void Ssu::updateStoreCredentials(const QString &userName, const QString &accessToken){
SsuCoreConfig *settings = SsuCoreConfig::instance();
settings->beginGroup("credentials-store");
settings->setValue("username", reply.argumentAt<0>());
settings->setValue("password", reply.argumentAt<1>());
settings->setValue("username", userName);
settings->setValue("password", accessToken);
settings->endGroup();
settings->sync();
}
}
void Ssu::unregister(){
......
......@@ -180,7 +180,7 @@ class Ssu: public QObject {
/**
* Try to update credentials for (Jolla) store
*/
void updateStoreCredentials();
void updateStoreCredentials(const QString &userName, const QString &accessToken);
signals:
/**
......
......@@ -194,3 +194,8 @@ void Ssud::updateRepos(){
repoManager.update();
autoclose.start();
}
void Ssud::updateStoreCredentials(const QString &userName, const QString &accessToken){
ssu.updateStoreCredentials(userName, accessToken);
autoclose.start();
}
......@@ -42,6 +42,7 @@ class Ssud: public QObject {
void modifyRepo(int action, const QString &repo);
void addRepo(const QString &repo, const QString &url);
void updateRepos();
void updateStoreCredentials(const QString &userName, const QString &accessToken);
bool error();
QString lastError();
......
......@@ -139,11 +139,12 @@ void SsuUrlResolver::run(){
// store-auth-repos domain setting use store credentials. Refresh
// here, as we only know after checking scope if we need to have
// store credentials at all
if (credentialsScope == "store"){
ssu.updateStoreCredentials();
if (ssu.error())
error (ssu.lastError());
}
// store-client updates the store credentials via dbus call on
// every startup (or sign in to be precise).
// TODO: Is there need to check that the credentials were really
// set by store-client?
headerList.append(QString("credentials=%1").arg(credentialsScope));
writeZyppCredentialsIfNeeded(credentialsScope);
} else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment