mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-29 03:40:55 +00:00
Added: CProfile and CServer classes have their own sources, see #279
This commit is contained in:
parent
0fc7d54c8c
commit
43e8593735
6 changed files with 277 additions and 183 deletions
|
@ -24,122 +24,6 @@
|
||||||
#define new DEBUG_NEW
|
#define new DEBUG_NEW
|
||||||
#endif
|
#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::s_instance = NULL;
|
||||||
|
|
||||||
CConfigFile::CConfigFile(QObject *parent):QObject(parent), m_version(-1),
|
CConfigFile::CConfigFile(QObject *parent):QObject(parent), m_version(-1),
|
||||||
|
|
|
@ -18,73 +18,8 @@
|
||||||
#define CONFIGFILE_H
|
#define CONFIGFILE_H
|
||||||
|
|
||||||
#include "operation.h"
|
#include "operation.h"
|
||||||
|
#include "server.h"
|
||||||
class CServer
|
#include "profile.h"
|
||||||
{
|
|
||||||
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<CServer> 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<CProfile> CProfiles;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Config file management and other stuff related to location of files/directories.
|
* Config file management and other stuff related to location of files/directories.
|
||||||
|
|
120
code/ryzom/tools/client/ryzom_installer/src/profile.cpp
Normal file
120
code/ryzom/tools/client/ryzom_installer/src/profile.cpp
Normal file
|
@ -0,0 +1,120 @@
|
||||||
|
// 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 "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();
|
||||||
|
}
|
55
code/ryzom/tools/client/ryzom_installer/src/profile.h
Normal file
55
code/ryzom/tools/client/ryzom_installer/src/profile.h
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
// 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 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<CProfile> CProfiles;
|
||||||
|
|
||||||
|
#endif
|
44
code/ryzom/tools/client/ryzom_installer/src/server.cpp
Normal file
44
code/ryzom/tools/client/ryzom_installer/src/server.cpp
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
// 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 "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;
|
||||||
|
}
|
56
code/ryzom/tools/client/ryzom_installer/src/server.h
Normal file
56
code/ryzom/tools/client/ryzom_installer/src/server.h
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
// 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 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<CServer> CServers;
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in a new issue