1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "configfile.h"
25 const CServer NoServer
;
27 void CServer::loadFromSettings(const QSettings
&settings
)
29 id
= settings
.value("id").toString();
30 name
= settings
.value("name").toString();
31 displayUrl
= settings
.value("display_url").toString();
32 filesListUrl
= settings
.value("files_list_url").toString();
33 dataDownloadUrl
= settings
.value("data_download_url").toString();
34 dataDownloadFilename
= settings
.value("data_download_filename").toString();
35 dataCompressedSize
= settings
.value("data_compressed_size").toULongLong();
36 dataUncompressedSize
= settings
.value("data_uncompressed_size").toULongLong();
37 clientDownloadUrl
= settings
.value("client_download_url").toString();
38 clientDownloadFilename
= settings
.value("client_download_filename").toString();
40 clientFilename
= settings
.value("client_filename_windows").toString();
41 clientFilenameOld
= settings
.value("client_filename_old_windows").toString();
42 configurationFilename
= settings
.value("configuration_filename_windows").toString();
43 #elif defined(Q_OS_MAC)
44 clientFilename
= settings
.value("client_filename_osx").toString();
45 clientFilenameOld
= settings
.value("client_filename_old_osx").toString();
46 configurationFilename
= settings
.value("configuration_filename_osx").toString();
48 clientFilename
= settings
.value("client_filename_linux").toString();
49 clientFilenameOld
= settings
.value("client_filename_old_linux").toString();
50 configurationFilename
= settings
.value("configuration_filename_linux").toString();
52 comments
= settings
.value("comments").toString();
55 void CServer::loadFromServers(const CServers
&servers
)
57 foreach(const CServer
&server
, servers
)
61 // found the same server
62 loadFromServer(server
);
68 void CServer::loadFromServer(const CServer
&server
)
73 displayUrl
= server
.displayUrl
;
74 filesListUrl
= server
.filesListUrl
;
75 dataDownloadUrl
= server
.dataDownloadUrl
;
76 dataDownloadFilename
= server
.dataDownloadFilename
;
77 dataCompressedSize
= server
.dataCompressedSize
;
78 dataUncompressedSize
= server
.dataUncompressedSize
;
79 clientDownloadUrl
= server
.clientDownloadUrl
;
80 clientDownloadFilename
= server
.clientDownloadFilename
;
81 clientFilename
= server
.clientFilename
;
82 clientFilenameOld
= server
.clientFilenameOld
;
83 configurationFilename
= server
.configurationFilename
;
84 comments
= server
.comments
;
87 void CServer::saveToSettings(QSettings
&settings
) const
89 settings
.setValue("id", id
);
90 settings
.setValue("name", name
);
91 settings
.setValue("display_url", displayUrl
);
92 settings
.setValue("files_list_url", filesListUrl
);
93 settings
.setValue("data_download_url", dataDownloadUrl
);
94 settings
.setValue("data_download_filename", dataDownloadFilename
);
95 settings
.setValue("data_compressed_size", dataCompressedSize
);
96 settings
.setValue("data_uncompressed_size", dataUncompressedSize
);
97 settings
.setValue("client_download_url", clientDownloadUrl
);
98 settings
.setValue("client_download_filename", clientDownloadFilename
);
100 settings
.setValue("client_filename_windows", clientFilename
);
101 settings
.setValue("client_filename_old_windows", clientFilenameOld
);
102 settings
.setValue("configuration_filename_windows", configurationFilename
);
103 #elif defined(Q_OS_MAC)
104 settings
.setValue("client_filename_osx", clientFilename
);
105 settings
.setValue("client_filename_old_osx", clientFilenameOld
);
106 settings
.setValue("configuration_filename_osx", configurationFilename
);
108 settings
.setValue("client_filename_linux", clientFilename
);
109 settings
.setValue("client_filename_old_linux", clientFilenameOld
);
110 settings
.setValue("configuration_filename_linux", configurationFilename
);
112 settings
.setValue("comments", comments
);
115 QString
CServer::getDirectory() const
117 return CConfigFile::getInstance()->getInstallationDirectory() + "/" + id
;
120 QString
CServer::getClientFullPath() const
122 if (clientFilename
.isEmpty()) return "";
124 return getDirectory() + "/" + clientFilename
;
127 QString
CServer::getConfigurationFullPath() const
129 if (configurationFilename
.isEmpty()) return "";
131 return getDirectory() + "/" + configurationFilename
;
134 QString
CServer::getDefaultClientConfigFullPath() const
136 return getDirectory() + "/client_default.cfg";