Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'add_brand' into 'master'
[ssu] Add 'brand' interface to ssu

See merge request mer-core/ssu!25
  • Loading branch information
saukko committed Apr 18, 2019
2 parents abb5545 + 8d15662 commit a0975fb
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 6 deletions.
9 changes: 6 additions & 3 deletions dbus/org.nemo.ssu.xml
Expand Up @@ -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 -->
Expand All @@ -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>
Expand Down
1 change: 1 addition & 0 deletions declarative/plugins.qmltypes
Expand Up @@ -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" }
Expand Down
5 changes: 5 additions & 0 deletions libssu/ssu.cpp
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions libssu/ssu.h
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions libssu/ssucoreconfig.cpp
Expand Up @@ -82,6 +82,10 @@ QString SsuCoreConfig::domain(bool pretty)
}
}

QString SsuCoreConfig::brand() {
return value("brand").toString();
}

bool SsuCoreConfig::isRegistered()
{
if (!contains("privateKey"))
Expand Down
5 changes: 5 additions & 0 deletions libssu/ssucoreconfig_p.h
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions libssu/ssurepomanager.cpp
Expand Up @@ -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;
Expand Down
16 changes: 16 additions & 0 deletions ssucli/ssucli.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions ssucli/ssucli.h
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions ssud/ssud.cpp
Expand Up @@ -56,6 +56,11 @@ Ssud::~Ssud()
{
}

QString Ssud::brand() {
autoclose.start();
return ssu.brand();
}

QString Ssud::deviceModel()
{
SsuDeviceInfo deviceInfo;
Expand Down
1 change: 1 addition & 0 deletions ssud/ssud.h
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions ssuks/ssukickstarter.cpp
Expand Up @@ -18,7 +18,6 @@

/* TODO:
* - commands from the command section should be verified
* - allow overriding brand key
*/


Expand Down Expand Up @@ -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());

Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit a0975fb

Please sign in to comment.