[bluemonkey] irc settings configurable
authorKevron Rees <tripzero.kev@gmail.com>
Sat, 8 Jun 2013 00:58:25 +0000 (17:58 -0700)
committerKevron Rees <tripzero.kev@gmail.com>
Sat, 8 Jun 2013 00:58:25 +0000 (17:58 -0700)
examples/bluemonkey/bluemonkeyconfig
examples/bluemonkey/ircSettings.js [new file with mode: 0644]
plugins/bluemonkey/bluemonkey.cpp
plugins/bluemonkey/irccoms.cpp
plugins/dbus/CMakeLists.txt

index 5f840b9..c7dc9d3 100644 (file)
@@ -3,17 +3,13 @@
 
        "sources" : [ 
                {
-                       "name" : "ExampleSouce",
-                       "path" : "/usr/lib/automotive-message-broker/examplesourceplugin.so"
+                       "name" : "Database",
+                        "path" : "/usr/lib/automotive-message-broker/databasesinkplugin.so",
+                        "properties" : "{ 'properties' : ['VehicleSpeed','EngineSpeed'] }"             
                }
        ],
        "sinks": [
                {
-                       "name" : "Database",
-                       "path" : "/usr/lib/automotive-message-broker/databasesinkplugin.so",
-                       "properties" : "{ 'properties' : ['VehicleSpeed','EngineSpeed'] }"
-               },
-               {
                        "name" : "Bluemonkey Sink",
                        "path" : "/usr/lib/automotive-message-broker/bluemonkeyplugin.so"
                }
diff --git a/examples/bluemonkey/ircSettings.js b/examples/bluemonkey/ircSettings.js
new file mode 100644 (file)
index 0000000..06439d3
--- /dev/null
@@ -0,0 +1,26 @@
+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 6dd2670..0bd0d79 100644 (file)
@@ -74,11 +74,6 @@ QVariant gvariantToQVariant(GVariant *value)
 BluemonkeySink::BluemonkeySink(AbstractRoutingEngine* e, map<string, string> config): QObject(0), AbstractSink(e, config), engine(nullptr)
 {
        irc = new IrcCommunication(this);
-       irc->connect("chat.freenode.com",8001,"","tripzero","bluemonkey","");
-       connect(irc,&IrcCommunication::connected, [&]() {
-               irc->join("#linuxice");
-               irc->join("#bluemonkey");
-       });
 
        reloadEngine();
 
index a32358a..51c5360 100644 (file)
@@ -6,6 +6,7 @@
 #include <QFile>
 #include <QNetworkProxy>
 #include <QTimer>
+#include <QScriptEngine>
 
 #define foreach Q_FOREACH
 
@@ -22,6 +23,26 @@ IrcCommunication::IrcCommunication(QObject* parent)
        QObject::connect(session,SIGNAL(connecting()),this,SIGNAL(connecting()));
        QObject::connect(session,SIGNAL(messageReceived(IrcMessage*)),this,SLOT(messageReceived(IrcMessage*)));
 
+       QScriptEngine *engine = new QScriptEngine(this);
+
+       QScriptValue eventEngineValue = engine->newQObject(this);
+       engine->globalObject().setProperty("irc", eventEngineValue);
+
+       QString str = "ircSettings.js";
+
+       QFile file(str);
+       if(!file.open(QIODevice::ReadOnly))
+       {
+               qDebug()<<"failed to open config file: "<<str;
+               return;
+       }
+
+       QString script = file.readAll();
+
+       file.close();
+
+       engine->evaluate(script);
+
 }
 
 void IrcCommunication::announce(QString s)
index ee0ee7b..cc90a75 100644 (file)
@@ -15,6 +15,6 @@ target_link_libraries(dbussinkplugin amb -L${CMAKE_CURRENT_BINARY_DIR}/lib ${lin
 install (TARGETS dbussinkplugin LIBRARY DESTINATION lib${LIB_SUFFIX}/automotive-message-broker)
 install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/amb.conf DESTINATION /etc/dbus-1/system.d )
 
-add_custom_target(idl COMMAND c++2idl ${dbussinkplugin_headers} > ${CMAKE_CURRENT_SOURCE_DIR}/amb.idl WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+#add_custom_target(idl COMMAND c++2idl ${dbussinkplugin_headers} > ${CMAKE_CURRENT_SOURCE_DIR}/amb.idl WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
 
 add_subdirectory(amb-qt)