From 1c03b41fabd3da412a89e812cbccd106c66e427c Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 7 Jun 2016 13:24:26 +0200 Subject: [PATCH] Changed: Delete clients and profiles operations --HG-- branch : develop --- .../ryzom_installer/src/operationdialog.cpp | 82 +++++++++++++++++-- .../ryzom_installer/src/operationdialog.h | 1 + 2 files changed, 74 insertions(+), 9 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp index ef05f1ce8..81db90561 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp @@ -668,45 +668,109 @@ bool COperationDialog::createAddRemoveEntry() return true; } +bool COperationDialog::deleteAddRemoveEntry() +{ +#ifdef Q_OS_WIN + QSettings settings("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Ryzom", QSettings::NativeFormat); + settings.remove(""); +#endif + + emit done(); + + return true; +} + void COperationDialog::deleteComponentsServers() { m_currentOperation = QApplication::tr("Delete client files"); m_currentOperationProgressFormat = QApplication::tr("Deleting %1..."); -// connect(m_downloader, SIGNAL(downloadPrepare()), SLOT(onProgressPrepare())); -// connect(m_downloader, SIGNAL(downloadInit(qint64, qint64)), SLOT(onProgressInit(qint64, qint64))); -// connect(m_downloader, SIGNAL(downloadStart()), SLOT(onProgressStart())); -// connect(m_downloader, SIGNAL(downloadStop()), SLOT(onProgressStop())); -// connect(m_downloader, SIGNAL(downloadProgress(qint64, QString)), SLOT(onProgressProgress(qint64, QString))); - + emit prepare(); + emit init(0, m_components.servers.size()); + emit start(); CConfigFile *config = CConfigFile::getInstance(); + int i = 0; + foreach(int serverIndex, m_components.servers) { + if (operationShouldStop()) + { + emit stop(); + return; + } + const CServer &server = config->getServer(serverIndex); + emit progress(i++, server.name); + QString path = config->getInstallationDirectory() + "/" + server.id; QDir dir(path); - if (!dir.exists() || !dir.removeRecursively()) + if (dir.exists() && !dir.removeRecursively()) { - emit onProgressFail(tr("Uninstall to delete files for client %1").arg(server.name)); + emit fail(tr("Unable to delete files for client %1").arg(server.name)); + return; } } - emit onProgressSuccess(m_components.servers.size()); + emit success(m_components.servers.size()); emit done(); } void COperationDialog::deleteComponentsProfiles() { + m_currentOperation = QApplication::tr("Delete profiles"); + m_currentOperationProgressFormat = QApplication::tr("Deleting profile %1..."); + + emit prepare(); + emit init(0, m_components.servers.size()); + + CConfigFile *config = CConfigFile::getInstance(); + + int i = 0; + + foreach(int profileIndex, m_components.profiles) + { + if (operationShouldStop()) + { + emit stop(); + return; + } + + const CProfile &profile = config->getProfile(profileIndex); + + emit progress(i++, profile.name); + + QString path = config->getProfileDirectory() + "/" + profile.id; + + QDir dir(path); + + if (dir.exists() && !dir.removeRecursively()) + { + emit fail(tr("Unable to delete files for profile %1").arg(profile.name)); + return; + } + } + + emit success(m_components.servers.size()); emit done(); } void COperationDialog::deleteComponentsInstaller() { + m_currentOperation = QApplication::tr("Delete installer"); + m_currentOperationProgressFormat = QApplication::tr("Deleting %1..."); + + CConfigFile *config = CConfigFile::getInstance(); + + // TODO: delete installer + + deleteAddRemoveEntry(); + + emit onProgressSuccess(m_components.servers.size()); emit done(); } diff --git a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.h b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.h index 61105742d..fe252ab6a 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.h +++ b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.h @@ -107,6 +107,7 @@ protected: bool createDefaultProfile(); bool createDefaultShortcuts(); bool createAddRemoveEntry(); + bool deleteAddRemoveEntry(); void deleteComponentsServers(); void deleteComponentsProfiles(); void deleteComponentsInstaller();