diff --git a/alterator/include/alterator_loader.h b/alterator/include/alterator_loader.h index bc39d35..264cf8e 100644 --- a/alterator/include/alterator_loader.h +++ b/alterator/include/alterator_loader.h @@ -22,7 +22,8 @@ public: signals: void move(QString windowId, QString targetUrl); - void ifaceReq( QString senderId, QString service, QString path + void ifaceReq( QString senderId, QString shortName + , QString service, QString path , QString interface, QDBusConnection connection ); public slots: @@ -38,7 +39,7 @@ private: void open(QString targetUrl); void justMove(QString senderId, QString targetUrl); - void collectIfaces(QObject *window); + void collectIfaces(QObject *window, QString targetId); QHash> past; QHash> future; diff --git a/alterator/include/dbus_connector.h b/alterator/include/dbus_connector.h index 5e59c22..4d7b91b 100644 --- a/alterator/include/dbus_connector.h +++ b/alterator/include/dbus_connector.h @@ -10,11 +10,12 @@ namespace Alterator{ class DBusConnector: public QObject { + Q_OBJECT public: DBusConnector(QObject *parent = nullptr); signals: - void pushInLogs(QString targetId, QList logs); + //void pushInLogs(QString targetId, QList logs); void giveInterface(QString targetId, DBusInterface *iface); public slots: diff --git a/alterator/include/dbus_interface.h b/alterator/include/dbus_interface.h index da5e886..e8c46ae 100644 --- a/alterator/include/dbus_interface.h +++ b/alterator/include/dbus_interface.h @@ -14,6 +14,9 @@ class DBusInterface: public QObject{ public: DBusInterface( DBusPropertyMap *introspection, QDBusInterface *ri, QString iname, QString sname, QObject *parent = 0 ); + + QString getShortName(); + DBusPropertyMap *getProperties(); public slots: void propertyUpdatedFromDBus( QDBusArgument ifaceName diff --git a/alterator/src/alterator_loader.cpp b/alterator/src/alterator_loader.cpp index 69cdb40..d4c3933 100644 --- a/alterator/src/alterator_loader.cpp +++ b/alterator/src/alterator_loader.cpp @@ -23,6 +23,9 @@ Loader::Loader(QObject *p):QObject(p) open(startingPage); connect(dbus, SIGNAL(giveInterface(QString, DBusInterface *)) , this, SLOT(getIface(QString, DBusInterface *))); + connect(this, SIGNAL(ifaceReq( QString, QString, QString, QString, QString, QDBusConnection)) + , dbus, SLOT(ifaceReq( QString, QString, QString, QString, QString, QDBusConnection))); + } void Loader::open(QString targetUrl){ @@ -31,6 +34,7 @@ void Loader::open(QString targetUrl){ QObject *window = engine->rootObjects().last(); window->setProperty("url", targetUrl); window->setProperty("windowId", windowId); + collectIfaces(window, windowId); past.insert(windowId, QVector() << targetUrl); future.insert(windowId, QVector()); widgets.insert(windowId, window); @@ -89,10 +93,26 @@ void Loader::forvard(QString senderId){ } void Loader::getIface(QString targetId, DBusInterface *iface){ - qDebug() << engine->rootContext()->children(); + QQmlContext *pageContext = new QQmlContext(engine->rootContext()); + widgets[targetId]->findChild( + "currentPageN", Qt::FindChildrenRecursively)->create(pageContext); + pageContext->setContextProperty(iface->getShortName(), iface); + QQmlContext *ifaceContext = new QQmlContext(pageContext); + widgets[targetId]->findChild( + "currentPageN", Qt::FindChildrenRecursively)->create(ifaceContext); + ifaceContext->setContextProperty("properties", iface->getProperties()); } -void Loader::collectIfaces(QObject *window){ - QList window->property("requiredInterfaces"); +void Loader::collectIfaces(QObject *window, QString targetId){ + QList raw = window->property("requiredInterfaces").toList(); + QVariant i; + foreach(i, raw){ + QHash t = i.toHash(); + emit(ifaceReq(targetId, t["shortName"].toString() + , t["service"].toString(), t["path"].toString() + , t["interface"].toString() + , t["isSessionBus"].toBool() ? QDBusConnection::sessionBus() + : QDBusConnection::systemBus())); + } } } diff --git a/alterator/src/dbus_interface.cpp b/alterator/src/dbus_interface.cpp index 6f0242d..7dd771a 100644 --- a/alterator/src/dbus_interface.cpp +++ b/alterator/src/dbus_interface.cpp @@ -9,6 +9,14 @@ DBusInterface::DBusInterface( DBusPropertyMap *introspection, QDBusInterface *ri ifaceName = iname; connect(introspection, SIGNAL(updateDBus()), this, SLOT(updateDBus())); } + +QString DBusInterface::getShortName(){ + return shortName; +} +DBusPropertyMap * DBusInterface::getProperties(){ + return properties; +} + void DBusInterface::propertyUpdatedFromDBus( QDBusArgument ifaceName , QDBusArgument changedProperties diff --git a/resources/DistInfo.qml b/resources/DistInfo.qml index 955dc37..4337349 100644 --- a/resources/DistInfo.qml +++ b/resources/DistInfo.qml @@ -10,7 +10,7 @@ import shared 1.0 ScrollView { id: view - property var RequiredInterfaces: + property var requiredInterfaces: [ {shortname : "hostname" , service : "org.freedesktop.hostname1" , path : "/org/freedesktop/hostname1"