src: Removed everything license key related

* removed license check
* removed license from ApplicationSettings
* removed LicenseGenerator
* removed license tests
* removed lib_license
* removed dependency on Botan
* removed license generation in all scripts
This commit is contained in:
Eberhard Graether
2019-10-18 13:05:30 +02:00
parent 2cfce03f6e
commit 0d8e992bdf
61 changed files with 63 additions and 3639 deletions
+2
View File
@@ -680,4 +680,6 @@ add_files(
utility/utilityWindows.h
utility/utilityXml.cpp
utility/utilityXml.h
utility/Version.cpp
utility/Version.h
)
+1 -53
View File
@@ -7,7 +7,6 @@
#include "FileSystem.h"
#include "GraphViewStyle.h"
#include "IDECommunicationController.h"
#include "LicenseChecker.h"
#include "logging.h"
#include "LogManager.h"
#include "MainView.h"
@@ -42,8 +41,6 @@ void Application::createInstance(
bool hasGui = (viewFactory != nullptr);
Version::setApplicationVersion(version);
LicenseChecker::loadPublicKey();
LicenseChecker::setEncodeKey(AppPath::getAppPath().str());
if (hasGui)
{
@@ -128,7 +125,6 @@ void Application::loadStyle(const FilePath& colorSchemePath)
Application::Application(bool withGUI)
: m_hasGUI(withGUI)
, m_lastLicenseCheck(TimeStamp::now())
{
}
@@ -362,17 +358,6 @@ void Application::handleMessage(MessageWindowFocus* message)
{
m_updateChecker->checkUpdate();
}
if (!ApplicationSettings::getInstance()->getNonCommercialUse() && TimeStamp::now().deltaHours(m_lastLicenseCheck) > 1)
{
m_lastLicenseCheck = TimeStamp::now();
LicenseChecker::LicenseState state = LicenseChecker::checkCurrentLicense();
if (state != LicenseChecker::LicenseState::VALID)
{
m_mainView->forceEnterLicense(LicenseChecker::getLicenseErrorForState(state));
}
}
}
FilePath Application::migrateProjectSettings(const FilePath& projectSettingsFilePath) const
@@ -437,36 +422,11 @@ void Application::loadWindow(bool showStartWindow)
appSettings->save();
}
LicenseChecker::LicenseState state = LicenseChecker::LicenseState::VALID;
std::string licenseError;
if (!appSettings->getNonCommercialUse())
{
state = LicenseChecker::setCurrentLicenseStringEncoded(appSettings->getLicenseString());
licenseError = LicenseChecker::getLicenseErrorForState(state);
if (state == LicenseChecker::LicenseState::VALID)
{
MessageStatus(L"Found valid license key, unlocked application.").dispatch();
}
else if (state == LicenseChecker::LicenseState::EMPTY)
{
licenseError = "";
}
else if (state == LicenseChecker::LicenseState::MALFORMED)
{
licenseError = "Plese re-enter your license key.";
appSettings->setLicenseString("");
appSettings->save();
}
}
updateTitle();
bool showEula = (EULA_ACCEPT_REQUIRED && appSettings->getAcceptedEulaVersion() < EULA_VERSION);
bool enterLicense = (state != LicenseChecker::LicenseState::VALID);
m_mainView->loadWindow(showStartWindow, showEula, enterLicense, licenseError);
m_mainView->loadWindow(showStartWindow, showEula);
m_loadedWindow = true;
}
else if (!showStartWindow)
@@ -550,18 +510,6 @@ void Application::updateTitle()
{
std::wstring title = L"Sourcetrail";
switch (LicenseChecker::getCurrentLicenseType())
{
case LicenseType::TEST:
title += L" [test]";
break;
case LicenseType::NON_COMMERCIAL:
title += L" [non-commercial]";
break;
case LicenseType::COMMERCIAL:
break;
}
if (m_project)
{
FilePath projectPath = m_project->getProjectSettingsFilePath();
-3
View File
@@ -14,7 +14,6 @@
#include "MessageSwitchColorScheme.h"
#include "MessageWindowFocus.h"
#include "Project.h"
#include "TimeStamp.h"
class Bookmark;
class IDECommunicationController;
@@ -102,8 +101,6 @@ private:
std::shared_ptr<IDECommunicationController> m_ideCommunicationController;
std::shared_ptr<UpdateChecker> m_updateChecker;
TimeStamp m_lastLicenseCheck;
};
#endif // APPLICATION_H
+1 -2
View File
@@ -32,12 +32,11 @@ public:
virtual void refreshView() = 0;
virtual void loadWindow(bool showStartWindow, bool showEULA, bool enterLicense, std::string licenseError) = 0;
virtual void loadWindow(bool showStartWindow, bool showEULA) = 0;
virtual void hideStartScreen() = 0;
virtual void setTitle(const std::wstring& title) = 0;
virtual void activateWindow() = 0;
virtual void forceEnterLicense(std::string licenseError) = 0;
virtual void updateRecentProjectMenu() = 0;
-21
View File
@@ -1,7 +1,6 @@
#include "ApplicationSettings.h"
#include "AppPath.h"
#include "License.h"
#include "Logger.h"
#include "ResourcePaths.h"
#include "SettingsMigrator.h"
@@ -689,23 +688,3 @@ void ApplicationSettings::setControlsGraphZoomOnMouseWheel(bool zoomingDefault)
{
setValue<bool>("controls/graph_zoom_on_mouse_wheel", zoomingDefault);
}
std::string ApplicationSettings::getLicenseString() const
{
return getValue<std::string>("user/license/license", "");
}
void ApplicationSettings::setLicenseString(const std::string& licenseString)
{
setValue<std::string>("user/license/license", licenseString);
}
bool ApplicationSettings::getNonCommercialUse() const
{
return getValue<bool>("user/license/non_commercial_use", false);
}
void ApplicationSettings::setNonCommercialUse(bool nonCommercialUse)
{
setValue<bool>("user/license/non_commercial_use", nonCommercialUse);
}
-7
View File
@@ -193,13 +193,6 @@ public:
bool getControlsGraphZoomOnMouseWheel() const;
void setControlsGraphZoomOnMouseWheel(bool zoomingDefault);
// license
std::string getLicenseString() const;
void setLicenseString(const std::string& licenseString);
bool getNonCommercialUse() const;
void setNonCommercialUse(bool nonCommercialUse);
private:
ApplicationSettings(const ApplicationSettings&);
void operator=(const ApplicationSettings&);
+170
View File
@@ -0,0 +1,170 @@
#include "Version.h"
#include <vector>
#include <sstream>
namespace {
template <typename ContainerType>
ContainerType split(const std::string& str, const std::string& delimiter)
{
size_t pos = 0;
size_t oldPos = 0;
ContainerType c;
do
{
pos = str.find(delimiter, oldPos);
c.push_back(str.substr(oldPos, pos - oldPos));
oldPos = pos + delimiter.size();
}
while (pos != std::string::npos);
return c;
}
}
Version Version::s_version;
Version Version::fromString(const std::string& versionString)
{
try
{
Version version;
std::vector<std::string> parts = split<std::vector<std::string>>(versionString, ".");
if (!parts.empty())
{
version.m_year = std::stoi(parts[0]);
}
if (parts.size() > 1)
{
version.m_minorNumber = std::stoi(parts[1]);
}
if (parts.size() > 2)
{
std::vector<std::string> hashParts = split<std::vector<std::string>>(parts[2], "-");
if (!hashParts.empty())
{
version.m_commitNumber = std::stoi(hashParts[0]);
}
if (hashParts.size() > 1)
{
version.m_commitHash = hashParts[1];
}
}
return version;
}
catch (std::invalid_argument e)
{
// LOG_ERROR("Version string is invalid: " + versionString);
}
return Version();
}
void Version::setApplicationVersion(const Version& version)
{
s_version = version;
}
const Version& Version::getApplicationVersion()
{
return s_version;
}
Version::Version(int year, int minor, int commit, const std::string& hash)
: m_year(year)
, m_minorNumber(minor)
, m_commitNumber(commit)
, m_commitHash(hash)
{
}
bool Version::isEmpty() const
{
return m_year == 0 && m_minorNumber == 0 && m_commitNumber == 0;
}
bool Version::isValid() const
{
return (0 < m_minorNumber && m_minorNumber < 5 && m_year > 2016);
}
Version Version::toShortVersion() const
{
return Version(m_year, m_minorNumber);
}
std::string Version::toShortString() const
{
std::stringstream ss;
ss << m_year << '.' << m_minorNumber;
return ss.str();
}
std::string Version::toString() const
{
std::stringstream ss;
ss << m_year << '.' << m_minorNumber << '-' << m_commitNumber << '-' << m_commitHash;
return ss.str();
}
std::string Version::toDisplayString() const
{
return std::to_string(m_year) + '.' + std::to_string(m_minorNumber) + '.' + std::to_string(m_commitNumber);
}
std::wstring Version::toDisplayWString() const
{
return std::to_wstring(m_year) + L'.' + std::to_wstring(m_minorNumber) + L'.' + std::to_wstring(m_commitNumber);
}
bool Version::operator<(const Version& other) const
{
if (m_year != other.m_year)
{
return m_year < other.m_year;
}
else if (m_minorNumber != other.m_minorNumber)
{
return m_minorNumber < other.m_minorNumber;
}
else
{
return m_commitNumber < other.m_commitNumber;
}
}
bool Version::operator>(const Version& other) const
{
if (m_year != other.m_year)
{
return m_year > other.m_year;
}
else if (m_minorNumber != other.m_minorNumber)
{
return m_minorNumber > other.m_minorNumber;
}
else
{
return m_commitNumber > other.m_commitNumber;
}
}
bool Version::operator==(const Version& other) const
{
return m_year == other.m_year && m_minorNumber == other.m_minorNumber && m_commitNumber == other.m_commitNumber;
}
Version& Version::operator+=(const int& number)
{
int minor = this->m_minorNumber - 1 + number;
this->m_year += minor/4;
this->m_minorNumber = (minor%4) + 1;
return *this;
}
+41
View File
@@ -0,0 +1,41 @@
#ifndef VERSION_H
#define VERSION_H
#include <string>
class Version
{
public:
static Version fromString(const std::string& versionString);
static void setApplicationVersion(const Version& version);
static const Version& getApplicationVersion();
Version(int year = 0, int minor = 0, int commit = 0, const std::string& hash = "");
bool isEmpty() const;
bool isValid() const;
Version toShortVersion() const;
std::string toString() const;
std::string toShortString() const;
std::string toDisplayString() const;
std::wstring toDisplayWString() const;
bool operator<(const Version& other) const;
bool operator>(const Version& other) const;
bool operator==(const Version& other) const;
Version& operator+=(const int& number);
private:
static Version s_version;
int m_year;
int m_minorNumber;
int m_commitNumber;
std::string m_commitHash;
};
#endif // VERSION_H