diff options
Diffstat (limited to 'src/libs')
57 files changed, 757 insertions, 2510 deletions
diff --git a/src/libs/installer/addqtcreatorarrayvalueoperation.cpp b/src/libs/installer/addqtcreatorarrayvalueoperation.cpp index 7da24febe..23d160a9a 100644 --- a/src/libs/installer/addqtcreatorarrayvalueoperation.cpp +++ b/src/libs/installer/addqtcreatorarrayvalueoperation.cpp @@ -103,7 +103,7 @@ bool AddQtCreatorArrayValueOperation::performOperation() int arraySize = settings.beginReadArray(arrayName); for (int i = 0; i < arraySize; ++i) { settings.setArrayIndex(i); - //if it is already there we have nothing todo + //if it is already there we have nothing to do if (settings.value(key).toString() == value) return true; oldArrayValues.append(settings.value(key).toString()); @@ -121,7 +121,7 @@ bool AddQtCreatorArrayValueOperation::performOperation() settings.setValue(key, value); settings.endArray(); - settings.sync(); //be save ;) + settings.sync(); //be safe ;) setValue(QLatin1String("ArrayValueSet"), true); return true; } @@ -178,7 +178,7 @@ bool AddQtCreatorArrayValueOperation::undoOperation() } settings.endArray(); - settings.sync(); //be save ;) + settings.sync(); //be safe ;) return true; } diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp index 4fb390040..1b37cc12c 100644 --- a/src/libs/installer/component.cpp +++ b/src/libs/installer/component.cpp @@ -589,7 +589,7 @@ void Component::loadLicenses(const QString &directory, const QHash<QString, QVar for (it = licenseHash.begin(); it != licenseHash.end(); ++it) { const QString &fileName = it.value().toString(); - if (!ProductKeyCheck::instance(d->m_core)->isValidLicenseTextFile(fileName)) + if (!ProductKeyCheck::instance()->isValidLicenseTextFile(fileName)) continue; QFileInfo fileInfo(fileName); @@ -936,8 +936,9 @@ void Component::addOperation(Operation *operation) void Component::addElevatedOperation(Operation *operation) { if (value(scRequiresAdminRights, scFalse) != scTrue) { - qWarning() << QString::fromLatin1("component %1 uses addElevatedOperation in the script, but it doesn't" - "have the needed RequiresAdminRights tag").arg(name()); + qWarning() << QString::fromLatin1("Component %1 uses addElevatedOperation in the script, " + "but it does not have the needed RequiresAdminRights tag" + ).arg(name()); } addOperation(operation); operation->setValue(QLatin1String("admin"), true); @@ -1203,7 +1204,7 @@ bool Component::isAutoDependOn(const QSet<QString> &componentsToInstall) const QLatin1String("isAutoDependOn")); } catch (const Error &error) { MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), - QLatin1String("isAutoDependOnError"), tr("Can't resolve isAutoDependOn in %1" + QLatin1String("isAutoDependOnError"), tr("Cannot resolve isAutoDependOn in %1" ).arg(name()), error.message()); return false; } @@ -1253,7 +1254,7 @@ bool Component::isDefault() const QLatin1String("isDefault")); } catch (const Error &error) { MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), - QLatin1String("isDefaultError"), tr("Can't resolve isDefault in %1").arg(name()), + QLatin1String("isDefaultError"), tr("Cannot resolve isDefault in %1").arg(name()), error.message()); return false; } diff --git a/src/libs/installer/consumeoutputoperation.cpp b/src/libs/installer/consumeoutputoperation.cpp index 2d3bc1ec0..95d143b4a 100644 --- a/src/libs/installer/consumeoutputoperation.cpp +++ b/src/libs/installer/consumeoutputoperation.cpp @@ -104,17 +104,20 @@ bool ConsumeOutputOperation::performOperation() } QByteArray executableOutput; - QProcess process; const QStringList processArguments = arguments().mid(2); // in some cases it is not runable, because another process is blocking it(filewatcher ...) int waitCount = 0; - while (executableOutput.isEmpty() && waitCount < 60) { - + while (executableOutput.isEmpty() && waitCount < 3) { + QProcess process; process.start(executable.absoluteFilePath(), processArguments, QIODevice::ReadOnly); - if (process.waitForFinished(2000)) { + if (process.waitForFinished(10000)) { if (process.exitStatus() == QProcess::CrashExit) { + qWarning() << executable.absoluteFilePath() << processArguments + << "crashed with exit code" << process.exitCode() + << "standard output: " << process.readAllStandardOutput() + << "error output: " << process.readAllStandardError(); setError(UserDefinedError); setErrorString(tr("Running '%1' resulted in a crash.").arg( QDir::toNativeSeparators(executable.absoluteFilePath()))); @@ -134,7 +137,7 @@ bool ConsumeOutputOperation::performOperation() } if (executableOutput.isEmpty()) { - qWarning() << QString::fromLatin1("Can't get any query output from executable: '%1'").arg( + qWarning() << QString::fromLatin1("Cannot get any query output from executable: '%1'").arg( executable.absoluteFilePath()); } core->setValue(installerKeyName, QString::fromLatin1(executableOutput)); diff --git a/src/libs/installer/createlocalrepositoryoperation.cpp b/src/libs/installer/createlocalrepositoryoperation.cpp index 0eb11b3aa..c8964796d 100644 --- a/src/libs/installer/createlocalrepositoryoperation.cpp +++ b/src/libs/installer/createlocalrepositoryoperation.cpp @@ -365,8 +365,7 @@ bool CreateLocalRepositoryOperation::undoOperation() if (createdDir == QDir::root() || !createdDir.exists()) return true; - QFile::remove(createdDir.path() + QLatin1String("/.DS_Store")); - QFile::remove(createdDir.path() + QLatin1String("/Thumbs.db")); + QInstaller::removeSystemGeneratedFiles(createdDir.path()); errno = 0; const bool result = QDir::root().rmdir(createdDir.path()); diff --git a/src/libs/installer/createshortcutoperation.cpp b/src/libs/installer/createshortcutoperation.cpp index 9f9084e05..963f0aaf8 100644 --- a/src/libs/installer/createshortcutoperation.cpp +++ b/src/libs/installer/createshortcutoperation.cpp @@ -250,7 +250,7 @@ bool CreateShortcutOperation::undoOperation() { const QString &linkLocation = arguments().at(1); if (!deleteFileNowOrLater(linkLocation) ) - qDebug() << "Can't delete:" << linkLocation; + qDebug() << "Cannot delete:" << linkLocation; QDir dir; // remove all directories we created const QStringList directoriesToDelete = value(QLatin1String("createddirs")).toStringList(); diff --git a/src/libs/installer/environmentvariablesoperation.cpp b/src/libs/installer/environmentvariablesoperation.cpp index 192272a8d..4c423d94f 100644 --- a/src/libs/installer/environmentvariablesoperation.cpp +++ b/src/libs/installer/environmentvariablesoperation.cpp @@ -67,19 +67,15 @@ void EnvironmentVariableOperation::backup() } #ifdef Q_OS_WIN -static bool broadcastChange() { +static void broadcastEnvironmentChange() +{ // Use SendMessageTimeout to Broadcast a message to the whole system to update settings of all // running applications. This is needed to activate the changes done above without logout+login. - // Note that cmd.exe does not respond to any WM_SETTINGCHANGE messages... - DWORD aResult = 0; - LRESULT sendresult = SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, - 0, (LPARAM) "Environment", SMTO_BLOCK | SMTO_ABORTIFHUNG, 5000, &aResult); - if (sendresult == 0 || aResult != 0) { - qWarning("Failed to broadcast a WM_SETTINGCHANGE message\n"); - return false; - } - - return true; + DWORD_PTR aResult = 0; + LRESULT sendresult = SendMessageTimeoutW(HWND_BROADCAST, WM_SETTINGCHANGE, + 0, (LPARAM) L"Environment", SMTO_BLOCK | SMTO_ABORTIFHUNG, 5000, &aResult); + if (sendresult == 0 || aResult != 0) + qWarning("Failed to broadcast the WM_SETTINGCHANGE message."); } #endif @@ -161,16 +157,15 @@ bool EnvironmentVariableOperation::performOperation() Error err = NoError; - err = isSystemWide - ? writeSetting<QSettingsWrapper>(regPath, name, value, &errorString, &oldvalue) - : writeSetting<QSettingsWrapper>(regPath, name, value, &errorString, &oldvalue); + err = writeSetting<QSettingsWrapper>(regPath, name, value, &errorString, &oldvalue); if (err != NoError) { setError(err); setErrorString(errorString); return false; } - const bool bret = broadcastChange(); - Q_UNUSED(bret); // this is not critical, so fall-through + + broadcastEnvironmentChange(); + setValue(QLatin1String("oldvalue"), oldvalue); return true; } @@ -215,9 +210,7 @@ bool EnvironmentVariableOperation::undoOperation() QString errorString; - const Error err = isSystemWide - ? undoSetting<QSettingsWrapper>(regPath, name, value, oldvalue, &errorString) - : undoSetting<QSettingsWrapper>(regPath, name, value, oldvalue, &errorString); + const Error err = undoSetting<QSettingsWrapper>(regPath, name, value, oldvalue, &errorString); if (err != NoError) { setError(err); diff --git a/src/libs/installer/fileutils.cpp b/src/libs/installer/fileutils.cpp index 6f8c44622..e499fd100 100644 --- a/src/libs/installer/fileutils.cpp +++ b/src/libs/installer/fileutils.cpp @@ -49,6 +49,7 @@ #include <QtCore/QTemporaryFile> #include <QtCore/QThread> #include <QtCore/QUrl> +#include <QtCore/QCoreApplication> #include <QImageReader> #include <errno.h> @@ -141,9 +142,15 @@ QString QInstaller::humanReadableSize(const qint64 &size, int precision) double sizeAsDouble = size; static QStringList measures; if (measures.isEmpty()) - measures << QString::fromLatin1("bytes") << QString::fromLatin1("KiB") << QString::fromLatin1("MiB") - << QString::fromLatin1("GiB") << QString::fromLatin1("TiB") << QString::fromLatin1("PiB") - << QString::fromLatin1("EiB") << QString::fromLatin1("ZiB") << QString::fromLatin1("YiB"); + measures << QCoreApplication::translate("QInstaller", "bytes") + << QCoreApplication::translate("QInstaller", "KiB") + << QCoreApplication::translate("QInstaller", "MiB") + << QCoreApplication::translate("QInstaller", "GiB") + << QCoreApplication::translate("QInstaller", "TiB") + << QCoreApplication::translate("QInstaller", "PiB") + << QCoreApplication::translate("QInstaller", "EiB") + << QCoreApplication::translate("QInstaller", "ZiB") + << QCoreApplication::translate("QInstaller", "YiB"); QStringListIterator it(measures); QString measure(it.next()); @@ -453,20 +460,63 @@ QString QInstaller::generateTemporaryFileName(const QString &templ) return f.fileName(); } +static char *installer_mkdtemp(char *templateName) +{ + QDir newDir; +#if defined(Q_OS_QNX ) || defined(Q_OS_WIN) || defined(Q_OS_ANDROID) + static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + + const size_t length = strlen(templateName); + + char *XXXXXX = templateName + length - 6; + + if ((length < 6u) || strncmp(XXXXXX, "XXXXXX", 6)) + return 0; + + for (int i = 0; i < 256; ++i) { + /* Fill in the random bits. */ + int v = qrand(); + XXXXXX[0] = letters[v % 62]; + v /= 62; + XXXXXX[1] = letters[v % 62]; + v = qrand(); + XXXXXX[2] = letters[v % 62]; + v /= 62; + XXXXXX[3] = letters[v % 62]; + v = qrand(); + XXXXXX[4] = letters[v % 62]; + v /= 62; + XXXXXX[5] = letters[v % 62]; + + QString templateNameStr = QFile::decodeName(templateName); + + newDir = QDir(templateNameStr); + if (newDir.mkpath(templateNameStr)) + return templateName; + } + return 0; +#else + return mkdtemp(templateName); +#endif +} + QString QInstaller::createTemporaryDirectory(const QString &templateName) { + // TODO: use QTemporaryDir if we switched to Qt5 QString path = QDir::tempPath() + QLatin1String("/") + templateName + QLatin1String("XXXXXX"); - { + path = QFile::decodeName(installer_mkdtemp(QFile::encodeName(path).data())); + if (path.isEmpty()) { QTemporaryFile f(path); if (!f.open()) { - throw Error(QObject::tr("Could not create temporary directory %1: %2").arg(f.fileName(), - f.errorString())); + throw Error(QObject::tr("Could not create temporary directory at %1: %2" + ).arg(QFileInfo(f).absolutePath(), f.errorString())); + } else { + throw Error(QObject::tr("Could not create temporary directory at %1: unknown error" + ).arg(QFileInfo(f).absolutePath())); } - path = f.fileName(); } - qDebug() << "\nCreating temporary directory at:" << path; - QInstaller::mkpath(path); + qDebug() << "Temporary directory created:" << path; return path; } diff --git a/src/libs/installer/fsengineclient.cpp b/src/libs/installer/fsengineclient.cpp index abc686fd9..2a7a8a5bd 100644 --- a/src/libs/installer/fsengineclient.cpp +++ b/src/libs/installer/fsengineclient.cpp @@ -797,8 +797,8 @@ void FSEngineClientHandler::Private::maybeStartServer() const QMessageBox::Button res = QInstaller::MessageBoxHandler::critical(QInstaller::MessageBoxHandler::currentBestSuitParent(), - QObject::tr("Authorization Error"), QObject::tr("Couldn't get authorization."), - QObject::tr("Couldn't get authorization that is needed for continuing the installation.\n" + QObject::tr("Authorization Error"), QObject::tr("Could not get authorization."), + QObject::tr("Could not get authorization that is needed for continuing the installation.\n" "Either abort the installation or use the fallback solution by running\n" "%1\nas root and then clicking ok.").arg(fallback), QMessageBox::Abort | QMessageBox::Ok, QMessageBox::Ok); diff --git a/src/libs/installer/getrepositoriesmetainfojob.cpp b/src/libs/installer/getrepositoriesmetainfojob.cpp index c4564e781..cde872064 100644 --- a/src/libs/installer/getrepositoriesmetainfojob.cpp +++ b/src/libs/installer/getrepositoriesmetainfojob.cpp @@ -121,7 +121,7 @@ void GetRepositoriesMetaInfoJob::doStart() { if ((m_core->isInstaller() && !m_core->isOfflineOnly()) || (m_core->isUpdater() || m_core->isPackageManager())) { - const ProductKeyCheck *const productKeyCheck = ProductKeyCheck::instance(m_core); + const ProductKeyCheck *const productKeyCheck = ProductKeyCheck::instance(); foreach (const Repository &repo, m_core->settings().repositories()) { if (repo.isEnabled() && productKeyCheck->isValidRepository(repo)) m_repositories += repo; diff --git a/src/libs/installer/init.cpp b/src/libs/installer/init.cpp index a8a7f54d8..12891f0e2 100644 --- a/src/libs/installer/init.cpp +++ b/src/libs/installer/init.cpp @@ -59,20 +59,13 @@ #include "minimumprogressoperation.h" #include "licenseoperation.h" #include "applyproductkeyoperation.h" +#include "settingsoperation.h" // QtSDK specific #include "qtpatchoperation.h" #include "consumeoutputoperation.h" -#include "setdemospathonqtoperation.h" -#include "setexamplespathonqtoperation.h" -#include "setpluginpathonqtcoreoperation.h" -#include "setimportspathonqtcoreoperation.h" -#include "setpathonqtcoreoperation.h" -#include "registerqtincreatorqnxoperation.h" #include "setqtcreatorvalueoperation.h" #include "addqtcreatorarrayvalueoperation.h" -#include "registertoolchainoperation.h" -#include "registerdefaultdebuggeroperation.h" #ifdef Q_OS_MAC # include "macreplaceinstallnamesoperation.h" @@ -147,9 +140,12 @@ static void initResources() { Q_INIT_RESOURCE(patch_file_lists); Q_INIT_RESOURCE(installer); + // Qt5 or better qmake generates that automatically, so this is only needed on Qt4 # if QT_VERSION < 0x050000 Q_IMPORT_PLUGIN(qico) Q_UNUSED(qt_plugin_instance_qico()); + Q_IMPORT_PLUGIN(qtaccessiblewidgets) + Q_UNUSED(qt_plugin_instance_qtaccessiblewidgets()); # endif } #endif @@ -245,16 +241,9 @@ void QInstaller::init() factory.registerUpdateOperation<LicenseOperation>(QLatin1String("License")); factory.registerUpdateOperation<ApplyProductKeyOperation>(QLatin1String("ApplyProductKey")); factory.registerUpdateOperation<ConsumeOutputOperation>(QLatin1String("ConsumeOutput")); + factory.registerUpdateOperation<SettingsOperation>(QLatin1String("Settings")); // QtSDK specific - factory.registerUpdateOperation<RegisterQtInCreatorQNXOperation>(QLatin1String("RegisterQtInCreatorQNX")); - factory.registerUpdateOperation<RegisterToolChainOperation>(QLatin1String("RegisterToolChain")); - factory.registerUpdateOperation<RegisterDefaultDebuggerOperation>(QLatin1String("RegisterDefaultDebugger")); - factory.registerUpdateOperation<SetDemosPathOnQtOperation>(QLatin1String("SetDemosPathOnQt")); - factory.registerUpdateOperation<SetExamplesPathOnQtOperation>(QLatin1String("SetExamplesPathOnQt")); - factory.registerUpdateOperation<SetPluginPathOnQtCoreOperation>(QLatin1String("SetPluginPathOnQtCore")); - factory.registerUpdateOperation<SetImportsPathOnQtCoreOperation>(QLatin1String("SetImportsPathOnQtCore")); - factory.registerUpdateOperation<SetPathOnQtCoreOperation>(QLatin1String("SetPathOnQtCore")); factory.registerUpdateOperation<SetQtCreatorValueOperation>(QLatin1String("SetQtCreatorValue")); factory.registerUpdateOperation<AddQtCreatorArrayValueOperation>(QLatin1String("AddQtCreatorArrayValue")); factory.registerUpdateOperation<QtPatchOperation>(QLatin1String("QtPatch")); diff --git a/src/libs/installer/installer.pro b/src/libs/installer/installer.pro index 653b65d6f..149287428 100644 --- a/src/libs/installer/installer.pro +++ b/src/libs/installer/installer.pro @@ -52,18 +52,10 @@ HEADERS += packagemanagercore.h \ componentmodel.h \ qinstallerglobal.h \ qtpatch.h \ - persistentsettings.h \ - projectexplorer_export.h \ qtpatchoperation.h \ consumeoutputoperation.h \ - setpathonqtcoreoperation.h \ - setdemospathonqtoperation.h \ - setexamplespathonqtoperation.h \ - setpluginpathonqtcoreoperation.h \ - setimportspathonqtcoreoperation.h \ replaceoperation.h \ linereplaceoperation.h \ - registertoolchainoperation.h \ setqtcreatorvalueoperation.h \ addqtcreatorarrayvalueoperation.h \ copydirectoryoperation.h \ @@ -98,8 +90,6 @@ HEADERS += packagemanagercore.h \ licenseoperation.h \ component_p.h \ qtcreator_constants.h \ - qtcreatorpersistentsettings.h \ - registerdefaultdebuggeroperation.h \ qprocesswrapper.h \ qsettingswrapper.h \ constants.h \ @@ -109,10 +99,12 @@ HEADERS += packagemanagercore.h \ link.h \ createlinkoperation.h \ packagemanagercoredata.h \ - registerqtincreatorqnxoperation.h \ applyproductkeyoperation.h \ globals.h \ - graph.h + graph.h \ + settingsoperation.h \ + testrepository.h \ + packagemanagerpagefactory.h SOURCES += packagemanagercore.cpp \ packagemanagercore_p.cpp \ @@ -128,17 +120,10 @@ HEADERS += packagemanagercore.h \ scriptengine.cpp \ componentmodel.cpp \ qtpatch.cpp \ - persistentsettings.cpp \ qtpatchoperation.cpp \ consumeoutputoperation.cpp \ - setpathonqtcoreoperation.cpp \ - setdemospathonqtoperation.cpp \ - setexamplespathonqtoperation.cpp \ - setpluginpathonqtcoreoperation.cpp \ - setimportspathonqtcoreoperation.cpp \ replaceoperation.cpp \ linereplaceoperation.cpp \ - registertoolchainoperation.cpp \ setqtcreatorvalueoperation.cpp \ addqtcreatorarrayvalueoperation.cpp \ copydirectoryoperation.cpp \ @@ -170,8 +155,6 @@ HEADERS += packagemanagercore.h \ getrepositoriesmetainfojob.cpp \ licenseoperation.cpp \ component_p.cpp \ - qtcreatorpersistentsettings.cpp \ - registerdefaultdebuggeroperation.cpp \ qprocesswrapper.cpp \ templates.cpp \ qsettingswrapper.cpp \ @@ -182,9 +165,11 @@ HEADERS += packagemanagercore.h \ link.cpp \ createlinkoperation.cpp \ packagemanagercoredata.cpp \ - registerqtincreatorqnxoperation.cpp \ applyproductkeyoperation.cpp \ - globals.cpp + globals.cpp \ + settingsoperation.cpp \ + testrepository.cpp \ + packagemanagerpagefactory.cpp RESOURCES += resources/patch_file_lists.qrc \ resources/installer.qrc diff --git a/src/libs/installer/macreplaceinstallnamesoperation.cpp b/src/libs/installer/macreplaceinstallnamesoperation.cpp index fa5e6139a..9ec553358 100644 --- a/src/libs/installer/macreplaceinstallnamesoperation.cpp +++ b/src/libs/installer/macreplaceinstallnamesoperation.cpp @@ -148,7 +148,7 @@ int MacReplaceInstallNamesOperation::updateExecutableInfo(MacBinaryInfo *binaryI QProcessWrapper otool; otool.start(QLatin1String("otool"), QStringList() << QLatin1String("-l") << binaryInfo->fileName); if (!otool.waitForStarted()) { - setError(UserDefinedError, tr("Can't invoke otool. Is Xcode installed?")); + setError(UserDefinedError, tr("Cannot invoke otool. Is Xcode installed?")); return -1; } otool.waitForFinished(); @@ -230,7 +230,7 @@ bool MacReplaceInstallNamesOperation::execCommand(const QString &cmd, const QStr QProcessWrapper process; process.start(cmd, args); if (!process.waitForStarted()) { - setError(UserDefinedError, tr("Can't start process %0.").arg(cmd)); + setError(UserDefinedError, tr("Cannot start process %0.").arg(cmd)); return false; } process.waitForFinished(); diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index fc1ecff02..09e1a5094 100644 --- a/src/libs/installer/packagemanagercore.cpp +++ b/src/libs/installer/packagemanagercore.cpp @@ -545,11 +545,12 @@ quint64 PackageManagerCore::requiredDiskSpace() const */ quint64 PackageManagerCore::requiredTemporaryDiskSpace() const { - quint64 result = 0; + if (isOfflineOnly()) + return 0; + quint64 result = 0; foreach (QInstaller::Component *component, orderedComponentsToInstall()) result += size(component, scCompressedSize); - return result; } @@ -648,6 +649,19 @@ void PackageManagerCore::rollBackInstallation() const bool becameAdmin = !d->m_FSEngineClientHandler->isActive() && operation->value(QLatin1String("admin")).toBool() && gainAdminRights(); + if (operation->hasValue(QLatin1String("uninstall-only"))) { + // We know the mkdir operation which is creating the target path. If we do a + // full uninstall, prevent a forced remove of the full install path including the + // target , instead try to remove the target only and only if it is empty, + // otherwise fail silently. Note: we will ever experience this only -if- + // RemoveTargetDir is set, otherwise the operation does not exist at all. + const bool isMkDir = (operation->name() == QLatin1String("Mkdir")); + const bool removeTargetDir = QVariant(value(scRemoveTargetDir)).toBool(); + const bool uninstallOnly = operation->value(QLatin1String("uninstall-only")).toBool(); + if (isMkDir && uninstallOnly && removeTargetDir) + operation->setValue(QLatin1String("forceremoval"), false); + } + PackageManagerCorePrivate::performOperationThreaded(operation, PackageManagerCorePrivate::Undo); const QString componentName = operation->value(QLatin1String("component")).toString(); @@ -886,8 +900,8 @@ bool PackageManagerCore::fetchRemotePackagesTree() return false; } - if (!ProductKeyCheck::instance(this)->hasValidKey()) { - d->setStatus(Failure, ProductKeyCheck::instance(this)->lastErrorString()); + if (!ProductKeyCheck::instance()->hasValidKey()) { + d->setStatus(Failure, ProductKeyCheck::instance()->lastErrorString()); return false; } @@ -1681,15 +1695,23 @@ QString PackageManagerCore::findLibrary(const QString &name, const QStringList & #if defined(Q_OS_WIN) return findPath(QString::fromLatin1("%1.lib").arg(name), findPaths); #else +#if defined(Q_OS_MAC) if (findPaths.isEmpty()) { findPaths.push_back(QLatin1String("/lib")); findPaths.push_back(QLatin1String("/usr/lib")); findPaths.push_back(QLatin1String("/usr/local/lib")); findPaths.push_back(QLatin1String("/opt/local/lib")); } -#if defined(Q_OS_MAC) const QString dynamic = findPath(QString::fromLatin1("lib%1.dylib").arg(name), findPaths); #else + if (findPaths.isEmpty()) { + findPaths.push_back(QLatin1String("/lib")); + findPaths.push_back(QLatin1String("/usr/lib")); + findPaths.push_back(QLatin1String("/usr/local/lib")); + findPaths.push_back(QLatin1String("/lib64")); + findPaths.push_back(QLatin1String("/usr/lib64")); + findPaths.push_back(QLatin1String("/usr/local/lib64")); + } const QString dynamic = findPath(QString::fromLatin1("lib%1.so*").arg(name), findPaths); #endif if (!dynamic.isEmpty()) diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index 2e5e3e369..5416bc9f2 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -554,7 +554,7 @@ bool PackageManagerCorePrivate::appendComponentToInstall(Component *component) if (dependencyComponent == 0) { QString errorMessage; if (!dependencyComponent) - errorMessage = QString::fromLatin1("Can't find missing dependency (%1) for %2."); + errorMessage = QString::fromLatin1("Cannot find missing dependency (%1) for %2."); errorMessage = errorMessage.arg(dependencyComponentName, component->name()); qDebug() << qPrintable(errorMessage); m_componentsToInstallError.append(errorMessage); @@ -601,16 +601,6 @@ QString PackageManagerCorePrivate::installReason(Component *component) void PackageManagerCorePrivate::initialize(const QHash<QString, QString> ¶ms) { - if (!ProductKeyCheck::instance(m_core)->hasValidKey()) { - if (m_core->isInstaller()) { - setStatus(PackageManagerCore::Failure, ProductKeyCheck::instance(m_core)->lastErrorString()); - } else { - MessageBoxHandler::warning(MessageBoxHandler::currentBestSuitParent(), - QLatin1String("ProductKeyCheckError"), ProductKeyCheck::instance(m_core)->lastErrorString(), - ProductKeyCheck::instance(m_core)->maintainanceToolDetailErrorNotice(), QMessageBox::Ok); - } - } - m_coreCheckedHash.clear(); m_data = PackageManagerCoreData(params); m_componentsToInstallCalculated = false; diff --git a/src/libs/installer/packagemanagercoredata.cpp b/src/libs/installer/packagemanagercoredata.cpp index 65123efba..16fc6dc00 100644 --- a/src/libs/installer/packagemanagercoredata.cpp +++ b/src/libs/installer/packagemanagercoredata.cpp @@ -44,8 +44,14 @@ #include "fileutils.h" #include "qsettingswrapper.h" +#include <QDesktopServices> #include <QDir> +#ifdef Q_OS_WIN +# include <windows.h> +# include <shlobj.h> +#endif + namespace QInstaller { @@ -61,6 +67,20 @@ PackageManagerCoreData::PackageManagerCoreData(const QHash<QString, QString> &va m_variables.insert(QLatin1String("HomeDir"), QDir::homePath()); m_variables.insert(scTargetConfigurationFile, QLatin1String("components.xml")); + QString dir = QLatin1String("/opt"); +#ifdef Q_OS_WIN + TCHAR buffer[MAX_PATH + 1] = { 0 }; + SHGetFolderPath(0, CSIDL_PROGRAM_FILES, 0, 0, buffer); + dir = QString::fromWCharArray(buffer); +#elif defined (Q_OS_MAC) +# if QT_VERSION < 0x050000 + dir = QDesktopServices::storageLocation(QDesktopServices::ApplicationsLocation); +# else + dir = QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation).value(0); +# endif +#endif + m_variables.insert(QLatin1String("ApplicationsDir"), dir); + #ifdef Q_OS_WIN m_variables.insert(QLatin1String("os"), QLatin1String("win")); #elif defined(Q_OS_MAC) diff --git a/src/libs/installer/packagemanagergui.cpp b/src/libs/installer/packagemanagergui.cpp index 98abefe75..5a940c525 100644 --- a/src/libs/installer/packagemanagergui.cpp +++ b/src/libs/installer/packagemanagergui.cpp @@ -55,10 +55,8 @@ #include "kdsysinfo.h" #include <QtCore/QDir> -#include <QtCore/QDynamicPropertyChangeEvent> #include <QtCore/QPair> #include <QtCore/QProcess> -#include <QtCore/QRegExp> #include <QtCore/QSettings> #include <QtCore/QTimer> @@ -66,7 +64,6 @@ #include <QDesktopServices> #include <QFileDialog> #include <QGridLayout> -#include <QFormLayout> #include <QHBoxLayout> #include <QHeaderView> #include <QLabel> @@ -74,14 +71,11 @@ #include <QListWidget> #include <QListWidgetItem> #include <QMessageBox> -#include <QProgressBar> #include <QPushButton> #include <QRadioButton> #include <QTextBrowser> -#include <QTreeWidget> #include <QTreeView> #include <QVBoxLayout> -#include <QScrollBar> #include <QShowEvent> using namespace KDUpdater; @@ -531,7 +525,6 @@ void PackageManagerGui::cancelButtonClicked() void PackageManagerGui::rejectWithoutPrompt() { - m_core->setCanceled(); QDialog::reject(); } @@ -630,6 +623,7 @@ void PackageManagerGui::dependsOnLocalInstallerBinary() PackageManagerPage::PackageManagerPage(PackageManagerCore *core) : m_fresh(true) , m_complete(true) + , m_needsSettingsButton(false) , m_core(core) , validatorComponent(0) { @@ -1725,7 +1719,7 @@ void PerformInstallationPage::entering() setCommitPage(true); if (packageManagerCore()->isUninstaller()) { - setButtonText(QWizard::CommitButton, tr("&Uninstall")); + setButtonText(QWizard::CommitButton, tr("U&ninstall")); setTitle(tr("Uninstalling %1").arg(productName())); QTimer::singleShot(30, packageManagerCore(), SLOT(runUninstaller())); diff --git a/src/libs/installer/packagemanagergui.h b/src/libs/installer/packagemanagergui.h index 913bfb2a6..304f5f2a1 100644 --- a/src/libs/installer/packagemanagergui.h +++ b/src/libs/installer/packagemanagergui.h @@ -162,6 +162,10 @@ public: void setValidatePageComponent(QInstaller::Component *component); bool validatePage(); + + bool settingsButtonRequested() const { return m_needsSettingsButton; } + void setSettingsButtonRequested(bool request) { m_needsSettingsButton = request; } + signals: void entered(); void left(); @@ -185,6 +189,7 @@ protected: private: bool m_fresh; bool m_complete; + bool m_needsSettingsButton; PackageManagerCore *m_core; QInstaller::Component *validatorComponent; diff --git a/src/libs/installer/setpathonqtcoreoperation.h b/src/libs/installer/packagemanagerpagefactory.cpp index 1b63c7ede..ddfb5b6d4 100644 --- a/src/libs/installer/setpathonqtcoreoperation.h +++ b/src/libs/installer/packagemanagerpagefactory.cpp @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the Qt Installer Framework. @@ -39,25 +39,19 @@ ** **************************************************************************/ -#ifndef SETPATHONQTCOREOPERATION_H -#define SETPATHONQTCOREOPERATION_H - -#include "qinstallerglobal.h" +#include <packagemanagerpagefactory.h> namespace QInstaller { -class SetPathOnQtCoreOperation : public Operation +PackageManagerPageFactory &PackageManagerPageFactory::instance() { -public: - SetPathOnQtCoreOperation(); - - void backup(); - bool performOperation(); - bool undoOperation(); - bool testOperation(); - Operation *clone() const; -}; + static PackageManagerPageFactory factory; + return factory; +} -} // namespace +PackageManagerPage *PackageManagerPageFactory::create(int id, PackageManagerCore *core) const +{ + return KDGenericFactory<PackageManagerPage, int, PackageManagerCore*>::createWithArg(id, core); +} -#endif // SETPATHONQTCOREOPERATION_H +} diff --git a/src/libs/installer/registerdefaultdebuggeroperation.h b/src/libs/installer/packagemanagerpagefactory.h index 87712e5d8..001fb6cd5 100644 --- a/src/libs/installer/registerdefaultdebuggeroperation.h +++ b/src/libs/installer/packagemanagerpagefactory.h @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the Qt Installer Framework. @@ -39,25 +39,34 @@ ** **************************************************************************/ -#ifndef REGISTERDEFAULTDEBUGGEROPERATION_H -#define REGISTERDEFAULTDEBUGGEROPERATION_H +#ifndef PACKAGEMANAGERPAGEFACTORY_H +#define PACKAGEMANAGERPAGEFACTORY_H -#include "qinstallerglobal.h" +#include <kdgenericfactory.h> +#include <packagemanagergui.h> namespace QInstaller { -class RegisterDefaultDebuggerOperation : public Operation +class PackageManagerCore; +class PackageManagerPage; + +class INSTALLER_EXPORT PackageManagerPageFactory : public KDGenericFactory<PackageManagerPage, + int, QInstaller::PackageManagerCore*> { + Q_DISABLE_COPY(PackageManagerPageFactory) + public: - RegisterDefaultDebuggerOperation(); + static PackageManagerPageFactory &instance(); + template<typename T> void registerPackageManagerPage(int id) + { + registerProductWithArg<T>(id); + } + PackageManagerPage *create(int id, QInstaller::PackageManagerCore *core) const; - void backup(); - bool performOperation(); - bool undoOperation(); - bool testOperation(); - Operation *clone() const; +private: + PackageManagerPageFactory() {} }; } // namespace QInstaller -#endif // REGISTERDEFAULTDEBUGGEROPERATION_H +#endif // PACKAGEMANAGERPAGEFACTORY_H diff --git a/src/libs/installer/packagemanagerproxyfactory.cpp b/src/libs/installer/packagemanagerproxyfactory.cpp index 42f8e9893..219ff5e49 100644 --- a/src/libs/installer/packagemanagerproxyfactory.cpp +++ b/src/libs/installer/packagemanagerproxyfactory.cpp @@ -79,8 +79,10 @@ QList<QNetworkProxy> PackageManagerProxyFactory::queryProxy(const QNetworkProxyQ if (query.url().scheme() == QLatin1String("ftp")) return list << settings.ftpProxy(); - if (query.url().scheme() == QLatin1String("http")) - return list << settings.httpProxy(); + if ((query.url().scheme() == QLatin1String("http")) + || (query.url().scheme() == QLatin1String("https"))) { + return list << settings.httpProxy(); + } } return list << QNetworkProxy(QNetworkProxy::DefaultProxy); } diff --git a/src/libs/installer/persistentsettings.cpp b/src/libs/installer/persistentsettings.cpp deleted file mode 100644 index ecafe7682..000000000 --- a/src/libs/installer/persistentsettings.cpp +++ /dev/null @@ -1,221 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#include "persistentsettings.h" - -#include <QtCore/QDebug> -#include <QtCore/QFile> -#include <QtCore/QVariant> -#include <QtXml/QDomDocument> -#include <QtXml/QDomCDATASection> -#include <QtXml/QDomElement> - - -using namespace ProjectExplorer; - -PersistentSettingsReader::PersistentSettingsReader() -{ -} - -QVariant PersistentSettingsReader::restoreValue(const QString &variable) const -{ - if (m_valueMap.contains(variable)) - return m_valueMap.value(variable); - return QVariant(); -} - -QVariantMap PersistentSettingsReader::restoreValues() const -{ - return m_valueMap; -} - -bool PersistentSettingsReader::load(const QString &fileName) -{ - m_valueMap.clear(); - - QFile file(fileName); - if (!file.open(QIODevice::ReadOnly)) - return false; - - QDomDocument doc; - if (!doc.setContent(&file)) - return false; - - QDomElement root = doc.documentElement(); - if (root.nodeName() != QLatin1String("qtcreator")) - return false; - - QDomElement child = root.firstChildElement(); - for (; !child.isNull(); child = child.nextSiblingElement()) { - if (child.nodeName() == QLatin1String("data")) - readValues(child); - } - - file.close(); - return true; -} - -QVariant PersistentSettingsReader::readValue(const QDomElement &valElement) const -{ - QString name = valElement.nodeName(); - QString type = valElement.attribute(QLatin1String("type")); - QVariant v; - - if (name == QLatin1String("value")) { - if(type == QLatin1String("QChar")) { - //Workaround: QTBUG-12345 - v.setValue(QChar(valElement.text().at(0))); - } else { - v.setValue(valElement.text()); - v.convert(QVariant::nameToType(type.toLatin1().data())); - } - } else if (name == QLatin1String("valuelist")) { - QDomElement child = valElement.firstChildElement(); - QList<QVariant> valList; - for (; !child.isNull(); child = child.nextSiblingElement()) { - valList << readValue(child); - } - v.setValue(valList); - } else if (name == QLatin1String("valuemap")) { - QDomElement child = valElement.firstChildElement(); - QMap<QString, QVariant> valMap; - for (; !child.isNull(); child = child.nextSiblingElement()) { - QString key = child.attribute(QLatin1String("key")); - valMap.insert(key, readValue(child)); - } - v.setValue(valMap); - } - - return v; -} - -void PersistentSettingsReader::readValues(const QDomElement &data) -{ - QString variable; - QVariant v; - - QDomElement child = data.firstChildElement(); - for (; !child.isNull(); child = child.nextSiblingElement()) { - if (child.nodeName() == QLatin1String("variable")) - variable = child.text(); - else - v = readValue(child); - } - - m_valueMap.insert(variable, v); -} - -/// -/// PersistentSettingsWriter -/// - -PersistentSettingsWriter::PersistentSettingsWriter() -{ -} - -void PersistentSettingsWriter::writeValue(QDomElement &ps, const QVariant &variant) -{ - if (variant.type() == QVariant::StringList || variant.type() == QVariant::List) { - QDomElement values = ps.ownerDocument().createElement(QLatin1String("valuelist")); - values.setAttribute(QLatin1String("type"), QLatin1String(QVariant::typeToName(QVariant::List))); - QList<QVariant> varList = variant.toList(); - foreach (const QVariant &var, varList) { - writeValue(values, var); - } - ps.appendChild(values); - } else if (variant.type() == QVariant::Map) { - QDomElement values = ps.ownerDocument().createElement(QLatin1String("valuemap")); - values.setAttribute(QLatin1String("type"), QLatin1String(QVariant::typeToName(QVariant::Map))); - - QMap<QString, QVariant> varMap = variant.toMap(); - QMap<QString, QVariant>::const_iterator i = varMap.constBegin(); - while (i != varMap.constEnd()) { - writeValue(values, i.value()); - values.lastChild().toElement(). - setAttribute(QLatin1String("key"), i.key()); - ++i; - } - - ps.appendChild(values); - } else { - QDomElement value = ps.ownerDocument().createElement(QLatin1String("value")); - ps.appendChild(value); - QDomText valueText = ps.ownerDocument().createTextNode(variant.toString()); - value.appendChild(valueText); - value.setAttribute(QLatin1String("type"), QLatin1String(variant.typeName())); - ps.appendChild(value); - } -} - -void PersistentSettingsWriter::saveValue(const QString &variable, const QVariant &value) -{ - m_valueMap[variable] = value; -} - -bool PersistentSettingsWriter::save(const QString &fileName, const QString &docType) -{ - QFile file(fileName); - if (!file.open(QIODevice::WriteOnly)) - return false; - - QDomDocument doc(docType); - - QDomElement root = doc.createElement(QLatin1String("qtcreator")); - doc.appendChild(root); - - QMap<QString, QVariant>::const_iterator i = m_valueMap.constBegin(); - while (i != m_valueMap.constEnd()) { - QDomElement ps = doc.createElement(QLatin1String("data")); - root.appendChild(ps); - - QDomElement variable = doc.createElement(QLatin1String("variable")); - ps.appendChild(variable); - QDomText variableText = doc.createTextNode(i.key()); - variable.appendChild(variableText); - - writeValue(ps, i.value()); - ++i; - } - - file.write(doc.toByteArray()); - file.close(); - return true; -} diff --git a/src/libs/installer/persistentsettings.h b/src/libs/installer/persistentsettings.h deleted file mode 100644 index 71249cd70..000000000 --- a/src/libs/installer/persistentsettings.h +++ /dev/null @@ -1,84 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#ifndef PERSISTENTSETTINGS_H -#define PERSISTENTSETTINGS_H - -#include "projectexplorer_export.h" - -#include <QtCore/QMap> -#include <QtCore/QVariant> - -QT_BEGIN_NAMESPACE -class QDomElement; -QT_END_NAMESPACE - -namespace ProjectExplorer { - -class PROJECTEXPLORER_EXPORT PersistentSettingsReader -{ -public: - PersistentSettingsReader(); - QVariant restoreValue(const QString &variable) const; - QVariantMap restoreValues() const; - bool load(const QString & fileName); - -private: - QVariant readValue(const QDomElement &valElement) const; - void readValues(const QDomElement &data); - QMap<QString, QVariant> m_valueMap; -}; - -class PROJECTEXPLORER_EXPORT PersistentSettingsWriter -{ -public: - PersistentSettingsWriter(); - void saveValue(const QString &variable, const QVariant &value); - bool save(const QString &fileName, const QString &docType); - -private: - void writeValue(QDomElement &ps, const QVariant &value); - QMap<QString, QVariant> m_valueMap; -}; - -} // namespace ProjectExplorer - -#endif // PERSISTENTSETTINGS_H diff --git a/src/libs/installer/productkeycheck.cpp b/src/libs/installer/productkeycheck.cpp index a4af2b6d3..232dbb719 100644 --- a/src/libs/installer/productkeycheck.cpp +++ b/src/libs/installer/productkeycheck.cpp @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (c) 2012 Digia Plc and/or its subsidiary(-ies). +** Copyright (c) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Installer Framework @@ -27,18 +27,13 @@ ** **************************************************************************/ -#include <productkeycheck.h> -#include <packagemanagercore.h> +#include "productkeycheck.h" +#include "packagemanagercore.h" class ProductKeyCheckPrivate { - public: - static QPointer<QInstaller::PackageManagerCore> core; }; -QPointer<QInstaller::PackageManagerCore> ProductKeyCheckPrivate::core = 0; - - ProductKeyCheck::ProductKeyCheck() : d(new ProductKeyCheckPrivate()) { @@ -49,20 +44,17 @@ ProductKeyCheck::~ProductKeyCheck() delete d; } -ProductKeyCheck *ProductKeyCheck::instance(QInstaller::PackageManagerCore *core) +ProductKeyCheck *ProductKeyCheck::instance() { static ProductKeyCheck instance; - if (core) - instance.setPackageManagerCore(core); return &instance; } -void ProductKeyCheck::setPackageManagerCore(QInstaller::PackageManagerCore *core) +void ProductKeyCheck::init(QInstaller::PackageManagerCore *core) { - ProductKeyCheckPrivate::core = core; + Q_UNUSED(core) } - bool ProductKeyCheck::hasValidKey() { return true; @@ -89,9 +81,13 @@ bool ProductKeyCheck::isValidLicenseTextFile(const QString &/*fileName*/) return true; } - bool ProductKeyCheck::isValidRepository(const QInstaller::Repository &repository) const { Q_UNUSED(repository) return true; -}
\ No newline at end of file +} + +QList<int> ProductKeyCheck::registeredPages() const +{ + return QList<int>(); +} diff --git a/src/libs/installer/productkeycheck.h b/src/libs/installer/productkeycheck.h index 6d72089e2..3df747f37 100644 --- a/src/libs/installer/productkeycheck.h +++ b/src/libs/installer/productkeycheck.h @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (c) 2012 Digia Plc and/or its subsidiary(-ies). +** Copyright (c) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Installer Framework @@ -30,11 +30,9 @@ #ifndef PRODUCTKEYCHECK_H #define PRODUCTKEYCHECK_H -#include "qinstallerglobal.h" +#include "installer_global.h" #include <QString> -#include <QHash> -#include <QPointer> namespace QInstaller{ class PackageManagerCore; @@ -47,8 +45,8 @@ class INSTALLER_EXPORT ProductKeyCheck { public: ~ProductKeyCheck(); - static ProductKeyCheck *instance(QInstaller::PackageManagerCore *core = 0); - static void setPackageManagerCore(QInstaller::PackageManagerCore *core); + static ProductKeyCheck *instance(); + void init(QInstaller::PackageManagerCore *core); // was validLicense bool hasValidKey(); @@ -64,9 +62,12 @@ public: // to filter repositories not matching the license bool isValidRepository(const QInstaller::Repository &repository) const; + QList<int> registeredPages() const; + private: ProductKeyCheck(); ProductKeyCheckPrivate *const d; + Q_DISABLE_COPY(ProductKeyCheck) }; #endif // PRODUCTKEYCHECK_H diff --git a/src/libs/installer/progresscoordinator.h b/src/libs/installer/progresscoordinator.h index 263b25695..bdd154195 100644 --- a/src/libs/installer/progresscoordinator.h +++ b/src/libs/installer/progresscoordinator.h @@ -42,13 +42,15 @@ #ifndef PROGRESSCOORDINATOR_H #define PROGRESSCOORDINATOR_H +#include "installer_global.h" + #include <QtCore/QHash> #include <QtCore/QObject> #include <QtCore/QPointer> namespace QInstaller { -class ProgressCoordinator : public QObject +class INSTALLER_EXPORT ProgressCoordinator : public QObject { Q_OBJECT diff --git a/src/libs/installer/projectexplorer_export.h b/src/libs/installer/projectexplorer_export.h deleted file mode 100644 index 0e8cb470b..000000000 --- a/src/libs/installer/projectexplorer_export.h +++ /dev/null @@ -1 +0,0 @@ -#define PROJECTEXPLORER_EXPORT diff --git a/src/libs/installer/qtcreatorpersistentsettings.cpp b/src/libs/installer/qtcreatorpersistentsettings.cpp deleted file mode 100644 index bc035b422..000000000 --- a/src/libs/installer/qtcreatorpersistentsettings.cpp +++ /dev/null @@ -1,236 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#include "qtcreatorpersistentsettings.h" -#include "qtcreator_constants.h" - -#include <QDebug> -#include <QStringList> -#include <QFile> -#include <QDir> - -QtCreatorPersistentSettings::QtCreatorPersistentSettings() -{ -} - -bool QtCreatorPersistentSettings::init(const QString &fileName) -{ - Q_ASSERT(!fileName.isEmpty()); - if (fileName.isEmpty()) - return false; - m_fileName = fileName; - if (m_reader.load(m_fileName) && !versionCheck()) - return false; - - m_toolChains = readValidToolChains(); - m_abiToDebuggerHash = readAbiToDebuggerHash(); - - return true; -} - -bool QtCreatorPersistentSettings::versionCheck() -{ - QVariantMap data = m_reader.restoreValues(); - - // Check version: - int version = data.value(QLatin1String(TOOLCHAIN_FILE_VERSION_KEY), 0).toInt(); - if (version < 1) - return false; - return true; -} - - -QHash<QString, QVariantMap> QtCreatorPersistentSettings::readValidToolChains() -{ - if (m_fileName.isEmpty()) - return QHash<QString, QVariantMap>(); - - QHash<QString, QVariantMap> toolChainHash; - - QVariantMap data = m_reader.restoreValues(); - - int count = data.value(QLatin1String(TOOLCHAIN_COUNT_KEY), 0).toInt(); - for (int i = 0; i < count; ++i) { - const QString key = QLatin1String(TOOLCHAIN_DATA_KEY) + QString::number(i); - - const QVariantMap toolChainMap = data.value(key).toMap(); - - //gets the path variable, hope ".Path" will stay in QtCreator - QStringList pathContainingKeyList = QStringList(toolChainMap.keys()).filter(QLatin1String( - ".Path")); - foreach (const QString& pathKey, pathContainingKeyList) { - QString path = toolChainMap.value(pathKey).toString(); - if (!path.isEmpty() && QFile::exists(path)) { - toolChainHash.insert(path, toolChainMap); - } - } - } - return toolChainHash; -} - -QHash<QString, QString> QtCreatorPersistentSettings::abiToDebuggerHash() -{ - return m_abiToDebuggerHash; -} - -QHash<QString, QString> QtCreatorPersistentSettings::readAbiToDebuggerHash() -{ - if (m_fileName.isEmpty()) - return QHash<QString, QString>(); - - QHash<QString, QString> abiToDebuggerHash; - - QVariantMap data = m_reader.restoreValues(); - - // Read default debugger settings (if any) - int count = data.value(QLatin1String(DEFAULT_DEBUGGER_COUNT_KEY)).toInt(); - for (int i = 0; i < count; ++i) { - const QString abiKey = QString::fromLatin1(DEFAULT_DEBUGGER_ABI_KEY) + QString::number(i); - if (!data.contains(abiKey)) - continue; - const QString pathKey = QString::fromLatin1(DEFAULT_DEBUGGER_PATH_KEY) + QString::number(i); - if (!data.contains(pathKey)) - continue; - abiToDebuggerHash.insert(data.value(abiKey).toString(), data.value(pathKey).toString()); - } - return abiToDebuggerHash; -} - -bool QtCreatorPersistentSettings::addToolChain(const QtCreatorToolChain &toolChain) -{ - if (toolChain.key.isEmpty()) - return false; - if (toolChain.type.isEmpty()) - return false; - if (toolChain.displayName.isEmpty()) - return false; - if (toolChain.abiString.isEmpty()) - return false; - if (toolChain.compilerPath.isEmpty()) - return false; - - QVariantMap newToolChainVariantMap; - - newToolChainVariantMap.insert(QLatin1String(ID_KEY), - QString::fromLatin1("%1:%2.%3").arg(toolChain.type, QFileInfo(toolChain.compilerPath - ).absoluteFilePath(), toolChain.abiString)); - newToolChainVariantMap.insert(QLatin1String(DISPLAY_NAME_KEY), toolChain.displayName); - newToolChainVariantMap.insert(QString::fromLatin1("ProjectExplorer.%1.Path").arg(toolChain.key), - QFileInfo(toolChain.compilerPath).absoluteFilePath()); - newToolChainVariantMap.insert(QString::fromLatin1("ProjectExplorer.%1.TargetAbi").arg(toolChain.key), - toolChain.abiString); - newToolChainVariantMap.insert(QString::fromLatin1("ProjectExplorer.%1.Debugger").arg(toolChain.key), - QFileInfo(toolChain.debuggerPath).absoluteFilePath()); - - m_toolChains.insert(QFileInfo(toolChain.compilerPath).absoluteFilePath(), newToolChainVariantMap); - return true; -} - -bool QtCreatorPersistentSettings::removeToolChain(const QtCreatorToolChain &toolChain) -{ - m_toolChains.remove(QFileInfo(toolChain.compilerPath).absoluteFilePath()); - return true; -} - -void QtCreatorPersistentSettings::addDefaultDebugger(const QString &abiString, const QString &debuggerPath) -{ - m_abiToDebuggerHash.insert(abiString, debuggerPath); -} - -void QtCreatorPersistentSettings::removeDefaultDebugger(const QString &abiString) -{ - m_abiToDebuggerHash.remove(abiString); -} - -bool QtCreatorPersistentSettings::save() -{ - if (m_fileName.isEmpty()) - return false; - - m_writer.saveValue(QLatin1String(DEFAULT_DEBUGGER_COUNT_KEY), m_abiToDebuggerHash.count()); - - QHashIterator<QString, QString> it(m_abiToDebuggerHash); - int debuggerCounter = 0; - while (it.hasNext()) { - it.next(); - const QString abiKey = QString::fromLatin1(DEFAULT_DEBUGGER_ABI_KEY) + QString::number( - debuggerCounter); - const QString pathKey = QString::fromLatin1(DEFAULT_DEBUGGER_PATH_KEY) + QString::number( - debuggerCounter); - m_writer.saveValue(abiKey, it.key()); - m_writer.saveValue(pathKey, it.value()); - debuggerCounter++; - } - - m_writer.saveValue(QLatin1String(TOOLCHAIN_COUNT_KEY), m_toolChains.count()); - - int toolChainCounter = 0; - - foreach (QVariantMap toolChainMap, m_toolChains.values()) { - if (toolChainMap.isEmpty()) - continue; - - //if we added a new debugger we need to adjust the tool chains - QString abiString; - //find the abiString - foreach (const QString &key, toolChainMap.keys()) { - if (key.contains(QLatin1String(".TargetAbi"))) { - abiString = toolChainMap.value(key).toString(); - break; - } - } - //adjust debugger path - foreach (const QString &key, toolChainMap.keys()) { - if (key.contains(QLatin1String(".Debugger"))) { - toolChainMap.insert(key, m_abiToDebuggerHash.value(abiString)); - break; - } - } - - m_writer.saveValue(QLatin1String(TOOLCHAIN_DATA_KEY) + QString::number(toolChainCounter++), - toolChainMap); - } - - m_writer.saveValue(QLatin1String(TOOLCHAIN_FILE_VERSION_KEY), 1); - - QDir().mkpath(QFileInfo(m_fileName).absolutePath()); - return m_writer.save(m_fileName, QLatin1String("QtCreatorToolChains")); -} diff --git a/src/libs/installer/qtcreatorpersistentsettings.h b/src/libs/installer/qtcreatorpersistentsettings.h deleted file mode 100644 index 4e299475a..000000000 --- a/src/libs/installer/qtcreatorpersistentsettings.h +++ /dev/null @@ -1,88 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#ifndef QTCREATORPERSISTENTSETTINGS_H -#define QTCREATORPERSISTENTSETTINGS_H - -#include "persistentsettings.h" - -#include <QHash> -#include <QString> -#include <QVariantMap> - -struct QtCreatorToolChain -{ - QString key; - QString type; - QString displayName; - QString abiString; - QString compilerPath; - QString debuggerPath; - QString armVersion; - QString force32Bit; -}; - -class QtCreatorPersistentSettings -{ -public: - QtCreatorPersistentSettings(); - bool init(const QString &fileName); - bool addToolChain(const QtCreatorToolChain &toolChain); - bool removeToolChain(const QtCreatorToolChain &toolChain); - void addDefaultDebugger(const QString &abiString, const QString &debuggerPath); - void removeDefaultDebugger(const QString &abiString); - bool save(); - QHash<QString, QString> abiToDebuggerHash(); - -private: - QHash<QString, QVariantMap> readValidToolChains(); - QHash<QString, QString> readAbiToDebuggerHash(); - bool versionCheck(); - - QString m_fileName; - QHash<QString, QVariantMap> m_toolChains; - QHash<QString, QString> m_abiToDebuggerHash; - ProjectExplorer::PersistentSettingsReader m_reader; - ProjectExplorer::PersistentSettingsWriter m_writer; - -}; - -#endif // QTCREATORPERSISTENTSETTINGS_H diff --git a/src/libs/installer/qtpatch.cpp b/src/libs/installer/qtpatch.cpp index 6581815c2..825c9ad48 100644 --- a/src/libs/installer/qtpatch.cpp +++ b/src/libs/installer/qtpatch.cpp @@ -75,7 +75,7 @@ QHash<QString, QByteArray> QtPatch::qmakeValues(const QString &qmakePath, QByteA // in some cases qmake is not runable, because another process is blocking it(filewatcher ...) int waitCount = 0; - while (qmakeValueHash.isEmpty() && waitCount < 60) { + while (qmakeValueHash.isEmpty() && waitCount < 3) { QFileInfo qmake(qmakePath); if (!qmake.exists()) { @@ -92,13 +92,16 @@ QHash<QString, QByteArray> QtPatch::qmakeValues(const QString &qmakePath, QByteA QProcess process; process.start(qmake.absoluteFilePath(), args, QIODevice::ReadOnly); - if (process.waitForFinished(2000)) { + if (process.waitForFinished(10000)) { + QByteArray output = process.readAllStandardOutput(); + qmakeOutput->append(output); if (process.exitStatus() == QProcess::CrashExit) { - qDebug() << qmakePath << "was crashed"; + qWarning() << qmake.absoluteFilePath() << args + << "crashed with exit code" << process.exitCode() + << "standard output: " << output + << "error output: " << process.readAllStandardError(); return qmakeValueHash; } - QByteArray output = process.readAllStandardOutput(); - qmakeOutput->append(output); qmakeValueHash = readQmakeOutput(output); } if (qmakeValueHash.isEmpty()) { @@ -113,7 +116,7 @@ QHash<QString, QByteArray> QtPatch::qmakeValues(const QString &qmakePath, QByteA } if (qmakeValueHash.isEmpty()) - qDebug() << "Can't get any query output from qmake."; + qDebug() << "Cannot get any query output from qmake."; return qmakeValueHash; } diff --git a/src/libs/installer/registerdefaultdebuggeroperation.cpp b/src/libs/installer/registerdefaultdebuggeroperation.cpp deleted file mode 100644 index d6cdac851..000000000 --- a/src/libs/installer/registerdefaultdebuggeroperation.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#include "registerdefaultdebuggeroperation.h" - -#include "persistentsettings.h" -#include "packagemanagercore.h" -#include "qtcreator_constants.h" -#include "qtcreatorpersistentsettings.h" - -#include <QString> -#include <QFileInfo> -#include <QDir> -#include <QSettings> -#include <QDebug> - -using namespace QInstaller; - -using namespace ProjectExplorer; - -//TODO move this to a general location it is used on some classes -static QString fromNativeSeparatorsAllOS(const QString &pathName) -{ - QString n = pathName; - for (int i = 0; i < n.size(); ++i) { - if (n.at(i) == QLatin1Char('\\')) - n[i] = QLatin1Char('/'); - } - return n; -} - -RegisterDefaultDebuggerOperation::RegisterDefaultDebuggerOperation() -{ - setName(QLatin1String("RegisterDefaultDebugger")); -} - -void RegisterDefaultDebuggerOperation::backup() -{ -} - -/** application binary interface - this is an internal creator typ as a String CPU-OS-OS_FLAVOR-BINARY_FORMAT-WORD_WIDTH - * CPU: arm x86 mips ppc itanium - * OS: linux macos symbian unix windows - * OS_FLAVOR: generic maemo meego generic device emulator generic msvc2005 msvc2008 msvc2010 msys ce - * BINARY_FORMAT: elf pe mach_o qml_rt - * WORD_WIDTH: 8 16 32 64 - */ - -bool RegisterDefaultDebuggerOperation::performOperation() -{ - const QStringList args = arguments(); - - if (args.count() != 2) { - setError(InvalidArguments); - setErrorString(tr("Invalid arguments in %0: %1 arguments given, %2 expected%3.") - .arg(name()).arg(arguments().count()).arg(tr("exactly 2"), QLatin1String(""))); - return false; - } - - QString toolChainsXmlFilePath; - - PackageManagerCore *const core = value(QLatin1String("installer")).value<PackageManagerCore*>(); - if (!core) { - setError(UserDefinedError); - setErrorString(tr("Needed installer object in \"%1\" operation is empty.").arg(name())); - return false; - } - if (core->value(scQtCreatorInstallerToolchainsFile).isEmpty()) { - setError(UserDefinedError); - setErrorString(tr("There is no value set for %1 on the installer object.").arg( - scQtCreatorInstallerToolchainsFile)); - return false; - } - toolChainsXmlFilePath = core->value(scQtCreatorInstallerToolchainsFile); - - int argCounter = 0; - const QString &abiString = args.at(argCounter++); //for example x86-windows-msys-pe-32bit - const QString &debuggerPath = fromNativeSeparatorsAllOS(args.at(argCounter++)); - - QtCreatorPersistentSettings creatorToolChainSettings; - - if (!creatorToolChainSettings.init(toolChainsXmlFilePath)) { - setError(UserDefinedError); - setErrorString(tr("Can't read from tool chains xml file(%1) correctly.") - .arg(toolChainsXmlFilePath)); - return false; - } - - creatorToolChainSettings.addDefaultDebugger(abiString, debuggerPath); - return creatorToolChainSettings.save(); -} - -bool RegisterDefaultDebuggerOperation::undoOperation() -{ - const QStringList args = arguments(); - - if (args.count() != 2) { - setError(InvalidArguments); - setErrorString(tr("Invalid arguments in %0: %1 arguments given, 2 expected.") - .arg(name()).arg(args.count())); - return false; - } - - PackageManagerCore *const core = value(QLatin1String("installer")).value<PackageManagerCore*>(); - if (!core) { - setError(UserDefinedError); - setErrorString(tr("Needed installer object in \"%1\" operation is empty.").arg(name())); - return false; - } - - // default value is the old value to keep the possibility that old saved operations can run undo -#ifdef Q_OS_MAC - QString toolChainsXmlFilePath = core->value(scQtCreatorInstallerToolchainsFile, - QString::fromLatin1("%1/Qt Creator.app/Contents/Resources/QtProject/toolChains.xml").arg( - core->value(QLatin1String("TargetDir")))); -#else - QString toolChainsXmlFilePath = core->value(scQtCreatorInstallerToolchainsFile, - QString::fromLatin1("%1/QtCreator/share/qtcreator/QtProject/toolChains.xml").arg(core->value( - QLatin1String("TargetDir")))); -#endif - - int argCounter = 0; - const QString &abiString = args.at(argCounter++); //for example x86-windows-msys-pe-32bit - const QString &debuggerPath = fromNativeSeparatorsAllOS(args.at(argCounter++)); - Q_UNUSED(debuggerPath) - - QtCreatorPersistentSettings creatorToolChainSettings; - - creatorToolChainSettings.init(toolChainsXmlFilePath); - creatorToolChainSettings.removeDefaultDebugger(abiString); - return creatorToolChainSettings.save(); -} - -bool RegisterDefaultDebuggerOperation::testOperation() -{ - return true; -} - -Operation *RegisterDefaultDebuggerOperation::clone() const -{ - return new RegisterDefaultDebuggerOperation(); -} diff --git a/src/libs/installer/registerqtincreatorqnxoperation.cpp b/src/libs/installer/registerqtincreatorqnxoperation.cpp deleted file mode 100644 index be99de4c7..000000000 --- a/src/libs/installer/registerqtincreatorqnxoperation.cpp +++ /dev/null @@ -1,248 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#include "registerqtincreatorqnxoperation.h" - -#include "packagemanagercore.h" -#include "qtcreator_constants.h" -#include "persistentsettings.h" - -#include <QString> -#include <QFileInfo> -#include <QDir> -#include <QSettings> -#include <QDebug> - - -using namespace QInstaller; - -// TODO: move this to a general location it is used on some classes -static QString fromNativeSeparatorsAllOS(const QString &pathName) -{ - QString n = pathName; - for (int i = 0; i < n.size(); ++i) { - if (n.at(i) == QLatin1Char('\\')) - n[i] = QLatin1Char('/'); - } - return n; -} - -static QString absoluteQmakePath(const QString &path) -{ - QString versionQmakePath = QDir(path).absolutePath(); - if (!versionQmakePath.endsWith(QLatin1String("qmake")) - && !versionQmakePath.endsWith(QLatin1String("qmake.exe"))) { -#if defined (Q_OS_WIN) - versionQmakePath.append(QLatin1String("/bin/qmake.exe")); -#elif defined(Q_OS_UNIX) - versionQmakePath.append(QLatin1String("/bin/qmake")); -#endif - } - return fromNativeSeparatorsAllOS(versionQmakePath); -} - -RegisterQtInCreatorQNXOperation::RegisterQtInCreatorQNXOperation() -{ - setName(QLatin1String("RegisterQtInCreatorQNX")); -} - -void RegisterQtInCreatorQNXOperation::backup() -{ -} - -// Parameter List: -// Name - String displayed as name in Qt Creator -// qmake path - location of the qmake binary -// Type identifier - Desktop, Simulator, Symbian, ... -// SDK identifier - unique string to identify Qt version inside of the SDK (eg. desk473, simu11, ...) -// System Root Path -// sbs path -bool RegisterQtInCreatorQNXOperation::performOperation() -{ - const QStringList args = arguments(); - - if (args.count() < 5) { - setError(InvalidArguments); - setErrorString(tr("Invalid arguments in %0: %1 arguments given, %2 expected%3.") - .arg(name()).arg(arguments().count()).arg(tr("at least 5"), QLatin1String(""))); - return false; - } - - PackageManagerCore *const core = value(QLatin1String("installer")).value<PackageManagerCore*>(); - if (!core) { - setError(UserDefinedError); - setErrorString(tr("Needed installer object in \"%1\" operation is empty.").arg(name())); - return false; - } - - if (core->value(scQtCreatorInstallerQtVersionFile).isEmpty()) { - setError(UserDefinedError); - setErrorString(tr("There is no value set for %1 on the installer object.").arg( - scQtCreatorInstallerQtVersionFile)); - return false; - } - const QString qtVersionsFileName = core->value(scQtCreatorInstallerQtVersionFile); - int argCounter = 0; - const QString &versionName = args.at(argCounter++); - const QString &path = QDir::toNativeSeparators(args.value(argCounter++)); - const QString versionQmakePath = absoluteQmakePath(path); - - const QString &sdkPath = args.at(argCounter++); - const QString &versionTypeIdentifier = args.at(argCounter++); - const QString &versionSDKIdentifier = args.at(argCounter++); - const QString &versionSystemRoot = fromNativeSeparatorsAllOS(args.value(argCounter++)); - const QString &versionSbsPath = fromNativeSeparatorsAllOS(args.value(argCounter++)); - - ProjectExplorer::PersistentSettingsReader reader; - int qtVersionCount = 0; - QVariantMap map; - if (reader.load(qtVersionsFileName)) { - map = reader.restoreValues(); - qtVersionCount = map.value(QLatin1String("QtVersion.Count")).toInt(); - map.remove(QLatin1String("QtVersion.Count")); - map.remove(QLatin1String("Version")); - } - - ProjectExplorer::PersistentSettingsWriter writer; - // Store old qt versions - if (!map.isEmpty()) { - for (int i = 0; i < qtVersionCount; ++i) { - writer.saveValue(QString::fromLatin1("QtVersion.%1").arg(i) - , map[QLatin1String("QtVersion.") + QString::number(i)].toMap()); - } - map.clear(); - } - // Enter new version - map.insert(QLatin1String("Id"), -1); - map.insert(QLatin1String("Arch"), 1); - map.insert(QLatin1String("Name"), versionName); - map.insert(QLatin1String("QMakePath"), versionQmakePath); - map.insert(QLatin1String("SDKPath"), sdkPath); - map.insert(QLatin1String("QtVersion.Type"), - QLatin1String("Qt4ProjectManager.QtVersion.") + versionTypeIdentifier); - map.insert(QLatin1String("isAutodetected"), true); - map.insert(QLatin1String("autodetectionSource"), - QLatin1String("SDK.") + versionSDKIdentifier); - if (!versionSystemRoot.isEmpty()) - map.insert(QLatin1String("SystemRoot"), versionSystemRoot); - if (!versionSbsPath.isEmpty()) - map.insert(QLatin1String("SBSv2Directory"), versionSbsPath); - - writer.saveValue(QLatin1String("QtVersion.") + QString::number(qtVersionCount), map); - - writer.saveValue(QLatin1String("Version"), 1); - writer.saveValue(QLatin1String("QtVersion.Count"), qtVersionCount + 1); - QDir().mkpath(QFileInfo(qtVersionsFileName).absolutePath()); - writer.save(qtVersionsFileName, QLatin1String("QtCreatorQtVersions")); - - return true; -} - -bool RegisterQtInCreatorQNXOperation::undoOperation() -{ - const QStringList args = arguments(); - - if (args.count() < 4) { - setError(InvalidArguments); - setErrorString(tr("Invalid arguments in %0: %1 arguments given, minimum 4 expected.") - .arg(name()).arg(args.count())); - return false; - } - - PackageManagerCore *const core = value(QLatin1String("installer")).value<PackageManagerCore*>(); - if (!core) { - setError(UserDefinedError); - setErrorString(tr("Needed installer object in \"%1\" operation is empty.").arg(name())); - return false; - } - - // default value is the old value to keep the possibility that old saved operations can run undo -#ifdef Q_OS_MAC - QString qtVersionsFileName = core->value(scQtCreatorInstallerQtVersionFile, - QString::fromLatin1("%1/Qt Creator.app/Contents/Resources/QtProject/qtversion.xml").arg( - core->value(QLatin1String("TargetDir")))); -#else - QString qtVersionsFileName = core->value(scQtCreatorInstallerQtVersionFile, - QString::fromLatin1("%1/QtCreator/share/qtcreator/QtProject/qtversion.xml").arg(core->value( - QLatin1String("TargetDir")))); -#endif - - ProjectExplorer::PersistentSettingsReader reader; - // If no file, then it has been removed already - if (!reader.load(qtVersionsFileName)) - return true; - - const QVariantMap map = reader.restoreValues(); - - ProjectExplorer::PersistentSettingsWriter writer; - const int qtVersionCount = map.value(QLatin1String("QtVersion.Count")).toInt(); - - int currentVersionIndex = 0; - for (int i = 0; i < qtVersionCount; ++i) { - QVariantMap versionMap = map[QLatin1String("QtVersion.") + QString::number(i)].toMap(); - - const QString path = QDir::toNativeSeparators(args.value(1)); - const QString versionQmakePath = absoluteQmakePath(path); - - //use absoluteQmakePath function to normalize the path string, for example // - const QString existingQtQMakePath = absoluteQmakePath( - versionMap[QLatin1String("QMakePath")].toString()); - if (existingQtQMakePath == versionQmakePath) - continue; - writer.saveValue(QString::fromLatin1("QtVersion.%1").arg(currentVersionIndex++), versionMap); - } - - writer.saveValue(QLatin1String("QtVersion.Count"), currentVersionIndex); - writer.saveValue(QLatin1String("Version"), map[QLatin1String("Version")].toInt()); - - writer.save(qtVersionsFileName, QLatin1String("QtCreatorQtVersions")); - return true; -} - -bool RegisterQtInCreatorQNXOperation::testOperation() -{ - return true; -} - -Operation *RegisterQtInCreatorQNXOperation::clone() const -{ - return new RegisterQtInCreatorQNXOperation(); -} diff --git a/src/libs/installer/registertoolchainoperation.cpp b/src/libs/installer/registertoolchainoperation.cpp deleted file mode 100644 index 0caf1451b..000000000 --- a/src/libs/installer/registertoolchainoperation.cpp +++ /dev/null @@ -1,198 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#include "registertoolchainoperation.h" - -#include "persistentsettings.h" -#include "packagemanagercore.h" -#include "qtcreator_constants.h" -#include "qtcreatorpersistentsettings.h" - -#include <QtCore/QDebug> -#include <QtCore/QDir> -#include <QtCore/QFileInfo> -#include <QtCore/QSettings> -#include <QtCore/QString> - -using namespace QInstaller; - -using namespace ProjectExplorer; - -RegisterToolChainOperation::RegisterToolChainOperation() -{ - setName(QLatin1String("RegisterToolChain")); -} - -void RegisterToolChainOperation::backup() -{ -} - -bool RegisterToolChainOperation::performOperation() -{ - const QStringList args = arguments(); - - if (args.count() < 4) { - setError(InvalidArguments); - setErrorString(tr("Invalid arguments in %0: %1 arguments given, %2 expected%3.") - .arg(name()).arg(arguments().count()).arg(tr("at least 4"), QLatin1String(""))); - return false; - } - - QString toolChainsXmlFilePath; - - PackageManagerCore *const core = value(QLatin1String("installer")).value<PackageManagerCore*>(); - if (!core) { - setError(UserDefinedError); - setErrorString(tr("Needed installer object in '%1' operation is empty.").arg(name())); - return false; - } - if (core->value(scQtCreatorInstallerToolchainsFile).isEmpty()) { - setError(UserDefinedError); - setErrorString(tr("There is no value set for '%1' on the installer object.").arg( - scQtCreatorInstallerToolchainsFile)); - return false; - } - toolChainsXmlFilePath = core->value(scQtCreatorInstallerToolchainsFile); - - QtCreatorToolChain toolChain; - - int argCounter = 0; - toolChain.key = args.at(argCounter++); //Qt SDK:gccPath - toolChain.type = args.at(argCounter++); //where this toolchain is defined in QtCreator - toolChain.displayName = args.at(argCounter++); //nice special Toolchain (Qt SDK) - toolChain.abiString = args.at(argCounter++); //x86-windows-msys-pe-32bit - toolChain.compilerPath = QDir::toNativeSeparators(args.at(argCounter++)); //gccPath - if (args.count() > argCounter) - toolChain.debuggerPath = QDir::toNativeSeparators(args.at(argCounter++)); - if (args.count() > argCounter) - toolChain.armVersion = args.at(argCounter++); - if (args.count() > argCounter) - toolChain.force32Bit = args.at(argCounter++); - - QtCreatorPersistentSettings creatorToolChainSettings; - - if (!creatorToolChainSettings.init(toolChainsXmlFilePath)) { - setError(UserDefinedError); - setErrorString(tr("Can't read from tool chains xml file(%1) correctly.") - .arg(toolChainsXmlFilePath)); - return false; - } - - if (!creatorToolChainSettings.addToolChain(toolChain)) { - setError(InvalidArguments); - setErrorString(tr("Some arguments are not right in %1 operation.") - .arg(name()).arg(args.count())); - return false; - } - return creatorToolChainSettings.save(); -} - -bool RegisterToolChainOperation::undoOperation() -{ - const QStringList args = arguments(); - - if (args.count() < 4) { - setError(InvalidArguments); - setErrorString(tr("Invalid arguments in %0: %1 arguments given, minimum 4 expected.") - .arg(name()).arg(args.count())); - return false; - } - - PackageManagerCore *const core = value(QLatin1String("installer")).value<PackageManagerCore*>(); - if (!core) { - setError(UserDefinedError); - setErrorString(tr("Needed installer object in \"%1\" operation is empty.").arg(name())); - return false; - } - - // default value is the old value to keep the possibility that old saved operations can run undo -#ifdef Q_OS_MAC - QString toolChainsXmlFilePath = core->value(scQtCreatorInstallerToolchainsFile, - QString::fromLatin1("%1/Qt Creator.app/Contents/Resources/QtProject/toolChains.xml").arg( - core->value(QLatin1String("TargetDir")))); -#else - QString toolChainsXmlFilePath = core->value(scQtCreatorInstallerToolchainsFile, - QString::fromLatin1("%1/QtCreator/share/qtcreator/QtProject/toolChains.xml").arg(core->value( - QLatin1String("TargetDir")))); -#endif - - QtCreatorToolChain toolChain; - - int argCounter = 0; - toolChain.key = args.at(argCounter++); //Qt SDK:gccPath - toolChain.type = args.at(argCounter++); //where this toolchain is defined in QtCreator - toolChain.displayName = args.at(argCounter++); //nice special Toolchain (Qt SDK) - toolChain.abiString = args.at(argCounter++); //x86-windows-msys-pe-32bit - toolChain.compilerPath = QDir::toNativeSeparators(args.at(argCounter++)); //gccPath - if (args.count() > argCounter) - toolChain.debuggerPath = QDir::toNativeSeparators(args.at(argCounter++)); - if (args.count() > argCounter) - toolChain.armVersion = args.at(argCounter++); - if (args.count() > argCounter) - toolChain.force32Bit = args.at(argCounter++); - - QtCreatorPersistentSettings creatorToolChainSettings; - - if (!creatorToolChainSettings.init(toolChainsXmlFilePath)) { - setError(UserDefinedError); - setErrorString(tr("Can't read from tool chains xml file(%1) correctly.") - .arg(toolChainsXmlFilePath)); - return false; - } - - if (!creatorToolChainSettings.removeToolChain(toolChain)) { - setError(InvalidArguments); - setErrorString(tr("Some arguments are not right in %1 operation.") - .arg(name()).arg(args.count())); - return false; - } - return creatorToolChainSettings.save(); -} - -bool RegisterToolChainOperation::testOperation() -{ - return true; -} - -Operation *RegisterToolChainOperation::clone() const -{ - return new RegisterToolChainOperation(); -} diff --git a/src/libs/installer/registertoolchainoperation.h b/src/libs/installer/registertoolchainoperation.h deleted file mode 100644 index bd745adfb..000000000 --- a/src/libs/installer/registertoolchainoperation.h +++ /dev/null @@ -1,81 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#ifndef REGISTERTOOLCHAINOPERATION_H -#define REGISTERTOOLCHAINOPERATION_H - -#include "qinstallerglobal.h" - -namespace QInstaller { - -/*! - Arguments: - * SDK Path - to find the QtCreator installation - * ToolChainKey - is the internal QtCreator settings key usually: GccToolChain - * toolchain type - where this toolchain is defined in QtCreator - * ProjectExplorer.ToolChain.Gcc ProjectExplorer.ToolChain.Mingw - * ProjectExplorer.ToolChain.LinuxIcc ProjectExplorer.ToolChain.Msvc - * Qt4ProjectManager.ToolChain.GCCE Qt4ProjectManager.ToolChain.Maemo - * display name - the name how it will be displayed in QtCreator - * application binary interface - this is an internal creator typ as a String CPU-OS-OS_FLAVOR-BINARY_FORMAT-WORD_WIDTH - * CPU: arm x86 mips ppc itanium - * OS: linux macos symbian unix windows - * OS_FLAVOR: generic maemo meego generic device emulator generic msvc2005 msvc2008 msvc2010 msys ce - * BINARY_FORMAT: elf pe mach_o qml_rt - * WORD_WIDTH: 8 16 32 64 - * compiler path - the binary which is used as the compiler - * debugger path - the binary which is used as the debugger -*/ -class RegisterToolChainOperation : public Operation -{ -public: - RegisterToolChainOperation(); - - void backup(); - bool performOperation(); - bool undoOperation(); - bool testOperation(); - Operation *clone() const; -}; - -} // namespace QInstaller - -#endif // REGISTERTOOLCHAINOPERATION_H diff --git a/src/libs/installer/scriptengine.cpp b/src/libs/installer/scriptengine.cpp index 9931d956e..a2fe9f049 100644 --- a/src/libs/installer/scriptengine.cpp +++ b/src/libs/installer/scriptengine.cpp @@ -162,16 +162,19 @@ QScriptValue qFileDialogGetExistingDirectory(QScriptContext *context, QScriptEng QScriptValue qFileDialogGetOpenFileName(QScriptContext *context, QScriptEngine *engine) { Q_UNUSED(engine); - const QScriptValue check = checkArguments(context, 0, 2); + const QScriptValue check = checkArguments(context, 0, 3); if (check.isError()) return check; QString caption; QString dir; + QString fileNameFilter; if (context->argumentCount() > 0) caption = context->argument(0).toString(); if (context->argumentCount() > 1) dir = context->argument(1).toString(); - return QFileDialog::getExistingDirectory(0, caption, dir); + if (context->argumentCount() > 2) + fileNameFilter = context->argument(2).toString(); + return QFileDialog::getOpenFileName(0, caption, dir, fileNameFilter); } } //namespace QInstaller @@ -201,6 +204,8 @@ ScriptEngine::ScriptEngine(PackageManagerCore *core) QScriptValue fileDialog = newArray(); fileDialog.setProperty(QLatin1String("getExistingDirectory"), newFunction(qFileDialogGetExistingDirectory)); + fileDialog.setProperty(QLatin1String("getOpenFileName"), + newFunction(qFileDialogGetOpenFileName)); globalObject().setProperty(QLatin1String("QFileDialog"), fileDialog); const QList<Component*> components = m_core->availableComponents(); diff --git a/src/libs/installer/setdemospathonqtoperation.cpp b/src/libs/installer/setdemospathonqtoperation.cpp deleted file mode 100644 index d558b3e21..000000000 --- a/src/libs/installer/setdemospathonqtoperation.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#include "setdemospathonqtoperation.h" - -#include "qtpatch.h" - -#include <QtCore/QDir> -#include <QtCore/QSettings> -#include <QtCore/QDebug> - -using namespace QInstaller; - -SetDemosPathOnQtOperation::SetDemosPathOnQtOperation() -{ - setName(QLatin1String("SetDemosPathOnQt")); -} - -void SetDemosPathOnQtOperation::backup() -{ -} - -bool SetDemosPathOnQtOperation::performOperation() -{ - const QStringList args = arguments(); - - if (args.count() != 2) { - setError(InvalidArguments); - setErrorString(tr("Invalid arguments in %0: %1 arguments given, %2 expected%3.") - .arg(name()).arg(arguments().count()).arg(tr("exactly 2"), QLatin1String(""))); - return false; - } - - const QString qtDir = args.at(0); - QByteArray newValue = QDir::toNativeSeparators(args.at(1)).toUtf8(); - - QString qmakePath = qtDir + QLatin1String("/bin/qmake"); -#ifdef Q_OS_WIN - qmakePath = qmakePath + QLatin1String(".exe"); -#endif - - QByteArray qmakeOutput; - QHash<QString, QByteArray> qmakeValueHash = QtPatch::qmakeValues(qmakePath, &qmakeOutput); - - if (qmakeValueHash.isEmpty()) { - setError(UserDefinedError); - setErrorString(tr("The output of \n'%1 -query'\nis not parseable. Please file a bugreport with this " - "dialog at https://bugreports.qt-project.org.\noutput: %2").arg(QDir::toNativeSeparators(qmakePath), - QString::fromUtf8(qmakeOutput))); - return false; - } - - QByteArray oldValue = qmakeValueHash.value(QLatin1String("QT_INSTALL_DEMOS")); - bool oldQtPathFromQMakeIsEmpty = oldValue.isEmpty(); - if (oldQtPathFromQMakeIsEmpty) { - qDebug() << "qpatch: warning: It was not possible to get the old values from" << qmakePath; - } - - if (newValue.size() >= 255) { - setError(UserDefinedError); - setErrorString(tr("Qt patch error: new Qt demo path '%1'\nneeds to be less than 255 characters.") - .arg(QString::fromLocal8Bit(newValue)) ); - return false; - } - - QString qtConfPath = qtDir + QLatin1String("/bin/qt.conf"); - if (QFile::exists(qtConfPath)) { - QSettings settings(qtConfPath, QSettings::IniFormat); - settings.setValue(QLatin1String("Paths/Demos"), QString::fromUtf8(newValue)); - } - - oldValue = QByteArray("qt_demopath=%1").replace("%1", oldValue); - newValue = QByteArray("qt_demopath=%1").replace("%1", newValue); - - bool isPatched = QtPatch::patchBinaryFile(qmakePath, oldValue, newValue); - if (!isPatched) { - qDebug() << "qpatch: warning: could not patch the demo path in" << qmakePath; - } - - return true; -} - -bool SetDemosPathOnQtOperation::undoOperation() -{ - return true; -} - -bool SetDemosPathOnQtOperation::testOperation() -{ - return true; -} - -Operation *SetDemosPathOnQtOperation::clone() const -{ - return new SetDemosPathOnQtOperation(); -} - diff --git a/src/libs/installer/setexamplespathonqtoperation.cpp b/src/libs/installer/setexamplespathonqtoperation.cpp deleted file mode 100644 index e73aed25a..000000000 --- a/src/libs/installer/setexamplespathonqtoperation.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#include "setexamplespathonqtoperation.h" - -#include "qtpatch.h" - -#include <QtCore/QDir> -#include <QtCore/QSettings> -#include <QtCore/QDebug> - -using namespace QInstaller; - -SetExamplesPathOnQtOperation::SetExamplesPathOnQtOperation() -{ - setName(QLatin1String("SetExamplesPathOnQt")); -} - -void SetExamplesPathOnQtOperation::backup() -{ -} - -bool SetExamplesPathOnQtOperation::performOperation() -{ - const QStringList args = arguments(); - - if (args.count() != 2) { - setError(InvalidArguments); - setErrorString(tr("Invalid arguments in %0: %1 arguments given, %2 expected%3.") - .arg(name()).arg(arguments().count()).arg(tr("exactly 2"), QLatin1String(""))); - return false; - } - - const QString qtDir = args.at(0); - QByteArray newValue = QDir::toNativeSeparators(args.at(1)).toUtf8(); - - QString qmakePath = qtDir + QLatin1String("/bin/qmake"); -#ifdef Q_OS_WIN - qmakePath = qmakePath + QLatin1String(".exe"); -#endif - - QByteArray qmakeOutput; - QHash<QString, QByteArray> qmakeValueHash = QtPatch::qmakeValues(qmakePath, &qmakeOutput); - - if (qmakeValueHash.isEmpty()) { - setError(UserDefinedError); - setErrorString(tr("The output of \n'%1 -query'\nis not parseable. Please file a bugreport with this " - "dialog at https://bugreports.qt-project.org.\noutput: %2").arg(QDir::toNativeSeparators(qmakePath), - QString::fromUtf8(qmakeOutput))); - return false; - } - - QByteArray oldValue = qmakeValueHash.value(QLatin1String("QT_INSTALL_EXAMPLES")); - bool oldQtPathFromQMakeIsEmpty = oldValue.isEmpty(); - if (oldQtPathFromQMakeIsEmpty) { - qDebug() << "qpatch: warning: It was not possible to get the old values from" << qmakePath; - } - - if (newValue.size() >= 255) { - setError(UserDefinedError); - setErrorString(tr("Qt patch error: new Qt example path '%1'\nneeds to be less than 255 characters.") - .arg(QString::fromLocal8Bit(newValue))); - return false; - } - - QString qtConfPath = qtDir + QLatin1String("/bin/qt.conf"); - - if (QFile::exists(qtConfPath)) { - QSettings settings(qtConfPath, QSettings::IniFormat); - settings.setValue( QLatin1String("Paths/Examples"), QString::fromUtf8(newValue)); - } - - oldValue = QByteArray("qt_xmplpath=%1").replace("%1", oldValue); - newValue = QByteArray("qt_xmplpath=%1").replace("%1", newValue); - - bool isPatched = QtPatch::patchBinaryFile(qmakePath, oldValue, newValue); - if (!isPatched) { - qDebug() << "qpatch: warning: could not patch the example path in" << qmakePath; - } - - return true; -} - -bool SetExamplesPathOnQtOperation::undoOperation() -{ - return true; -} - -bool SetExamplesPathOnQtOperation::testOperation() -{ - return true; -} - -Operation *SetExamplesPathOnQtOperation::clone() const -{ - return new SetExamplesPathOnQtOperation(); -} - diff --git a/src/libs/installer/setexamplespathonqtoperation.h b/src/libs/installer/setexamplespathonqtoperation.h deleted file mode 100644 index 7f2df6b4e..000000000 --- a/src/libs/installer/setexamplespathonqtoperation.h +++ /dev/null @@ -1,63 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#ifndef SETEXAMPLESPATHONQTOPERATION_H -#define SETEXAMPLESPATHONQTOPERATION_H - -#include "qinstallerglobal.h" - -namespace QInstaller { - -class SetExamplesPathOnQtOperation : public Operation -{ -public: - SetExamplesPathOnQtOperation(); - - void backup(); - bool performOperation(); - bool undoOperation(); - bool testOperation(); - Operation *clone() const; -}; - -} // namespace - -#endif // SETEXAMPLESPATHONQTOPERATION_H diff --git a/src/libs/installer/setimportspathonqtcoreoperation.cpp b/src/libs/installer/setimportspathonqtcoreoperation.cpp deleted file mode 100644 index 685aee846..000000000 --- a/src/libs/installer/setimportspathonqtcoreoperation.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#include "setimportspathonqtcoreoperation.h" - -#include "qtpatch.h" - -#include <QtCore/QByteArrayMatcher> -#include <QtCore/QDir> -#include <QtCore/QDebug> - -using namespace QInstaller; - -namespace { - QByteArray getOldValue(const QString &binaryPath) - { - QFileInfo fileInfo(binaryPath); - - if (!fileInfo.exists()) { - qDebug() << QString::fromLatin1("qpatch: warning: file '%1' not found").arg(binaryPath); - return QByteArray(); - } - - - QFile file(binaryPath); - int readOpenCount = 0; - while (!file.open(QFile::ReadOnly) && readOpenCount < 20000) { - ++readOpenCount; - qApp->processEvents(); - } - Q_ASSERT(file.isOpen()); - if (!file.isOpen()) { - qDebug() << QString::fromLatin1("qpatch: warning: file '%1' can not be opened as ReadOnly.").arg( - binaryPath); - qDebug() << file.errorString(); - return QByteArray(); - } - - const QByteArray source = file.readAll(); - file.close(); - - int offset = 0; - QByteArray searchValue("qt_impspath="); - QByteArrayMatcher byteArrayMatcher(searchValue); - offset = byteArrayMatcher.indexIn(source, offset); - Q_ASSERT(offset > 0); - if (offset == -1) - return QByteArray(); - - int stringEndPosition = offset; - while(source.at(stringEndPosition++) != '\0') {} - // between the search string and the first \0 is the QByteArray we are looking for - return source.mid(offset + searchValue.size(), stringEndPosition - offset); - } -} - -SetImportsPathOnQtCoreOperation::SetImportsPathOnQtCoreOperation() -{ - setName(QLatin1String("SetImportsPathOnQtCore")); -} - -void SetImportsPathOnQtCoreOperation::backup() -{ -} - -bool SetImportsPathOnQtCoreOperation::performOperation() -{ - const QStringList args = arguments(); - - if (args.count() != 2) { - setError(InvalidArguments); - setErrorString(tr("Invalid arguments in %0: %1 arguments given, %2 expected%3.") - .arg(name()).arg(arguments().count()).arg(tr("exactly 2"), QLatin1String(""))); - return false; - } - - const QString qtCoreLibraryDir = args.at(0); - const QByteArray newValue = QDir::toNativeSeparators(args.at(1)).toUtf8(); - - if (newValue.size() >= 255) { - setError(UserDefinedError); - setErrorString(tr("Qt patch error: new Qt imports path '%1'\nneeds to be less than 255 characters.") - .arg(QString::fromLocal8Bit(newValue))); - return false; - } - QStringList libraryFiles; -#ifdef Q_OS_WIN - libraryFiles << QString::fromLatin1("%1/QtCore4.dll").arg(qtCoreLibraryDir); - libraryFiles << QString::fromLatin1("%1/QtCore4d.dll").arg(qtCoreLibraryDir); -#else - libraryFiles << qtCoreLibraryDir + QLatin1String("/libQtCore.so"); -#endif - foreach (const QString coreLibrary, libraryFiles) { - if (QFile::exists(coreLibrary)) { - QByteArray oldValue(getOldValue(coreLibrary)); - Q_ASSERT(!oldValue.isEmpty()); - oldValue = QByteArray("qt_impspath=%1").replace("%1", oldValue); - QByteArray adjutedNewValue = QByteArray("qt_impspath=%1").replace("%1", newValue); - - bool isPatched = QtPatch::patchBinaryFile(coreLibrary, oldValue, adjutedNewValue); - if (!isPatched) { - qDebug() << "qpatch: warning: could not patch the imports path in" << coreLibrary; - } - } - } - - return true; -} - -bool SetImportsPathOnQtCoreOperation::undoOperation() -{ - return true; -} - -bool SetImportsPathOnQtCoreOperation::testOperation() -{ - return true; -} - -Operation *SetImportsPathOnQtCoreOperation::clone() const -{ - return new SetImportsPathOnQtCoreOperation(); -} - diff --git a/src/libs/installer/setimportspathonqtcoreoperation.h b/src/libs/installer/setimportspathonqtcoreoperation.h deleted file mode 100644 index 7dbb9c7d3..000000000 --- a/src/libs/installer/setimportspathonqtcoreoperation.h +++ /dev/null @@ -1,63 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#ifndef SETIMPORTSPATHONQTCOREOPERATION_H -#define SETIMPORTSPATHONQTCOREOPERATION_H - -#include "qinstallerglobal.h" - -namespace QInstaller { - -class SetImportsPathOnQtCoreOperation : public Operation -{ -public: - SetImportsPathOnQtCoreOperation(); - - void backup(); - bool performOperation(); - bool undoOperation(); - bool testOperation(); - Operation *clone() const; -}; - -} // namespace - -#endif // SETIMPORTSPATHONQTCOREOPERATION_H diff --git a/src/libs/installer/setpathonqtcoreoperation.cpp b/src/libs/installer/setpathonqtcoreoperation.cpp deleted file mode 100644 index c6950246d..000000000 --- a/src/libs/installer/setpathonqtcoreoperation.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#include "setpathonqtcoreoperation.h" - -#include "qtpatch.h" - -#include <QtCore/QByteArrayMatcher> -#include <QtCore/QDir> -#include <QtCore/QDebug> - -using namespace QInstaller; - -namespace { - QByteArray getOldValue(const QString &binaryPath, const QByteArray &typeValue) - { - QFileInfo fileInfo(binaryPath); - - if (!fileInfo.exists()) { - qDebug() << QString::fromLatin1("qpatch: warning: file '%1' not found.").arg( - binaryPath); - return QByteArray(); - } - - QFile file(binaryPath); - int readOpenCount = 0; - while (!file.open(QFile::ReadOnly) && readOpenCount < 20000) { - ++readOpenCount; - qApp->processEvents(); - } - Q_ASSERT(file.isOpen()); - if (!file.isOpen()) { - qDebug() << QString::fromLatin1("qpatch: warning: file '%1' can not be opened as ReadOnly.").arg( - binaryPath); - qDebug() << file.errorString(); - return QByteArray(); - } - - const QByteArray source = file.readAll(); - file.close(); - - int offset = 0; - QByteArray searchValue = typeValue; - searchValue.append("="); - QByteArrayMatcher byteArrayMatcher(searchValue); - offset = byteArrayMatcher.indexIn(source, offset); - Q_ASSERT(offset > 0); - if (offset == -1) - return QByteArray(); - - int stringEndPosition = offset; - - // go to the position where the other data starts - while (source.at(stringEndPosition++) != '\0') {} - - // between the search string and the first \0 is the QByteArray we are looking for - return source.mid(offset + searchValue.size(), stringEndPosition - offset); - } -} - -SetPathOnQtCoreOperation::SetPathOnQtCoreOperation() -{ - setName(QLatin1String("SetPathOnQtCore")); -} - -void SetPathOnQtCoreOperation::backup() -{ -} - -bool SetPathOnQtCoreOperation::performOperation() -{ - const QStringList args = arguments(); - - if (args.count() != 3) { - setError(InvalidArguments); - setErrorString(tr("Invalid arguments in %0: %1 arguments given, %2 expected%3.") - .arg(name()).arg(arguments().count()).arg(tr("exactly 3"), QLatin1String(""))); - return false; - } - - const QString qtCoreLibraryDir = args.at(0); - const QByteArray typeValue(args.at(1).toUtf8()); - const QByteArray newValue = QDir::toNativeSeparators(args.at(2)).toUtf8(); - - QStringList possibleTypes; - possibleTypes << QLatin1String("qt_prfxpath") - << QLatin1String("qt_docspath") - << QLatin1String("qt_hdrspath") - << QLatin1String("qt_libspath") - << QLatin1String("qt_binspath") - << QLatin1String("qt_plugpath") - << QLatin1String("qt_impspath") - << QLatin1String("qt_datapath") - << QLatin1String("qt_trnspath") - << QLatin1String("qt_xmplpath") - << QLatin1String("qt_demopath"); - - if (!possibleTypes.contains(QString::fromUtf8(typeValue))) { - setError(InvalidArguments); - setErrorString(tr("The second type/value needs to be one of: %1").arg(possibleTypes.join( - QLatin1String(", ")))); - return false; - } - - if (newValue.size() >= 255) { - qDebug() << "qpatch: error: newQtDir needs to be less than 255 characters."; - return false; - } - QStringList libraryFiles; -#ifdef Q_OS_WIN - libraryFiles << QString::fromLatin1("%1/QtCore4.dll").arg(qtCoreLibraryDir); - libraryFiles << QString::fromLatin1("%1/QtCore4d.dll").arg(qtCoreLibraryDir); -#else - libraryFiles << qtCoreLibraryDir + QLatin1String("/libQtCore.so"); -#endif - foreach (const QString coreLibrary, libraryFiles) { - if (QFile::exists(coreLibrary)) { - QByteArray oldValue(getOldValue(coreLibrary, typeValue)); - Q_ASSERT(!oldValue.isEmpty()); - oldValue = QByteArray("%0=%1").replace("%0", typeValue).replace("%1", oldValue); - QByteArray adjutedNewValue = - QByteArray("%0=%1").replace("%0", typeValue).replace("%1", newValue); - - bool isPatched = QtPatch::patchBinaryFile(coreLibrary, oldValue, adjutedNewValue); - if (!isPatched) { - qDebug() << "qpatch: warning: could not patch the plugin path in" << coreLibrary; - } - } - } - - return true; -} - -bool SetPathOnQtCoreOperation::undoOperation() -{ - return true; -} - -bool SetPathOnQtCoreOperation::testOperation() -{ - return true; -} - -Operation *SetPathOnQtCoreOperation::clone() const -{ - return new SetPathOnQtCoreOperation(); -} - diff --git a/src/libs/installer/setpluginpathonqtcoreoperation.cpp b/src/libs/installer/setpluginpathonqtcoreoperation.cpp deleted file mode 100644 index cafdda24c..000000000 --- a/src/libs/installer/setpluginpathonqtcoreoperation.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#include "setpluginpathonqtcoreoperation.h" - -#include "qtpatch.h" - -#include <QtCore/QByteArrayMatcher> -#include <QtCore/QDir> -#include <QtCore/QDebug> - -using namespace QInstaller; - -namespace { - QByteArray getOldValue(const QString &binaryPath) - { - QFileInfo fileInfo(binaryPath); - - if (!fileInfo.exists()) { - qDebug() << QString::fromLatin1("qpatch: warning: file '%1' not found").arg(binaryPath); - return QByteArray(); - } - - QFile file(binaryPath); - int readOpenCount = 0; - while (!file.open(QFile::ReadOnly) && readOpenCount < 20000) { - ++readOpenCount; - qApp->processEvents(); - } - Q_ASSERT(file.isOpen()); - if (!file.isOpen()) { - qDebug() << QString::fromLatin1("qpatch: warning: file '%1' can not be opened as ReadOnly.").arg( - binaryPath); - qDebug() << file.errorString(); - return QByteArray(); - } - - const QByteArray source = file.readAll(); - file.close(); - - int offset = 0; - QByteArray searchValue("qt_plugpath="); - QByteArrayMatcher byteArrayMatcher(searchValue); - offset = byteArrayMatcher.indexIn(source, offset); - Q_ASSERT(offset > 0); - if (offset == -1) - return QByteArray(); - - int stringEndPosition = offset; - while(source.at(stringEndPosition++) != '\0') {} - // between the search string and the first \0 is the QByteArray we are looking for - return source.mid(offset + searchValue.size(), stringEndPosition - offset); - } -} - -SetPluginPathOnQtCoreOperation::SetPluginPathOnQtCoreOperation() -{ - setName(QLatin1String("SetPluginPathOnQtCore")); -} - -void SetPluginPathOnQtCoreOperation::backup() -{ -} - -bool SetPluginPathOnQtCoreOperation::performOperation() -{ - const QStringList args = arguments(); - - if (args.count() != 2) { - setError(InvalidArguments); - setErrorString(tr("Invalid arguments in %0: %1 arguments given, %2 expected%3.") - .arg(name()).arg(arguments().count()).arg(tr("exactly 2"), QLatin1String(""))); - return false; - } - - const QString qtCoreLibraryDir = args.at(0); - const QByteArray newValue = QDir::toNativeSeparators(args.at(1)).toUtf8(); - - if (newValue.size() >= 255) { - setError(UserDefinedError); - setErrorString(tr("Qt patch error: new Qt plugin path '%1'\nneeds to be less than 255 characters.") - .arg(QString::fromLocal8Bit(newValue))); - return false; - } - QStringList libraryFiles; -#ifdef Q_OS_WIN - libraryFiles << QString::fromLatin1("%1/QtCore4.dll").arg(qtCoreLibraryDir); - libraryFiles << QString::fromLatin1("%1/QtCore4d.dll").arg(qtCoreLibraryDir); -#else - libraryFiles << qtCoreLibraryDir + QLatin1String("/libQtCore.so"); -#endif - foreach (const QString &coreLibrary, libraryFiles) { - if (QFile::exists(coreLibrary)) { - QByteArray oldValue(getOldValue(coreLibrary)); - Q_ASSERT(!oldValue.isEmpty()); - oldValue = QByteArray("qt_plugpath=%1").replace("%1", oldValue); - QByteArray adjutedNewValue = QByteArray("qt_plugpath=%1").replace("%1", newValue); - - bool isPatched = QtPatch::patchBinaryFile(coreLibrary, oldValue, adjutedNewValue); - if (!isPatched) - qDebug() << "qpatch: warning: could not patch the plugin path in" << coreLibrary; - } - } - - return true; -} - -bool SetPluginPathOnQtCoreOperation::undoOperation() -{ - return true; -} - -bool SetPluginPathOnQtCoreOperation::testOperation() -{ - return true; -} - -Operation *SetPluginPathOnQtCoreOperation::clone() const -{ - return new SetPluginPathOnQtCoreOperation(); -} - diff --git a/src/libs/installer/setpluginpathonqtcoreoperation.h b/src/libs/installer/setpluginpathonqtcoreoperation.h deleted file mode 100644 index 99d9c4bfe..000000000 --- a/src/libs/installer/setpluginpathonqtcoreoperation.h +++ /dev/null @@ -1,63 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#ifndef SETPLUGINPATHONQTCOREOPERATION_H -#define SETPLUGINPATHONQTCOREOPERATION_H - -#include "qinstallerglobal.h" - -namespace QInstaller { - -class SetPluginPathOnQtCoreOperation : public Operation -{ -public: - SetPluginPathOnQtCoreOperation(); - - void backup(); - bool performOperation(); - bool undoOperation(); - bool testOperation(); - Operation *clone() const; -}; - -} // namespace - -#endif // SETPLUGINPATHONQTCOREOPERATION_H diff --git a/src/libs/installer/setqtcreatorvalueoperation.cpp b/src/libs/installer/setqtcreatorvalueoperation.cpp index 28e0f9134..4f2bbfbc1 100644 --- a/src/libs/installer/setqtcreatorvalueoperation.cpp +++ b/src/libs/installer/setqtcreatorvalueoperation.cpp @@ -110,7 +110,7 @@ bool SetQtCreatorValueOperation::performOperation() if (!group.isEmpty()) settings.endGroup(); - settings.sync(); //be save ;) + settings.sync(); //be safe ;) return true; } diff --git a/src/libs/installer/settings.cpp b/src/libs/installer/settings.cpp index d8f409f46..7d8f234cf 100644 --- a/src/libs/installer/settings.cpp +++ b/src/libs/installer/settings.cpp @@ -563,6 +563,11 @@ bool Settings::repositorySettingsPageVisible() const return d->m_data.value(scRepositorySettingsPageVisible, true).toBool(); } +void Settings::setRepositorySettingsPageVisible(bool visible) +{ + d->m_data.insert(scRepositorySettingsPageVisible, visible); +} + Settings::ProxyType Settings::proxyType() const { return Settings::ProxyType(d->m_data.value(scProxyType, Settings::NoProxy).toInt()); diff --git a/src/libs/installer/settings.h b/src/libs/installer/settings.h index 85a2ea68e..a86b5f5fc 100644 --- a/src/libs/installer/settings.h +++ b/src/libs/installer/settings.h @@ -142,6 +142,7 @@ public: QVariantList values(const QString &key, const QVariantList &defaultValue = QVariantList()) const; bool repositorySettingsPageVisible() const; + void setRepositorySettingsPageVisible(bool visible); Settings::ProxyType proxyType() const; void setProxyType(Settings::ProxyType type); diff --git a/src/libs/installer/settingsoperation.cpp b/src/libs/installer/settingsoperation.cpp new file mode 100644 index 000000000..6fde21268 --- /dev/null +++ b/src/libs/installer/settingsoperation.cpp @@ -0,0 +1,216 @@ +/************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Installer Framework. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +**************************************************************************/ +#include "settingsoperation.h" +#include "packagemanagercore.h" +#include "kdupdaterupdateoperations.h" + +#include <QSettings> +#include <QDir> +#include <QDebug> + +using namespace QInstaller; + +SettingsOperation::SettingsOperation() +{ + setName(QLatin1String("Settings")); +} + +void SettingsOperation::backup() +{ +} + +bool SettingsOperation::checkArguments() +{ + const QString path = argumentKeyValue(QLatin1String("path")); + const QString method = argumentKeyValue(QLatin1String("method")); + const QString key = argumentKeyValue(QLatin1String("key")); + const QString aValue = argumentKeyValue(QLatin1String("value")); + + QStringList missingArguments; + if (path.isEmpty()) + missingArguments << QLatin1String("path"); + if (method.isEmpty()) + missingArguments << QLatin1String("method"); + if (key.isEmpty()) + missingArguments << QLatin1String("key"); + if (method != QLatin1String("remove") && aValue.isEmpty()) + missingArguments << QLatin1String("value"); + + if (!missingArguments.isEmpty()) { + setError(InvalidArguments); + setErrorString(tr("Missing argument(s) '%1' calling '%2' with arguments '%3'.").arg( + missingArguments.join(QLatin1String("; ")), name(), arguments().join(QLatin1String("; ")))); + return false; + } + QStringList possibleMethodValues; + possibleMethodValues << QLatin1String("set") << QLatin1String("remove") << + QLatin1String("add_array_value") << QLatin1String("remove_array_value"); + + if (!possibleMethodValues.contains(method)) { + setError(InvalidArguments); + setErrorString(tr("Current method argument calling '%1' with arguments '%2' is not " + "supported. Please use set, remove, add_array_value or remove_array_value.").arg(name(), + arguments().join(QLatin1String("; ")))); + return false; + } + return true; +} + + +bool SettingsOperation::performOperation() +{ + // Arguments: + // 1. path=settings file path or registry path + // 2. method=set|remove|add_array_value|remove_array_value + // 3. key=can be prepended by a category name separated by slash + // 4. value=just the value + // optional arguments are + // formate=native or ini TODO + // backup=true or false (default is true) TODO + // NOTE: remove and remove_array_value will do nothing at the undostep + + if (!checkArguments()) + return false; + const QString path = argumentKeyValue(QLatin1String("path")); + const QString method = argumentKeyValue(QLatin1String("method")); + const QString key = argumentKeyValue(QLatin1String("key")); + const QString aValue = argumentKeyValue(QLatin1String("value")); + + // use MkdirOperation to get the path so it can remove it with MkdirOperation::undoOperation later + KDUpdater::MkdirOperation mkDirOperation; + mkDirOperation.setArguments(QStringList() << QFileInfo(path).absolutePath()); + mkDirOperation.backup(); + if (!mkDirOperation.performOperation()) { + setError(mkDirOperation.error()); + setErrorString(mkDirOperation.errorString()); + return false; + } + setValue(QLatin1String("createddir"), mkDirOperation.value(QLatin1String("createddir"))); + + QSettings settings(path, QSettings::IniFormat); + if (method == QLatin1String("set")) + settings.setValue(key, aValue); + else if (method == QLatin1String("remove")) + settings.remove(key); + else if (method == QLatin1String("add_array_value")) { + QVariant valueVariant = settings.value(key); + if (valueVariant.canConvert<QStringList>()) { + QStringList array = valueVariant.toStringList(); + array.append(aValue); + settings.setValue(key, array); + } else { + settings.setValue(key, aValue); + } + } else if (method == QLatin1String("remove_array_value")) { + QVariant valueVariant = settings.value(key); + if (valueVariant.canConvert<QStringList>()) { + QStringList array = valueVariant.toStringList(); + array.removeOne(aValue); + settings.setValue(key, array); + } else { + settings.remove(key); + } + } + + return true; +} + +bool SettingsOperation::undoOperation() +{ + if (!checkArguments()) + return false; + const QString path = argumentKeyValue(QLatin1String("path")); + const QString method = argumentKeyValue(QLatin1String("method")); + const QString key = argumentKeyValue(QLatin1String("key")); + const QString aValue = argumentKeyValue(QLatin1String("value")); + + if (method.startsWith(QLatin1String("remove"))) + return true; + + bool cleanUp = false; + { // kill the scope to kill settings object, else remove file will not work + QSettings settings(path, QSettings::IniFormat); + if (method == QLatin1String("set")) { + settings.remove(key); + } else if (method == QLatin1String("add_array_value")) { + QVariant valueVariant = settings.value(key); + if (valueVariant.canConvert<QStringList>()) { + QStringList array = valueVariant.toStringList(); + array.removeOne(aValue); + if (array.isEmpty()) + settings.remove(key); + else + settings.setValue(key, array); + } else { + settings.setValue(key, aValue); + } + } + settings.sync(); // be safe + cleanUp = settings.allKeys().isEmpty(); + } + + if (cleanUp) { + QFile settingsFile(path); + if (!settingsFile.remove()) + qWarning() << settingsFile.errorString(); + if (!value(QLatin1String("createddir")).toString().isEmpty()) { + KDUpdater::MkdirOperation mkDirOperation; + mkDirOperation.setArguments(QStringList() << QFileInfo(path).absolutePath()); + mkDirOperation.setValue(QLatin1String("createddir"), value(QLatin1String("createddir"))); + + if (!mkDirOperation.undoOperation()) { + qWarning() << mkDirOperation.errorString(); + } + } + } + return true; +} + +bool SettingsOperation::testOperation() +{ + return true; +} + +Operation *SettingsOperation::clone() const +{ + return new SettingsOperation(); +} + diff --git a/src/libs/installer/registerqtincreatorqnxoperation.h b/src/libs/installer/settingsoperation.h index 5b6a3c9b1..248c9a0df 100644 --- a/src/libs/installer/registerqtincreatorqnxoperation.h +++ b/src/libs/installer/settingsoperation.h @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the Qt Installer Framework. @@ -39,25 +39,28 @@ ** **************************************************************************/ -#ifndef REGISTERQTINCREATORQNXOPERATION_H -#define REGISTERQTINCREATORQNXOPERATION_H +#ifndef SETTINGSOPERATION_H +#define SETTINGSOPERATION_H #include "qinstallerglobal.h" namespace QInstaller { -class RegisterQtInCreatorQNXOperation : public Operation +class INSTALLER_EXPORT SettingsOperation : public Operation { public: - RegisterQtInCreatorQNXOperation(); + SettingsOperation(); void backup(); bool performOperation(); bool undoOperation(); bool testOperation(); Operation *clone() const; + +private: + bool checkArguments(); }; } // namespace QInstaller -#endif // REGISTERQTINCREATORQNXOPERATION_H +#endif // SETTINGSOPERATION_H diff --git a/src/libs/installer/testrepository.cpp b/src/libs/installer/testrepository.cpp new file mode 100644 index 000000000..a39c499a1 --- /dev/null +++ b/src/libs/installer/testrepository.cpp @@ -0,0 +1,168 @@ +/************************************************************************** +** +** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Installer Framework. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +**************************************************************************/ +#include "testrepository.h" + +#include <kdupdaterfiledownloader.h> +#include <kdupdaterfiledownloaderfactory.h> + +#include <QtCore/QFile> + +using namespace QInstaller; + +TestRepository::TestRepository(QObject *parent) + : KDJob(parent) + , m_downloader(0) +{ + setTimeout(10000); + setAutoDelete(false); + setCapabilities(Cancelable); +} + +TestRepository::~TestRepository() +{ + if (m_downloader) + m_downloader->deleteLater(); +} + +Repository TestRepository::repository() const +{ + return m_repository; +} + +void TestRepository::setRepository(const Repository &repository) +{ + cancel(); + + setError(NoError); + setErrorString(QString()); + m_repository = repository; +} + +void TestRepository::doStart() +{ + if (m_downloader) + m_downloader->deleteLater(); + + const QUrl url = m_repository.url(); + if (url.isEmpty()) { + emitFinishedWithError(InvalidUrl, tr("Empty repository URL.")); + return; + } + + m_downloader = KDUpdater::FileDownloaderFactory::instance().create(url.scheme(), this); + if (!m_downloader) { + emitFinishedWithError(InvalidUrl, tr("URL scheme not supported: %1 (%2).") + .arg(url.scheme(), url.toString())); + return; + } + + QAuthenticator auth; + auth.setUser(m_repository.username()); + auth.setPassword(m_repository.password()); + m_downloader->setAuthenticator(auth); + + connect(m_downloader, SIGNAL(downloadCompleted()), this, SLOT(downloadCompleted())); + connect(m_downloader, SIGNAL(downloadAborted(QString)), this, SLOT(downloadAborted(QString)), + Qt::QueuedConnection); + connect(m_downloader, SIGNAL(authenticatorChanged(QAuthenticator)), this, + SLOT(onAuthenticatorChanged(QAuthenticator))); + + m_downloader->setAutoRemoveDownloadedFile(true); + m_downloader->setUrl(QUrl(url.toString() + QString::fromLatin1("/Updates.xml"))); + + m_downloader->download(); +} + +void TestRepository::doCancel() +{ + if (m_downloader) { + QString errorString = m_downloader->errorString(); + if (errorString.isEmpty()) + errorString = tr("Got a timeout while testing: '%1'").arg(m_repository.displayname()); + // at the moment the download sends downloadCompleted() if we cancel it, so just + disconnect(m_downloader, 0, this, 0); + m_downloader->cancelDownload(); + emitFinishedWithError(KDJob::Canceled, errorString); + } +} + +void TestRepository::downloadCompleted() +{ + QString errorMsg; + int error = DownloadError; + + if (m_downloader->isDownloaded()) { + QFile file(m_downloader->downloadedFileName()); + if (file.exists() && file.open(QIODevice::ReadOnly)) { + QDomDocument doc; + QString errorMsg; + if (!doc.setContent(&file, &errorMsg)) { + error = InvalidUpdatesXml; + errorMsg = tr("Could not parse Updates.xml! Error: %1.").arg(errorMsg); + } else { + error = NoError; + } + } else { + errorMsg = tr("Updates.xml could not be opened for reading!"); + } + } else { + errorMsg = tr("Updates.xml could not be found on server!"); + } + + if (error > NoError) + emitFinishedWithError(error, errorMsg); + else + emitFinished(); + + m_downloader->deleteLater(); + m_downloader = 0; +} + +void TestRepository::downloadAborted(const QString &reason) +{ + emitFinishedWithError(DownloadError, reason); +} + +void TestRepository::onAuthenticatorChanged(const QAuthenticator &authenticator) +{ + m_repository.setUsername(authenticator.user()); + m_repository.setPassword(authenticator.password()); +} diff --git a/src/libs/installer/setdemospathonqtoperation.h b/src/libs/installer/testrepository.h index 27d25c9f9..c1ecc039c 100644 --- a/src/libs/installer/setdemospathonqtoperation.h +++ b/src/libs/installer/testrepository.h @@ -38,26 +38,58 @@ ** $QT_END_LICENSE$ ** **************************************************************************/ - -#ifndef SETDEMOSPATHONQTOPERATION_H -#define SETDEMOSPATHONQTOPERATION_H +#ifndef TESTREPOSITORY_H +#define TESTREPOSITORY_H #include "qinstallerglobal.h" +#include <repository.h> +#include <settings.h> + +#include <kdjob.h> + +QT_BEGIN_NAMESPACE +class QAuthenticator; +class QLocale; +class QVariant; +QT_END_NAMESPACE + +namespace KDUpdater { + class FileDownloader; +} + +namespace QInstaller { + class PackageManagerCore; +} + namespace QInstaller { -class SetDemosPathOnQtOperation : public Operation +class INSTALLER_EXPORT TestRepository : public KDJob { + Q_OBJECT + public: - SetDemosPathOnQtOperation(); - void backup(); - bool performOperation(); - bool undoOperation(); - bool testOperation(); - Operation *clone() const; + explicit TestRepository(QObject *parent = 0); + ~TestRepository(); + + QInstaller::Repository repository() const; + void setRepository(const QInstaller::Repository &repository); + +private: + void doStart(); + void doCancel(); + +private Q_SLOTS: + void downloadCompleted(); + void downloadAborted(const QString &reason); + void onAuthenticatorChanged(const QAuthenticator &authenticator); + +private: + QInstaller::Repository m_repository; + KDUpdater::FileDownloader *m_downloader; }; -} // namespace +} //namespace QInstaller -#endif // SETDEMOSPATHONQTOPERATION_H +#endif // TESTREPOSITORY_H diff --git a/src/libs/installer/updater.cpp b/src/libs/installer/updater.cpp index b51b332ed..ae6eaac29 100644 --- a/src/libs/installer/updater.cpp +++ b/src/libs/installer/updater.cpp @@ -40,6 +40,7 @@ **************************************************************************/ #include "updater.h" +#include "productkeycheck.h" #include "binaryformat.h" #include "component.h" #include "init.h" @@ -77,6 +78,7 @@ bool Updater::checkForUpdates() PackageManagerCore core(content.magicMarker(), content.performedOperations()); core.setUpdater(); PackageManagerCore::setVirtualComponentsVisible(true); + ProductKeyCheck::instance()->init(&core); if (!core.fetchRemotePackagesTree()) return false; diff --git a/src/libs/kdtools/kdgenericfactory.h b/src/libs/kdtools/kdgenericfactory.h index 349c5ee92..4108c16fd 100644 --- a/src/libs/kdtools/kdgenericfactory.h +++ b/src/libs/kdtools/kdgenericfactory.h @@ -46,13 +46,14 @@ #include <QtCore/QHash> -template <typename T_Product, typename T_Identifier = QString> +template <typename T_Product, typename T_Identifier = QString, typename T_Argument = QString> class KDGenericFactory { public: virtual ~KDGenericFactory() {} typedef T_Product *(*FactoryFunction)(); + typedef T_Product *(*FactoryFunctionWithArg)(const T_Argument &arg); template <typename T> void registerProduct(const T_Identifier &name) @@ -73,6 +74,25 @@ public: return (*it)(); } + template <typename T> + void registerProductWithArg(const T_Identifier &name) + { +#ifdef Q_CC_MSVC + FactoryFunctionWithArg function = &KDGenericFactory::create<T>; +#else // compile fix for old gcc + FactoryFunctionWithArg function = &create<T>; +#endif + map2.insert(name, function); + } + + T_Product *createWithArg(const T_Identifier &name, const T_Argument &arg) const + { + const typename QHash<T_Identifier, FactoryFunctionWithArg>::const_iterator it = map2.find(name); + if (it == map2.end()) + return 0; + return (*it)(arg); + } + private: template <typename T> static T_Product *create() @@ -80,7 +100,14 @@ private: return new T; } + template <typename T> + static T_Product *create(const T_Argument &arg) + { + return new T(arg); + } + QHash<T_Identifier, FactoryFunction> map; + QHash<T_Identifier, FactoryFunctionWithArg> map2; }; #endif diff --git a/src/libs/kdtools/kdsavefile.cpp b/src/libs/kdtools/kdsavefile.cpp index 483f1b338..88b95f42e 100644 --- a/src/libs/kdtools/kdsavefile.cpp +++ b/src/libs/kdtools/kdsavefile.cpp @@ -299,7 +299,7 @@ bool KDSaveFile::open(OpenMode mode) return opened; } -bool KDSaveFile::atEnd() +bool KDSaveFile::atEnd() const { return d->tmpFile ? d->tmpFile->atEnd() : QIODevice::atEnd(); } diff --git a/src/libs/kdtools/kdsavefile.h b/src/libs/kdtools/kdsavefile.h index 24eee9870..7408892d0 100644 --- a/src/libs/kdtools/kdsavefile.h +++ b/src/libs/kdtools/kdsavefile.h @@ -76,7 +76,7 @@ public: bool resize(qint64 size); int handle() const; - bool atEnd(); + bool atEnd() const; qint64 bytesAvailable() const; qint64 bytesToWrite() const; bool canReadLine() const; diff --git a/src/libs/kdtools/kdupdaterfiledownloader.cpp b/src/libs/kdtools/kdupdaterfiledownloader.cpp index a7fbfe85b..95b574b2f 100644 --- a/src/libs/kdtools/kdupdaterfiledownloader.cpp +++ b/src/libs/kdtools/kdupdaterfiledownloader.cpp @@ -320,13 +320,13 @@ void KDUpdater::FileDownloader::emitDownloadStatus() if (bytesReceived.endsWith(tmp)) bytesReceived.chop(tmp.length()); - status = bytesReceived + tr(" of ") + bytesToReceive; + status = tr("%1 of %2").arg(bytesReceived).arg(bytesToReceive); } else { if (d->m_bytesReceived > 0) - status = humanReadableSize(d->m_bytesReceived) + tr(" downloaded."); + status = tr("%1 downloaded.").arg(humanReadableSize(d->m_bytesReceived)); } - status += QLatin1String(" (") + humanReadableSize(d->m_downloadSpeed) + tr("/sec") + QLatin1Char(')'); + status += QLatin1Char(' ') + tr("(%1/sec)").arg(humanReadableSize(d->m_downloadSpeed)); if (d->m_bytesToReceive > 0 && d->m_downloadSpeed > 0) { const qint64 time = (d->m_bytesToReceive - d->m_bytesReceived) / d->m_downloadSpeed; @@ -337,22 +337,22 @@ void KDUpdater::FileDownloader::emitDownloadStatus() QString days; if (d > 0) - days = QString::number(d) + (d < 2 ? tr(" day") : tr(" days")) + QLatin1String(", "); + days = tr("%n day(s), ", "", d); QString hours; if (h > 0) - hours = QString::number(h) + (h < 2 ? tr(" hour") : tr(" hours")) + QLatin1String(", "); + hours = tr("%n hour(s), ", "", h); QString minutes; if (m > 0) - minutes = QString::number(m) + (m < 2 ? tr(" minute") : tr(" minutes")); + minutes = tr("%n minute(s)", "", m); QString seconds; if (s >= 0 && minutes.isEmpty()) { s = (s <= 0 ? 1 : s); - seconds = QString::number(s) + (s < 2 ? tr(" second") : tr(" seconds")); + seconds = tr("%n second(s)", "", s); } - status += tr(" - ") + days + hours + minutes + seconds + tr(" remaining."); + status += tr(" - %1%2%3%4 remaining.").arg(days).arg(hours).arg(minutes).arg(seconds); } else { status += tr(" - unknown time remaining."); } diff --git a/src/libs/kdtools/kdupdaterupdatefinder.cpp b/src/libs/kdtools/kdupdaterupdatefinder.cpp index f37fa9244..e53c47280 100644 --- a/src/libs/kdtools/kdupdaterupdatefinder.cpp +++ b/src/libs/kdtools/kdupdaterupdatefinder.cpp @@ -227,7 +227,7 @@ void UpdateFinder::Private::computeUpdates() } // All done - q->reportProgress(100, tr("%1 updates found.").arg(updates.count())); + q->reportProgress(100, tr("%n update(s) found.", "", updates.count())); q->reportDone(); } diff --git a/src/libs/kdtools/kdupdaterupdateoperation.cpp b/src/libs/kdtools/kdupdaterupdateoperation.cpp index c1591f467..9ba165d4b 100644 --- a/src/libs/kdtools/kdupdaterupdateoperation.cpp +++ b/src/libs/kdtools/kdupdaterupdateoperation.cpp @@ -176,6 +176,40 @@ QStringList UpdateOperation::arguments() const return m_arguments; } +struct StartsWith +{ + StartsWith(const QString &searchTerm) + : m_searchTerm(searchTerm) {} + + bool operator()(const QString &searchString) + { + return searchString.startsWith(m_searchTerm); + } + + QString m_searchTerm; +}; + + +QString UpdateOperation::argumentKeyValue(const QString &key, const QString &defaultValue) const +{ + const QString keySeparater(key + QLatin1String("=")); + const QStringList tArguments(arguments()); + QStringList::const_iterator it = std::find_if(tArguments.begin(), tArguments.end(), + StartsWith(keySeparater)); + if (it == tArguments.end()) + return defaultValue; + + const QString value = it->mid(keySeparater.size()); + + it = std::find_if(++it, tArguments.end(), StartsWith(keySeparater)); + if (it != tArguments.end()) { + qWarning() << QString::fromLatin1("There are multiple keys in the arguments calling" + " '%1'. Only the first found '%2' is used: '%3'").arg(name(), key, arguments().join( + QLatin1String("; "))); + } + return value; +} + /*! Returns error details in case performOperation() failed. */ diff --git a/src/libs/kdtools/kdupdaterupdateoperation.h b/src/libs/kdtools/kdupdaterupdateoperation.h index cac68d2f1..21b7b64a3 100644 --- a/src/libs/kdtools/kdupdaterupdateoperation.h +++ b/src/libs/kdtools/kdupdaterupdateoperation.h @@ -75,6 +75,7 @@ public: void setArguments(const QStringList &args); QStringList arguments() const; + QString argumentKeyValue(const QString & key, const QString &defaultValue = QString()) const; void clear(); QString errorString() const; int error() const; |