Commit e74cb64c authored by Andrew Branson's avatar Andrew Branson

Merge branch 'jb47762' into 'master'

Domain configuration

See merge request !37
parents 5affee87 babf6054
......@@ -4,8 +4,8 @@
<!--
/**
* DBus service for interfacing with ssu management
* Copyright (C) 2013 Jolla Ltd.
* Contact: Bernd Wachter <bernd.wachter@jollamobile.com>
* Copyright (C) 2013 - 2019 Jolla Ltd.
* Copyright (C) 2019 Open Mobile Platform LLC.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
......@@ -103,6 +103,20 @@
</method>
<method name="updateRepos">
</method>
<method name="listDomains">
<arg direction="out" type="a(s)"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QStringList"/>
</method>
<method name="setDomainConfig">
<arg direction="in" type="s" name="domain"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="QVariantMap"/>
<arg direction="in" type="a{ss}" name="config"/>
</method>
<method name="getDomainConfig">
<arg direction="in" type="s" name="domain"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
<arg direction="out" type="a{ss}"/>
</method>
<method name="error">
<arg direction="out" type="b" name="status"/>
......
......@@ -123,6 +123,16 @@ Module {
Parameter { name: "domain"; type: "string" }
}
Method { name: "useSslVerify"; type: "bool" }
Method { name: "listDomains"; type: "QStringList" }
Method {
name: "getDomainConfig"; type: "QVariantMap"
Parameter { name: "domain"; type: "string" }
}
Method {
name: "setDomainConfig"
Parameter { name: "domain"; type: "string" }
Parameter { name: "config"; type: "QVariantMap" }
}
}
Component {
name: "SsuFeatureModel"
......
TARGET = ssu
include(../ssulibrary.pri)
ssu_dbus_interface.files = ../dbus/org.nemo.ssu.xml
ssu_dbus_interface.source_flags = -c SsuDBusInterface
ssu_dbus_interface.header_flags = -c SsuDBusInterface -i ssud/ssud_dbus.h
DBUS_INTERFACES += ssu_dbus_interface
# TODO: which headers are public? i.e. to be installed
public_headers = \
ssu.h \
ssudeviceinfo.h \
ssurepomanager.h \
ssufeaturemodel.h
ssufeaturemodel.h \
ssuproxy.h
HEADERS = \
$${public_headers} \
......@@ -27,7 +33,8 @@ SOURCES = \
ssufeaturemodel.cpp \
ssuvariables.cpp \
ssurepomanager.cpp \
ssusettings.cpp
ssusettings.cpp \
ssuproxy.cpp
CONFIG += link_pkgconfig
QT += network xml dbus
......
/**
* @file ssu.cpp
* @copyright 2012 Jolla Ltd.
* @author Bernd Wachter <bernd.wachter@jollamobile.com>
* @date 2012
* @copyright 2012 - 2019 Jolla Ltd.
* @copyright 2019 Open Mobile Platform LLC.
* @copyright LGPLv2+
* @date 2012 - 2019
*/
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
*/
#include <QtNetwork>
#include <QtXml/QDomDocument>
#include <QDBusConnection>
......@@ -262,6 +278,35 @@ bool Ssu::registerDevice(QDomDocument *response)
return true;
}
QStringList Ssu::listDomains() {
SsuSettings repoSettings(SSU_REPO_CONFIGURATION, SSU_REPO_CONFIGURATION_DIR);
QRegExp domainFilter("-domain$");
return repoSettings.childGroups().filter(domainFilter).replaceInStrings(domainFilter, "");
}
void Ssu::setDomainConfig(const QString &domain, QVariantMap config) {
SsuSettings repoSettings(SSU_REPO_CONFIGURATION, SSU_REPO_CONFIGURATION_DIR);
repoSettings.beginGroup(domain + "-domain");
repoSettings.remove("");
for (QVariantMap::iterator i = config.begin(); i != config.end(); i++) {
repoSettings.setValue(i.key(), i.value());
}
repoSettings.endGroup();
repoSettings.sync();
}
QVariantMap Ssu::getDomainConfig(const QString &domain) {
SsuSettings repoSettings(SSU_REPO_CONFIGURATION, SSU_REPO_CONFIGURATION_DIR);
QVariantMap config;
repoSettings.beginGroup(domain + "-domain");
foreach(QString key, repoSettings.allKeys()) {
config.insert(key, repoSettings.value(key).toString());
}
repoSettings.endGroup();
return config;
}
// RND repos have flavour (devel, testing, release), and release (latest, next)
// Release repos only have release (latest, next, version number)
QString Ssu::repoUrl(const QString &repoName, bool rndRepo,
......
/**
* @file ssu.h
* @copyright 2012 Jolla Ltd.
* @author Bernd Wachter <bernd.wachter@jollamobile.com>
* @date 2012
* @copyright 2012 - 2019 Jolla Ltd.
* @copyright 2019 Open Mobile Platform LLC.
* @copyright LGPLv2+
* @date 2012 - 2019
*/
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef _Ssu_H
......@@ -160,6 +177,9 @@ public:
/// See SsuCoreConfig::useSslVerify
Q_INVOKABLE bool useSslVerify();
Q_INVOKABLE QStringList listDomains();
Q_INVOKABLE void setDomainConfig(const QString &domain, QVariantMap config);
Q_INVOKABLE QVariantMap getDomainConfig(const QString &domain);
private:
QString errorString;
bool errorFlag;
......
#include <QDBusConnection>
#include "ssuproxy.h"
SsuProxy::SsuProxy()
: SsuDBusInterface("org.nemo.ssu", "/org/nemo/ssu", QDBusConnection::systemBus(), 0)
{
}
/**
* @file ssuproxy.h
* @copyright 2019 Jolla Ltd.
* @copyright 2019 Open Mobile Platform LLC.
* @copyright LGPLv2+
* @date 2019
*/
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef _SSUPROXY_H
#define _SSUPROXY_H
#include "../libssu/ssu_interface.h"
class SsuProxy: public SsuDBusInterface
{
Q_OBJECT
public:
SsuProxy();
};
#endif // _SSUPROXY_H
/**
* @file ssurepomanager.cpp
* @copyright 2013 Jolla Ltd.
* @author Bernd Wachter <bwachter@lart.info>
* @date 2013
* @copyright 2013 - 2019 Jolla Ltd.
* @copyright 2019 Open Mobile Platform Ltd.
* @copyright LGPLv2+
* @date 2013 - 2019
*/
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
*/
#include <QStringList>
......@@ -98,14 +115,20 @@ int SsuRepoManager::enable(const QString &repo)
SsuCoreConfig *ssuSettings = SsuCoreConfig::instance();
QStringList disabledRepos;
if (ssuSettings->contains("disabled-repos"))
if (ssuSettings->contains("disabled-repos")) {
disabledRepos = ssuSettings->value("disabled-repos").toStringList();
disabledRepos.removeAll(repo);
disabledRepos.removeDuplicates();
disabledRepos.removeAll(repo);
disabledRepos.removeDuplicates();
if (disabledRepos.size() > 0)
ssuSettings->setValue("disabled-repos", disabledRepos);
else
ssuSettings->remove("disabled-repos");
ssuSettings->sync();
}
ssuSettings->setValue("disabled-repos", disabledRepos);
ssuSettings->sync();
return 0;
}
......@@ -125,15 +148,19 @@ int SsuRepoManager::remove(const QString &repo)
if (ssuSettings->contains("repository-urls/" + repo))
ssuSettings->remove("repository-urls/" + repo);
if (ssuSettings->contains("enabled-repos")) {
QStringList enabledRepos = ssuSettings->value("enabled-repos").toStringList();
if (enabledRepos.contains(repo)) {
enabledRepos.removeAll(repo);
enabledRepos.removeDuplicates();
ssuSettings->setValue("enabled-repos", enabledRepos);
QStringList sections;
sections << "enabled-repos" << "disabled-repos";
for (const QString &section: sections) {
if (ssuSettings->contains(section)) {
QStringList repos = ssuSettings->value(section).toStringList();
repos.removeAll(repo);
repos.removeDuplicates();
if (repos.size() > 0)
ssuSettings->setValue(section, repos);
else
ssuSettings->remove(section);
}
}
ssuSettings->sync();
return 0;
......
/**
* @file ssusettings_p.h
* @copyright 2013 Jolla Ltd.
* @author Bernd Wachter <bwachter@lart.info>
* @date 2013
* @copyright 2013 - 2019 Jolla Ltd.
* @copyright 2019 Open Mobile Platform LLC.
* @copyright LGPLv2+
* @date 2013 - 2019
*/
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef _SSUSETTINGS_P_H
......@@ -32,7 +49,7 @@ public:
private:
QString defaultSettingsFile, settingsd;
void merge(bool keepOld = false);
void merge(bool keepOld = true);
static void merge(QSettings *masterSettings, const QStringList &settingsFiles);
void upgrade();
......
Name: ssu
Version: 0.44.6
Release: 1
Summary: SSU enabler for RND
Summary: Seamless Software Upgrade
Group: System/Base
License: GPLv2+ and LGPLv2.1+ and BSD-3-clause
Source0: %{name}-%{version}.tar.gz
URL: https://git.merproject.org/mer-core/ssu
URL: https://git.sailfishos.org/mer-core/ssu
BuildRequires: pkgconfig(Qt5Core)
BuildRequires: pkgconfig(Qt5DBus)
BuildRequires: pkgconfig(Qt5Network)
......@@ -25,7 +25,10 @@ Requires: ssu-vendor-data
Requires: ssu-network-proxy
%description
%{summary}.
%{summary} repository management tool. Manages software repositories,
including hardware adaptation and other optional features, and repository
user credentials. Alternative repository configurations may be specified for
RnD mode.
%files
%defattr(-,root,root,-)
......@@ -204,4 +207,4 @@ fi
%post
/sbin/ldconfig
# make sure an old ssud isn't still running
killall ssud
killall ssud || :
/**
* @file ssucli.cpp
* @copyright 2012 Jolla Ltd.
* @author Bernd Wachter <bernd.wachter@jollamobile.com>
* @date 2012
* @copyright 2012 - 2019 Jolla Ltd.
* @copyright 2019 Open Mobile Platform LLC.
* @copyright LGPLv2+
* @date 2012 - 2019
*/
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
*/
#include <QCoreApplication>
#include <termios.h>
......@@ -29,7 +45,7 @@ SsuCli::SsuCli()
connect(&ssu, SIGNAL(done()),
this, SLOT(handleResponse()));
ssuProxy = new SsuProxy("org.nemo.ssu", "/org/nemo/ssu", QDBusConnection::systemBus(), 0);
ssuProxy = new SsuProxy();
connect(ssuProxy, SIGNAL(done()),
this, SLOT(handleDBusResponse()));
......@@ -84,14 +100,42 @@ void SsuCli::optBrand(QStringList opt)
void SsuCli::optDomain(QStringList opt)
{
QTextStream qout(stdout);
QTextStream qerr(stderr);
if (opt.count() == 3 && opt.at(2) == "-s") {
qout << ssu.domain();
state = Idle;
} else if (opt.count() > 2 && opt.at(2) == "-c") {
if (opt.count() == 3) { // dump all domain config
QVariantMap config = ssu.getDomainConfig(ssu.domain());
for (QVariantMap::iterator i = config.begin(); i != config.end(); i++) {
qout << i.key() << ": " << i.value().toString() << endl;
}
state = Idle;
} else if (opt.count() == 4) { // dump one domain config value
QVariantMap config = ssu.getDomainConfig(ssu.domain());
qout << config.value(opt.at(3)).toString() << endl;
state = Idle;
} else if (opt.count() == 5) { // set one domain config value
QVariantMap config = ssu.getDomainConfig(ssu.domain());
config.insert(opt.at(3), opt.at(4));
QDBusPendingReply<> reply = ssuProxy->setDomainConfig(ssu.domain(), config);
reply.waitForFinished();
if (reply.isError()) {
qerr << fallingBackToDirectUse(reply.error()) << endl;
ssu.setDomainConfig(ssu.domain(), config);
}
}
} else if (opt.count() == 3) {
qout << "Changing domain from " << ssu.domain()
<< " to " << opt.at(2) << endl;
ssu.setDomain(opt.at(2));
if (ssu.listDomains().contains(opt.at(2))) {
qout << "Changing domain from " << ssu.domain()
<< " to " << opt.at(2) << endl;
ssu.setDomain(opt.at(2));
}
else {
qout << "Domain " << opt.at(2) << " does not exist" << endl;
state = Idle;
}
state = Idle;
} else if (opt.count() == 2) {
......@@ -736,6 +780,11 @@ void SsuCli::usage(const QString &message)
<< "\t [-r] \toperate on repository only variables" << endl
<< "\t <variable> \tdisplay value of <variable>" << endl
<< "\t <variable> <value> \tset value of <variable> to <value>" << endl
<< "\tdomain do \tdisplay current device domain" << endl
<< "\t [newdomain] \tset new domain" << endl
<< "\t [-c] \tshow domain configuration" << endl
<< "\t -c <variable> \tshow single domain variable" << endl
<< "\t -c <variable> <val>\tset single domain variable" << endl
<< endl
<< "Device management:" << endl
<< "\tstatus, s \tprint registration status and device information" << endl
......
/**
* @file ssucli.h
* @copyright 2012 Jolla Ltd.
* @author Bernd Wachter <bernd.wachter@jollamobile.com>
* @date 2012
* @copyright 2012 - 2019 Jolla Ltd.
* @copyright 2019 Open Mobile Platform LLC.
* @copyright LGPLv2+
* @date 2012 - 2019
*/
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef _SsuCli_H
......@@ -14,7 +31,7 @@
#include <QDebug>
#include "libssu/ssu.h"
#include "ssu_interface.h"
#include "libssu/ssuproxy.h"
class SsuCli: public QObject
{
......
......@@ -8,8 +8,3 @@ CONFIG += link_pkgconfig
HEADERS = ssucli.h
SOURCES = main.cpp \
ssucli.cpp
ssu_dbus_interface.files = ../dbus/org.nemo.ssu.xml
ssu_dbus_interface.source_flags = -c SsuProxy
ssu_dbus_interface.header_flags = -c SsuProxy -i ssud/ssud_dbus.h
DBUS_INTERFACES += ssu_dbus_interface
/**
* @file ssud.cpp
* @copyright 2013 Jolla Ltd.
* @author Bernd Wachter <bwachter@lart.info>
* @date 2013
* @copyright 2013 - 2019 Jolla Ltd.
* @copyright 2019 Open Mobile Platform LLC.
* @copyright LGPLv2+
* @date 2013 - 2019
*/
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
*/
#include "ssud.h"
......@@ -256,3 +273,21 @@ QList<SsuRepo> Ssud::listRepos(bool rnd)
autoclose.start();
return reposList;
}
QStringList Ssud::listDomains()
{
autoclose.start();
return ssu.listDomains();
}
void Ssud::setDomainConfig(const QString &domain, QVariantMap config)
{
ssu.setDomainConfig(domain, config);
autoclose.start();
}
QVariantMap Ssud::getDomainConfig(const QString &domain)
{
autoclose.start();
return ssu.getDomainConfig(domain);
}
/**
* @file ssud.h
* @copyright 2013 Jolla Ltd.
* @author Bernd Wachter <bwachter@lart.info>
* @date 2013
* @copyright 2013-2019 Jolla Ltd.
* @copyright 2019 Open Mobile Platform LLC.
* @copyright LGPLv2+
* @date 2013 - 2019
*/
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef _SSUD_H
......@@ -48,6 +65,9 @@ public slots:
void addRepo(const QString &repo, const QString &url);
void updateRepos();
QList<SsuRepo> listRepos(bool rnd);
QStringList listDomains();
void setDomainConfig(const QString &domain, QVariantMap config);
QVariantMap getDomainConfig(const QString &domain);
bool error();
QString lastError();
......
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