option(opencvlux_plugin "OpenCV Lux plugin" OFF)
option(gpsd_plugin "gpsd location plugin" OFF)
option(murphy_plugin "murphy policy framework plugin" OFF)
+option(bluemonkey_plugin "bluemonkey irc plugin" OFF)
if(opencvlux_plugin)
message(STATUS "OpenCV Lux plugin enabled")
add_subdirectory(opencvlux)
add_subdirectory(gpsd)
add_subdirectory(murphyplugin)
+add_subdirectory(bluemonkey)
--- /dev/null
+if(bluemonkey_plugin)
+
+
+FIND_PACKAGE(Qt4 COMPONENTS QtCore QtNetwork QtScript REQUIRED)
+include(${QT_USE_FILE})
+ADD_DEFINITIONS(${QT_DEFINITIONS})
+
+set(QT_USE_QSCRIPT TRUE)
+set(QT_USE_NETWORK TRUE)
+set(QT_DONT_USE_QTGUI TRUE)
+
+set(communi_INCLUDE_DIRS /usr/include/qt4/Communi)
+set(communi_LIBRARIES -lCommuni)
+add_definitions(-DCOMMUNI_SHARED)
+
+include_directories(${CMAKE_SOURCE_DIR}/lib ${include_dirs} ${communi_INCLUDE_DIRS})
+
+set(bluemonkeyplugin_headers bluemonkey.h irccoms.h)
+set(bluemonkeyplugin_sources bluemonkey.cpp irccoms.cpp)
+
+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)
+
+endif(bluemonkey_plugin)
--- /dev/null
+/*
+ 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 "bluemonkey.h"
+#include "abstractroutingengine.h"
+#include "debugout.h"
+
+#include <glib.h>
+
+
+extern "C" AbstractSinkManager * create(AbstractRoutingEngine* routingengine, map<string, string> config)
+{
+ return new BluemonkeySinkManager(routingengine, config);
+}
+
+BluemonkeySink::BluemonkeySink(AbstractRoutingEngine* engine, map<string, string> config): AbstractSink(engine, config)
+{
+
+}
+
+
+PropertyList BluemonkeySink::subscriptions()
+{
+
+}
+
+void BluemonkeySink::supportedChanged(PropertyList supportedProperties)
+{
+
+}
+
+void BluemonkeySink::propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, std::string uuid)
+{
+
+}
+
+std::string BluemonkeySink::uuid()
+{
+ return "bluemonkey";
+}
--- /dev/null
+/*
+ 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 BluemonkeySink_H
+#define BluemonkeySink_H
+
+#include "abstractsink.h"
+#include <QObject>
+
+class BluemonkeySink : public QObject, public AbstractSink
+{
+Q_OBJECT
+public:
+ BluemonkeySink(AbstractRoutingEngine* engine, map<string, string> config);
+ virtual PropertyList subscriptions();
+ virtual void supportedChanged(PropertyList supportedProperties);
+ virtual void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, std::string uuid);
+ virtual std::string uuid();
+};
+
+class BluemonkeySinkManager: public AbstractSinkManager
+{
+public:
+ BluemonkeySinkManager(AbstractRoutingEngine* engine, map<string, string> config)
+ :AbstractSinkManager(engine, config)
+ {
+ new BluemonkeySink(routingEngine, config);
+ }
+};
+
+#endif // BluemonkeySink_H
--- /dev/null
+#include "irccoms.h"
+#include <QtDebug>
+#include <IrcCommand>
+#include <IrcMessage>
+#include <QSslSocket>
+#include <QScriptEngine>
+#include <QFile>
+#include <QNetworkProxy>
+#include <QTimer>
+
+
+IrcCommunication::IrcCommunication(QObject* parent)
+ :QObject(parent)
+{
+ session = new IrcSession(this);
+ mSsl=false;
+
+ QObject::connect(session,SIGNAL(connected()),this,SIGNAL(connected()));
+ QObject::connect(session,SIGNAL(disconnected()),this,SIGNAL(disconnected()));
+ QObject::connect(session,SIGNAL(disconnected()),this,SLOT(reconnect()));
+ QObject::connect(session,SIGNAL(socketError(QAbstractSocket::SocketError)),this,SLOT(socketError(QAbstractSocket::SocketError)));
+ QObject::connect(session,SIGNAL(connecting()),this,SIGNAL(connecting()));
+ QObject::connect(session,SIGNAL(messageReceived(IrcMessage*)),this,SLOT(messageReceived(IrcMessage*)));
+
+}
+
+void IrcCommunication::announce(QString s)
+{
+ qDebug()<<"channels: "<<mChannels;
+ foreach(QString channel, mChannels)
+ {
+ qDebug()<<"sending "<<s<<" to channel: "<<channel;
+ IrcCommand command;
+ command.setType(IrcCommand::Message);
+ command.setParameters(QStringList()<<channel<<s);
+ session->sendCommand(&command);
+ }
+}
+
+void IrcCommunication::respond(QString target, QString s)
+{
+ IrcCommand command;
+ command.setType(IrcCommand::Message);
+ command.setParameters(QStringList()<<target<<s);
+ session->sendCommand(&command);
+}
+
+void IrcCommunication::messageReceived(IrcMessage *msg)
+{
+ qDebug()<<"message received "<<msg->type()<<" prefix: "<<msg->sender().prefix()<<" params:"<<msg->parameters();
+
+ if(msg->type() == IrcMessage::Private)
+ {
+ if(msg->parameters().count() > 1)
+ {
+ QString sender = msg->parameters().at(0);
+ QString m = msg->parameters().at(1);
+
+ message(sender,msg->sender().prefix(),m);
+ }
+
+ }
+}
+
+void IrcCommunication::connect(QString host, int port, QString proxy, QString user, QString nick, QString pass)
+{
+ session->setHost(host);
+ session->setPort(port);
+ session->setUserName(user);
+ session->setNickName(nick);
+ session->setRealName(nick);
+
+ if(!proxy.isEmpty())
+ {
+ if(!proxy.contains(":"))
+ {
+ qDebug("proxy format must be 'address:port'");
+ return;
+ }
+ QString host = proxy.split(":").at(0);
+ int port = proxy.split(":").at(1).toInt();
+
+ QNetworkProxy netproxy;
+ netproxy.setType(QNetworkProxy::Socks5Proxy);
+ netproxy.setHostName(host);
+ netproxy.setPort(port);
+
+ QNetworkProxy::setApplicationProxy(netproxy);
+ }
+
+ qDebug()<<"opening irc session";
+ session->open();
+}
+
+void IrcCommunication::setSsl(bool use)
+{
+ if(use)
+ session->setSocket(new QSslSocket(this));
+}
+
+void IrcCommunication::join(QString channel)
+{
+ if(!mChannels.contains(channel))
+ mChannels.append(channel);
+
+ IrcCommand command;
+ command.setType(IrcCommand::Join);
+ command.setParameters(QStringList()<<channel);
+ session->sendCommand(&command);
+}
+
+void IrcCommunication::reconnect()
+{
+ QTimer::singleShot(5000,session,SLOT(open()));
+}
+
+void IrcCommunication::sslError(QList<QSslError>)
+{
+ qDebug()<<"some ssl errors!! trying to ignore them";
+ QSslSocket* socket = qobject_cast<QSslSocket*>(session->socket());
+ if(socket)
+ {
+ socket->ignoreSslErrors();
+ }
+}
+
+void IrcCommunication::socketError(QAbstractSocket::SocketError error)
+{
+ qDebug()<<"Socket error. attempting to reconnect..."<<error;
+ reconnect();
+}
+
+void IrcCommunication::setIgnoreInvalidCert(bool ignore)
+{
+ if(ignore)
+ QObject::connect(session->socket(),SIGNAL(sslErrors(QList<QSslError>)),this,SLOT(sslError(QList<QSslError>)));
+}
--- /dev/null
+#ifndef COMMUNICATION_H
+#define COMMUNICATION_H
+#include <QObject>
+#include <QVariant>
+#include <QStringList>
+
+#include <QSslError>
+
+#include <IrcSession>
+#include <IrcMessage>
+
+class IrcCommunication: public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QStringList channels READ channels WRITE setChannels)
+ Q_PROPERTY(bool ssl WRITE setSsl)
+public:
+ IrcCommunication(QObject* parent=0);
+ QStringList channels() { return mChannels; }
+ void setChannels(QStringList c) { mChannels = c; }
+
+public slots:
+ void respond(QString target, QString msg);
+ void announce(QString);
+ void connect(QString host,int port, QString proxy, QString user, QString nick, QString pass);
+ void setSsl(bool use);
+ void setIgnoreInvalidCert(bool ignore);
+ void join(QString channel);
+
+ void reconnect();
+
+private slots:
+ void messageReceived(IrcMessage*);
+ void sslError(QList<QSslError>);
+ void socketError(QAbstractSocket::SocketError);
+
+signals:
+ void message(QString sender, QString prefix, QString codes);
+ void connecting();
+ void connected();
+ void disconnected();
+
+private:
+ bool mSsl;
+ QStringList mChannels;
+ IrcSession *session;
+};
+
+#endif // COMMUNICATION_H