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 @@ ...@@ -44,13 +44,13 @@
<arg direction="out" type="s" name="model"/> <arg direction="out" type="s" name="model"/>
</method> </method>
<method name="deviceFamily"> <method name="deviceFamily">
<arg direction="out" type="s" name="model"/> <arg direction="out" type="s" name="family"/>
</method> </method>
<method name="deviceUid"> <method name="deviceUid">
<arg direction="out" type="s" name="model"/> <arg direction="out" type="s" name="uid"/>
</method> </method>
<method name="deviceVariant"> <method name="deviceVariant">
<arg direction="out" type="s" name="model"/> <arg direction="out" type="s" name="variant"/>
</method> </method>
<!-- return a model-specific string suitable for displaying --> <!-- return a model-specific string suitable for displaying -->
<!-- see documentation of Ssu::DisplayType for supported types --> <!-- see documentation of Ssu::DisplayType for supported types -->
...@@ -73,6 +73,9 @@ ...@@ -73,6 +73,9 @@
<method name="flavour"> <method name="flavour">
<arg direction="out" type="s" name="flavour"/> <arg direction="out" type="s" name="flavour"/>
</method> </method>
<method name="brand">
<arg direction="out" type="s" name="brand"/>
</method>
<method name="setFlavour"> <method name="setFlavour">
<arg direction="in" type="s" name="flavour"/> <arg direction="in" type="s" name="flavour"/>
</method> </method>
......
...@@ -350,6 +350,7 @@ Module { ...@@ -350,6 +350,7 @@ Module {
Method { name: "lastError"; type: "string" } Method { name: "lastError"; type: "string" }
Method { name: "unregister" } Method { name: "unregister" }
Method { name: "flavour"; type: "string" } Method { name: "flavour"; type: "string" }
Method { name: "brand"; type: "string" }
Method { name: "deviceMode"; type: "DeviceModeFlags" } Method { name: "deviceMode"; type: "DeviceModeFlags" }
Method { name: "domain"; type: "string" } Method { name: "domain"; type: "string" }
Method { name: "isRegistered"; type: "bool" } Method { name: "isRegistered"; type: "bool" }
......
...@@ -155,6 +155,11 @@ QString Ssu::domain() ...@@ -155,6 +155,11 @@ QString Ssu::domain()
return settings->domain(true); return settings->domain(true);
} }
QString Ssu::brand() {
SsuCoreConfig *settings = SsuCoreConfig::instance();
return settings->brand();
}
bool Ssu::isRegistered() bool Ssu::isRegistered()
{ {
SsuCoreConfig *settings = SsuCoreConfig::instance(); SsuCoreConfig *settings = SsuCoreConfig::instance();
......
...@@ -141,6 +141,8 @@ public: ...@@ -141,6 +141,8 @@ public:
Q_INVOKABLE DeviceModeFlags deviceMode(); Q_INVOKABLE DeviceModeFlags deviceMode();
/// See SsuCoreConfig::domain; returns printable version /// See SsuCoreConfig::domain; returns printable version
Q_INVOKABLE QString domain(); Q_INVOKABLE QString domain();
/// See SsuCoreConfig::brand
Q_INVOKABLE QString brand();
/// See SsuCoreConfig::isRegistered /// See SsuCoreConfig::isRegistered
Q_INVOKABLE bool isRegistered(); Q_INVOKABLE bool isRegistered();
/// See SsuCoreConfig::lastCredentialsUpdate /// See SsuCoreConfig::lastCredentialsUpdate
......
...@@ -82,6 +82,10 @@ QString SsuCoreConfig::domain(bool pretty) ...@@ -82,6 +82,10 @@ QString SsuCoreConfig::domain(bool pretty)
} }
} }
QString SsuCoreConfig::brand() {
return value("brand").toString();
}
bool SsuCoreConfig::isRegistered() bool SsuCoreConfig::isRegistered()
{ {
if (!contains("privateKey")) if (!contains("privateKey"))
......
...@@ -65,6 +65,11 @@ public: ...@@ -65,6 +65,11 @@ public:
* @return domain, or "" if not set * @return domain, or "" if not set
*/ */
Q_INVOKABLE QString domain(bool pretty = false); 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 * Return devices RND registration status
* @retval true device is registered * @retval true device is registered
......
...@@ -421,6 +421,8 @@ QString SsuRepoManager::url(const QString &repoName, bool rndRepo, ...@@ -421,6 +421,8 @@ QString SsuRepoManager::url(const QString &repoName, bool rndRepo,
domain = settings->domain(); domain = settings->domain();
} }
repoParameters.insert("brand", settings->brand());
// variableSection does autodetection for the domain default section // variableSection does autodetection for the domain default section
SsuSettings repoSettings(SSU_REPO_CONFIGURATION, QSettings::IniFormat); SsuSettings repoSettings(SSU_REPO_CONFIGURATION, QSettings::IniFormat);
SsuVariables var; SsuVariables var;
......
...@@ -68,6 +68,19 @@ void SsuCli::handleDBusResponse() ...@@ -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) void SsuCli::optDomain(QStringList opt)
{ {
QTextStream qout(stdout); QTextStream qout(stdout);
...@@ -563,6 +576,7 @@ void SsuCli::optStatus(QStringList opt) ...@@ -563,6 +576,7 @@ void SsuCli::optStatus(QStringList opt)
else else
qout << "Release: " << ssu.release() << endl; qout << "Release: " << ssu.release() << endl;
qout << "Domain: " << ssu.domain() << endl; qout << "Domain: " << ssu.domain() << endl;
qout << "Brand: " << (ssu.brand().isEmpty() ? "N/A" : ssu.brand()) << endl;
} }
void SsuCli::optUpdateCredentials(QStringList opt) void SsuCli::optUpdateCredentials(QStringList opt)
...@@ -639,6 +653,7 @@ void SsuCli::run() ...@@ -639,6 +653,7 @@ void SsuCli::run()
// those need to set state to Idle on success // those need to set state to Idle on success
"register", "r", 0, -1, &SsuCli::optRegister, "register", "r", 0, -1, &SsuCli::optRegister,
"repos", "lr", 0, -1, &SsuCli::optRepos, "repos", "lr", 0, -1, &SsuCli::optRepos,
"brand", "b", 0, -1, &SsuCli::optBrand,
"flavour", "fl", 0, -1, &SsuCli::optFlavour, "flavour", "fl", 0, -1, &SsuCli::optFlavour,
"mode", "m", 0, -1, &SsuCli::optMode, "mode", "m", 0, -1, &SsuCli::optMode,
"model", "mo", 0, -1, &SsuCli::optModel, "model", "mo", 0, -1, &SsuCli::optModel,
...@@ -729,6 +744,7 @@ void SsuCli::usage(const QString &message) ...@@ -729,6 +744,7 @@ void SsuCli::usage(const QString &message)
<< "\tupdate, up \tupdate repository credentials" << endl << "\tupdate, up \tupdate repository credentials" << endl
<< "\t [-f] \tforce update" << endl << "\t [-f] \tforce update" << endl
<< "\tmodel, mo \tprint name of device model (like N9)" << endl << "\tmodel, mo \tprint name of device model (like N9)" << endl
<< "\tbrand, b \tprint brand of device model" << endl
<< endl; << endl;
if (!message.isEmpty()) if (!message.isEmpty())
qout << message << endl; qout << message << endl;
......
...@@ -34,6 +34,7 @@ private: ...@@ -34,6 +34,7 @@ private:
int state; int state;
void usage(const QString &message = QString()); void usage(const QString &message = QString());
void uidWarning(); void uidWarning();
void optBrand(QStringList opt);
void optDomain(QStringList opt); void optDomain(QStringList opt);
void optFlavour(QStringList opt); void optFlavour(QStringList opt);
void optMode(QStringList opt); void optMode(QStringList opt);
......
...@@ -56,6 +56,11 @@ Ssud::~Ssud() ...@@ -56,6 +56,11 @@ Ssud::~Ssud()
{ {
} }
QString Ssud::brand() {
autoclose.start();
return ssu.brand();
}
QString Ssud::deviceModel() QString Ssud::deviceModel()
{ {
SsuDeviceInfo deviceInfo; SsuDeviceInfo deviceInfo;
......
...@@ -36,6 +36,7 @@ public slots: ...@@ -36,6 +36,7 @@ public slots:
void unregisterDevice(); void unregisterDevice();
QString domain(); QString domain();
/* repository management */ /* repository management */
QString brand();
int deviceMode(); int deviceMode();
void setDeviceMode(int mode); void setDeviceMode(int mode);
void setDeviceMode(int mode, int editMode); void setDeviceMode(int mode, int editMode);
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
/* TODO: /* TODO:
* - commands from the command section should be verified * - commands from the command section should be verified
* - allow overriding brand key
*/ */
...@@ -276,7 +275,7 @@ bool SsuKickstarter::write(const QString &kickstart) ...@@ -276,7 +275,7 @@ bool SsuKickstarter::write(const QString &kickstart)
if (!rndMode && repoOverride.contains("flavourName")) if (!rndMode && repoOverride.contains("flavourName"))
repoOverride.remove("flavourName"); repoOverride.remove("flavourName");
//TODO: check for mandatory keys, brand, .. //TODO: check for mandatory keys, ..
if (!repoOverride.contains("deviceModel")) if (!repoOverride.contains("deviceModel"))
repoOverride.insert("deviceModel", deviceInfo.deviceModel()); repoOverride.insert("deviceModel", deviceInfo.deviceModel());
...@@ -298,7 +297,7 @@ bool SsuKickstarter::write(const QString &kickstart) ...@@ -298,7 +297,7 @@ bool SsuKickstarter::write(const QString &kickstart)
} }
if (!repoOverride.contains("brand")) { if (!repoOverride.contains("brand")) {
qerr << "No brand set. Check your configuration." << endl; qerr << "Brand is missing in your configuration." << endl;
return false; return false;
} }
...@@ -381,6 +380,7 @@ bool SsuKickstarter::write(const QString &kickstart) ...@@ -381,6 +380,7 @@ bool SsuKickstarter::write(const QString &kickstart)
kout << kickstartType << endl; kout << kickstartType << endl;
kout << "# DeviceModel: " << deviceInfo.deviceModel() << endl; kout << "# DeviceModel: " << deviceInfo.deviceModel() << endl;
kout << "# DeviceVariant: " << deviceInfo.deviceVariant(true) << endl; kout << "# DeviceVariant: " << deviceInfo.deviceVariant(true) << endl;
kout << "# Brand: " << repoOverride.value("brand") << endl;
if (!suggestedFeatures.isEmpty()) if (!suggestedFeatures.isEmpty())
kout << suggestedFeatures << endl; kout << suggestedFeatures << endl;
kout << "# SuggestedImageType: " << imageType << 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