[bluemonkey] moved configs to proper location
authorKevron Rees <tripzero.kev@gmail.com>
Sat, 8 Jun 2013 01:19:00 +0000 (18:19 -0700)
committerKevron Rees <tripzero.kev@gmail.com>
Sat, 8 Jun 2013 01:19:00 +0000 (18:19 -0700)
examples/bluemonkey/authSettings.js [deleted file]
examples/bluemonkey/bluemonkeyconfig
examples/bluemonkey/config.js [deleted file]
examples/bluemonkey/ircSettings.js [deleted file]
plugins/bluemonkey/CMakeLists.txt
plugins/bluemonkey/authenticate.cpp
plugins/bluemonkey/authenticate.h
plugins/bluemonkey/bluemonkey.cpp
plugins/bluemonkey/irccoms.cpp
plugins/bluemonkey/irccoms.h

diff --git a/examples/bluemonkey/authSettings.js b/examples/bluemonkey/authSettings.js
deleted file mode 100644 (file)
index a678486..0000000
+++ /dev/null
@@ -1 +0,0 @@
-auth.pin = "000"
index c7dc9d3..67006b3 100644 (file)
        "sinks": [
                {
                        "name" : "Bluemonkey Sink",
-                       "path" : "/usr/lib/automotive-message-broker/bluemonkeyplugin.so"
+                       "path" : "/usr/lib/automotive-message-broker/bluemonkeyplugin.so",
+                       "authSettings" : "/etc/ambd/authSettings.js",
+                       "ircSettings" : "/etc/ambd/ircSettings.js",
+                       "config" : "/etc/ambd/config.js",
+                       "customPrograms" : "/etc/ambd/customPrograms.js"
+
                }
        ]
 }
diff --git a/examples/bluemonkey/config.js b/examples/bluemonkey/config.js
deleted file mode 100644 (file)
index 363f3f8..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-var speedProperty = bluemonkey.subscribeTo("VehicleSpeed");
-
-bluemonkey.loadConfig("customPrograms.js");
-
-       
diff --git a/examples/bluemonkey/ircSettings.js b/examples/bluemonkey/ircSettings.js
deleted file mode 100644 (file)
index 06439d3..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-var address = "chat.freenode.com"
-var port = 8001
-var proxy = ""
-var username = ""
-var nick = ""
-var pass = ""
-
-
-function ircConnecting() {
-        print("connecting to irc");
-}
-
-function ircConnected() {
-        print("connected");
-        for(var i=0;i<irc.channels.length;i++)
-        {
-                irc.join(irc.channels[i]);
-        }
-}
-
-
-irc.channels = ["#bluemonkey","#linuxice"]
-irc.connected.connect(ircConnected);
-irc.connecting.connect(ircConnecting);
-
-irc.connect(address,port,proxy,username,nick,pass);
index 8ec0840..5c83883 100644 (file)
@@ -28,6 +28,10 @@ add_library(bluemonkeyplugin MODULE ${bluemonkeyplugin_sources})
 set_target_properties(bluemonkeyplugin PROPERTIES PREFIX "")
 target_link_libraries(bluemonkeyplugin amb -L${CMAKE_CURRENT_BINARY_DIR}/lib ${link_libraries} ${QT_LIBRARIES} ${communi_LIBRARIES})
 
-install(TARGETS bluemonkeyplugin LIBRARY DESTINATION lib/automotive-message-broker)
+set(config_files ${CMAKE_CURRENT_SOURCE_DIR}/ircSettings.js
+    ${CMAKE_CURRENT_SOURCE_DIR}/authSettings.js
+    ${CMAKE_CURRENT_SOURCE_DIR}/config.js)
 
+install(TARGETS bluemonkeyplugin LIBRARY DESTINATION lib/automotive-message-broker)
+install (FILES ${config_files} DESTINATION /etc/ambd)
 endif(bluemonkey_plugin)
index b13c6eb..0097456 100644 (file)
@@ -2,7 +2,7 @@
 #include <QSettings>
 #include <QtScript>
 
