summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevron Rees <kevron.m.rees@intel.com>2013-09-09 10:33:51 -0700
committerKevron Rees <kevron.m.rees@intel.com>2013-09-09 10:33:51 -0700
commit8f6168fc167c8a9197b466842cef6a632d463108 (patch)
treec4810e17c410c1d7e9c32b7fcc7f044c23ed688b
parenta6148f9168d0f1d2e67cefd128ddce9ae741fb23 (diff)
downloadautomotive-message-broker-8f6168fc167c8a9197b466842cef6a632d463108.tar.gz
updated bluemonkey irc abilities
-rw-r--r--CMakeLists.txt6
-rw-r--r--plugins/bluemonkey/CMakeLists.txt2
-rw-r--r--plugins/bluemonkey/irccoms.cpp71
-rw-r--r--plugins/bluemonkey/irccoms.h16
4 files changed, 44 insertions, 51 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 51efa454..8e428b83 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -80,7 +80,11 @@ if(qtmainloop)
message(STATUS "using Qt5")
set(QT_INCLUDE_DIRS ${Qt5Core_INCLUDE_DIRS})
set(QT_LIBRARIES ${Qt5Core_LIBRARIES})
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS} -mcmodel=large")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
+ if(CMAKE_SIZEOF_VOID_P MATCHES "8")
+ message(STATUS "can has 64bits")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcmodel=large")
+ endif(CMAKE_SIZEOF_VOID_P MATCHES "8")
add_definitions(${Qt5Core_DEFINITIONS})
else(Qt5Core_FOUND)
message(STATUS "using Qt4")
diff --git a/plugins/bluemonkey/CMakeLists.txt b/plugins/bluemonkey/CMakeLists.txt
index 23251d2e..ff045733 100644
--- a/plugins/bluemonkey/CMakeLists.txt
+++ b/plugins/bluemonkey/CMakeLists.txt
@@ -20,7 +20,7 @@ if(Qt5Core_FOUND)
endif(Qt5Core_FOUND)
set(CMAKE_AUTOMOC ON)
-set(communi_INCLUDE_DIRS /usr/include/qt4/Communi)
+set(communi_INCLUDE_DIRS /usr/include/qt5/Communi)
set(communi_LIBRARIES -lCommuni)
add_definitions(-DCOMMUNI_SHARED)
diff --git a/plugins/bluemonkey/irccoms.cpp b/plugins/bluemonkey/irccoms.cpp
index 1450c27c..55b95e86 100644
--- a/plugins/bluemonkey/irccoms.cpp
+++ b/plugins/bluemonkey/irccoms.cpp
@@ -3,35 +3,31 @@
#include <IrcCommand>
#include <IrcMessage>
#include <QSslSocket>
+#include <QSslError>
#include <QFile>
#include <QNetworkProxy>
#include <QTimer>
#include <QScriptEngine>
+#include <debugout.h>
#define foreach Q_FOREACH
IrcCommunication::IrcCommunication(std::map<std::string, std::string> config, QObject* parent)
- :QObject(parent)
+ :IrcSession(parent)
{
- session = new IrcSession(this);
- mSsl=false;
-
- QObject::connect(session, &IrcSession::connected, [this](){
- connectedChanged();
- connected();
+ QObject::connect(this, &IrcCommunication::connected, [this](){
announceDequeue();
+ connectedChanged(true);
});
- QObject::connect(session, &IrcSession::disconnected, [this](){
- connectedChanged();
- disconnected();
+ QObject::connect(this, &IrcCommunication::disconnected, [this](){
+ connectedChanged(false);
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*)));
+ QObject::connect(this,SIGNAL(socketError(QAbstractSocket::SocketError)),this,SLOT(socketError(QAbstractSocket::SocketError)));
+ QObject::connect(this,SIGNAL(messageReceived(IrcMessage*)),this,SLOT(onMessageReceived(IrcMessage*)));
QScriptEngine *engine = new QScriptEngine(this);
@@ -43,7 +39,7 @@ IrcCommunication::IrcCommunication(std::map<std::string, std::string> config, QO
QFile file(str);
if(!file.open(QIODevice::ReadOnly))
{
- qDebug()<<"failed to open irc config file: "<<str;
+ DebugOut(DebugOut::Error)<<"failed to open irc config file: "<<str.toStdString()<<endl;
return;
}
@@ -51,13 +47,10 @@ IrcCommunication::IrcCommunication(std::map<std::string, std::string> config, QO
file.close();
- engine->evaluate(script);
+ QScriptValue response = engine->evaluate(script);
-}
+ DebugOut()<<response.toString().toStdString()<<endl;
-bool IrcCommunication::isConnected()
-{
- return session->isConnected();
}
void IrcCommunication::announceDequeue()
@@ -84,20 +77,20 @@ void IrcCommunication::announce(QString s)
IrcCommand command;
command.setType(IrcCommand::Message);
command.setParameters(QStringList()<<channel<<s);
- session->sendCommand(&command);
+ sendCommand(&command);
}
}
void IrcCommunication::respond(QString target, QString s)
{
IrcCommand *command = IrcCommand::createMessage(target,s);
- session->sendCommand(command);
+ sendCommand(command);
delete command;
}
-void IrcCommunication::messageReceived(IrcMessage *msg)
+void IrcCommunication::onMessageReceived(IrcMessage *msg)
{
qDebug()<<"message received "<<msg->type()<<" prefix: "<<msg->sender().prefix()<<" params:"<<msg->parameters();
@@ -116,11 +109,11 @@ void IrcCommunication::messageReceived(IrcMessage *msg)
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);
+ setHost(host);
+ setPort(port);
+ setUserName(user);
+ setNickName(nick);
+ setRealName(nick);
if(!proxy.isEmpty())
{
@@ -141,13 +134,15 @@ void IrcCommunication::connect(QString host, int port, QString proxy, QString us
}
qDebug()<<"opening irc session";
- session->open();
+ open();
}
void IrcCommunication::setSsl(bool use)
{
if(use)
- session->setSocket(new QSslSocket(this));
+ {
+ setSecure(true);
+ }
}
void IrcCommunication::join(QString channel)
@@ -158,26 +153,26 @@ void IrcCommunication::join(QString channel)
IrcCommand command;
command.setType(IrcCommand::Join);
command.setParameters(QStringList()<<channel);
- session->sendCommand(&command);
+ sendCommand(&command);
}
void IrcCommunication::reconnect()
{
- if(session->socket()->state() == QAbstractSocket::ConnectingState)
+ if(socket()->state() == QAbstractSocket::ConnectingState)
QTimer::singleShot(5000,this,SLOT(reconnect()));
else
- QTimer::singleShot(5000,session,SLOT(open()));
+ QTimer::singleShot(5000,this,SLOT(open()));
}
-/*void IrcCommunication::sslError(QList<QSslError>)
+void IrcCommunication::sslError(QList<QSslError> &)
{
qDebug()<<"some ssl errors!! trying to ignore them";
- QSslSocket* socket = qobject_cast<QSslSocket*>(session->socket());
- if(socket)
+ QSslSocket* sock = qobject_cast<QSslSocket*>(socket());
+ if(sock)
{
- socket->ignoreSslErrors();
+ sock->ignoreSslErrors();
}
-}*/
+}
void IrcCommunication::socketError(QAbstractSocket::SocketError error)
{
@@ -188,5 +183,5 @@ void IrcCommunication::socketError(QAbstractSocket::SocketError error)
void IrcCommunication::setIgnoreInvalidCert(bool ignore)
{
if(ignore)
- QObject::connect(session->socket(),SIGNAL(),this,SLOT(sslError(QList<QSslError>)));
+ QObject::connect(socket(),SIGNAL(sslErrors(QList<QSslError>&)),this,SLOT(sslError(QList<QSslError>&)));
}
diff --git a/plugins/bluemonkey/irccoms.h b/plugins/bluemonkey/irccoms.h
index 20f19942..261d016b 100644
--- a/plugins/bluemonkey/irccoms.h
+++ b/plugins/bluemonkey/irccoms.h
@@ -3,23 +3,23 @@
#include <QObject>
#include <QVariant>
#include <QStringList>
+#include <QSslError>
#include <map>
+#include <QAbstractSocket>
#include <IrcSession>
#include <IrcMessage>
-class IrcCommunication: public QObject
+class IrcCommunication: public IrcSession
{
Q_OBJECT
Q_PROPERTY(QStringList channels READ channels WRITE setChannels)
Q_PROPERTY(bool ssl WRITE setSsl)
- Q_PROPERTY(bool isConnected READ isConnected NOTIFY connectedChanged)
public:
IrcCommunication(std::map<std::string, std::string> config, QObject* parent=0);
QStringList channels() { return mChannels; }
void setChannels(QStringList c) { mChannels = c; }
- bool isConnected();
void announceDequeue();
public Q_SLOTS:
@@ -33,22 +33,16 @@ public Q_SLOTS:
void reconnect();
private Q_SLOTS:
- void messageReceived(IrcMessage*);
-// void sslError(QList<QSslError>);
+ void onMessageReceived(IrcMessage*);
+ void sslError(QList<QSslError> &);
void socketError(QAbstractSocket::SocketError);
Q_SIGNALS:
void message(QString sender, QString prefix, QString codes);
- void connecting();
- void connected();
- void disconnected();
- void connectedChanged();
private:
- bool mSsl;
QStringList announceQueue;
QStringList mChannels;
- IrcSession *session;
};
#endif // COMMUNICATION_H