From 287355c038426ddc3598a464d79e4ed3058ef31e Mon Sep 17 00:00:00 2001 From: Bernd Wachter Date: Sat, 9 Nov 2013 02:54:38 +0200 Subject: [PATCH] Reverting "[ssu] Expose new dbus API for updating the store credentials." Revert "[ssu] Expose new dbus API for updating the store credentials." This reverts commit 38a305203d7c94cbca8a4f927c83c9e3b6f9d846. --- dbus/org.nemo.ssu.xml | 4 ---- libssu/ssu.cpp | 24 +++++++++++++++++------- libssu/ssu.h | 2 +- ssud/ssud.cpp | 5 ----- ssud/ssud.h | 1 - ssuurlresolver/ssuurlresolver.cpp | 11 +++++------ 6 files changed, 23 insertions(+), 24 deletions(-) diff --git a/dbus/org.nemo.ssu.xml b/dbus/org.nemo.ssu.xml index 9e5a644..291f630 100644 --- a/dbus/org.nemo.ssu.xml +++ b/dbus/org.nemo.ssu.xml @@ -88,10 +88,6 @@ - - - - diff --git a/libssu/ssu.cpp b/libssu/ssu.cpp index 947884d..db5cf8b 100644 --- a/libssu/ssu.cpp +++ b/libssu/ssu.cpp @@ -609,13 +609,23 @@ void Ssu::updateCredentials(bool force){ manager->get(request); } -void Ssu::updateStoreCredentials(const QString &userName, const QString &accessToken){ - SsuCoreConfig *settings = SsuCoreConfig::instance(); - settings->beginGroup("credentials-store"); - settings->setValue("username", userName); - settings->setValue("password", accessToken); - settings->endGroup(); - settings->sync(); +void Ssu::updateStoreCredentials(){ + QDBusMessage message = QDBusMessage::createMethodCall("com.jolla.jollastore", + "/StoreClient", + "com.jolla.jollastore", + "storeCredentials"); + QDBusPendingReply reply = QDBusConnection::sessionBus().asyncCall(message); + reply.waitForFinished(); + if (reply.isError()) { + setError(QString("Store credentials not received. %1").arg(reply.error().message())); + } else { + SsuCoreConfig *settings = SsuCoreConfig::instance(); + settings->beginGroup("credentials-store"); + settings->setValue("username", reply.argumentAt<0>()); + settings->setValue("password", reply.argumentAt<1>()); + settings->endGroup(); + settings->sync(); + } } void Ssu::unregister(){ diff --git a/libssu/ssu.h b/libssu/ssu.h index 8a67740..816d412 100644 --- a/libssu/ssu.h +++ b/libssu/ssu.h @@ -180,7 +180,7 @@ class Ssu: public QObject { /** * Try to update credentials for (Jolla) store */ - void updateStoreCredentials(const QString &userName, const QString &accessToken); + void updateStoreCredentials(); signals: /** diff --git a/ssud/ssud.cpp b/ssud/ssud.cpp index 8678afe..2816db1 100644 --- a/ssud/ssud.cpp +++ b/ssud/ssud.cpp @@ -194,8 +194,3 @@ void Ssud::updateRepos(){ repoManager.update(); autoclose.start(); } - -void Ssud::updateStoreCredentials(const QString &userName, const QString &accessToken){ - ssu.updateStoreCredentials(userName, accessToken); - autoclose.start(); -} diff --git a/ssud/ssud.h b/ssud/ssud.h index 1e209a7..5537835 100644 --- a/ssud/ssud.h +++ b/ssud/ssud.h @@ -42,7 +42,6 @@ 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(); diff --git a/ssuurlresolver/ssuurlresolver.cpp b/ssuurlresolver/ssuurlresolver.cpp index 43c35e1..7699829 100644 --- a/ssuurlresolver/ssuurlresolver.cpp +++ b/ssuurlresolver/ssuurlresolver.cpp @@ -139,12 +139,11 @@ 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 - - // 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? - + if (credentialsScope == "store"){ + ssu.updateStoreCredentials(); + if (ssu.error()) + error (ssu.lastError()); + } headerList.append(QString("credentials=%1").arg(credentialsScope)); writeZyppCredentialsIfNeeded(credentialsScope); } else