diff options
author | hjk <qthjk@ovi.com> | 2011-11-17 22:12:18 +0100 |
---|---|---|
committer | hjk <qthjk@ovi.com> | 2011-11-18 15:54:20 +0100 |
commit | dcc4b445439be3d835ee61807dbcf95edafd9d0e (patch) | |
tree | 72c94c8cc098400b60d23017a5eb1af09252bf7e | |
parent | 48654f2d61e9b7065664031d2fecadd7b07ca139 (diff) |
Code cosmetics.
Change-Id: Ia42fccff507fce1e999d4534656984b6ebf5184b
Reviewed-by: Karsten Heimrich <karsten.heimrich@nokia.com>
72 files changed, 637 insertions, 675 deletions
diff --git a/installerbuilder/common/binaryformatengine.cpp b/installerbuilder/common/binaryformatengine.cpp index 176072d8a..47a9784b3 100644 --- a/installerbuilder/common/binaryformatengine.cpp +++ b/installerbuilder/common/binaryformatengine.cpp @@ -34,15 +34,15 @@ using namespace QInstallerCreator; -namespace -{ +namespace { + class StringListIterator : public QAbstractFileEngineIterator { public: - StringListIterator( const QStringList& list, QDir::Filters filters, const QStringList& nameFilters ) - : QAbstractFileEngineIterator( filters, nameFilters ), - list( list ), - index( -1 ) + StringListIterator( const QStringList &list, QDir::Filters filters, const QStringList &nameFilters) + : QAbstractFileEngineIterator(filters, nameFilters), + list(list), + index(-1) { } @@ -53,7 +53,7 @@ public: QString next() { - if( !hasNext() ) + if(!hasNext()) return QString(); ++index; return currentFilePath(); @@ -61,58 +61,59 @@ public: QString currentFileName() const { - return index < 0 ? QString() : list[ index ]; + return index < 0 ? QString() : list[index]; } private: const QStringList list; int index; }; -} -BinaryFormatEngine::BinaryFormatEngine( const ComponentIndex& index, const QString& fileName ) - : m_index( index ) - , m_hasComponent( false ) - , m_hasArchive( false ) - , m_archive( 0 ) +} // anon namespace + +BinaryFormatEngine::BinaryFormatEngine(const ComponentIndex &index, const QString &fileName) + : m_index(index) + , m_hasComponent(false) + , m_hasArchive(false) + , m_archive(0) { - setArchive( fileName ); + setArchive(fileName); } BinaryFormatEngine::~BinaryFormatEngine() { } -void BinaryFormatEngine::setArchive( const QString& file ) +void BinaryFormatEngine::setArchive(const QString &file) { m_fileNamePath = file; - static const QChar sep = QChar::fromLatin1( '/' ); - static const QString prefix = QString::fromLatin1( "installer://" ); - Q_ASSERT( file.toLower().startsWith( prefix ) ); + static const QChar sep = QChar::fromLatin1('/'); + static const QString prefix = QString::fromLatin1("installer://"); + Q_ASSERT(file.toLower().startsWith(prefix)); // cut the prefix - QString path = file.mid( prefix.length() ); - while( path.endsWith( sep ) ) - path.chop( 1 ); + QString path = file.mid(prefix.length()); + while (path.endsWith(sep)) + path.chop(1); QString arch; - const QString comp = path.section( sep, 0, 0 ); + const QString comp = path.section(sep, 0, 0); m_hasComponent = !comp.isEmpty(); - m_hasArchive = path.contains( sep ); - if( m_hasArchive ) - arch = path.section( sep, 1, 1 ); + m_hasArchive = path.contains(sep); + if (m_hasArchive) + arch = path.section(sep, 1, 1); - m_component = m_index.componentByName( comp.toUtf8() ); - m_archive = m_component.archiveByName( arch.toUtf8() ); + m_component = m_index.componentByName(comp.toUtf8()); + m_archive = m_component.archiveByName(arch.toUtf8()); } /** * \reimp */ -void BinaryFormatEngine::setFileName( const QString& file ) +void BinaryFormatEngine::setFileName(const QString &file) { - setArchive( file ); + setArchive(file); } /** @@ -120,7 +121,7 @@ void BinaryFormatEngine::setFileName( const QString& file ) */ bool BinaryFormatEngine::close() { - if( m_archive == 0 ) + if (m_archive == 0) return false; const bool result = m_archive->isOpen(); @@ -131,9 +132,9 @@ bool BinaryFormatEngine::close() /** * \reimp */ -bool BinaryFormatEngine::open( QIODevice::OpenMode mode ) +bool BinaryFormatEngine::open(QIODevice::OpenMode mode) { - return m_archive == 0 ? false : m_archive->open( mode ); + return m_archive == 0 ? false : m_archive->open(mode); } /** @@ -147,32 +148,31 @@ qint64 BinaryFormatEngine::pos() const /** * \reimp */ -qint64 BinaryFormatEngine::read( char* data, qint64 maxlen ) +qint64 BinaryFormatEngine::read(char *data, qint64 maxlen) { - return m_archive == 0 ? -1 : m_archive->read( data, maxlen ); + return m_archive == 0 ? -1 : m_archive->read(data, maxlen); } /** * \reimp */ -bool BinaryFormatEngine::seek( qint64 offset ) +bool BinaryFormatEngine::seek(qint64 offset) { - return m_archive == 0 ? false : m_archive->seek( offset ); + return m_archive == 0 ? false : m_archive->seek(offset); } /** * \reimp */ -QString BinaryFormatEngine::fileName( FileName file ) const +QString BinaryFormatEngine::fileName(FileName file) const { - switch( file ) - { + switch(file) { case BaseName: - return m_fileNamePath.section( QChar::fromLatin1( '/' ), -1, -1, QString::SectionSkipEmpty ); + return m_fileNamePath.section(QChar::fromLatin1('/'), -1, -1, QString::SectionSkipEmpty); case PathName: case AbsolutePathName: case CanonicalPathName: - return m_fileNamePath.section( QChar::fromLatin1( '/' ), 0, -2, QString::SectionSkipEmpty ); + return m_fileNamePath.section(QChar::fromLatin1('/'), 0, -2, QString::SectionSkipEmpty); case DefaultName: case AbsoluteName: case CanonicalName: @@ -185,32 +185,29 @@ QString BinaryFormatEngine::fileName( FileName file ) const /** * \reimp */ -bool BinaryFormatEngine::copy( const QString& newName ) +bool BinaryFormatEngine::copy(const QString &newName) { - if( QFile::exists( newName ) ) + if (QFile::exists(newName)) return false; - QFile target( newName ); - if( !target.open( QIODevice::WriteOnly ) ) + QFile target(newName); + if (!target.open(QIODevice::WriteOnly)) return false; qint64 bytesLeft = size(); - if( !open( QIODevice::ReadOnly ) ) + if (!open(QIODevice::ReadOnly)) return false; - char data[ 4096 ]; - while( bytesLeft > 0 ) - { - const qint64 len = qMin< qint64 >( bytesLeft, 4096 ); - const qint64 bytesRead = read( data, len ); - if( bytesRead != len ) - { + char data[4096]; + while(bytesLeft > 0) { + const qint64 len = qMin<qint64>(bytesLeft, 4096); + const qint64 bytesRead = read(data, len); + if (bytesRead != len) { close(); return false; } - const qint64 bytesWritten = target.write( data, len ); - if( bytesWritten != len ) - { + const qint64 bytesWritten = target.write(data, len); + if (bytesWritten != len) { close(); return false; } @@ -224,16 +221,16 @@ bool BinaryFormatEngine::copy( const QString& newName ) /** * \reimp */ -QAbstractFileEngine::FileFlags BinaryFormatEngine::fileFlags( FileFlags type ) const +QAbstractFileEngine::FileFlags BinaryFormatEngine::fileFlags(FileFlags type) const { FileFlags result; - if( ( type & FileType ) && m_archive != 0 ) + if ((type & FileType) && m_archive != 0) result |= FileType; - if( ( type & DirectoryType ) && !m_hasArchive ) + if ((type & DirectoryType) && !m_hasArchive) result |= DirectoryType; - if( ( type & ExistsFlag ) && m_hasArchive && m_archive != 0 ) + if ((type & ExistsFlag) && m_hasArchive && m_archive != 0) result |= ExistsFlag; - if( ( type & ExistsFlag ) && !m_hasArchive && !m_component.name().isEmpty() ) + if ((type & ExistsFlag) && !m_hasArchive && !m_component.name().isEmpty()) result |= ExistsFlag; return result; @@ -242,54 +239,50 @@ QAbstractFileEngine::FileFlags BinaryFormatEngine::fileFlags( FileFlags type ) c /** * \reimp */ -QAbstractFileEngineIterator* BinaryFormatEngine::beginEntryList( QDir::Filters filters, const QStringList& filterNames ) +QAbstractFileEngineIterator *BinaryFormatEngine::beginEntryList(QDir::Filters filters, const QStringList &filterNames) { - const QStringList entries = entryList( filters, filterNames ); - return new StringListIterator( entries, filters, filterNames ); + const QStringList entries = entryList(filters, filterNames); + return new StringListIterator(entries, filters, filterNames); } /** * \reimp */ -QStringList BinaryFormatEngine::entryList( QDir::Filters filters, const QStringList& filterNames ) const +QStringList BinaryFormatEngine::entryList(QDir::Filters filters, const QStringList &filterNames) const { - if( m_hasArchive ) + if (m_hasArchive) return QStringList(); QStringList result; - if( m_hasComponent && ( filters & QDir::Files ) ) - { + if (m_hasComponent && (filters & QDir::Files)) { const QVector< QSharedPointer<Archive> > archives = m_component.archives(); - Q_FOREACH( const QSharedPointer<Archive>& i, archives ) - result.push_back( QString::fromUtf8( i->name() ) ); + foreach (const QSharedPointer<Archive> &i, archives) + result.push_back(QString::fromUtf8(i->name())); } - else if( !m_hasComponent && ( filters & QDir::Dirs ) ) - { - const QVector< Component > components = m_index.components(); - Q_FOREACH( const Component& i, components ) - result.push_back( QString::fromUtf8( i.name() ) ); + else if (!m_hasComponent && (filters & QDir::Dirs)) { + const QVector<Component> components = m_index.components(); + foreach (const Component &i, components) + result.push_back(QString::fromUtf8(i.name())); } - if( filterNames.isEmpty() ) + if (filterNames.isEmpty()) return result; - QList< QRegExp > regexps; - Q_FOREACH( const QString& i, filterNames ) - regexps.push_back( QRegExp( i, Qt::CaseInsensitive, QRegExp::Wildcard ) ); + QList<QRegExp> regexps; + foreach (const QString &i, filterNames) + regexps.push_back(QRegExp(i, Qt::CaseInsensitive, QRegExp::Wildcard)); QStringList entries; - Q_FOREACH( const QString& i, result ) - { + foreach (const QString &i, result) { bool matched = false; - Q_FOREACH( const QRegExp& reg, regexps ) - { - matched = reg.exactMatch( i ); - if( matched ) + foreach (const QRegExp ®, regexps) { + matched = reg.exactMatch(i); + if (matched) break; } - if( matched ) - entries.push_back( i ); + if (matched) + entries.push_back(i); } return entries; diff --git a/installerbuilder/common/binaryformatengine.h b/installerbuilder/common/binaryformatengine.h index d6f4e49e6..41053b382 100644 --- a/installerbuilder/common/binaryformatengine.h +++ b/installerbuilder/common/binaryformatengine.h @@ -30,34 +30,32 @@ #include "binaryformat.h" -namespace QInstallerCreator -{ +namespace QInstallerCreator { class BinaryFormatEngine : public QAbstractFileEngine { public: - BinaryFormatEngine( const ComponentIndex& index, const QString& fileName ); + BinaryFormatEngine(const ComponentIndex &index, const QString &fileName); ~BinaryFormatEngine(); - void setFileName( const QString& file ); - - Iterator* beginEntryList( QDir::Filters filters, const QStringList& filterNames ); + void setFileName(const QString &file); - bool copy( const QString& newName ); + Iterator *beginEntryList(QDir::Filters filters, const QStringList &filterNames); + bool copy(const QString &newName); bool close(); - bool open( QIODevice::OpenMode mode ); + bool open(QIODevice::OpenMode mode); qint64 pos() const; - qint64 read( char* data, qint64 maxlen ); - bool seek( qint64 offset ); + qint64 read(char *data, qint64 maxlen); + bool seek(qint64 offset); qint64 size() const; - QString fileName( FileName file = DefaultName ) const; - FileFlags fileFlags( FileFlags type = FileInfoAll ) const; - QStringList entryList( QDir::Filters filters, const QStringList& filterNames ) const; + QString fileName(FileName file = DefaultName) const; + FileFlags fileFlags(FileFlags type = FileInfoAll) const; + QStringList entryList(QDir::Filters filters, const QStringList &filterNames) const; protected: - void setArchive( const QString& file ); + void setArchive(const QString &file); private: const ComponentIndex m_index; @@ -68,6 +66,6 @@ private: QString m_fileNamePath; }; -} +} // namespace QInstallerCreator #endif diff --git a/installerbuilder/common/binaryformatenginehandler.cpp b/installerbuilder/common/binaryformatenginehandler.cpp index 9fc917f1a..8b020425f 100644 --- a/installerbuilder/common/binaryformatenginehandler.cpp +++ b/installerbuilder/common/binaryformatenginehandler.cpp @@ -40,77 +40,77 @@ using namespace QInstallerCreator; -static BinaryFormatEngineHandler* s_instance = 0; +static BinaryFormatEngineHandler *s_instance = 0; class BinaryFormatEngineHandler::Private { public: - Private( const ComponentIndex& i ) - : index( i ) + Private(const ComponentIndex &i) + : index(i) { } ComponentIndex index; }; -BinaryFormatEngineHandler::BinaryFormatEngineHandler( const ComponentIndex& index ) - : d( new Private( index ) ) +BinaryFormatEngineHandler::BinaryFormatEngineHandler(const ComponentIndex &index) + : d(new Private(index)) { s_instance = this; } -BinaryFormatEngineHandler::BinaryFormatEngineHandler( const BinaryFormatEngineHandler& other ) +BinaryFormatEngineHandler::BinaryFormatEngineHandler(const BinaryFormatEngineHandler &other) : QAbstractFileEngineHandler(), - d( new Private( other.d->index ) ) + d(new Private(other.d->index)) { s_instance = this; } BinaryFormatEngineHandler::~BinaryFormatEngineHandler() { - if( s_instance == this ) + if (s_instance == this) s_instance = 0; delete d; } -void BinaryFormatEngineHandler::setComponentIndex( const ComponentIndex& index ) +void BinaryFormatEngineHandler::setComponentIndex(const ComponentIndex &index) { d->index = index; } -QAbstractFileEngine* BinaryFormatEngineHandler::create( const QString& fileName ) const +QAbstractFileEngine *BinaryFormatEngineHandler::create(const QString &fileName) const { - return fileName.startsWith( QLatin1String( "installer://" ), Qt::CaseInsensitive ) ? new BinaryFormatEngine( d->index, fileName ) : 0; + return fileName.startsWith(QLatin1String("installer://"), Qt::CaseInsensitive ) ? new BinaryFormatEngine(d->index, fileName) : 0; } -BinaryFormatEngineHandler* BinaryFormatEngineHandler::instance() +BinaryFormatEngineHandler *BinaryFormatEngineHandler::instance() { return s_instance; } -void BinaryFormatEngineHandler::registerArchive( const QString& pathName, const QString& archive ) +void BinaryFormatEngineHandler::registerArchive(const QString &pathName, const QString &archive) { - static const QChar sep = QChar::fromLatin1( '/' ); - static const QString prefix = QString::fromLatin1( "installer://" ); - Q_ASSERT( pathName.toLower().startsWith( prefix ) ); + static const QChar sep = QChar::fromLatin1('/'); + static const QString prefix = QString::fromLatin1("installer://"); + Q_ASSERT(pathName.toLower().startsWith(prefix)); // cut the prefix - QString path = pathName.mid( prefix.length() ); - while( path.endsWith( sep ) ) - path.chop( 1 ); + QString path = pathName.mid(prefix.length()); + while (path.endsWith(sep)) + path.chop(1); - const QString comp = path.section( sep, 0, 0 ); - const QString archiveName = path.section( sep, 1, 1 ); + const QString comp = path.section(sep, 0, 0); + const QString archiveName = path.section(sep, 1, 1); - Component c = d->index.componentByName( comp.toUtf8() ); - if( c.name().isEmpty() ) - c.setName( comp.toUtf8() ); + Component c = d->index.componentByName(comp.toUtf8()); + if (c.name().isEmpty()) + c.setName(comp.toUtf8()); - QList< QSharedPointer< Archive > > registered; - QSharedPointer< Archive > newArchive( new Archive( archive ) ); - newArchive->setName( archiveName.toUtf8() ); - registered.push_back( newArchive ); - c.appendArchive( newArchive ); - d->index.insertComponent( c ); + QList< QSharedPointer<Archive> > registered; + QSharedPointer<Archive> newArchive(new Archive(archive)); + newArchive->setName(archiveName.toUtf8()); + registered.push_back(newArchive); + c.appendArchive(newArchive); + d->index.insertComponent(c); } diff --git a/installerbuilder/common/binaryformatenginehandler.h b/installerbuilder/common/binaryformatenginehandler.h index 7a6798f57..c39561041 100644 --- a/installerbuilder/common/binaryformatenginehandler.h +++ b/installerbuilder/common/binaryformatenginehandler.h @@ -31,24 +31,23 @@ #include <QtCore/QAbstractFileEngineHandler> -namespace QInstallerCreator -{ +namespace QInstallerCreator { class ComponentIndex; class INSTALLER_EXPORT BinaryFormatEngineHandler : public QAbstractFileEngineHandler { public: - explicit BinaryFormatEngineHandler( const ComponentIndex& index ); - BinaryFormatEngineHandler( const BinaryFormatEngineHandler& other ); + explicit BinaryFormatEngineHandler(const ComponentIndex &index); + BinaryFormatEngineHandler(const BinaryFormatEngineHandler &other); ~BinaryFormatEngineHandler(); - QAbstractFileEngine* create( const QString& fileName ) const; + QAbstractFileEngine *create(const QString &fileName) const; - void setComponentIndex( const ComponentIndex& index ); + void setComponentIndex(const ComponentIndex &index); - static BinaryFormatEngineHandler* instance(); + static BinaryFormatEngineHandler *instance(); - void registerArchive( const QString& fileName, const QString& path ); + void registerArchive(const QString &fileName, const QString &path); private: class Private; diff --git a/installerbuilder/common/fileutils.h b/installerbuilder/common/fileutils.h index c405f8461..94ee64ab9 100644 --- a/installerbuilder/common/fileutils.h +++ b/installerbuilder/common/fileutils.h @@ -70,7 +70,7 @@ private: qint64 INSTALLER_EXPORT blockingRead(QIODevice *in, char *buffer, qint64 size); void INSTALLER_EXPORT blockingCopy(QIODevice *in, QIODevice *out, qint64 size); - qint64 INSTALLER_EXPORT blockingWrite(QIODevice *out, const char* buffer, qint64 size); + qint64 INSTALLER_EXPORT blockingWrite(QIODevice *out, const char *buffer, qint64 size); qint64 INSTALLER_EXPORT blockingWrite(QIODevice *out, const QByteArray& ba); /*! diff --git a/installerbuilder/common/repository.cpp b/installerbuilder/common/repository.cpp index f67b73886..690a513ac 100644 --- a/installerbuilder/common/repository.cpp +++ b/installerbuilder/common/repository.cpp @@ -95,7 +95,7 @@ QUrl Repository::url() const /*! Sets the repository URL to the one specified at \a url. */ -void Repository::setUrl(const QUrl& url) +void Repository::setUrl(const QUrl &url) { m_url = url; } diff --git a/installerbuilder/common/repository.h b/installerbuilder/common/repository.h index a2c77f4e0..fcce3e969 100644 --- a/installerbuilder/common/repository.h +++ b/installerbuilder/common/repository.h @@ -50,7 +50,7 @@ public: bool isDefault() const; QUrl url() const; - void setUrl(const QUrl& url); + void setUrl(const QUrl &url); bool isEnabled() const; void setEnabled(bool enabled); @@ -78,7 +78,7 @@ inline uint qHash(const Repository &repository) return qHash(repository.url().toString()); } -} // namespace QInstaller +} // namespace QInstaller Q_DECLARE_METATYPE(QInstaller::Repository) diff --git a/installerbuilder/common/utils.cpp b/installerbuilder/common/utils.cpp index 887da30d7..d99c2d279 100644 --- a/installerbuilder/common/utils.cpp +++ b/installerbuilder/common/utils.cpp @@ -47,7 +47,8 @@ static bool verb = false; -void QInstaller::setVerbose( bool v ) { +void QInstaller::setVerbose(bool v) +{ verb = v; } @@ -57,7 +58,7 @@ bool QInstaller::isVerbose() } #ifdef Q_WS_WIN -void qWinMsgHandler(QtMsgType t, const char* str); +void qWinMsgHandler(QtMsgType t, const char *str); class debugstream : public std::ostream { @@ -88,7 +89,7 @@ private: }; #endif -std::ostream& QInstaller::stdverbose() +std::ostream &QInstaller::stdverbose() { static std::fstream null; #ifdef Q_WS_WIN @@ -101,46 +102,47 @@ std::ostream& QInstaller::stdverbose() return null; } -std::ostream& QInstaller::operator<<( std::ostream& os, const QUrl& url ) +std::ostream &QInstaller::operator<<(std::ostream &os, const QUrl &url) { return os << "QUrl( " << url.toString() << ")"; } -std::ostream& QInstaller::operator<<( std::ostream& os, const QString& string ) +std::ostream &QInstaller::operator<<(std::ostream &os, const QString &string) { return os << qPrintable(string); } -std::ostream& QInstaller::operator<<( std::ostream& os, const QByteArray& array ) +std::ostream &QInstaller::operator<<(std::ostream &os, const QByteArray &array) { return os << '"' << QString::fromAscii( array ) << '"'; } //TODO from kdupdaterfiledownloader.cpp, use that one once merged -QByteArray QInstaller::calculateHash( QIODevice* device, QCryptographicHash::Algorithm algo ) { - Q_ASSERT( device ); - QCryptographicHash hash( algo ); +QByteArray QInstaller::calculateHash(QIODevice *device, QCryptographicHash::Algorithm algo) +{ + Q_ASSERT(device); + QCryptographicHash hash(algo); QByteArray buffer; - buffer.resize( 512 * 1024 ); - while ( true ) { - const qint64 numRead = device->read( buffer.data(), buffer.size() ); - if ( numRead <= 0 ) + buffer.resize(512 * 1024); + while (true) { + const qint64 numRead = device->read(buffer.data(), buffer.size()); + if (numRead <= 0) return hash.result(); - hash.addData( buffer.constData(), numRead ); + hash.addData(buffer.constData(), numRead); } return QByteArray(); // never reached } -QString QInstaller::replaceVariables(const QHash<QString,QString>& vars, const QString &str) +QString QInstaller::replaceVariables(const QHash<QString, QString> &vars, const QString &str) { QString res; int pos = 0; while (true) { - int pos1 = str.indexOf( QLatin1Char( '@' ), pos); + int pos1 = str.indexOf(QLatin1Char('@'), pos); if (pos1 == -1) break; - int pos2 = str.indexOf( QLatin1Char( '@' ), pos1 + 1); + int pos2 = str.indexOf(QLatin1Char('@'), pos1 + 1); if (pos2 == -1) break; res += str.mid(pos, pos1 - pos); @@ -158,10 +160,10 @@ QString QInstaller::replaceWindowsEnvironmentVariables(const QString &str) QString res; int pos = 0; while (true) { - int pos1 = str.indexOf( QLatin1Char( '%' ), pos); + int pos1 = str.indexOf(QLatin1Char( '%'), pos); if (pos1 == -1) break; - int pos2 = str.indexOf( QLatin1Char( '%' ), pos1 + 1); + int pos2 = str.indexOf(QLatin1Char( '%'), pos1 + 1); if (pos2 == -1) break; res += str.mid(pos, pos1 - pos); @@ -185,9 +187,9 @@ QInstaller::VerboseWriter::~VerboseWriter() if (logFileName.isEmpty()) // binarycreator return; //if the installer installed nothing - there is no target directory - where the logfile can be saved - if (!QFileInfo(logFileName).absoluteDir().exists()) { + if (!QFileInfo(logFileName).absoluteDir().exists()) return; - } + QFile output(logFileName); if (output.open(QIODevice::ReadWrite | QIODevice::Append)) { QString logInfo; @@ -206,14 +208,14 @@ void QInstaller::VerboseWriter::setOutputStream(const QString &fileName) } -Q_GLOBAL_STATIC(QInstaller::VerboseWriter, verboseWriter); +Q_GLOBAL_STATIC(QInstaller::VerboseWriter, verboseWriter) -QInstaller::VerboseWriter* QInstaller::VerboseWriter::instance() +QInstaller::VerboseWriter *QInstaller::VerboseWriter::instance() { return verboseWriter(); } -QInstaller::VerboseWriter& QInstaller::verbose() +QInstaller::VerboseWriter &QInstaller::verbose() { return *verboseWriter(); } diff --git a/installerbuilder/common/utils.h b/installerbuilder/common/utils.h index a479e6f70..898b2b111 100644 --- a/installerbuilder/common/utils.h +++ b/installerbuilder/common/utils.h @@ -40,45 +40,45 @@ QT_BEGIN_NAMESPACE class QIODevice; QT_END_NAMESPACE -namespace QInstaller -{ - QByteArray INSTALLER_EXPORT calculateHash( QIODevice* device, QCryptographicHash::Algorithm algo ); +namespace QInstaller { - QString INSTALLER_EXPORT replaceVariables( const QHash<QString,QString>& vars, const QString &str ); - QString INSTALLER_EXPORT replaceWindowsEnvironmentVariables( const QString &str ); + QByteArray INSTALLER_EXPORT calculateHash(QIODevice *device, QCryptographicHash::Algorithm algo); + + QString INSTALLER_EXPORT replaceVariables(const QHash<QString,QString> &vars, const QString &str); + QString INSTALLER_EXPORT replaceWindowsEnvironmentVariables(const QString &str); QStringList INSTALLER_EXPORT parseCommandLineArgs(int argc, char **argv); #ifdef Q_OS_WIN QString createCommandline(const QString &program, const QStringList &arguments); #endif - void INSTALLER_EXPORT setVerbose( bool v ); + void INSTALLER_EXPORT setVerbose(bool v); bool INSTALLER_EXPORT isVerbose(); INSTALLER_EXPORT std::ostream& stdverbose(); - INSTALLER_EXPORT std::ostream& operator<<( std::ostream& os, const QUrl& url ); - INSTALLER_EXPORT std::ostream& operator<<( std::ostream& os, const QString& string ); - INSTALLER_EXPORT std::ostream& operator<<( std::ostream& os, const QByteArray& array ); - template< typename T > - std::ostream& operator<<( std::ostream& os, const QList< T >& list ) + INSTALLER_EXPORT std::ostream& operator<<(std::ostream &os, const QUrl &url); + INSTALLER_EXPORT std::ostream& operator<<(std::ostream &os, const QString &string); + INSTALLER_EXPORT std::ostream& operator<<(std::ostream &os, const QByteArray &array); + template <typename T> + std::ostream& operator<<(std::ostream &os, const QList<T> &list) { os << "("; - for( typename QList< T >::const_iterator it = list.begin(); it != list.end(); ++it ) + for (typename QList<T>::const_iterator it = list.begin(); it != list.end(); ++it) os << *it; os << ");"; return os; } class VerboseWriter; - INSTALLER_EXPORT VerboseWriter& verbose(); + INSTALLER_EXPORT VerboseWriter &verbose(); class INSTALLER_EXPORT VerboseWriter : public QObject { Q_OBJECT public: - VerboseWriter(QObject* parent = 0); + VerboseWriter(QObject *parent = 0); ~VerboseWriter(); - static VerboseWriter* instance(); + static VerboseWriter *instance(); inline VerboseWriter &operator<<(bool t) { stdverbose() << t; stream << (t ? "true" : "false"); return *this; } inline VerboseWriter &operator<<(int t) { stdverbose() << t; stream << t; return *this; } @@ -92,11 +92,11 @@ namespace QInstaller inline VerboseWriter &operator<<(const QLatin1String &t) { stdverbose() << t; stream << t; return *this; } inline VerboseWriter &operator<<(const char *t) { stdverbose() << t; stream << t; return *this; } inline VerboseWriter &operator<<(const QUrl &t) { return verbose() << t.toString(); } - template< typename T > - VerboseWriter& operator<<(const QList< T >& list ) + template <typename T> + VerboseWriter &operator<<(const QList<T> &list) { verbose() << "List ( "; - for( typename QList< T >::const_iterator it = list.begin(); it != list.end(); ++it ) + for (typename QList< T >::const_iterator it = list.begin(); it != list.end(); ++it) verbose() << *it <<"; "; return verbose() << ");"; } diff --git a/installerbuilder/common/zipjob.cpp b/installerbuilder/common/zipjob.cpp index 0b3018279..97191f623 100644 --- a/installerbuilder/common/zipjob.cpp +++ b/installerbuilder/common/zipjob.cpp @@ -43,49 +43,49 @@ class ZipJob::Private { ZipJob* const q; public: - explicit Private( ZipJob* qq ) : - q( qq ), - outputDevice( 0 ), - process( 0 ) + explicit Private(ZipJob *qq) : + q(qq), + outputDevice(0), + process(0) { } - QIODevice* outputDevice; + QIODevice *outputDevice; QDir workingDir; - QProcess* process; + QProcess *process; QStringList filesToArchive; }; -Q_DECLARE_METATYPE( QProcess::ExitStatus ); +Q_DECLARE_METATYPE(QProcess::ExitStatus) ZipJob::ZipJob() - : QObject(), - QRunnable(), - d( new Private( this ) ) + : d(new Private(this)) { - qRegisterMetaType< QProcess::ExitStatus >(); + qRegisterMetaType<QProcess::ExitStatus>(); } -ZipJob::~ZipJob() { +ZipJob::~ZipJob() +{ delete d; } -void ZipJob::run() { - assert( !d->process ); +void ZipJob::run() +{ + assert(!d->process); d->process = new QProcess; - d->process->setWorkingDirectory( d->workingDir.absolutePath() ); + d->process->setWorkingDirectory(d->workingDir.absolutePath()); QStringList args; args << QLatin1String( "-" ) << QLatin1String( "-r" ) << d->filesToArchive; - connect( d->process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)) ); - connect( d->process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processFinished(int,QProcess::ExitStatus)) ); - connect( d->process, SIGNAL(readyReadStandardOutput()), this, SLOT(processReadyReadStandardOutput()) ); + connect(d->process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError))); + connect(d->process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processFinished(int,QProcess::ExitStatus))); + connect(d->process, SIGNAL(readyReadStandardOutput()), this, SLOT(processReadyReadStandardOutput())); - d->process->start( QLatin1String( "zip" ), args ); - if ( !d->process->waitForStarted() ) { + d->process->start(QLatin1String("zip"), args); + if (!d->process->waitForStarted()) { //TODO handle } - if ( !d->process->waitForFinished( INT_MAX ) ) { + if (!d->process->waitForFinished(INT_MAX)) { //TODO handle } @@ -94,21 +94,24 @@ void ZipJob::run() { // emit result } -void ZipJob::processError( QProcess::ProcessError ) { +void ZipJob::processError(QProcess::ProcessError) +{ emit error(); } -void ZipJob::processFinished( int, QProcess::ExitStatus ) { +void ZipJob::processFinished(int, QProcess::ExitStatus) +{ emit finished(); } -void ZipJob::processReadyReadStandardOutput() { +void ZipJob::processReadyReadStandardOutput() +{ const QByteArray buf = d->process->readAll(); const qint64 toWrite = buf.size(); qint64 written = 0; - while ( written < toWrite ) { - const qint64 num = d->outputDevice->write( buf.constData() + written, toWrite - written ); - if ( num < 0 ) { + while (written < toWrite) { + const qint64 num = d->outputDevice->write(buf.constData() + written, toWrite - written); + if (num < 0) { //TODO: handle error return; } @@ -116,30 +119,33 @@ void ZipJob::processReadyReadStandardOutput() { } } -void ZipJob::setOutputDevice( QIODevice* device ) +void ZipJob::setOutputDevice(QIODevice *device) { d->outputDevice = device; } -void ZipJob::setWorkingDirectory( const QDir& dir ) { +void ZipJob::setWorkingDirectory(const QDir &dir) +{ d->workingDir = dir; } -void ZipJob::setFilesToArchive( const QStringList& files ) { +void ZipJob::setFilesToArchive(const QStringList &files) +{ d->filesToArchive = files; } -class UnzipJob::Private { - UnzipJob* const q; +class UnzipJob::Private +{ + UnzipJob *const q; public: - explicit Private( UnzipJob* qq ) - : q( qq ), - inputDevice( 0 ) + explicit Private(UnzipJob *qq) + : q(qq), + inputDevice(0) { } public: - QIODevice* inputDevice; + QIODevice *inputDevice; QString outputPath; QStringList filesToExtract; }; @@ -147,26 +153,27 @@ public: UnzipJob::UnzipJob() : QObject(), QRunnable(), - d( new Private( this ) ) + d(new Private(this)) { - qRegisterMetaType< QProcess::ExitStatus >(); + qRegisterMetaType<QProcess::ExitStatus>(); } -UnzipJob::~UnzipJob() { +UnzipJob::~UnzipJob() +{ delete d; } -void UnzipJob::setInputDevice( QIODevice* device ) +void UnzipJob::setInputDevice(QIODevice *device) { d->inputDevice = device; } -void UnzipJob::setOutputPath( const QString& path ) +void UnzipJob::setOutputPath(const QString &path) { d->outputPath = path; } -void UnzipJob::processError( QProcess::ProcessError ) +void UnzipJob::processError(QProcess::ProcessError) { emit error(); } @@ -177,40 +184,37 @@ void UnzipJob::run() // TODO: this won't work on Windows... grmpfl, but on Mac and Linux, at least... QStringList args; args << QLatin1String( "/dev/stdin" ); - if( !d->filesToExtract.isEmpty() ) - args << QLatin1String( "-x" ) << d->filesToExtract; - process.setWorkingDirectory( d->outputPath ); - process.start( QLatin1String( "unzip" ), args ); - connect( &process, SIGNAL( error( QProcess::ProcessError ) ), this, SLOT( processError( QProcess::ProcessError ) ) ); - connect( &process, SIGNAL( finished( int, QProcess::ExitStatus ) ), this, SLOT( processFinished( int, QProcess::ExitStatus ) ) ); - if( !process.waitForStarted() ) - { + if (!d->filesToExtract.isEmpty()) + args << QLatin1String("-x") << d->filesToExtract; + process.setWorkingDirectory(d->outputPath); + process.start(QLatin1String("unzip"), args); + connect(&process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError))); + connect(&process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(processFinished(int, QProcess::ExitStatus ))); + if (!process.waitForStarted()) { // TODO handle return; } const int bufferSize = 4096; QByteArray buffer; - while( d->inputDevice->bytesAvailable() > 0 || d->inputDevice->waitForReadyRead( INT_MAX ) ) - { - buffer = d->inputDevice->read( bufferSize ); - process.write( buffer ); - process.waitForBytesWritten( INT_MAX ); + while (d->inputDevice->bytesAvailable() > 0 || d->inputDevice->waitForReadyRead(INT_MAX)) { + buffer = d->inputDevice->read(bufferSize); + process.write(buffer); + process.waitForBytesWritten(INT_MAX); } process.closeWriteChannel(); - if( !process.waitForFinished( INT_MAX ) ) - { + if (!process.waitForFinished(INT_MAX)) { // TODO handle } } -void UnzipJob::processFinished( int, QProcess::ExitStatus ) +void UnzipJob::processFinished(int, QProcess::ExitStatus) { emit finished(); } -void UnzipJob::setFilesToExtract( const QStringList& files ) +void UnzipJob::setFilesToExtract(const QStringList &files) { d->filesToExtract = files; } diff --git a/installerbuilder/common/zipjob.h b/installerbuilder/common/zipjob.h index 77ad833a7..f7241fe1c 100644 --- a/installerbuilder/common/zipjob.h +++ b/installerbuilder/common/zipjob.h @@ -43,49 +43,51 @@ public: ZipJob(); ~ZipJob(); - void setOutputDevice( QIODevice* device ); - void setWorkingDirectory( const QDir& dir ); - void setFilesToArchive( const QStringList& files ); + void setOutputDevice(QIODevice *device); + void setWorkingDirectory(const QDir &dir); + void setFilesToArchive(const QStringList &files); - /* reimp */ void run(); + void run(); Q_SIGNALS: void finished(); void error(); private Q_SLOTS: - void processError( QProcess::ProcessError ); - void processFinished( int, QProcess::ExitStatus ); + void processError(QProcess::ProcessError); + void processFinished(int, QProcess::ExitStatus); void processReadyReadStandardOutput(); private: class Private; - Private* const d; + Private *const d; }; -class UnzipJob : public QObject, public QRunnable { +class UnzipJob : public QObject, public QRunnable +{ Q_OBJECT + public: UnzipJob(); ~UnzipJob(); - void setInputDevice( QIODevice* device ); - void setOutputPath( const QString& path ); - void setFilesToExtract( const QStringList& files ); + void setInputDevice(QIODevice *device); + void setOutputPath(const QString &path); + void setFilesToExtract(const QStringList &files); - /* reimp */ void run(); + void run(); Q_SIGNALS: void finished(); void error(); private Q_SLOTS: - void processError( QProcess::ProcessError ); - void processFinished( int, QProcess::ExitStatus ); + void processError(QProcess::ProcessError); + void processFinished(int, QProcess::ExitStatus); private: class Private; - Private* const d; + Private *const d; }; #endif // ZIPJOB_H diff --git a/installerbuilder/libinstaller/adminauthorization_mac.cpp b/installerbuilder/libinstaller/adminauthorization_mac.cpp index b65cb88a8..4cfbae837 100644 --- a/installerbuilder/libinstaller/adminauthorization_mac.cpp +++ b/installerbuilder/libinstaller/adminauthorization_mac.cpp @@ -46,8 +46,7 @@ class AdminAuthorization::Private { public: - Private() - : auth(0) { } + Private() : auth(0) { } AuthorizationRef auth; }; @@ -99,9 +98,9 @@ bool AdminAuthorization::authorize() return true; } -bool AdminAuthorization::execute(QWidget*, const QString& program, const QStringList& arguments) +bool AdminAuthorization::execute(QWidget *, const QString &program, const QStringList &arguments) { - QVector<char* > args; + QVector<char *> args; QVector<QByteArray> utf8Args; foreach (const QString &argument, arguments) { utf8Args.push_back(argument.toUtf8()); diff --git a/installerbuilder/libinstaller/adminauthorization_win.cpp b/installerbuilder/libinstaller/adminauthorization_win.cpp index a734e78cf..82a1613fa 100644 --- a/installerbuilder/libinstaller/adminauthorization_win.cpp +++ b/installerbuilder/libinstaller/adminauthorization_win.cpp @@ -41,14 +41,6 @@ #include <windows.h> -class AdminAuthorization::Private -{ -public: - Private() - { - } -}; - AdminAuthorization::AdminAuthorization() { } @@ -69,33 +61,33 @@ bool AdminAuthorization::hasAdminRights() SID_IDENTIFIER_AUTHORITY authority = SECURITY_NT_AUTHORITY; PSID adminGroup; // Initialize SID. - if( !AllocateAndInitializeSid( &authority, - 2, - SECURITY_BUILTIN_DOMAIN_RID, - DOMAIN_ALIAS_RID_ADMINS, - 0, 0, 0, 0, 0, 0, - &adminGroup)) + if (!AllocateAndInitializeSid(&authority, + 2, + SECURITY_BUILTIN_DOMAIN_RID, + DOMAIN_ALIAS_RID_ADMINS, + 0, 0, 0, 0, 0, 0, + &adminGroup)) return false; BOOL isInAdminGroup = FALSE; - if( !CheckTokenMembership( 0, adminGroup, &isInAdminGroup )) + if (!CheckTokenMembership(0, adminGroup, &isInAdminGroup)) isInAdminGroup = FALSE; - FreeSid( adminGroup ); + FreeSid(adminGroup); return isInAdminGroup; } -bool AdminAuthorization::execute( QWidget*, const QString& program, const QStringList& arguments ) +bool AdminAuthorization::execute(QWidget *, const QString &program, const QStringList &arguments) { qDebug() << Q_FUNC_INFO; - const QString file = QDir::toNativeSeparators( program ); - const QString args = QInstaller::createCommandline( QString(), arguments ); + const QString file = QDir::toNativeSeparators(program); + const QString args = QInstaller::createCommandline(QString(), arguments); - const int len = GetShortPathNameW( (wchar_t*)file.utf16(), 0, 0 ); - if( len == 0 ) + const int len = GetShortPathNameW((wchar_t *)file.utf16(), 0, 0); + if (len == 0) return false; - wchar_t* const buffer = new wchar_t[ len ]; - GetShortPathName( (wchar_t*)file.utf16(), buffer, len ); + wchar_t *const buffer = new wchar_t[len]; + GetShortPathName((wchar_t *)file.utf16(), buffer, len); SHELLEXECUTEINFOW TempInfo = { 0 }; TempInfo.cbSize = sizeof(SHELLEXECUTEINFOW); @@ -103,13 +95,13 @@ bool AdminAuthorization::execute( QWidget*, const QString& program, const QStrin TempInfo.hwnd = 0; TempInfo.lpVerb = L"runas"; TempInfo.lpFile = buffer; - TempInfo.lpParameters = (wchar_t*)args.utf16(); + TempInfo.lpParameters = (wchar_t *)args.utf16(); TempInfo.lpDirectory = 0; TempInfo.nShow = SW_NORMAL; qDebug() << QLatin1String("\t starting elevated process with ::ShellExecuteExW( &TempInfo );"); - const bool result = ::ShellExecuteExW( &TempInfo ); + const bool result = ::ShellExecuteExW(&TempInfo); qDebug() << QLatin1String("\t after starting elevated process"); delete[] buffer; return result; diff --git a/installerbuilder/libinstaller/adminauthorization_x11.cpp b/installerbuilder/libinstaller/adminauthorization_x11.cpp index 385e41853..3e8d03a18 100644 --- a/installerbuilder/libinstaller/adminauthorization_x11.cpp +++ b/installerbuilder/libinstaller/adminauthorization_x11.cpp @@ -58,11 +58,6 @@ #define SU_COMMAND "/usr/bin/sudo" //#define SU_COMMAND "/bin/echo" -class AdminAuthorization::Private -{ -public: -}; - AdminAuthorization::AdminAuthorization() { } @@ -76,202 +71,185 @@ bool AdminAuthorization::authorize() return true; } -static QString getPassword( QWidget* parent ) +static QString getPassword(QWidget *) { - if( QApplication::type() == QApplication::GuiClient ) - { + if (QApplication::type() == QApplication::GuiClient) { bool ok = false; - const QString result = QInputDialog::getText( 0, QObject::tr( "Authorization required" ), QObject::tr( "Enter your password to authorize for sudo:" ), QLineEdit::Password, QString(), &ok ); + const QString result = QInputDialog::getText(0, QObject::tr( "Authorization required" ), QObject::tr( "Enter your password to authorize for sudo:" ), QLineEdit::Password, QString(), &ok); return ok ? result : QString(); - } - else - { - std::cout << QObject::tr( "Authorization required" ).toStdString() << std::endl; - std::cout << QObject::tr( "Enter your password to authorize for sudo:" ).toStdString() << std::endl; + } else { + std::cout << QObject::tr("Authorization required").toStdString() << std::endl; + std::cout << QObject::tr("Enter your password to authorize for sudo:").toStdString() << std::endl; std::string password; std::cin >> password; - return QString::fromStdString( password ); + return QString::fromStdString(password); } } -static void printError( QWidget* parent, const QString& value ) +static void printError(QWidget *parent, const QString &value) { - if( QApplication::type() == QApplication::GuiClient ) - { - QMessageBox::critical( parent, QObject::tr( "Error acquiring admin rights" ), value, QMessageBox::Ok, QMessageBox::Ok ); - } + if (QApplication::type() == QApplication::GuiClient) + QMessageBox::critical(parent, QObject::tr( "Error acquiring admin rights" ), value, QMessageBox::Ok, QMessageBox::Ok); else - { std::cout << value.toStdString() << std::endl; - } } -bool AdminAuthorization::execute( QWidget* parent, const QString& program, const QStringList& arguments ) +bool AdminAuthorization::execute(QWidget *parent, const QString &program, const QStringList &arguments) { // as we cannot pipe the password to su in QProcess, we need to setup a pseudo-terminal for it int masterFD = -1; int slaveFD = -1; char ptsn[ PATH_MAX ]; - if( ::openpty( &masterFD, &slaveFD, ptsn, 0, 0 ) ) + if (::openpty(&masterFD, &slaveFD, ptsn, 0, 0)) return false; - masterFD = ::posix_openpt( O_RDWR | O_NOCTTY ); - if( masterFD < 0 ) + masterFD = ::posix_openpt(O_RDWR | O_NOCTTY); + if (masterFD < 0) return false; - const QByteArray ttyName = ::ptsname( masterFD ); + const QByteArray ttyName = ::ptsname(masterFD); - if( ::grantpt( masterFD ) ) - { - ::close( masterFD ); + if (::grantpt(masterFD)) { + ::close(masterFD); return false; } - ::revoke( ttyName ); - ::unlockpt( masterFD ); + ::revoke(ttyName); + ::unlockpt(masterFD); - slaveFD = ::open( ttyName, O_RDWR | O_NOCTTY ); - if( slaveFD < 0 ) - { - ::close( masterFD ); + slaveFD = ::open(ttyName, O_RDWR | O_NOCTTY); + if (slaveFD < 0) { + ::close(masterFD); return false; } - ::fcntl( masterFD, F_SETFD, FD_CLOEXEC ); - ::fcntl( slaveFD, F_SETFD, FD_CLOEXEC ); - int pipedData[ 2 ]; - if ( pipe( pipedData ) != 0) + ::fcntl(masterFD, F_SETFD, FD_CLOEXEC); + ::fcntl(slaveFD, F_SETFD, FD_CLOEXEC); + int pipedData[2]; + if (pipe(pipedData) != 0) return false; - int flags = ::fcntl( pipedData[ 0 ], F_GETFD ); - if ( flags != -1 ) - ::fcntl( pipedData[ 0 ], F_SETFL, flags | O_NONBLOCK ); + + int flags = ::fcntl(pipedData[0], F_GETFD); + if (flags != -1) + ::fcntl(pipedData[0], F_SETFL, flags | O_NONBLOCK); pid_t child = fork(); - if( child < -1 ) - { - ::close( masterFD ); - ::close( slaveFD ); - ::close( pipedData[ 0 ]); - ::close( pipedData[ 1 ]); + if (child < -1) { + ::close(masterFD); + ::close(slaveFD); + ::close(pipedData[0]); + ::close(pipedData[1]); return false; } // parent process - else if( child > 0 ) - { - ::close( slaveFD ); + else if (child > 0) { + ::close(slaveFD); //close writing end of pipe - ::close( pipedData[1]); + ::close(pipedData[1]); - QRegExp re( QLatin1String( "[Pp]assword.*:" ) ); + QRegExp re(QLatin1String("[Pp]assword.*:")); QByteArray errData; - flags = ::fcntl( masterFD, F_GETFD ); -// if ( flags != -1 ) -// ::fcntl( masterFD, F_SETFL, flags | O_NONBLOCK ); + flags = ::fcntl(masterFD, F_GETFD); +// if (flags != -1) +// ::fcntl(masterFD, F_SETFL, flags | O_NONBLOCK); int bytes = 0; int errBytes = 0; - char buf[ 1024 ]; - while( bytes >= 0 ) - { + char buf[1024]; + while (bytes >= 0) { int state; - if( ::waitpid( child, &state, WNOHANG ) == -1 ) + if (::waitpid(child, &state, WNOHANG) == -1) break; - bytes = ::read( masterFD, buf, 1023 ); - errBytes = ::read( pipedData[ 0 ], buf, 1023 ); - if ( errBytes > 0 ) - errData.append( buf, errBytes ); - if( bytes > 0 ) - { - const QString line = QString::fromLatin1( buf, bytes ); - if( re.indexIn( line ) != -1 ) - { - const QString password = getPassword( parent ); - if ( password == QString() ) - { + bytes = ::read(masterFD, buf, 1023); + errBytes = ::read(pipedData[0], buf, 1023); + if (errBytes > 0) + errData.append(buf, errBytes); + if (bytes > 0) { + const QString line = QString::fromLatin1(buf, bytes); + if (re.indexIn(line) != -1) { + const QString password = getPassword(parent); + if (password == QString()) { QByteArray pwd = password.toLatin1(); - for ( int i = 0; i < 3; ++i ) - { - ::write( masterFD, pwd.data(), pwd.length() ); - ::write( masterFD, "\n", 1 ); + for (int i = 0; i < 3; ++i) { + ::write(masterFD, pwd.data(), pwd.length()); + ::write(masterFD, "\n", 1); } return false; } QByteArray pwd = password.toLatin1(); - ::write( masterFD, pwd.data(), pwd.length() ); - ::write( masterFD, "\n", 1 ); - ::read( masterFD, buf, pwd.length() + 1 ); + ::write(masterFD, pwd.data(), pwd.length()); + ::write(masterFD, "\n", 1); + ::read(masterFD, buf, pwd.length() + 1); } } - if( bytes == 0 ) - ::usleep( 100000 ); + if (bytes == 0) + ::usleep(100000); } - if ( !errData.isEmpty() ) - { - printError( parent, QString::fromLocal8Bit( errData.constData() ) ); + if (!errData.isEmpty()) { + printError(parent, QString::fromLocal8Bit(errData.constData())); return false; } int status; - child = ::wait( &status ); - const int exited = WIFEXITED( status ); - const int exitStatus = WEXITSTATUS( status ); - ::close( pipedData[1]); - if( exited ) + child = ::wait(&status); + const int exited = WIFEXITED(status); + const int exitStatus = WEXITSTATUS(status); + ::close(pipedData[1]); + if (exited) return exitStatus == 0; return false; } // child process - else - { - ::close( pipedData[ 0 ] ); + else { + ::close(pipedData[0]); // Reset signal handlers - for( int sig = 1; sig < NSIG; ++sig ) - signal( sig, SIG_DFL ); - signal( SIGHUP, SIG_IGN ); + for (int sig = 1; sig < NSIG; ++sig) + signal(sig, SIG_DFL); + signal(SIGHUP, SIG_IGN); ::setsid(); - ::ioctl( slaveFD, TIOCSCTTY, 1 ); + ::ioctl(slaveFD, TIOCSCTTY, 1); int pgrp = ::getpid(); - ::tcsetpgrp( slaveFD, pgrp ); + ::tcsetpgrp(slaveFD, pgrp); - ::dup2( slaveFD, 0 ); - ::dup2( slaveFD, 1 ); - ::dup2( pipedData[ 1 ], 2 ); + ::dup2(slaveFD, 0); + ::dup2(slaveFD, 1); + ::dup2(pipedData[1], 2); // close all file descriptors struct rlimit rlp; - getrlimit( RLIMIT_NOFILE, &rlp ); - for( int i = 3; i < static_cast< int >( rlp.rlim_cur ); ++i ) - ::close( i ); + getrlimit(RLIMIT_NOFILE, &rlp); + for (int i = 3; i < static_cast<int>(rlp.rlim_cur); ++i) + ::close(i); - char** argp = (char**) ::malloc( arguments.count() + 4 * sizeof( char* ) ); - QList< QByteArray > args; - args.push_back( SU_COMMAND ); - args.push_back( "-b" ); - args.push_back( program.toLocal8Bit() ); - for( QStringList::const_iterator it = arguments.begin(); it != arguments.end(); ++it ) - args.push_back( it->toLocal8Bit() ); + char **argp = (char **) ::malloc(arguments.count() + 4 * sizeof(char *)); + QList<QByteArray> args; + args.push_back(SU_COMMAND); + args.push_back("-b"); + args.push_back(program.toLocal8Bit()); + for (QStringList::const_iterator it = arguments.begin(); it != arguments.end(); ++it) + args.push_back(it->toLocal8Bit()); int i = 0; - for( QList< QByteArray >::iterator it = args.begin(); it != args.end(); ++it, ++i ) - argp[ i ] = it->data(); - argp[ i ] = 0; + for (QList<QByteArray>::iterator it = args.begin(); it != args.end(); ++it, ++i) + argp[i] = it->data(); + argp[i] = 0; - ::unsetenv( "LANG" ); - ::unsetenv( "LC_ALL" ); + ::unsetenv("LANG"); + ::unsetenv("LC_ALL"); - ::execv( SU_COMMAND, argp ); - _exit( 0 ); + ::execv(SU_COMMAND, argp); + _exit(0); return false; } } -// has no guarantee to work, its implemented as discussed with Tim Jenssen and Niels Weber +// has no guarantee to work bool AdminAuthorization::hasAdminRights() { return getuid() == 0; diff --git a/installerbuilder/libinstaller/createdesktopentryoperation.cpp b/installerbuilder/libinstaller/createdesktopentryoperation.cpp index 6de8987ab..f07f6db32 100644 --- a/installerbuilder/libinstaller/createdesktopentryoperation.cpp +++ b/installerbuilder/libinstaller/createdesktopentryoperation.cpp @@ -120,7 +120,7 @@ void CreateDesktopEntryOperation::backup() try { setValue(QLatin1String("backupOfExistingDesktopEntry"), generateTemporaryFileName(filename)); - } catch (const QInstaller::Error& e) { + } catch (const QInstaller::Error &e) { setErrorString(e.message()); return; } @@ -132,7 +132,7 @@ void CreateDesktopEntryOperation::backup() bool CreateDesktopEntryOperation::performOperation() { const QStringList args = arguments(); - if(args.count() != 2) { + if (args.count() != 2) { setError(InvalidArguments); setErrorString(tr("Invalid arguments in %0: %1 arguments given, 2 expected.").arg(name()).arg(args .count())); @@ -140,7 +140,7 @@ bool CreateDesktopEntryOperation::performOperation() } const QString filename = absoluteFileName(); - const QString& values = args[1]; + const QString &values = args[1]; if (QFile::exists(filename) && !deleteFileNowOrLater(filename)) { setError(UserDefinedError); @@ -198,7 +198,7 @@ bool CreateDesktopEntryOperation::testOperation() return true; } -Operation* CreateDesktopEntryOperation::clone() const +Operation *CreateDesktopEntryOperation::clone() const { return new CreateDesktopEntryOperation(); } diff --git a/installerbuilder/libinstaller/createshortcutoperation.cpp b/installerbuilder/libinstaller/createshortcutoperation.cpp index c37d74942..4cd221ab8 100644 --- a/installerbuilder/libinstaller/createshortcutoperation.cpp +++ b/installerbuilder/libinstaller/createshortcutoperation.cpp @@ -120,16 +120,16 @@ CreateShortcutOperation::~CreateShortcutOperation() { } -static bool isWorkingDirOption(const QString& s) +static bool isWorkingDirOption(const QString &s) { return s.startsWith(QLatin1String("workingDirectory=")); } -static QString takeWorkingDirArgument(QStringList& args) +static QString takeWorkingDirArgument(QStringList &args) { QString workingDir; // if the args contain an option in the form "workingDirectory=...", find it and consume it - QStringList::iterator wdiropt = std::find_if (args.begin(), args.end(), isWorkingDirOption); + QStringList::iterator wdiropt = std::find_if(args.begin(), args.end(), isWorkingDirOption); if (wdiropt != args.end()) { workingDir = wdiropt->mid(QString::fromLatin1("workingDirectory=").size()); args.erase(wdiropt); diff --git a/installerbuilder/libinstaller/createshortcutoperation.h b/installerbuilder/libinstaller/createshortcutoperation.h index f5bfcbcf9..d505afa68 100644 --- a/installerbuilder/libinstaller/createshortcutoperation.h +++ b/installerbuilder/libinstaller/createshortcutoperation.h @@ -40,7 +40,7 @@ public: bool performOperation(); bool undoOperation(); bool testOperation(); - Operation* clone() const; + Operation *clone() const; }; } diff --git a/installerbuilder/libinstaller/downloadarchivesjob.h b/installerbuilder/libinstaller/downloadarchivesjob.h index c65e3baea..0b4a5dba1 100644 --- a/installerbuilder/libinstaller/downloadarchivesjob.h +++ b/installerbuilder/libinstaller/downloadarchivesjob.h @@ -93,6 +93,6 @@ private: int m_progressChangedTimerId; }; -} // namespace QInstaller +} // namespace QInstaller #endif // DOWNLOADARCHIVESJOB_H diff --git a/installerbuilder/libinstaller/elevatedexecuteoperation.cpp b/installerbuilder/libinstaller/elevatedexecuteoperation.cpp index 2c2bcfcc2..ec5d8179a 100644 --- a/installerbuilder/libinstaller/elevatedexecuteoperation.cpp +++ b/installerbuilder/libinstaller/elevatedexecuteoperation.cpp @@ -87,7 +87,7 @@ bool ElevatedExecuteOperation::performOperation() return false; } QStringList args; - foreach(const QString &argument, arguments()) { + foreach (const QString &argument, arguments()) { if (argument!=QLatin1String("UNDOEXECUTE")) args.append(argument); else diff --git a/installerbuilder/libinstaller/environmentvariablesoperation.cpp b/installerbuilder/libinstaller/environmentvariablesoperation.cpp index aa00bc3df..6dff3f860 100644 --- a/installerbuilder/libinstaller/environmentvariablesoperation.cpp +++ b/installerbuilder/libinstaller/environmentvariablesoperation.cpp @@ -112,10 +112,10 @@ UpdateOperation::Error writeSetting(const QString ®Path, template <typename SettingsType> UpdateOperation::Error undoSetting(const QString ®Path, - const QString &name, - const QString &value, - const QString &oldValue, - QString *errorString) + const QString &name, + const QString &value, + const QString &oldValue, + QString *errorString) { QString actual; { @@ -124,13 +124,11 @@ UpdateOperation::Error undoSetting(const QString ®Path, } if (actual != value) //key changed, don't undo return UpdateOperation::UserDefinedError; - else { - QString dontcare; - return writeSetting<SettingsType>(regPath, name, oldValue, errorString, &dontcare); - } + QString dontcare; + return writeSetting<SettingsType>(regPath, name, oldValue, errorString, &dontcare); } -} +} // namespace bool EnvironmentVariableOperation::performOperation() { @@ -231,7 +229,7 @@ bool EnvironmentVariableOperation::testOperation() return true; } -Operation* EnvironmentVariableOperation::clone() const +Operation *EnvironmentVariableOperation::clone() const { return new EnvironmentVariableOperation(); } diff --git a/installerbuilder/libinstaller/extractarchiveoperation_p.h b/installerbuilder/libinstaller/extractarchiveoperation_p.h index 8cd05947c..5055323c0 100644 --- a/installerbuilder/libinstaller/extractarchiveoperation_p.h +++ b/installerbuilder/libinstaller/extractarchiveoperation_p.h @@ -87,9 +87,7 @@ public: bool createBackups; QVector<QPair<QString, QString> > backupFiles; - explicit Callback() - : state(S_OK), - createBackups(true) {} + Callback() : state(S_OK), createBackups(true) {} Q_SIGNALS: void progressChanged(const QString &filename); diff --git a/installerbuilder/libinstaller/fakestopprocessforupdateoperation.cpp b/installerbuilder/libinstaller/fakestopprocessforupdateoperation.cpp index 9d486819a..508604dbc 100644 --- a/installerbuilder/libinstaller/fakestopprocessforupdateoperation.cpp +++ b/installerbuilder/libinstaller/fakestopprocessforupdateoperation.cpp @@ -41,25 +41,25 @@ Copied from QInstaller with some adjustments Return true, if a process with \a name is running. On Windows, the comparision is case-insensitive. */ -static bool isProcessRunning(const QString& name, const QList< KDSysInfo::ProcessInfo > &processes) +static bool isProcessRunning(const QString &name, const QList<KDSysInfo::ProcessInfo> &processes) { - for(QList< KDSysInfo::ProcessInfo >::const_iterator it = processes.constBegin(); it != processes.constEnd(); ++it) { + for (QList<KDSysInfo::ProcessInfo>::const_iterator it = processes.constBegin(); it != processes.constEnd(); ++it) { if (it->name.isEmpty()) continue; #ifndef Q_WS_WIN - if(it->name == name) + if (it->name == name) return true; const QFileInfo fi(it->name); - if(fi.fileName() == name || fi.baseName() == name) + if (fi.fileName() == name || fi.baseName() == name) return true; #else - if(it->name.toLower() == name.toLower()) + if (it->name.toLower() == name.toLower()) return true; - if(it->name.toLower() == QDir::toNativeSeparators(name.toLower())) + if (it->name.toLower() == QDir::toNativeSeparators(name.toLower())) return true; const QFileInfo fi(it->name); - if(fi.fileName().toLower() == name.toLower() || fi.baseName().toLower() == name.toLower()) + if (fi.fileName().toLower() == name.toLower() || fi.baseName().toLower() == name.toLower()) return true; #endif } @@ -68,9 +68,9 @@ static bool isProcessRunning(const QString& name, const QList< KDSysInfo::Proces static QStringList checkRunningProcessesFromList(const QStringList &processList) { - const QList< KDSysInfo::ProcessInfo > allProcesses = KDSysInfo::runningProcesses(); + const QList<KDSysInfo::ProcessInfo> allProcesses = KDSysInfo::runningProcesses(); QStringList stillRunningProcesses; - foreach (const QString process, processList) { + foreach (const QString &process, processList) { if (!process.isEmpty() && isProcessRunning(process, allProcesses)) stillRunningProcesses.append(process); } @@ -86,12 +86,10 @@ FakeStopProcessForUpdateOperation::FakeStopProcessForUpdateOperation() FakeStopProcessForUpdateOperation::~FakeStopProcessForUpdateOperation() { - } void FakeStopProcessForUpdateOperation::backup() { - } bool FakeStopProcessForUpdateOperation::performOperation() @@ -127,7 +125,7 @@ bool FakeStopProcessForUpdateOperation::testOperation() return true; } -Operation* FakeStopProcessForUpdateOperation::clone() const +Operation *FakeStopProcessForUpdateOperation::clone() const { return new FakeStopProcessForUpdateOperation(); } diff --git a/installerbuilder/libinstaller/fsengineclient.cpp b/installerbuilder/libinstaller/fsengineclient.cpp index bb7b19108..215959172 100644 --- a/installerbuilder/libinstaller/fsengineclient.cpp +++ b/installerbuilder/libinstaller/fsengineclient.cpp @@ -84,7 +84,7 @@ public: ~FSEngineClient(); bool atEnd() const; - Iterator* beginEntryList(QDir::Filters filters, const QStringList &filterNames); + Iterator *beginEntryList(QDir::Filters filters, const QStringList &filterNames); bool caseSensitive() const; bool close(); bool copy(const QString &newName); @@ -124,7 +124,7 @@ private: private: friend class FSEngineClientHandler; - mutable QTcpSocket* socket; + mutable QTcpSocket *socket; mutable QDataStream stream; }; @@ -297,7 +297,7 @@ QString FSEngineClient::errorString() const /*! \reimp */ -bool FSEngineClient::extension(Extension extension, const ExtensionOption* option, ExtensionReturn* output) +bool FSEngineClient::extension(Extension extension, const ExtensionOption *option, ExtensionReturn *output) { Q_UNUSED(extension) Q_UNUSED(option) @@ -424,7 +424,7 @@ qint64 FSEngineClient::pos() const /*! \reimp */ -qint64 FSEngineClient::read(char* data, qint64 maxlen) +qint64 FSEngineClient::read(char *data, qint64 maxlen) { stream << QString::fromLatin1("QFSFileEngine::read"); stream << maxlen; @@ -447,7 +447,7 @@ qint64 FSEngineClient::read(char* data, qint64 maxlen) /*! \reimp */ -qint64 FSEngineClient::readLine(char* data, qint64 maxlen) +qint64 FSEngineClient::readLine(char *data, qint64 maxlen) { stream << QString::fromLatin1("QFSFileEngine::readLine"); stream << maxlen; @@ -564,7 +564,7 @@ bool FSEngineClient::supportsExtension(Extension extension) const /*! \reimp */ -qint64 FSEngineClient::write(const char* data, qint64 len) +qint64 FSEngineClient::write(const char *data, qint64 len) { stream << QString::fromLatin1("QFSFileEngine::write"); stream << len; @@ -606,7 +606,7 @@ public: QStringList serverArguments; QString key; - StillAliveThread* const thread; + StillAliveThread *const thread; }; /*! @@ -626,7 +626,7 @@ void FSEngineClientHandler::enableTestMode() d->serverStarted = true; } -void FSEngineClientHandler::init(quint16 port, const QHostAddress& a) +void FSEngineClientHandler::init(quint16 port, const QHostAddress &a) { d->address = a; d->port = port; @@ -667,7 +667,7 @@ FSEngineClientHandler::~FSEngineClientHandler() /*! Returns a previously created FSEngineClientHandler instance. */ -FSEngineClientHandler& FSEngineClientHandler::instance() +FSEngineClientHandler &FSEngineClientHandler::instance() { static FSEngineClientHandler instance; return instance; @@ -722,7 +722,7 @@ QAbstractFileEngine* FSEngineClientHandler::create(const QString &fileName) cons if (fileName.isEmpty() || fileName.startsWith(QLatin1String(":"))) return 0; // empty filename or Qt resource - FSEngineClient* const client = new FSEngineClient; + FSEngineClient *const client = new FSEngineClient; // authorize client->stream << QString::fromLatin1("authorize"); client->stream << d->key; diff --git a/installerbuilder/libinstaller/fsengineserver.cpp b/installerbuilder/libinstaller/fsengineserver.cpp index 3a81b11ef..04d275369 100644 --- a/installerbuilder/libinstaller/fsengineserver.cpp +++ b/installerbuilder/libinstaller/fsengineserver.cpp @@ -49,19 +49,19 @@ typedef int descriptor_t; # include <windows.h> #endif -bool startDetached(const QString &program, const QStringList& args, const QString &workingDirectory, - qint64* pid) +bool startDetached(const QString &program, const QStringList &args, const QString &workingDirectory, + qint64 *pid) { #ifdef Q_WS_WIN 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), + 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 }; const QString arguments = QInstaller::createCommandline(program, args); - const bool success = CreateProcess(0, const_cast<wchar_t*> (static_cast<const wchar_t*>(arguments.utf16())), + const bool success = CreateProcess(0, const_cast<wchar_t *>(static_cast<const wchar_t *>(arguments.utf16())), 0, 0, FALSE, CREATE_UNICODE_ENVIRONMENT | CREATE_NEW_CONSOLE, 0, (wchar_t*)workingDirectory.utf16(), &startupInfo, &pinfo); @@ -83,7 +83,7 @@ class QProcessSignalReceiver : public QObject { Q_OBJECT public: - QProcessSignalReceiver(QObject* parent = 0) + QProcessSignalReceiver(QObject *parent = 0) : QObject(parent) { connect(parent, SIGNAL(finished(int, QProcess::ExitStatus)), this, @@ -140,7 +140,7 @@ private: QFSFileEngine engine; const descriptor_t descriptor; QDataStream receivedStream; - QSettings* settings; + QSettings *settings; QProcess *process; QProcessSignalReceiver *signalReceiver; @@ -168,7 +168,7 @@ FSEngineServer::FSEngineServer(const QHostAddress &address, quint16 port, QObjec */ FSEngineServer::~FSEngineServer() { - const QList<QThread*> threads = findChildren<QThread*>(); + const QList<QThread *> threads = findChildren<QThread *>(); foreach (QThread *thread, threads) thread->wait(); } @@ -179,7 +179,7 @@ FSEngineServer::~FSEngineServer() void FSEngineServer::incomingConnection(int socketDescriptor) { qApp->processEvents(); - QThread* const thread = new FSEngineConnectionThread(socketDescriptor, this); + QThread *const thread = new FSEngineConnectionThread(socketDescriptor, this); connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); thread->start(); watchdog.resetTimeoutTimer(); @@ -233,7 +233,7 @@ void QProcessSignalReceiver::processReadyRead() void QProcessSignalReceiver::processStateChanged(QProcess::ProcessState newState) { receivedSignals.push_back(QLatin1String("stateChanged")); - receivedSignals.push_back(static_cast<int> (newState)); + receivedSignals.push_back(static_cast<int>(newState)); } /*! @@ -285,9 +285,9 @@ void FSEngineConnectionThread::run() } } -static QDataStream& operator<<(QDataStream& stream, const QSettings::Status& status) +static QDataStream &operator<<(QDataStream &stream, const QSettings::Status &status) { - return stream << static_cast<int> (status); + return stream << static_cast<int>(status); } /*! diff --git a/installerbuilder/libinstaller/getrepositoriesmetainfojob.cpp b/installerbuilder/libinstaller/getrepositoriesmetainfojob.cpp index 88793bf0c..974ace1ff 100644 --- a/installerbuilder/libinstaller/getrepositoriesmetainfojob.cpp +++ b/installerbuilder/libinstaller/getrepositoriesmetainfojob.cpp @@ -159,9 +159,9 @@ void GetRepositoriesMetaInfoJob::fetchNextRepo() m_job->start(); } -void GetRepositoriesMetaInfoJob::jobFinished(KDJob* j) +void GetRepositoriesMetaInfoJob::jobFinished(KDJob *j) { - const GetRepositoryMetaInfoJob *const job = qobject_cast<const GetRepositoryMetaInfoJob*>(j); + const GetRepositoryMetaInfoJob *const job = qobject_cast<const GetRepositoryMetaInfoJob *>(j); Q_ASSERT(job); if (job->error() != KDJob::NoError && !job->temporaryDirectory().isEmpty()) { @@ -172,7 +172,7 @@ void GetRepositoriesMetaInfoJob::jobFinished(KDJob* j) } if (job->error() == KDJob::Canceled - || job->error() >= KDJob::UserDefinedError && job->error() < QInstaller::UserIgnoreError) { + || (job->error() >= KDJob::UserDefinedError && job->error() < QInstaller::UserIgnoreError)) { emit infoMessage(j, job->errorString()); verbose() << job->errorString() << std::endl; emitFinishedWithError(job->error(), job->errorString()); diff --git a/installerbuilder/libinstaller/globalsettingsoperation.cpp b/installerbuilder/libinstaller/globalsettingsoperation.cpp index 163de80a1..58e939538 100644 --- a/installerbuilder/libinstaller/globalsettingsoperation.cpp +++ b/installerbuilder/libinstaller/globalsettingsoperation.cpp @@ -100,12 +100,12 @@ bool GlobalSettingsOperation::testOperation() return true; } -Operation* GlobalSettingsOperation::clone() const +Operation *GlobalSettingsOperation::clone() const { return new GlobalSettingsOperation(); } -QSettingsWrapper* GlobalSettingsOperation::setup(QString *key, QString *value, const QStringList &arguments) +QSettingsWrapper *GlobalSettingsOperation::setup(QString *key, QString *value, const QStringList &arguments) { if (arguments.count() == 4) { const QString &company = arguments.at(0); diff --git a/installerbuilder/libinstaller/globalsettingsoperation.h b/installerbuilder/libinstaller/globalsettingsoperation.h index 051d50cba..db1ea7537 100644 --- a/installerbuilder/libinstaller/globalsettingsoperation.h +++ b/installerbuilder/libinstaller/globalsettingsoperation.h @@ -42,12 +42,12 @@ public: bool performOperation(); bool undoOperation(); bool testOperation(); - Operation* clone() const; + Operation *clone() const; private: - QSettingsWrapper* setup(QString *key, QString *value, const QStringList &args); + QSettingsWrapper *setup(QString *key, QString *value, const QStringList &args); }; -} // namespace +} // namespace QInstaller #endif // GLOBALSETTINGSOPERATION_H diff --git a/installerbuilder/libinstaller/init.cpp b/installerbuilder/libinstaller/init.cpp index bce1fd2ac..89c36cfdd 100644 --- a/installerbuilder/libinstaller/init.cpp +++ b/installerbuilder/libinstaller/init.cpp @@ -84,16 +84,16 @@ #include <unix/C/7zCrc.h> -namespace NArchive -{ -namespace NBz2{void registerArcBZip2();} -namespace NGz{void registerArcGZip();} -namespace NLzma{ namespace NLzmaAr { void registerArcLzma();}} -namespace NLzma{ namespace NLzma86Ar { void registerArcLzma86();}} -namespace NSplit{void registerArcSplit();} -namespace NXz{void registerArcxz();} -namespace NZ{void registerArcZ();} +namespace NArchive { +namespace NBz2 { void registerArcBZip2(); } +namespace NGz { void registerArcGZip(); } +namespace NLzma { namespace NLzmaAr { void registerArcLzma(); } } +namespace NLzma { namespace NLzma86Ar { void registerArcLzma86(); } } +namespace NSplit { void registerArcSplit(); } +namespace NXz { void registerArcxz(); } +namespace NZ {void registerArcZ(); } } + void registerArc7z(); void registerArcCab(); void registerArcTar(); @@ -148,14 +148,14 @@ static void initArchives() static void initResources() { - Q_INIT_RESOURCE( openssl ); - Q_INIT_RESOURCE( patch_file_lists ); + Q_INIT_RESOURCE(openssl); + Q_INIT_RESOURCE(patch_file_lists); #if defined(USE_STATIC_SQLITE_PLUGIN) - Q_IMPORT_PLUGIN( qsqlite ); //RegisterDocumentationOperation needs this + Q_IMPORT_PLUGIN(qsqlite); // RegisterDocumentationOperation needs this #endif } -static void messageHandler( QtMsgType type, const char* msg ) +static void messageHandler(QtMsgType type, const char *msg) { QInstaller::verbose() << msg << std::endl; if (type != QtFatalMsg && QString::fromLatin1(msg).contains(QLatin1String("Object::connect: "))) { @@ -166,45 +166,45 @@ static void messageHandler( QtMsgType type, const char* msg ) void QInstaller::init() { ::initResources(); - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::CreateShortcutOperation >( QLatin1String( "CreateShortcut" ) ); - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::CreateDesktopEntryOperation >( QLatin1String( "CreateDesktopEntry" ) ); - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::ExtractArchiveOperation >( QLatin1String( "Extract" ) ); - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::GlobalSettingsOperation >( QLatin1String( "GlobalConfig" ) ); - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::EnvironmentVariableOperation >( QLatin1String( "EnvironmentVariable" ) ); - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::RegisterFileTypeOperation >( QLatin1String( "RegisterFileType" ) ); - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::SelfRestartOperation >( QLatin1String( "SelfRestart" ) ); - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::InstallIconsOperation >( QLatin1String( "InstallIcons" ) ); - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::ElevatedExecuteOperation >( QLatin1String( "Execute" ) ); - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::FakeStopProcessForUpdateOperation >( QLatin1String( "FakeStopProcessForUpdate" ) ); - - //added for NDK - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::SimpleMoveFileOperation >( QLatin1String( "SimpleMoveFile") ); - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::CopyDirectoryOperation >( QLatin1String( "CopyDirectory") ); - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::RegisterDocumentationOperation >( QLatin1String( "RegisterDocumentation") ); - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::RegisterQtInCreatorOperation>( QLatin1String( "RegisterQtInCreator") ); - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::RegisterQtInCreatorV2Operation>( QLatin1String( "RegisterQtInCreatorV2") ); - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::RegisterQtInCreatorV23Operation>( QLatin1String( "RegisterQtInCreatorV23") ); - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::RegisterToolChainOperation>( QLatin1String( "RegisterToolChain") ); - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::RegisterDefaultDebuggerOperation>( QLatin1String( "RegisterDefaultDebugger") ); - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::SetDemosPathOnQtOperation>( QLatin1String( "SetDemosPathOnQt") ); - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::SetExamplesPathOnQtOperation>( QLatin1String( "SetExamplesPathOnQt") ); - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::SetPluginPathOnQtCoreOperation>( QLatin1String( "SetPluginPathOnQtCore") ); - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::SetImportsPathOnQtCoreOperation>( QLatin1String( "SetImportsPathOnQtCore") ); - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::SetPathOnQtCoreOperation>( QLatin1String( "SetPathOnQtCore") ); - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::SetQtCreatorValueOperation>( QLatin1String( "SetQtCreatorValue") ); - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::AddQtCreatorArrayValueOperation>( QLatin1String( "AddQtCreatorArrayValue") ); - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::QtPatchOperation >( QLatin1String( "QtPatch" ) ); - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::ReplaceOperation >( QLatin1String( "Replace" ) ); - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::LineReplaceOperation >( QLatin1String( "LineReplace" ) ); - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::UpdateCreatorSettingsFrom21To22Operation >( QLatin1String( "UpdateCreatorSettingsFrom21To22" ) ); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::CreateShortcutOperation>(QLatin1String("CreateShortcut")); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::CreateDesktopEntryOperation>(QLatin1String("CreateDesktopEntry")); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::ExtractArchiveOperation>(QLatin1String("Extract")); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::GlobalSettingsOperation>(QLatin1String("GlobalConfig")); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::EnvironmentVariableOperation>(QLatin1String( "EnvironmentVariable")); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::RegisterFileTypeOperation>(QLatin1String("RegisterFileType")); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::SelfRestartOperation>(QLatin1String("SelfRestart")); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::InstallIconsOperation>(QLatin1String("InstallIcons")); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::ElevatedExecuteOperation>(QLatin1String("Execute")); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::FakeStopProcessForUpdateOperation>(QLatin1String("FakeStopProcessForUpdate")); + + // added for NDK + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::SimpleMoveFileOperation>(QLatin1String("SimpleMoveFile")); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::CopyDirectoryOperation>(QLatin1String("CopyDirectory")); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::RegisterDocumentationOperation>(QLatin1String("RegisterDocumentation")); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::RegisterQtInCreatorOperation>(QLatin1String("RegisterQtInCreator")); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::RegisterQtInCreatorV2Operation>(QLatin1String("RegisterQtInCreatorV2")); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::RegisterQtInCreatorV23Operation>(QLatin1String("RegisterQtInCreatorV23")); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::RegisterToolChainOperation>(QLatin1String("RegisterToolChain") ); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::RegisterDefaultDebuggerOperation>(QLatin1String( "RegisterDefaultDebugger")); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::SetDemosPathOnQtOperation>(QLatin1String("SetDemosPathOnQt")); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::SetExamplesPathOnQtOperation>(QLatin1String("SetExamplesPathOnQt")); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::SetPluginPathOnQtCoreOperation>(QLatin1String("SetPluginPathOnQtCore")); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::SetImportsPathOnQtCoreOperation>(QLatin1String("SetImportsPathOnQtCore")); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::SetPathOnQtCoreOperation>(QLatin1String("SetPathOnQtCore")); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::SetQtCreatorValueOperation>(QLatin1String("SetQtCreatorValue")); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::AddQtCreatorArrayValueOperation>(QLatin1String("AddQtCreatorArrayValue")); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::QtPatchOperation>(QLatin1String("QtPatch")); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::ReplaceOperation>(QLatin1String("Replace")); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::LineReplaceOperation>(QLatin1String( "LineReplace" ) ); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::UpdateCreatorSettingsFrom21To22Operation>(QLatin1String("UpdateCreatorSettingsFrom21To22")); KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::MinimumProgressOperation>(QLatin1String("MinimumProgress")); KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation<QInstaller::LicenseOperation>(QLatin1String("License")); - KDUpdater::FileDownloaderFactory::setFollowRedirects( true ); + KDUpdater::FileDownloaderFactory::setFollowRedirects(true); #ifdef Q_OS_MAC - KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::MacReplaceInstallNamesOperation >( QLatin1String( "ReplaceInstallNames" ) ); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::MacReplaceInstallNamesOperation>(QLatin1String("ReplaceInstallNames")); #endif // Q_OS_MAC // load 7z stuff, if we're a static lib @@ -214,5 +214,5 @@ void QInstaller::init() //QNetworkProxyFactory::setUseSystemConfiguration( true ); // qDebug -> verbose() - qInstallMsgHandler( messageHandler ); + qInstallMsgHandler(messageHandler); } diff --git a/installerbuilder/libinstaller/lazyplaintextedit.cpp b/installerbuilder/libinstaller/lazyplaintextedit.cpp index 51ed080a0..c8bd383d2 100644 --- a/installerbuilder/libinstaller/lazyplaintextedit.cpp +++ b/installerbuilder/libinstaller/lazyplaintextedit.cpp @@ -77,7 +77,7 @@ void LazyPlainTextEdit::clear() } -void LazyPlainTextEdit::setVisible ( bool visible ) +void LazyPlainTextEdit::setVisible(bool visible) { if (m_timerId) { killTimer(m_timerId); diff --git a/installerbuilder/libinstaller/licenseoperation.cpp b/installerbuilder/libinstaller/licenseoperation.cpp index a7b6e2e1a..637213114 100644 --- a/installerbuilder/libinstaller/licenseoperation.cpp +++ b/installerbuilder/libinstaller/licenseoperation.cpp @@ -117,7 +117,7 @@ bool LicenseOperation::testOperation() return true; } -Operation* LicenseOperation::clone() const +Operation *LicenseOperation::clone() const { return new LicenseOperation(); } diff --git a/installerbuilder/libinstaller/macreplaceinstallnamesoperation.cpp b/installerbuilder/libinstaller/macreplaceinstallnamesoperation.cpp index 42a2a47f6..ad8342b4a 100644 --- a/installerbuilder/libinstaller/macreplaceinstallnamesoperation.cpp +++ b/installerbuilder/libinstaller/macreplaceinstallnamesoperation.cpp @@ -90,7 +90,7 @@ bool MacReplaceInstallNamesOperation::testOperation() return true; } -Operation* MacReplaceInstallNamesOperation::clone() const +Operation *MacReplaceInstallNamesOperation::clone() const { return new MacReplaceInstallNamesOperation; } @@ -98,8 +98,8 @@ Operation* MacReplaceInstallNamesOperation::clone() const bool MacReplaceInstallNamesOperation::apply(const QString &indicator, const QString &installationDir, const QString &searchDir) { - mIndicator = indicator; - mInstallationDir = installationDir; + m_indicator = indicator; + m_installationDir = installationDir; QStringList alreadyPatchedFrameworks; QLatin1String frameworkSuffix(".framework"); @@ -135,7 +135,7 @@ bool MacReplaceInstallNamesOperation::apply(const QString &indicator, const QStr return error() == NoError; } -void MacReplaceInstallNamesOperation::extractExecutableInfo(const QString &fileName, QString& frameworkId, +void MacReplaceInstallNamesOperation::extractExecutableInfo(const QString &fileName, QString &frameworkId, QStringList &frameworks, QString &originalBuildDir) { verbose() << "Relocator calling otool -l for " << fileName << std::endl; @@ -182,7 +182,7 @@ void MacReplaceInstallNamesOperation::extractExecutableInfo(const QString &fileN frameworkId = line; originalBuildDir = frameworkId; - idx = originalBuildDir.indexOf(mIndicator); + idx = originalBuildDir.indexOf(m_indicator); if (idx < 0) { originalBuildDir.clear(); } else { @@ -208,7 +208,7 @@ void MacReplaceInstallNamesOperation::relocateBinary(const QString &fileName) << originalBuildDir << std::endl; QStringList args; - if (frameworkId.contains(mIndicator) || QFileInfo(frameworkId).fileName() == frameworkId) { + if (frameworkId.contains(m_indicator) || QFileInfo(frameworkId).fileName() == frameworkId) { args << QLatin1String("-id") << fileName << fileName; if (!execCommand(QLatin1String("install_name_tool"), args)) return; @@ -216,13 +216,13 @@ void MacReplaceInstallNamesOperation::relocateBinary(const QString &fileName) foreach (const QString &fw, frameworks) { - if (originalBuildDir.isEmpty() && fw.contains(mIndicator)) { - originalBuildDir = fw.left(fw.indexOf(mIndicator)); + if (originalBuildDir.isEmpty() && fw.contains(m_indicator)) { + originalBuildDir = fw.left(fw.indexOf(m_indicator)); } if (originalBuildDir.isEmpty() || !fw.contains(originalBuildDir)) continue; QString newPath = fw; - newPath.replace(originalBuildDir, mInstallationDir); + newPath.replace(originalBuildDir, m_installationDir); args.clear(); args << QLatin1String("-change") << fw << newPath << fileName; diff --git a/installerbuilder/libinstaller/macreplaceinstallnamesoperation.h b/installerbuilder/libinstaller/macreplaceinstallnamesoperation.h index 6fc271043..f88f66b34 100644 --- a/installerbuilder/libinstaller/macreplaceinstallnamesoperation.h +++ b/installerbuilder/libinstaller/macreplaceinstallnamesoperation.h @@ -51,8 +51,8 @@ private: bool execCommand(const QString &cmd, const QStringList &args); private: - QString mIndicator; - QString mInstallationDir; + QString m_indicator; + QString m_installationDir; }; } // namespace QInstaller diff --git a/installerbuilder/libinstaller/messageboxhandler.cpp b/installerbuilder/libinstaller/messageboxhandler.cpp index 5f7d02b10..260b20398 100644 --- a/installerbuilder/libinstaller/messageboxhandler.cpp +++ b/installerbuilder/libinstaller/messageboxhandler.cpp @@ -124,14 +124,14 @@ MessageBoxHandler::~MessageBoxHandler() { } -MessageBoxHandler* MessageBoxHandler::instance() +MessageBoxHandler *MessageBoxHandler::instance() { if (m_instance == 0) m_instance = new MessageBoxHandler(qApp); return m_instance; } -QWidget* MessageBoxHandler::currentBestSuitParent() +QWidget *MessageBoxHandler::currentBestSuitParent() { if (QApplication::type() == QApplication::Tty) { Q_ASSERT_X(false, Q_FUNC_INFO, "We can't find a parent widget if we are a console application."); @@ -173,28 +173,28 @@ void MessageBoxHandler::setAutomaticAnswer(const QString &identifier, QMessageBo // -- static -QMessageBox::StandardButton MessageBoxHandler::critical(QWidget* parent, const QString &identifier, +QMessageBox::StandardButton MessageBoxHandler::critical(QWidget *parent, const QString &identifier, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton button) { return instance()->showMessageBox(criticalType, parent, identifier, title, text, buttons, button); } -QMessageBox::StandardButton MessageBoxHandler::information(QWidget* parent, const QString &identifier, +QMessageBox::StandardButton MessageBoxHandler::information(QWidget *parent, const QString &identifier, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton button) { return instance()->showMessageBox(informationType, parent, identifier, title, text, buttons, button); } -QMessageBox::StandardButton MessageBoxHandler::question(QWidget* parent, const QString &identifier, +QMessageBox::StandardButton MessageBoxHandler::question(QWidget *parent, const QString &identifier, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton button) { return instance()->showMessageBox(questionType, parent, identifier, title, text, buttons, button); } -QMessageBox::StandardButton MessageBoxHandler::warning(QWidget* parent, const QString &identifier, +QMessageBox::StandardButton MessageBoxHandler::warning(QWidget *parent, const QString &identifier, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton button) { @@ -247,7 +247,7 @@ static QMessageBox::StandardButton showNewMessageBox(QWidget *parent, QMessageBo QMessageBox::StandardButton defaultButton) { QMessageBox msgBox(icon, title, text, QMessageBox::NoButton, parent); - QDialogButtonBox *buttonBox = msgBox.findChild<QDialogButtonBox*>(); + QDialogButtonBox *buttonBox = msgBox.findChild<QDialogButtonBox *>(); Q_ASSERT(buttonBox != 0); uint mask = QMessageBox::FirstButton; diff --git a/installerbuilder/libinstaller/minimumprogressoperation.h b/installerbuilder/libinstaller/minimumprogressoperation.h index e2290651e..2bbf73b15 100644 --- a/installerbuilder/libinstaller/minimumprogressoperation.h +++ b/installerbuilder/libinstaller/minimumprogressoperation.h @@ -44,12 +44,12 @@ public: bool performOperation(); bool undoOperation(); bool testOperation(); - Operation* clone() const; + Operation *clone() const; signals: void progressChanged(double progress); }; -} // namespace +} // namespace QInstaller #endif // MINIMUMPROGRESSOPERATION_H diff --git a/installerbuilder/libinstaller/operationrunner.cpp b/installerbuilder/libinstaller/operationrunner.cpp index ade5e31d3..68abf55be 100644 --- a/installerbuilder/libinstaller/operationrunner.cpp +++ b/installerbuilder/libinstaller/operationrunner.cpp @@ -124,9 +124,9 @@ int OperationRunner::runOperation(const QStringList &arguments) } OutputHandler myOutPutHandler; - QObject* const operationObject = dynamic_cast<QObject*>(operation); + QObject *const operationObject = dynamic_cast<QObject *>(operation); if (operationObject != 0) { - const QMetaObject* const mo = operationObject->metaObject(); + const QMetaObject *const mo = operationObject->metaObject(); if (mo->indexOfSignal(QMetaObject::normalizedSignature("outputTextChanged(QString)")) > -1) { QObject::connect(operationObject, SIGNAL(outputTextChanged(QString)), &myOutPutHandler, SLOT(drawItToCommandLine(QString))); diff --git a/installerbuilder/libinstaller/operationrunner.h b/installerbuilder/libinstaller/operationrunner.h index c92614e77..5ee646ae9 100644 --- a/installerbuilder/libinstaller/operationrunner.h +++ b/installerbuilder/libinstaller/operationrunner.h @@ -48,6 +48,6 @@ private: PackageManagerCore *m_core; }; -} // namespace QInstaller +} // namespace QInstaller #endif diff --git a/installerbuilder/libinstaller/packagemanagercore.cpp b/installerbuilder/libinstaller/packagemanagercore.cpp index d0ca2f0b2..64431e631 100644 --- a/installerbuilder/libinstaller/packagemanagercore.cpp +++ b/installerbuilder/libinstaller/packagemanagercore.cpp @@ -69,7 +69,7 @@ static QFont sVirtualComponentsFont; static bool sNoForceInstallation = false; static bool sVirtualComponentsVisible = false; -static QScriptValue checkArguments(QScriptContext* context, int amin, int amax) +static QScriptValue checkArguments(QScriptContext *context, int amin, int amax) { if (context->argumentCount() < amin || context->argumentCount() > amax) { if (amin != amax) { @@ -96,7 +96,7 @@ static bool componentMatches(const Component *component, const QString &name, return PackageManagerCore::versionMatches(component->value(scVersion), version); } -Component* PackageManagerCore::subComponentByName(const QInstaller::PackageManagerCore *installer, +Component *PackageManagerCore::subComponentByName(const QInstaller::PackageManagerCore *installer, const QString &name, const QString &version, Component *check) { if (name.isEmpty()) @@ -112,8 +112,8 @@ Component* PackageManagerCore::subComponentByName(const QInstaller::PackageManag else rootComponents = check->childComponents(false, AllMode); - foreach (QInstaller::Component* component, rootComponents) { - Component* const result = subComponentByName(installer, name, version, component); + foreach (QInstaller::Component *component, rootComponents) { + Component *const result = subComponentByName(installer, name, version, component); if (result != 0) return result; } @@ -132,7 +132,7 @@ Component* PackageManagerCore::subComponentByName(const QInstaller::PackageManag Scriptable version of PackageManagerCore::componentByName(QString). \sa PackageManagerCore::componentByName */ -QScriptValue QInstaller::qInstallerComponentByName(QScriptContext* context, QScriptEngine* engine) +QScriptValue QInstaller::qInstallerComponentByName(QScriptContext *context, QScriptEngine *engine) { const QScriptValue check = checkArguments(context, 1, 1); if (check.isError()) @@ -146,7 +146,7 @@ QScriptValue QInstaller::qInstallerComponentByName(QScriptContext* context, QScr return engine->newQObject(core->componentByName(name)); } -QScriptValue QInstaller::qDesktopServicesOpenUrl(QScriptContext* context, QScriptEngine* engine) +QScriptValue QInstaller::qDesktopServicesOpenUrl(QScriptContext *context, QScriptEngine *engine) { Q_UNUSED(engine); const QScriptValue check = checkArguments(context, 1, 1); @@ -158,7 +158,7 @@ QScriptValue QInstaller::qDesktopServicesOpenUrl(QScriptContext* context, QScrip return QDesktopServices::openUrl(QUrl::fromUserInput(url)); } -QScriptValue QInstaller::qDesktopServicesDisplayName(QScriptContext* context, QScriptEngine* engine) +QScriptValue QInstaller::qDesktopServicesDisplayName(QScriptContext *context, QScriptEngine *engine) { Q_UNUSED(engine); const QScriptValue check = checkArguments(context, 1, 1); @@ -169,7 +169,7 @@ QScriptValue QInstaller::qDesktopServicesDisplayName(QScriptContext* context, QS return QDesktopServices::displayName(location); } -QScriptValue QInstaller::qDesktopServicesStorageLocation(QScriptContext* context, QScriptEngine* engine) +QScriptValue QInstaller::qDesktopServicesStorageLocation(QScriptContext *context, QScriptEngine *engine) { Q_UNUSED(engine); const QScriptValue check = checkArguments(context, 1, 1); @@ -363,7 +363,7 @@ int PackageManagerCore::downloadNeededArchives(double partProgressSize) ProgressCoordinator::instance()->emitLabelAndDetailTextChanged(tr("\nDownloading packages...")); // don't have it on the stack, since it keeps the temporary files - DownloadArchivesJob* const archivesJob = + DownloadArchivesJob *const archivesJob = new DownloadArchivesJob(d->m_settings.publicKey(), this); archivesJob->setAutoDelete(false); archivesJob->setArchivesToDownload(archivesToDownload); @@ -677,7 +677,7 @@ bool PackageManagerCore::fetchRemotePackagesTree() into the installer's GUI wizard. The widget is added before \a page. \a page has to be a value of \ref QInstaller::PackageManagerCore::WizardPage "WizardPage". */ -bool PackageManagerCore::addWizardPage(Component* component, const QString &name, int page) +bool PackageManagerCore::addWizardPage(Component *component, const QString &name, int page) { if (QWidget* const widget = component->userInterface(name)) { emit wizardPageInsertionRequested(widget, static_cast<WizardPage>(page)); @@ -864,7 +864,7 @@ QList<Component*> PackageManagerCore::availableComponents() const the returned component to have at least version 4.5. If no component matches the requirement, 0 is returned. */ -Component* PackageManagerCore::componentByName(const QString &name) const +Component *PackageManagerCore::componentByName(const QString &name) const { if (name.isEmpty()) return 0; @@ -1269,7 +1269,7 @@ QString PackageManagerCore::error() const */ bool PackageManagerCore::finishedWithSuccess() const { - return (d->m_status == PackageManagerCore::Success) || d->m_needToWriteUninstaller; + return d->m_status == PackageManagerCore::Success || d->m_needToWriteUninstaller; } void PackageManagerCore::interrupt() diff --git a/installerbuilder/libinstaller/packagemanagercore_p.h b/installerbuilder/libinstaller/packagemanagercore_p.h index 952a5fa6d..d58f269a1 100644 --- a/installerbuilder/libinstaller/packagemanagercore_p.h +++ b/installerbuilder/libinstaller/packagemanagercore_p.h @@ -249,6 +249,6 @@ private: void setCheckedState(Component *component, Qt::CheckState state); }; -} // QInstaller +} // namespace QInstaller #endif // PACKAGEMANAGERCORE_P_H diff --git a/installerbuilder/libinstaller/packagemanagergui.h b/installerbuilder/libinstaller/packagemanagergui.h index 37a5ee7e8..45f3ce630 100644 --- a/installerbuilder/libinstaller/packagemanagergui.h +++ b/installerbuilder/libinstaller/packagemanagergui.h @@ -69,7 +69,7 @@ public: void callControlScriptMethod(const QString& methodName); void triggerControlScriptForCurrentPage(); - QScriptEngine* controlScriptEngine() const; + QScriptEngine *controlScriptEngine() const; Q_INVOKABLE PackageManagerPage* page(int pageId) const; Q_INVOKABLE QWidget* pageWidgetByObjectName(const QString& name) const; @@ -91,10 +91,10 @@ public Q_SLOTS: void setModified(bool value); protected Q_SLOTS: - void wizardPageInsertionRequested(QWidget* widget, QInstaller::PackageManagerCore::WizardPage page); - void wizardPageRemovalRequested(QWidget* widget); - void wizardWidgetInsertionRequested(QWidget* widget, QInstaller::PackageManagerCore::WizardPage page); - void wizardWidgetRemovalRequested(QWidget* widget); + void wizardPageInsertionRequested(QWidget *widget, QInstaller::PackageManagerCore::WizardPage page); + void wizardPageRemovalRequested(QWidget *widget); + void wizardWidgetInsertionRequested(QWidget *widget, QInstaller::PackageManagerCore::WizardPage page); + void wizardWidgetRemovalRequested(QWidget *widget); void wizardPageVisibilityChangeRequested(bool visible, int page); void slotCurrentPageChanged(int id); void delayedControlScriptExecution(int id); @@ -105,13 +105,13 @@ private Q_SLOTS: void onLanguageChanged(); protected: - bool event(QEvent* event); + bool event(QEvent *event); void showEvent(QShowEvent *event); PackageManagerCore *packageManagerCore() const { return m_core; } private: class Private; - Private* const d; + Private *const d; PackageManagerCore *m_core; }; @@ -229,8 +229,8 @@ public: Q_INVOKABLE void selectAll(); Q_INVOKABLE void deselectAll(); Q_INVOKABLE void selectDefault(); - Q_INVOKABLE void selectComponent(const QString& id); - Q_INVOKABLE void deselectComponent(const QString& id); + Q_INVOKABLE void selectComponent(const QString &id); + Q_INVOKABLE void deselectComponent(const QString &id); protected: void entering(); diff --git a/installerbuilder/libinstaller/performinstallationform.h b/installerbuilder/libinstaller/performinstallationform.h index f7ca0ed73..c2ab28f33 100644 --- a/installerbuilder/libinstaller/performinstallationform.h +++ b/installerbuilder/libinstaller/performinstallationform.h @@ -61,7 +61,7 @@ signals: void showDetailsChanged(); public slots: - void appendProgressDetails( const QString &details); + void appendProgressDetails(const QString &details); void updateProgress(); void toggleDetails(); void clearDetailsBrowser(); diff --git a/installerbuilder/libinstaller/persistentsettings.cpp b/installerbuilder/libinstaller/persistentsettings.cpp index 16131c228..bb895cdf9 100644 --- a/installerbuilder/libinstaller/persistentsettings.cpp +++ b/installerbuilder/libinstaller/persistentsettings.cpp @@ -48,7 +48,7 @@ PersistentSettingsReader::PersistentSettingsReader() } -QVariant PersistentSettingsReader::restoreValue(const QString & variable) const +QVariant PersistentSettingsReader::restoreValue(const QString &variable) const { if (m_valueMap.contains(variable)) return m_valueMap.value(variable); @@ -60,7 +60,7 @@ QVariantMap PersistentSettingsReader::restoreValues() const return m_valueMap; } -bool PersistentSettingsReader::load(const QString & fileName) +bool PersistentSettingsReader::load(const QString &fileName) { m_valueMap.clear(); @@ -143,7 +143,6 @@ void PersistentSettingsReader::readValues(const QDomElement &data) PersistentSettingsWriter::PersistentSettingsWriter() { - } void PersistentSettingsWriter::writeValue(QDomElement &ps, const QVariant &variant) @@ -180,12 +179,12 @@ void PersistentSettingsWriter::writeValue(QDomElement &ps, const QVariant &varia } } -void PersistentSettingsWriter::saveValue(const QString & variable, const QVariant &value) +void PersistentSettingsWriter::saveValue(const QString &variable, const QVariant &value) { m_valueMap[variable] = value; } -bool PersistentSettingsWriter::save(const QString & fileName, const QString & docType) +bool PersistentSettingsWriter::save(const QString &fileName, const QString &docType) { QFile file(fileName); if (!file.open(QIODevice::WriteOnly)) diff --git a/installerbuilder/libinstaller/persistentsettings.h b/installerbuilder/libinstaller/persistentsettings.h index 605cb9cfb..2ad911a4b 100644 --- a/installerbuilder/libinstaller/persistentsettings.h +++ b/installerbuilder/libinstaller/persistentsettings.h @@ -49,7 +49,7 @@ class PROJECTEXPLORER_EXPORT PersistentSettingsReader { public: PersistentSettingsReader(); - QVariant restoreValue(const QString & variable) const; + QVariant restoreValue(const QString &variable) const; QVariantMap restoreValues() const; bool load(const QString & fileName); @@ -63,8 +63,8 @@ class PROJECTEXPLORER_EXPORT PersistentSettingsWriter { public: PersistentSettingsWriter(); - void saveValue(const QString & variable, const QVariant &value); - bool save(const QString & fileName, const QString & docType); + void saveValue(const QString &variable, const QVariant &value); + bool save(const QString &fileName, const QString &docType); private: void writeValue(QDomElement &ps, const QVariant &value); diff --git a/installerbuilder/libinstaller/progresscoordinator.cpp b/installerbuilder/libinstaller/progresscoordinator.cpp index c633cc707..9206ae5cf 100644 --- a/installerbuilder/libinstaller/progresscoordinator.cpp +++ b/installerbuilder/libinstaller/progresscoordinator.cpp @@ -61,9 +61,9 @@ ProgressCoordinator::~ProgressCoordinator() { } -ProgressCoordinator* ProgressCoordinator::instance() +ProgressCoordinator *ProgressCoordinator::instance() { - static ProgressCoordinator* instance = 0; + static ProgressCoordinator *instance = 0; if (instance == 0) instance = new ProgressCoordinator(qApp); return instance; diff --git a/installerbuilder/libinstaller/progresscoordinator.h b/installerbuilder/libinstaller/progresscoordinator.h index 781551d8f..e00baccf4 100644 --- a/installerbuilder/libinstaller/progresscoordinator.h +++ b/installerbuilder/libinstaller/progresscoordinator.h @@ -37,7 +37,7 @@ class ProgressCoordinator : public QObject Q_OBJECT public: - static ProgressCoordinator* instance(); + static ProgressCoordinator *instance(); ~ProgressCoordinator(); void registerPartProgress(QObject *sender, const char *signal, double partProgressSize); diff --git a/installerbuilder/libinstaller/qinstallerglobal.h b/installerbuilder/libinstaller/qinstallerglobal.h index 11d05ef8a..60de3a249 100644 --- a/installerbuilder/libinstaller/qinstallerglobal.h +++ b/installerbuilder/libinstaller/qinstallerglobal.h @@ -73,6 +73,7 @@ QScriptValue qInstallerComponentByName(QScriptContext *context, QScriptEngine *e QScriptValue qDesktopServicesOpenUrl(QScriptContext *context, QScriptEngine *engine); QScriptValue qDesktopServicesDisplayName(QScriptContext *context, QScriptEngine *engine); QScriptValue qDesktopServicesStorageLocation(QScriptContext *context, QScriptEngine *engine); -} + +} // namespace QInstaller #endif // QINSTALLER_GLOBAL_H diff --git a/installerbuilder/libinstaller/qprocesswrapper.cpp b/installerbuilder/libinstaller/qprocesswrapper.cpp index f9cefa41c..d6c4d26c0 100644 --- a/installerbuilder/libinstaller/qprocesswrapper.cpp +++ b/installerbuilder/libinstaller/qprocesswrapper.cpp @@ -75,7 +75,7 @@ public: { public: explicit TimerBlocker(const QProcessWrapper *wrapper) - : w(const_cast< QProcessWrapper*> (wrapper)) + : w(const_cast<QProcessWrapper *>(wrapper)) { w->d->ignoreTimer = true; } @@ -267,7 +267,7 @@ void QProcessWrapper::closeWriteChannel() callRemoteVoidMethod<void>(d->stream, QLatin1String("QProcess::closeWriteChannel")); else d->process.closeWriteChannel(); -}; +} int QProcessWrapper::exitCode() const { @@ -275,7 +275,7 @@ int QProcessWrapper::exitCode() const if (d->createSocket()) return callRemoteMethod<int>(d->stream, QLatin1String("QProcess::exitCode")); return static_cast< int>(d->process.exitCode()); -}; +} QProcessWrapper::ExitStatus QProcessWrapper::exitStatus() const { @@ -283,7 +283,7 @@ QProcessWrapper::ExitStatus QProcessWrapper::exitStatus() const if (d->createSocket()) return callRemoteMethod<QProcessWrapper::ExitStatus>(d->stream, QLatin1String("QProcess::exitStatus")); return static_cast< QProcessWrapper::ExitStatus>(d->process.exitStatus()); -}; +} void QProcessWrapper::kill() { @@ -300,7 +300,7 @@ QByteArray QProcessWrapper::readAll() if (d->createSocket()) return callRemoteMethod<QByteArray>(d->stream, QLatin1String("QProcess::readAll")); return d->process.readAll(); -}; +} QByteArray QProcessWrapper::readAllStandardOutput() { @@ -308,9 +308,9 @@ QByteArray QProcessWrapper::readAllStandardOutput() if (d->createSocket()) return callRemoteMethod<QByteArray>(d->stream, QLatin1String("QProcess::readAllStandardOutput")); return d->process.readAllStandardOutput(); -}; +} -void QProcessWrapper::start(const QString& param1, const QStringList& param2, QIODevice::OpenMode param3) +void QProcessWrapper::start(const QString ¶m1, const QStringList ¶m2, QIODevice::OpenMode param3) { const Private::TimerBlocker blocker(this); if (d->createSocket()) @@ -319,7 +319,7 @@ void QProcessWrapper::start(const QString& param1, const QStringList& param2, QI d->process.start(param1, param2, param3); } -void QProcessWrapper::start(const QString& param1) +void QProcessWrapper::start(const QString ¶m1) { const Private::TimerBlocker blocker(this); if (d->createSocket()) @@ -373,7 +373,7 @@ QString QProcessWrapper::workingDirectory() const return static_cast< QString>(d->process.workingDirectory()); } -void QProcessWrapper::setEnvironment(const QStringList& param1) +void QProcessWrapper::setEnvironment(const QStringList ¶m1) { const Private::TimerBlocker blocker(this); if (d->createSocket()) @@ -383,7 +383,7 @@ void QProcessWrapper::setEnvironment(const QStringList& param1) } #ifdef Q_OS_WIN -void QProcessWrapper::setNativeArguments(const QString& param1) +void QProcessWrapper::setNativeArguments(const QString ¶m1) { const Private::TimerBlocker blocker(this); if (d->createSocket()) @@ -393,7 +393,7 @@ void QProcessWrapper::setNativeArguments(const QString& param1) } #endif -void QProcessWrapper::setWorkingDirectory(const QString& param1) +void QProcessWrapper::setWorkingDirectory(const QString ¶m1) { const Private::TimerBlocker blocker(this); if (d->createSocket()) diff --git a/installerbuilder/libinstaller/qsettingswrapper.cpp b/installerbuilder/libinstaller/qsettingswrapper.cpp index bc03f8eaf..21e6640b9 100644 --- a/installerbuilder/libinstaller/qsettingswrapper.cpp +++ b/installerbuilder/libinstaller/qsettingswrapper.cpp @@ -229,7 +229,7 @@ void QSettingsWrapper::clear() else d->settings.clear(); } -bool QSettingsWrapper::contains(const QString& param1) const +bool QSettingsWrapper::contains(const QString ¶m1) const { if (d->createSocket()) return callRemoteMethod<bool>(d->stream, QLatin1String("QSettings::contains"), param1); @@ -297,7 +297,7 @@ QString QSettingsWrapper::organizationName() const return static_cast<QString>(d->settings.organizationName()); } -void QSettingsWrapper::remove(const QString& param1) +void QSettingsWrapper::remove(const QString ¶m1) { if (d->createSocket()) callRemoteVoidMethod(d->stream, QLatin1String("QSettings::remove"), param1); @@ -323,17 +323,17 @@ void QSettingsWrapper::setFallbacksEnabled(bool param1) else d->settings.setFallbacksEnabled(param1); } -void QSettingsWrapper::setIniCodec(QTextCodec* codec) +void QSettingsWrapper::setIniCodec(QTextCodec *codec) { d->settings.setIniCodec(codec); } -void QSettingsWrapper::setIniCodec(const char* codecName) +void QSettingsWrapper::setIniCodec(const char *codecName) { d->settings.setIniCodec(codecName); } -void QSettingsWrapper::setValue(const QString& param1, const QVariant& param2) +void QSettingsWrapper::setValue(const QString ¶m1, const QVariant ¶m2) { if (d->createSocket()) callRemoteVoidMethod(d->stream, QLatin1String("QSettings::setValue"), param1, param2); @@ -356,7 +356,7 @@ void QSettingsWrapper::sync() d->settings.sync(); } -QVariant QSettingsWrapper::value(const QString& param1, const QVariant& param2) const +QVariant QSettingsWrapper::value(const QString ¶m1, const QVariant ¶m2) const { if (d->createSocket()) return callRemoteMethod<QVariant>(d->stream, QLatin1String("QSettings::value"), param1, param2); diff --git a/installerbuilder/libinstaller/qsettingswrapper.h b/installerbuilder/libinstaller/qsettingswrapper.h index c807e62c8..e0f70bf92 100644 --- a/installerbuilder/libinstaller/qsettingswrapper.h +++ b/installerbuilder/libinstaller/qsettingswrapper.h @@ -28,8 +28,8 @@ #include <installer_global.h> -#include<QtCore/QObject> -#include<QtCore/QVariant> +#include <QtCore/QObject> +#include <QtCore/QVariant> class INSTALLER_EXPORT QSettingsWrapper : public QObject { diff --git a/installerbuilder/libinstaller/qtcreatorpersistentsettings.cpp b/installerbuilder/libinstaller/qtcreatorpersistentsettings.cpp index f6ab8418f..15ec53dfb 100644 --- a/installerbuilder/libinstaller/qtcreatorpersistentsettings.cpp +++ b/installerbuilder/libinstaller/qtcreatorpersistentsettings.cpp @@ -42,7 +42,7 @@ QHash<QString, QVariantMap> QtCreatorPersistentSettings::readValidToolChains() if (m_fileName.isEmpty()) return QHash<QString, QVariantMap>(); - QHash< QString, QVariantMap > toolChainHash; + QHash<QString, QVariantMap> toolChainHash; QVariantMap data = m_reader.restoreValues(); diff --git a/installerbuilder/libinstaller/qtcreatorpersistentsettings.h b/installerbuilder/libinstaller/qtcreatorpersistentsettings.h index eb43cda39..0f8ca7c07 100644 --- a/installerbuilder/libinstaller/qtcreatorpersistentsettings.h +++ b/installerbuilder/libinstaller/qtcreatorpersistentsettings.h @@ -7,7 +7,8 @@ #include <QString> #include <QVariantMap> -struct QtCreatorToolChain { +struct QtCreatorToolChain +{ QString key; QString type; QString displayName; diff --git a/installerbuilder/libinstaller/qtpatch.cpp b/installerbuilder/libinstaller/qtpatch.cpp index 655497421..4e70a5300 100644 --- a/installerbuilder/libinstaller/qtpatch.cpp +++ b/installerbuilder/libinstaller/qtpatch.cpp @@ -59,9 +59,8 @@ namespace { void sleepCopiedFromQTest(int ms) { - if (ms < 0) { + if (ms < 0) return; - } #ifdef Q_OS_WIN Sleep(uint(ms)); #else @@ -84,7 +83,7 @@ namespace { }//"anonymous" namespace -QHash<QString, QByteArray> QtPatch::qmakeValues(const QString & qmakePath, QByteArray * qmakeOutput) +QHash<QString, QByteArray> QtPatch::qmakeValues(const QString &qmakePath, QByteArray *qmakeOutput) { QHash<QString, QByteArray> qmakeValueHash; @@ -109,7 +108,7 @@ QHash<QString, QByteArray> QtPatch::qmakeValues(const QString & qmakePath, QByte process.start(qmake.absoluteFilePath(), args, QIODevice::ReadOnly); if (process.waitForFinished(2000)) { if (process.exitStatus() == QProcess::CrashExit) { - QInstaller::verbose() << qPrintable( QString(QLatin1String("%1 was crashed")).arg(qmakePath) ) << std::endl; + QInstaller::verbose() << qPrintable(QString(QLatin1String("%1 was crashed")).arg(qmakePath) ) << std::endl; return qmakeValueHash; } QByteArray output = process.readAllStandardOutput(); @@ -141,18 +140,18 @@ QHash<QString, QByteArray> QtPatch::qmakeValues(const QString & qmakePath, QByte return qmakeValueHash; } -bool QtPatch::patchBinaryFile( const QString & fileName, - const QByteArray & oldQtPath, - const QByteArray & newQtPath ) +bool QtPatch::patchBinaryFile(const QString &fileName, + const QByteArray &oldQtPath, + const QByteArray &newQtPath) { QFile file(fileName); - if ( !file.exists() ) { + if (!file.exists()) { QInstaller::verbose() << "qpatch: warning: file `" << qPrintable(fileName) << "' not found" << std::endl; return false; } openFileForPatching(&file); - if (! file.isOpen()) { + if (!file.isOpen()) { QInstaller::verbose() << "qpatch: warning: file `" << qPrintable(fileName) << "' can not open." << std::endl; QInstaller::verbose() << qPrintable(file.errorString()) << std::endl; return false; @@ -165,9 +164,9 @@ bool QtPatch::patchBinaryFile( const QString & fileName, } // device must be open -bool QtPatch::patchBinaryFile( QIODevice* device, - const QByteArray & oldQtPath, - const QByteArray & newQtPath ) +bool QtPatch::patchBinaryFile(QIODevice *device, + const QByteArray &oldQtPath, + const QByteArray &newQtPath) { if (!(device->openMode() == QIODevice::ReadWrite)) { QInstaller::verbose() << "qpatch: warning: This function needs an open device for writing." << std::endl; @@ -178,7 +177,7 @@ bool QtPatch::patchBinaryFile( QIODevice* device, int offset = 0; QByteArray overwritePath(newQtPath); - if(overwritePath.size() < oldQtPath.size()) { + if (overwritePath.size() < oldQtPath.size()) { QByteArray fillByteArray(oldQtPath.size() - overwritePath.size(), '\0'); overwritePath.append(fillByteArray); } @@ -186,7 +185,7 @@ bool QtPatch::patchBinaryFile( QIODevice* device, QByteArrayMatcher byteArrayMatcher(oldQtPath); forever { offset = byteArrayMatcher.indexIn(source, offset); - if(offset == -1) + if (offset == -1) break; device->seek(offset); device->write(overwritePath); @@ -196,12 +195,12 @@ bool QtPatch::patchBinaryFile( QIODevice* device, return true; } -bool QtPatch::patchTextFile( const QString & fileName, - const QHash<QByteArray, QByteArray> &searchReplacePairs) +bool QtPatch::patchTextFile(const QString &fileName, + const QHash<QByteArray, QByteArray> &searchReplacePairs) { QFile file(fileName); - if (! file.open(QFile::ReadOnly)) { + if (!file.open(QFile::ReadOnly)) { QInstaller::verbose() << "qpatch: warning: Open the file '" << qPrintable(fileName) << "' stopped: " << qPrintable(file.errorString()) << std::endl; @@ -212,12 +211,12 @@ bool QtPatch::patchTextFile( const QString & fileName, file.close(); QHashIterator<QByteArray, QByteArray> it(searchReplacePairs); - while(it.hasNext()) { + while (it.hasNext()) { it.next(); source.replace(it.key(), it.value()); } - if (! file.open(QFile::WriteOnly | QFile::Truncate)) { + if (!file.open(QFile::WriteOnly | QFile::Truncate)) { QInstaller::verbose() << "qpatch: error: file `" << qPrintable(fileName) << "' not writable" << std::endl; return false; } @@ -227,12 +226,12 @@ bool QtPatch::patchTextFile( const QString & fileName, } -bool QtPatch::openFileForPatching(QFile* file) +bool QtPatch::openFileForPatching(QFile *file) { if (file->openMode() == QIODevice::NotOpen) { // in some cases the file can not open, because another process is blocking it(filewatcher ...) int waitCount = 0; - while (! file->open(QFile::ReadWrite) && waitCount < 60) { + while (!file->open(QFile::ReadWrite) && waitCount < 60) { ++waitCount; static const int waitTimeInMilliSeconds = 500; uiDetachedWait(waitTimeInMilliSeconds); diff --git a/installerbuilder/libinstaller/qtpatch.h b/installerbuilder/libinstaller/qtpatch.h index 73170917e..d38c4dc8d 100644 --- a/installerbuilder/libinstaller/qtpatch.h +++ b/installerbuilder/libinstaller/qtpatch.h @@ -32,21 +32,22 @@ #include <QHash> #include <QFile> -namespace QtPatch -{ - QHash<QString, QByteArray> INSTALLER_EXPORT qmakeValues(const QString &qmakePath, QByteArray * qmakeOutput); - - bool INSTALLER_EXPORT patchBinaryFile( const QString &fileName, - const QByteArray &oldQtPath, - const QByteArray &newQtPath ); - - bool INSTALLER_EXPORT patchBinaryFile( QIODevice* device, - const QByteArray &oldQtPath, - const QByteArray &newQtPath ); - - bool INSTALLER_EXPORT patchTextFile( const QString &fileName, - const QHash<QByteArray, QByteArray> &searchReplacePairs); - bool INSTALLER_EXPORT openFileForPatching(QFile* file); -}; +namespace QtPatch { + +QHash<QString, QByteArray> INSTALLER_EXPORT qmakeValues(const QString &qmakePath, QByteArray *qmakeOutput); + +bool INSTALLER_EXPORT patchBinaryFile(const QString &fileName, + const QByteArray &oldQtPath, + const QByteArray &newQtPath ); + +bool INSTALLER_EXPORT patchBinaryFile(QIODevice *device, + const QByteArray &oldQtPath, + const QByteArray &newQtPath ); + +bool INSTALLER_EXPORT patchTextFile(const QString &fileName, + const QHash<QByteArray, QByteArray> &searchReplacePairs); +bool INSTALLER_EXPORT openFileForPatching(QFile *file); + +} #endif // QTPATCH_H diff --git a/installerbuilder/libinstaller/qtpatchoperation.cpp b/installerbuilder/libinstaller/qtpatchoperation.cpp index 281e99a3a..5ee7083f0 100644 --- a/installerbuilder/libinstaller/qtpatchoperation.cpp +++ b/installerbuilder/libinstaller/qtpatchoperation.cpp @@ -53,8 +53,8 @@ using namespace QInstaller; //"anonymous" namespace to make clear that this is only for inside use namespace { - QMap<QByteArray, QByteArray> generatePatchValueMap(const QByteArray & newQtPath, - const QHash<QString, QByteArray> & qmakeValueHash) + QMap<QByteArray, QByteArray> generatePatchValueMap(const QByteArray &newQtPath, + const QHash<QString, QByteArray> &qmakeValueHash) { QMap<QByteArray, QByteArray> replaceMap; //first == searchstring: second == replace string char nativeSeperator = QDir::separator().toAscii(); @@ -114,7 +114,7 @@ namespace { return replaceMap; } -}//"anonymous" namespace +} // anonymous namespace QtPatchOperation::QtPatchOperation() { @@ -346,7 +346,7 @@ bool QtPatchOperation::testOperation() return true; } -Operation* QtPatchOperation::clone() const +Operation *QtPatchOperation::clone() const { return new QtPatchOperation(); } diff --git a/installerbuilder/libinstaller/qtpatchoperation.h b/installerbuilder/libinstaller/qtpatchoperation.h index 73cc53808..177220278 100644 --- a/installerbuilder/libinstaller/qtpatchoperation.h +++ b/installerbuilder/libinstaller/qtpatchoperation.h @@ -40,9 +40,9 @@ public: bool performOperation(); bool undoOperation(); bool testOperation(); - Operation* clone() const; + Operation *clone() const; }; -} // namespace +} // namespace QInstaller #endif // QTPATCHOPERATION_H diff --git a/installerbuilder/libinstaller/registerdefaultdebuggeroperation.cpp b/installerbuilder/libinstaller/registerdefaultdebuggeroperation.cpp index 337665398..da34ab066 100644 --- a/installerbuilder/libinstaller/registerdefaultdebuggeroperation.cpp +++ b/installerbuilder/libinstaller/registerdefaultdebuggeroperation.cpp @@ -161,7 +161,7 @@ bool RegisterDefaultDebuggerOperation::testOperation() return true; } -Operation* RegisterDefaultDebuggerOperation::clone() const +Operation *RegisterDefaultDebuggerOperation::clone() const { return new RegisterDefaultDebuggerOperation(); } diff --git a/installerbuilder/libinstaller/registerdefaultdebuggeroperation.h b/installerbuilder/libinstaller/registerdefaultdebuggeroperation.h index fbfc1be0c..08511b1af 100644 --- a/installerbuilder/libinstaller/registerdefaultdebuggeroperation.h +++ b/installerbuilder/libinstaller/registerdefaultdebuggeroperation.h @@ -41,9 +41,9 @@ public: bool performOperation(); bool undoOperation(); bool testOperation(); - Operation* clone() const; + Operation *clone() const; }; -} // namespace +} // namespace QInstaller #endif // REGISTERDEFAULTDEBUGGEROPERATION_H diff --git a/installerbuilder/libinstaller/registerdocumentationoperation.cpp b/installerbuilder/libinstaller/registerdocumentationoperation.cpp index ffd314fd6..3a771d7cc 100644 --- a/installerbuilder/libinstaller/registerdocumentationoperation.cpp +++ b/installerbuilder/libinstaller/registerdocumentationoperation.cpp @@ -153,7 +153,7 @@ bool RegisterDocumentationOperation::testOperation() return true; } -Operation* RegisterDocumentationOperation::clone() const +Operation *RegisterDocumentationOperation::clone() const { return new RegisterDocumentationOperation(); } diff --git a/installerbuilder/libinstaller/registerdocumentationoperation.h b/installerbuilder/libinstaller/registerdocumentationoperation.h index 0f9abe55d..c1ed9d564 100644 --- a/installerbuilder/libinstaller/registerdocumentationoperation.h +++ b/installerbuilder/libinstaller/registerdocumentationoperation.h @@ -40,9 +40,9 @@ public: bool performOperation(); bool undoOperation(); bool testOperation(); - Operation* clone() const; + Operation *clone() const; }; -} // namespace +} // namespace QInstaller #endif // REGISTERDOCUMENTATIONOPERATION_H diff --git a/installerbuilder/libinstaller/registerqtoperation.h b/installerbuilder/libinstaller/registerqtoperation.h index 0c63fd8ac..41a8972e9 100644 --- a/installerbuilder/libinstaller/registerqtoperation.h +++ b/installerbuilder/libinstaller/registerqtoperation.h @@ -40,9 +40,9 @@ public: bool performOperation(); bool undoOperation(); bool testOperation(); - Operation* clone() const; + Operation *clone() const; }; -}; // namespace +} // namespace QInstaller #endif // REGISTERQTINCREATOROPERATION_H diff --git a/installerbuilder/libinstaller/registerqtv23operation.cpp b/installerbuilder/libinstaller/registerqtv23operation.cpp index 93910f173..9cf7926aa 100644 --- a/installerbuilder/libinstaller/registerqtv23operation.cpp +++ b/installerbuilder/libinstaller/registerqtv23operation.cpp @@ -232,7 +232,7 @@ bool RegisterQtInCreatorV23Operation::testOperation() return true; } -Operation* RegisterQtInCreatorV23Operation::clone() const +Operation *RegisterQtInCreatorV23Operation::clone() const { return new RegisterQtInCreatorV23Operation(); } diff --git a/installerbuilder/libinstaller/registerqtv23operation.h b/installerbuilder/libinstaller/registerqtv23operation.h index fdbbc5004..6ffa045dd 100644 --- a/installerbuilder/libinstaller/registerqtv23operation.h +++ b/installerbuilder/libinstaller/registerqtv23operation.h @@ -40,9 +40,9 @@ public: bool performOperation(); bool undoOperation(); bool testOperation(); - Operation* clone() const; + Operation *clone() const; }; -} // namespace +} // namespace QInstaller #endif // REGISTERQTINCREATORV2OPERATION_H diff --git a/installerbuilder/libinstaller/registerqtv2operation.cpp b/installerbuilder/libinstaller/registerqtv2operation.cpp index e5a5a41fb..bc9f566ba 100644 --- a/installerbuilder/libinstaller/registerqtv2operation.cpp +++ b/installerbuilder/libinstaller/registerqtv2operation.cpp @@ -199,7 +199,7 @@ bool RegisterQtInCreatorV2Operation::testOperation() return true; } -Operation* RegisterQtInCreatorV2Operation::clone() const +Operation *RegisterQtInCreatorV2Operation::clone() const { return new RegisterQtInCreatorV2Operation(); } diff --git a/installerbuilder/libinstaller/registerqtv2operation.h b/installerbuilder/libinstaller/registerqtv2operation.h index ef0f50a8e..2a2d3e158 100644 --- a/installerbuilder/libinstaller/registerqtv2operation.h +++ b/installerbuilder/libinstaller/registerqtv2operation.h @@ -40,9 +40,9 @@ public: bool performOperation(); bool undoOperation(); bool testOperation(); - Operation* clone() const; + Operation *clone() const; }; -} // namespace +} // namespace QInstaller #endif // REGISTERQTINCREATORV2OPERATION_H diff --git a/installerbuilder/libinstaller/registertoolchainoperation.h b/installerbuilder/libinstaller/registertoolchainoperation.h index 86c36ebd9..68f3c16b5 100644 --- a/installerbuilder/libinstaller/registertoolchainoperation.h +++ b/installerbuilder/libinstaller/registertoolchainoperation.h @@ -61,6 +61,6 @@ public: Operation *clone() const; }; -} // namespace +} // namespace QInstaller #endif // REGISTERTOOLCHAINOPERATION_H diff --git a/installerbuilder/libinstaller/replaceoperation.h b/installerbuilder/libinstaller/replaceoperation.h index 9186c704d..a54434317 100644 --- a/installerbuilder/libinstaller/replaceoperation.h +++ b/installerbuilder/libinstaller/replaceoperation.h @@ -43,6 +43,6 @@ public: Operation *clone() const; }; -} // namespace +} // namespace QInstaller #endif // REPLACEOPERATION_H diff --git a/installerbuilder/libinstaller/setimportspathonqtcoreoperation.cpp b/installerbuilder/libinstaller/setimportspathonqtcoreoperation.cpp index 07ff50984..c3bb6e47f 100644 --- a/installerbuilder/libinstaller/setimportspathonqtcoreoperation.cpp +++ b/installerbuilder/libinstaller/setimportspathonqtcoreoperation.cpp @@ -53,12 +53,12 @@ namespace { QFile file(binaryPath); int readOpenCount = 0; - while (! file.open(QFile::ReadOnly) && readOpenCount < 20000) { + while (!file.open(QFile::ReadOnly) && readOpenCount < 20000) { ++readOpenCount; qApp->processEvents(); } Q_ASSERT(file.isOpen()); - if (! file.isOpen()) { + if (!file.isOpen()) { verbose() << "qpatch: warning: file `" << qPrintable(binaryPath) << "' can not open as ReadOnly." << std::endl; verbose() << file.errorString() << std::endl; @@ -73,7 +73,7 @@ namespace { QByteArrayMatcher byteArrayMatcher(searchValue); offset = byteArrayMatcher.indexIn(source, offset); Q_ASSERT(offset > 0); - if(offset == -1) + if (offset == -1) return QByteArray(); int stringEndPosition = offset; diff --git a/installerbuilder/libinstaller/setpathonqtcoreoperation.cpp b/installerbuilder/libinstaller/setpathonqtcoreoperation.cpp index a8ccb19b5..50c823df0 100644 --- a/installerbuilder/libinstaller/setpathonqtcoreoperation.cpp +++ b/installerbuilder/libinstaller/setpathonqtcoreoperation.cpp @@ -40,7 +40,7 @@ using namespace QInstaller; namespace { - QByteArray getOldValue(const QString & binaryPath, const QByteArray &typeValue) + QByteArray getOldValue(const QString &binaryPath, const QByteArray &typeValue) { QFileInfo fileInfo(binaryPath); diff --git a/installerbuilder/libinstaller/setpluginpathonqtcoreoperation.cpp b/installerbuilder/libinstaller/setpluginpathonqtcoreoperation.cpp index 4cc11e702..07240cc95 100644 --- a/installerbuilder/libinstaller/setpluginpathonqtcoreoperation.cpp +++ b/installerbuilder/libinstaller/setpluginpathonqtcoreoperation.cpp @@ -41,7 +41,7 @@ using namespace QInstaller; namespace { - QByteArray getOldValue(const QString & binaryPath) + QByteArray getOldValue(const QString &binaryPath) { QFileInfo fileInfo(binaryPath); @@ -73,7 +73,7 @@ namespace { QByteArrayMatcher byteArrayMatcher(searchValue); offset = byteArrayMatcher.indexIn(source, offset); Q_ASSERT(offset > 0); - if(offset == -1) + if (offset == -1) return QByteArray(); int stringEndPosition = offset; diff --git a/installerbuilder/libinstaller/simplemovefileoperation.cpp b/installerbuilder/libinstaller/simplemovefileoperation.cpp index dcc68d969..0a2edaf13 100644 --- a/installerbuilder/libinstaller/simplemovefileoperation.cpp +++ b/installerbuilder/libinstaller/simplemovefileoperation.cpp @@ -109,7 +109,7 @@ bool SimpleMoveFileOperation::testOperation() return true; } -Operation* SimpleMoveFileOperation::clone() const +Operation *SimpleMoveFileOperation::clone() const { return new SimpleMoveFileOperation(); } diff --git a/installerbuilder/libinstaller/updatecreatorsettingsfrom21to22operation.cpp b/installerbuilder/libinstaller/updatecreatorsettingsfrom21to22operation.cpp index 72052017e..afe4eb0c4 100644 --- a/installerbuilder/libinstaller/updatecreatorsettingsfrom21to22operation.cpp +++ b/installerbuilder/libinstaller/updatecreatorsettingsfrom21to22operation.cpp @@ -184,7 +184,7 @@ bool convertQtInstallerSettings(QSettings &settings, const QString &toolChainsXm return false; } - foreach (const QString mingwPath, mingwToolChains) { + foreach (const QString &mingwPath, mingwToolChains) { if (mingwPath.isEmpty()) continue; QInstaller::RegisterToolChainOperation operation; @@ -223,7 +223,7 @@ bool convertQtInstallerSettings(QSettings &settings, const QString &toolChainsXm return true; } -void convertDefaultGDBInstallerSettings(QSettings &settings, QInstaller::PackageManagerCore* const core) +void convertDefaultGDBInstallerSettings(QSettings &settings, QInstaller::PackageManagerCore *const core) { settings.beginGroup(QLatin1String("GdbBinaries21")); diff --git a/installerbuilder/libinstaller/updater.h b/installerbuilder/libinstaller/updater.h index 5b035c67c..602491eb8 100644 --- a/installerbuilder/libinstaller/updater.h +++ b/installerbuilder/libinstaller/updater.h @@ -44,6 +44,6 @@ public: void setVerbose(bool verbose); }; -} // namespace QInstaller +} // namespace QInstaller #endif diff --git a/installerbuilder/libinstaller/updatesettings.cpp b/installerbuilder/libinstaller/updatesettings.cpp index 0347beb1d..6892b4078 100644 --- a/installerbuilder/libinstaller/updatesettings.cpp +++ b/installerbuilder/libinstaller/updatesettings.cpp @@ -52,12 +52,12 @@ private: UpdateSettings *const q; public: - QSettings& settings() + QSettings &settings() { return externalSettings ? *externalSettings : internalSettings; } - const QSettings& settings() const + const QSettings &settings() const { return externalSettings ? *externalSettings : internalSettings; } @@ -69,10 +69,10 @@ public: private: QSettings internalSettings; - static QSettings* externalSettings; + static QSettings *externalSettings; }; -QSettings* UpdateSettings::Private::externalSettings = 0; +QSettings *UpdateSettings::Private::externalSettings = 0; // -- UpdateSettings |