summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevron Rees <kevron.m.rees@intel.com>2015-01-19 13:46:12 -0800
committerKevron Rees <kevron.m.rees@intel.com>2015-01-19 13:46:12 -0800
commitcd515ebf86fbf26667b271db3098b2aaced58e44 (patch)
treee94e5ed95bbe69c06c068c10085e81aeb304691d
parent15884536cb9091cb8328dc7da15790d380d89810 (diff)
downloadautomotive-message-broker-cd515ebf86fbf26667b271db3098b2aaced58e44.tar.gz
[bluemonkey] - added dbus module
-rw-r--r--plugins/bluemonkey/CMakeLists.txt13
-rw-r--r--plugins/bluemonkey/bluemonkey.cpp6
-rw-r--r--plugins/bluemonkey/bluemonkey.h17
-rw-r--r--plugins/bluemonkey/bmdbus.cpp40
-rw-r--r--plugins/bluemonkey/bmdbus.h48
-rw-r--r--plugins/bluemonkey/config.js11
-rw-r--r--plugins/bluemonkey/db.cpp18
-rw-r--r--plugins/bluemonkey/db.h18
-rw-r--r--plugins/bluemonkey/irccoms.cpp18
-rw-r--r--plugins/bluemonkey/irccoms.h18
10 files changed, 192 insertions, 15 deletions
diff --git a/plugins/bluemonkey/CMakeLists.txt b/plugins/bluemonkey/CMakeLists.txt
index 71a75692..f829d4fc 100644
--- a/plugins/bluemonkey/CMakeLists.txt
+++ b/plugins/bluemonkey/CMakeLists.txt
@@ -42,6 +42,17 @@ if(Qt5Sql_FOUND)
install(TARGETS bluemonkeyDbModule LIBRARY DESTINATION ${PLUGIN_INSTALL_PATH})
endif()
+find_package(Qt5DBus)
+
+if(Qt5DBus_FOUND)
+ message(STATUS "enabling dbus bluemonkey module")
+ add_library(bluemonkeyDBusModule MODULE bmdbus.cpp)
+ set_target_properties(bluemonkeyDBusModule PROPERTIES PREFIX "")
+ target_link_libraries(bluemonkeyDBusModule ${link_libraries} amb -L${CMAKE_CURRENT_BINARY_DIR}/lib ${QT_LIBRARIES} ${Qt5DBus_LIBRARIES})
+ set(QT_INCLUDE_DIRS ${QT_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS})
+ install(TARGETS bluemonkeyDBusModule LIBRARY DESTINATION ${PLUGIN_INSTALL_PATH})
+endif()
+
include_directories(${CMAKE_SOURCE_DIR}/lib ${include_dirs} ${communi_INCLUDE_DIRS} ${QT_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/plugins/common)
set(bluemonkeyplugin_headers bluemonkey.h authenticate.h)
@@ -51,7 +62,7 @@ add_library(bluemonkeyplugin MODULE ${bluemonkeyplugin_sources})
set_target_properties(bluemonkeyplugin PROPERTIES PREFIX "")
target_link_libraries(bluemonkeyplugin dl amb -L${CMAKE_CURRENT_BINARY_DIR}/lib ${link_libraries} ${QT_LIBRARIES} ${communi_LIBRARIES} amb-plugins-common -L${CMAKE_CURRENT_BINARY_DIR}/plugins/common)
-set(config_files ${CMAKE_CURRENT_SOURCE_DIR}/config.js)
+set(config_files ${CMAKE_CURRENT_BINARY_DIR}/config.js)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/config.js ${CMAKE_CURRENT_BINARY_DIR}/config.js @ONLY)
install(TARGETS bluemonkeyplugin LIBRARY DESTINATION ${PLUGIN_INSTALL_PATH})
diff --git a/plugins/bluemonkey/bluemonkey.cpp b/plugins/bluemonkey/bluemonkey.cpp
index 958e43ce..c4078343 100644
--- a/plugins/bluemonkey/bluemonkey.cpp
+++ b/plugins/bluemonkey/bluemonkey.cpp
@@ -166,6 +166,8 @@ BluemonkeySink::~BluemonkeySink()
{
dlclose(module);
}
+
+ engine->deleteLater();
}
@@ -253,7 +255,7 @@ void BluemonkeySink::loadConfig(QString str)
file.close();
- DebugOut()<<"evaluating script: "<<script.toStdString()<<endl;
+ DebugOut(7)<<"evaluating script: "<<script.toStdString()<<endl;
QJSValue val = engine->evaluate(script);
@@ -312,7 +314,7 @@ void BluemonkeySink::reloadEngine()
if(engine)
engine->deleteLater();
- engine = new QJSEngine(this);
+ engine = new QJSEngine();
QJSValue value = engine->newQObject(this);
engine->globalObject().setProperty("bluemonkey", value);
diff --git a/plugins/bluemonkey/bluemonkey.h b/plugins/bluemonkey/bluemonkey.h
index 13c7c309..f08e9002 100644
--- a/plugins/bluemonkey/bluemonkey.h
+++ b/plugins/bluemonkey/bluemonkey.h
@@ -20,8 +20,9 @@
#ifndef BluemonkeySink_H
#define BluemonkeySink_H
-#include "abstractsource.h"
-#include "ambpluginimpl.h"
+#include <abstractsource.h>
+#include <ambpluginimpl.h>
+#include <uuidhelper.h>
#include <map>
@@ -30,20 +31,12 @@
#include <QJsonDocument>
#include <QDateTime>
#include <QJSValue>
-#include "uuidhelper.h"
+#include <QThread>
#include "authenticate.h"
class QJSEngine;
-class ModuleInterface
-{
-public:
- virtual std::map<std::string, QObject*> objects(std::map<string, string> config) = 0;
-};
-
-Q_DECLARE_INTERFACE(ModuleInterface, "org.automotive.bluemonkey.moduleinterface")
-
class Property: public QObject, public AbstractSink
{
Q_OBJECT
@@ -54,7 +47,7 @@ class Property: public QObject, public AbstractSink
Q_PROPERTY(int zone READ zone)
public:
- Property(VehicleProperty::Property, QString srcFilter, AbstractRoutingEngine* re, Zone::Type zone = Zone::None, QObject *parent = 0);
+ Property(VehicleProperty::Property, QString srcFilter, AbstractRoutingEngine * re, Zone::Type zone = Zone::None, QObject * parent = 0);
QString name();
void setType(QString t);
diff --git a/plugins/bluemonkey/bmdbus.cpp b/plugins/bluemonkey/bmdbus.cpp
new file mode 100644
index 00000000..8f26c7fc
--- /dev/null
+++ b/plugins/bluemonkey/bmdbus.cpp
@@ -0,0 +1,40 @@
+/*
+ Copyright (C) 2012 Intel Corporation
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#include "bmdbus.h"
+
+#include <QDBusInterface>
+#include <QDBusConnection>
+
+extern "C" std::map<std::string, QObject*> create(std::map<std::string, std::string> config, QObject* parent)
+{
+ std::map<std::string, QObject*> moduleInstances;
+ moduleInstances["dbus"] = new BMDBus(parent);
+ return moduleInstances;
+}
+
+BMDBus::BMDBus(QObject *parent)
+ :QObject(parent)
+{
+
+}
+
+QObject *BMDBus::createInterface(const QString &service, const QString &path, const QString &interface, BMDBus::Connection bus)
+{
+ return new QDBusInterface(service, path, interface, bus == Session ? QDBusConnection::sessionBus() : QDBusConnection::systemBus(), this);
+}
diff --git a/plugins/bluemonkey/bmdbus.h b/plugins/bluemonkey/bmdbus.h
new file mode 100644
index 00000000..903963c3
--- /dev/null
+++ b/plugins/bluemonkey/bmdbus.h
@@ -0,0 +1,48 @@
+/*
+ Copyright (C) 2012 Intel Corporation
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#ifndef BM_DBUS_H_
+#define BM_DBUS_H_
+
+#include <QObject>
+
+class BMDBus : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(Connection)
+
+public:
+
+ enum Connection{
+ System,
+ Session
+ };
+
+ BMDBus(QObject * parent = nullptr);
+
+public Q_SLOTS:
+
+ QObject* createInterface(const QString & service, const QString & path, const QString & interface, Connection bus);
+
+private: ///methods:
+
+
+};
+
+
+#endif
diff --git a/plugins/bluemonkey/config.js b/plugins/bluemonkey/config.js
index cb7549e2..131247e8 100644
--- a/plugins/bluemonkey/config.js
+++ b/plugins/bluemonkey/config.js
@@ -27,6 +27,17 @@ dbusConnected.changed.connect(function () {
{'AnswerToTheUniverse' : 'AnswerToTheUniverse'}]);
});
+bluemonkey.loadModule("@PLUGIN_INSTALL_PATH@/bluemonkeyDBusModule.so");
+
+if(dbus)
+{
+ var dbusIface = dbus.createInterface("org.freedesktop.DBus", "/", "org.freedesktop.DBus", dbus.Session);
+
+ var reply = dbusIface.GetId();
+
+ bluemonkey.log("org.freedesktop.DBus.GetId() response: " + reply);
+}
+
bluemonkey.createCustomProperty("VehicleSpeed", 10);
bluemonkey.createCustomProperty("EngineSpeed", 5000);
bluemonkey.createCustomProperty("PowertrainTorque", 324);
diff --git a/plugins/bluemonkey/db.cpp b/plugins/bluemonkey/db.cpp
index 07bb9e3f..609e7314 100644
--- a/plugins/bluemonkey/db.cpp
+++ b/plugins/bluemonkey/db.cpp
@@ -1,3 +1,21 @@
+/*
+ Copyright (C) 2012 Intel Corporation
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
#include "db.h"
#include <debugout.h>
diff --git a/plugins/bluemonkey/db.h b/plugins/bluemonkey/db.h
index 32716dfe..33298bdc 100644
--- a/plugins/bluemonkey/db.h
+++ b/plugins/bluemonkey/db.h
@@ -1,3 +1,21 @@
+/*
+ Copyright (C) 2012 Intel Corporation
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
#include <QObject>
#include <QSqlDatabase>
#include <QSqlQuery>
diff --git a/plugins/bluemonkey/irccoms.cpp b/plugins/bluemonkey/irccoms.cpp
index 3d0eaa47..02beffd7 100644
--- a/plugins/bluemonkey/irccoms.cpp
+++ b/plugins/bluemonkey/irccoms.cpp
@@ -1,3 +1,21 @@
+/*
+ Copyright (C) 2012 Intel Corporation
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
#include "irccoms.h"
#include <QtDebug>
#include <IrcCommand>
diff --git a/plugins/bluemonkey/irccoms.h b/plugins/bluemonkey/irccoms.h
index cf0ef0b8..dacfd6a4 100644
--- a/plugins/bluemonkey/irccoms.h
+++ b/plugins/bluemonkey/irccoms.h
@@ -1,3 +1,21 @@
+/*
+ Copyright (C) 2012 Intel Corporation
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
#ifndef COMMUNICATION_H
#define COMMUNICATION_H
#include <QObject>