2016-02-25 20:19:27 +00:00
|
|
|
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
|
|
|
// 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 <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
#include "stdpch.h"
|
|
|
|
#include "configfile.h"
|
|
|
|
#include "utils.h"
|
|
|
|
|
|
|
|
#include "nel/misc/path.h"
|
|
|
|
|
|
|
|
#ifdef DEBUG_NEW
|
|
|
|
#define new DEBUG_NEW
|
|
|
|
#endif
|
|
|
|
|
|
|
|
const CServer NoServer;
|
2016-02-27 17:43:14 +00:00
|
|
|
const CProfile NoProfile;
|
2016-02-25 20:19:27 +00:00
|
|
|
|
2016-06-14 17:45:29 +00:00
|
|
|
QString CServer::getDirectory() const
|
|
|
|
{
|
|
|
|
return CConfigFile::getInstance()->getInstallationDirectory() + "/" + id;
|
|
|
|
}
|
|
|
|
|
2016-06-19 19:04:00 +00:00
|
|
|
QString CServer::getClientFullPath() const
|
|
|
|
{
|
|
|
|
if (clientFilename.isEmpty()) return "";
|
|
|
|
|
|
|
|
return getDirectory() + "/" + clientFilename;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString CServer::getConfigurationFullPath() const
|
|
|
|
{
|
|
|
|
if (configurationFilename.isEmpty()) return "";
|
|
|
|
|
|
|
|
return getDirectory() + "/" + configurationFilename;
|
|
|
|
}
|
|
|
|
|
2016-06-14 17:45:29 +00:00
|
|
|
QString CProfile::getDirectory() const
|
|
|
|
{
|
|
|
|
return CConfigFile::getInstance()->getProfileDirectory() + "/" + id;
|
|
|
|
}
|
|
|
|
|
2016-06-19 19:04:00 +00:00
|
|
|
QString CProfile::getClientFullPath() const
|
|
|
|
{
|
|
|
|
if (!executable.isEmpty()) return executable;
|
|
|
|
|
|
|
|
const CServer &s = CConfigFile::getInstance()->getServer(server);
|
|
|
|
|
|
|
|
return s.getClientFullPath();
|
|
|
|
}
|
|
|
|
|
2016-07-25 16:31:11 +00:00
|
|
|
QString CProfile::getClientDesktopShortcutFullPath() const
|
2016-06-19 19:04:00 +00:00
|
|
|
{
|
|
|
|
#ifdef Q_OS_WIN32
|
|
|
|
return CConfigFile::getInstance()->getDesktopDirectory() + "/" + name + ".lnk";
|
2016-07-25 16:31:11 +00:00
|
|
|
#elif defined(Q_OS_MAC)
|
2016-06-19 19:04:00 +00:00
|
|
|
return "";
|
2016-07-25 16:31:11 +00:00
|
|
|
#else
|
|
|
|
return CConfigFile::getInstance()->getDesktopDirectory() + "/" + name + ".desktop";
|
2016-06-19 19:04:00 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-07-25 16:31:11 +00:00
|
|
|
QString CProfile::getClientMenuShortcutFullPath() const
|
2016-06-19 19:04:00 +00:00
|
|
|
{
|
|
|
|
#ifdef Q_OS_WIN32
|
|
|
|
return CConfigFile::getInstance()->getMenuDirectory() + "/" + name + ".lnk";
|
2016-07-25 16:31:11 +00:00
|
|
|
#elif defined(Q_OS_MAC)
|
2016-06-19 19:04:00 +00:00
|
|
|
return "";
|
2016-07-25 16:31:11 +00:00
|
|
|
#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
|
2016-07-26 16:22:18 +00:00
|
|
|
// under Windows, icon is included in executable
|
2016-07-25 16:31:11 +00:00
|
|
|
icon = executable;
|
|
|
|
#else
|
2016-07-26 16:22:18 +00:00
|
|
|
// icon is in the same directory as client
|
|
|
|
icon = s.getDirectory() + "/ryzom_client.png";
|
2016-06-19 19:04:00 +00:00
|
|
|
#endif
|
2016-07-25 16:31:11 +00:00
|
|
|
|
|
|
|
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();
|
2016-06-19 19:04:00 +00:00
|
|
|
}
|
|
|
|
|
2016-02-25 20:19:27 +00:00
|
|
|
CConfigFile *CConfigFile::s_instance = NULL;
|
|
|
|
|
2016-07-27 09:52:59 +00:00
|
|
|
CConfigFile::CConfigFile(QObject *parent):QObject(parent), m_version(-1),
|
|
|
|
m_defaultServerIndex(0), m_defaultProfileIndex(0), m_use64BitsClient(false), m_shouldUninstallOldClient(true)
|
2016-02-25 20:19:27 +00:00
|
|
|
{
|
|
|
|
s_instance = this;
|
|
|
|
|
2016-07-25 16:54:37 +00:00
|
|
|
// only keep language ISO 639 code
|
|
|
|
m_language = QLocale::system().name().left(2);
|
|
|
|
|
2016-07-27 09:52:59 +00:00
|
|
|
// default config file in included in resources
|
|
|
|
m_defaultConfigPath = ":/templates/ryzom_installer.ini";
|
2016-07-25 16:54:37 +00:00
|
|
|
|
|
|
|
// the config file we'll write
|
2016-07-27 09:52:59 +00:00
|
|
|
m_configPath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/ryzom_installer.ini";
|
2016-02-25 20:19:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CConfigFile::~CConfigFile()
|
|
|
|
{
|
|
|
|
s_instance = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CConfigFile::load()
|
|
|
|
{
|
2016-07-27 09:52:59 +00:00
|
|
|
// load default values
|
|
|
|
load(m_defaultConfigPath);
|
|
|
|
|
|
|
|
return load(m_configPath);
|
2016-02-25 20:19:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CConfigFile::load(const QString &filename)
|
|
|
|
{
|
2016-07-27 09:52:59 +00:00
|
|
|
if (!QFile::exists(filename)) return false;
|
|
|
|
|
2016-02-25 20:19:27 +00:00
|
|
|
QSettings settings(filename, QSettings::IniFormat);
|
|
|
|
|
2016-07-27 09:52:59 +00:00
|
|
|
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
|
2016-02-25 20:19:27 +00:00
|
|
|
settings.beginGroup("common");
|
2016-05-25 21:28:05 +00:00
|
|
|
m_language = settings.value("language", m_language).toString();
|
2016-02-25 20:19:27 +00:00
|
|
|
m_srcDirectory = settings.value("source_directory").toString();
|
|
|
|
m_installationDirectory = settings.value("installation_directory").toString();
|
2016-05-29 18:32:33 +00:00
|
|
|
m_use64BitsClient = settings.value("use_64bits_client", true).toBool();
|
|
|
|
m_shouldUninstallOldClient = settings.value("should_uninstall_old_client", true).toBool();
|
2016-02-25 20:19:27 +00:00
|
|
|
settings.endGroup();
|
|
|
|
|
2016-07-27 09:52:59 +00:00
|
|
|
if (!useDefaultValues)
|
|
|
|
{
|
|
|
|
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();
|
2016-05-27 20:20:41 +00:00
|
|
|
|
2016-07-27 09:52:59 +00:00
|
|
|
settings.beginGroup("servers");
|
|
|
|
int serversCount = settings.value("size").toInt();
|
|
|
|
m_defaultServerIndex = settings.value("default").toInt();
|
|
|
|
settings.endGroup();
|
2016-02-25 20:19:27 +00:00
|
|
|
|
2016-07-27 09:52:59 +00:00
|
|
|
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();
|
2016-02-25 20:19:27 +00:00
|
|
|
#if defined(Q_OS_WIN)
|
2016-07-27 09:52:59 +00:00
|
|
|
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();
|
2016-02-25 20:19:27 +00:00
|
|
|
#elif defined(Q_OS_MAC)
|
2016-07-27 09:52:59 +00:00
|
|
|
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();
|
2016-02-25 20:19:27 +00:00
|
|
|
#else
|
2016-07-27 09:52:59 +00:00
|
|
|
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();
|
2016-02-25 20:19:27 +00:00
|
|
|
#endif
|
2016-07-27 09:52:59 +00:00
|
|
|
server.comments = settings.value("comments").toString();
|
2016-02-25 20:19:27 +00:00
|
|
|
|
2016-07-27 09:52:59 +00:00
|
|
|
settings.endGroup();
|
|
|
|
}
|
2016-02-25 20:19:27 +00:00
|
|
|
}
|
|
|
|
|
2016-07-27 09:52:59 +00:00
|
|
|
// custom choices, always keep them
|
2016-02-27 17:43:14 +00:00
|
|
|
settings.beginGroup("profiles");
|
|
|
|
int profilesCounts = settings.value("size").toInt();
|
2016-05-16 09:12:30 +00:00
|
|
|
m_defaultProfileIndex = settings.value("default").toInt();
|
2016-02-25 20:19:27 +00:00
|
|
|
settings.endGroup();
|
|
|
|
|
2016-02-27 17:43:14 +00:00
|
|
|
m_profiles.resize(profilesCounts);
|
2016-02-25 20:19:27 +00:00
|
|
|
|
2016-02-27 17:43:14 +00:00
|
|
|
for(int i = 0; i < profilesCounts; ++i)
|
2016-02-25 20:19:27 +00:00
|
|
|
{
|
2016-02-27 17:43:14 +00:00
|
|
|
CProfile &profile = m_profiles[i];
|
2016-02-25 20:19:27 +00:00
|
|
|
|
2016-02-27 17:43:14 +00:00
|
|
|
settings.beginGroup(QString("profile_%1").arg(i));
|
2016-02-25 20:19:27 +00:00
|
|
|
|
2016-05-16 12:45:43 +00:00
|
|
|
profile.id = settings.value("id").toString();
|
2016-02-27 17:43:14 +00:00
|
|
|
profile.name = settings.value("name").toString();
|
|
|
|
profile.server = settings.value("server").toString();
|
|
|
|
profile.executable = settings.value("executable").toString();
|
2016-03-05 11:33:19 +00:00
|
|
|
profile.arguments = settings.value("arguments").toString();
|
2016-02-27 17:43:14 +00:00
|
|
|
profile.comments = settings.value("comments").toString();
|
2016-03-12 20:54:44 +00:00
|
|
|
profile.desktopShortcut = settings.value("desktop_shortcut").toBool();
|
|
|
|
profile.menuShortcut = settings.value("menu_shortcut").toBool();
|
2016-02-25 20:19:27 +00:00
|
|
|
|
|
|
|
settings.endGroup();
|
|
|
|
}
|
|
|
|
|
|
|
|
return !m_servers.isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CConfigFile::save() const
|
|
|
|
{
|
|
|
|
QSettings settings(m_configPath, QSettings::IniFormat);
|
|
|
|
|
2016-07-27 09:52:59 +00:00
|
|
|
settings.setValue("version", m_version);
|
|
|
|
|
2016-02-25 20:19:27 +00:00
|
|
|
settings.beginGroup("common");
|
|
|
|
settings.setValue("language", m_language);
|
|
|
|
settings.setValue("source_directory", m_srcDirectory);
|
|
|
|
settings.setValue("installation_directory", m_installationDirectory);
|
|
|
|
settings.setValue("use_64bits_client", m_use64BitsClient);
|
2016-05-29 18:32:33 +00:00
|
|
|
settings.setValue("should_uninstall_old_client", m_shouldUninstallOldClient);
|
2016-02-25 20:19:27 +00:00
|
|
|
settings.endGroup();
|
|
|
|
|
2016-05-27 20:20:41 +00:00
|
|
|
settings.beginGroup("product");
|
|
|
|
settings.setValue("name", m_productName);
|
|
|
|
settings.setValue("publisher", m_productPublisher);
|
|
|
|
settings.setValue("url_about", m_productAboutUrl);
|
|
|
|
settings.setValue("url_update", m_productUpdateUrl);
|
|
|
|
settings.setValue("url_help", m_productHelpUrl);
|
|
|
|
settings.setValue("comments", m_productComments);
|
|
|
|
settings.endGroup();
|
|
|
|
|
2016-02-25 20:19:27 +00:00
|
|
|
settings.beginGroup("servers");
|
|
|
|
settings.setValue("size", m_servers.size());
|
2016-05-16 09:12:30 +00:00
|
|
|
settings.setValue("default", m_defaultServerIndex);
|
2016-02-25 20:19:27 +00:00
|
|
|
settings.endGroup();
|
|
|
|
|
|
|
|
for(int i = 0; i < m_servers.size(); ++i)
|
|
|
|
{
|
|
|
|
const CServer &server = m_servers[i];
|
|
|
|
|
|
|
|
settings.beginGroup(QString("server_%1").arg(i));
|
|
|
|
|
|
|
|
settings.setValue("id", server.id);
|
|
|
|
settings.setValue("name", server.name);
|
|
|
|
settings.setValue("display_url", server.displayUrl);
|
|
|
|
settings.setValue("data_download_url", server.dataDownloadUrl);
|
|
|
|
settings.setValue("data_download_filename", server.dataDownloadFilename);
|
|
|
|
settings.setValue("data_compressed_size", server.dataCompressedSize);
|
|
|
|
settings.setValue("data_uncompressed_size", server.dataUncompressedSize);
|
|
|
|
settings.setValue("client_download_url", server.clientDownloadUrl);
|
|
|
|
settings.setValue("client_download_filename", server.clientDownloadFilename);
|
|
|
|
#if defined(Q_OS_WIN)
|
|
|
|
settings.setValue("client_filename_windows", server.clientFilename);
|
2016-05-25 21:28:42 +00:00
|
|
|
settings.setValue("client_filename_old_windows", server.clientFilenameOld);
|
2016-05-18 07:56:22 +00:00
|
|
|
settings.setValue("configuration_filename_windows", server.configurationFilename);
|
2016-05-25 21:28:42 +00:00
|
|
|
settings.setValue("installer_filename_windows", server.installerFilename);
|
2016-02-25 20:19:27 +00:00
|
|
|
#elif defined(Q_OS_MAC)
|
|
|
|
settings.setValue("client_filename_osx", server.clientFilename);
|
2016-05-25 21:28:42 +00:00
|
|
|
settings.setValue("client_filename_old_osx", server.clientFilenameOld);
|
2016-05-18 07:56:22 +00:00
|
|
|
settings.setValue("configuration_filename_osx", server.configurationFilename);
|
2016-05-25 21:28:42 +00:00
|
|
|
settings.setValue("installer_filename_osx", server.installerFilename);
|
2016-02-25 20:19:27 +00:00
|
|
|
#else
|
|
|
|
settings.setValue("client_filename_linux", server.clientFilename);
|
2016-05-25 21:28:42 +00:00
|
|
|
settings.setValue("client_filename_old_linux", server.clientFilenameOld);
|
2016-05-18 07:56:22 +00:00
|
|
|
settings.setValue("configuration_filename_linux", server.configurationFilename);
|
2016-05-25 21:28:42 +00:00
|
|
|
settings.setValue("installer_filename_linux", server.installerFilename);
|
2016-02-25 20:19:27 +00:00
|
|
|
#endif
|
|
|
|
settings.setValue("comments", server.comments);
|
|
|
|
|
|
|
|
settings.endGroup();
|
|
|
|
}
|
|
|
|
|
2016-02-27 17:43:14 +00:00
|
|
|
settings.beginGroup("profiles");
|
|
|
|
settings.setValue("size", m_profiles.size());
|
2016-05-16 09:12:30 +00:00
|
|
|
settings.setValue("default", m_defaultProfileIndex);
|
2016-02-25 20:19:27 +00:00
|
|
|
settings.endGroup();
|
|
|
|
|
2016-02-27 17:43:14 +00:00
|
|
|
for(int i = 0; i < m_profiles.size(); ++i)
|
2016-02-25 20:19:27 +00:00
|
|
|
{
|
2016-02-27 17:43:14 +00:00
|
|
|
const CProfile &profile = m_profiles[i];
|
2016-02-25 20:19:27 +00:00
|
|
|
|
2016-02-27 17:43:14 +00:00
|
|
|
settings.beginGroup(QString("profile_%1").arg(i));
|
2016-02-25 20:19:27 +00:00
|
|
|
|
2016-02-27 17:43:14 +00:00
|
|
|
settings.setValue("id", profile.id);
|
|
|
|
settings.setValue("name", profile.name);
|
|
|
|
settings.setValue("server", profile.server);
|
|
|
|
settings.setValue("executable", profile.executable);
|
2016-03-05 11:33:19 +00:00
|
|
|
settings.setValue("arguments", profile.arguments);
|
2016-02-27 17:43:14 +00:00
|
|
|
settings.setValue("comments", profile.comments);
|
2016-03-12 20:54:44 +00:00
|
|
|
settings.setValue("desktop_shortcut", profile.desktopShortcut);
|
|
|
|
settings.setValue("menu_shortcut", profile.menuShortcut);
|
2016-02-25 20:19:27 +00:00
|
|
|
|
|
|
|
settings.endGroup();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
CConfigFile* CConfigFile::getInstance()
|
|
|
|
{
|
|
|
|
return s_instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CConfigFile::getServersCount() const
|
|
|
|
{
|
|
|
|
return m_servers.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
const CServer& CConfigFile::getServer(int i) const
|
|
|
|
{
|
2016-05-16 09:12:30 +00:00
|
|
|
if (i < 0) i = m_defaultServerIndex;
|
2016-02-25 20:19:27 +00:00
|
|
|
|
|
|
|
if (i >= m_servers.size()) return NoServer;
|
|
|
|
|
|
|
|
return m_servers.at(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
const CServer& CConfigFile::getServer(const QString &id) const
|
|
|
|
{
|
|
|
|
for(int i = 0; i < m_servers.size(); ++i)
|
|
|
|
{
|
|
|
|
if (m_servers[i].id == id) return m_servers[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
// default server
|
|
|
|
return getServer();
|
|
|
|
}
|
|
|
|
|
2016-06-12 11:52:28 +00:00
|
|
|
void CConfigFile::backupProfiles()
|
|
|
|
{
|
|
|
|
m_backupProfiles = m_profiles;
|
|
|
|
}
|
|
|
|
|
2016-02-27 17:43:14 +00:00
|
|
|
int CConfigFile::getProfilesCount() const
|
2016-02-25 20:19:27 +00:00
|
|
|
{
|
2016-02-27 17:43:14 +00:00
|
|
|
return m_profiles.size();
|
2016-02-25 20:19:27 +00:00
|
|
|
}
|
|
|
|
|
2016-02-27 17:43:14 +00:00
|
|
|
CProfile CConfigFile::getProfile(int i) const
|
2016-02-25 20:19:27 +00:00
|
|
|
{
|
2016-05-16 09:12:30 +00:00
|
|
|
if (i < 0) i = m_defaultProfileIndex;
|
2016-02-25 20:19:27 +00:00
|
|
|
|
2016-02-27 17:43:14 +00:00
|
|
|
if (i >= m_profiles.size()) return NoProfile;
|
2016-02-25 20:19:27 +00:00
|
|
|
|
2016-02-27 17:43:14 +00:00
|
|
|
return m_profiles.at(i);
|
2016-02-25 20:19:27 +00:00
|
|
|
}
|
|
|
|
|
2016-06-14 17:43:45 +00:00
|
|
|
CProfile CConfigFile::getProfile(const QString &id) const
|
|
|
|
{
|
|
|
|
for (int i = 0; i < m_profiles.size(); ++i)
|
|
|
|
{
|
|
|
|
if (m_profiles[i].id == id) return m_profiles[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
// default profile
|
|
|
|
return getProfile();
|
|
|
|
}
|
|
|
|
|
2016-02-27 17:43:14 +00:00
|
|
|
void CConfigFile::setProfile(int i, const CProfile &profile)
|
2016-02-25 20:19:27 +00:00
|
|
|
{
|
2016-02-27 17:43:14 +00:00
|
|
|
m_profiles[i] = profile;
|
2016-02-25 20:19:27 +00:00
|
|
|
}
|
|
|
|
|
2016-02-27 17:43:14 +00:00
|
|
|
int CConfigFile::addProfile(const CProfile &profile)
|
2016-02-25 20:19:27 +00:00
|
|
|
{
|
2016-02-27 17:43:14 +00:00
|
|
|
m_profiles.append(profile);
|
2016-02-25 20:19:27 +00:00
|
|
|
|
2016-02-27 17:43:14 +00:00
|
|
|
return m_profiles.size()-1;
|
2016-02-25 20:19:27 +00:00
|
|
|
}
|
|
|
|
|
2016-02-27 17:43:14 +00:00
|
|
|
void CConfigFile::removeProfile(int i)
|
2016-02-25 20:19:27 +00:00
|
|
|
{
|
2016-02-27 17:43:14 +00:00
|
|
|
m_profiles.removeAt(i);
|
2016-06-14 17:46:18 +00:00
|
|
|
}
|
2016-02-25 20:19:27 +00:00
|
|
|
|
2016-06-14 17:46:18 +00:00
|
|
|
void CConfigFile::removeProfile(const QString &id)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < m_profiles.size(); ++i)
|
|
|
|
{
|
|
|
|
if (m_profiles[i].id == id) removeProfile(i);
|
|
|
|
}
|
2016-02-25 20:19:27 +00:00
|
|
|
}
|
|
|
|
|
2016-06-19 19:04:00 +00:00
|
|
|
QString CConfigFile::getDesktopDirectory() const
|
|
|
|
{
|
|
|
|
return QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString CConfigFile::getMenuDirectory() const
|
|
|
|
{
|
|
|
|
return QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation) + "/" + QApplication::applicationName();
|
|
|
|
}
|
|
|
|
|
2016-02-25 20:19:27 +00:00
|
|
|
bool CConfigFile::has64bitsOS()
|
|
|
|
{
|
2016-07-26 16:23:03 +00:00
|
|
|
#ifdef Q_OS_WIN32
|
|
|
|
// 64 bits only supported under Vista and up
|
|
|
|
if (QSysInfo::windowsVersion() < QSysInfo::WV_VISTA) return false;
|
|
|
|
#endif
|
|
|
|
|
2016-02-25 20:19:27 +00:00
|
|
|
return QSysInfo::currentCpuArchitecture() == "x86_64";
|
|
|
|
}
|
|
|
|
|
2016-05-16 09:12:30 +00:00
|
|
|
int CConfigFile::getDefaultServerIndex() const
|
2016-02-25 20:19:27 +00:00
|
|
|
{
|
2016-05-16 09:12:30 +00:00
|
|
|
return m_defaultServerIndex;
|
2016-02-25 20:19:27 +00:00
|
|
|
}
|
|
|
|
|
2016-05-16 09:12:30 +00:00
|
|
|
void CConfigFile::setDefaultServerIndex(int index)
|
2016-02-25 20:19:27 +00:00
|
|
|
{
|
2016-05-16 09:12:30 +00:00
|
|
|
m_defaultServerIndex = index;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CConfigFile::getDefaultProfileIndex() const
|
|
|
|
{
|
|
|
|
return m_defaultProfileIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CConfigFile::setDefaultProfileIndex(int index)
|
|
|
|
{
|
|
|
|
m_defaultProfileIndex = index;
|
2016-02-25 20:19:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CConfigFile::isRyzomInstallerConfigured() const
|
|
|
|
{
|
2016-02-27 17:43:14 +00:00
|
|
|
return m_profiles.size() > 0;
|
2016-02-25 20:19:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString CConfigFile::getInstallationDirectory() const
|
|
|
|
{
|
|
|
|
return m_installationDirectory;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CConfigFile::setInstallationDirectory(const QString &directory)
|
|
|
|
{
|
|
|
|
m_installationDirectory = directory;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString CConfigFile::getSrcServerDirectory() const
|
|
|
|
{
|
|
|
|
return m_srcDirectory;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CConfigFile::setSrcServerDirectory(const QString &directory)
|
|
|
|
{
|
|
|
|
m_srcDirectory = directory;
|
|
|
|
}
|
|
|
|
|
2016-02-27 17:43:14 +00:00
|
|
|
QString CConfigFile::getProfileDirectory() const
|
2016-02-25 20:19:27 +00:00
|
|
|
{
|
|
|
|
return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
|
|
|
}
|
|
|
|
|
2016-02-27 17:43:14 +00:00
|
|
|
QString CConfigFile::getSrcProfileDirectory() const
|
2016-02-25 20:19:27 +00:00
|
|
|
{
|
2016-06-19 19:04:00 +00:00
|
|
|
QString filename = "client.cfg";
|
|
|
|
|
|
|
|
QStringList paths;
|
|
|
|
|
|
|
|
// same path as client
|
|
|
|
paths << getSrcServerDirectory();
|
|
|
|
|
|
|
|
// profile path root
|
|
|
|
paths << getProfileDirectory();
|
|
|
|
|
|
|
|
#if !defined(Q_OS_WIN32) && !defined(Q_OS_MAC)
|
|
|
|
// specific path under Linux
|
|
|
|
paths << QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/.ryzom";
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// search config file in these locations
|
|
|
|
foreach(const QString &path, paths)
|
|
|
|
{
|
|
|
|
if (QFile::exists(path + "/" + filename)) return path;
|
|
|
|
}
|
2016-02-25 20:19:27 +00:00
|
|
|
|
2016-06-19 19:04:00 +00:00
|
|
|
return "";
|
2016-02-25 20:19:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CConfigFile::use64BitsClient() const
|
|
|
|
{
|
|
|
|
return m_use64BitsClient;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CConfigFile::setUse64BitsClient(bool on)
|
|
|
|
{
|
|
|
|
m_use64BitsClient = on;
|
|
|
|
}
|
|
|
|
|
2016-05-29 18:32:33 +00:00
|
|
|
bool CConfigFile::shouldUninstallOldClient() const
|
|
|
|
{
|
|
|
|
return m_shouldUninstallOldClient;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CConfigFile::setShouldUninstallOldClient(bool on)
|
|
|
|
{
|
|
|
|
m_shouldUninstallOldClient = on;
|
|
|
|
}
|
|
|
|
|
2016-05-27 20:20:41 +00:00
|
|
|
QString CConfigFile::expandVariables(const QString &str) const
|
2016-02-25 20:19:27 +00:00
|
|
|
{
|
|
|
|
QString res = str;
|
|
|
|
|
|
|
|
res.replace("$TIMESTAMP", QString::number(QDateTime::currentDateTime().toTime_t()));
|
|
|
|
res.replace("$LANG", m_language);
|
|
|
|
res.replace("$ARCH", getClientArch());
|
2016-07-25 16:32:15 +00:00
|
|
|
res.replace("$PRODUCT_NAME", m_productName);
|
|
|
|
res.replace("$PRODUCT_PUBLISHER", m_productPublisher);
|
|
|
|
res.replace("$PRODUCT_ABOUT_URL", m_productAboutUrl);
|
|
|
|
res.replace("$PRODUCT_HELP_URL", m_productHelpUrl);
|
|
|
|
res.replace("$PRODUCT_COMMENTS", m_productComments);
|
2016-02-25 20:19:27 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString CConfigFile::getClientArch() const
|
|
|
|
{
|
|
|
|
#if defined(Q_OS_WIN)
|
|
|
|
return QString("win%1").arg(m_use64BitsClient ? 64:32);
|
|
|
|
#elif defined(Q_OS_MAC)
|
2016-05-18 07:56:43 +00:00
|
|
|
// only 64 bits clients under OS X, because there not any 32 bits OS X version anymore
|
2016-02-25 20:19:27 +00:00
|
|
|
return "osx";
|
|
|
|
#else
|
|
|
|
return QString("linux%1").arg(m_use64BitsClient ? 64:32);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
QString CConfigFile::getCurrentDirectory()
|
|
|
|
{
|
|
|
|
return QDir::current().absolutePath();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString CConfigFile::getParentDirectory()
|
|
|
|
{
|
|
|
|
QDir current = QDir::current();
|
|
|
|
current.cdUp();
|
|
|
|
return current.absolutePath();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString CConfigFile::getApplicationDirectory()
|
|
|
|
{
|
|
|
|
return QApplication::applicationDirPath();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString CConfigFile::getOldInstallationDirectory()
|
|
|
|
{
|
|
|
|
// HKEY_CURRENT_USER/SOFTWARE/Nevrax/RyzomInstall/InstallId=1917716796 (string)
|
|
|
|
#if defined(Q_OS_WIN)
|
|
|
|
// NSIS previous 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
|
|
|
|
|
|
|
|
if (settings.contains("Ryzom Install Path"))
|
|
|
|
{
|
|
|
|
return QDir::fromNativeSeparators(settings.value("Ryzom Install Path").toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
// check default directory if registry key not found
|
|
|
|
return CConfigFile::has64bitsOS() ? "C:/Program Files (x86)/Ryzom":"C:/Program Files/Ryzom";
|
|
|
|
#elif defined(Q_OS_MAC)
|
|
|
|
return "/Applications/Ryzom.app";
|
|
|
|
#else
|
|
|
|
return QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/.ryzom";
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-05-25 21:28:05 +00:00
|
|
|
QString CConfigFile::getOldInstallationLanguage()
|
|
|
|
{
|
|
|
|
#if defined(Q_OS_WIN)
|
|
|
|
// NSIS previous 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
|
|
|
|
|
|
|
|
if (settings.contains("Language"))
|
|
|
|
{
|
|
|
|
QString languageCode = settings.value("Language").toString();
|
|
|
|
|
2016-05-26 17:32:21 +00:00
|
|
|
// 1036 = French (France), 1033 = English (USA), 1031 = German
|
|
|
|
if (languageCode == "1036") return "fr";
|
|
|
|
if (languageCode == "1031") return "de";
|
|
|
|
if (languageCode == "1033") return "en";
|
|
|
|
}
|
2016-05-25 21:28:05 +00:00
|
|
|
#endif
|
2016-05-26 17:32:21 +00:00
|
|
|
|
|
|
|
return "";
|
2016-05-25 21:28:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString CConfigFile::getNewInstallationLanguage()
|
|
|
|
{
|
|
|
|
#if defined(Q_OS_WIN)
|
2016-05-26 17:32:21 +00:00
|
|
|
// NSIS new official installer
|
2016-05-25 21:28:05 +00:00
|
|
|
#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
|
|
|
|
|
|
|
|
if (settings.contains("Ryzom Install Path"))
|
|
|
|
{
|
|
|
|
return QDir::fromNativeSeparators(settings.value("Ryzom Install Path").toString());
|
|
|
|
}
|
|
|
|
#endif
|
2016-05-26 17:32:21 +00:00
|
|
|
|
|
|
|
return "";
|
2016-05-25 21:28:05 +00:00
|
|
|
}
|
|
|
|
|
2016-02-25 20:19:27 +00:00
|
|
|
QString CConfigFile::getNewInstallationDirectory()
|
|
|
|
{
|
|
|
|
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CConfigFile::isRyzomInstalledIn(const QString &directory) const
|
|
|
|
{
|
|
|
|
// check client and data
|
|
|
|
return isRyzomClientInstalledIn(directory) && areRyzomDataInstalledIn(directory);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CConfigFile::areRyzomDataInstalledIn(const QString &directory) const
|
|
|
|
{
|
2016-06-12 12:18:36 +00:00
|
|
|
if (directory.isEmpty()) return false;
|
|
|
|
|
2016-02-25 20:19:27 +00:00
|
|
|
QDir dir(directory);
|
|
|
|
|
|
|
|
// directory doesn't exist
|
|
|
|
if (!dir.exists()) return false;
|
|
|
|
|
2016-05-16 14:30:46 +00:00
|
|
|
if (!dir.cd("data") || !dir.exists()) return false;
|
2016-02-25 20:19:27 +00:00
|
|
|
|
|
|
|
// at least 200 BNP in data directory
|
|
|
|
if (dir.entryList(QStringList() << "*.bnp", QDir::Files).size() < 200) return false;
|
|
|
|
|
2016-05-25 21:28:42 +00:00
|
|
|
// ryzom.ttf or fonts.bnp is required
|
|
|
|
if (!dir.exists("fonts/ryzom.ttf") && !dir.exists("fonts.bnp")) return false;
|
2016-05-16 14:30:46 +00:00
|
|
|
|
|
|
|
// gamedev.bnp is required
|
|
|
|
if (!dir.exists("gamedev.bnp")) return false;
|
|
|
|
|
|
|
|
// interfaces.bnp is required
|
|
|
|
if (!dir.exists("interfaces.bnp")) return false;
|
|
|
|
|
2016-02-25 20:19:27 +00:00
|
|
|
// TODO: more checks
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CConfigFile::isRyzomClientInstalledIn(const QString &directory) const
|
|
|
|
{
|
2016-06-12 12:18:36 +00:00
|
|
|
if (directory.isEmpty()) return false;
|
|
|
|
|
2016-02-25 20:19:27 +00:00
|
|
|
QDir dir(directory);
|
|
|
|
|
|
|
|
// directory doesn't exist
|
|
|
|
if (!dir.exists()) return false;
|
|
|
|
|
2016-05-25 21:28:42 +00:00
|
|
|
// current server
|
|
|
|
CServer server = getServer();
|
2016-05-14 16:50:27 +00:00
|
|
|
|
2016-05-25 21:28:42 +00:00
|
|
|
QString clientFilename = server.clientFilename;
|
|
|
|
|
|
|
|
// check if new client is defined and exists
|
|
|
|
if (!clientFilename.isEmpty() && !dir.exists(clientFilename))
|
|
|
|
{
|
|
|
|
clientFilename = server.clientFilenameOld;
|
|
|
|
|
|
|
|
// check if old client is defined and exists
|
|
|
|
if (!dir.exists(clientFilename)) return false;
|
2016-07-25 16:38:25 +00:00
|
|
|
|
|
|
|
// client 2.1-
|
2016-05-25 21:28:42 +00:00
|
|
|
}
|
2016-07-25 16:38:25 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// client 3.0+
|
2016-02-25 20:19:27 +00:00
|
|
|
|
2016-07-25 16:38:25 +00:00
|
|
|
// client_default.cfg doesn't exist
|
|
|
|
if (!dir.exists("client_default.cfg")) return false;
|
|
|
|
|
|
|
|
// TODO: more checks
|
|
|
|
}
|
2016-02-25 20:19:27 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-05-14 16:50:27 +00:00
|
|
|
bool CConfigFile::foundTemporaryFiles(const QString &directory) const
|
|
|
|
{
|
2016-06-12 12:18:36 +00:00
|
|
|
if (directory.isEmpty()) return false;
|
|
|
|
|
2016-05-14 16:50:27 +00:00
|
|
|
QDir dir(directory);
|
|
|
|
|
|
|
|
// directory doesn't exist
|
|
|
|
if (!dir.exists()) return false;
|
|
|
|
|
|
|
|
if (!dir.cd("data") && dir.exists()) return false;
|
|
|
|
|
2016-06-19 19:04:31 +00:00
|
|
|
QStringList filter;
|
|
|
|
filter << "*.string_cache";
|
|
|
|
|
|
|
|
if (dir.exists("packed_sheets.bnp"))
|
|
|
|
{
|
|
|
|
filter << "*.packed_sheets";
|
|
|
|
filter << "*.packed";
|
|
|
|
filter << "*.pem";
|
|
|
|
}
|
|
|
|
|
2016-05-14 16:50:27 +00:00
|
|
|
// temporary files
|
2016-06-19 19:04:31 +00:00
|
|
|
if (!dir.entryList(filter, QDir::Files).isEmpty()) return true;
|
2016-05-14 16:50:27 +00:00
|
|
|
|
|
|
|
// fonts directory is not needed anymore
|
2016-06-19 19:04:31 +00:00
|
|
|
if (dir.exists("fonts.bnp") && dir.cd("fonts") && dir.exists()) return true;
|
2016-05-14 16:50:27 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CConfigFile::shouldCreateDesktopShortcut() const
|
|
|
|
{
|
|
|
|
const CProfile &profile = getProfile();
|
|
|
|
|
2016-06-19 19:04:00 +00:00
|
|
|
if (!profile.desktopShortcut) return false;
|
|
|
|
|
2016-07-25 16:31:11 +00:00
|
|
|
QString shortcut = profile.getClientDesktopShortcutFullPath();
|
|
|
|
|
|
|
|
return !shortcut.isEmpty() && !NLMISC::CFile::isExists(qToUtf8(shortcut));
|
2016-06-18 20:40:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CConfigFile::shouldCreateMenuShortcut() const
|
|
|
|
{
|
|
|
|
const CProfile &profile = getProfile();
|
|
|
|
|
2016-06-19 19:04:00 +00:00
|
|
|
if (!profile.menuShortcut) return false;
|
|
|
|
|
2016-07-25 16:31:11 +00:00
|
|
|
QString shortcut = profile.getClientMenuShortcutFullPath();
|
|
|
|
|
|
|
|
return !shortcut.isEmpty() && !NLMISC::CFile::isExists(qToUtf8(shortcut));
|
2016-05-14 16:50:27 +00:00
|
|
|
}
|
|
|
|
|
2016-06-19 19:04:00 +00:00
|
|
|
QString CConfigFile::getInstallerFullPath() const
|
2016-02-25 20:19:27 +00:00
|
|
|
{
|
2016-06-19 19:04:00 +00:00
|
|
|
return QApplication::applicationFilePath();
|
2016-06-11 15:02:44 +00:00
|
|
|
}
|
|
|
|
|
2016-06-19 19:04:00 +00:00
|
|
|
QString CConfigFile::getInstallerMenuLinkFullPath() const
|
2016-06-11 15:02:44 +00:00
|
|
|
{
|
2016-06-19 19:04:00 +00:00
|
|
|
#ifdef Q_OS_WIN32
|
|
|
|
return QString("%1/%2/%2 Installer.lnk").arg(QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation)).arg(QApplication::applicationName());
|
|
|
|
#else
|
|
|
|
return "";
|
|
|
|
#endif
|
2016-02-25 20:19:27 +00:00
|
|
|
}
|
|
|
|
|
2016-07-27 09:54:35 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-02-25 20:19:27 +00:00
|
|
|
QString CConfigFile::getSrcServerClientBNPFullPath() const
|
|
|
|
{
|
|
|
|
return QString("%1/unpack/exedll_%2.bnp").arg(getSrcServerDirectory()).arg(getClientArch());
|
|
|
|
}
|
|
|
|
|
2016-06-14 17:39:39 +00:00
|
|
|
OperationStep CConfigFile::getInstallNextStep() const
|
2016-02-25 20:19:27 +00:00
|
|
|
{
|
2016-02-27 17:43:14 +00:00
|
|
|
// get last used profile
|
|
|
|
const CProfile &profile = getProfile();
|
2016-02-25 20:19:27 +00:00
|
|
|
|
|
|
|
// get server used by it or default server
|
2016-02-27 17:43:14 +00:00
|
|
|
CServer server = getServer(profile.server);
|
2016-02-25 20:19:27 +00:00
|
|
|
|
2016-02-27 17:43:14 +00:00
|
|
|
// no or wrong profile
|
2016-02-25 20:19:27 +00:00
|
|
|
if (server.id.isEmpty())
|
|
|
|
{
|
|
|
|
// get last used server
|
|
|
|
server = getServer();
|
|
|
|
}
|
|
|
|
|
|
|
|
// no or wrong server
|
|
|
|
if (server.id.isEmpty())
|
|
|
|
{
|
|
|
|
// get first server
|
|
|
|
server = getServer(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// no server defined, shouldn't happen
|
|
|
|
if (server.id.isEmpty())
|
|
|
|
{
|
|
|
|
return DisplayNoServerError;
|
|
|
|
}
|
|
|
|
|
|
|
|
// only show wizard if installation directory undefined
|
|
|
|
if (getInstallationDirectory().isEmpty())
|
|
|
|
{
|
2016-05-25 21:23:48 +00:00
|
|
|
// if launched from current directory, it means we just patched files
|
|
|
|
QString currentDirectory = getCurrentDirectory();
|
|
|
|
|
|
|
|
if (!isRyzomInstalledIn(currentDirectory))
|
|
|
|
{
|
|
|
|
// Ryzom is in the same directory as Ryzom Installer
|
|
|
|
currentDirectory = getApplicationDirectory();
|
|
|
|
|
|
|
|
if (!isRyzomInstalledIn(currentDirectory))
|
|
|
|
{
|
|
|
|
currentDirectory.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// install or migrate depending if Ryzom was found in current directory
|
|
|
|
return currentDirectory.isEmpty() ? ShowInstallWizard:ShowMigrateWizard;
|
2016-02-25 20:19:27 +00:00
|
|
|
}
|
|
|
|
|
2016-06-14 17:45:29 +00:00
|
|
|
QString serverDirectory = server.getDirectory();
|
2016-02-25 20:19:27 +00:00
|
|
|
|
|
|
|
if (getSrcServerDirectory().isEmpty())
|
|
|
|
{
|
|
|
|
// user decided to download files
|
|
|
|
|
|
|
|
// downloaded files are kept in server directory
|
|
|
|
QString dataFile = getInstallationDirectory() + "/" + server.dataDownloadFilename;
|
2016-06-18 17:50:26 +00:00
|
|
|
QString clientFile = getInstallationDirectory() + "/" + expandVariables(server.clientDownloadFilename);
|
2016-02-25 20:19:27 +00:00
|
|
|
|
|
|
|
// data are not copied
|
|
|
|
if (!areRyzomDataInstalledIn(serverDirectory))
|
|
|
|
{
|
|
|
|
// when file is not finished, it has .part extension
|
|
|
|
if (!QFile::exists(dataFile))
|
|
|
|
{
|
|
|
|
return DownloadData;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ExtractDownloadedData;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isRyzomClientInstalledIn(serverDirectory))
|
|
|
|
{
|
|
|
|
// when file is not finished, it has .part extension
|
|
|
|
if (!QFile::exists(clientFile))
|
|
|
|
{
|
|
|
|
return DownloadClient;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ExtractDownloadedClient;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// user decided to copy files
|
|
|
|
|
|
|
|
// data are not copied
|
|
|
|
if (!areRyzomDataInstalledIn(serverDirectory))
|
|
|
|
{
|
2016-05-16 14:30:46 +00:00
|
|
|
// selected directory contains Ryzom files (shouldn't fail)
|
|
|
|
if (areRyzomDataInstalledIn(getSrcServerDirectory()))
|
|
|
|
{
|
2016-06-14 17:39:39 +00:00
|
|
|
return CopyDataFiles;
|
2016-05-16 14:30:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-05-25 21:23:48 +00:00
|
|
|
return ShowInstallWizard;
|
2016-05-16 14:30:46 +00:00
|
|
|
}
|
2016-02-25 20:19:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// client is not extracted from BNP
|
|
|
|
if (!isRyzomClientInstalledIn(serverDirectory))
|
|
|
|
{
|
2016-05-14 16:50:27 +00:00
|
|
|
if (foundTemporaryFiles(serverDirectory))
|
|
|
|
{
|
|
|
|
return CleanFiles;
|
|
|
|
}
|
|
|
|
|
2016-02-25 20:19:27 +00:00
|
|
|
if (QFile::exists(getSrcServerClientBNPFullPath()))
|
|
|
|
{
|
|
|
|
return ExtractBnpClient;
|
|
|
|
}
|
|
|
|
|
2016-06-18 17:50:26 +00:00
|
|
|
QString clientFile = getInstallationDirectory() + "/" + expandVariables(server.clientDownloadFilename);
|
2016-02-25 20:19:27 +00:00
|
|
|
|
2016-05-26 17:32:59 +00:00
|
|
|
// when file is not finished, it has .part extension
|
|
|
|
if (!QFile::exists(clientFile))
|
|
|
|
{
|
|
|
|
return DownloadClient;
|
2016-02-25 20:19:27 +00:00
|
|
|
}
|
2016-05-26 17:32:59 +00:00
|
|
|
|
|
|
|
return ExtractDownloadedClient;
|
2016-02-25 20:19:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-26 17:30:18 +00:00
|
|
|
// if installer not found in installation directory, extract it from BNP
|
|
|
|
if (!QFile::exists(getInstallationDirectory() + "/" + server.installerFilename))
|
|
|
|
{
|
|
|
|
return CopyInstaller;
|
|
|
|
}
|
|
|
|
|
2016-02-27 17:43:14 +00:00
|
|
|
// no default profile
|
2016-05-16 12:45:43 +00:00
|
|
|
if (profile.id.isEmpty())
|
2016-02-25 20:19:27 +00:00
|
|
|
{
|
2016-02-27 17:43:14 +00:00
|
|
|
return CreateProfile;
|
2016-02-25 20:19:27 +00:00
|
|
|
}
|
|
|
|
|
2016-05-14 16:53:35 +00:00
|
|
|
QString clientCfg = QString("%1/%2/client.cfg").arg(getProfileDirectory()).arg(profile.id);
|
|
|
|
|
2016-02-27 17:43:14 +00:00
|
|
|
// migration profile
|
2016-05-14 16:53:35 +00:00
|
|
|
if (!getSrcServerDirectory().isEmpty() && QFile::exists(getSrcProfileDirectory() + "/client.cfg") && !QFile::exists(clientCfg))
|
2016-02-25 20:19:27 +00:00
|
|
|
{
|
2016-02-27 17:43:14 +00:00
|
|
|
return CopyProfileFiles;
|
2016-02-25 20:19:27 +00:00
|
|
|
}
|
|
|
|
|
2016-07-25 16:31:11 +00:00
|
|
|
if (shouldCreateDesktopShortcut() || shouldCreateMenuShortcut())
|
2016-06-18 20:40:02 +00:00
|
|
|
{
|
2016-07-25 16:31:11 +00:00
|
|
|
return CreateProfileShortcuts;
|
2016-02-25 20:19:27 +00:00
|
|
|
}
|
|
|
|
|
2016-05-26 17:34:15 +00:00
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
// check that Add/Remove entry is created under Windows
|
|
|
|
QSettings settings("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Ryzom", QSettings::NativeFormat);
|
|
|
|
|
|
|
|
if (!settings.contains("InstallLocation")) return CreateAddRemoveEntry;
|
|
|
|
#endif
|
|
|
|
|
2016-06-26 17:42:35 +00:00
|
|
|
if (m_shouldUninstallOldClient && !getSrcServerDirectory().isEmpty() && QFile::exists(getSrcServerDirectory() + "/Uninstall.exe"))
|
|
|
|
{
|
|
|
|
return UninstallOldClient;
|
|
|
|
}
|
|
|
|
|
2016-02-25 20:19:27 +00:00
|
|
|
return Done;
|
|
|
|
}
|
2016-05-27 20:20:41 +00:00
|
|
|
|
|
|
|
QString CConfigFile::getProductName() const
|
|
|
|
{
|
|
|
|
return m_productName;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString CConfigFile::getProductPublisher() const
|
|
|
|
{
|
|
|
|
return m_productPublisher;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString CConfigFile::getProductAboutUrl() const
|
|
|
|
{
|
|
|
|
return expandVariables(m_productAboutUrl);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString CConfigFile::getProductUpdateUrl() const
|
|
|
|
{
|
|
|
|
return expandVariables(m_productUpdateUrl);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString CConfigFile::getProductHelpUrl() const
|
|
|
|
{
|
|
|
|
return expandVariables(m_productHelpUrl);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString CConfigFile::getProductComments() const
|
|
|
|
{
|
|
|
|
return m_productComments;
|
|
|
|
}
|