summaryrefslogtreecommitdiffstats
path: root/installerbuilder
diff options
context:
space:
mode:
authorhjk <qthjk@ovi.com>2011-11-19 12:41:47 +0100
committerTim Jenssen <tim.jenssen@nokia.com>2011-11-21 13:14:57 +0100
commit7a3e381ec098a5f011aeea69c5ec58dd66421545 (patch)
treee5081aa5037065fa4e429e2e82f61c471d41e49f /installerbuilder
parentec0f2ecb6f50805df4bb0f5f578531707d0eb575 (diff)
Whitespace style.
Change-Id: Ia850cf4766cf88054e9ff1a46371623835bf0137 Reviewed-by: Tim Jenssen <tim.jenssen@nokia.com>
Diffstat (limited to 'installerbuilder')
-rw-r--r--installerbuilder/binarycreator/binarycreator.cpp2
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/environment.cpp40
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdjob.cpp108
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdlockfile.cpp12
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdlockfile_unix.cpp30
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdlockfile_win.cpp33
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdrunoncechecker.cpp79
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdsavefile.cpp324
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdselfrestarter.cpp44
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo.cpp55
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo_mac.cpp18
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo_win.cpp62
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo_x11.cpp81
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterapplication.cpp96
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterapplication.h2
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterfiledownloader.cpp83
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterfiledownloaderfactory.cpp35
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterpackagesinfo.cpp189
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdupdatersignatureverificationresult.cpp6
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdupdatersignatureverifier.cpp14
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdupdatertask.cpp57
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufcompresscommon.cpp67
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufuncompressor.cpp98
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdate.cpp128
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdatefinder.cpp392
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateinstaller.cpp190
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateoperation.cpp158
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateoperationfactory.cpp32
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateoperations.cpp637
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateoperations.h7
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdatesinfo.cpp233
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdatesinfo_p.h8
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdatesourcesinfo.cpp203
33 files changed, 1698 insertions, 1825 deletions
diff --git a/installerbuilder/binarycreator/binarycreator.cpp b/installerbuilder/binarycreator/binarycreator.cpp
index 200e0481c..405c0d4b4 100644
--- a/installerbuilder/binarycreator/binarycreator.cpp
+++ b/installerbuilder/binarycreator/binarycreator.cpp
@@ -705,7 +705,7 @@ int main(int argc, char **argv)
}
verbose() << " Appending " << archive.fileName() << ".sig ("
<< signature.size() << " bytes)" << std::endl;
- const QSharedPointer< Archive > sigArch(new Archive(arch->name() + ".sig", signature));
+ const QSharedPointer<Archive> sigArch(new Archive(arch->name() + ".sig", signature));
comp.appendArchive(sigArch);
}
}
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/environment.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/environment.cpp
index f269bba72..8bdabb5c5 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/environment.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/environment.cpp
@@ -6,7 +6,8 @@
using namespace KDUpdater;
-class Environment::Private {
+class Environment::Private
+{
public:
static Environment s_instance;
QHash<QString, QString> tempValues;
@@ -15,39 +16,44 @@ public:
Environment Environment::Private::s_instance;
Environment::Environment()
- : d( new Private )
+ : d(new Private)
{
}
-Environment::~Environment() {
+Environment::~Environment()
+{
delete d;
}
-Environment& Environment::instance() {
+Environment &Environment::instance()
+{
return Private::s_instance;
}
-QString Environment::value( const QString& key, const QString& defvalue ) const {
- const QHash<QString,QString>::ConstIterator it = d->tempValues.constFind( key );
- if ( it != d->tempValues.constEnd() )
+QString Environment::value(const QString &key, const QString &defvalue) const
+{
+ const QHash<QString, QString>::ConstIterator it = d->tempValues.constFind(key);
+ if (it != d->tempValues.constEnd())
return *it;
- else
- return QProcessEnvironment::systemEnvironment().value( key, defvalue );
+ return QProcessEnvironment::systemEnvironment().value(key, defvalue);
}
-void Environment::setTemporaryValue( const QString& key, const QString& value ) {
- d->tempValues.insert( key, value );
+void Environment::setTemporaryValue(const QString &key, const QString &value)
+{
+ d->tempValues.insert(key, value);
}
-QProcessEnvironment Environment::applyTo( const QProcessEnvironment& qpe_ ) const {
- QProcessEnvironment qpe( qpe_ );
+QProcessEnvironment Environment::applyTo(const QProcessEnvironment &qpe_) const
+{
+ QProcessEnvironment qpe(qpe_);
QHash<QString, QString>::ConstIterator it = d->tempValues.constBegin();
const QHash<QString, QString>::ConstIterator end = d->tempValues.constEnd();
- for ( ; it != end; ++it )
- qpe.insert( it.key(), it.value() );
+ for ( ; it != end; ++it)
+ qpe.insert(it.key(), it.value());
return qpe;
}
-void Environment::applyTo( QProcess* proc ) {
- proc->setProcessEnvironment( applyTo( proc->processEnvironment() ) );
+void Environment::applyTo(QProcess *proc)
+{
+ proc->setProcessEnvironment(applyTo(proc->processEnvironment()));
}
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdjob.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdjob.cpp
index f1e297bde..4038d4344 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdjob.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdjob.cpp
@@ -24,19 +24,25 @@
#include <QEventLoop>
-class KDJob::Private {
- KDJob* const q;
+class KDJob::Private
+{
+ KDJob *const q;
public:
- explicit Private( KDJob* qq ) : q( qq ), error( KDJob::NoError ), errorString(), caps( KDJob::NoCapabilities ), autoDelete( true ), totalAmount( 100 ), processedAmount( 0 ) {}
+ explicit Private(KDJob *qq)
+ : q(qq), error(KDJob::NoError), caps(KDJob::NoCapabilities), autoDelete(true),
+ totalAmount(100), processedAmount(0)
+ {}
- void delayedStart() {
+ void delayedStart()
+ {
q->doStart();
- emit q->started( q );
+ emit q->started(q);
}
- void waitForSignal( const char* sig ) {
+ void waitForSignal(const char *sig)
+ {
QEventLoop loop;
- q->connect( q, sig, &loop, SLOT(quit()) );
+ q->connect(q, sig, &loop, SLOT(quit()));
loop.exec();
}
@@ -48,82 +54,102 @@ public:
quint64 processedAmount;
};
-KDJob::KDJob( QObject* parent ) : QObject( parent ), d( new Private( this ) ) {
-}
+KDJob::KDJob(QObject *parent)
+ : QObject(parent),
+ d(new Private(this))
+{}
-KDJob::~KDJob() {
+KDJob::~KDJob()
+{
delete d;
}
-bool KDJob::autoDelete() const {
+bool KDJob::autoDelete() const
+{
return d->autoDelete;
}
-void KDJob::setAutoDelete( bool autoDelete ) {
+void KDJob::setAutoDelete(bool autoDelete)
+{
d->autoDelete = autoDelete;
}
-int KDJob::error() const {
+int KDJob::error() const
+{
return d->error;
}
-QString KDJob::errorString() const {
+QString KDJob::errorString() const
+{
return d->errorString;
}
-void KDJob::emitFinished() {
- emit finished( this );
- if ( d->autoDelete )
+void KDJob::emitFinished()
+{
+ emit finished(this);
+ if (d->autoDelete)
deleteLater();
}
-void KDJob::emitFinishedWithError( int error, const QString& errorString ) {
+void KDJob::emitFinishedWithError(int error, const QString &errorString)
+{
d->error = error;
d->errorString = errorString;
emitFinished();
}
-void KDJob::setError( int error ) {
+void KDJob::setError(int error)
+{
d->error = error;
}
-void KDJob::setErrorString( const QString& errorString ) {
+void KDJob::setErrorString(const QString &errorString)
+{
d->errorString = errorString;
}
-void KDJob::waitForStarted() {
- d->waitForSignal( SIGNAL(started(KDJob*)) );
+void KDJob::waitForStarted()
+{
+ d->waitForSignal(SIGNAL(started(KDJob*)));
}
-void KDJob::waitForFinished() {
- d->waitForSignal( SIGNAL(finished(KDJob*)) );
+void KDJob::waitForFinished()
+{
+ d->waitForSignal(SIGNAL(finished(KDJob*)));
}
-KDJob::Capabilities KDJob::capabilities() const {
+KDJob::Capabilities KDJob::capabilities() const
+{
return d->caps;
}
-bool KDJob::hasCapability( Capability c ) const {
- return d->caps.testFlag( c );
+bool KDJob::hasCapability(Capability c) const
+{
+ return d->caps.testFlag(c);
}
-void KDJob::setCapabilities( Capabilities c ) {
+void KDJob::setCapabilities(Capabilities c)
+{
d->caps = c;
}
-void KDJob::start() {
- QMetaObject::invokeMethod( this, "delayedStart", Qt::QueuedConnection );
+void KDJob::start()
+{
+ QMetaObject::invokeMethod(this, "delayedStart", Qt::QueuedConnection);
}
-void KDJob::doCancel() {
+void KDJob::doCancel()
+{
}
-void KDJob::cancel() {
+void KDJob::cancel()
+{
doCancel();
- setError( Canceled );
+ setError(Canceled);
}
-quint64 KDJob::totalAmount() const {
+quint64 KDJob::totalAmount() const
+{
return d->totalAmount;
}
@@ -131,18 +157,20 @@ quint64 KDJob::processedAmount() const {
return d->processedAmount;
}
-void KDJob::setTotalAmount( quint64 amount ) {
- if ( d->totalAmount == amount )
+void KDJob::setTotalAmount(quint64 amount)
+{
+ if (d->totalAmount == amount)
return;
d->totalAmount = amount;
- emit progress( this, d->processedAmount, d->totalAmount );
+ emit progress(this, d->processedAmount, d->totalAmount);
}
-void KDJob::setProcessedAmount( quint64 amount ) {
- if ( d->processedAmount == amount )
+void KDJob::setProcessedAmount(quint64 amount)
+{
+ if (d->processedAmount == amount)
return;
d->processedAmount = amount;
- emit progress( this, d->processedAmount, d->totalAmount );
+ emit progress(this, d->processedAmount, d->totalAmount);
}
#include "moc_kdjob.cpp"
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdlockfile.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdlockfile.cpp
index bc0562c09..3a440b6b0 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdlockfile.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdlockfile.cpp
@@ -24,15 +24,15 @@
#include "kdlockfile_p.h"
-KDLockFile::Private::Private( const QString& filename_ )
- : filename( filename_ )
- , handle( 0 )
- , locked( false )
+KDLockFile::Private::Private(const QString &filename_)
+ : filename(filename_)
+ , handle(0)
+ , locked(false)
{
}
-KDLockFile::KDLockFile( const QString& name )
- : d( new Private( name ) )
+KDLockFile::KDLockFile(const QString &name)
+ : d( new Private(name))
{
}
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdlockfile_unix.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdlockfile_unix.cpp
index 4f6ed3cbb..c40eb3b7d 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdlockfile_unix.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdlockfile_unix.cpp
@@ -35,43 +35,43 @@ KDLockFile::Private::~Private()
bool KDLockFile::Private::lock()
{
- if ( locked )
+ if (locked)
return true;
errorString.clear();
errno = 0;
- handle = open( filename.toLatin1().constData(), O_CREAT | O_RDWR | O_NONBLOCK, 0600 );
- if ( handle == -1 ) {
- errorString = QObject::tr("Could not create lock file %1: %2").arg( filename, QLatin1String( strerror( errno ) ) );
+ handle = open(filename.toLatin1().constData(), O_CREAT | O_RDWR | O_NONBLOCK, 0600);
+ if (handle == -1) {
+ errorString = QObject::tr("Could not create lock file %1: %2").arg(filename, QLatin1String(strerror(errno)));
return false;
}
- const QString pid = QString::number( qApp->applicationPid() );
+ const QString pid = QString::number(qApp->applicationPid());
const QByteArray data = pid.toLatin1();
errno = 0;
qint64 written = 0;
- while ( written < data.size() ) {
- const qint64 n = write( handle, data.constData() + written, data.size() - written );
- if ( n < 0 ) {
+ while (written < data.size()) {
+ const qint64 n = write(handle, data.constData() + written, data.size() - written);
+ if (n < 0) {
errorString = QObject::tr("Could not write PID to lock file %1: %2").arg( filename, QLatin1String( strerror( errno ) ) );
return false;
}
written += n;
}
errno = 0;
- locked = flock( handle, LOCK_NB | LOCK_EX ) != -1;
- if ( !locked )
- errorString = QObject::tr("Could not lock lock file %1: %2").arg( filename, QLatin1String( strerror( errno ) ) );
+ locked = flock(handle, LOCK_NB | LOCK_EX) != -1;
+ if (!locked)
+ errorString = QObject::tr("Could not lock lock file %1: %2").arg(filename, QLatin1String(strerror(errno)));
return locked;
}
bool KDLockFile::Private::unlock()
{
errorString.clear();
- if ( !locked )
+ if (!locked)
return true;
errno = 0;
- locked = flock( handle, LOCK_UN | LOCK_NB ) == -1;
- if ( locked )
- errorString = QObject::tr("Could not unlock lock file %1: %2").arg( filename, QLatin1String( strerror( errno ) ) );
+ locked = flock(handle, LOCK_UN | LOCK_NB) == -1;
+ if (locked)
+ errorString = QObject::tr("Could not unlock lock file %1: %2").arg(filename, QLatin1String(strerror(errno)));
return !locked;
}
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdlockfile_win.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdlockfile_win.cpp
index f7fed60ab..f139bd0d4 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdlockfile_win.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdlockfile_win.cpp
@@ -33,23 +33,23 @@ KDLockFile::Private::~Private()
bool KDLockFile::Private::lock()
{
- const QFileInfo fi( filename );
- handle = CreateFile( filename.toStdWString().data(),
- GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ,
- NULL, fi.exists() ? OPEN_EXISTING : CREATE_NEW,
- FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE, NULL );
+ const QFileInfo fi(filename);
+ handle = CreateFile(filename.toStdWString().data(),
+ GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ,
+ NULL, fi.exists() ? OPEN_EXISTING : CREATE_NEW,
+ FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE, NULL);
- if ( !handle )
+ if (!handle)
return false;
- QString pid = QString::number( qApp->applicationPid() );
+ QString pid = QString::number(qApp->applicationPid());
QByteArray data = pid.toLatin1();
- DWORD bytesWritten;
- const bool wrotePid = WriteFile( handle, data.data(), data.size(), &bytesWritten, NULL );
- if ( !wrotePid )
+ DWORD bytesWritten;
+ const bool wrotePid = WriteFile(handle, data.data(), data.size(), &bytesWritten, NULL);
+ if (!wrotePid)
return false;
- FlushFileBuffers( handle );
+ FlushFileBuffers(handle);
- const bool locked = LockFile( handle, 0, 0, fi.size(), 0 );
+ const bool locked = LockFile(handle, 0, 0, fi.size(), 0);
this->locked = locked;
return locked;
@@ -57,12 +57,11 @@ bool KDLockFile::Private::lock()
bool KDLockFile::Private::unlock()
{
- const QFileInfo fi( filename );
- if ( locked )
- {
- const bool success = UnlockFile( handle, 0, 0, 0, fi.size() );
+ const QFileInfo fi(filename);
+ if (locked) {
+ const bool success = UnlockFile(handle, 0, 0, 0, fi.size());
this->locked = !success;
- CloseHandle( handle );
+ CloseHandle(handle);
return success;
}
return true;
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdrunoncechecker.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdrunoncechecker.cpp
index 1a59dd3f7..86a50728b 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdrunoncechecker.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdrunoncechecker.cpp
@@ -34,29 +34,20 @@
class KDRunOnceChecker::Private
{
public:
- Private( const QString& filename );
- ~Private();
+ Private(const QString &filename);
+
KDLockFile m_lockfile;
bool m_hasLock;
};
-KDRunOnceChecker::Private::Private( const QString& filename )
- : m_lockfile( filename )
- , m_hasLock( false )
-{
-
-}
-
-KDRunOnceChecker::Private::~Private()
-{
-
-}
-
-KDRunOnceChecker::KDRunOnceChecker( const QString& filename )
- :d( new Private( filename ) )
-{
+KDRunOnceChecker::Private::Private(const QString &filename)
+ : m_lockfile(filename)
+ , m_hasLock(false)
+{}
-}
+KDRunOnceChecker::KDRunOnceChecker(const QString &filename)
+ :d(new Private(filename))
+{}
KDRunOnceChecker::~KDRunOnceChecker()
{
@@ -66,23 +57,24 @@ KDRunOnceChecker::~KDRunOnceChecker()
class ProcessnameEquals
{
public:
- ProcessnameEquals( const QString& name ): m_name( name ){}
- bool operator()( const KDSysInfo::ProcessInfo& info )
+ ProcessnameEquals(const QString &name): m_name(name) {}
+
+ bool operator()(const KDSysInfo::ProcessInfo &info)
{
#ifndef Q_WS_WIN
- if( info.name == m_name )
+ if (info.name == m_name)
return true;
- const QFileInfo fi( info.name );
- if( fi.fileName() == m_name || fi.baseName() == m_name )
+ const QFileInfo fi(info.name);
+ if (fi.fileName() == m_name || fi.baseName() == m_name)
return true;
return false;
#else
- if( info.name.toLower() == m_name.toLower() )
+ if (info.name.toLower() == m_name.toLower())
return true;
- if( info.name.toLower() == QDir::toNativeSeparators(m_name.toLower()) )
+ if (info.name.toLower() == QDir::toNativeSeparators(m_name.toLower()))
return true;
- const QFileInfo fi( info.name );
- if( fi.fileName().toLower() == m_name.toLower() || fi.baseName().toLower() == m_name.toLower() )
+ const QFileInfo fi(info.name);
+ if (fi.fileName().toLower() == m_name.toLower() || fi.baseName().toLower() == m_name.toLower())
return true;
return info.name == m_name;
#endif
@@ -92,39 +84,34 @@ private:
QString m_name;
};
-bool KDRunOnceChecker::isRunning( Dependencies depends )
+bool KDRunOnceChecker::isRunning(Dependencies depends)
{
bool running = false;
- switch ( depends )
- {
- case( Lockfile ):
- {
+ switch (depends) {
+ case Lockfile: {
const bool locked = d->m_hasLock || d->m_lockfile.lock();
- if ( locked )
+ if (locked)
d->m_hasLock = true;
running = running || ! locked;
}
break;
- case( ProcessList ):
- {
- const QList< KDSysInfo::ProcessInfo > allProcesses = KDSysInfo::runningProcesses();
+ case ProcessList: {
+ const QList<KDSysInfo::ProcessInfo> allProcesses = KDSysInfo::runningProcesses();
const QString appName = qApp->applicationFilePath();
- //QList< KDSysInfo::ProcessInfo >::const_iterator it = std::find_if( allProcesses.constBegin(), allProcesses.constEnd(), ProcessnameEquals( appName ) );
- const int count = std::count_if( allProcesses.constBegin(), allProcesses.constEnd(), ProcessnameEquals( appName ) );
+ //QList< KDSysInfo::ProcessInfo >::const_iterator it = std::find_if(allProcesses.constBegin(), allProcesses.constEnd(), ProcessnameEquals(appName));
+ const int count = std::count_if(allProcesses.constBegin(), allProcesses.constEnd(), ProcessnameEquals(appName));
running = running || /*it != allProcesses.constEnd()*/count > 1;
}
break;
- case( Both ):
- {
- const QList< KDSysInfo::ProcessInfo > allProcesses = KDSysInfo::runningProcesses();
+ case Both: {
+ const QList<KDSysInfo::ProcessInfo> allProcesses = KDSysInfo::runningProcesses();
const QString appName = qApp->applicationFilePath();
- //QList< KDSysInfo::ProcessInfo >::const_iterator it = std::find_if( allProcesses.constBegin(), allProcesses.constEnd(), ProcessnameEquals( appName ) );
- const int count = std::count_if( allProcesses.constBegin(), allProcesses.constEnd(), ProcessnameEquals( appName ) );
+ //QList< KDSysInfo::ProcessInfo >::const_iterator it = std::find_if(allProcesses.constBegin(), allProcesses.constEnd(), ProcessnameEquals(appName));
+ const int count = std::count_if(allProcesses.constBegin(), allProcesses.constEnd(), ProcessnameEquals(appName));
const bool locked = d->m_hasLock || d->m_lockfile.lock();
- if ( locked )
+ if (locked)
d->m_hasLock = true;
- running = running || ( /*it != allProcesses.constEnd()*/count > 1 && !locked );
-
+ running = running || ( /*it != allProcesses.constEnd()*/count > 1 && !locked);
}
break;
}
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdsavefile.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdsavefile.cpp
index 8c2a80f49..d866968cf 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdsavefile.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdsavefile.cpp
@@ -35,102 +35,108 @@
#include <sys/types.h>
#include <fcntl.h>
-static int permissionsToMode( QFile::Permissions p, bool* ok ) {
- Q_ASSERT( ok );
+static int permissionsToMode(QFile::Permissions p, bool *ok)
+{
+ Q_ASSERT(ok);
int m = 0;
#ifdef Q_OS_WIN
//following qfsfileengine_win.cpp: QFSFileEngine::setPermissions()
- if ( p & QFile::ReadOwner || p & QFile::ReadUser || p & QFile::ReadGroup || p & QFile::ReadOther )
+ if (p & QFile::ReadOwner || p & QFile::ReadUser || p & QFile::ReadGroup || p & QFile::ReadOther)
m |= _S_IREAD;
- if ( p & QFile::WriteOwner || p & QFile::WriteUser || p & QFile::WriteGroup || p & QFile::WriteOther )
+ if (p & QFile::WriteOwner || p & QFile::WriteUser || p & QFile::WriteGroup || p & QFile::WriteOther)
m |= _S_IWRITE;
*ok = m != 0;
#else
- if ( p & QFile::ReadUser )
+ if (p & QFile::ReadUser)
m |= S_IRUSR;
- if ( p & QFile::WriteUser )
+ if (p & QFile::WriteUser)
m |= S_IWUSR;
- if ( p & QFile::ExeUser)
+ if (p & QFile::ExeUser)
m |= S_IXUSR;
- if ( p & QFile::ReadGroup )
+ if (p & QFile::ReadGroup)
m |= S_IRGRP;
- if ( p & QFile::WriteGroup )
+ if (p & QFile::WriteGroup)
m |= S_IWGRP;
- if ( p & QFile::ExeGroup )
+ if (p & QFile::ExeGroup)
m |= S_IXGRP;
- if ( p & QFile::ReadOther )
+ if (p & QFile::ReadOther)
m |= S_IROTH;
- if ( p & QFile::WriteOther )
+ if (p & QFile::WriteOther)
m |= S_IWOTH;
- if ( p & QFile::ExeOther )
+ if (p & QFile::ExeOther)
m |= S_IXOTH;
*ok = true;
#endif
return m;
}
-static bool sync( int fd ) {
+static bool sync(int fd)
+{
#ifdef Q_OS_WIN
- return _commit( fd ) == 0;
+ return _commit(fd) == 0;
#else
- return fsync( fd ) == 0;
+ return fsync(fd) == 0;
#endif
}
-static QString makeAbsolute( const QString& path ) {
- if ( QDir::isAbsolutePath( path ) )
+static QString makeAbsolute(const QString &path)
+{
+ if (QDir::isAbsolutePath(path))
return path;
return QDir::currentPath() + QLatin1String("/") + path;
}
-static int myOpen( const QString& path, int flags, int mode ) {
+static int myOpen(const QString &path, int flags, int mode)
+{
#ifdef Q_OS_WIN
int fd;
- _wsopen_s( &fd, reinterpret_cast<const wchar_t*>( path.utf16() ), flags, _SH_DENYRW, mode );
+ _wsopen_s(&fd, reinterpret_cast<const wchar_t *>(path.utf16()), flags, _SH_DENYRW, mode);
return fd;
#else
- return open( QFile::encodeName( path ).constData(), flags, mode );
+ return open(QFile::encodeName(path).constData(), flags, mode);
#endif
}
-static void myClose( int fd ) {
+static void myClose(int fd)
+{
#ifdef Q_OS_WIN
- _close( fd );
+ _close(fd);
#else
- close( fd );
+ close(fd);
#endif
}
-static bool touchFile( const QString& path, QFile::Permissions p ) {
+static bool touchFile(const QString &path, QFile::Permissions p)
+{
bool ok;
- const int mode = permissionsToMode( p, &ok );
- if ( !ok )
+ const int mode = permissionsToMode(p, &ok);
+ if (!ok)
return false;
- const int fd = myOpen( QDir::toNativeSeparators( path ), O_WRONLY|O_CREAT, mode );
- if ( fd < 0 )
- {
- QFile file( path );
- if( !file.open( QIODevice::WriteOnly ) )
+ const int fd = myOpen(QDir::toNativeSeparators(path), O_WRONLY|O_CREAT, mode);
+ if (fd < 0) {
+ QFile file(path);
+ if (!file.open(QIODevice::WriteOnly))
return false;
- if( !file.setPermissions( p ) ) {
- QFile::remove( path );
+ if (!file.setPermissions(p)) {
+ QFile::remove(path);
return false;
}
return true;
}
- sync( fd );
- myClose( fd );
+ sync(fd);
+ myClose(fd);
return true;
}
-static QFile* createFile( const QString& path, QIODevice::OpenMode m, QFile::Permissions p, bool* openOk ) {
- Q_ASSERT( openOk );
- if ( !touchFile( path, p ) )
+static QFile *createFile(const QString &path, QIODevice::OpenMode m, QFile::Permissions p, bool *openOk)
+{
+ Q_ASSERT(openOk);
+ if (!touchFile(path, p))
return 0;
- std::auto_ptr<QFile> file( new QFile( path ) );
- *openOk = file->open( m | QIODevice::Append );
- if ( !*openOk )
- QFile::remove( path ); // try to remove empty file
+ std::auto_ptr<QFile> file(new QFile(path));
+ *openOk = file->open(m | QIODevice::Append);
+ if (!*openOk)
+ QFile::remove(path); // try to remove empty file
return file.release();
}
@@ -138,13 +144,13 @@ static QFile* createFile( const QString& path, QIODevice::OpenMode m, QFile::Per
Generates a temporary file name based on template \a path
\internal
*/
-static QString generateTempFileName( const QString& path )
+static QString generateTempFileName(const QString &path)
{
- const QString tmp = path + QLatin1String( "tmp.dsfdf.%1" ); //TODO: use random suffix
+ const QString tmp = path + QLatin1String("tmp.dsfdf.%1"); //TODO: use random suffix
int count = 1;
- while ( QFile::exists( tmp.arg( count ) ) )
+ while (QFile::exists(tmp.arg(count)))
++count;
- return tmp.arg( count );
+ return tmp.arg(count);
}
/*!
@@ -154,86 +160,100 @@ static QString generateTempFileName( const QString& path )
*/
-class KDSaveFile::Private {
- KDSaveFile* const q;
+class KDSaveFile::Private
+{
+ KDSaveFile *const q;
public:
- explicit Private( const QString& fname, KDSaveFile* qq ) : q( qq ),
+ explicit Private(const QString &fname, KDSaveFile *qq)
+ : q(qq),
#ifdef Q_OS_WIN
- backupExtension( QLatin1String(".bak") ),
+ backupExtension(QLatin1String(".bak")),
#else
- backupExtension( QLatin1String("~") ),
+ backupExtension(QLatin1String("~")),
#endif
- permissions( QFile::ReadUser|QFile::WriteUser), filename( fname ), tmpFile() {
+ permissions(QFile::ReadUser|QFile::WriteUser), filename(fname), tmpFile()
+ {
//TODO respect umask instead of hardcoded default permissions
}
- ~Private() {
+ ~Private()
+ {
deleteTempFile();
}
- bool deleteTempFile() {
- if ( !tmpFile )
+ bool deleteTempFile()
+ {
+ if (!tmpFile)
return true;
const QString name = tmpFile->fileName();
delete tmpFile;
//force a real close by deleting the object, before deleting the actual file. Needed on Windows
- QFile tmp( name );
+ QFile tmp(name);
return tmp.remove();
}
- bool recreateTemporaryFile( QIODevice::OpenMode mode ) {
+ bool recreateTemporaryFile(QIODevice::OpenMode mode)
+ {
deleteTempFile();
bool ok;
- tmpFile = createFile( generateTempFileName( filename ), mode, permissions, &ok );
- QObject::connect( tmpFile, SIGNAL(aboutToClose()), q, SIGNAL(aboutToClose()) );
- QObject::connect( tmpFile, SIGNAL(bytesWritten(qint64)), q, SIGNAL(bytesWritten(qint64)) );
- QObject::connect( tmpFile, SIGNAL(readChannelFinished()), q, SIGNAL(readChannelFinished()) );
- QObject::connect( tmpFile, SIGNAL(readyRead()), q, SIGNAL(readyRead()) );
+ tmpFile = createFile(generateTempFileName( filename ), mode, permissions, &ok);
+ QObject::connect(tmpFile, SIGNAL(aboutToClose()), q, SIGNAL(aboutToClose()));
+ QObject::connect(tmpFile, SIGNAL(bytesWritten(qint64)), q, SIGNAL(bytesWritten(qint64)));
+ QObject::connect(tmpFile, SIGNAL(readChannelFinished()), q, SIGNAL(readChannelFinished()));
+ QObject::connect(tmpFile, SIGNAL(readyRead()), q, SIGNAL(readyRead()));
return ok;
}
- QString generateBackupName() const {
+ QString generateBackupName() const
+ {
const QString bf = filename + backupExtension;
- if ( !QFile::exists( bf ) )
+ if (!QFile::exists(bf))
return bf;
int count = 1;
- while ( QFile::exists( bf + QString::number( count ) ) )
+ while (QFile::exists(bf + QString::number(count)))
++count;
- return bf + QString::number( count );
+ return bf + QString::number(count);
}
- void propagateErrors() {
- if ( !tmpFile )
+ void propagateErrors()
+ {
+ if (!tmpFile)
return;
- q->setErrorString( tmpFile->errorString() );
+ q->setErrorString(tmpFile->errorString());
}
+
QString backupExtension;
QFile::Permissions permissions;
QString filename;
QPointer<QFile> tmpFile;
};
-KDSaveFile::KDSaveFile( const QString& filename, QObject* parent ) : QIODevice( parent ), d( new Private( makeAbsolute( filename ), this ) ) {
-}
-KDSaveFile::~KDSaveFile() {
+KDSaveFile::KDSaveFile(const QString &filename, QObject *parent)
+ : QIODevice(parent), d( new Private(makeAbsolute(filename), this))
+{}
+
+KDSaveFile::~KDSaveFile()
+{
delete d;
}
-void KDSaveFile::close() {
+void KDSaveFile::close()
+{
d->deleteTempFile();
QIODevice::close();
}
-bool KDSaveFile::open( OpenMode mode ) {
- setOpenMode( QIODevice::NotOpen );
- if ( mode & QIODevice::Append ) {
- setErrorString( tr("Append mode not supported.") );
+bool KDSaveFile::open(OpenMode mode)
+{
+ setOpenMode(QIODevice::NotOpen);
+ if (mode & QIODevice::Append) {
+ setErrorString(tr("Append mode not supported."));
return false;
}
- if ( ( mode & QIODevice::WriteOnly ) == 0 ) {
- setErrorString( tr("Read-only access not supported.") );
+ if ((mode & QIODevice::WriteOnly) == 0){
+ setErrorString(tr("Read-only access not supported."));
return false;
}
@@ -242,167 +262,191 @@ bool KDSaveFile::open( OpenMode mode ) {
// setErrorString( tr("The target file %1 exists and is not writable").arg( d->filename ) );
// return false;
//}
- const bool opened = d->recreateTemporaryFile( mode );
- if ( opened ) {
- setOpenMode( mode );
+ const bool opened = d->recreateTemporaryFile(mode);
+ if (opened) {
+ setOpenMode(mode);
}
//if target file already exists, apply permissions of existing file to temp file
return opened;
}
-bool KDSaveFile::atEnd() {
+bool KDSaveFile::atEnd()
+{
return d->tmpFile ? d->tmpFile->atEnd() : QIODevice::atEnd();
}
-qint64 KDSaveFile::bytesAvailable() const {
+qint64 KDSaveFile::bytesAvailable() const
+{
return d->tmpFile ? d->tmpFile->bytesAvailable() : QIODevice::bytesAvailable();
}
-qint64 KDSaveFile::bytesToWrite() const {
+qint64 KDSaveFile::bytesToWrite() const
+{
return d->tmpFile ? d->tmpFile->bytesToWrite() : QIODevice::bytesToWrite();
}
-bool KDSaveFile::canReadLine() const {
+bool KDSaveFile::canReadLine() const
+{
return d->tmpFile ? d->tmpFile->canReadLine() : QIODevice::canReadLine();
}
-bool KDSaveFile::isSequential() const {
+bool KDSaveFile::isSequential() const
+{
return d->tmpFile ? d->tmpFile->isSequential() : QIODevice::isSequential();
}
-qint64 KDSaveFile::pos() const {
+qint64 KDSaveFile::pos() const
+{
return d->tmpFile ? d->tmpFile->pos() : QIODevice::pos();
}
-bool KDSaveFile::reset() {
+bool KDSaveFile::reset()
+{
return d->tmpFile ? d->tmpFile->reset() : QIODevice::reset();
}
-bool KDSaveFile::seek( qint64 pos ) {
- const bool ret = d->tmpFile ? d->tmpFile->seek( pos ) : QIODevice::seek( pos );
- if ( !ret )
+bool KDSaveFile::seek(qint64 pos)
+{
+ const bool ret = d->tmpFile ? d->tmpFile->seek(pos) : QIODevice::seek(pos);
+ if (!ret)
d->propagateErrors();
return ret;
}
-qint64 KDSaveFile::size() const {
+qint64 KDSaveFile::size() const
+{
return d->tmpFile ? d->tmpFile->size() : QIODevice::size();
}
-bool KDSaveFile::waitForBytesWritten( int msecs ) {
- return d->tmpFile ? d->tmpFile->waitForBytesWritten( msecs ) : QIODevice::waitForBytesWritten( msecs );
+bool KDSaveFile::waitForBytesWritten(int msecs)
+{
+ return d->tmpFile ? d->tmpFile->waitForBytesWritten(msecs) : QIODevice::waitForBytesWritten(msecs);
}
-bool KDSaveFile::waitForReadyRead( int msecs ) {
- return d->tmpFile ? d->tmpFile->waitForReadyRead( msecs ) : QIODevice::waitForReadyRead( msecs );
+bool KDSaveFile::waitForReadyRead(int msecs)
+{
+ return d->tmpFile ? d->tmpFile->waitForReadyRead(msecs) : QIODevice::waitForReadyRead(msecs);
}
-bool KDSaveFile::commit( KDSaveFile::CommitMode mode ) {
- if ( !d->tmpFile )
+bool KDSaveFile::commit(KDSaveFile::CommitMode mode)
+{
+ if (!d->tmpFile)
return false;
const QString tmpfname = d->tmpFile->fileName();
d->tmpFile->flush();
delete d->tmpFile;
- QFile orig( d->filename );
+ QFile orig(d->filename);
QString backup;
- if ( orig.exists() ) {
+ if (orig.exists()) {
backup = d->generateBackupName();
- if ( !orig.rename( backup ) ) {
- setErrorString( tr("Could not backup existing file %1: %2").arg( d->filename, orig.errorString() ) );
- QFile tmp( tmpfname );
- if ( !tmp.remove() ) // TODO how to report this error?
+ if (!orig.rename(backup)) {
+ setErrorString(tr("Could not backup existing file %1: %2").arg( d->filename, orig.errorString()));
+ QFile tmp(tmpfname);
+ if (!tmp.remove()) // TODO how to report this error?
qWarning() << "Could not remove temp file" << tmpfname << tmp.errorString();
- if ( mode != OverwriteExistingFile )
+ if (mode != OverwriteExistingFile)
return false;
}
}
- QFile target( tmpfname );
- if ( !target.rename( d->filename ) ) {
- setErrorString( target.errorString() );
+ QFile target(tmpfname);
+ if (!target.rename(d->filename)) {
+ setErrorString(target.errorString());
return false;
}
- if ( mode == OverwriteExistingFile ) {
- QFile tmp( backup );
- const bool removed = !tmp.exists() || tmp.remove( backup );
- if ( !removed )
+ if (mode == OverwriteExistingFile) {
+ QFile tmp(backup);
+ const bool removed = !tmp.exists() || tmp.remove(backup);
+ if (!removed)
qWarning() << "Could not remove the backup: " << tmp.errorString();
}
return true;
}
-QString KDSaveFile::fileName() const {
+QString KDSaveFile::fileName() const
+{
return d->filename;
}
-void KDSaveFile::setFileName( const QString& filename ) {
- const QString fn = makeAbsolute( filename );
- if ( fn == d->filename )
+void KDSaveFile::setFileName(const QString &filename)
+{
+ const QString fn = makeAbsolute(filename);
+ if (fn == d->filename)
return;
close();
delete d->tmpFile;
d->filename = fn;
}
-qint64 KDSaveFile::readData( char* data, qint64 maxSize ) {
- if ( !d->tmpFile ) {
- setErrorString( tr("TODO") );
+qint64 KDSaveFile::readData(char *data, qint64 maxSize)
+{
+ if (!d->tmpFile) {
+ setErrorString(tr("TODO"));
return -1;
}
- const qint64 ret = d->tmpFile->read( data, maxSize );
+ const qint64 ret = d->tmpFile->read(data, maxSize);
d->propagateErrors();
return ret;
}
-qint64 KDSaveFile::readLineData( char* data, qint64 maxSize ) {
- if ( !d->tmpFile ) {
- setErrorString( tr("TODO") );
+qint64 KDSaveFile::readLineData(char *data, qint64 maxSize)
+{
+ if (!d->tmpFile) {
+ setErrorString(tr("TODO"));
return -1;
}
- const qint64 ret = d->tmpFile->readLine( data, maxSize );
+ const qint64 ret = d->tmpFile->readLine(data, maxSize);
d->propagateErrors();
return ret;
}
-qint64 KDSaveFile::writeData( const char* data, qint64 maxSize ) {
- if ( !d->tmpFile ) {
- setErrorString( tr("TODO") );
+qint64 KDSaveFile::writeData(const char *data, qint64 maxSize)
+{
+ if (!d->tmpFile) {
+ setErrorString(tr("TODO"));
return -1;
}
- const qint64 ret = d->tmpFile->write( data, maxSize );
+ const qint64 ret = d->tmpFile->write(data, maxSize);
d->propagateErrors();
return ret;
}
-bool KDSaveFile::flush() {
+bool KDSaveFile::flush()
+{
return d->tmpFile ? d->tmpFile->flush() : false;
}
-bool KDSaveFile::resize( qint64 sz ) {
- return d->tmpFile ? d->tmpFile->resize( sz ) : false;
+bool KDSaveFile::resize(qint64 sz)
+{
+ return d->tmpFile ? d->tmpFile->resize(sz) : false;
}
-int KDSaveFile::handle() const {
+int KDSaveFile::handle() const
+{
return d->tmpFile ? d->tmpFile->handle() : -1;
}
-QFile::Permissions KDSaveFile::permissions() const {
+QFile::Permissions KDSaveFile::permissions() const
+{
return d->tmpFile ? d->tmpFile->permissions() : d->permissions;
}
-bool KDSaveFile::setPermissions( QFile::Permissions p ) {
+bool KDSaveFile::setPermissions(QFile::Permissions p)
+{
d->permissions = p;
- if ( d->tmpFile )
- return d->tmpFile->setPermissions( p );
+ if (d->tmpFile)
+ return d->tmpFile->setPermissions(p);
return false;
}
-void KDSaveFile::setBackupExtension( const QString& ext ) {
+void KDSaveFile::setBackupExtension(const QString &ext)
+{
d->backupExtension = ext;
}
-QString KDSaveFile::backupExtension() const {
+QString KDSaveFile::backupExtension() const
+{
return d->backupExtension;
}
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdselfrestarter.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdselfrestarter.cpp
index c739f82dc..22457bd92 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdselfrestarter.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdselfrestarter.cpp
@@ -26,54 +26,62 @@
#include <QtCore/QDir>
#include <QtCore/QProcess>
-class KDSelfRestarter::Private {
+class KDSelfRestarter::Private
+{
public:
- Private( int argc, char** argv ) : restartOnQuit( false ) {
- executable = QString::fromLocal8Bit( argv[0] );
+ Private(int argc, char *argv[])
+ : restartOnQuit(false)
+ {
+ executable = QString::fromLocal8Bit(argv[0]);
workingPath = QDir::currentPath();
- for ( int i = 1; i < argc; ++i )
- args << QString::fromLocal8Bit( argv[i] );
+ for (int i = 1; i < argc; ++i)
+ args << QString::fromLocal8Bit(argv[i]);
}
Private()
{
executable = qApp->applicationFilePath();
workingPath = QDir::currentPath();
- args = qApp->arguments().mid( 1 );
+ args = qApp->arguments().mid(1);
}
- ~Private() {
- if ( restartOnQuit )
- QProcess::startDetached( executable, args, workingPath );
+ ~Private()
+ {
+ if (restartOnQuit)
+ QProcess::startDetached(executable, args, workingPath);
}
QString executable;
QStringList args;
bool restartOnQuit;
QString workingPath;
- static KDSelfRestarter* instance;
+ static KDSelfRestarter *instance;
};
-KDSelfRestarter* KDSelfRestarter::Private::instance = 0;
+KDSelfRestarter *KDSelfRestarter::Private::instance = 0;
-KDSelfRestarter::KDSelfRestarter( int argc, char** argv ) : d( new Private( argc, argv ) ) {
- Q_ASSERT_X( !Private::instance, Q_FUNC_INFO, "Cannot create more than one KDSelfRestarter instance" );
+KDSelfRestarter::KDSelfRestarter(int argc, char *argv[])
+ : d(new Private(argc, argv))
+{
+ Q_ASSERT_X(!Private::instance, Q_FUNC_INFO, "Cannot create more than one KDSelfRestarter instance");
Private::instance = this;
}
KDSelfRestarter::~KDSelfRestarter()
{
- Q_ASSERT_X( Private::instance == this, Q_FUNC_INFO, "Cannot create more than one KDSelfRestarter instance" );
+ Q_ASSERT_X(Private::instance == this, Q_FUNC_INFO, "Cannot create more than one KDSelfRestarter instance");
delete d;
Private::instance = 0;
}
-void KDSelfRestarter::setRestartOnQuit( bool restart ) {
- Q_ASSERT_X( Private::instance, Q_FUNC_INFO, "KDSelfRestarter instance must be created in main()" );
- if ( Private::instance )
+void KDSelfRestarter::setRestartOnQuit(bool restart)
+{
+ Q_ASSERT_X(Private::instance, Q_FUNC_INFO, "KDSelfRestarter instance must be created in main()");
+ if (Private::instance)
Private::instance->d->restartOnQuit = restart;
}
-bool KDSelfRestarter::restartOnQuit() {
+bool KDSelfRestarter::restartOnQuit()
+{
return Private::instance ? Private::instance->d->restartOnQuit : false;
}
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo.cpp
index 55b0519db..d00b55eaa 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo.cpp
@@ -22,6 +22,9 @@
#include "kdsysinfo.h"
+#include <QDir>
+#include <QDebug>
+
#include <algorithm>
KDSysInfo::KDSysInfo()
@@ -32,16 +35,13 @@ KDSysInfo::~KDSysInfo()
{
}
-#include <QDir>
-#include <QDebug>
-
-QDebug operator<<( QDebug dbg, KDSysInfo::Volume volume )
+QDebug operator<<(QDebug dbg, KDSysInfo::Volume volume)
{
return dbg << "KDSysInfo::Volume(" << volume.path() << ")";
}
-QPair< quint64, quint64 > volumeSpace( const QString& volume );
-QString volumeName( const QString& volume );
+QPair<quint64, quint64> volumeSpace(const QString &volume);
+QString volumeName(const QString &volume);
class KDSysInfo::Volume::Private : public QSharedData
{
@@ -55,12 +55,12 @@ public:
KDSysInfo::Volume::Volume()
- : d( new Private )
+ : d(new Private)
{
}
-KDSysInfo::Volume::Volume( const Volume& other )
- : d( other.d )
+KDSysInfo::Volume::Volume(const Volume &other)
+ : d(other.d)
{
}
@@ -68,29 +68,29 @@ KDSysInfo::Volume::~Volume()
{
}
-void KDSysInfo::Volume::swap( KDSysInfo::Volume& other )
+void KDSysInfo::Volume::swap(KDSysInfo::Volume& other)
{
- std::swap( d, other.d );
+ std::swap(d, other.d);
}
-KDSysInfo::Volume& KDSysInfo::Volume::operator=( const KDSysInfo::Volume& other )
+KDSysInfo::Volume& KDSysInfo::Volume::operator=(const KDSysInfo::Volume &other)
{
- KDSysInfo::Volume tmp( other );
- swap( tmp );
+ KDSysInfo::Volume tmp(other);
+ swap(tmp);
return *this;
}
-void KDSysInfo::Volume::setPath( const QString& path )
+void KDSysInfo::Volume::setPath(const QString &path)
{
d->p = path;
}
-bool KDSysInfo::Volume::operator == ( const Volume& other ) const
+bool KDSysInfo::Volume::operator==(const Volume &other) const
{
return d->name == other.d->name && d->p == other.d->p;
}
-void KDSysInfo::Volume::setName( const QString& name )
+void KDSysInfo::Volume::setName(const QString &name)
{
d->name = name;
}
@@ -110,7 +110,7 @@ quint64 KDSysInfo::Volume::size() const
return d->size;
}
-void KDSysInfo::Volume::setSize( const quint64& size )
+void KDSysInfo::Volume::setSize(const quint64 &size)
{
d->size = size;
}
@@ -130,37 +130,36 @@ quint64 KDSysInfo::Volume::availableSpace() const
return d->availableSpace;
}
-void KDSysInfo::Volume::setAvailableSpace( const quint64& available )
+void KDSysInfo::Volume::setAvailableSpace(const quint64 &available)
{
d->availableSpace = available;
}
struct PathLongerThan
{
- bool operator()( const KDSysInfo::Volume& lhs, const KDSysInfo::Volume& rhs ) const
+ bool operator()(const KDSysInfo::Volume &lhs, const KDSysInfo::Volume &rhs) const
{
return lhs.path().length() > rhs.path().length();
}
};
-KDSysInfo::Volume KDSysInfo::Volume::fromPath( const QString& path )
+KDSysInfo::Volume KDSysInfo::Volume::fromPath(const QString &path)
{
- QList< KDSysInfo::Volume > volumes = mountedVolumes();
+ QList<KDSysInfo::Volume> volumes = mountedVolumes();
// sort by length to get the longest mount point (not just "/") first
- std::sort( volumes.begin(), volumes.end(), PathLongerThan() );
- for( QList< KDSysInfo::Volume >::const_iterator it = volumes.constBegin(); it != volumes.constEnd(); ++it )
- {
+ std::sort(volumes.begin(), volumes.end(), PathLongerThan());
+ for (QList< KDSysInfo::Volume >::const_iterator it = volumes.constBegin(); it != volumes.constEnd(); ++it) {
#ifdef Q_WS_WIN
- if( QDir::toNativeSeparators( path ).toLower().startsWith( it->path().toLower() ) )
+ if (QDir::toNativeSeparators(path).toLower().startsWith(it->path().toLower()))
#else
- if( QDir(path).canonicalPath().startsWith( it->path() ) )
+ if (QDir(path).canonicalPath().startsWith(it->path()))
#endif
return *it;
}
return KDSysInfo::Volume();
}
-QDebug operator<<( QDebug dbg, KDSysInfo::ProcessInfo process )
+QDebug operator<<(QDebug dbg, KDSysInfo::ProcessInfo process)
{
return dbg << "KDSysInfo::ProcessInfo(" << process.id << ", " << process.name << ")";
}
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo_mac.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo_mac.cpp
index a8d62425c..bf1d070b8 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo_mac.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo_mac.cpp
@@ -26,22 +26,22 @@
#include <sys/mount.h>
-static QString qt_mac_hfsunistr_to_qstring( const HFSUniStr255* hfs )
+static QString qt_mac_hfsunistr_to_qstring(const HFSUniStr255 *hfs)
{
- const QChar* const charPointer = reinterpret_cast< const QChar* >( hfs->unicode );
- return QString( charPointer, hfs->length );
+ const QChar *charPointer = reinterpret_cast<const QChar *>(hfs->unicode);
+ return QString(charPointer, hfs->length);
}
quint64 KDSysInfo::installedMemory()
{
SInt32 mb = 0;
- Gestalt( gestaltPhysicalRAMSizeInMegabytes, &mb );
- return quint64( static_cast< quint64 >( mb ) * 1024LL * 1024LL );
+ Gestalt(gestaltPhysicalRAMSizeInMegabytes, &mb);
+ return quint64(static_cast<quint64>(mb) * 1024LL * 1024LL);
}
-QList< KDSysInfo::Volume > KDSysInfo::mountedVolumes()
+QList<KDSysInfo::Volume> KDSysInfo::mountedVolumes()
{
- QList< KDSysInfo::Volume > result;
+ QList<KDSysInfo::Volume> result;
FSVolumeRefNum volume;
FSVolumeInfo info;
HFSUniStr255 volName;
@@ -69,7 +69,7 @@ QList< KDSysInfo::Volume > KDSysInfo::mountedVolumes()
return result;
}
-QList< KDSysInfo::ProcessInfo > KDSysInfo::runningProcesses()
+QList<KDSysInfo::ProcessInfo> KDSysInfo::runningProcesses()
{
- return QList< KDSysInfo::ProcessInfo >();
+ return QList<KDSysInfo::ProcessInfo>();
}
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo_win.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo_win.cpp
index 86d152431..00d84ada7 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo_win.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo_win.cpp
@@ -36,33 +36,31 @@
quint64 KDSysInfo::installedMemory()
{
MEMORYSTATUSEX status;
- status.dwLength = sizeof( status );
- GlobalMemoryStatusEx( &status );
- return quint64( status.ullTotalPhys );
+ status.dwLength = sizeof(status);
+ GlobalMemoryStatusEx(&status);
+ return quint64(status.ullTotalPhys);
}
-QPair< quint64, quint64 > volumeSpace( const QString& volume )
+QPair<quint64, quint64> volumeSpace(const QString &volume)
{
- QPair< quint64, quint64 > result;
+ QPair<quint64, quint64> result;
ULARGE_INTEGER bytes;
ULARGE_INTEGER freebytes;
- if( GetDiskFreeSpaceExA( qPrintable( volume ), 0, &bytes, &freebytes ) != 0 )
- {
- result.first = quint64( bytes.QuadPart );
- result.second = quint64( freebytes.QuadPart );
+ if (GetDiskFreeSpaceExA(qPrintable(volume), 0, &bytes, &freebytes) != 0) {
+ result.first = quint64(bytes.QuadPart);
+ result.second = quint64(freebytes.QuadPart);
}
return result;
}
-QString volumeName( const QString& volume )
+QString volumeName(const QString &volume)
{
- char name[ MAX_PATH + 1 ] = "";
+ char name[MAX_PATH + 1] = "";
DWORD dummy;
- char dummy2[ MAX_PATH + 1 ] = "";
- GetVolumeInformationA( qPrintable( volume ), name, MAX_PATH + 1, &dummy, &dummy, &dummy, dummy2, MAX_PATH + 1 );
- QString vName = QString::fromLatin1( name );
- if( vName.isEmpty() )
- {
+ char dummy2[MAX_PATH + 1] = "";
+ GetVolumeInformationA(qPrintable(volume), name, MAX_PATH + 1, &dummy, &dummy, &dummy, dummy2, MAX_PATH + 1);
+ QString vName = QString::fromLatin1(name);
+ if(vName.isEmpty()) {
const uint driveType = GetDriveTypeA( qPrintable( volume ) );
switch( driveType )
{
@@ -94,12 +92,11 @@ QString fileSystemType(const QString &path)
return QLatin1String("unknown");
}
-QList< KDSysInfo::Volume > KDSysInfo::mountedVolumes()
+QList<KDSysInfo::Volume> KDSysInfo::mountedVolumes()
{
QList< Volume > result;
const QFileInfoList drives = QDir::drives();
- for( QFileInfoList::const_iterator it = drives.constBegin(); it != drives.constEnd(); ++it )
- {
+ for (QFileInfoList::const_iterator it = drives.constBegin(); it != drives.constEnd(); ++it) {
Volume volume;
const QString path = QDir::toNativeSeparators( it->path() );
volume.setPath( path );
@@ -115,8 +112,8 @@ QList< KDSysInfo::Volume > KDSysInfo::mountedVolumes()
struct EnumWindowsProcParam
{
- QList< KDSysInfo::ProcessInfo > processes;
- QList< quint32 > seenIDs;
+ QList<KDSysInfo::ProcessInfo> processes;
+ QList<quint32> seenIDs;
};
//BOOL CALLBACK EnumWindowsProc( HWND hWnd, LPARAM lParam )
@@ -226,8 +223,8 @@ QList< KDSysInfo::ProcessInfo > KDSysInfo::runningProcesses()
QString whichFailed;
QString executablePath;
KDSysInfo::ProcessInfo info;
- if ( QSysInfo::windowsVersion() > QSysInfo::WV_5_2 )
- {
+
+ if (QSysInfo::windowsVersion() > QSysInfo::WV_5_2) {
succ = callPtr( procHandle, 0, buffer, &bufferSize );
executablePath = QString::fromLatin1( buffer );
}
@@ -236,29 +233,26 @@ QList< KDSysInfo::ProcessInfo > KDSysInfo::runningProcesses()
if (pGetProcessImageFileNamePtr) {
succ = callPtrXp( procHandle, buffer, bufferSize );
executablePath = QString::fromLatin1( buffer );
- for ( int i = 0; i < deviceList.count(); ++i )
- {
+ for (int i = 0; i < deviceList.count(); ++i)
executablePath.replace( QString::fromLatin1( "\\Device\\HarddiskVolume%1\\" ).arg( i + 1 ), deviceList.at( i ) );
- }
}
}
- if ( succ )
- {
+ if (succ) {
const quint32 pid = processStruct.th32ProcessID;
- param.seenIDs.append( pid );
+ param.seenIDs.append(pid);
info.id = pid;
info.name = executablePath;
- param.processes.append( info );
+ param.processes.append(info);
}
- CloseHandle( procHandle );
- foundProcess = Process32Next( snapshot, &processStruct );
+ CloseHandle(procHandle);
+ foundProcess = Process32Next(snapshot, &processStruct);
}
- if ( snapshot )
- CloseHandle( snapshot );
+ if (snapshot)
+ CloseHandle(snapshot);
kernel32.unload();
return param.processes;
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo_x11.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo_x11.cpp
index f54f63c8e..d237869f3 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo_x11.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo_x11.cpp
@@ -33,90 +33,83 @@
quint64 KDSysInfo::installedMemory()
{
#ifdef Q_OS_LINUX
- QFile f( QLatin1String( "/proc/meminfo" ) );
- f.open( QIODevice::ReadOnly );
- QTextStream stream( &f );
- while( true )
- {
+ QFile f(QLatin1String("/proc/meminfo"));
+ f.open(QIODevice::ReadOnly);
+ QTextStream stream(&f);
+ while (true) {
const QString s = stream.readLine();
- if( !s.startsWith( QLatin1String( "MemTotal:" ) ) )
+ if( !s.startsWith(QLatin1String("MemTotal:" )))
continue;
- else if( s.isEmpty() )
+ else if (s.isEmpty())
return quint64();
- const QStringList parts = s.split( QLatin1Char( ' ' ), QString::SkipEmptyParts );
- return quint64( parts.at(1).toInt() * 1024LL );
+ const QStringList parts = s.split(QLatin1Char(' '), QString::SkipEmptyParts);
+ return quint64(parts.at(1).toInt() * 1024LL);
}
#else
quint64 physmem;
size_t len = sizeof physmem;
static int mib[2] = { CTL_HW, HW_MEMSIZE };
- sysctl( mib, 2, &physmem, &len, 0, 0 );
- return quint64( physmem );
+ sysctl(mib, 2, &physmem, &len, 0, 0);
+ return quint64(physmem);
#endif
return 0;
}
-QList< KDSysInfo::Volume > KDSysInfo::mountedVolumes()
+QList<KDSysInfo::Volume> KDSysInfo::mountedVolumes()
{
- QList< Volume > result;
+ QList<Volume> result;
- QFile f( QLatin1String( "/etc/mtab" ) );
- if ( !f.open( QIODevice::ReadOnly ) ) {
- qCritical( "%s: Could not open %s: %s", Q_FUNC_INFO, qPrintable(f.fileName()), qPrintable(f.errorString()) );
+ QFile f(QLatin1String("/etc/mtab"));
+ if (!f.open(QIODevice::ReadOnly)) {
+ qCritical("%s: Could not open %s: %s", Q_FUNC_INFO, qPrintable(f.fileName()), qPrintable(f.errorString()));
return QList<KDSysInfo::Volume>(); //better error-handling?
}
- QTextStream stream( &f );
- while( true )
- {
+ QTextStream stream(&f);
+ while (true) {
const QString s = stream.readLine();
- if ( s.isNull() )
+ if (s.isNull())
return result;
- if( !s.startsWith( QLatin1Char( '/' ) ) )
+ if (!s.startsWith(QLatin1Char('/')))
continue;
- const QStringList parts = s.split( QLatin1Char( ' ' ), QString::SkipEmptyParts );
+ const QStringList parts = s.split( QLatin1Char(' '), QString::SkipEmptyParts);
Volume v;
- v.setName( parts.at( 1 ) );
- v.setPath( parts.at( 1 ) );
+ v.setName(parts.at(1));
+ v.setPath(parts.at(1));
struct statvfs data;
- if( statvfs( qPrintable( v.name() ), &data ) == 0 )
- {
- v.setSize( quint64( static_cast< quint64 >( data.f_blocks ) * data.f_bsize ) );
- v.setAvailableSpace( quint64( static_cast< quint64> ( data.f_bavail ) * data.f_bsize ) );
+ if (statvfs(qPrintable(v.name()), &data) == 0) {
+ v.setSize(quint64(static_cast<quint64>(data.f_blocks) * data.f_bsize));
+ v.setAvailableSpace(quint64(static_cast<quint64>(data.f_bavail) * data.f_bsize));
}
- result.push_back( v );
+ result.push_back(v);
}
return result;
}
-QList< KDSysInfo::ProcessInfo > KDSysInfo::runningProcesses()
+QList<KDSysInfo::ProcessInfo> KDSysInfo::runningProcesses()
{
- QList< KDSysInfo::ProcessInfo > processes;
- QDir procDir( QLatin1String( "/proc" ) );
- const QFileInfoList procCont = procDir.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot | QDir::Readable );
- QRegExp validator( QLatin1String( "[0-9]+" ) );
- Q_FOREACH( const QFileInfo& info, procCont )
- {
- if ( validator.exactMatch( info.fileName() ) )
- {
- const QString linkPath = QDir( info.absoluteFilePath() ).absoluteFilePath( QLatin1String( "exe" ) );
- const QFileInfo linkInfo( linkPath );
- if ( linkInfo.exists() )
- {
+ QList<KDSysInfo::ProcessInfo> processes;
+ QDir procDir(QLatin1String("/proc"));
+ const QFileInfoList procCont = procDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::Readable);
+ QRegExp validator(QLatin1String("[0-9]+"));
+ Q_FOREACH (const QFileInfo &info, procCont) {
+ if (validator.exactMatch(info.fileName())) {
+ const QString linkPath = QDir(info.absoluteFilePath()).absoluteFilePath(QLatin1String("exe"));
+ const QFileInfo linkInfo(linkPath);
+ if (linkInfo.exists()) {
KDSysInfo::ProcessInfo processInfo;
processInfo.name = linkInfo.symLinkTarget();
processInfo.id = info.fileName().toInt();
- processes.append( processInfo );
+ processes.append(processInfo);
}
}
}
return processes;
}
-
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterapplication.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterapplication.cpp
index cf4379c90..0c771556f 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterapplication.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterapplication.cpp
@@ -61,23 +61,25 @@ ConfigurationInterface::~ConfigurationInterface()
}
namespace {
+
class DefaultConfigImpl : public ConfigurationInterface
{
public:
- QVariant value( const QString& key ) const
+ QVariant value(const QString &key) const
{
QSettings settings;
- settings.beginGroup( QLatin1String("KDUpdater") );
- return settings.value( key );
+ settings.beginGroup(QLatin1String("KDUpdater"));
+ return settings.value(key);
}
- void setValue( const QString& key, const QVariant& value )
+ void setValue(const QString &key, const QVariant &value)
{
QSettings settings;
- settings.beginGroup( QLatin1String("KDUpdater") );
- settings.setValue( key, value );
+ settings.beginGroup(QLatin1String("KDUpdater"));
+ settings.setValue(key, value);
}
};
+
}
/*!
@@ -99,41 +101,41 @@ namespace {
struct Application::ApplicationData
{
- explicit ApplicationData( ConfigurationInterface* config ) :
+ explicit ApplicationData(ConfigurationInterface *config) :
packagesInfo(0),
updateSourcesInfo(0),
- configurationInterface( config ? config : new DefaultConfigImpl )
+ configurationInterface(config ? config : new DefaultConfigImpl)
{
- const QStringList oldFiles = configurationInterface->value( QLatin1String("FilesForDelayedDeletion") ).toStringList();
- Q_FOREACH( const QString& i, oldFiles ) { //TODO this should happen asnyc and report errors, I guess
- QFile f( i );
- if ( f.exists() && !f.remove() ) {
- qWarning( "Could not delete file %s: %s", qPrintable(i), qPrintable(f.errorString()) );
+ const QStringList oldFiles = configurationInterface->value(QLatin1String("FilesForDelayedDeletion")).toStringList();
+ Q_FOREACH(const QString &i, oldFiles) { //TODO this should happen asnyc and report errors, I guess
+ QFile f(i);
+ if (f.exists() && !f.remove()) {
+ qWarning("Could not delete file %s: %s", qPrintable(i), qPrintable(f.errorString()));
filesForDelayedDeletion << i; // try again next time
}
}
- configurationInterface->setValue( QLatin1String("FilesForDelayedDeletion"), filesForDelayedDeletion );
+ configurationInterface->setValue(QLatin1String("FilesForDelayedDeletion"), filesForDelayedDeletion);
}
~ApplicationData()
{
delete packagesInfo;
delete updateSourcesInfo;
- qDeleteAll( verifiers );
+ qDeleteAll(verifiers);
delete configurationInterface;
}
- static Application* instance;
+ static Application *instance;
QString applicationDirectory;
- PackagesInfo* packagesInfo;
- UpdateSourcesInfo* updateSourcesInfo;
- QMap<Application::SignatureTarget, const SignatureVerifier*> verifiers;
+ PackagesInfo *packagesInfo;
+ UpdateSourcesInfo *updateSourcesInfo;
+ QMap<Application::SignatureTarget, const SignatureVerifier *> verifiers;
QStringList filesForDelayedDeletion;
- ConfigurationInterface* configurationInterface;
+ ConfigurationInterface *configurationInterface;
};
-Application* Application::ApplicationData::instance = 0;
+Application *Application::ApplicationData::instance = 0;
/*!
Constructor of the Application class. The class will be constructed and configured to
@@ -156,7 +158,7 @@ Application::Application(ConfigurationInterface* config, QObject* p) : QObject(p
*/
Application::~Application()
{
- if( this == ApplicationData::instance )
+ if (this == ApplicationData::instance)
ApplicationData::instance = 0;
delete d;
}
@@ -164,7 +166,7 @@ Application::~Application()
/*!
Returns a previousle created Application instance.
*/
-Application* Application::instance()
+Application *Application::instance()
{
return ApplicationData::instance;
}
@@ -173,17 +175,17 @@ Application* Application::instance()
Changes the applicationDirPath directory to \c dir. Packages.xml and UpdateSources.xml found in the new
application directory will be used.
*/
-void Application::setApplicationDirectory(const QString& dir)
+void Application::setApplicationDirectory(const QString &dir)
{
- if( d->applicationDirectory == dir )
+ if (d->applicationDirectory == dir)
return;
QDir dirObj(dir);
// FIXME: Perhaps we should check whether dir exists on the local file system or not
d->applicationDirectory = dirObj.absolutePath();
- setPackagesXMLFileName( QString::fromLatin1( "%1/Packages.xml" ).arg(dir) );
- setUpdateSourcesXMLFileName( QString::fromLatin1( "%1/UpdateSources.xml" ).arg(dir) );
+ setPackagesXMLFileName(QString::fromLatin1("%1/Packages.xml").arg(dir));
+ setUpdateSourcesXMLFileName(QString::fromLatin1("%1/UpdateSources.xml").arg(dir));
}
/*!
@@ -199,7 +201,7 @@ QString Application::applicationDirectory() const
*/
QString Application::applicationName() const
{
- if( d->packagesInfo->isValid() )
+ if (d->packagesInfo->isValid())
return d->packagesInfo->applicationName();
return QCoreApplication::applicationName();
@@ -210,23 +212,23 @@ QString Application::applicationName() const
*/
QString Application::applicationVersion() const
{
- if( d->packagesInfo->isValid() )
+ if (d->packagesInfo->isValid())
return d->packagesInfo->applicationVersion();
return QString();
}
-const SignatureVerifier* Application::signatureVerifier( SignatureTarget target ) const
+const SignatureVerifier *Application::signatureVerifier(SignatureTarget target) const
{
- return d->verifiers.value( target );
+ return d->verifiers.value(target);
}
-void Application::setSignatureVerifier( SignatureTarget target, const SignatureVerifier* v )
+void Application::setSignatureVerifier(SignatureTarget target, const SignatureVerifier *v)
{
- delete d->verifiers.value( target );
- d->verifiers.remove( target );
- if ( v )
- d->verifiers.insert( target, v->clone() );
+ delete d->verifiers.value(target);
+ d->verifiers.remove(target);
+ if (v)
+ d->verifiers.insert(target, v->clone());
}
/*!
@@ -234,14 +236,14 @@ void Application::setSignatureVerifier( SignatureTarget target, const SignatureV
*/
int Application::compatLevel() const
{
- if(d->packagesInfo->isValid())
+ if (d->packagesInfo->isValid())
return d->packagesInfo->compatLevel();
return -1;
}
-void Application::addUpdateSource( const QString& name, const QString& title,
- const QString& description, const QUrl& url, int priority )
+void Application::addUpdateSource(const QString &name, const QString &title,
+ const QString &description, const QUrl &url, int priority)
{
UpdateSourceInfo info;
info.name = name;
@@ -249,7 +251,7 @@ void Application::addUpdateSource( const QString& name, const QString& title,
info.description = description;
info.url = url;
info.priority = priority;
- d->updateSourcesInfo->addUpdateSourceInfo( info );
+ d->updateSourcesInfo->addUpdateSourceInfo(info);
}
@@ -259,9 +261,9 @@ void Application::addUpdateSource( const QString& name, const QString& title,
\sa KDUpdater::PackagesInfo::setFileName()
*/
-void Application::setPackagesXMLFileName(const QString& fileName)
+void Application::setPackagesXMLFileName(const QString &fileName)
{
- d->packagesInfo->setFileName( fileName );
+ d->packagesInfo->setFileName(fileName);
}
/*!
@@ -286,9 +288,9 @@ PackagesInfo* Application::packagesInfo() const
\sa KDUpdater::UpdateSourcesInfo::setFileName()
*/
-void Application::setUpdateSourcesXMLFileName(const QString& fileName)
+void Application::setUpdateSourcesXMLFileName(const QString &fileName)
{
- d->updateSourcesInfo->setFileName( fileName );
+ d->updateSourcesInfo->setFileName(fileName);
}
/*!
@@ -307,7 +309,7 @@ UpdateSourcesInfo* Application::updateSourcesInfo() const
return d->updateSourcesInfo;
}
-void Application::printError( int errorCode, const QString& error )
+void Application::printError(int errorCode, const QString &error)
{
qDebug() << errorCode << error;
}
@@ -317,8 +319,8 @@ QStringList Application::filesForDelayedDeletion() const
return d->filesForDelayedDeletion;
}
-void Application::addFilesForDelayedDeletion( const QStringList& files )
+void Application::addFilesForDelayedDeletion(const QStringList &files)
{
d->filesForDelayedDeletion << files;
- d->configurationInterface->setValue( QLatin1String("FilesForDelayedDeletion"), d->filesForDelayedDeletion );
+ d->configurationInterface->setValue(QLatin1String("FilesForDelayedDeletion"), d->filesForDelayedDeletion);
}
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterapplication.h b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterapplication.h
index f8252d96e..2fb24de08 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterapplication.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterapplication.h
@@ -91,6 +91,6 @@ private:
ApplicationData *d;
};
-}
+} // namespace KDUpdater
#endif // KD_UPDATER_APPLICATION_H
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterfiledownloader.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterfiledownloader.cpp
index 60f6872ed..357abc8fc 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterfiledownloader.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterfiledownloader.cpp
@@ -245,7 +245,7 @@ struct KDUpdater::FileDownloader::Private
FileDownloaderProxyFactory *m_factory;
};
-KDUpdater::FileDownloader::FileDownloader(const QString &scheme, QObject* parent)
+KDUpdater::FileDownloader::FileDownloader(const QString &scheme, QObject *parent)
: QObject(parent)
, d(new Private)
{
@@ -293,7 +293,7 @@ void FileDownloader::setDownloadAborted(const QString &error)
void KDUpdater::FileDownloader::setDownloadCompleted(const QString &path)
{
HashVerificationJob *job = new HashVerificationJob;
- QFile* file = new QFile(path, job);
+ QFile *file = new QFile(path, job);
if (!file->open(QIODevice::ReadOnly)) {
emit downloadProgress(1);
onError();
@@ -316,7 +316,7 @@ void KDUpdater::FileDownloader::setDownloadCanceled()
emit downloadStatus(tr("Download canceled."));
}
-void KDUpdater::FileDownloader::sha1SumVerified(KDUpdater::HashVerificationJob* job)
+void KDUpdater::FileDownloader::sha1SumVerified(KDUpdater::HashVerificationJob *job)
{
if (job->hasError()) {
onError();
@@ -544,16 +544,17 @@ struct KDUpdater::LocalFileDownloader::Private
: source(0)
, destination(0)
, downloaded(false)
- , timerId(-1) { }
+ , timerId(-1)
+ {}
- QFile* source;
- QFile* destination;
+ QFile *source;
+ QFile *destination;
QString destFileName;
bool downloaded;
int timerId;
};
-KDUpdater::LocalFileDownloader::LocalFileDownloader(QObject* parent)
+KDUpdater::LocalFileDownloader::LocalFileDownloader(QObject *parent)
: KDUpdater::FileDownloader(QLatin1String("file"), parent)
, d (new Private)
{
@@ -630,7 +631,7 @@ void KDUpdater::LocalFileDownloader::setDownloadedFileName(const QString &name)
d->destFileName = name;
}
-KDUpdater::LocalFileDownloader* KDUpdater::LocalFileDownloader::clone(QObject* parent) const
+KDUpdater::LocalFileDownloader *KDUpdater::LocalFileDownloader::clone(QObject *parent) const
{
return new LocalFileDownloader(parent);
}
@@ -696,7 +697,7 @@ void LocalFileDownloader::onSuccess()
{
d->downloaded = true;
d->destFileName = d->destination->fileName();
- if (QTemporaryFile *file = dynamic_cast<QTemporaryFile*> (d->destination))
+ if (QTemporaryFile *file = dynamic_cast<QTemporaryFile *>(d->destination))
file->setAutoRemove(false);
d->destination->close();
delete d->destination;
@@ -724,16 +725,17 @@ struct KDUpdater::ResourceFileDownloader::Private
{
Private()
: downloaded(false),
- timerId(-1) { }
+ timerId(-1)
+ {}
QString destFileName;
bool downloaded;
int timerId;
};
-KDUpdater::ResourceFileDownloader::ResourceFileDownloader(QObject* parent)
+KDUpdater::ResourceFileDownloader::ResourceFileDownloader(QObject *parent)
: KDUpdater::FileDownloader(QLatin1String("resource"), parent)
- , d (new Private)
+ , d(new Private)
{
}
@@ -787,7 +789,7 @@ void KDUpdater::ResourceFileDownloader::setDownloadedFileName(const QString &/*n
Q_ASSERT_X(false, "KDUpdater::ResourceFileDownloader::setDownloadedFileName", "Not supported!");
}
-KDUpdater::ResourceFileDownloader* KDUpdater::ResourceFileDownloader::clone(QObject* parent) const
+KDUpdater::ResourceFileDownloader *KDUpdater::ResourceFileDownloader::clone(QObject *parent) const
{
return new ResourceFileDownloader(parent);
}
@@ -803,7 +805,7 @@ void KDUpdater::ResourceFileDownloader::cancelDownload()
setDownloadCanceled();
}
-void KDUpdater::ResourceFileDownloader::timerEvent(QTimerEvent*)
+void KDUpdater::ResourceFileDownloader::timerEvent(QTimerEvent *)
{
killTimer(d->timerId);
d->timerId = -1;
@@ -830,19 +832,20 @@ struct KDUpdater::FtpDownloader::Private
, destination(0)
, downloaded(false)
, ftpCmdId(-1)
- , aborted(false) { }
+ , aborted(false)
+ {}
- QFtp* ftp;
- QFile* destination;
+ QFtp *ftp;
+ QFile *destination;
QString destFileName;
bool downloaded;
int ftpCmdId;
bool aborted;
};
-KDUpdater::FtpDownloader::FtpDownloader(QObject* parent)
+KDUpdater::FtpDownloader::FtpDownloader(QObject *parent)
: KDUpdater::FileDownloader(QLatin1String("ftp"), parent)
- , d (new Private)
+ , d(new Private)
{
}
@@ -878,8 +881,8 @@ void KDUpdater::FtpDownloader::doDownload()
connect(d->ftp, SIGNAL(commandStarted(int)), this, SLOT(ftpCmdStarted(int)));
connect(d->ftp, SIGNAL(commandFinished(int, bool)), this, SLOT(ftpCmdFinished(int, bool)));
connect(d->ftp, SIGNAL(stateChanged(int)), this, SLOT(ftpStateChanged(int)));
- connect(d->ftp, SIGNAL(dataTransferProgress(qint64, qint64)), this, SLOT(ftpDataTransferProgress(qint64,
- qint64)));
+ connect(d->ftp, SIGNAL(dataTransferProgress(qint64, qint64)), this,
+ SLOT(ftpDataTransferProgress(qint64, qint64)));
connect(d->ftp, SIGNAL(readyRead()), this, SLOT(ftpReadyRead()));
if (FileDownloaderProxyFactory *factory = proxyFactory()) {
@@ -903,7 +906,7 @@ void KDUpdater::FtpDownloader::setDownloadedFileName(const QString &name)
d->destFileName = name;
}
-KDUpdater::FtpDownloader* KDUpdater::FtpDownloader::clone(QObject* parent) const
+KDUpdater::FtpDownloader *KDUpdater::FtpDownloader::clone(QObject *parent) const
{
return new FtpDownloader(parent);
}
@@ -966,7 +969,7 @@ void FtpDownloader::onSuccess()
{
d->downloaded = true;
d->destFileName = d->destination->fileName();
- if (QTemporaryFile *file = dynamic_cast<QTemporaryFile*> (d->destination))
+ if (QTemporaryFile *file = dynamic_cast<QTemporaryFile *>(d->destination))
file->setAutoRemove(false);
delete d->destination;
d->destination = 0;
@@ -1053,19 +1056,20 @@ void KDUpdater::FtpDownloader::timerEvent(QTimerEvent *event)
struct KDUpdater::HttpDownloader::Private
{
- explicit Private(HttpDownloader* qq)
+ explicit Private(HttpDownloader *qq)
: q(qq)
, http(0)
, destination(0)
, downloaded(false)
, aborted(false)
, retrying(false)
- , m_authenticationDone(false) { }
+ , m_authenticationDone(false)
+ {}
- HttpDownloader* const q;
+ HttpDownloader *const q;
QNetworkAccessManager manager;
- QNetworkReply* http;
- QFile* destination;
+ QNetworkReply *http;
+ QFile *destination;
QString destFileName;
bool downloaded;
bool aborted;
@@ -1080,13 +1084,12 @@ struct KDUpdater::HttpDownloader::Private
destination->close();
destination->deleteLater();
destination = 0;
-
}
};
-KDUpdater::HttpDownloader::HttpDownloader(QObject* parent)
+KDUpdater::HttpDownloader::HttpDownloader(QObject *parent)
: KDUpdater::FileDownloader(QLatin1String("http"), parent)
- , d (new Private(this))
+ , d(new Private(this))
{
connect(&d->manager, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)), this,
SLOT(onAuthenticationRequired(QNetworkReply*, QAuthenticator*)));
@@ -1132,7 +1135,7 @@ void KDUpdater::HttpDownloader::setDownloadedFileName(const QString &name)
d->destFileName = name;
}
-KDUpdater::HttpDownloader* KDUpdater::HttpDownloader::clone(QObject* parent) const
+KDUpdater::HttpDownloader *KDUpdater::HttpDownloader::clone(QObject *parent) const
{
return new HttpDownloader(parent);
}
@@ -1218,7 +1221,7 @@ void KDUpdater::HttpDownloader::onSuccess()
{
d->downloaded = true;
d->destFileName = d->destination->fileName();
- if (QTemporaryFile *file = dynamic_cast<QTemporaryFile*> (d->destination))
+ if (QTemporaryFile *file = dynamic_cast<QTemporaryFile *>(d->destination))
file->setAutoRemove(false);
delete d->destination;
d->destination = 0;
@@ -1306,9 +1309,9 @@ void KDUpdater::HttpDownloader::onAuthenticationRequired(QNetworkReply *reply, Q
class SignatureVerificationDownloader::Private
{
- SignatureVerificationDownloader* const q;
+ SignatureVerificationDownloader *const q;
public:
- explicit Private(FileDownloader* dl, SignatureVerificationDownloader* qq)
+ explicit Private(FileDownloader *dl, SignatureVerificationDownloader *qq)
: q(qq)
, verifier(0)
, downloader(dl)
@@ -1330,7 +1333,7 @@ public:
delete sigDownloader;
}
- const SignatureVerifier* verifier;
+ const SignatureVerifier *verifier;
FileDownloader *downloader;
FileDownloader *sigDownloader;
QUrl signatureUrl;
@@ -1339,7 +1342,7 @@ public:
bool actualDownloadDone : 1;
};
-SignatureVerificationDownloader::SignatureVerificationDownloader(FileDownloader* downloader, QObject* parent)
+SignatureVerificationDownloader::SignatureVerificationDownloader(FileDownloader *downloader, QObject *parent)
: FileDownloader(downloader->scheme(), parent)
, d(new Private(downloader, this))
{
@@ -1365,7 +1368,7 @@ const SignatureVerifier* SignatureVerificationDownloader::signatureVerifier() co
return d->verifier;
}
-void SignatureVerificationDownloader::setSignatureVerifier(const SignatureVerifier* verifier)
+void SignatureVerificationDownloader::setSignatureVerifier(const SignatureVerifier *verifier)
{
delete d->verifier;
d->verifier = verifier ? verifier->clone() : 0;
@@ -1396,7 +1399,7 @@ void SignatureVerificationDownloader::setDownloadedFileName(const QString &/*nam
Q_ASSERT_X(false, "SignatureVerificationDownloader::setDownloadedFileName", "Not supported!");
}
-FileDownloader* SignatureVerificationDownloader::clone(QObject* parent) const
+FileDownloader *SignatureVerificationDownloader::clone(QObject *parent) const
{
return new SignatureVerificationDownloader(d->downloader->clone(), parent);
}
@@ -1511,7 +1514,7 @@ void SignatureVerificationDownloader::signatureDownloadCompleted()
setDownloadCompleted(d->downloadedFileName);
#if 0
- SignatureVerificationRunnable* runnable = new SignatureVerificationRunnable;
+ SignatureVerificationRunnable *runnable = new SignatureVerificationRunnable;
runnable->setSignature(signature);
runnable->setData(dataFile.release());
runnable->setVerifier(d->verifier);
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterfiledownloaderfactory.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterfiledownloaderfactory.cpp
index c66ac5aee..ea6fe5650 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterfiledownloaderfactory.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterfiledownloaderfactory.cpp
@@ -55,17 +55,17 @@ FileDownloaderFactory& FileDownloaderFactory::instance()
Constructor
*/
FileDownloaderFactory::FileDownloaderFactory()
- : d ( new FileDownloaderFactoryData )
+ : d (new FileDownloaderFactoryData)
{
// Register the default file downloader set
- registerFileDownloader< LocalFileDownloader >( QLatin1String( "file" ) );
- registerFileDownloader< FtpDownloader >( QLatin1String( "ftp" ) );
- registerFileDownloader< HttpDownloader >( QLatin1String( "http" ) );
- registerFileDownloader< ResourceFileDownloader >( QLatin1String( "resource" ) );
+ registerFileDownloader<LocalFileDownloader>( QLatin1String("file"));
+ registerFileDownloader<FtpDownloader>(QLatin1String("ftp"));
+ registerFileDownloader<HttpDownloader>(QLatin1String("http"));
+ registerFileDownloader<ResourceFileDownloader >(QLatin1String("resource"));
d->m_followRedirects = false;
}
-void FileDownloaderFactory::setFollowRedirects( bool val )
+void FileDownloaderFactory::setFollowRedirects(bool val)
{
FileDownloaderFactory::instance().d->m_followRedirects = val;
}
@@ -85,24 +85,25 @@ FileDownloaderFactory::~FileDownloaderFactory()
passed as parameter to this function.
\note Ownership of this object remains to the programmer.
*/
-FileDownloader* FileDownloaderFactory::create( const QString& scheme, QObject* parent ) const
+FileDownloader *FileDownloaderFactory::create(const QString &scheme, QObject *parent) const
{
- return create( scheme, 0, QUrl(), parent );
+ return create(scheme, 0, QUrl(), parent);
}
-FileDownloader* FileDownloaderFactory::create( const QString& scheme, const SignatureVerifier* verifier, const QUrl& signatureUrl, QObject* parent ) const
+FileDownloader *FileDownloaderFactory::create(const QString &scheme, const SignatureVerifier *verifier,
+ const QUrl &signatureUrl, QObject *parent) const
{
- FileDownloader* const downloader = KDGenericFactory< FileDownloader >::create( scheme );
- if( downloader != 0 ) {
- downloader->setFollowRedirects( d->m_followRedirects );
- downloader->setParent( parent );
+ FileDownloader *downloader = KDGenericFactory<FileDownloader>::create(scheme);
+ if (downloader != 0) {
+ downloader->setFollowRedirects(d->m_followRedirects);
+ downloader->setParent(parent);
}
- if( !verifier )
+ if (!verifier)
return downloader;
- SignatureVerificationDownloader* const svdl = new SignatureVerificationDownloader( downloader, parent );
- svdl->setSignatureVerifier( verifier );
- svdl->setSignatureUrl( signatureUrl );
+ SignatureVerificationDownloader *svdl = new SignatureVerificationDownloader(downloader, parent);
+ svdl->setSignatureVerifier(verifier);
+ svdl->setSignatureUrl(signatureUrl);
return svdl;
}
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterpackagesinfo.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterpackagesinfo.cpp
index 8a079ec9b..c151998a8 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterpackagesinfo.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterpackagesinfo.cpp
@@ -75,15 +75,15 @@ using namespace KDUpdater;
struct PackagesInfo::PackagesInfoData
{
- PackagesInfoData( PackagesInfo* qq ) :
- q( qq ),
+ PackagesInfoData(PackagesInfo *qq) :
+ q(qq),
application(0),
error(PackagesInfo::NotYetReadError),
compatLevel(-1),
- modified( false )
+ modified(false)
{}
- PackagesInfo* q;
- Application* application;
+ PackagesInfo *q;
+ Application *application;
QString errorMessage;
PackagesInfo::Error error;
QString fileName;
@@ -94,11 +94,11 @@ struct PackagesInfo::PackagesInfoData
QVector<PackageInfo> packageInfoList;
- void addPackageFrom(const QDomElement& packageE);
- void setInvalidContentError( const QString& detail );
+ void addPackageFrom(const QDomElement &packageE);
+ void setInvalidContentError(const QString &detail);
};
-void PackagesInfo::PackagesInfoData::setInvalidContentError(const QString& detail)
+void PackagesInfo::PackagesInfoData::setInvalidContentError(const QString &detail)
{
error = PackagesInfo::InvalidContentError;
errorMessage = tr("%1 contains invalid content: %2").arg(fileName, detail);
@@ -107,9 +107,9 @@ void PackagesInfo::PackagesInfoData::setInvalidContentError(const QString& detai
/*!
\internal
*/
-PackagesInfo::PackagesInfo(Application* application)
+PackagesInfo::PackagesInfo(Application *application)
: QObject(application),
- d( new PackagesInfoData( this ) )
+ d(new PackagesInfoData(this))
{
d->application = application;
}
@@ -183,7 +183,7 @@ QString PackagesInfo::fileName() const
Sets the application name. By default this is the name specified in
the ApplicationName XML element of the Packages.xml file.
*/
-void PackagesInfo::setApplicationName(const QString& name)
+void PackagesInfo::setApplicationName(const QString &name)
{
d->applicationName = name;
d->modified = true;
@@ -229,7 +229,7 @@ int PackagesInfo::packageInfoCount() const
*/
PackageInfo PackagesInfo::packageInfo(int index) const
{
- if( index < 0 || index >= d->packageInfoList.count() )
+ if (index < 0 || index >= d->packageInfoList.count())
return PackageInfo();
return d->packageInfoList[index];
@@ -249,9 +249,8 @@ int PackagesInfo::compatLevel() const
*/
int PackagesInfo::findPackageInfo(const QString& pkgName) const
{
- for(int i=0; i<d->packageInfoList.count(); i++)
- {
- if( d->packageInfoList[i].name == pkgName )
+ for (int i = 0; i < d->packageInfoList.count(); i++) {
+ if (d->packageInfoList[i].name == pkgName)
return i;
}
@@ -279,11 +278,10 @@ void PackagesInfo::refresh()
d->packageInfoList.clear();
d->modified = false;
- QFile file( d->fileName );
+ QFile file(d->fileName);
// if the file does not exist then we just skip the reading
- if( !file.exists() )
- {
+ if (!file.exists()) {
d->error = NotYetReadError;
d->errorMessage = tr("The file \"%1\" does not exist").arg(d->fileName);
emit reset();
@@ -291,8 +289,7 @@ void PackagesInfo::refresh()
}
// Open Packages.xml
- if( !file.open(QFile::ReadOnly) )
- {
+ if (!file.open(QFile::ReadOnly)) {
d->error = CouldNotReadPackageFileError;
d->errorMessage = tr("Could not open \"%1\"").arg(d->fileName);
emit reset();
@@ -304,8 +301,7 @@ void PackagesInfo::refresh()
QString parseErrorMessage;
int parseErrorLine;
int parseErrorColumn;
- if( !doc.setContent( &file, &parseErrorMessage, &parseErrorLine, &parseErrorColumn ) )
- {
+ if (!doc.setContent(&file, &parseErrorMessage, &parseErrorLine, &parseErrorColumn)) {
d->error = InvalidXmlError;
d->errorMessage = tr("Parse error in %1 at %2, %3: %4")
.arg(d->fileName,
@@ -319,28 +315,26 @@ void PackagesInfo::refresh()
// Now populate information from the XML file.
QDomElement rootE = doc.documentElement();
- if( rootE.tagName() != QLatin1String( "Packages" ) )
- {
+ if (rootE.tagName() != QLatin1String("Packages")) {
d->setInvalidContentError(tr("root element %1 unexpected, should be \"Packages\"").arg(rootE.tagName()));
emit reset();
return;
}
QDomNodeList childNodes = rootE.childNodes();
- for(int i=0; i<childNodes.count(); i++)
- {
+ for (int i = 0; i < childNodes.count(); i++) {
QDomNode childNode = childNodes.item(i);
QDomElement childNodeE = childNode.toElement();
- if( childNodeE.isNull() )
+ if (childNodeE.isNull())
continue;
- if( childNodeE.tagName() == QLatin1String( "ApplicationName" ) )
+ if (childNodeE.tagName() == QLatin1String("ApplicationName"))
d->applicationName = childNodeE.text();
- else if( childNodeE.tagName() == QLatin1String( "ApplicationVersion" ) )
+ else if (childNodeE.tagName() == QLatin1String("ApplicationVersion"))
d->applicationVersion = childNodeE.text();
- else if( childNodeE.tagName() == QLatin1String( "Package" ) )
- d->addPackageFrom( childNodeE );
- else if( childNodeE.tagName() == QLatin1String( "CompatLevel" ) )
+ else if (childNodeE.tagName() == QLatin1String("Package"))
+ d->addPackageFrom(childNodeE);
+ else if (childNodeE.tagName() == QLatin1String("CompatLevel"))
d->compatLevel = childNodeE.text().toInt();
}
@@ -361,12 +355,14 @@ void PackagesInfo::setCompatLevel(int level)
/*!
Marks the package with \a name as installed in \a version.
*/
-bool PackagesInfo::installPackage( const QString& name, const QString& version, const QString& title, const QString& description,
- const QStringList& dependencies, bool forcedInstallation, bool virtualComp, quint64 uncompressedSize,
- const QString &inheritVersionFrom)
+bool PackagesInfo::installPackage(const QString &name, const QString &version,
+ const QString &title, const QString &description,
+ const QStringList &dependencies, bool forcedInstallation,
+ bool virtualComp, quint64 uncompressedSize,
+ const QString &inheritVersionFrom)
{
- if( findPackageInfo( name ) != -1 )
- return updatePackage( name, version, QDate::currentDate() );
+ if (findPackageInfo(name) != -1)
+ return updatePackage(name, version, QDate::currentDate());
PackageInfo info;
info.name = name;
@@ -379,7 +375,7 @@ bool PackagesInfo::installPackage( const QString& name, const QString& version,
info.forcedInstallation = forcedInstallation;
info.virtualComp = virtualComp;
info.uncompressedSize = uncompressedSize;
- d->packageInfoList.push_back( info );
+ d->packageInfoList.push_back(info);
d->modified = true;
return true;
}
@@ -388,12 +384,13 @@ bool PackagesInfo::installPackage( const QString& name, const QString& version,
Update the package.
*/
bool PackagesInfo::updatePackage(const QString &name,
- const QString &version,
- const QDate &date)
+ const QString &version,
+ const QDate &date)
{
int index = findPackageInfo(name);
- if (index==-1) return false;
+ if (index == -1)
+ return false;
d->packageInfoList[index].version = version;
d->packageInfoList[index].lastUpdateDate = date;
@@ -404,13 +401,13 @@ bool PackagesInfo::updatePackage(const QString &name,
/*!
Remove the package with \a name.
*/
-bool PackagesInfo::removePackage( const QString& name )
+bool PackagesInfo::removePackage(const QString &name)
{
- const int index = findPackageInfo( name );
- if( index == -1 )
+ const int index = findPackageInfo(name);
+ if (index == -1)
return false;
- d->packageInfoList.remove( index );
+ d->packageInfoList.remove(index);
d->modified = true;
return true;
}
@@ -418,67 +415,64 @@ bool PackagesInfo::removePackage( const QString& name )
static void addTextChildHelper(QDomNode *node,
const QString &tag,
const QString &text,
- const QString &attributeName=QString(),
- const QString &attributeValue=QString())
+ const QString &attributeName = QString(),
+ const QString &attributeValue = QString())
{
QDomElement domElement = node->ownerDocument().createElement(tag);
QDomText domText = node->ownerDocument().createTextNode(text);
domElement.appendChild(domText);
- if(!attributeName.isEmpty())
+ if (!attributeName.isEmpty())
domElement.setAttribute(attributeName, attributeValue);
node->appendChild(domElement);
}
void PackagesInfo::writeToDisk()
{
- if( d->modified && ( !d->packageInfoList.isEmpty() || QFile::exists( d->fileName ) ) )
- {
+ if (d->modified && (!d->packageInfoList.isEmpty() || QFile::exists(d->fileName))) {
QDomDocument doc;
- QDomElement root = doc.createElement(QLatin1String( "Packages") ) ;
+ QDomElement root = doc.createElement(QLatin1String("Packages")) ;
doc.appendChild(root);
- addTextChildHelper(&root, QLatin1String( "ApplicationName" ), d->applicationName);
- addTextChildHelper(&root, QLatin1String( "ApplicationVersion" ), d->applicationVersion);
- if (d->compatLevel!=-1) {
+ addTextChildHelper(&root, QLatin1String("ApplicationName"), d->applicationName);
+ addTextChildHelper(&root, QLatin1String("ApplicationVersion"), d->applicationVersion);
+ if (d->compatLevel != -1)
addTextChildHelper(&root, QLatin1String( "CompatLevel" ), QString::number(d->compatLevel));
- }
Q_FOREACH (const PackageInfo &info, d->packageInfoList) {
- QDomElement package = doc.createElement( QLatin1String( "Package" ) );
+ QDomElement package = doc.createElement(QLatin1String("Package"));
- addTextChildHelper( &package, QLatin1String( "Name" ), info.name );
- addTextChildHelper( &package, QLatin1String( "Pixmap" ), info.pixmap );
- addTextChildHelper( &package, QLatin1String( "Title" ), info.title );
- addTextChildHelper( &package, QLatin1String( "Description" ), info.description );
+ addTextChildHelper(&package, QLatin1String("Name"), info.name);
+ addTextChildHelper(&package, QLatin1String("Pixmap"), info.pixmap);
+ addTextChildHelper(&package, QLatin1String("Title"), info.title);
+ addTextChildHelper(&package, QLatin1String("Description"), info.description);
if (info.inheritVersionFrom.isEmpty())
- addTextChildHelper( &package, QLatin1String( "Version" ), info.version );
+ addTextChildHelper(&package, QLatin1String("Version"), info.version);
else
- addTextChildHelper( &package, QLatin1String( "Version" ), info.version,
+ addTextChildHelper(&package, QLatin1String("Version"), info.version,
QLatin1String("inheritVersionFrom"), info.inheritVersionFrom);
- addTextChildHelper( &package, QLatin1String( "LastUpdateDate" ), info.lastUpdateDate.toString( Qt::ISODate ) );
- addTextChildHelper( &package, QLatin1String( "InstallDate" ), info.installDate.toString( Qt::ISODate) );
- addTextChildHelper( &package, QLatin1String( "Size" ), QString::number( info.uncompressedSize ) );
- QString assembledDependencies = QLatin1String( "" );
- Q_FOREACH( const QString & val, info.dependencies ){
- assembledDependencies += val + QLatin1String( "," );
+ addTextChildHelper(&package, QLatin1String("LastUpdateDate"), info.lastUpdateDate.toString(Qt::ISODate));
+ addTextChildHelper(&package, QLatin1String("InstallDate"), info.installDate.toString(Qt::ISODate));
+ addTextChildHelper(&package, QLatin1String("Size"), QString::number(info.uncompressedSize));
+ QString assembledDependencies = QLatin1String("");
+ Q_FOREACH (const QString & val, info.dependencies) {
+ assembledDependencies += val + QLatin1String(",");
}
- if ( info.dependencies.count() > 0 )
- assembledDependencies.chop( 1 );
- addTextChildHelper( &package, QLatin1String( "Dependencies" ), assembledDependencies );
- if ( info.forcedInstallation )
- addTextChildHelper( &package, QLatin1String( "ForcedInstallation" ), QLatin1String( "true" ) );
- if ( info.virtualComp )
- addTextChildHelper( &package, QLatin1String( "Virtual" ), QLatin1String( "true" ) );
+ if (info.dependencies.count() > 0)
+ assembledDependencies.chop(1);
+ addTextChildHelper(&package, QLatin1String("Dependencies"), assembledDependencies);
+ if (info.forcedInstallation)
+ addTextChildHelper(&package, QLatin1String("ForcedInstallation"), QLatin1String("true"));
+ if (info.virtualComp)
+ addTextChildHelper(&package, QLatin1String("Virtual"), QLatin1String("true"));
root.appendChild(package);
}
// Open Packages.xml
- QFile file( d->fileName );
- if( !file.open(QFile::WriteOnly) ) {
+ QFile file(d->fileName);
+ if (!file.open(QFile::WriteOnly))
return;
- }
file.write(doc.toByteArray(4));
file.close();
@@ -486,52 +480,51 @@ void PackagesInfo::writeToDisk()
}
}
-void PackagesInfo::PackagesInfoData::addPackageFrom(const QDomElement& packageE)
+void PackagesInfo::PackagesInfoData::addPackageFrom(const QDomElement &packageE)
{
- if( packageE.isNull() )
+ if (packageE.isNull())
return;
QDomNodeList childNodes = packageE.childNodes();
- if(childNodes.count() == 0)
+ if (childNodes.count() == 0)
return;
PackageInfo info;
info.forcedInstallation = false;
info.virtualComp = false;
- for(int i=0; i<childNodes.count(); i++)
- {
+ for (int i = 0; i < childNodes.count(); i++) {
QDomNode childNode = childNodes.item(i);
QDomElement childNodeE = childNode.toElement();
- if( childNodeE.isNull() )
+ if (childNodeE.isNull())
continue;
- if( childNodeE.tagName() == QLatin1String( "Name" ) )
+ if (childNodeE.tagName() == QLatin1String("Name"))
info.name = childNodeE.text();
- else if( childNodeE.tagName() == QLatin1String( "Pixmap" ) )
+ else if (childNodeE.tagName() == QLatin1String("Pixmap"))
info.pixmap = childNodeE.text();
- else if( childNodeE.tagName() == QLatin1String( "Title" ) )
+ else if (childNodeE.tagName() == QLatin1String("Title"))
info.title = childNodeE.text();
- else if( childNodeE.tagName() == QLatin1String( "Description" ) )
+ else if (childNodeE.tagName() == QLatin1String("Description"))
info.description = childNodeE.text();
- else if( childNodeE.tagName() == QLatin1String( "Version" ) ) {
+ else if (childNodeE.tagName() == QLatin1String("Version")) {
info.version = childNodeE.text();
info.inheritVersionFrom = childNodeE.attribute(QLatin1String("inheritVersionFrom"));
}
- else if( childNodeE.tagName() == QLatin1String( "Virtual" ) )
- info.virtualComp = childNodeE.text().toLower() == QLatin1String( "true" ) ? true : false;
- else if( childNodeE.tagName() == QLatin1String( "Size" ) )
+ else if (childNodeE.tagName() == QLatin1String("Virtual"))
+ info.virtualComp = childNodeE.text().toLower() == QLatin1String("true") ? true : false;
+ else if (childNodeE.tagName() == QLatin1String("Size"))
info.uncompressedSize = childNodeE.text().toULongLong();
- else if( childNodeE.tagName() == QLatin1String( "Dependencies" ) )
- info.dependencies = childNodeE.text().split( QRegExp(QLatin1String("\\b(,|, )\\b")), QString::SkipEmptyParts );
- else if( childNodeE.tagName() == QLatin1String( "ForcedInstallation" ) )
+ else if (childNodeE.tagName() == QLatin1String("Dependencies"))
+ info.dependencies = childNodeE.text().split(QRegExp(QLatin1String("\\b(,|, )\\b")), QString::SkipEmptyParts);
+ else if (childNodeE.tagName() == QLatin1String("ForcedInstallation"))
info.forcedInstallation = childNodeE.text().toLower() == QLatin1String( "true" ) ? true : false;
- else if( childNodeE.tagName() == QLatin1String( "LastUpdateDate" ) )
+ else if (childNodeE.tagName() == QLatin1String("LastUpdateDate"))
info.lastUpdateDate = QDate::fromString(childNodeE.text(), Qt::ISODate);
- else if( childNodeE.tagName() == QLatin1String( "InstallDate" ) )
+ else if (childNodeE.tagName() == QLatin1String("InstallDate"))
info.installDate = QDate::fromString(childNodeE.text(), Qt::ISODate);
}
- this->packageInfoList.append( info );
+ this->packageInfoList.append(info);
}
/*!
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdatersignatureverificationresult.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdatersignatureverificationresult.cpp
index 0b1f61a57..d4c35d1e5 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdatersignatureverificationresult.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdatersignatureverificationresult.cpp
@@ -29,9 +29,11 @@
using namespace KDUpdater;
-class SignatureVerificationResult::Private : public QSharedData {
+class SignatureVerificationResult::Private : public QSharedData
+{
public:
- Private() : QSharedData(), validity( SignatureVerificationResult::UnknownValidity ) {
+ Private() : QSharedData(), validity( SignatureVerificationResult::UnknownValidity )
+ {
}
Private( const Private& other ) : QSharedData( other ), validity( other.validity ), errorString( other.errorString ) {
}
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdatersignatureverifier.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdatersignatureverifier.cpp
index 28cba7098..2be695e21 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdatersignatureverifier.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdatersignatureverifier.cpp
@@ -31,16 +31,16 @@ SignatureVerifier::~SignatureVerifier()
{
}
-SignatureVerificationResult SignatureVerifier::verify( const QString& dataFile, const QString& signatureFile ) const
+SignatureVerificationResult SignatureVerifier::verify(const QString &dataFile, const QString &signatureFile ) const
{
- QFile dFile( dataFile );
- QFile sFile( signatureFile );
+ QFile dFile(dataFile);
+ QFile sFile(signatureFile);
- if( !dFile.open( QIODevice::ReadOnly ) )
+ if (!dFile.open(QIODevice::ReadOnly))
return SignatureVerificationResult();
- if( !sFile.open( QIODevice::ReadOnly ) )
- return SignatureVerificationResult( SignatureVerificationResult::BadSignature );
+ if (!sFile.open(QIODevice::ReadOnly))
+ return SignatureVerificationResult(SignatureVerificationResult::BadSignature);
- return verify( dFile.readAll(), sFile.readAll() );
+ return verify(dFile.readAll(), sFile.readAll());
}
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdatertask.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdatertask.cpp
index 6297594c0..098f74dd2 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdatertask.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdatertask.cpp
@@ -41,8 +41,8 @@
struct KDUpdater::Task::TaskData
{
- TaskData( Task* qq) :
- q( qq )
+ TaskData(Task *qq) :
+ q(qq)
{
caps = KDUpdater::Task::NoCapability;
errorCode = 0;
@@ -54,7 +54,7 @@ struct KDUpdater::Task::TaskData
autoDelete = true;
}
- Task* q;
+ Task *q;
int caps;
QString name;
int errorCode;
@@ -71,13 +71,13 @@ struct KDUpdater::Task::TaskData
/*!
\internal
*/
-KDUpdater::Task::Task(const QString& name, int caps, QObject* parent)
+KDUpdater::Task::Task(const QString &name, int caps, QObject *parent)
: QObject(parent),
- d( new TaskData( this ) )
+ d(new TaskData(this))
{
d->caps = caps;
d->name = name;
-};
+}
/*!
\internal
@@ -185,14 +185,12 @@ QString KDUpdater::Task::progressText() const
*/
void KDUpdater::Task::run()
{
- if(d->started)
- {
+ if (d->started) {
qDebug("Trying to start an already started task");
return;
}
- if(d->finished || d->stopped)
- {
+ if (d->finished || d->stopped) {
qDebug("Trying to start a finished or canceled task");
return;
}
@@ -213,15 +211,13 @@ void KDUpdater::Task::run()
*/
void KDUpdater::Task::stop()
{
- if( !(d->caps & Stoppable) )
- {
+ if (!(d->caps & Stoppable)) {
const QString errorMsg = tr("'%1' cannot be stopped").arg(d->name);
reportError(KDUpdater::ECannotStopTask, errorMsg);
return;
}
- if(!d->started)
- {
+ if (!d->started) {
qDebug("Trying to stop an unstarted task");
return;
}
@@ -233,8 +229,7 @@ void KDUpdater::Task::stop()
}
d->stopped = doStop();
- if(!d->stopped)
- {
+ if (!d->stopped) {
const QString errorMsg = tr("Cannot stop task '%1'").arg(d->name);
reportError(KDUpdater::ECannotStopTask, errorMsg);
return;
@@ -253,28 +248,25 @@ void KDUpdater::Task::stop()
*/
void KDUpdater::Task::pause()
{
- if( !(d->caps & Pausable) )
- {
+ if (!(d->caps & Pausable)) {
const QString errorMsg = tr("'%1' cannot be paused").arg(d->name);
reportError(KDUpdater::ECannotPauseTask, errorMsg);
return;
}
- if(!d->started)
- {
+ if (!d->started) {
qDebug("Trying to pause an unstarted task");
return;
}
- if(d->finished || d->stopped)
- {
+ if (d->finished || d->stopped) {
qDebug("Trying to pause a finished or canceled task");
return;
}
d->paused = doPause();
- if(!d->paused)
- {
+
+ if (!d->paused) {
const QString errorMsg = tr("Cannot pause task '%1'").arg(d->name);
reportError(KDUpdater::ECannotPauseTask, errorMsg);
return;
@@ -295,15 +287,14 @@ void KDUpdater::Task::pause()
*/
void KDUpdater::Task::resume()
{
- if(!d->paused)
- {
+ if (!d->paused) {
qDebug("Trying to resume an unpaused task");
return;
}
const bool val = doResume();
- if(!val)
- {
+
+ if (!val) {
const QString errorMsg = tr("Cannot resume task '%1'").arg(d->name);
reportError(KDUpdater::ECannotResumeTask, errorMsg);
return;
@@ -323,21 +314,21 @@ void KDUpdater::Task::resume()
/*!
\internal
*/
-void KDUpdater::Task::reportProgress(int percent, const QString& text)
+void KDUpdater::Task::reportProgress(int percent, const QString &text)
{
- if(d->progressPc == percent)
+ if (d->progressPc == percent)
return;
d->progressPc = percent;
d->progressText = text;
- emit progressValue( d->progressPc );
- emit progressText( d->progressText );
+ emit progressValue(d->progressPc);
+ emit progressText(d->progressText);
}
/*!
\internal
*/
-void KDUpdater::Task::reportError(int errorCode, const QString& errorText)
+void KDUpdater::Task::reportError(int errorCode, const QString &errorText)
{
d->errorCode = errorCode;
d->errorText = errorText;
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufcompresscommon.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufcompresscommon.cpp
index 4a93b92c2..4a5707b07 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufcompresscommon.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufcompresscommon.cpp
@@ -29,42 +29,40 @@ using namespace KDUpdater;
bool UFHeader::isValid() const
{
- return magic == QLatin1String( KD_UPDATER_UF_HEADER_MAGIC ) &&
- fileList.count() == permList.count() &&
- fileList.count() == isDirList.count();
+ return magic == QLatin1String(KD_UPDATER_UF_HEADER_MAGIC)
+ && fileList.count() == permList.count()
+ && fileList.count() == isDirList.count();
}
-void UFHeader::addToHash(QCryptographicHash& hash) const
+void UFHeader::addToHash(QCryptographicHash &hash) const
{
QByteArray data;
- QDataStream stream( &data, QIODevice::WriteOnly );
+ QDataStream stream(&data, QIODevice::WriteOnly);
stream << *this;
hash.addData(data);
}
UFEntry::UFEntry()
- : permissions( 0 )
-{
-}
+ : permissions(0)
+{}
bool UFEntry::isValid() const
{
return !fileName.isEmpty();
}
-void UFEntry::addToHash(QCryptographicHash& hash) const
+void UFEntry::addToHash(QCryptographicHash &hash) const
{
QByteArray data;
- QDataStream stream( &data, QIODevice::WriteOnly );
- stream.setVersion( QDataStream::Qt_4_2 );
+ QDataStream stream(&data, QIODevice::WriteOnly);
+ stream.setVersion(QDataStream::Qt_4_2);
stream << *this;
hash.addData(data);
}
-namespace KDUpdater
-{
+namespace KDUpdater {
-QDataStream& operator<<( QDataStream& stream, const UFHeader& hdr )
+QDataStream &operator<<(QDataStream &stream, const UFHeader &hdr)
{
stream << hdr.magic;
stream << hdr.fileList;
@@ -73,35 +71,36 @@ QDataStream& operator<<( QDataStream& stream, const UFHeader& hdr )
return stream;
}
-QDataStream& operator>>( QDataStream& stream, UFHeader& hdr )
+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 && hdr.magic != QLatin1String(KD_UPDATER_UF_HEADER_MAGIC))
+ stream.setStatus(QDataStream::ReadCorruptData);
- if( stream.status() == QDataStream::Ok )
+ if (stream.status() == QDataStream::Ok)
stream >> hdr.fileList;
- if( stream.status() == QDataStream::Ok )
+ if (stream.status() == QDataStream::Ok)
stream >> hdr.permList;
- if( stream.status() == QDataStream::Ok )
+ 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.fileList.count() != hdr.permList.count() || hdr.permList.count() != hdr.isDirList.count()))
+ stream.setStatus(QDataStream::ReadCorruptData);
- if( stream.status() != QDataStream::Ok )
+ if( stream.status() != QDataStream::Ok)
hdr = UFHeader();
- if( oldStatus != QDataStream::Ok )
- stream.setStatus( oldStatus );
+ if (oldStatus != QDataStream::Ok)
+ stream.setStatus(oldStatus);
return stream;
}
-QDataStream& operator<<( QDataStream& stream, const UFEntry& entry )
+QDataStream &operator<<( QDataStream &stream, const UFEntry &entry)
{
stream << entry.fileName;
stream << entry.permissions;
@@ -109,23 +108,23 @@ QDataStream& operator<<( QDataStream& stream, const UFEntry& entry )
return stream;
}
-QDataStream& operator>>( QDataStream& stream, UFEntry& entry )
+QDataStream &operator>>( QDataStream &stream, UFEntry &entry)
{
const QDataStream::Status oldStatus = stream.status();
- if( stream.status() == QDataStream::Ok )
+ if (stream.status() == QDataStream::Ok)
stream >> entry.fileName;
- if( stream.status() == QDataStream::Ok )
+ if (stream.status() == QDataStream::Ok)
stream >> entry.permissions;
- if( stream.status() == QDataStream::Ok )
+ if (stream.status() == QDataStream::Ok)
stream >> entry.fileData;
- if( stream.status() != QDataStream::Ok )
+ if (stream.status() != QDataStream::Ok)
entry = UFEntry();
- if( oldStatus != QDataStream::Ok )
- stream.setStatus( oldStatus );
+ if (oldStatus != QDataStream::Ok)
+ stream.setStatus(oldStatus);
return stream;
}
-}
+} // namespace KDUpdater
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufuncompressor.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufuncompressor.cpp
index 42d40cfbc..4ae146b97 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufuncompressor.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterufuncompressor.cpp
@@ -39,10 +39,10 @@ public:
QString destination;
QString errorMessage;
- void setError(const QString& msg);
+ void setError(const QString &msg);
};
-void UFUncompressor::Private::setError(const QString& msg)
+void UFUncompressor::Private::setError(const QString &msg)
{
errorMessage = msg;
}
@@ -62,7 +62,7 @@ QString UFUncompressor::errorString() const
return d->errorMessage;
}
-void UFUncompressor::setFileName(const QString& fileName)
+void UFUncompressor::setFileName(const QString &fileName)
{
d->ufFileName = fileName;
}
@@ -72,7 +72,7 @@ QString UFUncompressor::fileName() const
return d->ufFileName;
}
-void UFUncompressor::setDestination(const QString& dest)
+void UFUncompressor::setDestination(const QString &dest)
{
d->destination = dest;
}
@@ -87,28 +87,27 @@ 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() ));
+ 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 );
+ 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." ) );
+ 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 ) ) {
+ if (header.magic != QLatin1String( KD_UPDATER_UF_HEADER_MAGIC)) {
d->setError(tr("Wrong file format (magic number not found)"));
return false;
}
@@ -119,19 +118,16 @@ bool UFUncompressor::uncompress()
// Lets create the required directory structure
int numExpectedFiles = 0;
- for(int i=0; i<header.fileList.count(); i++)
- {
- const QString fileName = header.fileList[i];
+ for (int i = 0; i < header.fileList.count(); i++) {
+ const QString fileName = header.fileList.at(i);
// qDebug("ToUncompress %s", qPrintable(fileName));
- if( header.isDirList[i] )
- {
- if ( !dir.mkpath( fileName ) )
- {
- d->setError(tr("Could not create folder: %1/%2").arg( d->destination, 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(QLatin1String( "%1/%2" )).arg(d->destination, fileName) );
- fileEngine.setPermissions( header.permList[i] | QAbstractFileEngine::ExeOwnerPerm );
+ fileEngine.setFileName(QString(QLatin1String("%1/%2")).arg(d->destination, fileName));
+ fileEngine.setPermissions(header.permList[i] | QAbstractFileEngine::ExeOwnerPerm);
} else {
++numExpectedFiles;
}
@@ -139,51 +135,42 @@ bool UFUncompressor::uncompress()
// Lets now create files within these directories
int numActualFiles = 0;
- while( !ufDS.atEnd() && numActualFiles < numExpectedFiles )
- {
+ 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 ) );
+ 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(QLatin1String( "%1/%2" )).arg(d->destination, ufEntry.fileName);
- const QByteArray ba = qUncompress( ufEntry.fileData );
+ const QByteArray ba = qUncompress(ufEntry.fileData);
// check the size
- QDataStream stream( ufEntry.fileData );
- stream.setVersion( QDataStream::Qt_4_2 );
+ 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 ) );
+ 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() ));
+ 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 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() ) );
+ 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;
@@ -191,13 +178,12 @@ bool UFUncompressor::uncompress()
ufeFile.close();
- const QFile::Permissions perm = static_cast< QFile::Permissions >( ufEntry.permissions );
- ufeFile.setPermissions( perm );
+ const QFile::Permissions perm = static_cast<QFile::Permissions>(ufEntry.permissions);
+ ufeFile.setPermissions(perm);
- if ( ufeFile.error() != QFile::NoError )
- {
+ if (ufeFile.error() != QFile::NoError) {
ufeFile.remove();
- d->setError( tr("Failed writing uncompressed data to %1: %2").arg( completeFileName, ufeFile.errorString() ) );
+ d->setError(tr("Failed writing uncompressed data to %1: %2").arg(completeFileName, ufeFile.errorString()));
return false;
}
@@ -205,7 +191,7 @@ bool UFUncompressor::uncompress()
++numActualFiles;
}
- if( numExpectedFiles != numActualFiles ) {
+ if (numExpectedFiles != numActualFiles) {
d->errorMessage = tr("Corrupt file (wrong number of files)");
return false;
}
@@ -213,7 +199,7 @@ bool UFUncompressor::uncompress()
QByteArray hashdata;
ufDS >> hashdata;
- if( hashdata != hash.result() ) {
+ if (hashdata != hash.result()) {
d->errorMessage = tr("Corrupt file (wrong hash)");
return false;
}
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdate.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdate.cpp
index 0761e7926..f90bccea3 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdate.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdate.cpp
@@ -30,6 +30,8 @@
#include <QFile>
+using namespace KDUpdater;
+
/*!
\ingroup kdupdater
\class KDUpdater::Update kdupdaterupdate.h KDUpdaterUpdate
@@ -46,38 +48,39 @@
KDUpdater::UpdateFinder (which is a friend class). The destructor however is public.
*/
-struct KDUpdater::Update::UpdateData
+struct Update::UpdateData
{
- UpdateData( Update* qq ) :
- q( qq ),
- application( 0 ),
- compressedSize( 0 ),
- uncompressedSize( 0 )
+ UpdateData(Update *qq) :
+ q(qq),
+ application(0),
+ compressedSize(0),
+ uncompressedSize(0)
{}
- Update* q;
- Application* application;
- KDUpdater::UpdateSourceInfo sourceInfo;
+ Update *q;
+ Application *application;
+ UpdateSourceInfo sourceInfo;
QMap<QString, QVariant> data;
QUrl updateUrl;
UpdateType type;
- QList<UpdateOperation*> operations;
+ QList<UpdateOperation *> operations;
QByteArray sha1sum;
quint64 compressedSize;
quint64 uncompressedSize;
- KDUpdater::FileDownloader* fileDownloader;
+ FileDownloader *fileDownloader;
};
/*!
\internal
*/
-KDUpdater::Update::Update(KDUpdater::Application* application, const KDUpdater::UpdateSourceInfo& sourceInfo,
- UpdateType type, const QUrl& updateUrl, const QMap<QString, QVariant>& data, quint64 compressedSize, quint64 uncompressedSize, const QByteArray& sha1sum )
- : KDUpdater::Task(QLatin1String( "Update" ), Stoppable, application),
- d( new UpdateData( this ) )
+Update::Update(Application *application, const UpdateSourceInfo &sourceInfo,
+ UpdateType type, const QUrl &updateUrl, const QMap<QString, QVariant> &data,
+ quint64 compressedSize, quint64 uncompressedSize, const QByteArray &sha1sum)
+ : Task(QLatin1String("Update"), Stoppable, application),
+ d(new UpdateData(this))
{
d->application = application;
d->sourceInfo = sourceInfo;
@@ -89,40 +92,37 @@ KDUpdater::Update::Update(KDUpdater::Application* application, const KDUpdater::
d->uncompressedSize = uncompressedSize;
d->sha1sum = sha1sum;
- const SignatureVerifier* verifier = d->application->signatureVerifier( Application::Packages );
+ const SignatureVerifier *verifier = d->application->signatureVerifier(Application::Packages);
- d->fileDownloader = FileDownloaderFactory::instance().create( updateUrl.scheme(), verifier, QUrl(), this);
- if(d->fileDownloader)
- {
+ d->fileDownloader = FileDownloaderFactory::instance().create(updateUrl.scheme(), verifier, QUrl(), this);
+ if (d->fileDownloader) {
d->fileDownloader->setUrl(d->updateUrl);
- d->fileDownloader->setSha1Sum( d->sha1sum );
+ d->fileDownloader->setSha1Sum(d->sha1sum);
connect(d->fileDownloader, SIGNAL(downloadProgress(double)), this, SLOT(downloadProgress(double)));
connect(d->fileDownloader, SIGNAL(downloadCanceled()), this, SIGNAL(stopped()));
connect(d->fileDownloader, SIGNAL(downloadCompleted()), this, SIGNAL(finished()));
}
- switch( type ) {
+ switch (type) {
case NewPackage:
- case PackageUpdate:
- {
- KDUpdater::UpdateOperation* packageOperation = UpdateOperationFactory::instance().create( QLatin1String( "UpdatePackage" ) );
+ case PackageUpdate: {
+ UpdateOperation *packageOperation = UpdateOperationFactory::instance().create(QLatin1String("UpdatePackage"));
QStringList args;
- args << data.value( QLatin1String( "Name" ) ).toString()
- << data.value( QLatin1String( "Version" ) ).toString()
- << data.value( QLatin1String( "ReleaseDate" ) ).toString();
+ args << data.value(QLatin1String("Name")).toString()
+ << data.value(QLatin1String("Version")).toString()
+ << data.value(QLatin1String("ReleaseDate")).toString();
packageOperation->setArguments(args);
- packageOperation->setApplication( application );
- d->operations.append( packageOperation );
+ packageOperation->setApplication(application);
+ d->operations.append(packageOperation);
break;
}
- case CompatUpdate:
- {
- KDUpdater::UpdateOperation* compatOperation = UpdateOperationFactory::instance().create( QLatin1String( "UpdateCompatLevel" ) );
+ case CompatUpdate: {
+ UpdateOperation *compatOperation = UpdateOperationFactory::instance().create(QLatin1String("UpdateCompatLevel"));
QStringList args;
- args << data.value( QLatin1String( "CompatLevel" ) ).toString();
+ args << data.value(QLatin1String("CompatLevel")).toString();
compatOperation->setArguments(args);
- compatOperation->setApplication( application );
- d->operations.append( compatOperation );
+ compatOperation->setApplication(application);
+ d->operations.append(compatOperation);
break;
}
default:
@@ -133,12 +133,12 @@ KDUpdater::Update::Update(KDUpdater::Application* application, const KDUpdater::
/*!
Destructor
*/
-KDUpdater::Update::~Update()
+Update::~Update()
{
const QString fileName = this->downloadedFileName();
- if( !fileName.isEmpty() )
- QFile::remove( fileName );
- qDeleteAll( d->operations );
+ if (!fileName.isEmpty())
+ QFile::remove(fileName);
+ qDeleteAll(d->operations);
d->operations.clear();
delete d;
}
@@ -146,7 +146,7 @@ KDUpdater::Update::~Update()
/*!
Returns the application for which this class is downloading the UpdateFile
*/
-KDUpdater::Application* KDUpdater::Update::application() const
+Application *Update::application() const
{
return d->application;
}
@@ -154,25 +154,25 @@ KDUpdater::Application* KDUpdater::Update::application() const
/*!
Returns the release date of the update downloaded by this class
*/
-QDate KDUpdater::Update::releaseDate() const
+QDate Update::releaseDate() const
{
- return d->data.value( QLatin1String( "ReleaseDate" ) ).toDate();
+ return d->data.value(QLatin1String("ReleaseDate")).toDate();
}
/*!
Returns data whose name is given in parameter, or an invalid QVariant if the data doesn't exist.
*/
-QVariant KDUpdater::Update::data( const QString& name, const QVariant &defaultValue ) const
+QVariant Update::data(const QString &name, const QVariant &defaultValue) const
{
- if ( d->data.contains( name ) )
- return d->data.value( name );
+ if (d->data.contains(name))
+ return d->data.value(name);
return defaultValue;
}
/*!
Returns the complete URL of the UpdateFile downloaded by this class.
*/
-QUrl KDUpdater::Update::updateUrl() const
+QUrl Update::updateUrl() const
{
return d->updateUrl;
}
@@ -180,7 +180,7 @@ QUrl KDUpdater::Update::updateUrl() const
/*!
Returns the update source info on which this update was created.
*/
-KDUpdater::UpdateSourceInfo KDUpdater::Update::sourceInfo() const
+UpdateSourceInfo Update::sourceInfo() const
{
return d->sourceInfo;
}
@@ -188,7 +188,7 @@ KDUpdater::UpdateSourceInfo KDUpdater::Update::sourceInfo() const
/*!
* Returns the type of update
*/
-KDUpdater::UpdateType KDUpdater::Update::type() const
+UpdateType Update::type() const
{
return d->type;
}
@@ -197,7 +197,7 @@ KDUpdater::UpdateType KDUpdater::Update::type() const
Returns true of the update can be downloaded, false otherwise. The function
returns false if the URL scheme is not supported by this class.
*/
-bool KDUpdater::Update::canDownload() const
+bool Update::canDownload() const
{
return d->fileDownloader && d->fileDownloader->canDownload();
}
@@ -209,7 +209,7 @@ bool KDUpdater::Update::canDownload() const
\note: The downloaded UpdateFile will be deleted when this class is destroyed
*/
-bool KDUpdater::Update::isDownloaded() const
+bool Update::isDownloaded() const
{
return d->fileDownloader && d->fileDownloader->isDownloaded();
}
@@ -218,9 +218,9 @@ bool KDUpdater::Update::isDownloaded() const
Returns the name of the downloaded UpdateFile after the download is complete, ie
when \ref isDownloaded() returns true.
*/
-QString KDUpdater::Update::downloadedFileName() const
+QString Update::downloadedFileName() const
{
- if(d->fileDownloader)
+ if (d->fileDownloader)
return d->fileDownloader->downloadedFileName();
return QString();
@@ -229,7 +229,7 @@ QString KDUpdater::Update::downloadedFileName() const
/*!
\internal
*/
-void KDUpdater::Update::downloadProgress(double value)
+void Update::downloadProgress(double value)
{
Q_ASSERT(value <= 1);
reportProgress(value * 100, tr("Downloading update..."));
@@ -238,7 +238,7 @@ void KDUpdater::Update::downloadProgress(double value)
/*!
\internal
*/
-void KDUpdater::Update::downloadCompleted()
+void Update::downloadCompleted()
{
reportProgress(100, tr("Update downloaded"));
reportDone();
@@ -247,7 +247,7 @@ void KDUpdater::Update::downloadCompleted()
/*!
\internal
*/
-void KDUpdater::Update::downloadAborted(const QString& msg)
+void Update::downloadAborted(const QString &msg)
{
reportError(msg);
}
@@ -255,18 +255,18 @@ void KDUpdater::Update::downloadAborted(const QString& msg)
/*!
\internal
*/
-void KDUpdater::Update::doRun()
+void Update::doRun()
{
- if(d->fileDownloader)
+ if (d->fileDownloader)
d->fileDownloader->download();
}
/*!
\internal
*/
-bool KDUpdater::Update::doStop()
+bool Update::doStop()
{
- if(d->fileDownloader)
+ if (d->fileDownloader)
d->fileDownloader->cancelDownload();
return true;
}
@@ -274,7 +274,7 @@ bool KDUpdater::Update::doStop()
/*!
\internal
*/
-bool KDUpdater::Update::doPause()
+bool Update::doPause()
{
return false;
}
@@ -282,7 +282,7 @@ bool KDUpdater::Update::doPause()
/*!
\internal
*/
-bool KDUpdater::Update::doResume()
+bool Update::doResume()
{
return false;
}
@@ -291,7 +291,7 @@ bool KDUpdater::Update::doResume()
Returns a list of operations needed by this update. For example, package update needs to change
the package version, compat update needs to change the compat level...
*/
-QList<KDUpdater::UpdateOperation*> KDUpdater::Update::operations() const
+QList<UpdateOperation *> Update::operations() const
{
return d->operations;
}
@@ -299,7 +299,7 @@ QList<KDUpdater::UpdateOperation*> KDUpdater::Update::operations() const
/*!
* Returns the compressed size of this update's data file.
*/
-quint64 KDUpdater::Update::compressedSize() const
+quint64 Update::compressedSize() const
{
return d->compressedSize;
}
@@ -307,7 +307,7 @@ quint64 KDUpdater::Update::compressedSize() const
/*!
* Returns the uncompressed size of this update's data file.
*/
-quint64 KDUpdater::Update::uncompressedSize() const
+quint64 Update::uncompressedSize() const
{
return d->uncompressedSize;
}
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdatefinder.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdatefinder.cpp
index 551a81f46..f1e73ef79 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdatefinder.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdatefinder.cpp
@@ -78,33 +78,33 @@ updateInstaller.installUpdates( updates );
//
// Private
//
-class KDUpdater::UpdateFinder::Private
+class UpdateFinder::Private
{
public:
- Private( UpdateFinder* qq ) :
- q( qq ),
+ Private(UpdateFinder *qq) :
+ q(qq),
application(0),
- updateType(KDUpdater::PackageUpdate)
+ updateType(PackageUpdate)
{}
~Private()
{
- qDeleteAll( updates );
- qDeleteAll( updatesInfoList );
- qDeleteAll( updateXmlFDList );
+ qDeleteAll(updates);
+ qDeleteAll(updatesInfoList);
+ qDeleteAll(updateXmlFDList);
}
- UpdateFinder* q;
- KDUpdater::Application* application;
- QList<KDUpdater::Update*> updates;
+ UpdateFinder *q;
+ Application *application;
+ QList<Update *> updates;
UpdateTypes updateType;
// Temporary structure that notes down information about updates.
bool cancel;
int downloadCompleteCount;
- QList<KDUpdater::UpdateSourceInfo> updateSourceInfoList;
- QList<KDUpdater::UpdatesInfo*> updatesInfoList;
- QList<KDUpdater::FileDownloader*> updateXmlFDList;
+ QList<UpdateSourceInfo> updateSourceInfoList;
+ QList<UpdatesInfo *> updatesInfoList;
+ QList<FileDownloader *> updateXmlFDList;
void clear();
void computeUpdates();
@@ -112,12 +112,13 @@ public:
bool downloadUpdateXMLFiles();
bool computeApplicableUpdates();
- QList<KDUpdater::UpdateInfo> applicableUpdates(KDUpdater::UpdatesInfo* updatesInfo, bool addNewPackages = false );
- void createUpdateObjects(const KDUpdater::UpdateSourceInfo& sourceInfo,
- const QList<KDUpdater::UpdateInfo>& updateInfoList);
- bool checkForUpdatePriority(const KDUpdater::UpdateSourceInfo& sourceInfo,
- const KDUpdater::UpdateInfo& updateInfo);
- int pickUpdateFileInfo(const QList<KDUpdater::UpdateFileInfo>& updateFiles);
+ QList<UpdateInfo> applicableUpdates(UpdatesInfo *updatesInfo,
+ bool addNewPackages = false);
+ void createUpdateObjects(const UpdateSourceInfo &sourceInfo,
+ const QList<UpdateInfo> &updateInfoList);
+ bool checkForUpdatePriority(const UpdateSourceInfo &sourceInfo,
+ const UpdateInfo &updateInfo);
+ int pickUpdateFileInfo(const QList<UpdateFileInfo> &updateFiles);
void slotDownloadDone();
};
@@ -137,16 +138,15 @@ static int computePercent(int done, int total)
Releases all internal resources consumed while downloading and computing updates.
*/
-void KDUpdater::UpdateFinder::Private::clear()
+void UpdateFinder::Private::clear()
{
- qDeleteAll( updates );
+ qDeleteAll(updates);
updates.clear();
- qDeleteAll( updatesInfoList );
+ qDeleteAll(updatesInfoList);
updatesInfoList.clear();
- qDeleteAll( updateXmlFDList );
+ qDeleteAll(updateXmlFDList);
updateXmlFDList.clear();
updateSourceInfoList.clear();
-
downloadCompleteCount = 0;
}
@@ -170,7 +170,7 @@ void KDUpdater::UpdateFinder::Private::clear()
\note Each time this function is called, all the previously computed updates are discarded
and its resources are freed.
*/
-void KDUpdater::UpdateFinder::Private::computeUpdates()
+void UpdateFinder::Private::computeUpdates()
{
// Computing updates is done in two stages
// 1. Downloading Update XML files from all the update sources
@@ -180,23 +180,23 @@ void KDUpdater::UpdateFinder::Private::computeUpdates()
clear();
// First do some quick sanity checks on the packages info
- KDUpdater::PackagesInfo* packages = application->packagesInfo();
- if( !packages ) {
+ PackagesInfo *packages = application->packagesInfo();
+ if (!packages) {
q->reportError(tr("Could not access the package information of this application"));
return;
}
- if( !packages->isValid() ) {
+ if (!packages->isValid()) {
q->reportError(packages->errorString());
return;
}
// Now do some quick sanity checks on the update sources info
- KDUpdater::UpdateSourcesInfo* sources = application->updateSourcesInfo();
- if( !sources ) {
+ UpdateSourcesInfo *sources = application->updateSourcesInfo();
+ if (!sources) {
q->reportError(tr("Could not access the update sources information of this application"));
return;
}
- if( !sources->isValid() ) {
+ if (!sources->isValid()) {
q->reportError(sources->errorString());
return;
}
@@ -204,21 +204,19 @@ void KDUpdater::UpdateFinder::Private::computeUpdates()
// Now we can start...
// Step 1: 0 - 49 percent
- if(!downloadUpdateXMLFiles() || cancel)
- {
+ if (!downloadUpdateXMLFiles() || cancel) {
clear();
return;
}
// Step 2: 50 - 100 percent
- if(!computeApplicableUpdates() || cancel)
- {
+ if (!computeApplicableUpdates() || cancel) {
clear();
return;
}
// All done
- q->reportProgress( 100, tr("%1 updates found").arg(updates.count()) );
+ q->reportProgress(100, tr("%1 updates found").arg(updates.count()));
q->reportDone();
}
@@ -229,7 +227,7 @@ void KDUpdater::UpdateFinder::Private::computeUpdates()
\sa \ref computeUpdates()
*/
-void KDUpdater::UpdateFinder::Private::cancelComputeUpdates()
+void UpdateFinder::Private::cancelComputeUpdates()
{
cancel = true;
}
@@ -250,30 +248,29 @@ void KDUpdater::UpdateFinder::Private::cancelComputeUpdates()
The function gets into an event loop until all the downloads are complete.
*/
-bool KDUpdater::UpdateFinder::Private::downloadUpdateXMLFiles()
+bool UpdateFinder::Private::downloadUpdateXMLFiles()
{
- if( !application )
+ if (!application)
return false;
- KDUpdater::UpdateSourcesInfo* updateSources = application->updateSourcesInfo();
- if( !updateSources )
+ UpdateSourcesInfo *updateSources = application->updateSourcesInfo();
+ if (!updateSources )
return false;
- // Create KDUpdater::FileDownloader and KDUpdater::UpdatesInfo for each update
- for(int i=0; i<updateSources->updateSourceInfoCount(); i++)
- {
- KDUpdater::UpdateSourceInfo info = updateSources->updateSourceInfo(i);
+ // Create FileDownloader and UpdatesInfo for each update
+ for (int i = 0; i < updateSources->updateSourceInfoCount(); i++) {
+ UpdateSourceInfo info = updateSources->updateSourceInfo(i);
QUrl updateXmlUrl = QString::fromLatin1("%1/Updates.xml").arg(info.url.toString());
- const SignatureVerifier* verifier = application->signatureVerifier( Application::Metadata );
- KDUpdater::FileDownloader* downloader = FileDownloaderFactory::instance().create(updateXmlUrl.scheme(), verifier, QUrl(), q);
- if( !downloader )
+ const SignatureVerifier *verifier = application->signatureVerifier(Application::Metadata);
+ FileDownloader *downloader = FileDownloaderFactory::instance().create(updateXmlUrl.scheme(), verifier, QUrl(), q);
+ if (!downloader)
continue;
downloader->setUrl(updateXmlUrl);
downloader->setAutoRemoveDownloadedFile(true);
- KDUpdater::UpdatesInfo* updatesInfo = new KDUpdater::UpdatesInfo;
+ UpdatesInfo *updatesInfo = new UpdatesInfo;
updateSourceInfoList.append(info);
updateXmlFDList.append(downloader);
updatesInfoList.append(updatesInfo);
@@ -288,19 +285,17 @@ bool KDUpdater::UpdateFinder::Private::downloadUpdateXMLFiles()
// Trigger download of Updates.xml file
downloadCompleteCount = 0;
- for(int i=0; i<updateXmlFDList.count(); i++)
- {
- KDUpdater::FileDownloader* downloader = updateXmlFDList[i];
+ for (int i = 0; i < updateXmlFDList.count(); i++) {
+ FileDownloader *downloader = updateXmlFDList.at(i);
downloader->download();
}
// Wait until all downloaders have completed their downloads.
- while(1)
- {
+ while (true) {
QCoreApplication::processEvents();
- if( cancel )
+ if (cancel)
return false;
- if( downloadCompleteCount == updateXmlFDList.count())
+ if (downloadCompleteCount == updateXmlFDList.count())
break;
int pc = computePercent(downloadCompleteCount, updateXmlFDList.count());
@@ -311,13 +306,12 @@ bool KDUpdater::UpdateFinder::Private::downloadUpdateXMLFiles()
// donwload of update XML files.
// Lets now get rid of update sources whose Updates.xml could not be downloaded
- for(int i=0; i<updateXmlFDList.count(); i++)
- {
- KDUpdater::FileDownloader* downloader = updateXmlFDList[i];
- if( downloader->isDownloaded() )
+ for (int i = 0; i < updateXmlFDList.count(); i++) {
+ FileDownloader *downloader = updateXmlFDList.at(i);
+ if (downloader->isDownloaded())
continue;
- KDUpdater::UpdateSourceInfo info = updateSourceInfoList[i];
+ UpdateSourceInfo info = updateSourceInfoList.at(i);
QString msg = tr("Could not download updates from %1 ('%2')").arg(info.name, info.url.toString());
q->reportError(msg);
@@ -329,17 +323,15 @@ bool KDUpdater::UpdateFinder::Private::downloadUpdateXMLFiles()
--i;
}
- if (updatesInfoList.isEmpty()) {
+ if (updatesInfoList.isEmpty())
return false;
- }
// Lets parse the downloaded update XML files and get rid of the downloaders.
- for(int i=0; i<updateXmlFDList.count(); i++)
- {
- KDUpdater::FileDownloader* downloader = updateXmlFDList[i];
- KDUpdater::UpdatesInfo* updatesInfo = updatesInfoList[i];
+ for (int i = 0; i < updateXmlFDList.count(); i++) {
+ FileDownloader *downloader = updateXmlFDList.at(i);
+ UpdatesInfo *updatesInfo = updatesInfoList.at(i);
- updatesInfo->setFileName( downloader->downloadedFileName() );
+ updatesInfo->setFileName(downloader->downloadedFileName());
if (!updatesInfo->isValid()) {
QString msg = updatesInfo->errorString();
@@ -352,14 +344,13 @@ bool KDUpdater::UpdateFinder::Private::downloadUpdateXMLFiles()
--i;
}
}
- qDeleteAll( updateXmlFDList );
+ qDeleteAll(updateXmlFDList);
updateXmlFDList.clear();
- if (updatesInfoList.isEmpty()) {
+ if (updatesInfoList.isEmpty())
return false;
- }
- q->reportProgress( 49, tr("Updates.xml file(s) downloaded from update sources") );
+ q->reportProgress(49, tr("Updates.xml file(s) downloaded from update sources"));
return true;
}
@@ -371,43 +362,40 @@ bool KDUpdater::UpdateFinder::Private::downloadUpdateXMLFiles()
KDUpdater::PackagesInfo. There by figures out whether an update is applicable for
this application or not.
*/
-bool KDUpdater::UpdateFinder::Private::computeApplicableUpdates()
+bool UpdateFinder::Private::computeApplicableUpdates()
{
- if( updateType & KDUpdater::CompatUpdate )
- {
- KDUpdater::UpdateInfo compatUpdateInfo;
- KDUpdater::UpdateSourceInfo compatUpdateSourceInfo;
+ if (updateType & CompatUpdate) {
+ UpdateInfo compatUpdateInfo;
+ UpdateSourceInfo compatUpdateSourceInfo;
// Required compat level
- int reqCompatLevel = application->compatLevel()+1;
+ int reqCompatLevel = application->compatLevel() + 1;
q->reportProgress(60, tr("Looking for compatibility update..."));
// We are only interested in compat updates.
- for(int i=0; i<updatesInfoList.count(); i++)
- {
- KDUpdater::UpdatesInfo* info = updatesInfoList[i];
- KDUpdater::UpdateSourceInfo updateSource = updateSourceInfoList[i];
+ for (int i = 0; i < updatesInfoList.count(); i++) {
+ UpdatesInfo *info = updatesInfoList.at(i);
+ UpdateSourceInfo updateSource = updateSourceInfoList.at(i);
// If we already have a compat update, just check if the source currently being
// considered has a higher priority or not.
- if(compatUpdateInfo.data.contains( QLatin1String( "CompatLevel" ) ) && updateSource.priority < compatUpdateSourceInfo.priority)
+ if (compatUpdateInfo.data.contains(QLatin1String("CompatLevel")) && updateSource.priority < compatUpdateSourceInfo.priority)
continue;
// Lets look for comapt updates that provide compat level one-higher than
// the application's current compat level.
- QList<KDUpdater::UpdateInfo> updatesInfo = info->updatesInfo( KDUpdater::CompatUpdate, reqCompatLevel );
+ QList<UpdateInfo> updatesInfo = info->updatesInfo(CompatUpdate, reqCompatLevel);
- if( updatesInfo.count() == 0 )
+ if (updatesInfo.count() == 0)
continue;
- compatUpdateInfo = updatesInfo.at( 0 );
+ compatUpdateInfo = updatesInfo.at(0);
compatUpdateSourceInfo = updateSource;
}
- bool found = (compatUpdateInfo.data.contains( QLatin1String( "CompatLevel" ) ));
- if(found)
- {
+ bool found = compatUpdateInfo.data.contains(QLatin1String("CompatLevel"));
+ if (found) {
q->reportProgress(80, tr("Found compatibility update.."));
// Lets create an update for this compat update.
@@ -416,87 +404,80 @@ bool KDUpdater::UpdateFinder::Private::computeApplicableUpdates()
// Pick a update file based on arch and OS.
int pickUpdateFileIndex = pickUpdateFileInfo(compatUpdateInfo.updateFiles);
- if(pickUpdateFileIndex < 0)
- {
+ if (pickUpdateFileIndex < 0) {
q->reportError(tr("Compatibility update for the required architecture and hardware configuration was not found"));
q->reportProgress(100, tr("Compatibility update not found"));
return false;
}
- KDUpdater::UpdateFileInfo fileInfo = compatUpdateInfo.updateFiles.at( pickUpdateFileIndex );
+ UpdateFileInfo fileInfo = compatUpdateInfo.updateFiles.at(pickUpdateFileIndex);
// Create an update for this entry
- url = QString::fromLatin1( "%1/%2" ).arg( compatUpdateSourceInfo.url.toString(), fileInfo.fileName );
- KDUpdater::Update* update = q->constructUpdate(application,
- compatUpdateSourceInfo,
- KDUpdater::CompatUpdate, url,
- compatUpdateInfo.data, fileInfo.compressedSize, fileInfo.uncompressedSize, fileInfo.sha1sum );
+ url = QString::fromLatin1("%1/%2").arg( compatUpdateSourceInfo.url.toString(), fileInfo.fileName);
+ Update *update = q->constructUpdate(application, compatUpdateSourceInfo, CompatUpdate,
+ url, compatUpdateInfo.data, fileInfo.compressedSize,
+ fileInfo.uncompressedSize, fileInfo.sha1sum);
// Register the update
updates.append(update);
// Done
q->reportProgress(100, tr("Compatibility update found"));
- }
- else
+ } else {
q->reportProgress(100, tr("No compatibility updates found"));
+ }
}
- if ( updateType & PackageUpdate )
- {
+ if (updateType & PackageUpdate) {
// We are not looking for normal updates, not compat ones.
- for(int i=0; i<updatesInfoList.count(); i++)
- {
+ for (int i = 0; i < updatesInfoList.count(); i++) {
// Fetch updates applicable to this application.
- KDUpdater::UpdatesInfo* info = updatesInfoList[i];
- QList<KDUpdater::UpdateInfo> updates = applicableUpdates(info , updateType & NewPackage );
- if( !updates.count() )
+ UpdatesInfo *info = updatesInfoList.at(i);
+ QList<UpdateInfo> updates = applicableUpdates(info , updateType & NewPackage);
+ if (!updates.count())
continue;
- if( cancel )
+ if (cancel)
return false;
- KDUpdater::UpdateSourceInfo updateSource = updateSourceInfoList[i];
+ UpdateSourceInfo updateSource = updateSourceInfoList.at(i);
- // Create KDUpdater::Update objects for updates that have a valid
+ // Create Update objects for updates that have a valid
// UpdateFile
createUpdateObjects(updateSource, updates);
- if( cancel )
+ if (cancel)
return false;
// Report progress
int pc = computePercent(i, updatesInfoList.count());
pc = computeProgressPercentage(51, 100, pc);
- q->reportProgress( pc, tr("Computing applicable updates") );
+ q->reportProgress(pc, tr("Computing applicable updates"));
}
}
- q->reportProgress( 99, tr("Application updates computed") );
+ q->reportProgress(99, tr("Application updates computed"));
return true;
}
-QList<KDUpdater::UpdateInfo> KDUpdater::UpdateFinder::Private::applicableUpdates( KDUpdater::UpdatesInfo* updatesInfo, bool addNewPackages )
+QList<UpdateInfo> UpdateFinder::Private::applicableUpdates(UpdatesInfo *updatesInfo, bool addNewPackages)
{
- QList<KDUpdater::UpdateInfo> retList;
+ QList<UpdateInfo> retList;
- if( !updatesInfo || updatesInfo->updateInfoCount( PackageUpdate ) == 0 )
+ if (!updatesInfo || updatesInfo->updateInfoCount( PackageUpdate ) == 0)
return retList;
- KDUpdater::PackagesInfo* packages = this->application->packagesInfo();
- if( !packages )
+ PackagesInfo *packages = this->application->packagesInfo();
+ if (!packages)
return retList;
// Check to see if the updates info contains updates for any application
- bool anyApp = updatesInfo->applicationName() == QLatin1String( "{AnyApplication}" );
+ bool anyApp = updatesInfo->applicationName() == QLatin1String("{AnyApplication}");
int appNameIndex = -1;
- if( !anyApp )
- {
+ if (!anyApp) {
// updatesInfo->applicationName() describes one application or a series of
// application names separated by commas.
QString appName = updatesInfo->applicationName();
- appName = appName.replace(QLatin1String( ", " ),
- QLatin1String( "," ));
- appName = appName.replace(QLatin1String( " ," ),
- QLatin1String( "," ));
+ appName = appName.replace(QLatin1String( ", " ), QLatin1String( "," ));
+ appName = appName.replace(QLatin1String( " ," ), QLatin1String( "," ));
// Catch hold of app names contained updatesInfo->applicationName()
QStringList apps = appName.split(QRegExp(QLatin1String("\\b(,|, )\\b")), QString::SkipEmptyParts);
@@ -504,24 +485,25 @@ QList<KDUpdater::UpdateInfo> KDUpdater::UpdateFinder::Private::applicableUpdates
// If the application appName isnt one of the app names, then
// the updates are not applicable.
- if( appNameIndex < 0 )
+ if (appNameIndex < 0)
return retList;
}
-#if 0 //Nokia-SDK: ignore ApplicationVersion, it has no purpose and just causes problems if someone bumps the config.xml application version accidentally
+#if 0
+ // Nokia-SDK: ignore ApplicationVersion, it has no purpose and just causes
+ // problems if someone bumps the config.xml application version accidentally
// Check to see if the update repository versions match with app version
- if( !anyApp )
- {
+ if (!anyApp) {
QString appVersion = updatesInfo->applicationVersion();
appVersion = appVersion.replace(QLatin1String( ", " ), QLatin1String( "," ));
appVersion = appVersion.replace(QLatin1String( " ," ), QLatin1String( "," ));
QStringList versions = appVersion.split(QLatin1String( "," ), QString::SkipEmptyParts);
- if( appNameIndex >= versions.count() )
+ if (appNameIndex >= versions.count())
return retList; // please give us well formatted Updates.xml files.
- QString version = versions[appNameIndex];
- if( KDUpdater::compareVersion(this->application->applicationVersion(), version) != 0 )
+ QString version = versions.at(appNameIndex);
+ if (KDUpdater::compareVersion(this->application->applicationVersion(), version) != 0)
return retList;
}
#endif
@@ -529,22 +511,20 @@ QList<KDUpdater::UpdateInfo> KDUpdater::UpdateFinder::Private::applicableUpdates
// Check to see if version numbers match. This means that the version
// number of the update should be greater than the version number of
// the package that is currently installed.
- QList<KDUpdater::UpdateInfo> updateList = updatesInfo->updatesInfo( KDUpdater::PackageUpdate );
- for(int i=0; i<updatesInfo->updateInfoCount( PackageUpdate ); i++)
- {
- KDUpdater::UpdateInfo updateInfo = updateList.at( i );
- if( !addNewPackages )
- {
- int pkgInfoIdx = packages->findPackageInfo( updateInfo.data.value( QLatin1String( "Name" ) ).toString() );
- if( pkgInfoIdx < 0 )
+ QList<UpdateInfo> updateList = updatesInfo->updatesInfo(PackageUpdate);
+ for (int i = 0; i < updatesInfo->updateInfoCount(PackageUpdate); i++) {
+ UpdateInfo updateInfo = updateList.at(i);
+ if (!addNewPackages) {
+ int pkgInfoIdx = packages->findPackageInfo( updateInfo.data.value(QLatin1String("Name")).toString());
+ if (pkgInfoIdx < 0)
continue;
- KDUpdater::PackageInfo pkgInfo = packages->packageInfo( pkgInfoIdx );
+ PackageInfo pkgInfo = packages->packageInfo(pkgInfoIdx);
// First check to see if the update version is more than package version
- QString updateVersion = updateInfo.data.value( QLatin1String( "Version" ) ).toString();
+ QString updateVersion = updateInfo.data.value(QLatin1String("Version")).toString();
QString pkgVersion = pkgInfo.version;
- if( KDUpdater::compareVersion(updateVersion, pkgVersion) <= 0 )
+ if (KDUpdater::compareVersion(updateVersion, pkgVersion) <= 0)
continue;
// It is quite possible that we may have already installed the update.
@@ -552,8 +532,8 @@ QList<KDUpdater::UpdateInfo> KDUpdater::UpdateFinder::Private::applicableUpdates
// of the update. This way we can compare and figure out if the update
// has been installed or not.
QDate pkgDate = pkgInfo.lastUpdateDate;
- QDate updateDate = updateInfo.data.value( QLatin1String( "ReleaseDate" ) ).toDate();
- if( pkgDate > updateDate )
+ QDate updateDate = updateInfo.data.value(QLatin1String("ReleaseDate")).toDate();
+ if (pkgDate > updateDate)
continue;
}
@@ -564,14 +544,13 @@ QList<KDUpdater::UpdateInfo> KDUpdater::UpdateFinder::Private::applicableUpdates
return retList;
}
-void KDUpdater::UpdateFinder::Private::createUpdateObjects(const KDUpdater::UpdateSourceInfo& sourceInfo, const QList<KDUpdater::UpdateInfo>& updateInfoList)
+void UpdateFinder::Private::createUpdateObjects(const UpdateSourceInfo &sourceInfo, const QList<UpdateInfo> &updateInfoList)
{
- for(int i=0; i<updateInfoList.count(); i++)
- {
- KDUpdater::UpdateInfo info = updateInfoList[i];
+ for (int i = 0; i < updateInfoList.count(); i++) {
+ UpdateInfo info = updateInfoList.at(i);
// Compat level checks
- if( info.data.contains( QLatin1String( "RequiredCompatLevel" ) ) &&
- info.data.value( QLatin1String( "RequiredCompatLevel" ) ).toInt() != application->compatLevel() )
+ if (info.data.contains(QLatin1String("RequiredCompatLevel")) &&
+ info.data.value(QLatin1String("RequiredCompatLevel")).toInt() != application->compatLevel())
{
qDebug() << "Update \"" << info.data.value( QLatin1String( "Name" ) ).toString() << "\" at \""
<< sourceInfo.name << "\"(\"" << sourceInfo.url.toString() << "\") requires a different compat level";
@@ -580,10 +559,9 @@ void KDUpdater::UpdateFinder::Private::createUpdateObjects(const KDUpdater::Upda
// If another update of the same name exists, then use the update coming from
// a higher priority.
- if( !checkForUpdatePriority(sourceInfo, info) )
- {
+ if (!checkForUpdatePriority(sourceInfo, info)) {
qDebug() << "Skipping Update \""
- << info.data.value( QLatin1String( "Name" ) ).toString()
+ << info.data.value(QLatin1String("Name")).toString()
<< "\" from \""
<< sourceInfo.name
<< "\"(\""
@@ -595,37 +573,36 @@ void KDUpdater::UpdateFinder::Private::createUpdateObjects(const KDUpdater::Upda
// Pick a update file based on arch and OS.
int pickUpdateFileIndex = this->pickUpdateFileInfo(info.updateFiles);
- if(pickUpdateFileIndex < 0)
+ if (pickUpdateFileIndex < 0)
continue;
- KDUpdater::UpdateFileInfo fileInfo = info.updateFiles.at( pickUpdateFileIndex );
+ UpdateFileInfo fileInfo = info.updateFiles.at(pickUpdateFileIndex);
// Create an update for this entry
- QUrl url( QString::fromLatin1("%1/%2").arg( sourceInfo.url.toString(), fileInfo.fileName ) );
- KDUpdater::Update* update = q->constructUpdate(application, sourceInfo, KDUpdater::PackageUpdate, url, info.data, fileInfo.compressedSize, fileInfo.uncompressedSize, fileInfo.sha1sum );
+ QUrl url(QString::fromLatin1("%1/%2").arg( sourceInfo.url.toString(), fileInfo.fileName));
+ Update *update = q->constructUpdate(application, sourceInfo, PackageUpdate, url, info.data, fileInfo.compressedSize, fileInfo.uncompressedSize, fileInfo.sha1sum);
// Register the update
this->updates.append(update);
}
}
-bool KDUpdater::UpdateFinder::Private::checkForUpdatePriority(const KDUpdater::UpdateSourceInfo& sourceInfo, const KDUpdater::UpdateInfo& updateInfo)
+bool UpdateFinder::Private::checkForUpdatePriority(const UpdateSourceInfo &sourceInfo, const UpdateInfo &updateInfo)
{
- for(int i=0; i<this->updates.count(); i++)
- {
- KDUpdater::Update* update = this->updates[i];
- if( update->data( QLatin1String( "Name" ) ).toString() != updateInfo.data.value( QLatin1String( "Name" ) ).toString() )
+ for (int i = 0; i < this->updates.count(); i++){
+ Update *update = this->updates.at(i);
+ if (update->data(QLatin1String("Name")).toString() != updateInfo.data.value(QLatin1String("Name")).toString())
continue;
// Bingo, update was previously found elsewhere.
// If the existing update comes from a higher priority server, then cool :)
- if( update->sourceInfo().priority > sourceInfo.priority )
+ if (update->sourceInfo().priority > sourceInfo.priority)
return false;
// If the existing update has a higher version number, keep it
- if ( KDUpdater::compareVersion(update->data( QLatin1String( "Version" ) ).toString(),
- updateInfo.data.value( QLatin1String( "Version" ) ).toString()) > 0)
+ if (KDUpdater::compareVersion(update->data(QLatin1String("Version")).toString(),
+ updateInfo.data.value(QLatin1String("Version")).toString()) > 0)
return false;
// Otherwise the old update must be deleted.
@@ -639,7 +616,7 @@ bool KDUpdater::UpdateFinder::Private::checkForUpdatePriority(const KDUpdater::U
return true;
}
-int KDUpdater::UpdateFinder::Private::pickUpdateFileInfo(const QList<KDUpdater::UpdateFileInfo>& updateFiles)
+int UpdateFinder::Private::pickUpdateFileInfo(const QList<UpdateFileInfo> &updateFiles)
{
#ifdef Q_WS_MAC
QString os = QLatin1String( "MacOSX" );
@@ -653,14 +630,13 @@ int KDUpdater::UpdateFinder::Private::pickUpdateFileInfo(const QList<KDUpdater::
QString arch = QLatin1String( "i386" ); // only one architecture considered for now.
- for(int i=0; i<updateFiles.count(); i++)
- {
- KDUpdater::UpdateFileInfo fileInfo = updateFiles[i];
+ for (int i = 0; i < updateFiles.count(); i++) {
+ UpdateFileInfo fileInfo = updateFiles.at(i);
- if( fileInfo.arch != arch )
+ if (fileInfo.arch != arch)
continue;
- if( fileInfo.os != QLatin1String( "Any" ) && fileInfo.os != os )
+ if (fileInfo.os != QLatin1String("Any") && fileInfo.os != os)
continue;
return i;
@@ -678,9 +654,9 @@ int KDUpdater::UpdateFinder::Private::pickUpdateFileInfo(const QList<KDUpdater::
/*!
Constructs a update finder for a given \ref KDUpdater::Application.
*/
-KDUpdater::UpdateFinder::UpdateFinder(KDUpdater::Application* application)
- : KDUpdater::Task(QLatin1String( "UpdateFinder" ), Stoppable, application),
- d( new Private( this ) )
+UpdateFinder::UpdateFinder(Application *application)
+ : Task(QLatin1String("UpdateFinder"), Stoppable, application),
+ d(new Private(this))
{
d->application = application;
}
@@ -688,7 +664,7 @@ KDUpdater::UpdateFinder::UpdateFinder(KDUpdater::Application* application)
/*!
Destructor
*/
-KDUpdater::UpdateFinder::~UpdateFinder()
+UpdateFinder::~UpdateFinder()
{
delete d;
}
@@ -697,7 +673,7 @@ KDUpdater::UpdateFinder::~UpdateFinder()
Returns a pointer to the update application for which this function computes all
the updates.
*/
-KDUpdater::Application* KDUpdater::UpdateFinder::application() const
+Application *UpdateFinder::application() const
{
return d->application;
}
@@ -706,7 +682,7 @@ KDUpdater::Application* KDUpdater::UpdateFinder::application() const
Returns a list of KDUpdater::Update objects. The update objects returned in this list
are made children of the \ref KDUpdater::Application object associated with this class.
*/
-QList<KDUpdater::Update*> KDUpdater::UpdateFinder::updates() const
+QList<Update *> UpdateFinder::updates() const
{
return d->updates;
}
@@ -714,7 +690,7 @@ QList<KDUpdater::Update*> KDUpdater::UpdateFinder::updates() const
/*!
Looks only for a certain type of update. By default, only package update
*/
-void KDUpdater::UpdateFinder::setUpdateType(UpdateTypes type)
+void UpdateFinder::setUpdateType(UpdateTypes type)
{
d->updateType = type;
}
@@ -722,7 +698,7 @@ void KDUpdater::UpdateFinder::setUpdateType(UpdateTypes type)
/*!
Returns the type of updates searched
*/
-KDUpdater::UpdateTypes KDUpdater::UpdateFinder::updateType() const
+UpdateTypes UpdateFinder::updateType() const
{
return d->updateType;
}
@@ -732,7 +708,7 @@ KDUpdater::UpdateTypes KDUpdater::UpdateFinder::updateType() const
Implemented from \ref KDUpdater::Task::doStart().
*/
-void KDUpdater::UpdateFinder::doRun()
+void UpdateFinder::doRun()
{
d->computeUpdates();
}
@@ -742,7 +718,7 @@ void KDUpdater::UpdateFinder::doRun()
Implemented form \ref KDUpdater::Task::doStop()
*/
-bool KDUpdater::UpdateFinder::doStop()
+bool UpdateFinder::doStop()
{
d->cancelComputeUpdates();
@@ -757,7 +733,7 @@ bool KDUpdater::UpdateFinder::doStop()
Implemented form \ref KDUpdater::Task::doStop()
*/
-bool KDUpdater::UpdateFinder::doPause()
+bool UpdateFinder::doPause()
{
// Not a pausable task
return false;
@@ -768,7 +744,7 @@ bool KDUpdater::UpdateFinder::doPause()
Implemented form \ref KDUpdater::Task::doStop()
*/
-bool KDUpdater::UpdateFinder::doResume()
+bool UpdateFinder::doResume()
{
// Not a pausable task, hence it is not resumable as well
return false;
@@ -777,7 +753,7 @@ bool KDUpdater::UpdateFinder::doResume()
/*!
\internal
*/
-void KDUpdater::UpdateFinder::Private::slotDownloadDone()
+void UpdateFinder::Private::slotDownloadDone()
{
++downloadCompleteCount;
@@ -789,10 +765,11 @@ void KDUpdater::UpdateFinder::Private::slotDownloadDone()
/*!
\internal
*/
-KDUpdater::Update* KDUpdater::UpdateFinder::constructUpdate( Application* application, const UpdateSourceInfo& sourceInfo,
- UpdateType type, const QUrl& updateUrl, const QMap< QString, QVariant >& data, quint64 compressedSize, quint64 uncompressedSize, const QByteArray& sha1sum )
+Update *UpdateFinder::constructUpdate(Application *application, const UpdateSourceInfo &sourceInfo,
+ UpdateType type, const QUrl &updateUrl, const QMap<QString, QVariant> &data,
+ quint64 compressedSize, quint64 uncompressedSize, const QByteArray &sha1sum )
{
- return new Update( application, sourceInfo, type, updateUrl, data, compressedSize, uncompressedSize, sha1sum );
+ return new Update(application, sourceInfo, type, updateUrl, data, compressedSize, uncompressedSize, sha1sum);
}
@@ -827,62 +804,57 @@ KDUpdater::Update* KDUpdater::UpdateFinder::constructUpdate( Application* applic
\endcode
*/
-int KDUpdater::compareVersion(const QString& v1, const QString& v2)
+int KDUpdater::compareVersion(const QString &v1, const QString &v2)
{
// For tests refer VersionCompareFnTest testcase.
// Check for equality
- if( v1 == v2 )
+ if (v1 == v2)
return 0;
// Split version numbers across .
- const QStringList v1_comps = v1.split( QRegExp( QLatin1String( "\\.|-" ) ) );
- const QStringList v2_comps = v2.split( QRegExp( QLatin1String( "\\.|-" ) ) );
+ const QStringList v1_comps = v1.split(QRegExp(QLatin1String( "\\.|-")));
+ const QStringList v2_comps = v2.split(QRegExp(QLatin1String( "\\.|-")));
// Check each component of the version
int index = 0;
- while(1)
- {
- if( index == v1_comps.count() && index < v2_comps.count() )
+ while (true) {
+ if (index == v1_comps.count() && index < v2_comps.count())
return -1;
- else if( index < v1_comps.count() && index == v2_comps.count() )
+ if (index < v1_comps.count() && index == v2_comps.count())
return +1;
- else if( index >= v1_comps.count() || index >= v2_comps.count() )
+ if (index >= v1_comps.count() || index >= v2_comps.count())
break;
bool v1_ok, v2_ok;
int v1_comp = v1_comps[index].toInt(&v1_ok);
int v2_comp = v2_comps[index].toInt(&v2_ok);
- if(!v1_ok)
- {
- if(v1_comps[index] == QLatin1String( "x" ) )
+ if (!v1_ok) {
+ if (v1_comps[index] == QLatin1String("x"))
return 0;
}
- if(!v2_ok)
- {
- if(v2_comps[index] == QLatin1String( "x") )
+ if (!v2_ok) {
+ if (v2_comps[index] == QLatin1String("x"))
return 0;
}
- if( !v1_ok && !v2_ok )
- {
- return v1_comps[ index ].compare( v2_comps[ index ] );
- }
+ if (!v1_ok && !v2_ok)
+ return v1_comps[index].compare(v2_comps[index]);
- if( v1_comp < v2_comp )
+ if (v1_comp < v2_comp)
return -1;
- if( v1_comp > v2_comp )
+ if (v1_comp > v2_comp)
return +1;
// v1_comp == v2_comp
++index;
}
- if( index < v2_comps.count() )
+ if (index < v2_comps.count())
return +1;
- if( index < v1_comps.count() )
+ if (index < v1_comps.count())
return -1;
// Controversial return. I hope this never happens.
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateinstaller.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateinstaller.cpp
index 3b8d2dbd4..bc7304212 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateinstaller.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateinstaller.cpp
@@ -35,6 +35,8 @@
#include <QDomElement>
#include <QDate>
+using namespace KDUpdater;
+
/*!
\ingroup kdupdater
\class KDUpdater::UpdateInstaller kdupdaterupdateinstaller.h KDUpdaterUpdateInstaller
@@ -52,16 +54,16 @@
\note All temporary files created during the installation of the update will be destroyed
immediately after the installation is complete.
*/
-class KDUpdater::UpdateInstaller::Private
+class UpdateInstaller::Private
{
public:
- Private( UpdateInstaller* qq ) :
- q( qq )
+ Private(UpdateInstaller *qq) :
+ q(qq)
{}
- UpdateInstaller* q;
+ UpdateInstaller *q;
- KDUpdater::Application* application;
+ Application *application;
int updateDownloadDoneCount;
int updateDownloadProgress;
int totalUpdates;
@@ -69,11 +71,11 @@ class KDUpdater::UpdateInstaller::Private
int totalProgressPc;
int currentProgressPc;
- QList<KDUpdater::Update*> updates;
+ QList<Update *> updates;
- void resolveArguments(QStringList& args);
+ void resolveArguments(QStringList &args);
- void removeDirectory(const QDir & dir);
+ void removeDirectory(const QDir &dir);
void slotUpdateDownloadProgress(int percent);
void slotUpdateDownloadDone();
};
@@ -94,9 +96,9 @@ static int computePercent(int done, int total)
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.
*/
-KDUpdater::UpdateInstaller::UpdateInstaller(KDUpdater::Application* application)
- : KDUpdater::Task(QLatin1String( "UpdateInstaller" ), NoCapability, application),
- d( new Private( this ) )
+UpdateInstaller::UpdateInstaller(Application *application)
+ : Task(QLatin1String("UpdateInstaller"), NoCapability, application),
+ d(new Private(this))
{
d->application = application;
}
@@ -104,7 +106,7 @@ KDUpdater::UpdateInstaller::UpdateInstaller(KDUpdater::Application* application)
/*!
Destructor
*/
-KDUpdater::UpdateInstaller::~UpdateInstaller()
+UpdateInstaller::~UpdateInstaller()
{
delete d;
}
@@ -112,7 +114,7 @@ KDUpdater::UpdateInstaller::~UpdateInstaller()
/*!
Returns the update application for which the update is being installed
*/
-KDUpdater::Application* KDUpdater::UpdateInstaller::application() const
+Application *UpdateInstaller::application() const
{
return d->application;
}
@@ -121,7 +123,7 @@ KDUpdater::Application* KDUpdater::UpdateInstaller::application() const
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 KDUpdater::UpdateInstaller::setUpdatesToInstall(const QList<KDUpdater::Update*>& updates)
+void UpdateInstaller::setUpdatesToInstall(const QList<Update *> &updates)
{
d->updates = updates;
}
@@ -129,7 +131,7 @@ void KDUpdater::UpdateInstaller::setUpdatesToInstall(const QList<KDUpdater::Upda
/*!
Returns the updates that would be installed when the next time \ref the start) method is called.
*/
-QList<KDUpdater::Update*> KDUpdater::UpdateInstaller::updatesToInstall() const
+QList<Update *> UpdateInstaller::updatesToInstall() const
{
return d->updates;
}
@@ -137,18 +139,17 @@ QList<KDUpdater::Update*> KDUpdater::UpdateInstaller::updatesToInstall() const
/*!
\internal
*/
-void KDUpdater::UpdateInstaller::doRun()
+void UpdateInstaller::doRun()
{
- QList<KDUpdater::Update*>& updates = d->updates;
+ 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++)
- {
- KDUpdater::Update* update = updates[i];
- if( update->application() != d->application )
+ for (int i = 0; i < updates.count(); i++) {
+ Update *update = updates[i];
+ if (update->application() != d->application)
continue;
update->setProperty("_ProgressPc_", 0);
@@ -162,8 +163,7 @@ void KDUpdater::UpdateInstaller::doRun()
d->currentProgressPc = 0;
// Wait until all updates have been downloaded
- while(d->updateDownloadDoneCount != updates.count())
- {
+ while (d->updateDownloadDoneCount != updates.count()) {
QCoreApplication::processEvents();
// Normalized progress
@@ -186,9 +186,8 @@ void KDUpdater::UpdateInstaller::doRun()
pcDiff = computeProgressPercentage(50, 95, pcDiff) - 50;
// Now install one update after another.
- for(int i=0; i<updates.count(); i++)
- {
- KDUpdater::Update* update = updates[i];
+ for (int i = 0; i < updates.count(); i++) {
+ Update *update = updates[i];
// Global progress
QString msg = tr("Installing %1..").arg(update->name());
@@ -196,7 +195,7 @@ void KDUpdater::UpdateInstaller::doRun()
int maxPc = minPc + pcDiff;
reportProgress(minPc, msg);
- if( update->application() != d->application )
+ if (update->application() != d->application)
continue;
QDir::setCurrent(oldCWD.absolutePath());
@@ -215,14 +214,13 @@ void KDUpdater::UpdateInstaller::doRun()
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 );
+ 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 );
+ dir.rmdir(dirName);
}
d->toRemoveDirs.clear();
@@ -234,7 +232,7 @@ void KDUpdater::UpdateInstaller::doRun()
/*!
\internal
*/
-bool KDUpdater::UpdateInstaller::doStop()
+bool UpdateInstaller::doStop()
{
return false;
}
@@ -242,7 +240,7 @@ bool KDUpdater::UpdateInstaller::doStop()
/*!
\internal
*/
-bool KDUpdater::UpdateInstaller::doPause()
+bool UpdateInstaller::doPause()
{
return false;
}
@@ -250,18 +248,17 @@ bool KDUpdater::UpdateInstaller::doPause()
/*!
\internal
*/
-bool KDUpdater::UpdateInstaller::doResume()
+bool UpdateInstaller::doResume()
{
return false;
}
-bool KDUpdater::UpdateInstaller::installUpdate(KDUpdater::Update* update, int minPc, int maxPc)
+bool UpdateInstaller::installUpdate(Update *update, int minPc, int maxPc)
{
- QString updateName( update->name() );
+ QString updateName = update->name();
// Sanity checks
- if( !update->isDownloaded() )
- {
+ if (!update->isDownloaded()) {
QString msg = tr("Could not download update '%1'").arg(update->name());
reportError(msg);
return false;
@@ -275,15 +272,15 @@ bool KDUpdater::UpdateInstaller::installUpdate(KDUpdater::Update* update, int mi
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 );
+ QDir dir(fi.absolutePath());
+ dir.mkdir(dirName);
+ dir.cd(dirName);
d->toRemoveDirs << dir.absolutePath();
// Step 2: Unpack the update file into the update directory
- KDUpdater::UFUncompressor uncompressor;
- uncompressor.setFileName( updateFile );
- uncompressor.setDestination( dir.absolutePath() );
+ UFUncompressor uncompressor;
+ uncompressor.setFileName(updateFile);
+ uncompressor.setDestination(dir.absolutePath());
if (!uncompressor.uncompress()) {
reportError(tr("Couldn't uncompress update: %1")
@@ -293,17 +290,14 @@ bool KDUpdater::UpdateInstaller::installUpdate(KDUpdater::Update* update, int mi
// Step 3: Find out the directory in which UpdateInstructions.xml can be found
QDir updateDir = dir;
- while( !updateDir.exists(QLatin1String( "UpdateInstructions.xml" )) )
- {
+ while (!updateDir.exists(QLatin1String("UpdateInstructions.xml"))) {
QString path = updateDir.absolutePath();
QFileInfoList fiList = updateDir.entryInfoList(QDir::Dirs|QDir::NoDotAndDotDot);
- if( !fiList.count() ) // || fiList.count() >= 2 )
- {
+ 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());
}
@@ -313,14 +307,12 @@ bool KDUpdater::UpdateInstaller::installUpdate(KDUpdater::Update* update, int mi
// Step 4: Now load the UpdateInstructions.xml file
QDomDocument doc;
QFile file(updateDir.absoluteFilePath(QLatin1String( "UpdateInstructions.xml" )));
- if( !file.open(QFile::ReadOnly) )
- {
+ 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) )
- {
+ if (!doc.setContent(&file)) {
QString msg = tr("Could not read UpdateInstructions.xml of %1").arg(update->name());
reportError(msg);
return false;
@@ -330,45 +322,41 @@ bool KDUpdater::UpdateInstaller::installUpdate(KDUpdater::Update* update, int mi
QDomNodeList operEList = doc.elementsByTagName(QLatin1String( "UpdateOperation" ));
QString msg = tr("Installing %1").arg(updateName);
- for(int i=0; i<operEList.count(); i++)
- {
+ 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" ));
+ 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" ) );
+ QString onError = errorE.attribute(QLatin1String("Action"), QLatin1String("Abort"));
QStringList args;
- while( !argE.isNull() )
- {
+ while(!argE.isNull()) {
args << argE.text();
- argE = argE.nextSiblingElement(QLatin1String( "Arg" ));
+ argE = argE.nextSiblingElement(QLatin1String("Arg"));
}
//QString operSignature = QString::fromLatin1("%1(%2)").arg(operName, args.join( QLatin1String( ", ") ) );
// Fetch update operation
- KDUpdater::UpdateOperation* const updateOperation = KDUpdater::UpdateOperationFactory::instance().create(operName);
- if( !updateOperation )
- {
+ 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" ) )
+ if (onError == QLatin1String("Continue"))
continue;
- if( onError == QLatin1String( "Abort" ) )
+ if (onError == QLatin1String("Abort"))
return false;
- if( onError == QLatin1String( "AskUser" ) )
- {
+ if (onError == QLatin1String("AskUser")) {
// TODO:
continue;
}
@@ -379,24 +367,22 @@ bool KDUpdater::UpdateInstaller::installUpdate(KDUpdater::Update* update, int mi
// Now set the arguments to the update operation and execute the update operation
updateOperation->setArguments(args);
- updateOperation->setApplication( d->application );
+ updateOperation->setApplication(d->application);
const bool success = updateOperation->performOperation();
updateOperation->clear();
- if( !success )
- {
+ if (!success) {
QString errMsg = tr("Cannot execute '%1'").arg(updateOperation->operationCommand());
reportError(errMsg);
- if( onError == QLatin1String( "Continue" ) )
+ if (onError == QLatin1String("Continue"))
continue;
- if( onError == QLatin1String( "Abort" ) )
+ if (onError == QLatin1String("Abort"))
return false;
- if( onError == QLatin1String( "AskUser" ) )
- {
+ if (onError == QLatin1String("AskUser")) {
// TODO:
continue;
}
@@ -404,9 +390,8 @@ bool KDUpdater::UpdateInstaller::installUpdate(KDUpdater::Update* update, int mi
delete updateOperation;
}
- Q_FOREACH( UpdateOperation* updateOperation, update->operations() ) {
+ Q_FOREACH (UpdateOperation *updateOperation, update->operations())
updateOperation->performOperation();
- }
msg = tr("Finished installing update %1").arg(update->name());
reportProgress(maxPc, msg);
@@ -416,16 +401,16 @@ bool KDUpdater::UpdateInstaller::installUpdate(KDUpdater::Update* update, int mi
/*!
\internal
*/
-void KDUpdater::UpdateInstaller::Private::slotUpdateDownloadProgress(int percent)
+void UpdateInstaller::Private::slotUpdateDownloadProgress(int percent)
{
// 0-49 percent progress is dedicated for the download of updates
- KDUpdater::Update* update = qobject_cast<KDUpdater::Update*>(q->sender());
- if( !update )
+ Update *update = qobject_cast<Update *>(q->sender());
+ if (!update)
return;
int oldPc = update->property("_ProgressPc_").toInt();
int diffPc = percent-oldPc;
- if(diffPc <= 0)
+ if (diffPc <= 0)
return;
currentProgressPc += diffPc;
@@ -435,46 +420,43 @@ void KDUpdater::UpdateInstaller::Private::slotUpdateDownloadProgress(int percent
/*!
\internal
*/
-void KDUpdater::UpdateInstaller::Private::slotUpdateDownloadDone()
+void UpdateInstaller::Private::slotUpdateDownloadDone()
{
++updateDownloadDoneCount;
}
-void KDUpdater::UpdateInstaller::Private::resolveArguments(QStringList& args)
+void UpdateInstaller::Private::resolveArguments(QStringList& args)
{
- for(int i=0; i<args.count(); i++)
- {
+ 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());
+ 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 KDUpdater::UpdateInstaller::Private::removeDirectory(const QDir & dir)
+void UpdateInstaller::Private::removeDirectory(const QDir &dir)
{
QFileInfoList fiList = dir.entryInfoList(QDir::Dirs|QDir::Files|QDir::NoDotAndDotDot);
- if( !fiList.count() )
+ if (!fiList.count())
return;
- for(int i=0; i<fiList.count(); i++)
- {
+ for (int i = 0; i < fiList.count(); i++) {
QFileInfo fi = fiList[i];
- if( fi.isDir() )
- {
+ if (fi.isDir()) {
QDir childDir = fi.absoluteFilePath();
- removeDirectory( childDir );
- dir.rmdir( childDir.dirName() );
+ removeDirectory(childDir);
+ dir.rmdir(childDir.dirName());
+ } else if(fi.isFile()) {
+ QFile::remove(fi.absoluteFilePath());
}
- else if( fi.isFile() )
- QFile::remove( fi.absoluteFilePath() );
}
}
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateoperation.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateoperation.cpp
index 7c4121e8e..e09ae83bb 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateoperation.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateoperation.cpp
@@ -46,10 +46,10 @@
* \internal
* Returns a filename for a temporary file based on \a templateName
*/
-static QString backupFileName( const QString& templateName = QString() )
+static QString backupFileName(const QString &templateName)
{
- const QFileInfo templ( templateName );
- QTemporaryFile file( QDir::temp().absoluteFilePath( templ.fileName() ) );
+ const QFileInfo templ(templateName);
+ QTemporaryFile file( QDir::temp().absoluteFilePath(templ.fileName()));
file.open();
const QString name = file.fileName();
file.close();
@@ -61,18 +61,18 @@ using namespace KDUpdater;
struct UpdateOperation::UpdateOperationData
{
- UpdateOperationData( UpdateOperation* qq ) :
- q( qq ),
- error( 0 ),
+ UpdateOperationData(UpdateOperation *qq) :
+ q(qq),
+ error(0),
application(0)
{}
- UpdateOperation* q;
+ UpdateOperation *q;
QString name;
QStringList args;
QString errorString;
int error;
- Application* application;
+ Application *application;
QVariantMap values;
QStringList delayedDeletionFiles;
};
@@ -82,18 +82,17 @@ struct UpdateOperation::UpdateOperationData
Constructor
*/
UpdateOperation::UpdateOperation()
- : d ( new UpdateOperationData( this ) )
-{
-}
+ : d(new UpdateOperationData(this))
+{}
/*!
Destructor
*/
UpdateOperation::~UpdateOperation()
{
- Application* const app = Application::instance();
- if( app )
- app->addFilesForDelayedDeletion( filesForDelayedDeletion() );
+ Application *const app = Application::instance();
+ if (app)
+ app->addFilesForDelayedDeletion(filesForDelayedDeletion());
delete d;
}
@@ -122,42 +121,42 @@ QString UpdateOperation::operationCommand() const
/*!
Returns true if there exists a setting called \a name. Otherwise returns false.
*/
-bool UpdateOperation::hasValue( const QString& name ) const
+bool UpdateOperation::hasValue(const QString &name) const
{
- return d->values.contains( name );
+ return d->values.contains(name);
}
/*!
Clears the value of setting \a name and removes it.
\post hasValue( \a name ) returns false.
*/
-void UpdateOperation::clearValue( const QString& name )
+void UpdateOperation::clearValue(const QString &name)
{
- d->values.remove( name );
+ d->values.remove(name);
}
/*!
Returns the value of setting \a name. If the setting does not exists,
this returns an empty QVariant.
*/
-QVariant UpdateOperation::value( const QString& name ) const
+QVariant UpdateOperation::value(const QString &name) const
{
- return hasValue( name ) ? d->values[ name ] : QVariant();
+ return hasValue(name) ? d->values[name] : QVariant();
}
/*!
Sets the value of setting \a name to \a value.
*/
-void UpdateOperation::setValue( const QString& name, const QVariant& value )
+void UpdateOperation::setValue(const QString &name, const QVariant &value)
{
- d->values[ name ] = value;
+ d->values[name] = value;
}
/*!
Sets a update operation name. Subclasses will have to provide a unique
name to describe this operation.
*/
-void UpdateOperation::setName(const QString& name)
+void UpdateOperation::setName(const QString &name)
{
d->name = name;
}
@@ -166,7 +165,7 @@ void UpdateOperation::setName(const QString& name)
Through this function, arguments to the update operation can be specified
to the update operation.
*/
-void UpdateOperation::setArguments(const QStringList& args)
+void UpdateOperation::setArguments(const QStringList &args)
{
d->args = args;
}
@@ -175,7 +174,7 @@ void UpdateOperation::setArguments(const QStringList& args)
Sets the Application for this operation.
This may be used by some operations
*/
-void UpdateOperation::setApplication( Application* application )
+void UpdateOperation::setApplication(Application *application)
{
d->application = application;
}
@@ -208,7 +207,7 @@ int UpdateOperation::error() const
/*!
* Used by subclasses to set the error string.
*/
-void UpdateOperation::setErrorString( const QString& str )
+void UpdateOperation::setErrorString(const QString &str)
{
d->errorString = str;
}
@@ -216,10 +215,10 @@ void UpdateOperation::setErrorString( const QString& str )
/*!
* Used by subclasses to set the error code.
*/
-void UpdateOperation::setError( int error, const QString& errorString )
+void UpdateOperation::setError(int error, const QString &errorString)
{
d->error = error;
- if( !errorString.isNull() )
+ if (!errorString.isNull())
d->errorString = errorString;
}
@@ -242,7 +241,7 @@ QStringList UpdateOperation::filesForDelayedDeletion() const
(and the file isn't used anymore for sure).
@param files the files to be registered
*/
-void UpdateOperation::registerForDelayedDeletion( const QStringList& files )
+void UpdateOperation::registerForDelayedDeletion(const QStringList &files)
{
d->delayedDeletionFiles << files;
}
@@ -250,30 +249,29 @@ void UpdateOperation::registerForDelayedDeletion( const QStringList& files )
/*!
Tries to delete \a file. If \a file can't be deleted, it gets registered for delayed deletion.
*/
-bool UpdateOperation::deleteFileNowOrLater( const QString& file, QString* errorString )
+bool UpdateOperation::deleteFileNowOrLater(const QString &file, QString *errorString)
{
- if( file.isEmpty() || QFile::remove( file ) )
+ if (file.isEmpty() || QFile::remove(file))
return true;
- if( !QFile::exists( file ) )
+ if (!QFile::exists(file))
return true;
- const QString backup = backupFileName( file );
- QFile f( file );
- if( !f.rename( backup ) )
- {
- if ( errorString )
+ const QString backup = backupFileName(file);
+ QFile f(file);
+ if (!f.rename(backup)) {
+ if (errorString)
*errorString = f.errorString();
return false;
}
- registerForDelayedDeletion( QStringList( backup ) );
+ registerForDelayedDeletion(QStringList(backup));
return true;
}
/*!
Returns a pointer to the current Application
*/
-Application* UpdateOperation::application() const
+Application *UpdateOperation::application() const
{
return d->application;
}
@@ -315,43 +313,39 @@ Application* UpdateOperation::application() const
QDomDocument UpdateOperation::toXml() const
{
QDomDocument doc;
- QDomElement root = doc.createElement( QLatin1String("operation") );
- doc.appendChild( root );
- QDomElement args = doc.createElement( QLatin1String("arguments") );
- Q_FOREACH( const QString &s, arguments() ) {
- QDomElement arg = doc.createElement( QLatin1String("argument") );
- arg.appendChild( doc.createTextNode(s) );
- args.appendChild( arg );
+ QDomElement root = doc.createElement(QLatin1String("operation"));
+ doc.appendChild(root);
+ QDomElement args = doc.createElement(QLatin1String("arguments"));
+ Q_FOREACH (const QString &s, arguments()) {
+ QDomElement arg = doc.createElement(QLatin1String("argument"));
+ arg.appendChild(doc.createTextNode(s));
+ args.appendChild(arg);
}
- root.appendChild( args );
- if( d->values.isEmpty() )
+ root.appendChild(args);
+ if (d->values.isEmpty())
return doc;
// append all values set with setValue
- QDomElement values = doc.createElement( QLatin1String( "values" ) );
- for( QVariantMap::const_iterator it = d->values.begin(); it != d->values.end(); ++it )
- {
- QDomElement value = doc.createElement( QLatin1String( "value" ) );
+ QDomElement values = doc.createElement(QLatin1String("values"));
+ for (QVariantMap::const_iterator it = d->values.begin(); it != d->values.end(); ++it) {
+ QDomElement value = doc.createElement(QLatin1String("value"));
const QVariant& variant = it.value();
- value.setAttribute( QLatin1String( "name" ), it.key() );
- value.setAttribute( QLatin1String( "type" ), QLatin1String( QVariant::typeToName( variant.type() ) ) );
+ value.setAttribute(QLatin1String("name"), it.key());
+ value.setAttribute(QLatin1String("type"), QLatin1String( QVariant::typeToName( variant.type())));
- if( variant.type() != QVariant::List && variant.type() != QVariant::StringList && qVariantCanConvert< QString >( variant ) )
- {
+ if (variant.type() != QVariant::List && variant.type() != QVariant::StringList && qVariantCanConvert<QString>(variant)) {
// it can convert to string? great!
- value.appendChild( doc.createTextNode( variant.toString() ) );
- }
- else
- {
+ value.appendChild( doc.createTextNode(variant.toString()));
+ } else {
// no? then we have to go the hard way...
QByteArray data;
- QDataStream stream( &data, QIODevice::WriteOnly );
+ QDataStream stream(&data, QIODevice::WriteOnly);
stream << variant;
- value.appendChild( doc.createTextNode( QLatin1String( data.toBase64().data() ) ) );
+ value.appendChild(doc.createTextNode(QLatin1String( data.toBase64().data())));
}
- values.appendChild( value );
+ values.appendChild(value);
}
- root.appendChild( values );
+ root.appendChild(values);
return doc;
}
@@ -359,40 +353,38 @@ QDomDocument UpdateOperation::toXml() const
Restores UpdateOperation's arguments and values from the XML document \a doc.
Returns true on success, otherwise false.
*/
-bool UpdateOperation::fromXml( const QDomDocument &doc )
+bool UpdateOperation::fromXml(const QDomDocument &doc)
{
QStringList args;
const QDomElement root = doc.documentElement();
- const QDomElement argsElem = root.firstChildElement( QLatin1String("arguments") );
- Q_ASSERT( ! argsElem.isNull() );
- for( QDomNode n = argsElem.firstChild(); ! n.isNull(); n = n.nextSibling() ) {
+ const QDomElement argsElem = root.firstChildElement(QLatin1String("arguments"));
+ Q_ASSERT(! argsElem.isNull());
+ for (QDomNode n = argsElem.firstChild(); ! n.isNull(); n = n.nextSibling()) {
const QDomElement e = n.toElement();
- if( !e.isNull() && e.tagName() == QLatin1String("argument") )
+ if (!e.isNull() && e.tagName() == QLatin1String("argument"))
args << e.text();
}
setArguments(args);
d->values.clear();
- const QDomElement values = root.firstChildElement( QLatin1String( "values" ) );
- for( QDomNode n = values.firstChild(); !n.isNull(); n = n.nextSibling() )
- {
+ const QDomElement values = root.firstChildElement(QLatin1String("values"));
+ for (QDomNode n = values.firstChild(); !n.isNull(); n = n.nextSibling()) {
const QDomElement v = n.toElement();
- if( v.isNull() || v.tagName() != QLatin1String( "value" ) )
+ if (v.isNull() || v.tagName() != QLatin1String("value"))
continue;
- const QString name = v.attribute( QLatin1String( "name" ) );
- const QString type = v.attribute( QLatin1String( "type" ) );
+ const QString name = v.attribute(QLatin1String("name"));
+ const QString type = v.attribute(QLatin1String("type"));
const QString value = v.text();
- const QVariant::Type t = QVariant::nameToType( type.toLatin1().data() );
- QVariant var = qVariantFromValue( value );
- if( t == QVariant::List || t == QVariant::StringList || !var.convert( t ) )
- {
- QDataStream stream( QByteArray::fromBase64( value.toLatin1() ) );
+ const QVariant::Type t = QVariant::nameToType(type.toLatin1().data());
+ QVariant var = qVariantFromValue(value);
+ if (t == QVariant::List || t == QVariant::StringList || !var.convert(t)) {
+ QDataStream stream(QByteArray::fromBase64( value.toLatin1()));
stream >> var;
}
- d->values[ name ] = var;
+ d->values[name] = var;
}
return true;
@@ -403,13 +395,13 @@ bool UpdateOperation::fromXml( const QDomDocument &doc )
Returns true on success, otherwise false.
\overload
*/
-bool UpdateOperation::fromXml( const QString &xml )
+bool UpdateOperation::fromXml(const QString &xml)
{
QDomDocument doc;
QString errorMsg;
int errorLine;
int errorColumn;
- if ( ! doc.setContent( xml, &errorMsg, &errorLine, &errorColumn ) ) {
+ if (!doc.setContent( xml, &errorMsg, &errorLine, &errorColumn)) {
qWarning() << "Error parsing xml error=" << errorMsg << "line=" << errorLine << "column=" << errorColumn;
return false;
}
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateoperationfactory.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateoperationfactory.cpp
index d603f3edb..bdd677f9b 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateoperationfactory.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateoperationfactory.cpp
@@ -53,7 +53,7 @@ struct UpdateOperationFactory::UpdateOperationFactoryData
/*!
Returns the UpdateOperationFactory instance. The instance is created if needed.
*/
-UpdateOperationFactory& UpdateOperationFactory::instance()
+UpdateOperationFactory &UpdateOperationFactory::instance()
{
static UpdateOperationFactory theFactory;
return theFactory;
@@ -63,19 +63,19 @@ UpdateOperationFactory& UpdateOperationFactory::instance()
Constructor
*/
UpdateOperationFactory::UpdateOperationFactory()
- : d ( new UpdateOperationFactoryData )
+ : d(new UpdateOperationFactoryData)
{
// Register the default update operation set
- registerUpdateOperation< CopyOperation >( QLatin1String( "Copy" ) );
- registerUpdateOperation< MoveOperation >( QLatin1String( "Move" ) );
- registerUpdateOperation< DeleteOperation >( QLatin1String( "Delete" ) );
- registerUpdateOperation< MkdirOperation >( QLatin1String( "Mkdir" ) );
- registerUpdateOperation< RmdirOperation >( QLatin1String( "Rmdir" ) );
- registerUpdateOperation< AppendFileOperation >( QLatin1String( "AppendFile" ) );
- registerUpdateOperation< PrependFileOperation >( QLatin1String( "PrependFile" ) );
- registerUpdateOperation< ExecuteOperation >( QLatin1String( "Execute" ) );
- registerUpdateOperation< UpdatePackageOperation >( QLatin1String( "UpdatePackage" ) );
- registerUpdateOperation< UpdateCompatOperation >( QLatin1String( "UpdateCompat" ) );
+ registerUpdateOperation<CopyOperation>(QLatin1String("Copy"));
+ registerUpdateOperation<MoveOperation>(QLatin1String("Move"));
+ registerUpdateOperation<DeleteOperation>(QLatin1String("Delete"));
+ registerUpdateOperation<MkdirOperation>(QLatin1String("Mkdir"));
+ registerUpdateOperation<RmdirOperation>(QLatin1String("Rmdir"));
+ registerUpdateOperation<AppendFileOperation>(QLatin1String("AppendFile"));
+ registerUpdateOperation<PrependFileOperation>(QLatin1String("PrependFile"));
+ registerUpdateOperation<ExecuteOperation>(QLatin1String("Execute"));
+ registerUpdateOperation<UpdatePackageOperation>(QLatin1String("UpdatePackage"));
+ registerUpdateOperation<UpdateCompatOperation>(QLatin1String("UpdateCompat"));
}
UpdateOperationFactory::~UpdateOperationFactory()
@@ -102,16 +102,16 @@ QStringList UpdateOperationFactory::availableUpdateOperations() const
/*
Unregisters the update operation previously registered with \a name.
*/
-void UpdateOperationFactory::unregisterUpdateOperation( const QString& name )
+void UpdateOperationFactory::unregisterUpdateOperation(const QString &name)
{
- unregisterProduct( name );
+ unregisterProduct(name);
}
/*!
Registers \a create to be a factory function to create an UpdateOperation with \a name.
\sa registerUpdateOperation
*/
-void UpdateOperationFactory::registerUpdateOperationFactory( const QString& name, UpdateOperationFactoryFunction create )
+void UpdateOperationFactory::registerUpdateOperationFactory(const QString &name, UpdateOperationFactoryFunction create)
{
- registerProductionFunction( name, create );
+ registerProductionFunction(name, create);
}
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateoperations.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateoperations.cpp
index 29fb254d9..181f27faf 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateoperations.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateoperations.cpp
@@ -46,37 +46,33 @@
using namespace KDUpdater;
-static bool removeDirectory( const QString& path, QString* errorString )
+static bool removeDirectory(const QString &path, QString *errorString)
{
- Q_ASSERT( errorString );
- const QFileInfoList entries = QDir( path ).entryInfoList( QDir::NoDotAndDotDot | QDir::AllEntries | QDir::Hidden );
- for( QFileInfoList::const_iterator it = entries.constBegin(); it != entries.constEnd(); ++it )
- {
- if( it->isDir() && !it->isSymLink() )
- {
- removeDirectory( it->filePath(), errorString );
- }
- else
- {
- QFile f( it->filePath() );
- if( !f.remove() )
+ Q_ASSERT(errorString);
+ const QFileInfoList entries = QDir(path).entryInfoList(QDir::NoDotAndDotDot | QDir::AllEntries | QDir::Hidden);
+ for (QFileInfoList::const_iterator it = entries.constBegin(); it != entries.constEnd(); ++it) {
+ if (it->isDir() && !it->isSymLink()) {
+ removeDirectory(it->filePath(), errorString);
+ } else {
+ QFile f(it->filePath());
+ if (!f.remove())
return false;
}
}
errno = 0;
- const bool success = QDir().rmdir( path );
- if ( errno )
- *errorString = QLatin1String( strerror(errno) );
+ const bool success = QDir().rmdir(path);
+ if (errno)
+ *errorString = QLatin1String(strerror(errno));
return success;
}
/*
* \internal
* Returns a filename for a temporary file based on \a templateName
*/
-static QString backupFileName( const QString& templateName = QString() )
+static QString backupFileName(const QString &templateName)
{
- QTemporaryFile file( templateName );
+ QTemporaryFile file(templateName);
file.open();
const QString name = file.fileName();
file.close();
@@ -90,31 +86,30 @@ static QString backupFileName( const QString& templateName = QString() )
CopyOperation::CopyOperation()
{
- setName(QLatin1String( "Copy" ));
+ setName(QLatin1String("Copy"));
}
CopyOperation::~CopyOperation()
{
- deleteFileNowOrLater( value( QLatin1String( "backupOfExistingDestination" ) ).toString() );
+ deleteFileNowOrLater(value(QLatin1String("backupOfExistingDestination")).toString());
}
void CopyOperation::backup()
{
const QString dest = arguments().last();
- if( !QFile::exists( dest ) )
- {
- clearValue( QLatin1String( "backupOfExistingDestination" ) );
+ if (!QFile::exists(dest)) {
+ clearValue(QLatin1String("backupOfExistingDestination"));
return;
}
- setValue( QLatin1String( "backupOfExistingDestination" ), backupFileName( dest ) );
+ setValue(QLatin1String("backupOfExistingDestination"), backupFileName(dest));
// race condition: The backup file could get created
// by another process right now. But this is the same
// in QFile::copy...
- const bool success = QFile::rename( dest, value( QLatin1String( "backupOfExistingDestination" ) ).toString() );
- if(!success)
- setError( UserDefinedError, tr("Could not backup file %1").arg(dest) );
+ const bool success = QFile::rename(dest, value(QLatin1String("backupOfExistingDestination")).toString());
+ if (!success)
+ setError(UserDefinedError, tr("Could not backup file %1").arg(dest));
}
bool CopyOperation::performOperation()
@@ -123,9 +118,9 @@ bool CopyOperation::performOperation()
// First arg provides the complete file name of source
// Second arg provides the complete file name of dest
QStringList args = this->arguments();
- if( args.count() != 2 ) {
- setError( InvalidArguments );
- setErrorString( tr("Invalid arguments: %1 arguments given, 2 expected.").arg( args.count() ) );
+ if (args.count() != 2) {
+ setError(InvalidArguments);
+ setErrorString(tr("Invalid arguments: %1 arguments given, 2 expected.").arg(args.count()));
return false;
}
QString source = args.first();
@@ -134,21 +129,20 @@ bool CopyOperation::performOperation()
// If destination file exists, then we cannot use QFile::copy()
// because it does not overwrite an existing file. So we remove
// the destination file.
- if( QFile::exists(dest) )
- {
- QFile file( dest );
- if( !file.remove() ) {
- setError( UserDefinedError );
- setErrorString( tr("Could not remove destination file %1: %2.").arg( dest, file.errorString() ) );
+ if (QFile::exists(dest)) {
+ QFile file(dest);
+ if (!file.remove()) {
+ setError(UserDefinedError);
+ setErrorString(tr("Could not remove destination file %1: %2.").arg(dest, file.errorString()));
return false;
}
}
- QFile file( source );
- const bool copied = file.copy( dest );
- if ( !copied ) {
- setError( UserDefinedError );
- setErrorString( tr("Could not copy %1 to %2: %3.").arg( source, dest, file.errorString() ) );
+ QFile file(source);
+ const bool copied = file.copy(dest);
+ if (!copied) {
+ setError(UserDefinedError);
+ setErrorString(tr("Could not copy %1 to %2: %3.").arg(source, dest, file.errorString()));
}
return copied;
}
@@ -157,25 +151,23 @@ bool CopyOperation::undoOperation()
{
const QString dest = arguments().last();
- QFile destF( dest );
+ QFile destF(dest);
// first remove the dest
- if( !destF.remove() )
- {
- setError( UserDefinedError, tr("Could not delete file %1: %2").arg(dest, destF.errorString()) );
+ if (!destF.remove()) {
+ setError(UserDefinedError, tr("Could not delete file %1: %2").arg(dest, destF.errorString()));
return false;
}
// no backup was done:
// the copy destination file wasn't existing yet - that's no error
- if( !hasValue( QLatin1String( "backupOfExistingDestination" ) ) )
+ if (!hasValue(QLatin1String("backupOfExistingDestination")))
return true;
- QFile backupF( value( QLatin1String( "backupOfExistingDestination" ) ).toString() );
+ QFile backupF(value(QLatin1String("backupOfExistingDestination")).toString());
// otherwise we have to copy the backup back:
- const bool success = backupF.rename( dest );
- if(!success) {
- setError( UserDefinedError, tr("Could not restore backup file into %1: %2").arg(dest, backupF.errorString()) );
- }
+ const bool success = backupF.rename(dest);
+ if (!success)
+ setError(UserDefinedError, tr("Could not restore backup file into %1: %2").arg(dest, backupF.errorString()));
return success;
}
@@ -185,15 +177,15 @@ bool CopyOperation::undoOperation()
QDomDocument CopyOperation::toXml() const
{
// we don't want to save the backupOfExistingDestination
- if( !hasValue( QLatin1String( "backupOfExistingDestination" ) ) )
+ if (!hasValue(QLatin1String("backupOfExistingDestination")))
return UpdateOperation::toXml();
- CopyOperation* const me = const_cast< CopyOperation* >( this );
+ CopyOperation *const me = const_cast<CopyOperation *>(this);
- const QVariant v = value( QLatin1String( "backupOfExistingDestination" ) );
- me->clearValue( QLatin1String( "backupOfExistingDestination" ) );
+ const QVariant v = value(QLatin1String("backupOfExistingDestination"));
+ me->clearValue(QLatin1String("backupOfExistingDestination"));
const QDomDocument xml = UpdateOperation::toXml();
- me->setValue( QLatin1String( "backupOfExistingDestination" ), v );
+ me->setValue(QLatin1String("backupOfExistingDestination"), v);
return xml;
}
@@ -203,7 +195,7 @@ bool CopyOperation::testOperation()
return true;
}
-CopyOperation* CopyOperation::clone() const
+CopyOperation *CopyOperation::clone() const
{
return new CopyOperation();
}
@@ -215,31 +207,30 @@ CopyOperation* CopyOperation::clone() const
MoveOperation::MoveOperation()
{
- setName(QLatin1String( "Move" ));
+ setName(QLatin1String("Move"));
}
MoveOperation::~MoveOperation()
{
- deleteFileNowOrLater( value( QLatin1String( "backupOfExistingDestination" ) ).toString() );
+ deleteFileNowOrLater(value(QLatin1String("backupOfExistingDestination")).toString());
}
void MoveOperation::backup()
{
const QString dest = arguments().last();
- if( !QFile::exists( dest ) )
- {
- clearValue( QLatin1String( "backupOfExistingDestination" ) );
+ if (!QFile::exists(dest)) {
+ clearValue(QLatin1String("backupOfExistingDestination"));
return;
}
- setValue( QLatin1String( "backupOfExistingDestination" ), backupFileName( dest ) );
+ setValue(QLatin1String("backupOfExistingDestination"), backupFileName(dest));
// race condition: The backup file could get created
// by another process right now. But this is the same
// in QFile::copy...
- const bool success = QFile::rename( dest, value( QLatin1String( "backupOfExistingDestination" ) ).toString() );
- if(!success)
- setError( UserDefinedError, tr("Could not backup file %1").arg(dest) );
+ const bool success = QFile::rename(dest, value(QLatin1String("backupOfExistingDestination")).toString());
+ if (!success)
+ setError(UserDefinedError, tr("Could not backup file %1").arg(dest));
}
bool MoveOperation::performOperation()
@@ -248,9 +239,9 @@ bool MoveOperation::performOperation()
// First arg provides the complete file name of source
// Second arg provides the complete file name of dest
QStringList args = this->arguments();
- if( args.count() != 2 ) {
- setError( InvalidArguments );
- setErrorString( tr("Invalid arguments: %1 arguments given, 2 expected.").arg( args.count() ) );
+ if (args.count() != 2) {
+ setError(InvalidArguments);
+ setErrorString(tr("Invalid arguments: %1 arguments given, 2 expected.").arg(args.count()));
return false;
}
@@ -260,26 +251,25 @@ bool MoveOperation::performOperation()
// If destination file exists, then we cannot use QFile::copy()
// because it does not overwrite an existing file. So we remove
// the destination file.
- if( QFile::exists(dest) )
- {
- QFile file( dest );
- if( !file.remove(dest) ) {
- setError( UserDefinedError );
- setErrorString( tr("Could not remove destination file %1: %2.").arg( dest, file.errorString() ) );
+ if (QFile::exists(dest)) {
+ QFile file(dest);
+ if (!file.remove(dest)) {
+ setError(UserDefinedError);
+ setErrorString(tr("Could not remove destination file %1: %2.").arg(dest, file.errorString()));
return false;
}
}
// Copy source to destination.
- QFile file( source );
- const bool copied = file.copy( source, dest );
- if ( !copied ) {
- setError( UserDefinedError );
- setErrorString( tr("Could not copy %1 to %2: %3.").arg( source, dest, file.errorString() ) );
+ QFile file(source);
+ const bool copied = file.copy(source, dest);
+ if (!copied) {
+ setError(UserDefinedError);
+ setErrorString(tr("Could not copy %1 to %2: %3.").arg(source, dest, file.errorString()));
return false;
}
- return deleteFileNowOrLater( source );
+ return deleteFileNowOrLater(source);
}
bool MoveOperation::undoOperation()
@@ -289,30 +279,28 @@ bool MoveOperation::undoOperation()
const QString& dest = args.last();
// first: copy back the destination to source
- QFile destF( dest );
- if( !destF.copy( source ) )
- {
- setError( UserDefinedError, tr("Cannot copy %1 to %2: %3").arg( dest, source, destF.errorString() ) );
+ QFile destF(dest);
+ if (!destF.copy(source)) {
+ setError(UserDefinedError, tr("Cannot copy %1 to %2: %3").arg(dest, source, destF.errorString()));
return false;
}
// second: delete the move destination
- if( !deleteFileNowOrLater( dest ) )
- {
- setError( UserDefinedError, tr( "Cannot remove file %1" ) );
+ if (!deleteFileNowOrLater(dest)) {
+ setError(UserDefinedError, tr("Cannot remove file %1"));
return false;
}
// no backup was done:
// the move destination file wasn't existing yet - that's no error
- if( !hasValue( QLatin1String( "backupOfExistingDestination" ) ) )
+ if (!hasValue(QLatin1String("backupOfExistingDestination")))
return true;
// otherwise we have to copy the backup back:
- QFile backupF( value( QLatin1String( "backupOfExistingDestination" ) ).toString() );
- const bool success = backupF.rename( dest );
- if(!success)
- setError( UserDefinedError, tr("Cannot restore backup file for %1: %2").arg(dest, backupF.errorString()) );
+ QFile backupF(value(QLatin1String("backupOfExistingDestination")).toString());
+ const bool success = backupF.rename(dest);
+ if (!success)
+ setError(UserDefinedError, tr("Cannot restore backup file for %1: %2").arg(dest, backupF.errorString()));
return success;
}
@@ -323,7 +311,7 @@ bool MoveOperation::testOperation()
return true;
}
-MoveOperation* MoveOperation::clone() const
+MoveOperation *MoveOperation::clone() const
{
return new MoveOperation;
}
@@ -335,22 +323,22 @@ MoveOperation* MoveOperation::clone() const
DeleteOperation::DeleteOperation()
{
- setName(QLatin1String( "Delete" ));
+ setName(QLatin1String("Delete"));
}
DeleteOperation::~DeleteOperation()
{
- deleteFileNowOrLater( value( QLatin1String( "backupOfExistingFile" ) ).toString() );
+ deleteFileNowOrLater(value(QLatin1String("backupOfExistingFile")).toString());
}
void DeleteOperation::backup()
{
const QString fileName = arguments().first();
- setValue( QLatin1String( "backupOfExistingFile" ), backupFileName( fileName ) );
- QFile file( fileName );
- const bool success = file.copy( value( QLatin1String( "backupOfExistingFile" ) ).toString() );
- if(!success)
- setError( UserDefinedError, tr("Cannot create backup of %1: %2").arg(fileName, file.errorString()) );
+ setValue(QLatin1String("backupOfExistingFile"), backupFileName(fileName));
+ QFile file(fileName);
+ const bool success = file.copy(value(QLatin1String("backupOfExistingFile")).toString());
+ if (!success)
+ setError(UserDefinedError, tr("Cannot create backup of %1: %2").arg(fileName, file.errorString()));
}
bool DeleteOperation::performOperation()
@@ -358,26 +346,26 @@ bool DeleteOperation::performOperation()
// Requires only one parameter. That is the name of
// the file to remove.
QStringList args = this->arguments();
- if( args.count() != 1 ) {
- setError( InvalidArguments );
- setErrorString( tr("Invalid arguments: %1 arguments given, 1 expected.").arg( args.count() ) );
+ if (args.count() != 1) {
+ setError(InvalidArguments);
+ setErrorString(tr("Invalid arguments: %1 arguments given, 1 expected.").arg(args.count()));
return false;
}
const QString fName = args.first();
- return deleteFileNowOrLater( fName );
+ return deleteFileNowOrLater(fName);
}
bool DeleteOperation::undoOperation()
{
- if( !hasValue( QLatin1String( "backupOfExistingFile" ) ) )
+ if (!hasValue(QLatin1String("backupOfExistingFile")))
return true;
const QString fileName = arguments().first();
- QFile backupF( value( QLatin1String( "backupOfExistingFile" ) ).toString() );
- const bool success = backupF.copy( fileName ) && deleteFileNowOrLater( backupF.fileName() );
- if(!success)
- setError( UserDefinedError, tr("Cannot restore backup file for %1: %2").arg(fileName, backupF.errorString()) );
+ QFile backupF(value(QLatin1String("backupOfExistingFile")).toString());
+ const bool success = backupF.copy(fileName) && deleteFileNowOrLater(backupF.fileName());
+ if (!success)
+ setError(UserDefinedError, tr("Cannot restore backup file for %1: %2").arg(fileName, backupF.errorString()));
return success;
}
@@ -388,7 +376,7 @@ bool DeleteOperation::testOperation()
return true;
}
-DeleteOperation* DeleteOperation::clone() const
+DeleteOperation *DeleteOperation::clone() const
{
return new DeleteOperation;
}
@@ -399,15 +387,15 @@ DeleteOperation* DeleteOperation::clone() const
QDomDocument DeleteOperation::toXml() const
{
// we don't want to save the backupOfExistingFile
- if( !hasValue( QLatin1String( "backupOfExistingFile" ) ) )
+ if (!hasValue(QLatin1String("backupOfExistingFile")))
return UpdateOperation::toXml();
- DeleteOperation* const me = const_cast< DeleteOperation* >( this );
+ DeleteOperation *const me = const_cast<DeleteOperation *>(this);
- const QVariant v = value( QLatin1String( "backupOfExistingFile" ) );
- me->clearValue( QLatin1String( "backupOfExistingFile" ) );
+ const QVariant v = value(QLatin1String("backupOfExistingFile"));
+ me->clearValue(QLatin1String("backupOfExistingFile"));
const QDomDocument xml = UpdateOperation::toXml();
- me->setValue( QLatin1String( "backupOfExistingFile" ), v );
+ me->setValue(QLatin1String("backupOfExistingFile"), v);
return xml;
}
@@ -417,41 +405,34 @@ QDomDocument DeleteOperation::toXml() const
MkdirOperation::MkdirOperation()
{
- setName(QLatin1String( "Mkdir" ));
-}
-
-MkdirOperation::~MkdirOperation()
-{
-
+ setName(QLatin1String("Mkdir"));
}
void MkdirOperation::backup()
{
- static const QRegExp re( QLatin1String( "\\\\|/" ) );
- static const QLatin1String sep( "/" );
+ static const QRegExp re(QLatin1String("\\\\|/"));
+ static const QLatin1String sep("/");
QString path = arguments().first();
- path.replace( re, sep );
+ path.replace(re, sep);
QDir createdDir = QDir::root();
// find out, which part of the path is the first one we actually need to create
int end = 0;
- while( true )
- {
- QString p = path.section( sep, 0, ++end );
- createdDir = QDir( p );
- if( !createdDir.exists() )
+ while (true) {
+ QString p = path.section(sep, 0, ++end);
+ createdDir = QDir(p);
+ if (!createdDir.exists())
break;
- else if( p == path )
- {
+ if (p == path) {
// everything did already exist -> nothing to do for us (nothing to revert then, either)
createdDir = QDir::root();
break;
}
}
- setValue( QLatin1String( "createddir" ), createdDir.absolutePath() );
+ setValue(QLatin1String("createddir"), createdDir.absolutePath());
}
bool MkdirOperation::performOperation()
@@ -459,56 +440,56 @@ bool MkdirOperation::performOperation()
// Requires only one parameter. That is the name of
// the file to remove.
QStringList args = this->arguments();
- if( args.count() != 1 ) {
- setError( InvalidArguments );
- setErrorString( tr("Invalid arguments: %1 arguments given, 1 expected.").arg( args.count() ) );
+ if (args.count() != 1) {
+ setError(InvalidArguments);
+ setErrorString(tr("Invalid arguments: %1 arguments given, 1 expected.").arg(args.count()));
return false;
}
QString dirName = args.first();
const bool created = QDir::root().mkpath(dirName);
- if ( !created ) {
- setError( UserDefinedError );
- setErrorString( tr("Could not create folder %1: Unknown error.").arg( dirName ) );
+ if (!created) {
+ setError(UserDefinedError);
+ setErrorString(tr("Could not create folder %1: Unknown error.").arg(dirName));
}
return created;
}
bool MkdirOperation::undoOperation()
{
- Q_ASSERT( arguments().count() == 1 );
+ Q_ASSERT(arguments().count() == 1);
- QDir createdDir = QDir( value( QLatin1String( "createddir" ) ).toString() );
- const bool forceremoval = QVariant( value( QLatin1String( "forceremoval" ) ) ).toBool();
+ QDir createdDir = QDir(value(QLatin1String("createddir")).toString());
+ const bool forceremoval = QVariant(value(QLatin1String("forceremoval"))).toBool();
// Since refactoring we know the mkdir operation which is creating the target path. If we do a full
// uninstall prevent removing the full path including target, instead remove the target only. (QTIFW-46)
if (hasValue(QLatin1String("uninstall-only")) && value(QLatin1String("uninstall-only")).toBool())
createdDir = QDir(arguments().first());
- if( createdDir == QDir::root() )
+ if (createdDir == QDir::root())
return true;
- if( !createdDir.exists())
+ if (!createdDir.exists())
return true;
QString errorString;
- if( forceremoval )
- return removeDirectory( createdDir.path(), &errorString );
+ if (forceremoval)
+ return removeDirectory(createdDir.path(), &errorString);
// even remove some hidden, OS-created files in there
#if defined Q_WS_MAC
- QFile::remove( createdDir.path() + QLatin1String( "/.DS_Store" ) );
+ QFile::remove(createdDir.path() + QLatin1String("/.DS_Store"));
#elif defined Q_WS_WIN
- QFile::remove( createdDir.path() + QLatin1String( "/Thumbs.db" ) );
+ QFile::remove(createdDir.path() + QLatin1String("/Thumbs.db"));
#endif
errno = 0;
- const bool result = QDir::root().rmdir( createdDir.path() );
- if ( !result ) {
- if ( errorString.isEmpty() )
- setError( UserDefinedError, tr("Cannot remove directory %1: %2").arg( createdDir.path(), errorString ) );
+ const bool result = QDir::root().rmdir(createdDir.path());
+ if (!result) {
+ if (errorString.isEmpty())
+ setError(UserDefinedError, tr("Cannot remove directory %1: %2").arg(createdDir.path(), errorString));
else
- setError( UserDefinedError, tr("Cannot remove directory %1: %2").arg( createdDir.path(), QLatin1String(strerror(errno)) ) );
+ setError(UserDefinedError, tr("Cannot remove directory %1: %2").arg(createdDir.path(), QLatin1String(strerror(errno))));
}
return result;
}
@@ -519,7 +500,7 @@ bool KDUpdater::MkdirOperation::testOperation()
return true;
}
-MkdirOperation* MkdirOperation::clone() const
+MkdirOperation *MkdirOperation::clone() const
{
return new MkdirOperation;
}
@@ -530,13 +511,8 @@ MkdirOperation* MkdirOperation::clone() const
RmdirOperation::RmdirOperation()
{
- setValue( QLatin1String( "removed" ), false );
- setName(QLatin1String( "Rmdir" ));
-}
-
-RmdirOperation::~RmdirOperation()
-{
-
+ setValue(QLatin1String("removed"), false);
+ setName(QLatin1String("Rmdir"));
}
void RmdirOperation::backup()
@@ -549,40 +525,40 @@ bool RmdirOperation::performOperation()
// Requires only one parameter. That is the name of
// the file to remove.
QStringList args = this->arguments();
- if( args.count() != 1 ) {
- setError( InvalidArguments );
- setErrorString( tr("Invalid arguments: %1 arguments given, 1 expected.").arg( args.count() ) );
+ if (args.count() != 1) {
+ setError(InvalidArguments);
+ setErrorString(tr("Invalid arguments: %1 arguments given, 1 expected.").arg(args.count()));
return false;
}
QString dirName = args.first();
- QDir dir( dirName );
- if( !dir.exists() ) {
- setError( UserDefinedError );
- setErrorString( tr("Could not remove folder %1: The folder does not exist.").arg( dirName ) );
+ QDir dir(dirName);
+ if (!dir.exists()) {
+ setError(UserDefinedError);
+ setErrorString(tr("Could not remove folder %1: The folder does not exist.").arg(dirName));
return false;
}
errno = 0;
- const bool removed = dir.rmdir( dirName );
- setValue( QLatin1String( "removed" ), removed );
- if ( !removed ) {
- setError( UserDefinedError );
- setErrorString( tr("Could not remove folder %1: %2.").arg( dirName, QLatin1String(strerror(errno)) ) );
+ const bool removed = dir.rmdir(dirName);
+ setValue(QLatin1String("removed"), removed);
+ if (!removed) {
+ setError(UserDefinedError);
+ setErrorString(tr("Could not remove folder %1: %2.").arg(dirName, QLatin1String(strerror(errno))));
}
return removed;
}
bool RmdirOperation::undoOperation()
{
- if( !value( QLatin1String( "removed" ) ).toBool() )
+ if (!value(QLatin1String("removed")).toBool())
return true;
- const QFileInfo fi( arguments().first() );
+ const QFileInfo fi(arguments().first());
errno = 0;
- const bool success = fi.dir().mkdir( fi.fileName() );
- if(!success)
- setError( UserDefinedError, tr("Cannot recreate directory %1: %2").arg( fi.fileName(), QLatin1String(strerror(errno)) ) );
+ const bool success = fi.dir().mkdir(fi.fileName());
+ if( !success)
+ setError(UserDefinedError, tr("Cannot recreate directory %1: %2").arg(fi.fileName(), QLatin1String(strerror(errno))));
return success;
}
@@ -593,7 +569,7 @@ bool RmdirOperation::testOperation()
return true;
}
-RmdirOperation* RmdirOperation::clone() const
+RmdirOperation *RmdirOperation::clone() const
{
return new RmdirOperation;
}
@@ -605,27 +581,21 @@ RmdirOperation* RmdirOperation::clone() const
AppendFileOperation::AppendFileOperation()
{
- setName(QLatin1String( "AppendFile" ));
-}
-
-AppendFileOperation::~AppendFileOperation()
-{
-
+ setName(QLatin1String("AppendFile"));
}
void AppendFileOperation::backup()
{
const QString filename = arguments().first();
- QFile file( filename );
- if( !file.exists() )
+ QFile file(filename);
+ if (!file.exists())
return; // nothing to backup
- setValue( QLatin1String( "backupOfFile" ), backupFileName( filename ) );
- if( !file.copy( value( QLatin1String( "backupOfFile" ) ).toString() ) )
- {
- setError( UserDefinedError, tr("Cannot backup file %1: %2").arg(filename, file.errorString()) );
- clearValue( QLatin1String( "backupOfFile" ) );
+ setValue(QLatin1String("backupOfFile"), backupFileName(filename));
+ if (!file.copy(value(QLatin1String("backupOfFile")).toString())) {
+ setError(UserDefinedError, tr("Cannot backup file %1: %2").arg(filename, file.errorString()));
+ clearValue(QLatin1String("backupOfFile"));
}
}
@@ -635,9 +605,9 @@ bool AppendFileOperation::performOperation()
// of the file into which a text has to be appended. Second argument
// is the text to append.
QStringList args = this->arguments();
- if( args.count() != 2 ) {
- setError( InvalidArguments );
- setErrorString( tr("Invalid arguments: %1 arguments given, 2 expected.").arg( args.count() ) );
+ if (args.count() != 2) {
+ setError(InvalidArguments);
+ setErrorString(tr("Invalid arguments: %1 arguments given, 2 expected.").arg(args.count()));
return false;
}
@@ -645,18 +615,16 @@ bool AppendFileOperation::performOperation()
QString text = args.last();
QFile file(fName);
- if( !file.open(QFile::Append) )
- {
+ if (!file.open(QFile::Append)) {
// first we rename the file, then we copy it to the real target and open the copy - the renamed original is then marked for deletion
- const QString newName = backupFileName( fName );
- if( !QFile::rename( fName, newName ) && QFile::copy( newName, fName ) && file.open( QFile::Append ) )
- {
- QFile::rename( newName, fName );
- setError( UserDefinedError );
- setErrorString( tr("Could not open file %1 for writing: %2.").arg( file.fileName(), file.errorString() ) );
+ const QString newName = backupFileName(fName);
+ if (!QFile::rename(fName, newName) && QFile::copy(newName, fName) && file.open(QFile::Append)) {
+ QFile::rename(newName, fName);
+ setError(UserDefinedError);
+ setErrorString(tr("Could not open file %1 for writing: %2.").arg(file.fileName(), file.errorString()));
return false;
}
- deleteFileNowOrLater( newName );
+ deleteFileNowOrLater(newName);
}
QTextStream ts(&file);
@@ -670,27 +638,26 @@ bool AppendFileOperation::undoOperation()
{
// backupOfFile being empty -> file didn't exist before -> no error
const QString filename = arguments().first();
- const QString backupOfFile = value( QLatin1String( "backupOfFile" ) ).toString();
- if( !backupOfFile.isEmpty() && !QFile::exists( backupOfFile ) )
- {
- setError( UserDefinedError, tr("Cannot find backup file for %1").arg(filename) );
+ const QString backupOfFile = value(QLatin1String("backupOfFile")).toString();
+ if (!backupOfFile.isEmpty() && !QFile::exists(backupOfFile)) {
+ setError(UserDefinedError, tr("Cannot find backup file for %1").arg(filename));
return false;
}
- const bool removed = deleteFileNowOrLater( filename );
- if ( !removed ) {
- setError( UserDefinedError, tr("Could not restore backup file for %1.").arg( filename ) );
+ const bool removed = deleteFileNowOrLater(filename);
+ if (!removed) {
+ setError(UserDefinedError, tr("Could not restore backup file for %1.").arg(filename));
return false;
}
// got deleted? We might be done, if it didn't exist before
- if( backupOfFile.isEmpty() )
+ if (backupOfFile.isEmpty())
return true;
- QFile backupFile( backupOfFile );
- const bool success = backupFile.rename( filename );
- if ( !success )
- setError( UserDefinedError, tr("Could not restore backup file for %1: %2").arg(filename, backupFile.errorString()) );
+ QFile backupFile(backupOfFile);
+ const bool success = backupFile.rename(filename);
+ if (!success)
+ setError(UserDefinedError, tr("Could not restore backup file for %1: %2").arg(filename, backupFile.errorString()));
return success;
}
@@ -700,7 +667,7 @@ bool AppendFileOperation::testOperation()
return true;
}
-AppendFileOperation* AppendFileOperation::clone() const
+AppendFileOperation *AppendFileOperation::clone() const
{
return new AppendFileOperation;
}
@@ -712,27 +679,21 @@ AppendFileOperation* AppendFileOperation::clone() const
PrependFileOperation::PrependFileOperation()
{
- setName(QLatin1String( "PrependFile" ));
-}
-
-PrependFileOperation::~PrependFileOperation()
-{
-
+ setName(QLatin1String("PrependFile"));
}
void PrependFileOperation::backup()
{
const QString filename = arguments().first();
- QFile file( filename );
- if( !file.exists() )
+ QFile file(filename);
+ if (!file.exists())
return; // nothing to backup
- setValue( QLatin1String( "backupOfFile" ), backupFileName( filename ) );
- if( !file.copy( value( QLatin1String( "backupOfFile" ) ).toString() ) )
- {
- setError( UserDefinedError, tr("Cannot backup file %1: %2").arg(filename, file.errorString()) );
- clearValue( QLatin1String( "backupOfFile" ) );
+ setValue(QLatin1String("backupOfFile"), backupFileName(filename));
+ if (!file.copy(value(QLatin1String("backupOfFile")).toString())) {
+ setError(UserDefinedError, tr("Cannot backup file %1: %2").arg(filename, file.errorString()));
+ clearValue(QLatin1String("backupOfFile"));
}
}
@@ -742,9 +703,9 @@ bool PrependFileOperation::performOperation()
// of the file into which a text has to be appended. Second argument
// is the text to append.
QStringList args = this->arguments();
- if( args.count() != 2 ) {\
- setError( InvalidArguments );
- setErrorString( tr("Invalid arguments: %1 arguments given, 2 expected.").arg( args.count() ) );
+ if (args.count() != 2) {
+ setError(InvalidArguments);
+ setErrorString(tr("Invalid arguments: %1 arguments given, 2 expected.").arg(args.count()));
return false;
}
@@ -753,29 +714,28 @@ bool PrependFileOperation::performOperation()
// Load the file first.
QFile file(fName);
- if( !file.open(QFile::ReadOnly) ) {
- setError( UserDefinedError );
- setErrorString( tr("Could not open file %1 for reading: %2.").arg( file.fileName(), file.errorString() ) );
+ if (!file.open(QFile::ReadOnly)) {
+ setError(UserDefinedError);
+ setErrorString(tr("Could not open file %1 for reading: %2.").arg(file.fileName(), file.errorString()));
return false;
}
- QString fContents( QLatin1String( file.readAll() ) );
+ QString fContents(QLatin1String(file.readAll()));
file.close();
// Prepend text to the file text
fContents = text + fContents;
// Now re-open the file in write only mode.
- if( !file.open(QFile::WriteOnly) ) {
+ if (!file.open(QFile::WriteOnly)) {
// first we rename the file, then we copy it to the real target and open the copy - the renamed original is then marked for deletion
- const QString newName = backupFileName( fName );
- if( !QFile::rename( fName, newName ) && QFile::copy( newName, fName ) && file.open( QFile::WriteOnly ) )
- {
- QFile::rename( newName, fName );
- setError( UserDefinedError );
- setErrorString( tr("Could not open file %1 for writing: %2.").arg( file.fileName(), file.errorString() ) );
+ const QString newName = backupFileName(fName);
+ if (!QFile::rename(fName, newName) && QFile::copy(newName, fName) && file.open(QFile::WriteOnly)) {
+ QFile::rename(newName, fName);
+ setError(UserDefinedError);
+ setErrorString(tr("Could not open file %1 for writing: %2.").arg(file.fileName(), file.errorString()));
return false;
}
- deleteFileNowOrLater( newName );
+ deleteFileNowOrLater(newName);
}
QTextStream ts(&file);
ts << fContents;
@@ -788,27 +748,25 @@ bool PrependFileOperation::undoOperation()
{
// bockupOfFile being empty -> file didn't exist before -> no error
const QString filename = arguments().first();
- const QString backupOfFile = value( QLatin1String( "backupOfFile" ) ).toString();
- if( !backupOfFile.isEmpty() && !QFile::exists( backupOfFile ) )
- {
- setError( UserDefinedError, tr("Cannot find backup file for %1").arg(filename) );
+ const QString backupOfFile = value(QLatin1String("backupOfFile")).toString();
+ if (!backupOfFile.isEmpty() && !QFile::exists(backupOfFile)) {
+ setError(UserDefinedError, tr("Cannot find backup file for %1").arg(filename));
return false;
}
- if( !deleteFileNowOrLater( filename ) )
- {
- setError( UserDefinedError, tr("Cannot restore backup file for %1").arg( filename ) );
+ if (!deleteFileNowOrLater(filename)) {
+ setError(UserDefinedError, tr("Cannot restore backup file for %1").arg(filename));
return false;
}
// got deleted? We might be done, if it didn't exist before
- if( backupOfFile.isEmpty() )
+ if (backupOfFile.isEmpty())
return true;
- QFile backupF( backupOfFile );
- const bool success = backupF.rename( filename );
- if(!success)
- setError( UserDefinedError, tr("Cannot restore backup file for %1: %2").arg(filename, backupF.errorString()) );
+ QFile backupF(backupOfFile);
+ const bool success = backupF.rename(filename);
+ if (!success)
+ setError(UserDefinedError, tr("Cannot restore backup file for %1: %2").arg(filename, backupF.errorString()));
return success;
}
@@ -819,7 +777,7 @@ bool PrependFileOperation::testOperation()
return true;
}
-PrependFileOperation* PrependFileOperation::clone() const
+PrependFileOperation *PrependFileOperation::clone() const
{
return new PrependFileOperation;
}
@@ -832,12 +790,7 @@ PrependFileOperation* PrependFileOperation::clone() const
ExecuteOperation::ExecuteOperation()
: QObject()
{
- setName(QLatin1String( "Execute" ));
-}
-
-ExecuteOperation::~ExecuteOperation()
-{
-
+ setName(QLatin1String("Execute"));
}
void ExecuteOperation::backup()
@@ -845,7 +798,7 @@ void ExecuteOperation::backup()
// this is not possible, since the process can do whatever...
}
-#if defined( SUPPORT_DETACHED_PROCESS_EXECUTION ) && defined( Q_WS_WIN )
+#if defined(SUPPORT_DETACHED_PROCESS_EXECUTION) && defined(Q_WS_WIN)
// stolen from qprocess_win.cpp
static QString qt_create_commandline(const QString &program, const QStringList &arguments)
{
@@ -860,19 +813,19 @@ static QString qt_create_commandline(const QString &program, const QStringList &
args = programName + QLatin1Char(' ');
}
- for (int i=0; i<arguments.size(); ++i) {
+ for (int i = 0; i < arguments.size(); ++i) {
QString tmp = arguments.at(i);
// in the case of \" already being in the string the \ must also be escaped
- tmp.replace( QLatin1String("\\\""), QLatin1String("\\\\\"") );
+ tmp.replace(QLatin1String("\\\""), QLatin1String("\\\\\""));
// escape a single " because the arguments will be parsed
- tmp.replace( QLatin1Char('\"'), QLatin1String("\\\"") );
+ tmp.replace(QLatin1Char('\"'), QLatin1String("\\\""));
if (tmp.isEmpty() || tmp.contains(QLatin1Char(' ')) || tmp.contains(QLatin1Char('\t'))) {
// The argument must not end with a \ since this would be interpreted
// as escaping the quote -- rather put the \ behind the quote: e.g.
// rather use "foo"\ than "foo\"
QString endQuote(QLatin1Char('\"'));
int i = tmp.length();
- while (i>0 && tmp.at(i-1) == QLatin1Char('\\')) {
+ while (i > 0 && tmp.at(i - 1) == QLatin1Char('\\')) {
--i;
endQuote += QLatin1Char('\\');
}
@@ -890,74 +843,67 @@ bool ExecuteOperation::performOperation()
// This operation receives only one argument. It is the complete
// command line of the external program to execute.
QStringList args = this->arguments();
- if( args.isEmpty() )
- {
- setError( InvalidArguments );
- setErrorString( tr("Invalid arguments: %1 arguments given, 2 expected.").arg( args.count() ) );
+ if (args.isEmpty()) {
+ setError(InvalidArguments);
+ setErrorString(tr("Invalid arguments: %1 arguments given, 2 expected.").arg(args.count()));
return false;
}
- QList< int > allowedExitCodes;
+ QList<int> allowedExitCodes;
- QRegExp re( QLatin1String( "^\\{((-?\\d+,)*-?\\d+)\\}$" ) );
- if( re.exactMatch( args.first() ) )
- {
- const QStringList numbers = re.cap( 1 ).split( QLatin1Char( ',' ) );
- for( QStringList::const_iterator it = numbers.begin(); it != numbers.end(); ++it )
- allowedExitCodes.push_back( it->toInt() );
+ QRegExp re(QLatin1String("^\\{((-?\\d+,)*-?\\d+)\\}$"));
+ if (re.exactMatch(args.first())) {
+ const QStringList numbers = re.cap(1).split(QLatin1Char(','));
+ for (QStringList::const_iterator it = numbers.begin(); it != numbers.end(); ++it)
+ allowedExitCodes.push_back(it->toInt());
args.pop_front();
- }
- else
- {
- allowedExitCodes.push_back( 0 );
+ } else {
+ allowedExitCodes.push_back(0);
}
bool success = false;
#ifdef SUPPORT_DETACHED_PROCESS_EXECUTION
// unix style: when there's an ampersand after the command, it's started detached
- if( args.count() >= 2 && args.last() == QLatin1String( "&" ) )
- {
+ if (args.count() >= 2 && args.last() == QLatin1String("&")) {
args.pop_back();
#ifdef Q_WS_WIN
- QString arguments = qt_create_commandline( args.front(), args.mid( 1 ) );
+ QString arguments = qt_create_commandline(args.front(), args.mid(1));
PROCESS_INFORMATION pinfo;
- STARTUPINFOW startupInfo = { sizeof( STARTUPINFO ), 0, 0, 0,
- static_cast< ulong >( CW_USEDEFAULT ), static_cast< ulong >( CW_USEDEFAULT ),
- static_cast< ulong >( CW_USEDEFAULT ), static_cast< ulong >( CW_USEDEFAULT ),
+ STARTUPINFOW startupInfo = { sizeof(STARTUPINFO), 0, 0, 0,
+ static_cast< ulong >(CW_USEDEFAULT), static_cast< ulong >(CW_USEDEFAULT),
+ static_cast< ulong >(CW_USEDEFAULT), static_cast< ulong >(CW_USEDEFAULT),
0, 0, 0, STARTF_USESHOWWINDOW, SW_HIDE, 0, 0, 0, 0, 0
};
- success = CreateProcess( 0, const_cast< wchar_t* >( static_cast< const wchar_t* >( arguments.utf16() ) ),
- 0, 0, FALSE, CREATE_UNICODE_ENVIRONMENT | CREATE_NEW_CONSOLE, 0,
- 0,
- &startupInfo, &pinfo );
+ success = CreateProcess(0, const_cast< wchar_t* >(static_cast< const wchar_t* >(arguments.utf16())),
+ 0, 0, FALSE, CREATE_UNICODE_ENVIRONMENT | CREATE_NEW_CONSOLE, 0,
+ 0,
+ &startupInfo, &pinfo);
#else
- success = QProcess::startDetached( args.front(), args.mid( 1 ) );
+ success = QProcess::startDetached(args.front(), args.mid(1));
#endif
}
else
#endif
{
- Environment::instance().applyTo( &process ); //apply non-persistent variables
- process.start( args.front(), args.mid( 1 ) );
+ Environment::instance().applyTo(&process); //apply non-persistent variables
+ process.start(args.front(), args.mid(1));
QEventLoop loop;
- QObject::connect( &process, SIGNAL( finished( int, QProcess::ExitStatus ) ), &loop, SLOT( quit() ) );
- QObject::connect( &process, SIGNAL(readyRead()), this, SLOT(readProcessOutput()));
- success = process.waitForStarted( -1 );
- if( success )
- {
+ QObject::connect(&process, SIGNAL(finished(int, QProcess::ExitStatus)), &loop, SLOT(quit()));
+ QObject::connect(&process, SIGNAL(readyRead()), this, SLOT(readProcessOutput()));
+ success = process.waitForStarted(-1);
+ if (success) {
loop.exec();
- setValue( QLatin1String( "ExitCode" ), process.exitCode() );
- success = allowedExitCodes.contains( process.exitCode() );
+ setValue(QLatin1String("ExitCode"), process.exitCode());
+ success = allowedExitCodes.contains(process.exitCode());
}
}
- if(!success)
- {
- setError( UserDefinedError );
- setErrorString( tr("Execution failed: \"%1\"").arg( args.join( QLatin1String( " " ) ) ) );
+ if (!success) {
+ setError(UserDefinedError);
+ setErrorString(tr("Execution failed: \"%1\"").arg(args.join(QLatin1String(" "))));
}
return success;
@@ -969,9 +915,9 @@ bool ExecuteOperation::performOperation()
*/
void ExecuteOperation::cancelOperation()
{
- if( process.state() == QProcess::Running )
+ if (process.state() == QProcess::Running)
process.terminate();
- if( !process.waitForFinished( 10000 ) )
+ if (!process.waitForFinished(10000))
process.kill();
}
@@ -994,7 +940,7 @@ bool ExecuteOperation::testOperation()
return true;
}
-ExecuteOperation* ExecuteOperation::clone() const
+ExecuteOperation *ExecuteOperation::clone() const
{
return new ExecuteOperation;
}
@@ -1006,19 +952,14 @@ ExecuteOperation* ExecuteOperation::clone() const
UpdatePackageOperation::UpdatePackageOperation()
{
- setName(QLatin1String( "UpdatePackage" ));
-}
-
-UpdatePackageOperation::~UpdatePackageOperation()
-{
-
+ setName(QLatin1String("UpdatePackage"));
}
void UpdatePackageOperation::backup()
{
- const PackageInfo info = application()->packagesInfo()->packageInfo( application()->packagesInfo()->findPackageInfo( arguments().first() ) );
- setValue( QLatin1String( "oldVersion" ), info.version );
- setValue( QLatin1String( "oldDate" ), info.lastUpdateDate );
+ const PackageInfo info = application()->packagesInfo()->packageInfo(application()->packagesInfo()->findPackageInfo(arguments().first()));
+ setValue(QLatin1String("oldVersion"), info.version);
+ setValue(QLatin1String("oldDate"), info.lastUpdateDate);
}
bool UpdatePackageOperation::performOperation()
@@ -1026,18 +967,17 @@ bool UpdatePackageOperation::performOperation()
// This operation receives three arguments : the name of the package
// the new version and the release date
const QStringList args = this->arguments();
- if( args.count() != 3 )
- {
- setError( InvalidArguments, tr("Invalid arguments: %1 arguments given, 3 expected.").arg( args.count() ) );
+ if (args.count() != 3) {
+ setError(InvalidArguments, tr("Invalid arguments: %1 arguments given, 3 expected.").arg(args.count()));
return false;
}
- const QString& packageName = args.at( 0 );
- const QString& version = args.at( 1 );
- const QDate date = QDate::fromString( args.at( 2 ) );
- const bool success = application()->packagesInfo()->updatePackage( packageName, version, date );
- if(!success)
- setError( UserDefinedError, tr("Cannot update %1-%2").arg( packageName, version ) );
+ const QString &packageName = args.at(0);
+ const QString &version = args.at(1);
+ const QDate date = QDate::fromString(args.at(2));
+ const bool success = application()->packagesInfo()->updatePackage(packageName, version, date);
+ if (!success)
+ setError(UserDefinedError, tr("Cannot update %1-%2").arg(packageName, version));
return success;
}
@@ -1045,12 +985,12 @@ bool UpdatePackageOperation::performOperation()
bool UpdatePackageOperation::undoOperation()
{
const QString packageName = arguments().first();
- const QString version = arguments().at( 1 );
- const QString oldVersion = value( QLatin1String( "oldVersion" ) ).toString();
- const QDate oldDate = value( QLatin1String( "oldDate" ) ).toDate();
- const bool success = application()->packagesInfo()->updatePackage( packageName, oldVersion, oldDate );
- if(!success)
- setError( UserDefinedError, tr("Cannot restore %1-%2").arg( packageName, version ) );
+ const QString version = arguments().at(1);
+ const QString oldVersion = value(QLatin1String("oldVersion")).toString();
+ const QDate oldDate = value(QLatin1String("oldDate")).toDate();
+ const bool success = application()->packagesInfo()->updatePackage(packageName, oldVersion, oldDate);
+ if (!success)
+ setError(UserDefinedError, tr("Cannot restore %1-%2").arg(packageName, version));
return success;
}
@@ -1061,7 +1001,7 @@ bool UpdatePackageOperation::testOperation()
return true;
}
-UpdatePackageOperation* UpdatePackageOperation::clone() const
+UpdatePackageOperation *UpdatePackageOperation::clone() const
{
return new UpdatePackageOperation;
}
@@ -1073,43 +1013,36 @@ UpdatePackageOperation* UpdatePackageOperation::clone() const
UpdateCompatOperation::UpdateCompatOperation()
{
- setName(QLatin1String( "UpdateCompatLevel" ));
-}
-
-UpdateCompatOperation::~UpdateCompatOperation()
-{
-
+ setName(QLatin1String("UpdateCompatLevel"));
}
void UpdateCompatOperation::backup()
{
- setValue( QLatin1String( "oldCompatLevel" ), application()->packagesInfo()->compatLevel() );
+ setValue(QLatin1String("oldCompatLevel"), application()->packagesInfo()->compatLevel());
}
bool UpdateCompatOperation::performOperation()
{
// This operation receives one argument : the new compat level
const QStringList args = this->arguments();
- if( args.count() != 1 )
- {
- setError( InvalidArguments, tr("Invalid arguments: %1 arguments given, 1 expected.").arg( args.count() ) );
+ if (args.count() != 1) {
+ setError(InvalidArguments, tr("Invalid arguments: %1 arguments given, 1 expected.").arg(args.count()));
return false;
}
const int level = args.first().toInt();
- application()->packagesInfo()->setCompatLevel( level );
+ application()->packagesInfo()->setCompatLevel(level);
return true;
}
bool UpdateCompatOperation::undoOperation()
{
- if( !hasValue( QLatin1String( "oldCompatLevel" ) ) )
- {
- setError( UserDefinedError, tr("Cannot restore previous compat-level") );
+ if (!hasValue(QLatin1String("oldCompatLevel"))) {
+ setError(UserDefinedError, tr("Cannot restore previous compat-level"));
return false;
}
- application()->packagesInfo()->setCompatLevel( value( QLatin1String( "oldCompatLevel" ) ).toInt() );
+ application()->packagesInfo()->setCompatLevel(value(QLatin1String("oldCompatLevel")).toInt());
return true;
}
@@ -1119,7 +1052,7 @@ bool UpdateCompatOperation::testOperation()
return true;
}
-UpdateCompatOperation* UpdateCompatOperation::clone() const
+UpdateCompatOperation *UpdateCompatOperation::clone() const
{
return new UpdateCompatOperation;
}
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateoperations.h b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateoperations.h
index 1e0057163..40480d1e1 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateoperations.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdateoperations.h
@@ -78,7 +78,6 @@ class KDTOOLS_EXPORT MkdirOperation : public UpdateOperation
{
public:
MkdirOperation();
- ~MkdirOperation();
void backup();
bool performOperation();
@@ -91,7 +90,6 @@ class KDTOOLS_EXPORT RmdirOperation : public UpdateOperation
{
public:
RmdirOperation();
- ~RmdirOperation();
void backup();
bool performOperation();
@@ -104,7 +102,6 @@ class KDTOOLS_EXPORT AppendFileOperation : public UpdateOperation
{
public:
AppendFileOperation();
- ~AppendFileOperation();
void backup();
bool performOperation();
@@ -117,7 +114,6 @@ class KDTOOLS_EXPORT PrependFileOperation : public UpdateOperation
{
public:
PrependFileOperation();
- ~PrependFileOperation();
void backup();
bool performOperation();
@@ -132,7 +128,6 @@ class KDTOOLS_EXPORT ExecuteOperation : public QObject, public UpdateOperation
public:
ExecuteOperation();
- ~ExecuteOperation();
void backup();
bool performOperation();
@@ -157,7 +152,6 @@ class KDTOOLS_EXPORT UpdatePackageOperation : public UpdateOperation
{
public:
UpdatePackageOperation();
- ~UpdatePackageOperation();
void backup();
bool performOperation();
@@ -170,7 +164,6 @@ class KDTOOLS_EXPORT UpdateCompatOperation : public UpdateOperation
{
public:
UpdateCompatOperation();
- ~UpdateCompatOperation();
void backup();
bool performOperation();
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdatesinfo.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdatesinfo.cpp
index b707e7720..420876056 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdatesinfo.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdatesinfo.cpp
@@ -28,10 +28,12 @@
#include <QFile>
#include <QSharedData>
+using namespace KDUpdater;
+
//
-// KDUpdater::UpdatesInfo::UpdatesInfoData
+// UpdatesInfo::UpdatesInfoData
//
-struct KDUpdater::UpdatesInfo::UpdatesInfoData : public QSharedData
+struct UpdatesInfo::UpdatesInfoData : public QSharedData
{
Q_DECLARE_TR_FUNCTIONS(KDUpdater::UpdatesInfoData)
@@ -44,26 +46,25 @@ public:
QString applicationName;
QString applicationVersion;
int compatLevel;
- QList<KDUpdater::UpdateInfo> updateInfoList;
+ QList<UpdateInfo> updateInfoList;
- void parseFile(const QString& updateXmlFile);
- bool parsePackageUpdateElement(const QDomElement & updateE);
- bool parseCompatUpdateElement(const QDomElement & updateE);
+ void parseFile(const QString &updateXmlFile);
+ bool parsePackageUpdateElement(const QDomElement &updateE);
+ bool parseCompatUpdateElement(const QDomElement &updateE);
- void setInvalidContentError( const QString& detail );
+ void setInvalidContentError(const QString &detail);
};
-void KDUpdater::UpdatesInfo::UpdatesInfoData::setInvalidContentError(const QString& detail)
+void UpdatesInfo::UpdatesInfoData::setInvalidContentError(const QString &detail)
{
error = UpdatesInfo::InvalidContentError;
errorMessage = tr("Updates.Xml contains invalid content: %1").arg(detail);
}
-void KDUpdater::UpdatesInfo::UpdatesInfoData::parseFile(const QString& updateXmlFile)
+void UpdatesInfo::UpdatesInfoData::parseFile(const QString &updateXmlFile)
{
- QFile file( updateXmlFile );
- if( !file.open(QFile::ReadOnly) )
- {
+ QFile file(updateXmlFile);
+ if (!file.open(QFile::ReadOnly)) {
error = UpdatesInfo::CouldNotReadUpdateInfoFileError;
errorMessage = tr("Could not read \"%1\"").arg(updateXmlFile);
return;
@@ -73,46 +74,43 @@ void KDUpdater::UpdatesInfo::UpdatesInfoData::parseFile(const QString& updateXml
QString parseErrorMessage;
int parseErrorLine;
int parseErrorColumn;
- if( !doc.setContent( &file, &parseErrorMessage, &parseErrorLine, &parseErrorColumn ) )
- {
+ if (!doc.setContent(&file, &parseErrorMessage, &parseErrorLine, &parseErrorColumn)) {
error = UpdatesInfo::InvalidXmlError;
errorMessage = tr("Parse error in %1 at %2, %3: %4")
- .arg( updateXmlFile,
- QString::number( parseErrorLine ),
- QString::number( parseErrorColumn ),
- parseErrorMessage );
+ .arg(updateXmlFile,
+ QString::number(parseErrorLine),
+ QString::number(parseErrorColumn),
+ parseErrorMessage);
return;
}
QDomElement rootE = doc.documentElement();
- if( rootE.tagName() != QLatin1String( "Updates" ) )
- {
+ if (rootE.tagName() != QLatin1String("Updates")) {
setInvalidContentError(tr("root element %1 unexpected, should be \"Updates\"").arg(rootE.tagName()));
return;
}
QDomNodeList childNodes = rootE.childNodes();
- for(int i=0; i<childNodes.count(); i++)
- {
+ for(int i = 0; i < childNodes.count(); i++) {
QDomNode childNode = childNodes.at(i);
QDomElement childE = childNode.toElement();
- if( childE.isNull() )
+ if (childE.isNull())
continue;
- if( childE.tagName() == QLatin1String( "ApplicationName" ) )
+ if (childE.tagName() == QLatin1String("ApplicationName"))
applicationName = childE.text();
- else if( childE.tagName() == QLatin1String( "ApplicationVersion" ) )
+ else if (childE.tagName() == QLatin1String("ApplicationVersion"))
applicationVersion = childE.text();
- else if( childE.tagName() == QLatin1String( "RequiredCompatLevel" ) )
+ else if (childE.tagName() == QLatin1String("RequiredCompatLevel"))
compatLevel = childE.text().toInt();
- else if( childE.tagName() == QLatin1String( "PackageUpdate" ) ) {
- const bool res = parsePackageUpdateElement( childE );
+ else if (childE.tagName() == QLatin1String("PackageUpdate")) {
+ const bool res = parsePackageUpdateElement(childE);
if (!res) {
//error handled in subroutine
return;
}
- } else if( childE.tagName() == QLatin1String( "CompatUpdate" ) ) {
- const bool res = parseCompatUpdateElement( childE );
+ } else if (childE.tagName() == QLatin1String("CompatUpdate")) {
+ const bool res = parseCompatUpdateElement(childE);
if (!res) {
//error handled in subroutine
return;
@@ -120,14 +118,12 @@ void KDUpdater::UpdatesInfo::UpdatesInfoData::parseFile(const QString& updateXml
}
}
- if (applicationName.isEmpty())
- {
+ if (applicationName.isEmpty()) {
setInvalidContentError(tr("ApplicationName element is missing"));
return;
}
- if (applicationVersion.isEmpty())
- {
+ if (applicationVersion.isEmpty()) {
setInvalidContentError(tr("ApplicationVersion element is missing"));
return;
}
@@ -136,36 +132,33 @@ void KDUpdater::UpdatesInfo::UpdatesInfoData::parseFile(const QString& updateXml
errorMessage.clear();
}
-bool KDUpdater::UpdatesInfo::UpdatesInfoData::parsePackageUpdateElement(const QDomElement & updateE)
+bool UpdatesInfo::UpdatesInfoData::parsePackageUpdateElement(const QDomElement &updateE)
{
- if( updateE.isNull() )
+ if (updateE.isNull())
return false;
- KDUpdater::UpdateInfo info;
- info.type = KDUpdater::PackageUpdate;
+ UpdateInfo info;
+ info.type = PackageUpdate;
QDomNodeList childNodes = updateE.childNodes();
- for(int i=0; i<childNodes.count(); i++)
- {
+ for (int i = 0; i < childNodes.count(); i++) {
QDomNode childNode = childNodes.at(i);
QDomElement childE = childNode.toElement();
- if( childE.isNull() )
+ if (childE.isNull())
continue;
- if (childE.tagName() == QLatin1String( "ReleaseNotes" )) {
+ if (childE.tagName() == QLatin1String("ReleaseNotes")) {
info.data[childE.tagName()] = QUrl(childE.text());
- }
- else if (childE.tagName() == QLatin1String( "UpdateFile" )) {
- KDUpdater::UpdateFileInfo ufInfo;
- ufInfo.arch = childE.attribute(QLatin1String( "Arch" ), QLatin1String( "i386" ));
- ufInfo.os = childE.attribute(QLatin1String( "OS" ));
- ufInfo.compressedSize = childE.attribute( QLatin1String( "CompressedSize" ) ).toLongLong();
- ufInfo.uncompressedSize = childE.attribute( QLatin1String( "UncompressedSize" ) ).toLongLong();
- ufInfo.sha1sum = QByteArray::fromHex( childE.attribute( QLatin1String( "sha1sum" ) ).toAscii() );
+ } else if (childE.tagName() == QLatin1String("UpdateFile")) {
+ UpdateFileInfo ufInfo;
+ ufInfo.arch = childE.attribute(QLatin1String("Arch"), QLatin1String("i386"));
+ ufInfo.os = childE.attribute(QLatin1String("OS"));
+ ufInfo.compressedSize = childE.attribute(QLatin1String("CompressedSize")).toLongLong();
+ ufInfo.uncompressedSize = childE.attribute(QLatin1String("UncompressedSize")).toLongLong();
+ ufInfo.sha1sum = QByteArray::fromHex(childE.attribute(QLatin1String("sha1sum")).toAscii());
ufInfo.fileName = childE.text();
info.updateFiles.append(ufInfo);
- }
- else if (childE.tagName() == QLatin1String("Licenses")) {
+ } else if (childE.tagName() == QLatin1String("Licenses")) {
QHash<QString, QVariant> licenseHash;
const QDomNodeList licenseNodes = childE.childNodes();
for (int i = 0; i < licenseNodes.count(); ++i) {
@@ -178,33 +171,27 @@ bool KDUpdater::UpdatesInfo::UpdatesInfoData::parsePackageUpdateElement(const QD
}
if (!licenseHash.isEmpty())
info.data.insert(QLatin1String("Licenses"), licenseHash);
- }
- else if (childE.tagName() == QLatin1String( "Version" )) {
+ } else if (childE.tagName() == QLatin1String("Version")) {
info.data.insert(QLatin1String("inheritVersionFrom"), childE.attribute(QLatin1String("inheritVersionFrom")));
info.data[childE.tagName()] = childE.text();
- }
- else {
+ } else {
info.data[childE.tagName()] = childE.text();
}
}
- if (!info.data.contains( QLatin1String( "Name" ) ))
- {
+ if (!info.data.contains(QLatin1String("Name"))) {
setInvalidContentError(tr("PackageUpdate element without Name"));
return false;
}
- else if (!info.data.contains( QLatin1String( "Version" ) ))
- {
+ if (!info.data.contains(QLatin1String("Version"))) {
setInvalidContentError(tr("PackageUpdate element without Version"));
return false;
}
- else if (!info.data.contains( QLatin1String( "ReleaseDate" ) ))
- {
+ if (!info.data.contains(QLatin1String("ReleaseDate"))) {
setInvalidContentError(tr("PackageUpdate element without ReleaseDate"));
return false;
}
- else if (info.updateFiles.isEmpty())
- {
+ if (info.updateFiles.isEmpty()) {
setInvalidContentError(tr("PackageUpdate element without UpdateFile"));
return false;
}
@@ -213,52 +200,45 @@ bool KDUpdater::UpdatesInfo::UpdatesInfoData::parsePackageUpdateElement(const QD
return true;
}
-bool KDUpdater::UpdatesInfo::UpdatesInfoData::parseCompatUpdateElement(const QDomElement & updateE)
+bool UpdatesInfo::UpdatesInfoData::parseCompatUpdateElement(const QDomElement &updateE)
{
- if( updateE.isNull() )
+ if (updateE.isNull())
return false;
- KDUpdater::UpdateInfo info;
- info.type = KDUpdater::CompatUpdate;
+ UpdateInfo info;
+ info.type = CompatUpdate;
QDomNodeList childNodes = updateE.childNodes();
- for(int i=0; i<childNodes.count(); i++)
- {
+ for (int i = 0; i < childNodes.count(); i++) {
QDomNode childNode = childNodes.at(i);
QDomElement childE = childNode.toElement();
- if( childE.isNull() )
+ if (childE.isNull())
continue;
- if( childE.tagName() == QLatin1String( "ReleaseNotes" ) ) {
+ if (childE.tagName() == QLatin1String("ReleaseNotes")) {
info.data[childE.tagName()] = QUrl(childE.text());
- }
- else if( childE.tagName() == QLatin1String( "UpdateFile" ) )
- {
- KDUpdater::UpdateFileInfo ufInfo;
- ufInfo.arch = childE.attribute(QLatin1String( "Arch" ), QLatin1String( "i386" ));
- ufInfo.os = childE.attribute(QLatin1String( "OS" ));
+ } else if (childE.tagName() == QLatin1String("UpdateFile")) {
+ UpdateFileInfo ufInfo;
+ ufInfo.arch = childE.attribute(QLatin1String("Arch"), QLatin1String("i386"));
+ ufInfo.os = childE.attribute(QLatin1String("OS"));
ufInfo.fileName = childE.text();
info.updateFiles.append(ufInfo);
- }
- else {
+ } else {
info.data[childE.tagName()] = childE.text();
}
}
- if (!info.data.contains( QLatin1String( "CompatLevel" ) ))
- {
+ if (!info.data.contains(QLatin1String("CompatLevel"))) {
setInvalidContentError(tr("CompatUpdate element without CompatLevel"));
return false;
}
- if (!info.data.contains( QLatin1String( "ReleaseDate" ) ))
- {
+ if (!info.data.contains(QLatin1String("ReleaseDate"))) {
setInvalidContentError(tr("CompatUpdate element without ReleaseDate"));
return false;
}
- if (info.updateFiles.isEmpty())
- {
+ if (info.updateFiles.isEmpty()) {
setInvalidContentError(tr("CompatUpdate element without UpdateFile"));
return false;
}
@@ -269,30 +249,30 @@ bool KDUpdater::UpdatesInfo::UpdatesInfoData::parseCompatUpdateElement(const QDo
//
-// KDUpdater::UpdatesInfo
+// UpdatesInfo
//
-KDUpdater::UpdatesInfo::UpdatesInfo()
- : d(new KDUpdater::UpdatesInfo::UpdatesInfoData)
+UpdatesInfo::UpdatesInfo()
+ : d(new UpdatesInfo::UpdatesInfoData)
{
}
-KDUpdater::UpdatesInfo::~UpdatesInfo()
+UpdatesInfo::~UpdatesInfo()
{
}
-bool KDUpdater::UpdatesInfo::isValid() const
+bool UpdatesInfo::isValid() const
{
return d->error == NoError;
}
-QString KDUpdater::UpdatesInfo::errorString() const
+QString UpdatesInfo::errorString() const
{
return d->errorMessage;
}
-void KDUpdater::UpdatesInfo::setFileName(const QString& updateXmlFile)
+void UpdatesInfo::setFileName(const QString &updateXmlFile)
{
- if( d->updateXmlFile == updateXmlFile )
+ if (d->updateXmlFile == updateXmlFile)
return;
d->applicationName.clear();
@@ -300,73 +280,70 @@ void KDUpdater::UpdatesInfo::setFileName(const QString& updateXmlFile)
d->updateInfoList.clear();
d->updateXmlFile = updateXmlFile;
- d->parseFile( d->updateXmlFile );
+ d->parseFile(d->updateXmlFile);
}
-QString KDUpdater::UpdatesInfo::fileName() const
+QString UpdatesInfo::fileName() const
{
return d->updateXmlFile;
}
-QString KDUpdater::UpdatesInfo::applicationName() const
+QString UpdatesInfo::applicationName() const
{
return d->applicationName;
}
-QString KDUpdater::UpdatesInfo::applicationVersion() const
+QString UpdatesInfo::applicationVersion() const
{
return d->applicationVersion;
}
-int KDUpdater::UpdatesInfo::compatLevel() const
+int UpdatesInfo::compatLevel() const
{
return d->compatLevel;
}
-int KDUpdater::UpdatesInfo::updateInfoCount( int type) const
+int UpdatesInfo::updateInfoCount(int type) const
{
- if ( type == KDUpdater::AllUpdate ) {
+ if (type == AllUpdate)
return d->updateInfoList.count();
- }
+
int count = 0;
- for ( int i=0; i<d->updateInfoList.count(); ++i ) {
- if ( d->updateInfoList.at( i ).type == type )
+ for (int i = 0; i < d->updateInfoList.count(); ++i) {
+ if (d->updateInfoList.at(i).type == type)
++count;
}
return count;
}
-KDUpdater::UpdateInfo KDUpdater::UpdatesInfo::updateInfo(int index) const
+UpdateInfo UpdatesInfo::updateInfo(int index) const
{
- if(index < 0 || index >= d->updateInfoList.count())
- return KDUpdater::UpdateInfo();
+ if (index < 0 || index >= d->updateInfoList.count())
+ return UpdateInfo();
- return d->updateInfoList.at( index );
+ return d->updateInfoList.at(index);
}
-QList<KDUpdater::UpdateInfo> KDUpdater::UpdatesInfo::updatesInfo( int type, int compatLevel ) const
+QList<UpdateInfo> UpdatesInfo::updatesInfo(int type, int compatLevel) const
{
- QList<KDUpdater::UpdateInfo> list;
- if ( compatLevel == -1 ) {
- if ( type == KDUpdater::AllUpdate ) {
+ QList<UpdateInfo> list;
+ if (compatLevel == -1) {
+ if (type == AllUpdate)
return d->updateInfoList;
+ for (int i = 0; i < d->updateInfoList.count(); ++i) {
+ if (d->updateInfoList.at(i).type == type)
+ list.append(d->updateInfoList.at(i));
}
- for ( int i=0; i<d->updateInfoList.count(); ++i ) {
- if ( d->updateInfoList.at( i ).type == type )
- list.append( d->updateInfoList.at( i ) );
- }
- }
- else {
- for ( int i=0; i<d->updateInfoList.count(); ++i ) {
- UpdateInfo updateInfo = d->updateInfoList.at( i );
- if ( updateInfo.type == type ) {
- if ( updateInfo.type == CompatUpdate ) {
- if ( updateInfo.data.value( QLatin1String( "CompatLevel" ) ) == compatLevel )
- list.append( updateInfo );
- }
- else {
- if ( updateInfo.data.value( QLatin1String( "RequiredCompatLevel" ) ) == compatLevel )
- list.append( updateInfo );
+ } else {
+ for (int i = 0; i < d->updateInfoList.count(); ++i) {
+ UpdateInfo updateInfo = d->updateInfoList.at(i);
+ if (updateInfo.type == type) {
+ if (updateInfo.type == CompatUpdate) {
+ if (updateInfo.data.value(QLatin1String("CompatLevel")) == compatLevel)
+ list.append(updateInfo);
+ } else {
+ if (updateInfo.data.value(QLatin1String("RequiredCompatLevel")) == compatLevel)
+ list.append(updateInfo);
}
}
}
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdatesinfo_p.h b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdatesinfo_p.h
index 976146a9a..7c4bc5b3f 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdatesinfo_p.h
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdatesinfo_p.h
@@ -42,10 +42,10 @@ namespace KDUpdater {
struct UpdateFileInfo
{
UpdateFileInfo()
- : compressedSize( 0 ),
- uncompressedSize( 0 )
- {
- }
+ : compressedSize(0),
+ uncompressedSize(0)
+ {}
+
QString arch;
QString os;
QString fileName;
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdatesourcesinfo.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdatesourcesinfo.cpp
index 14a765a5b..e4fbae43c 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdatesourcesinfo.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdupdaterupdatesourcesinfo.cpp
@@ -84,49 +84,49 @@
* Changes made to the object could be saved back to the source file
*/
-namespace KDUpdater
-{
+using namespace KDUpdater;
+
struct UpdateSourceInfoPriorityHigherThan
{
- bool operator()( const UpdateSourceInfo& lhs, const UpdateSourceInfo& rhs ) const
+ bool operator()(const UpdateSourceInfo &lhs, const UpdateSourceInfo &rhs) const
{
return lhs.priority > rhs.priority;
}
};
-}
-struct KDUpdater::UpdateSourcesInfo::UpdateSourcesInfoData
+
+struct UpdateSourcesInfo::UpdateSourcesInfoData
{
- UpdateSourcesInfoData( UpdateSourcesInfo* qq ) :
- q( qq ),
+ UpdateSourcesInfoData(UpdateSourcesInfo *qq) :
+ q(qq),
error(UpdateSourcesInfo::NotYetReadError),
application(0),
modified(false)
{}
- UpdateSourcesInfo* q;
+ UpdateSourcesInfo *q;
QString errorMessage;
UpdateSourcesInfo::Error error;
- KDUpdater::Application* application;
+ Application *application;
bool modified;
QString fileName;
- QList<KDUpdater::UpdateSourceInfo> updateSourceInfoList;
+ QList<UpdateSourceInfo> updateSourceInfoList;
- void addUpdateSourceFrom( const QDomElement & element );
- void addChildElement( QDomDocument & doc, QDomElement & parentE, const QString & tagName, const QString & text, bool htmlText=false );
- void setInvalidContentError( const QString& detail );
+ void addUpdateSourceFrom(const QDomElement &element);
+ void addChildElement(QDomDocument &doc, QDomElement &parentE, const QString &tagName, const QString &text, bool htmlText = false);
+ void setInvalidContentError(const QString &detail);
void clearError();
void saveChanges();
};
-void KDUpdater::UpdateSourcesInfo::UpdateSourcesInfoData::setInvalidContentError(const QString& detail)
+void UpdateSourcesInfo::UpdateSourcesInfoData::setInvalidContentError(const QString &detail)
{
error = UpdateSourcesInfo::InvalidContentError;
errorMessage = tr("%1 contains invalid content: %2").arg(fileName, detail);
}
-void KDUpdater::UpdateSourcesInfo::UpdateSourcesInfoData::clearError()
+void UpdateSourcesInfo::UpdateSourcesInfoData::clearError()
{
error = UpdateSourcesInfo::NoError;
errorMessage.clear();
@@ -135,9 +135,9 @@ void KDUpdater::UpdateSourcesInfo::UpdateSourcesInfoData::clearError()
/*!
\internal
*/
-KDUpdater::UpdateSourcesInfo::UpdateSourcesInfo(Application* application)
+UpdateSourcesInfo::UpdateSourcesInfo(Application *application)
: QObject(application),
- d( new KDUpdater::UpdateSourcesInfo::UpdateSourcesInfoData( this ) )
+ d(new UpdateSourcesInfo::UpdateSourcesInfoData(this))
{
d->application = application;
}
@@ -145,7 +145,7 @@ KDUpdater::UpdateSourcesInfo::UpdateSourcesInfo(Application* application)
/*!
\internal
*/
-KDUpdater::UpdateSourcesInfo::~UpdateSourcesInfo()
+UpdateSourcesInfo::~UpdateSourcesInfo()
{
d->saveChanges();
delete d;
@@ -154,7 +154,7 @@ KDUpdater::UpdateSourcesInfo::~UpdateSourcesInfo()
/*!
Returns a pointer to the update application for which this class manages update sources.
*/
-KDUpdater::Application* KDUpdater::UpdateSourcesInfo::application() const
+Application *UpdateSourcesInfo::application() const
{
return d->application;
}
@@ -162,7 +162,7 @@ KDUpdater::Application* KDUpdater::UpdateSourcesInfo::application() const
/*!
\internal
*/
-bool KDUpdater::UpdateSourcesInfo::isValid() const
+bool UpdateSourcesInfo::isValid() const
{
return d->error == NoError;
}
@@ -170,7 +170,7 @@ bool KDUpdater::UpdateSourcesInfo::isValid() const
/*!
returns a human-readable description of the error
*/
-QString KDUpdater::UpdateSourcesInfo::errorString() const
+QString UpdateSourcesInfo::errorString() const
{
return d->errorMessage;
}
@@ -178,17 +178,17 @@ QString KDUpdater::UpdateSourcesInfo::errorString() const
/*!
returns the last error
*/
-KDUpdater::UpdateSourcesInfo::Error KDUpdater::UpdateSourcesInfo::error() const
+UpdateSourcesInfo::Error UpdateSourcesInfo::error() const
{
return d->error;
}
-bool KDUpdater::UpdateSourcesInfo::isModified() const
+bool UpdateSourcesInfo::isModified() const
{
return d->modified;
}
-void KDUpdater::UpdateSourcesInfo::setModified(bool modified)
+void UpdateSourcesInfo::setModified(bool modified)
{
d->modified = modified;
}
@@ -199,9 +199,9 @@ void KDUpdater::UpdateSourcesInfo::setModified(bool modified)
\sa KDUpdater::Application::setUpdateSourcesXMLFileName()
*/
-void KDUpdater::UpdateSourcesInfo::setFileName(const QString& fileName)
+void UpdateSourcesInfo::setFileName(const QString &fileName)
{
- if( d->fileName == fileName )
+ if (d->fileName == fileName)
return;
d->fileName = fileName;
@@ -211,7 +211,7 @@ void KDUpdater::UpdateSourcesInfo::setFileName(const QString& fileName)
/*!
Returns the name of the UpdateSources.xml file that this class referred to.
*/
-QString KDUpdater::UpdateSourcesInfo::fileName() const
+QString UpdateSourcesInfo::fileName() const
{
return d->fileName;
}
@@ -219,7 +219,7 @@ QString KDUpdater::UpdateSourcesInfo::fileName() const
/*!
Returns the number of update source info structures contained in this class.
*/
-int KDUpdater::UpdateSourcesInfo::updateSourceInfoCount() const
+int UpdateSourcesInfo::updateSourceInfoCount() const
{
return d->updateSourceInfoList.count();
}
@@ -228,10 +228,10 @@ int KDUpdater::UpdateSourcesInfo::updateSourceInfoCount() const
Returns the update source info structure at \c index. If an invalid index is passed
the function returns a dummy constructor.
*/
-KDUpdater::UpdateSourceInfo KDUpdater::UpdateSourcesInfo::updateSourceInfo(int index) const
+UpdateSourceInfo UpdateSourcesInfo::updateSourceInfo(int index) const
{
- if( index < 0 || index >= d->updateSourceInfoList.count() )
- return KDUpdater::UpdateSourceInfo();
+ if (index < 0 || index >= d->updateSourceInfoList.count())
+ return UpdateSourceInfo();
return d->updateSourceInfoList[index];
}
@@ -240,12 +240,12 @@ KDUpdater::UpdateSourceInfo KDUpdater::UpdateSourcesInfo::updateSourceInfo(int i
Adds an update source info to this class. Upon successful addition, the class emits a
\ref updateSourceInfoAdded() signal.
*/
-void KDUpdater::UpdateSourcesInfo::addUpdateSourceInfo(const KDUpdater::UpdateSourceInfo& info)
+void UpdateSourcesInfo::addUpdateSourceInfo(const UpdateSourceInfo &info)
{
- if( d->updateSourceInfoList.contains( info ) )
+ if (d->updateSourceInfoList.contains(info))
return;
- d->updateSourceInfoList.push_back( info );
- qSort( d->updateSourceInfoList.begin(), d->updateSourceInfoList.end(), KDUpdater::UpdateSourceInfoPriorityHigherThan() );
+ d->updateSourceInfoList.push_back(info);
+ qSort(d->updateSourceInfoList.begin(), d->updateSourceInfoList.end(), UpdateSourceInfoPriorityHigherThan());
emit updateSourceInfoAdded(info);
d->modified = true;
}
@@ -254,9 +254,9 @@ void KDUpdater::UpdateSourcesInfo::addUpdateSourceInfo(const KDUpdater::UpdateSo
Removes an update source info from this class. Upon successful removal, the class emits a
\ref updateSourceInfoRemoved() signal.
*/
-void KDUpdater::UpdateSourcesInfo::removeUpdateSourceInfo(const KDUpdater::UpdateSourceInfo& info)
+void UpdateSourcesInfo::removeUpdateSourceInfo(const UpdateSourceInfo &info)
{
- if( !d->updateSourceInfoList.contains(info) )
+ if (!d->updateSourceInfoList.contains(info))
return;
d->updateSourceInfoList.removeAll(info);
emit updateSourceInfoRemoved(info);
@@ -267,11 +267,11 @@ void KDUpdater::UpdateSourcesInfo::removeUpdateSourceInfo(const KDUpdater::Updat
Removes an update source info at \index in this class. Upon successful removal, the class emits a
\ref updateSourceInfoRemoved() signal.
*/
-void KDUpdater::UpdateSourcesInfo::removeUpdateSourceInfoAt(int index)
+void UpdateSourcesInfo::removeUpdateSourceInfoAt(int index)
{
- if( index < 0 || index >= d->updateSourceInfoList.count() )
+ if (index < 0 || index >= d->updateSourceInfoList.count())
return;
- KDUpdater::UpdateSourceInfo info = d->updateSourceInfoList[index];
+ UpdateSourceInfo info = d->updateSourceInfoList[index];
d->updateSourceInfoList.removeAt(index);
emit updateSourceInfoRemoved(info);
d->modified = true;
@@ -285,20 +285,17 @@ void KDUpdater::UpdateSourcesInfo::removeUpdateSourceInfoAt(int index)
Depending on what the function does \ref updateSourceInfoAdded() or \ref updateSourceInfoChanged()
signal is emitted.
*/
-void KDUpdater::UpdateSourcesInfo::setUpdateSourceInfoAt(int index, const KDUpdater::UpdateSourceInfo& info)
+void UpdateSourcesInfo::setUpdateSourceInfoAt(int index, const UpdateSourceInfo &info)
{
- if( index < 0 || index > d->updateSourceInfoList.count() )
+ if (index < 0 || index > d->updateSourceInfoList.count())
return;
- if( index == d->updateSourceInfoList.count() )
- {
+ if (index == d->updateSourceInfoList.count()) {
d->updateSourceInfoList.append(info);
emit updateSourceInfoAdded(info);
- }
- else
- {
- KDUpdater::UpdateSourceInfo oldInfo = d->updateSourceInfoList[index];
- if( info == oldInfo )
+ } else {
+ UpdateSourceInfo oldInfo = d->updateSourceInfoList[index];
+ if (info == oldInfo)
return;
d->updateSourceInfoList[index] = info;
@@ -310,24 +307,22 @@ void KDUpdater::UpdateSourcesInfo::setUpdateSourceInfoAt(int index, const KDUpda
/*!
This slot reloads the update source information from UpdateSources.xml.
*/
-void KDUpdater::UpdateSourcesInfo::refresh()
+void UpdateSourcesInfo::refresh()
{
d->saveChanges(); // save changes done in the previous file
d->updateSourceInfoList.clear();
- QFile file( d->fileName );
+ QFile file(d->fileName);
// if the file does not exist then we just skip the reading
- if( !file.exists() )
- {
+ if (!file.exists()) {
d->clearError();
emit reset();
return;
}
// Open the XML file
- if( !file.open(QFile::ReadOnly) )
- {
+ if (!file.open(QFile::ReadOnly)) {
d->errorMessage = tr("Could not read \"%1\"").arg(d->fileName);
d->error = CouldNotReadSourceFileError;
emit reset();
@@ -338,36 +333,33 @@ void KDUpdater::UpdateSourcesInfo::refresh()
QString parseErrorMessage;
int parseErrorLine;
int parseErrorColumn;
- if( !doc.setContent( &file, &parseErrorMessage, &parseErrorLine, &parseErrorColumn ) )
- {
+ if (!doc.setContent(&file, &parseErrorMessage, &parseErrorLine, &parseErrorColumn)) {
d->error = InvalidXmlError;
d->errorMessage = tr("XML Parse error in %1 at %2, %3: %4")
- .arg( d->fileName,
- QString::number( parseErrorLine ),
- QString::number( parseErrorColumn ),
- parseErrorMessage );
+ .arg(d->fileName,
+ QString::number(parseErrorLine),
+ QString::number(parseErrorColumn),
+ parseErrorMessage);
emit reset();
return;
}
// Now parse the XML file.
QDomElement rootE = doc.documentElement();
- if( rootE.tagName() != QLatin1String( "UpdateSources" ) )
- {
+ if (rootE.tagName() != QLatin1String("UpdateSources")) {
d->setInvalidContentError(tr("Root element %1 unexpected, should be \"UpdateSources\"").arg(rootE.tagName()));
emit reset();
return;
}
QDomNodeList childNodes = rootE.childNodes();
- for(int i=0; i<childNodes.count(); i++)
- {
+ for (int i = 0; i < childNodes.count(); i++) {
QDomNode childNode = childNodes.item(i);
QDomElement childNodeE = childNode.toElement();
- if( childNodeE.isNull() )
+ if (childNodeE.isNull())
continue;
- if( childNodeE.tagName() == QLatin1String( "UpdateSource" ) )
+ if (childNodeE.tagName() == QLatin1String("UpdateSource"))
d->addUpdateSourceFrom(childNodeE);
}
@@ -375,101 +367,94 @@ void KDUpdater::UpdateSourcesInfo::refresh()
emit reset();
}
-void KDUpdater::UpdateSourcesInfo::UpdateSourcesInfoData::saveChanges()
+void UpdateSourcesInfo::UpdateSourcesInfoData::saveChanges()
{
- if( !modified || fileName.isEmpty() )
+ if (!modified || fileName.isEmpty())
return;
const bool hadSaveError = error == UpdateSourcesInfo::CouldNotSaveChangesError;
QDomDocument doc;
- QDomElement rootE = doc.createElement( QLatin1String( "UpdateSources") );
+ QDomElement rootE = doc.createElement(QLatin1String("UpdateSources"));
doc.appendChild(rootE);
- for(int i=0; i<updateSourceInfoList.count(); i++)
- {
- KDUpdater::UpdateSourceInfo info = updateSourceInfoList[i];
+ for (int i = 0; i < updateSourceInfoList.count(); i++) {
+ UpdateSourceInfo info = updateSourceInfoList.at(i);
- QDomElement infoE = doc.createElement( QLatin1String( "UpdateSource" ) );
+ QDomElement infoE = doc.createElement(QLatin1String("UpdateSource"));
rootE.appendChild(infoE);
- addChildElement(doc, infoE, QLatin1String( "Name" ), info.name);
- addChildElement(doc, infoE, QLatin1String( "Title" ), info.title);
- addChildElement(doc, infoE, QLatin1String( "Description" ), info.description,
- (info.description.length() && info.description[0] == QLatin1Char( '<' ) ) );
- addChildElement(doc, infoE, QLatin1String( "Url" ), info.url.toString());
+ addChildElement(doc, infoE, QLatin1String("Name"), info.name);
+ addChildElement(doc, infoE, QLatin1String("Title"), info.title);
+ addChildElement(doc, infoE, QLatin1String("Description"), info.description,
+ (info.description.length() && info.description.at(0) == QLatin1Char('<')));
+ addChildElement(doc, infoE, QLatin1String("Url"), info.url.toString());
}
- QFile file( fileName );
- if ( !file.open( QFile::WriteOnly ) )
- {
+ QFile file(fileName);
+ if (!file.open(QFile::WriteOnly)) {
error = UpdateSourcesInfo::CouldNotSaveChangesError;
errorMessage = tr("Could not save changes to \"%1\": %2").arg(fileName, file.errorString());
return;
}
- QTextStream stream( &file );
- doc.save( stream, 2 );
+ QTextStream stream(&file);
+ doc.save(stream, 2);
stream.flush();
file.close();
- if ( file.error() != QFile::NoError )
- {
+ if (file.error() != QFile::NoError) {
error = UpdateSourcesInfo::CouldNotSaveChangesError;
errorMessage = tr("Could not save changes to \"%1\": %2").arg(fileName, file.errorString());
return;
}
//if there was a write error before, clear the error, as the write was successful now
- if ( hadSaveError )
+ if (hadSaveError)
clearError();
modified = false;
}
-void KDUpdater::UpdateSourcesInfo::UpdateSourcesInfoData::addUpdateSourceFrom( const QDomElement & element )
+void UpdateSourcesInfo::UpdateSourcesInfoData::addUpdateSourceFrom(const QDomElement &element)
{
- if( element.tagName() != QLatin1String( "UpdateSource" ) )
+ if (element.tagName() != QLatin1String("UpdateSource"))
return;
QDomNodeList childNodes = element.childNodes();
- if(!childNodes.count())
+ if (!childNodes.count())
return;
- KDUpdater::UpdateSourceInfo info;
+ UpdateSourceInfo info;
- for(int i=0; i<childNodes.count(); i++)
- {
+ for (int i = 0; i<childNodes.count(); i++) {
QDomNode childNode = childNodes.item(i);
QDomElement childNodeE = childNode.toElement();
- if( childNodeE.isNull() )
+ if (childNodeE.isNull())
continue;
- if( childNodeE.tagName() == QLatin1String( "Name" ) )
+ if (childNodeE.tagName() == QLatin1String("Name"))
info.name = childNodeE.text();
- else if( childNodeE.tagName() == QLatin1String( "Title" ) )
+ else if (childNodeE.tagName() == QLatin1String("Title"))
info.title = childNodeE.text();
- else if( childNodeE.tagName() == QLatin1String( "Description" ) )
+ else if (childNodeE.tagName() == QLatin1String("Description"))
info.description = childNodeE.text();
- else if( childNodeE.tagName() == QLatin1String( "Url" ) )
+ else if (childNodeE.tagName() == QLatin1String("Url"))
info.url = childNodeE.text();
}
this->updateSourceInfoList.append(info);
}
-void KDUpdater::UpdateSourcesInfo::UpdateSourcesInfoData::addChildElement( QDomDocument & doc, QDomElement & parentE, const QString & tagName, const QString & text, bool htmlText )
+void UpdateSourcesInfo::UpdateSourcesInfoData::addChildElement(QDomDocument &doc, QDomElement &parentE, const QString &tagName, const QString &text, bool htmlText)
{
QDomElement childE = doc.createElement(tagName);
parentE.appendChild(childE);
- if( htmlText )
- {
+ if (htmlText) {
QDomCDATASection textE = doc.createCDATASection(text);
childE.appendChild(textE);
- }
- else
- {
+ } else {
QDomText textE = doc.createTextNode(text);
childE.appendChild(textE);
}
@@ -504,8 +489,12 @@ void KDUpdater::UpdateSourcesInfo::UpdateSourcesInfoData::addChildElement( QDomD
\var QUrl KDUpdater::UpdateSourceInfo::priority
*/
-bool KDUpdater::operator==( const UpdateSourceInfo & lhs, const UpdateSourceInfo & rhs )
+namespace KDUpdater {
+
+bool operator==(const UpdateSourceInfo &lhs, const UpdateSourceInfo &rhs)
{
- return (lhs.name == rhs.name) && (lhs.title == rhs.title) &&
- (lhs.description == rhs.description) && (lhs.url == rhs.url);
+ return lhs.name == rhs.name && lhs.title == rhs.title
+ && lhs.description == rhs.description && lhs.url == rhs.url;
}
+
+} // namespace KDUpdater