Commit c2a459be authored by pvuorela's avatar pvuorela

Merge branch 'master' into 'master'

Cleanups

See merge request !9
parents 35dba2bc aec48298
...@@ -26,7 +26,7 @@ QString DeclarativeSsuDeviceInfo::deviceModel() ...@@ -26,7 +26,7 @@ QString DeclarativeSsuDeviceInfo::deviceModel()
return info.deviceModel(); return info.deviceModel();
} }
QString DeclarativeSsuDeviceInfo::displayName(const int type) QString DeclarativeSsuDeviceInfo::displayName(int type)
{ {
return info.displayName(type); return info.displayName(type);
} }
......
...@@ -32,16 +32,19 @@ public: ...@@ -32,16 +32,19 @@ public:
* multithreaded environment, unless you like funny results. * multithreaded environment, unless you like funny results.
*/ */
Q_INVOKABLE QString deviceFamily(); Q_INVOKABLE QString deviceFamily();
/** /**
* Try to find the device variant for the system this is running on. * Try to find the device variant for the system this is running on.
* If the device is not a variant it will return an empty string. If * If the device is not a variant it will return an empty string. If
* fallback is set to true it return the device model in this case. * fallback is set to true it return the device model in this case.
*/ */
Q_INVOKABLE QString deviceVariant(bool fallback = false); Q_INVOKABLE QString deviceVariant(bool fallback = false);
/** /**
* Try to find out ond what kind of system this is running * Try to find out ond what kind of system this is running
*/ */
Q_INVOKABLE QString deviceModel(); Q_INVOKABLE QString deviceModel();
/** /**
* Return a string suitable for display in dialogs, ... * Return a string suitable for display in dialogs, ...
* *
...@@ -52,7 +55,7 @@ public: ...@@ -52,7 +55,7 @@ public:
* If no manufacturer is found UNKNOWN is returned. * If no manufacturer is found UNKNOWN is returned.
* For an invalid type an empty string 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: private:
SsuDeviceInfo info; SsuDeviceInfo info;
......
...@@ -79,7 +79,7 @@ Sandbox::~Sandbox() ...@@ -79,7 +79,7 @@ Sandbox::~Sandbox()
} }
if (!m_tempDir.isEmpty() && QFileInfo(m_tempDir).exists()) { if (!m_tempDir.isEmpty() && QFileInfo(m_tempDir).exists()) {
if (QProcess::execute("rm", QStringList() << "-rf" << m_tempDir) != 0) { if (!QDir(m_tempDir).removeRecursively()) {
qWarning("%s: Failed to remove temporary directory", Q_FUNC_INFO); qWarning("%s: Failed to remove temporary directory", Q_FUNC_INFO);
} }
} }
...@@ -276,7 +276,7 @@ bool Sandbox::prepare() ...@@ -276,7 +276,7 @@ bool Sandbox::prepare()
QString Sandbox::createTmpDir(const QString &nameTemplate) QString Sandbox::createTmpDir(const QString &nameTemplate)
{ {
static const int REASONABLE_REPEAT_COUNT = 10; const int REASONABLE_REPEAT_COUNT = 10;
for (int i = 0; i < REASONABLE_REPEAT_COUNT; ++i) { for (int i = 0; i < REASONABLE_REPEAT_COUNT; ++i) {
QString path; QString path;
......
...@@ -37,7 +37,8 @@ static void restoreUid() ...@@ -37,7 +37,8 @@ static void restoreUid()
} }
} }
Ssu::Ssu(): QObject() Ssu::Ssu()
: QObject()
{ {
errorFlag = false; errorFlag = false;
pendingRequests = 0; pendingRequests = 0;
...@@ -75,13 +76,13 @@ Ssu::Ssu(): QObject() ...@@ -75,13 +76,13 @@ Ssu::Ssu(): QObject()
// FIXME, the whole credentials stuff needs reworking // FIXME, the whole credentials stuff needs reworking
// should probably be part of repo handling instead of core configuration // 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(); SsuCoreConfig *settings = SsuCoreConfig::instance();
return settings->credentials(scope); return settings->credentials(scope);
} }
QString Ssu::credentialsScope(QString repoName, bool rndRepo) QString Ssu::credentialsScope(const QString &repoName, bool rndRepo)
{ {
SsuCoreConfig *settings = SsuCoreConfig::instance(); SsuCoreConfig *settings = SsuCoreConfig::instance();
SsuSettings repoSettings(SSU_REPO_CONFIGURATION, QSettings::IniFormat); SsuSettings repoSettings(SSU_REPO_CONFIGURATION, QSettings::IniFormat);
...@@ -124,7 +125,7 @@ QString Ssu::credentialsScope(QString repoName, bool rndRepo) ...@@ -124,7 +125,7 @@ QString Ssu::credentialsScope(QString repoName, bool rndRepo)
return settings->credentialsScope(repoName, rndRepo); return settings->credentialsScope(repoName, rndRepo);
} }
QString Ssu::credentialsUrl(QString scope) QString Ssu::credentialsUrl(const QString &scope)
{ {
SsuCoreConfig *settings = SsuCoreConfig::instance(); SsuCoreConfig *settings = SsuCoreConfig::instance();
return settings->credentialsUrl(scope); return settings->credentialsUrl(scope);
...@@ -178,19 +179,19 @@ void Ssu::setDeviceMode(Ssu::DeviceModeFlags mode, enum Ssu::EditMode editMode) ...@@ -178,19 +179,19 @@ void Ssu::setDeviceMode(Ssu::DeviceModeFlags mode, enum Ssu::EditMode editMode)
settings->setDeviceMode(mode, editMode); settings->setDeviceMode(mode, editMode);
} }
void Ssu::setFlavour(QString flavour) void Ssu::setFlavour(const QString &flavour)
{ {
SsuCoreConfig *settings = SsuCoreConfig::instance(); SsuCoreConfig *settings = SsuCoreConfig::instance();
settings->setFlavour(flavour); settings->setFlavour(flavour);
} }
void Ssu::setRelease(QString release, bool rnd) void Ssu::setRelease(const QString &release, bool rnd)
{ {
SsuCoreConfig *settings = SsuCoreConfig::instance(); SsuCoreConfig *settings = SsuCoreConfig::instance();
settings->setRelease(release, rnd); settings->setRelease(release, rnd);
} }
void Ssu::setDomain(QString domain) void Ssu::setDomain(const QString &domain)
{ {
SsuCoreConfig *settings = SsuCoreConfig::instance(); SsuCoreConfig *settings = SsuCoreConfig::instance();
settings->setDomain(domain); settings->setDomain(domain);
...@@ -223,8 +224,9 @@ bool Ssu::registerDevice(QDomDocument *response) ...@@ -223,8 +224,9 @@ bool Ssu::registerDevice(QDomDocument *response)
settings->setValue("registered", false); settings->setValue("registered", false);
setError("Certificate is invalid"); setError("Certificate is invalid");
return false; return false;
} else } else {
settings->setValue("certificate", certificate.toPem()); settings->setValue("certificate", certificate.toPem());
}
QString privateKeyString = response->elementsByTagName("privateKey").at(0).toElement().text(); QString privateKeyString = response->elementsByTagName("privateKey").at(0).toElement().text();
QSslKey privateKey(privateKeyString.toLatin1(), QSsl::Rsa); QSslKey privateKey(privateKeyString.toLatin1(), QSsl::Rsa);
...@@ -233,8 +235,9 @@ bool Ssu::registerDevice(QDomDocument *response) ...@@ -233,8 +235,9 @@ bool Ssu::registerDevice(QDomDocument *response)
settings->setValue("registered", false); settings->setValue("registered", false);
setError("Private key is invalid"); setError("Private key is invalid");
return false; return false;
} else } else {
settings->setValue("privateKey", privateKey.toPem()); settings->setValue("privateKey", privateKey.toPem());
}
// oldUser is just for reference purposes, in case we want to notify // oldUser is just for reference purposes, in case we want to notify
// about owner changes for the device // about owner changes for the device
...@@ -256,7 +259,7 @@ bool Ssu::registerDevice(QDomDocument *response) ...@@ -256,7 +259,7 @@ bool Ssu::registerDevice(QDomDocument *response)
// RND repos have flavour (devel, testing, release), and release (latest, next) // RND repos have flavour (devel, testing, release), and release (latest, next)
// Release repos only have release (latest, next, version number) // 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> repoParameters,
QHash<QString, QString> parametersOverride) QHash<QString, QString> parametersOverride)
{ {
...@@ -289,7 +292,7 @@ void Ssu::requestFinished(QNetworkReply *reply) ...@@ -289,7 +292,7 @@ void Ssu::requestFinished(QNetworkReply *reply)
/// @TODO: indicate that the device is not registered if there's a 404 on credentials update url /// @TODO: indicate that the device is not registered if there's a 404 on credentials update url
if (settings->contains("home-url")) { if (settings->contains("home-url")) {
QString homeUrl = settings->value("home-url").toString().arg(""); QString homeUrl = settings->value("home-url").toString().arg(QString());
homeUrl.remove(QRegExp("//+$")); homeUrl.remove(QRegExp("//+$"));
if (request.url().toString().startsWith(homeUrl, Qt::CaseInsensitive)) { if (request.url().toString().startsWith(homeUrl, Qt::CaseInsensitive)) {
...@@ -353,11 +356,11 @@ success: ...@@ -353,11 +356,11 @@ success:
} }
} }
void Ssu::sendRegistration(QString usernameDomain, QString password) void Ssu::sendRegistration(const QString &usernameDomain, const QString &password)
{ {
errorFlag = false; errorFlag = false;
QString ssuCaCertificate, ssuRegisterUrl; QString ssuRegisterUrl;
QString username, domainName; QString username, domainName;
SsuLog *ssuLog = SsuLog::instance(); SsuLog *ssuLog = SsuLog::instance();
...@@ -381,7 +384,7 @@ void Ssu::sendRegistration(QString usernameDomain, QString password) ...@@ -381,7 +384,7 @@ void Ssu::sendRegistration(QString usernameDomain, QString password)
setDomain(settings->value("default-rnd-domain").toString()); setDomain(settings->value("default-rnd-domain").toString());
} }
ssuCaCertificate = SsuRepoManager::caCertificatePath(); QString ssuCaCertificate = SsuRepoManager::caCertificatePath();
if (ssuCaCertificate.isEmpty()) { if (ssuCaCertificate.isEmpty()) {
setError("CA certificate for ssu not set ('_ca-certificate in domain')"); setError("CA certificate for ssu not set ('_ca-certificate in domain')");
return; return;
...@@ -393,11 +396,12 @@ void Ssu::sendRegistration(QString usernameDomain, QString password) ...@@ -393,11 +396,12 @@ void Ssu::sendRegistration(QString usernameDomain, QString password)
setError("URL for ssu registration not set (config key 'register-url')"); setError("URL for ssu registration not set (config key 'register-url')");
return; return;
} }
} else } else {
ssuRegisterUrl = settings->value("register-url").toString(); ssuRegisterUrl = settings->value("register-url").toString();
}
QString IMEI = deviceInfo.deviceUid(); QString IMEI = deviceInfo.deviceUid();
if (IMEI == "") { if (IMEI.isEmpty()) {
setError("No valid UID available for your device. For phones: is your modem online?"); setError("No valid UID available for your device. For phones: is your modem online?");
return; return;
} }
...@@ -432,10 +436,8 @@ void Ssu::sendRegistration(QString usernameDomain, QString password) ...@@ -432,10 +436,8 @@ void Ssu::sendRegistration(QString usernameDomain, QString password)
ssuLog->print(LOG_DEBUG, QString("Sending request to %1") ssuLog->print(LOG_DEBUG, QString("Sending request to %1")
.arg(request.url().url())); .arg(request.url().url()));
QNetworkReply *reply;
pendingRequests++; pendingRequests++;
reply = manager->post(request, form.query(QUrl::FullyEncoded).toStdString().c_str()); manager->post(request, form.query(QUrl::FullyEncoded).toStdString().c_str());
// we could expose downloadProgress() from reply in case we want progress info // we could expose downloadProgress() from reply in case we want progress info
QString homeUrl = settings->value("home-url").toString().arg(username); QString homeUrl = settings->value("home-url").toString().arg(username);
...@@ -482,7 +484,7 @@ bool Ssu::setCredentials(QDomDocument *response) ...@@ -482,7 +484,7 @@ bool Ssu::setCredentials(QDomDocument *response)
credentialScopes.append(scope); credentialScopes.append(scope);
} }
} else { } else {
setError(""); setError(QString());
return false; return false;
} }
} }
...@@ -494,7 +496,7 @@ bool Ssu::setCredentials(QDomDocument *response) ...@@ -494,7 +496,7 @@ bool Ssu::setCredentials(QDomDocument *response)
return true; return true;
} }
void Ssu::setError(QString errorMessage) void Ssu::setError(const QString &errorMessage)
{ {
errorFlag = true; errorFlag = true;
errorString = errorMessage; errorString = errorMessage;
...@@ -509,7 +511,7 @@ void Ssu::setError(QString errorMessage) ...@@ -509,7 +511,7 @@ void Ssu::setError(QString errorMessage)
emit done(); emit done();
} }
void Ssu::storeAuthorizedKeys(QByteArray data) void Ssu::storeAuthorizedKeys(const QByteArray &data)
{ {
QDir dir; QDir dir;
SsuLog *ssuLog = SsuLog::instance(); SsuLog *ssuLog = SsuLog::instance();
...@@ -537,8 +539,9 @@ void Ssu::storeAuthorizedKeys(QByteArray data) ...@@ -537,8 +539,9 @@ void Ssu::storeAuthorizedKeys(QByteArray data)
ssuLog->print(LOG_DEBUG, QString("Dropping to %1/%2 for writing authorized keys") ssuLog->print(LOG_DEBUG, QString("Dropping to %1/%2 for writing authorized keys")
.arg(uid_min) .arg(uid_min)
.arg(pw->pw_gid)); .arg(pw->pw_gid));
} else } else {
return; return;
}
homePath = Sandbox::map(homePath); homePath = Sandbox::map(homePath);
...@@ -549,13 +552,14 @@ void Ssu::storeAuthorizedKeys(QByteArray data) ...@@ -549,13 +552,14 @@ void Ssu::storeAuthorizedKeys(QByteArray data)
return; return;
} }
if (!dir.exists(homePath + "/.ssh")) if (!dir.exists(homePath + "/.ssh")) {
if (!dir.mkdir(homePath + "/.ssh")) { if (!dir.mkdir(homePath + "/.ssh")) {
ssuLog->print(LOG_DEBUG, QString("Unable to create .ssh in %1") ssuLog->print(LOG_DEBUG, QString("Unable to create .ssh in %1")
.arg(homePath)); .arg(homePath));
restoreUid(); restoreUid();
return; return;
} }
}
QFile::setPermissions(homePath + "/.ssh", QFile::setPermissions(homePath + "/.ssh",
QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner); QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner);
...@@ -579,7 +583,7 @@ void Ssu::updateCredentials(bool force) ...@@ -579,7 +583,7 @@ void Ssu::updateCredentials(bool force)
SsuLog *ssuLog = SsuLog::instance(); SsuLog *ssuLog = SsuLog::instance();
if (deviceInfo.deviceUid() == "") { if (deviceInfo.deviceUid().isEmpty()) {
setError("No valid UID available for your device. For phones: is your modem online?"); setError("No valid UID available for your device. For phones: is your modem online?");
return; return;
} }
...@@ -597,8 +601,9 @@ void Ssu::updateCredentials(bool force) ...@@ -597,8 +601,9 @@ void Ssu::updateCredentials(bool force)
setError("URL for credentials update not set (config key 'credentials-url')"); setError("URL for credentials update not set (config key 'credentials-url')");
return; return;
} }
} else } else {
ssuCredentialsUrl = settings->value("credentials-url").toString(); ssuCredentialsUrl = settings->value("credentials-url").toString();
}
if (!isRegistered()) { if (!isRegistered()) {
setError("Device is not registered."); setError("Device is not registered.");
...@@ -661,8 +666,9 @@ void Ssu::updateStoreCredentials() ...@@ -661,8 +666,9 @@ void Ssu::updateStoreCredentials()
if (settings->value("ignore-credential-errors").toBool() == true) { if (settings->value("ignore-credential-errors").toBool() == true) {
ssuLog->print(LOG_WARNING, QString("Warning: ignore-credential-errors is set, passing auth errors down to libzypp")); ssuLog->print(LOG_WARNING, QString("Warning: ignore-credential-errors is set, passing auth errors down to libzypp"));
ssuLog->print(LOG_WARNING, QString("Store credentials not received. %1").arg(reply.error().message())); ssuLog->print(LOG_WARNING, QString("Store credentials not received. %1").arg(reply.error().message()));
} else } else {
setError(QString("Store credentials not received. %1").arg(reply.error().message())); setError(QString("Store credentials not received. %1").arg(reply.error().message()));
}
} else { } else {
SsuCoreConfig *settings = SsuCoreConfig::instance(); SsuCoreConfig *settings = SsuCoreConfig::instance();
settings->beginGroup("credentials-store"); settings->beginGroup("credentials-store");
......
...@@ -85,7 +85,7 @@ public: ...@@ -85,7 +85,7 @@ public:
* Find a username/password pair for the given scope * Find a username/password pair for the given scope
* @return a QPair with username and password, or an empty QPair if scope is invalid * @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 * Get the scope for a repository, taking into account different scopes for
* release and RnD repositories * release and RnD repositories
...@@ -95,11 +95,11 @@ public: ...@@ -95,11 +95,11 @@ public:
* *
* @return a string containing the scope; it can be used to look up login credentials using credentials() * @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 * 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 * Returns if the last operation was successful
* @retval true last operation was successful * @retval true last operation was successful
...@@ -116,7 +116,7 @@ public: ...@@ -116,7 +116,7 @@ public:
* Resolve a repository url * Resolve a repository url
* @return the repository URL on success, an empty string on error * @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> repoParameters = QHash<QString, QString>(),
QHash<QString, QString> parametersOverride = QHash<QString, QString>()); QHash<QString, QString> parametersOverride = QHash<QString, QString>());
/** /**
...@@ -146,11 +146,11 @@ public: ...@@ -146,11 +146,11 @@ public:
/// See SsuCoreConfig::setDeviceMode /// See SsuCoreConfig::setDeviceMode
Q_INVOKABLE void setDeviceMode(DeviceModeFlags mode, enum EditMode editMode = Replace); Q_INVOKABLE void setDeviceMode(DeviceModeFlags mode, enum EditMode editMode = Replace);
/// See SsuCoreConfig::setFlavour /// See SsuCoreConfig::setFlavour
Q_INVOKABLE void setFlavour(QString flavour); Q_INVOKABLE void setFlavour(const QString &flavour);
/// See SsuCoreConfig::setRelease /// 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 /// See SsuCoreConfig::setDomain
Q_INVOKABLE void setDomain(QString domain); Q_INVOKABLE void setDomain(const QString &domain);
/// See SsuCoreConfig::useSslVerify /// See SsuCoreConfig::useSslVerify
Q_INVOKABLE bool useSslVerify(); Q_INVOKABLE bool useSslVerify();
...@@ -162,7 +162,7 @@ private: ...@@ -162,7 +162,7 @@ private:
bool registerDevice(QDomDocument *response); bool registerDevice(QDomDocument *response);
bool setCredentials(QDomDocument *response); bool setCredentials(QDomDocument *response);
bool verifyResponse(QDomDocument *response); bool verifyResponse(QDomDocument *response);
void storeAuthorizedKeys(QByteArray data); void storeAuthorizedKeys(const QByteArray &data);
private slots: private slots:
void requestFinished(QNetworkReply *reply); void requestFinished(QNetworkReply *reply);
...@@ -170,7 +170,7 @@ private slots: ...@@ -170,7 +170,7 @@ private slots:
* Set errorString returned by lastError to errorMessage, set * Set errorString returned by lastError to errorMessage, set
* errorFlag returned by error() to true, and emit done() * errorFlag returned by error() to true, and emit done()
*/ */
void setError(QString errorMessage); void setError(const QString &errorMessage);
public slots: public slots:
/** /**
...@@ -182,7 +182,7 @@ public slots: ...@@ -182,7 +182,7 @@ public slots:
* error() to check if an error occured, and use lastError() to retrieve the last * error() to check if an error occured, and use lastError() to retrieve the last
* error message. * 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 * 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 * for this to work. updateCredentials remembers the time of the last credentials
......
...@@ -25,7 +25,7 @@ SsuCoreConfig *SsuCoreConfig::instance() ...@@ -25,7 +25,7 @@ SsuCoreConfig *SsuCoreConfig::instance()
return ssuCoreConfig; return ssuCoreConfig;
} }
QPair<QString, QString> SsuCoreConfig::credentials(QString scope) QPair<QString, QString> SsuCoreConfig::credentials(const QString &scope)
{ {
QPair<QString, QString> ret; QPair<QString, QString> ret;
beginGroup("credentials-" + scope); beginGroup("credentials-" + scope);
...@@ -35,7 +35,7 @@ QPair<QString, QString> SsuCoreConfig::credentials(QString scope) ...@@ -35,7 +35,7 @@ QPair<QString, QString> SsuCoreConfig::credentials(QString scope)
return ret; return ret;
} }
QString SsuCoreConfig::credentialsScope(QString repoName, bool rndRepo) QString SsuCoreConfig::credentialsScope(const QString &repoName, bool rndRepo)
{ {
Q_UNUSED(repoName) Q_UNUSED(repoName)
Q_UNUSED(rndRepo) Q_UNUSED(rndRepo)
...@@ -46,7 +46,7 @@ QString SsuCoreConfig::credentialsScope(QString repoName, bool rndRepo) ...@@ -46,7 +46,7 @@ QString SsuCoreConfig::credentialsScope(QString repoName, bool rndRepo)
return "your-configuration-is-broken-and-does-not-contain-credentials-scope"; 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)) if (contains("credentials-url-" + scope))
return value("credentials-url-" + scope).toString(); return value("credentials-url-" + scope).toString();
...@@ -77,8 +77,9 @@ QString SsuCoreConfig::domain(bool pretty) ...@@ -77,8 +77,9 @@ QString SsuCoreConfig::domain(bool pretty)
return value("domain").toString().replace(":", "-"); return value("domain").toString().replace(":", "-");
else else
return value("domain").toString(); return value("domain").toString();
} else } else {
return ""; return QString();
}
} }
bool SsuCoreConfig::isRegistered() bool SsuCoreConfig::isRegistered()
...@@ -111,14 +112,15 @@ void SsuCoreConfig::setDeviceMode(Ssu::DeviceModeFlags mode, enum Ssu::EditMode ...@@ -111,14 +112,15 @@ void SsuCoreConfig::setDeviceMode(Ssu::DeviceModeFlags mode, enum Ssu::EditMode
oldMode |= mode; oldMode |= mode;
} else if ((editMode & Ssu::Remove) == Ssu::Remove) { } else if ((editMode & Ssu::Remove) == Ssu::Remove) {
oldMode &= ~mode; oldMode &= ~mode;
} else } else {
oldMode = mode; oldMode = mode;
}
setValue("deviceMode", oldMode); setValue("deviceMode", oldMode);
sync(); sync();
} }
void SsuCoreConfig::setFlavour(QString flavour) void SsuCoreConfig::setFlavour(const QString &flavour)
{ {
setValue("flavour", flavour); setValue("flavour", flavour);
// flavour is RnD only, so enable RnD mode // flavour is RnD only, so enable RnD mode
...@@ -126,7 +128,7 @@ void SsuCoreConfig::setFlavour(QString flavour) ...@@ -126,7 +128,7 @@ void SsuCoreConfig::setFlavour(QString flavour)
sync(); sync();
} }
void SsuCoreConfig::setRelease(QString release, bool rnd) void SsuCoreConfig::setRelease(const QString &release, bool rnd)
{ {
if (rnd) { if (rnd) {
setValue("rndRelease", release); setValue("rndRelease", release);
...@@ -139,11 +141,11 @@ void SsuCoreConfig::setRelease(QString release, bool rnd) ...@@ -139,11 +141,11 @@ void SsuCoreConfig::setRelease(QString release, bool rnd)
sync(); sync();
} }
void SsuCoreConfig::setDomain(QString domain) void SsuCoreConfig::setDomain(const QString &domain)
{ {
// - in domain messes with default section autodetection, // - in domain messes with default section autodetection,
// so change it to : // so change it to :
setValue("domain", domain.replace("-", ":")); setValue("domain", QString(domain).replace("-", ":"));
sync(); sync();
} }
......
...@@ -34,7 +34,7 @@ public: ...@@ -34,7 +34,7 @@ public:
* Find a username/password pair for the given scope * Find a username/password pair for the given scope
* @return a QPair with username and password, or an empty QPair if scope is invalid * @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 * Get the scope for a repository, taking into account different scopes for
* release and RnD repositories * release and RnD repositories
...@@ -44,11 +44,11 @@ public: ...@@ -44,11 +44,11 @@ public:
* *
* @return a string containing the scope; it can be used to look up login credentials using credentials() * @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 * 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 * Get the current flavour when RnD repositories are used
* @return current flavour (usually something like testing, release, ..) * @return current flavour (usually something like testing, release, ..)
...@@ -87,15 +87,15 @@ public: ...@@ -87,15 +87,15 @@ public:
/** /**
* Set the flavour used when resolving RND repositories * 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 * 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, ..) * 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 * Return configuration settings regarding ssl verification
* @retval true SSL verification must be used; that's the default if not configured * @retval true SSL verification must be used; that's the default if not configured
......
...@@ -23,7 +23,8 @@ ...@@ -23,7 +23,8 @@
#include "../constants.h" #include "../constants.h"
SsuDeviceInfo::SsuDeviceInfo(QString model): QObject() SsuDeviceInfo::SsuDeviceInfo(const QString &model)
: QObject()
{ {
boardMappings = new SsuSettings(SSU_BOARD_MAPPING_CONFIGURATION, SSU_BOARD_MAPPING_CONFIGURATION_DIR); boardMappings = new SsuSettings(SSU_BOARD_MAPPING_CONFIGURATION, SSU_BOARD_MAPPING_CONFIGURATION_DIR);
if (!model.isEmpty()) if (!model.isEmpty())
...@@ -101,9 +102,9 @@ QString SsuDeviceInfo::adaptationVariables(const QString &adaptationName, QHash< ...@@ -101,9 +102,9 @@ QString SsuDeviceInfo::adaptationVariables(const QString &adaptationName, QHash<
void SsuDeviceInfo::clearCache() void SsuDeviceInfo::clearCache()
{ {
cachedFamily = ""; cachedFamily.clear();