Commit be3f8805 authored by Aard's avatar Aard

[ssu] Prepare support for special store repositories

parent 1960cf53
......@@ -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);
}
......@@ -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();
......
......@@ -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:
/**
......
......@@ -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);
......@@ -155,7 +161,7 @@ void SsuUrlResolver::run(){
if (resolvedUrl.isEmpty()){
error("URL for repository is not set.");
} else if (resolvedUrl.indexOf(QRegExp("[a-z]*://", Qt::CaseInsensitive)) != 0) {
error ("URL for repository is invalid.");
error("URL for repository is invalid.");
} else {
PluginFrame out("RESOLVEDURL");
out.setBody(resolvedUrl.toStdString());
......
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