summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTim Jenssen <tim.jenssen@digia.com>2013-03-12 15:10:15 +0100
committerTim Jenssen <tim.jenssen@digia.com>2013-03-12 15:10:15 +0100
commitde8d24fa6ccca3b201a8468d90631af7124c9c3c (patch)
treea9d6928741a6725a0c858108943247d301db777a /src
parent887efb810f4773ed0b4cf8c8cc3e53ec846c8146 (diff)
parent9e4194a90026cfc9fce2d59256813193e54859d6 (diff)
Merge remote-tracking branch 'origin/1.3'
Diffstat (limited to 'src')
-rw-r--r--src/libs/installer/applyproductkeyoperation.cpp66
-rw-r--r--src/libs/installer/applyproductkeyoperation.h51
-rw-r--r--src/libs/installer/component.cpp6
-rw-r--r--src/libs/installer/init.cpp2
-rw-r--r--src/libs/installer/installer.pro19
-rw-r--r--src/libs/installer/packagemanagercore.cpp7
-rw-r--r--src/libs/installer/packagemanagercore_p.cpp14
-rw-r--r--src/libs/installer/productkeycheck.cpp80
-rw-r--r--src/libs/installer/productkeycheck.h62
-rw-r--r--src/sdk/installerbasecommons.cpp6
-rw-r--r--src/sdk/sdk.pro7
-rw-r--r--src/sdk/tabcontroller.cpp6
12 files changed, 321 insertions, 5 deletions
diff --git a/src/libs/installer/applyproductkeyoperation.cpp b/src/libs/installer/applyproductkeyoperation.cpp
new file mode 100644
index 000000000..4556df743
--- /dev/null
+++ b/src/libs/installer/applyproductkeyoperation.cpp
@@ -0,0 +1,66 @@
+/**************************************************************************
+**
+** Copyright (c) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of Installer Framework
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+**************************************************************************/
+
+#include "applyproductkeyoperation.h"
+#include "productkeycheck.h"
+
+using namespace QInstaller;
+
+ApplyProductKeyOperation::ApplyProductKeyOperation()
+{
+ setName(QLatin1String("ApplyProductKey"));
+}
+
+void ApplyProductKeyOperation::backup()
+{
+}
+
+bool ApplyProductKeyOperation::performOperation()
+{
+ if (!ProductKeyCheck::instance()->applyKey(arguments())) {
+ setError(UserDefinedError);
+ setErrorString(ProductKeyCheck::instance()->lastErrorString());
+ }
+ return true;
+}
+
+bool ApplyProductKeyOperation::undoOperation()
+{
+ return true;
+}
+
+bool ApplyProductKeyOperation::testOperation()
+{
+ return true;
+}
+
+Operation *ApplyProductKeyOperation::clone() const
+{
+ return new ApplyProductKeyOperation();
+}
diff --git a/src/libs/installer/applyproductkeyoperation.h b/src/libs/installer/applyproductkeyoperation.h
new file mode 100644
index 000000000..9761492a1
--- /dev/null
+++ b/src/libs/installer/applyproductkeyoperation.h
@@ -0,0 +1,51 @@
+/**************************************************************************
+**
+** Copyright (c) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of Installer Framework
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+**************************************************************************/
+
+#ifndef APPLYPRODUCTKEYOPERATION_H
+#define APPLYPRODUCTKEYOPERATION_H
+
+#include "qinstallerglobal.h"
+
+namespace QInstaller {
+
+class INSTALLER_EXPORT ApplyProductKeyOperation : public Operation
+{
+public:
+ ApplyProductKeyOperation();
+
+ void backup();
+ bool performOperation();
+ bool undoOperation();
+ bool testOperation();
+ Operation *clone() const;
+};
+
+} // namespace
+
+#endif // APPLYPRODUCTKEYOPERATION_H
diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp
index 064e74cb5..fb554155f 100644
--- a/src/libs/installer/component.cpp
+++ b/src/libs/installer/component.cpp
@@ -50,6 +50,8 @@
#include <kdupdaterupdatesourcesinfo.h>
#include <kdupdaterupdateoperationfactory.h>
+#include <productkeycheck.h>
+
#include <QtCore/QDirIterator>
#include <QtCore/QTranslator>
@@ -497,6 +499,10 @@ void Component::loadLicenses(const QString &directory, const QHash<QString, QVar
QHash<QString, QVariant>::const_iterator it;
for (it = licenseHash.begin(); it != licenseHash.end(); ++it) {
const QString &fileName = it.value().toString();
+
+ if (!ProductKeyCheck::instance()->isValidLicense(fileName))
+ continue;
+
QFileInfo fileInfo(fileName);
QFile file(QString::fromLatin1("%1%2_%3.%4").arg(directory, fileInfo.baseName(),
QLocale().name().toLower(), fileInfo.completeSuffix()));
diff --git a/src/libs/installer/init.cpp b/src/libs/installer/init.cpp
index a49f74690..579446ebf 100644
--- a/src/libs/installer/init.cpp
+++ b/src/libs/installer/init.cpp
@@ -58,6 +58,7 @@
#include "linereplaceoperation.h"
#include "minimumprogressoperation.h"
#include "licenseoperation.h"
+#include "applyproductkeyoperation.h"
// QtSDK specific
#include "qtpatchoperation.h"
@@ -240,6 +241,7 @@ void QInstaller::init()
factory.registerUpdateOperation<LineReplaceOperation>(QLatin1String("LineReplace"));
factory.registerUpdateOperation<MinimumProgressOperation>(QLatin1String("MinimumProgress"));
factory.registerUpdateOperation<LicenseOperation>(QLatin1String("License"));
+ factory.registerUpdateOperation<ApplyProductKeyOperation>(QLatin1String("ApplyProductKey"));
// QtSDK specific
factory.registerUpdateOperation<RegisterQtInCreatorQNXOperation>(QLatin1String("RegisterQtInCreatorQNX"));
diff --git a/src/libs/installer/installer.pro b/src/libs/installer/installer.pro
index 17dd3bfdc..3b0b10813 100644
--- a/src/libs/installer/installer.pro
+++ b/src/libs/installer/installer.pro
@@ -6,6 +6,19 @@ include(../7zip/7zip.pri)
include(../kdtools/kdtools.pri)
include(../../../installerfw.pri)
+# productkeycheck API
+# call qmake "PRODUCTKEYCHECK_PRI_FILE=<your_path_to_pri_file>"
+# content of that pri file needs to be:
+# SOURCES += $$PWD/productkeycheck.cpp
+# ...
+# your files if needed
+HEADERS += productkeycheck.h
+!isEmpty(PRODUCTKEYCHECK_PRI_FILE) {
+ include($$PRODUCTKEYCHECK_PRI_FILE)
+} else {
+ SOURCES += productkeycheck.cpp
+}
+
DESTDIR = $$IFW_LIB_PATH
DLLDESTDIR = $$IFW_APP_PATH
@@ -85,7 +98,8 @@ HEADERS += packagemanagercore.h \
link.h \
createlinkoperation.h \
packagemanagercoredata.h \
- registerqtincreatorqnxoperation.h
+ registerqtincreatorqnxoperation.h \
+ applyproductkeyoperation.h
SOURCES += packagemanagercore.cpp \
packagemanagercore_p.cpp \
@@ -153,7 +167,8 @@ HEADERS += packagemanagercore.h \
link.cpp \
createlinkoperation.cpp \
packagemanagercoredata.cpp \
- registerqtincreatorqnxoperation.cpp
+ registerqtincreatorqnxoperation.cpp \
+ applyproductkeyoperation.cpp
RESOURCES += resources/patch_file_lists.qrc \
resources/installer.qrc
diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp
index 1829be95e..63f4eb45a 100644
--- a/src/libs/installer/packagemanagercore.cpp
+++ b/src/libs/installer/packagemanagercore.cpp
@@ -57,6 +57,8 @@
#include "settings.h"
#include "utils.h"
+#include <productkeycheck.h>
+
#include <QFuture>
#include <QFutureWatcher>
#include <QtConcurrentRun>
@@ -697,6 +699,11 @@ bool PackageManagerCore::fetchRemotePackagesTree()
return false;
}
+ if (!ProductKeyCheck::instance()->hasValidKey()) {
+ d->setStatus(Failure, ProductKeyCheck::instance()->lastErrorString());
+ return false;
+ }
+
const LocalPackagesHash installedPackages = d->localInstalledPackages();
if (!isInstaller() && status() == Failure)
return false;
diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp
index 5bcbb5418..35603eab3 100644
--- a/src/libs/installer/packagemanagercore_p.cpp
+++ b/src/libs/installer/packagemanagercore_p.cpp
@@ -60,7 +60,9 @@
#include "kdupdaterupdateoperationfactory.h"
#include "kdupdaterupdatefinder.h"
-#include <QtConcurrentRun>
+#include <productkeycheck.h>
+
+#include <QtCore/QtConcurrentRun>
#include <QtCore/QCoreApplication>
#include <QtCore/QDir>
#include <QtCore/QDirIterator>
@@ -555,6 +557,16 @@ QString PackageManagerCorePrivate::installReason(Component *component)
void PackageManagerCorePrivate::initialize(const QHash<QString, QString> &params)
{
+ if (!ProductKeyCheck::instance()->hasValidKey()) {
+ if (m_core->isInstaller()) {
+ setStatus(PackageManagerCore::Failure, ProductKeyCheck::instance()->lastErrorString());
+ } else {
+ MessageBoxHandler::warning(MessageBoxHandler::currentBestSuitParent(),
+ QLatin1String("ProductKeyCheckError"), ProductKeyCheck::instance()->lastErrorString(),
+ ProductKeyCheck::instance()->maintainanceToolDetailErrorNotice(), QMessageBox::Ok);
+ }
+ }
+
m_coreCheckedHash.clear();
m_data = PackageManagerCoreData(params);
m_componentsToInstallCalculated = false;
diff --git a/src/libs/installer/productkeycheck.cpp b/src/libs/installer/productkeycheck.cpp
new file mode 100644
index 000000000..f975db821
--- /dev/null
+++ b/src/libs/installer/productkeycheck.cpp
@@ -0,0 +1,80 @@
+/**************************************************************************
+**
+** Copyright (c) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of Installer Framework
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+**************************************************************************/
+
+#include <productkeycheck.h>
+
+
+class ProductKeyCheckPrivate
+{
+};
+
+
+ProductKeyCheck::ProductKeyCheck()
+ : d(new ProductKeyCheckPrivate())
+{
+}
+
+ProductKeyCheck::~ProductKeyCheck()
+{
+ delete d;
+}
+
+ProductKeyCheck *ProductKeyCheck::instance()
+{
+ static ProductKeyCheck *instance = 0;
+ if (instance == 0)
+ instance = new ProductKeyCheck();
+ return instance;
+}
+
+bool ProductKeyCheck::hasValidKey()
+{
+ return true;
+}
+
+bool ProductKeyCheck::applyKey(const QStringList &/*arguments*/)
+{
+ return true;
+}
+
+QString ProductKeyCheck::lastErrorString()
+{
+ return QString();
+}
+
+QString ProductKeyCheck::maintainanceToolDetailErrorNotice()
+{
+ return QString();
+}
+
+// to filter none valid licenses
+bool ProductKeyCheck::isValidLicense(const QString &/*fileName*/)
+{
+ return true;
+}
diff --git a/src/libs/installer/productkeycheck.h b/src/libs/installer/productkeycheck.h
new file mode 100644
index 000000000..1ecffc3d2
--- /dev/null
+++ b/src/libs/installer/productkeycheck.h
@@ -0,0 +1,62 @@
+/**************************************************************************
+**
+** Copyright (c) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of Installer Framework
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+**************************************************************************/
+
+#ifndef PRODUCTKEYCHECK_H
+#define PRODUCTKEYCHECK_H
+
+#include "qinstallerglobal.h"
+
+#include <QString>
+#include <QHash>
+
+class ProductKeyCheckPrivate;
+
+class INSTALLER_EXPORT ProductKeyCheck
+{
+public:
+ ~ProductKeyCheck();
+ static ProductKeyCheck *instance();
+
+ // was validLicense
+ bool hasValidKey();
+ QString lastErrorString();
+ QString maintainanceToolDetailErrorNotice();
+
+ //is used in the generic ApplyProductKeyOperation, for example to patch things
+ bool applyKey(const QStringList &arguments);
+
+ // to filter none valid licenses
+ bool isValidLicense(const QString &fileName);
+
+private:
+ ProductKeyCheck();
+ ProductKeyCheckPrivate *const d;
+};
+
+#endif // PRODUCTKEYCHECK_H
diff --git a/src/sdk/installerbasecommons.cpp b/src/sdk/installerbasecommons.cpp
index 6ae1ddc3a..5a08d20d3 100644
--- a/src/sdk/installerbasecommons.cpp
+++ b/src/sdk/installerbasecommons.cpp
@@ -45,6 +45,8 @@
#include <packagemanagercore.h>
#include <settings.h>
+#include <productkeycheck.h>
+
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
#include <QtCore/QTimer>
@@ -112,6 +114,8 @@ IntroductionPageImpl::IntroductionPageImpl(QInstaller::PackageManagerCore *core)
connect(core, SIGNAL(metaJobInfoMessage(QString)), this, SLOT(setMessage(QString)));
connect(core, SIGNAL(coreNetworkSettingsChanged()), this, SLOT(onCoreNetworkSettingsChanged()));
+
+ m_updateComponents->setEnabled(ProductKeyCheck::instance()->hasValidKey());
}
int IntroductionPageImpl::nextId() const
@@ -230,7 +234,7 @@ void IntroductionPageImpl::showMaintenanceTools()
void IntroductionPageImpl::setMaintenanceToolsEnabled(bool enable)
{
m_packageManager->setEnabled(enable);
- m_updateComponents->setEnabled(enable);
+ m_updateComponents->setEnabled(enable && ProductKeyCheck::instance()->hasValidKey());
m_removeAllComponents->setEnabled(enable);
}
diff --git a/src/sdk/sdk.pro b/src/sdk/sdk.pro
index d376535b0..a986b41ef 100644
--- a/src/sdk/sdk.pro
+++ b/src/sdk/sdk.pro
@@ -4,7 +4,12 @@ TARGET = installerbase
include(../../installerfw.pri)
-QT += network script
+QT += network script xml
+
+isEqual(QT_MAJOR_VERSION, 5) {
+ QT += widgets
+}
+
DESTDIR = $$IFW_APP_PATH
if (exists($$LRELEASE)) {
diff --git a/src/sdk/tabcontroller.cpp b/src/sdk/tabcontroller.cpp
index ad9b1db13..95b6298ee 100644
--- a/src/sdk/tabcontroller.cpp
+++ b/src/sdk/tabcontroller.cpp
@@ -45,6 +45,8 @@
#include <packagemanagercore.h>
+#include <productkeycheck.h>
+
#include <QtCore/QTimer>
#include <QtScript/QScriptEngine>
@@ -123,6 +125,10 @@ void TabController::setManagerParams(const QHash<QString, QString> &params)
int TabController::init()
{
+ if (!ProductKeyCheck::instance()->hasValidKey() && d->m_core->isInstaller()) {
+ return PackageManagerCore::Failure;
+ }
+
if (!d->m_init) {
d->m_init = true;
// this should called as early as possible, to handle error message boxes for example