diff options
Diffstat (limited to 'src/libs')
27 files changed, 642 insertions, 813 deletions
diff --git a/src/libs/installer/abstractfiletask.h b/src/libs/installer/abstractfiletask.h index 858a35f40..1a57dff69 100644 --- a/src/libs/installer/abstractfiletask.h +++ b/src/libs/installer/abstractfiletask.h @@ -48,12 +48,6 @@ #include <QObject> #include <QReadWriteLock> -#if QT_VERSION < 0x050000 -#include <qtconcurrentexception.h> -#define QException QtConcurrent::Exception -#define QUnhandledException QtConcurrent::UnhandledException -#endif - namespace QInstaller { namespace TaskRole { diff --git a/src/libs/installer/binaryformatenginehandler.h b/src/libs/installer/binaryformatenginehandler.h index 107f834f4..155d9a588 100644 --- a/src/libs/installer/binaryformatenginehandler.h +++ b/src/libs/installer/binaryformatenginehandler.h @@ -44,11 +44,7 @@ #include "installer_global.h" -#if QT_VERSION < 0x050000 -# include <QtCore/QAbstractFileEngineHandler> -#else -# include <QtCore/private/qabstractfileengine_p.h> -#endif +#include <QtCore/private/qabstractfileengine_p.h> namespace QInstallerCreator { diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp index 1b37cc12c..a1550b47c 100644 --- a/src/libs/installer/component.cpp +++ b/src/libs/installer/component.cpp @@ -547,13 +547,8 @@ void Component::loadTranslations(const QDir &directory, const QStringList &qms) */ void Component::loadUserInterfaces(const QDir &directory, const QStringList &uis) { -#if QT_VERSION < 0x050000 - if (QApplication::type() == QApplication::Tty) - return; -#else if (qobject_cast<QApplication*> (qApp) == 0) return; -#endif QDirIterator it(directory.path(), uis, QDir::Files); while (it.hasNext()) { @@ -569,11 +564,7 @@ void Component::loadUserInterfaces(const QDir &directory, const QStringList &uis QWidget *const widget = loader.load(&file, 0); if (!widget) { throw Error(tr("Could not load the requested UI file '%1'. Error: %2").arg(it.fileName(), -#if QT_VERSION < 0x050000 - tr("An error has occurred while reading the UI file."))); -#else loader.errorString())); -#endif } d->m_userInterfaces.insert(widget->objectName(), widget); } @@ -1395,6 +1386,11 @@ void Component::updateModelData(const QString &key, const QString &data) if (key == scVirtual) { if (data.toLower() == scTrue) setData(d->m_core->virtualComponentsFont(), Qt::FontRole); + if (Component *const parent = parentComponent()) { + parent->removeComponent(this); + parent->appendComponent(this); + } + emit virtualStateChanged(); } if (key == scRemoteDisplayVersion) diff --git a/src/libs/installer/component.h b/src/libs/installer/component.h index eefe41ebb..3ff814a30 100644 --- a/src/libs/installer/component.h +++ b/src/libs/installer/component.h @@ -224,6 +224,7 @@ public Q_SLOTS: Q_SIGNALS: void loaded(); + void virtualStateChanged(); void selectedChanged(bool selected); void valueChanged(const QString &key, const QString &value); diff --git a/src/libs/installer/component_p.cpp b/src/libs/installer/component_p.cpp index ae4a149a5..7c7ec30d6 100644 --- a/src/libs/installer/component_p.cpp +++ b/src/libs/installer/component_p.cpp @@ -42,16 +42,9 @@ #include "component_p.h" #include "component.h" -#include "messageboxhandler.h" #include "packagemanagercore.h" -#include <QApplication> - -#if QT_VERSION < 0x050000 -# include <QDesktopServices> -#else -# include <QStandardPaths> -#endif +#include <QWidget> namespace QInstaller { diff --git a/src/libs/installer/component_p.h b/src/libs/installer/component_p.h index 821e891d7..98d3cf2f4 100644 --- a/src/libs/installer/component_p.h +++ b/src/libs/installer/component_p.h @@ -44,10 +44,10 @@ #include "qinstallerglobal.h" -#include <QtCore/QPointer> -#include <QtCore/QStringList> -#include <QtCore/QUrl> +#include <QPointer> #include <QScriptValue> +#include <QStringList> +#include <QUrl> namespace QInstaller { diff --git a/src/libs/installer/componentmodel.cpp b/src/libs/installer/componentmodel.cpp index 080e84d85..14be1e259 100644 --- a/src/libs/installer/componentmodel.cpp +++ b/src/libs/installer/componentmodel.cpp @@ -338,6 +338,7 @@ void ComponentModel::setRootComponents(QList<QInstaller::Component*> rootCompone // show virtual components only in case we run as updater or if the core engine is set to show them const bool showVirtuals = m_core->isUpdater() || m_core->virtualComponentsVisible(); foreach (Component *const component, rootComponents) { + connect(component, SIGNAL(virtualStateChanged()), this, SLOT(onVirtualStateChanged())); if ((!showVirtuals) && component->isVirtual()) continue; m_rootComponentList.append(component); @@ -396,6 +397,7 @@ void ComponentModel::slotModelReset() foreach (Component *const component, components) { if (component->checkState() == Qt::Checked) checked.insert(component); + connect(component, SIGNAL(virtualStateChanged()), this, SLOT(onVirtualStateChanged())); } updateCheckedState(checked, Qt::Checked); @@ -409,6 +411,16 @@ void ComponentModel::slotModelReset() updateAndEmitModelState(); // update the internal state } +void ComponentModel::onVirtualStateChanged() +{ + // If the virtual state of a component changes, force a reset of the component model. + // Make sure to pass the right components list depending on the package manager run mode. + if (m_core->isUpdater()) + setRootComponents(m_core->updaterComponents()); + else + setRootComponents(m_core->rootComponents()); +} + // -- private diff --git a/src/libs/installer/componentmodel.h b/src/libs/installer/componentmodel.h index a691906a4..0931e7ebc 100644 --- a/src/libs/installer/componentmodel.h +++ b/src/libs/installer/componentmodel.h @@ -108,6 +108,7 @@ Q_SIGNALS: private Q_SLOTS: void slotModelReset(); + void onVirtualStateChanged(); private: void updateAndEmitModelState(); diff --git a/src/libs/installer/downloadarchivesjob.cpp b/src/libs/installer/downloadarchivesjob.cpp index 7e1196bcf..332c62f2a 100644 --- a/src/libs/installer/downloadarchivesjob.cpp +++ b/src/libs/installer/downloadarchivesjob.cpp @@ -145,14 +145,13 @@ void DownloadArchivesJob::finishedHashDownload() { Q_ASSERT(m_downloader != 0); - const QString tempFile = m_downloader->downloadedFileName(); - QFile sha1HashFile(tempFile); - if (sha1HashFile.open(QFile::ReadOnly)) + QFile sha1HashFile(m_downloader->downloadedFileName()); + if (sha1HashFile.open(QFile::ReadOnly)) { m_currentHash = sha1HashFile.readAll(); - else + fetchNextArchive(); + } else { finishWithError(tr("Downloading hash signature failed.")); - - fetchNextArchive(); + } } /*! @@ -176,7 +175,7 @@ void DownloadArchivesJob::fetchNextArchive() m_downloader = setupDownloader(QString(), m_core->value(QLatin1String("UrlQueryString"))); if (!m_downloader) { m_archivesToDownload.removeFirst(); - QMetaObject::invokeMethod(this, "fetchNextArchive", Qt::QueuedConnection); + QMetaObject::invokeMethod(this, "fetchNextArchiveHash", Qt::QueuedConnection); return; } @@ -232,22 +231,18 @@ void DownloadArchivesJob::registerFile() finishWithError(tr("Could not verify Hash")); return; } + } else { + ++m_archivesDownloaded; + if (m_progressChangedTimerId) { + killTimer(m_progressChangedTimerId); + m_progressChangedTimerId = 0; + emit progressChanged(double(m_archivesDownloaded) / m_archivesToDownloadCount); + } - fetchNextArchiveHash(); - return; - } - - ++m_archivesDownloaded; - if (m_progressChangedTimerId) { - killTimer(m_progressChangedTimerId); - m_progressChangedTimerId = 0; - emit progressChanged(double(m_archivesDownloaded) / m_archivesToDownloadCount); + const QPair<QString, QString> pair = m_archivesToDownload.takeFirst(); + QInstallerCreator::BinaryFormatEngineHandler::instance()->registerArchive(pair.first, + m_downloader->downloadedFileName()); } - - const QPair<QString, QString> pair = m_archivesToDownload.takeFirst(); - QInstallerCreator::BinaryFormatEngineHandler::instance()->registerArchive(pair.first, - m_downloader->downloadedFileName()); - fetchNextArchiveHash(); } diff --git a/src/libs/installer/downloadfiletask.cpp b/src/libs/installer/downloadfiletask.cpp index 1cb64251a..b978bb818 100644 --- a/src/libs/installer/downloadfiletask.cpp +++ b/src/libs/installer/downloadfiletask.cpp @@ -240,7 +240,7 @@ void Downloader::onError(QNetworkReply::NetworkError error) void Downloader::onSslErrors(const QList<QSslError> &sslErrors) { -#if defined(QT_NO_SSL) || defined(QT_NO_OPENSSL) +#ifdef QT_NO_SSL Q_UNUSED(sslErrors); #else foreach (const QSslError &error, sslErrors) @@ -327,8 +327,7 @@ QNetworkReply *Downloader::startDownload(const FileTaskItem &item) connect(reply, SIGNAL(readyRead()), this, SLOT(onReadyRead())); connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onError(QNetworkReply::NetworkError))); -#ifndef QT_NO_OPENSSL - // TODO: once we switch to Qt5, use QT_NO_SSL instead of QT_NO_OPENSSL +#ifndef QT_NO_SSL connect(reply, SIGNAL(sslErrors(QList<QSslError>)), SLOT(onSslErrors(QList<QSslError>))); #endif connect(reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(onDownloadProgress(qint64, diff --git a/src/libs/installer/fsengineclient.h b/src/libs/installer/fsengineclient.h index e74fb5be0..779731af4 100644 --- a/src/libs/installer/fsengineclient.h +++ b/src/libs/installer/fsengineclient.h @@ -45,12 +45,7 @@ #include "installer_global.h" #include <QtNetwork/QHostAddress> - -#if QT_VERSION < 0x050000 -# include <QtCore/QAbstractFileEngineHandler> -#else -# include <QtCore/private/qabstractfileengine_p.h> -#endif +#include <QtCore/private/qabstractfileengine_p.h> QT_BEGIN_NAMESPACE class QTcpSocket; diff --git a/src/libs/installer/fsengineserver.cpp b/src/libs/installer/fsengineserver.cpp index 669ed4248..59a9621d7 100644 --- a/src/libs/installer/fsengineserver.cpp +++ b/src/libs/installer/fsengineserver.cpp @@ -50,11 +50,7 @@ #include <QtNetwork/QTcpSocket> -#if QT_VERSION < 0x050000 -# include <QtCore/QFSFileEngine> -#else -# include <QtCore/private/qfsfileengine_p.h> -#endif +#include <QtCore/private/qfsfileengine_p.h> typedef int descriptor_t; diff --git a/src/libs/installer/getrepositorymetainfojob.cpp b/src/libs/installer/getrepositorymetainfojob.cpp deleted file mode 100644 index 8b6b53484..000000000 --- a/src/libs/installer/getrepositorymetainfojob.cpp +++ /dev/null @@ -1,548 +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 "getrepositorymetainfojob.h" - -#include "errors.h" -#include "lib7z_facade.h" -#include "messageboxhandler.h" -#include "packagemanagercore_p.h" -#include "utils.h" - -#include "kdupdaterfiledownloader.h" -#include "kdupdaterfiledownloaderfactory.h" - -#include "productkeycheck.h" - -#include <QTimer> - -using namespace KDUpdater; -using namespace QInstaller; - - -// -- GetRepositoryMetaInfoJob::ZipRunnable - -class GetRepositoryMetaInfoJob::ZipRunnable : public QObject, public QRunnable -{ - Q_OBJECT - -public: - ZipRunnable(const QString &archive, const QString &targetDir) - : QObject() - , QRunnable() - , m_archive(archive) - , m_targetDir(targetDir) - {} - - void run() - { - QFile archive(m_archive); - if (archive.open(QIODevice::ReadOnly)) { - try { - Lib7z::extractArchive(&archive, m_targetDir); - if (!archive.remove()) { - qWarning("Could not delete file %s: %s", qPrintable(m_archive), - qPrintable(archive.errorString())); - } - emit finished(true, QString()); - } catch (const Lib7z::SevenZipException& e) { - emit finished(false, tr("Error while extracting '%1': %2").arg(m_archive, e.message())); - } catch (...) { - emit finished(false, tr("Unknown exception caught while extracting %1.").arg(m_archive)); - } - } else { - emit finished(false, tr("Could not open %1 for reading. Error: %2").arg(m_archive, - archive.errorString())); - } - } - -Q_SIGNALS: - void finished(bool success, const QString &errorString); - -private: - const QString m_archive; - const QString m_targetDir; -}; - - -// -- GetRepositoryMetaInfoJob - -GetRepositoryMetaInfoJob::GetRepositoryMetaInfoJob(PackageManagerCore *core, QObject *parent) - : KDJob(parent) - , m_canceled(false) - , m_silentRetries(4) - , m_retriesLeft(m_silentRetries) - , m_downloader(0) - , m_core(core) - , m_watcher(0) -{ - setTotalAmount(100); - setCapabilities(Cancelable); -} - -GetRepositoryMetaInfoJob::~GetRepositoryMetaInfoJob() -{ - if (m_downloader) - m_downloader->deleteLater(); -} - -Repository GetRepositoryMetaInfoJob::repository() const -{ - return m_repository; -} - -void GetRepositoryMetaInfoJob::setRepository(const Repository &r) -{ - m_repository = r; - qDebug() << "Setting repository with URL:" << r.displayname(); -} - -int GetRepositoryMetaInfoJob::silentRetries() const -{ - return m_silentRetries; -} - -void GetRepositoryMetaInfoJob::setSilentRetries(int retries) -{ - m_silentRetries = retries; -} - -void GetRepositoryMetaInfoJob::doStart() -{ - m_canceled = false; - setProcessedAmount(0); - m_packageHash.clear(); - m_packageNames.clear(); - m_packageVersions.clear(); - m_retriesLeft = m_silentRetries; - - startUpdatesXmlDownload(); -} - -void GetRepositoryMetaInfoJob::doCancel() -{ - m_canceled = true; - if (m_downloader) - m_downloader->cancelDownload(); - if (m_watcher) - m_watcher->cancel(); -#if QT_VERSION >= 0x050200 - m_threadPool.clear(); -#endif - m_threadPool.waitForDone(); -} - -void GetRepositoryMetaInfoJob::finished(int error, const QString &errorString) -{ - m_threadPool.waitForDone(); - (error > KDJob::NoError) ? emitFinishedWithError(error, errorString) : emitFinished(); -} - -QString GetRepositoryMetaInfoJob::temporaryDirectory() const -{ - return m_temporaryDirectory; -} - -QString GetRepositoryMetaInfoJob::releaseTemporaryDirectory() const -{ - m_tempDirDeleter.releaseAll(); - return m_temporaryDirectory; -} - -// Updates.xml download - -void GetRepositoryMetaInfoJob::startUpdatesXmlDownload() -{ - if (m_downloader) { - m_downloader->deleteLater(); - m_downloader = 0; - } - - const QUrl url = m_repository.url(); - if (url.isEmpty()) { - finished(QInstaller::InvalidUrl, tr("Empty repository URL.")); - return; - } - - if (!url.isValid()) { - finished(QInstaller::InvalidUrl, tr("Invalid repository URL: %1").arg(m_repository.displayname())); - return; - } - - m_downloader = FileDownloaderFactory::instance().create(url.scheme(), this); - if (!m_downloader) { - finished(QInstaller::InvalidUrl, tr("URL scheme not supported: %1 (%2)").arg(url.scheme(), - m_repository.displayname())); - return; - } - - QString updatesFileName = QString::fromLatin1("Updates.xml"); - if (m_retriesLeft == m_silentRetries) - updatesFileName = QString::fromLatin1("Updates_%1.xml").arg(QLocale().name().toLower()); - - // append a random string to avoid proxy caches - m_downloader->setUrl(QUrl(url.toString() + QString::fromLatin1("/%1?").arg(updatesFileName) - .append(QString::number(qrand() * qrand())))); - - QAuthenticator auth; - auth.setUser(m_repository.username()); - auth.setPassword(m_repository.password()); - m_downloader->setAuthenticator(auth); - - m_downloader->setAutoRemoveDownloadedFile(false); - connect(m_downloader, SIGNAL(downloadCompleted()), this, SLOT(updatesXmlDownloadFinished())); - connect(m_downloader, SIGNAL(downloadCanceled()), this, SLOT(updatesXmlDownloadCanceled())); - connect(m_downloader, SIGNAL(downloadAborted(QString)), this, - SLOT(updatesXmlDownloadError(QString)), Qt::QueuedConnection); - connect(m_downloader, SIGNAL(authenticatorChanged(QAuthenticator)), this, - SLOT(onAuthenticatorChanged(QAuthenticator))); - m_downloader->download(); -} - -void GetRepositoryMetaInfoJob::updatesXmlDownloadCanceled() -{ - finished(KDJob::Canceled, m_downloader->errorString()); -} - -void GetRepositoryMetaInfoJob::updatesXmlDownloadFinished() -{ - emit infoMessage(this, tr("Retrieving component meta information...")); - - const QString fn = m_downloader->downloadedFileName(); - Q_ASSERT(!fn.isEmpty()); - Q_ASSERT(QFile::exists(fn)); - - QFile updatesFile(fn); - - if (!updatesFile.open(QIODevice::ReadOnly)) { - finished(QInstaller::DownloadError, tr("Could not open Updates.xml for reading. Error: %1") - .arg(updatesFile.errorString())); - return; - } - - QString err; - QDomDocument doc; - const bool success = doc.setContent(&updatesFile, &err); - updatesFile.close(); - - if (!success) { - const QString msg = tr("Could not fetch a valid version of Updates.xml from repository: %1. " - "Error: %2").arg(m_repository.displayname(), err); - - const QMessageBox::StandardButton b = - MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), - QLatin1String("updatesXmlDownloadError"), tr("Download Error"), msg, QMessageBox::Cancel); - - if (b == QMessageBox::Cancel || b == QMessageBox::NoButton) { - finished(KDJob::Canceled, msg); - return; - } - } - - emit infoMessage(this, tr("Parsing component meta information...")); - - const QDomElement root = doc.documentElement(); - // search for additional repositories that we might need to check - const QDomNode repositoryUpdate = root.firstChildElement(QLatin1String("RepositoryUpdate")); - if (!repositoryUpdate.isNull()) { - QHash<QString, QPair<Repository, Repository> > repositoryUpdates; - const QDomNodeList children = repositoryUpdate.toElement().childNodes(); - for (int i = 0; i < children.count(); ++i) { - const QDomElement el = children.at(i).toElement(); - if (!el.isNull() && el.tagName() == QLatin1String("Repository")) { - const QString action = el.attribute(QLatin1String("action")); - if (action == QLatin1String("add")) { - // add a new repository to the defaults list - Repository repository(el.attribute(QLatin1String("url")), true); - repository.setUsername(el.attribute(QLatin1String("username"))); - repository.setPassword(el.attribute(QLatin1String("password"))); - repository.setDisplayName(el.attribute(QLatin1String("displayname"))); - if (ProductKeyCheck::instance()->isValidRepository(repository)) { - repositoryUpdates.insertMulti(action, qMakePair(repository, Repository())); - qDebug() << "Repository to add:" << repository.displayname(); - } - } else if (action == QLatin1String("remove")) { - // remove possible default repositories using the given server url - Repository repository(el.attribute(QLatin1String("url")), true); - repositoryUpdates.insertMulti(action, qMakePair(repository, Repository())); - - qDebug() << "Repository to remove:" << repository.displayname(); - } else if (action == QLatin1String("replace")) { - // replace possible default repositories using the given server url - Repository oldRepository(el.attribute(QLatin1String("oldUrl")), true); - Repository newRepository(el.attribute(QLatin1String("newUrl")), true); - newRepository.setUsername(el.attribute(QLatin1String("username"))); - newRepository.setPassword(el.attribute(QLatin1String("password"))); - newRepository.setDisplayName(el.attribute(QLatin1String("displayname"))); - - if (ProductKeyCheck::instance()->isValidRepository(newRepository)) { - // store the new repository and the one old it replaces - repositoryUpdates.insertMulti(action, qMakePair(newRepository, oldRepository)); - qDebug() << "Replace repository:" << oldRepository.displayname() << "with:" - << newRepository.displayname(); - } - } else { - qDebug() << "Invalid additional repositories action set in Updates.xml fetched from:" - << m_repository.displayname() << "Line:" << el.lineNumber(); - } - } - } - - if (!repositoryUpdates.isEmpty()) { - const QSet<Repository> temporaries = m_core->settings().temporaryRepositories(); - // in case the temp repository introduced something new, we only want that temporary - if (temporaries.contains(m_repository)) { - - QSet<Repository> childTempRepositories; - typedef QPair<Repository, Repository> RepositoryPair; - - QList<RepositoryPair> values = repositoryUpdates.values(QLatin1String("add")); - foreach (const RepositoryPair &value, values) - childTempRepositories.insert(value.first); - - values = repositoryUpdates.values(QLatin1String("replace")); - foreach (const RepositoryPair &value, values) - childTempRepositories.insert(value.first); - - QSet<Repository> newChildTempRepositories = childTempRepositories.subtract(temporaries); - if (newChildTempRepositories.count() > 0) { - m_core->settings().addTemporaryRepositories(newChildTempRepositories, true); - finished(QInstaller::RepositoryUpdatesReceived, tr("Repository updates received.")); - return; - } - } else if (m_core->settings().updateDefaultRepositories(repositoryUpdates) == Settings::UpdatesApplied) { - if (m_core->isUpdater() || m_core->isPackageManager()) - m_core->writeMaintenanceConfigFiles(); - finished(QInstaller::RepositoryUpdatesReceived, tr("Repository updates received.")); - return; - } - } - } - - const QDomNodeList children = root.childNodes(); - for (int i = 0; i < children.count(); ++i) { - const QDomElement el = children.at(i).toElement(); - if (el.isNull()) - continue; - if (el.tagName() == QLatin1String("PackageUpdate")) { - const QDomNodeList c2 = el.childNodes(); - for (int j = 0; j < c2.count(); ++j) { - if (c2.at(j).toElement().tagName() == scName) - m_packageNames << c2.at(j).toElement().text(); - else if (c2.at(j).toElement().tagName() == scRemoteVersion) - m_packageVersions << c2.at(j).toElement().text(); - else if (c2.at(j).toElement().tagName() == QLatin1String("SHA1")) - m_packageHash << c2.at(j).toElement().text(); - } - } - } - - try { - m_temporaryDirectory = createTemporaryDirectory(QLatin1String("remoterepo-")); - m_tempDirDeleter.add(m_temporaryDirectory); - } catch (const QInstaller::Error& e) { - finished(QInstaller::ExtractionError, e.message()); - return; - } - if (!updatesFile.rename(m_temporaryDirectory + QLatin1String("/Updates.xml"))) { - finished(QInstaller::DownloadError, tr("Could not move Updates.xml to target location. Error: %1") - .arg(updatesFile.errorString())); - return; - } - - setProcessedAmount(1); - emit infoMessage(this, tr("Finished updating component meta information.")); - - if (m_packageNames.isEmpty()) { - finished(KDJob::NoError); - setProcessedAmount(100); - } else { - downloadMetaInfo(); - } -} - -void GetRepositoryMetaInfoJob::updatesXmlDownloadError(const QString &err) -{ - if (m_retriesLeft <= 0) { - const QString msg = tr("Could not fetch Updates.xml from repository: %1. Error: %2") - .arg(m_repository.displayname(), err); - - QMessageBox::StandardButtons buttons = QMessageBox::Retry | QMessageBox::Cancel; - const QMessageBox::StandardButton b = - MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), - QLatin1String("updatesXmlDownloadError"), tr("Download Error"), msg, buttons); - - if (b == QMessageBox::Cancel || b == QMessageBox::NoButton) { - finished(KDJob::Canceled, msg); - return; - } - } - - m_retriesLeft--; - QTimer::singleShot(1500, this, SLOT(startUpdatesXmlDownload())); -} - -// meta data download - -void GetRepositoryMetaInfoJob::downloadMetaInfo() -{ - emit infoMessage(this, tr("Retrieving component information from remote repository...")); - if (m_canceled) { - finished(KDJob::Canceled, tr("Meta data download canceled.")); - return; - } - - if (m_packageNames.isEmpty()) { - finished(KDJob::NoError); - return; - } - - bool online = true; - if (m_repository.url().scheme().isEmpty()) - online = false; - - QList<FileTaskItem> items; - const QString repoUrl = m_repository.url().toString(); - for (int i = 0; i < m_packageNames.count(); ++i) { - items.append(FileTaskItem(QString::fromLatin1("%1/%2/%3meta.7z").arg(repoUrl, - m_packageNames.at(i), (online ? m_packageVersions.at(i) : QString())))); - items[i].insert(TaskRole::Checksum, m_packageHash.value(i).toLatin1()); - } - - QAuthenticator auth; - auth.setUser(m_repository.username()); - auth.setPassword(m_repository.password()); - - m_metaDataTask.setTaskItems(items); - m_metaDataTask.setAuthenticator(auth); - m_metaDataTask.setProxyFactory(m_core->proxyFactory()->clone()); - - m_watcher = new QFutureWatcher<FileTaskResult>(this); - connect(m_watcher, SIGNAL(finished()), this, SLOT(metaInfoDownloadFinished())); - connect(m_watcher, SIGNAL(progressValueChanged(int)), this, SLOT(onProgressValueChanged(int))); - m_watcher->setFuture(QtConcurrent::run(&DownloadFileTask::doTask, &m_metaDataTask)); -} - -void GetRepositoryMetaInfoJob::metaInfoDownloadFinished() -{ - QFutureWatcher<FileTaskResult> *task = static_cast<QFutureWatcher<FileTaskResult> *>(sender()); - try { - task->waitForFinished(); - QFuture<FileTaskResult> future = task->future(); - if (future.resultCount() > 0) { - foreach (const FileTaskResult &result, future.results()) { - ZipRunnable *runnable = new ZipRunnable(result.target(), m_temporaryDirectory); - connect(runnable, SIGNAL(finished(bool, QString)), this, SLOT(unzipFinished(bool, - QString))); - m_threadPool.start(runnable); - } - } - finished(KDJob::NoError); - } catch (FileTaskException &e) { - doCancel(); - finished(KDJob::Canceled, e.message()); - } catch (QUnhandledException &e) { - doCancel(); - finished(KDJob::Canceled, QLatin1String(e.what())); - } catch (...) { - doCancel(); - finished(KDJob::Canceled, tr("Unknown exception.")); - } -} - -void GetRepositoryMetaInfoJob::onProgressValueChanged(int progress) -{ - setProcessedAmount(progress + 1); -} - -void GetRepositoryMetaInfoJob::unzipFinished(bool ok, const QString &error) -{ - if (!ok) { - doCancel(); - finished(QInstaller::ExtractionError, error); - } -} - -bool GetRepositoryMetaInfoJob::updateRepositories(QSet<Repository> *repositories, const QString &username, - const QString &password, const QString &displayname) -{ - if (!repositories->contains(m_repository)) - return false; - - repositories->remove(m_repository); - m_repository.setUsername(username); - m_repository.setPassword(password); - m_repository.setDisplayName(displayname); - repositories->insert(m_repository); - return true; -} - -void GetRepositoryMetaInfoJob::onAuthenticatorChanged(const QAuthenticator &authenticator) -{ - const QString username = authenticator.user(); - const QString password = authenticator.password(); - if (username != m_repository.username() || password != m_repository.password()) { - QSet<Repository> repositories = m_core->settings().defaultRepositories(); - bool reposChanged = updateRepositories(&repositories, username, password); - if (reposChanged) - m_core->settings().setDefaultRepositories(repositories); - - repositories = m_core->settings().temporaryRepositories(); - reposChanged |= updateRepositories(&repositories, username, password); - if (reposChanged) { - m_core->settings().setTemporaryRepositories(repositories, - m_core->settings().hasReplacementRepos()); - } - - repositories = m_core->settings().userRepositories(); - reposChanged |= updateRepositories(&repositories, username, password); - if (reposChanged) - m_core->settings().setUserRepositories(repositories); - - if (reposChanged) { - if (m_core->isUpdater() || m_core->isPackageManager()) - m_core->writeMaintenanceConfigFiles(); - finished(QInstaller::RepositoryUpdatesReceived, tr("Repository updates received.")); - } - } -} - -#include "getrepositorymetainfojob.moc" -#include "moc_getrepositorymetainfojob.cpp" diff --git a/src/libs/installer/init.cpp b/src/libs/installer/init.cpp index eedae80bd..f55b22b94 100644 --- a/src/libs/installer/init.cpp +++ b/src/libs/installer/init.cpp @@ -140,13 +140,6 @@ 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 @@ -181,11 +174,6 @@ static QByteArray trimAndPrepend(QtMsgType type, const QByteArray &msg) return ba; } -#if QT_VERSION < 0x050000 -static void messageHandler(QtMsgType type, const char *msg) -{ - const QByteArray ba = trimAndPrepend(type, msg); -#else void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) { // suppress warning from QPA minimal plugin @@ -197,22 +185,15 @@ void messageHandler(QtMsgType type, const QMessageLogContext &context, const QSt QString::fromLatin1(context.file)).arg(context.line).arg( QString::fromLatin1(context.function)).toLocal8Bit(); } -#endif verbose() << ba.constData() << std::endl; if (!isVerbose() && type != QtDebugMsg) std::cout << ba.constData() << std::endl << std::endl; if (type == QtFatalMsg) { -#if QT_VERSION < 0x050000 - QtMsgHandler oldMsgHandler = qInstallMsgHandler(0); - qt_message_output(type, msg); - qInstallMsgHandler(oldMsgHandler); -#else QtMessageHandler oldMsgHandler = qInstallMessageHandler(0); qt_message_output(type, context, msg); qInstallMessageHandler(oldMsgHandler); -#endif } } @@ -256,11 +237,5 @@ void QInstaller::init() #ifdef Q_OS_MAC factory.registerUpdateOperation<MacReplaceInstallNamesOperation>(QLatin1String("ReplaceInstallNames")); #endif // Q_OS_MAC - - // qDebug -> verbose() -#if QT_VERSION < 0x050000 - qInstallMsgHandler(messageHandler); -#else qInstallMessageHandler(messageHandler); -#endif } diff --git a/src/libs/installer/installer.pro b/src/libs/installer/installer.pro index 54ff619d6..3d1f5a9e7 100644 --- a/src/libs/installer/installer.pro +++ b/src/libs/installer/installer.pro @@ -31,11 +31,10 @@ DEFINES += BUILD_LIB_INSTALLER QT += \ script \ network \ - xml - -isEqual(QT_MAJOR_VERSION, 5) { - QT += concurrent widgets core-private -} + xml \ + concurrent \ + widgets \ + core-private HEADERS += packagemanagercore.h \ packagemanagercore_p.h \ diff --git a/src/libs/installer/messageboxhandler.cpp b/src/libs/installer/messageboxhandler.cpp index 69fc62570..09aa43c1d 100644 --- a/src/libs/installer/messageboxhandler.cpp +++ b/src/libs/installer/messageboxhandler.cpp @@ -151,13 +151,8 @@ MessageBoxHandler *MessageBoxHandler::instance() QWidget *MessageBoxHandler::currentBestSuitParent() { -#if QT_VERSION < 0x050000 - if (QApplication::type() == QApplication::Tty) - return 0; -#else if (qobject_cast<QApplication*> (qApp) == 0) return 0; -#endif if (qApp->activeModalWidget()) return qApp->activeModalWidget(); @@ -319,13 +314,8 @@ QMessageBox::StandardButton MessageBoxHandler::showMessageBox(MessageType messag qDebug() << QString::fromLatin1("created %1 message box %2: '%3', %4").arg(messageTypeHash .value(messageType),identifier, title, text); -#if QT_VERSION < 0x050000 - if (QApplication::type() == QApplication::Tty) - return defaultButton; -#else if (qobject_cast<QApplication*> (qApp) == 0) return defaultButton; -#endif if (m_automaticAnswers.contains(identifier)) return m_automaticAnswers.value(identifier); diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index 61ce92467..139296bdb 100644 --- a/src/libs/installer/packagemanagercore.cpp +++ b/src/libs/installer/packagemanagercore.cpp @@ -77,9 +77,7 @@ # include "qt_windows.h" #endif -#if QT_VERSION >= 0x050000 -# include <QStandardPaths> -#endif +#include <QStandardPaths> /*! \qmltype QInstaller diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index c73a7fc82..8fcee1a7f 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -1499,6 +1499,7 @@ bool PackageManagerCorePrivate::runInstaller() ProgressCoordinator::instance()->addManualPercentagePoints(1); ProgressCoordinator::instance()->emitLabelAndDetailTextChanged(tr("Preparing the installation...")); + m_core->calculateComponentsToInstall(); const QList<Component*> componentsToInstall = m_core->orderedComponentsToInstall(); qDebug() << "Install size:" << componentsToInstall.size() << "components"; @@ -1510,7 +1511,7 @@ bool PackageManagerCorePrivate::runInstaller() } if (!adminRightsGained) { - foreach (Component *component, m_core->orderedComponentsToInstall()) { + foreach (Component *component, componentsToInstall) { if (component->value(scRequiresAdminRights, scFalse) == scFalse) continue; diff --git a/src/libs/installer/packagemanagercoredata.cpp b/src/libs/installer/packagemanagercoredata.cpp index 16fc6dc00..a0eafdf79 100644 --- a/src/libs/installer/packagemanagercoredata.cpp +++ b/src/libs/installer/packagemanagercoredata.cpp @@ -43,6 +43,7 @@ #include "errors.h" #include "fileutils.h" #include "qsettingswrapper.h" +#include "utils.h" #include <QDesktopServices> #include <QDir> @@ -66,6 +67,8 @@ PackageManagerCoreData::PackageManagerCoreData(const QHash<QString, QString> &va m_variables.insert(QLatin1String("RootDir"), QDir::rootPath()); m_variables.insert(QLatin1String("HomeDir"), QDir::homePath()); m_variables.insert(scTargetConfigurationFile, QLatin1String("components.xml")); + m_variables.insert(QLatin1String("InstallerDirPath"), QCoreApplication::applicationDirPath()); + m_variables.insert(QLatin1String("InstallerFilePath"), QCoreApplication::applicationFilePath()); QString dir = QLatin1String("/opt"); #ifdef Q_OS_WIN @@ -73,11 +76,7 @@ PackageManagerCoreData::PackageManagerCoreData(const QHash<QString, QString> &va 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); @@ -93,6 +92,26 @@ PackageManagerCoreData::PackageManagerCoreData(const QHash<QString, QString> &va // TODO: add more platforms as needed... #endif +#ifdef Q_OS_WIN + QSettingsWrapper user(QLatin1String("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\" + "CurrentVersion\\Explorer\\User Shell Folders"), QSettingsWrapper::NativeFormat); + QSettingsWrapper system(QLatin1String("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\" + "CurrentVersion\\Explorer\\Shell Folders"), QSettingsWrapper::NativeFormat); + + const QString programs = user.value(QLatin1String("Programs"), QString()).toString(); + const QString allPrograms = system.value(QLatin1String("Common Programs"), QString()).toString(); + + QString desktop; + if (m_variables.value(QLatin1String("AllUsers")) == scTrue) { + desktop = system.value(QLatin1String("Desktop")).toString(); + } else { + desktop = user.value(QLatin1String("Desktop")).toString(); + } + m_variables.insert(QLatin1String("DesktopDir"), replaceWindowsEnvironmentVariables(desktop)); + m_variables.insert(QLatin1String("UserStartMenuProgramsPath"), replaceWindowsEnvironmentVariables(programs)); + m_variables.insert(QLatin1String("AllUsersStartMenuProgramsPath"), replaceWindowsEnvironmentVariables(allPrograms)); +#endif + try { m_settings = Settings::fromFileAndPrefix(QLatin1String(":/metadata/installer-config/config.xml"), QLatin1String(":/metadata/installer-config/"), Settings::RelaxedParseMode); diff --git a/src/libs/installer/packagemanagergui.cpp b/src/libs/installer/packagemanagergui.cpp index 3bec356ab..d5599791a 100644 --- a/src/libs/installer/packagemanagergui.cpp +++ b/src/libs/installer/packagemanagergui.cpp @@ -51,13 +51,13 @@ #include "settings.h" #include "utils.h" #include "scriptengine.h" +#include "productkeycheck.h" #include "kdsysinfo.h" #include <QtCore/QDir> #include <QtCore/QPair> #include <QtCore/QProcess> -#include <QtCore/QSettings> #include <QtCore/QTimer> #include <QCheckBox> @@ -71,6 +71,7 @@ #include <QListWidget> #include <QListWidgetItem> #include <QMessageBox> +#include <QProgressBar> #include <QPushButton> #include <QRadioButton> #include <QTextBrowser> @@ -78,6 +79,10 @@ #include <QVBoxLayout> #include <QShowEvent> +#ifdef Q_OS_WIN +# include <qt_windows.h> +#endif + using namespace KDUpdater; using namespace QInstaller; @@ -117,6 +122,8 @@ TRANSLATOR QInstaller::FinishedPage class DynamicInstallerPage : public PackageManagerPage { + Q_OBJECT + public: explicit DynamicInstallerPage(QWidget *widget, PackageManagerCore *core = 0) : PackageManagerPage(core) @@ -125,13 +132,17 @@ public: setObjectName(QLatin1String("Dynamic") + widget->objectName()); setPixmap(QWizard::WatermarkPixmap, QPixmap()); - setLayout(new QVBoxLayout); setColoredSubTitle(QLatin1String(" ")); setColoredTitle(widget->windowTitle()); m_widget->setProperty("complete", true); m_widget->setProperty("final", false); + m_widget->setProperty("commit", false); widget->installEventFilter(this); + + setLayout(new QVBoxLayout); layout()->addWidget(widget); + layout()->setContentsMargins(0, 0, 0, 0); + layout()->addItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding)); } QWidget *widget() const @@ -157,6 +168,8 @@ protected: emit completeChanged(); if (m_widget->property("final").toBool() != isFinalPage()) setFinalPage(m_widget->property("final").toBool()); + if (m_widget->property("commit").toBool() != isCommitPage()) + setFinalPage(m_widget->property("commit").toBool()); break; default: @@ -450,6 +463,7 @@ void PackageManagerGui::showEvent(QShowEvent *event) } } } + setMinimumSize(size()); } QWizard::showEvent(event); QMetaObject::invokeMethod(this, "dependsOnLocalInstallerBinary", Qt::QueuedConnection); @@ -506,25 +520,20 @@ void PackageManagerGui::wizardPageVisibilityChangeRequested(bool visible, int p) } } -PackageManagerPage *PackageManagerGui::page(int pageId) const +QWidget *PackageManagerGui::pageById(int id) const { - return qobject_cast<PackageManagerPage*> (QWizard::page(pageId)); + return page(id); } -QWidget *PackageManagerGui::pageWidgetByObjectName(const QString &name) const +QWidget *PackageManagerGui::pageByObjectName(const QString &name) const { const QList<int> ids = pageIds(); foreach (const int i, ids) { PackageManagerPage *const p = qobject_cast<PackageManagerPage*> (page(i)); - if (p && p->objectName() == name) { - // For dynamic pages, return the contained widget (as read from the UI file), not the - // wrapper page - if (DynamicInstallerPage *dp = dynamic_cast<DynamicInstallerPage*>(p)) - return dp->widget(); + if (p && p->objectName() == name) return p; - } } - qDebug() << "No page found for object name" << name; + qWarning() << "No page found for object name" << name; return 0; } @@ -533,6 +542,20 @@ QWidget *PackageManagerGui::currentPageWidget() const return currentPage(); } +QWidget *PackageManagerGui::pageWidgetByObjectName(const QString &name) const +{ + QWidget *const widget = pageByObjectName(name); + if (PackageManagerPage *const p = qobject_cast<PackageManagerPage*> (widget)) { + // For dynamic pages, return the contained widget (as read from the UI file), not the + // wrapper page + if (DynamicInstallerPage *dp = qobject_cast<DynamicInstallerPage *>(p)) + return dp->widget(); + return p; + } + qWarning() << "No page found for object name" << name; + return 0; +} + void PackageManagerGui::cancelButtonClicked() { const int id = currentId(); @@ -825,31 +848,322 @@ int PackageManagerPage::nextId() const IntroductionPage::IntroductionPage(PackageManagerCore *core) : PackageManagerPage(core) - , m_widget(0) + , m_updatesFetched(false) + , m_allPackagesFetched(false) + , m_label(0) + , m_msgLabel(0) + , m_errorLabel(0) + , m_progressBar(0) + , m_packageManager(0) + , m_updateComponents(0) + , m_removeAllComponents(0) { setObjectName(QLatin1String("IntroductionPage")); setColoredTitle(tr("Setup - %1").arg(productName())); + QVBoxLayout *layout = new QVBoxLayout(this); + setLayout(layout); + m_msgLabel = new QLabel(this); m_msgLabel->setWordWrap(true); m_msgLabel->setObjectName(QLatin1String("MessageLabel")); m_msgLabel->setText(tr("Welcome to the %1 Setup Wizard.").arg(productName())); - QVBoxLayout *layout = new QVBoxLayout(this); - setLayout(layout); + QWidget *widget = new QWidget(this); + QVBoxLayout *boxLayout = new QVBoxLayout(widget); + + m_packageManager = new QRadioButton(tr("Package manager"), this); + m_packageManager->setObjectName(QLatin1String("PackageManagerRadioButton")); + boxLayout->addWidget(m_packageManager); + m_packageManager->setChecked(core->isPackageManager()); + connect(m_packageManager, SIGNAL(toggled(bool)), this, SLOT(setPackageManager(bool))); + + m_updateComponents = new QRadioButton(tr("Update components"), this); + m_updateComponents->setObjectName(QLatin1String("UpdaterRadioButton")); + boxLayout->addWidget(m_updateComponents); + m_updateComponents->setChecked(core->isUpdater()); + connect(m_updateComponents, SIGNAL(toggled(bool)), this, SLOT(setUpdater(bool))); + + m_removeAllComponents = new QRadioButton(tr("Remove all components"), this); + m_removeAllComponents->setObjectName(QLatin1String("UninstallerRadioButton")); + boxLayout->addWidget(m_removeAllComponents); + m_removeAllComponents->setChecked(core->isUninstaller()); + connect(m_removeAllComponents, SIGNAL(toggled(bool)), this, SLOT(setUninstaller(bool))); + connect(m_removeAllComponents, SIGNAL(toggled(bool)), core, SLOT(setCompleteUninstallation(bool))); + + boxLayout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding)); + + m_label = new QLabel(this); + m_label->setWordWrap(true); + m_label->setText(tr("Retrieving information from remote installation sources...")); + boxLayout->addWidget(m_label); + + m_progressBar = new QProgressBar(this); + m_progressBar->setRange(0, 0); + boxLayout->addWidget(m_progressBar); + + boxLayout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding)); + + m_errorLabel = new QLabel(this); + m_errorLabel->setWordWrap(true); + boxLayout->addWidget(m_errorLabel); + layout->addWidget(m_msgLabel); + layout->addWidget(widget); layout->addItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding)); + + core->setCompleteUninstallation(core->isUninstaller()); + + connect(core, SIGNAL(metaJobProgress(int)), this, SLOT(onProgressChanged(int))); + connect(core, SIGNAL(metaJobInfoMessage(QString)), this, SLOT(setMessage(QString))); + connect(core, SIGNAL(coreNetworkSettingsChanged()), this, SLOT(onCoreNetworkSettingsChanged())); + + m_updateComponents->setEnabled(ProductKeyCheck::instance()->hasValidKey()); } -void IntroductionPage::setWidget(QWidget *widget) +int IntroductionPage::nextId() const { - if (m_widget) { - layout()->removeWidget(m_widget); - delete m_widget; + if (packageManagerCore()->isUninstaller()) + return PackageManagerCore::ReadyForInstallation; + + if (packageManagerCore()->isUpdater() || packageManagerCore()->isPackageManager()) + return PackageManagerCore::ComponentSelection; + + return PackageManagerPage::nextId(); +} + +bool IntroductionPage::validatePage() +{ + PackageManagerCore *core = packageManagerCore(); + if (core->isUninstaller()) + return true; + + setComplete(false); + if (!validRepositoriesAvailable()) { + setErrorMessage(QLatin1String("<font color=\"red\">") + tr("At least one valid and enabled " + "repository required for this action to succeed.") + QLatin1String("</font>")); + return isComplete(); + } + + gui()->setSettingsButtonEnabled(false); + const bool maintanence = core->isUpdater() || core->isPackageManager(); + if (maintanence) { + showAll(); + setMaintenanceToolsEnabled(false); + } else { + showMetaInfoUdate(); + } + + // fetch updater packages + if (core->isUpdater()) { + if (!m_updatesFetched) { + m_updatesFetched = core->fetchRemotePackagesTree(); + if (!m_updatesFetched) + setErrorMessage(core->error()); + } + + callControlScript(QLatin1String("UpdaterSelectedCallback")); + + if (m_updatesFetched) { + if (core->updaterComponents().count() <= 0) + setErrorMessage(QLatin1String("<b>") + tr("No updates available.") + QLatin1String("</b>")); + else + setComplete(true); + } } - m_widget = widget; - if (m_widget) - static_cast<QVBoxLayout*>(layout())->addWidget(m_widget, 1); + + // fetch common packages + if (core->isInstaller() || core->isPackageManager()) { + bool localPackagesTreeFetched = false; + if (!m_allPackagesFetched) { + // first try to fetch the server side packages tree + m_allPackagesFetched = core->fetchRemotePackagesTree(); + if (!m_allPackagesFetched) { + QString error = core->error(); + if (core->isPackageManager() && core->status() != PackageManagerCore::ForceUpdate) { + // if that fails and we're in maintenance mode, try to fetch local installed tree + localPackagesTreeFetched = core->fetchLocalPackagesTree(); + if (localPackagesTreeFetched) { + // if that succeeded, adjust error message + error = QLatin1String("<font color=\"red\">") + error + tr(" Only local package " + "management available.") + QLatin1String("</font>"); + } + } + setErrorMessage(error); + } + } + + callControlScript(QLatin1String("PackageManagerSelectedCallback")); + + if (m_allPackagesFetched | localPackagesTreeFetched) + setComplete(true); + } + + if (maintanence) { + showMaintenanceTools(); + setMaintenanceToolsEnabled(true); + } else { + hideAll(); + } + gui()->setSettingsButtonEnabled(true); + + return isComplete(); +} + +void IntroductionPage::showAll() +{ + showWidgets(true); +} + +void IntroductionPage::hideAll() +{ + showWidgets(false); +} + +void IntroductionPage::showMetaInfoUdate() +{ + showWidgets(false); + m_label->setVisible(true); + m_progressBar->setVisible(true); +} + +void IntroductionPage::showMaintenanceTools() +{ + showWidgets(true); + m_label->setVisible(false); + m_progressBar->setVisible(false); +} + +void IntroductionPage::setMaintenanceToolsEnabled(bool enable) +{ + m_packageManager->setEnabled(enable); + m_updateComponents->setEnabled(enable && ProductKeyCheck::instance()->hasValidKey()); + m_removeAllComponents->setEnabled(enable); +} + +// -- public slots + +void IntroductionPage::setMessage(const QString &msg) +{ + m_label->setText(msg); +} + +void IntroductionPage::onProgressChanged(int progress) +{ + m_progressBar->setRange(0, 100); + m_progressBar->setValue(progress); +} + +void IntroductionPage::setErrorMessage(const QString &error) +{ + QPalette palette; + const PackageManagerCore::Status s = packageManagerCore()->status(); + if (s == PackageManagerCore::Failure || s == PackageManagerCore::Failure) { + palette.setColor(QPalette::WindowText, Qt::red); + } else { + palette.setColor(QPalette::WindowText, palette.color(QPalette::WindowText)); + } + + m_errorLabel->setText(error); + m_errorLabel->setPalette(palette); +} + +void IntroductionPage::callControlScript(const QString &callback) +{ + // Initialize the gui. Needs to be done after check repositories as only then the ui can handle + // hide of pages depending on the components. + gui()->init(); + gui()->callControlScriptMethod(callback); +} + +bool IntroductionPage::validRepositoriesAvailable() const +{ + const PackageManagerCore *const core = packageManagerCore(); + bool valid = (core->isInstaller() && core->isOfflineOnly()) || core->isUninstaller(); + + if (!valid) { + foreach (const Repository &repo, core->settings().repositories()) { + if (repo.isEnabled() && repo.isValid()) { + valid = true; + break; + } + } + } + return valid; +} + +// -- private slots + +void IntroductionPage::setUpdater(bool value) +{ + if (value) { + entering(); + gui()->showSettingsButton(true); + packageManagerCore()->setUpdater(); + emit packageManagerCoreTypeChanged(); + } +} + +void IntroductionPage::setUninstaller(bool value) +{ + if (value) { + entering(); + gui()->showSettingsButton(false); + packageManagerCore()->setUninstaller(); + emit packageManagerCoreTypeChanged(); + } +} + +void IntroductionPage::setPackageManager(bool value) +{ + if (value) { + entering(); + gui()->showSettingsButton(true); + packageManagerCore()->setPackageManager(); + emit packageManagerCoreTypeChanged(); + } +} + +void IntroductionPage::onCoreNetworkSettingsChanged() +{ + m_updatesFetched = false; + m_allPackagesFetched = false; +} + +// -- private + +void IntroductionPage::entering() +{ + setComplete(true); + showWidgets(false); + setMessage(QString()); + setErrorMessage(QString()); + setButtonText(QWizard::CancelButton, tr("Quit")); + + m_progressBar->setValue(0); + m_progressBar->setRange(0, 0); + PackageManagerCore *core = packageManagerCore(); + if (core->isUninstaller() || core->isUpdater() || core->isPackageManager()) { + showMaintenanceTools(); + setMaintenanceToolsEnabled(true); + } + setSettingsButtonRequested((!core->isOfflineOnly()) && (!core->isUninstaller())); +} + +void IntroductionPage::leaving() +{ + m_progressBar->setValue(0); + m_progressBar->setRange(0, 0); + setButtonText(QWizard::CancelButton, gui()->defaultButtonText(QWizard::CancelButton)); +} + +void IntroductionPage::showWidgets(bool show) +{ + m_label->setVisible(show); + m_progressBar->setVisible(show); + m_packageManager->setVisible(show); + m_updateComponents->setVisible(show); + m_removeAllComponents->setVisible(show); } void IntroductionPage::setText(const QString &text) @@ -1335,6 +1649,16 @@ TargetDirectoryPage::TargetDirectoryPage(PackageManagerCore *core) hlayout->addWidget(browseButton); layout->addLayout(hlayout); + + QPalette palette; + palette.setColor(QPalette::WindowText, Qt::red); + + m_warningLabel = new QLabel(this); + m_warningLabel->setPalette(palette); + m_warningLabel->setWordWrap(true); + m_warningLabel->setObjectName(QLatin1String("WarningLabel")); + layout->addWidget(m_warningLabel); + setLayout(layout); } @@ -1365,44 +1689,52 @@ void TargetDirectoryPage::initializePage() bool TargetDirectoryPage::validatePage() { - if (targetDir().isEmpty()) { - MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), - QLatin1String("EmptyTargetDirectoryMessage"), tr("Error"), tr("The install directory " - "cannot be empty, please specify a valid folder."), QMessageBox::Ok); - return false; - } + if (!isVisible()) + return true; - const QDir dir(targetDir()); - // it exists, but is empty (might be created by the Browse button (getExistingDirectory) - if (dir.exists() && dir.entryList(QDir::NoDotAndDotDot).isEmpty()) + const QString remove = packageManagerCore()->value(QLatin1String("RemoveTargetDir")); + if (!QVariant(remove).toBool()) return true; - if (dir.exists() && dir.isReadable()) { - // it exists, but is not empty - if (dir == QDir::root()) { - MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), - QLatin1String("ForbiddenTargetDirectoryMessage"), tr("Error"), tr("As the install " - "directory is completely deleted on uninstall, installing in %1 is forbidden.") - .arg(QDir::rootPath()), - QMessageBox::Ok); - return false; - } + const QString targetDir = this->targetDir(); + const QDir dir(targetDir); + // the directory exists and is empty... + if (dir.exists() && dir.entryList(QDir::AllEntries | QDir::NoDotAndDotDot).isEmpty()) + return true; - if (!QVariant(packageManagerCore()->value(scRemoveTargetDir)).toBool()) - return true; + const QFileInfo fi(targetDir); + if (fi.isDir()) { + QString fileName = packageManagerCore()->settings().uninstallerName(); +#if defined(Q_OS_MAC) + if (QFileInfo(QCoreApplication::applicationDirPath() + QLatin1String("/../..")).isBundle()) + fileName += QLatin1String(".app/Contents/MacOS/") + fileName; +#elif defined(Q_OS_WIN) + fileName += QLatin1String(".exe"); +#endif + + QFileInfo fi2(targetDir + QDir::separator() + fileName); + if (fi2.exists()) { + return failWithError(QLatin1String("TargetDirectoryInUse"), tr("The folder you selected already " + "exists and contains an installation. Choose a different target for installation.")); + } - return MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), - QLatin1String("OverwriteTargetDirectoryMessage"), tr("Warning"), tr("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?"), - QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes; + return askQuestion(QLatin1String("OverwriteTargetDirectory"), + tr("You have selected an existing, non-empty folder for installation.\nNote that it will be " + "completely wiped on uninstallation of this application.\nIt is not advisable to install into " + "this folder as installation might fail.\nDo you want to continue?")); + } else if (fi.isFile() || fi.isSymLink()) { + return failWithError(QLatin1String("WrongTargetDirectory"), tr("You have selected an existing file " + "or symlink, please choose a different target for installation.")); } return true; } void TargetDirectoryPage::entering() { + if (QPushButton *const b = qobject_cast<QPushButton *>(gui()->button(QWizard::NextButton))) { + b->setDefault(true); + b->setFocus(); + } } void TargetDirectoryPage::leaving() @@ -1410,10 +1742,6 @@ void TargetDirectoryPage::leaving() packageManagerCore()->setValue(scTargetDir, targetDir()); } -void TargetDirectoryPage::targetDirSelected() -{ -} - void TargetDirectoryPage::dirRequested() { const QString newDirName = QFileDialog::getExistingDirectory(this, @@ -1423,6 +1751,94 @@ void TargetDirectoryPage::dirRequested() m_lineEdit->setText(QDir::toNativeSeparators(newDirName)); } +bool TargetDirectoryPage::isComplete() const +{ + m_warningLabel->setText(targetDirWarning()); + return m_warningLabel->text().isEmpty(); +} + +QString TargetDirectoryPage::targetDirWarning() const +{ + if (targetDir().isEmpty()) { + return tr("The installation path cannot be empty, please specify a valid " + "folder."); + } + + if (QDir(targetDir()).isRelative()) { + return tr("The installation path cannot be relative, please specify an " + "absolute path."); + } + + QDir target(targetDir()); + target = target.canonicalPath(); + + if (target.isRoot()) { + return tr("As the install directory is completely deleted, installing " + "in %1 is forbidden.").arg(QDir::toNativeSeparators(QDir::rootPath())); + } + + if (target == QDir::home()) { + return tr("As the install directory is completely deleted, installing " + "in %1 is forbidden.").arg(QDir::toNativeSeparators(QDir::homePath())); + } + + QString dir = QDir::toNativeSeparators(targetDir()); +#ifdef Q_OS_WIN + // folder length (set by user) + maintenance tool name length (no extension) + extra padding + if ((dir.length() + packageManagerCore()->settings().uninstallerName().length() + 20) >= MAX_PATH) { + return tr("The path you have entered is too long, please make sure to " + "specify a valid path."); + } + + if (dir.count() >= 3 && dir.indexOf(QRegExp(QLatin1String("[a-zA-Z]:"))) == 0 + && dir.at(2) != QLatin1Char('\\')) { + return tr("The path you have entered is not valid, please make sure to " + "specify a valid drive."); + } + + // remove e.g. "c:" + dir = dir.mid(2); +#endif + + QString ambiguousChars = QLatin1String("[~<>|?*!@#$%^&:,; ]"); + if (packageManagerCore()->settings().allowSpaceInPath()) + ambiguousChars.remove(QLatin1Char(' ')); + + // check if there are not allowed characters in the target path + if (dir.contains(QRegExp(ambiguousChars))) { + return tr("The installation path must not contain %1, " + "please specify a valid folder.").arg(ambiguousChars); + } + + dir = targetDir(); + if (!packageManagerCore()->settings().allowNonAsciiCharacters()) { + for (int i = 0; i < dir.length(); ++i) { + if (dir.at(i).unicode() & 0xff80) { + return tr("The path or installation directory contains non ASCII " + "characters. This is currently not supported! Please choose a different path or " + "installation directory."); + } + } + } + + return QString(); +} + +bool TargetDirectoryPage::askQuestion(const QString &identifier, const QString &message) +{ + QMessageBox::StandardButton bt = + MessageBoxHandler::warning(MessageBoxHandler::currentBestSuitParent(), identifier, + tr("Warning"), message, QMessageBox::Yes | QMessageBox::No); + return bt == QMessageBox::Yes; +} + +bool TargetDirectoryPage::failWithError(const QString &identifier, const QString &message) +{ + MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), identifier, + tr("Error"), message); + return false; +} + // -- StartMenuDirectoryPage @@ -1437,45 +1853,19 @@ StartMenuDirectoryPage::StartMenuDirectoryPage(PackageManagerCore *core) m_lineEdit = new QLineEdit(this); m_lineEdit->setObjectName(QLatin1String("LineEdit")); + m_lineEdit->setText(core->value(scStartMenuDir, productName())); - QString startMenuDir = core->value(scStartMenuDir); - if (startMenuDir.isEmpty()) - startMenuDir = productName(); - m_lineEdit->setText(startMenuDir); - - // grab existing start menu folders - QSettings user(QLatin1String("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\" - "Explorer\\User Shell Folders"), QSettings::NativeFormat); - // User Shell Folders uses %USERPROFILE% - startMenuPath = replaceWindowsEnvironmentVariables(user.value(QLatin1String("Programs"), - QString()).toString()); - core->setValue(QLatin1String("DesktopDir"), replaceWindowsEnvironmentVariables(user - .value(QLatin1String("Desktop")).toString())); - - QDir dir(startMenuPath); // user only dirs - QStringList dirs = dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot); - - if (core->value(QLatin1String("AllUsers")) == QLatin1String("true")) { - qDebug() << "AllUsers set. Using HKEY_LOCAL_MACHINE"; - QSettings system(QLatin1String("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\" - "CurrentVersion\\Explorer\\Shell Folders"), QSettings::NativeFormat); - startMenuPath = system.value(QLatin1String("Common Programs"), QString()).toString(); - core->setValue(QLatin1String("DesktopDir"),system.value(QLatin1String("Desktop")) - .toString()); - - dir.setPath(startMenuPath); // system only dirs - dirs += dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot); + startMenuPath = core->value(QLatin1String("UserStartMenuProgramsPath")); + QStringList dirs = QDir(startMenuPath).entryList(QDir::AllDirs | QDir::NoDotAndDotDot); + if (core->value(QLatin1String("AllUsers")) == scTrue) { + startMenuPath = core->value(QLatin1String("AllUsersStartMenuProgramsPath")); + dirs += QDir(startMenuPath).entryList(QDir::AllDirs | QDir::NoDotAndDotDot); } - - qDebug() << "StartMenuPath: \t" << startMenuPath; - qDebug() << "DesktopDir: \t" << core->value(QLatin1String("DesktopDir")); + dirs.removeDuplicates(); m_listWidget = new QListWidget(this); - if (!dirs.isEmpty()) { - dirs.removeDuplicates(); - foreach (const QString &dir, dirs) - new QListWidgetItem(dir, m_listWidget); - } + foreach (const QString &dir, dirs) + new QListWidgetItem(dir, m_listWidget); QVBoxLayout *layout = new QVBoxLayout(this); layout->addWidget(m_lineEdit); @@ -1536,6 +1926,7 @@ ReadyForInstallationPage::ReadyForInstallationPage(PackageManagerCore *core) baseLayout->addLayout(topLayout); m_taskDetailsButton = new QPushButton(tr("&Show Details"), this); + m_taskDetailsButton->setFocusPolicy(Qt::NoFocus); m_taskDetailsButton->setObjectName(QLatin1String("TaskDetailsButton")); m_taskDetailsButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); connect(m_taskDetailsButton, SIGNAL(clicked()), this, SLOT(toggleDetails())); @@ -1927,8 +2318,13 @@ void FinishedPage::entering() setButtonText(QWizard::CommitButton, tr("Restart")); setButtonText(QWizard::CancelButton, gui()->defaultButtonText(QWizard::FinishButton)); } else { - if (packageManagerCore()->isInstaller()) + if (packageManagerCore()->isInstaller()) { m_commitButton = wizard()->button(QWizard::FinishButton); + if (QPushButton *const b = qobject_cast<QPushButton *>(m_commitButton)) { + b->setDefault(true); + b->setFocus(); + } + } gui()->setOption(QWizard::NoCancelButton, true); if (QAbstractButton *cancel = gui()->button(QWizard::CancelButton)) diff --git a/src/libs/installer/packagemanagergui.h b/src/libs/installer/packagemanagergui.h index 948fb346a..a2cf23139 100644 --- a/src/libs/installer/packagemanagergui.h +++ b/src/libs/installer/packagemanagergui.h @@ -58,6 +58,7 @@ class QLabel; class QLineEdit; class QListWidget; class QListWidgetItem; +class QProgressBar; class QRadioButton; class QTextBrowser; QT_END_NAMESPACE @@ -83,9 +84,12 @@ public: void loadControlScript(const QString& scriptPath); void callControlScriptMethod(const QString& methodName); - Q_INVOKABLE PackageManagerPage* page(int pageId) const; - Q_INVOKABLE QWidget* pageWidgetByObjectName(const QString& name) const; + Q_INVOKABLE QWidget *pageById(int id) const; + Q_INVOKABLE QWidget *pageByObjectName(const QString &name) const; + Q_INVOKABLE QWidget* currentPageWidget() const; + Q_INVOKABLE QWidget* pageWidgetByObjectName(const QString &name) const; + Q_INVOKABLE QString defaultButtonText(int wizardButton) const; Q_INVOKABLE void clickButton(int wizardButton, int delayInMs = 0); Q_INVOKABLE bool isButtonEnabled(int wizardButton); @@ -210,12 +214,51 @@ class INSTALLER_EXPORT IntroductionPage : public PackageManagerPage public: explicit IntroductionPage(PackageManagerCore *core); - void setWidget(QWidget *widget); void setText(const QString &text); + int nextId() const; + bool validatePage(); + + void showAll(); + void hideAll(); + void showMetaInfoUdate(); + void showMaintenanceTools(); + void setMaintenanceToolsEnabled(bool enable); + + public Q_SLOTS: + void onCoreNetworkSettingsChanged(); + void setMessage(const QString &msg); + void onProgressChanged(int progress); + void setErrorMessage(const QString &error); + +Q_SIGNALS: + void packageManagerCoreTypeChanged(); + + private Q_SLOTS: + void setUpdater(bool value); + void setUninstaller(bool value); + void setPackageManager(bool value); + private: + void entering(); + void leaving(); + + void showWidgets(bool show); + void callControlScript(const QString &callback); + + bool validRepositoriesAvailable() const; + +private: + bool m_updatesFetched; + bool m_allPackagesFetched; + + QLabel *m_label; QLabel *m_msgLabel; - QWidget *m_widget; + QLabel *m_errorLabel; + QProgressBar *m_progressBar; + QRadioButton *m_packageManager; + QRadioButton *m_updateComponents; + QRadioButton *m_removeAllComponents; }; @@ -296,17 +339,23 @@ public: void initializePage(); bool validatePage(); + bool isComplete() const; protected: void entering(); void leaving(); private Q_SLOTS: - void targetDirSelected(); void dirRequested(); private: + QString targetDirWarning() const; + bool askQuestion(const QString &identifier, const QString &message); + bool failWithError(const QString &identifier, const QString &message); + +private: QLineEdit *m_lineEdit; + QLabel *m_warningLabel; }; diff --git a/src/libs/installer/scriptengine.cpp b/src/libs/installer/scriptengine.cpp index 87faa2cee..e131390b3 100644 --- a/src/libs/installer/scriptengine.cpp +++ b/src/libs/installer/scriptengine.cpp @@ -41,6 +41,7 @@ #include "scriptengine.h" #include "component.h" +#include "globals.h" #include "packagemanagercore.h" #include "messageboxhandler.h" #include "errors.h" @@ -115,15 +116,9 @@ QScriptValue qDesktopServicesDisplayName(QScriptContext *context, QScriptEngine if (check.isError()) return check; -#if QT_VERSION < 0x050000 - const QDesktopServices::StandardLocation location = - static_cast< QDesktopServices::StandardLocation >(context->argument(0).toInt32()); - return QDesktopServices::displayName(location); -#else const QStandardPaths::StandardLocation location = static_cast< QStandardPaths::StandardLocation >(context->argument(0).toInt32()); return QStandardPaths::displayName(location); -#endif } QScriptValue qDesktopServicesStorageLocation(QScriptContext *context, QScriptEngine *engine) @@ -133,15 +128,9 @@ QScriptValue qDesktopServicesStorageLocation(QScriptContext *context, QScriptEng if (check.isError()) return check; -#if QT_VERSION < 0x050000 - const QDesktopServices::StandardLocation location = - static_cast< QDesktopServices::StandardLocation >(context->argument(0).toInt32()); - return QDesktopServices::storageLocation(location); -#else const QStandardPaths::StandardLocation location = static_cast< QStandardPaths::StandardLocation >(context->argument(0).toInt32()); return QStandardPaths::writableLocation(location); -#endif } QScriptValue qFileDialogGetExistingDirectory(QScriptContext *context, QScriptEngine *engine) @@ -248,16 +237,17 @@ QScriptValue ScriptEngine::loadInConext(const QString &context, const QString &f fileName, file.errorString())); } - // create inside closure in one line to keep linenumber in the right order - // which is used as a debug output in an exception case - // scriptContent will be added as the last arg command to prevent wrong - // replacements of %1, %2 or %3 inside the scriptContent - QString scriptContent = QString::fromLatin1( - "(function() { %1 %3 ; return new %2; })();"); - - // merging everything together and as last we are adding the file content to prevent wrong - // replacements of %1 %2 or %3 inside the javascript code - scriptContent = scriptContent.arg(scriptInjection, context, QLatin1String(file.readAll())); + // Create a closure. Put the content in the first line to keep line number order in case of an + // exception. Script content will be added as the last argument to the command to prevent wrong + // replacements of %1, %2 or %3 inside the javascript code. + const QString scriptContent = QLatin1String("(function() {") + + scriptInjection + QString::fromUtf8(file.readAll()) + + QString::fromLatin1(";" + " if (typeof %1 != \"undefined\")" + " return new %1;" + " else" + " throw \"Missing Component constructor. Please check your script.\";" + "})();").arg(context); QScriptValue scriptContext = evaluate(scriptContent, fileName); if (hasUncaughtException()) { @@ -357,20 +347,6 @@ QScriptValue ScriptEngine::generateMessageBoxObject() QScriptValue ScriptEngine::generateDesktopServicesObject() { QScriptValue desktopServices = newArray(); -#if QT_VERSION < 0x050000 - desktopServices.setProperty(QLatin1String("DesktopLocation"), QDesktopServices::DesktopLocation); - desktopServices.setProperty(QLatin1String("DesktopLocation"), QDesktopServices::DesktopLocation); - desktopServices.setProperty(QLatin1String("DocumentsLocation"), QDesktopServices::DocumentsLocation); - desktopServices.setProperty(QLatin1String("FontsLocation"), QDesktopServices::FontsLocation); - desktopServices.setProperty(QLatin1String("ApplicationsLocation"), QDesktopServices::ApplicationsLocation); - desktopServices.setProperty(QLatin1String("MusicLocation"), QDesktopServices::MusicLocation); - desktopServices.setProperty(QLatin1String("MoviesLocation"), QDesktopServices::MoviesLocation); - desktopServices.setProperty(QLatin1String("PicturesLocation"), QDesktopServices::PicturesLocation); - desktopServices.setProperty(QLatin1String("TempLocation"), QDesktopServices::TempLocation); - desktopServices.setProperty(QLatin1String("HomeLocation"), QDesktopServices::HomeLocation); - desktopServices.setProperty(QLatin1String("DataLocation"), QDesktopServices::DataLocation); - desktopServices.setProperty(QLatin1String("CacheLocation"), QDesktopServices::CacheLocation); -#else desktopServices.setProperty(QLatin1String("DesktopLocation"), QStandardPaths::DesktopLocation); desktopServices.setProperty(QLatin1String("DesktopLocation"), QStandardPaths::DesktopLocation); desktopServices.setProperty(QLatin1String("DocumentsLocation"), QStandardPaths::DocumentsLocation); @@ -383,7 +359,6 @@ QScriptValue ScriptEngine::generateDesktopServicesObject() desktopServices.setProperty(QLatin1String("HomeLocation"), QStandardPaths::HomeLocation); desktopServices.setProperty(QLatin1String("DataLocation"), QStandardPaths::DataLocation); desktopServices.setProperty(QLatin1String("CacheLocation"), QStandardPaths::CacheLocation); -#endif desktopServices.setProperty(QLatin1String("openUrl"), newFunction(qDesktopServicesOpenUrl)); diff --git a/src/libs/installer/settings.cpp b/src/libs/installer/settings.cpp index 90cb431f4..56041916e 100644 --- a/src/libs/installer/settings.cpp +++ b/src/libs/installer/settings.cpp @@ -171,8 +171,13 @@ public: QVariantHash m_data; bool m_replacementRepos; - QString makeAbsolutePath(const QString &path) const + QString absolutePathFromKey(const QString &key, const QString &suffix = QString()) const { + const QString value = m_data.value(key).toString(); + if (value.isEmpty()) + return QString(); + + const QString path = value + suffix; if (QFileInfo(path).isAbsolute()) return path; return m_data.value(scPrefix).toString() + QLatin1String("/") + path; @@ -296,7 +301,7 @@ Settings Settings::fromFileAndPrefix(const QString &path, const QString &prefix, QString Settings::logo() const { - return d->makeAbsolutePath(d->m_data.value(scLogo).toString()); + return d->absolutePathFromKey(scLogo); } QString Settings::title() const @@ -326,22 +331,22 @@ QString Settings::url() const QString Settings::watermark() const { - return d->makeAbsolutePath(d->m_data.value(scWatermark).toString()); + return d->absolutePathFromKey(scWatermark); } QString Settings::banner() const { - return d->makeAbsolutePath(d->m_data.value(scBanner).toString()); + return d->absolutePathFromKey(scBanner); } QString Settings::background() const { - return d->makeAbsolutePath(d->m_data.value(scBackground).toString()); + return d->absolutePathFromKey(scBackground); } QString Settings::icon() const { - return d->makeAbsolutePath(d->m_data.value(scIcon).toString() + systemIconSuffix()); + return d->absolutePathFromKey(scIcon, systemIconSuffix()); } QString Settings::wizardStyle() const @@ -356,12 +361,12 @@ QString Settings::titleColor() const QString Settings::installerApplicationIcon() const { - return d->makeAbsolutePath(d->m_data.value(scInstallerApplicationIcon).toString() + systemIconSuffix()); + return d->absolutePathFromKey(scInstallerApplicationIcon, systemIconSuffix()); } QString Settings::installerWindowIcon() const { - return d->makeAbsolutePath(d->m_data.value(scInstallerWindowIcon).toString()); + return d->absolutePathFromKey(scInstallerWindowIcon); } QString Settings::systemIconSuffix() const diff --git a/src/libs/installer/settings.h b/src/libs/installer/settings.h index 9bce8bd70..5788ddb9b 100644 --- a/src/libs/installer/settings.h +++ b/src/libs/installer/settings.h @@ -52,10 +52,6 @@ #include <QtNetwork/QNetworkProxy> -#if QT_VERSION < 0x050000 - Q_DECLARE_METATYPE(QNetworkProxy) -#endif - namespace QInstaller { class Repository; diff --git a/src/libs/kdtools/kdupdaterfiledownloader.cpp b/src/libs/kdtools/kdupdaterfiledownloader.cpp index f2063c8c4..96baf88b3 100644 --- a/src/libs/kdtools/kdupdaterfiledownloader.cpp +++ b/src/libs/kdtools/kdupdaterfiledownloader.cpp @@ -823,8 +823,7 @@ KDUpdater::HttpDownloader::HttpDownloader(QObject *parent) : KDUpdater::FileDownloader(QLatin1String("http"), parent) , d(new Private(this)) { -#ifndef QT_NO_OPENSSL - // TODO: once we switch to Qt5, use QT_NO_SSL instead of QT_NO_OPENSSL +#ifndef QT_NO_SSL connect(&d->manager, SIGNAL(sslErrors(QNetworkReply*, QList<QSslError>)), this, SLOT(onSslErrors(QNetworkReply*, QList<QSslError>))); #endif @@ -1067,11 +1066,10 @@ void KDUpdater::HttpDownloader::onAuthenticationRequired(QNetworkReply *reply, Q } } -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL #include "messageboxhandler.h" -// TODO: once we switch to Qt5, use QT_NO_SSL instead of QT_NO_OPENSSL void KDUpdater::HttpDownloader::onSslErrors(QNetworkReply* reply, const QList<QSslError> &errors) { Q_UNUSED(reply) diff --git a/src/libs/kdtools/kdupdaterfiledownloader_p.h b/src/libs/kdtools/kdupdaterfiledownloader_p.h index c5019cae6..f5612f6ba 100644 --- a/src/libs/kdtools/kdupdaterfiledownloader_p.h +++ b/src/libs/kdtools/kdupdaterfiledownloader_p.h @@ -141,8 +141,7 @@ private Q_SLOTS: void httpDone(bool error); void httpReqFinished(); void onAuthenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator); -#ifndef QT_NO_OPENSSL - // TODO: once we switch to Qt5, use QT_NO_SSL instead of QT_NO_OPENSSL +#ifndef QT_NO_SSL void onSslErrors(QNetworkReply* reply, const QList<QSslError> &errors); #endif private: diff --git a/src/libs/kdtools/kdupdaterfiledownloaderfactory.cpp b/src/libs/kdtools/kdupdaterfiledownloaderfactory.cpp index 92dff42ee..cd6b552a5 100644 --- a/src/libs/kdtools/kdupdaterfiledownloaderfactory.cpp +++ b/src/libs/kdtools/kdupdaterfiledownloaderfactory.cpp @@ -77,8 +77,7 @@ FileDownloaderFactory::FileDownloaderFactory() registerFileDownloader<HttpDownloader>(QLatin1String("http")); registerFileDownloader<ResourceFileDownloader >(QLatin1String("resource")); -#ifndef QT_NO_OPENSSL - // TODO: once we switch to Qt5, use QT_NO_SSL instead of QT_NO_OPENSSL +#ifndef QT_NO_SSL if (QSslSocket::supportsSsl()) registerFileDownloader<HttpDownloader>(QLatin1String("https")); else |