Commit a0975fb9 authored by sage's avatar sage

Merge branch 'add_brand' into 'master'

[ssu] Add 'brand' interface to ssu

See merge request !25
parents abb5545c 8d156628
......@@ -44,13 +44,13 @@
<arg direction="out" type="s" name="model"/>
</method>
<method name="deviceFamily">
<arg direction="out" type="s" name="model"/>
<arg direction="out" type="s" name="family"/>
</method>
<method name="deviceUid">
<arg direction="out" type="s" name="model"/>
<arg direction="out" type="s" name="uid"/>
</method>
<method name="deviceVariant">
<arg direction="out" type="s" name="model"/>
<arg direction="out" type="s" name="variant"/>
</method>
<!-- return a model-specific string suitable for displaying -->
<!-- see documentation of Ssu::DisplayType for supported types -->
......@@ -73,6 +73,9 @@
<method name="flavour">
<arg direction="out" type="s" name="flavour"/>
</method>
<method name="brand">
<arg direction="out" type="s" name="brand"/>
</method>
<method name="setFlavour">
<arg direction="in" type="s" name="flavour"/>
</method>
......
......@@ -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" }
......
......@@ -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();
......
......@@ -141,6 +141,8 @@ public:
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
......
......@@ -82,6 +82,10 @@ QString SsuCoreConfig::domain(bool pretty)
}
}
QString SsuCoreConfig::brand() {
return value("brand").toString();
}
bool SsuCoreConfig::isRegistered()
{
if (!contains("privateKey"))
......
......@@ -65,6 +65,11 @@ public:
* @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
......
......@@ -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;
......
......@@ -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;
......
......@@ -34,6 +34,7 @@ private:
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);
......
......@@ -56,6 +56,11 @@ Ssud::~Ssud()
{
}
QString Ssud::brand() {
autoclose.start();
return ssu.brand();
}
QString Ssud::deviceModel()
{
SsuDeviceInfo deviceInfo;
......
......@@ -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);
......
......@@ -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;
......
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