summaryrefslogtreecommitdiffstats
path: root/installerbuilder
diff options
context:
space:
mode:
authorkh1 <karsten.heimrich@nokia.com>2012-02-13 15:36:22 +0100
committerKarsten Heimrich <karsten.heimrich@nokia.com>2012-02-14 12:18:42 +0100
commit1b2ceb1e7e87bfa36cf608bdf00523f60dd9ff4d (patch)
treee77866131c3b6137b0d6453ba868db80b0cbc533 /installerbuilder
parent5953d72df5fd2e34c1a4fe1485e0393b57aa687a (diff)
Remove some superfluous classes.
Change-Id: I7eccb7370a761960c0dfe5f4361fc114ac27d316 Reviewed-by: Tim Jenssen <tim.jenssen@nokia.com>
Diffstat (limited to 'installerbuilder')
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdtools.pri8
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterfiledownloader.cpp9
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufcompresscommon.cpp130
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufcompresscommon_p.h74
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufuncompressor.cpp208
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufuncompressor_p.h57
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateinstaller.cpp463
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateinstaller.h66
8 files changed, 0 insertions, 1015 deletions
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdtools.pri b/installerbuilder/libinstaller/3rdparty/kdtools/kdtools.pri
index 6e5942af6..19b41c203 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdtools.pri
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdtools.pri
@@ -38,12 +38,8 @@ HEADERS += $$PWD/kdupdater.h \
$$PWD/kdupdaterupdateoperations.h \
$$PWD/kdupdaterupdatesourcesinfo.h \
$$PWD/kdupdatertask.h \
- $$PWD/kdupdatersignatureverificationrunnable.h \
$$PWD/kdupdaterupdatefinder.h \
$$PWD/kdupdaterupdatesinfo_p.h \
- $$PWD/kdupdaterupdateinstaller.h \
- $$PWD/kdupdaterufuncompressor_p.h \
- $$PWD/kdupdaterufcompresscommon_p.h \
$$PWD/environment.h
SOURCES += $$PWD/kdupdaterapplication.cpp \
@@ -59,12 +55,8 @@ SOURCES += $$PWD/kdupdaterapplication.cpp \
$$PWD/kdupdaterupdateoperations.cpp \
$$PWD/kdupdaterupdatesourcesinfo.cpp \
$$PWD/kdupdatertask.cpp \
- $$PWD/kdupdatersignatureverificationrunnable.cpp \
$$PWD/kdupdaterupdatefinder.cpp \
$$PWD/kdupdaterupdatesinfo.cpp \
- $$PWD/kdupdaterupdateinstaller.cpp \
- $$PWD/kdupdaterufuncompressor.cpp \
- $$PWD/kdupdaterufcompresscommon.cpp \
$$PWD/environment.cpp
QT += gui
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterfiledownloader.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterfiledownloader.cpp
index 87bb9ca16..a9f042af0 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterfiledownloader.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterfiledownloader.cpp
@@ -1501,13 +1501,4 @@ void SignatureVerificationDownloader::signatureDownloadCompleted()
return;
}
setDownloadCompleted(d->downloadedFileName);
-
-#if 0
- SignatureVerificationRunnable *runnable = new SignatureVerificationRunnable;
- runnable->setSignature(signature);
- runnable->setData(dataFile.release());
- runnable->setVerifier(d->verifier);
- runnable->addResultListener(this, "verificationResult");
- QThreadPool::globalInstance()->start(runnable);
-#endif
}
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufcompresscommon.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufcompresscommon.cpp
deleted file mode 100644
index d11c1d333..000000000
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufcompresscommon.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
-**
-** This file is part of the KD Tools library.
-**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
-**
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
-**
-**********************************************************************/
-
-#include "kdupdaterufcompresscommon_p.h"
-
-#include <QCryptographicHash>
-#include <QDataStream>
-
-using namespace KDUpdater;
-
-bool UFHeader::isValid() const
-{
- return magic == QLatin1String(KD_UPDATER_UF_HEADER_MAGIC)
- && fileList.count() == permList.count()
- && fileList.count() == isDirList.count();
-}
-
-void UFHeader::addToHash(QCryptographicHash &hash) const
-{
- QByteArray data;
- QDataStream stream(&data, QIODevice::WriteOnly);
- stream << *this;
- hash.addData(data);
-}
-
-UFEntry::UFEntry()
- : permissions(0)
-{}
-
-bool UFEntry::isValid() const
-{
- return !fileName.isEmpty();
-}
-
-void UFEntry::addToHash(QCryptographicHash &hash) const
-{
- QByteArray data;
- QDataStream stream(&data, QIODevice::WriteOnly);
- stream.setVersion(QDataStream::Qt_4_2);
- stream << *this;
- hash.addData(data);
-}
-
-namespace KDUpdater {
-
-QDataStream &operator<<(QDataStream &stream, const UFHeader &hdr)
-{
- stream << hdr.magic;
- stream << hdr.fileList;
- stream << hdr.permList;
- stream << hdr.isDirList;
- return stream;
-}
-
-QDataStream &operator>>(QDataStream &stream, UFHeader &hdr)
-{
- const QDataStream::Status oldStatus = stream.status();
- stream >> hdr.magic;
- if (stream.status() == QDataStream::Ok && hdr.magic != QLatin1String(KD_UPDATER_UF_HEADER_MAGIC))
- stream.setStatus(QDataStream::ReadCorruptData);
-
- if (stream.status() == QDataStream::Ok)
- stream >> hdr.fileList;
-
- if (stream.status() == QDataStream::Ok)
- stream >> hdr.permList;
-
- if (stream.status() == QDataStream::Ok)
- stream >> hdr.isDirList;
-
- if (stream.status() == QDataStream::Ok
- && (hdr.fileList.count() != hdr.permList.count() || hdr.permList.count() != hdr.isDirList.count()))
- stream.setStatus(QDataStream::ReadCorruptData);
-
- if( stream.status() != QDataStream::Ok)
- hdr = UFHeader();
-
- if (oldStatus != QDataStream::Ok)
- stream.setStatus(oldStatus);
-
- return stream;
-}
-
-QDataStream &operator<<(QDataStream &stream, const UFEntry &entry)
-{
- stream << entry.fileName;
- stream << entry.permissions;
- stream << entry.fileData;
- return stream;
-}
-
-QDataStream &operator>>(QDataStream &stream, UFEntry &entry)
-{
- const QDataStream::Status oldStatus = stream.status();
- if (stream.status() == QDataStream::Ok)
- stream >> entry.fileName;
- if (stream.status() == QDataStream::Ok)
- stream >> entry.permissions;
- if (stream.status() == QDataStream::Ok)
- stream >> entry.fileData;
-
- if (stream.status() != QDataStream::Ok)
- entry = UFEntry();
-
- if (oldStatus != QDataStream::Ok)
- stream.setStatus(oldStatus);
-
- return stream;
-}
-
-} // namespace KDUpdater
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufcompresscommon_p.h b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufcompresscommon_p.h
deleted file mode 100644
index 7e064e775..000000000
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufcompresscommon_p.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
-**
-** This file is part of the KD Tools library.
-**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
-**
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
-**
-**********************************************************************/
-
-#ifndef KDTOOLS_KDUPDATE_UFCOMPRESSCOMMON_P_H
-#define KDTOOLS_KDUPDATE_UFCOMPRESSCOMMON_P_H
-
-#define KD_UPDATER_UF_HEADER_MAGIC "KDVCLZ"
-
-#include <kdtoolsglobal.h>
-
-#include <QtCore/QStringList>
-#include <QtCore/QByteArray>
-#include <QtCore/QVector>
-
-QT_BEGIN_NAMESPACE
-class QCryptographicHash;
-class QDataStream;
-QT_END_NAMESPACE
-
-namespace KDUpdater {
-
-struct KDTOOLS_EXPORT UFHeader
-{
- QString magic;
- QStringList fileList;
- QVector<quint64> permList;
- QList<bool> isDirList;
-
- bool isValid() const;
-
- void addToHash(QCryptographicHash &hash) const;
-};
-
-struct KDTOOLS_EXPORT UFEntry
-{
- QString fileName;
- quint64 permissions;
- QByteArray fileData;
-
- UFEntry();
-
- bool isValid() const;
-
- void addToHash(QCryptographicHash& hash) const;
-};
-
-KDTOOLS_EXPORT QDataStream &operator<<(QDataStream &stream, const UFHeader &hdr);
-KDTOOLS_EXPORT QDataStream &operator>>(QDataStream &stream, UFHeader &hdr);
-
-KDTOOLS_EXPORT QDataStream &operator<<(QDataStream &stream, const UFEntry &entry);
-KDTOOLS_EXPORT QDataStream &operator>>(QDataStream &stream, UFEntry &entry);
-
-} // namespace KDUpdater
-
-#endif // KDTOOLS_KDUPDATE_UFCOMPRESSCOMMON_P_H
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufuncompressor.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufuncompressor.cpp
deleted file mode 100644
index fda944544..000000000
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufuncompressor.cpp
+++ /dev/null
@@ -1,208 +0,0 @@
-/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
-**
-** This file is part of the KD Tools library.
-**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
-**
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
-**
-**********************************************************************/
-
-#include "kdupdaterufuncompressor_p.h"
-#include "kdupdaterufcompresscommon_p.h"
-
-#include <QCryptographicHash>
-#include <QDir>
-#include <QFile>
-#include <QFileInfo>
-#include <QFSFileEngine>
-#include <QDebug>
-
-using namespace KDUpdater;
-
-class UFUncompressor::Private
-{
-public:
- QString ufFileName;
- QString destination;
- QString errorMessage;
-
- void setError(const QString &msg);
-};
-
-void UFUncompressor::Private::setError(const QString &msg)
-{
- errorMessage = msg;
-}
-
-UFUncompressor::UFUncompressor()
- : d(new Private)
-{
-}
-
-UFUncompressor::~UFUncompressor()
-{
- delete d;
-}
-
-QString UFUncompressor::errorString() const
-{
- return d->errorMessage;
-}
-
-void UFUncompressor::setFileName(const QString &fileName)
-{
- d->ufFileName = fileName;
-}
-
-QString UFUncompressor::fileName() const
-{
- return d->ufFileName;
-}
-
-void UFUncompressor::setDestination(const QString &dest)
-{
- d->destination = dest;
-}
-
-QString UFUncompressor::destination() const
-{
- return d->destination;
-}
-
-bool UFUncompressor::uncompress()
-{
- d->errorMessage.clear();
-
- // First open the uf file for reading
- QFile ufFile(d->ufFileName);
- if (!ufFile.open(QFile::ReadOnly)) {
- d->setError(tr("Couldn't open file for reading: %1").arg( ufFile.errorString()));
- return false;
- }
-
- QDataStream ufDS(&ufFile);
- ufDS.setVersion(QDataStream::Qt_4_2);
- QCryptographicHash hash(QCryptographicHash::Md5);
-
- // Now read the header.
- UFHeader header;
- ufDS >> header;
- if (ufDS.status() != QDataStream::Ok || !header.isValid()) {
- d->setError(tr("Couldn't read the file header."));
- return false;
- }
- header.addToHash(hash);
-
- // Some basic checks.
- if (header.magic != QLatin1String( KD_UPDATER_UF_HEADER_MAGIC)) {
- d->setError(tr("Wrong file format (magic number not found)"));
- return false;
- }
-
- // Lets get to the destination directory
- const QDir dir(d->destination);
- QFSFileEngine fileEngine;
-
- // Lets create the required directory structure
- int numExpectedFiles = 0;
- for (int i = 0; i < header.fileList.count(); i++) {
- const QString fileName = header.fileList.at(i);
- // qDebug("ToUncompress %s", qPrintable(fileName));
- if (header.isDirList.at(i)) {
- if (!dir.mkpath(fileName)) {
- d->setError(tr("Could not create folder: %1/%2").arg(d->destination, fileName));
- return false;
- }
- fileEngine.setFileName(QString::fromLatin1("%1/%2").arg(d->destination, fileName));
- fileEngine.setPermissions(header.permList[i] | QAbstractFileEngine::ExeOwnerPerm);
- } else {
- ++numExpectedFiles;
- }
- }
-
- // Lets now create files within these directories
- int numActualFiles = 0;
- while (!ufDS.atEnd() && numActualFiles < numExpectedFiles) {
- UFEntry ufEntry;
- ufDS >> ufEntry;
- if (ufDS.status() != QDataStream::Ok || !ufEntry.isValid()) {
- d->setError(tr("Could not read information for entry %1.").arg(numActualFiles));
- return false;
- }
- ufEntry.addToHash(hash);
-
- const QString completeFileName = QString::fromLatin1("%1/%2").arg(d->destination, ufEntry.fileName);
-
- const QByteArray ba = qUncompress(ufEntry.fileData);
- // check the size
- QDataStream stream(ufEntry.fileData);
- stream.setVersion(QDataStream::Qt_4_2);
- qint32 length = 0;
- stream >> length;
- if (ba.length() != length) { // uncompress failed
- d->setError(tr("Could not uncompress entry %1, corrupt data").arg(ufEntry.fileName));
- return false;
- }
-
- QFile ufeFile(completeFileName);
- if (!ufeFile.open(QFile::WriteOnly)) {
- d->setError(tr("Could not open file %1 for writing: %2").arg(completeFileName, ufeFile.errorString()));
- return false;
- }
-
- const char *const data = ba.constData();
- const qint64 total = ba.size();
- qint64 written = 0;
-
- while (written < total) {
- const qint64 num = ufeFile.write(data + written, total - written);
- if (num == -1) {
- d->setError(tr("Failed writing uncompressed data to %1: %2").arg(completeFileName, ufeFile.errorString()));
- return false;
- }
- written += num;
- }
-
- ufeFile.close();
-
- const QFile::Permissions perm = static_cast<QFile::Permissions>(ufEntry.permissions);
- ufeFile.setPermissions(perm);
-
- if (ufeFile.error() != QFile::NoError) {
- ufeFile.remove();
- d->setError(tr("Failed writing uncompressed data to %1: %2").arg(completeFileName, ufeFile.errorString()));
- return false;
- }
-
- qDebug("Uncompressed %s", qPrintable(completeFileName));
- ++numActualFiles;
- }
-
- if (numExpectedFiles != numActualFiles) {
- d->errorMessage = tr("Corrupt file (wrong number of files)");
- return false;
- }
-
- QByteArray hashdata;
- ufDS >> hashdata;
-
- if (hashdata != hash.result()) {
- d->errorMessage = tr("Corrupt file (wrong hash)");
- return false;
- }
-
- return true;
-}
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufuncompressor_p.h b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufuncompressor_p.h
deleted file mode 100644
index c86728d5b..000000000
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufuncompressor_p.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
-**
-** This file is part of the KD Tools library.
-**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
-**
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
-**
-**********************************************************************/
-
-#ifndef KDTOOLS_KDUPDATERUFUNCOMPRESSOR_P_H
-#define KDTOOLS_KDUPDATERUFUNCOMPRESSOR_P_H
-
-#include <kdtoolsglobal.h>
-
-#include <QtCore/QCoreApplication>
-
-namespace KDUpdater {
-
-class KDTOOLS_EXPORT UFUncompressor
-{
- Q_DECLARE_TR_FUNCTIONS(KDUpdater::UFUncompressor)
-
-public:
- UFUncompressor();
- ~UFUncompressor();
-
- QString errorString() const;
-
- void setFileName(const QString &fileName);
- QString fileName() const;
-
- void setDestination(const QString &dest);
- QString destination() const;
-
- bool uncompress();
-
-private:
- class Private;
- Private *d;
-};
-
-} // namespace KDUpdater
-
-#endif // KDTOOLS_KDUPDATERUFUNCOMPRESSOR_P_H
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateinstaller.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateinstaller.cpp
deleted file mode 100644
index bc7304212..000000000
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateinstaller.cpp
+++ /dev/null
@@ -1,463 +0,0 @@
-/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
-**
-** This file is part of the KD Tools library.
-**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
-**
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
-**
-**********************************************************************/
-
-#include "kdupdaterupdateinstaller.h"
-#include "kdupdaterpackagesinfo.h"
-#include "kdupdaterapplication.h"
-#include "kdupdaterupdate.h"
-#include "kdupdaterupdateoperationfactory.h"
-#include "kdupdaterupdateoperation.h"
-#include "kdupdaterufuncompressor_p.h"
-
-#include <QCoreApplication>
-#include <QFileInfo>
-#include <QDir>
-#include <QDomDocument>
-#include <QDomElement>
-#include <QDate>
-
-using namespace KDUpdater;
-
-/*!
- \ingroup kdupdater
- \class KDUpdater::UpdateInstaller kdupdaterupdateinstaller.h KDUpdaterUpdateInstaller
- \brief Installs updates, given a list of \ref KDUpdater::Update objects
-
- This class installs updates, given a list of \ref KDUpdater::Update objects via the
- \ref installUpdates() method. To install the updates this class performs the following
- for each update
-
- \li Downloads the update files from its source
- \li Unpacks update files into a temporary directory
- \li Parses and executes UpdateInstructions.xml by making use of \ref KDUpdater::UpdateOperation
- objects sourced via \ref KDUpdater::UpdateOperationFactory
-
- \note All temporary files created during the installation of the update will be destroyed
- immediately after the installation is complete.
-*/
-class UpdateInstaller::Private
-{
- public:
- Private(UpdateInstaller *qq) :
- q(qq)
- {}
-
- UpdateInstaller *q;
-
- Application *application;
- int updateDownloadDoneCount;
- int updateDownloadProgress;
- int totalUpdates;
- QStringList toRemoveDirs;
-
- int totalProgressPc;
- int currentProgressPc;
- QList<Update *> updates;
-
- void resolveArguments(QStringList &args);
-
- void removeDirectory(const QDir &dir);
- void slotUpdateDownloadProgress(int percent);
- void slotUpdateDownloadDone();
-};
-
-// next two are duplicated from kdupdaterupdatefinder.cpp:
-
-static int computeProgressPercentage(int min, int max, int percent)
-{
- return min + qint64(max-min) * percent / 100 ;
-}
-
-static int computePercent(int done, int total)
-{
- return total ? done * Q_INT64_C(100) / total : 0 ;
-}
-
-/*!
- Constructs an instance of this class for the \ref KDUpdater::Application passed as
- parameter. Only updates meant for the specified application will be installed by this class.
-*/
-UpdateInstaller::UpdateInstaller(Application *application)
- : Task(QLatin1String("UpdateInstaller"), NoCapability, application),
- d(new Private(this))
-{
- d->application = application;
-}
-
-/*!
- Destructor
-*/
-UpdateInstaller::~UpdateInstaller()
-{
- delete d;
-}
-
-/*!
- Returns the update application for which the update is being installed
-*/
-Application *UpdateInstaller::application() const
-{
- return d->application;
-}
-
-/*!
- Use this function to let the installer know what updates are to be installed. The
- updates are actually installed when the \ref start() method is called on this class.
-*/
-void UpdateInstaller::setUpdatesToInstall(const QList<Update *> &updates)
-{
- d->updates = updates;
-}
-
-/*!
- Returns the updates that would be installed when the next time \ref the start) method is called.
-*/
-QList<Update *> UpdateInstaller::updatesToInstall() const
-{
- return d->updates;
-}
-
-/*!
- \internal
-*/
-void UpdateInstaller::doRun()
-{
- QList<Update *> &updates = d->updates;
-
- // First download all the updates
- d->updateDownloadDoneCount = 0;
- d->totalUpdates = updates.count();
-
- for (int i = 0; i < updates.count(); i++) {
- Update *update = updates[i];
- if (update->application() != d->application)
- continue;
-
- update->setProperty("_ProgressPc_", 0);
- connect(update, SIGNAL(progressValue(int)), this, SLOT(slotUpdateDownloadProgress(int)));
- connect(update, SIGNAL(finished()), this, SLOT(slotUpdateDownloadDone()));
- connect(update, SIGNAL(stopped()), this, SLOT(slotUpdateDownloadDone()));
- update->download();
- }
-
- d->totalProgressPc = updates.count() * 100;
- d->currentProgressPc = 0;
-
- // Wait until all updates have been downloaded
- while (d->updateDownloadDoneCount != updates.count()) {
- QCoreApplication::processEvents();
-
- // Normalized progress
- int progressPc = computePercent(d->currentProgressPc, d->totalProgressPc);
-
- // Bring the progress to within 50 percent
- progressPc = (progressPc>>1);
-
- // Report the progress
- reportProgress(progressPc, tr("Downloading updates..."));
- }
-
- // Global progress
- reportProgress(50, tr("Updates downloaded..."));
-
- // Save the current working directory of the application
- QDir oldCWD = QDir::current();
-
- int pcDiff = computePercent(1, updates.count());
- pcDiff = computeProgressPercentage(50, 95, pcDiff) - 50;
-
- // Now install one update after another.
- for (int i = 0; i < updates.count(); i++) {
- Update *update = updates[i];
-
- // Global progress
- QString msg = tr("Installing %1..").arg(update->name());
- int minPc = pcDiff*i + 50;
- int maxPc = minPc + pcDiff;
- reportProgress(minPc, msg);
-
- if (update->application() != d->application)
- continue;
-
- QDir::setCurrent(oldCWD.absolutePath());
- if (!installUpdate(update, minPc, maxPc)) {
- d->application->packagesInfo()->writeToDisk();
- return;
- }
- }
-
- d->application->packagesInfo()->writeToDisk();
-
- // Global progress
- reportProgress(95, tr("Finished installing updates. Now removing temporary files and directories.."));
-
- // Restore the current working directory of the application
- QDir::setCurrent(oldCWD.absolutePath());
-
- // Remove all the toRemoveDirs
- for (int i = 0; i < d->toRemoveDirs.count(); i++) {
- QDir dir(d->toRemoveDirs[i]);
- d->removeDirectory(dir);
-
- QString dirName = dir.dirName();
- dir.cdUp();
- dir.rmdir(dirName);
- }
- d->toRemoveDirs.clear();
-
- // Global progress
- reportProgress(100, tr("Removed temporary files and directories"));
- reportDone();
-}
-
-/*!
- \internal
-*/
-bool UpdateInstaller::doStop()
-{
- return false;
-}
-
-/*!
- \internal
-*/
-bool UpdateInstaller::doPause()
-{
- return false;
-}
-
-/*!
- \internal
-*/
-bool UpdateInstaller::doResume()
-{
- return false;
-}
-
-bool UpdateInstaller::installUpdate(Update *update, int minPc, int maxPc)
-{
- QString updateName = update->name();
-
- // Sanity checks
- if (!update->isDownloaded()) {
- QString msg = tr("Could not download update '%1'").arg(update->name());
- reportError(msg);
- return false;
- }
-
- // Step 1: Prepare a directory into which the UpdateFile will be unpacked.
- // If update file is C:/Users/PRASHA~1/AppData/Local/Temp/qt_temp.Hp1204 and
- // the applicationn name "MyApplication"
- // Then the directory would be %USERDIR%/AppData/Local/Temp/MyApplication_Update1
- static int count = 0;
- QString dirName = QString::fromLatin1("%1_Update%2").arg(d->application->applicationName(), QString::number(count++));
- QString updateFile = update->downloadedFileName();
- QFileInfo fi(updateFile);
- QDir dir(fi.absolutePath());
- dir.mkdir(dirName);
- dir.cd(dirName);
- d->toRemoveDirs << dir.absolutePath();
-
- // Step 2: Unpack the update file into the update directory
- UFUncompressor uncompressor;
- uncompressor.setFileName(updateFile);
- uncompressor.setDestination(dir.absolutePath());
-
- if (!uncompressor.uncompress()) {
- reportError(tr("Couldn't uncompress update: %1")
- .arg(uncompressor.errorString()));
- return false;
- }
-
- // Step 3: Find out the directory in which UpdateInstructions.xml can be found
- QDir updateDir = dir;
- while (!updateDir.exists(QLatin1String("UpdateInstructions.xml"))) {
- QString path = updateDir.absolutePath();
- QFileInfoList fiList = updateDir.entryInfoList(QDir::Dirs|QDir::NoDotAndDotDot);
- if (!fiList.count()) { // || fiList.count() >= 2 )
- QString msg = tr("Could not find UpdateInstructions.xml for %1").arg(update->name());
- reportError(msg);
- return false;
- }
- updateDir.cd(fiList.first().fileName());
- }
-
- // Set the application's current working directory as updateDir
- QDir::setCurrent(updateDir.absolutePath());
-
- // Step 4: Now load the UpdateInstructions.xml file
- QDomDocument doc;
- QFile file(updateDir.absoluteFilePath(QLatin1String( "UpdateInstructions.xml" )));
- if (!file.open(QFile::ReadOnly)) {
- QString msg = tr("Could not read UpdateInstructions.xml of %1").arg(update->name());
- reportError(msg);
- return false;
- }
- if (!doc.setContent(&file)) {
- QString msg = tr("Could not read UpdateInstructions.xml of %1").arg(update->name());
- reportError(msg);
- return false;
- }
-
- // Now parse and execute update operations
- QDomNodeList operEList = doc.elementsByTagName(QLatin1String( "UpdateOperation" ));
- QString msg = tr("Installing %1").arg(updateName);
-
- for (int i = 0; i < operEList.count(); i++) {
- int pc = computePercent(i+1, operEList.count());
- pc = computeProgressPercentage(minPc, maxPc, pc);
- reportProgress(pc, msg);
-
- // Fetch the important XML elements in UpdateOperation
- QDomElement operE = operEList.at(i).toElement();
- QDomElement nameE = operE.firstChildElement(QLatin1String("Name"));
- QDomElement errorE = operE.firstChildElement(QLatin1String("OnError"));
- QDomElement argE = operE.firstChildElement(QLatin1String("Arg"));
-
- // Figure out information about the update operation to perform
- QString operName = nameE.text();
- QString onError = errorE.attribute(QLatin1String("Action"), QLatin1String("Abort"));
- QStringList args;
- while(!argE.isNull()) {
- args << argE.text();
- argE = argE.nextSiblingElement(QLatin1String("Arg"));
- }
-
- //QString operSignature = QString::fromLatin1("%1(%2)").arg(operName, args.join( QLatin1String( ", ") ) );
-
- // Fetch update operation
- UpdateOperation *const updateOperation = UpdateOperationFactory::instance().create(operName);
- if (!updateOperation) {
- QString errMsg = tr("Update operation %1 not supported").arg(operName);
- reportError(errMsg);
-
- if (onError == QLatin1String("Continue"))
- continue;
-
- if (onError == QLatin1String("Abort"))
- return false;
-
- if (onError == QLatin1String("AskUser")) {
- // TODO:
- continue;
- }
- }
-
- // Now resolve special fields in arguments
- d->resolveArguments(args);
-
- // Now set the arguments to the update operation and execute the update operation
- updateOperation->setArguments(args);
- updateOperation->setApplication(d->application);
- const bool success = updateOperation->performOperation();
-
- updateOperation->clear();
-
- if (!success) {
- QString errMsg = tr("Cannot execute '%1'").arg(updateOperation->operationCommand());
- reportError(errMsg);
-
- if (onError == QLatin1String("Continue"))
- continue;
-
- if (onError == QLatin1String("Abort"))
- return false;
-
- if (onError == QLatin1String("AskUser")) {
- // TODO:
- continue;
- }
- }
- delete updateOperation;
- }
-
- Q_FOREACH (UpdateOperation *updateOperation, update->operations())
- updateOperation->performOperation();
-
- msg = tr("Finished installing update %1").arg(update->name());
- reportProgress(maxPc, msg);
- return true;
-}
-
-/*!
- \internal
-*/
-void UpdateInstaller::Private::slotUpdateDownloadProgress(int percent)
-{
- // 0-49 percent progress is dedicated for the download of updates
- Update *update = qobject_cast<Update *>(q->sender());
- if (!update)
- return;
-
- int oldPc = update->property("_ProgressPc_").toInt();
- int diffPc = percent-oldPc;
- if (diffPc <= 0)
- return;
-
- currentProgressPc += diffPc;
- update->setProperty("_ProgressPc_", percent);
-}
-
-/*!
- \internal
-*/
-void UpdateInstaller::Private::slotUpdateDownloadDone()
-{
- ++updateDownloadDoneCount;
-}
-
-void UpdateInstaller::Private::resolveArguments(QStringList& args)
-{
- for (int i = 0; i < args.count(); i++) {
- QString arg = args[i];
-
- arg = arg.replace(QLatin1String("{APPDIR}"), application->applicationDirectory());
- arg = arg.replace(QLatin1String("{HOME}"), QDir::homePath());
- arg = arg.replace(QLatin1String("{APPNAME}"), application->applicationName());
- arg = arg.replace(QLatin1String("{APPVERSION}"), application->applicationVersion());
- arg = arg.replace(QLatin1String("{CURPATH}"), QDir::currentPath());
- arg = arg.replace(QLatin1String("{ROOT}"), QDir::rootPath());
- arg = arg.replace(QLatin1String("{TEMP}"), QDir::tempPath());
-
- args[i] = arg;
- }
-}
-
-void UpdateInstaller::Private::removeDirectory(const QDir &dir)
-{
- QFileInfoList fiList = dir.entryInfoList(QDir::Dirs|QDir::Files|QDir::NoDotAndDotDot);
- if (!fiList.count())
- return;
-
- for (int i = 0; i < fiList.count(); i++) {
- QFileInfo fi = fiList[i];
- if (fi.isDir()) {
- QDir childDir = fi.absoluteFilePath();
- removeDirectory(childDir);
- dir.rmdir(childDir.dirName());
- } else if(fi.isFile()) {
- QFile::remove(fi.absoluteFilePath());
- }
- }
-}
-
-#include "moc_kdupdaterupdateinstaller.cpp"
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateinstaller.h b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateinstaller.h
deleted file mode 100644
index 4470ab6db..000000000
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateinstaller.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
-**
-** This file is part of the KD Tools library.
-**
-** Licensees holding valid commercial KD Tools licenses may use this file in
-** accordance with the KD Tools Commercial License Agreement provided with
-** the Software.
-**
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU Lesser General Public License version 2 and version 3 as published by the
-** Free Software Foundation and appearing in the file LICENSE.LGPL included.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** Contact info@kdab.com if any conditions of this licensing are not
-** clear to you.
-**
-**********************************************************************/
-
-#ifndef KD_UPDATER_UPDATE_INSTALLER_H
-#define KD_UPDATER_UPDATE_INSTALLER_H
-
-#include "kdupdater.h"
-#include "kdupdatertask.h"
-
-#include <QList>
-
-namespace KDUpdater {
-
-class Application;
-class Update;
-
-class KDTOOLS_EXPORT UpdateInstaller : public Task
-{
- Q_OBJECT
-
-public:
- explicit UpdateInstaller(Application *application);
- ~UpdateInstaller();
-
- Application *application() const;
-
- void setUpdatesToInstall(const QList<Update *> &updates);
- QList<Update *> updatesToInstall() const;
-
-private:
- void doRun();
- bool doStop();
- bool doPause();
- bool doResume();
-
- bool installUpdate(Update *update, int minPc, int maxPc);
-
- class Private;
- Private *d;
-
- Q_PRIVATE_SLOT(d, void slotUpdateDownloadProgress(int))
- Q_PRIVATE_SLOT(d, void slotUpdateDownloadDone())
-};
-
-} // namespace KDUpdater
-
-#endif // KD_UPDATER_UPDATE_INSTALLER_H