diff options
author | Katja Marttila <katja.marttila@qt.io> | 2018-01-30 09:28:23 +0200 |
---|---|---|
committer | Katja Marttila <katja.marttila@qt.io> | 2018-02-08 12:55:47 +0200 |
commit | fff2c98f4a7d8e4e903232b08f72aeffd5e0cda1 (patch) | |
tree | 901763a343a2085b6c21c314f1b789290ceaeb63 /src/libs/installer | |
parent | 0797935d299d0da007cae0ab89ee9ceadc41d670 (diff) | |
parent | e6c28c7fe32de1dca539c987e1c0a26f48ab0483 (diff) |
Merge remote-tracking branch 'origin/3.0' into master
Change-Id: I8d0c8b9faa9537b50e989ec264ed7bfe8d2e358b
Diffstat (limited to 'src/libs/installer')
-rw-r--r-- | src/libs/installer/copydirectoryoperation.cpp | 4 | ||||
-rw-r--r-- | src/libs/installer/environmentvariablesoperation.cpp | 51 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore.cpp | 6 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore_p.cpp | 4 | ||||
-rw-r--r-- | src/libs/installer/packagemanagerproxyfactory.cpp | 7 | ||||
-rw-r--r-- | src/libs/installer/remoteclient_p.h | 56 | ||||
-rw-r--r-- | src/libs/installer/scriptengine.cpp | 5 |
7 files changed, 95 insertions, 38 deletions
diff --git a/src/libs/installer/copydirectoryoperation.cpp b/src/libs/installer/copydirectoryoperation.cpp index cdd6da6ab..e83af07e1 100644 --- a/src/libs/installer/copydirectoryoperation.cpp +++ b/src/libs/installer/copydirectoryoperation.cpp @@ -85,7 +85,7 @@ bool CopyDirectoryOperation::performOperation() if (!dir.exists() || !dir.isDir()) { setError(InvalidArguments); setErrorString(tr("Invalid argument in %1: Directory \"%2\" is invalid.").arg(name()) - .arg(QDir::toNativeSeparators(sourcePath))); + .arg(QDir::toNativeSeparators(dir.absolutePath()))); return false; } } @@ -157,7 +157,7 @@ bool CopyDirectoryOperation::undoOperation() setErrorString(tr("Cannot remove file \"%1\".").arg(QDir::toNativeSeparators(file))); return false; } - dir.rmpath(QFileInfo(file).absolutePath()); + dir.rmdir(QFileInfo(file).absolutePath()); emit outputTextChanged(file); } diff --git a/src/libs/installer/environmentvariablesoperation.cpp b/src/libs/installer/environmentvariablesoperation.cpp index b80951d2b..7a8dbfb5a 100644 --- a/src/libs/installer/environmentvariablesoperation.cpp +++ b/src/libs/installer/environmentvariablesoperation.cpp @@ -65,6 +65,48 @@ static void broadcastEnvironmentChange() namespace { +bool handleRegExpandSz(const QString ®Path, const QString &name, + const QString &value, QString *errorString, + bool *error) +{ + bool setAsExpandSZ = false; +#ifdef Q_OS_WIN + // Account for when it is originally REG_EXPAND_SZ as we don't want + // to lose this setting (see Path environment variable) + const bool isLocalKey = regPath.startsWith(QStringLiteral("HKEY_LOCAL")); + HKEY hkey = isLocalKey ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; + // Drop the HKEY...\\ part + const QString keyPath = regPath.mid(isLocalKey ? 19 : 18, -1); + HKEY handle; + LONG res = RegOpenKeyEx(hkey, reinterpret_cast<const wchar_t *>(keyPath.utf16()), 0, + KEY_READ, &handle); + if (res == ERROR_SUCCESS) { + DWORD dataType; + DWORD dataSize; + res = RegQueryValueEx(handle, reinterpret_cast<const wchar_t *>(name.utf16()), 0, + &dataType, 0, &dataSize); + setAsExpandSZ = (res == ERROR_SUCCESS) && (dataType == REG_EXPAND_SZ); + if (setAsExpandSZ) { + RegCloseKey(handle); + res = RegOpenKeyEx(hkey, reinterpret_cast<const wchar_t *>(keyPath.utf16()), 0, + KEY_SET_VALUE, &handle); + if (res == ERROR_SUCCESS) { + const QByteArray data(reinterpret_cast<const char *>(value.utf16()), + (value.length() + 1) * 2); + res = RegSetValueEx(handle, reinterpret_cast<const wchar_t *>(name.utf16()), 0, REG_EXPAND_SZ, + reinterpret_cast<const unsigned char*>(data.constData()), data.size()); + RegCloseKey(handle); + } + if (res != ERROR_SUCCESS) { + *errorString = UpdateOperation::tr("Cannot write to registry path %1.").arg(regPath); + *error = true; + } + } + } +#endif + return setAsExpandSZ; +} + template <typename SettingsType> UpdateOperation::Error writeSetting(const QString ®Path, const QString &name, @@ -82,6 +124,10 @@ UpdateOperation::Error writeSetting(const QString ®Path, // remember old value for undo *oldValue = registry.value(name).toString(); + bool error = false; + if (handleRegExpandSz(regPath, name, value, errorString, &error)) + return error ? UpdateOperation::UserDefinedError : UpdateOperation::NoError; + // set the new value registry.setValue(name, value); registry.sync(); @@ -108,6 +154,11 @@ UpdateOperation::Error undoSetting(const QString ®Path, } if (actual != value) //key changed, don't undo return UpdateOperation::UserDefinedError; + + bool error = false; + if (handleRegExpandSz(regPath, name, oldValue, errorString, &error)) + return error ? UpdateOperation::UserDefinedError : UpdateOperation::NoError; + QString dontcare; return writeSetting<SettingsType>(regPath, name, oldValue, errorString, &dontcare); } diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index 58f7a8145..9b9c986e0 100644 --- a/src/libs/installer/packagemanagercore.cpp +++ b/src/libs/installer/packagemanagercore.cpp @@ -1324,6 +1324,12 @@ bool PackageManagerCore::setDefaultPageVisible(int page, bool visible) Sets a validator for the custom page specified by \a name and \a callbackName for the component \a component. + When using this, \a name has to match a dynamic page starting with \c Dynamic. For example, if the page + is called DynamicReadyToInstallWidget, then \a name should be set to \c ReadyToInstallWidget. The + \a callbackName should be set to a function that returns a boolean. When the \c Next button is pressed + on the custom page, then it will call the \a callbackName function. If this returns \c true, then it will + move to the next page. + \sa {installer::setValidatorForCustomPage}{installer.setValidatorForCustomPage} \sa setValidatorForCustomPageRequested() */ diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index fb1082294..57f430778 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -1197,8 +1197,8 @@ void PackageManagerCorePrivate::writeMaintenanceTool(OperationList performedOper performOperationThreaded(op, Backup); performOperationThreaded(op); - // copy application icons if it exists - const QString icon = QFileInfo(QCoreApplication::applicationFilePath()).baseName() + // copy application icons if it exists. + const QString icon = QFileInfo(QCoreApplication::applicationFilePath()).fileName() + QLatin1String(".icns"); op = createOwnedOperation(QLatin1String("Copy")); op->setArguments(QStringList() << (sourceAppDirPath + QLatin1String("/../Resources/") + icon) diff --git a/src/libs/installer/packagemanagerproxyfactory.cpp b/src/libs/installer/packagemanagerproxyfactory.cpp index 98aef7d9a..93135aa1f 100644 --- a/src/libs/installer/packagemanagerproxyfactory.cpp +++ b/src/libs/installer/packagemanagerproxyfactory.cpp @@ -62,13 +62,6 @@ QList<QNetworkProxy> PackageManagerProxyFactory::queryProxy(const QNetworkProxyQ QList<QNetworkProxy> list; if (settings.proxyType() == Settings::SystemProxy) { -#if defined(Q_OS_UNIX) && !defined(Q_OS_OSX) - QUrl proxyUrl = QUrl::fromUserInput(QString::fromUtf8(qgetenv("http_proxy"))); - if (proxyUrl.isValid()) { - return list << QNetworkProxy(QNetworkProxy::HttpProxy, proxyUrl.host(), proxyUrl.port(), - proxyUrl.userName(), proxyUrl.password()); - } -#endif QList<QNetworkProxy> systemProxies = systemProxyForQuery(query); auto proxyIter = systemProxies.begin(); diff --git a/src/libs/installer/remoteclient_p.h b/src/libs/installer/remoteclient_p.h index d1e873d43..ed1731342 100644 --- a/src/libs/installer/remoteclient_p.h +++ b/src/libs/installer/remoteclient_p.h @@ -125,32 +125,38 @@ public: if (!started) { if (m_authorizationFallbackDisabled) { - MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), - QLatin1String("AuthorizationError"), - QCoreApplication::translate("RemoteClient", "Cannot get authorization."), - QCoreApplication::translate("RemoteClient", - "Cannot get authorization that is needed for continuing the installation.\n\n" - "Please start the setup program as a user with the appropriate rights.\n" - "Or accept the elevation of access rights if being asked.")); - return; + QMessageBox::Button res = QMessageBox::Retry; + while (res == QMessageBox::Retry && !started) { + res = MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), + QLatin1String("AuthorizationError"), + QCoreApplication::translate("RemoteClient", "Cannot get authorization."), + QCoreApplication::translate("RemoteClient", + "Cannot get authorization that is needed for continuing the installation.\n\n" + "Please start the setup program as a user with the appropriate rights.\n" + "Or accept the elevation of access rights if being asked."), + QMessageBox::Abort | QMessageBox::Retry, QMessageBox::Retry); + if (res == QMessageBox::Retry) + started = AdminAuthorization::execute(0, m_serverCommand, m_serverArguments); + } + } else { + // something went wrong with authorizing, either user pressed cancel or entered + // wrong password + const QString fallback = m_serverCommand + QLatin1String(" ") + m_serverArguments + .join(QLatin1String(" ")); + + const QMessageBox::Button res = + MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), + QLatin1String("AuthorizationError"), + QCoreApplication::translate("RemoteClient", "Cannot get authorization."), + QCoreApplication::translate("RemoteClient", "Cannot get authorization that " + "is needed for continuing the installation.\n Either abort the " + "installation or use the fallback solution by running\n\n%1\n\nas a user " + "with the appropriate rights and then clicking OK.").arg(fallback), + QMessageBox::Abort | QMessageBox::Ok, QMessageBox::Ok); + + if (res == QMessageBox::Ok) + started = true; } - // something went wrong with authorizing, either user pressed cancel or entered - // wrong password - const QString fallback = m_serverCommand + QLatin1String(" ") + m_serverArguments - .join(QLatin1String(" ")); - - const QMessageBox::Button res = - MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), - QLatin1String("AuthorizationError"), - QCoreApplication::translate("RemoteClient", "Cannot get authorization."), - QCoreApplication::translate("RemoteClient", "Cannot get authorization that " - "is needed for continuing the installation.\n Either abort the " - "installation or use the fallback solution by running\n\n%1\n\nas a user " - "with the appropriate rights and then clicking OK.").arg(fallback), - QMessageBox::Abort | QMessageBox::Ok, QMessageBox::Ok); - - if (res == QMessageBox::Ok) - started = true; } } else { started = QInstaller::startDetached(m_serverCommand, m_serverArguments, diff --git a/src/libs/installer/scriptengine.cpp b/src/libs/installer/scriptengine.cpp index 59f71a52c..28f91a394 100644 --- a/src/libs/installer/scriptengine.cpp +++ b/src/libs/installer/scriptengine.cpp @@ -401,8 +401,9 @@ QJSValue ScriptEngine::loadInContext(const QString &context, const QString &file if (scriptContext.isError()) { throw Error(tr("Exception while loading the component script \"%1\": %2").arg( QDir::toNativeSeparators(QFileInfo(file).absoluteFilePath()), - scriptContext.toString().isEmpty() ? - tr("Unknown error.") : scriptContext.toString())); + scriptContext.toString().isEmpty() ? tr("Unknown error.") : scriptContext.toString() + + QStringLiteral(" ") + tr("on line number: ") + + scriptContext.property(QStringLiteral("lineNumber")).toString())); } return scriptContext; } |