Skip to content

Commit

Permalink
Export basic set of repositories for a device
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernd Wachter committed Mar 28, 2013
1 parent 6434ff0 commit b2478d5
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
51 changes: 51 additions & 0 deletions libssu/ssudeviceinfo.cpp
Expand Up @@ -153,6 +153,57 @@ QString SsuDeviceInfo::deviceUid(){
return IMEI;
}

QStringList SsuDeviceInfo::disabledRepos(){
QStringList result;

QString model = deviceVariant();
if (model == "")
model = deviceModel();

if (boardMappings->contains(model + "/disabled-repos"))
result = boardMappings->value(model + "/disabled-repos").toStringList();

return result;
}

QStringList SsuDeviceInfo::repos(bool rnd){
int adaptationCount = adaptationRepos().size();
QStringList result;

// for repo names we have adaptation0, adaptation1, ..., adaptationN
for (int i=0; i<adaptationCount; i++)
result.append(QString("adaptation%1").arg(i));

// now read the release/rnd repos
QSettings repoSettings(SSU_REPO_CONFIGURATION, QSettings::IniFormat);
QString repoKey = (rnd ? "default-repos/rnd" : "default-repos/release");
if (repoSettings.contains(repoKey))
result.append(repoSettings.value(repoKey).toStringList());

// TODO: add specific repos (developer, sdk, ..)

// read user-defined repositories from ssu.ini
// TODO: in strict mode, filter the repository list from there
QSettings ssuSettings(SSU_CONFIGURATION, QSettings::IniFormat);
ssuSettings.beginGroup("repository-urls");
result.append(ssuSettings.allKeys());
ssuSettings.endGroup();

result.removeDuplicates();

// read the disabled repositories for this device
foreach (const QString &key, disabledRepos())
result.removeAll(key);

// read the disabled repositories from user configuration
if (ssuSettings.contains("disabledRepos")){
foreach (const QString &key, ssuSettings.value("disabledRepos").toStringList())
result.removeAll(key);
}

return result;
}

QHash<QString, QString> SsuDeviceInfo::variableSection(QString section){
QHash<QString, QString> result;

Expand Down
8 changes: 8 additions & 0 deletions libssu/ssudeviceinfo.h
Expand Up @@ -39,6 +39,14 @@ class SsuDeviceInfo: public QObject {
* @return QSystemDeviceInfo::imei(), if available, or QSystemDeviceInfo::uniqueDeviceID()
*/
Q_INVOKABLE QString deviceUid();
/**
* Return the list of repositories explicitely disabled for this device
*/
QStringList disabledRepos();
/**
* Return the complete list of repositories configured for a device
*/
QStringList repos(bool rnd=false);
/**
* Override device model autodetection
*/
Expand Down

0 comments on commit b2478d5

Please sign in to comment.