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 <lars.knoll@digia.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
This commit is contained in:
parent
dd1220651c
commit
ebcb5c176f
312
configure
vendored
312
configure
vendored
@ -2766,203 +2766,25 @@ if [ "$COMMERCIAL_USER" = "ask" ]; then
|
||||
done
|
||||
fi
|
||||
|
||||
CFG_RTOS_ENABLED=yes
|
||||
EditionString=Commercial
|
||||
if [ -f "$relpath"/LICENSE.PREVIEW.COMMERCIAL ] && [ $COMMERCIAL_USER = "yes" ]; then
|
||||
# Commercial preview release
|
||||
Licensee="Preview"
|
||||
Edition="Preview"
|
||||
LicenseType="Technology Preview"
|
||||
EditionString="Technology Preview"
|
||||
elif [ $COMMERCIAL_USER = "yes" ]; then
|
||||
# one of commercial editions
|
||||
|
||||
# read in the license file
|
||||
[ -z "$LICENSE_FILE" ] && LICENSE_FILE="$QT_LICENSE_FILE"
|
||||
[ -z "$LICENSE_FILE" ] && LICENSE_FILE="$HOME/.qt-license"
|
||||
if [ -f "$LICENSE_FILE" ]; then
|
||||
tr -d '\r' <"$LICENSE_FILE" >"${LICENSE_FILE}.tmp"
|
||||
diff "${LICENSE_FILE}.tmp" "${LICENSE_FILE}" >/dev/null 2>&1 || LICENSE_FILE="${LICENSE_FILE}.tmp"
|
||||
. "$LICENSE_FILE" >/dev/null 2>&1
|
||||
if [ -z "$LicenseKeyExt" ]; then
|
||||
echo
|
||||
echo "You are using an old license file."
|
||||
echo
|
||||
echo "Please install the license file supplied by Digia,"
|
||||
echo "or install the Qt Open Source Edition if you intend to"
|
||||
echo "develop free software."
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "$Licensee" ]; then
|
||||
echo
|
||||
echo "Invalid license key. Please check the license key."
|
||||
if test -x "$relpath/bin/licheck"; then
|
||||
LicheckOutput=`$relpath/bin/licheck $relpath $outpath $PLATFORM $XPLATFORM`
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
else
|
||||
eval "$LicheckOutput"
|
||||
fi
|
||||
else
|
||||
if [ -z "$LicenseKeyExt" ]; then
|
||||
echo
|
||||
echo $ECHO_N "Please enter your license key: $ECHO_C"
|
||||
read LicenseKeyExt
|
||||
Licensee="Unknown user"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Key verification
|
||||
echo "$LicenseKeyExt" | grep ".....*-....*-....*-....*-.....*-.....*-...." >/dev/null 2>&1 \
|
||||
&& LicenseValid="yes" \
|
||||
|| LicenseValid="no"
|
||||
if [ "$LicenseValid" != "yes" ]; then
|
||||
echo
|
||||
echo "Invalid license key. Please check the license key."
|
||||
exit 1
|
||||
fi
|
||||
ProductCode=`echo $LicenseKeyExt | cut -f 1 -d - | cut -b 1`
|
||||
PlatformCode=`echo $LicenseKeyExt | cut -f 2 -d -`
|
||||
LicenseTypeCode=`echo $LicenseKeyExt | cut -f 3 -d -`
|
||||
LicenseFeatureCode=`echo $LicenseKeyExt | cut -f 4 -d - | cut -b 1`
|
||||
|
||||
# determine which edition we are licensed to use
|
||||
case "$LicenseTypeCode" in
|
||||
F4M)
|
||||
LicenseType="Commercial"
|
||||
case $ProductCode in
|
||||
F)
|
||||
Edition="Universal"
|
||||
;;
|
||||
B)
|
||||
Edition="FullFramework"
|
||||
EditionString="Full Framework"
|
||||
;;
|
||||
L)
|
||||
Edition="GUIFramework"
|
||||
EditionString="GUI Framework"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
Z4M|R4M|Q4M)
|
||||
LicenseType="Evaluation"
|
||||
QMakeVar add DEFINES QT_EVAL
|
||||
case $ProductCode in
|
||||
B)
|
||||
Edition="Evaluation"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
if [ -z "$LicenseType" -o -z "$Edition" ]; then
|
||||
echo
|
||||
echo "Invalid license key. Please check the license key."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# verify that we are licensed to use Qt on this platform
|
||||
LICENSE_EXTENSION=
|
||||
case "$PlatformCode" in
|
||||
*L)
|
||||
CFG_RTOS_ENABLED=yes
|
||||
PlatformCode=`echo "$PlatformCode" | sed 'h;y/8NPQRTZ/UCWX9M7/;x;G;s/\(.\)....\(.\)./\1\2/'`
|
||||
;;
|
||||
*)
|
||||
CFG_RTOS_ENABLED=no
|
||||
PlatformCode=`echo "$PlatformCode" | sed 's/.$//'`
|
||||
;;
|
||||
esac
|
||||
### EMBEDDED_QPA logic missing ###
|
||||
case "$PlatformCode,$XPLATFORM_MAC" in
|
||||
X9,* | XC,* | XU,* | XW,* | XM,*)
|
||||
# Qt All-OS
|
||||
LICENSE_EXTENSION="-ALLOS"
|
||||
;;
|
||||
8M,* | KM,* | S9,* | SC,* | SM,* | SU,* | SW,* | X9,* | XC,* | XU,* | XW,*)
|
||||
# Qt for Embedded Linux
|
||||
LICENSE_EXTENSION="-EMBEDDED"
|
||||
;;
|
||||
6M,* | N7,* | N9,* | NX,*)
|
||||
# Embedded no-deploy
|
||||
LICENSE_EXTENSION="-EMBEDDED"
|
||||
;;
|
||||
FM,* | LM,yes | ZM,no)
|
||||
# Desktop
|
||||
LICENSE_EXTENSION="-DESKTOP"
|
||||
;;
|
||||
*)
|
||||
Platform=Linux/X11
|
||||
[ "$XPLATFORM_MAC" = "yes" ] && Platform='Mac OS X'
|
||||
echo
|
||||
echo "You are not licensed for the $Platform platform."
|
||||
echo
|
||||
echo "Please use the contact form at http://qt.digia.com/contact-us"
|
||||
echo "to upgrade your license to include the $Platform platform, or install"
|
||||
echo "the Qt Open Source Edition if you intend to develop free software."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if test -r "$relpath/.LICENSE"; then
|
||||
# Generic, non-final license
|
||||
LICENSE_EXTENSION=""
|
||||
line=`sed 'y/a-z/A-Z/;q' "$relpath"/.LICENSE`
|
||||
case "$line" in
|
||||
*BETA*)
|
||||
Edition=Beta
|
||||
;;
|
||||
*TECHNOLOGY?PREVIEW*)
|
||||
Edition=Preview
|
||||
;;
|
||||
*EVALUATION*)
|
||||
Edition=Evaluation
|
||||
;;
|
||||
*)
|
||||
echo >&2 "Invalid license files; cannot continue"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Licensee="$Edition"
|
||||
EditionString="$Edition"
|
||||
fi
|
||||
|
||||
case "$LicenseFeatureCode" in
|
||||
B|G|L|Y)
|
||||
# US
|
||||
case "$LicenseType" in
|
||||
Commercial)
|
||||
cp -f "$relpath/.LICENSE${LICENSE_EXTENSION}-US" "$outpath/LICENSE"
|
||||
;;
|
||||
Evaluation)
|
||||
cp -f "$relpath/.LICENSE-EVALUATION-US" "$outpath/LICENSE"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
2|4|5|F)
|
||||
# non-US
|
||||
case "$LicenseType" in
|
||||
Commercial)
|
||||
cp -f "$relpath/.LICENSE${LICENSE_EXTENSION}" "$outpath/LICENSE"
|
||||
;;
|
||||
Evaluation)
|
||||
cp -f "$relpath/.LICENSE-EVALUATION" "$outpath/LICENSE"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
echo
|
||||
echo "Invalid license key. Please check the license key."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
case "$LicenseFeatureCode" in
|
||||
4|B|F|Y)
|
||||
CFG_RTOS_ENABLED=yes
|
||||
;;
|
||||
2|5|G|L)
|
||||
CFG_RTOS_ENABLED=no
|
||||
;;
|
||||
esac
|
||||
if [ '!' -f "$outpath/LICENSE" ]; then
|
||||
echo "The LICENSE, LICENSE.GPL LICENSE.LGPL file shipped with"
|
||||
echo "this software has disappeared."
|
||||
echo
|
||||
echo "Sorry, you are not licensed to use this software."
|
||||
echo "Try re-installing."
|
||||
echo "Error: This is the Open Source version of Qt."
|
||||
echo "If you want to use Enterprise features of Qt,"
|
||||
echo "use the contact form at http://qt.digia.com/contact-us"
|
||||
echo "to purchase a license."
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
@ -2972,22 +2794,11 @@ elif [ $COMMERCIAL_USER = "no" ]; then
|
||||
Edition="OpenSource"
|
||||
EditionString="Open Source"
|
||||
fi
|
||||
echo
|
||||
echo "This is the Qt ${EditionString} Edition."
|
||||
echo
|
||||
|
||||
if [ "$CFG_RTOS_ENABLED" = "no" ]; then
|
||||
case `basename "$XPLATFORM"` in
|
||||
qnx-* | vxworks-*)
|
||||
echo ""
|
||||
echo "You are not licensed for Qt for `basename $XPLATFORM`."
|
||||
echo ""
|
||||
echo "Please use the contact form at http://qt.digia.com/contact-us"
|
||||
echo "to upgrade your license to include this platform, or install"
|
||||
echo "the Qt Open Source Edition if you intend to develop free software."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
if [ "$Edition" = "OpenSource" ] || [ "$Edition" = "Preview" ]; then
|
||||
echo
|
||||
echo "This is the Qt ${EditionString} Edition."
|
||||
echo
|
||||
fi
|
||||
|
||||
if [ "$Edition" = "OpenSource" ]; then
|
||||
@ -3003,7 +2814,7 @@ if [ "$Edition" = "OpenSource" ]; then
|
||||
fi
|
||||
echo
|
||||
if [ "$OPT_CONFIRM_LICENSE" = "yes" ]; then
|
||||
echo "You have already accepted the terms of the $LicenseType license."
|
||||
echo "You have already accepted the terms of the $EditionString license."
|
||||
acceptance=yes
|
||||
else
|
||||
if [ -f "$relpath/LICENSE.GPL" ]; then
|
||||
@ -3034,7 +2845,7 @@ elif [ "$Edition" = "Preview" ]; then
|
||||
while true; do
|
||||
|
||||
if [ "$OPT_CONFIRM_LICENSE" = "yes" ]; then
|
||||
echo "You have already accepted the terms of the $LicenseType license."
|
||||
echo "You have already accepted the terms of the $EditionString license."
|
||||
acceptance=yes
|
||||
else
|
||||
echo "You are licensed to use this software under the terms of"
|
||||
@ -3058,77 +2869,6 @@ elif [ "$Edition" = "Preview" ]; then
|
||||
more "$relpath/LICENSE.PREVIEW.COMMERCIAL"
|
||||
fi
|
||||
done
|
||||
elif [ "$Edition" != "OpenSource" ]; then
|
||||
if [ -n "$ExpiryDate" ]; then
|
||||
ExpiryDate=`echo $ExpiryDate | sed -e 's,-,,g' | tr -d '\n\r'`
|
||||
[ -z "$ExpiryDate" ] && ExpiryDate="0"
|
||||
Today=`date +%Y%m%d`
|
||||
if [ "$Today" -gt "$ExpiryDate" ]; then
|
||||
case "$LicenseType" in
|
||||
Commercial|Academic|Educational)
|
||||
echo
|
||||
echo "WARNING WARNING WARNING WARNING"
|
||||
echo
|
||||
echo " Your support and upgrade period has expired."
|
||||
echo
|
||||
echo " You may continue to use your last licensed release"
|
||||
echo " of Qt under the terms of your existing license"
|
||||
echo " agreement. But you are not entitled to technical"
|
||||
echo " support, nor are you entitled to use any more recent"
|
||||
echo " Qt releases."
|
||||
echo
|
||||
echo " Please use the contact form at http://qt.digia.com/contact-us"
|
||||
echo " to renew your support and upgrades for this license."
|
||||
echo
|
||||
echo "WARNING WARNING WARNING WARNING"
|
||||
echo
|
||||
sleep 3
|
||||
;;
|
||||
Evaluation|*)
|
||||
echo
|
||||
echo "NOTICE NOTICE NOTICE NOTICE"
|
||||
echo
|
||||
echo " Your Evaluation license has expired."
|
||||
echo
|
||||
echo " You are no longer licensed to use this software. Please"
|
||||
echo " use the contact form at http://qt.digia.com/contact-us to"
|
||||
echo " purchase license, or install the Qt Open Source Edition"
|
||||
echo " if you intend to develop free software."
|
||||
echo
|
||||
echo "NOTICE NOTICE NOTICE NOTICE"
|
||||
echo
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
TheLicense=`head -n 1 "$outpath/LICENSE"`
|
||||
while true; do
|
||||
if [ "$OPT_CONFIRM_LICENSE" = "yes" ]; then
|
||||
echo "You have already accepted the terms of the $TheLicense."
|
||||
acceptance=yes
|
||||
else
|
||||
echo "You are licensed to use this software under the terms of"
|
||||
echo "the $TheLicense."
|
||||
echo
|
||||
echo "Type '?' to view the $TheLicense."
|
||||
echo "Type 'yes' to accept this license offer."
|
||||
echo "Type 'no' to decline this license offer."
|
||||
echo
|
||||
echo $ECHO_N "Do you accept the terms of the $TheLicense? $ECHO_C"
|
||||
read acceptance
|
||||
fi
|
||||
echo
|
||||
if [ "$acceptance" = "yes" ]; then
|
||||
break
|
||||
elif [ "$acceptance" = "no" ]; then
|
||||
echo "You are not licensed to use this software."
|
||||
echo
|
||||
exit 1
|
||||
else [ "$acceptance" = "?" ]
|
||||
more "$outpath/LICENSE"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
@ -3851,22 +3591,6 @@ else
|
||||
chmod -w "$outpath/src/corelib/global/qconfig.cpp"
|
||||
fi
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
if [ "$LicenseType" = "Evaluation" ]; then
|
||||
EVALKEY=qt_qevalkey=$LicenseKeyExt
|
||||
elif echo "$DEFINES" | grep QT_EVAL >/dev/null 2>&1; then
|
||||
EVALKEY=qt_qevalkey=
|
||||
fi
|
||||
|
||||
if [ -n "$EVALKEY" ]; then
|
||||
rm -f "$outpath/src/corelib/global/qconfig_eval.cpp"
|
||||
cat > "$outpath/src/corelib/global/qconfig_eval.cpp" <<EOF
|
||||
/* Evaluation license key */
|
||||
static const volatile char qt_eval_key_data [512 + 12] = "$EVALKEY";
|
||||
EOF
|
||||
chmod -w "$outpath/src/corelib/global/qconfig_eval.cpp"
|
||||
fi
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# build qmake
|
||||
@ -6224,10 +5948,6 @@ full)
|
||||
;;
|
||||
esac
|
||||
|
||||
cat >>"$outpath/src/corelib/global/qconfig.h.new" <<EOF
|
||||
|
||||
EOF
|
||||
|
||||
echo '/* Compile time features */' >>"$outpath/src/corelib/global/qconfig.h.new"
|
||||
[ '!' -z "$LicenseKeyExt" ] && echo "#define QT_PRODUCT_LICENSEKEY \"$LicenseKeyExt\"" >>"$outpath/src/corelib/global/qconfig.h.new"
|
||||
|
||||
|
@ -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
|
||||
|
@ -147,7 +147,6 @@ private:
|
||||
QString sybase;
|
||||
QString sybaseLibs;
|
||||
|
||||
QMap<QString,QString> licenseInfo;
|
||||
QString outputLine;
|
||||
|
||||
QTextStream outStream;
|
||||
|
@ -40,191 +40,56 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "tools.h"
|
||||
#include "environment.h"
|
||||
|
||||
#include <qdir.h>
|
||||
#include <qfile.h>
|
||||
#include <qbytearray.h>
|
||||
#include <qstringlist.h>
|
||||
|
||||
|
||||
// std stuff ------------------------------------
|
||||
#include <iostream>
|
||||
#include <windows.h>
|
||||
#include <conio.h>
|
||||
#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<QString,QString> &dictionary, QMap<QString,QString> &licenseInfo,
|
||||
const QString &path, const QString &sourcePath)
|
||||
void Tools::checkLicense(QMap<QString,QString> &dictionary,
|
||||
const QString &sourcePath, const QString &buildPath)
|
||||
{
|
||||
QString tpLicense = sourcePath + "/LICENSE.PREVIEW.OPENSOURCE";
|
||||
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
|
||||
}
|
||||
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." <<partNumber<< endl;
|
||||
return;
|
||||
}
|
||||
const QString licenseChecker =
|
||||
QDir::toNativeSeparators(sourcePath + "/bin/licheck.exe");
|
||||
|
||||
char products = licenseParts[0][0];
|
||||
char* platforms = licenseParts[1];
|
||||
char* licenseSchema = licenseParts[2];
|
||||
char licenseFeatures = licenseParts[3][0];
|
||||
if (QFile::exists(licenseChecker)) {
|
||||
const QString qMakeSpec =
|
||||
QDir::toNativeSeparators(dictionary.value("QMAKESPEC"));
|
||||
const QString xQMakeSpec =
|
||||
QDir::toNativeSeparators(dictionary.value("XQMAKESPEC"));
|
||||
|
||||
// Determine edition ---------------------------------------------------------------------------
|
||||
QString licenseType;
|
||||
if (strcmp(licenseSchema,"F4M") == 0) {
|
||||
licenseType = "Commercial";
|
||||
if (products == 'F') {
|
||||
dictionary["EDITION"] = "Universal";
|
||||
} else if (products == 'B') {
|
||||
dictionary["EDITION"] = "FullFramework";
|
||||
QString command = QString("%1 %2 %3 %4 %5")
|
||||
.arg(licenseChecker,
|
||||
QDir::toNativeSeparators(sourcePath),
|
||||
QDir::toNativeSeparators(buildPath),
|
||||
qMakeSpec, xQMakeSpec);
|
||||
|
||||
int returnValue = 0;
|
||||
QString licheckOutput = Environment::execute(command, &returnValue);
|
||||
|
||||
if (returnValue) {
|
||||
dictionary["DONE"] = "error";
|
||||
} else {
|
||||
dictionary["EDITION"] = "GUIFramework";
|
||||
foreach (const QString &var, licheckOutput.split('\n'))
|
||||
dictionary[var.section('=', 0, 0).toUpper()] = var.section('=', 1, 1);
|
||||
}
|
||||
} else if (strcmp(licenseSchema,"Z4M") == 0 || strcmp(licenseSchema,"R4M") == 0 || strcmp(licenseSchema,"Q4M") == 0) {
|
||||
if (products == 'B') {
|
||||
dictionary["EDITION"] = "Evaluation";
|
||||
licenseType = "Evaluation";
|
||||
}
|
||||
}
|
||||
|
||||
if (platforms[2] == 'L') {
|
||||
static const char src[] = "8NPQRTZ";
|
||||
static const char dst[] = "UCWX9M7";
|
||||
const char *p = strchr(src, platforms[1]);
|
||||
platforms[1] = dst[p - src];
|
||||
}
|
||||
|
||||
#define PL(a,b) (int(a)+int(b)*256)
|
||||
int platformCode = PL(platforms[0],platforms[1]);
|
||||
switch (platformCode) {
|
||||
case PL('X','9'):
|
||||
case PL('X','C'):
|
||||
case PL('X','U'):
|
||||
case PL('X','W'):
|
||||
case PL('X','M'): // old license key
|
||||
dictionary["LICENSE_EXTENSION"] = "-ALLOS";
|
||||
break;
|
||||
|
||||
case PL('6', 'M'):
|
||||
case PL('8', 'M'):
|
||||
case PL('K', 'M'): // old license key
|
||||
case PL('N', '7'):
|
||||
case PL('N', '9'):
|
||||
case PL('N', 'X'):
|
||||
case PL('S', '9'):
|
||||
case PL('S', 'C'):
|
||||
case PL('S', 'U'):
|
||||
case PL('S', 'W'):
|
||||
dictionary["LICENSE_EXTENSION"] = "-EMBEDDED";
|
||||
if (dictionary["PLATFORM NAME"].contains("Windows CE")
|
||||
&& platformCode != PL('6', 'M') && platformCode != PL('S', '9')
|
||||
&& platformCode != PL('S', 'C') && platformCode != PL('S', 'U')
|
||||
&& platformCode != PL('S', 'W') && platformCode != PL('K', 'M')) {
|
||||
dictionary["DONE"] = "error";
|
||||
}
|
||||
break;
|
||||
case PL('R', 'M'):
|
||||
case PL('F', 'M'):
|
||||
dictionary["LICENSE_EXTENSION"] = "-DESKTOP";
|
||||
if (!dictionary["PLATFORM NAME"].endsWith("Windows")) {
|
||||
dictionary["DONE"] = "error";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
dictionary["DONE"] = "error";
|
||||
break;
|
||||
}
|
||||
#undef PL
|
||||
|
||||
if (dictionary.value("DONE") == "error") {
|
||||
cout << "You are not licensed for the " << dictionary["PLATFORM NAME"] << " platform." << endl << endl;
|
||||
cout << "Please use the contact form at http://qt.digia.com/contact-us to upgrade your license" << endl;
|
||||
cout << "to include the " << dictionary["PLATFORM NAME"] << " platform, or install the" << endl;
|
||||
cout << "Qt Open Source Edition if you intend to develop free software." << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
// Override for evaluation licenses
|
||||
if (dictionary["EDITION"] == "Evaluation")
|
||||
dictionary["LICENSE_EXTENSION"] = "-EVALUATION";
|
||||
|
||||
if (QFile::exists(sourcePath + "/.LICENSE")) {
|
||||
// Generic, no-suffix license
|
||||
dictionary["LICENSE_EXTENSION"].clear();
|
||||
} else if (dictionary["LICENSE_EXTENSION"].isEmpty()) {
|
||||
cout << "License file does not contain proper license key." << endl;
|
||||
} else {
|
||||
cout << endl << "Error: Could not find licheck.exe" << endl
|
||||
<< "Try re-installing." << endl << endl;
|
||||
dictionary["DONE"] = "error";
|
||||
}
|
||||
if (licenseType.isEmpty()
|
||||
|| dictionary["EDITION"].isEmpty()) {
|
||||
cout << "License file does not contain proper license key." << endl;
|
||||
dictionary["DONE"] = "error";
|
||||
return;
|
||||
}
|
||||
|
||||
// copy one of .LICENSE-*(-US) to LICENSE
|
||||
QString toLicenseFile = sourcePath + "/LICENSE";
|
||||
QString fromLicenseFile = sourcePath + "/.LICENSE" + dictionary["LICENSE_EXTENSION"];
|
||||
if (licenseFeatures == 'B' || licenseFeatures == 'G'
|
||||
|| licenseFeatures == 'L' || licenseFeatures == 'Y')
|
||||
fromLicenseFile += "-US";
|
||||
|
||||
if (!CopyFile((wchar_t*)QDir::toNativeSeparators(fromLicenseFile).utf16(),
|
||||
(wchar_t*)QDir::toNativeSeparators(toLicenseFile).utf16(), false)) {
|
||||
cout << "Failed to copy license file (" << fromLicenseFile << ")";
|
||||
dictionary["DONE"] = "error";
|
||||
return;
|
||||
}
|
||||
dictionary["LICENSE FILE"] = toLicenseFile;
|
||||
}
|
||||
|
||||
|
@ -43,15 +43,13 @@
|
||||
#define _TOOLS_H_
|
||||
|
||||
#include <qstring.h>
|
||||
#include <qstringlist.h>
|
||||
#include <qmap.h>
|
||||
|
||||
|
||||
class Tools
|
||||
{
|
||||
public:
|
||||
static void checkLicense(QMap<QString,QString> &dictionary, QMap<QString,QString> &licenseInfo,
|
||||
const QString &path, const QString &sourcePath);
|
||||
static void checkLicense(QMap<QString,QString> &dictionary,
|
||||
const QString &sourcePath, const QString &buildPath);
|
||||
};
|
||||
|
||||
#endif // _TOOLS_H_
|
||||
|
Loading…
Reference in New Issue
Block a user