summaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
authorChristian Klinger2016-05-09 17:53:24 +0200
committerChristian Klinger2016-05-09 17:53:24 +0200
commita005cef7f69cfeca6e5c083ea8b7ebc45fe5207c (patch)
treeb30f4383684b87c41a91088c49f0732364d2f48d /src/client
parentadded "Disconnect"-Button (closes #2764). (diff)
downloadpvs2-a005cef7f69cfeca6e5c083ea8b7ebc45fe5207c.tar.gz
pvs2-a005cef7f69cfeca6e5c083ea8b7ebc45fe5207c.tar.xz
pvs2-a005cef7f69cfeca6e5c083ea8b7ebc45fe5207c.zip
Priorities for rooms.
Diffstat (limited to 'src/client')
-rw-r--r--src/client/toolbar/toolbar.cpp30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/client/toolbar/toolbar.cpp b/src/client/toolbar/toolbar.cpp
index 64fc5dc..73a7588 100644
--- a/src/client/toolbar/toolbar.cpp
+++ b/src/client/toolbar/toolbar.cpp
@@ -189,8 +189,11 @@ void Toolbar::enterEvent(QEvent* e)
QWidget::enterEvent(e);
}
+/** Identifies the responsible manager for this client by searching through the
+ * configuration file. The manager whose room has the highest priority is chosen. */
QString Toolbar::identifyMgrIP()
{
+ qDebug() << "identify mgr ip";
SYSTEM_SETTINGS(conf);
if (!conf.contains("rooms")) {
@@ -201,40 +204,41 @@ QString Toolbar::identifyMgrIP()
QStringList rooms = conf.value("rooms").toStringList();
// qDebug() << rooms;
- for (auto i : rooms)
- {
- qDebug() << "i: " << i;
+ /* go through all rooms and check if this client is a member of the room. */
+ int last_priority = -1;
+ QString last_mgr_ip = "";
+ for (auto i : rooms) {
conf.beginGroup(i);
if (!conf.contains("mgrIP")) {
qDebug() << "Invalid config file!";
return "";
}
+ QString mgr_candidate= conf.value("mgrIP").toString();
+ int priority = conf.value("priority").toInt();
- // Find the managerIP of current room.
- QString mgrIP = conf.value("mgrIP").toString();
- foreach (const QHostAddress &address, QNetworkInterface::allAddresses())
- {
+ foreach (const QHostAddress &address, QNetworkInterface::allAddresses()) {
int size = conf.beginReadArray("client");
for (int j = 0; j < size; ++j) {
conf.setArrayIndex(j);
/*
- *
* CFG to test this
* http://git.openslx.org/tm-scripts.git/plain/server/modules/pvs2-freiburg/etc/xdg/openslx/pvs2client.ini
*
*/
QString ip = conf.value("ip").toString();
- if (address != QHostAddress(QHostAddress::LocalHost) && ip == address.toString())
- {
- qDebug("Found this ip in config.");
- return mgrIP;
+ if (address != QHostAddress(QHostAddress::LocalHost)
+ && ip == address.toString() &&
+ priority > last_priority) {
+ last_priority = priority;
+ last_mgr_ip = mgr_candidate;
}
}
conf.endArray();
}
conf.endGroup();
}
- return "";
+ qDebug() << "best mgr ip is " << last_mgr_ip << " with priority = " << last_priority;
+ return last_mgr_ip;
}
/*