ui: Added plugin ports to preferences

bug id = 145
This commit is contained in:
Eberhard Graether
2016-08-26 14:41:39 +02:00
parent 401c23f572
commit ca0a1ffb89
12 changed files with 134 additions and 19 deletions
@@ -6,17 +6,35 @@ QtIDECommunicationController::QtIDECommunicationController(QObject* parent, Stor
: IDECommunicationController(storageAccess)
, m_tcpWrapper(parent)
{
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
m_tcpWrapper.setReadCallback(std::bind(&QtIDECommunicationController::handleIncomingMessage, this, std::placeholders::_1));
m_tcpWrapper.setServerPort(appSettings->getCoatiPort());
m_tcpWrapper.setClientPort(appSettings->getPluginPort());
m_tcpWrapper.startListening();
}
QtIDECommunicationController::~QtIDECommunicationController()
{}
void QtIDECommunicationController::startListening()
{
m_onQtThread(
[=]()
{
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
m_tcpWrapper.setServerPort(appSettings->getCoatiPort());
m_tcpWrapper.setClientPort(appSettings->getPluginPort());
m_tcpWrapper.startListening();
}
);
}
void QtIDECommunicationController::stopListening()
{
m_onQtThread(
[=]()
{
m_tcpWrapper.stopListening();
}
);
}
bool QtIDECommunicationController::isListening() const
{
return m_tcpWrapper.isListening();
@@ -25,4 +43,4 @@ bool QtIDECommunicationController::isListening() const
void QtIDECommunicationController::sendMessage(const std::string& message) const
{
m_tcpWrapper.sendMessage(message);
}
}
@@ -6,6 +6,7 @@
#include "QtTcpWrapper.h"
#include "component/controller/IDECommunicationController.h"
#include "qt/utility/QtThreadedFunctor.h"
#include "settings/ApplicationSettings.h"
class StorageAccess;
@@ -17,12 +18,17 @@ public:
QtIDECommunicationController(QObject* parent, StorageAccess* storageAccess);
~QtIDECommunicationController();
virtual void startListening();
virtual void stopListening();
virtual bool isListening() const;
private:
virtual void sendMessage(const std::string& message) const;
QtTcpWrapper m_tcpWrapper;
QtThreadedLambdaFunctor m_onQtThread;
};
#endif // QT_IDE_COMMUNICATION_CONTROLLER
#endif // QT_IDE_COMMUNICATION_CONTROLLER
+11 -4
View File
@@ -8,22 +8,29 @@ QtTcpWrapper::QtTcpWrapper(QObject* parent, const std::string& ip, const quint16
, m_clientPort(clientPort)
, m_ip(ip)
{
m_tcpServer = new QTcpServer(this);
connect(m_tcpServer, SIGNAL(newConnection()), this, SLOT(acceptConnection()));
}
void QtTcpWrapper::startListening()
{
QHostAddress address(m_ip.c_str());
m_tcpServer = new QTcpServer(this);
connect(m_tcpServer, SIGNAL(newConnection()), this, SLOT(acceptConnection()));
if (!m_tcpServer->listen(QHostAddress::LocalHost, m_serverPort))
{
LOG_ERROR_STREAM(<< "TCP server failed to start with error: \"" + m_tcpServer->errorString().toStdString() + "\". Unable to listen for IDE plugin messages.");
}
}
void QtTcpWrapper::stopListening()
{
if (isListening())
{
m_tcpServer->close();
}
}
QtTcpWrapper::~QtTcpWrapper()
{
if (m_tcpServer != NULL)
+1
View File
@@ -17,6 +17,7 @@ public:
~QtTcpWrapper();
void startListening();
void stopListening();
void sendMessage(const std::string& message) const;