Commit daa478ad authored by Christian Kandeler's avatar Christian Kandeler

Factor out license check.

Change-Id: Ifcaab7252239bde1affa8bc55ab38761c0f6e99f
Reviewed-by: 's avatarNikolai Kosjar <nikolai.kosjar@theqtcompany.com>
parent 313724ac
......@@ -28,6 +28,7 @@ HEADERS += \
clangstaticanalyzerdiagnosticmodel.h \
clangstaticanalyzerdiagnosticview.h \
clangstaticanalyzer_global.h \
clangstaticanalyzerlicensecheck.h \
clangstaticanalyzerlogfilereader.h \
clangstaticanalyzerplugin.h \
clangstaticanalyzerprojectsettings.h \
......
......@@ -30,6 +30,7 @@ QtcCommercialPlugin {
"clangstaticanalyzerdiagnosticmodel.h",
"clangstaticanalyzerdiagnosticview.cpp",
"clangstaticanalyzerdiagnosticview.h",
"clangstaticanalyzerlicensecheck.h",
"clangstaticanalyzerlogfilereader.cpp",
"clangstaticanalyzerlogfilereader.h",
"clangstaticanalyzerplugin.cpp",
......
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd
** All rights reserved.
** For any questions to The Qt Company, please use contact form at http://www.qt.io/contact-us
**
** This file is part of the Qt Enterprise ClangStaticAnalyzer Add-on.
**
** Licensees holding valid Qt Enterprise licenses may use this file in
** accordance with the Qt Enterprise License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company.
**
** If you have questions regarding the use of this file, please use
** contact form at http://www.qt.io/contact-us
**
****************************************************************************/
#ifndef CLANGSTATICANALYZERLICENSECHECK_H
#define CLANGSTATICANALYZERLICENSECHECK_H
#ifdef LICENSECHECKER
#include <extensionsystem/pluginmanager.h>
#include <licensechecker/licensecheckerplugin.h>
#endif
inline bool enterpriseFeaturesAvailable()
{
#ifdef LICENSECHECKER
LicenseChecker::LicenseCheckerPlugin *licenseChecker
= ExtensionSystem::PluginManager::getObject<LicenseChecker::LicenseCheckerPlugin>();
if (licenseChecker && licenseChecker->hasValidLicense()) {
if (licenseChecker->enterpriseFeatures())
return true;
} else {
qWarning() << "Invalid license, disabling Clang Static Analyzer";
}
return false;
#else // LICENSECHECKER
return true;
#endif
}
#endif // Include guard.
......@@ -20,6 +20,7 @@
#include "clangstaticanalyzerconfigwidget.h"
#include "clangstaticanalyzerconstants.h"
#include "clangstaticanalyzerlicensecheck.h"
#include "clangstaticanalyzerprojectsettingswidget.h"
#include "clangstaticanalyzerruncontrolfactory.h"
#include "clangstaticanalyzertool.h"
......@@ -38,12 +39,6 @@
#include <coreplugin/dialogs/ioptionspage.h>
#include <projectexplorer/projectpanelfactory.h>
#ifdef LICENSECHECKER
#include <licensechecker/licensecheckerplugin.h>
#endif
#include <extensionsystem/pluginmanager.h>
#include <QAction>
#include <QDebug>
#include <QMainWindow>
......@@ -117,21 +112,7 @@ bool ClangStaticAnalyzerPlugin::initialize(const QStringList &arguments, QString
panelFactory->setDisplayName(tr("Clang Static Analyzer Settings"));
panelFactory->setSimpleCreateWidgetFunction<ProjectSettingsWidget>(QIcon());
ProjectExplorer::ProjectPanelFactory::registerFactory(panelFactory);
#ifdef LICENSECHECKER
LicenseChecker::LicenseCheckerPlugin *licenseChecker
= ExtensionSystem::PluginManager::getObject<LicenseChecker::LicenseCheckerPlugin>();
if (licenseChecker && licenseChecker->hasValidLicense()) {
if (licenseChecker->enterpriseFeatures())
return initializeEnterpriseFeatures(arguments, errorString);
} else {
qWarning() << "Invalid license, disabling Clang Static Analyzer";
}
return true;
#else // LICENSECHECKER
return initializeEnterpriseFeatures(arguments, errorString);
#endif
}
bool ClangStaticAnalyzerPlugin::initializeEnterpriseFeatures(const QStringList &arguments,
......@@ -140,6 +121,9 @@ bool ClangStaticAnalyzerPlugin::initializeEnterpriseFeatures(const QStringList &
Q_UNUSED(arguments);
Q_UNUSED(errorString);
if (!enterpriseFeaturesAvailable())
return true;
auto tool = m_analyzerTool = new ClangStaticAnalyzerTool(this);
addAutoReleasedObject(new ClangStaticAnalyzerRunControlFactory(m_analyzerTool));
addAutoReleasedObject(new ClangStaticAnalyzerOptionsPage);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment