From 0943b2889c5da133f3739df9a61e686dbee56292 Mon Sep 17 00:00:00 2001 From: kervala Date: Thu, 26 May 2016 19:30:18 +0200 Subject: [PATCH] Changed: Copy installer --HG-- branch : develop --- .../client/ryzom_installer/src/configfile.cpp | 6 +++ .../client/ryzom_installer/src/configfile.h | 1 + .../ryzom_installer/src/filescopier.cpp | 22 +++++++- .../client/ryzom_installer/src/filescopier.h | 5 +- .../ryzom_installer/src/operationdialog.cpp | 51 +++++++++++++++++++ .../ryzom_installer/src/operationdialog.h | 1 + 6 files changed, 82 insertions(+), 4 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp index 3028ba7b6..f305c7395 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp @@ -696,6 +696,12 @@ CConfigFile::InstallationStep CConfigFile::getNextStep() const } } + // if installer not found in installation directory, extract it from BNP + if (!QFile::exists(getInstallationDirectory() + "/" + server.installerFilename)) + { + return CopyInstaller; + } + // no default profile if (profile.id.isEmpty()) { diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.h b/code/ryzom/tools/client/ryzom_installer/src/configfile.h index 71756d031..d65c8aae7 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.h +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.h @@ -92,6 +92,7 @@ public: CopyProfileFiles, CleanFiles, ExtractBnpClient, + CopyInstaller, CreateProfile, CreateShortcuts, Done diff --git a/code/ryzom/tools/client/ryzom_installer/src/filescopier.cpp b/code/ryzom/tools/client/ryzom_installer/src/filescopier.cpp index 8b2af9be8..3478a936d 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/filescopier.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/filescopier.cpp @@ -48,9 +48,9 @@ void CFilesCopier::setIncludeFilter(const QStringList &filter) m_includeFilter = filter; } -void CFilesCopier::setExcludeFilter(const QStringList &filter) +void CFilesCopier::addFile(const QString &filename) { - m_excludeFilter = filter; + m_files << filename; } bool CFilesCopier::exec() @@ -127,6 +127,24 @@ void CFilesCopier::getFilesList(FilesToCopy &files) files << file; } } + + // copy additional files + foreach(const QString &fullpath, m_files) + { + QFileInfo fileInfo(fullpath); + + if (fileInfo.isFile()) + { + FileToCopy file; + file.filename = fileInfo.fileName(); + file.src = fileInfo.filePath(); + file.dst = m_destinationDirectory + "/" + fileInfo.fileName(); + file.size = fileInfo.size(); + file.date = fileInfo.lastModified().toTime_t(); + + files << file; + } + } } bool CFilesCopier::copyFiles(const FilesToCopy &files) diff --git a/code/ryzom/tools/client/ryzom_installer/src/filescopier.h b/code/ryzom/tools/client/ryzom_installer/src/filescopier.h index 0148bfdaf..02ef3ddba 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/filescopier.h +++ b/code/ryzom/tools/client/ryzom_installer/src/filescopier.h @@ -35,7 +35,8 @@ public: void setDesinationDirectory(const QString &src); void setIncludeFilter(const QStringList &filter); - void setExcludeFilter(const QStringList &filter); + + void addFile(const QString &file); bool exec(); @@ -61,7 +62,7 @@ protected: QString m_destinationDirectory; QStringList m_includeFilter; - QStringList m_excludeFilter; + QStringList m_files; }; #endif diff --git a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp index 765c66127..5368c02db 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp @@ -136,6 +136,10 @@ void COperationDialog::processNextStep() QtConcurrent::run(this, &COperationDialog::extractBnpClient); break; + case CConfigFile::CopyInstaller: + QtConcurrent::run(this, &COperationDialog::copyIntaller); + break; + case CConfigFile::CleanFiles: QtConcurrent::run(this, &COperationDialog::cleanFiles); break; @@ -407,6 +411,53 @@ void COperationDialog::extractBnpClient() emit done(); } +void COperationDialog::copyIntaller() +{ + CConfigFile *config = CConfigFile::getInstance(); + + // default server + const CServer &server = config->getServer(); + + m_currentOperation = QApplication::tr("Copy installer to new location"); + m_currentOperationProgressFormat = QApplication::tr("Copying %1..."); + + QString destinationDirectory = config->getInstallationDirectory(); + + // rename old client to installer + QString newInstallerFilename = server.installerFilename; + + if (!newInstallerFilename.isEmpty()) + { + QString oldInstallerFullPath = QApplication::applicationFilePath(); + QString newInstallerFullPath = config->getInstallationDirectory() + "/" + newInstallerFilename; + + if (!QFile::exists(newInstallerFullPath)) + { + QStringList filter; + filter << "msvcp100.dll"; + filter << "msvcr100.dll"; + + CFilesCopier copier(this); + copier.setIncludeFilter(filter); + copier.addFile(oldInstallerFullPath); + copier.setSourceDirectory(config->getSrcServerDirectory()); + copier.setDestinationDirectory(config->getInstallationDirectory()); + copier.exec(); + + // copied file + oldInstallerFullPath = config->getInstallationDirectory() + "/" + QFileInfo(oldInstallerFullPath).fileName(); + + // rename old filename if different + if (oldInstallerFullPath != newInstallerFullPath) + { + QFile::rename(oldInstallerFullPath, newInstallerFullPath); + } + } + } + + emit done(); +} + void COperationDialog::cleanFiles() { CConfigFile *config = CConfigFile::getInstance(); diff --git a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.h b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.h index c8a7c1276..f72b0a877 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.h +++ b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.h @@ -87,6 +87,7 @@ protected: void copyServerFiles(); void copyProfileFiles(); void extractBnpClient(); + void copyIntaller(); void cleanFiles(); bool createDefaultProfile(); bool createDefaultShortcuts();