From 05243ce0bce0cc96b59889d15a511705c538e171 Mon Sep 17 00:00:00 2001 From: Katja Marttila Date: Tue, 3 Jan 2023 09:55:08 +0200 Subject: Adapt to changes in QAbstractFileEngine Task-number: QTIFW-1829 Change-Id: I72e814cfcf852e8de47f0e772abdcb0ad9eba38f Reviewed-by: Arttu Tarkiainen --- src/libs/installer/binaryformat.cpp | 11 +++++++++-- src/libs/installer/binaryformat.h | 6 +++++- src/libs/installer/binaryformatengine.cpp | 9 ++++++++- src/libs/installer/binaryformatengine.h | 7 ++++++- src/libs/installer/remotefileengine.cpp | 23 ++++++++++++++++++++++- src/libs/installer/remotefileengine.h | 10 ++++++++++ src/libs/installer/remoteserverconnection.cpp | 11 ++++++++++- 7 files changed, 70 insertions(+), 7 deletions(-) (limited to 'src/libs/installer') diff --git a/src/libs/installer/binaryformat.cpp b/src/libs/installer/binaryformat.cpp index 9ed7742db..59cc5fb42 100644 --- a/src/libs/installer/binaryformat.cpp +++ b/src/libs/installer/binaryformat.cpp @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2023 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -153,12 +153,19 @@ void Resource::setName(const QByteArray &name) Opens a resource in QIODevice::ReadOnly mode. The function returns \c true if successful. */ +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) bool Resource::open() +#else +bool Resource::open(std::optional permissions) +#endif { if (isOpen()) return false; - +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) if (!m_file.open(QIODevice::ReadOnly | QIODevice::Unbuffered)) { +#else + if (!m_file.open(QIODevice::ReadOnly | QIODevice::Unbuffered, permissions)) { +#endif setErrorString(m_file.errorString()); return false; } diff --git a/src/libs/installer/binaryformat.h b/src/libs/installer/binaryformat.h index 26d510530..fa1becc32 100644 --- a/src/libs/installer/binaryformat.h +++ b/src/libs/installer/binaryformat.h @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2022 The Qt Company Ltd. +** Copyright (C) 2023 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -58,7 +58,11 @@ public: Resource(const QString &path, const Range &segment); ~Resource(); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) bool open(); +#else + bool open(std::optional permissions = std::nullopt); +#endif void close() override; bool seek(qint64 pos) override; diff --git a/src/libs/installer/binaryformatengine.cpp b/src/libs/installer/binaryformatengine.cpp index 681e6db79..8aa8cdca5 100644 --- a/src/libs/installer/binaryformatengine.cpp +++ b/src/libs/installer/binaryformatengine.cpp @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2023 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -127,9 +127,16 @@ bool BinaryFormatEngine::close() /*! \internal */ +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) bool BinaryFormatEngine::open(QIODevice::OpenMode mode) +#else +bool BinaryFormatEngine::open(QIODevice::OpenMode mode, std::optional permissions) +#endif { Q_UNUSED(mode) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + Q_UNUSED(permissions) +#endif return m_resource.isNull() ? false : m_resource->open(); } diff --git a/src/libs/installer/binaryformatengine.h b/src/libs/installer/binaryformatengine.h index bf72e5f1f..169bfe0f9 100644 --- a/src/libs/installer/binaryformatengine.h +++ b/src/libs/installer/binaryformatengine.h @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2022 The Qt Company Ltd. +** Copyright (C) 2023 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -47,7 +47,12 @@ public: bool copy(const QString &newName) override; bool close() override; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) bool open(QIODevice::OpenMode mode) override; +#else + bool open(QIODevice::OpenMode mode, + std::optional permissions = std::nullopt) override; +#endif qint64 pos() const override; qint64 read(char *data, qint64 maxlen) override; bool seek(qint64 offset) override; diff --git a/src/libs/installer/remotefileengine.cpp b/src/libs/installer/remotefileengine.cpp index adc5b8561..039b5196a 100644 --- a/src/libs/installer/remotefileengine.cpp +++ b/src/libs/installer/remotefileengine.cpp @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2023 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -313,6 +313,7 @@ bool RemoteFileEngine::link(const QString &newName) /*! \reimp */ +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) bool RemoteFileEngine::mkdir(const QString &dirName, bool createParentDirectories) const { if ((const_cast(this))->connectToServer()) { @@ -320,18 +321,38 @@ bool RemoteFileEngine::mkdir(const QString &dirName, bool createParentDirectorie dirName, createParentDirectories); } return m_fileEngine.mkdir(dirName, createParentDirectories); + +} +#else +bool RemoteFileEngine::mkdir(const QString &dirName, bool createParentDirectories, + std::optional permissions) const +{ + if ((const_cast(this))->connectToServer()) { + return callRemoteMethod(QString::fromLatin1(Protocol::QAbstractFileEngineMkdir), + dirName, createParentDirectories); + } + return m_fileEngine.mkdir(dirName, createParentDirectories, permissions); } +#endif /*! \reimp */ +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) bool RemoteFileEngine::open(QIODevice::OpenMode mode) +#else +bool RemoteFileEngine::open(QIODevice::OpenMode mode, std::optional permissions) +#endif { if (connectToServer()) { return callRemoteMethod(QString::fromLatin1(Protocol::QAbstractFileEngineOpen), static_cast(mode | QIODevice::Unbuffered)); } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) return m_fileEngine.open(mode | QIODevice::Unbuffered); +#else + return m_fileEngine.open(mode | QIODevice::Unbuffered, permissions); +#endif } /*! diff --git a/src/libs/installer/remotefileengine.h b/src/libs/installer/remotefileengine.h index 35ebf7742..6227a0444 100644 --- a/src/libs/installer/remotefileengine.h +++ b/src/libs/installer/remotefileengine.h @@ -53,7 +53,12 @@ public: RemoteFileEngine(); ~RemoteFileEngine(); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) bool open(QIODevice::OpenMode mode) override; +#else + bool open(QIODevice::OpenMode mode, + std::optional permissions = std::nullopt) override; +#endif bool close() override; bool flush() override; bool syncToDisk() override; @@ -66,7 +71,12 @@ public: bool rename(const QString &newName) override; bool renameOverwrite(const QString &newName) override; bool link(const QString &newName) override; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) bool mkdir(const QString &dirName, bool createParentDirectories) const override; +#else + bool mkdir(const QString &dirName, bool createParentDirectories, + std::optional permissions = std::nullopt) const override; +#endif bool rmdir(const QString &dirName, bool recurseParentDirectories) const override; bool setSize(qint64 size) override; bool caseSensitive() const override; diff --git a/src/libs/installer/remoteserverconnection.cpp b/src/libs/installer/remoteserverconnection.cpp index ed3d343fe..bf4e8040c 100644 --- a/src/libs/installer/remoteserverconnection.cpp +++ b/src/libs/installer/remoteserverconnection.cpp @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2022 The Qt Company Ltd. +** Copyright (C) 2023 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -497,11 +497,20 @@ void RemoteServerConnection::handleQFSFileEngine(RemoteServerReply *reply, const bool createParentDirectories; data >>dirName; data >>createParentDirectories; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) reply->send(m_engine->mkdir(dirName, createParentDirectories)); +#else + reply->send(m_engine->mkdir(dirName, createParentDirectories, std::nullopt)); +#endif + } else if (command == QLatin1String(Protocol::QAbstractFileEngineOpen)) { qint32 openMode; data >>openMode; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) reply->send(m_engine->open(static_cast (openMode))); +#else + reply->send(m_engine->open(static_cast (openMode), std::nullopt)); +#endif } else if (command == QLatin1String(Protocol::QAbstractFileEngineOwner)) { qint32 owner; data >>owner; -- cgit v1.2.3