summaryrefslogtreecommitdiff
path: root/src/gui/windows/serverdialog.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-04-13 15:46:41 +0300
committerAndrei Karas <akaras@inbox.ru>2016-04-14 00:46:22 +0300
commit93feb7fbf408ccc9178832d5f21c3806cb2a9f16 (patch)
treeb0ee8c847e5933a86ea53dea5a3f87b8c6533191 /src/gui/windows/serverdialog.cpp
parent99ecd9ba734a308ae374d4494856d8bb3617f8a0 (diff)
downloadplus-93feb7fbf408ccc9178832d5f21c3806cb2a9f16.tar.gz
plus-93feb7fbf408ccc9178832d5f21c3806cb2a9f16.tar.bz2
plus-93feb7fbf408ccc9178832d5f21c3806cb2a9f16.tar.xz
plus-93feb7fbf408ccc9178832d5f21c3806cb2a9f16.zip
Add support for different groups of update servers reading from servers list.
Diffstat (limited to 'src/gui/windows/serverdialog.cpp')
-rw-r--r--src/gui/windows/serverdialog.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp
index dac370887..04663de71 100644
--- a/src/gui/windows/serverdialog.cpp
+++ b/src/gui/windows/serverdialog.cpp
@@ -44,6 +44,7 @@
#include "utils/delete2.h"
#include "utils/gettext.h"
#include "utils/langs.h"
+#include "utils/paths.h"
#include "debug.h"
@@ -237,6 +238,7 @@ void ServerDialog::connectToSelectedServer()
mServerInfo->persistentIp = server.persistentIp;
mServerInfo->updateMirrors = server.updateMirrors;
mServerInfo->packetVersion = server.packetVersion;
+ mServerInfo->updateHosts = server.updateHosts;
settings.persistentIp = mServerInfo->persistentIp;
settings.supportUrl = mServerInfo->supportUrl;
@@ -447,6 +449,33 @@ void ServerDialog::downloadServerList()
config.setValue("serverslistupdate", getDateString());
}
+static void loadHostsGroup(const XmlNodePtr node,
+ ServerInfo &server)
+{
+ HostsGroup group;
+ group.name = XML::getProperty(node,
+ "name",
+ // TRANSLATORS: unknown hosts group name
+ _("Unknown"));
+ for_each_xml_child_node(hostNode, node)
+ {
+ if (!xmlNameEqual(hostNode, "host"))
+ continue;
+ const std::string host = XmlChildContent(hostNode);
+ if (host.empty())
+ continue;
+ if (!checkPath(host))
+ {
+ logger->log1("Warning: incorrect update server name");
+ continue;
+ }
+
+ group.hosts.push_back(host);
+ }
+ if (!group.hosts.empty())
+ server.updateHosts.push_back(group);
+}
+
void ServerDialog::loadServers(const bool addNew)
{
XML::Document doc(std::string(mDir).append("/").append(
@@ -563,6 +592,10 @@ void ServerDialog::loadServers(const bool addNew)
{
server.updateMirrors.push_back(XmlChildContent(subNode));
}
+ else if (xmlNameEqual(subNode, "updates"))
+ {
+ loadHostsGroup(subNode, server);
+ }
}
server.version.first = font->getWidth(version);
@@ -587,6 +620,7 @@ void ServerDialog::loadServers(const bool addNew)
mServers[i].althostname = server.althostname;
mServers[i].persistentIp = server.persistentIp;
mServers[i].updateMirrors = server.updateMirrors;
+ mServers[i].updateHosts = server.updateHosts;
mServers[i].packetVersion = server.packetVersion;
mServersListModel->setVersionString(i, version);
found = true;