summaryrefslogtreecommitdiffstats
path: root/src/client/toolbar/toolbar.cpp
diff options
context:
space:
mode:
authorBjörn Hagemeister2014-08-25 18:08:15 +0200
committerBjörn Hagemeister2014-08-25 18:08:15 +0200
commit6cb63e7e30906f428c601ba00fd15c14e07093cf (patch)
treef83ea27e10616a384c26480e662854cf02ac8834 /src/client/toolbar/toolbar.cpp
parentNew Feature: Button for reloading room configuration of choosable room. (diff)
downloadpvs2-6cb63e7e30906f428c601ba00fd15c14e07093cf.tar.gz
pvs2-6cb63e7e30906f428c601ba00fd15c14e07093cf.tar.xz
pvs2-6cb63e7e30906f428c601ba00fd15c14e07093cf.zip
Client is able to auto - connect to the same room belonging manager.
Diffstat (limited to 'src/client/toolbar/toolbar.cpp')
-rw-r--r--src/client/toolbar/toolbar.cpp84
1 files changed, 82 insertions, 2 deletions
diff --git a/src/client/toolbar/toolbar.cpp b/src/client/toolbar/toolbar.cpp
index 837bc08..0f90492 100644
--- a/src/client/toolbar/toolbar.cpp
+++ b/src/client/toolbar/toolbar.cpp
@@ -4,18 +4,20 @@
* Created on: 21.01.2013
* Author: sr
*/
+#include <QNetworkInterface>
#include "../../shared/settings.h"
#include "../net/serverconnection.h"
#include "../vnc/vncwindow.h"
#include "../vnc/vncserver.h"
+#include "../util/util.h"
#include "toolbar.h"
#include "ui_toolbar.h"
/***************************************************************************//**
- * @brief Constructor of the Toolbar.
+ * @brief
*
* Does exact teh same as Toolbar::Toolbar(QWidget *parent) but additionally
* instantly tries to connect to a pvsmgr with the given sessionName.
@@ -27,7 +29,36 @@
Toolbar::Toolbar(const QByteArray sessionName, QWidget *parent)
: Toolbar(parent)
{
- _connectWindow->connectToSession(sessionName);
+ qDebug() << "sessionName - constructor";
+ _connectWindow->connectToSession(sessionName, NULL);
+}
+
+/***************************************************************************//**
+ * @brief Constructor of the Toolbar.
+ *
+ * Does exact the same as Toolbar::Toolbar(QWidget *parent) but additionally
+ * instantly tries to connect to the pvsmgr in its room without sessionName.
+ * @param autoConnect
+ * @param parent
+ */
+Toolbar::Toolbar(const bool autoConnect, QWidget *parent) : Toolbar(parent)
+{
+ qDebug() << "auto - constructor!";
+
+ if (autoConnect) {
+ // Getting manager ip.
+ QString mgrIp = identifyMgrIP();
+ qDebug() << "mgrIP: " << mgrIp;
+ if (mgrIp != NULL) {
+ qDebug() << "Starting WITH specific mgrIP";
+ _connectWindow->connectToSession("", mgrIp);
+ } else {
+ qDebug() << "Starting WITHOUT specific mgrIP";
+ _connectWindow->connectToSession("", NULL);
+ }
+ } else {
+ _connectWindow->connectToSession("", NULL);
+ }
}
/***************************************************************************//**
@@ -144,6 +175,55 @@ void Toolbar::enterEvent(QEvent* e)
QWidget::enterEvent(e);
}
+QString Toolbar::identifyMgrIP()
+{
+ SYSTEM_SETTINGS(conf);
+ qDebug() << "Settings contain" << conf.allKeys();
+
+ if (!conf.contains("rooms")) {
+ qDebug() << "Invalid config file!";
+ return NULL;
+ }
+
+ QStringList rooms = conf.value("rooms").toStringList();
+ qDebug() << rooms;
+
+ for (auto i : rooms)
+ {
+ qDebug() << "i: " << i;
+ conf.beginGroup(i);
+ if (!conf.contains("mgrIP")) {
+ qDebug() << "Invalid config file!";
+ return NULL;
+ }
+
+ // Find the managerIP of current room.
+ QString mgrIP = conf.value("mgrIP").toString();
+ 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;
+ }
+ }
+ conf.endArray();
+ }
+ conf.endGroup();
+ }
+ return NULL;
+}
+
/*
* Slots
*/