summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
authorArttu Tarkiainen <arttu.tarkiainen@qt.io>2021-11-12 10:06:42 +0200
committerArttu Tarkiainen <arttu.tarkiainen@qt.io>2021-11-12 10:06:42 +0200
commit8feea98f9c51efa4effa37e86d02ffcc44961709 (patch)
tree8eeaf8035cd77ba15efca2431a1599848d1d150b /src/libs
parent3ad787d0dd580a8cfb37f4e56b55f1889e24727b (diff)
parente0b1a21917d052919bfda6f49980a6a7afd3998b (diff)
Merge remote-tracking branch 'origin/4.2'
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/installer/abstractarchive.cpp2
-rw-r--r--src/libs/installer/createlocalrepositoryoperation.cpp1
-rw-r--r--src/libs/installer/globals.cpp7
-rw-r--r--src/libs/installer/globals.h1
-rw-r--r--src/libs/installer/lib7z_facade.cpp18
-rw-r--r--src/libs/installer/libarchivearchive.cpp130
-rw-r--r--src/libs/installer/libarchivearchive.h11
-rw-r--r--src/libs/installer/libarchivewrapper.cpp13
-rw-r--r--src/libs/installer/libarchivewrapper_p.cpp66
-rw-r--r--src/libs/installer/libarchivewrapper_p.h4
-rw-r--r--src/libs/installer/loggingutils.cpp17
-rw-r--r--src/libs/installer/loggingutils.h2
-rw-r--r--src/libs/installer/protocol.h2
-rw-r--r--src/libs/installer/remoteserverconnection.cpp4
-rw-r--r--src/libs/installer/remoteserverconnection_p.h10
15 files changed, 232 insertions, 56 deletions
diff --git a/src/libs/installer/abstractarchive.cpp b/src/libs/installer/abstractarchive.cpp
index dd9b8e625..f2b4300c4 100644
--- a/src/libs/installer/abstractarchive.cpp
+++ b/src/libs/installer/abstractarchive.cpp
@@ -65,7 +65,7 @@ namespace QInstaller {
*/
/*!
- \fn QInstaller::AbstractArchive::completedChanged(quint64 completed, quint64 total)
+ \fn QInstaller::AbstractArchive::completedChanged(const quint64 completed, const quint64 total)
The ratio of \a completed entries from \a total changed. Subclasses should emit
this whenever the progress changes.
diff --git a/src/libs/installer/createlocalrepositoryoperation.cpp b/src/libs/installer/createlocalrepositoryoperation.cpp
index a40838178..576e4fa3d 100644
--- a/src/libs/installer/createlocalrepositoryoperation.cpp
+++ b/src/libs/installer/createlocalrepositoryoperation.cpp
@@ -129,6 +129,7 @@ static QString createArchive(const QString repoPath, const QString &sourceDir, c
throw Error(CreateLocalRepositoryOperation::tr("Cannot create archive \"%1\": %2")
.arg(QDir::toNativeSeparators(archive.fileName()), archiveFile.errorString()));
}
+ archiveFile.close();
removeFiles(sourceDir, helper); // cleanup the files we compressed
if (!archive.rename(sourceDir + fileName)) {
throw Error(CreateLocalRepositoryOperation::tr("Cannot move file \"%1\" to \"%2\": %3")
diff --git a/src/libs/installer/globals.cpp b/src/libs/installer/globals.cpp
index 0da4bc3b6..adf1d2f6e 100644
--- a/src/libs/installer/globals.cpp
+++ b/src/libs/installer/globals.cpp
@@ -33,7 +33,6 @@
const char IFW_SERVER[] = "ifw.server";
const char IFW_INSTALLER_INSTALLLOG[] = "ifw.installer.installlog";
const char IFW_DEVELOPER_BUILD[] = "ifw.developer.build";
-const char IFW_PACKAGE_INFO[] = "ifw.package.info";
// Internal-only, hidden in --help text
const char IFW_PROGRESS_INDICATOR[] = "ifw.progress.indicator";
@@ -61,16 +60,10 @@ namespace QInstaller
\internal
*/
-/*!
- \fn QInstaller::lcPackageInfo()
- \internal
-*/
-
Q_LOGGING_CATEGORY(lcServer, IFW_SERVER)
Q_LOGGING_CATEGORY(lcInstallerInstallLog, IFW_INSTALLER_INSTALLLOG)
Q_LOGGING_CATEGORY(lcProgressIndicator, IFW_PROGRESS_INDICATOR)
Q_LOGGING_CATEGORY(lcDeveloperBuild, IFW_DEVELOPER_BUILD)
-Q_LOGGING_CATEGORY(lcPackageInfo, IFW_PACKAGE_INFO)
/*!
Returns available logging categories.
diff --git a/src/libs/installer/globals.h b/src/libs/installer/globals.h
index 5053f6d9f..b22331e2c 100644
--- a/src/libs/installer/globals.h
+++ b/src/libs/installer/globals.h
@@ -40,7 +40,6 @@ INSTALLER_EXPORT Q_DECLARE_LOGGING_CATEGORY(lcInstallerInstallLog)
INSTALLER_EXPORT Q_DECLARE_LOGGING_CATEGORY(lcProgressIndicator)
INSTALLER_EXPORT Q_DECLARE_LOGGING_CATEGORY(lcDeveloperBuild)
-INSTALLER_EXPORT Q_DECLARE_LOGGING_CATEGORY(lcPackageInfo)
QStringList INSTALLER_EXPORT loggingCategories();
diff --git a/src/libs/installer/lib7z_facade.cpp b/src/libs/installer/lib7z_facade.cpp
index 17176d7b0..6d1b6a57d 100644
--- a/src/libs/installer/lib7z_facade.cpp
+++ b/src/libs/installer/lib7z_facade.cpp
@@ -188,12 +188,6 @@ namespace Lib7z {
Prints string \a s.
*/
-/*!
- \fn bool Lib7z::operator==(const File &lhs, const File &rhs);
-
- Returns \c true if \a lhs and \a rhs are equal; otherwise returns \c false.
-*/
-
// -- 7z init codecs, archives
std::once_flag gOnceFlag;
@@ -770,6 +764,18 @@ STDMETHODIMP ExtractCallback::SetOperationResult(Int32 /*resultEOperationResult*
*/
/*!
+ \typedef Lib7z::Compression
+
+ Synonym for QInstaller::CompressionLevel
+*/
+
+/*!
+ \typedef Lib7z::File
+
+ Synonym for QInstaller::ArchiveEntry
+*/
+
+/*!
\namespace Lib7z
\inmodule QtInstallerFramework
\brief The Lib7z namespace contains miscellaneous identifiers used throughout the Lib7z library.
diff --git a/src/libs/installer/libarchivearchive.cpp b/src/libs/installer/libarchivearchive.cpp
index ad5609490..d3a79bd40 100644
--- a/src/libs/installer/libarchivearchive.cpp
+++ b/src/libs/installer/libarchivearchive.cpp
@@ -32,6 +32,8 @@
#include "errors.h"
#include "globals.h"
+#include <stdio.h>
+
#include <QApplication>
#include <QFileInfo>
#include <QDir>
@@ -93,7 +95,11 @@ void ExtractWorker::extract(const QString &dirPath, const quint64 totalFiles)
foreach (const QString &directory, createdDirs)
emit currentEntryChanged(directory);
- int status = archive_read_open(reader.get(), this, nullptr, readCallback, nullptr);
+ archive_read_set_read_callback(reader.get(), readCallback);
+ archive_read_set_callback_data(reader.get(), this);
+ archive_read_set_seek_callback(reader.get(), seekCallback);
+
+ int status = archive_read_open1(reader.get());
if (status != ARCHIVE_OK) {
m_status = Failure;
emit finished(QLatin1String(archive_error_string(reader.get())));
@@ -117,6 +123,12 @@ void ExtractWorker::extract(const QString &dirPath, const quint64 totalFiles)
const QString outputPath = dirPath + QDir::separator() + QString::fromLocal8Bit(current);
archive_entry_set_pathname(entry, outputPath.toLocal8Bit());
+ const char *hardlink = archive_entry_hardlink(entry);
+ if (hardlink) {
+ const QString hardLinkPath = dirPath + QDir::separator() + QString::fromLocal8Bit(hardlink);
+ archive_entry_set_hardlink(entry, hardLinkPath.toLocal8Bit());
+ }
+
emit currentEntryChanged(outputPath);
if (!writeEntry(reader.get(), writer.get(), entry))
return;
@@ -142,6 +154,12 @@ void ExtractWorker::addDataBlock(const QByteArray buffer)
emit dataReadyForRead();
}
+void ExtractWorker::onFilePositionChanged(qint64 pos)
+{
+ m_lastPos = pos;
+ emit seekReady();
+}
+
void ExtractWorker::cancel()
{
m_status = Canceled;
@@ -177,6 +195,26 @@ ssize_t ExtractWorker::readCallback(archive *reader, void *caller, const void **
return buffer->size();
}
+la_int64_t ExtractWorker::seekCallback(archive *reader, void *caller, la_int64_t offset, int whence)
+{
+ Q_UNUSED(reader)
+
+ ExtractWorker *obj;
+ if (!(obj = static_cast<ExtractWorker *>(caller)))
+ return ARCHIVE_FATAL;
+
+ emit obj->seekRequested(static_cast<qint64>(offset), whence);
+
+ {
+ QEventLoop loop;
+ QTimer::singleShot(30000, &loop, &QEventLoop::quit);
+ connect(obj, &ExtractWorker::seekReady, &loop, &QEventLoop::quit);
+ loop.exec();
+ }
+
+ return static_cast<la_int64_t>(obj->m_lastPos);
+}
+
bool ExtractWorker::writeEntry(archive *reader, archive *writer, archive_entry *entry)
{
int status;
@@ -235,6 +273,13 @@ bool ExtractWorker::writeEntry(archive *reader, archive *writer, archive_entry *
*/
/*!
+ \fn QInstaller::LibArchiveArchive::seekRequested(qint64 offset, int whence)
+
+ Emitted when the worker object requires a seek to \a offset to continue extracting.
+ The \a whence value defines the starting position for \a offset.
+*/
+
+/*!
\fn QInstaller::LibArchiveArchive::workerFinished()
Emitted when the worker object finished extracting an archive.
@@ -267,6 +312,12 @@ bool ExtractWorker::writeEntry(archive *reader, archive *writer, archive_entry *
*/
/*!
+ \fn QInstaller::LibArchiveArchive::workerAboutToSetFilePosition(qint64 pos)
+
+ Emitted when the worker object is about to set new file position \a pos.
+*/
+
+/*!
Constructs an archive object representing an archive file
specified by \a filename with \a parent as the parent object.
*/
@@ -377,7 +428,7 @@ bool LibArchiveArchive::extract(const QString &dirPath, const quint64 totalFiles
foreach (const QString &directory, createdDirs)
emit currentEntryChanged(directory);
- int status = archive_read_open(reader.get(), m_data, nullptr, readCallback, nullptr);
+ int status = archiveReadOpenWithCallbacks(reader.get());
if (status != ARCHIVE_OK)
throw Error(QLatin1String(archive_error_string(reader.get())));
@@ -395,6 +446,12 @@ bool LibArchiveArchive::extract(const QString &dirPath, const quint64 totalFiles
const QString outputPath = dirPath + QDir::separator() + QString::fromLocal8Bit(current);
archive_entry_set_pathname(entry, outputPath.toLocal8Bit());
+ const char *hardlink = archive_entry_hardlink(entry);
+ if (hardlink) {
+ const QString hardLinkPath = dirPath + QDir::separator() + QString::fromLocal8Bit(hardlink);
+ archive_entry_set_hardlink(entry, hardLinkPath.toLocal8Bit());
+ }
+
emit currentEntryChanged(outputPath);
if (!writeEntry(reader.get(), writer.get(), entry))
throw Error(errorString()); // appropriate error string set in writeEntry()
@@ -455,7 +512,7 @@ bool LibArchiveArchive::create(const QStringList &data)
if (status < ARCHIVE_OK)
throw Error(QLatin1String(archive_error_string(writer.get())));
- if (fileOrDir.isDir())
+ if (fileOrDir.isDir() || archive_entry_size(entry.get()) == 0)
continue; // nothing to copy
QFile file(pathWithoutNamespace(QLatin1String(archive_entry_sourcepath(entry.get()))));
@@ -496,7 +553,7 @@ QVector<ArchiveEntry> LibArchiveArchive::list()
QVector<ArchiveEntry> entries;
try {
- int status = archive_read_open(reader.get(), m_data, nullptr, readCallback, nullptr);
+ int status = archiveReadOpenWithCallbacks(reader.get());
if (status != ARCHIVE_OK)
throw Error(QLatin1String(archive_error_string(reader.get())));
@@ -537,7 +594,7 @@ bool LibArchiveArchive::isSupported()
configureReader(reader.get());
try {
- const int status = archive_read_open(reader.get(), m_data, nullptr, readCallback, nullptr);
+ const int status = archiveReadOpenWithCallbacks(reader.get());
if (status != ARCHIVE_OK)
throw Error(QLatin1String(archive_error_string(reader.get())));
} catch (const Error &e) {
@@ -575,6 +632,14 @@ void LibArchiveArchive::workerSetDataAtEnd()
}
/*!
+ Signals the worker object that the client file position changed to \a pos.
+*/
+void LibArchiveArchive::workerSetFilePosition(qint64 pos)
+{
+ emit workerAboutToSetFilePosition(pos);
+}
+
+/*!
Cancels the extract in progress for the worker object.
*/
void LibArchiveArchive::workerCancel()
@@ -672,9 +737,11 @@ void LibArchiveArchive::initExtractWorker()
connect(this, &LibArchiveArchive::workerAboutToExtract, &m_worker, &ExtractWorker::extract);
connect(this, &LibArchiveArchive::workerAboutToAddDataBlock, &m_worker, &ExtractWorker::addDataBlock);
connect(this, &LibArchiveArchive::workerAboutToSetDataAtEnd, &m_worker, &ExtractWorker::dataAtEnd);
+ connect(this, &LibArchiveArchive::workerAboutToSetFilePosition, &m_worker, &ExtractWorker::onFilePositionChanged);
connect(this, &LibArchiveArchive::workerAboutToCancel, &m_worker, &ExtractWorker::cancel);
connect(&m_worker, &ExtractWorker::dataBlockRequested, this, &LibArchiveArchive::dataBlockRequested);
+ connect(&m_worker, &ExtractWorker::seekRequested, this, &LibArchiveArchive::seekRequested);
connect(&m_worker, &ExtractWorker::finished, this, &LibArchiveArchive::onWorkerFinished);
connect(&m_worker, &ExtractWorker::currentEntryChanged, this, &LibArchiveArchive::currentEntryChanged);
@@ -684,6 +751,20 @@ void LibArchiveArchive::initExtractWorker()
}
/*!
+ \internal
+
+ Sets default callbacks for archive \a reader and opens for reading.
+*/
+int LibArchiveArchive::archiveReadOpenWithCallbacks(archive *reader)
+{
+ archive_read_set_read_callback(reader, readCallback);
+ archive_read_set_callback_data(reader, m_data);
+ archive_read_set_seek_callback(reader, seekCallback);
+
+ return archive_read_open1(reader);
+}
+
+/*!
Writes the current \a entry header, then pulls data from the archive \a reader
and writes it to the \a writer handle.
*/
@@ -767,6 +848,43 @@ ssize_t LibArchiveArchive::readCallback(archive *reader, void *archiveData, cons
}
/*!
+ \internal
+
+ Seeks to specified \a offset in the file device in \a archiveData and returns the position.
+ Possible \a whence values are \c SEEK_SET, \c SEEK_CUR, and \c SEEK_END. Returns
+ \c ARCHIVE_FATAL if the seek fails.
+*/
+la_int64_t LibArchiveArchive::seekCallback(archive *reader, void *archiveData, la_int64_t offset, int whence)
+{
+ Q_UNUSED(reader)
+
+ ArchiveData *data;
+ if (!(data = static_cast<ArchiveData *>(archiveData)))
+ return ARCHIVE_FATAL;
+
+ if (!data->file.isOpen() || data->file.isSequential())
+ return ARCHIVE_FATAL;
+
+ switch (whence) {
+ case SEEK_SET: // moves file pointer position to the beginning of the file
+ if (!data->file.seek(offset))
+ return ARCHIVE_FATAL;
+ break;
+ case SEEK_CUR: // moves file pointer position to given location
+ if (!data->file.seek(data->file.pos() + offset))
+ return ARCHIVE_FATAL;
+ break;
+ case SEEK_END: // moves file pointer position to the end of file
+ if (!data->file.seek(data->file.size() + offset))
+ return ARCHIVE_FATAL;
+ break;
+ default:
+ return ARCHIVE_FATAL;
+ }
+ return data->file.pos();
+}
+
+/*!
Returns the \a path to a file or directory, without the Win32 namespace prefix.
On Unix platforms, the \a path is returned unaltered.
*/
@@ -794,7 +912,7 @@ quint64 LibArchiveArchive::totalFiles()
configureReader(reader.get());
try {
- int status = archive_read_open(reader.get(), m_data, nullptr, readCallback, nullptr);
+ int status = archiveReadOpenWithCallbacks(reader.get());
if (status != ARCHIVE_OK)
throw Error(QLatin1String(archive_error_string(reader.get())));
diff --git a/src/libs/installer/libarchivearchive.h b/src/libs/installer/libarchivearchive.h
index e0281e655..796069ed1 100644
--- a/src/libs/installer/libarchivearchive.h
+++ b/src/libs/installer/libarchivearchive.h
@@ -64,12 +64,15 @@ public:
public Q_SLOTS:
void extract(const QString &dirPath, const quint64 totalFiles);
void addDataBlock(const QByteArray buffer);
+ void onFilePositionChanged(qint64 pos);
void cancel();
Q_SIGNALS:
void dataBlockRequested();
void dataAtEnd();
void dataReadyForRead();
+ void seekRequested(qint64 offset, int whence);
+ void seekReady();
void finished(const QString &errorString = QString());
void currentEntryChanged(const QString &filename);
@@ -77,10 +80,12 @@ Q_SIGNALS:
private:
static ssize_t readCallback(archive *reader, void *caller, const void **buff);
+ static la_int64_t seekCallback(archive *reader, void *caller, la_int64_t offset, int whence);
bool writeEntry(archive *reader, archive *writer, archive_entry *entry);
private:
QByteArray m_buffer;
+ qint64 m_lastPos = 0;
Status m_status;
};
@@ -107,16 +112,19 @@ public:
void workerExtract(const QString &dirPath, const quint64 totalFiles);
void workerAddDataBlock(const QByteArray buffer);
void workerSetDataAtEnd();
+ void workerSetFilePosition(qint64 pos);
void workerCancel();
ExtractWorker::Status workerStatus() const;
Q_SIGNALS:
void dataBlockRequested();
+ void seekRequested(qint64 offset, int whence);
void workerFinished();
void workerAboutToExtract(const QString &dirPath, const quint64 totalFiles);
void workerAboutToAddDataBlock(const QByteArray buffer);
void workerAboutToSetDataAtEnd();
+ void workerAboutToSetFilePosition(qint64 pos);
void workerAboutToCancel();
public Q_SLOTS:
@@ -133,11 +141,14 @@ private:
void initExtractWorker();
+ int archiveReadOpenWithCallbacks(archive *reader);
bool writeEntry(archive *reader, archive *writer, archive_entry *entry);
static qint64 readData(QFile *file, char *data, qint64 maxSize);
static ssize_t readCallback(archive *reader, void *archiveData, const void **buff);
+ static la_int64_t seekCallback(archive *reader, void *archiveData, la_int64_t offset, int whence);
+
static QString pathWithoutNamespace(const QString &path);
quint64 totalFiles();
diff --git a/src/libs/installer/libarchivewrapper.cpp b/src/libs/installer/libarchivewrapper.cpp
index c259678ca..9fbbeb889 100644
--- a/src/libs/installer/libarchivewrapper.cpp
+++ b/src/libs/installer/libarchivewrapper.cpp
@@ -45,19 +45,6 @@ namespace QInstaller {
*/
/*!
- \fn QInstaller::LibArchiveWrapper::currentEntryChanged(const QString &filename)
-
- Current entry changed to \a filename. Emitted when the entry to process is changed.
-*/
-
-/*!
- \fn QInstaller::LibArchiveWrapper::completedChanged(quint64 completed, quint64 total)
-
- The ratio of \a completed entries from \a total changed.
- Emitted when the progress changes.
-*/
-
-/*!
Constructs an archive object representing an archive file
specified by \a filename with \a parent as the parent object.
*/
diff --git a/src/libs/installer/libarchivewrapper_p.cpp b/src/libs/installer/libarchivewrapper_p.cpp
index 5509812cf..30f81554a 100644
--- a/src/libs/installer/libarchivewrapper_p.cpp
+++ b/src/libs/installer/libarchivewrapper_p.cpp
@@ -41,13 +41,13 @@ namespace QInstaller {
*/
/*!
- \fn QInstaller::ArchiveWrapper::dataBlockRequested()
+ \fn QInstaller::LibArchiveWrapperPrivate::dataBlockRequested()
Emitted when the server process has requested another data block.
*/
/*!
- \fn QInstaller::ArchiveWrapper::remoteWorkerFinished()
+ \fn QInstaller::LibArchiveWrapperPrivate::remoteWorkerFinished()
Emitted when the server process has finished extracting an archive.
*/
@@ -77,7 +77,6 @@ LibArchiveWrapperPrivate::LibArchiveWrapperPrivate()
*/
LibArchiveWrapperPrivate::~LibArchiveWrapperPrivate()
{
- m_timer.stop();
}
/*!
@@ -140,6 +139,10 @@ QString LibArchiveWrapperPrivate::errorString() const
bool LibArchiveWrapperPrivate::extract(const QString &dirPath, const quint64 totalFiles)
{
if (connectToServer()) {
+ QTimer timer;
+ connect(&timer, &QTimer::timeout, this, &LibArchiveWrapperPrivate::processSignals);
+ timer.start();
+
m_lock.lockForWrite();
callRemoteMethod(QLatin1String(Protocol::AbstractArchiveExtract), dirPath, totalFiles);
m_lock.unlock();
@@ -148,6 +151,7 @@ bool LibArchiveWrapperPrivate::extract(const QString &dirPath, const quint64 tot
connect(this, &LibArchiveWrapperPrivate::remoteWorkerFinished, &loop, &QEventLoop::quit);
loop.exec();
}
+ timer.stop();
return (workerStatus() == ExtractWorker::Success);
}
return m_archive.extract(dirPath, totalFiles);
@@ -247,6 +251,10 @@ void LibArchiveWrapperPrivate::processSignals()
emit completedChanged(completed, total);
} else if (name == QLatin1String(Protocol::AbstractArchiveSignalDataBlockRequested)) {
emit dataBlockRequested();
+ } else if (name == QLatin1String(Protocol::AbstractArchiveSignalSeekRequested)) {
+ const qint64 offset = receivedSignals.takeFirst().value<qint64>();
+ const int whence = receivedSignals.takeFirst().value<int>();
+ emit seekRequested(offset, whence);
} else if (name == QLatin1String(Protocol::AbstractArchiveSignalWorkerFinished)) {
emit remoteWorkerFinished();
}
@@ -258,7 +266,7 @@ void LibArchiveWrapperPrivate::processSignals()
*/
void LibArchiveWrapperPrivate::onDataBlockRequested()
{
- constexpr quint64 blockSize = 10 * 1024 * 1024; // 10MB
+ constexpr quint64 blockSize = 1024 * 1024; // 1MB
QFile *const file = &m_archive.m_data->file;
if (!file->isOpen() || file->isSequential()) {
@@ -294,15 +302,39 @@ void LibArchiveWrapperPrivate::onDataBlockRequested()
}
/*!
- Starts the timer to process server-side signals and connects handler
- signals for the matching signals of the wrapper object.
+ Seeks to specified \a offset in the underlying file device. Possible \a whence
+ values are \c SEEK_SET, \c SEEK_CUR, and \c SEEK_END.
*/
-void LibArchiveWrapperPrivate::init()
+void LibArchiveWrapperPrivate::onSeekRequested(qint64 offset, int whence)
{
- m_timer.start(250);
- QObject::connect(&m_timer, &QTimer::timeout,
- this, &LibArchiveWrapperPrivate::processSignals);
+ QFile *const file = &m_archive.m_data->file;
+ if (!file->isOpen() || file->isSequential()) {
+ qCWarning(QInstaller::lcInstallerInstallLog) << file->errorString();
+ setClientFilePosition(ARCHIVE_FATAL);
+ return;
+ }
+ bool success = false;
+ switch (whence) {
+ case SEEK_SET: // moves file pointer position to the beginning of the file
+ success = file->seek(offset);
+ break;
+ case SEEK_CUR: // moves file pointer position to given location
+ success = file->seek(file->pos() + offset);
+ break;
+ case SEEK_END: // moves file pointer position to the end of file
+ success = file->seek(file->size() + offset);
+ break;
+ default:
+ break;
+ }
+ setClientFilePosition(success ? file->pos() : ARCHIVE_FATAL);
+}
+/*!
+ Connects handler signals for the matching signals of the wrapper object.
+*/
+void LibArchiveWrapperPrivate::init()
+{
QObject::connect(&m_archive, &LibArchiveArchive::currentEntryChanged,
this, &LibArchiveWrapperPrivate::currentEntryChanged);
QObject::connect(&m_archive, &LibArchiveArchive::completedChanged,
@@ -310,6 +342,8 @@ void LibArchiveWrapperPrivate::init()
QObject::connect(this, &LibArchiveWrapperPrivate::dataBlockRequested,
this, &LibArchiveWrapperPrivate::onDataBlockRequested);
+ QObject::connect(this, &LibArchiveWrapperPrivate::seekRequested,
+ this, &LibArchiveWrapperPrivate::onSeekRequested);
}
/*!
@@ -338,6 +372,18 @@ void LibArchiveWrapperPrivate::setClientDataAtEnd()
}
/*!
+ Calls a remote method to set new file position \a pos.
+*/
+void LibArchiveWrapperPrivate::setClientFilePosition(qint64 pos)
+{
+ if (connectToServer()) {
+ m_lock.lockForWrite();
+ callRemoteMethod(QLatin1String(Protocol::AbstractArchiveSetFilePosition), pos, dummy);
+ m_lock.unlock();
+ }
+}
+
+/*!
Calls a remote method to retrieve and return the status of
the extract worker on a server process.
*/
diff --git a/src/libs/installer/libarchivewrapper_p.h b/src/libs/installer/libarchivewrapper_p.h
index ea8409da0..4277cd4f9 100644
--- a/src/libs/installer/libarchivewrapper_p.h
+++ b/src/libs/installer/libarchivewrapper_p.h
@@ -66,6 +66,7 @@ Q_SIGNALS:
void currentEntryChanged(const QString &filename);
void completedChanged(const quint64 completed, const quint64 total);
void dataBlockRequested();
+ void seekRequested(qint64 offset, int whence);
void remoteWorkerFinished();
public Q_SLOTS:
@@ -74,16 +75,17 @@ public Q_SLOTS:
private Q_SLOTS:
void processSignals();
void onDataBlockRequested();
+ void onSeekRequested(qint64 offset, int whence);
private:
void init();
void addDataBlock(const QByteArray &buffer);
void setClientDataAtEnd();
+ void setClientFilePosition(qint64 pos);
ExtractWorker::Status workerStatus() const;
private:
- QTimer m_timer;
mutable QReadWriteLock m_lock;
LibArchiveArchive m_archive;
diff --git a/src/libs/installer/loggingutils.cpp b/src/libs/installer/loggingutils.cpp
index 6e7bff44a..a2b561c53 100644
--- a/src/libs/installer/loggingutils.cpp
+++ b/src/libs/installer/loggingutils.cpp
@@ -145,10 +145,7 @@ void LoggingHandler::messageHandler(QtMsgType type, const QMessageLogContext &co
static Uptime uptime;
- QString ba;
- if (context.category != lcPackageInfo().categoryName()) {
- ba = QLatin1Char('[') + QString::number(uptime.elapsed()) + QStringLiteral("] ");
- }
+ QString ba = QLatin1Char('[') + QString::number(uptime.elapsed()) + QStringLiteral("] ");
ba += trimAndPrepend(type, msg);
if (type != QtDebugMsg && context.file) {
@@ -160,7 +157,7 @@ void LoggingHandler::messageHandler(QtMsgType type, const QMessageLogContext &co
if (VerboseWriter *log = VerboseWriter::instance())
log->appendLine(ba);
- if (type != QtDebugMsg || isVerbose() || context.category == lcPackageInfo().categoryName())
+ if (type != QtDebugMsg || isVerbose())
std::cout << qPrintable(ba) << std::endl;
if (type == QtFatalMsg) {
@@ -251,9 +248,9 @@ bool LoggingHandler::outputRedirected() const
}
/*!
- Prints basic information about \a components.
+ Prints update information from \a components.
*/
-void LoggingHandler::printComponentInfo(const QList<Component *> components) const
+void LoggingHandler::printUpdateInformation(const QList<Component *> components) const
{
QDomDocument doc;
QDomElement root = doc.createElement(QLatin1String("updates"));
@@ -267,7 +264,7 @@ void LoggingHandler::printComponentInfo(const QList<Component *> components) con
update.setAttribute(QLatin1String("id"), component->value(scName));
root.appendChild(update);
}
- qCDebug(lcPackageInfo) << qPrintable(doc.toString(4));
+ std::cout << qPrintable(doc.toString(4));
}
/*!
@@ -297,7 +294,7 @@ void LoggingHandler::printLocalPackageInformation(const QList<KDUpdater::LocalPa
}
root.appendChild(update);
}
- qCDebug(lcPackageInfo) << qPrintable(doc.toString(4));
+ std::cout << qPrintable(doc.toString(4));
}
/*!
@@ -341,7 +338,7 @@ void LoggingHandler::printPackageInformation(const PackagesList &matchedPackages
}
root.appendChild(update);
}
- qCDebug(lcPackageInfo) << qPrintable(doc.toString(4));
+ std::cout << qPrintable(doc.toString(4));
}
/*!
diff --git a/src/libs/installer/loggingutils.h b/src/libs/installer/loggingutils.h
index a997a6d60..06f0400f8 100644
--- a/src/libs/installer/loggingutils.h
+++ b/src/libs/installer/loggingutils.h
@@ -57,7 +57,7 @@ public:
VerbosityLevel verboseLevel() const;
bool outputRedirected() const;
- void printComponentInfo(const QList<Component *> components) const;
+ void printUpdateInformation(const QList<Component *> components) const;
void printLocalPackageInformation(const QList<KDUpdater::LocalPackage> &packages) const;
void printPackageInformation(const PackagesList &matchedPackages, const LocalPackagesHash &installedPackages) const;
diff --git a/src/libs/installer/protocol.h b/src/libs/installer/protocol.h
index c7eb9a308..65241e00b 100644
--- a/src/libs/installer/protocol.h
+++ b/src/libs/installer/protocol.h
@@ -177,6 +177,7 @@ const char AbstractArchiveIsSupported[] = "AbstractArchive::isSupported";
const char AbstractArchiveSetCompressionLevel[] = "AbstractArchive::setCompressionLevel";
const char AbstractArchiveAddDataBlock[] = "AbstractArchive::addDataBlock";
const char AbstractArchiveSetClientDataAtEnd[] = "AbstractArchive::setClientDataAtEnd";
+const char AbstractArchiveSetFilePosition[] = "AbstractArchive::setFilePosition";
const char AbstractArchiveWorkerStatus[] = "AbstractArchive::workerStatus";
const char AbstractArchiveCancel[] = "AbstractArchive::cancel";
@@ -184,6 +185,7 @@ const char GetAbstractArchiveSignals[] = "GetAbstractArchiveSignals";
const char AbstractArchiveSignalCurrentEntryChanged[] = "AbstractArchive::currentEntryChanged";
const char AbstractArchiveSignalCompletedChanged[] = "AbstractArchive::completedChanged";
const char AbstractArchiveSignalDataBlockRequested[] = "AbstractArchive::dataBlockRequested";
+const char AbstractArchiveSignalSeekRequested[] = "AbstractArchive::seekRequested";
const char AbstractArchiveSignalWorkerFinished[] = "AbstractArchive::workerFinished";
} // namespace Protocol
diff --git a/src/libs/installer/remoteserverconnection.cpp b/src/libs/installer/remoteserverconnection.cpp
index 5d72f834d..9e141ea48 100644
--- a/src/libs/installer/remoteserverconnection.cpp
+++ b/src/libs/installer/remoteserverconnection.cpp
@@ -596,6 +596,10 @@ void RemoteServerConnection::handleArchive(QIODevice *socket, const QString &com
archive->workerAddDataBlock(buff);
} else if (command == QLatin1String(Protocol::AbstractArchiveSetClientDataAtEnd)) {
archive->workerSetDataAtEnd();
+ } else if (command == QLatin1String(Protocol::AbstractArchiveSetFilePosition)) {
+ qint64 pos;
+ data >> pos;
+ archive->workerSetFilePosition(pos);
} else if (command == QLatin1String(Protocol::AbstractArchiveWorkerStatus)) {
sendData(socket, static_cast<qint32>(archive->workerStatus()));
} else if (command == QLatin1String(Protocol::AbstractArchiveCancel)) {
diff --git a/src/libs/installer/remoteserverconnection_p.h b/src/libs/installer/remoteserverconnection_p.h
index dc6d794b6..977a64711 100644
--- a/src/libs/installer/remoteserverconnection_p.h
+++ b/src/libs/installer/remoteserverconnection_p.h
@@ -143,6 +143,8 @@ private:
this, &AbstractArchiveSignalReceiver::onCompletedChanged);
connect(archive, &LibArchiveArchive::dataBlockRequested,
this, &AbstractArchiveSignalReceiver::onDataBlockRequested);
+ connect(archive, &LibArchiveArchive::seekRequested,
+ this, &AbstractArchiveSignalReceiver::onSeekRequested);
connect(archive, &LibArchiveArchive::workerFinished,
this, &AbstractArchiveSignalReceiver::onWorkerFinished);
}
@@ -169,6 +171,14 @@ private Q_SLOTS:
m_receivedSignals.append(QLatin1String(Protocol::AbstractArchiveSignalDataBlockRequested));
}
+ void onSeekRequested(qint64 offset, int whence)
+ {
+ QMutexLocker _(&m_lock);
+ m_receivedSignals.append(QLatin1String(Protocol::AbstractArchiveSignalSeekRequested));
+ m_receivedSignals.append(offset);
+ m_receivedSignals.append(whence);
+ }
+
void onWorkerFinished()
{
QMutexLocker _(&m_lock);