logic: vs plugin upgrade

Updated documentation and removed obsolete plugin ui
This commit is contained in:
Manuel Dobusch
2016-11-29 14:06:02 +01:00
parent e1968eaaac
commit d24e5b5bbd
13 changed files with 279 additions and 11 deletions
+1
View File
@@ -276,6 +276,7 @@ add_files(
utility/messaging/type/MessageLoadProject.h
utility/messaging/type/MessageMoveIDECursor.h
utility/messaging/type/MessageNewErrors.h
utility/messaging/type/MessagePingReceived.h
utility/messaging/type/MessagePluginPortChange.h
utility/messaging/type/MessageProjectEdit.h
utility/messaging/type/MessageProjectNew.h
@@ -12,6 +12,7 @@
#include "utility/messaging/type/MessageProjectNew.h"
#include "utility/messaging/type/MessageStatus.h"
#include "utility/messaging/type/MessageActivateFile.h"
#include "utility/messaging/type/MessagePingReceived.h"
IDECommunicationController::IDECommunicationController(StorageAccess* storageAccess)
: m_storageAccess(storageAccess)
@@ -48,6 +49,10 @@ void IDECommunicationController::handleIncomingMessage(const std::string& messag
{
handleCreateCDBProjectMessage(NetworkProtocolHelper::parseCreateCDBProjectMessage(message));
}
else if (type == NetworkProtocolHelper::MESSAGE_TYPE::PING)
{
handlePing(NetworkProtocolHelper::parsePingMessage(message));
}
else
{
handleCreateProjectMessage(NetworkProtocolHelper::parseCreateProjectMessage(message));
@@ -152,8 +157,6 @@ void IDECommunicationController::handleCreateCDBProjectMessage(const NetworkProt
msg->setHeaderPaths(message.headerPaths);
msg->ideId = message.ideId;
bool foo = msg->fromCDB();
MessageDispatchWhenLicenseValid(msg).dispatch();
}
else
@@ -162,6 +165,32 @@ void IDECommunicationController::handleCreateCDBProjectMessage(const NetworkProt
}
}
void IDECommunicationController::handlePing(const NetworkProtocolHelper::PingMessage& message)
{
if (message.valid)
{
std::shared_ptr<MessagePingReceived> msg = std::make_shared<MessagePingReceived>();
msg->ideId = message.ideId;
std::string ideName = "unknown";
if (msg->ideId == "vs")
{
ideName = "Visual Studio";
}
// TODO: add the other ides
std::string message = ideName + " instance detected";
MessageStatus(message, false, false).dispatch();
MessageDispatchWhenLicenseValid(msg).dispatch();
}
else
{
LOG_ERROR_STREAM(<< "Can't handle ping, message is invalid");
}
}
void IDECommunicationController::handleMessage(MessageIDECreateCDB* message)
{
std::string networkMessage = NetworkProtocolHelper::buildCreateCDBMessage();
@@ -38,6 +38,7 @@ private:
void handleSetActiveTokenMessage(const NetworkProtocolHelper::SetActiveTokenMessage& message);
void handleCreateProjectMessage(const NetworkProtocolHelper::CreateProjectMessage& message);
void handleCreateCDBProjectMessage(const NetworkProtocolHelper::CreateCDBProjectMessage& message);
void handlePing(const NetworkProtocolHelper::PingMessage& message);
virtual void handleMessage(MessageIDECreateCDB* message);
virtual void handleMessage(MessageMoveIDECursor* message);
@@ -14,6 +14,7 @@ std::string NetworkProtocolHelper::m_endOfMessageToken = "<EOM>";
std::string NetworkProtocolHelper::m_createProjectPrefix = "createProject";
std::string NetworkProtocolHelper::m_createCDBProjectPrefix = "createCDBProject";
std::string NetworkProtocolHelper::m_createCDBPrefix = "createCDB";
std::string NetworkProtocolHelper::m_pingPrefix = "ping";
NetworkProtocolHelper::MESSAGE_TYPE NetworkProtocolHelper::getMessageType(const std::string& message)
{
@@ -33,6 +34,10 @@ NetworkProtocolHelper::MESSAGE_TYPE NetworkProtocolHelper::getMessageType(const
{
return MESSAGE_TYPE::CREATE_CDB_MESSAGE;
}
else if (subMessages[0] == m_pingPrefix)
{
return MESSAGE_TYPE::PING;
}
else
{
return MESSAGE_TYPE::UNKNOWN;
@@ -196,6 +201,48 @@ NetworkProtocolHelper::CreateCDBProjectMessage NetworkProtocolHelper::parseCreat
return networkMessage;
}
NetworkProtocolHelper::PingMessage NetworkProtocolHelper::parsePingMessage(const std::string& message)
{
std::vector<std::string> subMessages = divideMessage(message);
NetworkProtocolHelper::PingMessage pingMessage;
if (subMessages.size() > 0)
{
if (subMessages[0] == m_pingPrefix)
{
if (subMessages.size() < 2)
{
LOG_ERROR_STREAM(<< "Failed to parse PingMessage message, too few tokens");
}
else
{
std::string ideId = subMessages[1];
if (ideId.length() > 0)
{
std::string nonConstId = ideId;
boost::algorithm::to_lower(nonConstId);
pingMessage.ideId = ideId;
pingMessage.valid = true;
}
else
{
LOG_WARNING_STREAM(<< "Failed to parse ide ID string. Is " << ideId);
}
}
}
else
{
LOG_ERROR_STREAM(<< "Failed to parse message, invalid type token: " << subMessages[0] << ". Expected " << m_pingPrefix);
}
}
return pingMessage;
}
std::string NetworkProtocolHelper::buildSetIDECursorMessage(const std::string& fileLocation, const unsigned int row, const unsigned int column)
{
std::stringstream messageStream;
@@ -222,6 +269,18 @@ std::string NetworkProtocolHelper::buildCreateCDBMessage()
return messageStream.str();
}
std::string NetworkProtocolHelper::buildPingMessage()
{
std::stringstream messageStream;
messageStream << m_pingPrefix;
messageStream << m_divider;
messageStream << "coati";
messageStream << m_endOfMessageToken;
return messageStream.str();
}
std::vector<std::string> NetworkProtocolHelper::divideMessage(const std::string& message)
{
std::vector<std::string> result;
@@ -53,12 +53,25 @@ public:
bool valid;
};
struct PingMessage
{
public:
PingMessage()
: ideId("")
, valid(false)
{}
std::string ideId;
bool valid;
};
enum MESSAGE_TYPE
{
UNKNOWN = 0,
SET_ACTIVE_TOKEN,
CREATE_PROJECT,
CREATE_CDB_MESSAGE
CREATE_CDB_MESSAGE,
PING
};
static MESSAGE_TYPE getMessageType(const std::string& message);
@@ -66,9 +79,11 @@ public:
static SetActiveTokenMessage parseSetActiveTokenMessage(const std::string& message);
static CreateProjectMessage parseCreateProjectMessage(const std::string& message);
static CreateCDBProjectMessage parseCreateCDBProjectMessage(const std::string& message);
static PingMessage parsePingMessage(const std::string& message);
static std::string buildSetIDECursorMessage(const std::string& fileLocation, const unsigned int row, const unsigned int column);
static std::string buildCreateCDBMessage();
static std::string buildPingMessage();
private:
static std::vector<std::string> divideMessage(const std::string& message);
@@ -85,6 +100,7 @@ private:
static std::string m_createProjectPrefix;
static std::string m_createCDBProjectPrefix;
static std::string m_createCDBPrefix;
static std::string m_pingPrefix;
};
#endif // NETWORK_PROTOCOL_HELPER_H
@@ -0,0 +1,23 @@
#ifndef MESSAGE_PING_RECEIVED_H
#define MESSAGE_PING_RECEIVED_H
#include "utility/messaging/Message.h"
class MessagePingReceived
: public Message<MessagePingReceived>
{
public:
MessagePingReceived()
: ideId("")
{
}
static const std::string getStaticType()
{
return "MessagePingReceived";
}
std::string ideId;
};
#endif // MESSAGE_PING_RECEIVED_H