-Authenticate::Authenticate(QObject *parent) :
+Authenticate::Authenticate(std::map<std::string, std::string> config, QObject *parent) :
     QObject(parent)
 {
        QSettings settings;
@@ -13,7 +13,7 @@ Authenticate::Authenticate(QObject *parent) :
        QScriptValue eventEngineValue = engine.newQObject(this);
        engine.globalObject().setProperty("auth", eventEngineValue);
 
-       QString str = "authSettings.js";
+       QString str = config["authSettings"].c_str();
 
        QFile file(str);
        if(!file.open(QIODevice::ReadOnly))
index 601f758..df84283 100644 (file)
@@ -3,13 +3,15 @@
 
 #include <QObject>
 #include <QStringList>
+#include <map>
+#include <string>
 
 class Authenticate : public QObject
 {
     Q_OBJECT
        Q_PROPERTY(QString pin READ pin WRITE setPin)
 public:
-    explicit Authenticate(QObject *parent = 0);
+       explicit Authenticate(std::map<std::string, std::string> config, QObject *parent = 0);
        void setPin(QString p) { mPin = p; }
        QString pin() { return mPin; }
 
index 0bd0d79..58923c5 100644 (file)
@@ -73,11 +73,11 @@ QVariant gvariantToQVariant(GVariant *value)
 
 BluemonkeySink::BluemonkeySink(AbstractRoutingEngine* e, map<string, string> config): QObject(0), AbstractSink(e, config), engine(nullptr)
 {
-       irc = new IrcCommunication(this);
+       irc = new IrcCommunication(config, this);
 
        reloadEngine();
 
-       auth = new Authenticate(this);
+       auth = new Authenticate(config, this);
 
        connect(irc, &IrcCommunication::message, [&](QString sender, QString prefix, QString codes ) {
 
@@ -184,12 +184,14 @@ void BluemonkeySink::reloadEngine()
        QScriptValue value = engine->newQObject(this);
        engine->globalObject().setProperty("bluemonkey", value);
 
-       loadConfig("config.js");
+
+
+       loadConfig(configuration["config"].c_str());
 }
 
 void BluemonkeySink::writeProgram(QString program)
 {
-       QFile file("customPrograms.js");
+       QFile file(configuration["customPrograms"].c_str());
 
        file.open(QIODevice::ReadWrite | QIODevice::Append);
 
index 51c5360..4a98403 100644 (file)
 
 #define foreach Q_FOREACH
 
-IrcCommunication::IrcCommunication(QObject* parent)
+IrcCommunication::IrcCommunication(std::map<std::string, std::string> config, QObject* parent)
        :QObject(parent)
 {
+
        session = new IrcSession(this);
        mSsl=false;
 
@@ -28,12 +29,12 @@ IrcCommunication::IrcCommunication(QObject* parent)
        QScriptValue eventEngineValue = engine->newQObject(this);
        engine->globalObject().setProperty("irc", eventEngineValue);
 
-       QString str = "ircSettings.js";
+       QString str = config["ircSettings"].c_str();
 
        QFile file(str);
        if(!file.open(QIODevice::ReadOnly))
        {
-               qDebug()<<"failed to open config file: "<<str;
+               qDebug()<<"failed to open irc config file: "<<str;
                return;
        }
 
index 8c4a61e..6033362 100644 (file)
@@ -3,6 +3,7 @@
 #include <QObject>
 #include <QVariant>
 #include <QStringList>
+#include <map>
 
 #include <IrcSession>
 #include <IrcMessage>
@@ -13,7 +14,7 @@ class IrcCommunication: public QObject
        Q_PROPERTY(QStringList channels READ channels WRITE setChannels)
        Q_PROPERTY(bool ssl WRITE setSsl)
 public:
-       IrcCommunication(QObject* parent=0);
+       IrcCommunication(std::map<std::string, std::string> config, QObject* parent=0);
        QStringList channels() { return mChannels; }
        void setChannels(QStringList c) { mChannels = c; }