ui: Prevent network message handling without valid licence

Message by the ide com. controller are now caught by the licence checker to prevent them from causing trouble when waiting for the licence.

bug id = 45
This commit is contained in:
Manuel Dobusch
2016-03-02 18:50:20 +01:00
parent 612e12b35f
commit 8b4b4bb027
4 changed files with 235 additions and 1 deletions
+34
View File
@@ -2,8 +2,10 @@
#define LICENSE_CHECKER_H
#include "utility/messaging/MessageListener.h"
#include "utility/messaging/type/MessageActivateTokenLocations.h"
#include "utility/messaging/type/MessageEnteredLicense.h"
#include "utility/messaging/type/MessageLoadProject.h"
#include "utility/messaging/type/MessageProjectNew.h"
#include "utility/messaging/type/MessageStatus.h"
#include "License.h"
@@ -15,6 +17,8 @@
class LicenseChecker
: public MessageListener<MessageEnteredLicense>
, public MessageListener<MessageLoadProject>
, public MessageListener<MessageProjectNew>
, public MessageListener<MessageActivateTokenLocations>
{
public:
LicenseChecker()
@@ -59,6 +63,36 @@ private:
}
}
void handleMessage(MessageProjectNew* message)
{
if (!checkLicenseString())
{
m_resendMessage = std::make_shared<MessageProjectNew>(*message);
message->cancel();
if (!m_forcedLicenseEntering)
{
m_app->showLicenseScreen();
m_forcedLicenseEntering = true;
}
}
}
void handleMessage(MessageActivateTokenLocations* message)
{
if (!checkLicenseString())
{
m_resendMessage = std::make_shared<MessageActivateTokenLocations>(*message);
message->cancel();
if (!m_forcedLicenseEntering)
{
m_app->showLicenseScreen();
m_forcedLicenseEntering = true;
}
}
}
inline bool checkLicenseString()
{
MessageStatus("preparing...", false, true).dispatch();
@@ -15,6 +15,7 @@
IDECommunicationController::IDECommunicationController(StorageAccess* storageAccess)
: m_storageAccess(storageAccess)
, m_enabled(true)
{
}
@@ -24,6 +25,11 @@ IDECommunicationController::~IDECommunicationController()
void IDECommunicationController::handleIncomingMessage(const std::string& message)
{
if (m_enabled == false)
{
return;
}
NetworkProtocolHelper::MESSAGE_TYPE type = NetworkProtocolHelper::getMessageType(message);
if (type == NetworkProtocolHelper::MESSAGE_TYPE::UNKNOWN)
@@ -40,6 +46,16 @@ void IDECommunicationController::handleIncomingMessage(const std::string& messag
}
}
bool IDECommunicationController::getEnabled() const
{
return m_enabled;
}
void IDECommunicationController::setEnabled(const bool enabled)
{
m_enabled = enabled;
}
void IDECommunicationController::handleSetActiveTokenMessage(const NetworkProtocolHelper::SetActiveTokenMessage& message)
{
if (message.valid)
@@ -22,6 +22,9 @@ public:
void handleIncomingMessage(const std::string& message);
bool getEnabled() const;
void setEnabled(const bool enabled);
private:
void handleSetActiveTokenMessage(const NetworkProtocolHelper::SetActiveTokenMessage& message);
void handleCreateProjectMessage(const NetworkProtocolHelper::CreateProjectMessage& message);
@@ -30,6 +33,8 @@ private:
virtual void sendMessage(const std::string& message) const = 0;
StorageAccess* m_storageAccess;
bool m_enabled;
};
#endif // IDE_COMMUNICATION_CONTROLLER_H