From 1980bbaa03ae7536f5a6a1d3a5397da80c89e355 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 10 Oct 2016 20:30:17 +0200 Subject: [client] Skip rooms with no mgrIP when selecting "myRooms" --- src/client/toolbar/toolbar.cpp | 33 +++++++++++++++++++-------------- 1 file 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 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(); } -- cgit v1.2.3-55-g7522