From 87df259f0748b0bd22052bbee5f777a41cb8b15d Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 27 Jul 2016 12:44:09 +0200 Subject: [PATCH] Merge with develop --- .../client/ryzom_installer/CMakeLists.txt | 4 + .../client/ryzom_installer/res/resources.qrc | 1 + .../ryzom_installer/res/ryzom_installer.ini | 61 +++++ .../ryzom_installer/res/ryzom_installer.png | Bin 0 -> 6646 bytes .../client/ryzom_installer/src/configfile.cpp | 226 ++++++++++++------ .../client/ryzom_installer/src/configfile.h | 3 + .../tools/client/ryzom_installer/src/main.cpp | 35 ++- .../ryzom_installer/src/operationdialog.cpp | 26 +- .../client/ryzom_installer/src/utils.cpp | 49 ---- .../tools/client/ryzom_installer/src/utils.h | 2 - 10 files changed, 270 insertions(+), 137 deletions(-) create mode 100644 code/ryzom/tools/client/ryzom_installer/res/ryzom_installer.ini create mode 100644 code/ryzom/tools/client/ryzom_installer/res/ryzom_installer.png diff --git a/code/ryzom/tools/client/ryzom_installer/CMakeLists.txt b/code/ryzom/tools/client/ryzom_installer/CMakeLists.txt index b096af884..2726ea489 100644 --- a/code/ryzom/tools/client/ryzom_installer/CMakeLists.txt +++ b/code/ryzom/tools/client/ryzom_installer/CMakeLists.txt @@ -51,3 +51,7 @@ IF(WITH_PCH) ENDIF() INSTALL(TARGETS ryzom_installer_qt RUNTIME DESTINATION ${RYZOM_GAMES_PREFIX} COMPONENT client) + +IF(UNIX AND NOT APPLE) + INSTALL(FILES res/ryzom_installer.png DESTINATION ${RYZOM_SHARE_PREFIX} COMPONENT client) +ENDIF() diff --git a/code/ryzom/tools/client/ryzom_installer/res/resources.qrc b/code/ryzom/tools/client/ryzom_installer/res/resources.qrc index 66d8f502e..50fb5825f 100644 --- a/code/ryzom/tools/client/ryzom_installer/res/resources.qrc +++ b/code/ryzom/tools/client/ryzom_installer/res/resources.qrc @@ -7,5 +7,6 @@ template.desktop + ryzom_installer.ini diff --git a/code/ryzom/tools/client/ryzom_installer/res/ryzom_installer.ini b/code/ryzom/tools/client/ryzom_installer/res/ryzom_installer.ini new file mode 100644 index 000000000..82d43b657 --- /dev/null +++ b/code/ryzom/tools/client/ryzom_installer/res/ryzom_installer.ini @@ -0,0 +1,61 @@ +version=1 + +[common] +installation_directory= + +[product] +name=Ryzom +publisher="Winch Gate Property Limited" +url_about=http://ryzom.com/?lang=$LANG +url_help=http://app.ryzom.com/app_forum/index.php?page=topic/view/22047/1&post149889=$LANG#1 +comments=Science-fantasy MMORPG + +[servers] +size=2 + +[server_0] +id=ryzom_live +name=Atys +display_url="http://app.ryzom.com/app_releasenotes/index.php?lang=$LANG" +data_download_url="http://downloads.sourceforge.net/project/ryzom/ryzom_live_data.7z?r=&ts=$TIMESTAMP" +data_download_filename=ryzom_live_data.7z +data_compressed_size=1500000000 +data_uncompressed_size=10000000000 +client_download_url="http://downloads.sourceforge.net/project/ryzom/ryzom_live_client_$ARCH.zip?r=&ts=$TIMESTAMP" +client_download_filename=ryzom_live_client_$ARCH.zip +client_filename_windows=ryzom_client_r.exe +client_filename_osx=Ryzom.app/Contents/MacOS/Ryzom +client_filename_linux=ryzom_client +client_filename_old_windows=client_ryzom_rd.exe +configuration_filename_windows=ryzom_configuration_qt_r.exe +configuration_filename_osx=Ryzom.app/Contents/MacOS/RyzomConfiguration +configuration_filename_linux=ryzom_configuration_qt +installer_filename_windows=ryzom_installer_qt_r.exe +installer_filename_osx=RyzomInstaller.app/Contents/MacOS/RyzomInstaller +installer_filename_linux=ryzom_installer_qt +comments= + +[server_1] +id=ryzom_dev +name=Yubo +display_url="http://app.ryzom.com/app_releasenotes/index.php?lang=$LANG" +data_download_url="http://downloads.sourceforge.net/project/ryzom/ryzom_live_data.7z?r=&ts=$TIMESTAMP" +data_download_filename=ryzom_live_data.7z +data_compressed_size=1500000000 +data_uncompressed_size=10000000000 +client_download_url="http://downloads.sourceforge.net/project/ryzom/ryzom_live_client_$ARCH.zip?r=&ts=$TIMESTAMP" +client_download_filename=ryzom_live_client_$ARCH.zip +client_filename_windows=ryzom_client_r.exe +client_filename_osx=Ryzom.app/Contents/MacOS/Ryzom +client_filename_linux=ryzom_client +client_filename_old_windows=client_ryzom_rd.exe +configuration_filename_windows=ryzom_configuration_qt_r.exe +configuration_filename_osx=Ryzom.app/Contents/MacOS/RyzomConfiguration +configuration_filename_linux=ryzom_configuration_qt +installer_filename_windows=ryzom_installer_qt_r.exe +installer_filename_osx=RyzomInstaller.app/Contents/MacOS/RyzomInstaller +installer_filename_linux=ryzom_installer_qt +comments=Test server + +[profiles] +size=0 diff --git a/code/ryzom/tools/client/ryzom_installer/res/ryzom_installer.png b/code/ryzom/tools/client/ryzom_installer/res/ryzom_installer.png new file mode 100644 index 0000000000000000000000000000000000000000..67e3034ef83fc784834c7c42a375fcb816dcae5c GIT binary patch literal 6646 zcmV004R>004l5008;`004mK004C`008P>0026e000+ooVrmw00006 zVoOIv0RI600RN!9r;`8x010qNS#tmY3ljhU3ljkVnw%H_000McNliru-wPKG2qhfh zDJTE{80ASsK~!kot(sYkWLbXJf9I}oV~@y)jNB`;Dr;Z5ySl5odse)R-7sVDGDaXH z3uI%1gb-j5ZwSK!FGe81fGkF%0xuhq3LS(RD2N5&p;vK z!$bFYuxG$Cn7?$StD|#uzwi9N|It0?JA(fYp_KaOqxi6)0Qq5GCY6CgC`jWd&Mezh zN+}%E_%nZ7e6KIa55W$AI*3FnU1l<`pr9lOgv_$oilZo=y3iT@zsl_SpFxQ44bpc#1^?SD1K;K1*+xBDy07msPW+3y^*U!9D`-My_lW)e@Tjn;`XOY7&$MqcT@JS^2K%kLEn z%dg+x?LJMdAM$5GzV=@~&&NOe6W=wF?`qUH!An2`?eo|F;hD~0=VyISw$3fTlCI6Y z@DXC8+;8t@cW=MzwMY7PwK`LM`J*2hRqD02=S{nNPj2g*civg^-5{}QMkRLQOLnd# z&#!;qS1OH@uZ=P9_DAlW{rmUa%b)&?>hJCGS6)2vXCt7LLVatHh|@IJA03|f+}D5c z=eD*t{$hez^o<8ATe z#`UN>@Z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LKmG9bz%TaTX-Pkf5G0t@rUICbsm%HU98$1{XG}6I7^agBw;cU)8MudMQ>P{d}t~8mZo^D zr1TNukKD#TMqqzBU`|-He)z|5@4cUBQtqc2(oeOsVWx70yqz{%jUY&ZauTQ7!m&%t zG|y8g&r_Z`MJ6j$Ym3ZOXQ@}}~q zZ6&3P5b2);{~ax+e*b`%PG7~}d7`XRb*iWFW){ceSm_I)(iX!swb2YrJD){CpuFi+ z3*!WIi&P1sR1u|uFi|8)hL$T~7VBifV&eIX#}fvb6s9BvFtk z>3gy2wKomVy(W_Qwvw^~L?{Ix7ViJmBa4B06p^1lM%-&lqfm4$C79Nb@WqF^|C8Xq%_IAh@$nPS;%#kEKKqP7H%b{? z4m3U+TK1<@zPzA0j;-0YVHhT+VX9oAjA_~Eng&WrB{QVVl#+@plf+R-9ECECf;3Z! zZfHhi>2|1R>5&+8_qFM`Ewb!AlzKxc^#}+MLZQ@m1plWJ0Ql&!3tZd2!zWHYFErb+ z6mlt6=|?le{&<=zT!;;GEwgeJVLQ4oZCy7^blp(8rb(2NN@h}mCNn8ymMWPhnM#vX z%aYhkLeGwaeJhGLwKRRKlzdw$bra|SiBbyj9c1%85dgSSp2JyKA@!zM#fl~j!%?Vt z1!oh~^Qo?1kcPdI8rG~dtdcTJ6W!20yzn5AQi&{;T9zbwns`Q<42(4HYH8BeK9I>R zrPLizhaf^exa{(61^fR@;G6M6ZHe-+Q$)iadM>94UAKj%)qrIMCzKHD3bCeym{me6 zBgg?tD3uAN5}~9klIx;yrF*7SLF*-0XQLTSa0000bbVXQnWMOn= zI&E)cX=Zr$G&(RiIx{ybFflqXFtRBcga7~l07*qoM6N<$f)bne AegFUf literal 0 HcmV?d00001 diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp index 1181dd613..204f86229 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp @@ -142,30 +142,19 @@ void CProfile::updateShortcuts() const CConfigFile *CConfigFile::s_instance = NULL; -CConfigFile::CConfigFile(QObject *parent):QObject(parent), m_defaultServerIndex(0), m_defaultProfileIndex(0), m_use64BitsClient(false), m_shouldUninstallOldClient(true) +CConfigFile::CConfigFile(QObject *parent):QObject(parent), m_version(-1), + m_defaultServerIndex(0), m_defaultProfileIndex(0), m_use64BitsClient(false), m_shouldUninstallOldClient(true) { s_instance = this; // only keep language ISO 639 code m_language = QLocale::system().name().left(2); - // it won't be found if run with uninstall flag, but since we already have a local installer.ini... - QString configFile = getCurrentDirectory() + "/installer.ini"; - - if (!QFile::exists(configFile)) - { - configFile = QApplication::applicationDirPath() + "/installer.ini"; - - if (!QFile::exists(configFile)) - { - configFile.clear(); - } - } - - m_defaultConfigPath = configFile; + // default config file in included in resources + m_defaultConfigPath = ":/templates/ryzom_installer.ini"; // the config file we'll write - m_configPath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/installer.ini"; + m_configPath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/ryzom_installer.ini"; } CConfigFile::~CConfigFile() @@ -175,13 +164,30 @@ CConfigFile::~CConfigFile() bool CConfigFile::load() { - return load(m_configPath) || load(m_defaultConfigPath); + // load default values + return load(m_defaultConfigPath) || load(m_configPath); } bool CConfigFile::load(const QString &filename) { + if (!QFile::exists(filename)) return false; + QSettings settings(filename, QSettings::IniFormat); + int defaultVersion = m_version; + int currentVersion = settings.value("version", 0).toInt(); + + bool useDefaultValues = defaultVersion > currentVersion; + + // set default version from default config + if (defaultVersion == -1) m_version = currentVersion; + + if (useDefaultValues) + { + // TODO: make a backup of custom installer.ini + } + + // custom choices, always keep them settings.beginGroup("common"); m_language = settings.value("language", m_language).toString(); m_srcDirectory = settings.value("source_directory").toString(); @@ -190,58 +196,62 @@ bool CConfigFile::load(const QString &filename) m_shouldUninstallOldClient = settings.value("should_uninstall_old_client", true).toBool(); settings.endGroup(); - settings.beginGroup("product"); - m_productName = settings.value("name").toString(); - m_productPublisher = settings.value("publisher").toString(); - m_productAboutUrl = settings.value("url_about").toString(); - m_productUpdateUrl = settings.value("url_update").toString(); - m_productHelpUrl = settings.value("url_help").toString(); - m_productComments = settings.value("comments").toString(); - settings.endGroup(); - - settings.beginGroup("servers"); - int serversCount = settings.value("size").toInt(); - m_defaultServerIndex = settings.value("default").toInt(); - settings.endGroup(); - - m_servers.resize(serversCount); - - for(int i = 0; i < serversCount; ++i) + if (!useDefaultValues) { - CServer &server = m_servers[i]; - - settings.beginGroup(QString("server_%1").arg(i)); - - server.id = settings.value("id").toString(); - server.name = settings.value("name").toString(); - server.displayUrl = settings.value("display_url").toString(); - server.dataDownloadUrl = settings.value("data_download_url").toString(); - server.dataDownloadFilename = settings.value("data_download_filename").toString(); - server.dataCompressedSize = settings.value("data_compressed_size").toULongLong(); - server.dataUncompressedSize = settings.value("data_uncompressed_size").toULongLong(); - server.clientDownloadUrl = settings.value("client_download_url").toString(); - server.clientDownloadFilename = settings.value("client_download_filename").toString(); -#if defined(Q_OS_WIN) - server.clientFilename = settings.value("client_filename_windows").toString(); - server.clientFilenameOld = settings.value("client_filename_old_windows").toString(); - server.configurationFilename = settings.value("configuration_filename_windows").toString(); - server.installerFilename = settings.value("installer_filename_windows").toString(); -#elif defined(Q_OS_MAC) - server.clientFilename = settings.value("client_filename_osx").toString(); - server.clientFilenameOld = settings.value("client_filename_old_osx").toString(); - server.configurationFilename = settings.value("configuration_filename_osx").toString(); - server.installerFilename = settings.value("installer_filename_osx").toString(); -#else - server.clientFilename = settings.value("client_filename_linux").toString(); - server.clientFilenameOld = settings.value("client_filename_old_linux").toString(); - server.configurationFilename = settings.value("configuration_filename_linux").toString(); - server.installerFilename = settings.value("installer_filename_linux").toString(); -#endif - server.comments = settings.value("comments").toString(); - + settings.beginGroup("product"); + m_productName = settings.value("name").toString(); + m_productPublisher = settings.value("publisher").toString(); + m_productAboutUrl = settings.value("url_about").toString(); + m_productUpdateUrl = settings.value("url_update").toString(); + m_productHelpUrl = settings.value("url_help").toString(); + m_productComments = settings.value("comments").toString(); settings.endGroup(); + + settings.beginGroup("servers"); + int serversCount = settings.value("size").toInt(); + m_defaultServerIndex = settings.value("default").toInt(); + settings.endGroup(); + + m_servers.resize(serversCount); + + for (int i = 0; i < serversCount; ++i) + { + CServer &server = m_servers[i]; + + settings.beginGroup(QString("server_%1").arg(i)); + + server.id = settings.value("id").toString(); + server.name = settings.value("name").toString(); + server.displayUrl = settings.value("display_url").toString(); + server.dataDownloadUrl = settings.value("data_download_url").toString(); + server.dataDownloadFilename = settings.value("data_download_filename").toString(); + server.dataCompressedSize = settings.value("data_compressed_size").toULongLong(); + server.dataUncompressedSize = settings.value("data_uncompressed_size").toULongLong(); + server.clientDownloadUrl = settings.value("client_download_url").toString(); + server.clientDownloadFilename = settings.value("client_download_filename").toString(); +#if defined(Q_OS_WIN) + server.clientFilename = settings.value("client_filename_windows").toString(); + server.clientFilenameOld = settings.value("client_filename_old_windows").toString(); + server.configurationFilename = settings.value("configuration_filename_windows").toString(); + server.installerFilename = settings.value("installer_filename_windows").toString(); +#elif defined(Q_OS_MAC) + server.clientFilename = settings.value("client_filename_osx").toString(); + server.clientFilenameOld = settings.value("client_filename_old_osx").toString(); + server.configurationFilename = settings.value("configuration_filename_osx").toString(); + server.installerFilename = settings.value("installer_filename_osx").toString(); +#else + server.clientFilename = settings.value("client_filename_linux").toString(); + server.clientFilenameOld = settings.value("client_filename_old_linux").toString(); + server.configurationFilename = settings.value("configuration_filename_linux").toString(); + server.installerFilename = settings.value("installer_filename_linux").toString(); +#endif + server.comments = settings.value("comments").toString(); + + settings.endGroup(); + } } + // custom choices, always keep them settings.beginGroup("profiles"); int profilesCounts = settings.value("size").toInt(); m_defaultProfileIndex = settings.value("default").toInt(); @@ -274,6 +284,8 @@ bool CConfigFile::save() const { QSettings settings(m_configPath, QSettings::IniFormat); + settings.setValue("version", m_version); + settings.beginGroup("common"); settings.setValue("language", m_language); settings.setValue("source_directory", m_srcDirectory); @@ -641,9 +653,11 @@ QString CConfigFile::getOldInstallationLanguage() QSettings settings("HKEY_LOCAL_MACHINE\\Software\\Nevrax\\Ryzom", QSettings::NativeFormat); #endif - if (settings.contains("Language")) + QString key = "Language"; + + if (settings.contains(key)) { - QString languageCode = settings.value("Language").toString(); + QString languageCode = settings.value(key).toString(); // 1036 = French (France), 1033 = English (USA), 1031 = German if (languageCode == "1036") return "fr"; @@ -659,16 +673,18 @@ QString CConfigFile::getNewInstallationLanguage() { #if defined(Q_OS_WIN) // NSIS new official installer -#ifdef Q_OS_WIN64 - // use WOW6432Node in 64 bits (64 bits OS and 64 bits Installer) because Ryzom old installer was in 32 bits - QSettings settings("HKEY_LOCAL_MACHINE\\Software\\WOW6432Node\\Nevrax\\Ryzom", QSettings::NativeFormat); -#else - QSettings settings("HKEY_LOCAL_MACHINE\\Software\\Nevrax\\Ryzom", QSettings::NativeFormat); -#endif + QSettings settings("HKEY_CURRENT_USER\\Software\\Winch Gate\\Ryzom", QSettings::NativeFormat); - if (settings.contains("Ryzom Install Path")) + QString key = "Language"; + + if (settings.contains(key)) { - return QDir::fromNativeSeparators(settings.value("Ryzom Install Path").toString()); + QString languageCode = settings.value(key).toString(); + + // 1036 = French (France), 1033 = English (USA), 1031 = German + if (languageCode == "1036") return "fr"; + if (languageCode == "1031") return "de"; + if (languageCode == "1033") return "en"; } #endif @@ -677,6 +693,19 @@ QString CConfigFile::getNewInstallationLanguage() QString CConfigFile::getNewInstallationDirectory() { +#if defined(Q_OS_WIN) + // NSIS new official installer + QSettings settings("HKEY_CURRENT_USER\\Software\\Winch Gate\\Ryzom", QSettings::NativeFormat); + + QString key = "Ryzom Install Path"; + + if (settings.contains(key)) + { + return QDir::fromNativeSeparators(settings.value(key).toString()); + } +#endif + + // default location return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation); } @@ -805,7 +834,7 @@ bool CConfigFile::shouldCreateMenuShortcut() const QString CConfigFile::getInstallerFullPath() const { - return QApplication::applicationFilePath(); + return QApplication::applicationDirPath(); } QString CConfigFile::getInstallerMenuLinkFullPath() const @@ -817,6 +846,51 @@ QString CConfigFile::getInstallerMenuLinkFullPath() const #endif } +QStringList CConfigFile::getInstallerRequiredFiles() const +{ + // list of all files required by installer (and its executable too) + QStringList files; + +#ifdef Q_OS_WIN + + // VC++ runtimes +#if _MSC_VER == 1900 + // VC++ 2015 + files << "msvcp140.dll"; + files << "msvcr140.dll"; +#elif _MSC_VER == 1800 + // VC++ 2013 + files << "msvcp120.dll"; + files << "msvcr120.dll"; +#elif _MSC_VER == 1700 + // VC++ 2012 + files << "msvcp110.dll"; + files << "msvcr110.dll"; +#elif _MSC_VER == 1600 + // VC++ 2010 + files << "msvcp100.dll"; + files << "msvcr100.dll"; +#elif _MSC_VER == 1500 + // VC++ 2008 + files << "msvcp90.dll"; + files << "msvcr90.dll"; +#else + // unsupported compiler +#endif + +#elif defined(Q_OS_MAC) + // TODO: for OS X +#else + // icon under Linux + files << "ryzom_installer.png"; +#endif + + // include current executable + files << QFileInfo(QApplication::applicationFilePath()).fileName(); + + return files; +} + QString CConfigFile::getSrcServerClientBNPFullPath() const { return QString("%1/unpack/exedll_%2.bnp").arg(getSrcServerDirectory()).arg(getClientArch()); diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.h b/code/ryzom/tools/client/ryzom_installer/src/configfile.h index ed1768c6c..de3440086 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.h +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.h @@ -181,6 +181,8 @@ public: QString getInstallerFullPath() const; QString getInstallerMenuLinkFullPath() const; + QStringList getInstallerRequiredFiles() const; + QString getSrcServerClientBNPFullPath() const; OperationStep getInstallNextStep() const; @@ -194,6 +196,7 @@ public: QString getProductComments() const; private: + int m_version; int m_defaultServerIndex; int m_defaultProfileIndex; diff --git a/code/ryzom/tools/client/ryzom_installer/src/main.cpp b/code/ryzom/tools/client/ryzom_installer/src/main.cpp index f46790110..82ab9939c 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/main.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/main.cpp @@ -47,6 +47,39 @@ #define new DEBUG_NEW #endif +// copy all specified files from current directory to destination directory +bool copyInstallerFiles(const QStringList &files, const QString &destination) +{ + QString path = QApplication::applicationDirPath(); + + foreach(const QString &file, files) + { + // convert to absolute path + QString srcPath = path + "/" + file; + QString dstPath = destination + "/" + file; + + if (QFile::exists(srcPath)) + { + if (QFile::exists(dstPath)) + { + if (!QFile::remove(dstPath)) + { + qDebug() << "Unable to delete" << dstPath; + } + } + + if (!QFile::copy(srcPath, dstPath)) + { + qDebug() << "Unable to copy" << srcPath << "to" << dstPath; + + return false; + } + } + } + + return true; +} + int main(int argc, char *argv[]) { #if defined(_MSC_VER) && defined(_DEBUG) @@ -115,7 +148,7 @@ int main(int argc, char *argv[]) if (QApplication::applicationDirPath() != tempPath) { // copy installer and required files to TEMP directory - if (copyInstallerExecutable(tempPath)) + if (copyInstallerFiles(config.getInstallerRequiredFiles(), tempPath)) { QString tempFile = tempPath + "/" + QFileInfo(QApplication::applicationFilePath()).fileName(); diff --git a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp index c24943f7d..1a4cf9f13 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp @@ -715,13 +715,8 @@ void COperationDialog::copyInstaller() if (!QFile::exists(newInstallerFullPath)) { - QStringList filter; - filter << "msvcp100.dll"; - filter << "msvcr100.dll"; - filter << "ryzom_installer.png"; - CFilesCopier copier(this); - copier.setIncludeFilter(filter); + copier.setIncludeFilter(config->getInstallerRequiredFiles()); copier.addFile(oldInstallerFullPath); copier.setSourceDirectory(config->getSrcServerDirectory().isEmpty() ? QApplication::applicationDirPath():config->getSrcServerDirectory()); copier.setDestinationDirectory(config->getInstallationDirectory()); @@ -1123,8 +1118,6 @@ void COperationDialog::deleteComponentsInstaller() CConfigFile *config = CConfigFile::getInstance(); - // TODO: delete installer - deleteAddRemoveEntry(); // delete menu @@ -1137,7 +1130,22 @@ void COperationDialog::deleteComponentsInstaller() dir.removeRecursively(); } - // TODO: + path = config->getInstallerFullPath(); + QStringList files = config->getInstallerRequiredFiles(); + + foreach(const QString &file, files) + { + QString fullPath = path + "/" + file; + + // delete file + if (!QFile::remove(fullPath)) + { +#ifdef Q_OS_WIN32 + // under Windows, a running executable is locked, so we need to delete it later + MoveFileExW(qToWide(QDir::toNativeSeparators(fullPath)), NULL, MOVEFILE_DELAY_UNTIL_REBOOT); +#endif + } + } // reset it once it's done m_removeComponents.installer = false; diff --git a/code/ryzom/tools/client/ryzom_installer/src/utils.cpp b/code/ryzom/tools/client/ryzom_installer/src/utils.cpp index 1e3c324a7..cdbadc246 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/utils.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/utils.cpp @@ -239,52 +239,3 @@ bool resolveLink(const QWidget &window, const QString &pathLink, QString &pathOb } #endif - -bool copyInstallerExecutable(const QString &destination) -{ - QString path = QApplication::applicationDirPath(); - - QStringList files; -#ifdef Q_OS_WIN - - // VC++ runtimes -#if _MSC_VER == 1900 - files << "msvcp140.dll"; - files << "msvcr140.dll"; -#else _MSC_VER == 1600 - files << "msvcp100.dll"; - files << "msvcr100.dll"; -#endif - -#else -#endif - - files << QFileInfo(QApplication::applicationFilePath()).fileName(); - - foreach(const QString &file, files) - { - // convert to absolute path - QString srcPath = path + "/" + file; - QString dstPath = destination + "/" + file; - - if (QFile::exists(srcPath)) - { - if (QFile::exists(dstPath)) - { - if (!QFile::remove(dstPath)) - { - qDebug() << "Unable to delete" << dstPath; - } - } - - if (!QFile::copy(srcPath, dstPath)) - { - qDebug() << "Unable to copy" << srcPath << "to" << dstPath; - - return false; - } - } - } - - return true; -} diff --git a/code/ryzom/tools/client/ryzom_installer/src/utils.h b/code/ryzom/tools/client/ryzom_installer/src/utils.h index 8072f69d6..363c30b9e 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/utils.h +++ b/code/ryzom/tools/client/ryzom_installer/src/utils.h @@ -51,6 +51,4 @@ wchar_t* qToWide(const QString &str); bool createLink(const QString &link, const QString &name, const QString &executable, const QString &arguments, const QString &icon, const QString &workingDir); bool resolveLink(const QWidget &window, const QString &pathLink, QString &pathObj); -bool copyInstallerExecutable(const QString &destination); - #endif