/
ssufeaturemanager.cpp
80 lines (64 loc) · 2.3 KB
/
ssufeaturemanager.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/**
* @file ssufeaturemanager.cpp
* @copyright 2013 Jolla Ltd.
* @author Bernd Wachter <bwachter@lart.info>
* @date 2013
*/
#include <QStringList>
#include <QRegExp>
#include <QDirIterator>
#include "ssudeviceinfo.h"
#include "ssufeaturemanager.h"
#include "ssucoreconfig.h"
#include "ssulog.h"
#include "ssuvariables.h"
#include "ssu.h"
#include "../constants.h"
#ifndef SSU_FEATURE_CONFIGURATION
/// Path to the main ssu configuration file
#define SSU_FEATURE_CONFIGURATION "/var/cache/ssu/features.ini"
#endif
#ifndef SSU_FEATURE_CONFIGURATION_DIR
/// Path to the main ssu configuration file
#define SSU_FEATURE_CONFIGURATION_DIR "/usr/share/ssu/features.d"
#endif
SsuFeatureManager::SsuFeatureManager(): QObject() {
featureSettings = new SsuSettings(SSU_FEATURE_CONFIGURATION, SSU_FEATURE_CONFIGURATION_DIR);
}
// @TODO - allow enabling/disabling features
// - export feature file for mic through ssu-ks
// - add feature header in ssu-ks
//
// all features have a list of repositories in the repos key
// if there are enabled/disabled features, check the repos keys from all enabled features
// and only enable the repositories from those
QStringList SsuFeatureManager::repos(bool rndRepo, int filter){
QStringList r;
QStringList keys;
SsuCoreConfig *settings = SsuCoreConfig::instance();
// @TODO features currently can't be blacklisted, but just ignoring user filter
// is still the best way atm
if (filter == Ssu::UserFilter)
return r;
QString repoHeader = QString("repositories-%1/")
.arg(rndRepo ? "rnd" : "release");
// take the global groups
featureSettings->beginGroup("repositories");
r.append(featureSettings->allKeys());
featureSettings->endGroup();
// and override with rnd/release specific groups
featureSettings->beginGroup(repoHeader);
r.append(featureSettings->allKeys());
featureSettings->endGroup();
r.removeDuplicates();
return r;
}
QString SsuFeatureManager::url(QString repo, bool rndRepo){
QString repoHeader = QString("repositories-%1/")
.arg(rndRepo ? "rnd" : "release");
if (featureSettings->contains(repoHeader + repo))
return featureSettings->value(repoHeader + repo).toString();
else if (featureSettings->contains("repositorios/" + repo))
return featureSettings->value("repositories/" + repo).toString();
return "";
}