khanat-code-old/code/ryzom/tools/client/ryzom_installer/src/configfile.h

225 lines
5.6 KiB
C
Raw Normal View History

2016-05-14 16:55:54 +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/>.
#ifndef CONFIGFILE_H
#define CONFIGFILE_H
2016-06-14 18:18:10 +00:00
#include "operation.h"
class CServer
2016-05-14 16:55:54 +00:00
{
2016-06-14 18:18:10 +00:00
public:
2016-05-14 16:55:54 +00:00
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;
2016-05-26 17:36:25 +00:00
QString clientFilenameOld;
2016-05-18 07:57:33 +00:00
QString configurationFilename;
2016-05-26 17:36:25 +00:00
QString installerFilename;
2016-05-14 16:55:54 +00:00
QString comments;
2016-06-14 18:18:10 +00:00
// helpers
QString getDirectory() const;
2016-06-19 19:10:23 +00:00
QString getClientFullPath() const;
QString getConfigurationFullPath() const;
2016-05-14 16:55:54 +00:00
};
extern const CServer NoServer;
typedef QVector<CServer> CServers;
2016-06-14 18:18:10 +00:00
class CProfile
2016-05-14 16:55:54 +00:00
{
2016-06-14 18:18:10 +00:00
public:
2016-05-14 16:55:54 +00:00
CProfile()
{
desktopShortcut = false;
menuShortcut = false;
}
2016-05-16 14:31:30 +00:00
QString id;
2016-05-14 16:55:54 +00:00
QString name;
QString server;
QString executable;
QString arguments;
QString comments;
bool desktopShortcut;
bool menuShortcut;
2016-06-14 18:18:10 +00:00
// helpers
QString getDirectory() const;
2016-06-19 19:10:23 +00:00
QString getClientFullPath() const;
2016-07-25 16:58:02 +00:00
QString getClientDesktopShortcutFullPath() const;
QString getClientMenuShortcutFullPath() const;
void createShortcuts() const;
void deleteShortcuts() const;
void updateShortcuts() const;
2016-05-14 16:55:54 +00:00
};
extern const CProfile NoProfile;
typedef QVector<CProfile> CProfiles;
/**
* Config file management and other stuff related to location of files/directories.
*
* \author Cedric 'Kervala' OCHS
* \date 2016
*/
class CConfigFile : public QObject
{
Q_OBJECT
public:
CConfigFile(QObject *parent = NULL);
virtual ~CConfigFile();
bool load();
bool load(const QString &filename);
bool save() const;
static CConfigFile* getInstance();
CServers getServers() const { return m_servers; }
void setServers(const CServers &servers) { m_servers = servers; }
int getServersCount() const;
const CServer& getServer(int i = -1) const;
const CServer& getServer(const QString &id) const;
CProfiles getProfiles() const { return m_profiles; }
void setProfiles(const CProfiles &profiles) { m_profiles = profiles; }
2016-06-12 13:44:48 +00:00
CProfiles getBackupProfiles() const { return m_backupProfiles; }
void backupProfiles();
2016-05-14 16:55:54 +00:00
int getProfilesCount() const;
CProfile getProfile(int i = -1) const;
2016-06-14 18:18:10 +00:00
CProfile getProfile(const QString &id) const;
2016-05-14 16:55:54 +00:00
void setProfile(int i, const CProfile &profile);
int addProfile(const CProfile &profile);
void removeProfile(int i);
2016-06-14 18:18:10 +00:00
void removeProfile(const QString &id);
2016-05-14 16:55:54 +00:00
2016-05-16 09:13:45 +00:00
int getDefaultServerIndex() const;
void setDefaultServerIndex(int index);
int getDefaultProfileIndex() const;
void setDefaultProfileIndex(int index);
2016-05-14 16:55:54 +00:00
bool isRyzomInstallerConfigured() const;
QString getInstallationDirectory() const;
void setInstallationDirectory(const QString &directory);
QString getSrcServerDirectory() const;
void setSrcServerDirectory(const QString &directory);
QString getProfileDirectory() const;
QString getSrcProfileDirectory() const;
2016-06-19 19:10:23 +00:00
QString getDesktopDirectory() const;
QString getMenuDirectory() const;
2016-05-14 16:55:54 +00:00
static bool has64bitsOS();
// default directories
static QString getCurrentDirectory();
static QString getParentDirectory();
static QString getApplicationDirectory();
static QString getOldInstallationDirectory();
static QString getNewInstallationDirectory();
2016-05-26 17:36:25 +00:00
static QString getOldInstallationLanguage();
static QString getNewInstallationLanguage();
2016-05-14 16:55:54 +00:00
2016-05-26 17:36:25 +00:00
// status of installation
2016-05-14 16:55:54 +00:00
bool isRyzomInstalledIn(const QString &directory) const;
bool areRyzomDataInstalledIn(const QString &directory) const;
bool isRyzomClientInstalledIn(const QString &directory) const;
2016-05-26 17:36:25 +00:00
2016-05-14 16:55:54 +00:00
bool foundTemporaryFiles(const QString &directory) const;
bool shouldCreateDesktopShortcut() const;
2016-06-18 20:41:12 +00:00
bool shouldCreateMenuShortcut() const;
2016-05-14 16:55:54 +00:00
// installation choices
bool use64BitsClient() const;
void setUse64BitsClient(bool on);
2016-05-29 18:38:55 +00:00
bool shouldUninstallOldClient() const;
void setShouldUninstallOldClient(bool on);
2016-05-27 20:24:20 +00:00
QString expandVariables(const QString &str) const;
2016-05-14 16:55:54 +00:00
QString getClientArch() const;
2016-06-19 19:10:23 +00:00
QString getInstallerFullPath() const;
QString getInstallerMenuLinkFullPath() const;
2016-05-14 16:55:54 +00:00
QString getSrcServerClientBNPFullPath() const;
2016-06-14 18:18:10 +00:00
OperationStep getInstallNextStep() const;
2016-05-14 16:55:54 +00:00
2016-05-27 20:24:20 +00:00
// product details
QString getProductName() const;
QString getProductPublisher() const;
QString getProductAboutUrl() const;
QString getProductUpdateUrl() const;
QString getProductHelpUrl() const;
QString getProductComments() const;
2016-05-14 16:55:54 +00:00
private:
2016-05-16 09:13:45 +00:00
int m_defaultServerIndex;
int m_defaultProfileIndex;
2016-05-14 16:55:54 +00:00
CServers m_servers;
CProfiles m_profiles;
2016-06-12 13:44:48 +00:00
CProfiles m_backupProfiles;
2016-05-14 16:55:54 +00:00
QString m_installationDirectory;
QString m_srcDirectory;
bool m_use64BitsClient;
2016-05-29 18:38:55 +00:00
bool m_shouldUninstallOldClient;
2016-05-14 16:55:54 +00:00
QString m_language;
QString m_defaultConfigPath;
QString m_configPath;
2016-05-27 20:24:20 +00:00
// product
QString m_productName;
QString m_productPublisher;
QString m_productAboutUrl;
QString m_productUpdateUrl;
QString m_productHelpUrl;
QString m_productComments;
2016-05-14 16:55:54 +00:00
static CConfigFile *s_instance;
};
#endif