From 7ee609ae859a7374cd7b78bce54f1e5d39303666 Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 14 Aug 2016 12:47:56 +0200 Subject: [PATCH 01/10] Changed: Allow to get size of a directory recursively or not, see #279 --HG-- branch : develop --- .../tools/client/ryzom_installer/src/operationdialog.cpp | 4 ++-- .../tools/client/ryzom_installer/src/uninstalldialog.cpp | 4 ++-- code/ryzom/tools/client/ryzom_installer/src/utils.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp index 1a4cf9f13..73fc76149 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp @@ -920,7 +920,7 @@ bool COperationDialog::createAddRemoveEntry() settings.setValue("DisplayIcon", nativeFullPath + ",0"); settings.setValue("DisplayName", QApplication::applicationName()); settings.setValue("DisplayVersion", RYZOM_VERSION); - settings.setValue("EstimatedSize", getDirectorySize(config->getInstallationDirectory())); + settings.setValue("EstimatedSize", getDirectorySize(config->getInstallationDirectory(), true)); settings.setValue("InstallDate", QDateTime::currentDateTime().toString("Ymd")); settings.setValue("InstallLocation", config->getInstallationDirectory()); settings.setValue("MajorVersion", versionTokens[0].toInt()); @@ -965,7 +965,7 @@ bool COperationDialog::updateAddRemoveEntry() QStringList versionTokens = QApplication::applicationVersion().split('.'); settings.setValue("DisplayVersion", QApplication::applicationVersion()); - settings.setValue("EstimatedSize", getDirectorySize(config->getInstallationDirectory())); + settings.setValue("EstimatedSize", getDirectorySize(config->getInstallationDirectory(), true)); settings.setValue("MajorVersion", versionTokens[0].toInt()); settings.setValue("MinorVersion", versionTokens[1].toInt()); #endif diff --git a/code/ryzom/tools/client/ryzom_installer/src/uninstalldialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/uninstalldialog.cpp index a527e680a..94ea973e6 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/uninstalldialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/uninstalldialog.cpp @@ -243,7 +243,7 @@ void CUninstallDialog::updateSizes() { const CServer &server = config->getServer(it.key()); - qint64 bytes = getDirectorySize(server.getDirectory()); + qint64 bytes = getDirectorySize(server.getDirectory(), true); emit updateSize(it.value(), qBytesToHumanReadable(bytes)); @@ -257,7 +257,7 @@ void CUninstallDialog::updateSizes() { const CProfile &profile = config->getProfile(it.key()); - qint64 bytes = getDirectorySize(profile.getDirectory()); + qint64 bytes = getDirectorySize(profile.getDirectory(), true); emit updateSize(it.value(), qBytesToHumanReadable(bytes)); diff --git a/code/ryzom/tools/client/ryzom_installer/src/utils.h b/code/ryzom/tools/client/ryzom_installer/src/utils.h index 363c30b9e..6de89bcba 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/utils.h +++ b/code/ryzom/tools/client/ryzom_installer/src/utils.h @@ -30,7 +30,7 @@ QString qBytesToHumanReadable(qint64 bytes); -qint64 getDirectorySize(const QString &directory); +qint64 getDirectorySize(const QString &directory, bool recursize); // Convert a UTF-8 string to QString QString qFromUtf8(const std::string &str); From 4e707172516dc45878139a664f5cc12b6be9642b Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 14 Aug 2016 12:48:33 +0200 Subject: [PATCH 02/10] Fixed: Wrong name of packed sheets BNP, see #279 --HG-- branch : develop --- code/ryzom/tools/client/ryzom_installer/src/filescleaner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/filescleaner.cpp b/code/ryzom/tools/client/ryzom_installer/src/filescleaner.cpp index 2f310e056..be62ee2a9 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/filescleaner.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/filescleaner.cpp @@ -51,7 +51,7 @@ bool CFilesCleaner::exec() QStringList filter; filter << "*.string_cache"; - if (dir.exists("packed_sheets.bnp")) + if (dir.exists("packedsheets.bnp")) { filter << "*.packed_sheets"; filter << "*.packed"; From 29caab3ae763c9420f6b6d84c33f795bdeb1987d Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 14 Aug 2016 12:49:39 +0200 Subject: [PATCH 03/10] Changed: Always copy installer if different, see #279 --HG-- branch : develop --- .../ryzom_installer/src/operationdialog.cpp | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp index 73fc76149..455ce0be5 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp @@ -713,23 +713,25 @@ void COperationDialog::copyInstaller() QString oldInstallerFullPath = QApplication::applicationFilePath(); QString newInstallerFullPath = config->getInstallationDirectory() + "/" + newInstallerFilename; - if (!QFile::exists(newInstallerFullPath)) + // always copy new installers + CFilesCopier copier(this); + copier.setIncludeFilter(config->getInstallerRequiredFiles()); + copier.addFile(oldInstallerFullPath); + copier.setSourceDirectory(config->getSrcServerDirectory().isEmpty() ? QApplication::applicationDirPath():config->getSrcServerDirectory()); + copier.setDestinationDirectory(config->getInstallationDirectory()); + copier.exec(); + + // copied file + oldInstallerFullPath = config->getInstallationDirectory() + "/" + QFileInfo(oldInstallerFullPath).fileName(); + + // rename old filename if different + if (oldInstallerFullPath != newInstallerFullPath) { - CFilesCopier copier(this); - copier.setIncludeFilter(config->getInstallerRequiredFiles()); - copier.addFile(oldInstallerFullPath); - copier.setSourceDirectory(config->getSrcServerDirectory().isEmpty() ? QApplication::applicationDirPath():config->getSrcServerDirectory()); - copier.setDestinationDirectory(config->getInstallationDirectory()); - copier.exec(); + // delete previous installer + QFile::remove(newInstallerFullPath); - // copied file - oldInstallerFullPath = config->getInstallationDirectory() + "/" + QFileInfo(oldInstallerFullPath).fileName(); - - // rename old filename if different - if (oldInstallerFullPath != newInstallerFullPath) - { - QFile::rename(oldInstallerFullPath, newInstallerFullPath); - } + // rename new installer with final name + QFile::rename(oldInstallerFullPath, newInstallerFullPath); } // create menu directory if defined From fbd2c86629026d2e3a2efdfc1e1e6c246d96e3cc Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 14 Aug 2016 12:50:11 +0200 Subject: [PATCH 04/10] Changed: Computes size of downloaded files, see #279 --HG-- branch : develop --- .../tools/client/ryzom_installer/src/uninstalldialog.cpp | 5 +++++ code/ryzom/tools/client/ryzom_installer/src/utils.cpp | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/uninstalldialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/uninstalldialog.cpp index 94ea973e6..bfba57840 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/uninstalldialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/uninstalldialog.cpp @@ -264,6 +264,11 @@ void CUninstallDialog::updateSizes() ++it; } + // downloaded files + qint64 bytes = getDirectorySize(config->getInstallationDirectory(), false); + + emit updateSize(m_downloadedFilesIndex, qBytesToHumanReadable(bytes)); + emit updateLayout(); } diff --git a/code/ryzom/tools/client/ryzom_installer/src/utils.cpp b/code/ryzom/tools/client/ryzom_installer/src/utils.cpp index cdbadc246..28860ffab 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/utils.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/utils.cpp @@ -34,7 +34,7 @@ QString qBytesToHumanReadable(qint64 bytes) return QString::fromUtf8(NLMISC::bytesToHumanReadable(bytes).c_str()); } -qint64 getDirectorySize(const QString &directory) +qint64 getDirectorySize(const QString &directory, bool recursize) { qint64 size = 0; @@ -52,7 +52,7 @@ qint64 getDirectorySize(const QString &directory) if (fileInfo.isDir()) { - size += getDirectorySize(fileInfo.absoluteFilePath()); + if (recursize) size += getDirectorySize(fileInfo.absoluteFilePath(), true); } else { From 378ae6ecbb48a245a0edb198e070647c20ca6403 Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 14 Aug 2016 12:50:29 +0200 Subject: [PATCH 05/10] Fixed: Missing Q_OBJECT, see #279 --HG-- branch : develop --- code/ryzom/tools/client/ryzom_installer/src/profilesmodel.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/ryzom/tools/client/ryzom_installer/src/profilesmodel.h b/code/ryzom/tools/client/ryzom_installer/src/profilesmodel.h index ca78ec028..b7fe64185 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/profilesmodel.h +++ b/code/ryzom/tools/client/ryzom_installer/src/profilesmodel.h @@ -11,6 +11,8 @@ */ class CProfilesModel : public QAbstractListModel { + Q_OBJECT + public: CProfilesModel(QObject *parent); CProfilesModel(const CProfiles &profiles, QObject *parent); From 0f587c079d1bf90c6535ba2c7d8b4415f08e0ed7 Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 14 Aug 2016 12:52:22 +0200 Subject: [PATCH 06/10] Fixed: Save config after choosing if we should uninstall previous version, see #279 --HG-- branch : develop --- .../ryzom/tools/client/ryzom_installer/src/operationdialog.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp index 455ce0be5..c706dba84 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp @@ -798,6 +798,9 @@ void COperationDialog::uninstallOldClient() // don't ask this question anymore CConfigFile::getInstance()->setShouldUninstallOldClient(false); } + + // save the choice + CConfigFile::getInstance()->save(); } } #endif From bb58710623f299d332ed1fef28cf7e7fd5391c80 Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 14 Aug 2016 13:26:45 +0200 Subject: [PATCH 07/10] Added: CProfile and CServer classes have their own sources, see #279 --HG-- branch : develop --- .../client/ryzom_installer/src/configfile.cpp | 116 ----------------- .../client/ryzom_installer/src/configfile.h | 69 +--------- .../client/ryzom_installer/src/profile.cpp | 120 ++++++++++++++++++ .../client/ryzom_installer/src/profile.h | 55 ++++++++ .../client/ryzom_installer/src/server.cpp | 44 +++++++ .../tools/client/ryzom_installer/src/server.h | 56 ++++++++ 6 files changed, 277 insertions(+), 183 deletions(-) create mode 100644 code/ryzom/tools/client/ryzom_installer/src/profile.cpp create mode 100644 code/ryzom/tools/client/ryzom_installer/src/profile.h create mode 100644 code/ryzom/tools/client/ryzom_installer/src/server.cpp create mode 100644 code/ryzom/tools/client/ryzom_installer/src/server.h diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp index de485e870..241dbeed0 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp @@ -24,122 +24,6 @@ #define new DEBUG_NEW #endif -const CServer NoServer; -const CProfile NoProfile; - -QString CServer::getDirectory() const -{ - return CConfigFile::getInstance()->getInstallationDirectory() + "/" + id; -} - -QString CServer::getClientFullPath() const -{ - if (clientFilename.isEmpty()) return ""; - - return getDirectory() + "/" + clientFilename; -} - -QString CServer::getConfigurationFullPath() const -{ - if (configurationFilename.isEmpty()) return ""; - - return getDirectory() + "/" + configurationFilename; -} - -QString CProfile::getDirectory() const -{ - return CConfigFile::getInstance()->getProfileDirectory() + "/" + id; -} - -QString CProfile::getClientFullPath() const -{ - if (!executable.isEmpty()) return executable; - - const CServer &s = CConfigFile::getInstance()->getServer(server); - - return s.getClientFullPath(); -} - -QString CProfile::getClientDesktopShortcutFullPath() const -{ -#ifdef Q_OS_WIN32 - return CConfigFile::getInstance()->getDesktopDirectory() + "/" + name + ".lnk"; -#elif defined(Q_OS_MAC) - return ""; -#else - return CConfigFile::getInstance()->getDesktopDirectory() + "/" + name + ".desktop"; -#endif -} - -QString CProfile::getClientMenuShortcutFullPath() const -{ -#ifdef Q_OS_WIN32 - return CConfigFile::getInstance()->getMenuDirectory() + "/" + name + ".lnk"; -#elif defined(Q_OS_MAC) - return ""; -#else - return CConfigFile::getInstance()->getMenuDirectory() + "/" + name + ".desktop"; -#endif -} - -void CProfile::createShortcuts() const -{ - const CServer &s = CConfigFile::getInstance()->getServer(server); - - QString executable = getClientFullPath(); - QString workingDir = s.getDirectory(); - - QString arguments = QString("--profile %1").arg(id); - - // append custom arguments - if (!arguments.isEmpty()) arguments += QString(" %1").arg(arguments); - - QString icon; - -#ifdef Q_OS_WIN32 - // under Windows, icon is included in executable - icon = executable; -#else - // icon is in the same directory as client - icon = s.getDirectory() + "/ryzom_client.png"; -#endif - - if (desktopShortcut) - { - QString shortcut = getClientDesktopShortcutFullPath(); - - // create desktop shortcut - createLink(shortcut, name, executable, arguments, icon, workingDir); - } - - if (menuShortcut) - { - QString shortcut = getClientMenuShortcutFullPath(); - - // create menu shortcut - createLink(shortcut, name, executable, arguments, icon, workingDir); - } -} - -void CProfile::deleteShortcuts() const -{ - // delete desktop shortcut - QString link = getClientDesktopShortcutFullPath(); - - if (QFile::exists(link)) QFile::remove(link); - - // delete menu shortcut - link = getClientMenuShortcutFullPath(); - - if (QFile::exists(link)) QFile::remove(link); -} - -void CProfile::updateShortcuts() const -{ - deleteShortcuts(); - createShortcuts(); -} - CConfigFile *CConfigFile::s_instance = NULL; CConfigFile::CConfigFile(QObject *parent):QObject(parent), m_version(-1), diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.h b/code/ryzom/tools/client/ryzom_installer/src/configfile.h index de3440086..058e5c475 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.h +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.h @@ -18,73 +18,8 @@ #define CONFIGFILE_H #include "operation.h" - -class CServer -{ -public: - CServer() - { - dataCompressedSize = 0; - dataUncompressedSize = 0; - } - - QString id; - QString name; - QString displayUrl; - QString dataDownloadUrl; - QString dataDownloadFilename; - qint64 dataCompressedSize; - qint64 dataUncompressedSize; - QString clientDownloadUrl; - QString clientDownloadFilename; - QString clientFilename; - QString clientFilenameOld; - QString configurationFilename; - QString installerFilename; - QString comments; - - // helpers - QString getDirectory() const; - QString getClientFullPath() const; - QString getConfigurationFullPath() const; -}; - -extern const CServer NoServer; - -typedef QVector CServers; - -class CProfile -{ -public: - CProfile() - { - desktopShortcut = false; - menuShortcut = false; - } - - QString id; - QString name; - QString server; - QString executable; - QString arguments; - QString comments; - bool desktopShortcut; - bool menuShortcut; - - // helpers - QString getDirectory() const; - QString getClientFullPath() const; - QString getClientDesktopShortcutFullPath() const; - QString getClientMenuShortcutFullPath() const; - - void createShortcuts() const; - void deleteShortcuts() const; - void updateShortcuts() const; -}; - -extern const CProfile NoProfile; - -typedef QVector CProfiles; +#include "server.h" +#include "profile.h" /** * Config file management and other stuff related to location of files/directories. diff --git a/code/ryzom/tools/client/ryzom_installer/src/profile.cpp b/code/ryzom/tools/client/ryzom_installer/src/profile.cpp new file mode 100644 index 000000000..6f67495cc --- /dev/null +++ b/code/ryzom/tools/client/ryzom_installer/src/profile.cpp @@ -0,0 +1,120 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include "stdpch.h" +#include "profile.h" +#include "configfile.h" +#include "utils.h" + +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif + +const CProfile NoProfile; + +QString CProfile::getDirectory() const +{ + return CConfigFile::getInstance()->getProfileDirectory() + "/" + id; +} + +QString CProfile::getClientFullPath() const +{ + if (!executable.isEmpty()) return executable; + + const CServer &s = CConfigFile::getInstance()->getServer(server); + + return s.getClientFullPath(); +} + +QString CProfile::getClientDesktopShortcutFullPath() const +{ +#ifdef Q_OS_WIN32 + return CConfigFile::getInstance()->getDesktopDirectory() + "/" + name + ".lnk"; +#elif defined(Q_OS_MAC) + return ""; +#else + return CConfigFile::getInstance()->getDesktopDirectory() + "/" + name + ".desktop"; +#endif +} + +QString CProfile::getClientMenuShortcutFullPath() const +{ +#ifdef Q_OS_WIN32 + return CConfigFile::getInstance()->getMenuDirectory() + "/" + name + ".lnk"; +#elif defined(Q_OS_MAC) + return ""; +#else + return CConfigFile::getInstance()->getMenuDirectory() + "/" + name + ".desktop"; +#endif +} + +void CProfile::createShortcuts() const +{ + const CServer &s = CConfigFile::getInstance()->getServer(server); + + QString executable = getClientFullPath(); + QString workingDir = s.getDirectory(); + + QString arguments = QString("--profile %1").arg(id); + + // append custom arguments + if (!arguments.isEmpty()) arguments += QString(" %1").arg(arguments); + + QString icon; + +#ifdef Q_OS_WIN32 + // under Windows, icon is included in executable + icon = executable; +#else + // icon is in the same directory as client + icon = s.getDirectory() + "/ryzom_client.png"; +#endif + + if (desktopShortcut) + { + QString shortcut = getClientDesktopShortcutFullPath(); + + // create desktop shortcut + createLink(shortcut, name, executable, arguments, icon, workingDir); + } + + if (menuShortcut) + { + QString shortcut = getClientMenuShortcutFullPath(); + + // create menu shortcut + createLink(shortcut, name, executable, arguments, icon, workingDir); + } +} + +void CProfile::deleteShortcuts() const +{ + // delete desktop shortcut + QString link = getClientDesktopShortcutFullPath(); + + if (QFile::exists(link)) QFile::remove(link); + + // delete menu shortcut + link = getClientMenuShortcutFullPath(); + + if (QFile::exists(link)) QFile::remove(link); +} + +void CProfile::updateShortcuts() const +{ + deleteShortcuts(); + createShortcuts(); +} diff --git a/code/ryzom/tools/client/ryzom_installer/src/profile.h b/code/ryzom/tools/client/ryzom_installer/src/profile.h new file mode 100644 index 000000000..df34788b1 --- /dev/null +++ b/code/ryzom/tools/client/ryzom_installer/src/profile.h @@ -0,0 +1,55 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef PROFILE_H +#define PROFILE_H + +#include "operation.h" + +class CProfile +{ +public: + CProfile() + { + desktopShortcut = false; + menuShortcut = false; + } + + QString id; + QString name; + QString server; + QString executable; + QString arguments; + QString comments; + bool desktopShortcut; + bool menuShortcut; + + // helpers + QString getDirectory() const; + QString getClientFullPath() const; + QString getClientDesktopShortcutFullPath() const; + QString getClientMenuShortcutFullPath() const; + + void createShortcuts() const; + void deleteShortcuts() const; + void updateShortcuts() const; +}; + +extern const CProfile NoProfile; + +typedef QVector CProfiles; + +#endif diff --git a/code/ryzom/tools/client/ryzom_installer/src/server.cpp b/code/ryzom/tools/client/ryzom_installer/src/server.cpp new file mode 100644 index 000000000..9f6924c42 --- /dev/null +++ b/code/ryzom/tools/client/ryzom_installer/src/server.cpp @@ -0,0 +1,44 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include "stdpch.h" +#include "server.h" +#include "configfile.h" + +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif + +const CServer NoServer; + +QString CServer::getDirectory() const +{ + return CConfigFile::getInstance()->getInstallationDirectory() + "/" + id; +} + +QString CServer::getClientFullPath() const +{ + if (clientFilename.isEmpty()) return ""; + + return getDirectory() + "/" + clientFilename; +} + +QString CServer::getConfigurationFullPath() const +{ + if (configurationFilename.isEmpty()) return ""; + + return getDirectory() + "/" + configurationFilename; +} diff --git a/code/ryzom/tools/client/ryzom_installer/src/server.h b/code/ryzom/tools/client/ryzom_installer/src/server.h new file mode 100644 index 000000000..7a8f2d258 --- /dev/null +++ b/code/ryzom/tools/client/ryzom_installer/src/server.h @@ -0,0 +1,56 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef SERVER_H +#define SERVER_H + +#include "operation.h" + +class CServer +{ +public: + CServer() + { + dataCompressedSize = 0; + dataUncompressedSize = 0; + } + + QString id; + QString name; + QString displayUrl; + QString dataDownloadUrl; + QString dataDownloadFilename; + qint64 dataCompressedSize; + qint64 dataUncompressedSize; + QString clientDownloadUrl; + QString clientDownloadFilename; + QString clientFilename; + QString clientFilenameOld; + QString configurationFilename; + QString installerFilename; + QString comments; + + // helpers + QString getDirectory() const; + QString getClientFullPath() const; + QString getConfigurationFullPath() const; +}; + +extern const CServer NoServer; + +typedef QVector CServers; + +#endif From 78efe0a895753cc07e6c8392d00b7e348732b898 Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 14 Aug 2016 13:28:50 +0200 Subject: [PATCH 08/10] Changed: Try to load config file everytime, see #279 --HG-- branch : develop --- code/ryzom/tools/client/ryzom_installer/src/configfile.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp index 241dbeed0..f59ee44df 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp @@ -49,7 +49,12 @@ CConfigFile::~CConfigFile() bool CConfigFile::load() { // load default values - return load(m_defaultConfigPath) || load(m_configPath); + if (!load(m_defaultConfigPath)) return false; + + // ignore return value, since we'll always have valid values + load(m_configPath); + + return true; } bool CConfigFile::load(const QString &filename) From 2bc1e268683cbc2a793cf95a883e884b4bc9c257 Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 14 Aug 2016 13:29:27 +0200 Subject: [PATCH 09/10] Changed: Check modification time of Installer to determine if it must be copied again, see #279 --HG-- branch : develop --- .../client/ryzom_installer/src/configfile.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp index f59ee44df..345dd80bc 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp @@ -911,8 +911,20 @@ OperationStep CConfigFile::getInstallNextStep() const } } + QString installerDst = getInstallationDirectory() + "/" + server.installerFilename; + // if installer not found in installation directory, extract it from BNP - if (!QFile::exists(getInstallationDirectory() + "/" + server.installerFilename)) + if (QFile::exists(installerDst)) + { + QString installerSrc = getInstallerCurrentFilePath(); + + // copy it too if destination one if older than new one + uint64 srcDate = QFileInfo(installerSrc).lastModified().toTime_t(); + uint64 dstDate = QFileInfo(installerDst).lastModified().toTime_t(); + + if (srcDate > dstDate) return CopyInstaller; + } + else { return CopyInstaller; } From 373654ea460f200059ec73f560edf81591d095f1 Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 14 Aug 2016 13:35:46 +0200 Subject: [PATCH 10/10] Changed: Rerun installer from TEMP under Windows, see #279 --HG-- branch : develop --- .../client/ryzom_installer/src/configfile.cpp | 19 +++++++++- .../client/ryzom_installer/src/configfile.h | 6 +++- .../tools/client/ryzom_installer/src/main.cpp | 35 ++++++++++--------- .../ryzom_installer/src/operationdialog.cpp | 4 +-- 4 files changed, 43 insertions(+), 21 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp index 345dd80bc..6e978cd80 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp @@ -722,11 +722,28 @@ bool CConfigFile::shouldCreateMenuShortcut() const return !shortcut.isEmpty() && !NLMISC::CFile::isExists(qToUtf8(shortcut)); } -QString CConfigFile::getInstallerFullPath() const +QString CConfigFile::getInstallerCurrentFilePath() const { + // installer is always run from TEMP under Windows + return QApplication::applicationFilePath(); +} + +QString CConfigFile::getInstallerCurrentDirPath() const +{ + // installer is always run from TEMP under Windows return QApplication::applicationDirPath(); } +QString CConfigFile::getInstallerOriginalFilePath() const +{ + return getInstallerOriginalDirPath() + "/" + QFileInfo(QApplication::applicationFilePath()).fileName(); +} + +QString CConfigFile::getInstallerOriginalDirPath() const +{ + return m_installationDirectory; +} + QString CConfigFile::getInstallerMenuLinkFullPath() const { #ifdef Q_OS_WIN32 diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.h b/code/ryzom/tools/client/ryzom_installer/src/configfile.h index 058e5c475..b2a4ae7e5 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.h +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.h @@ -113,7 +113,11 @@ public: QString getClientArch() const; - QString getInstallerFullPath() const; + QString getInstallerCurrentFilePath() const; + QString getInstallerCurrentDirPath() const; + QString getInstallerOriginalFilePath() const; + QString getInstallerOriginalDirPath() const; + QString getInstallerMenuLinkFullPath() const; QStringList getInstallerRequiredFiles() const; diff --git a/code/ryzom/tools/client/ryzom_installer/src/main.cpp b/code/ryzom/tools/client/ryzom_installer/src/main.cpp index 481c15bff..2e4ad5481 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/main.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/main.cpp @@ -120,6 +120,24 @@ int main(int argc, char *argv[]) return 1; } +#if defined(Q_OS_WIN) && !defined(_DEBUG) + // under Windows, Ryzom Installer should always be copied in TEMP directory + QString tempPath = QStandardPaths::writableLocation(QStandardPaths::TempLocation); + + // check if launched from TEMP directory + if (step == Done && QApplication::applicationDirPath() != tempPath) + { + // copy installer and required files to TEMP directory + if (copyInstallerFiles(config.getInstallerRequiredFiles(), tempPath)) + { + QString tempFile = tempPath + "/" + QFileInfo(QApplication::applicationFilePath()).fileName(); + + // launch copy in TEMP directory with same arguments + if (QProcess::startDetached(tempFile, QApplication::arguments())) return 0; + } + } +#endif + // use product name from ryzom_installer.ini if (!config.getProductName().isEmpty()) QApplication::setApplicationName(config.getProductName()); @@ -141,23 +159,6 @@ int main(int argc, char *argv[]) if (parser.isSet(uninstallOption)) { -#if defined(Q_OS_WIN) && !defined(_DEBUG) - QString tempPath = QStandardPaths::writableLocation(QStandardPaths::TempLocation); - - // check if launched from TEMP directory - if (QApplication::applicationDirPath() != tempPath) - { - // copy installer and required files to TEMP directory - if (copyInstallerFiles(config.getInstallerRequiredFiles(), tempPath)) - { - QString tempFile = tempPath + "/" + QFileInfo(QApplication::applicationFilePath()).fileName(); - - // launch copy in TEMP directory with same arguments - if (QProcess::startDetached(tempFile, QApplication::arguments())) return 0; - } - } -#endif - SComponents components; // add all servers by default diff --git a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp index c706dba84..da7a2f52d 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp @@ -1135,7 +1135,7 @@ void COperationDialog::deleteComponentsInstaller() dir.removeRecursively(); } - path = config->getInstallerFullPath(); + path = config->getInstallerOriginalDirPath(); QStringList files = config->getInstallerRequiredFiles(); foreach(const QString &file, files) @@ -1143,7 +1143,7 @@ void COperationDialog::deleteComponentsInstaller() QString fullPath = path + "/" + file; // delete file - if (!QFile::remove(fullPath)) + if (QFile::exists(fullPath) && !QFile::remove(fullPath)) { #ifdef Q_OS_WIN32 // under Windows, a running executable is locked, so we need to delete it later