Skip to content

Commit

Permalink
[ssu] Prepare support for special store repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernd Wachter committed Nov 1, 2013
1 parent 1960cf5 commit be3f880
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
19 changes: 19 additions & 0 deletions libssu/ssu.cpp
Expand Up @@ -76,6 +76,11 @@ QPair<QString, QString> Ssu::credentials(QString scope){

QString Ssu::credentialsScope(QString repoName, bool rndRepo){
SsuCoreConfig *settings = SsuCoreConfig::instance();

// hardcoded magic for doing special privileges store repositories
if (repoName == "store" || repoName.startsWith("store-c-"))
return "store";

return settings->credentialsScope(repoName, rndRepo);
}

Expand Down Expand Up @@ -580,6 +585,20 @@ void Ssu::updateCredentials(bool force){
manager->get(request);
}

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();
}

void Ssu::unregister(){
SsuCoreConfig *settings = SsuCoreConfig::instance();
Expand Down
4 changes: 4 additions & 0 deletions libssu/ssu.h
Expand Up @@ -177,6 +177,10 @@ class Ssu: public QObject {
* error message.
*/
void updateCredentials(bool force=false);
/**
* Try to update credentials for (Jolla) store
*/
void updateStoreCredentials();

signals:
/**
Expand Down
6 changes: 6 additions & 0 deletions ssuurlresolver/ssuurlresolver.cpp
Expand Up @@ -125,6 +125,12 @@ void SsuUrlResolver::run(){
} else
ssuLog->print(LOG_DEBUG, "Device not registered -- skipping credential update");

if (repo == "store" || repo.startsWith("store-c-")){
ssu.updateStoreCredentials();
if (ssu.error())
error (ssu.lastError());
}

// resolve base url
resolvedUrl = ssu.repoUrl(repo, isRnd, repoParameters);

Expand Down

0 comments on commit be3f880

Please sign in to comment.