[bluemonkey] - added dbus module
authorKevron Rees <kevron.m.rees@intel.com>
Mon, 19 Jan 2015 21:46:12 +0000 (13:46 -0800)
committerKevron Rees <kevron.m.rees@intel.com>
Mon, 19 Jan 2015 21:46:12 +0000 (13:46 -0800)
plugins/bluemonkey/CMakeLists.txt
plugins/bluemonkey/bluemonkey.cpp
plugins/bluemonkey/bluemonkey.h
plugins/bluemonkey/bmdbus.cpp [new file with mode: 0644]
plugins/bluemonkey/bmdbus.h [new file with mode: 0644]
plugins/bluemonkey/config.js
plugins/bluemonkey/db.cpp
plugins/bluemonkey/db.h
plugins/bluemonkey/irccoms.cpp
plugins/bluemonkey/irccoms.h

index 71a7569..f829d4f 100644 (file)
@@ -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})
index 958e43c..c407834 100644 (file)
@@ -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);
index 13c7c30..f08e900 100644 (file)
@@ -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>
 
 #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 (file)
index 0000000..8f26c7f
--- /dev/null
@@ -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 (file)
index 0000000..903963c
--- /dev/null
@@ -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
index cb7549e..131247e 100644 (file)
@@ -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);
index 07bb9e3..609e731 100644 (file)
@@ -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>
index 32716df..33298bd 100644 (file)
@@ -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>
index 3d0eaa4..02beffd 100644 (file)
@@ -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>
index cf0ef0b..dacfd6a 100644 (file)
@@ -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>