From ebcb5c176fa3552960f3b96c2fcbd7aaa2b29e50 Mon Sep 17 00:00:00 2001 From: Kalle Viironen Date: Wed, 26 Feb 2014 16:16:34 +0200 Subject: Externalize license key handling from configure Enterprise only license key handling removed from configure. This does not affect the functionality of the Open Source version nor the enterprise version. Change-Id: I01736eba3066c56b6e50e022fae8de6aa9bd884b Reviewed-by: Lars Knoll Reviewed-by: Oswald Buddenhagen --- tools/configure/configureapp.cpp | 38 +++----- tools/configure/configureapp.h | 1 - tools/configure/tools.cpp | 189 ++++++--------------------------------- tools/configure/tools.h | 6 +- 4 files changed, 40 insertions(+), 194 deletions(-) (limited to 'tools/configure') diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index fddf99d2da..9cebe6682b 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -3388,7 +3388,7 @@ void Configure::generateConfigfiles() << endl; } tmpStream << "/* License information */" << endl; - tmpStream << "#define QT_PRODUCT_LICENSEE \"" << licenseInfo[ "LICENSEE" ] << "\"" << endl; + tmpStream << "#define QT_PRODUCT_LICENSEE \"" << dictionary[ "LICENSEE" ] << "\"" << endl; tmpStream << "#define QT_PRODUCT_LICENSE \"" << dictionary[ "EDITION" ] << "\"" << endl; tmpStream << endl; if (dictionary["BUILDDEV"] == "yes") { @@ -3508,16 +3508,6 @@ void Configure::generateConfigfiles() dictionary[ "DONE" ] = "error"; } - if (dictionary["EDITION"] == "Evaluation" || qmakeDefines.contains("QT_EVAL")) { - FileWriter tmpStream(buildPath + "/src/corelib/global/qconfig_eval.cpp"); - - tmpStream << "/* Evaluation license key */" << endl - << "static const volatile char qt_eval_key_data [512 + 12] = \"qt_qevalkey=" << licenseInfo["LICENSEKEYEXT"] << "\";" << endl; - - if (!tmpStream.flush()) - dictionary[ "DONE" ] = "error"; - } - } void Configure::displayConfig() @@ -3542,10 +3532,10 @@ void Configure::displayConfig() sout << " PATH=\n " << env << endl; if (dictionary[QStringLiteral("EDITION")] != QStringLiteral("OpenSource")) { - QString l1 = licenseInfo[ "LICENSEE" ]; - QString l2 = licenseInfo[ "LICENSEID" ]; + QString l1 = dictionary[ "LICENSEE" ]; + QString l2 = dictionary[ "LICENSEID" ]; QString l3 = dictionary["EDITION"] + ' ' + "Edition"; - QString l4 = licenseInfo[ "EXPIRYDATE" ]; + QString l4 = dictionary[ "EXPIRYDATE" ]; sout << "Licensee...................." << (l1.isNull() ? "" : l1) << endl; sout << "License ID.................." << (l2.isNull() ? "" : l2) << endl; sout << "Product license............." << (l3.isNull() ? "" : l3) << endl; @@ -3877,7 +3867,7 @@ void Configure::generateQConfigCpp() { FileWriter tmpStream(buildPath + "/src/corelib/global/qconfig.cpp"); tmpStream << "/* Licensed */" << endl - << "static const char qt_configure_licensee_str [512 + 12] = \"qt_lcnsuser=" << licenseInfo["LICENSEE"] << "\";" << endl + << "static const char qt_configure_licensee_str [512 + 12] = \"qt_lcnsuser=" << dictionary["LICENSEE"] << "\";" << endl << "static const char qt_configure_licensed_products_str [512 + 12] = \"qt_lcnsprod=" << dictionary["EDITION"] << "\";" << endl << endl << "/* Build date */" << endl @@ -4302,7 +4292,7 @@ void Configure::readLicense() } if (hasOpenSource && openSource) { cout << endl << "This is the " << dictionary["PLATFORM NAME"] << " Open Source Edition." << endl; - licenseInfo["LICENSEE"] = "Open Source"; + dictionary["LICENSEE"] = "Open Source"; dictionary["EDITION"] = "OpenSource"; cout << endl; if (!showLicense(dictionary["LICENSE FILE"])) { @@ -4316,20 +4306,14 @@ void Configure::readLicense() } #ifdef COMMERCIAL_VERSION else { - Tools::checkLicense(dictionary, licenseInfo, firstLicensePath(), sourcePath); - if (dictionary["DONE"] != "error") { - // give the user some feedback, and prompt for license acceptance - cout << endl << "This is the " << dictionary["PLATFORM NAME"] << " " << dictionary["EDITION"] << " Edition."<< endl << endl; - if (!showLicense(dictionary["LICENSE FILE"])) { - cout << "Configuration aborted since license was not accepted"; - dictionary["DONE"] = "error"; - return; - } - } + Tools::checkLicense(dictionary, sourcePath, buildPath); } #else // !COMMERCIAL_VERSION else { - cout << endl << "Cannot build commercial edition from the open source version of the library." << endl; + cout << endl << "Error: This is the Open Source version of Qt." + << endl << "If you want to use Enterprise features of Qt," + << endl << "use the contact form at http://qt.digia.com/contact-us" + << endl << "to purchase a license." << endl << endl; dictionary["DONE"] = "error"; } #endif diff --git a/tools/configure/configureapp.h b/tools/configure/configureapp.h index 36668f18ba..e8de10dcf7 100644 --- a/tools/configure/configureapp.h +++ b/tools/configure/configureapp.h @@ -147,7 +147,6 @@ private: QString sybase; QString sybaseLibs; - QMap licenseInfo; QString outputLine; QTextStream outStream; diff --git a/tools/configure/tools.cpp b/tools/configure/tools.cpp index 07c3c82a0b..e2a6f3cc8a 100644 --- a/tools/configure/tools.cpp +++ b/tools/configure/tools.cpp @@ -40,191 +40,56 @@ ****************************************************************************/ #include "tools.h" +#include "environment.h" #include #include #include +#include - -// std stuff ------------------------------------ #include -#include -#include -#define NUMBER_OF_PARTS 7 -std::ostream &operator<<(std::ostream &s, const QString &val); // defined in configureapp.cpp +std::ostream &operator<<(std::ostream &s, const QString &val); using namespace std; -void Tools::checkLicense(QMap &dictionary, QMap &licenseInfo, - const QString &path, const QString &sourcePath) +void Tools::checkLicense(QMap &dictionary, + const QString &sourcePath, const QString &buildPath) { - QString tpLicense = sourcePath + "/LICENSE.PREVIEW.OPENSOURCE"; - if (QFile::exists(tpLicense)) { - dictionary["EDITION"] = "Preview"; - dictionary["LICENSE FILE"] = tpLicense; - return; // No license key checking in Tech Preview - } - tpLicense = sourcePath + "/LICENSE.PREVIEW.COMMERCIAL"; + QString tpLicense = sourcePath + "/LICENSE.PREVIEW.COMMERCIAL"; if (QFile::exists(tpLicense)) { dictionary["EDITION"] = "Preview"; dictionary["LICENSE FILE"] = tpLicense; - return; // No license key checking in Tech Preview - } - - // Read in the license file - QFile licenseFile(path); - if( !path.isEmpty() && licenseFile.open( QFile::ReadOnly ) ) { - cout << "Reading license file in....." << qPrintable(path) << endl; - - QString buffer = licenseFile.readLine(1024); - while (!buffer.isEmpty()) { - if( buffer[ 0 ] != '#' ) { - QStringList components = buffer.split( '=' ); - if ( components.size() >= 2 ) { - QStringList::Iterator it = components.begin(); - QString key = (*it++).trimmed().remove('"').toUpper(); - QString value = (*it++).trimmed().remove('"'); - licenseInfo[ key ] = value; - } - } - // read next line - buffer = licenseFile.readLine(1024); - } - licenseFile.close(); - } else { - cout << "License file not found in " << QDir::homePath() << endl; - cout << "Please put the Qt license file, '.qt-license' in your home " - << "directory and run configure again."; - dictionary["DONE"] = "error"; - return; - } - - // Verify license info... - QString licenseKey = licenseInfo["LICENSEKEYEXT"]; - QByteArray clicenseKey = licenseKey.toLatin1(); - //We check the license - static const char * const SEP = "-"; - char *licenseParts[NUMBER_OF_PARTS]; - int partNumber = 0; - for (char *part = strtok(clicenseKey.data(), SEP); part != 0; part = strtok(0, SEP)) - licenseParts[partNumber++] = part; - if (partNumber < (NUMBER_OF_PARTS-1)) { - dictionary["DONE"] = "error"; - cout << "License file does not contain proper license key." < -#include #include - class Tools { public: - static void checkLicense(QMap &dictionary, QMap &licenseInfo, - const QString &path, const QString &sourcePath); + static void checkLicense(QMap &dictionary, + const QString &sourcePath, const QString &buildPath); }; #endif // _TOOLS_H_ -- cgit v1.2.3