work in progress
This commit is contained in:
parent
d9e2c4d3bf
commit
f874d764db
@ -22,14 +22,12 @@ find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Quick QuickWidgets D
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/alterator_loader.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/dbus_connector.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/dbus_interface.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/dbus_action.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/dbus_property_map.cpp)
|
||||
|
||||
set(HEADERS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/alterator_loader.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/dbus_connector.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/dbus_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/dbus_action.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/dbus_property_map.h)
|
||||
|
||||
set(ALTERATORLIB_VERSION 0.0.1)
|
||||
|
@ -11,14 +11,14 @@
|
||||
#include "dbus_connector.h"
|
||||
#include "dbus_interface.h"
|
||||
#include "alterator_loader_config.h"
|
||||
#include "dbus_action.h"
|
||||
//#include "dbus_action.h"
|
||||
|
||||
namespace Alterator{
|
||||
class Loader: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Loader(QObject *p);
|
||||
Loader(QObject *p = 0);
|
||||
|
||||
signals:
|
||||
void move(QString windowId, QString targetUrl);
|
||||
@ -31,15 +31,14 @@ public slots:
|
||||
void closed(QString senderId);
|
||||
void back(QString senderId);
|
||||
void forvard(QString senderId);
|
||||
void getIface(QList<DBusInterface> ifaces);
|
||||
void getIface(QString targetId, DBusInterface * iface);
|
||||
|
||||
private:
|
||||
const QString windowUrl = windowURLM;
|
||||
|
||||
void open(QString targetUrl);
|
||||
void justMove(QString senderId, QString targetUrl);
|
||||
void collectIfaces(QString targetId);
|
||||
void pushInIface(QString targetId, DBusInterface *iface);
|
||||
void collectIfaces(QObject *window);
|
||||
|
||||
QHash<QString, QVector<QString>> past;
|
||||
QHash<QString, QVector<QString>> future;
|
||||
|
@ -18,13 +18,14 @@ signals:
|
||||
void giveInterface(QString targetId, DBusInterface *iface);
|
||||
|
||||
public slots:
|
||||
void ifaceReq(QString senderId, QString service, QString path
|
||||
void ifaceReq(QString senderId, QString shortName
|
||||
, QString service, QString path
|
||||
, QString interface, QDBusConnection connection);
|
||||
private:
|
||||
// QHash<QString, QDBusInterface *> realIfaces;
|
||||
// QHash<QString, QQmlPropertyMap *> introspections;
|
||||
|
||||
QQmlPropertyMap *introspect(QString service, QString path
|
||||
DBusPropertyMap *introspect(QString service, QString path
|
||||
, QString interface, QDBusConnection connection);
|
||||
};
|
||||
}
|
||||
|
@ -4,17 +4,27 @@
|
||||
#include <QObject>
|
||||
#include <QDBusInterface>
|
||||
#include <QQmlPropertyMap>
|
||||
#include <QDBusArgument>
|
||||
#include "dbus_property_map.h"
|
||||
|
||||
namespace Alterator{
|
||||
class DBusInterface: public QObject{
|
||||
Q_OBJECT
|
||||
Q_ENUM(QDBus::CallMode)
|
||||
// Q_ENUM(QDBus::CallMode)
|
||||
public:
|
||||
DBusInterface( QQmlPropertyMap *introspection, QDBusInterface *ri
|
||||
, QObject *parent = 0 );
|
||||
DBusInterface( DBusPropertyMap *introspection, QDBusInterface *ri,
|
||||
QString iname, QString sname, QObject *parent = 0 );
|
||||
public slots:
|
||||
void propertyUpdatedFromDBus(
|
||||
QDBusArgument ifaceName
|
||||
, QDBusArgument changedProperties
|
||||
, QDBusArgument invalidProperties);
|
||||
void updateDBus(const QString &key, const QVariant &input);
|
||||
private:
|
||||
QDBusInterface *realIface;
|
||||
QQmlPropertyMap *properties;
|
||||
DBusPropertyMap *properties;
|
||||
QString shortName;
|
||||
QString ifaceName;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,14 @@
|
||||
#ifndef DBUS_PROPERTY_MAP_H
|
||||
#define DBUS_PROPERTY_MAP_H
|
||||
#include <QQmlPropertyMap>
|
||||
namespace Alterator{
|
||||
class DBusPropertyMap : public QQmlPropertyMap{
|
||||
public:
|
||||
DBusPropertyMap(QQmlPropertyMap *derived, QObject *parent);
|
||||
|
||||
QVariant updateValue(const QString &key, const QVariant &input);
|
||||
signals:
|
||||
void updateDBus(const QString &key, const QVariant &input);
|
||||
};
|
||||
}
|
||||
#endif // DBUS_PROPERTY_MAP_H
|
||||
|
@ -21,6 +21,8 @@ Loader::Loader(QObject *p):QObject(p)
|
||||
future = QHash<QString, QVector<QString>>();
|
||||
widgets = QHash<QString, QObject*>();
|
||||
open(startingPage);
|
||||
connect(dbus, SIGNAL(giveInterface(QString, DBusInterface *))
|
||||
, this, SLOT(getIface(QString, DBusInterface *)));
|
||||
}
|
||||
|
||||
void Loader::open(QString targetUrl){
|
||||
@ -85,4 +87,12 @@ void Loader::forvard(QString senderId){
|
||||
justMove(senderId, targetUrl);
|
||||
}
|
||||
}
|
||||
|
||||
void Loader::getIface(QString targetId, DBusInterface *iface){
|
||||
qDebug() << engine->rootContext()->children();
|
||||
}
|
||||
|
||||
void Loader::collectIfaces(QObject *window){
|
||||
QList<QVariant> window->property("requiredInterfaces");
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "dbus_connector.h"
|
||||
#include "dbus_property_map.h"
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusConnection>
|
||||
#include <QXmlStreamReader>
|
||||
@ -10,25 +11,31 @@ DBusConnector::DBusConnector(QObject *parent): QObject(parent)
|
||||
// introspections = QHash<QString, QQmlPropertyMap *>();
|
||||
}
|
||||
|
||||
QQmlPropertyMap *DBusConnector::introspect(QString service, QString path //FIXME
|
||||
DBusPropertyMap *DBusConnector::introspect(QString service, QString path //FIXME
|
||||
, QString interface
|
||||
, QDBusConnection connection)
|
||||
{
|
||||
QDBusInterface introspectable =
|
||||
QDBusInterface(service, path
|
||||
, "org.freedesktop.DBus.Introspectable", connection);
|
||||
QQmlPropertyMap *introspection = new QQmlPropertyMap(this);
|
||||
QQmlPropertyMap *t = new QQmlPropertyMap(this);
|
||||
DBusPropertyMap *introspection = new DBusPropertyMap(t, this);
|
||||
QXmlStreamReader reader = QXmlStreamReader(
|
||||
introspectable.call("Introspect").arguments()[0].toString());
|
||||
return introspection;
|
||||
}
|
||||
|
||||
void DBusConnector::ifaceReq(QString senderId, QString service, QString path
|
||||
void DBusConnector::ifaceReq(QString senderId, QString shortName
|
||||
, QString service, QString path
|
||||
, QString interface, QDBusConnection connection){
|
||||
QDBusInterface *realIface = new QDBusInterface( service, path, interface
|
||||
, connection, this);
|
||||
DBusInterface *iface = new DBusInterface(
|
||||
introspect(service, path, interface, connection), realIface, this);
|
||||
introspect(service, path, interface, connection)
|
||||
, realIface, interface, shortName, this);
|
||||
connection.connect( service, path, "org.freedesktop.DBus.Properties"
|
||||
, "PropertiesChanged", iface
|
||||
, SLOT(propertyUpdatedFromDBus()) );
|
||||
emit(giveInterface(senderId, iface));
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,47 @@
|
||||
#include "dbus_interface.h"
|
||||
|
||||
namespace Alterator {
|
||||
DBusInterface::DBusInterface( QQmlPropertyMap *introspection, QDBusInterface *ri
|
||||
, QObject *parent): QObject(parent){
|
||||
DBusInterface::DBusInterface( DBusPropertyMap *introspection, QDBusInterface *ri,
|
||||
QString iname, QString sname, QObject *parent): QObject(parent){
|
||||
realIface = ri;
|
||||
properties = introspection;
|
||||
shortName = sname;
|
||||
ifaceName = iname;
|
||||
connect(introspection, SIGNAL(updateDBus()), this, SLOT(updateDBus()));
|
||||
}
|
||||
void DBusInterface::propertyUpdatedFromDBus(
|
||||
QDBusArgument ifaceName
|
||||
, QDBusArgument changedProperties
|
||||
, QDBusArgument invalidProperties){
|
||||
QString in;
|
||||
ifaceName >> in;
|
||||
if (in != DBusInterface::ifaceName){
|
||||
return;
|
||||
}
|
||||
changedProperties.beginMap();
|
||||
while(!changedProperties.atEnd()){
|
||||
QString key;
|
||||
QVariant val;
|
||||
changedProperties.beginMapEntry();
|
||||
changedProperties >> key >> val;
|
||||
changedProperties.endMapEntry();
|
||||
properties->insert(key, val);
|
||||
changedProperties.endMapEntry();
|
||||
}
|
||||
changedProperties.endMap();
|
||||
invalidProperties.beginArray();
|
||||
while(!invalidProperties.atEnd()){
|
||||
QString key;
|
||||
invalidProperties.beginMapEntry();
|
||||
invalidProperties >> key;
|
||||
changedProperties.endMapEntry();
|
||||
properties->clear(key);
|
||||
}
|
||||
invalidProperties.endArray();
|
||||
}
|
||||
|
||||
void DBusInterface::updateDBus(const QString &key, const QVariant &input){
|
||||
auto t = key.toLocal8Bit();
|
||||
realIface->setProperty(t.data(), input);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#include "dbus_property_map.h"
|
||||
|
||||
namespace Alterator{
|
||||
DBusPropertyMap::DBusPropertyMap(QQmlPropertyMap *derived, QObject *parent) : QQmlPropertyMap(derived, parent){}
|
||||
|
||||
QVariant DBusPropertyMap::updateValue(const QString &key, const QVariant &input){
|
||||
emit(updateValue(key, input));
|
||||
return input;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user