summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2016-10-10 20:30:17 +0200
committerSimon Rettberg2016-10-10 20:30:17 +0200
commit1980bbaa03ae7536f5a6a1d3a5397da80c89e355 (patch)
treedaef3b8f661f6d273c6abf641046cb641428e1a2
parent[client] Remove "Room" prefix in connect window dropdown (diff)
downloadpvs2-1980bbaa03ae7536f5a6a1d3a5397da80c89e355.tar.gz
pvs2-1980bbaa03ae7536f5a6a1d3a5397da80c89e355.tar.xz
pvs2-1980bbaa03ae7536f5a6a1d3a5397da80c89e355.zip
[client] Skip rooms with no mgrIP when selecting "myRooms"
-rw-r--r--src/client/toolbar/toolbar.cpp33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/client/toolbar/toolbar.cpp b/src/client/toolbar/toolbar.cpp
index 2ef9699..13e5cfb 100644
--- a/src/client/toolbar/toolbar.cpp
+++ b/src/client/toolbar/toolbar.cpp
@@ -272,29 +272,34 @@ QList<Room> Toolbar::myRooms()
QStringList roomNames = conf->value("rooms").toStringList();
/* go through all rooms and check if this client is a member of the room. */
+ auto localAddresses = QNetworkInterface::allAddresses();
for (auto roomName : roomNames) {
conf->beginGroup(roomName);
+ if (conf->contains("name")) {
+ roomName = conf->value("name").toString();
+ }
if (!conf->contains("mgrIP")) {
- qDebug() << "Invalid config file!";
- return myRooms;
+ qDebug() << "Room " << roomName << " has no mgrIP: Invalid config file!";
}
QString mgrIP = conf->value("mgrIP").toString();
int priority = conf->value("priority").toInt();
- foreach (const QHostAddress & address, QNetworkInterface::allAddresses()) {
- int size = conf->beginReadArray("client");
- for (int j = 0; j < size; ++j) {
- conf->setArrayIndex(j);
- QString ip = conf->value("ip").toString();
- if (address != QHostAddress(QHostAddress::LocalHost)
- && ip == address.toString() ) {
- /* add this room to the list */
- Room r(roomName, mgrIP, priority);
- myRooms << r;
- break;
+ if (mgrIP.length() != 0) {
+ foreach (const QHostAddress & address, localAddresses) {
+ int size = conf->beginReadArray("client");
+ for (int j = 0; j < size; ++j) {
+ conf->setArrayIndex(j);
+ QString ip = conf->value("ip").toString();
+ if (address != QHostAddress(QHostAddress::LocalHost)
+ && ip == address.toString() ) {
+ /* add this room to the list */
+ Room r(roomName, mgrIP, priority);
+ myRooms << r;
+ break;
+ }
}
+ conf->endArray();
}
- conf->endArray();
}
conf->endGroup();
}