Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #24 from kananoja/store_credentials
Browse files Browse the repository at this point in the history
[jolla] Resolve store credentials from store-client via dbus
  • Loading branch information
bwachter committed Nov 6, 2013
2 parents be3f880 + 603c68b commit b48fad8
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions libssu/ssu.cpp
Expand Up @@ -7,6 +7,9 @@

#include <QtNetwork>
#include <QtXml/QDomDocument>
#include <QDBusConnection>
#include <QDBusMessage>
#include <QDBusPendingReply>

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <QUrlQuery>
Expand Down Expand Up @@ -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<QString, QString> 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(){
Expand Down

0 comments on commit b48fad8

Please sign in to comment.