diff --git a/libssu/ssu.cpp b/libssu/ssu.cpp index 4dd1fb8..cd41b07 100644 --- a/libssu/ssu.cpp +++ b/libssu/ssu.cpp @@ -7,6 +7,9 @@ #include #include +#include +#include +#include #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include @@ -586,18 +589,22 @@ void Ssu::updateCredentials(bool force){ } void Ssu::updateStoreCredentials(){ - SsuCoreConfig *settings = SsuCoreConfig::instance(); - QString username, password; - - // TODO: - // - get values for username/password from store - // - use setError() to set error state if credentials can't be received - - settings->beginGroup("credentials-store"); - settings->setValue("username", username); - settings->setValue("password", password); - settings->endGroup(); - settings->sync(); + 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(){