Skip to content

Commit

Permalink
Merge branch 'master' into 'master'
Browse files Browse the repository at this point in the history
[ssu] Provide list repos over dbus. Fixes MER#1933

See merge request mer-core/ssu!21
  • Loading branch information
Matti Kosola committed Jul 12, 2018
2 parents 6402886 + f10a500 commit 869e49e
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 19 deletions.
5 changes: 5 additions & 0 deletions dbus/org.nemo.ssu.xml
Expand Up @@ -93,6 +93,11 @@
<arg direction="in" type="s" name="repo" />
<arg direction="in" type="s" name="url" />
</method>
<method name="listRepos">
<arg type="a(ssa{sv})" direction="out"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QList&lt;SsuRepo&gt;"/>
<arg name="rnd" type="b" direction="in"/>
</method>
<method name="updateRepos">
</method>

Expand Down
10 changes: 0 additions & 10 deletions ssu.pro
Expand Up @@ -31,13 +31,3 @@ static_config.files = repos.ini ssu-defaults.ini board-mappings.ini
static_config.path = /usr/share/ssu

INSTALLS += config static_config oneshot macros

system(qdbusxml2cpp \
-c SsuAdaptor \
-a ssud/ssuadaptor.h:ssud/ssuadaptor.cpp \
dbus/org.nemo.ssu.xml)

system(qdbusxml2cpp \
-c SsuProxy \
-p ssucli/ssuproxy.h:ssucli/ssuproxy.cpp \
dbus/org.nemo.ssu.xml)
2 changes: 2 additions & 0 deletions ssucli/ssucli.cpp
Expand Up @@ -22,6 +22,8 @@
SsuCli::SsuCli()
: QObject()
{
qDBusRegisterMetaType<SsuRepo>();

connect(this, SIGNAL(done()),
QCoreApplication::instance(), SLOT(quit()), Qt::DirectConnection);
connect(&ssu, SIGNAL(done()),
Expand Down
2 changes: 1 addition & 1 deletion ssucli/ssucli.h
Expand Up @@ -14,7 +14,7 @@
#include <QDebug>

#include "libssu/ssu.h"
#include "ssuproxy.h"
#include "ssu_interface.h"

class SsuCli: public QObject
{
Expand Down
11 changes: 7 additions & 4 deletions ssucli/ssucli.pro
Expand Up @@ -5,8 +5,11 @@ include(ssucli_dependencies.pri)
QT += network dbus
CONFIG += link_pkgconfig

HEADERS = ssucli.h \
ssuproxy.h
HEADERS = ssucli.h
SOURCES = main.cpp \
ssucli.cpp \
ssuproxy.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
22 changes: 21 additions & 1 deletion ssud/ssud.cpp
Expand Up @@ -6,7 +6,7 @@
*/

#include "ssud.h"
#include "ssuadaptor.h"
#include "ssu_adaptor.h"

#include "libssu/ssudeviceinfo.h"
#include "libssu/ssurepomanager.h"
Expand All @@ -19,6 +19,8 @@ const char *Ssud::OBJECT_PATH = "/org/nemo/ssu";
Ssud::Ssud(QObject *parent)
: QObject(parent)
{
qDBusRegisterMetaType<SsuRepo>();
qDBusRegisterMetaType<QList<SsuRepo>>();
QDBusConnection connection = QDBusConnection::systemBus();
if (!connection.registerObject(OBJECT_PATH, this)) {
qFatal("Cannot register object at %s", OBJECT_PATH);
Expand Down Expand Up @@ -231,3 +233,21 @@ void Ssud::updateRepos()
repoManager.update();
autoclose.start();
}

QList<SsuRepo> Ssud::listRepos(bool rnd)
{
QList<SsuRepo> reposList;
SsuRepoManager repoManager;

for (const QString &repo : repoManager.repos(rnd)) {
const QString repoUrl = ssu.repoUrl(repo, rnd);

SsuRepo ssuRepo;
ssuRepo.name = repo;
ssuRepo.url = repoUrl;

reposList.append(ssuRepo);
}
autoclose.start();
return reposList;
}
2 changes: 2 additions & 0 deletions ssud/ssud.h
Expand Up @@ -13,6 +13,7 @@
#include <QTimer>

#include "libssu/ssu.h"
#include "ssud_dbus.h"

class Ssud: public QObject
{
Expand Down Expand Up @@ -45,6 +46,7 @@ public slots:
void modifyRepo(int action, const QString &repo);
void addRepo(const QString &repo, const QString &url);
void updateRepos();
QList<SsuRepo> listRepos(bool rnd);

bool error();
QString lastError();
Expand Down
12 changes: 9 additions & 3 deletions ssud/ssud.pro
Expand Up @@ -5,9 +5,10 @@ include(ssud_dependencies.pri)
QT += network dbus
CONFIG += link_pkgconfig

HEADERS = ssuadaptor.h \
ssud.h
SOURCES = ssuadaptor.cpp \
HEADERS = \
ssud.h \
ssud_dbus.h
SOURCES = \
ssud.cpp \
main.cpp

Expand All @@ -23,3 +24,8 @@ conf.files = ../dbus/$${DBUS_SERVICE_NAME}.conf
conf.path = /etc/dbus-1/system.d/

INSTALLS += systemd service conf

ssu_dbus_adaptor.files = ../dbus/org.nemo.ssu.xml
ssu_dbus_adaptor.source_flags = -c SsuAdaptor
ssu_dbus_adaptor.header_flags = -c SsuAdaptor -i ssud/ssud_dbus.h
DBUS_ADAPTORS += ssu_dbus_adaptor
32 changes: 32 additions & 0 deletions ssud/ssud_dbus.h
@@ -0,0 +1,32 @@
#ifndef SSUD_INCLUDE_H
#define SSUD_INCLUDE_H

#include <QDBusArgument>
#include <QString>
#include <QVariantMap>

struct SsuRepo {
QString name;
QString url;
QVariantMap parameters;
};

inline QDBusArgument &operator<<(QDBusArgument &argument, const SsuRepo &myRepo)
{
argument.beginStructure();
argument << myRepo.name << myRepo.url << myRepo.parameters;
argument.endStructure();
return argument;
}

inline const QDBusArgument &operator>>(const QDBusArgument &argument, SsuRepo &myRepo)
{
argument.beginStructure();
argument >> myRepo.name >> myRepo.url >> myRepo.parameters;
argument.endStructure();
return argument;
}

Q_DECLARE_METATYPE(SsuRepo)

#endif // SSUD_INCLUDE_H

0 comments on commit 869e49e

Please sign in to comment.