Commit 34f3c3c7 authored by Aard's avatar Aard

[ssu] Make SsuSettings sandbox aware, and move QSettings users to SsuSettings

parent a31af5f8
......@@ -10,7 +10,6 @@
#include <QDateTime>
#include <QObject>
#include <QSettings>
#include <QDebug>
#include <QtXml/QDomDocument>
......
......@@ -9,7 +9,6 @@
#define _SSUCORECONFIG_H
#include <QObject>
#include <QSettings>
#include "ssusettings.h"
#include "ssu.h"
......
......@@ -294,7 +294,7 @@ QStringList SsuDeviceInfo::repos(bool rnd, int filter){
result.append(QString("adaptation%1").arg(i));
// now read the release/rnd repos
QSettings repoSettings(SSU_REPO_CONFIGURATION, QSettings::IniFormat);
SsuSettings 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());
......
......@@ -9,7 +9,6 @@
#define _SSUDEVICEINFO_H
#include <QObject>
#include <QSettings>
#include "ssusettings.h"
......
......@@ -12,6 +12,7 @@
#include "ssudeviceinfo.h"
#include "ssurepomanager.h"
#include "ssucoreconfig.h"
#include "ssusettings.h"
#include "ssulog.h"
#include "ssuvariables.h"
#include "ssu.h"
......@@ -195,8 +196,7 @@ QStringList SsuRepoManager::repoVariables(QHash<QString, QString> *storageHash,
SsuVariables var;
SsuCoreConfig *settings = SsuCoreConfig::instance();
QStringList configSections;
QSettings repoSettings(SSU_REPO_CONFIGURATION, QSettings::IniFormat);
//QSettings *repoSettings = new QSettings(SSU_REPO_CONFIGURATION, QSettings::IniFormat);
SsuSettings repoSettings(SSU_REPO_CONFIGURATION, QSettings::IniFormat);
// fill in all arbitrary variables from ssu.ini
var.resolveSection(settings, "repository-url-variables", storageHash);
......@@ -240,7 +240,7 @@ QString SsuRepoManager::url(QString repoName, bool rndRepo,
SsuVariables var;
SsuLog *ssuLog = SsuLog::instance();
SsuCoreConfig *settings = SsuCoreConfig::instance();
QSettings repoSettings(SSU_REPO_CONFIGURATION, QSettings::IniFormat);
SsuSettings repoSettings(SSU_REPO_CONFIGURATION, QSettings::IniFormat);
SsuDeviceInfo deviceInfo;
// set debugSplit for incorrectly configured debuginfo repositories (debugSplit
......
......@@ -9,7 +9,6 @@
#define _SSUREPOMANAGER_H
#include <QObject>
#include <QSettings>
#include <QHash>
class SsuRepoManager: public QObject {
......
......@@ -18,21 +18,32 @@ SsuSettings::SsuSettings(): QSettings(){
}
SsuSettings::SsuSettings(const QString &fileName, Format format, QObject *parent):
QSettings(fileName, format, parent){
QSettings(SsuSettings::sandboxPrefix() + fileName, format, parent){
}
SsuSettings::SsuSettings(const QString &fileName, Format format, const QString &defaultFileName, QObject *parent):
QSettings(fileName, format, parent){
defaultSettingsFile = defaultFileName;
QSettings(SsuSettings::sandboxPrefix() + fileName, format, parent){
defaultSettingsFile = SsuSettings::sandboxPrefix() + defaultFileName;
upgrade();
}
SsuSettings::SsuSettings(const QString &fileName, const QString &settingsDirectory, QObject *parent):
QSettings(fileName, QSettings::IniFormat, parent){
settingsd = settingsDirectory;
QSettings(SsuSettings::sandboxPrefix() + fileName, QSettings::IniFormat, parent){
settingsd = SsuSettings::sandboxPrefix() + settingsDirectory;
merge();
}
QString SsuSettings::sandboxPrefix(){
/// @TODO: do some verification on the sandbox dir before using it
QString sandboxDir = getenv("SSU_SANDBOX_DIR");
if (!sandboxDir.isEmpty() && !sandboxDir.endsWith("/"))
sandboxDir += "/";
return sandboxDir;
}
void SsuSettings::merge(bool keepOld){
if (settingsd == "")
return;
......
......@@ -28,6 +28,7 @@ class SsuSettings: public QSettings {
* style settings are supported in this mode.
*/
SsuSettings(const QString &fileName, const QString &settingsDirectory, QObject *parent=0);
static QString sandboxPrefix();
private:
QString defaultSettingsFile, settingsd;
......
......@@ -17,7 +17,7 @@ SsuVariables::SsuVariables(): QObject() {
}
void SsuVariables::resolveSection(QSettings *settings, QString section, QHash<QString, QString> *storageHash){
void SsuVariables::resolveSection(SsuSettings *settings, QString section, QHash<QString, QString> *storageHash){
QStringList repoVariables;
settings->beginGroup(section);
......
......@@ -9,9 +9,10 @@
#define _SSUVARIABLES_H
#include <QObject>
#include <QSettings>
#include <QHash>
#include "ssusettings.h"
class SsuVariables: public QObject {
Q_OBJECT
......@@ -22,7 +23,7 @@ class SsuVariables: public QObject {
* run them through the variable expander, and add them to the supplied
* QHash
*/
void resolveSection(QSettings *settings, QString section, QHash<QString, QString> *storageHash);
void resolveSection(SsuSettings *settings, QString section, QHash<QString, QString> *storageHash);
/**
* Resolve a whole string, containing several variables. Variables inside variables are allowed
*/
......
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