diff options
37 files changed, 330 insertions, 217 deletions
diff --git a/src/libs/installer/adminauthorization_win.cpp b/src/libs/installer/adminauthorization_win.cpp index 3ad193b5e..6fdef741c 100644 --- a/src/libs/installer/adminauthorization_win.cpp +++ b/src/libs/installer/adminauthorization_win.cpp @@ -35,6 +35,8 @@ #include <qt_windows.h> +#include "globals.h" + #ifdef Q_CC_MINGW # ifndef SEE_MASK_NOASYNC # define SEE_MASK_NOASYNC 0x00000100 @@ -106,14 +108,15 @@ bool AdminAuthorization::execute(QWidget *, const QString &program, const QStrin shellExecuteInfo.lpParameters = (wchar_t *)args.utf16(); shellExecuteInfo.fMask = SEE_MASK_NOASYNC; - qDebug() << "Starting elevated process" << file << "with arguments" << args; + qCDebug(QInstaller::lcServer) << "Starting elevated process" << file + << "with arguments" << args; if (ShellExecuteExW(&shellExecuteInfo)) { - qDebug() << "Finished starting elevated process."; + qCDebug(QInstaller::lcServer) << "Finished starting elevated process."; return true; } else { - qWarning() << "Error while starting elevated process" << program - << ":" << QInstaller::windowsErrorString(GetLastError()); + qCWarning(QInstaller::lcServer) << "Error while starting elevated process" << program + << ":" << QInstaller::windowsErrorString(GetLastError()); } return false; } diff --git a/src/libs/installer/adminauthorization_x11.cpp b/src/libs/installer/adminauthorization_x11.cpp index 7068bb2c6..08b20b2f6 100644 --- a/src/libs/installer/adminauthorization_x11.cpp +++ b/src/libs/installer/adminauthorization_x11.cpp @@ -59,6 +59,8 @@ #include <iostream> +#include "globals.h" + #define SU_COMMAND "/usr/bin/sudo" //#define SU_COMMAND "/bin/echo" @@ -95,7 +97,7 @@ static void printError(QWidget *parent, const QString &value) bool AdminAuthorization::execute(QWidget *parent, const QString &program, const QStringList &arguments) { const QString fallback = program + QLatin1String(" ") + arguments.join(QLatin1String(" ")); - qDebug() << "Fallback:" << fallback; + qCDebug(QInstaller::lcServer) << "Fallback:" << fallback; // as we cannot pipe the password to su in QProcess, we need to setup a pseudo-terminal for it int masterFD = -1; diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp index e8abe2383..6cd48db4b 100644 --- a/src/libs/installer/component.cpp +++ b/src/libs/installer/component.cpp @@ -553,7 +553,7 @@ void Component::loadComponentScript(const QString &fileName) } catch (const Error &error) { if (packageManagerCore()->settings().allowUnstableComponents()) { setUnstable(Component::Component::ScriptLoadingFailed, error.message()); - qWarning() << error.message(); + qCWarning(QInstaller::lcGeneral) << error.message(); } else { throw error; } @@ -871,7 +871,7 @@ void Component::addDownloadableArchive(const QString &path) { Q_ASSERT(isFromOnlineRepository()); - qDebug() << "addDownloadable" << path; + qCDebug(QInstaller::lcGeneral) << "addDownloadable" << path; d->m_downloadableArchives.append(d->m_vars.value(scVersion) + path); } @@ -1332,7 +1332,8 @@ bool Component::isDefault() const } if (!valueFromScript.isError()) return valueFromScript.toBool(); - qDebug() << "Value from script is not valid." << (valueFromScript.toString().isEmpty() + qCWarning(QInstaller::lcGeneral) << "Value from script is not valid." + << (valueFromScript.toString().isEmpty() ? QString::fromLatin1("Unknown error.") : valueFromScript.toString()); return false; } diff --git a/src/libs/installer/consumeoutputoperation.cpp b/src/libs/installer/consumeoutputoperation.cpp index 43c78193c..3203f84d4 100644 --- a/src/libs/installer/consumeoutputoperation.cpp +++ b/src/libs/installer/consumeoutputoperation.cpp @@ -29,6 +29,7 @@ #include "consumeoutputoperation.h" #include "packagemanagercore.h" #include "utils.h" +#include "globals.h" #include <QFile> #include <QDir> @@ -99,10 +100,11 @@ bool ConsumeOutputOperation::performOperation() process.start(executable.absoluteFilePath(), processArguments, QIODevice::ReadOnly); 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(); + qCWarning(QInstaller::lcGeneral) << 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()))); @@ -116,13 +118,15 @@ bool ConsumeOutputOperation::performOperation() uiDetachedWait(waitTimeInMilliSeconds); } if (process.state() > QProcess::NotRunning ) { - qWarning() << executable.absoluteFilePath() << "process is still running, need to kill it."; + qCWarning(QInstaller::lcGeneral) << executable.absoluteFilePath() + << "process is still running, need to kill it."; process.kill(); } } if (executableOutput.isEmpty()) { - qWarning() << "Cannot get any query output from executable" << executable.absoluteFilePath(); + qCWarning(QInstaller::lcGeneral) << "Cannot get any query output from executable" + << executable.absoluteFilePath(); } core->setValue(installerKeyName, QString::fromLocal8Bit(executableOutput)); return true; diff --git a/src/libs/installer/createdesktopentryoperation.cpp b/src/libs/installer/createdesktopentryoperation.cpp index e6d3b16e7..0904f434e 100644 --- a/src/libs/installer/createdesktopentryoperation.cpp +++ b/src/libs/installer/createdesktopentryoperation.cpp @@ -29,6 +29,7 @@ #include "errors.h" #include "fileutils.h" +#include "globals.h" #include <QDir> #include <QFile> @@ -158,7 +159,8 @@ bool CreateDesktopEntryOperation::undoOperation() // first remove the link QFile file(filename); if (file.exists() && !file.remove()) { - qWarning() << "Cannot delete file" << filename << ":" << file.errorString(); + qCWarning(QInstaller::lcGeneral) << "Cannot delete file" << filename + << ":" << file.errorString(); return true; } @@ -168,13 +170,15 @@ bool CreateDesktopEntryOperation::undoOperation() QFile backupFile(value(QLatin1String("backupOfExistingDesktopEntry")).toString()); if (!backupFile.exists()) { // do not treat this as a real error: The backup file might have been just nuked by the user. - qWarning() << "Cannot restore original desktop entry at" << filename - << ": Backup file" << backupFile.fileName() << "does not exist anymore."; + qCWarning(QInstaller::lcGeneral) << "Cannot restore original desktop entry at" << filename + << ": Backup file" << backupFile.fileName() << "does not exist anymore."; return true; } - if (!backupFile.rename(filename)) - qWarning() << "Cannot restore the file" << filename << ":" << backupFile.errorString(); + if (!backupFile.rename(filename)) { + qCWarning(QInstaller::lcGeneral) << "Cannot restore the file" << filename + << ":" << backupFile.errorString(); + } return true; } diff --git a/src/libs/installer/createshortcutoperation.cpp b/src/libs/installer/createshortcutoperation.cpp index bbe3feba1..5a6acd2ba 100644 --- a/src/libs/installer/createshortcutoperation.cpp +++ b/src/libs/installer/createshortcutoperation.cpp @@ -29,6 +29,7 @@ #include "fileutils.h" #include "utils.h" +#include "globals.h" #include <QDebug> #include <QDir> @@ -276,7 +277,7 @@ bool CreateShortcutOperation::undoOperation() const QString &linkLocation = arguments().at(1); if (!deleteFileNowOrLater(linkLocation) ) - qDebug() << "Cannot delete:" << linkLocation; + qCWarning(QInstaller::lcGeneral) << "Cannot delete:" << linkLocation; QDir dir; // remove all directories we created const QStringList directoriesToDelete = value(QLatin1String("createddirs")).toStringList(); diff --git a/src/libs/installer/downloadfiletask.cpp b/src/libs/installer/downloadfiletask.cpp index a5d47ad3b..626716223 100644 --- a/src/libs/installer/downloadfiletask.cpp +++ b/src/libs/installer/downloadfiletask.cpp @@ -29,6 +29,7 @@ #include "downloadfiletask.h" #include "downloadfiletask_p.h" +#include "globals.h" #include <QCoreApplication> #include <QDir> @@ -259,7 +260,7 @@ void Downloader::onError(QNetworkReply::NetworkError error) //with RepositoryUpdate in Updates.xml later. //: %2 is a sentence describing the error if (data.taskItem.source().contains(QLatin1String("Updates.xml"), Qt::CaseInsensitive)) { - qDebug() << QString::fromLatin1("Network error while downloading '%1': %2.").arg( + qCWarning(QInstaller::lcServer) << QString::fromLatin1("Network error while downloading '%1': %2.").arg( data.taskItem.source(), reply->errorString()); } else { m_futureInterface->reportException( @@ -279,7 +280,7 @@ void Downloader::onSslErrors(const QList<QSslError> &sslErrors) Q_UNUSED(sslErrors); #else foreach (const QSslError &error, sslErrors) - qDebug() << "SSL error:" << error.errorString(); + qCWarning(QInstaller::lcServer) << "SSL error:" << error.errorString(); #endif } diff --git a/src/libs/installer/elevatedexecuteoperation.cpp b/src/libs/installer/elevatedexecuteoperation.cpp index aa88f0398..05149fb26 100644 --- a/src/libs/installer/elevatedexecuteoperation.cpp +++ b/src/libs/installer/elevatedexecuteoperation.cpp @@ -30,6 +30,7 @@ #include "environment.h" #include "qprocesswrapper.h" +#include "globals.h" #include <QtCore/QDebug> #include <QtCore/QProcessEnvironment> @@ -146,7 +147,8 @@ bool ElevatedExecuteOperation::Private::run(const QStringList &arguments) process = new QProcessWrapper(); if (!workingDirectory.isEmpty()) { process->setWorkingDirectory(workingDirectory); - qDebug() << "ElevatedExecuteOperation setWorkingDirectory:" << workingDirectory; + qCDebug(QInstaller::lcGeneral) << "ElevatedExecuteOperation setWorkingDirectory:" + << workingDirectory; } QProcessEnvironment penv; @@ -167,7 +169,8 @@ bool ElevatedExecuteOperation::Private::run(const QStringList &arguments) //readProcessOutput should only called from this current Thread -> Qt::DirectConnection QObject::connect(process, SIGNAL(readyRead()), q, SLOT(readProcessOutput()), Qt::DirectConnection); process->start(args.front(), args.mid(1)); - qDebug() << args.front() << "started, arguments:" << QStringList(args.mid(1)).join(QLatin1String(" ")); + qCDebug(QInstaller::lcGeneral) << args.front() << "started, arguments:" + << QStringList(args.mid(1)).join(QLatin1String(" ")); bool success = false; //we still like the none blocking possibility to perform this operation without threads @@ -213,7 +216,7 @@ bool ElevatedExecuteOperation::Private::run(const QStringList &arguments) QByteArray standardErrorOutput = process->readAllStandardError(); // in error case it would be useful to see something in verbose output if (!standardErrorOutput.isEmpty()) - qWarning().noquote() << standardErrorOutput; + qCWarning(QInstaller::lcGeneral).noquote() << standardErrorOutput; returnValue = false; } @@ -240,14 +243,15 @@ void ElevatedExecuteOperation::Private::readProcessOutput() Q_ASSERT(process); Q_ASSERT(QThread::currentThread() == process->thread()); if (QThread::currentThread() != process->thread()) { - qDebug() << Q_FUNC_INFO << "can only be called from the same thread as the process is."; + qCDebug(QInstaller::lcGeneral) << Q_FUNC_INFO << "can only be called from the " + "same thread as the process is."; } const QByteArray output = process->readAll(); if (!output.isEmpty()) { if (q->error() == UserDefinedError) - qWarning() << output; + qCWarning(QInstaller::lcGeneral)<< output; else - qDebug() << output; + qCDebug(QInstaller::lcGeneral) << output; emit q->outputTextChanged(QString::fromLocal8Bit(output)); } } diff --git a/src/libs/installer/environmentvariablesoperation.cpp b/src/libs/installer/environmentvariablesoperation.cpp index 1f3b56d52..953379ba7 100644 --- a/src/libs/installer/environmentvariablesoperation.cpp +++ b/src/libs/installer/environmentvariablesoperation.cpp @@ -32,6 +32,7 @@ #include <stdlib.h> #include "environment.h" +#include "globals.h" #ifdef Q_OS_WIN # include <windows.h> @@ -59,7 +60,7 @@ static void broadcastEnvironmentChange() 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."); + qCWarning(QInstaller::lcGeneral) << "Failed to broadcast the WM_SETTINGCHANGE message."; } #endif diff --git a/src/libs/installer/extractarchiveoperation.cpp b/src/libs/installer/extractarchiveoperation.cpp index b5bf96954..f589ed4c1 100644 --- a/src/libs/installer/extractarchiveoperation.cpp +++ b/src/libs/installer/extractarchiveoperation.cpp @@ -29,6 +29,7 @@ #include "extractarchiveoperation_p.h" #include "constants.h" +#include "globals.h" #include <QEventLoop> #include <QThreadPool> @@ -120,7 +121,7 @@ bool ExtractArchiveOperation::performOperation() setValue(QLatin1String("files"), file.fileName()); file.close(); } else { - qWarning() << "Cannot open file for writing " << file.fileName() << ":" << file.errorString(); + qCWarning(QInstaller::lcGeneral) << "Cannot open file for writing " << file.fileName() << ":" << file.errorString(); } // TODO: Use backups for rollback, too? Doesn't work for uninstallation though. @@ -177,7 +178,7 @@ void ExtractArchiveOperation::startUndoProcess(const QStringList &files) void ExtractArchiveOperation::deleteDataFile(const QString &fileName) { if (fileName.isEmpty()) { - qWarning() << Q_FUNC_INFO << "data file name cannot be empty."; + qCWarning(QInstaller::lcGeneral) << Q_FUNC_INFO << "data file name cannot be empty."; return; } QFile file(fileName); @@ -187,7 +188,7 @@ void ExtractArchiveOperation::deleteDataFile(const QString &fileName) if (directory.exists() && directory.isEmpty()) directory.rmdir(directory.path()); } else { - qWarning() << "Cannot remove data file" << file.fileName(); + qCWarning(QInstaller::lcGeneral) << "Cannot remove data file" << file.fileName(); } } @@ -214,7 +215,7 @@ bool ExtractArchiveOperation::readDataFileContents(QString &targetDir, QStringLi } else { // We should not be here. Either user has manually deleted the installer related // files or same component is installed several times. - qWarning() << "Cannot open file " << file.fileName() << " for reading:" + qCWarning(QInstaller::lcGeneral) << "Cannot open file " << file.fileName() << " for reading:" << file.errorString() << ". Component is already uninstalled " << "or file is manually deleted."; } diff --git a/src/libs/installer/fileutils.cpp b/src/libs/installer/fileutils.cpp index b11768494..7829083e4 100644 --- a/src/libs/installer/fileutils.cpp +++ b/src/libs/installer/fileutils.cpp @@ -27,6 +27,7 @@ **************************************************************************/ #include "fileutils.h" +#include "globals.h" #include <errors.h> #include <QtCore/QDateTime> @@ -188,7 +189,7 @@ void QInstaller::removeFiles(const QString &path, bool ignoreErrors) QDir::toNativeSeparators(f.fileName()), f.errorString()); if (!ignoreErrors) throw Error(errorMessage); - qWarning().noquote() << errorMessage; + qCWarning(QInstaller::lcGeneral).noquote() << errorMessage; } } } @@ -231,7 +232,7 @@ void QInstaller::removeDirectory(const QString &path, bool ignoreErrors) errnoToQString(errno)); if (!ignoreErrors) throw Error(errorMessage); - qWarning().noquote() << errorMessage; + qCWarning(QInstaller::lcGeneral).noquote() << errorMessage; } } } @@ -312,14 +313,14 @@ bool QInstaller::setDefaultFilePermissions(const QString &fileName, DefaultFileP bool QInstaller::setDefaultFilePermissions(QFile *file, DefaultFilePermissions permissions) { if (!file->exists()) { - qWarning() << "Target" << file->fileName() << "does not exists."; + qCWarning(QInstaller::lcGeneral) << "Target" << file->fileName() << "does not exists."; return false; } if (file->permissions() == static_cast<QFileDevice::Permission>(permissions)) return true; if (!file->setPermissions(static_cast<QFileDevice::Permission>(permissions))) { - qWarning() << "Cannot set default permissions for target" + qCWarning(QInstaller::lcGeneral) << "Cannot set default permissions for target" << file->fileName() << ":" << file->errorString(); return false; } @@ -529,13 +530,14 @@ void QInstaller::setApplicationIcon(const QString &application, const QString &i { QFile iconFile(icon); if (!iconFile.open(QIODevice::ReadOnly)) { - qWarning() << "Cannot use" << icon << "as an application icon:" << iconFile.errorString(); + qCWarning(QInstaller::lcGeneral) << "Cannot use" << icon << "as an application icon:" + << iconFile.errorString(); return; } if (QImageReader::imageFormat(icon) != "ico") { - qWarning() << "Cannot use" << icon << "as an application icon, unsupported format" - << QImageReader::imageFormat(icon).constData(); + qCWarning(QInstaller::lcGeneral) << "Cannot use" << icon << "as an application icon, " + "unsupported format" << QImageReader::imageFormat(icon).constData(); return; } diff --git a/src/libs/installer/globals.cpp b/src/libs/installer/globals.cpp index 851ebd35d..517bcdecf 100644 --- a/src/libs/installer/globals.cpp +++ b/src/libs/installer/globals.cpp @@ -33,6 +33,8 @@ const char IFW_COMPONENT_CHECKER[] = "ifw.componentChecker"; const char IFW_RESOURCES[] = "ifw.resources"; const char IFW_TRANSLATIONS[] = "ifw.translations"; const char IFW_NETWORK[] = "ifw.network"; +const char IFW_SERVER[] = "ifw.server"; +const char IFW_GENERAL[] = "ifw.general"; const char IFW_PACKAGE_DISPLAYNAME[] = "ifw.package.displayname"; const char IFW_PACKAGE_DESCRIPTION[] = "ifw.package.description"; @@ -64,6 +66,8 @@ Q_LOGGING_CATEGORY(lcComponentChecker, IFW_COMPONENT_CHECKER) Q_LOGGING_CATEGORY(lcResources, IFW_RESOURCES) Q_LOGGING_CATEGORY(lcTranslations, IFW_TRANSLATIONS) Q_LOGGING_CATEGORY(lcNetwork, IFW_NETWORK) +Q_LOGGING_CATEGORY(lcServer, IFW_SERVER) +Q_LOGGING_CATEGORY(lcGeneral, IFW_GENERAL) Q_LOGGING_CATEGORY(lcPackageDisplayname, IFW_PACKAGE_DISPLAYNAME); Q_LOGGING_CATEGORY(lcPackageDescription, IFW_PACKAGE_DESCRIPTION) @@ -117,7 +121,9 @@ QStringList loggingCategories() << QLatin1String(IFW_PACKAGE_LICENSES) << QLatin1String(IFW_PACKAGE_UNCOMPRESSEDSIZE) << QLatin1String(IFW_PACKAGE_COMPRESSEDSIZE) - << QLatin1String(IFW_INSTALLER_INSTALLLOG); + << QLatin1String(IFW_INSTALLER_INSTALLLOG) + << QLatin1String(IFW_SERVER) + << QLatin1String(IFW_GENERAL); return categories; } diff --git a/src/libs/installer/globals.h b/src/libs/installer/globals.h index ceca321ec..cd8ef8197 100644 --- a/src/libs/installer/globals.h +++ b/src/libs/installer/globals.h @@ -39,6 +39,8 @@ INSTALLER_EXPORT Q_DECLARE_LOGGING_CATEGORY(lcComponentChecker) INSTALLER_EXPORT Q_DECLARE_LOGGING_CATEGORY(lcResources) INSTALLER_EXPORT Q_DECLARE_LOGGING_CATEGORY(lcTranslations) INSTALLER_EXPORT Q_DECLARE_LOGGING_CATEGORY(lcNetwork) +INSTALLER_EXPORT Q_DECLARE_LOGGING_CATEGORY(lcServer) +INSTALLER_EXPORT Q_DECLARE_LOGGING_CATEGORY(lcGeneral) INSTALLER_EXPORT Q_DECLARE_LOGGING_CATEGORY(lcPackageDisplayname) INSTALLER_EXPORT Q_DECLARE_LOGGING_CATEGORY(lcPackageDescription) diff --git a/src/libs/installer/installercalculator.cpp b/src/libs/installer/installercalculator.cpp index d381cfa9a..6a7e66692 100644 --- a/src/libs/installer/installercalculator.cpp +++ b/src/libs/installer/installercalculator.cpp @@ -31,6 +31,7 @@ #include "component.h" #include "packagemanagercore.h" #include "settings.h" +#include <globals.h> #include <QDebug> @@ -116,7 +117,7 @@ bool InstallerCalculator::appendComponentsToInstall(const QList<Component *> &co foreach (Component *component, components){ if (m_toInstallComponentIds.contains(component->name())) { const QString errorMessage = recursionError(component); - qWarning().noquote() << errorMessage; + qCWarning(QInstaller::lcGeneral).noquote() << errorMessage; m_componentsToInstallError.append(errorMessage); Q_ASSERT_X(!m_toInstallComponentIds.contains(component->name()), Q_FUNC_INFO, qPrintable(errorMessage)); @@ -168,7 +169,7 @@ bool InstallerCalculator::appendComponentToInstall(Component *component, const Q const QString errorMessage = QCoreApplication::translate("InstallerCalculator", "Cannot find missing dependency \"%1\" for \"%2\".").arg(dependencyComponentName, component->name()); - qWarning().noquote() << errorMessage; + qCWarning(QInstaller::lcGeneral).noquote() << errorMessage; m_componentsToInstallError.append(errorMessage); if (component->packageManagerCore()->settings().allowUnstableComponents()) { component->setUnstable(Component::UnstableError::MissingDependency, errorMessage); @@ -204,7 +205,7 @@ bool InstallerCalculator::appendComponentToInstall(Component *component, const Q && !m_toInstallComponentIds.contains(component->name()))) { if (m_visitedComponents.value(component).contains(dependencyComponent)) { const QString errorMessage = recursionError(component); - qWarning().noquote() << errorMessage; + qCWarning(QInstaller::lcGeneral).noquote() << errorMessage; m_componentsToInstallError = errorMessage; Q_ASSERT_X(!m_visitedComponents.value(component).contains(dependencyComponent), Q_FUNC_INFO, qPrintable(errorMessage)); diff --git a/src/libs/installer/installiconsoperation.cpp b/src/libs/installer/installiconsoperation.cpp index 15d47c72a..1b227a05b 100644 --- a/src/libs/installer/installiconsoperation.cpp +++ b/src/libs/installer/installiconsoperation.cpp @@ -29,6 +29,7 @@ #include "fileutils.h" #include "packagemanagercore.h" +#include "globals.h" #include <QDebug> #include <QDir> @@ -265,10 +266,10 @@ bool InstallIconsOperation::undoOperation() } if (!warningMessages.isEmpty()) { - qWarning() << "Undo of operation" << name() << "with arguments" + qCWarning(QInstaller::lcGeneral) << "Undo of operation" << name() << "with arguments" << arguments().join(QLatin1String(", ")) << "had some problems."; foreach (const QString &message, warningMessages) { - qWarning().noquote() << message; + qCWarning(QInstaller::lcGeneral).noquote() << message; } } diff --git a/src/libs/installer/lib7z_facade.cpp b/src/libs/installer/lib7z_facade.cpp index 1869c964f..e31a826ca 100644 --- a/src/libs/installer/lib7z_facade.cpp +++ b/src/libs/installer/lib7z_facade.cpp @@ -35,6 +35,7 @@ #include "lib7z_extract.h" #include "lib7z_list.h" #include "lib7z_guid.h" +#include "globals.h" #ifndef Q_OS_WIN # include "StdAfx.h" @@ -273,7 +274,7 @@ struct DirectoryGuard return; QDir dir(m_path); if (!dir.rmdir(m_path)) - qWarning() << "Cannot delete directory " << m_path; + qCWarning(QInstaller::lcGeneral) << "Cannot delete directory " << m_path; } /*! diff --git a/src/libs/installer/link.cpp b/src/libs/installer/link.cpp index 0c79ec4c9..f5a0903ae 100644 --- a/src/libs/installer/link.cpp +++ b/src/libs/installer/link.cpp @@ -28,6 +28,7 @@ #include "link.h" #include "utils.h" +#include "globals.h" #include <QFileInfo> #include <QDir> @@ -88,7 +89,8 @@ public: OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, nullptr); if (m_dirHandle == INVALID_HANDLE_VALUE) { - qWarning() << "Cannot open" << path << ":" << QInstaller::windowsErrorString(GetLastError()); + qCWarning(QInstaller::lcGeneral) << "Cannot open" << path << ":" + << QInstaller::windowsErrorString(GetLastError()); } } @@ -137,12 +139,13 @@ QString readWindowsSymLink(const QString &path) Link createJunction(const QString &linkPath, const QString &targetPath) { if (!QDir().mkpath(linkPath)) { - qWarning() << "Cannot create the mount directory" << linkPath; + qCWarning(QInstaller::lcGeneral) << "Cannot create the mount directory" << linkPath; return Link(linkPath); } FileHandleWrapper dirHandle(linkPath); if (dirHandle.handle() == INVALID_HANDLE_VALUE) { - qWarning() << "Cannot open" << linkPath << ":" << QInstaller::windowsErrorString(GetLastError()); + qCWarning(QInstaller::lcGeneral) << "Cannot open" << linkPath << ":" + << QInstaller::windowsErrorString(GetLastError()); return Link(linkPath); } @@ -175,7 +178,7 @@ Link createJunction(const QString &linkPath, const QString &targetPath) if (!::DeviceIoControl(dirHandle.handle(), FSCTL_SET_REPARSE_POINT, reparseStructData, reparseStructData->ReparseDataLength + REPARSE_DATA_BUFFER_HEADER_SIZE, nullptr, 0, &bytesReturned, nullptr)) { - qWarning() << "Cannot set the reparse point for" << linkPath << "to" << targetPath + qCWarning(QInstaller::lcGeneral) << "Cannot set the reparse point for" << linkPath << "to" << targetPath << ":" << QInstaller::windowsErrorString(GetLastError()); } return Link(linkPath); @@ -197,7 +200,8 @@ bool removeJunction(const QString &path) REPARSE_GUID_DATA_BUFFER_HEADER_SIZE, nullptr, 0, &bytesReturned, nullptr)) { - qWarning() << "Cannot remove the reparse point" << path << ":" << QInstaller::windowsErrorString(GetLastError()); + qCWarning(QInstaller::lcGeneral) << "Cannot remove the reparse point" << path << ":" + << QInstaller::windowsErrorString(GetLastError()); return false; } } @@ -210,7 +214,8 @@ Link createLnSymlink(const QString &linkPath, const QString &targetPath) int linkedError = symlink(QFileInfo(targetPath).absoluteFilePath().toUtf8(), QFileInfo(linkPath).absoluteFilePath().toUtf8()); if (linkedError != 0) { - qWarning() << "Cannot create a symlink from" << linkPath << "to" << targetPath << ":" << linkedError; + qCWarning(QInstaller::lcGeneral) << "Cannot create a symlink from" << linkPath << "to" + << targetPath << ":" << linkedError; } @@ -237,7 +242,7 @@ Link Link::create(const QString &link, const QString &targetPath) if (!linkPathExists) linkPathExists = QDir().mkpath(linkPath); if (!linkPathExists) { - qWarning() << "Cannot create the needed directories" << link; + qCWarning(QInstaller::lcGeneral) << "Cannot create the needed directories" << link; return Link(link); } @@ -245,8 +250,8 @@ Link Link::create(const QString &link, const QString &targetPath) if (QFileInfo(targetPath).isDir()) return createJunction(link, targetPath); - qWarning() << "At the moment the" << Q_FUNC_INFO << "can not create anything else as " - << "junctions for directories under windows"; + qCWarning(QInstaller::lcGeneral) << "At the moment the" << Q_FUNC_INFO + << "can not create anything else as " << "junctions for directories under windows"; return Link(link); #else return createLnSymlink(link, targetPath); diff --git a/src/libs/installer/messageboxhandler.cpp b/src/libs/installer/messageboxhandler.cpp index 28e09df44..2620bd818 100644 --- a/src/libs/installer/messageboxhandler.cpp +++ b/src/libs/installer/messageboxhandler.cpp @@ -28,6 +28,8 @@ #include "messageboxhandler.h" +#include "globals.h" + #include <QtCore/QDebug> #include <QApplication> @@ -401,7 +403,7 @@ QMessageBox::StandardButton MessageBoxHandler::showMessageBox(MessageType messag messageTypeHash.insert(warningType, QLatin1String("warning")); }; - qDebug().nospace() << "Created " << messageTypeHash.value(messageType).toUtf8().constData() + qCDebug(QInstaller::lcGeneral).nospace() << "Created " << messageTypeHash.value(messageType).toUtf8().constData() << " message box " << identifier << ": " << title << ", " << text; if (qobject_cast<QApplication*> (qApp) == nullptr) diff --git a/src/libs/installer/metadatajob.cpp b/src/libs/installer/metadatajob.cpp index 09389aec0..f5a453307 100644 --- a/src/libs/installer/metadatajob.cpp +++ b/src/libs/installer/metadatajob.cpp @@ -35,6 +35,7 @@ #include "serverauthenticationdialog.h" #include "settings.h" #include "testrepository.h" +#include "globals.h" #include <QTemporaryDir> #include <QtMath> @@ -134,8 +135,8 @@ void MetadataJob::doStart() items.append(item); } else { - qDebug() << "Trying to parse compressed repo as normal repository."\ - "Check repository syntax."; + qCWarning(QInstaller::lcGeneral) << "Trying to parse compressed repo as " + "normal repository. Check repository syntax."; } } } @@ -196,7 +197,7 @@ void MetadataJob::startUnzipRepositoryTask(const Repository &repo) { QTemporaryDir tempRepoDir(QDir::tempPath() + QLatin1String("/compressedRepo-XXXXXX")); if (!tempRepoDir.isValid()) { - qDebug() << "Cannot create unique temporary directory."; + qCWarning(QInstaller::lcGeneral) << "Cannot create unique temporary directory."; return; } tempRepoDir.setAutoRemove(false); @@ -292,10 +293,10 @@ void MetadataJob::xmlTaskFinished() if (e.type() == AuthenticationRequiredException::Type::Proxy) { const QNetworkProxy proxy = e.proxy(); ProxyCredentialsDialog proxyCredentials(proxy); - qDebug().noquote() << e.message(); + qCWarning(QInstaller::lcGeneral) << e.message(); if (proxyCredentials.exec() == QDialog::Accepted) { - qDebug() << "Retrying with new credentials ..."; + qCDebug(QInstaller::lcGeneral) << "Retrying with new credentials ..."; PackageManagerProxyFactory *factory = m_core->proxyFactory(); factory->setProxyCredentials(proxy, proxyCredentials.userName(), @@ -307,7 +308,7 @@ void MetadataJob::xmlTaskFinished() emitFinishedWithError(QInstaller::DownloadError, tr("Missing proxy credentials.")); } } else if (e.type() == AuthenticationRequiredException::Type::Server) { - qDebug().noquote() << e.message(); + qCWarning(QInstaller::lcGeneral) << e.message(); ServerAuthenticationDialog dlg(e.message(), e.taskItem()); if (dlg.exec() == QDialog::Accepted) { Repository original = e.taskItem().value(TaskRole::UserRole) @@ -327,7 +328,7 @@ void MetadataJob::xmlTaskFinished() update.insert(QLatin1String("replace"), qMakePair(original, replacement)); if (s.updateRepositoryCategories(update) == Settings::UpdatesApplied) - qDebug() << "Repository categories updated."; + qCDebug(QInstaller::lcGeneral()) << "Repository categories updated."; if (s.updateDefaultRepositories(update) == Settings::UpdatesApplied || s.updateUserRepositories(update) == Settings::UpdatesApplied) { @@ -429,7 +430,7 @@ void MetadataJob::metadataTaskFinished() .arg(item.value(TaskRole::SourceFile).toString()); if (m_core->settings().allowUnstableComponents()) { m_shaMissmatchPackages.append(item.value(TaskRole::Name).toString()); - qWarning() << mismatchMessage; + qCWarning(QInstaller::lcGeneral) << mismatchMessage; } else { throw QInstaller::TaskException(mismatchMessage); } @@ -544,7 +545,7 @@ MetadataJob::Status MetadataJob::parseUpdatesXml(const QList<FileTaskResult> &re Metadata metadata; QTemporaryDir tmp(QDir::tempPath() + QLatin1String("/remoterepo-XXXXXX")); if (!tmp.isValid()) { - qDebug() << "Cannot create unique temporary directory."; + qCWarning(QInstaller::lcGeneral) << "Cannot create unique temporary directory."; return XmlDownloadFailure; } @@ -554,19 +555,21 @@ MetadataJob::Status MetadataJob::parseUpdatesXml(const QList<FileTaskResult> &re QFile file(result.target()); if (!file.rename(metadata.directory + QLatin1String("/Updates.xml"))) { - qDebug() << "Cannot rename target to Updates.xml:" << file.errorString(); + qCWarning(QInstaller::lcGeneral) << "Cannot rename target to Updates.xml:" + << file.errorString(); return XmlDownloadFailure; } if (!file.open(QIODevice::ReadOnly)) { - qDebug() << "Cannot open Updates.xml for reading:" << file.errorString(); + qCWarning(QInstaller::lcGeneral) << "Cannot open Updates.xml for reading:" + << file.errorString(); return XmlDownloadFailure; } QString error; QDomDocument doc; if (!doc.setContent(&file, &error)) { - qDebug().nospace() << "Cannot fetch a valid version of Updates.xml from repository " + qCWarning(QInstaller::lcGeneral).nospace() << "Cannot fetch a valid version of Updates.xml from repository " << metadata.repository.displayname() << ": " << error; //If there are other repositories, try to use those continue; @@ -676,7 +679,8 @@ MetadataJob::Status MetadataJob::parseUpdatesXml(const QList<FileTaskResult> &re repository.setDisplayName(el.attribute(QLatin1String("displayname"))); if (ProductKeyCheck::instance()->isValidRepository(repository)) { repositoryUpdates.insertMulti(action, qMakePair(repository, Repository())); - qDebug() << "Repository to add:" << repository.displayname(); + qCDebug(QInstaller::lcGeneral) << "Repository to add:" + << repository.displayname(); } } else if (action == QLatin1String("remove")) { // remove possible default repositories using the given server url @@ -684,7 +688,8 @@ MetadataJob::Status MetadataJob::parseUpdatesXml(const QList<FileTaskResult> &re repository.setDisplayName(el.attribute(QLatin1String("displayname"))); repositoryUpdates.insertMulti(action, qMakePair(repository, Repository())); - qDebug() << "Repository to remove:" << repository.displayname(); + qCDebug(QInstaller::lcGeneral) << "Repository to remove:" + << repository.displayname(); } else if (action == QLatin1String("replace")) { // replace possible default repositories using the given server url Repository oldRepository(resolveUrl(result, el.attribute(QLatin1String("oldUrl"))), true); @@ -696,12 +701,13 @@ MetadataJob::Status MetadataJob::parseUpdatesXml(const QList<FileTaskResult> &re 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(); + qCDebug(QInstaller::lcGeneral) << "Replace repository" + << oldRepository.displayname() << "with" << newRepository.displayname(); } } else { - qDebug() << "Invalid additional repositories action set in Updates.xml fetched " - "from" << metadata.repository.displayname() << "line:" << el.lineNumber(); + qCWarning(QInstaller::lcGeneral) << "Invalid additional repositories action set " + "in Updates.xml fetched from" << metadata.repository.displayname() + << "line:" << el.lineNumber(); } } } diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index 398f218b9..ccb4034e4 100644 --- a/src/libs/installer/packagemanagercore.cpp +++ b/src/libs/installer/packagemanagercore.cpp @@ -1053,7 +1053,7 @@ PackageManagerCore::PackageManagerCore(qint64 magicmaker, const QList<OperationB "remove the packages from components.xml which operations are missing, " "or reinstall the packages."; } else { - qDebug() << "Operations sanity check succeeded."; + qCDebug(QInstaller::lcGeneral) << "Operations sanity check succeeded."; } } @@ -2039,7 +2039,7 @@ void PackageManagerCore::listInstalledPackages() const QStringList &keys = installedPackages.keys(); foreach (const QString &key, keys) { KDUpdater::LocalPackage package = installedPackages.value(key); - qDebug() << package.name; + qCDebug(QInstaller::lcPackageName) << package.name; } } @@ -2055,7 +2055,7 @@ void PackageManagerCore::updateComponentsSilently(const QStringList &componentsT const QList<QInstaller::Component*> componentList = componentsMarkedForInstallation(); if (componentList.count() == 0) { - qDebug() << "No updates available."; + qCDebug(QInstaller::lcInstallerInstallLog) << "No updates available."; } else { // Check if essential components are available (essential components are disabled). // If essential components are found, update first essential updates, @@ -2084,9 +2084,9 @@ void PackageManagerCore::updateComponentsSilently(const QStringList &componentsT if (d->calculateComponentsAndRun()) { if (essentialUpdatesFound) - qDebug() << "Essential components updated successfully."; + qCDebug(QInstaller::lcInstallerInstallLog) << "Essential components updated successfully."; else - qDebug() << "Components updated successfully."; + qCDebug(QInstaller::lcInstallerInstallLog) << "Components updated successfully."; } } } @@ -2226,7 +2226,8 @@ bool PackageManagerCore::killProcess(const QString &absoluteFilePath) const processPath = QDir::cleanPath(processPath.replace(QLatin1Char('\\'), QLatin1Char('/'))); if (processPath == normalizedPath) { - qDebug().nospace() << "try to kill process " << process.name << " (" << process.id << ")"; + qCDebug(QInstaller::lcGeneral).nospace() << "try to kill process " << process.name + << " (" << process.id << ")"; //to keep the ui responsible use QtConcurrent::run QFutureWatcher<bool> futureWatcher; @@ -2240,7 +2241,7 @@ bool PackageManagerCore::killProcess(const QString &absoluteFilePath) const if (!future.isFinished()) loop.exec(); - qDebug() << process.name << "killed!"; + qCDebug(QInstaller::lcGeneral) << process.name << "killed!"; return future.result(); } } @@ -2363,7 +2364,8 @@ bool PackageManagerCore::executeDetached(const QString &program, const QStringLi QString adjustedWorkingDir = replaceVariables(workingDirectory); foreach (const QString &argument, arguments) adjustedArguments.append(replaceVariables(argument)); - qDebug() << "run application as detached process:" << adjustedProgram << adjustedArguments << adjustedWorkingDir; + qCDebug(QInstaller::lcGeneral) << "run application as detached process:" << adjustedProgram + << adjustedArguments << adjustedWorkingDir; if (workingDirectory.isEmpty()) return QProcess::startDetached(adjustedProgram, adjustedArguments); else @@ -2881,7 +2883,7 @@ bool PackageManagerCore::updateComponentData(struct Data &data, Component *compo if (isVerbose()) { static QString lastLocalPath; if (lastLocalPath != localPath) - qDebug() << "Url is:" << localPath; + qCDebug(QInstaller::lcGeneral) << "Url is:" << localPath; lastLocalPath = localPath; } @@ -2957,7 +2959,7 @@ void PackageManagerCore::storeReplacedComponents(QHash<QString, Component *> &co // installer binary or the installed component list, just ignore it. This // can happen when in installer mode and probably package manager mode too. if (isUpdater()) - qDebug() << componentName << "- Does not exist in the repositories anymore."; + qCWarning(QInstaller::lcGeneral) << componentName << "- Does not exist in the repositories anymore."; continue; } if (!componentToReplace && !d->componentsToReplace().contains(componentName)) { diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index e7a97d772..f08b88f09 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -92,15 +92,15 @@ public: { if (!m_operation) return; - qDebug().noquote() << QString::fromLatin1("%1 %2 operation: %3").arg(state, m_operation->value( - QLatin1String("component")).toString(), m_operation->name()); - qDebug().noquote() << QString::fromLatin1("\t- arguments: %1").arg(m_operation->arguments() - .join(QLatin1String(", "))); + qCDebug(QInstaller::lcGeneral).noquote() << QString::fromLatin1("%1 %2 operation: %3") + .arg(state, m_operation->value(QLatin1String("component")).toString(), m_operation->name()); + qCDebug(QInstaller::lcGeneral).noquote() << QString::fromLatin1("\t- arguments: %1") + .arg(m_operation->arguments().join(QLatin1String(", "))); } ~OperationTracer() { if (!m_operation) return; - qDebug() << "Done"; + qCDebug(QInstaller::lcGeneral) << "Done"; } private: Operation *m_operation; @@ -254,12 +254,14 @@ PackageManagerCorePrivate::PackageManagerCorePrivate(PackageManagerCore *core, q QScopedPointer<QInstaller::Operation> op(KDUpdater::UpdateOperationFactory::instance() .create(operation.name, core)); if (op.isNull()) { - qWarning() << "Failed to load unknown operation" << operation.name; + qCWarning(QInstaller::lcGeneral) << "Failed to load unknown operation" + << operation.name; continue; } if (!op->fromXml(operation.xml)) { - qWarning() << "Failed to load XML for operation" << operation.name; + qCWarning(QInstaller::lcGeneral) << "Failed to load XML for operation" + << operation.name; continue; } m_performedOperationsOld.append(op.take()); @@ -500,7 +502,7 @@ void PackageManagerCorePrivate::clearUpdaterComponentLists() const QList<QPair<Component*, Component*> > list = m_componentsToReplaceUpdaterMode.values(); for (int i = 0; i < list.count(); ++i) { if (usedComponents.contains(list.at(i).second)) - qWarning() << "a replacement was already in the list - is that correct?"; + qCWarning(QInstaller::lcGeneral) << "a replacement was already in the list - is that correct?"; else usedComponents.insert(list.at(i).second); } @@ -663,7 +665,7 @@ void PackageManagerCorePrivate::setStatus(int status, const QString &error) { m_error = error; if (!error.isEmpty()) - qDebug() << m_error; + qCWarning(QInstaller::lcGeneral) << m_error; if (m_status != status) { m_status = status; emit m_core->statusChanged(PackageManagerCore::Status(m_status)); @@ -882,7 +884,7 @@ void PackageManagerCorePrivate::readMaintenanceConfigFiles(const QString &target } break; case QXmlStreamReader::Invalid: { - qDebug() << reader.errorString(); + qCWarning(QInstaller::lcGeneral) << reader.errorString(); } break; default: @@ -1022,7 +1024,7 @@ void PackageManagerCorePrivate::registerPathsForUninstallation( void PackageManagerCorePrivate::writeMaintenanceToolBinary(QFile *const input, qint64 size, bool writeBinaryLayout) { QString maintenanceToolRenamedName = maintenanceToolName() + QLatin1String(".new"); - qDebug() << "Writing maintenance tool:" << maintenanceToolRenamedName; + qCDebug(QInstaller::lcGeneral) << "Writing maintenance tool:" << maintenanceToolRenamedName; ProgressCoordinator::instance()->emitLabelAndDetailTextChanged(tr("Writing maintenance tool.")); QFile out(generateTemporaryFileName()); @@ -1082,12 +1084,12 @@ void PackageManagerCorePrivate::writeMaintenanceToolBinary(QFile *const input, q QFile mt(maintenanceToolRenamedName); if (setDefaultFilePermissions(&mt, DefaultFilePermissions::Executable)) - qDebug() << "Wrote permissions for maintenance tool."; + qCDebug(QInstaller::lcGeneral) << "Wrote permissions for maintenance tool."; else - qDebug() << "Failed to write permissions for maintenance tool."; + qCWarning(QInstaller::lcGeneral) << "Failed to write permissions for maintenance tool."; if (out.exists() && !out.remove()) { - qWarning() << tr("Cannot remove temporary data file \"%1\": %2") + qCWarning(QInstaller::lcGeneral) << tr("Cannot remove temporary data file \"%1\": %2") .arg(out.fileName(), out.errorString()); } } @@ -1111,7 +1113,8 @@ void PackageManagerCorePrivate::writeMaintenanceToolBinaryData(QFileDevice *outp file.remove(); // clear all possible leftovers m_core->setValue(QString::fromLatin1("DefaultResourceReplacement"), QString()); } else { - qWarning() << "Cannot replace default resource with" << QDir::toNativeSeparators(newDefaultResource); + qCWarning(QInstaller::lcGeneral) << "Cannot replace default resource with" + << QDir::toNativeSeparators(newDefaultResource); } } @@ -1208,7 +1211,8 @@ void PackageManagerCorePrivate::writeMaintenanceTool(OperationList performedOper op = createOwnedOperation(QLatin1String("Mkdir")); op->setArguments(QStringList() << (targetAppDirPath + QLatin1String("/../Resources/qt_menu.nib"))); if (!op->performOperation()) { - qDebug() << "ERROR in Mkdir operation:" << op->errorString(); + qCWarning(QInstaller::lcGeneral) << "ERROR in Mkdir operation:" + << op->errorString(); } op = createOwnedOperation(QLatin1String("CopyDirectory")); @@ -1280,34 +1284,36 @@ void PackageManagerCorePrivate::writeMaintenanceTool(OperationList performedOper bool replacementExists = false; const QString installerBaseBinary = replaceVariables(m_installerBaseBinaryUnreplaced); if (!installerBaseBinary.isEmpty() && QFileInfo(installerBaseBinary).exists()) { - qDebug() << "Got a replacement installer base binary:" << installerBaseBinary; + qCDebug(QInstaller::lcGeneral) << "Got a replacement installer base binary:" + << installerBaseBinary; QFile replacementBinary(installerBaseBinary); try { QInstaller::openForRead(&replacementBinary); writeMaintenanceToolBinary(&replacementBinary, replacementBinary.size(), true); - qDebug() << "Wrote the binary with the new replacement."; + qCDebug(QInstaller::lcGeneral) << "Wrote the binary with the new replacement."; newBinaryWritten = true; replacementExists = true; } catch (const Error &error) { - qDebug() << error.message(); + qCWarning(QInstaller::lcGeneral) << error.message(); } if (!replacementBinary.remove()) { // Is there anything more sensible we can do with this error? I think not. It's not serious // enough for throwing / aborting the process. - qDebug() << "Cannot remove installer base binary" << installerBaseBinary - << "after updating the maintenance tool:" << replacementBinary.errorString(); + qCDebug(QInstaller::lcGeneral) << "Cannot remove installer base binary" + << installerBaseBinary << "after updating the maintenance tool:" + << replacementBinary.errorString(); } else { - qDebug() << "Removed installer base binary" << installerBaseBinary - << "after updating the maintenance tool."; + qCDebug(QInstaller::lcGeneral) << "Removed installer base binary" + << installerBaseBinary << "after updating the maintenance tool."; } m_installerBaseBinaryUnreplaced.clear(); } else if (!installerBaseBinary.isEmpty() && !QFileInfo(installerBaseBinary).exists()) { - qWarning() << "The current maintenance tool could not be updated." << installerBaseBinary - << "does not exist. Please fix the \"setInstallerBaseBinary(<temp_installer_base_" - "binary_path>)\" call in your script."; + qCWarning(QInstaller::lcGeneral) << "The current maintenance tool could not be updated." + << installerBaseBinary << "does not exist. Please fix the \"setInstallerBaseBinary" + "(<temp_installer_base_binary_path>)\" call in your script."; } QFile input; @@ -1317,8 +1323,8 @@ void PackageManagerCorePrivate::writeMaintenanceTool(OperationList performedOper try { if (isInstaller()) { if (QFile::exists(dataFile)) { - qWarning() << "Found binary data file" << dataFile << "but " - "deliberately not used. Running as installer requires to read the " + qCWarning(QInstaller::lcGeneral) << "Found binary data file" << dataFile + << "but deliberately not used. Running as installer requires to read the " "resources from the application binary."; } throw Error(); @@ -1400,7 +1406,8 @@ void PackageManagerCorePrivate::writeMaintenanceTool(OperationList performedOper if (newBinaryWritten) { const bool restart = replacementExists && isUpdater() && (!statusCanceledOrFailed()) && m_needsHardRestart; deferredRename(maintenanceToolName() + QLatin1String(".new"), maintenanceToolName(), restart); - qDebug() << "Maintenance tool restart:" << (restart ? "true." : "false."); + qCDebug(QInstaller::lcResources) << "Maintenance tool restart:" + << (restart ? "true." : "false."); } } catch (const Error &err) { setStatus(PackageManagerCore::Failure); @@ -1493,7 +1500,8 @@ bool PackageManagerCorePrivate::runInstaller() m_core->calculateComponentsToInstall(); const QList<Component*> componentsToInstall = m_core->orderedComponentsToInstall(); - qDebug() << "Install size:" << componentsToInstall.size() << "components"; + qCDebug(QInstaller::lcGeneral) << "Install size:" << componentsToInstall.size() + << "components"; callBeginInstallation(componentsToInstall); stopProcessesForUpdates(componentsToInstall); @@ -1605,7 +1613,8 @@ bool PackageManagerCorePrivate::runInstaller() setStatus(PackageManagerCore::Failure); MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), QLatin1String("installationError"), tr("Error"), err.message()); - qDebug() << "ROLLING BACK operations=" << m_performedOperationsCurrentSession.count(); + qCDebug(QInstaller::lcGeneral) << "ROLLING BACK operations=" + << m_performedOperationsCurrentSession.count(); } m_core->rollBackInstallation(); @@ -1637,7 +1646,8 @@ bool PackageManagerCorePrivate::runPackageUpdater() adminRightsGained = m_core->gainAdminRights(); const QList<Component *> componentsToInstall = m_core->orderedComponentsToInstall(); - qDebug() << "Install size:" << componentsToInstall.size() << "components"; + qCDebug(QInstaller::lcGeneral) << "Install size:" << componentsToInstall.size() + << "components"; callBeginInstallation(componentsToInstall); stopProcessesForUpdates(componentsToInstall); @@ -1779,7 +1789,8 @@ bool PackageManagerCorePrivate::runPackageUpdater() setStatus(PackageManagerCore::Failure); MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), QLatin1String("installationError"), tr("Error"), err.message()); - qDebug() << "ROLLING BACK operations=" << m_performedOperationsCurrentSession.count(); + qCDebug(QInstaller::lcGeneral) << "ROLLING BACK operations=" + << m_performedOperationsCurrentSession.count(); } m_core->rollBackInstallation(); @@ -1836,7 +1847,7 @@ bool PackageManagerCorePrivate::runUninstaller() if (updateAdminRights && !adminRightsGained) adminRightsGained = m_core->gainAdminRights(); removeDirectoryThreaded(targetDir(), true); - qDebug() << "Complete uninstallation was chosen."; + qCDebug(QInstaller::lcGeneral) << "Complete uninstallation was chosen."; } unregisterMaintenanceTool(); @@ -1885,7 +1896,7 @@ void PackageManagerCorePrivate::installComponent(Component *component, double pr bool becameAdmin = false; if (!adminRightsGained && operation->value(QLatin1String("admin")).toBool()) { becameAdmin = m_core->gainAdminRights(); - qDebug() << operation->name() << "as admin:" << becameAdmin; + qCDebug(QInstaller::lcGeneral) << operation->name() << "as admin:" << becameAdmin; } connectOperationToInstaller(operation, progressOperationSize); @@ -1897,9 +1908,9 @@ void PackageManagerCorePrivate::installComponent(Component *component, double pr bool ignoreError = false; bool ok = performOperationThreaded(operation); while (!ok && !ignoreError && m_core->status() != PackageManagerCore::Canceled) { - qDebug() << QString::fromLatin1("Operation \"%1\" with arguments \"%2\" failed: %3") - .arg(operation->name(), operation->arguments().join(QLatin1String("; ")), - operation->errorString()); + qCDebug(QInstaller::lcGeneral) << QString::fromLatin1("Operation \"%1\" with arguments " + "\"%2\" failed: %3").arg(operation->name(), operation->arguments() + .join(QLatin1String("; ")), operation->errorString()); const QMessageBox::StandardButton button = MessageBoxHandler::warning(MessageBoxHandler::currentBestSuitParent(), QLatin1String("installationErrorWithRetry"), tr("Installer Error"), @@ -1971,7 +1982,7 @@ bool PackageManagerCorePrivate::runningProcessesFound() excludeFiles.append(maintenanceToolName()); QStringList runningProcesses = runningInstallerProcesses(excludeFiles); if (!runningProcesses.isEmpty()) { - qDebug() << "Unable to update components. Please stop these processes: " + qCWarning(QInstaller::lcGeneral()) << "Unable to update components. Please stop these processes: " << runningProcesses << " and try again."; return true; } @@ -2109,7 +2120,7 @@ void PackageManagerCorePrivate::runUndoOperations(const OperationList &undoOpera becameAdmin = m_core->gainAdminRights(); connectOperationToInstaller(undoOperation, progressSize); - qDebug() << "undo operation=" << undoOperation->name(); + qCDebug(QInstaller::lcGeneral) << "undo operation=" << undoOperation->name(); bool ignoreError = false; bool ok = performOperationThreaded(undoOperation, PackageManagerCorePrivate::Undo); @@ -2341,7 +2352,8 @@ bool PackageManagerCorePrivate::addUpdateResourcesFromRepositories(bool parseChe try { QInstaller::openForRead(&updatesFile); } catch(const Error &e) { - qDebug() << "Error opening Updates.xml:" << e.message(); + qCWarning(QInstaller::lcGeneral) << "Error opening Updates.xml:" + << e.message(); setStatus(PackageManagerCore::Failure, tr("Cannot add temporary update source information.")); return false; } @@ -2351,8 +2363,9 @@ bool PackageManagerCorePrivate::addUpdateResourcesFromRepositories(bool parseChe QString error; QDomDocument doc; if (!doc.setContent(&updatesFile, &error, &line, &column)) { - qDebug().nospace() << "Parse error in file" << updatesFile.fileName() - << ": " << error << " at line " << line << " col " << column; + qCWarning(QInstaller::lcGeneral).nospace() << "Parse error in file " + << updatesFile.fileName() << ": " << error << " at line " << line + << " col " << column; setStatus(PackageManagerCore::Failure, tr("Cannot add temporary update source information.")); return false; } @@ -2464,8 +2477,9 @@ void PackageManagerCorePrivate::processFilesForDelayedDeletion() foreach (const QString &i, filesForDelayedDeletion) { QFile file(i); //TODO: this should happen asnyc and report errors, I guess if (file.exists() && !file.remove()) { - qWarning("Cannot delete file %s: %s", qPrintable(i), - qPrintable(file.errorString())); + qCWarning(QInstaller::lcGeneral) << "Cannot delete file " << qPrintable(i) << + ": " << qPrintable(file.errorString()); + m_filesForDelayedDeletion << i; // try again next time } } @@ -2498,7 +2512,7 @@ bool PackageManagerCorePrivate::calculateComponentsAndRun() { QString htmlOutput; bool componentsOk = m_core->calculateComponents(&htmlOutput); - qDebug().noquote() << htmlToString(htmlOutput); + qCDebug(QInstaller::lcInstallerInstallLog).noquote() << htmlToString(htmlOutput); if (componentsOk) { if (m_core->run()) { m_core->writeMaintenanceTool(); diff --git a/src/libs/installer/packagemanagergui.cpp b/src/libs/installer/packagemanagergui.cpp index 26f0c484b..7686e6c46 100644 --- a/src/libs/installer/packagemanagergui.cpp +++ b/src/libs/installer/packagemanagergui.cpp @@ -43,6 +43,7 @@ #include "componentselectionpage_p.h" #include "sysinfo.h" +#include "globals.h" #include <QApplication> @@ -323,12 +324,15 @@ PackageManagerGui::PackageManagerGui(PackageManagerCore *core, QWidget *parent) if (!styleSheetFile.isEmpty()) { QFile sheet(styleSheetFile); if (sheet.exists()) { - if (sheet.open(QIODevice::ReadOnly)) + if (sheet.open(QIODevice::ReadOnly)) { setStyleSheet(QString::fromLatin1(sheet.readAll())); - else - qWarning() << "The specified style sheet file can not be opened."; + } else { + qCWarning(QInstaller::lcGeneral) << "The specified style sheet file " + "can not be opened."; + } } else { - qWarning() << "A style sheet file is specified, but it does not exist."; + qCWarning(QInstaller::lcGeneral) << "A style sheet file is specified, " + "but it does not exist."; } } @@ -465,7 +469,7 @@ void PackageManagerGui::setTextItems(QObject *object, const QStringList &items) return; } - qDebug() << "Cannot set text items on object of type" + qCWarning(QInstaller::lcGeneral) << "Cannot set text items on object of type" << object->metaObject()->className() << "."; } @@ -522,7 +526,7 @@ void PackageManagerGui::clickButton(int wb, int delay) if (QAbstractButton *b = button(static_cast<QWizard::WizardButton>(wb))) QTimer::singleShot(delay, b, &QAbstractButton::click); else - qWarning() << "Button with type: " << d->buttonType(wb) << "not found!"; + qCWarning(QInstaller::lcGeneral) << "Button with type: " << d->buttonType(wb) << "not found!"; } /*! @@ -541,7 +545,7 @@ bool PackageManagerGui::isButtonEnabled(int wb) if (QAbstractButton *b = button(static_cast<QWizard::WizardButton>(wb))) return b->isEnabled(); - qWarning() << "Button with type: " << d->buttonType(wb) << "not found!"; + qCWarning(QInstaller::lcGeneral) << "Button with type: " << d->buttonType(wb) << "not found!"; return false; } @@ -574,7 +578,7 @@ void PackageManagerGui::loadControlScript(const QString &scriptPath) { d->m_controlScriptContext = m_core->controlScriptEngine()->loadInContext( QLatin1String("Controller"), scriptPath); - qDebug() << "Loaded control script" << scriptPath; + qCDebug(QInstaller::lcGeneral) << "Loaded control script" << scriptPath; } /*! @@ -588,7 +592,8 @@ void PackageManagerGui::callControlScriptMethod(const QString &methodName) const QJSValue returnValue = m_core->controlScriptEngine()->callScriptMethod( d->m_controlScriptContext, methodName); if (returnValue.isUndefined()) { - qDebug() << "Control script callback" << methodName << "does not exist."; + qCDebug(QInstaller::lcGeneral) << "Control script callback" << methodName + << "does not exist."; return; } } catch (const QInstaller::Error &e) { @@ -756,7 +761,7 @@ QWidget *PackageManagerGui::pageByObjectName(const QString &name) const if (p && p->objectName() == name) return p; } - qWarning() << "No page found for object name" << name; + qCWarning(QInstaller::lcGeneral) << "No page found for object name" << name; return nullptr; } @@ -784,7 +789,7 @@ QWidget *PackageManagerGui::pageWidgetByObjectName(const QString &name) const return dp->widget(); return p; } - qWarning() << "No page found for object name" << name; + qCWarning(QInstaller::lcGeneral) << "No page found for object name" << name; return nullptr; } @@ -2023,7 +2028,7 @@ bool ComponentSelectionPage::addVirtualComponentToUninstall(const QString &name) if (component && component->isInstalled() && component->isVirtual()) { component->setCheckState(Qt::Unchecked); core->componentsToInstallNeedsRecalculation(); - qDebug() << "Virtual component " << name << " was selected for uninstall by script."; + qCDebug(QInstaller::lcGeneral) << "Virtual component " << name << " was selected for uninstall by script."; return true; } return false; @@ -2396,7 +2401,7 @@ void ReadyForInstallationPage::entering() // at the moment there is no better way to check this if (targetVolume.size() == 0 && installVolumeAvailableSize == 0) { - qDebug().nospace() << "Cannot determine available space on device. " + qCWarning(QInstaller::lcGeneral).nospace() << "Cannot determine available space on device. " "Volume descriptor: " << targetVolume.volumeDescriptor() << ", Mount path: " << targetVolume.mountPath() << ". Continue silently."; return; // TODO: Shouldn't this also disable the "Next" button? @@ -2404,11 +2409,12 @@ void ReadyForInstallationPage::entering() const bool tempOnSameVolume = (targetVolume == tempVolume); if (tempOnSameVolume) { - qDebug() << "Tmp and install directories are on the same volume. Volume mount point:" - << targetVolume.mountPath() << "Free space available:" + qCDebug(QInstaller::lcGeneral) << "Tmp and install directories are on the same volume. " + "Volume mount point:" << targetVolume.mountPath() << "Free space available:" << humanReadableSize(installVolumeAvailableSize); } else { - qDebug() << "Tmp is on a different volume than the installation directory. Tmp volume mount point:" + qCDebug(QInstaller::lcGeneral) << "Tmp is on a different volume than the installation " + "directory. Tmp volume mount point:" << tempVolume.mountPath() << "Free space available:" << humanReadableSize(tempVolumeAvailableSize) << "Install volume mount point:" << targetVolume.mountPath() << "Free space available:" @@ -2434,7 +2440,8 @@ void ReadyForInstallationPage::entering() required += repositorySize; } - qDebug() << "Installation space required:" << humanReadableSize(required) << "Temporary space " + qCDebug(QInstaller::lcGeneral) << "Installation space required:" + << humanReadableSize(required) << "Temporary space " "required:" << humanReadableSize(tempRequired) << "Local repository size:" << humanReadableSize(repositorySize); @@ -2805,7 +2812,7 @@ void FinishedPage::handleFinishClicked() if (!m_runItCheckBox->isChecked() || program.isEmpty()) return; - qDebug() << "starting" << program << args; + qCDebug(QInstaller::lcGeneral) << "starting" << program << args; QProcess::startDetached(program, args); } diff --git a/src/libs/installer/progresscoordinator.cpp b/src/libs/installer/progresscoordinator.cpp index d3fbd764f..ab0133048 100644 --- a/src/libs/installer/progresscoordinator.cpp +++ b/src/libs/installer/progresscoordinator.cpp @@ -31,6 +31,8 @@ #include <QtCore/QCoreApplication> #include <QtCore/QDebug> +#include "globals.h" + using namespace QInstaller; QT_BEGIN_NAMESPACE @@ -101,7 +103,8 @@ void ProgressCoordinator::registerPartProgress(QObject *sender, const char *sign void ProgressCoordinator::partProgressChanged(double fraction) { if (fraction < 0 || fraction > 1) { - qWarning() << "The fraction is outside from possible value:" << fraction; + qCWarning(QInstaller::lcGeneral) << "The fraction is outside from possible value:" + << fraction; return; } @@ -117,12 +120,12 @@ void ProgressCoordinator::partProgressChanged(double fraction) double partProgressSize = m_senderPartProgressSizeHash.value(sender(), 0); if (partProgressSize == 0) { - qWarning() << "It seems that this sender was not registered in the right way:" << sender(); + qCWarning(QInstaller::lcGeneral) << "It seems that this sender was not registered " + "in the right way:" << sender(); return; } if (m_undoMode) { - //qDebug() << "fraction:" << fraction; double maxSize = m_reachedPercentageBeforeUndo * partProgressSize; double pendingCalculatedPartPercentage = maxSize * fraction; @@ -134,17 +137,21 @@ void ProgressCoordinator::partProgressChanged(double fraction) //Q_ASSERT(newCurrentCompletePercentage >= 0); //Q_ASSERT(newCurrentCompletePercentage <= 100); if (newCurrentCompletePercentage < 0) { - qDebug() << newCurrentCompletePercentage << "is smaller than 0 - this should not happen more than once"; + qCDebug(QInstaller::lcGeneral) << newCurrentCompletePercentage << "is smaller than 0 " + "- this should not happen more than once"; newCurrentCompletePercentage = 0; } if (newCurrentCompletePercentage > 100) { - qDebug() << newCurrentCompletePercentage << "is bigger than 100 - this should not happen more than once"; + qCDebug(QInstaller::lcGeneral) << newCurrentCompletePercentage << "is bigger than 100 " + "- this should not happen more than once"; newCurrentCompletePercentage = 100; } // In undo mode, the progress has to go backward, new has to be smaller than current - if (qRound(m_currentCompletePercentage) < qRound(newCurrentCompletePercentage)) - qDebug("Something is wrong with the calculation of the progress."); + if (qRound(m_currentCompletePercentage) < qRound(newCurrentCompletePercentage)) { + qCWarning(QInstaller::lcGeneral) << "Something is wrong with the calculation " + "of the progress."; + } m_currentCompletePercentage = newCurrentCompletePercentage; if (fraction == 1) { @@ -166,18 +173,20 @@ void ProgressCoordinator::partProgressChanged(double fraction) //Q_ASSERT(newCurrentCompletePercentage >= 0); //Q_ASSERT(newCurrentCompletePercentage <= 100); if (newCurrentCompletePercentage < 0) { - qDebug() << newCurrentCompletePercentage << "is smaller than 0 - this should not happen more than once"; + qCDebug(QInstaller::lcGeneral) << newCurrentCompletePercentage << "is smaller than 0 " + "- this should not happen more than once"; newCurrentCompletePercentage = 0; } if (newCurrentCompletePercentage > 100) { - qDebug() << newCurrentCompletePercentage << "is bigger than 100 - this should not happen more than once"; + qCDebug(QInstaller::lcGeneral) << newCurrentCompletePercentage << "is bigger than 100 " + "- this should not happen more than once"; newCurrentCompletePercentage = 100; } // In normal mode, the progress has to go forward, new has to be larger than current if (qRound(m_currentCompletePercentage) > qRound(newCurrentCompletePercentage)) - qDebug("Something is wrong with the calculation of the progress."); + qCWarning(QInstaller::lcGeneral) << "Something is wrong with the calculation of the progress."; m_currentCompletePercentage = newCurrentCompletePercentage; diff --git a/src/libs/installer/qtpatch.cpp b/src/libs/installer/qtpatch.cpp index 23ac372fd..07559acbd 100644 --- a/src/libs/installer/qtpatch.cpp +++ b/src/libs/installer/qtpatch.cpp @@ -28,6 +28,7 @@ #include "qtpatch.h" #include "utils.h" +#include "globals.h" #include <QString> #include <QStringList> @@ -83,7 +84,7 @@ QHash<QString, QByteArray> QtPatch::qmakeValues(const QString &qmakePath, QByteA QByteArray output = process.readAllStandardOutput(); qmakeOutput->append(output); if (process.exitStatus() == QProcess::CrashExit) { - qWarning() << qmake.absoluteFilePath() << args + qCWarning(QInstaller::lcGeneral) << qmake.absoluteFilePath() << args << "crashed with exit code" << process.exitCode() << "standard output:" << output << "error output:" << process.readAllStandardError(); @@ -97,13 +98,13 @@ QHash<QString, QByteArray> QtPatch::qmakeValues(const QString &qmakePath, QByteA QInstaller::uiDetachedWait(waitTimeInMilliSeconds); } if (process.state() > QProcess::NotRunning ) { - qDebug() << "qmake process is still running, need to kill it."; + qCWarning(QInstaller::lcGeneral) << "qmake process is still running, need to kill it."; process.kill(); } } if (qmakeValueHash.isEmpty()) - qDebug() << "Cannot get any query output from qmake."; + qCWarning(QInstaller::lcGeneral) << "Cannot get any query output from qmake."; return qmakeValueHash; } @@ -113,14 +114,15 @@ bool QtPatch::patchBinaryFile(const QString &fileName, { QFile file(fileName); if (!file.exists()) { - qDebug() << "qpatch: warning: file" << fileName << "not found"; + qCWarning(QInstaller::lcGeneral) << "qpatch: warning: file" << fileName << "not found"; return false; } openFileForPatching(&file); if (!file.isOpen()) { - qDebug() << "qpatch: warning: file" << qPrintable(fileName) << "cannot open."; - qDebug().noquote() << file.errorString(); + qCWarning(QInstaller::lcGeneral) << "qpatch: warning: file" << qPrintable(fileName) + << "cannot open."; + qCWarning(QInstaller::lcGeneral).noquote() << file.errorString(); return false; } @@ -136,7 +138,8 @@ bool QtPatch::patchBinaryFile(QIODevice *device, const QByteArray &newQtPath) { if (!(device->openMode() == QIODevice::ReadWrite)) { - qDebug() << "qpatch: warning: This function needs an open device for writing."; + qCWarning(QInstaller::lcGeneral) << "qpatch: warning: This function needs an " + "open device for writing."; return false; } const QByteArray source = device->readAll(); @@ -168,7 +171,8 @@ bool QtPatch::patchTextFile(const QString &fileName, QFile file(fileName); if (!file.open(QFile::ReadOnly)) { - qDebug() << "Cannot open file" << fileName << "for patching:" << file.errorString(); + qCWarning(QInstaller::lcGeneral) << "Cannot open file" << fileName << "for patching:" + << file.errorString(); return false; } @@ -182,7 +186,7 @@ bool QtPatch::patchTextFile(const QString &fileName, } if (!file.open(QFile::WriteOnly | QFile::Truncate)) { - qDebug() << "File" << fileName << "not writable."; + qCWarning(QInstaller::lcGeneral) << "File" << fileName << "not writable."; return false; } @@ -202,6 +206,7 @@ bool QtPatch::openFileForPatching(QFile *file) } return file->openMode() == QFile::ReadWrite; } - qDebug() << "File" << file->fileName() << "is open, so it cannot be opened again."; + qCWarning(QInstaller::lcGeneral) << "File" << file->fileName() << "is open, " + "so it cannot be opened again."; return false; } diff --git a/src/libs/installer/remoteserverconnection.cpp b/src/libs/installer/remoteserverconnection.cpp index b188e694e..1efe46b85 100644 --- a/src/libs/installer/remoteserverconnection.cpp +++ b/src/libs/installer/remoteserverconnection.cpp @@ -33,6 +33,7 @@ #include "remoteserverconnection_p.h" #include "utils.h" #include "permissionsettings.h" +#include "globals.h" #include <QCoreApplication> #include <QDataStream> @@ -171,13 +172,13 @@ void RemoteServerConnection::run() } else if (command.startsWith(QLatin1String(Protocol::QAbstractFileEngine))) { handleQFSFileEngine(&socket, command, stream); } else { - qDebug() << "Unknown command:" << command; + qCDebug(QInstaller::lcServer) << "Unknown command:" << command; } socket.flush(); } else { // authorization failed, connection not wanted socket.close(); - qDebug() << "Unknown command:" << command; + qCDebug(QInstaller::lcServer) << "Unknown command:" << command; return; } } @@ -285,7 +286,7 @@ void RemoteServerConnection::handleQProcess(QIODevice *socket, const QString &co } #endif else if (!command.isEmpty()) { - qDebug() << "Unknown QProcess command:" << command; + qCDebug(QInstaller::lcServer) << "Unknown QProcess command:" << command; } } @@ -366,7 +367,7 @@ void RemoteServerConnection::handleQSettings(QIODevice *socket, const QString &c } else if (command == QLatin1String(Protocol::QSettingsApplicationName)) { sendData(socket, settings->applicationName()); } else if (!command.isEmpty()) { - qDebug() << "Unknown QSettings command:" << command; + qCDebug(QInstaller::lcServer) << "Unknown QSettings command:" << command; } } @@ -502,7 +503,7 @@ void RemoteServerConnection::handleQFSFileEngine(QIODevice *socket, const QStrin data >> filetime; sendData(socket, m_engine->fileTime(static_cast<QAbstractFileEngine::FileTime> (filetime))); } else if (!command.isEmpty()) { - qDebug() << "Unknown QAbstractFileEngine command:" << command; + qCDebug(QInstaller::lcServer) << "Unknown QAbstractFileEngine command:" << command; } } diff --git a/src/libs/installer/scriptengine_p.h b/src/libs/installer/scriptengine_p.h index adbe2dc0c..67d642ff8 100644 --- a/src/libs/installer/scriptengine_p.h +++ b/src/libs/installer/scriptengine_p.h @@ -32,6 +32,7 @@ #include "component.h" #include "packagemanagercore.h" #include "packagemanagergui.h" +#include "globals.h" #include <QDebug> #include <QDesktopServices> @@ -49,7 +50,7 @@ public: ConsoleProxy() {} public slots : - void log(const QString &log) { qDebug().noquote() << log; } + void log(const QString &log) { qCDebug(QInstaller::lcGeneral).noquote() << log; } }; class InstallerProxy : public QObject diff --git a/src/libs/installer/settings.cpp b/src/libs/installer/settings.cpp index 3aa0baf18..618773937 100644 --- a/src/libs/installer/settings.cpp +++ b/src/libs/installer/settings.cpp @@ -31,6 +31,7 @@ #include "qinstallerglobal.h" #include "repository.h" #include "repositorycategory.h" +#include "globals.h" #include <QtCore/QFileInfo> #include <QtCore/QStringList> @@ -84,12 +85,13 @@ static void raiseError(QXmlStreamReader &reader, const QString &error, Settings: } else { QFile *xmlFile = qobject_cast<QFile*>(reader.device()); if (xmlFile) { - qWarning().noquote().nospace() + qCWarning(QInstaller::lcGeneral).noquote().nospace() << "Ignoring following settings reader error in " << xmlFile->fileName() << ", line " << reader.lineNumber() << ", column " << reader.columnNumber() << ": " << error; } else { - qWarning("Ignoring following settings reader error: %s", qPrintable(error)); + qCWarning(QInstaller::lcGeneral) << "Ignoring following settings reader error: " + << qPrintable(error); } } } diff --git a/src/libs/installer/settingsoperation.cpp b/src/libs/installer/settingsoperation.cpp index ccded868d..5f16a47e1 100644 --- a/src/libs/installer/settingsoperation.cpp +++ b/src/libs/installer/settingsoperation.cpp @@ -29,6 +29,7 @@ #include "packagemanagercore.h" #include "updateoperations.h" #include "qsettingswrapper.h" +#include "globals.h" #include <QDir> #include <QDebug> @@ -178,14 +179,14 @@ bool SettingsOperation::undoOperation() if (cleanUp) { QFile settingsFile(path); if (!settingsFile.remove()) - qWarning().noquote() << settingsFile.errorString(); + qCWarning(QInstaller::lcGeneral).noquote() << settingsFile.errorString(); if (!value(QLatin1String("createddir")).toString().isEmpty()) { KDUpdater::MkdirOperation mkDirOperation(packageManager()); mkDirOperation.setArguments(QStringList() << QFileInfo(path).absolutePath()); mkDirOperation.setValue(QLatin1String("createddir"), value(QLatin1String("createddir"))); if (!mkDirOperation.undoOperation()) { - qWarning().noquote() << mkDirOperation.errorString(); + qCWarning(QInstaller::lcGeneral).noquote() << mkDirOperation.errorString(); } } } diff --git a/src/libs/kdtools/filedownloader.cpp b/src/libs/kdtools/filedownloader.cpp index f12b6df5d..f134ce883 100644 --- a/src/libs/kdtools/filedownloader.cpp +++ b/src/libs/kdtools/filedownloader.cpp @@ -1575,7 +1575,7 @@ void KDUpdater::HttpDownloader::onSslErrors(QNetworkReply* reply, const QList<QS errorString += QLatin1String(", "); errorString += error.errorString(); } - qDebug() << errorString; + qCWarning(QInstaller::lcGeneral) << errorString; const QStringList arguments = QCoreApplication::arguments(); if (arguments.contains(QLatin1String("--script")) || arguments.contains(QLatin1String("Script")) diff --git a/src/libs/kdtools/filedownloaderfactory.cpp b/src/libs/kdtools/filedownloaderfactory.cpp index 7350df6e3..a61e5b195 100644 --- a/src/libs/kdtools/filedownloaderfactory.cpp +++ b/src/libs/kdtools/filedownloaderfactory.cpp @@ -28,6 +28,7 @@ #include "filedownloaderfactory.h" #include "filedownloader_p.h" +#include "globals.h" #include <QtNetwork/QSslSocket> @@ -68,7 +69,7 @@ FileDownloaderFactory::FileDownloaderFactory() if (QSslSocket::supportsSsl()) registerFileDownloader<HttpDownloader>(QLatin1String("https")); else - qWarning() << "Cannot register file downloader for https protocol: QSslSocket::supportsSsl() returns false"; + qCWarning(QInstaller::lcGeneral) << "Cannot register file downloader for https protocol: QSslSocket::supportsSsl() returns false"; #endif d->m_followRedirects = false; diff --git a/src/libs/kdtools/job.cpp b/src/libs/kdtools/job.cpp index 426aa1198..c655f8202 100644 --- a/src/libs/kdtools/job.cpp +++ b/src/libs/kdtools/job.cpp @@ -32,6 +32,7 @@ #include <QEventLoop> #include <QTimer> +#include "globals.h" // -- Job::Private @@ -183,7 +184,8 @@ void Job::cancel() } emitFinished(); } else { - qDebug() << "The current job cannot be canceled, missing \"Cancelable\" capability."; + qCDebug(QInstaller::lcGeneral) << "The current job cannot be canceled, " + "missing \"Cancelable\" capability."; } } diff --git a/src/libs/kdtools/runoncechecker.cpp b/src/libs/kdtools/runoncechecker.cpp index 91161ba8e..dda0ef730 100644 --- a/src/libs/kdtools/runoncechecker.cpp +++ b/src/libs/kdtools/runoncechecker.cpp @@ -30,6 +30,7 @@ #include "runoncechecker.h" #include "lockfile.h" #include "sysinfo.h" +#include "globals.h" #include <QCoreApplication> #include <QDebug> @@ -49,7 +50,7 @@ RunOnceChecker::RunOnceChecker(const QString &filename) RunOnceChecker::~RunOnceChecker() { if (!m_lockfile.unlock()) - qWarning().noquote() << m_lockfile.errorString(); + qCWarning(QInstaller::lcGeneral).noquote() << m_lockfile.errorString(); } class ProcessnameEquals @@ -97,7 +98,7 @@ bool RunOnceChecker::isRunning(RunOnceChecker::ConditionFlags flags) if (flags.testFlag(ConditionFlag::Lockfile)) { const bool locked = m_lockfile.lock(); if (!locked) - qWarning().noquote() << m_lockfile.errorString(); + qCWarning(QInstaller::lcGeneral).noquote() << m_lockfile.errorString(); return !locked; } return false; diff --git a/src/libs/kdtools/task.cpp b/src/libs/kdtools/task.cpp index 80bbcbd52..01ddfb0d7 100644 --- a/src/libs/kdtools/task.cpp +++ b/src/libs/kdtools/task.cpp @@ -28,6 +28,8 @@ #include "task.h" +#include "globals.h" + using namespace KDUpdater; /*! @@ -174,12 +176,12 @@ QString Task::progressText() const void Task::run() { if (m_started) { - qDebug("Trying to start an already started task"); + qCDebug(QInstaller::lcGeneral) << "Trying to start an already started task"; return; } if (m_stopped) { - qDebug("Trying to start a finished or canceled task"); + qCDebug(QInstaller::lcGeneral) << "Trying to start a finished or canceled task"; return; } @@ -206,13 +208,13 @@ void Task::stop() } if (!m_started) { - qDebug("Trying to stop an unstarted task"); + qCDebug(QInstaller::lcGeneral) << "Trying to stop an unstarted task"; return; } if(m_finished || m_stopped) { - qDebug("Trying to stop a finished or canceled task"); + qCDebug(QInstaller::lcGeneral) << "Trying to stop a finished or canceled task"; return; } @@ -243,12 +245,12 @@ void Task::pause() } if (!m_started) { - qDebug("Trying to pause an unstarted task"); + qCDebug(QInstaller::lcGeneral) << "Trying to pause an unstarted task"; return; } if (m_finished || m_stopped) { - qDebug("Trying to pause a finished or canceled task"); + qCDebug(QInstaller::lcGeneral) << "Trying to pause a finished or canceled task"; return; } @@ -276,7 +278,7 @@ void Task::pause() void Task::resume() { if (!m_paused) { - qDebug("Trying to resume an unpaused task"); + qCDebug(QInstaller::lcGeneral) << "Trying to resume an unpaused task"; return; } diff --git a/src/libs/kdtools/updatefinder.cpp b/src/libs/kdtools/updatefinder.cpp index b12ffac99..616159d23 100644 --- a/src/libs/kdtools/updatefinder.cpp +++ b/src/libs/kdtools/updatefinder.cpp @@ -418,23 +418,23 @@ UpdateFinder::Private::Resolution UpdateFinder::Private::checkPriorityAndVersion if (match > 0) { // new package has higher version, use - qDebug().nospace() << "Remove Package 'Name: " << name << ", Version: " - << existingPackage->data(QLatin1String("Version")).toString() - << ", Source: " << QFileInfo(existingPackage->packageSource().url.toLocalFile()).fileName() - << "' found a package with higher version 'Name: " - << name << ", Version: " << newPackage.value(QLatin1String("Version")).toString() - << ", Source: " << QFileInfo(source.url.toLocalFile()).fileName() << "'"; + qCDebug(QInstaller::lcGeneral).nospace() << "Remove Package 'Name: " << name + << ", Version: "<< existingPackage->data(QLatin1String("Version")).toString() + << ", Source: " << QFileInfo(existingPackage->packageSource().url.toLocalFile()).fileName() + << "' found a package with higher version 'Name: " + << name << ", Version: " << newPackage.value(QLatin1String("Version")).toString() + << ", Source: " << QFileInfo(source.url.toLocalFile()).fileName() << "'"; return Resolution::RemoveExisting; } if ((match == 0) && (source.priority > existingPackage->packageSource().priority)) { // new package version equals but priority is higher, use - qDebug().nospace() << "Remove Package 'Name: " << name << ", Priority: " - << existingPackage->packageSource().priority - << ", Source: " << QFileInfo(existingPackage->packageSource().url.toLocalFile()).fileName() - << "' found a package with higher priority 'Name: " - << name << ", Priority: " << source.priority - << ", Source: " << QFileInfo(source.url.toLocalFile()).fileName() << "'"; + qCDebug(QInstaller::lcGeneral).nospace() << "Remove Package 'Name: " << name + << ", Priority: " << existingPackage->packageSource().priority + << ", Source: " << QFileInfo(existingPackage->packageSource().url.toLocalFile()).fileName() + << "' found a package with higher priority 'Name: " + << name << ", Priority: " << source.priority + << ", Source: " << QFileInfo(source.url.toLocalFile()).fileName() << "'"; return Resolution::RemoveExisting; } if (q->isCompressedPackage() && match == 0 && source.priority == existingPackage->packageSource().priority) { diff --git a/src/libs/kdtools/updateoperation.cpp b/src/libs/kdtools/updateoperation.cpp index 1dcb0014b..b95f6f5a3 100644 --- a/src/libs/kdtools/updateoperation.cpp +++ b/src/libs/kdtools/updateoperation.cpp @@ -31,6 +31,7 @@ #include "constants.h" #include "fileutils.h" #include "packagemanagercore.h" +#include "globals.h" #include <QDataStream> #include <QDebug> @@ -248,9 +249,9 @@ QString UpdateOperation::argumentKeyValue(const QString &key, const QString &def it = std::find_if(++it, tArguments.end(), StartsWith(keySeparater)); if (it != tArguments.end()) { - qWarning().nospace() << "There are multiple keys in the arguments calling " << name() << ". " - << "Only the first found " << key << " is used: " - << arguments().join(QLatin1String("; ")); + qCWarning(QInstaller::lcGeneral).nospace() << "There are multiple keys in the arguments calling " + << name() << ". " << "Only the first found " << key << " is used: " + << arguments().join(QLatin1String("; ")); } return value; } @@ -517,7 +518,8 @@ bool UpdateOperation::fromXml(const QString &xml) int errorLine; int errorColumn; if (!doc.setContent( xml, &errorMsg, &errorLine, &errorColumn)) { - qWarning() << "Error parsing xml error=" << errorMsg << "line=" << errorLine << "column=" << errorColumn; + qCWarning(QInstaller::lcGeneral) << "Error parsing xml error=" << errorMsg + << "line=" << errorLine << "column=" << errorColumn; return false; } return fromXml(doc); diff --git a/src/sdk/installerbase.cpp b/src/sdk/installerbase.cpp index b1b0e9e5d..ce8106c60 100644 --- a/src/sdk/installerbase.cpp +++ b/src/sdk/installerbase.cpp @@ -155,7 +155,7 @@ int InstallerBase::run() qCDebug(QInstaller::lcTranslations) << "Language:" << QLocale().uiLanguages() .value(0, QLatin1String("No UI language set")).toUtf8().constData(); - qDebug().noquote() << "Arguments:" << arguments().join(QLatin1String(", ")); + qCDebug(QInstaller::lcGeneral).noquote() << "Arguments:" << arguments().join(QLatin1String(", ")); SDKApp::registerMetaResources(manager.collectionByName("QResources")); if (parser.isSet(QLatin1String(CommandLineOptions::StartClient))) { @@ -252,7 +252,7 @@ int InstallerBase::run() throw QInstaller::Error(QLatin1String("Empty repository list for option 'installCompressedRepository'.")); foreach (QString repository, repoList) { if (!QFileInfo::exists(repository)) { - qDebug() << "The file " << repository << "does not exist."; + qCWarning(QInstaller::lcGeneral) << "The file " << repository << "does not exist."; return EXIT_FAILURE; } } @@ -310,7 +310,7 @@ int InstallerBase::run() const QString path = fontIt.next(); qCDebug(QInstaller::lcResources) << "Registering custom font" << path; if (QFontDatabase::addApplicationFont(path) == -1) - qWarning() << "Failed to register font!"; + qCWarning(QInstaller::lcGeneral) << "Failed to register font!"; } } @@ -346,8 +346,22 @@ int InstallerBase::run() checkLicense(); m_core->autoRejectMessageBoxes(); if (m_core->isInstaller()) { - if (!setTargetDirFromCommandLine(parser)) + if (!setTargetDirFromCommandLine(parser)) { + const QString &value = parser.value(QLatin1String(CommandLineOptions::TargetDir)); + if (m_core->checkTargetDir(value)) { + QString targetDirWarning = m_core->targetDirWarning(value); + if (!targetDirWarning.isEmpty()) { + qCWarning(QInstaller::lcGeneral) << m_core->targetDirWarning(value); + return EXIT_FAILURE; + } + m_core->setValue(QLatin1String("TargetDir"), value); + } else { + return EXIT_FAILURE; + } + } else { + qCWarning(QInstaller::lcGeneral) << "Please specify target directory."; return EXIT_FAILURE; + } } QStringList packages; @@ -386,11 +400,11 @@ int InstallerBase::run() } if (squishPort != 0) { if (Squish::allowAttaching(squishPort)) - qDebug() << "Attaching to squish port " << squishPort << " succeeded"; + qCDebug(QInstaller::lcGeneral) << "Attaching to squish port " << squishPort << " succeeded"; else - qDebug() << "Attaching to squish failed."; + qCDebug(QInstaller::lcGeneral) << "Attaching to squish failed."; } else { - qWarning() << "Invalid squish port number: " << squishPort; + qCWarning(QInstaller::lcGeneral) << "Invalid squish port number: " << squishPort; } #endif const int result = QCoreApplication::instance()->exec(); @@ -435,7 +449,7 @@ QStringList InstallerBase::repositories(const QString &list) const { const QStringList items = list.split(QLatin1Char(','), QString::SkipEmptyParts); foreach (const QString &item, items) - qDebug().noquote() << "Adding custom repository:" << item; + qCDebug(QInstaller::lcGeneral).noquote() << "Adding custom repository:" << item; return items; } @@ -443,7 +457,7 @@ void InstallerBase::checkLicense() { const ProductKeyCheck *const productKeyCheck = ProductKeyCheck::instance(); if (!productKeyCheck->hasValidLicense()) { - qDebug() << "No valid license found."; + qCWarning(QInstaller::lcPackageLicenses) << "No valid license found."; throw QInstaller::Error(QLatin1String("No valid license found.")); } } diff --git a/src/sdk/tabcontroller.cpp b/src/sdk/tabcontroller.cpp index 75eb081ce..623b6d445 100644 --- a/src/sdk/tabcontroller.cpp +++ b/src/sdk/tabcontroller.cpp @@ -29,6 +29,7 @@ #include "installerbasecommons.h" #include "settingsdialog.h" +#include "globals.h" #include <packagemanagercore.h> @@ -111,7 +112,7 @@ int TabController::init() // this should called as early as possible, to handle error message boxes for example if (!d->m_controlScript.isEmpty()) { d->m_gui->loadControlScript(d->m_controlScript); - qDebug() << "Using control script:" << d->m_controlScript; + qCDebug(QInstaller::lcGeneral) << "Using control script:" << d->m_controlScript; } connect(d->m_gui, &QWizard::currentIdChanged, this, &TabController::onCurrentIdChanged); |