diff --git a/dbus/org.nemo.ssu.xml b/dbus/org.nemo.ssu.xml index e9711ee..d77abd5 100644 --- a/dbus/org.nemo.ssu.xml +++ b/dbus/org.nemo.ssu.xml @@ -44,13 +44,13 @@ - + - + - + @@ -73,6 +73,9 @@ + + + diff --git a/declarative/plugins.qmltypes b/declarative/plugins.qmltypes index ed8087e..d61595d 100644 --- a/declarative/plugins.qmltypes +++ b/declarative/plugins.qmltypes @@ -350,6 +350,7 @@ Module { Method { name: "lastError"; type: "string" } Method { name: "unregister" } Method { name: "flavour"; type: "string" } + Method { name: "brand"; type: "string" } Method { name: "deviceMode"; type: "DeviceModeFlags" } Method { name: "domain"; type: "string" } Method { name: "isRegistered"; type: "bool" } diff --git a/libssu/ssu.cpp b/libssu/ssu.cpp index 80c65a3..e811b0d 100644 --- a/libssu/ssu.cpp +++ b/libssu/ssu.cpp @@ -155,6 +155,11 @@ QString Ssu::domain() return settings->domain(true); } +QString Ssu::brand() { + SsuCoreConfig *settings = SsuCoreConfig::instance(); + return settings->brand(); +} + bool Ssu::isRegistered() { SsuCoreConfig *settings = SsuCoreConfig::instance(); diff --git a/libssu/ssu.h b/libssu/ssu.h index 718b0b5..c7522dd 100644 --- a/libssu/ssu.h +++ b/libssu/ssu.h @@ -141,6 +141,8 @@ class Ssu: public QObject Q_INVOKABLE DeviceModeFlags deviceMode(); /// See SsuCoreConfig::domain; returns printable version Q_INVOKABLE QString domain(); + /// See SsuCoreConfig::brand + Q_INVOKABLE QString brand(); /// See SsuCoreConfig::isRegistered Q_INVOKABLE bool isRegistered(); /// See SsuCoreConfig::lastCredentialsUpdate diff --git a/libssu/ssucoreconfig.cpp b/libssu/ssucoreconfig.cpp index cd1c353..d2b0812 100644 --- a/libssu/ssucoreconfig.cpp +++ b/libssu/ssucoreconfig.cpp @@ -82,6 +82,10 @@ QString SsuCoreConfig::domain(bool pretty) } } +QString SsuCoreConfig::brand() { + return value("brand").toString(); +} + bool SsuCoreConfig::isRegistered() { if (!contains("privateKey")) diff --git a/libssu/ssucoreconfig_p.h b/libssu/ssucoreconfig_p.h index e2f238d..af0b826 100644 --- a/libssu/ssucoreconfig_p.h +++ b/libssu/ssucoreconfig_p.h @@ -65,6 +65,11 @@ class SsuCoreConfig: public SsuSettings * @return domain, or "" if not set */ Q_INVOKABLE QString domain(bool pretty = false); + /** + * Get the current brand stored in the SSU_CONFIGURATION + * @return brand, or "" if not set + */ + Q_INVOKABLE QString brand(); /** * Return devices RND registration status * @retval true device is registered diff --git a/libssu/ssurepomanager.cpp b/libssu/ssurepomanager.cpp index bf3276c..2e50e9b 100644 --- a/libssu/ssurepomanager.cpp +++ b/libssu/ssurepomanager.cpp @@ -421,6 +421,8 @@ QString SsuRepoManager::url(const QString &repoName, bool rndRepo, domain = settings->domain(); } + repoParameters.insert("brand", settings->brand()); + // variableSection does autodetection for the domain default section SsuSettings repoSettings(SSU_REPO_CONFIGURATION, QSettings::IniFormat); SsuVariables var; diff --git a/ssucli/ssucli.cpp b/ssucli/ssucli.cpp index 5cd7578..c41314c 100644 --- a/ssucli/ssucli.cpp +++ b/ssucli/ssucli.cpp @@ -68,6 +68,19 @@ void SsuCli::handleDBusResponse() } } +void SsuCli::optBrand(QStringList opt) +{ + QTextStream qout(stdout); + + if (opt.count() == 3 && opt.at(2) == "-s") { + qout << ssu.brand(); + state = Idle; + } else if (opt.count() == 2) { + qout << "Device brand is: " << ssu.brand() << endl; + state = Idle; + } +} + void SsuCli::optDomain(QStringList opt) { QTextStream qout(stdout); @@ -563,6 +576,7 @@ void SsuCli::optStatus(QStringList opt) else qout << "Release: " << ssu.release() << endl; qout << "Domain: " << ssu.domain() << endl; + qout << "Brand: " << (ssu.brand().isEmpty() ? "N/A" : ssu.brand()) << endl; } void SsuCli::optUpdateCredentials(QStringList opt) @@ -639,6 +653,7 @@ void SsuCli::run() // those need to set state to Idle on success "register", "r", 0, -1, &SsuCli::optRegister, "repos", "lr", 0, -1, &SsuCli::optRepos, + "brand", "b", 0, -1, &SsuCli::optBrand, "flavour", "fl", 0, -1, &SsuCli::optFlavour, "mode", "m", 0, -1, &SsuCli::optMode, "model", "mo", 0, -1, &SsuCli::optModel, @@ -729,6 +744,7 @@ void SsuCli::usage(const QString &message) << "\tupdate, up \tupdate repository credentials" << endl << "\t [-f] \tforce update" << endl << "\tmodel, mo \tprint name of device model (like N9)" << endl + << "\tbrand, b \tprint brand of device model" << endl << endl; if (!message.isEmpty()) qout << message << endl; diff --git a/ssucli/ssucli.h b/ssucli/ssucli.h index 4bf81ed..5e6c80b 100644 --- a/ssucli/ssucli.h +++ b/ssucli/ssucli.h @@ -34,6 +34,7 @@ public slots: int state; void usage(const QString &message = QString()); void uidWarning(); + void optBrand(QStringList opt); void optDomain(QStringList opt); void optFlavour(QStringList opt); void optMode(QStringList opt); diff --git a/ssud/ssud.cpp b/ssud/ssud.cpp index 5e702a0..097afd2 100644 --- a/ssud/ssud.cpp +++ b/ssud/ssud.cpp @@ -56,6 +56,11 @@ Ssud::~Ssud() { } +QString Ssud::brand() { + autoclose.start(); + return ssu.brand(); +} + QString Ssud::deviceModel() { SsuDeviceInfo deviceInfo; diff --git a/ssud/ssud.h b/ssud/ssud.h index 17ddcea..cfb31e8 100644 --- a/ssud/ssud.h +++ b/ssud/ssud.h @@ -36,6 +36,7 @@ public slots: void unregisterDevice(); QString domain(); /* repository management */ + QString brand(); int deviceMode(); void setDeviceMode(int mode); void setDeviceMode(int mode, int editMode); diff --git a/ssuks/ssukickstarter.cpp b/ssuks/ssukickstarter.cpp index 86f81f5..ae464e6 100644 --- a/ssuks/ssukickstarter.cpp +++ b/ssuks/ssukickstarter.cpp @@ -18,7 +18,6 @@ /* TODO: * - commands from the command section should be verified - * - allow overriding brand key */ @@ -276,7 +275,7 @@ bool SsuKickstarter::write(const QString &kickstart) if (!rndMode && repoOverride.contains("flavourName")) repoOverride.remove("flavourName"); - //TODO: check for mandatory keys, brand, .. + //TODO: check for mandatory keys, .. if (!repoOverride.contains("deviceModel")) repoOverride.insert("deviceModel", deviceInfo.deviceModel()); @@ -298,7 +297,7 @@ bool SsuKickstarter::write(const QString &kickstart) } if (!repoOverride.contains("brand")) { - qerr << "No brand set. Check your configuration." << endl; + qerr << "Brand is missing in your configuration." << endl; return false; } @@ -381,6 +380,7 @@ bool SsuKickstarter::write(const QString &kickstart) kout << kickstartType << endl; kout << "# DeviceModel: " << deviceInfo.deviceModel() << endl; kout << "# DeviceVariant: " << deviceInfo.deviceVariant(true) << endl; + kout << "# Brand: " << repoOverride.value("brand") << endl; if (!suggestedFeatures.isEmpty()) kout << suggestedFeatures << endl; kout << "# SuggestedImageType: " << imageType << endl;