logic: Rewrote license checking logic for trial and app merge
This commit is contained in:
+13
-4
@@ -5,7 +5,6 @@
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/logging/LogManager.h"
|
||||
#include "utility/messaging/MessageQueue.h"
|
||||
#include "utility/messaging/type/MessageDispatchWhenLicenseValid.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/messaging/type/MessageShowStartScreen.h"
|
||||
#include "utility/scheduling/TaskScheduler.h"
|
||||
@@ -20,7 +19,6 @@
|
||||
#include "component/view/MainView.h"
|
||||
#include "component/view/ViewFactory.h"
|
||||
#include "data/StorageCache.h"
|
||||
#include "isTrial.h"
|
||||
#include "LicenseChecker.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "settings/ColorScheme.h"
|
||||
@@ -46,10 +44,10 @@ void Application::createInstance(
|
||||
s_instance->m_mainView = viewFactory->createMainView();
|
||||
s_instance->m_mainView->setTitle("Coati");
|
||||
|
||||
MessageDispatchWhenLicenseValid(std::make_shared<MessageShowStartScreen>()).dispatch();
|
||||
|
||||
s_instance->m_componentManager->setup(s_instance->m_mainView.get());
|
||||
s_instance->m_mainView->loadLayout();
|
||||
|
||||
MessageShowStartScreen().dispatch();
|
||||
}
|
||||
|
||||
if (networkFactory != nullptr)
|
||||
@@ -107,6 +105,7 @@ std::shared_ptr<Application> Application::s_instance;
|
||||
|
||||
Application::Application(bool withGUI)
|
||||
: m_hasGUI(withGUI)
|
||||
, m_isInTrial(false)
|
||||
{
|
||||
LicenseChecker::createInstance();
|
||||
}
|
||||
@@ -151,6 +150,11 @@ void Application::setTitle(const std::string& title)
|
||||
m_mainView->setTitle(title);
|
||||
}
|
||||
|
||||
bool Application::isInTrial() const
|
||||
{
|
||||
return m_isInTrial;
|
||||
}
|
||||
|
||||
void Application::createAndLoadProject(const FilePath& projectSettingsFilePath)
|
||||
{
|
||||
MessageStatus("Loading Project: " + projectSettingsFilePath.str(), false, true).dispatch();
|
||||
@@ -210,6 +214,11 @@ void Application::handleMessage(MessageActivateWindow* message)
|
||||
}
|
||||
}
|
||||
|
||||
void Application::handleMessage(MessageEnteredLicense* message)
|
||||
{
|
||||
m_isInTrial = false;
|
||||
}
|
||||
|
||||
void Application::handleMessage(MessageFinishedParsing* message)
|
||||
{
|
||||
m_project->logStats();
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "component/ComponentManager.h"
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageActivateWindow.h"
|
||||
#include "utility/messaging/type/MessageEnteredLicense.h"
|
||||
#include "utility/messaging/type/MessageFinishedParsing.h"
|
||||
#include "utility/messaging/type/MessageLoadProject.h"
|
||||
#include "utility/messaging/type/MessageRefresh.h"
|
||||
@@ -24,6 +25,7 @@ class ProjectFactoryModule;
|
||||
|
||||
class Application
|
||||
: public MessageListener<MessageActivateWindow>
|
||||
, public MessageListener<MessageEnteredLicense>
|
||||
, public MessageListener<MessageFinishedParsing>
|
||||
, public MessageListener<MessageLoadProject>
|
||||
, public MessageListener<MessageRefresh>
|
||||
@@ -52,12 +54,15 @@ public:
|
||||
|
||||
void setTitle(const std::string& title);
|
||||
|
||||
bool isInTrial() const;
|
||||
|
||||
private:
|
||||
static std::shared_ptr<Application> s_instance;
|
||||
|
||||
Application(bool withGUI=true);
|
||||
|
||||
virtual void handleMessage(MessageActivateWindow* message);
|
||||
virtual void handleMessage(MessageEnteredLicense* message);
|
||||
virtual void handleMessage(MessageFinishedParsing* message);
|
||||
virtual void handleMessage(MessageLoadProject* message);
|
||||
virtual void handleMessage(MessageRefresh* message);
|
||||
@@ -78,6 +83,8 @@ private:
|
||||
std::shared_ptr<ComponentManager> m_componentManager;
|
||||
|
||||
std::shared_ptr<IDECommunicationController> m_ideCommunicationController;
|
||||
|
||||
bool m_isInTrial;
|
||||
};
|
||||
|
||||
#endif // APPLICATION_H
|
||||
|
||||
@@ -366,7 +366,6 @@ add_files(
|
||||
|
||||
Application.cpp
|
||||
Application.h
|
||||
isTrial.h
|
||||
LicenseChecker.cpp
|
||||
LicenseChecker.h
|
||||
Project.cpp
|
||||
|
||||
+15
-19
@@ -4,7 +4,6 @@
|
||||
#include "utility/messaging/type/MessageForceEnterLicense.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
|
||||
#include "isTrial.h"
|
||||
#include "License.h"
|
||||
#include "PublicKey.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
@@ -118,29 +117,26 @@ LicenseChecker::LicenseChecker()
|
||||
|
||||
void LicenseChecker::handleMessage(MessageDispatchWhenLicenseValid* message)
|
||||
{
|
||||
if (!isTrial())
|
||||
MessageStatus("preparing...", false, true).dispatch();
|
||||
|
||||
LicenseState state = checkCurrentLicense();
|
||||
|
||||
MessageStatus("ready").dispatch();
|
||||
|
||||
if (state == LICENSE_VALID || message->allowTrial)
|
||||
{
|
||||
MessageStatus("preparing...", false, true).dispatch();
|
||||
message->content->dispatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pendingMessage = message->content;
|
||||
|
||||
LicenseState state = checkCurrentLicense();
|
||||
|
||||
MessageStatus("ready").dispatch();
|
||||
|
||||
if (state != LICENSE_VALID)
|
||||
if (!m_forcedLicenseEntering)
|
||||
{
|
||||
m_pendingMessage = message->content;
|
||||
|
||||
if (!m_forcedLicenseEntering)
|
||||
{
|
||||
m_forcedLicenseEntering = true;
|
||||
MessageForceEnterLicense(state == LICENSE_EXPIRED).dispatch();
|
||||
}
|
||||
|
||||
return;
|
||||
m_forcedLicenseEntering = true;
|
||||
MessageForceEnterLicense(state == LICENSE_EXPIRED).dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
message->content->dispatch();
|
||||
}
|
||||
|
||||
void LicenseChecker::handleMessage(MessageEnteredLicense* message)
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#define LICENSE_CHECKER_H
|
||||
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageEnteredLicense.h"
|
||||
#include "utility/messaging/type/MessageDispatchWhenLicenseValid.h"
|
||||
#include "utility/messaging/type/MessageEnteredLicense.h"
|
||||
|
||||
class License;
|
||||
|
||||
|
||||
+1
-2
@@ -28,7 +28,6 @@
|
||||
#include "Application.h"
|
||||
#include "CxxProject.h"
|
||||
#include "JavaProject.h"
|
||||
#include "isTrial.h"
|
||||
|
||||
Project::~Project()
|
||||
{
|
||||
@@ -86,7 +85,7 @@ bool Project::refresh(bool forceRefresh)
|
||||
}
|
||||
}
|
||||
|
||||
if (forceRefresh && question.size() && Application::getInstance()->hasGUI() && !isTrial())
|
||||
if (forceRefresh && question.size() && Application::getInstance()->hasGUI())
|
||||
{
|
||||
std::vector<std::string> options;
|
||||
options.push_back("Yes");
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#ifndef IS_TRIAL_H
|
||||
#define IS_TRIAL_H
|
||||
|
||||
bool isTrial();
|
||||
|
||||
#endif // IS_TRIAL_H
|
||||
@@ -7,8 +7,9 @@ class MessageDispatchWhenLicenseValid
|
||||
: public Message<MessageDispatchWhenLicenseValid>
|
||||
{
|
||||
public:
|
||||
MessageDispatchWhenLicenseValid(std::shared_ptr<MessageBase> content)
|
||||
MessageDispatchWhenLicenseValid(std::shared_ptr<MessageBase> content, bool allowTrial = false)
|
||||
: content(content)
|
||||
, allowTrial(allowTrial)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -18,6 +19,7 @@ public:
|
||||
}
|
||||
|
||||
std::shared_ptr<MessageBase> content;
|
||||
const bool allowTrial;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_DISPATCH_WHEN_LICENSE_VALID_H
|
||||
|
||||
Reference in New Issue
Block a user