logic: network port option
Added options to Coati and VS plugin to set network ports
This commit is contained in:
@@ -6,7 +6,12 @@ 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()
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "QtTcpWrapper.h"
|
||||
|
||||
#include "component/controller/IDECommunicationController.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
class StorageAccess;
|
||||
|
||||
|
||||
@@ -2,10 +2,15 @@
|
||||
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
QtTcpWrapper::QtTcpWrapper(QObject* parent, const std::string& ip, const quint16 port)
|
||||
QtTcpWrapper::QtTcpWrapper(QObject* parent, const std::string& ip, const quint16 serverPort, const quint16 clientPort)
|
||||
: QObject(parent)
|
||||
, m_port(port)
|
||||
, m_serverPort(serverPort)
|
||||
, m_clientPort(clientPort)
|
||||
, m_ip(ip)
|
||||
{
|
||||
}
|
||||
|
||||
void QtTcpWrapper::startListening()
|
||||
{
|
||||
QHostAddress address(m_ip.c_str());
|
||||
|
||||
@@ -13,7 +18,7 @@ QtTcpWrapper::QtTcpWrapper(QObject* parent, const std::string& ip, const quint16
|
||||
|
||||
connect(m_tcpServer, SIGNAL(newConnection()), this, SLOT(acceptConnection()));
|
||||
|
||||
if (!m_tcpServer->listen(QHostAddress::LocalHost, m_port))
|
||||
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.");
|
||||
}
|
||||
@@ -54,6 +59,26 @@ void QtTcpWrapper::setReadCallback(const std::function<void(const std::string&)>
|
||||
m_readCallback = callback;
|
||||
}
|
||||
|
||||
quint16 QtTcpWrapper::getServerPort() const
|
||||
{
|
||||
return m_serverPort;
|
||||
}
|
||||
|
||||
void QtTcpWrapper::setServerPort(const quint16 serverPort)
|
||||
{
|
||||
m_serverPort = serverPort;
|
||||
}
|
||||
|
||||
quint16 QtTcpWrapper::getClientPort() const
|
||||
{
|
||||
return m_clientPort;
|
||||
}
|
||||
|
||||
void QtTcpWrapper::setClientPort(const quint16 clientPort)
|
||||
{
|
||||
m_clientPort = clientPort;
|
||||
}
|
||||
|
||||
void QtTcpWrapper::acceptConnection()
|
||||
{
|
||||
m_tcpClient = m_tcpServer->nextPendingConnection();
|
||||
|
||||
@@ -13,13 +13,21 @@ class QtTcpWrapper : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtTcpWrapper(QObject* parent, const std::string& ip = "127.0.0.1", const quint16 port = 6667);
|
||||
QtTcpWrapper(QObject* parent, const std::string& ip = "127.0.0.1", const quint16 serverPort = 6667, const quint16 clientPort = 6666);
|
||||
~QtTcpWrapper();
|
||||
|
||||
void startListening();
|
||||
|
||||
void sendMessage(const std::string& message) const;
|
||||
|
||||
void setReadCallback(const std::function<void(const std::string&)>& callback);
|
||||
|
||||
quint16 getServerPort() const;
|
||||
void setServerPort(const quint16 serverPort);
|
||||
|
||||
quint16 getClientPort() const;
|
||||
void setClientPort(const quint16 clientPort);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
@@ -27,7 +35,8 @@ public slots:
|
||||
void startRead();
|
||||
|
||||
private:
|
||||
quint16 m_port;
|
||||
quint16 m_serverPort;
|
||||
quint16 m_clientPort;
|
||||
std::string m_ip;
|
||||
|
||||
std::function<void(const std::string&)> m_readCallback;
|
||||
|
||||
@@ -115,6 +115,7 @@ std::vector<FilePath> ApplicationSettings::getRecentProjects() const
|
||||
{
|
||||
std::vector<FilePath> recentProjects;
|
||||
std::vector<FilePath> loadedRecentProjects = getPathValues("user/recent_projects/recent_project");
|
||||
|
||||
for (FilePath project: loadedRecentProjects)
|
||||
{
|
||||
if (project.exists())
|
||||
@@ -139,3 +140,23 @@ void ApplicationSettings::setUserHasSeenSettings(bool hasSeenSettings)
|
||||
{
|
||||
setValue<bool>("user/has_seen_settings", hasSeenSettings);
|
||||
}
|
||||
|
||||
int ApplicationSettings::getPluginPort() const
|
||||
{
|
||||
return getValue<int>("network/plugin_port", 6666);
|
||||
}
|
||||
|
||||
void ApplicationSettings::setPluginPort(const int pluginPort)
|
||||
{
|
||||
setValue<int>("network/plugin_port", pluginPort);
|
||||
}
|
||||
|
||||
int ApplicationSettings::getCoatiPort() const
|
||||
{
|
||||
return getValue<int>("network/coati_port", 6667);
|
||||
}
|
||||
|
||||
void ApplicationSettings::setCoatiPort(const int coatiPort)
|
||||
{
|
||||
setValue<int>("network/coati_port", coatiPort);
|
||||
}
|
||||
@@ -55,6 +55,13 @@ public:
|
||||
std::vector<FilePath> getRecentProjects() const;
|
||||
bool setRecentProjects(const std::vector<FilePath>& recentProjects);
|
||||
|
||||
// network
|
||||
int getPluginPort() const;
|
||||
void setPluginPort(const int pluginPort);
|
||||
|
||||
int getCoatiPort() const;
|
||||
void setCoatiPort(const int coatiPort);
|
||||
|
||||
private:
|
||||
ApplicationSettings();
|
||||
ApplicationSettings(const ApplicationSettings&);
|
||||
|
||||
Reference in New Issue
Block a user