Commit 0477be35 authored by Aard's avatar Aard

Move repo filter definition to repo manager

parent b0f9a507
......@@ -316,7 +316,9 @@ QStringList SsuDeviceInfo::repos(bool rnd, int filter){
int adaptationCount = adaptationRepos().size();
QStringList result;
if (filter == NoFilter || filter == BoardFilter || filter == BoardFilterUserBlacklist){
if (filter == SsuRepoManager::NoFilter ||
filter == SsuRepoManager::BoardFilter ||
filter == SsuRepoManager::BoardFilterUserBlacklist){
// for repo names we have adaptation0, adaptation1, ..., adaptationN
for (int i=0; i<adaptationCount; i++)
result.append(QString("adaptation%1").arg(i));
......@@ -343,7 +345,8 @@ QStringList SsuDeviceInfo::repos(bool rnd, int filter){
// TODO: in strict mode, filter the repository list from there
SsuCoreConfig *ssuSettings = SsuCoreConfig::instance();
if (filter == NoFilter || filter == UserFilter){
if (filter == SsuRepoManager::NoFilter ||
filter == SsuRepoManager::UserFilter){
ssuSettings->beginGroup("repository-urls");
result.append(ssuSettings->allKeys());
ssuSettings->endGroup();
......@@ -353,7 +356,9 @@ QStringList SsuDeviceInfo::repos(bool rnd, int filter){
result.append(ssuSettings->value("enabled-repos").toStringList());
}
if (filter == NoFilter || filter == UserFilter || filter == BoardFilterUserBlacklist){
if (filter == SsuRepoManager::NoFilter ||
filter == SsuRepoManager::UserFilter ||
filter == SsuRepoManager::BoardFilterUserBlacklist){
// read the disabled repositories from user configuration
if (ssuSettings->contains("disabled-repos")){
foreach (const QString &key, ssuSettings->value("disabled-repos").toStringList())
......
......@@ -11,18 +11,12 @@
#include <QObject>
#include "ssusettings.h"
#include "ssurepomanager.h"
class SsuDeviceInfo: public QObject {
Q_OBJECT
public:
enum RepoFilter {
NoFilter,
UserFilter,
BoardFilter,
BoardFilterUserBlacklist
};
/**
* Initialize with device to override autodetection
*/
......@@ -74,7 +68,7 @@ class SsuDeviceInfo: public QObject {
* only board-specific, or only user-specific are returned.
* Disabled repositories are excluded depending on filter settings.
*/
QStringList repos(bool rnd=false, int filter=NoFilter);
QStringList repos(bool rnd=false, int filter=SsuRepoManager::NoFilter);
/**
* Override device model autodetection
*/
......
......@@ -238,7 +238,6 @@ QString SsuRepoManager::url(QString repoName, bool rndRepo,
QString r;
QStringList configSections;
SsuVariables var;
SsuLog *ssuLog = SsuLog::instance();
SsuCoreConfig *settings = SsuCoreConfig::instance();
SsuSettings repoSettings(SSU_REPO_CONFIGURATION, QSettings::IniFormat);
SsuDeviceInfo deviceInfo;
......
......@@ -15,6 +15,16 @@ class SsuRepoManager: public QObject {
Q_OBJECT
public:
/**
* Filters to control the output of the repository lookup methods
*/
enum RepoFilter {
NoFilter, ///< All repositories (global + user)
UserFilter, ///< Only user configured repositories
BoardFilter, ///< Only global repositories, with user blacklist ignored
BoardFilterUserBlacklist ///< Only global repositories, with user blacklist applied
};
SsuRepoManager();
/**
* Add a repository. Note: Repositories ending with -debuginfo receive special
......
......@@ -318,7 +318,7 @@ void RndSsuCli::optRepos(QStringList opt){
// micMode? handle it and return, as it's a lot simpler than full mode
if (micMode){
repos = deviceInfo.repos(rndRepo, SsuDeviceInfo::BoardFilter);
repos = deviceInfo.repos(rndRepo, SsuRepoManager::BoardFilter);
foreach (const QString &repo, repos){
QString repoName = repo;
if (repo.endsWith("-debuginfo")){
......@@ -338,10 +338,10 @@ void RndSsuCli::optRepos(QStringList opt){
}
if (device.isEmpty())
repos = deviceInfo.repos(rndRepo, SsuDeviceInfo::BoardFilterUserBlacklist);
repos = deviceInfo.repos(rndRepo, SsuRepoManager::BoardFilterUserBlacklist);
else {
qout << "Printing repository configuration for '" << device << "'" << endl << endl;
repos = deviceInfo.repos(rndRepo, SsuDeviceInfo::BoardFilter);
repos = deviceInfo.repos(rndRepo, SsuRepoManager::BoardFilter);
}
SsuCoreConfig *ssuSettings = SsuCoreConfig::instance();
......@@ -373,7 +373,7 @@ void RndSsuCli::optRepos(QStringList opt){
repos.clear();
continue;
}
repos = deviceInfo.repos(rndRepo, SsuDeviceInfo::UserFilter);
repos = deviceInfo.repos(rndRepo, SsuRepoManager::UserFilter);
qout << endl << "Enabled repositories (user): " << endl;
} else if (i==1){
repos = deviceInfo.disabledRepos();
......
......@@ -100,7 +100,7 @@ QStringList SsuKickstarter::repos(){
QStringList result;
SsuDeviceInfo deviceInfo(deviceModel);
QStringList repos = deviceInfo.repos(rndMode, SsuDeviceInfo::BoardFilter);
QStringList repos = deviceInfo.repos(rndMode, SsuRepoManager::BoardFilter);
foreach (const QString &repo, repos){
QString repoUrl = ssu.repoUrl(repo, rndMode, QHash<QString, QString>(), repoOverride);
......
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