From 1e1dbaec5c2845fe1f6e93afd1c5c34d5306e898 Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 29 May 2016 20:32:33 +0200 Subject: [PATCH] Changed: Uninstall previous Ryzom version if detected --HG-- branch : develop --- .../client/ryzom_installer/src/configfile.cpp | 21 +++++++++- .../client/ryzom_installer/src/configfile.h | 5 +++ .../ryzom_installer/src/operationdialog.cpp | 38 +++++++++++++++++++ .../ryzom_installer/src/operationdialog.h | 5 ++- 4 files changed, 65 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 4574e00b5..91877eb9e 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp @@ -29,7 +29,7 @@ const CProfile NoProfile; CConfigFile *CConfigFile::s_instance = NULL; -CConfigFile::CConfigFile(QObject *parent):QObject(parent), m_defaultServerIndex(0), m_defaultProfileIndex(0), m_use64BitsClient(false) +CConfigFile::CConfigFile(QObject *parent):QObject(parent), m_defaultServerIndex(0), m_defaultProfileIndex(0), m_use64BitsClient(false), m_shouldUninstallOldClient(true) { s_instance = this; @@ -56,7 +56,8 @@ bool CConfigFile::load(const QString &filename) m_language = settings.value("language", m_language).toString(); m_srcDirectory = settings.value("source_directory").toString(); m_installationDirectory = settings.value("installation_directory").toString(); - m_use64BitsClient = settings.value("use_64bits_client").toBool(); + m_use64BitsClient = settings.value("use_64bits_client", true).toBool(); + m_shouldUninstallOldClient = settings.value("should_uninstall_old_client", true).toBool(); settings.endGroup(); settings.beginGroup("product"); @@ -149,6 +150,7 @@ bool CConfigFile::save() const settings.setValue("source_directory", m_srcDirectory); settings.setValue("installation_directory", m_installationDirectory); settings.setValue("use_64bits_client", m_use64BitsClient); + settings.setValue("should_uninstall_old_client", m_shouldUninstallOldClient); settings.endGroup(); settings.beginGroup("product"); @@ -363,6 +365,16 @@ void CConfigFile::setUse64BitsClient(bool on) m_use64BitsClient = on; } +bool CConfigFile::shouldUninstallOldClient() const +{ + return m_shouldUninstallOldClient; +} + +void CConfigFile::setShouldUninstallOldClient(bool on) +{ + m_shouldUninstallOldClient = on; +} + QString CConfigFile::expandVariables(const QString &str) const { QString res = str; @@ -710,6 +722,11 @@ CConfigFile::InstallationStep CConfigFile::getNextStep() const return CopyInstaller; } + if (m_shouldUninstallOldClient && !getSrcServerDirectory().isEmpty() && QFile::exists(getSrcServerDirectory() + "/Uninstall.exe")) + { + return UninstallOldClient; + } + // 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 7a8f2307c..aa3a61f8b 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.h +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.h @@ -93,6 +93,7 @@ public: CleanFiles, ExtractBnpClient, CopyInstaller, + UninstallOldClient, CreateProfile, CreateShortcuts, CreateAddRemoveEntry, @@ -164,6 +165,9 @@ public: bool use64BitsClient() const; void setUse64BitsClient(bool on); + bool shouldUninstallOldClient() const; + void setShouldUninstallOldClient(bool on); + QString expandVariables(const QString &str) const; QString getClientArch() const; @@ -192,6 +196,7 @@ private: QString m_installationDirectory; QString m_srcDirectory; bool m_use64BitsClient; + bool m_shouldUninstallOldClient; QString m_language; QString m_defaultConfigPath; diff --git a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp index 509404f62..142187f8a 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp @@ -462,6 +462,44 @@ void COperationDialog::copyIntaller() emit done(); } +void COperationDialog::uninstallOldClient() +{ +#ifdef Q_OS_WIN + +#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\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Ryzom", QSettings::NativeFormat); +#else + QSettings settings("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Ryzom", QSettings::NativeFormat); +#endif + + // check if Ryzom 2.1.0 is installed + if (settings.contains("UninstallString")) + { + QString uninstaller = settings.value("UninstallString").toString(); + + if (!uninstaller.isEmpty() && QFile::exists(uninstaller)) + { + QMessageBox::StandardButtons button = QMessageBox::question(this, tr("Uninstall old client"), tr("An old version of Ryzom has been detected on this system, would you like to uninstall it to save space disk?")); + + if (button == QMessageBox::Yes) + { + CConfigFile::getInstance()->setShouldUninstallOldClient(true); + + QDesktopServices::openUrl(QUrl::fromLocalFile(uninstaller)); + } + else + { + // don't ask this question anymore + CConfigFile::getInstance()->setShouldUninstallOldClient(false); + } + } + } +#endif + + 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 06a47dfbf..6f6c008dc 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.h +++ b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.h @@ -86,9 +86,10 @@ protected: void downloadClient(); void copyServerFiles(); void copyProfileFiles(); - void extractBnpClient(); - void copyIntaller(); void cleanFiles(); + void extractBnpClient(); + void copyInstaller(); + void uninstallOldClient(); bool createDefaultProfile(); bool createDefaultShortcuts(); bool createAddRemoveEntry();