summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkh1 <qt-info@nokia.com>2011-05-12 14:57:32 +0200
committerkh1 <qt-info@nokia.com>2011-05-12 14:57:32 +0200
commit335911e45db8d3c887c0e759b721db1d74e41f99 (patch)
tree8f6b7acb638297a3626304fd1a8c155145f998ea
parent007d2517bc4931cf69ae55677034ec87a2843a8c (diff)
parent83fb4bc8b2573765a47ef6c5eb7058e17a7415e4 (diff)
Merge branch 'master' into refactor
Conflicts: installerbuilder/libinstaller/elevatedexecuteoperation.cpp installerbuilder/libinstaller/installiconsoperation.cpp installerbuilder/libinstaller/libinstaller.pro installerbuilder/libinstaller/qinstaller.cpp installerbuilder/libinstaller/registertoolchainoperation.cpp installerbuilder/libinstaller/selfrestartoperation.cpp
-rw-r--r--installerbuilder/libinstaller/copydirectoryoperation.cpp97
-rw-r--r--installerbuilder/libinstaller/createdesktopentryoperation.cpp110
-rw-r--r--installerbuilder/libinstaller/createshortcutoperation.cpp188
-rw-r--r--installerbuilder/libinstaller/elevatedexecuteoperation.cpp84
-rw-r--r--installerbuilder/libinstaller/environmentvariablesoperation.cpp9
-rw-r--r--installerbuilder/libinstaller/extractarchiveoperation.cpp96
-rw-r--r--installerbuilder/libinstaller/installiconsoperation.cpp201
-rw-r--r--installerbuilder/libinstaller/libinstaller.pro3
-rw-r--r--installerbuilder/libinstaller/licenseoperation.cpp8
-rw-r--r--installerbuilder/libinstaller/qinstaller.cpp15
-rw-r--r--installerbuilder/libinstaller/qinstaller.h6
-rw-r--r--installerbuilder/libinstaller/qinstaller_p.cpp8
-rw-r--r--installerbuilder/libinstaller/qinstaller_p.h1
-rw-r--r--installerbuilder/libinstaller/qtcreator_constants.h30
-rw-r--r--installerbuilder/libinstaller/qtpatchoperation.cpp146
-rw-r--r--installerbuilder/libinstaller/registerdocumentationoperation.cpp14
-rw-r--r--installerbuilder/libinstaller/registerfiletypeoperation.cpp119
-rw-r--r--installerbuilder/libinstaller/registerqtoperation.cpp18
-rw-r--r--installerbuilder/libinstaller/registerqtv2operation.cpp36
-rw-r--r--installerbuilder/libinstaller/registertoolchainoperation.cpp46
-rw-r--r--installerbuilder/libinstaller/replaceoperation.cpp16
-rw-r--r--installerbuilder/libinstaller/selfrestartoperation.cpp25
-rw-r--r--installerbuilder/libinstaller/setdemospathonqtoperation.cpp29
-rw-r--r--installerbuilder/libinstaller/setexamplespathonqtoperation.cpp27
-rw-r--r--installerbuilder/libinstaller/setimportspathonqtcoreoperation.cpp16
-rw-r--r--installerbuilder/libinstaller/setpluginpathonqtcoreoperation.cpp22
-rw-r--r--installerbuilder/libinstaller/setqtcreatorvalueoperation.cpp44
-rw-r--r--installerbuilder/libinstaller/simplemovefileoperation.cpp54
-rw-r--r--tools/operationrunner/fakeinstaller.cpp16
-rw-r--r--tools/operationrunner/fakeinstaller.h24
-rw-r--r--tools/operationrunner/operationrunner.cpp62
-rw-r--r--tools/operationrunner/operationrunner.pro6
32 files changed, 857 insertions, 719 deletions
diff --git a/installerbuilder/libinstaller/copydirectoryoperation.cpp b/installerbuilder/libinstaller/copydirectoryoperation.cpp
index 0a308b361..ac01c9422 100644
--- a/installerbuilder/libinstaller/copydirectoryoperation.cpp
+++ b/installerbuilder/libinstaller/copydirectoryoperation.cpp
@@ -49,7 +49,7 @@ TRANSLATOR QInstaller::CopyDirectoryOperation
CopyDirectoryOperation::CopyDirectoryOperation()
{
- setName( QLatin1String( "CopyDirectory" ) );
+ setName(QLatin1String("CopyDirectory"));
}
CopyDirectoryOperation::~CopyDirectoryOperation()
@@ -77,8 +77,8 @@ QList< QPair<QString,QString> > CopyDirectoryOperation::fileList()
Q_ASSERT(!arguments().at(0).isEmpty());
Q_ASSERT(!arguments().at(1).isEmpty());
if (m_fileList.isEmpty()) {
- const QString sourcePath = arguments().at( 0 );
- const QString targetPath = arguments().at( 1 );
+ const QString sourcePath = arguments().at(0);
+ const QString targetPath = arguments().at(1);
m_fileList = generateFileList(sourcePath, targetPath);
}
@@ -87,27 +87,23 @@ QList< QPair<QString,QString> > CopyDirectoryOperation::fileList()
QList< QPair<QString,QString> > CopyDirectoryOperation::generateFileList(const QString &sourcePath, const QString &targetPath)
{
- Q_ASSERT( QFileInfo( sourcePath ).isDir() );
- Q_ASSERT( !QFileInfo( targetPath ).exists() || QFileInfo( targetPath ).isDir() );
- if ( !QDir().mkpath( targetPath ) ) {
- qWarning() << QLatin1String("Could not create folder ") << targetPath;
+ Q_ASSERT(QFileInfo(sourcePath).isDir());
+ Q_ASSERT(!QFileInfo(targetPath).exists() || QFileInfo(targetPath).isDir());
+ if (!QDir().mkpath(targetPath)) {
+ qWarning() << QLatin1String("Could not create folder") << targetPath;
} else {
addDirectoryToDirectoryList(targetPath);
}
- QDirIterator it( sourcePath, QDir::NoDotAndDotDot | QDir::AllEntries | QDir::Hidden | QDir::System);
- while( it.hasNext() )
- {
- const QFileInfo currentFileInfo( it.next() );
- if( currentFileInfo.isDir() && !currentFileInfo.isSymLink() )
- {
- generateFileList( currentFileInfo.absoluteFilePath(), QDir( targetPath ).absoluteFilePath( currentFileInfo.fileName() ) );
- }
- else
- {
+ QDirIterator it(sourcePath, QDir::NoDotAndDotDot | QDir::AllEntries | QDir::Hidden | QDir::System);
+ while (it.hasNext()) {
+ const QFileInfo currentFileInfo(it.next());
+ if (currentFileInfo.isDir() && !currentFileInfo.isSymLink()) {
+ generateFileList( currentFileInfo.absoluteFilePath(), QDir(targetPath).absoluteFilePath(currentFileInfo.fileName()));
+ } else {
const QString source = currentFileInfo.absoluteFilePath();
- const QString target = QDir( targetPath ).absoluteFilePath( currentFileInfo.fileName() );
+ const QString target = QDir(targetPath).absoluteFilePath(currentFileInfo.fileName());
m_fileList.append(QPair<QString, QString>(source, target));
}
}
@@ -126,24 +122,23 @@ bool CopyDirectoryOperation::copyFilesFromInternalFileList()
// If destination file exists, then we cannot use QFile::copy()
// because it does not overwrite an existing file. So we remove
// the destination file.
- if( QFile::exists(dest) )
- {
- QFile file( dest );
- if( !file.remove() ) {
- setError( UserDefinedError );
- setErrorString( tr("Could not remove destination file %1: %2.").arg( dest, file.errorString() ) );
+ if (QFile::exists(dest)) {
+ QFile file(dest);
+ if (!file.remove()) {
+ setError(UserDefinedError);
+ setErrorString(tr("Could not remove destination file %1: %2.").arg( dest, file.errorString()));
return false;
}
}
- QFile file( source );
- const bool copied = file.copy( dest );
- if ( !copied ) {
- setError( UserDefinedError );
- setErrorString( tr("Could not copy %1 to %2: %3.").arg( source, dest, file.errorString() ) );
+ QFile file(source);
+ const bool copied = file.copy(dest);
+ if (!copied) {
+ setError(UserDefinedError);
+ setErrorString(tr("Could not copy %1 to %2: %3.").arg(source, dest, file.errorString()));
return false;
} else {
- addFileToFileList( dest );
+ addFileToFileList(dest);
}
}
return true;
@@ -151,14 +146,14 @@ bool CopyDirectoryOperation::copyFilesFromInternalFileList()
bool CopyDirectoryOperation::removeFilesFromInternalFileList()
{
- const QStringList fileNameList = value( QLatin1String( "files" ) ).toStringList();
+ const QStringList fileNameList = value(QLatin1String("files")).toStringList();
bool result = true;
foreach(const QString fileName, fileNameList) {
- result = result & deleteFileNowOrLater( fileName );
+ result = result & deleteFileNowOrLater(fileName);
}
- const QStringList directoryList = value( QLatin1String( "directories" ) ).toStringList();
+ const QStringList directoryList = value(QLatin1String("directories")).toStringList();
foreach(const QString directory, directoryList) {
QDir().rmdir(directory);
@@ -174,14 +169,14 @@ void CopyDirectoryOperation::backup()
bool CopyDirectoryOperation::performOperation()
{
const QStringList args = arguments();
- if( args.count() != 2 ) {
- setError( InvalidArguments );
- setErrorString( tr("Invalid arguments in %0: %1 arguments given, 2 expected.")
- .arg(name()).arg( args.count() ) );
+ if (args.count() != 2) {
+ setError(InvalidArguments);
+ setErrorString(tr("Invalid arguments in %0: %1 arguments given, 2 expected.")
+ .arg(name()).arg( args.count()));
return false;
}
- const QString sourcePath = args.at( 0 );
- const QString targetPath = args.at( 1 );
+// const QString sourcePath = args.at(0);
+// const QString targetPath = args.at(1);
typedef QList< QPair< QString, QString > > FileList;
@@ -196,28 +191,28 @@ bool CopyDirectoryOperation::performOperation()
bool CopyDirectoryOperation::undoOperation()
{
- Q_ASSERT( arguments().count() == 2 );
+ Q_ASSERT(arguments().count() == 2);
- QFuture< bool > allRemoved = QtConcurrent::run(this, &CopyDirectoryOperation::removeFilesFromInternalFileList);
+ QFuture<bool> allRemoved = QtConcurrent::run(this, &CopyDirectoryOperation::removeFilesFromInternalFileList);
letTheUiRunTillFinished(allRemoved);
return allRemoved.result();
}
-void CopyDirectoryOperation::addFileToFileList( const QString& fileName )
+void CopyDirectoryOperation::addFileToFileList(const QString& fileName)
{
- QStringList files = value( QLatin1String( "files" ) ).toStringList();
- files.push_front( fileName );
- setValue( QLatin1String( "files" ), files );
- emit outputTextChanged( fileName );
+ QStringList files = value(QLatin1String("files")).toStringList();
+ files.push_front(fileName);
+ setValue(QLatin1String("files"), files);
+ emit outputTextChanged(fileName);
}
-void CopyDirectoryOperation::addDirectoryToDirectoryList( const QString& directory )
+void CopyDirectoryOperation::addDirectoryToDirectoryList(const QString& directory)
{
- QStringList directories = value( QLatin1String( "directories" ) ).toStringList();
- directories.push_front( directory );
- setValue( QLatin1String( "directories" ), directories );
- emit outputTextChanged( directory );
+ QStringList directories = value(QLatin1String("directories")).toStringList();
+ directories.push_front(directory);
+ setValue( QLatin1String("directories"), directories);
+ emit outputTextChanged(directory);
}
bool CopyDirectoryOperation::testOperation()
diff --git a/installerbuilder/libinstaller/createdesktopentryoperation.cpp b/installerbuilder/libinstaller/createdesktopentryoperation.cpp
index 57fe6e36f..d514f761e 100644
--- a/installerbuilder/libinstaller/createdesktopentryoperation.cpp
+++ b/installerbuilder/libinstaller/createdesktopentryoperation.cpp
@@ -53,51 +53,50 @@ QString CreateDesktopEntryOperation::absoluteFileName()
const QString filename = arguments().first();
// give filename is already absolute
- if( QFileInfo( filename ).isAbsolute() )
+ if (QFileInfo(filename).isAbsolute())
return filename;
// we're not searching for the first time, let's re-use the old value
- if( hasValue( QLatin1String( "directory" ) ) )
- return QDir( value( QLatin1String( "directory" ) ).toString() ).absoluteFilePath( filename );
+ if (hasValue(QLatin1String("directory")))
+ return QDir(value(QLatin1String("directory")).toString()).absoluteFilePath(filename);
const QProcessEnvironment env;
- QStringList XDG_DATA_DIRS = env.value( QLatin1String( "XDG_DATA_DIRS" ) ).split( QLatin1Char( ':' ), QString::SkipEmptyParts );
- QStringList XDG_DATA_HOME = env.value( QLatin1String( "XDG_DATA_HOME" ) ).split( QLatin1Char( ':' ), QString::SkipEmptyParts );
+ QStringList XDG_DATA_DIRS = env.value(QLatin1String("XDG_DATA_DIRS")).split(QLatin1Char(':'), QString::SkipEmptyParts);
+ QStringList XDG_DATA_HOME = env.value(QLatin1String("XDG_DATA_HOME")).split(QLatin1Char(':'), QString::SkipEmptyParts);
- XDG_DATA_DIRS.push_back( QLatin1String( "/usr/share" ) ); // default path
- XDG_DATA_HOME.push_back( QDir::home().absoluteFilePath( QLatin1String( ".local/share" ) ) ); // default path
+ XDG_DATA_DIRS.push_back(QLatin1String("/usr/share")); // default path
+ XDG_DATA_HOME.push_back(QDir::home().absoluteFilePath(QLatin1String(".local/share"))); // default path
const QStringList directories = XDG_DATA_DIRS + XDG_DATA_HOME;
QString directory;
- for( QStringList::const_iterator it = directories.begin(); it != directories.end(); ++it )
- {
- if( it->isEmpty() )
+ for (QStringList::const_iterator it = directories.begin(); it != directories.end(); ++it) {
+ if (it->isEmpty())
continue;
- directory = QDir( *it ).absoluteFilePath( QLatin1String( "applications" ) );
- QDir dir( directory );
+ directory = QDir(*it).absoluteFilePath(QLatin1String("applications"));
+ QDir dir(directory);
// let's see wheter this dir exists or we're able to create it
- if( !dir.exists() && !QDir().mkpath( directory ) )
+ if (!dir.exists() && !QDir().mkpath(directory))
continue;
// we just try wheter we're able to open the file in ReadWrite
- QFile file( QDir( directory ).absoluteFilePath( filename ) );
+ QFile file(QDir(directory).absoluteFilePath(filename));
const bool existed = file.exists();
- if( !file.open( QIODevice::ReadWrite ) )
+ if (!file.open(QIODevice::ReadWrite))
continue;
file.close();
- if( !existed )
+ if (!existed)
file.remove();
break;
}
- if( !QDir( directory ).exists() )
- QDir().mkpath( directory );
+ if (!QDir(directory).exists())
+ QDir().mkpath(directory);
- setValue( QLatin1String( "directory" ), directory );
+ setValue(QLatin1String("directory"), directory);
- return QDir( directory ).absoluteFilePath( filename );
+ return QDir(directory).absoluteFilePath(filename);
}
/*
@@ -106,71 +105,67 @@ TRANSLATOR QInstaller::CreateDesktopEntryOperation
CreateDesktopEntryOperation::CreateDesktopEntryOperation()
{
- setName( QLatin1String( "CreateDesktopEntry" ) );
+ setName(QLatin1String("CreateDesktopEntry"));
}
CreateDesktopEntryOperation::~CreateDesktopEntryOperation()
{
- deleteFileNowOrLater( value( QLatin1String( "backupOfExistingDesktopEntry" ) ).toString() );
+ deleteFileNowOrLater(value(QLatin1String("backupOfExistingDesktopEntry")).toString());
}
void CreateDesktopEntryOperation::backup()
{
const QString filename = absoluteFileName();
- if( !QFile::exists( filename ) )
+ if (!QFile::exists(filename))
return;
try {
- setValue( QLatin1String( "backupOfExistingDesktopEntry" ), generateTemporaryFileName( filename ) );
- } catch ( const QInstaller::Error& e ) {
- setErrorString( e.message() );
+ setValue(QLatin1String("backupOfExistingDesktopEntry"), generateTemporaryFileName(filename));
+ } catch (const QInstaller::Error& e) {
+ setErrorString(e.message());
return;
}
- if( !QFile::copy( filename, value( QLatin1String( "backupOfExistingDesktopEntry" ) ).toString() ) )
- setErrorString( QObject::tr( "Could not backup file %1" ).arg( filename ) );
+ if (!QFile::copy(filename, value(QLatin1String("backupOfExistingDesktopEntry")).toString()))
+ setErrorString(QObject::tr("Could not backup file %1").arg(filename));
}
bool CreateDesktopEntryOperation::performOperation()
{
const QStringList args = arguments();
- if( args.count() != 2 )
- {
- setError( InvalidArguments );
- setErrorString( tr("Invalid arguments in %0: %1 arguments given, 2 expected.")
- .arg(name()).arg( args.count() ) );
+ if(args.count() != 2) {
+ setError(InvalidArguments);
+ setErrorString(tr("Invalid arguments in %0: %1 arguments given, 2 expected.")
+ .arg(name()).arg(args.count()));
return false;
}
const QString filename = absoluteFileName();
- const QString& values = args[ 1 ];
+ const QString& values = args[1];
- if( QFile::exists( filename ) && !deleteFileNowOrLater( filename ) )
- {
- setError( UserDefinedError );
- setErrorString( tr( "Failed to overwrite %1" ).arg( filename ) );
+ if (QFile::exists(filename) && !deleteFileNowOrLater(filename)) {
+ setError(UserDefinedError);
+ setErrorString(tr("Failed to overwrite %1").arg(filename));
return false;
}
- QFile file( filename );
- if( !file.open( QIODevice::WriteOnly ) )
- {
- setError( UserDefinedError );
- setErrorString( tr( "Could not write Desktop Entry at %1" ).arg( filename ) );
+ QFile file(filename);
+ if(!file.open(QIODevice::WriteOnly)) {
+ setError(UserDefinedError);
+ setErrorString(tr("Could not write Desktop Entry at %1").arg(filename));
return false;
}
QFile::setPermissions(filename, QFile::ReadOwner | QFile::WriteOwner | QFile::ReadUser | QFile::ReadGroup | QFile::ReadOther);
- QTextStream stream( &file );
- stream.setCodec( "UTF-8" );
- stream << QLatin1String( "[Desktop Entry]" ) << endl;
- stream << QLatin1String( "Encoding=UTF-8" ) << endl;
+ QTextStream stream(&file);
+ stream.setCodec("UTF-8");
+ stream << QLatin1String("[Desktop Entry]") << endl;
+ stream << QLatin1String("Encoding=UTF-8") << endl;
// Type=Application\nExec=qtcreator\nPath=...
- const QStringList pairs = values.split( QLatin1Char( '\n' ) );
- for( QStringList::const_iterator it = pairs.begin(); it != pairs.end(); ++it )
- {
+ const QStringList pairs = values.split(QLatin1Char('\n'));
+ for (QStringList::const_iterator it = pairs.begin(); it != pairs.end(); ++it) {
stream << *it << endl;
}
@@ -182,19 +177,18 @@ bool CreateDesktopEntryOperation::undoOperation()
const QString filename = absoluteFileName();
// first remove the link
- if( !deleteFileNowOrLater( filename ) )
- {
- setErrorString( QObject::tr( "Could not delete file %1" ).arg( filename ) );
+ if (!deleteFileNowOrLater(filename)) {
+ setErrorString(QObject::tr("Could not delete file %1").arg(filename));
return false;
}
- if( !hasValue( QLatin1String( "backupOfExistingDesktopEntry" ) ) )
+ if (!hasValue(QLatin1String("backupOfExistingDesktopEntry")))
return true;
- const QString backupOfExistingDesktopEntry = value( QLatin1String( "backupOfExistingDesktopEntry" ) ).toString();
- const bool success = QFile::copy( backupOfExistingDesktopEntry, filename ) && deleteFileNowOrLater( backupOfExistingDesktopEntry );
- if( !success )
- setErrorString( QObject::tr( "Could not restore backup file into %1" ).arg( filename ) );
+ const QString backupOfExistingDesktopEntry = value(QLatin1String("backupOfExistingDesktopEntry")).toString();
+ const bool success = QFile::copy(backupOfExistingDesktopEntry, filename) && deleteFileNowOrLater(backupOfExistingDesktopEntry);
+ if (!success)
+ setErrorString(QObject::tr("Could not restore backup file into %1").arg(filename));
return success;
}
diff --git a/installerbuilder/libinstaller/createshortcutoperation.cpp b/installerbuilder/libinstaller/createshortcutoperation.cpp
index 0aea4af63..ab7e0aff9 100644
--- a/installerbuilder/libinstaller/createshortcutoperation.cpp
+++ b/installerbuilder/libinstaller/createshortcutoperation.cpp
@@ -53,13 +53,13 @@
using namespace QInstaller;
-static bool createLink( QString fileName, QString linkName, QString workingDir, QString arguments = QString() )
+static bool createLink(QString fileName, QString linkName, QString workingDir, QString arguments = QString())
{
#ifdef Q_WS_WIN
bool ret = false;
fileName = QDir::toNativeSeparators(fileName);
linkName = QDir::toNativeSeparators(linkName);
- if ( workingDir.isEmpty() )
+ if (workingDir.isEmpty())
workingDir = QFileInfo(fileName).absolutePath();
workingDir = QDir::toNativeSeparators(workingDir);
@@ -78,8 +78,8 @@ static bool createLink( QString fileName, QString linkName, QString workingDir,
if (SUCCEEDED(hres)) {
hres = psl->SetPath((wchar_t *)fileName.utf16());
- if( SUCCEEDED( hres ) && !arguments.isNull() )
- hres = psl->SetArguments((wchar_t*)arguments.utf16() );
+ if(SUCCEEDED(hres) && !arguments.isNull())
+ hres = psl->SetArguments((wchar_t*)arguments.utf16());
if (SUCCEEDED(hres)) {
hres = psl->SetWorkingDirectory((wchar_t *)workingDir.utf16());
if (SUCCEEDED(hres)) {
@@ -101,9 +101,9 @@ static bool createLink( QString fileName, QString linkName, QString workingDir,
return ret;
#else
- Q_UNUSED( workingDir )
- Q_UNUSED( arguments )
- return QFile::link( fileName, linkName );
+ Q_UNUSED(workingDir)
+ Q_UNUSED(arguments)
+ return QFile::link(fileName, linkName);
#endif
}
@@ -113,25 +113,25 @@ TRANSLATOR QInstaller::CreateShortcutOperation
CreateShortcutOperation::CreateShortcutOperation()
{
- setName( QLatin1String( "CreateShortcut" ) );
+ setName(QLatin1String("CreateShortcut"));
}
CreateShortcutOperation::~CreateShortcutOperation()
{
- deleteFileNowOrLater( value( QLatin1String( "backupOfExistingShortcut" ) ).toString() );
+ deleteFileNowOrLater(value(QLatin1String("backupOfExistingShortcut")).toString());
}
-static bool isWorkingDirOption( const QString& s ) {
- return s.startsWith( QLatin1String("workingDirectory=") );
+static bool isWorkingDirOption(const QString& s) {
+ return s.startsWith(QLatin1String("workingDirectory="));
}
-static QString getWorkingDir( QStringList& args ) {
+static QString getWorkingDir(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 );
- if ( wdiropt != args.end() ) {
- workingDir = wdiropt->mid( QString::fromLatin1("workingDirectory=").size() );
- args.erase( wdiropt );
+ 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);
}
return workingDir;
}
@@ -139,9 +139,9 @@ static QString getWorkingDir( QStringList& args ) {
void CreateShortcutOperation::backup()
{
QStringList args = this->arguments();
- getWorkingDir( args ); //consume workingDirectory= option
+ getWorkingDir(args); //consume workingDirectory= option
- const QString path = QDir::fromNativeSeparators( QFileInfo( args.at( 1 ) ).absolutePath() );
+ const QString path = QDir::fromNativeSeparators(QFileInfo(args.at(1)).absolutePath());
//verbose() << "dir to create shortcut in " << path << std::endl;
@@ -150,20 +150,16 @@ void CreateShortcutOperation::backup()
// find out, which part of the path is the first one we actually need to create
int end = 0;
QStringList directoriesToCreate;
- while( true )
- {
- QString p = path.section( QLatin1String("/"), 0, ++end );
- createdDir = QDir( p );
- if( !createdDir.exists() )
- {
- directoriesToCreate.push_back( QDir::toNativeSeparators( createdDir.absolutePath() ) );
- verbose() << " backup created dir_pre " << QDir::toNativeSeparators( createdDir.absolutePath() ) << std::endl;
- if ( p == path)
+ while (true) {
+ QString p = path.section(QLatin1String("/"), 0, ++end);
+ createdDir = QDir(p);
+ if (!createdDir.exists()) {
+ directoriesToCreate.push_back(QDir::toNativeSeparators(createdDir.absolutePath()));
+ verbose() << " backup created dir_pre " << QDir::toNativeSeparators(createdDir.absolutePath()) << std::endl;
+ if (p == path)
break;
- }
- else if( p == path )
- {
+ } else if(p == path) {
// everything did already exist -> nothing to do for us (nothing to revert then, either)
createdDir = QDir::root();
break;
@@ -171,86 +167,84 @@ void CreateShortcutOperation::backup()
}
verbose() << " backup created dir " << createdDir.absolutePath() << std::endl;
- setValue( QLatin1String( "createddirs" ), directoriesToCreate );
+ setValue(QLatin1String("createddirs"), directoriesToCreate);
//link creation context
- const QString linkLocation = arguments()[ 1 ];
- if( !QFile::exists( linkLocation ) )
+ const QString linkLocation = arguments()[1];
+ if (!QFile::exists(linkLocation))
return;
try {
- setValue( QLatin1String( "backupOfExistingShortcut" ), generateTemporaryFileName( linkLocation ) );
- } catch ( const QInstaller::Error& e ) {
- setErrorString( e.message() );
+ setValue(QLatin1String("backupOfExistingShortcut"), generateTemporaryFileName(linkLocation));
+ } catch (const QInstaller::Error& e) {
+ setErrorString(e.message());
return;
}
- QFile f( linkLocation );
- if( !f.copy( value( QLatin1String( "backupOfExistingShortcut" ) ).toString() ) )
- setErrorString( QObject::tr( "Could not backup file %1: %2" ).arg( linkLocation, f.errorString() ) );
+ QFile f(linkLocation);
+ if (!f.copy(value(QLatin1String("backupOfExistingShortcut")).toString()))
+ setErrorString(QObject::tr("Could not backup file %1: %2").arg(linkLocation, f.errorString()));
}
bool CreateShortcutOperation::performOperation()
{
QStringList args = this->arguments();
- const QString workingDir = getWorkingDir( args );
+ const QString workingDir = getWorkingDir(args);
- if( args.count() != 2 && args.count() != 3 )
- {
- setError( InvalidArguments );
- setErrorString( QObject::tr("Invalid arguments: %1 arguments given, 2 or 3 expected (optional: \"workingDirectory=...\").").arg( args.count() ) );
+ if (args.count() != 2 && args.count() != 3) {
+ setError(InvalidArguments);
+ setErrorString(QObject::tr("Invalid arguments: %1 arguments given, 2 or 3 expected (optional: \"workingDirectory=...\").").arg(args.count()));
return false;
}
- const QString& linkTarget = args.at( 0 );
- const QString& linkLocation = args.at( 1 );
- const QString targetArguments = args.count() == 3 ? args[ 2 ] : QString();
+ const QString& linkTarget = args.at(0);
+ const QString& linkLocation = args.at(1);
+ const QString targetArguments = args.count() == 3 ? args[2] : QString();
- const QString dirName = QFileInfo( linkLocation ).absolutePath();
+ const QString dirName = QFileInfo(linkLocation).absolutePath();
//verbose() << "dir to create shortcut in " << dirName << std::endl;
errno = 0;
- const bool dirAlreadyExists = QDir( dirName ).exists();
+ const bool dirAlreadyExists = QDir(dirName).exists();
const bool created = dirAlreadyExists || QDir::root().mkpath(dirName);
- if ( !created ) {
- setError( UserDefinedError );
- setErrorString( tr("Could not create folder %1: %2.").arg( QDir::toNativeSeparators( dirName ), QLatin1String(strerror(errno)) ) );
+ if (!created) {
+ setError(UserDefinedError);
+ setErrorString(tr("Could not create folder %1: %2.").arg(QDir::toNativeSeparators(dirName), QLatin1String(strerror(errno))));
return false;
}
- TempDirDeleter deleter( dirName );
+ TempDirDeleter deleter(dirName);
- if( dirAlreadyExists )
+ if (dirAlreadyExists)
deleter.releaseAll();
#if 0 // disabled for now, isDir() also returns true if the link exists and points to a folder, then removing it fails
// link creation
- if ( QFileInfo( linkLocation ).isDir() ) {
+ if (QFileInfo(linkLocation).isDir()) {
errno = 0;
- if ( !QDir().rmdir( linkLocation ) ) {
- setError( UserDefinedError );
- setErrorString( QObject::tr( "Could not create link: failed to remove folder %1: %2" ).arg( QDir::toNativeSeparators( linkLocation ), QLatin1String(strerror(errno)) ) );
+ if (!QDir().rmdir(linkLocation)) {
+ setError(UserDefinedError);
+ setErrorString(QObject::tr("Could not create link: failed to remove folder %1: %2").arg(QDir::toNativeSeparators(linkLocation), QLatin1String(strerror(errno))));
return false;
}
}
#endif
- QString err;
+ QString errorString;
- if( QFile::exists( linkLocation ) && !deleteFileNowOrLater( linkLocation, &err ) )
- {
- setError( UserDefinedError );
- setErrorString( QObject::tr( "Failed to overwrite %1: %2" ).arg( QDir::toNativeSeparators( linkLocation ), err ) );
+ if (QFile::exists(linkLocation) && !deleteFileNowOrLater(linkLocation, &errorString)) {
+ setError(UserDefinedError);
+ setErrorString(QObject::tr("Failed to overwrite %1: %2").arg(QDir::toNativeSeparators(linkLocation),errorString));
return false;
}
- const bool linked = createLink( linkTarget, linkLocation, workingDir, targetArguments );
- if ( !linked ) {
- setError( UserDefinedError );
- setErrorString( tr("Could not create link %1: %2").arg( QDir::toNativeSeparators( linkLocation ), qt_error_string() ) );
+ const bool linked = createLink(linkTarget, linkLocation, workingDir, targetArguments);
+ if (!linked) {
+ setError(UserDefinedError);
+ setErrorString(tr("Could not create link %1: %2").arg(QDir::toNativeSeparators(linkLocation), qt_error_string()));
return false;
}
deleter.releaseAll();
@@ -262,70 +256,64 @@ bool CreateShortcutOperation::undoOperation()
const QString linkLocation = arguments()[ 1 ];
const QStringList args = this->arguments();
verbose() << " undo Shortcutoperation with arguments ";
- Q_FOREACH( const QString& val, args )
+ Q_FOREACH(const QString& val, args)
verbose() << val << " ";
verbose() << std::endl;
// first remove the link
- if( !deleteFileNowOrLater( linkLocation ) )
- {
- setErrorString( QObject::tr( "Could not delete file %1" ).arg( linkLocation ) );
+ if (!deleteFileNowOrLater(linkLocation)) {
+ setErrorString(QObject::tr("Could not delete file %1").arg(linkLocation));
return false;
}
verbose() << " link has been deleted " << std::endl;
- if( hasValue( QLatin1String( "backupOfExistingShortcut" ) ) ){
-
- const QString backupOfExistingShortcut = value( QLatin1String( "backupOfExistingShortcut" ) ).toString();
- const bool success = QFile::copy( backupOfExistingShortcut, linkLocation ) && deleteFileNowOrLater( backupOfExistingShortcut );
- if( !success ){
- setErrorString( QObject::tr( "Could not restore backup file into %1" ).arg( linkLocation ) );
+ if (hasValue(QLatin1String("backupOfExistingShortcut"))) {
+ const QString backupOfExistingShortcut = value(QLatin1String("backupOfExistingShortcut")).toString();
+ const bool success = QFile::copy(backupOfExistingShortcut, linkLocation) && deleteFileNowOrLater(backupOfExistingShortcut);
+ if (!success) {
+ setErrorString(QObject::tr("Could not restore backup file into %1").arg(linkLocation));
return success;
}
}
verbose() << " got behin backup " << std::endl;
- const QStringList createdDirsPaths = value( QLatin1String( "createddirs" ) ).toStringList();
- if ( createdDirsPaths.isEmpty() ) //no dir to delete (QDir( createdDirPath ) would return the current working directory -> never do that
+ const QStringList createdDirsPaths = value(QLatin1String("createddirs")).toStringList();
+ if (createdDirsPaths.isEmpty()) //no dir to delete (QDir(createdDirPath) would return the current working directory -> never do that
return true;
- const bool forceremoval = QVariant( value( QLatin1String( "forceremoval" ) ) ).toBool();
- QListIterator<QString> it( createdDirsPaths );
- for ( it.toBack(); it.hasPrevious(); )
- {
+ const bool forceremoval = QVariant(value(QLatin1String("forceremoval"))).toBool();
+ QListIterator<QString> it(createdDirsPaths);
+ for (it.toBack(); it.hasPrevious();) {
const QString createdDirPath = it.previous();
- const QDir createdDir = QDir( createdDirPath );
+ const QDir createdDir = QDir(createdDirPath);
verbose() << createdDir.absolutePath() << std::endl;
- if( createdDir == QDir::root() )
+ if (createdDir == QDir::root())
return true;
QString errorString;
- if( forceremoval )
- {
+ if (forceremoval) {
verbose() << " forced removal of path " << createdDir.path() << std::endl;
try{
- removeDirectory( createdDir.path(), false );
- }catch(const QInstaller::Error e){
- setError( UserDefinedError, e.message() );
+ removeDirectory(createdDir.path(), false);
+ }catch(const QInstaller::Error e) {
+ setError(UserDefinedError, e.message());
return false;
}
- }
- else
- {
+ } else {
// even remove some hidden, OS-created files in there
#if defined Q_WS_MAC
- QFile::remove( createdDir.path() + QLatin1String( "/.DS_Store" ) );
+ QFile::remove(createdDir.path() + QLatin1String("/.DS_Store"));
#elif defined Q_WS_WIN
- QFile::remove( createdDir.path() + QLatin1String( "/Thumbs.db" ) );
+ QFile::remove(createdDir.path() + QLatin1String("/Thumbs.db"));
#endif
errno = 0;
verbose() << " removal of path " << createdDir.path() << std::endl;
- const bool result = QDir::root().rmdir( createdDir.path() );
- if ( !result ) {
- if ( errorString.isEmpty() )
- setError( UserDefinedError, tr("Cannot remove directory %1: %2").arg( createdDir.path(), errorString ) );
+ const bool result = QDir::root().rmdir(createdDir.path());
+ if (!result) {
+ if (errorString.isEmpty())
+ setError(UserDefinedError, tr("Cannot remove directory %1: %2").arg(createdDir.path(), errorString));
else
- setError( UserDefinedError, tr("Cannot remove directory %1: %2").arg( createdDir.path(), QLatin1String(strerror(errno)) ) );
+ setError(UserDefinedError, tr("Cannot remove directory %1: %2").arg(createdDir.path(), QLatin1String(strerror(errno))));
return result;
}
}
diff --git a/installerbuilder/libinstaller/elevatedexecuteoperation.cpp b/installerbuilder/libinstaller/elevatedexecuteoperation.cpp
index 936e855f7..4c5e91093 100644
--- a/installerbuilder/libinstaller/elevatedexecuteoperation.cpp
+++ b/installerbuilder/libinstaller/elevatedexecuteoperation.cpp
@@ -2,7 +2,7 @@
**
** This file is part of Qt SDK**
**
-** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
+** Copyright(c) 2011 Nokia Corporation and/or its subsidiary(-ies).*
**
** Contact: Nokia Corporation qt-info@nokia.com**
**
@@ -27,7 +27,7 @@
** 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you are unsure which license is appropriate for your use, please contact
-** (qt-info@nokia.com).
+**(qt-info@nokia.com).
**
**************************************************************************/
#include "elevatedexecuteoperation.h"
@@ -45,8 +45,8 @@ using namespace QInstaller;
class ElevatedExecuteOperation::Private
{
public:
- explicit Private( ElevatedExecuteOperation* qq )
- : q( qq ), process(0), showStandardError(false)
+ explicit Private(ElevatedExecuteOperation* qq)
+ : q(qq), process(0), showStandardError(false)
{
}
~Private()
@@ -65,10 +65,10 @@ public:
};
ElevatedExecuteOperation::ElevatedExecuteOperation()
- : d( new Private( this ) )
+ : d(new Private(this))
{
// this operation has to "overwrite" the Execute operation from KDUpdater
- setName( QLatin1String( "Execute" ) );
+ setName(QLatin1String("Execute"));
}
ElevatedExecuteOperation::~ElevatedExecuteOperation()
@@ -79,10 +79,10 @@ bool ElevatedExecuteOperation::performOperation()
{
// This operation receives only one argument. It is the complete
// command line of the external program to execute.
- if( arguments().isEmpty() )
+ if (arguments().isEmpty())
{
- setError( InvalidArguments );
- setErrorString( tr("Invalid arguments in %1: %2 arguments given, at least 1 expected.").arg( name(), QString::number( arguments().count() ) ) );
+ setError(InvalidArguments);
+ setErrorString(tr("Invalid arguments in %1: %2 arguments given, at least 1 expected.").arg(name(), QString::number(arguments().count())));
return false;
}
QStringList args;
@@ -109,49 +109,49 @@ bool ElevatedExecuteOperation::Private::run(const QStringList& arguments)
}
- if ( args.last().endsWith( QLatin1String("showStandardError") ) ) {
+ if (args.last().endsWith(QLatin1String("showStandardError"))) {
showStandardError = true;
args.pop_back();
}
QList< int > allowedExitCodes;
- QRegExp re( QLatin1String( "^\\{((-?\\d+,)*-?\\d+)\\}$" ) );
- if( re.exactMatch( args.first() ) )
+ QRegExp re(QLatin1String("^\\{((-?\\d+,)*-?\\d+)\\}$"));
+ if (re.exactMatch(args.first()))
{
- const QStringList numbers = re.cap( 1 ).split( QLatin1Char( ',' ) );
- for( QStringList::const_iterator it = numbers.constBegin(); it != numbers.constEnd(); ++it )
- allowedExitCodes.push_back( it->toInt() );
+ const QStringList numbers = re.cap(1).split(QLatin1Char(','));
+ for(QStringList::const_iterator it = numbers.constBegin(); it != numbers.constEnd(); ++it)
+ allowedExitCodes.push_back(it->toInt());
args.pop_front();
}
else
{
- allowedExitCodes.push_back( 0 );
+ allowedExitCodes.push_back(0);
}
- const QString callstr = args.join( QLatin1String( " " ) );
+ const QString callstr = args.join(QLatin1String(" "));
// unix style: when there's an ampersand after the command, it's started detached
- if( args.count() >= 2 && args.last() == QLatin1String( "&" ) )
+ if (args.count() >= 2 && args.last() == QLatin1String("&"))
{
args.pop_back();
- const bool success = QProcess::startDetached( args.front(), args.mid( 1 ) );
- if ( !success ) {
- q->setError( UserDefinedError );
- q->setErrorString( tr( "Execution failed: Could not start detached: \"%1\"" ).arg( callstr ) );
+ const bool success = QProcess::startDetached(args.front(), args.mid(1));
+ if (!success) {
+ q->setError(UserDefinedError);
+ q->setErrorString(tr("Execution failed: Could not start detached: \"%1\"").arg(callstr));
}
return success;
}
process = new QProcessWrapper();
if (!workingDirectory.isEmpty()) {
- process->setWorkingDirectory( workingDirectory );
+ process->setWorkingDirectory(workingDirectory);
QInstaller::verbose() << " ElevatedExecuteOperation setWorkingDirectory: " << workingDirectory << std::endl;
}
QProcessEnvironment penv;
KDUpdater::Environment *kdEnv = KDUpdater::Environment::instance();
- //there is no way to serialize a QProcessEnvironment properly other than per mangled QStringList:
+ // there is no way to serialize a QProcessEnvironment properly other than per mangled QStringList:
// (i.e. no other way to list all keys)
process->setEnvironment(kdEnv->applyTo(penv).toStringList());
delete kdEnv;
@@ -164,19 +164,19 @@ bool ElevatedExecuteOperation::Private::run(const QStringList& arguments)
//we still like the none blocking possibility to perform this operation without threads
QEventLoop loop;
if (QThread::currentThread() == qApp->thread()) {
- QObject::connect( process, SIGNAL( finished( int, QProcess::ExitStatus ) ), &loop, SLOT( quit() ) );
+ QObject::connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), &loop, SLOT(quit()));
}
//readProcessOutput should only called from this current Thread -> Qt::DirectConnection
- QObject::connect( process, SIGNAL( readyRead() ), q, SLOT( readProcessOutput() ), Qt::DirectConnection );
+ QObject::connect(process, SIGNAL(readyRead()), q, SLOT(readProcessOutput()), Qt::DirectConnection);
#ifdef Q_OS_WIN
if (args.count() == 1) {
- process->setNativeArguments( args.front() );
+ process->setNativeArguments(args.front());
QInstaller::verbose() << " ElevatedExecuteOperation setNativeArguments to start: " << args.front() << std::endl;
process->start(QString(), QStringList());
} else
#endif
- process->start( args.front(), args.mid( 1 ) );
- QInstaller::verbose() << args.front() << " started, arguments: " << QStringList(args.mid( 1 )).join(QLatin1String(" ")) << std::endl;
+ process->start(args.front(), args.mid(1));
+ QInstaller::verbose() << args.front() << " started, arguments: " << QStringList(args.mid(1)).join(QLatin1String(" ")) << std::endl;
bool success = false;
//we still like the none blocking possibility to perform this operation without threads
@@ -187,11 +187,11 @@ bool ElevatedExecuteOperation::Private::run(const QStringList& arguments)
}
bool returnValue = true;
- if ( !success )
+ if (!success)
{
- q->setError( UserDefinedError );
+ q->setError(UserDefinedError);
//TODO: pass errorString() through the wrapper */
- q->setErrorString( tr( "Execution failed: Could not start: \"%1\"" ).arg( callstr ) );
+ q->setErrorString(tr("Execution failed: Could not start: \"%1\"").arg(callstr));
returnValue = false;
}
@@ -202,19 +202,19 @@ bool ElevatedExecuteOperation::Private::run(const QStringList& arguments)
readProcessOutput();
}
- q->setValue( QLatin1String( "ExitCode" ), process->exitCode() );
+ q->setValue(QLatin1String("ExitCode"), process->exitCode());
- if ( process->exitStatus() == QProcess::CrashExit )
+ if (process->exitStatus() == QProcess::CrashExit)
{
- q->setError( UserDefinedError );
- q->setErrorString( tr( "Execution failed (Crash): \"%1\"" ).arg( callstr ) );
+ q->setError(UserDefinedError);
+ q->setErrorString(tr("Execution failed(Crash): \"%1\"").arg(callstr));
returnValue = false;
}
- if ( !allowedExitCodes.contains( process->exitCode() ) )
+ if (!allowedExitCodes.contains(process->exitCode()))
{
- q->setError( UserDefinedError );
- q->setErrorString( tr( "Execution failed (Unexpected exit code: %1): \"%2\"" ).arg( QString::number( process->exitCode() ), callstr ) );
+ q->setError(UserDefinedError);
+ q->setErrorString(tr("Execution failed(Unexpected exit code: %1): \"%2\"").arg(QString::number(process->exitCode()), callstr));
returnValue = false;
}
@@ -242,9 +242,9 @@ void ElevatedExecuteOperation::Private::readProcessOutput()
QInstaller::verbose() << Q_FUNC_INFO << QLatin1String(" can only be called from the same thread as the process is.") << std::endl;
}
const QByteArray output = process->readAll();
- if( !output.isEmpty() ) {
- QInstaller::verbose() << QString::fromLocal8Bit( output ) << std::endl;
- emit q->outputTextChanged( QString::fromLocal8Bit( output ) );
+ if (!output.isEmpty()) {
+ QInstaller::verbose() << QString::fromLocal8Bit(output) << std::endl;
+ emit q->outputTextChanged(QString::fromLocal8Bit(output));
}
}
diff --git a/installerbuilder/libinstaller/environmentvariablesoperation.cpp b/installerbuilder/libinstaller/environmentvariablesoperation.cpp
index 1c2bde7bc..9bffa429c 100644
--- a/installerbuilder/libinstaller/environmentvariablesoperation.cpp
+++ b/installerbuilder/libinstaller/environmentvariablesoperation.cpp
@@ -137,9 +137,9 @@ UpdateOperation::Error undoSetting(const QString &regPath,
bool EnvironmentVariableOperation::performOperation()
{
if (arguments().count() < 2 || arguments().count() > 4) {
- setError( InvalidArguments );
- setErrorString( tr("Invalid arguments in %0: %1 arguments given, 2-3 expected.")
- .arg(name()).arg( arguments().count() ) );
+ setError(InvalidArguments);
+ setErrorString(tr("Invalid arguments in %0: %1 arguments given, 2-3 expected.")
+ .arg(name()).arg( arguments().count()));
return false;
}
@@ -151,8 +151,7 @@ bool EnvironmentVariableOperation::performOperation()
isPersistent = arguments().count() >= 3 ? arguments().at(2) == QLatin1String("true") : true;
const bool isSystemWide = arguments().count() >= 4 ? arguments().at(3) == QLatin1String("true") : false;
QString oldvalue;
- if (isPersistent)
- {
+ if (isPersistent) {
const QString regPath = isSystemWide ? QLatin1String( "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment" )
: QLatin1String( "HKEY_CURRENT_USER\\Environment" );
diff --git a/installerbuilder/libinstaller/extractarchiveoperation.cpp b/installerbuilder/libinstaller/extractarchiveoperation.cpp
index a58cc0071..b5f5252e2 100644
--- a/installerbuilder/libinstaller/extractarchiveoperation.cpp
+++ b/installerbuilder/libinstaller/extractarchiveoperation.cpp
@@ -47,7 +47,7 @@ TRANSLATOR QInstaller::ExtractArchiveOperation
ExtractArchiveOperation::ExtractArchiveOperation()
{
- setName( QLatin1String( "Extract" ) );
+ setName(QLatin1String("Extract"));
}
ExtractArchiveOperation::~ExtractArchiveOperation()
@@ -62,33 +62,33 @@ void ExtractArchiveOperation::backup()
bool ExtractArchiveOperation::performOperation()
{
const QStringList args = arguments();
- if( args.count() != 2 ) {
- setError( InvalidArguments );
- setErrorString( tr("Invalid arguments in %0: %1 arguments given, 2 expected.")
- .arg(name()).arg( args.count() ) );
+ if (args.count() != 2) {
+ setError(InvalidArguments);
+ setErrorString(tr("Invalid arguments in %0: %1 arguments given, 2 expected.")
+ .arg(name()).arg(args.count()));
return false;
}
const QString archivePath = args.first();
- const QString targetDir = args.at( 1 );
+ const QString targetDir = args.at(1);
Receiver receiver;
Callback callback;
//usually we have to connect it as queued connection but then some blocking work is in the main thread
- connect( &callback, SIGNAL(progressChanged(QString)), this, SLOT(slotProgressChanged(QString)), Qt::DirectConnection );
- connect( &callback, SIGNAL(progressChanged(int)), this, SIGNAL(progressChanged(int)), Qt::QueuedConnection );
+ connect(&callback, SIGNAL(progressChanged(QString)), this, SLOT(slotProgressChanged(QString)), Qt::DirectConnection);
+ connect(&callback, SIGNAL(progressChanged(int)), this, SIGNAL(progressChanged(int)), Qt::QueuedConnection);
- if(QInstaller::Installer *installer = this->value( QLatin1String( "installer" )).value<QInstaller::Installer*>()) {
- connect( installer, SIGNAL( statusChanged( QInstaller::Installer::Status ) ), &callback,
- SLOT( statusChanged( QInstaller::Installer::Status ) ), Qt::QueuedConnection );
+ if (QInstaller::Installer *installer = this->value(QLatin1String("installer")).value<QInstaller::Installer*>()) {
+ connect(installer, SIGNAL(statusChanged(QInstaller::Installer::Status)), &callback,
+ SLOT(statusChanged(QInstaller::Installer::Status)), Qt::QueuedConnection);
}
//Runnable is derived from QRunable which will be deleted by the ThreadPool -> no parent is needed
- Runnable* runnable = new Runnable( archivePath, targetDir, &callback );
- connect( runnable, SIGNAL(finished(bool,QString)), &receiver, SLOT(runnableFinished(bool,QString)), Qt::QueuedConnection );
+ Runnable* runnable = new Runnable(archivePath, targetDir, &callback);
+ connect(runnable, SIGNAL(finished(bool,QString)), &receiver, SLOT(runnableFinished(bool,QString)), Qt::QueuedConnection);
QEventLoop loop;
- connect( &receiver, SIGNAL( finished() ), &loop, SLOT( quit() ) );
+ connect(&receiver, SIGNAL(finished()), &loop, SLOT(quit()));
if (QThreadPool::globalInstance()->tryStart(runnable)) {
loop.exec();
} else {
@@ -104,21 +104,21 @@ bool ExtractArchiveOperation::performOperation()
//TODO use backups for rollback, too? doesn't work for uninstallation though
//delete all backups we can delete right now, remember the rest
- Q_FOREACH( const StringPair& i, backupFiles )
- deleteFileNowOrLater( i.second );
+ Q_FOREACH(const StringPair& i, backupFiles)
+ deleteFileNowOrLater(i.second);
- if ( !receiver.success ) {
- setError( UserDefinedError );
- setErrorString( receiver.errorString );
+ if (!receiver.success) {
+ setError(UserDefinedError);
+ setErrorString(receiver.errorString);
return false;
}
return true;
}
-WorkerThread::WorkerThread( ExtractArchiveOperation *op, const QStringList &files, QObject* parent )
- : QThread( parent )
- , m_files( files )
- , m_op( op )
+WorkerThread::WorkerThread(ExtractArchiveOperation *op, const QStringList &files, QObject* parent)
+ : QThread(parent)
+ , m_files(files)
+ , m_op(op)
{
}
@@ -127,53 +127,49 @@ WorkerThread::WorkerThread( ExtractArchiveOperation *op, const QStringList &file
*/
void WorkerThread::run()
{
- ExtractArchiveOperation* const op = m_op;//dynamic_cast< ExtractArchiveOperation* >( parent() );
- Q_ASSERT( op != 0 );
+ ExtractArchiveOperation* const op = m_op;//dynamic_cast< ExtractArchiveOperation* >(parent());
+ Q_ASSERT(op != 0);
int progress = -1;
int index = 0;
const int count = m_files.count();
- Q_FOREACH( const QString &file, m_files )
- {
- const QFileInfo fi( file );
- emit outputTextChanged( file );
- if( fi.isFile() || fi.isSymLink() )
- {
- op->deleteFileNowOrLater( fi.absoluteFilePath() );
- }
- else if( fi.isDir() )
- {
+ Q_FOREACH(const QString &file, m_files) {
+ const QFileInfo fi(file);
+ emit outputTextChanged(file);
+ if (fi.isFile() || fi.isSymLink()) {
+ op->deleteFileNowOrLater(fi.absoluteFilePath());
+ } else if (fi.isDir()) {
const QDir d = fi.dir();
// even remove some hidden, OS-created files in there
#if defined Q_WS_MAC
- op->deleteFileNowOrLater( file + QLatin1String( "/.DS_Store" ) );
+ op->deleteFileNowOrLater(file + QLatin1String("/.DS_Store"));
#elif defined Q_WS_WIN
- op->deleteFileNowOrLater( file + QLatin1String( "/Thumbs.db" ) );
+ op->deleteFileNowOrLater(file + QLatin1String("/Thumbs.db"));
#endif
- d.rmdir( file ); // directory may not exist
+ d.rmdir(file); // directory may not exist
}
const int newProgress = (index++) * 100 / count;
- if( progress != newProgress )
- emit progressChanged( newProgress );
+ if (progress != newProgress)
+ emit progressChanged(newProgress);
progress = newProgress;
}
}
bool ExtractArchiveOperation::undoOperation()
{
- Q_ASSERT( arguments().count() == 2 );
+ Q_ASSERT(arguments().count() == 2);
//const QString archivePath = arguments().first();
//const QString targetDir = arguments().last();
- const QStringList m_files = value( QLatin1String( "files" ) ).toStringList();
+ const QStringList m_files = value(QLatin1String("files")).toStringList();
- WorkerThread* const thread = new WorkerThread( this, m_files );
+ WorkerThread* const thread = new WorkerThread(this, m_files);
connect(thread, SIGNAL(outputTextChanged(QString)),
this, SIGNAL(outputTextChanged(QString)), Qt::QueuedConnection);
- connect( thread, SIGNAL( progressChanged( int ) ), this, SIGNAL( progressChanged( int ) ), Qt::QueuedConnection );
+ connect(thread, SIGNAL(progressChanged(int)), this, SIGNAL(progressChanged(int)), Qt::QueuedConnection);
QEventLoop loop;
- connect( thread, SIGNAL(finished()), &loop, SLOT( quit() ), Qt::QueuedConnection );
+ connect(thread, SIGNAL(finished()), &loop, SLOT(quit()), Qt::QueuedConnection);
thread->start();
loop.exec();
thread->deleteLater();
@@ -191,10 +187,10 @@ ExtractArchiveOperation* ExtractArchiveOperation::clone() const
}
//this slot is direct connected to the caller so please don't call it from another thread in the same time
-void ExtractArchiveOperation::slotProgressChanged( const QString& filename )
+void ExtractArchiveOperation::slotProgressChanged(const QString& filename)
{
- QStringList m_files = value( QLatin1String( "files" ) ).toStringList();
- m_files.push_front( filename );
- setValue( QLatin1String( "files" ), m_files );
- emit outputTextChanged( filename );
+ QStringList m_files = value(QLatin1String("files")).toStringList();
+ m_files.push_front(filename);
+ setValue(QLatin1String("files"), m_files);
+ emit outputTextChanged(filename);
}
diff --git a/installerbuilder/libinstaller/installiconsoperation.cpp b/installerbuilder/libinstaller/installiconsoperation.cpp
index eaf9e32a7..91cff906c 100644
--- a/installerbuilder/libinstaller/installiconsoperation.cpp
+++ b/installerbuilder/libinstaller/installiconsoperation.cpp
@@ -57,57 +57,57 @@ TRANSLATOR QInstaller::InstallIconsOperation
QString InstallIconsOperation::targetDirectory()
{
// we're not searching for the first time, let's re-use the old value
- if( hasValue( QLatin1String( "targetdirectory" ) ) )
- return value( QLatin1String( "targetdirectory" ) ).toString();
+ if (hasValue(QLatin1String("targetdirectory")))
+ return value(QLatin1String("targetdirectory")).toString();
#if QT_VERSION >= 0x040600
const QProcessEnvironment env;
- QStringList XDG_DATA_DIRS = env.value( QLatin1String( "XDG_DATA_DIRS" ) ).split( QLatin1Char( ':' ), QString::SkipEmptyParts );
+ QStringList XDG_DATA_DIRS = env.value(QLatin1String("XDG_DATA_DIRS")).split(QLatin1Char(':'), QString::SkipEmptyParts);
#else
const QStringList env = QProcess::systemEnvironment();
QStringList XDG_DATA_DIRS;
- for( QStringList::const_iterator it = env.begin(); it != env.end(); ++it )
+ for(QStringList::const_iterator it = env.begin(); it != env.end(); ++it)
{
- if( it->startsWith( QLatin1String( "XDG_DATA_DIRS=" ) ) )
- XDG_DATA_DIRS = it->mid( it->indexOf( QLatin1Char( '=' ) ) + 1 ).split( QLatin1Char( ':' ) );
+ if (it->startsWith(QLatin1String("XDG_DATA_DIRS=")))
+ XDG_DATA_DIRS = it->mid(it->indexOf(QLatin1Char('=')) + 1).split(QLatin1Char(':'));
}
#endif
- XDG_DATA_DIRS.push_back( QLatin1String( "/usr/share" ) ); // default path
- XDG_DATA_DIRS.push_back( QDir::home().absoluteFilePath( QLatin1String( ".icons" ) ) ); // default path
+ XDG_DATA_DIRS.push_back(QLatin1String("/usr/share")); // default path
+ XDG_DATA_DIRS.push_back(QDir::home().absoluteFilePath(QLatin1String(".icons"))); // default path
const QStringList& directories = XDG_DATA_DIRS;
QString directory;
- for( QStringList::const_iterator it = directories.begin(); it != directories.end(); ++it )
+ for(QStringList::const_iterator it = directories.begin(); it != directories.end(); ++it)
{
- if( it->isEmpty() )
+ if (it->isEmpty())
continue;
- if( it + 1 == directories.end() )
- directory = QDir( *it ).absolutePath();
+ if (it + 1 == directories.end())
+ directory = QDir(*it).absolutePath();
else
- directory = QDir( *it ).absoluteFilePath( QLatin1String( "icons" ) );
- QDir dir( directory );
+ directory = QDir(*it).absoluteFilePath(QLatin1String("icons"));
+ QDir dir(directory);
// let's see wheter this dir exists or we're able to create it
- if( !dir.exists() && !QDir().mkpath( directory ) )
+ if (!dir.exists() && !QDir().mkpath(directory))
continue;
// we just try wheter we're able to open the file in ReadWrite
- QFile file( QDir( directory ).absoluteFilePath( QLatin1String( "tmpfile" ) ) );
+ QFile file(QDir(directory).absoluteFilePath(QLatin1String("tmpfile")));
const bool existed = file.exists();
- if( !file.open( QIODevice::ReadWrite ) )
+ if (!file.open(QIODevice::ReadWrite))
continue;
file.close();
- if( !existed )
+ if (!existed)
file.remove();
break;
}
- if( !QDir( directory ).exists() )
- QDir().mkpath( directory );
+ if (!QDir(directory).exists())
+ QDir().mkpath(directory);
- setValue( QLatin1String( "directory" ), directory );
+ setValue(QLatin1String("directory"), directory);
return directory;
@@ -115,16 +115,16 @@ QString InstallIconsOperation::targetDirectory()
InstallIconsOperation::InstallIconsOperation()
{
- setName( QLatin1String( "InstallIcons" ) );
+ setName(QLatin1String("InstallIcons"));
}
InstallIconsOperation::~InstallIconsOperation()
{
- const QStringList backupFiles = value( QLatin1String( "backupfiles" ) ).toStringList();
- for( QStringList::const_iterator it = backupFiles.begin(); it != backupFiles.end(); it += 2 )
+ const QStringList backupFiles = value(QLatin1String("backupfiles")).toStringList();
+ for(QStringList::const_iterator it = backupFiles.begin(); it != backupFiles.end(); it += 2)
{
- const QString& backup = *( it + 1 );
- deleteFileNowOrLater( backup );
+ const QString& backup = *(it + 1);
+ deleteFileNowOrLater(backup);
}
}
@@ -136,24 +136,22 @@ void InstallIconsOperation::backup()
bool InstallIconsOperation::performOperation()
{
const QStringList args = arguments();
- if( args.count() != 1 )
- {
- setError( InvalidArguments );
- setErrorString( tr("Invalid arguments in %0: %1 arguments given, 1 expected.")
- .arg(name()).arg( args.count() ) );
+ if (args.count() != 1) {
+ setError(InvalidArguments);
+ setErrorString(tr("Invalid arguments in %0: %1 arguments given, 1 expected.")
+ .arg(name()).arg(args.count()));
return false;
}
const QString source = args.first();
- if( source.isEmpty() )
- {
- setError( InvalidArguments );
- setErrorString( QObject::tr("Invalid Argument: source folder must not be empty.") );
+ if (source.isEmpty()) {
+ setError(InvalidArguments);
+ setErrorString(QObject::tr("Invalid Argument: source folder must not be empty."));
return false;
}
- const QDir sourceDir = QDir( source );
- const QDir targetDir = QDir( targetDirectory() );
+ const QDir sourceDir = QDir(source);
+ const QDir targetDir = QDir(targetDirectory());
QStringList files;
QStringList backupFiles;
@@ -163,58 +161,52 @@ bool InstallIconsOperation::performOperation()
int currentItem = 0;
// iterate a first time to count the items (for proper progress)
- QDirIterator itCount( sourceDir.path(), QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot, QDirIterator::Subdirectories );
- while( itCount.hasNext() )
- {
+ QDirIterator itCount(sourceDir.path(), QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
+ while (itCount.hasNext()) {
itCount.next();
++numItems;
}
- Installer* const installer = qVariantValue< Installer* >( value( QLatin1String( "installer" ) ) );
+ Installer* const installer = qVariantValue< Installer* >(value(QLatin1String("installer")));
// iterate a second time to get the actual work done
- QDirIterator it( sourceDir.path(), QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot, QDirIterator::Subdirectories );
- while( it.hasNext() )
- {
+ QDirIterator it(sourceDir.path(), QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
+ while (it.hasNext()) {
qApp->processEvents();
const int status = installer->status();
- if( status == Installer::Canceled || status == Installer::Failure )
+ if(status == Installer::Canceled || status == Installer::Failure)
return true;
const QString source = it.next();
- const QString target = targetDir.absoluteFilePath( sourceDir.relativeFilePath( source ) );
+ const QString target = targetDir.absoluteFilePath(sourceDir.relativeFilePath(source));
- emit outputTextChanged( target );
- emit progressChanged( ++currentItem * 100 / numItems );
+ emit outputTextChanged(target);
+ emit progressChanged(++currentItem * 100 / numItems);
const QFileInfo fi = it.fileInfo();
- if( !fi.isDir() )
- {
- if( QFile( target ).exists() )
- {
+ if (!fi.isDir()) {
+ if (QFile(target).exists()) {
// first backup...
- const QString backup = generateTemporaryFileName( target + QLatin1String("XXXXXX") );
- QFile bf( target );
- if( !bf.copy( backup ) )
- {
- setError( UserDefinedError );
- setErrorString( QObject::tr( "Could not backup file %1: %2" ).arg( target, bf.errorString() ) );
+ const QString backup = generateTemporaryFileName(target + QLatin1String("XXXXXX"));
+ QFile bf(target);
+ if (!bf.copy(backup)) {
+ setError(UserDefinedError);
+ setErrorString(QObject::tr("Could not backup file %1: %2").arg(target, bf.errorString()));
undoOperation();
return false;
}
- backupFiles.push_back( target );
- backupFiles.push_back( backup );
- setValue( QLatin1String( "backupfiles" ), backupFiles );
+ backupFiles.push_back(target);
+ backupFiles.push_back(backup);
+ setValue(QLatin1String("backupfiles"), backupFiles);
// then delete it
QString errStr;
- if( !deleteFileNowOrLater( target, &errStr ) )
- {
- setError( UserDefinedError );
- setErrorString( QObject::tr( "Failed to overwrite %1: %2" ).arg( target, errStr ) );
+ if (!deleteFileNowOrLater(target, &errStr)) {
+ setError(UserDefinedError);
+ setErrorString(QObject::tr("Failed to overwrite %1: %2").arg(target, errStr));
undoOperation();
return false;
}
@@ -222,39 +214,33 @@ bool InstallIconsOperation::performOperation()
}
// copy the file to its new location
- QFile cf( source );
- if( !cf.copy( target ) )
- {
- setError( UserDefinedError );
- setErrorString( QObject::tr( "Failed to copy file %1: %2" ).arg( target, cf.errorString() ) );
+ QFile cf(source);
+ if (!cf.copy(target)) {
+ setError(UserDefinedError);
+ setErrorString(QObject::tr("Failed to copy file %1: %2").arg(target, cf.errorString()));
undoOperation();
return false;
}
- deleteFileNowOrLater( source );
- files.push_back( source );
- files.push_back( target );
- setValue( QLatin1String( "files" ), files );
- }
- else if( fi.isDir() && !QDir( target ).exists() )
- {
- if( !QDir().mkpath( target ) )
- {
- setErrorString( QObject::tr( "Could not create folder at %1: %2" ).arg( target, qt_error_string() ) );
+ deleteFileNowOrLater(source);
+ files.push_back(source);
+ files.push_back(target);
+ setValue(QLatin1String("files"), files);
+ } else if (fi.isDir() && !QDir(target).exists()) {
+ if (!QDir().mkpath(target)) {
+ setErrorString(QObject::tr("Could not create folder at %1: %2").arg(target, qt_error_string()));
undoOperation();
return false;
}
- createdDirectories.push_front( target );
- setValue( QLatin1String( "createddirectories" ), createdDirectories );
+ createdDirectories.push_front(target);
+ setValue(QLatin1String("createddirectories"), createdDirectories);
}
}
// this should work now if not, it's not _that_ problematic...
- try
- {
- removeDirectory( source );
+ try {
+ removeDirectory(source);
}
- catch( ... )
- {
+ catch(...) {
}
// reached this? cool :-)
@@ -266,51 +252,48 @@ bool InstallIconsOperation::undoOperation()
bool success = true;
// first copy back all files to their origin
- const QStringList files = value( QLatin1String( "files" ) ).toStringList();
- for( QStringList::const_iterator it = files.begin(); it != files.end(); it += 2 )
- {
+ const QStringList files = value(QLatin1String("files")).toStringList();
+ for (QStringList::const_iterator it = files.begin(); it != files.end(); it += 2) {
qApp->processEvents();
const QString& source = *it;
- const QString& target = *( it + 1 );
+ const QString& target = *(it + 1);
// first make sure the "source" path is valid
- QDir().mkpath( QFileInfo( source ).absolutePath() );
+ QDir().mkpath(QFileInfo(source).absolutePath());
// now copy target to source (feels weird, I know...)
- success = QFile::copy( target, source ) && success;
+ success = QFile::copy(target, source) && success;
// and remove target
- success = QFile::remove( target ) && success;
+ success = QFile::remove(target) && success;
}
// then copy back and remove all backuped files
- const QStringList backupFiles = value( QLatin1String( "backupfiles" ) ).toStringList();
- for( QStringList::const_iterator it = backupFiles.begin(); it != backupFiles.end(); it += 2 )
- {
+ const QStringList backupFiles = value(QLatin1String("backupfiles")).toStringList();
+ for (QStringList::const_iterator it = backupFiles.begin(); it != backupFiles.end(); it += 2) {
const QString& target = *it;
- const QString& backup = *( it + 1 );
+ const QString& backup = *(it + 1);
// remove the target
- if( QFile::exists( target ) )
- success = deleteFileNowOrLater( target ) && success;
+ if (QFile::exists(target))
+ success = deleteFileNowOrLater(target) && success;
// then copy the backup onto the target
- success = QFile::copy( backup, target ) && success;
+ success = QFile::copy(backup, target) && success;
// finally remove the backp
- success = deleteFileNowOrLater( backup ) && success;
+ success = deleteFileNowOrLater(backup) && success;
}
// then remove all directories created by us
- const QStringList createdDirectories = value( QLatin1String( "createddirectories" ) ).toStringList();
- for( QStringList::const_iterator it = createdDirectories.begin(); it != createdDirectories.end(); ++it )
- {
- const QDir dir( *it );
+ const QStringList createdDirectories = value(QLatin1String("createddirectories")).toStringList();
+ for(QStringList::const_iterator it = createdDirectories.begin(); it != createdDirectories.end(); ++it) {
+ const QDir dir(*it);
// even remove some hidden, OS-created files in there
#if defined Q_WS_MAC
- QFile::remove( dir.absoluteFilePath( QLatin1String( ".DS_Store" ) ) );
+ QFile::remove(dir.absoluteFilePath(QLatin1String(".DS_Store")));
#elif defined Q_WS_WIN
- QFile::remove( dir.absoluteFilePath( QLatin1String( "/Thumbs.db" ) ) );
+ QFile::remove(dir.absoluteFilePath(QLatin1String("/Thumbs.db")));
#endif
- success = QDir::root().rmdir( dir.path() );
+ success = QDir::root().rmdir(dir.path());
}
return success;
diff --git a/installerbuilder/libinstaller/libinstaller.pro b/installerbuilder/libinstaller/libinstaller.pro
index 3b9dccfd1..6d9c00681 100644
--- a/installerbuilder/libinstaller/libinstaller.pro
+++ b/installerbuilder/libinstaller/libinstaller.pro
@@ -90,7 +90,8 @@ HEADERS += $$PWD/qinstaller.h \
messageboxhandler.h \
getrepositoriesmetainfojob.h \
licenseoperation.h \
- qinstallercomponent_p.h
+ qinstallercomponent_p.h \
+ qtcreator_constants.h
SOURCES += $$PWD/qinstaller.cpp \
$$PWD/qinstaller_p.cpp \
diff --git a/installerbuilder/libinstaller/licenseoperation.cpp b/installerbuilder/libinstaller/licenseoperation.cpp
index 406ae2a17..968cc6b25 100644
--- a/installerbuilder/libinstaller/licenseoperation.cpp
+++ b/installerbuilder/libinstaller/licenseoperation.cpp
@@ -63,7 +63,13 @@ bool LicenseOperation::performOperation()
return false;
}
- Installer *installer = qVariantValue<Installer*>(value(QLatin1String("installer")));
+ const Installer* const installer = qVariantValue<Installer*>(value(QLatin1String("installer")));
+ if (!installer) {
+ setError( UserDefinedError );
+ setErrorString(tr("Needed installer object in \"%1\" operation is empty.").arg(name()));
+ return false;
+ }
+
QString targetDir = QString::fromLatin1("%1/%2").arg(installer->value(QLatin1String("TargetDir")),
QLatin1String("Licenses"));
diff --git a/installerbuilder/libinstaller/qinstaller.cpp b/installerbuilder/libinstaller/qinstaller.cpp
index e3c1217bf..eec25f30b 100644
--- a/installerbuilder/libinstaller/qinstaller.cpp
+++ b/installerbuilder/libinstaller/qinstaller.cpp
@@ -252,7 +252,6 @@ QString QInstaller::uncaughtExceptionString(QScriptEngine *scriptEngine/*, const
Non-existing page - this value has to be used if you want to insert a page after \a InstallationFinished
*/
-
KDUpdater::Application& Installer::updaterApplication() const
{
return *d->m_app;
@@ -553,6 +552,15 @@ bool Installer::isFileExtensionRegistered(const QString& extension) const
// -- QInstaller
+/*!
+ Used by operation runner to get a fake installer, can be removed if installerbase can do what operation
+ runner does.
+*/
+Installer::Installer()
+ : d(new InstallerPrivate())
+{
+}
+
Installer::Installer(qint64 magicmaker,
const QVector<KDUpdater::UpdateOperation*>& performedOperations)
: d(new InstallerPrivate(this, magicmaker, performedOperations))
@@ -572,7 +580,10 @@ Installer::~Installer()
QInstaller::VerboseWriter::instance()->setOutputStream(logFileName);
}
- d->m_FSEngineClientHandler->setActive(false);
+ // check for fake installer case
+ if (d->m_FSEngineClientHandler)
+ d->m_FSEngineClientHandler->setActive(false);
+
delete d;
}
diff --git a/installerbuilder/libinstaller/qinstaller.h b/installerbuilder/libinstaller/qinstaller.h
index d12cd4755..9294b237c 100644
--- a/installerbuilder/libinstaller/qinstaller.h
+++ b/installerbuilder/libinstaller/qinstaller.h
@@ -78,8 +78,8 @@ class INSTALLER_EXPORT Installer : public QObject
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
public:
- explicit Installer(qint64 magicmaker = 0,
- const QVector<KDUpdater::UpdateOperation*> &performedOperations
+ Installer();
+ explicit Installer(qint64 magicmaker, const QVector<KDUpdater::UpdateOperation*> &performedOperations
= QVector< KDUpdater::UpdateOperation*>());
~Installer();
@@ -138,7 +138,7 @@ public:
// parameter handling
Q_INVOKABLE void setValue(const QString &key, const QString &value);
- Q_INVOKABLE QString value(const QString &key, const QString &defaultValue = QString()) const;
+ virtual Q_INVOKABLE QString value(const QString &key, const QString &defaultValue = QString()) const;
Q_INVOKABLE bool containsValue(const QString &key) const;
//a way to have global flags share able from a component script to another one
diff --git a/installerbuilder/libinstaller/qinstaller_p.cpp b/installerbuilder/libinstaller/qinstaller_p.cpp
index d61edac2f..cbf448dfd 100644
--- a/installerbuilder/libinstaller/qinstaller_p.cpp
+++ b/installerbuilder/libinstaller/qinstaller_p.cpp
@@ -175,6 +175,14 @@ static void deferredRename(const QString &oldName, const QString &newName, bool
// -- InstallerPrivate
+InstallerPrivate::InstallerPrivate()
+ : m_tempDirDeleter(0)
+ , m_installerSettings(0)
+ , m_FSEngineClientHandler(0)
+ , q(0)
+{
+}
+
InstallerPrivate::InstallerPrivate(Installer *installer, qint64 magicInstallerMaker,
const QVector<KDUpdater::UpdateOperation*> &performedOperations)
: m_app(0)
diff --git a/installerbuilder/libinstaller/qinstaller_p.h b/installerbuilder/libinstaller/qinstaller_p.h
index 4333fcc66..93979683d 100644
--- a/installerbuilder/libinstaller/qinstaller_p.h
+++ b/installerbuilder/libinstaller/qinstaller_p.h
@@ -68,6 +68,7 @@ public:
Undo
};
+ InstallerPrivate();
explicit InstallerPrivate(Installer *q, qint64 magicInstallerMaker,
const QVector<KDUpdater::UpdateOperation*> &performedOperations);
~InstallerPrivate();
diff --git a/installerbuilder/libinstaller/qtcreator_constants.h b/installerbuilder/libinstaller/qtcreator_constants.h
new file mode 100644
index 000000000..f398bd6b3
--- /dev/null
+++ b/installerbuilder/libinstaller/qtcreator_constants.h
@@ -0,0 +1,30 @@
+#ifndef QTCREATOR_CONSTANTS_H
+#define QTCREATOR_CONSTANTS_H
+
+
+#if defined ( Q_OS_MAC )
+ static const char *const QtCreatorSettingsSuffixPath =
+ "/Qt Creator.app/Contents/Resources/Nokia/QtCreator.ini";
+#else
+ static const char *const QtCreatorSettingsSuffixPath =
+ "/QtCreator/share/qtcreator/Nokia/QtCreator.ini";
+#endif
+
+#if defined ( Q_OS_MAC )
+ static const char *const ToolChainSettingsSuffixPath =
+ "/Qt Creator.app/Contents/Resources/Nokia/toolChains.xml";
+#else
+ static const char *const ToolChainSettingsSuffixPath =
+ "/QtCreator/share/qtcreator/Nokia/toolChains.xml";
+#endif
+
+//Begin - copied from Creator
+static const char *const TOOLCHAIN_DATA_KEY = "ToolChain.";
+static const char *const TOOLCHAIN_COUNT_KEY = "ToolChain.Count";
+static const char *const TOOLCHAIN_FILE_VERSION_KEY = "Version";
+
+static const char *const ID_KEY = "ProjectExplorer.ToolChain.Id";
+static const char *const DISPLAY_NAME_KEY = "ProjectExplorer.ToolChain.DisplayName";
+//End - copied from Creator
+
+#endif //QTCREATOR_CONSTANTS_H
diff --git a/installerbuilder/libinstaller/qtpatchoperation.cpp b/installerbuilder/libinstaller/qtpatchoperation.cpp
index 4017626cb..e6da1ee18 100644
--- a/installerbuilder/libinstaller/qtpatchoperation.cpp
+++ b/installerbuilder/libinstaller/qtpatchoperation.cpp
@@ -52,63 +52,63 @@ 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();
QByteArray oldValue;
- oldValue = qmakeValueHash.value( QLatin1String("QT_INSTALL_PREFIX") );
- replaceMap.insert( QByteArray("qt_prfxpath=%1").replace( "%1", oldValue ),
- QByteArray("qt_prfxpath=%1/").replace( "%1/", newQtPath ) );
+ oldValue = qmakeValueHash.value(QLatin1String("QT_INSTALL_PREFIX"));
+ replaceMap.insert(QByteArray("qt_prfxpath=%1").replace("%1", oldValue),
+ QByteArray("qt_prfxpath=%1/").replace("%1/", newQtPath));
- oldValue = qmakeValueHash.value( QLatin1String("QT_INSTALL_DOCS") );
- replaceMap.insert( QByteArray("qt_docspath=%1").replace( "%1", oldValue ),
- QByteArray("qt_docspath=%1/doc").replace( "%1/", newQtPath + nativeSeperator ) );
+ oldValue = qmakeValueHash.value(QLatin1String("QT_INSTALL_DOCS"));
+ replaceMap.insert(QByteArray("qt_docspath=%1").replace("%1", oldValue),
+ QByteArray("qt_docspath=%1/doc").replace("%1/", newQtPath + nativeSeperator));
- oldValue = qmakeValueHash.value( QLatin1String("QT_INSTALL_HEADERS") );
- replaceMap.insert( QByteArray("qt_hdrspath=%1").replace( "%1", oldValue ),
- QByteArray("qt_hdrspath=%1/include").replace( "%1/", newQtPath + nativeSeperator ) );
+ oldValue = qmakeValueHash.value(QLatin1String("QT_INSTALL_HEADERS"));
+ replaceMap.insert(QByteArray("qt_hdrspath=%1").replace("%1", oldValue),
+ QByteArray("qt_hdrspath=%1/include").replace("%1/", newQtPath + nativeSeperator));
- oldValue = qmakeValueHash.value( QLatin1String("QT_INSTALL_LIBS") );
- replaceMap.insert( QByteArray("qt_libspath=%1").replace( "%1", oldValue ),
- QByteArray("qt_libspath=%1/lib").replace( "%1/", newQtPath + nativeSeperator ) );
+ oldValue = qmakeValueHash.value(QLatin1String("QT_INSTALL_LIBS"));
+ replaceMap.insert(QByteArray("qt_libspath=%1").replace("%1", oldValue),
+ QByteArray("qt_libspath=%1/lib").replace("%1/", newQtPath + nativeSeperator));
- oldValue = qmakeValueHash.value( QLatin1String("QT_INSTALL_BINS") );
- replaceMap.insert( QByteArray("qt_binspath=%1").replace( "%1", oldValue ),
- QByteArray("qt_binspath=%1/bin").replace( "%1/", newQtPath + nativeSeperator ) );
+ oldValue = qmakeValueHash.value(QLatin1String("QT_INSTALL_BINS"));
+ replaceMap.insert(QByteArray("qt_binspath=%1").replace("%1", oldValue),
+ QByteArray("qt_binspath=%1/bin").replace("%1/", newQtPath + nativeSeperator));
- oldValue = qmakeValueHash.value( QLatin1String("QT_INSTALL_PLUGINS") );
- replaceMap.insert( QByteArray("qt_plugpath=%1").replace( "%1", oldValue ),
- QByteArray("qt_plugpath=%1/plugins").replace( "%1/", newQtPath + nativeSeperator ) );
+ oldValue = qmakeValueHash.value(QLatin1String("QT_INSTALL_PLUGINS"));
+ replaceMap.insert(QByteArray("qt_plugpath=%1").replace("%1", oldValue),
+ QByteArray("qt_plugpath=%1/plugins").replace("%1/", newQtPath + nativeSeperator));
- oldValue = qmakeValueHash.value( QLatin1String("QT_INSTALL_IMPORTS") );
- replaceMap.insert( QByteArray("qt_impspath=%1").replace( "%1", oldValue ),
- QByteArray("qt_impspath=%1/imports").replace( "%1/", newQtPath + nativeSeperator ) );
+ oldValue = qmakeValueHash.value(QLatin1String("QT_INSTALL_IMPORTS"));
+ replaceMap.insert(QByteArray("qt_impspath=%1").replace("%1", oldValue),
+ QByteArray("qt_impspath=%1/imports").replace("%1/", newQtPath + nativeSeperator));
- oldValue = qmakeValueHash.value( QLatin1String("QT_INSTALL_DATA") );
- replaceMap.insert( QByteArray("qt_datapath=%1").replace( "%1", oldValue ),
- QByteArray("qt_datapath=%1/").replace( "%1/", newQtPath + nativeSeperator ) );
+ oldValue = qmakeValueHash.value(QLatin1String("QT_INSTALL_DATA"));
+ replaceMap.insert( QByteArray("qt_datapath=%1").replace("%1", oldValue),
+ QByteArray("qt_datapath=%1/").replace("%1/", newQtPath + nativeSeperator));
- oldValue = qmakeValueHash.value( QLatin1String("QT_INSTALL_TRANSLATIONS") );
- replaceMap.insert( QByteArray("qt_trnspath=%1").replace( "%1", oldValue ),
- QByteArray("qt_trnspath=%1/translations").replace( "%1/", newQtPath + nativeSeperator ) );
+ oldValue = qmakeValueHash.value(QLatin1String("QT_INSTALL_TRANSLATIONS"));
+ replaceMap.insert( QByteArray("qt_trnspath=%1").replace("%1", oldValue),
+ QByteArray("qt_trnspath=%1/translations").replace("%1/", newQtPath + nativeSeperator));
// This must not be patched. Commenting out to fix QTSDK-429
-// oldValue = qmakeValueHash.value( QLatin1String("QT_INSTALL_CONFIGURATION"));
-// replaceMap.insert( QByteArray("qt_stngpath=%1").replace( "%1", oldValue),
-// QByteArray("qt_stngpath=%1").replace( "%1", newQtPath));
+// oldValue = qmakeValueHash.value(QLatin1String("QT_INSTALL_CONFIGURATION"));
+// replaceMap.insert( QByteArray("qt_stngpath=%1").replace("%1", oldValue),
+// QByteArray("qt_stngpath=%1").replace("%1", newQtPath));
//examples and demoes can patched outside separately,
//but for cosmetic reasons - if the qt version gets no examples later.
- oldValue = qmakeValueHash.value( QLatin1String("QT_INSTALL_EXAMPLES") );
- replaceMap.insert( QByteArray("qt_xmplpath=%1").replace( "%1", oldValue ),
- QByteArray("qt_xmplpath=%1/examples").replace( "%1/", newQtPath + nativeSeperator ) );
+ oldValue = qmakeValueHash.value(QLatin1String("QT_INSTALL_EXAMPLES"));
+ replaceMap.insert( QByteArray("qt_xmplpath=%1").replace("%1", oldValue),
+ QByteArray("qt_xmplpath=%1/examples").replace("%1/", newQtPath + nativeSeperator));
- oldValue = qmakeValueHash.value( QLatin1String("QT_INSTALL_DEMOS") );
- replaceMap.insert( QByteArray("qt_demopath=%1").replace( "%1", oldValue ),
- QByteArray("qt_demopath=%1/demos").replace( "%1/", newQtPath + nativeSeperator ) );
+ oldValue = qmakeValueHash.value(QLatin1String("QT_INSTALL_DEMOS"));
+ replaceMap.insert( QByteArray("qt_demopath=%1").replace("%1", oldValue),
+ QByteArray("qt_demopath=%1/demos").replace("%1/", newQtPath + nativeSeperator));
return replaceMap;
}
@@ -134,10 +134,10 @@ bool QtPatchOperation::performOperation()
// 1. type
// 2. new/target qtpath
- if( arguments().count() != 2 ) {
- setError( InvalidArguments );
- setErrorString( tr("Invalid arguments in %0: %1 arguments given, 2 expected.")
- .arg(name()).arg( arguments().count() ) );
+ if(arguments().count() != 2) {
+ setError(InvalidArguments);
+ setErrorString(tr("Invalid arguments in %0: %1 arguments given, 2 expected.")
+ .arg(name()).arg(arguments().count()));
return false;
}
@@ -148,11 +148,11 @@ bool QtPatchOperation::performOperation()
type.contains(QLatin1String("mac"), Qt::CaseInsensitive);
if (!isPlatformSupported)
{
- setError( InvalidArguments );
- setErrorString( tr("First argument should be 'linux', 'mac' or 'windows'. No other type is supported at this time.") );
+ setError(InvalidArguments);
+ setErrorString(tr("First argument should be 'linux', 'mac' or 'windows'. No other type is supported at this time."));
return false;
}
- const QString newQtPathStr = QDir::toNativeSeparators( arguments().at(1) );
+ const QString newQtPathStr = QDir::toNativeSeparators(arguments().at(1));
const QByteArray newQtPath = newQtPathStr.toUtf8();
QString qmakePath = QString::fromUtf8(newQtPath) + QLatin1String("/bin/qmake");
@@ -162,10 +162,10 @@ bool QtPatchOperation::performOperation()
if (!QFile::exists(qmakePath))
{
- setError( UserDefinedError );
- setErrorString( tr("QMake from the current Qt version \n(%1)" \
+ setError(UserDefinedError);
+ setErrorString(tr("QMake from the current Qt version \n(%1)" \
"is not existing. Please make a bugreport with this dialog at http://bugreports.qt.nokia.com.\n" \
- ).arg(QDir::toNativeSeparators(qmakePath)));
+ ).arg(QDir::toNativeSeparators(qmakePath)));
return false;
}
@@ -174,35 +174,35 @@ bool QtPatchOperation::performOperation()
if (qmakeValueHash.isEmpty())
{
- setError( UserDefinedError );
- setErrorString( tr("The output of \n%1 -query\n" \
+ setError(UserDefinedError);
+ setErrorString(tr("The output of \n%1 -query\n" \
"is not parseable. Please make a bugreport with this dialog http://bugreports.qt.nokia.com.\n" \
"output: \"%2\"").arg(QDir::toNativeSeparators(qmakePath), QString::fromUtf8(qmakeOutput)));
return false;
}
- const QByteArray oldQtPath = qmakeValueHash.value( QLatin1String("QT_INSTALL_PREFIX") );
+ const QByteArray oldQtPath = qmakeValueHash.value(QLatin1String("QT_INSTALL_PREFIX"));
bool oldQtPathFromQMakeIsEmpty = oldQtPath.isEmpty();
//maybe we don't need this, but I 255 should be a rational limit
if (255 < newQtPath.size()) {
- setError( UserDefinedError );
- setErrorString( tr("Qt patch error: new Qt dir(%1)\n" \
- "needs to be less than 255 characters.").arg(newQtPathStr) );
+ setError(UserDefinedError);
+ setErrorString(tr("Qt patch error: new Qt dir(%1)\n" \
+ "needs to be less than 255 characters.").arg(newQtPathStr));
return false;
}
QFile patchFileListFile;
- if( type == QLatin1String("windows") )
- patchFileListFile.setFileName( QLatin1String(":/files-to-patch-windows") );
- else if( type == QLatin1String("linux") )
- patchFileListFile.setFileName( QLatin1String(":/files-to-patch-linux") );
+ if(type == QLatin1String("windows"))
+ patchFileListFile.setFileName(QLatin1String(":/files-to-patch-windows"));
+ else if(type == QLatin1String("linux"))
+ patchFileListFile.setFileName(QLatin1String(":/files-to-patch-linux"));
else if (type == QLatin1String("mac"))
- patchFileListFile.setFileName( QLatin1String(":/files-to-patch-macx") );
+ patchFileListFile.setFileName(QLatin1String(":/files-to-patch-macx"));
if (! patchFileListFile.open(QFile::ReadOnly)) {
- setError( UserDefinedError );
- setErrorString( tr("Qt patch error: Can not open %1.").arg(patchFileListFile.fileName()) );
+ setError(UserDefinedError);
+ setErrorString(tr("Qt patch error: Can not open %1.").arg(patchFileListFile.fileName()));
return false;
}
@@ -234,7 +234,7 @@ bool QtPatchOperation::performOperation()
QString prefix = QFile::decodeName(newQtPath);
- if (! prefix.endsWith(QLatin1Char('/')) )
+ if (! prefix.endsWith(QLatin1Char('/')))
prefix += QLatin1Char('/');
//BEGIN - patch binary files
@@ -250,8 +250,8 @@ bool QtPatchOperation::performOperation()
}
if (!QtPatch::openFileForPatching(&file)) {
- setError( UserDefinedError );
- setErrorString( tr("Qt patch error: Can not open %1(%2).").arg(file.fileName()).arg(file.errorString()) );
+ setError(UserDefinedError);
+ setErrorString(tr("Qt patch error: Can not open %1(%2).").arg(file.fileName()).arg(file.errorString()));
return false;
}
@@ -308,24 +308,28 @@ bool QtPatchOperation::performOperation()
#ifdef Q_OS_MAC
Relocator relocator;
bool successMacRelocating = false;
- QInstaller::Installer *installer = value(QLatin1String("installer")).value<QInstaller::Installer*>();
+ const Installer* const installer = qVariantValue<Installer*>(value(QLatin1String("installer")));
+ if (!installer) {
+ setError(UserDefinedError);
+ setErrorString(tr("Needed installer object in \"%1\" operation is empty.").arg(name()));
+ return false;
+ }
Q_CHECK_PTR(installer);
successMacRelocating = relocator.apply(newQtPathStr, installer->value(QLatin1String("TargetDir")));
if (!successMacRelocating)
{
- setError( UserDefinedError );
+ setError(UserDefinedError);
setErrorString(tr("Error while relocating Qt: %1").arg(relocator.errorMessage()));
return false;
}
#endif
- if (oldQtPathFromQMakeIsEmpty)
- {
- setError( UserDefinedError );
- setErrorString( tr("The installer was not able to get the unpatched path from \n%1.(maybe it is broken or removed)\n" \
+ if (oldQtPathFromQMakeIsEmpty) {
+ setError(UserDefinedError);
+ setErrorString(tr("The installer was not able to get the unpatched path from \n%1.(maybe it is broken or removed)\n" \
"It tried to patch the Qt binaries, but all other files in Qt are unpatched.\n" \
"This could result in a broken Qt version.\n" \
"Sometimes it helps to restart the installer with a switched off antivirus software."
- ).arg(QDir::toNativeSeparators(qmakePath)));
+ ).arg(QDir::toNativeSeparators(qmakePath)));
return false;
}
diff --git a/installerbuilder/libinstaller/registerdocumentationoperation.cpp b/installerbuilder/libinstaller/registerdocumentationoperation.cpp
index 3b8352e92..1e334a0ca 100644
--- a/installerbuilder/libinstaller/registerdocumentationoperation.cpp
+++ b/installerbuilder/libinstaller/registerdocumentationoperation.cpp
@@ -89,10 +89,10 @@ bool RegisterDocumentationOperation::performOperation()
{
const QStringList args = arguments();
- if( args.count() != 1 ) {
- setError( InvalidArguments );
- setErrorString( tr("Invalid arguments in %0: %1 arguments given, 1 expected.")
- .arg(name()).arg( args.count() ) );
+ if (args.count() != 1) {
+ setError(InvalidArguments);
+ setErrorString(tr("Invalid arguments in %0: %1 arguments given, 1 expected.")
+ .arg(name()).arg( args.count()));
return false;
}
const QString helpFile = args.at(0);
@@ -106,8 +106,8 @@ bool RegisterDocumentationOperation::performOperation()
const QString collectionFile = settingsDir.absolutePath() + QLatin1String("/helpcollection.qhc");
qDebug() << "collectionFile: " << collectionFile;
- if ( !QFileInfo( helpFile ).exists() ) {
- setError ( UserDefinedError );
+ if (!QFileInfo( helpFile ).exists()) {
+ setError(UserDefinedError);
setErrorString( tr("Could not register help file %1: File not found.").arg( helpFile ) );
return false;
}
@@ -131,7 +131,7 @@ bool RegisterDocumentationOperation::undoOperation()
settingsDir.mkpath(settingsDir.absolutePath());
const QString collectionFile = settingsDir.absolutePath() + QLatin1String("/helpcollection.qhc");
- if ( !QFileInfo( helpFile ).exists() ) {
+ if (!QFileInfo( helpFile ).exists()) {
setError ( UserDefinedError );
setErrorString( tr("Could not unregister help file %1: File not found.").arg( helpFile ) );
return false;
diff --git a/installerbuilder/libinstaller/registerfiletypeoperation.cpp b/installerbuilder/libinstaller/registerfiletypeoperation.cpp
index c2c2c88db..21000cf9e 100644
--- a/installerbuilder/libinstaller/registerfiletypeoperation.cpp
+++ b/installerbuilder/libinstaller/registerfiletypeoperation.cpp
@@ -60,10 +60,9 @@ bool RegisterFileTypeOperation::performOperation()
// (content type)
// (icon)
#ifdef Q_WS_WIN
- if( arguments().count() < 2 || arguments().count() > 5 )
- {
- setError( InvalidArguments );
- setErrorString( tr("Invalid arguments in %0").arg(name()) );
+ if (arguments().count() < 2 || arguments().count() > 5) {
+ setError(InvalidArguments);
+ setErrorString(tr("Invalid arguments in %0").arg(name()));
return false;
}
const QString extension = arguments()[ 0 ];
@@ -75,46 +74,44 @@ bool RegisterFileTypeOperation::performOperation()
const QString settingsPrefix = QString::fromLatin1( "Software/Classes/" );
//QSettings settings( QLatin1String( "HKEY_CLASSES_ROOT" ), QSettings::NativeFormat );
- QSettings settings( QLatin1String( "HKEY_CURRENT_USER" ), QSettings::NativeFormat );
+ QSettings settings(QLatin1String("HKEY_CURRENT_USER"), QSettings::NativeFormat);
// first backup the old values
- setValue( QLatin1String( "oldClass" ), settings.value( QString::fromLatin1( "%1.%2/Default" ).arg( settingsPrefix, extension ) ) );
- setValue( QLatin1String( "oldContentType" ), settings.value( QString::fromLatin1( "%1.%2/Content Type" ).arg( settingsPrefix, extension ) ) );
+ setValue(QLatin1String("oldClass"), settings.value(QString::fromLatin1("%1.%2/Default").arg(settingsPrefix, extension)));
+ setValue(QLatin1String("oldContentType"), settings.value(QString::fromLatin1("%1.%2/Content Type").arg(settingsPrefix, extension)));
// the file extension was not yet registered. Let's do so now
- settings.setValue( QString::fromLatin1( "%1.%2/Default" ).arg( settingsPrefix, extension ),
- className );
+ settings.setValue(QString::fromLatin1("%1.%2/Default").arg(settingsPrefix, extension), className);
// register the content type, if given
- if( !contentType.isEmpty() )
- settings.setValue( QString::fromLatin1( "%1.%2/Content Type" ).arg( settingsPrefix, extension ),
- contentType );
+ if (!contentType.isEmpty())
+ settings.setValue(QString::fromLatin1("%1.%2/Content Type").arg(settingsPrefix, extension), contentType);
//const QString className = settings.value( QString::fromLatin1( ".%1/Default" ).arg( extension ) ).toString();
//const QString oldClassName = value( QString::fromLatin1( ".%1/Default" ).arg( extension ) ).toString();
- setValue( QLatin1String( "className" ), className );
+ setValue(QLatin1String("className"), className);
// setValue( QLatin1String( "oldDescription" ), settings.value( QString::fromLatin1( "%1/Default" ).arg( oldClassName ) ) );
// setValue( QLatin1String( "oldIcon" ), settings.value( QString::fromLatin1( "%1/DefaultIcon/Default" ).arg( oldClassName ) ) );
// setValue( QLatin1String( "oldCommand" ), settings.value( QString::fromLatin1( "%1/shell/Open/Command/Default" ).arg( oldClassName ) ) );
// register the description, if given
- if( !description.isEmpty() )
- settings.setValue( QString::fromLatin1( "%1%2/Default" ).arg( settingsPrefix, className ),
- description );
+ if (!description.isEmpty())
+ settings.setValue(QString::fromLatin1("%1%2/Default").arg(settingsPrefix, className), description);
// register the icon, if given
- if( !icon.isEmpty() )
- settings.setValue( QString::fromLatin1( "%1%2/DefaultIcon/Default" ).arg( settingsPrefix, className ),
- icon );
+ if (!icon.isEmpty()) {
+ settings.setValue(QString::fromLatin1("%1%2/DefaultIcon/Default").arg(settingsPrefix,
+ className), icon);
+ }
// register the command to open the file
- settings.setValue( QString::fromLatin1( "%1%2/shell/Open/Command/Default" ).arg( settingsPrefix, className ),
- command );
+ settings.setValue(QString::fromLatin1("%1%2/shell/Open/Command/Default").arg(settingsPrefix,
+ className), command );
return true;
#else
- setError( UserDefinedError );
- setErrorString( QObject::tr( "Registering file types in only supported on Windows." ) );
+ setError(UserDefinedError);
+ setErrorString(QObject::tr("Registering file types in only supported on Windows."));
return false;
#endif
}
@@ -127,61 +124,65 @@ bool RegisterFileTypeOperation::undoOperation()
// (content type)
// (icon)
#ifdef Q_WS_WIN
- if( arguments().count() < 2 || arguments().count() > 5 )
- {
- setErrorString( tr("Register File Type: Invalid arguments") );
+ if (arguments().count() < 2 || arguments().count() > 5) {
+ setErrorString(tr("Register File Type: Invalid arguments"));
return false;
}
- const QString extension = arguments()[ 0 ];
- const QString command = arguments()[ 1 ];
- const QString description = arguments().count() > 2 ? arguments()[ 2 ] : QString(); // optional
- const QString contentType = arguments().count() > 3 ? arguments()[ 3 ] : QString(); // optional
- const QString icon = arguments().count() > 4 ? arguments()[ 4 ] : QString(); // optional
- const QString className = QString::fromLatin1( "%1_auto_file" ).arg( extension );
- const QString settingsPrefix = QString::fromLatin1( "Software/Classes/" );
+ const QString extension = arguments()[0];
+ const QString command = arguments()[1];
+ const QString description = arguments().count() > 2 ? arguments()[2] : QString(); // optional
+ const QString contentType = arguments().count() > 3 ? arguments()[3] : QString(); // optional
+ const QString icon = arguments().count() > 4 ? arguments()[4] : QString(); // optional
+ const QString className = QString::fromLatin1("%1_auto_file").arg(extension);
+ const QString settingsPrefix = QString::fromLatin1("Software/Classes/");
- QSettings settings( QLatin1String( "HKEY_CURRENT_USER" ), QSettings::NativeFormat );
+ QSettings settings(QLatin1String("HKEY_CURRENT_USER"), QSettings::NativeFormat);
- const QString restoredClassName = value( QLatin1String( "oldClassName" ) ).toString();
+ const QString restoredClassName = value(QLatin1String("oldClassName")).toString();
// register the command to open the file
- if( settings.value( QString::fromLatin1( "%1%2/shell/Open/Command/Default" ).arg( settingsPrefix, className ) ).toString() != command )
+ if (settings.value(QString::fromLatin1("%1%2/shell/Open/Command/Default").arg(settingsPrefix, className)).toString() != command)
return false;
- if( settings.value( QString::fromLatin1( "%1%2/DefaultIcon/Default" ).arg( settingsPrefix, className ) ).toString() != icon )
+ if (settings.value(QString::fromLatin1("%1%2/DefaultIcon/Default").arg(settingsPrefix, className)).toString() != icon)
return false;
- if( settings.value( QString::fromLatin1( "%1%2/Default" ).arg( settingsPrefix, className ) ).toString() != description )
+ if (settings.value(QString::fromLatin1("%1%2/Default").arg(settingsPrefix, className)).toString() != description)
return false;
- if( settings.value( QString::fromLatin1( "%1.%2/Content Type" ).arg( settingsPrefix, extension ) ).toString() != contentType )
+ if (settings.value(QString::fromLatin1("%1.%2/Content Type").arg(settingsPrefix, extension)).toString() != contentType)
return false;
- if( settings.value( QString::fromLatin1( "%1.%2/Default" ).arg( settingsPrefix, extension ) ).toString() != className )
+ if (settings.value(QString::fromLatin1("%1.%2/Default").arg(settingsPrefix, extension)).toString() != className)
return false;
- const QVariant oldCommand = value( QLatin1String( "oldCommand" ) );
- if( !oldCommand.isNull() )
- settings.setValue( QString::fromLatin1( "%1%2/shell/Open/Command/Default" ).arg( settingsPrefix, restoredClassName ),
- oldCommand );
- else
- settings.remove( QString::fromLatin1( "%1%2/shell/Open/Command/Default" ).arg( settingsPrefix, className ) );
+ const QVariant oldCommand = value(QLatin1String("oldCommand"));
+ if (!oldCommand.isNull()) {
+ settings.setValue(QString::fromLatin1("%1%2/shell/Open/Command/Default").arg(settingsPrefix,
+ restoredClassName ), oldCommand);
+ } else {
+ settings.remove(QString::fromLatin1("%1%2/shell/Open/Command/Default").arg(settingsPrefix,
+ className));
+ }
// register the icon, if given
- const QVariant oldIcon = value( QLatin1String( "oldIcon" ) );
- if( !oldIcon.isNull() )
- settings.setValue( QString::fromLatin1( "%1%2/DefaultIcon/Default" ).arg( settingsPrefix, restoredClassName ),
- oldIcon );
- else
- settings.remove( QString::fromLatin1( "%1%2/DefaultIcon/Default" ).arg( settingsPrefix, className ) );
+ const QVariant oldIcon = value(QLatin1String("oldIcon"));
+ if (!oldIcon.isNull()) {
+ settings.setValue(QString::fromLatin1("%1%2/DefaultIcon/Default").arg( settingsPrefix,
+ restoredClassName), oldIcon);
+ } else {
+ settings.remove(QString::fromLatin1("%1%2/DefaultIcon/Default").arg(settingsPrefix,
+ className));
+ }
// register the description, if given
- const QVariant oldDescription = value( QLatin1String( "oldDescription" ) );
- if( !oldDescription.isNull() )
- settings.setValue( QString::fromLatin1( "%1%2/Default" ).arg( settingsPrefix, restoredClassName ),
- oldDescription );
- else
- settings.remove( QString::fromLatin1( "%1%2/Default" ).arg( settingsPrefix, className ) );
+ const QVariant oldDescription = value(QLatin1String("oldDescription"));
+ if (!oldDescription.isNull()) {
+ settings.setValue(QString::fromLatin1("%1%2/Default").arg(settingsPrefix, restoredClassName),
+ oldDescription );
+ } else {
+ settings.remove(QString::fromLatin1("%1%2/Default").arg(settingsPrefix, className));
+ }
// content type
- settings.remove( QString::fromLatin1( "%1%2" ).arg( settingsPrefix, className ) );
+ settings.remove(QString::fromLatin1("%1%2").arg(settingsPrefix, className));
const QVariant oldContentType = value( QLatin1String( "oldContentType" ) );
if( !oldContentType.isNull() )
diff --git a/installerbuilder/libinstaller/registerqtoperation.cpp b/installerbuilder/libinstaller/registerqtoperation.cpp
index e7c915dc1..f5555c253 100644
--- a/installerbuilder/libinstaller/registerqtoperation.cpp
+++ b/installerbuilder/libinstaller/registerqtoperation.cpp
@@ -31,6 +31,7 @@
**
**************************************************************************/
#include "registerqtoperation.h"
+#include "qtcreator_constants.h"
#include <QString>
#include <QFileInfo>
@@ -58,9 +59,9 @@ bool RegisterQtInCreatorOperation::performOperation()
const QStringList args = arguments();
if( args.count() < 3) {
- setError( InvalidArguments );
- setErrorString( tr("Invalid arguments in %0: %1 arguments given, minimum 3 expected.")
- .arg(name()).arg( args.count() ) );
+ setError(InvalidArguments);
+ setErrorString(tr("Invalid arguments in %0: %1 arguments given, minimum 3 expected.")
+ .arg(name()).arg( args.count()));
return false;
}
@@ -86,15 +87,8 @@ bool RegisterQtInCreatorOperation::performOperation()
if (args.count() >= 9)
sbsPath = args.at(8);
-#if defined ( Q_OS_MAC )
- QSettings settings( QString( QLatin1String("%1/Qt Creator.app/Contents/Resources/Nokia/QtCreator.ini")
- ).arg(rootInstallPath),
- QSettings::IniFormat );
-#else
- QSettings settings( QString( QLatin1String("%1/QtCreator/share/qtcreator/Nokia/QtCreator.ini")
- ).arg(rootInstallPath),
- QSettings::IniFormat );
-#endif
+ QSettings settings(rootInstallPath + QLatin1String(QtCreatorSettingsSuffixPath),
+ QSettings::IniFormat);
QString newVersions;
QStringList oldNewQtVersions = settings.value(QLatin1String("NewQtVersions")
diff --git a/installerbuilder/libinstaller/registerqtv2operation.cpp b/installerbuilder/libinstaller/registerqtv2operation.cpp
index 81c7dc2d8..0767194c3 100644
--- a/installerbuilder/libinstaller/registerqtv2operation.cpp
+++ b/installerbuilder/libinstaller/registerqtv2operation.cpp
@@ -32,6 +32,7 @@
**************************************************************************/
#include "registerqtv2operation.h"
#include "qinstaller.h"
+#include "qtcreator_constants.h"
#include <QString>
#include <QFileInfo>
@@ -41,14 +42,6 @@
using namespace QInstaller;
-#if defined ( Q_OS_MAC )
- static const char *QtCreatorSettingsSuffixPath =
- "/Qt Creator.app/Contents/Resources/Nokia/QtCreator.ini";
-#else
- static const char *QtCreatorSettingsSuffixPath =
- "/QtCreator/share/qtcreator/Nokia/QtCreator.ini";
-#endif
-
RegisterQtInCreatorV2Operation::RegisterQtInCreatorV2Operation()
{
setName(QLatin1String("RegisterQtInCreatorV2"));
@@ -66,15 +59,25 @@ bool RegisterQtInCreatorV2Operation::performOperation()
{
const QStringList args = arguments();
- if( args.count() < 2) {
- setError( InvalidArguments );
+ if (args.count() < 2) {
+ setError(InvalidArguments);
setErrorString( tr("Invalid arguments in %0: %1 arguments given, minimum 2 expected.")
.arg(name()).arg( args.count() ) );
return false;
}
- const Installer* const installer = qVariantValue< Installer* >( value( QLatin1String( "installer" ) ) );
+ const Installer* const installer = qVariantValue<Installer*>(value(QLatin1String("installer")));
+ if (!installer) {
+ setError(UserDefinedError);
+ setErrorString(tr("Needed installer object in \"%1\" operation is empty.").arg(name()));
+ return false;
+ }
const QString &rootInstallPath = installer->value(QLatin1String("TargetDir"));
+ if (rootInstallPath.isEmpty() || !QDir(rootInstallPath).exists()) {
+ setError(UserDefinedError);
+ setErrorString(tr("The given TargetDir %1 is not a valid/existing dir.").arg(rootInstallPath));
+ return false;
+ }
int argCounter = 0;
const QString &versionName = args.value(argCounter++);
@@ -132,20 +135,25 @@ bool RegisterQtInCreatorV2Operation::undoOperation()
const QStringList args = arguments();
if (args.count() < 2) {
- setError( InvalidArguments );
+ setError(InvalidArguments);
setErrorString( tr("Invalid arguments in %0: %1 arguments given, minimum 2 expected.")
.arg(name()).arg( args.count() ) );
return false;
}
- const Installer* const installer = qVariantValue< Installer* >( value( QLatin1String( "installer" ) ) );
+ const Installer* const installer = qVariantValue<Installer*>(value(QLatin1String("installer")));
+ if (!installer) {
+ setError(UserDefinedError);
+ setErrorString(tr("Needed installer object in \"%1\" operation is empty.").arg(name()));
+ return false;
+ }
const QString &rootInstallPath = installer->value(QLatin1String("TargetDir"));
int argCounter = 0;
const QString &versionName = args.value(argCounter++);
const QString &path = args.value(argCounter++);
QString qmakePath = QDir(path).absolutePath();
- if ( !qmakePath.endsWith(QLatin1String("qmake"))
+ if (!qmakePath.endsWith(QLatin1String("qmake"))
|| !qmakePath.endsWith(QLatin1String("qmake.exe")))
{
#if defined ( Q_OS_WIN )
diff --git a/installerbuilder/libinstaller/registertoolchainoperation.cpp b/installerbuilder/libinstaller/registertoolchainoperation.cpp
index 4c2cd8946..905b6d1d3 100644
--- a/installerbuilder/libinstaller/registertoolchainoperation.cpp
+++ b/installerbuilder/libinstaller/registertoolchainoperation.cpp
@@ -33,6 +33,7 @@
#include "registertoolchainoperation.h"
#include "persistentsettings.h"
#include "qinstaller.h"
+#include "qtcreator_constants.h"
#include <QString>
#include <QFileInfo>
@@ -42,25 +43,8 @@
using namespace QInstaller;
-//Begin - copied from Creator
using namespace ProjectExplorer;
-static const char *const TOOLCHAIN_DATA_KEY = "ToolChain.";
-static const char *const TOOLCHAIN_COUNT_KEY = "ToolChain.Count";
-static const char *const TOOLCHAIN_FILE_VERSION_KEY = "Version";
-
-static const char *const ID_KEY = "ProjectExplorer.ToolChain.Id";
-static const char *const DISPLAY_NAME_KEY = "ProjectExplorer.ToolChain.DisplayName";
-//End - copied from Creator
-
-#if defined ( Q_OS_MAC )
- static const char *ToolChainSettingsSuffixPath =
- "/Qt Creator.app/Contents/Resources/Nokia/toolChains.xml";
-#else
- static const char *ToolChainSettingsSuffixPath =
- "/QtCreator/share/qtcreator/Nokia/toolChains.xml";
-#endif
-
RegisterToolChainOperation::RegisterToolChainOperation()
{
setName(QLatin1String("RegisterToolChain"));
@@ -79,13 +63,18 @@ bool RegisterToolChainOperation::performOperation()
const QStringList args = arguments();
if (args.count() < 4) {
- setError( InvalidArguments );
- setErrorString( tr("Invalid arguments in %0: %1 arguments given, minimum 4 expected.")
- .arg(name()).arg( args.count() ) );
+ setError(InvalidArguments);
+ setErrorString(tr("Invalid arguments in %0: %1 arguments given, minimum 4 expected.")
+ .arg(name()).arg(args.count()));
return false;
}
- const Installer* const installer = qVariantValue<Installer*>( value(QLatin1String("installer")));
+ const Installer* const installer = qVariantValue<Installer*>(value(QLatin1String("installer")));
+ if (!installer) {
+ setError(UserDefinedError);
+ setErrorString(tr("Needed installer object in \"%1\" operation is empty.").arg(name()));
+ return false;
+ }
const QString &rootInstallPath = installer->value(QLatin1String("TargetDir"));
int argCounter = 0;
@@ -117,7 +106,7 @@ bool RegisterToolChainOperation::performOperation()
// Check version:
int version = data.value(QLatin1String(TOOLCHAIN_FILE_VERSION_KEY), 0).toInt();
if (version < 1) {
- setError( UserDefinedError );
+ setError(UserDefinedError);
setErrorString(tr("Toolchain settings xml file %1 has not the right version.")
.arg(toolChainsXmlFilePath));
return false;
@@ -177,14 +166,19 @@ bool RegisterToolChainOperation::undoOperation()
const QStringList args = arguments();
if (args.count() < 4) {
- setError( InvalidArguments );
- setErrorString( tr("Invalid arguments in %0: %1 arguments given, minimum 4 expected.")
- .arg(name()).arg( args.count() ) );
+ setError(InvalidArguments);
+ setErrorString(tr("Invalid arguments in %0: %1 arguments given, minimum 4 expected.")
+ .arg(name()).arg(args.count()));
return false;
}
const Installer* const installer = qVariantValue< Installer* >( value( QLatin1String( "installer" ) ) );
const QString &rootInstallPath = installer->value(QLatin1String("TargetDir"));
+ if (rootInstallPath.isEmpty() || !QDir(rootInstallPath).exists()) {
+ setError(UserDefinedError);
+ setErrorString(tr("The given TargetDir %1 is not a valid/existing dir.").arg(rootInstallPath));
+ return false;
+ }
int argCounter = 0;
const QString &toolChainKey = args.at(argCounter++); //Qt SDK:gccPath
@@ -219,7 +213,7 @@ bool RegisterToolChainOperation::undoOperation()
// Check version:
int version = data.value(QLatin1String(TOOLCHAIN_FILE_VERSION_KEY), 0).toInt();
if (version < 1) {
- setError( UserDefinedError );
+ setError(UserDefinedError);
setErrorString(tr("Toolchain settings xml file %1 has not the right version.")
.arg(toolChainsXmlFilePath));
return false;
diff --git a/installerbuilder/libinstaller/replaceoperation.cpp b/installerbuilder/libinstaller/replaceoperation.cpp
index 4b9f31260..d7b50d733 100644
--- a/installerbuilder/libinstaller/replaceoperation.cpp
+++ b/installerbuilder/libinstaller/replaceoperation.cpp
@@ -61,9 +61,9 @@ bool ReplaceOperation::performOperation()
// 1. filename
// 2. Source-String
// 3. Replace-String
- if( args.count() != 3 ) {
- setError( InvalidArguments );
- setErrorString( tr("Invalid arguments in %0: %1 arguments given, 3 expected.")
+ if (args.count() != 3) {
+ setError(InvalidArguments);
+ setErrorString(tr("Invalid arguments in %0: %1 arguments given, 3 expected.")
.arg(name()).arg( args.count() ) );
return false;
}
@@ -78,8 +78,8 @@ bool ReplaceOperation::performOperation()
QFile file(currentFileName);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
- setError( UserDefinedError );
- setErrorString( QObject::tr( "Failed to open %1 for reading" ).arg( currentFileName ) );
+ setError(UserDefinedError);
+ setErrorString(QObject::tr("Failed to open %1 for reading").arg(currentFileName));
return false;
}
@@ -88,13 +88,13 @@ bool ReplaceOperation::performOperation()
file.close();
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
- setError( UserDefinedError );
- setErrorString( QObject::tr( "Failed to open %1 for writing" ).arg( currentFileName ) );
+ setError(UserDefinedError);
+ setErrorString(QObject::tr("Failed to open %1 for writing").arg(currentFileName));
return false;
}
//TODO: check that toAscii is right(?)
- file.write( replacedFileContent.toLocal8Bit() );
+ file.write(replacedFileContent.toLocal8Bit());
file.close();
return true;
diff --git a/installerbuilder/libinstaller/selfrestartoperation.cpp b/installerbuilder/libinstaller/selfrestartoperation.cpp
index f7330bbd1..2cadf2b7f 100644
--- a/installerbuilder/libinstaller/selfrestartoperation.cpp
+++ b/installerbuilder/libinstaller/selfrestartoperation.cpp
@@ -39,7 +39,7 @@ using namespace QInstaller;
SelfRestartOperation::SelfRestartOperation()
{
- setName( QLatin1String( "SelfRestart" ) );
+ setName(QLatin1String("SelfRestart"));
}
SelfRestartOperation::~SelfRestartOperation()
@@ -48,31 +48,36 @@ SelfRestartOperation::~SelfRestartOperation()
void SelfRestartOperation::backup()
{
- setValue( QLatin1String( "PreviousSelfRestart" ), KDSelfRestarter::restartOnQuit() );
+ setValue(QLatin1String("PreviousSelfRestart"), KDSelfRestarter::restartOnQuit());
}
bool SelfRestartOperation::performOperation()
{
- const Installer* const installer = qVariantValue< Installer* >( value( QLatin1String( "installer" ) ) );
+ const Installer* const installer = qVariantValue<Installer*>(value(QLatin1String("installer")));
+ if (!installer) {
+ setError(UserDefinedError);
+ setErrorString(tr("Needed installer object in \"%1\" operation is empty.").arg(name()));
+ return false;
+ }
+
if(!installer->isUpdater() && !installer->isPackageManager()) {
setError(UserDefinedError);
- setErrorString (tr("Self Restart: Only valid within updater or packagemanager mode."));
+ setErrorString(tr("Self Restart: Only valid within updater or packagemanager mode."));
return false;
}
- if( !arguments().isEmpty() )
- {
- setError( InvalidArguments );
- setErrorString( tr("Self Restart: Invalid arguments") );
+ if (!arguments().isEmpty()) {
+ setError(InvalidArguments);
+ setErrorString(tr("Self Restart: Invalid arguments"));
return false;
}
- KDSelfRestarter::setRestartOnQuit( true );
+ KDSelfRestarter::setRestartOnQuit(true);
return KDSelfRestarter::restartOnQuit();
}
bool SelfRestartOperation::undoOperation()
{
- KDSelfRestarter::setRestartOnQuit( value( QLatin1String( "PreviousSelfRestart" ) ).toBool() );
+ KDSelfRestarter::setRestartOnQuit(value(QLatin1String("PreviousSelfRestart")).toBool());
return true;
}
diff --git a/installerbuilder/libinstaller/setdemospathonqtoperation.cpp b/installerbuilder/libinstaller/setdemospathonqtoperation.cpp
index 575c5ddad..eaac48a53 100644
--- a/installerbuilder/libinstaller/setdemospathonqtoperation.cpp
+++ b/installerbuilder/libinstaller/setdemospathonqtoperation.cpp
@@ -58,10 +58,10 @@ bool SetDemosPathOnQtOperation::performOperation()
{
const QStringList args = arguments();
- if( args.count() != 2) {
- setError( InvalidArguments );
- setErrorString( tr("Invalid arguments in %0: %1 arguments given, exact 2 expected.")
- .arg(name()).arg( arguments().count() ) );
+ if (args.count() != 2) {
+ setError(InvalidArguments);
+ setErrorString(tr("Invalid arguments in %0: %1 arguments given, exact 2 expected.")
+ .arg(name()).arg(arguments().count()));
return false;
}
@@ -78,30 +78,30 @@ bool SetDemosPathOnQtOperation::performOperation()
if (qmakeValueHash.isEmpty())
{
- setError( UserDefinedError );
- setErrorString( tr("The output of \n%1 -query\n" \
- "is not parseable. Please make a bugreport with this dialog http://bugreports.qt.nokia.com.\n" \
- "output: \"%2\"").arg(QDir::toNativeSeparators(qmakePath), QString::fromUtf8(qmakeOutput)));
+ setError(UserDefinedError);
+ setErrorString(tr("The output of \n%1 -query\n" \
+ "is not parseable. Please make a bugreport with this dialog http://bugreports.qt.nokia.com.\n" \
+ "output: \"%2\"").arg(QDir::toNativeSeparators(qmakePath), QString::fromUtf8(qmakeOutput)));
return false;
}
- QByteArray oldValue = qmakeValueHash.value( QLatin1String("QT_INSTALL_DEMOS") );
+ QByteArray oldValue = qmakeValueHash.value(QLatin1String("QT_INSTALL_DEMOS"));
bool oldQtPathFromQMakeIsEmpty = oldValue.isEmpty();
if (oldQtPathFromQMakeIsEmpty) {
verbose() << "qpatch: warning: It was not able to get the old values from " << qPrintable(qmakePath) << std::endl;
}
if (255 < newValue.size()) {
- setError( UserDefinedError );
- setErrorString( tr("Qt patch error: new Qt demo path(%1)\n" \
- "needs to be less than 255 characters.").arg(QString::fromLocal8Bit(newValue)) );
+ setError(UserDefinedError);
+ setErrorString(tr("Qt patch error: new Qt demo path(%1)\n" \
+ "needs to be less than 255 characters.").arg(QString::fromLocal8Bit(newValue)) );
return false;
}
QString qtConfPath = qtDir + QLatin1String("/bin/qt.conf");
if (QFile::exists(qtConfPath)) {
QSettings settings(qtConfPath, QSettings::IniFormat);
- settings.setValue( QLatin1String("Paths/Demos"), QString::fromUtf8(newValue));
+ settings.setValue(QLatin1String("Paths/Demos"), QString::fromUtf8(newValue));
}
oldValue = QByteArray("qt_demopath=%1").replace("%1", oldValue);
@@ -109,7 +109,8 @@ bool SetDemosPathOnQtOperation::performOperation()
bool isPatched = QtPatch::patchBinaryFile(qmakePath, oldValue, newValue);
if (!isPatched) {
- QInstaller::verbose() << "qpatch: warning: could not patched the demo path in " << qPrintable(qmakePath) << std::endl;
+ QInstaller::verbose() << "qpatch: warning: could not patched the demo path in "
+ << qPrintable(qmakePath) << std::endl;
}
return true;
diff --git a/installerbuilder/libinstaller/setexamplespathonqtoperation.cpp b/installerbuilder/libinstaller/setexamplespathonqtoperation.cpp
index 17b668d38..17cceadeb 100644
--- a/installerbuilder/libinstaller/setexamplespathonqtoperation.cpp
+++ b/installerbuilder/libinstaller/setexamplespathonqtoperation.cpp
@@ -58,10 +58,10 @@ bool SetExamplesPathOnQtOperation::performOperation()
{
const QStringList args = arguments();
- if( args.count() != 2) {
- setError( InvalidArguments );
- setErrorString( tr("Invalid arguments in %0: %1 arguments given, exact 2 expected.")
- .arg(name()).arg( arguments().count() ) );
+ if (args.count() != 2) {
+ setError(InvalidArguments);
+ setErrorString(tr("Invalid arguments in %0: %1 arguments given, exact 2 expected.")
+ .arg(name()).arg(arguments().count()));
return false;
}
@@ -78,23 +78,24 @@ bool SetExamplesPathOnQtOperation::performOperation()
if (qmakeValueHash.isEmpty())
{
- setError( UserDefinedError );
- setErrorString( tr("The output of \n%1 -query\n" \
- "is not parseable. Please make a bugreport with this dialog http://bugreports.qt.nokia.com.\n" \
- "output: \"%2\"").arg(QDir::toNativeSeparators(qmakePath), QString::fromUtf8(qmakeOutput)));
+ setError(UserDefinedError);
+ setErrorString(tr("The output of \n%1 -query\n" \
+ "is not parseable. Please make a bugreport with this dialog http://bugreports.qt.nokia.com.\n" \
+ "output: \"%2\"").arg(QDir::toNativeSeparators(qmakePath), QString::fromUtf8(qmakeOutput)));
return false;
}
- QByteArray oldValue = qmakeValueHash.value( QLatin1String("QT_INSTALL_EXAMPLES") );
+ QByteArray oldValue = qmakeValueHash.value(QLatin1String("QT_INSTALL_EXAMPLES"));
bool oldQtPathFromQMakeIsEmpty = oldValue.isEmpty();
if (oldQtPathFromQMakeIsEmpty) {
- verbose() << "qpatch: warning: It was not able to get the old values from " << qPrintable(qmakePath) << std::endl;
+ verbose() << "qpatch: warning: It was not able to get the old values from "
+ << qPrintable(qmakePath) << std::endl;
}
if (255 < newValue.size()) {
- setError( UserDefinedError );
- setErrorString( tr("Qt patch error: new Qt example path(%1)\n" \
- "needs to be less than 255 characters.").arg(QString::fromLocal8Bit(newValue)) );
+ setError(UserDefinedError);
+ setErrorString(tr("Qt patch error: new Qt example path(%1)\n" \
+ "needs to be less than 255 characters.").arg(QString::fromLocal8Bit(newValue)));
return false;
}
diff --git a/installerbuilder/libinstaller/setimportspathonqtcoreoperation.cpp b/installerbuilder/libinstaller/setimportspathonqtcoreoperation.cpp
index 0f3d237ce..9d8f9c505 100644
--- a/installerbuilder/libinstaller/setimportspathonqtcoreoperation.cpp
+++ b/installerbuilder/libinstaller/setimportspathonqtcoreoperation.cpp
@@ -100,10 +100,10 @@ bool SetImportsPathOnQtCoreOperation::performOperation()
{
const QStringList args = arguments();
- if( args.count() != 2) {
- setError( InvalidArguments );
- setErrorString( tr("Invalid arguments in %0: %1 arguments given, exact 2 expected.")
- .arg(name()).arg( arguments().count() ) );
+ if (args.count() != 2) {
+ setError(InvalidArguments);
+ setErrorString(tr("Invalid arguments in %0: %1 arguments given, exact 2 expected.")
+ .arg(name()).arg( arguments().count()));
return false;
}
@@ -116,13 +116,13 @@ bool SetImportsPathOnQtCoreOperation::performOperation()
}
QStringList libraryFiles;
#ifdef Q_OS_WIN
- libraryFiles << QString( QLatin1String("%1/QtCore4.dll") ).arg(qtCoreLibraryDir);
- libraryFiles << QString( QLatin1String("%1/QtCore4d.dll") ).arg(qtCoreLibraryDir);
+ libraryFiles << QString(QLatin1String("%1/QtCore4.dll")).arg(qtCoreLibraryDir);
+ libraryFiles << QString(QLatin1String("%1/QtCore4d.dll")).arg(qtCoreLibraryDir);
#else
libraryFiles << qtCoreLibraryDir + QLatin1String("/libQtCore.so");
#endif
- foreach(const QString coreLibrary, libraryFiles) {
- if( QFile::exists(coreLibrary) ) {
+ foreach (const QString coreLibrary, libraryFiles) {
+ if (QFile::exists(coreLibrary)) {
QByteArray oldValue(getOldValue(coreLibrary));
Q_ASSERT(!oldValue.isEmpty());
oldValue = QByteArray("qt_impspath=%1").replace("%1", oldValue);
diff --git a/installerbuilder/libinstaller/setpluginpathonqtcoreoperation.cpp b/installerbuilder/libinstaller/setpluginpathonqtcoreoperation.cpp
index d531d37f7..9acc64b75 100644
--- a/installerbuilder/libinstaller/setpluginpathonqtcoreoperation.cpp
+++ b/installerbuilder/libinstaller/setpluginpathonqtcoreoperation.cpp
@@ -46,7 +46,7 @@ QByteArray getOldValue(const QString & binaryPath)
{
QFileInfo fileInfo(binaryPath);
- if ( !fileInfo.exists() ) {
+ if (!fileInfo.exists()) {
verbose() << "qpatch: warning: file `" << qPrintable(binaryPath) << "' not found" << std::endl;
return QByteArray();
}
@@ -54,12 +54,12 @@ QByteArray getOldValue(const QString & binaryPath)
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;
return QByteArray();
@@ -100,10 +100,10 @@ bool SetPluginPathOnQtCoreOperation::performOperation()
{
const QStringList args = arguments();
- if( args.count() != 2) {
- setError( InvalidArguments );
- setErrorString( tr("Invalid arguments in %0: %1 arguments given, exact 2 expected.")
- .arg(name()).arg( arguments().count() ) );
+ if (args.count() != 2) {
+ setError(InvalidArguments);
+ setErrorString(tr("Invalid arguments in %0: %1 arguments given, exact 2 expected.")
+ .arg(name()).arg( arguments().count()));
return false;
}
@@ -116,13 +116,13 @@ bool SetPluginPathOnQtCoreOperation::performOperation()
}
QStringList libraryFiles;
#ifdef Q_OS_WIN
- libraryFiles << QString( QLatin1String("%1/QtCore4.dll") ).arg(qtCoreLibraryDir);
- libraryFiles << QString( QLatin1String("%1/QtCore4d.dll") ).arg(qtCoreLibraryDir);
+ libraryFiles << QString(QLatin1String("%1/QtCore4.dll")).arg(qtCoreLibraryDir);
+ libraryFiles << QString(QLatin1String("%1/QtCore4d.dll")).arg(qtCoreLibraryDir);
#else
libraryFiles << qtCoreLibraryDir + QLatin1String("/libQtCore.so");
#endif
- foreach(const QString coreLibrary, libraryFiles) {
- if( QFile::exists(coreLibrary) ) {
+ foreach (const QString coreLibrary, libraryFiles) {
+ if (QFile::exists(coreLibrary) ) {
QByteArray oldValue(getOldValue(coreLibrary));
Q_ASSERT(!oldValue.isEmpty());
oldValue = QByteArray("qt_plugpath=%1").replace("%1", oldValue);
diff --git a/installerbuilder/libinstaller/setqtcreatorvalueoperation.cpp b/installerbuilder/libinstaller/setqtcreatorvalueoperation.cpp
index 47bd92462..ef2f481af 100644
--- a/installerbuilder/libinstaller/setqtcreatorvalueoperation.cpp
+++ b/installerbuilder/libinstaller/setqtcreatorvalueoperation.cpp
@@ -31,6 +31,7 @@
**
**************************************************************************/
#include "setqtcreatorvalueoperation.h"
+#include "qtcreator_constants.h"
#include <QString>
#include <QFileInfo>
@@ -56,7 +57,7 @@ void SetQtCreatorValueOperation::backup()
namespace {
QString groupName(const QString & groupName)
{
- if(groupName == QLatin1String("General")) {
+ if (groupName == QLatin1String("General")) {
return QString();
} else {
return groupName;
@@ -68,10 +69,10 @@ bool SetQtCreatorValueOperation::performOperation()
{
const QStringList args = arguments();
- if( args.count() != 4) {
- setError( InvalidArguments );
- setErrorString( tr("Invalid arguments in %0: %1 arguments given, exact 4 expected(rootInstallPath,group,key,value).")
- .arg(name()).arg( arguments().count() ) );
+ if (args.count() != 4) {
+ setError(InvalidArguments);
+ setErrorString(tr("Invalid arguments in %0: %1 arguments given, exact 4 expected(rootInstallPath,group,key,value).")
+ .arg(name()).arg( arguments().count()));
return false;
}
@@ -81,22 +82,16 @@ bool SetQtCreatorValueOperation::performOperation()
const QString &key = args.at(2);
const QString &value = args.at(3);
-#if defined(Q_OS_MAC)
- QString iniFileLocation = QLatin1String("%1/Qt Creator.app/Contents/Resources/Nokia/QtCreator.ini");
-#else
- QString iniFileLocation = QLatin1String("%1/QtCreator/share/qtcreator/Nokia/QtCreator.ini");
-#endif
+ QSettings settings(rootInstallPath + QLatin1String(QtCreatorSettingsSuffixPath),
+ QSettings::IniFormat);
- QSettings settings( iniFileLocation.arg(rootInstallPath),
- QSettings::IniFormat );
-
- if(!group.isEmpty()) {
+ if (!group.isEmpty()) {
settings.beginGroup(group);
}
settings.setValue(key, value);
- if(!group.isEmpty()) {
+ if (!group.isEmpty()) {
settings.endGroup();
}
@@ -105,6 +100,25 @@ bool SetQtCreatorValueOperation::performOperation()
bool SetQtCreatorValueOperation::undoOperation()
{
+ const QStringList args = arguments();
+
+ const QString &rootInstallPath = args.at(0); //for example "C:\\Nokia_SDK\\"
+
+ const QString &group = groupName(args.at(1));
+ const QString &key = args.at(2);
+
+ QSettings settings(rootInstallPath + QLatin1String(QtCreatorSettingsSuffixPath),
+ QSettings::IniFormat);
+
+ if (!group.isEmpty()) {
+ settings.beginGroup(group);
+ }
+
+ settings.remove(key);
+
+ if (!group.isEmpty()) {
+ settings.endGroup();
+ }
return true;
}
diff --git a/installerbuilder/libinstaller/simplemovefileoperation.cpp b/installerbuilder/libinstaller/simplemovefileoperation.cpp
index 5abea0437..201746803 100644
--- a/installerbuilder/libinstaller/simplemovefileoperation.cpp
+++ b/installerbuilder/libinstaller/simplemovefileoperation.cpp
@@ -46,7 +46,7 @@ TRANSLATOR QInstaller::SimpleMoveFileOperation
SimpleMoveFileOperation::SimpleMoveFileOperation()
{
- setName( QLatin1String( "SimpleMoveFile" ) );
+ setName(QLatin1String("SimpleMoveFile"));
}
SimpleMoveFileOperation::~SimpleMoveFileOperation()
@@ -60,44 +60,44 @@ void SimpleMoveFileOperation::backup()
bool SimpleMoveFileOperation::performOperation()
{
const QStringList args = arguments();
- if( args.count() != 2 ) {
- setError( InvalidArguments );
- setErrorString( tr("Invalid arguments in %0: %1 arguments given, 2 expected.")
- .arg(name()).arg( args.count() ) );
+ if (args.count() != 2) {
+ setError(InvalidArguments);
+ setErrorString(tr("Invalid arguments in %0: %1 arguments given, 2 expected.")
+ .arg(name()).arg(args.count()));
return false;
}
- const QString source = args.at( 0 );
- const QString target = args.at( 1 );
+ const QString source = args.at(0);
+ const QString target = args.at(1);
- if (source.isEmpty() || target.isEmpty() ) {
- setError( UserDefinedError );
- setErrorString( tr("None of the arguments can be empty: source(\"%1\"), target(\"%2\")")
- .arg(source, target) );
+ if (source.isEmpty() || target.isEmpty()) {
+ setError(UserDefinedError);
+ setErrorString(tr("None of the arguments can be empty: source(\"%1\"), target(\"%2\")")
+ .arg(source, target));
return false;
}
// If destination file exists, then we cannot use QFile::copy()
// because it does not overwrite an existing file. So we remove
// the destination file.
- if( QFile::exists( target ) )
+ if (QFile::exists(target))
{
- QFile file( target );
- if( !file.remove() ) {
- setError( UserDefinedError );
- setErrorString( tr("can not copy source(\"%1\") to target(\"%2\"), because target is existing and not removable.")
- .arg(source, target) );
+ QFile file(target);
+ if (!file.remove()) {
+ setError(UserDefinedError);
+ setErrorString(tr("can not copy source(\"%1\") to target(\"%2\"), because target is existing and not removable.")
+ .arg(source, target));
return false;
}
}
- QFile file( source );
- const bool moved = file.rename( target );
- if ( !moved ) {
- setError( UserDefinedError );
- setErrorString( tr("can not move source(\"%1\") to target(\"%2\"), %3")
- .arg(source, target, file.errorString()) );
+ QFile file(source);
+ const bool moved = file.rename(target);
+ if (!moved) {
+ setError(UserDefinedError);
+ setErrorString(tr("can not move source(\"%1\") to target(\"%2\"), %3")
+ .arg(source, target, file.errorString()));
return false;
}
return true;
@@ -105,10 +105,10 @@ bool SimpleMoveFileOperation::performOperation()
bool SimpleMoveFileOperation::undoOperation()
{
- const QString source = arguments().at( 0 );
- const QString target = arguments().at( 1 );
- QFile file( target );
- file.rename( source );
+ const QString source = arguments().at(0);
+ const QString target = arguments().at(1);
+ QFile file(target);
+ file.rename(source);
return true;
}
diff --git a/tools/operationrunner/fakeinstaller.cpp b/tools/operationrunner/fakeinstaller.cpp
new file mode 100644
index 000000000..e58aa1258
--- /dev/null
+++ b/tools/operationrunner/fakeinstaller.cpp
@@ -0,0 +1,16 @@
+#include "fakeinstaller.h"
+
+void FakeInstaller::setTargetDir(const QString &targetDir)
+{
+ m_targetDir = targetDir;
+}
+
+QString FakeInstaller::value(const QString &key, const QString &/*defaultValue*/) const
+{
+ if(key == QLatin1String("TargetDir")) {
+ return m_targetDir;
+ } else {
+ qFatal("This is only a fake installer and it can only handle \"TargetDir\" value.");
+ }
+ return QString();
+}
diff --git a/tools/operationrunner/fakeinstaller.h b/tools/operationrunner/fakeinstaller.h
new file mode 100644
index 000000000..e623a1487
--- /dev/null
+++ b/tools/operationrunner/fakeinstaller.h
@@ -0,0 +1,24 @@
+#ifndef FAKEINSTALLER_H
+#define FAKEINSTALLER_H
+
+#include <qinstaller.h>
+
+#include <QObject>
+#include <QMetaType>
+#include <QString>
+
+class FakeInstaller : public QInstaller::Installer
+{
+ Q_OBJECT
+public:
+ FakeInstaller() : QInstaller::Installer() {}
+ void setTargetDir(const QString &targetDir);
+ virtual Q_INVOKABLE QString value(const QString &key, const QString &defaultValue = QString()) const;
+
+private:
+ QString m_targetDir;
+};
+
+Q_DECLARE_METATYPE(FakeInstaller*)
+
+#endif // FAKEINSTALLER_H
diff --git a/tools/operationrunner/operationrunner.cpp b/tools/operationrunner/operationrunner.cpp
index 242aa9866..623c711c6 100644
--- a/tools/operationrunner/operationrunner.cpp
+++ b/tools/operationrunner/operationrunner.cpp
@@ -30,6 +30,10 @@
** (qt-info@nokia.com).
**
**************************************************************************/
+#include "fakeinstaller.h" //this should be the pseudo one next to this file
+
+#include <qinstaller.h>
+
#include <common/errors.h>
#include <common/utils.h>
#include <common/repositorygen.h>
@@ -43,6 +47,7 @@
#include <QFileInfo>
#include <QString>
#include <QStringList>
+#include <QDir>
#include <iostream>
@@ -51,8 +56,26 @@ static void printUsage()
std::cout << "Usage: " << std::endl;
std::cout << std::endl;
std::cout << "operationrunner \"Execute\" \"{0,1}\" \"C:\\Windows\\System32\\cmd.exe\" \"/A\" \"/Q\" \"/C\" \"magicmaemoscript.bat\" \"showStandardError\"" << std::endl;
+ std::cout << std::endl;
+ std::cout << std::endl;
+ std::cout << "Note: there is an optional argument --sdktargetdir which is needed by some operations" << std::endl;
+ std::cout << std::endl;
+ std::cout << "operationrunner --sdktargetdir c:\\QtSDK \"RegisterToolChain\" \"GccToolChain\" \"Qt4ProjectManager.ToolChain.GCCE\" \"GCCE 4 for Symbian targets\" \"arm-symbian-device-elf-32bit\" \"c:\\QtSDK\\Symbian\\tools\\gcce4\\bin\\arm-none-symbianelf-g++.exe\""<< std::endl;
}
+class OutputHandler : public QObject
+{
+ Q_OBJECT
+
+public slots:
+ void drawItToCommandLine(const QString &outPut)
+ {
+ std::cout << qPrintable(outPut) << std::endl;
+ }
+};
+
+
+
int main(int argc, char **argv)
{
try {
@@ -67,22 +90,57 @@ int main(int argc, char **argv)
}
argumentList.removeFirst(); // we don't need the application name
+ QString sdkTargetDir;
+ int sdkTargetDirArgumentPosition = argumentList.indexOf(QRegExp("--sdktargetdir", Qt::CaseInsensitive));
+ //+1 means the needed following argument
+ if (sdkTargetDirArgumentPosition != -1 && argumentList.count() > sdkTargetDirArgumentPosition + 1) {
+ sdkTargetDir = argumentList.at(sdkTargetDirArgumentPosition + 1);
+ if (!QDir(sdkTargetDir).exists()) {
+ std::cerr << qPrintable(QString("The following argument of %1 is not an existing directory.").arg(
+ argumentList.at(sdkTargetDirArgumentPosition))) << std::endl;
+ return 1;
+ }
+ argumentList.removeAt(sdkTargetDirArgumentPosition + 1);
+ argumentList.removeAt(sdkTargetDirArgumentPosition);
+ }
+
+
QInstaller::init();
QInstaller::setVerbose( true );
QString operationName = argumentList.takeFirst();
- KDUpdater::UpdateOperation* const operation = KDUpdater::UpdateOperationFactory::instance().create( operationName );
+ KDUpdater::UpdateOperation* const operation = KDUpdater::UpdateOperationFactory::instance().create(operationName);
if (!operation) {
std::cerr << "Can not find the operation: " << qPrintable(operationName) << std::endl;
return 1;
}
+
+ OutputHandler myOutPutHandler;
+ QObject* const operationObject = dynamic_cast<QObject*>(operation);
+ if (operationObject != 0) {
+ const QMetaObject* const mo = operationObject->metaObject();
+ if (mo->indexOfSignal(QMetaObject::normalizedSignature("outputTextChanged(QString)")) > -1) {
+ QObject::connect(operationObject, SIGNAL(outputTextChanged(QString)),
+ &myOutPutHandler, SLOT(drawItToCommandLine(QString)));
+ }
+ }
+
+ FakeInstaller fakeInstaller;
+ fakeInstaller.setTargetDir(sdkTargetDir);
+
+ operation->setValue(QLatin1String("installer"),
+ QVariant::fromValue(static_cast<QInstaller::Installer*>(&fakeInstaller)));
+
operation->setArguments(argumentList);
+
bool readyPerformed = operation->performOperation();
+ std::cout << "========================================" << std::endl;
if (readyPerformed) {
std::cout << "Operation was succesfully performed." << std::endl;
} else {
std::cerr << "There was a problem while performing the operation: " << qPrintable(operation->errorString()) << std::endl;
+ std::cerr << "\tNote: if you see something like installer is null/empty then --sdktargetdir argument was missing." << std::endl;
}
return 0;
} catch ( const QInstaller::Error& e ) {
@@ -90,3 +148,5 @@ int main(int argc, char **argv)
}
return 1;
}
+
+#include "operationrunner.moc"
diff --git a/tools/operationrunner/operationrunner.pro b/tools/operationrunner/operationrunner.pro
index 798c7cc35..a2882cbd7 100644
--- a/tools/operationrunner/operationrunner.pro
+++ b/tools/operationrunner/operationrunner.pro
@@ -10,6 +10,10 @@ CONFIG -= app_bundle
include(../../installerbuilder/libinstaller/libinstaller.pri)
# Input
-SOURCES += operationrunner.cpp
+SOURCES += operationrunner.cpp \
+ fakeinstaller.cpp
+
+HEADERS += \
+ fakeinstaller.h
LIBS = -L../../installerbuilder/lib -linstaller $$LIBS