Navigation Menu

Skip to content

Commit

Permalink
Merge branch 'jb47762' into 'master'
Browse files Browse the repository at this point in the history
Domain configuration

See merge request mer-core/ssu!37
  • Loading branch information
Andrew Branson committed Nov 5, 2019
2 parents 5affee8 + babf605 commit e74cb64
Show file tree
Hide file tree
Showing 15 changed files with 361 additions and 55 deletions.
18 changes: 16 additions & 2 deletions dbus/org.nemo.ssu.xml
Expand Up @@ -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
Expand Down Expand Up @@ -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"/>
Expand Down
10 changes: 10 additions & 0 deletions declarative/plugins.qmltypes
Expand Up @@ -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"
Expand Down
11 changes: 9 additions & 2 deletions libssu/libssu.pro
@@ -1,12 +1,18 @@
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} \
Expand All @@ -27,7 +33,8 @@ SOURCES = \
ssufeaturemodel.cpp \
ssuvariables.cpp \
ssurepomanager.cpp \
ssusettings.cpp
ssusettings.cpp \
ssuproxy.cpp

CONFIG += link_pkgconfig
QT += network xml dbus
Expand Down
51 changes: 48 additions & 3 deletions libssu/ssu.cpp
@@ -1,10 +1,26 @@
/**
* @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>
Expand Down Expand Up @@ -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,
Expand Down
26 changes: 23 additions & 3 deletions libssu/ssu.h
@@ -1,8 +1,25 @@
/**
* @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
Expand Down Expand Up @@ -160,6 +177,9 @@ class Ssu: public QObject
/// 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;
Expand Down
9 changes: 9 additions & 0 deletions libssu/ssuproxy.cpp
@@ -0,0 +1,9 @@

#include <QDBusConnection>
#include "ssuproxy.h"

SsuProxy::SsuProxy()
: SsuDBusInterface("org.nemo.ssu", "/org/nemo/ssu", QDBusConnection::systemBus(), 0)
{
}

38 changes: 38 additions & 0 deletions libssu/ssuproxy.h
@@ -0,0 +1,38 @@
/**
* @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
57 changes: 42 additions & 15 deletions libssu/ssurepomanager.cpp
@@ -1,8 +1,25 @@
/**
* @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>
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down
25 changes: 21 additions & 4 deletions libssu/ssusettings_p.h
@@ -1,8 +1,25 @@
/**
* @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
Expand Down Expand Up @@ -32,7 +49,7 @@ class SsuSettings: public QSettings

private:
QString defaultSettingsFile, settingsd;
void merge(bool keepOld = false);
void merge(bool keepOld = true);
static void merge(QSettings *masterSettings, const QStringList &settingsFiles);
void upgrade();

Expand Down
11 changes: 7 additions & 4 deletions rpm/ssu.spec
@@ -1,11 +1,11 @@
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)
Expand All @@ -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,-)
Expand Down Expand Up @@ -204,4 +207,4 @@ fi
%post
/sbin/ldconfig
# make sure an old ssud isn't still running
killall ssud
killall ssud || :

0 comments on commit e74cb64

Please sign in to comment.