Commit f10a5008 authored by akozhevnikov's avatar akozhevnikov

[ssu] Use SsuRepo struct for listRepos

parent 4b60d6d7
...@@ -94,9 +94,9 @@ ...@@ -94,9 +94,9 @@
<arg direction="in" type="s" name="url" /> <arg direction="in" type="s" name="url" />
</method> </method>
<method name="listRepos"> <method name="listRepos">
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantList"/> <arg type="a(ssa{sv})" direction="out"/>
<arg direction="in" type="b" name="rnd" /> <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QList&lt;SsuRepo&gt;"/>
<arg direction="out" type="a(v)" name="repos"/> <arg name="rnd" type="b" direction="in"/>
</method> </method>
<method name="updateRepos"> <method name="updateRepos">
</method> </method>
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
SsuCli::SsuCli() SsuCli::SsuCli()
: QObject() : QObject()
{ {
qDBusRegisterMetaType<SsuRepo>();
connect(this, SIGNAL(done()), connect(this, SIGNAL(done()),
QCoreApplication::instance(), SLOT(quit()), Qt::DirectConnection); QCoreApplication::instance(), SLOT(quit()), Qt::DirectConnection);
connect(&ssu, SIGNAL(done()), connect(&ssu, SIGNAL(done()),
......
...@@ -11,5 +11,5 @@ SOURCES = main.cpp \ ...@@ -11,5 +11,5 @@ SOURCES = main.cpp \
ssu_dbus_interface.files = ../dbus/org.nemo.ssu.xml ssu_dbus_interface.files = ../dbus/org.nemo.ssu.xml
ssu_dbus_interface.source_flags = -c SsuProxy ssu_dbus_interface.source_flags = -c SsuProxy
ssu_dbus_interface.header_flags = -c SsuProxy -i ssud/ssud_include.h ssu_dbus_interface.header_flags = -c SsuProxy -i ssud/ssud_dbus.h
DBUS_INTERFACES += ssu_dbus_interface DBUS_INTERFACES += ssu_dbus_interface
...@@ -19,6 +19,8 @@ const char *Ssud::OBJECT_PATH = "/org/nemo/ssu"; ...@@ -19,6 +19,8 @@ const char *Ssud::OBJECT_PATH = "/org/nemo/ssu";
Ssud::Ssud(QObject *parent) Ssud::Ssud(QObject *parent)
: QObject(parent) : QObject(parent)
{ {
qDBusRegisterMetaType<SsuRepo>();
qDBusRegisterMetaType<QList<SsuRepo>>();
QDBusConnection connection = QDBusConnection::systemBus(); QDBusConnection connection = QDBusConnection::systemBus();
if (!connection.registerObject(OBJECT_PATH, this)) { if (!connection.registerObject(OBJECT_PATH, this)) {
qFatal("Cannot register object at %s", OBJECT_PATH); qFatal("Cannot register object at %s", OBJECT_PATH);
...@@ -232,14 +234,19 @@ void Ssud::updateRepos() ...@@ -232,14 +234,19 @@ void Ssud::updateRepos()
autoclose.start(); autoclose.start();
} }
QVariantList Ssud::listRepos(bool rnd) QList<SsuRepo> Ssud::listRepos(bool rnd)
{ {
QVariantList reposList; QList<SsuRepo> reposList;
SsuRepoManager repoManager; SsuRepoManager repoManager;
for (const QString &repo : repoManager.repos(rnd)) { for (const QString &repo : repoManager.repos(rnd)) {
const QString repoUrl = ssu.repoUrl(repo, rnd); const QString repoUrl = ssu.repoUrl(repo, rnd);
reposList << QVariantMap({{ "url", repoUrl }, { "name", repo }});
SsuRepo ssuRepo;
ssuRepo.name = repo;
ssuRepo.url = repoUrl;
reposList.append(ssuRepo);
} }
autoclose.start(); autoclose.start();
return reposList; return reposList;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include <QTimer> #include <QTimer>
#include "libssu/ssu.h" #include "libssu/ssu.h"
#include "ssud_include.h" #include "ssud_dbus.h"
class Ssud: public QObject class Ssud: public QObject
{ {
...@@ -46,7 +46,7 @@ public slots: ...@@ -46,7 +46,7 @@ public slots:
void modifyRepo(int action, const QString &repo); void modifyRepo(int action, const QString &repo);
void addRepo(const QString &repo, const QString &url); void addRepo(const QString &repo, const QString &url);
void updateRepos(); void updateRepos();
QVariantList listRepos(bool rnd); QList<SsuRepo> listRepos(bool rnd);
bool error(); bool error();
QString lastError(); QString lastError();
......
...@@ -7,7 +7,7 @@ CONFIG += link_pkgconfig ...@@ -7,7 +7,7 @@ CONFIG += link_pkgconfig
HEADERS = \ HEADERS = \
ssud.h \ ssud.h \
ssud_include.h ssud_dbus.h
SOURCES = \ SOURCES = \
ssud.cpp \ ssud.cpp \
main.cpp main.cpp
...@@ -27,5 +27,5 @@ INSTALLS += systemd service conf ...@@ -27,5 +27,5 @@ INSTALLS += systemd service conf
ssu_dbus_adaptor.files = ../dbus/org.nemo.ssu.xml ssu_dbus_adaptor.files = ../dbus/org.nemo.ssu.xml
ssu_dbus_adaptor.source_flags = -c SsuAdaptor ssu_dbus_adaptor.source_flags = -c SsuAdaptor
ssu_dbus_adaptor.header_flags = -c SsuAdaptor -i ssud/ssud_include.h ssu_dbus_adaptor.header_flags = -c SsuAdaptor -i ssud/ssud_dbus.h
DBUS_ADAPTORS += ssu_dbus_adaptor DBUS_ADAPTORS += ssu_dbus_adaptor
#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
#ifndef SSUD_INCLUDE_H
#define SSUD_INCLUDE_H
#endif // SSUD_INCLUDE_H
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