option(tpms_plugin "TPMS plugin " OFF)
option(obd2_plugin "OBD-II plugin" ON)
option(database_plugin "Database plugins" OFF)
+option(qt_bindings "AMB Qt DBus bindings" OFF)
find_library(libtool_LIBRARY ltdl DOC "Libtool libraries")
find_path(libtool_INCLUDE_DIR ltdl.h DOC "Libtool headers")
install (TARGETS dbussinkplugin LIBRARY DESTINATION lib/automotive-message-broker)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/amb.conf DESTINATION /etc/dbus-1/system.d )
+
+add_subdirectory(amb-qt)
--- /dev/null
+if(qt_bindings)
+
+FIND_PACKAGE(Qt4 COMPONENTS QtCore QtDBus REQUIRED)
+include(${QT_USE_FILE})
+ADD_DEFINITIONS(${QT_DEFINITIONS})
+
+set(QT_USE_QTDBUS TRUE)
+set(QT_DONT_USE_QTGUI TRUE)
+set(ambqt_headers ambqt.h amb-qt_global.h)
+set(ambqt_sources ambqt.cpp)
+
+QT4_WRAP_CPP(ambqt_headers_moc ${ambqt_headers})
+
+include_directories(${CMAKE_SOURCE_DIR}/lib ${include_dirs} ${QT_INCLUDE_DIRS})
+
+add_library(amb-qt MODULE ${ambqt_sources} ${ambqt_headers_moc})
+
+target_link_libraries(amb-qt amb ${QT_LIBRARIES} -L${CMAKE_CURRENT_BINARY_DIR}/lib ${link_libraries} ${gio_LIBRARIES})
+
+install (TARGETS amb-qt LIBRARY DESTINATION lib)
+
+endif(qt_bindings)
--- /dev/null
+#ifndef AMBQT_GLOBAL_H
+#define AMBQT_GLOBAL_H
+
+#include <QtCore/qglobal.h>
+
+#if defined(AMBQT_LIBRARY)
+# define AMBQTSHARED_EXPORT Q_DECL_EXPORT
+#else
+# define AMBQTSHARED_EXPORT Q_DECL_IMPORT
+#endif
+
+#endif // AMBQT_GLOBAL_H
--- /dev/null
+#include "ambqt.h"
+#include <QDBusConnection>
+#include <QDBusInterface>
+#include <QtDebug>
+
+AmbProperty::AmbProperty(QString objectPath, QString interface, QString propertyName)
+ :QObject(),mPropertyName(propertyName)
+{
+
+ mInterface = new QDBusInterface("org.automotive.message.broker",objectPath, interface,QDBusConnection::systemBus(),this);
+
+ if(!QDBusConnection::systemBus().connect("org.automotive.message.broker", objectPath, interface, propertyName, this, SIGNAL(propertyChanged(QVariant))))
+ {
+ qDebug()<<"Failed to connect to signal";
+ qDebug()<<"path: "<<objectPath;
+ qDebug()<<"interface: "<<interface;
+ qDebug()<<"signal: "<<propertyName;
+ qDebug()<<"Error: "<<QDBusConnection::systemBus().lastError().message();
+ }
+
+}
--- /dev/null
+#ifndef AMBQT_H
+#define AMBQT_H
+
+#include <QObject>
+#include <QDBusInterface>
+
+class QDBusInterface;
+
+class AmbProperty: public QObject
+{
+ Q_OBJECT
+public:
+ AmbProperty(QString objectPath, QString interface, QString propertyName);
+
+ QVariant operator()() const
+ {
+ return mInterface->property(mPropertyName.toAscii().data());
+ }
+
+signals:
+ void propertyChanged(QVariant);
+
+private:
+ QString mPropertyName;
+ QDBusInterface* mInterface;
+};
+
+#endif // AMBQT_H