Commit 309ebecb authored by Pekka Vuorela's avatar Pekka Vuorela

[ssu] Use consistently const QString & on interfaces. Contributes to JB#38781

Plus some similar other interface details.
parent bf5ab44a
......@@ -26,7 +26,7 @@ QString DeclarativeSsuDeviceInfo::deviceModel()
return info.deviceModel();
}
QString DeclarativeSsuDeviceInfo::displayName(const int type)
QString DeclarativeSsuDeviceInfo::displayName(int type)
{
return info.displayName(type);
}
......
......@@ -55,7 +55,7 @@ public:
* If no manufacturer is found UNKNOWN is returned.
* For an invalid type an empty string is returned.
*/
Q_INVOKABLE QString displayName(const int type);
Q_INVOKABLE QString displayName(int type);
private:
SsuDeviceInfo info;
......
......@@ -76,13 +76,13 @@ Ssu::Ssu()
// FIXME, the whole credentials stuff needs reworking
// should probably be part of repo handling instead of core configuration
QPair<QString, QString> Ssu::credentials(QString scope)
QPair<QString, QString> Ssu::credentials(const QString &scope)
{
SsuCoreConfig *settings = SsuCoreConfig::instance();
return settings->credentials(scope);
}
QString Ssu::credentialsScope(QString repoName, bool rndRepo)
QString Ssu::credentialsScope(const QString &repoName, bool rndRepo)
{
SsuCoreConfig *settings = SsuCoreConfig::instance();
SsuSettings repoSettings(SSU_REPO_CONFIGURATION, QSettings::IniFormat);
......@@ -125,7 +125,7 @@ QString Ssu::credentialsScope(QString repoName, bool rndRepo)
return settings->credentialsScope(repoName, rndRepo);
}
QString Ssu::credentialsUrl(QString scope)
QString Ssu::credentialsUrl(const QString &scope)
{
SsuCoreConfig *settings = SsuCoreConfig::instance();
return settings->credentialsUrl(scope);
......@@ -179,19 +179,19 @@ void Ssu::setDeviceMode(Ssu::DeviceModeFlags mode, enum Ssu::EditMode editMode)
settings->setDeviceMode(mode, editMode);
}
void Ssu::setFlavour(QString flavour)
void Ssu::setFlavour(const QString &flavour)
{
SsuCoreConfig *settings = SsuCoreConfig::instance();
settings->setFlavour(flavour);
}
void Ssu::setRelease(QString release, bool rnd)
void Ssu::setRelease(const QString &release, bool rnd)
{
SsuCoreConfig *settings = SsuCoreConfig::instance();
settings->setRelease(release, rnd);
}
void Ssu::setDomain(QString domain)
void Ssu::setDomain(const QString &domain)
{
SsuCoreConfig *settings = SsuCoreConfig::instance();
settings->setDomain(domain);
......@@ -259,7 +259,7 @@ bool Ssu::registerDevice(QDomDocument *response)
// RND repos have flavour (devel, testing, release), and release (latest, next)
// Release repos only have release (latest, next, version number)
QString Ssu::repoUrl(QString repoName, bool rndRepo,
QString Ssu::repoUrl(const QString &repoName, bool rndRepo,
QHash<QString, QString> repoParameters,
QHash<QString, QString> parametersOverride)
{
......@@ -356,7 +356,7 @@ success:
}
}
void Ssu::sendRegistration(QString usernameDomain, QString password)
void Ssu::sendRegistration(const QString &usernameDomain, const QString &password)
{
errorFlag = false;
......@@ -496,7 +496,7 @@ bool Ssu::setCredentials(QDomDocument *response)
return true;
}
void Ssu::setError(QString errorMessage)
void Ssu::setError(const QString &errorMessage)
{
errorFlag = true;
errorString = errorMessage;
......@@ -511,7 +511,7 @@ void Ssu::setError(QString errorMessage)
emit done();
}
void Ssu::storeAuthorizedKeys(QByteArray data)
void Ssu::storeAuthorizedKeys(const QByteArray &data)
{
QDir dir;
SsuLog *ssuLog = SsuLog::instance();
......
......@@ -85,7 +85,7 @@ public:
* Find a username/password pair for the given scope
* @return a QPair with username and password, or an empty QPair if scope is invalid
*/
QPair<QString, QString> credentials(QString scope);
QPair<QString, QString> credentials(const QString &scope);
/**
* Get the scope for a repository, taking into account different scopes for
* release and RnD repositories
......@@ -95,11 +95,11 @@ public:
*
* @return a string containing the scope; it can be used to look up login credentials using credentials()
*/
QString credentialsScope(QString repoName, bool rndRepo = false);
QString credentialsScope(const QString &repoName, bool rndRepo = false);
/**
* Return the URL for which credentials scope is valid
*/
QString credentialsUrl(QString scope);
QString credentialsUrl(const QString &scope);
/**
* Returns if the last operation was successful
* @retval true last operation was successful
......@@ -116,7 +116,7 @@ public:
* Resolve a repository url
* @return the repository URL on success, an empty string on error
*/
QString repoUrl(QString repoName, bool rndRepo = false,
QString repoUrl(const QString &repoName, bool rndRepo = false,
QHash<QString, QString> repoParameters = QHash<QString, QString>(),
QHash<QString, QString> parametersOverride = QHash<QString, QString>());
/**
......@@ -146,11 +146,11 @@ public:
/// See SsuCoreConfig::setDeviceMode
Q_INVOKABLE void setDeviceMode(DeviceModeFlags mode, enum EditMode editMode = Replace);
/// See SsuCoreConfig::setFlavour
Q_INVOKABLE void setFlavour(QString flavour);
Q_INVOKABLE void setFlavour(const QString &flavour);
/// See SsuCoreConfig::setRelease
Q_INVOKABLE void setRelease(QString release, bool rnd = false);
Q_INVOKABLE void setRelease(const QString &release, bool rnd = false);
/// See SsuCoreConfig::setDomain
Q_INVOKABLE void setDomain(QString domain);
Q_INVOKABLE void setDomain(const QString &domain);
/// See SsuCoreConfig::useSslVerify
Q_INVOKABLE bool useSslVerify();
......@@ -162,7 +162,7 @@ private:
bool registerDevice(QDomDocument *response);
bool setCredentials(QDomDocument *response);
bool verifyResponse(QDomDocument *response);
void storeAuthorizedKeys(QByteArray data);
void storeAuthorizedKeys(const QByteArray &data);
private slots:
void requestFinished(QNetworkReply *reply);
......@@ -170,7 +170,7 @@ private slots:
* Set errorString returned by lastError to errorMessage, set
* errorFlag returned by error() to true, and emit done()
*/
void setError(QString errorMessage);
void setError(const QString &errorMessage);
public slots:
/**
......@@ -182,7 +182,7 @@ public slots:
* error() to check if an error occured, and use lastError() to retrieve the last
* error message.
*/
void sendRegistration(QString username, QString password);
void sendRegistration(const QString &username, const QString &password);
/**
* Try to update the RND repository credentials. The device needs to be registered
* for this to work. updateCredentials remembers the time of the last credentials
......
......@@ -25,7 +25,7 @@ SsuCoreConfig *SsuCoreConfig::instance()
return ssuCoreConfig;
}
QPair<QString, QString> SsuCoreConfig::credentials(QString scope)
QPair<QString, QString> SsuCoreConfig::credentials(const QString &scope)
{
QPair<QString, QString> ret;
beginGroup("credentials-" + scope);
......@@ -35,7 +35,7 @@ QPair<QString, QString> SsuCoreConfig::credentials(QString scope)
return ret;
}
QString SsuCoreConfig::credentialsScope(QString repoName, bool rndRepo)
QString SsuCoreConfig::credentialsScope(const QString &repoName, bool rndRepo)
{
Q_UNUSED(repoName)
Q_UNUSED(rndRepo)
......@@ -46,7 +46,7 @@ QString SsuCoreConfig::credentialsScope(QString repoName, bool rndRepo)
return "your-configuration-is-broken-and-does-not-contain-credentials-scope";
}
QString SsuCoreConfig::credentialsUrl(QString scope)
QString SsuCoreConfig::credentialsUrl(const QString &scope)
{
if (contains("credentials-url-" + scope))
return value("credentials-url-" + scope).toString();
......@@ -120,7 +120,7 @@ void SsuCoreConfig::setDeviceMode(Ssu::DeviceModeFlags mode, enum Ssu::EditMode
sync();
}
void SsuCoreConfig::setFlavour(QString flavour)
void SsuCoreConfig::setFlavour(const QString &flavour)
{
setValue("flavour", flavour);
// flavour is RnD only, so enable RnD mode
......@@ -128,7 +128,7 @@ void SsuCoreConfig::setFlavour(QString flavour)
sync();
}
void SsuCoreConfig::setRelease(QString release, bool rnd)
void SsuCoreConfig::setRelease(const QString &release, bool rnd)
{
if (rnd) {
setValue("rndRelease", release);
......@@ -141,11 +141,11 @@ void SsuCoreConfig::setRelease(QString release, bool rnd)
sync();
}
void SsuCoreConfig::setDomain(QString domain)
void SsuCoreConfig::setDomain(const QString &domain)
{
// - in domain messes with default section autodetection,
// so change it to :
setValue("domain", domain.replace("-", ":"));
setValue("domain", QString(domain).replace("-", ":"));
sync();
}
......
......@@ -34,7 +34,7 @@ public:
* Find a username/password pair for the given scope
* @return a QPair with username and password, or an empty QPair if scope is invalid
*/
QPair<QString, QString> credentials(QString scope);
QPair<QString, QString> credentials(const QString &scope);
/**
* Get the scope for a repository, taking into account different scopes for
* release and RnD repositories
......@@ -44,11 +44,11 @@ public:
*
* @return a string containing the scope; it can be used to look up login credentials using credentials()
*/
QString credentialsScope(QString repoName, bool rndRepo = false);
QString credentialsScope(const QString &repoName, bool rndRepo = false);
/**
* Return the URL for which credentials scope is valid
*/
QString credentialsUrl(QString scope);
QString credentialsUrl(const QString &scope);
/**
* Get the current flavour when RnD repositories are used
* @return current flavour (usually something like testing, release, ..)
......@@ -87,15 +87,15 @@ public:
/**
* Set the flavour used when resolving RND repositories
*/
Q_INVOKABLE void setFlavour(QString flavour);
Q_INVOKABLE void setFlavour(const QString &flavour);
/**
* Set the release version string for either a release, or a RnD snapshot
*/
Q_INVOKABLE void setRelease(QString release, bool rnd = false);
Q_INVOKABLE void setRelease(const QString &release, bool rnd = false);
/**
* Set the domain string (usually something like nemo, jolla, ..)
*/
Q_INVOKABLE void setDomain(QString domain);
Q_INVOKABLE void setDomain(const QString &domain);
/**
* Return configuration settings regarding ssl verification
* @retval true SSL verification must be used; that's the default if not configured
......
......@@ -340,7 +340,7 @@ QStringList SsuDeviceInfo::disabledRepos()
return result;
}
QString SsuDeviceInfo::displayName(const int type)
QString SsuDeviceInfo::displayName(int type)
{
QString model = deviceModel();
QString variant = deviceVariant(false);
......@@ -429,25 +429,27 @@ QStringList SsuDeviceInfo::repos(bool rnd, int filter)
return result;
}
QVariant SsuDeviceInfo::variable(QString section, const QString &key)
QVariant SsuDeviceInfo::variable(const QString &section, const QString &key)
{
/// @todo compat-setting as ssudeviceinfo guaranteed to prepend sections with var-;
/// SsuVariables does not have this guarantee. Remove from here as well.
if (!section.startsWith("var-"))
section = "var-" + section;
QString varSection(section);
if (!varSection.startsWith("var-"))
varSection = "var-" + varSection;
return SsuVariables::variable(boardMappings, section, key);
return SsuVariables::variable(boardMappings, varSection, key);
}
void SsuDeviceInfo::variableSection(QString section, QHash<QString, QString> *storageHash)
void SsuDeviceInfo::variableSection(const QString &section, QHash<QString, QString> *storageHash)
{
if (!section.startsWith("var-"))
section = "var-" + section;
QString varSection(section);
if (!varSection.startsWith("var-"))
varSection = "var-" + varSection;
SsuVariables::variableSection(boardMappings, section, storageHash);
SsuVariables::variableSection(boardMappings, varSection, storageHash);
}
void SsuDeviceInfo::setDeviceModel(QString model)
void SsuDeviceInfo::setDeviceModel(const QString &model)
{
if (model.isEmpty())
cachedModel.clear();
......
......@@ -22,7 +22,7 @@ public:
/**
* Initialize with device to override autodetection
*/
SsuDeviceInfo(QString model = "");
SsuDeviceInfo(const QString &model = QString());
virtual ~SsuDeviceInfo();
......@@ -85,7 +85,8 @@ public:
* If no manufacturer is found UNKNOWN is returned.
* For an invalid type an empty string is returned.
*/
Q_INVOKABLE QString displayName(const int type);
Q_INVOKABLE QString displayName(int type);
/**
* Return the complete list of repositories configured for a device.
* Depending on the filter options, all repostories (user and board),
......@@ -97,7 +98,7 @@ public:
/**
* Override device model autodetection
*/
Q_INVOKABLE void setDeviceModel(QString model = "");
Q_INVOKABLE void setDeviceModel(const QString &model = QString());
/**
* Return a variable from the given variable section. 'var'- is automatically
......@@ -105,13 +106,13 @@ public:
* through several variable sections (specified in the section) is supported,
* returned will be the first occurence of the variable.
*/
QVariant variable(QString section, const QString &key);
QVariant variable(const QString &section, const QString &key);
/**
* Return the requested variable section. 'var-' is automatically
* prepended to the section name if not specified already.
*/
void variableSection(QString section, QHash<QString, QString> *storageHash);
void variableSection(const QString &section, QHash<QString, QString> *storageHash);
/**
* Return a value from an adaptation section. Returns an empty string
......
......@@ -58,7 +58,7 @@ QStringList SsuFeatureManager::repos(bool rndRepo, int filter)
return r;
}
QString SsuFeatureManager::url(QString repo, bool rndRepo)
QString SsuFeatureManager::url(const QString &repo, bool rndRepo)
{
QString repoHeader = QString("repositories-%1/")
.arg(rndRepo ? "rnd" : "release");
......
......@@ -22,7 +22,7 @@ class SsuFeatureManager: public QObject
public:
SsuFeatureManager();
QStringList repos(bool rndRepo, int filter = Ssu::NoFilter);
QString url(QString repo, bool rndRepo);
QString url(const QString &repo, bool rndRepo);
private:
SsuSettings *featureSettings;
......
......@@ -24,7 +24,7 @@ SsuLog *SsuLog::instance()
return ssuLog;
}
void SsuLog::print(int priority, QString message)
void SsuLog::print(int priority, const QString &message)
{
// directly go through qsettings here to avoid recursive invocation
// of coreconfig / ssulog
......
......@@ -20,7 +20,7 @@ public:
/**
* Print a message to systemds journal, or to a text log file, if a fallback is defined
*/
void print(int priority, QString message);
void print(int priority, const QString &message);
private:
SsuLog() {}
......
......@@ -26,7 +26,7 @@ SsuRepoManager::SsuRepoManager()
{
}
int SsuRepoManager::add(QString repo, QString repoUrl)
int SsuRepoManager::add(const QString &repo, const QString &repoUrl)
{
SsuCoreConfig *ssuSettings = SsuCoreConfig::instance();
......@@ -55,15 +55,13 @@ int SsuRepoManager::add(QString repo, QString repoUrl)
return 0;
}
QString SsuRepoManager::caCertificatePath(QString domain)
QString SsuRepoManager::caCertificatePath(const QString &domain)
{
SsuCoreConfig *settings = SsuCoreConfig::instance();
SsuSettings repoSettings(SSU_REPO_CONFIGURATION, QSettings::IniFormat);
if (domain.isEmpty())
domain = settings->domain();
QString ca = SsuVariables::variable(&repoSettings, domain + "-domain",
QString ca = SsuVariables::variable(&repoSettings,
(domain.isEmpty() ? settings->domain() : domain) + "-domain",
"_ca-certificate").toString();
if (!ca.isEmpty())
return ca;
......@@ -75,7 +73,7 @@ QString SsuRepoManager::caCertificatePath(QString domain)
return QString();
}
int SsuRepoManager::disable(QString repo)
int SsuRepoManager::disable(const QString &repo)
{
SsuCoreConfig *ssuSettings = SsuCoreConfig::instance();
QStringList disabledRepos;
......@@ -92,7 +90,7 @@ int SsuRepoManager::disable(QString repo)
return 0;
}
int SsuRepoManager::enable(QString repo)
int SsuRepoManager::enable(const QString &repo)
{
SsuCoreConfig *ssuSettings = SsuCoreConfig::instance();
QStringList disabledRepos;
......@@ -109,7 +107,7 @@ int SsuRepoManager::enable(QString repo)
return 0;
}
int SsuRepoManager::remove(QString repo)
int SsuRepoManager::remove(const QString &repo)
{
SsuCoreConfig *ssuSettings = SsuCoreConfig::instance();
......@@ -389,7 +387,7 @@ QStringList SsuRepoManager::repoVariables(QHash<QString, QString> *storageHash,
// RND repos have flavour (devel, testing, release), and release (latest, next)
// Release repos only have release (latest, next, version number)
QString SsuRepoManager::url(QString repoName, bool rndRepo,
QString SsuRepoManager::url(const QString &repoName, bool rndRepo,
QHash<QString, QString> repoParameters,
QHash<QString, QString> parametersOverride)
{
......@@ -410,8 +408,7 @@ QString SsuRepoManager::url(QString repoName, bool rndRepo,
repoParameters.insert("deviceFamily", deviceInfo.deviceFamily());
repoParameters.insert("deviceModel", deviceInfo.deviceModel());
repoName = deviceInfo.adaptationVariables(repoName, &repoParameters);
QString adaptationRepoName = deviceInfo.adaptationVariables(repoName, &repoParameters);
SsuCoreConfig *settings = SsuCoreConfig::instance();
QString domain;
......@@ -443,15 +440,15 @@ QString SsuRepoManager::url(QString repoName, bool rndRepo,
SsuFeatureManager featureManager;
QString r;
if (settings->contains("repository-urls/" + repoName))
r = settings->value("repository-urls/" + repoName).toString();
else if (featureManager.url(repoName, rndRepo) != "")
r = featureManager.url(repoName, rndRepo);
else {
if (settings->contains("repository-urls/" + adaptationRepoName)) {
r = settings->value("repository-urls/" + adaptationRepoName).toString();
} else if (!featureManager.url(adaptationRepoName, rndRepo).isEmpty()) {
r = featureManager.url(adaptationRepoName, rndRepo);
} else {
foreach (const QString &section, configSections) {
repoSettings.beginGroup(section);
if (repoSettings.contains(repoName)) {
r = repoSettings.value(repoName).toString();
if (repoSettings.contains(adaptationRepoName)) {
r = repoSettings.value(adaptationRepoName).toString();
repoSettings.endGroup();
break;
}
......
......@@ -29,7 +29,7 @@ public:
*
* If the device is in UpdateMode this function does nothing.
*/
int add(QString repo, QString repoUrl = "");
int add(const QString &repo, const QString &repoUrl = QString());
/**
* Return the path to the CA certificate to be used for the given domain,
* or default domain, if omitted
......@@ -38,7 +38,7 @@ public:
* @retval -1 Repository not added because device is in update mode
* @retval -2 Repository not added because third party repositories are disabled
*/
static QString caCertificatePath(QString domain = "");
static QString caCertificatePath(const QString &domain = QString());
/**
* Disable a repository
*
......@@ -46,7 +46,7 @@ public:
* @retval -1 Request ignored because device is in update mode
* @retval -2 Request ignored because 3rd party repositories are disabled
*/
int disable(QString repo);
int disable(const QString &repo);
/**
* Enable a repository, given it's not disabled by board configuration
*
......@@ -54,7 +54,7 @@ public:
* @retval -1 Request ignored because device is in update mode
* @retval -2 Request ignored because 3rd party repositories are disabled
*/
int enable(QString repo);
int enable(const QString &repo);
/**
* Remove a repository
*
......@@ -62,7 +62,7 @@ public:
* @retval -1 Request ignored because device is in update mode
* @retval -2 Request ignored because 3rd party repositories are disabled
*/
int remove(QString repo);
int remove(const QString &repo);
/**
* Collect the list of repositories from different submodules
*/
......@@ -94,7 +94,7 @@ public:
* Resolve a repository url
* @return the repository URL on success, an empty string on error
*/
QString url(QString repoName, bool rndRepo = false,
QString url(const QString &repoName, bool rndRepo = false,
QHash<QString, QString> repoParameters = QHash<QString, QString>(),
QHash<QString, QString> parametersOverride = QHash<QString, QString>());
......
......@@ -19,7 +19,7 @@ SsuVariables::SsuVariables()
{
}
QString SsuVariables::defaultSection(SsuSettings *settings, QString section)
QString SsuVariables::defaultSection(SsuSettings *settings, const QString &section)
{
QStringList parts = section.split("-");
......@@ -36,7 +36,7 @@ QString SsuVariables::defaultSection(SsuSettings *settings, QString section)
return QString();
}
QString SsuVariables::resolveString(QString pattern, QHash<QString, QString> *variables, int recursionDepth)
QString SsuVariables::resolveString(const QString &pattern, QHash<QString, QString> *variables, int recursionDepth)
{
if (recursionDepth >= SSU_MAX_RECURSION) {
return "maximum-recursion-level-reached";
......@@ -46,13 +46,15 @@ QString SsuVariables::resolveString(QString pattern, QHash<QString, QString> *va
regex.setMinimal(true);
int pos = 0;
while ((pos = regex.indexIn(pattern, pos)) != -1) {
QString result(pattern);
while ((pos = regex.indexIn(result, pos)) != -1) {
QString match = regex.cap(0);
if (match.contains(":")) {
// variable is special, resolve before replacing
QString variable = resolveVariable(match, variables);
pattern.replace(match, variable);
result.replace(match, variable);
pos += variable.length();
} else {
// look up variable name in hashmap, and replace it with stored value,
......@@ -61,37 +63,39 @@ QString SsuVariables::resolveString(QString pattern, QHash<QString, QString> *va
variableName.remove(0, 2);
variableName.chop(1);
if (variables->contains(variableName)) {
pattern.replace(match, variables->value(variableName));
result.replace(match, variables->value(variableName));
pos += variables->value(variableName).length();
} else
pattern.replace(match, "");
} else {
result.replace(match, "");
}
}
}
// check if string still contains variables, and recurse
if (regex.indexIn(pattern, 0) != -1)
pattern = resolveString(pattern, variables, recursionDepth + 1);
if (regex.indexIn(result, 0) != -1)
result = resolveString(result, variables, recursionDepth + 1);
return pattern;
return result;
}
QString SsuVariables::resolveVariable(QString variable, QHash<QString, QString> *variables)
QString SsuVariables::resolveVariable(const QString &variable, QHash<QString, QString> *variables)
{
QString variableValue;
QString filteredVariable(variable);
if (variable.endsWith(")"))
variable.chop(1);
if (variable.startsWith("%("))
variable.remove(0, 2);
if (filteredVariable.endsWith(")"))
filteredVariable.chop(1);
if (filteredVariable.startsWith("%("))
filteredVariable.remove(0, 2);
// hunt for your colon
int magic = variable.indexOf(":");
int magic = filteredVariable.indexOf(":");
// seems you misplaced your colon
if (magic == -1) return variable;
if (magic == -1) return filteredVariable;
QStringRef variableName(&variable, 0, magic);
QStringRef variableSub(&variable, magic + 2, variable.length() - magic - 2);
QStringRef variableName(&filteredVariable, 0, magic);
QStringRef variableSub(&filteredVariable, magic + 2, filteredVariable.length() - magic - 2);
// Fill in variable value for later tests, if it exists
if (variables->contains(variableName.toString()))
......@@ -99,8 +103,8 @@ QString SsuVariables::resolveVariable(QString variable, QHash<QString, QString>
// find the operator who's after your colon
QChar op;
if (variable.length() > magic + 1)
op = variable.at(magic + 1);
if (filteredVariable.length() > magic + 1)
op = filteredVariable.at(magic + 1);
switch (op.toLatin1()) {
case '-':
......@@ -143,7 +147,7 @@ SsuSettings *SsuVariables::settings()
}
/// @todo add override capability with an override-section in ssu.ini
QVariant SsuVariables::variable(QString section, const QString &key)
QVariant SsuVariables::variable(const QString &section, const QString &key)
{
if (m_settings != NULL)
return variable(m_settings, section, key);
......@@ -151,7 +155,7 @@ QVariant SsuVariables::variable(QString section, const QString &key)
return QVariant();
}
QVariant SsuVariables::variable(SsuSettings *settings, QString section, const QString &key)
QVariant SsuVariables::variable(SsuSettings *settings, const QString &section, const QString &key)
{
QVariant value = readVariable(settings, section, key, 0);
......@@ -166,15 +170,14 @@ QVariant SsuVariables::variable(SsuSettings *settings, QString section, const QS
return value;
}
void SsuVariables::variableSection(QString section, QHash<QString, QString> *storageHash)
void SsuVariables::variableSection(const QString &section, QHash<QString, QString> *storageHash)
{
if (m_settings != NULL)
variableSection(m_settings, section, storageHash);
}
void SsuVariables::variableSection(SsuSettings *settings, QString section, QHash<QString, QString> *storageHash)
void SsuVariables::variableSection(SsuSettings *settings, const QString &section, QHash<QString, QString> *storageHash)
{
QString dSection = defaultSection(settings, section);
if (dSection.isEmpty()) {
readSection(settings, section, storageHash, 0);
......@@ -188,7 +191,7 @@ void SsuVariables::variableSection(SsuSettings *settings, QString section, QHash
// variables which exist in more than one section will get overwritten when discovered
// again
// the section itself gets evaluated at the end, again having a chance to overwrite variables
void SsuVariables::readSection(SsuSettings *settings, QString section,
void SsuVariables::readSection(SsuSettings *settings, const QString &section,
QHash<QString, QString> *storageHash, int recursionDepth,
bool logOverride)
{
......@@ -248,7 +251,7 @@ void SsuVariables::readSection(SsuSettings *settings, QString section,
settings->endGroup();
}
QVariant SsuVariables::readVariable(SsuSettings *settings, QString section, const QString &key,
QVariant SsuVariables::readVariable(SsuSettings *settings, const QString &section, const QString &key,
int recursionDepth, bool logOverride)
{
Q_UNUSED(logOverride)
......
......@@ -26,15 +26,15 @@ public:
* the first token (or second token for "var-" sections) replaced with
* "default". You should therefore avoid "-" in section names.
*/
static QString defaultSection(SsuSettings *settings, QString section);
static QString defaultSection(SsuSettings *settings, const QString &section);
/**
* Resolve a whole string, containing several variables. Variables inside variables are allowed
*/
static QString resolveString(QString pattern, QHash<QString, QString> *variables, int recursionDepth = 0);
static QString resolveString(const QString &pattern, QHash<QString, QString> *variables, int recursionDepth = 0);
/**
* Resolve variables; variable can be passed as %(var) or var
*/
static QString resolveVariable(QString variable, QHash<QString, QString> *variables);
static QString resolveVariable(const QString &variable, QHash<QString, QString> *variables);
/**
* Set the settings object to use
*/
......@@ -49,8 +49,8 @@ public:
* through several variable sections (specified in the section) is supported,
* returned will be the last occurence of the variable.
*/
QVariant variable(QString section, const QString &key);
static QVariant variable(SsuSettings *settings, QString section, const QString &key);
QVariant variable(const QString &section, const QString &key);