diff options
Diffstat (limited to 'src')
80 files changed, 1355 insertions, 3107 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/adminauthorization_win.cpp b/src/libs/installer/adminauthorization_win.cpp index 03003b21a..528f3403d 100644 --- a/src/libs/installer/adminauthorization_win.cpp +++ b/src/libs/installer/adminauthorization_win.cpp @@ -45,17 +45,14 @@ #include <QDebug> #include <QDir> +#include <qt_windows.h> + #ifdef Q_CC_MINGW -# ifndef _WIN32_WINNT -# define _WIN32_WINNT 0x0501 -# endif # ifndef SEE_MASK_NOASYNC # define SEE_MASK_NOASYNC 0x00000100 # endif #endif -#include <windows.h> - struct DeCoInitializer { DeCoInitializer() diff --git a/src/libs/installer/applyproductkeyoperation.cpp b/src/libs/installer/applyproductkeyoperation.cpp index 4556df743..5b561bd19 100644 --- a/src/libs/installer/applyproductkeyoperation.cpp +++ b/src/libs/installer/applyproductkeyoperation.cpp @@ -46,6 +46,7 @@ bool ApplyProductKeyOperation::performOperation() if (!ProductKeyCheck::instance()->applyKey(arguments())) { setError(UserDefinedError); setErrorString(ProductKeyCheck::instance()->lastErrorString()); + return false; } 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..8c5917852 100644 --- a/src/libs/installer/createshortcutoperation.cpp +++ b/src/libs/installer/createshortcutoperation.cpp @@ -52,12 +52,7 @@ using namespace QInstaller; #ifdef Q_OS_WIN -#ifdef Q_CC_MINGW -# ifndef _WIN32_WINNT -# define _WIN32_WINNT 0x0501 -# endif -#endif -#include <windows.h> +#include <qt_windows.h> #include <shlobj.h> #ifndef PIDLIST_ABSOLUTE @@ -250,7 +245,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..fe10277ea 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,31 +460,68 @@ 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; } #ifdef Q_OS_WIN -# ifdef Q_CC_MINGW -# ifndef _WIN32_WINNT -# define _WIN32_WINNT 0x0501 -# endif -# endif -#include <windows.h> - +#include <qt_windows.h> QString QInstaller::getShortPathName(const QString &name) { 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/link.cpp b/src/libs/installer/link.cpp index f8b872f33..d7588d077 100644 --- a/src/libs/installer/link.cpp +++ b/src/libs/installer/link.cpp @@ -50,13 +50,7 @@ #endif #ifdef Q_OS_WIN -#ifdef Q_CC_MINGW -# ifndef _WIN32_WINNT -# define _WIN32_WINNT 0x0501 -# endif -#endif - -#include <windows.h> +#include <qt_windows.h> #include <winioctl.h> #ifndef Q_CC_MINGW 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..782d3c574 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -78,7 +78,7 @@ #include <errno.h> #ifdef Q_OS_WIN -#include <windows.h> +#include <qt_windows.h> #endif namespace QInstaller { @@ -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/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/sysinfo_win.cpp b/src/libs/installer/sysinfo_win.cpp index 618d6cfdb..8b14d1567 100644 --- a/src/libs/installer/sysinfo_win.cpp +++ b/src/libs/installer/sysinfo_win.cpp @@ -40,7 +40,6 @@ **************************************************************************/ #include "kdsysinfo.h" - #include "link.h" #ifdef Q_CC_MINGW @@ -49,10 +48,10 @@ # endif #endif -#include <windows.h> +#include <qt_windows.h> #include <psapi.h> #include <tlhelp32.h> - +#include <winbase.h> #include <winnetwk.h> #ifndef Q_CC_MINGW 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/setexamplespathonqtoperation.h b/src/libs/installer/testrepository.h index 7f2df6b4e..c1ecc039c 100644 --- a/src/libs/installer/setexamplespathonqtoperation.h +++ b/src/libs/installer/testrepository.h @@ -38,26 +38,58 @@ ** $QT_END_LICENSE$ ** **************************************************************************/ - -#ifndef SETEXAMPLESPATHONQTOPERATION_H -#define SETEXAMPLESPATHONQTOPERATION_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 SetExamplesPathOnQtOperation : public Operation +class INSTALLER_EXPORT TestRepository : public KDJob { + Q_OBJECT + public: - SetExamplesPathOnQtOperation(); - 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 // SETEXAMPLESPATHONQTOPERATION_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/installer/utils.cpp b/src/libs/installer/utils.cpp index 2b5491f62..61af9ae27 100644 --- a/src/libs/installer/utils.cpp +++ b/src/libs/installer/utils.cpp @@ -47,7 +47,7 @@ #include <QtCore/QVector> #include <QCoreApplication> -#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) || defined(Q_OS_WINCE) # include "qt_windows.h" #endif @@ -55,10 +55,6 @@ #include <iostream> #include <sstream> - -#ifdef Q_OS_WIN -#include <windows.h> // for Sleep -#endif #ifdef Q_OS_UNIX #include <errno.h> #include <signal.h> @@ -210,6 +206,7 @@ QInstaller::VerboseWriter::VerboseWriter(QObject *parent) : QObject(parent) { preFileBuffer.open(QIODevice::ReadWrite); stream.setDevice(&preFileBuffer); + currentDateTimeAsString = QDateTime::currentDateTime().toString(); } QInstaller::VerboseWriter::~VerboseWriter() @@ -224,8 +221,9 @@ QInstaller::VerboseWriter::~VerboseWriter() QFile output(logFileName); if (output.open(QIODevice::ReadWrite | QIODevice::Append | QIODevice::Text)) { QString logInfo; - logInfo += QLatin1String("*************************************"); - logInfo += QLatin1String("Invoked:") + QDateTime::currentDateTime().toString(); + logInfo += QLatin1String("************************************* Invoked: "); + logInfo += currentDateTimeAsString; + logInfo += QLatin1String("\n"); output.write(logInfo.toLocal8Bit()); output.write(preFileBuffer.data()); output.close(); diff --git a/src/libs/installer/utils.h b/src/libs/installer/utils.h index 229dfe95a..2bc7a1801 100644 --- a/src/libs/installer/utils.h +++ b/src/libs/installer/utils.h @@ -96,6 +96,7 @@ namespace QInstaller { QTextStream stream; QBuffer preFileBuffer; QString logFileName; + QString currentDateTimeAsString; }; } 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/kdsysinfo_win.cpp b/src/libs/kdtools/kdsysinfo_win.cpp index edeeb6879..cc28b35d2 100644 --- a/src/libs/kdtools/kdsysinfo_win.cpp +++ b/src/libs/kdtools/kdsysinfo_win.cpp @@ -44,13 +44,7 @@ #include <QLibrary> #include <QStringList> -#ifdef Q_CC_MINGW -# ifndef _WIN32_WINNT -# define _WIN32_WINNT 0x0501 -# endif -#endif - -#include <windows.h> +#include <qt_windows.h> #include <psapi.h> #include <tlhelp32.h> 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; diff --git a/src/sdk/console.h b/src/sdk/console.h new file mode 100644 index 000000000..7eb4aa3f4 --- /dev/null +++ b/src/sdk/console.h @@ -0,0 +1,131 @@ +/************************************************************************** +** +** Copyright (C) 2014 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 CONSOLE_H +#define CONSOLE_H + +#include <QtCore/QtGlobal> + +#ifdef Q_OS_WIN +# include <qt_windows.h> +# include <wincon.h> + +# include <fstream> +# include <iostream> + +# ifndef ENABLE_INSERT_MODE +# define ENABLE_INSERT_MODE 0x0020 +# endif + +# ifndef ENABLE_QUICK_EDIT_MODE +# define ENABLE_QUICK_EDIT_MODE 0x0040 +# endif + +# ifndef ENABLE_EXTENDED_FLAGS +# define ENABLE_EXTENDED_FLAGS 0x0080 +# endif + +class Console +{ +public: + Console() + { + AllocConsole(); + HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE); + if (handle != INVALID_HANDLE_VALUE) { + COORD largestConsoleWindowSize = GetLargestConsoleWindowSize(handle); + largestConsoleWindowSize.X -= 3; + largestConsoleWindowSize.Y = 5000; + SetConsoleScreenBufferSize(handle, largestConsoleWindowSize); + } + + handle = GetStdHandle(STD_INPUT_HANDLE); + if (handle != INVALID_HANDLE_VALUE) + SetConsoleMode(handle, ENABLE_INSERT_MODE | ENABLE_QUICK_EDIT_MODE | ENABLE_EXTENDED_FLAGS); + + m_oldCin = std::cin.rdbuf(); + m_newCin.open("CONIN$"); + std::cin.rdbuf(m_newCin.rdbuf()); + + m_oldCout = std::cout.rdbuf(); + m_newCout.open("CONOUT$"); + std::cout.rdbuf(m_newCout.rdbuf()); + + m_oldCerr = std::cerr.rdbuf(); + m_newCerr.open("CONOUT$"); + std::cerr.rdbuf(m_newCerr.rdbuf()); +# ifndef Q_CC_MINGW + HMENU systemMenu = GetSystemMenu(GetConsoleWindow(), FALSE); + if (systemMenu != NULL) + RemoveMenu(systemMenu, SC_CLOSE, MF_BYCOMMAND); + DrawMenuBar(GetConsoleWindow()); +# endif + } + + ~Console() + { + system("PAUSE"); + + std::cin.rdbuf(m_oldCin); + std::cerr.rdbuf(m_oldCerr); + std::cout.rdbuf(m_oldCout); + + FreeConsole(); + } + +private: + std::ifstream m_newCin; + std::ofstream m_newCout; + std::ofstream m_newCerr; + + std::streambuf* m_oldCin; + std::streambuf* m_oldCout; + std::streambuf* m_oldCerr; +}; +#else +class Console +{ +public: + Console() {} +}; +#endif + +#endif // CONSOLE_H diff --git a/src/sdk/installerbase.cpp b/src/sdk/installerbase.cpp index 8d7518fcf..3629cc22f 100644 --- a/src/sdk/installerbase.cpp +++ b/src/sdk/installerbase.cpp @@ -41,6 +41,7 @@ #include "installerbase_p.h" #include "installerbasecommons.h" +#include "sdkapp.h" #include "tabcontroller.h" #include <binaryformat.h> @@ -61,6 +62,8 @@ #include <kdrunoncechecker.h> #include <kdupdaterfiledownloaderfactory.h> +#include <productkeycheck.h> + #include <QDirIterator> #include <QtCore/QTranslator> #include <QMessageBox> @@ -151,7 +154,7 @@ int main(int argc, char *argv[]) // this is the FSEngineServer as an admin rights process upon request: if (args.count() >= 3 && args[1] == QLatin1String("--startserver")) { - MyCoreApplication app(argc, argv); + SDKApp<QCoreApplication> app(argc, argv); FSEngineServer* const server = new FSEngineServer(args[2].toInt()); if (args.count() >= 4) server->setAuthorizationKey(args[3]); @@ -173,18 +176,21 @@ int main(int argc, char *argv[]) #endif if (args.contains(QLatin1String("--checkupdates"))) { - MyCoreApplication app(argc, argv); + SDKApp<QCoreApplication> app(argc, argv); if (runCheck.isRunning(KDRunOnceChecker::ProcessList)) return 0; Updater u; - u.setVerbose(args.contains(QLatin1String("--verbose")) || args.contains(QLatin1String("-v"))); + if (args.contains(QLatin1String("--verbose")) || args.contains(QLatin1String("-v"))) { + app.setVerbose(); + u.setVerbose(true); + } return u.checkForUpdates() ? 0 : 1; } if (args.contains(QLatin1String("--runoperation")) || args.contains(QLatin1String("--undooperation"))) { - MyCoreApplication app(argc, argv); + SDKApp<QCoreApplication> app(argc, argv); OperationRunner o; o.setVerbose(args.contains(QLatin1String("--verbose")) || args.contains(QLatin1String("-v"))); @@ -192,7 +198,7 @@ int main(int argc, char *argv[]) } if (args.contains(QLatin1String("--update-installerbase"))) { - MyCoreApplication app(argc, argv); + SDKApp<QCoreApplication> app(argc, argv); if (runCheck.isRunning(KDRunOnceChecker::ProcessList)) return 0; @@ -216,7 +222,7 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } - MyCoreApplication app(argc, argv); + SDKApp<QCoreApplication> app(argc, argv); // input, if not given use current app QString input; @@ -233,7 +239,7 @@ int main(int argc, char *argv[]) } // from here, the "normal" installer binary is running - MyApplication app(argc, argv); + SDKApp<QApplication> app(argc, argv); args = app.arguments(); if (runCheck.isRunning(KDRunOnceChecker::ProcessList)) { @@ -295,6 +301,7 @@ int main(int argc, char *argv[]) // instantiate the installer we are actually going to use QInstaller::PackageManagerCore core(content.magicMarker(), content.performedOperations()); + ProductKeyCheck::instance()->init(&core); QString controlScript; QHash<QString, QString> params; diff --git a/src/sdk/installerbase.qrc b/src/sdk/installerbase.qrc index 678515eaf..c43461833 100644 --- a/src/sdk/installerbase.qrc +++ b/src/sdk/installerbase.qrc @@ -1,13 +1,13 @@ <RCC> <qresource prefix="/"> - <file>translations/de_de.qm</file> + <file alias="translations/de_DE.qm">translations/de_de.qm</file> <file>translations/qt_de.qm</file> - <file>translations/en_us.qm</file> - <file>translations/ru_ru.qm</file> + <file alias="translations/en_US.qm">translations/en_us.qm</file> + <file alias="translations/ru_RU.qm">translations/ru_ru.qm</file> <file>translations/qt_ru.qm</file> - <file>translations/zh_cn.qm</file> + <file alias="translations/zh_CN.qm">translations/zh_cn.qm</file> <file>translations/qt_zh_CN.qm</file> - <file>translations/ja_jp.qm</file> + <file alias="translations/ja_JP.qm">translations/ja_jp.qm</file> <file>translations/qt_ja.qm</file> </qresource> </RCC> diff --git a/src/sdk/installerbase_p.cpp b/src/sdk/installerbase_p.cpp index 4fcbe7b6e..2c79e0dde 100644 --- a/src/sdk/installerbase_p.cpp +++ b/src/sdk/installerbase_p.cpp @@ -39,6 +39,7 @@ ** **************************************************************************/ #include "installerbase_p.h" +#include "console.h" #include <binaryformat.h> #include <errors.h> @@ -58,147 +59,14 @@ #include <QMessageBox> -#include <fstream> #include <iomanip> #include <iostream> -#ifdef Q_OS_WIN -# include <windows.h> -# include <wincon.h> - -# ifndef ENABLE_INSERT_MODE -# define ENABLE_INSERT_MODE 0x0020 -# endif - -# ifndef ENABLE_QUICK_EDIT_MODE -# define ENABLE_QUICK_EDIT_MODE 0x0040 -# endif - -# ifndef ENABLE_EXTENDED_FLAGS -# define ENABLE_EXTENDED_FLAGS 0x0080 -# endif -#endif - using namespace KDUpdater; using namespace QInstaller; using namespace QInstallerCreator; -// -- MyCoreApplication - -MyCoreApplication::MyCoreApplication(int &argc, char **argv) - : QCoreApplication(argc, argv) -{ -} - -// re-implemented from QCoreApplication so we can throw exceptions in scripts and slots -bool MyCoreApplication::notify(QObject *receiver, QEvent *event) -{ - try { - return QCoreApplication::notify(receiver, event); - } catch(std::exception &e) { - qFatal("Exception thrown: %s", e.what()); - } - return false; -} - - -// -- MyApplicationConsole - -class MyApplicationConsole -{ -public: - MyApplicationConsole() - { -#ifdef Q_OS_WIN - AllocConsole(); - - HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE); - if (handle != INVALID_HANDLE_VALUE) { - COORD largestConsoleWindowSize = GetLargestConsoleWindowSize(handle); - largestConsoleWindowSize.X -= 3; - largestConsoleWindowSize.Y = 5000; - SetConsoleScreenBufferSize(handle, largestConsoleWindowSize); - } - - handle = GetStdHandle(STD_INPUT_HANDLE); - if (handle != INVALID_HANDLE_VALUE) - SetConsoleMode(handle, ENABLE_INSERT_MODE | ENABLE_QUICK_EDIT_MODE | ENABLE_EXTENDED_FLAGS); - - m_oldCin = std::cin.rdbuf(); - m_newCin.open("CONIN$"); - std::cin.rdbuf(m_newCin.rdbuf()); - - m_oldCout = std::cout.rdbuf(); - m_newCout.open("CONOUT$"); - std::cout.rdbuf(m_newCout.rdbuf()); - - m_oldCerr = std::cerr.rdbuf(); - m_newCerr.open("CONOUT$"); - std::cerr.rdbuf(m_newCerr.rdbuf()); -# ifndef Q_CC_MINGW - HMENU systemMenu = GetSystemMenu(GetConsoleWindow(), FALSE); - if (systemMenu != NULL) - RemoveMenu(systemMenu, SC_CLOSE, MF_BYCOMMAND); - DrawMenuBar(GetConsoleWindow()); -# endif -#endif - } - ~MyApplicationConsole() - { -#ifdef Q_OS_WIN - system("PAUSE"); - - std::cin.rdbuf(m_oldCin); - std::cerr.rdbuf(m_oldCerr); - std::cout.rdbuf(m_oldCout); - - FreeConsole(); -#endif - } - -private: - std::ifstream m_newCin; - std::ofstream m_newCout; - std::ofstream m_newCerr; - - std::streambuf* m_oldCin; - std::streambuf* m_oldCout; - std::streambuf* m_oldCerr; -}; - - -// -- MyApplication - -MyApplication::MyApplication(int &argc, char **argv) - : QApplication(argc, argv) - , m_console(0) -{ -} - -MyApplication::~MyApplication() -{ - delete m_console; -} - -void MyApplication::setVerbose() -{ - if (!m_console) - m_console = new MyApplicationConsole; -} - -// re-implemented from QApplication so we can throw exceptions in scripts and slots -bool MyApplication::notify(QObject *receiver, QEvent *event) -{ - try { - return QApplication::notify(receiver, event); - } catch(std::exception &e) { - qFatal("Exception thrown: %s", e.what()); - } - return false; -} - - // -- InstallerBase InstallerBase::InstallerBase(QObject *parent) @@ -307,7 +175,7 @@ void InstallerBase::showUsage() { #define WIDTH1 46 #define WIDTH2 40 - MyApplicationConsole c; + Console c; std::cout << "Usage: SDKMaintenanceTool [OPTIONS]" << std::endl << std::endl; std::cout << "User:"<<std::endl; @@ -373,7 +241,7 @@ void InstallerBase::showUsage() /* static*/ void InstallerBase::showVersion(const QString &version) { - MyApplicationConsole c; + Console c; std::cout << qPrintable(version) << std::endl; } diff --git a/src/sdk/installerbase_p.h b/src/sdk/installerbase_p.h index cd6ed0142..5d3e66e31 100644 --- a/src/sdk/installerbase_p.h +++ b/src/sdk/installerbase_p.h @@ -39,8 +39,10 @@ ** **************************************************************************/ +#ifndef INSTALLERBASE_P_H +#define INSTALLERBASE_P_H + #include <QThread> -#include <QApplication> namespace KDUpdater { class FileDownloader; @@ -50,8 +52,6 @@ QT_BEGIN_NAMESPACE class QFile; QT_END_NAMESPACE -class MyApplicationConsole; - class Sleep : public QThread { public: @@ -89,22 +89,4 @@ private: QScopedPointer<KDUpdater::FileDownloader> m_downloader; }; -class MyCoreApplication : public QCoreApplication -{ -public: - MyCoreApplication(int &argc, char **argv); - virtual bool notify(QObject *receiver, QEvent *event); -}; - -class MyApplication : public QApplication -{ -public: - MyApplication(int &argc, char **argv); - ~MyApplication(); - - void setVerbose(); - virtual bool notify(QObject *receiver, QEvent *event); - -private: - MyApplicationConsole *m_console; -}; +#endif // INSTALLERBASE_P_H diff --git a/src/sdk/installerbasecommons.cpp b/src/sdk/installerbasecommons.cpp index a4e5047d0..0cf85a0ec 100644 --- a/src/sdk/installerbasecommons.cpp +++ b/src/sdk/installerbasecommons.cpp @@ -43,6 +43,7 @@ #include <component.h> #include <messageboxhandler.h> #include <packagemanagercore.h> +#include <packagemanagerpagefactory.h> #include <settings.h> #include <productkeycheck.h> @@ -339,6 +340,7 @@ void IntroductionPageImpl::entering() showMaintenanceTools(); setMaintenanceToolsEnabled(true); } + setSettingsButtonRequested((!core->isOfflineOnly()) && (!core->isUninstaller())); } void IntroductionPageImpl::leaving() @@ -502,6 +504,13 @@ bool TargetDirectoryPageImpl::validatePage() InstallerGui::InstallerGui(PackageManagerCore *core) : PackageManagerGui(core, 0) { + ProductKeyCheck *checker = ProductKeyCheck::instance(); + foreach (const int id, checker->registeredPages()) { + PackageManagerPage *page = PackageManagerPageFactory::instance().create(id, core); + Q_ASSERT_X(page, Q_FUNC_INFO, qPrintable(QString::fromLatin1("Page with %1 couldn't be " + "constructed.").arg(id))); + setPage(id, page); + } setPage(PackageManagerCore::Introduction, new IntroductionPageImpl(core)); setPage(PackageManagerCore::TargetDirectory, new TargetDirectoryPageImpl(core)); setPage(PackageManagerCore::ComponentSelection, new ComponentSelectionPage(core)); @@ -524,6 +533,14 @@ void InstallerGui::init() MaintenanceGui::MaintenanceGui(PackageManagerCore *core) : PackageManagerGui(core, 0) { + ProductKeyCheck *checker = ProductKeyCheck::instance(); + foreach (const int id, checker->registeredPages()) { + PackageManagerPage *page = PackageManagerPageFactory::instance().create(id, core); + Q_ASSERT_X(page, Q_FUNC_INFO, qPrintable(QString::fromLatin1("Page with %1 couldn't be " + "constructed.").arg(id))); + setPage(id, page); + } + IntroductionPageImpl *intro = new IntroductionPageImpl(core); connect(intro, SIGNAL(packageManagerCoreTypeChanged()), this, SLOT(updateRestartPage())); diff --git a/src/sdk/sdk.pro b/src/sdk/sdk.pro index 8b428fe48..b2588603b 100644 --- a/src/sdk/sdk.pro +++ b/src/sdk/sdk.pro @@ -76,7 +76,9 @@ FORMS += settingsdialog.ui HEADERS += installerbase_p.h \ tabcontroller.h \ installerbasecommons.h \ - settingsdialog.h + settingsdialog.h \ + console.h \ + sdkapp.h SOURCES = installerbase.cpp \ installerbase_p.cpp \ diff --git a/src/libs/installer/setdemospathonqtoperation.h b/src/sdk/sdkapp.h index 27d25c9f9..78d586560 100644 --- a/src/libs/installer/setdemospathonqtoperation.h +++ b/src/sdk/sdkapp.h @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 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,46 @@ ** **************************************************************************/ -#ifndef SETDEMOSPATHONQTOPERATION_H -#define SETDEMOSPATHONQTOPERATION_H +#ifndef SDKAPP_H +#define SDKAPP_H -#include "qinstallerglobal.h" +#include "console.h" -namespace QInstaller { +#include <QApplication> -class SetDemosPathOnQtOperation : public Operation +template<class T> +class SDKApp : public T { public: - SetDemosPathOnQtOperation(); + SDKApp(int& argc, char** argv) + : T(argc, argv) + , m_console(0) + { + } - void backup(); - bool performOperation(); - bool undoOperation(); - bool testOperation(); - Operation *clone() const; -}; + virtual ~SDKApp() + { + delete m_console; + } + + void setVerbose() + { + if (!m_console) + m_console = new Console; + } -} // namespace + virtual bool notify(QObject *receiver, QEvent *event) + { + try { + return T::notify(receiver, event); + } catch (std::exception &e) { + qFatal("Exception thrown: %s", e.what()); + } + return false; + } + +private: + Console *m_console; +}; -#endif // SETDEMOSPATHONQTOPERATION_H +#endif // SDKAPP_H diff --git a/src/sdk/settingsdialog.cpp b/src/sdk/settingsdialog.cpp index 1a7903403..305fc051a 100644 --- a/src/sdk/settingsdialog.cpp +++ b/src/sdk/settingsdialog.cpp @@ -42,8 +42,6 @@ #include "settingsdialog.h" #include "ui_settingsdialog.h" -#include <kdupdaterfiledownloader.h> -#include <kdupdaterfiledownloaderfactory.h> #include <packagemanagercore.h> #include <productkeycheck.h> @@ -57,130 +55,6 @@ using namespace QInstaller; - -// -- TestRepositoryJob - -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()); -} - - // -- PasswordDelegate void PasswordDelegate::showPasswords(bool show) @@ -576,6 +450,6 @@ void SettingsDialog::insertRepositories(const QSet<Repository> repos, QTreeWidge foreach (const Repository &repo, repos) { RepositoryItem *item = new RepositoryItem(repo); rootItem->addChild(item); - item->setHidden(!ProductKeyCheck::instance(m_core)->isValidRepository(repo)); + item->setHidden(!ProductKeyCheck::instance()->isValidRepository(repo)); } } diff --git a/src/sdk/settingsdialog.h b/src/sdk/settingsdialog.h index 1a6633c67..a2386acbb 100644 --- a/src/sdk/settingsdialog.h +++ b/src/sdk/settingsdialog.h @@ -43,8 +43,7 @@ #include <repository.h> #include <settings.h> - -#include <kdjob.h> +#include <testrepository.h> #include <QDialog> #include <QStyledItemDelegate> @@ -56,10 +55,6 @@ class QLocale; class QVariant; QT_END_NAMESPACE -namespace KDUpdater { - class FileDownloader; -} - namespace QInstaller { class PackageManagerCore; } @@ -68,36 +63,6 @@ namespace Ui { class SettingsDialog; } - -// -- TestRepositoryJob - -class TestRepository : public KDJob -{ - Q_OBJECT - -public: - - 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; -}; - - // -- PasswordDelegate class PasswordDelegate : public QStyledItemDelegate @@ -177,7 +142,7 @@ private: QInstaller::PackageManagerCore *m_core; bool m_showPasswords; - TestRepository m_testRepository; + QInstaller::TestRepository m_testRepository; QList<QTreeWidgetItem*> m_rootItems; }; diff --git a/src/sdk/tabcontroller.cpp b/src/sdk/tabcontroller.cpp index 770ea8007..d0e322251 100644 --- a/src/sdk/tabcontroller.cpp +++ b/src/sdk/tabcontroller.cpp @@ -124,10 +124,6 @@ void TabController::setManagerParams(const QHash<QString, QString> ¶ms) int TabController::init() { - if (!ProductKeyCheck::instance()->hasValidKey() && d->m_core->isInstaller()) { - return PackageManagerCore::Failure; - } - if (!d->m_init) { d->m_init = true; // this should called as early as possible, to handle error message boxes for example @@ -200,9 +196,9 @@ void TabController::onSettingsButtonClicked() void TabController::onCurrentIdChanged(int newId) { - if (d->m_gui && d->m_core) { - d->m_gui->showSettingsButton((newId == PackageManagerCore::Introduction) & - (!d->m_core->isOfflineOnly()) & (!d->m_core->isUninstaller())); + if (d->m_gui) { + if (PackageManagerPage *page = d->m_gui->page(newId)) + d->m_gui->showSettingsButton(page->settingsButtonRequested()); } } diff --git a/src/sdk/translations/de_de.ts b/src/sdk/translations/de_de.ts index c042c4990..006e71b4e 100644 --- a/src/sdk/translations/de_de.ts +++ b/src/sdk/translations/de_de.ts @@ -2119,8 +2119,8 @@ Bitte kopieren Sie den Installer auf ein lokales Laufwerk</translation> <context> <name>QInstaller::PerformInstallationPage</name> <message> - <location filename="../../libs/installer/packagemanagergui.cpp" line="1728"/> - <source>&Uninstall</source> + <location filename="../../libs/installer/packagemanagergui.cpp" line="1722"/> + <source>U&ninstall</source> <translation>&Deinstallieren</translation> </message> <message> diff --git a/src/sdk/translations/en_us.ts b/src/sdk/translations/en_us.ts index 330f5f394..a5d636a2c 100644 --- a/src/sdk/translations/en_us.ts +++ b/src/sdk/translations/en_us.ts @@ -1902,7 +1902,7 @@ Please copy the installer to a local drive</source> <name>QInstaller::PerformInstallationPage</name> <message> <location filename="../../libs/installer/packagemanagergui.cpp" line="1733"/> - <source>&Uninstall</source> + <source>U&ninstall</source> <translation type="unfinished"></translation> </message> <message> diff --git a/src/sdk/translations/ja_jp.ts b/src/sdk/translations/ja_jp.ts index 6af882705..3303cfd10 100644 --- a/src/sdk/translations/ja_jp.ts +++ b/src/sdk/translations/ja_jp.ts @@ -153,56 +153,44 @@ <translation> - 残り時間: 不明。</translation> </message> <message> - <source> of </source> - <translation> / </translation> + <source>%1 of %2</source> + <translation>%1 / %2</translation> </message> <message> - <source> downloaded.</source> - <translation> ダウンロードしました。</translation> + <source>%1 downloaded.</source> + <translation>%1 ダウンロードしました。</translation> </message> <message> - <source>/sec</source> - <translation>/秒</translation> + <source>(%1/sec)</source> + <translation>(%1/秒)</translation> </message> - <message> - <source> day</source> - <translation>日</translation> - </message> - <message> - <source> days</source> - <translation>日</translation> - </message> - <message> - <source> hour</source> - <translation>時間</translation> - </message> - <message> - <source> hours</source> - <translation>時間</translation> - </message> - <message> - <source> minute</source> - <translation>分</translation> - </message> - <message> - <source> minutes</source> - <translation>分</translation> + <message numerus="yes"> + <source>%n day(s), </source> + <translation> + <numerusform>%n 日 </numerusform> + </translation> </message> - <message> - <source> second</source> - <translation> 秒</translation> + <message numerus="yes"> + <source>%n hour(s), </source> + <translation> + <numerusform>%n 時間 </numerusform> + </translation> </message> - <message> - <source> seconds</source> - <translation> 秒</translation> + <message numerus="yes"> + <source>%n minute(s)</source> + <translation> + <numerusform>%n 分 </numerusform> + </translation> </message> - <message> - <source> - </source> - <translation> - </translation> + <message numerus="yes"> + <source>%n second(s)</source> + <translation> + <numerusform>%n 秒 </numerusform> + </translation> </message> <message> - <source> remaining.</source> - <translation>の残り時間。</translation> + <source> - %1%2%3%4 remaining.</source> + <translation>- 残り時間 %1%2%3%4。</translation> </message> </context> <context> @@ -446,9 +434,11 @@ <source>Application updates computed.</source> <translation>アプリケーションに更新を適用しました。</translation> </message> - <message> - <source>%1 updates found.</source> - <translation>%1個の更新が見つかりました。</translation> + <message numerus="yes"> + <source>%n update(s) found.</source> + <translation> + <numerusform>%n個の更新が見つかりました。</numerusform> + </translation> </message> </context> <context> @@ -528,6 +518,45 @@ </message> </context> <context> + <name>QInstaller</name> + <message> + <source>bytes</source> + <translation>バイト</translation> + </message> + <message> + <source>KiB</source> + <translation>KB</translation> + </message> + <message> + <source>MiB</source> + <translation>MB</translation> + </message> + <message> + <source>GiB</source> + <translation>GB</translation> + </message> + <message> + <source>TiB</source> + <translation>TB</translation> + </message> + <message> + <source>PiB</source> + <translation>PB</translation> + </message> + <message> + <source>EiB</source> + <translation>EB</translation> + </message> + <message> + <source>ZiB</source> + <translation>ZB</translation> + </message> + <message> + <source>YiB</source> + <translation>YB</translation> + </message> +</context> +<context> <name>QInstaller::AddQtCreatorArrayValueOperation</name> <message> <source>exactly 4</source> @@ -585,11 +614,11 @@ <translation>更新情報: </translation> </message> <message> - <source>Can't resolve isAutoDependOn in %1</source> + <source>Cannot resolve isAutoDependOn in %1</source> <translation>%1 の isAutoDependOn を解決できません</translation> </message> <message> - <source>Can't resolve isDefault in %1</source> + <source>Cannot resolve isDefault in %1</source> <translation>%1 の isDefault を解決できません</translation> </message> </context> @@ -1210,11 +1239,11 @@ Error while loading %2</source> <translation>与えられた引数のうち、少なくとも一つが空です。引数1=%1, 引数2=%2, 引数3=%3</translation> </message> <message> - <source>Can't invoke otool. Is Xcode installed?</source> + <source>Cannot invoke otool. Is Xcode installed?</source> <translation>otool を起動できません。Xcode はインストールされていますか?</translation> </message> <message> - <source>Can't start process %0.</source> + <source>Cannot start process %0.</source> <translation>プロセス %0 を起動できません。</translation> </message> </context> @@ -1569,8 +1598,8 @@ Please copy the installer to a local drive</source> <translation>%1のインストール</translation> </message> <message> - <source>&Uninstall</source> - <translation>アンインストール(&U)</translation> + <source>U&ninstall</source> + <translation>アンインストール(&N)</translation> </message> </context> <context> @@ -1709,33 +1738,6 @@ Qt のバイナリにパッチを適用しようとしましたが、Qt の他 </message> </context> <context> - <name>QInstaller::RegisterDefaultDebuggerOperation</name> - <message> - <source>Invalid arguments in %0: %1 arguments given, 2 expected.</source> - <translation>%0 に無効な引数: %1個の引数が渡されましたが、必要なのは2個です。</translation> - </message> - <message> - <source>Needed installer object in "%1" operation is empty.</source> - <translation>"%1" のインストーラ作成に必要な操作が見つかりません。</translation> - </message> - <message> - <source>Invalid arguments in %0: %1 arguments given, %2 expected%3.</source> - <translation>%0 に無効な引数: %1個の引数が渡されましたが、必要なのは%2です%3。</translation> - </message> - <message> - <source>exactly 2</source> - <translation>2個</translation> - </message> - <message> - <source>There is no value set for %1 on the installer object.</source> - <translation>インストーラの %1 用に値が設定されていません。</translation> - </message> - <message> - <source>Can't read from tool chains xml file(%1) correctly.</source> - <translation>ツールチェイン XML ファイル(%1) を正常に読み込むことができません。</translation> - </message> -</context> -<context> <name>QInstaller::RegisterFileTypeOperation</name> <message> <source>Invalid arguments in %0: %1 arguments given, %2 expected%3.</source> @@ -1751,64 +1753,6 @@ Qt のバイナリにパッチを適用しようとしましたが、Qt の他 </message> </context> <context> - <name>QInstaller::RegisterQtInCreatorQNXOperation</name> - <message> - <source>Invalid arguments in %0: %1 arguments given, %2 expected%3.</source> - <translation>%0 に無効な引数: %1個の引数が渡されましたが、必要なのは%2です%3。</translation> - </message> - <message> - <source>at least 5</source> - <translation>少なくとも5個</translation> - </message> - <message> - <source>Needed installer object in "%1" operation is empty.</source> - <translation>"%1" のインストーラ作成に必要な操作が見つかりません。</translation> - </message> - <message> - <source>There is no value set for %1 on the installer object.</source> - <translation>インストーラの %1 用に値が設定されていません。</translation> - </message> - <message> - <source>Invalid arguments in %0: %1 arguments given, minimum 4 expected.</source> - <translation>%0 に無効な引数: %1個の引数が渡されましたが、必要なのは少なくとも4個です。</translation> - </message> -</context> -<context> - <name>QInstaller::RegisterToolChainOperation</name> - <message> - <source>at least 4</source> - <translation>少なくとも4個</translation> - </message> - <message> - <source>Needed installer object in '%1' operation is empty.</source> - <translation>'%1' のインストーラ作成に必要な操作が見つかりません。</translation> - </message> - <message> - <source>There is no value set for '%1' on the installer object.</source> - <translation>インストーラの %1 用に値が設定されていません。</translation> - </message> - <message> - <source>Invalid arguments in %0: %1 arguments given, minimum 4 expected.</source> - <translation>%0 に無効な引数: %1個の引数が渡されましたが、必要なのは少なくとも4個です。</translation> - </message> - <message> - <source>Needed installer object in "%1" operation is empty.</source> - <translation>"%1" のインストーラ作成に必要な操作が見つかりません。</translation> - </message> - <message> - <source>Invalid arguments in %0: %1 arguments given, %2 expected%3.</source> - <translation>%0 に無効な引数: %1個の引数が渡されましたが、必要なのは%2です%3。</translation> - </message> - <message> - <source>Some arguments are not right in %1 operation.</source> - <translation>いくつかの引数が %1 の操作には正しくありません。</translation> - </message> - <message> - <source>Can't read from tool chains xml file(%1) correctly.</source> - <translation>ツールチェイン XML ファイル(%1) を正常に読み込むことができません。</translation> - </message> -</context> -<context> <name>QInstaller::ReplaceOperation</name> <message> <source>Invalid arguments in %0: %1 arguments given, %2 expected%3.</source> @@ -1861,109 +1805,6 @@ Qt のバイナリにパッチを適用しようとしましたが、Qt の他 </message> </context> <context> - <name>QInstaller::SetDemosPathOnQtOperation</name> - <message> - <source>Invalid arguments in %0: %1 arguments given, %2 expected%3.</source> - <translation>%0 に無効な引数: %1個の引数が渡されましたが、必要なのは%2です%3。</translation> - </message> - <message> - <source>exactly 2</source> - <translation>2個</translation> - </message> - <message> - <source>The output of -'%1 -query' -is not parseable. Please file a bugreport with this dialog at https://bugreports.qt-project.org. -output: %2</source> - <translation>以下の出力がパースできません。 -%1 -query -このダイアログから https://bugreports.qt-project.org へバグ報告をしてください。 -出力: "%2"</translation> - </message> - <message> - <source>Qt patch error: new Qt demo path '%1' -needs to be less than 255 characters.</source> - <translation>Qt パッチエラー: 新しい Qt デモのパス '%1' -は255文字以下である必要があります。</translation> - </message> -</context> -<context> - <name>QInstaller::SetExamplesPathOnQtOperation</name> - <message> - <source>Invalid arguments in %0: %1 arguments given, %2 expected%3.</source> - <translation>%0 に無効な引数: %1個の引数が渡されましたが、必要なのは%2です%3。</translation> - </message> - <message> - <source>exactly 2</source> - <translation>2個</translation> - </message> - <message> - <source>The output of -'%1 -query' -is not parseable. Please file a bugreport with this dialog at https://bugreports.qt-project.org. -output: %2</source> - <translation>以下の出力がパースできません。 -%1 -query -このダイアログから https://bugreports.qt-project.org へバグ報告をしてください。 -出力: "%2"</translation> - </message> - <message> - <source>Qt patch error: new Qt example path '%1' -needs to be less than 255 characters.</source> - <translation>Qt パッチエラー: 新しい Qt サンプルのパス '%1' -は255文字以下である必要があります。</translation> - </message> -</context> -<context> - <name>QInstaller::SetImportsPathOnQtCoreOperation</name> - <message> - <source>Invalid arguments in %0: %1 arguments given, %2 expected%3.</source> - <translation>%0 に無効な引数: %1個の引数が渡されましたが、必要なのは%2です%3。</translation> - </message> - <message> - <source>exactly 2</source> - <translation>2個</translation> - </message> - <message> - <source>Qt patch error: new Qt imports path '%1' -needs to be less than 255 characters.</source> - <translation>Qt パッチエラー: 新しい Qt の import パス '%1' -は255文字以下である必要があります。</translation> - </message> -</context> -<context> - <name>QInstaller::SetPathOnQtCoreOperation</name> - <message> - <source>Invalid arguments in %0: %1 arguments given, %2 expected%3.</source> - <translation>%0 に無効な引数: %1個の引数が渡されましたが、必要なのは%2です%3。</translation> - </message> - <message> - <source>exactly 3</source> - <translation>3個</translation> - </message> - <message> - <source>The second type/value needs to be one of: %1</source> - <translation>二番目の引数の型あるいは値は右記のいずれかである必要があります: %1</translation> - </message> -</context> -<context> - <name>QInstaller::SetPluginPathOnQtCoreOperation</name> - <message> - <source>Invalid arguments in %0: %1 arguments given, %2 expected%3.</source> - <translation>%0 に無効な引数: %1個の引数が渡されましたが、必要なのは%2です%3。</translation> - </message> - <message> - <source>exactly 2</source> - <translation>2個</translation> - </message> - <message> - <source>Qt patch error: new Qt plugin path '%1' -needs to be less than 255 characters.</source> - <translation>Qt パッチエラー: 新しい Qt のプラグインパス '%1' -は255文字以下である必要があります。</translation> - </message> -</context> -<context> <name>QInstaller::SetQtCreatorValueOperation</name> <message> <source>Invalid arguments in %0: %1 arguments given, %2 expected%3.</source> @@ -1991,6 +1832,17 @@ needs to be less than 255 characters.</source> </message> </context> <context> + <name>QInstaller::SettingsOperation</name> + <message> + <source>Missing argument(s) '%1' calling '%2' with arguments '%3'.</source> + <translation>'%2' を引数 '%3' で呼び出しましたが、'%1' の引数が不足しています。</translation> + </message> + <message> + <source>Current method argument calling '%1' with arguments '%2' is not supported. Please use set, remove, add_array_value or remove_array_value.</source> + <translation>'%1' の呼び出し時に method 引数の値として '%2' はサポートされていません。set, remove, add_array_value, remove_array_value を使用してください。</translation> + </message> +</context> +<context> <name>QInstaller::SimpleMoveFileOperation</name> <message> <source>Invalid arguments in %0: %1 arguments given, %2 expected%3.</source> @@ -2073,6 +1925,33 @@ needs to be less than 255 characters.</source> </message> </context> <context> + <name>QInstaller::TestRepository</name> + <message> + <source>Empty repository URL.</source> + <translation>リポジトリの URL が空です。</translation> + </message> + <message> + <source>URL scheme not supported: %1 (%2).</source> + <translation>この URL スキームはサポートしてません: %1 (%2)</translation> + </message> + <message> + <source>Got a timeout while testing: '%1'</source> + <translation>テスト中にタイムアウトが発生しました: '%1'</translation> + </message> + <message> + <source>Could not parse Updates.xml! Error: %1.</source> + <translation>Updates.xml を解析できませんでした! エラー: %1</translation> + </message> + <message> + <source>Updates.xml could not be opened for reading!</source> + <translation>読み込み用に Updates.xml を開けませんでした!</translation> + </message> + <message> + <source>Updates.xml could not be found on server!</source> + <translation>サーバ上に Updates.xml が見つかりませんでした!</translation> + </message> +</context> +<context> <name>QInstallerCreator::Archive</name> <message> <source>Could not create %1: %2</source> @@ -2094,22 +1973,10 @@ needs to be less than 255 characters.</source> <context> <name>QObject</name> <message> - <source>Searched whole file, no marker found</source> - <translation>ファイル全体を検索しましたが、マーカーが見つかりませんでした</translation> - </message> - <message> - <source>Could not seek to %1 in file %2: %3</source> - <translation>ファイル %2 の %1 へシークできませんでした: %3</translation> - </message> - <message> <source>No marker found, stopped after %1.</source> <translation>マーカーが見つからなかったため、%1 で停止しました。</translation> </message> <message> - <source>No marker found, unknown exception caught.</source> - <translation>マーカーが見つかりませんでした。未知の例外が発生しました。</translation> - </message> - <message> <source>Cannot create zipped file for path %1: %2</source> <translation>%1 に ZIP ファイルを作成できませんでした: %2</translation> </message> @@ -2194,10 +2061,6 @@ needs to be less than 255 characters.</source> <translation>テンプレート %1 用の一時ファイルを開けませんでした: %2</translation> </message> <message> - <source>Could not create temporary folder for template %1: %2</source> - <translation>テンプレート %1 用の一時フォルダを作成できませんでした: %2</translation> - </message> - <message> <source>Could not create lock file %1: %2</source> <translation>ロックファイル %1 を作成できませんでした: %2</translation> </message> @@ -2446,11 +2309,19 @@ needs to be less than 255 characters.</source> <translation>続行するにはこれらのプロセスを終了してください: %1</translation> </message> <message> - <source>Couldn't get authorization.</source> + <source>Could not create temporary directory at %1: %2</source> + <translation>テンプレート用の一時ディレクトリを %1 に作成できませんでした: %2</translation> + </message> + <message> + <source>Could not create temporary directory at %1: unknown error</source> + <translation>テンプレート用の一時フォルダを %1 に作成できませんでした: 未知のエラー</translation> + </message> + <message> + <source>Could not get authorization.</source> <translation>認証することができませんでした。</translation> </message> <message> - <source>Couldn't get authorization that is needed for continuing the installation. + <source>Could not get authorization that is needed for continuing the installation. Either abort the installation or use the fallback solution by running %1 as root and then clicking ok.</source> @@ -2459,6 +2330,10 @@ as root and then clicking ok.</source> %1 を実行した後に「OK」をクリックしてください。</translation> </message> + <message> + <source>Failed to seek in file %1. Reason: %2.</source> + <translation>ファイル %1 のシークに失敗しました: %2</translation> + </message> </context> <context> <name>Settings</name> @@ -2467,4 +2342,231 @@ as root and then clicking ok.</source> <translation>読み込み用に設定ファイル %1 を開けませんでした: %2</translation> </message> </context> +<context> + <name>SettingsDialog</name> + <message> + <source>Settings</source> + <translation>設定</translation> + </message> + <message> + <source>Network</source> + <translation>ネットワーク</translation> + </message> + <message> + <source>No proxy</source> + <translation>プロキシを使用しない</translation> + </message> + <message> + <source>System proxy settings</source> + <translation>システムのプロキシ設定を使用する</translation> + </message> + <message> + <source>Manual proxy configuration</source> + <translation>手動でプロキシを設定する</translation> + </message> + <message> + <source>HTTP proxy:</source> + <translation>HTTP プロキシ:</translation> + </message> + <message> + <source>Port:</source> + <translation>ポート:</translation> + </message> + <message> + <source>HTTP proxy requires authentication</source> + <translation>HTTP プロキシで認証が必要</translation> + </message> + <message> + <source>Username:</source> + <translation>ユーザ名:</translation> + </message> + <message> + <source>Password:</source> + <translation>パスワード:</translation> + </message> + <message> + <source>FTP proxy:</source> + <translation>FTP プロキシ:</translation> + </message> + <message> + <source>FTP proxy requires authentication</source> + <translation>FTP プロキシで認証が必要</translation> + </message> + <message> + <source>Repositories</source> + <translation>リポジトリ</translation> + </message> + <message> + <source>Add Username and Password for authentication if needed.</source> + <translation>認証が必要な場合はユーザ名とパスワードを記述してください。</translation> + </message> + <message> + <source>Use temporary repositories only</source> + <translation>一時リポジトリのみを使用する</translation> + </message> + <message> + <source>Add</source> + <translation>追加</translation> + </message> + <message> + <source>Remove</source> + <translation>削除</translation> + </message> + <message> + <source>Test</source> + <translation>テスト</translation> + </message> + <message> + <source>Show Passwords</source> + <translation>パスワードを表示する</translation> + </message> + <message> + <source>Check this to use repository during fetch.</source> + <translation>このリポジトリの内容を取得する場合はチェックしてください。</translation> + </message> + <message> + <source>Add the username to authenticate on the server.</source> + <translation>サーバでの認証用ユーザ名を追加してください。</translation> + </message> + <message> + <source>Add the password to authenticate on the server.</source> + <translation>サーバでの認証用パスワードを追加してください。</translation> + </message> + <message> + <source>The servers URL that contains a valid repository.</source> + <translation>有効なリポジトリを含むサーバのURLです。</translation> + </message> + <message> + <source>There was an error testing this repository.</source> + <translation>このリポジトリのテスト中にエラーが発生しました。</translation> + </message> + <message> + <source>Do you want to disable the tested repository?</source> + <translation>このテスト済みリポジトリを無効にしますか?</translation> + </message> + <message> + <source>Hide Passwords</source> + <translation>パスワードを隠す</translation> + </message> + <message> + <source>Use</source> + <translation>利用</translation> + </message> + <message> + <source>Username</source> + <translation>ユーザ名</translation> + </message> + <message> + <source>Password</source> + <translation>パスワード</translation> + </message> + <message> + <source>Repository</source> + <translation>リポジトリ</translation> + </message> + <message> + <source>Default repositories</source> + <translation>デフォルトリポジトリ</translation> + </message> + <message> + <source>Temporary repositories</source> + <translation>一時リポジトリ</translation> + </message> + <message> + <source>User defined repositories</source> + <translation>ユーザ定義リポジトリ</translation> + </message> +</context> +<context> + <name>IntroductionPageImpl</name> + <message> + <source>Package manager</source> + <translation>パッケージマネージャ</translation> + </message> + <message> + <source>Update components</source> + <translation>コンポーネントの更新</translation> + </message> + <message> + <source>Remove all components</source> + <translation>すべてのコンポーネントの削除</translation> + </message> + <message> + <source>Retrieving information from remote installation sources...</source> + <translation>リモートのインストール元から情報を取得しています...</translation> + </message> + <message> + <source>At least one valid and enabled repository required for this action to succeed.</source> + <translation>このアクションの実行にはひとつ以上の有効なリポジトリが必要です。</translation> + </message> + <message> + <source>No updates available.</source> + <translation>新しい更新はありません。</translation> + </message> + <message> + <source> Only local package management available.</source> + <translation> ローカルのパッケージ管理のみ利用できます。</translation> + </message> + <message> + <source>Quit</source> + <translation>終了</translation> + </message> +</context> +<context> + <name>TargetDirectoryPageImpl</name> + <message> + <source>The installation path cannot be empty, please specify a valid folder.</source> + <translation>インストール先のパスは空にできません。有効なフォルダを指定してください。</translation> + </message> + <message> + <source>The installation path cannot be relative, please specify an absolute path.</source> + <translation>インストール先のパスに相対パスは使用できません。絶対パスで指定してください。</translation> + </message> + <message> + <source>The path you have entered is too long, please make sure to specify a valid path.</source> + <translation>入力したパスが長すぎます。有効なパスかどうか確認してください。</translation> + </message> + <message> + <source>The path you have entered is not valid, please make sure to specify a valid drive.</source> + <translation>入力したパスは無効です。有効なドライブかどうか確認してください。</translation> + </message> + <message> + <source>The installation path must not contain %1, please specify a valid folder.</source> + <translation>インストール先のパスに %1 は使用できません。有効なフォルダを指定してください。</translation> + </message> + <message> + <source>The path or installation directory contains non ASCII characters. This is currently not supported! Please choose a different path or installation directory.</source> + <translation>インストール先のディレクトリあるいはそれまでのパスに非 ASCII 文字が含まれています。そのようなパスへのインストールはサポートされていません。別のディレクトリあるいはパスを選択してください。</translation> + </message> + <message> + <source>Warning</source> + <translation>警告</translation> + </message> + <message> + <source>Error</source> + <translation>エラー</translation> + </message> + <message> + <source>As the install directory is completely deleted installing in %1 is forbidden.</source> + <translation>インストールしたディレクトリはアンインストール時に完全に削除されるため、%1 へのインストールは許可できません。</translation> + </message> + <message> + <source>The folder you selected already exists and contains an installation. Choose a different target for installation.</source> + <translation>選択されたフォルダは既に存在し、インストール済みです。他のインストール先を選択してください。</translation> + </message> + <message> + <source>You have selected an existing, non-empty folder for installation. +Note that it will be completely wiped on uninstallation of this application. +It is not advisable to install into this folder as installation might fail. +Do you want to continue?</source> + <translation>既存の空ではないフォルダをインストール先に選択しました。 +このアプリケーションをアンインストールする時にはこのフォルダすべてが消去されることに注意してください。 +このフォルダへのインストールは失敗する可能性もあり推奨されません。 +インストールを継続しますか?</translation> + </message> + <message> + <source>You have selected an existing file or symlink, please choose a different target for installation.</source> + <translation>既存のファイルあるいはシンボリックリンクを選択しました。他のインストール先を選択してください。</translation> + </message> +</context> </TS> diff --git a/src/sdk/translations/ru_ru.ts b/src/sdk/translations/ru_ru.ts index 65c35d62a..f7fcf2917 100644 --- a/src/sdk/translations/ru_ru.ts +++ b/src/sdk/translations/ru_ru.ts @@ -1921,7 +1921,7 @@ Please copy the installer to a local drive</source> <name>QInstaller::PerformInstallationPage</name> <message> <location filename="../../libs/installer/packagemanagergui.cpp" line="1733"/> - <source>&Uninstall</source> + <source>U&ninstall</source> <translation>&Удалить</translation> </message> <message> diff --git a/src/sdk/translations/sv_se.ts b/src/sdk/translations/sv_se.ts index 4dafb0cac..c6557cdab 100644 --- a/src/sdk/translations/sv_se.ts +++ b/src/sdk/translations/sv_se.ts @@ -1815,7 +1815,7 @@ Installing component %1</source> <name>QInstaller::PerformInstallationPage</name> <message> <location filename="../../libinstaller/packagemanagergui.cpp" line="1776"/> - <source>&Uninstall</source> + <source>U&ninstall</source> <translation type="unfinished"></translation> </message> <message> diff --git a/src/sdk/translations/zh_cn.ts b/src/sdk/translations/zh_cn.ts index 58acbd106..022d368ec 100644 --- a/src/sdk/translations/zh_cn.ts +++ b/src/sdk/translations/zh_cn.ts @@ -1606,7 +1606,7 @@ Please copy the installer to a local drive</source> <context> <name>QInstaller::PerformInstallationPage</name> <message> - <source>&Uninstall</source> + <source>U&ninstall</source> <translation>卸载(&U)</translation> </message> <message> |