summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorManuel Schneider2014-09-03 15:40:39 +0200
committerManuel Schneider2014-09-03 15:40:39 +0200
commit6017ad54c22bcb991c832f90d2a19722198886bb (patch)
tree384bbf35357aba506d2bae131abc4747b8c30af0 /src
parentChange system settings path. Change name of config file (diff)
parentAdded german translations for client. (diff)
downloadpvs2-6017ad54c22bcb991c832f90d2a19722198886bb.tar.gz
pvs2-6017ad54c22bcb991c832f90d2a19722198886bb.tar.xz
pvs2-6017ad54c22bcb991c832f90d2a19722198886bb.zip
Merge branch 'master' of git.openslx.org:pvs2
Diffstat (limited to 'src')
-rw-r--r--src/client/connectwindow/connectwindow.cpp9
-rw-r--r--src/client/connectwindow/connectwindow.h2
-rw-r--r--src/client/main.cpp13
-rw-r--r--src/client/net/serverconnection.cpp2
-rw-r--r--src/client/net/serverdiscovery.cpp36
-rw-r--r--src/client/net/serverdiscovery.h4
-rw-r--r--src/client/toolbar/toolbar.cpp86
-rw-r--r--src/client/toolbar/toolbar.h2
-rw-r--r--src/client/util/util.h4
-rw-r--r--src/server/connectionframe/connectionframe.cpp2
-rw-r--r--src/server/connectionframe/connectionframe.h4
-rw-r--r--src/server/mainwindow/mainwindow.cpp177
-rw-r--r--src/server/mainwindow/mainwindow.h9
-rw-r--r--src/server/reloadroomwindow/reloadroomwindow.cpp13
-rw-r--r--src/server/reloadroomwindow/reloadroomwindow.h25
15 files changed, 327 insertions, 61 deletions
diff --git a/src/client/connectwindow/connectwindow.cpp b/src/client/connectwindow/connectwindow.cpp
index 7f24281..90cba27 100644
--- a/src/client/connectwindow/connectwindow.cpp
+++ b/src/client/connectwindow/connectwindow.cpp
@@ -158,13 +158,13 @@ void ConnectWindow::showEvent(QShowEvent* event)
* if not --> connect to given sessionName.
* @param sessionName
*/
-void ConnectWindow::connectToSession(const QByteArray sessionName)
+void ConnectWindow::connectToSession(const QByteArray sessionName, QString mgrIP)
{
if (_connected || _state != Idle)
return;
_state = Scanning;
this->updateState();
- _serverDiscovery.start(sessionName);
+ _serverDiscovery.start(sessionName, mgrIP);
}
/*
@@ -199,7 +199,8 @@ void ConnectWindow::onBtnConnection()
{
// Connect (scan for session)
_tryReconnect = true;
- connectToSession(_ui->lineEditName->text().toUtf8());
+ // qDebug() << _ui->lineEditName->text().toUtf8();
+ connectToSession(_ui->lineEditName->text().toUtf8(), NULL);
}
}
@@ -279,5 +280,5 @@ void ConnectWindow::onConnectionDisconnected()
_state = Idle;
this->updateState();
if (_tryReconnect)
- connectToSession(_ui->lineEditName->text().toUtf8());
+ connectToSession(_ui->lineEditName->text().toUtf8(), NULL);
}
diff --git a/src/client/connectwindow/connectwindow.h b/src/client/connectwindow/connectwindow.h
index df112fe..a786119 100644
--- a/src/client/connectwindow/connectwindow.h
+++ b/src/client/connectwindow/connectwindow.h
@@ -54,7 +54,7 @@ public:
explicit ConnectWindow(QWidget *parent = NULL);
virtual ~ConnectWindow();
- void connectToSession(const QByteArray sessionName);
+ void connectToSession(const QByteArray sessionName, QString mgrIP);
private:
Ui::ConnectWindow *_ui;
diff --git a/src/client/main.cpp b/src/client/main.cpp
index 0907528..b268ca3 100644
--- a/src/client/main.cpp
+++ b/src/client/main.cpp
@@ -5,7 +5,7 @@
int main(int argc, char** argv)
{
if (argc > 2) {
- std::cerr << "Usage: " << argv[0] << " [sessionId]" << std::endl;
+ std::cerr << "Usage: " << argv[0] << " [sessionId] | --auto" << std::endl;
exit(EXIT_FAILURE);
}
@@ -42,7 +42,16 @@ int main(int argc, char** argv)
translator.load(":pvsclient");
app.installTranslator(&translator);
+ if (argc == 2) {
+ if (argv[1] == std::string("--auto")) {
+ qDebug() << "Calling Toolbar(true)";
+ Toolbar *pvsclient = new Toolbar(true); // auto connect client without session ID.
+ } else {
+ Toolbar *pvsclient = new Toolbar(QByteArray(argv[1])); // connect client with given session ID.
+ }
+ } else {
+ Toolbar *pvsclient = new Toolbar(); // create normal client.
+ }
- Toolbar *pvsclient = argc == 2 ? new Toolbar(QByteArray(argv[1])) : new Toolbar();
return app.exec();
}
diff --git a/src/client/net/serverconnection.cpp b/src/client/net/serverconnection.cpp
index babd64f..7954c34 100644
--- a/src/client/net/serverconnection.cpp
+++ b/src/client/net/serverconnection.cpp
@@ -26,7 +26,7 @@ ServerConnection::ServerConnection(const QString& host, const quint16 port, cons
connect(_socket, SIGNAL(encrypted()), this, SLOT(sock_connected()));
connect(_socket, SIGNAL(readyRead()), this, SLOT(sock_dataArrival()));
connect(_socket, SIGNAL(disconnected()), this, SLOT(sock_closed()));
- connect(_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(sock_error(QAbstractSocket::SocketError)));
+ connect(_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(sock_error(QAbstractSocket::SocketError)));
connect(_socket,
SIGNAL(sslErrors(const QList<QSslError> &)),
this,
diff --git a/src/client/net/serverdiscovery.cpp b/src/client/net/serverdiscovery.cpp
index a4edb46..2cd0796 100644
--- a/src/client/net/serverdiscovery.cpp
+++ b/src/client/net/serverdiscovery.cpp
@@ -45,8 +45,14 @@ ServerDiscovery::~ServerDiscovery()
/***************************************************************************//**
* @brief start
*/
-void ServerDiscovery::start(const QByteArray& sessionName)
+void ServerDiscovery::start(const QByteArray& sessionName, QString mgrIP)
{
+ if (mgrIP != NULL) {
+ _mgrIP.setAddress(mgrIP);
+ } else {
+ _mgrIP = NULL;
+ }
+
//assert(!this->isActive());
// Set the session which is searched
@@ -98,21 +104,31 @@ void ServerDiscovery::doDiscovery()
_packet.setField(_SALT1, salt1);
_packet.setField(_SALT2, _salt2);
_packet.setField(_IPLIST, iplist);
- foreach (QNetworkInterface interface, QNetworkInterface::allInterfaces())
+
+ // Check if specifig manager IP is given. If not broadcast in whole network.
+ if (_mgrIP != QHostAddress::Null)
+ {
+ qDebug() << "Broadcasting to " << _mgrIP.toString();
+ if (!_packet.writeMessage(&_discoverySocket, _mgrIP, SERVICE_DISCOVERY_PORT))
+ qDebug("Failed");
+ } else
{
- foreach (QNetworkAddressEntry entry, interface.addressEntries())
+ foreach (QNetworkInterface interface, QNetworkInterface::allInterfaces())
{
- if (!entry.broadcast().isNull() && entry.ip() != QHostAddress::LocalHost && entry.ip() != QHostAddress::LocalHostIPv6)
+ foreach (QNetworkAddressEntry entry, interface.addressEntries())
{
- qDebug() << "Broadcasting to " << entry.broadcast().toString();
- if (!_packet.writeMessage(&_discoverySocket, entry.broadcast(), SERVICE_DISCOVERY_PORT))
- qDebug("FAILED");
+ if (!entry.broadcast().isNull() && entry.ip() != QHostAddress::LocalHost && entry.ip() != QHostAddress::LocalHostIPv6)
+ {
+ qDebug() << "Broadcasting to " << entry.broadcast().toString();
+ if (!_packet.writeMessage(&_discoverySocket, entry.broadcast(), SERVICE_DISCOVERY_PORT))
+ qDebug("FAILED");
+ }
}
}
+ qDebug("Broadcasting to 255.255.255.255");
+ if (!_packet.writeMessage(&_discoverySocket, QHostAddress::Broadcast, SERVICE_DISCOVERY_PORT))
+ qDebug("FAILED");
}
- qDebug("Broadcasting to 255.255.255.255");
- if (!_packet.writeMessage(&_discoverySocket, QHostAddress::Broadcast, SERVICE_DISCOVERY_PORT))
- qDebug("FAILED");
// Start the timer again with a larger interval
if (_discoveryTimer.interval() < 5000)
diff --git a/src/client/net/serverdiscovery.h b/src/client/net/serverdiscovery.h
index 093b841..fee9fd0 100644
--- a/src/client/net/serverdiscovery.h
+++ b/src/client/net/serverdiscovery.h
@@ -19,7 +19,7 @@ class ServerDiscovery : public QObject
explicit ServerDiscovery(QObject *parent = 0);
~ServerDiscovery();
- void start(const QByteArray& sessionName);
+ void start(const QByteArray& sessionName, QString mgrIP);
void stop();
inline bool isActive(){ return _discoveryTimer.isActive(); }
@@ -32,6 +32,8 @@ class ServerDiscovery : public QObject
QUdpSocket _discoverySocket;
NetworkMessage _packet;
+ QHostAddress _mgrIP;
+
static const int UDPBUFSIZ = 9000;
static const int SALT_LEN = 18;
diff --git a/src/client/toolbar/toolbar.cpp b/src/client/toolbar/toolbar.cpp
index 837bc08..1838166 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,38 @@
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 If parent is 0, the new widget becomes a window. If parent is
+ * another widget, this widget becomes a child window inside parent. The new
+ * widget is deleted when its parent is deleted.
+ */
+Toolbar::Toolbar(const bool autoConnect, QWidget *parent) : Toolbar(parent)
+{
+ qDebug() << "auto - constructor!";
+
+ if (autoConnect) {
+ // Try 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 +177,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
*/
diff --git a/src/client/toolbar/toolbar.h b/src/client/toolbar/toolbar.h
index 80ddd69..84f6d2d 100644
--- a/src/client/toolbar/toolbar.h
+++ b/src/client/toolbar/toolbar.h
@@ -32,6 +32,7 @@ class Toolbar : public QWidget
public:
Toolbar(QWidget *parent = 0);
Toolbar(const QByteArray sessionName, QWidget *parent = 0);
+ Toolbar(const bool autoConnect, QWidget *parent = 0);
virtual ~Toolbar();
private:
@@ -49,6 +50,7 @@ private:
void leaveEvent(QEvent* e);
void enterEvent(QEvent* e);
+ QString identifyMgrIP();
private slots:
void onVncServerIsRunning(int port);
diff --git a/src/client/util/util.h b/src/client/util/util.h
index 82248c0..662599f 100644
--- a/src/client/util/util.h
+++ b/src/client/util/util.h
@@ -6,8 +6,8 @@
// Use like this:
// USER_SETTINGS(settings)
// settings.value("somekey")
-#define USER_SETTINGS(name) QSettings name (QSettings::IniFormat, QSettings::UserScope, "openslx", "pvs2client")
-#define SYSTEM_SETTINGS(name) QSettings name (QSettings::IniFormat, QSettings::SystemScope, "openslx", "pvs2client")
+#define USER_SETTINGS(name) QSettings name (QSettings::IniFormat, QSettings::UserScope, "openslx", "pvs2")
+#define SYSTEM_SETTINGS(name) QSettings name (QSettings::IniFormat, QSettings::SystemScope, "openslx", "pvs2")
#include <QDir>
diff --git a/src/server/connectionframe/connectionframe.cpp b/src/server/connectionframe/connectionframe.cpp
index 1bf6fb6..39aba12 100644
--- a/src/server/connectionframe/connectionframe.cpp
+++ b/src/server/connectionframe/connectionframe.cpp
@@ -188,7 +188,7 @@ void ConnectionFrame::mouseReleaseEvent(QMouseEvent* event)
if ((this->pos() - _previousPosition).manhattanLength() > _startDragDistance )
{
qDebug("Moved");
- emit frameMoved(this);
+ emit frameMoved(true, this);
}
else
{
diff --git a/src/server/connectionframe/connectionframe.h b/src/server/connectionframe/connectionframe.h
index faa1390..188cdc7 100644
--- a/src/server/connectionframe/connectionframe.h
+++ b/src/server/connectionframe/connectionframe.h
@@ -61,7 +61,7 @@ public:
const inline QPoint& getCurrentPosition() const { return _currentPosition; }
const QString& computerId() const { return _computerId; }
- inline void setComputerId(QString computerId) { _computerId = computerId; }
+ const inline void setComputerId(QString computerId) { _computerId = computerId; }
Client* client() const { return _client; }
inline const bool isTutor() const { return _isTutor; }
@@ -78,7 +78,7 @@ protected:
void timerEvent(QTimerEvent* event);
signals:
- void frameMoved(ConnectionFrame* frame);
+ void frameMoved(bool activateTrash, ConnectionFrame* frame);
void doubleClicked(ConnectionFrame* frame);
void clicked(ConnectionFrame* frame);
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp
index 55e4bce..17e821a 100644
--- a/src/server/mainwindow/mainwindow.cpp
+++ b/src/server/mainwindow/mainwindow.cpp
@@ -24,6 +24,8 @@
#include "../sessionnamewindow/sessionnamewindow.h"
#include "../connectionframe/connectionframe.h"
#include "../helpwindow/helpwindow.h"
+#include "../reloadroomwindow/reloadroomwindow.h"
+#include "ui_reloadroom.h"
// Network
#include "../net/listenserver.h"
#include "../net/client.h"
@@ -61,6 +63,8 @@ MainWindow::MainWindow(QString ipListUrl, QWidget* parent) :
_sessionNameWindow = new SessionNameWindow(this);
_helpWindow = new HelpWindow(this);
_helpWindow->setWindowTitle("Help");
+ _reloadWindow = new ReloadRoomWindow(this);
+ _reloadWindow->setWindowTitle("Reload Room");
ui->setupUi(this);
Global::setSessionName();
@@ -98,6 +102,7 @@ MainWindow::MainWindow(QString ipListUrl, QWidget* parent) :
connect(ui->action_SetAsTutor, SIGNAL(triggered()), this, SLOT(onButtonStopProjection()));
connect(ui->action_Lock, SIGNAL(toggled(bool)), this, SLOT(onButtonLock(bool)));
connect(ui->action_Help, SIGNAL(triggered()), this, SLOT(onButtonHelp()));
+ connect(ui->actionReload_Room_Configuration, SIGNAL(triggered()), this, SLOT(onButtonReloadRoomConfig()));
/* Stuff for the button lock */
//Setup a timeout
@@ -129,7 +134,9 @@ MainWindow::MainWindow(QString ipListUrl, QWidget* parent) :
_discoveryListener = new DiscoveryListener();
// Finally
-// this->onSessionNameUpdate();
+ _countSessionNameUpdate = 0;
+ this->onSessionNameUpdate(); // Just make lable visible.
+ _countSessionNameUpdate = 0;
_tileWidth = ui->frmRoom->size().width() / _tilesX;
_tileHeight = ui->frmRoom->size().height() / _tilesY;
@@ -209,7 +216,7 @@ ConnectionFrame* MainWindow::createFrame()
ConnectionFrame *cf = new ConnectionFrame(ui->frmRoom, _tileWidth, _tileHeight);
_clientFrames.append(cf);
cf->show();
- connect(cf, SIGNAL(frameMoved(ConnectionFrame *)), this, SLOT(onPlaceFrame(ConnectionFrame *)));
+ connect(cf, SIGNAL(frameMoved(bool, ConnectionFrame *)), this, SLOT(onPlaceFrame(bool, ConnectionFrame *)));
connect(cf, SIGNAL(clicked(ConnectionFrame *)), this, SLOT(onFrameClicked(ConnectionFrame *)));
return cf;
}
@@ -228,7 +235,7 @@ ConnectionFrame* MainWindow::createFrame(QString computerId, QPoint position)
cf->setCurrentPosition(position);
_clientFrames.append(cf);
cf->show();
- connect(cf, SIGNAL(frameMoved(ConnectionFrame *)), this, SLOT(onPlaceFrame(ConnectionFrame *)));
+ connect(cf, SIGNAL(frameMoved(bool, ConnectionFrame *)), this, SLOT(onPlaceFrame(bool, ConnectionFrame *)));
connect(cf, SIGNAL(clicked(ConnectionFrame *)), this, SLOT(onFrameClicked(ConnectionFrame *)));
return cf;
}
@@ -309,12 +316,23 @@ void MainWindow::tryToUseRoomTemplate()
for (auto i : rooms)
{
+ qDebug() << "i: " << i;
conf.beginGroup(i);
if (!conf.contains("mgrIP")) {
qDebug() << "Invalid config file!";
return;
}
- // Find the room that list the ip of this host as mgr
+
+ // First store all room configurations in _rooms.
+ int size = conf.beginReadArray("client");
+ for (int j = 0; j < size; j++) {
+ conf.setArrayIndex(j);
+ // qDebug() << "ip: " << conf.value("ip").toString() << " pos: " << conf.value("pos").toPoint();
+ _rooms[i].append(qMakePair(conf.value("ip").toString(), conf.value("pos").toPoint()));
+ }
+ conf.endArray();
+
+ // Find the managerIP of current room.
QString mgrIP = conf.value("mgrIP").toString();
foreach (const QHostAddress &address, QNetworkInterface::allAddresses())
{
@@ -322,8 +340,8 @@ void MainWindow::tryToUseRoomTemplate()
{
qDebug("Found this ip in config.");
int size = conf.beginReadArray("client");
- for (int i = 0; i < size; ++i) {
- conf.setArrayIndex(i);
+ for (int j = 0; j < size; ++j) {
+ conf.setArrayIndex(j);
/*
*
@@ -334,8 +352,9 @@ void MainWindow::tryToUseRoomTemplate()
// Add the frame
// Position is given in grid coordinates, createFrame take pixels
- qDebug() << conf.value("ip").toString();
+ QString computerId = conf.value("ip").toString();
QPoint coord = conf.value("pos").toPoint();
+ qDebug() << computerId;
qDebug() << coord;
qDebug() << _tileWidth ;
qDebug() << _tileHeight ;
@@ -344,9 +363,9 @@ void MainWindow::tryToUseRoomTemplate()
coord.setY(coord.y() * _tileHeight);
qDebug() << coord ;
- ConnectionFrame *cf = createFrame(conf.value("ip").toString(), coord);
+ ConnectionFrame *cf = createFrame(computerId, coord);
cf->move(cf->getCurrentPosition());
- onPlaceFrame(cf);
+ onPlaceFrame(false, cf);
}
conf.endArray();
}
@@ -525,7 +544,7 @@ void MainWindow::onTutorListDownloaded(QByteArray& tutorList)
* Place Frame to from user specified position.
* @param frame
*/
-void MainWindow::onPlaceFrame(ConnectionFrame* frame)
+void MainWindow::onPlaceFrame(bool activateTrash, ConnectionFrame* frame)
{
if (_tilesX <= 0 || _tilesY <= 0)
return;
@@ -542,31 +561,34 @@ void MainWindow::onPlaceFrame(ConnectionFrame* frame)
else if (y > s.height() - _tileHeight)
y = (_tilesY - 1) * _tileHeight;
- const QRect &trashCenter = ui->trash->geometry();
- // Check if x coordinate is in trash position.
- if (trashCenter.contains(p))
+ // Check if x coordinate is in trash position. Check only if activateTrash = true!
+ if (activateTrash)
{
- // Do not offer deleting online client.
- if (frame->client() != NULL)
- {
- QMessageBox::critical(this, tr("Selection"), sStrClientOnline);
- frame->move(frame->getPreviousPosition());
- return;
- }
- else
+ const QRect &trashCenter = ui->trash->geometry();
+ if (trashCenter.contains(p))
{
- int ret = QMessageBox::question(this, "Warning", "Sure, You want to delete selected client?", 0, 1, 2);
- if (ret == 1)
+ // Do not offer deleting online client.
+ if (frame->client() != NULL)
{
- frame->hide();
- frame->deleteLater();
- _clientFrames.removeOne(frame);
+ QMessageBox::critical(this, tr("Selection"), sStrClientOnline);
+ frame->move(frame->getPreviousPosition());
return;
}
else
{
- frame->move(frame->getPreviousPosition());
- return;
+ int ret = QMessageBox::question(this, "Warning", "Sure, You want to delete selected client?", 0, 1, 2);
+ if (ret == 1)
+ {
+ frame->hide();
+ frame->deleteLater();
+ _clientFrames.removeOne(frame);
+ return;
+ }
+ else
+ {
+ frame->move(frame->getPreviousPosition());
+ return;
+ }
}
}
}
@@ -611,7 +633,18 @@ void MainWindow::onFrameClicked(ConnectionFrame* frame)
*/
void MainWindow::onSessionNameClick()
{
- _sessionNameWindow->show(Global::sessionName());
+ _countSessionNameUpdate++;
+ if (_countSessionNameUpdate > 1)
+ {
+ int ret = QMessageBox::question(this, "Warning", "Sure, You want to change SessionName again?\n"
+ "All Clients will be deleted afterwards.", 0, 1, 2);
+ if (ret == 1)
+ {
+ _sessionNameWindow->show(Global::sessionName());
+ }
+ }
+ else
+ _sessionNameWindow->show((Global::sessionName()));
}
/***************************************************************************//**
@@ -621,12 +654,17 @@ void MainWindow::onSessionNameUpdate()
{
// Stop all projections and clear all clients, which where connected to old sessionName.
reset();
- for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
+ if (_countSessionNameUpdate > 1)
{
- (*it)->hide();
- (*it)->deleteLater();
+ {
+ for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
+ {
+ (*it)->hide();
+ (*it)->deleteLater();
+ }
+ _clientFrames.clear();
+ }
}
- _clientFrames.clear();
_sessionNameLabel->setText(tr("Session Name: %1 [click to edit]").arg(Global::sessionName()));
}
@@ -655,6 +693,71 @@ void MainWindow::startVncServerIfNecessary(int from)
}
}
+void MainWindow::onButtonReloadRoomConfig()
+{
+ connect(_reloadWindow->ui->buttonBox, SIGNAL(accepted()), this, SLOT(onReloadRoomOk()));
+ connect(_reloadWindow->ui->buttonBox, SIGNAL(rejected()), this, SLOT(onReloadRoomCancel()));
+ qDebug() << "in onButtonReloadRoomConfig!" << "size of room: " << _rooms.size();
+ QList<QString> keyList = _rooms.keys();
+ for (QList<QString>::iterator it = keyList.begin(); it != keyList.end() ; it++) {
+ _reloadWindow->ui->roomList->addItem(*it);
+ }
+ _reloadWindow->show();
+}
+
+void MainWindow::onReloadRoomCancel()
+{
+ disconnect(_reloadWindow->ui->buttonBox, SIGNAL(accepted()), this, SLOT(onReloadRoomOk()));
+ disconnect(_reloadWindow->ui->buttonBox, SIGNAL(rejected()), this, SLOT(onReloadRoomCancel()));
+ _reloadWindow->ui->roomList->clear();
+ _reloadWindow->hide();
+}
+
+void MainWindow::onReloadRoomOk()
+{
+ int ret = QMessageBox::QMessageBox::question(this, "Warning", tr("Are you sure you want to reload the room?\n"
+ "Note that all clients will be deleted."), 0, 1, 2);
+
+ if (ret == 1) {
+ disconnect(_reloadWindow->ui->buttonBox, SIGNAL(accepted()), this, SLOT(onReloadRoomOk()));
+ disconnect(_reloadWindow->ui->buttonBox, SIGNAL(rejected()), this, SLOT(onReloadRoomCancel()));
+ // Delete all clients.
+ for (QList<ConnectionFrame*>::iterator it = _clientFrames.begin(); it != _clientFrames.end(); it++)
+ {
+ (*it)->hide();
+ (*it)->deleteLater();
+ }
+ _clientFrames.clear();
+
+ // Load new room configuration.
+ QString roomToReload = _reloadWindow->ui->roomList->currentItem()->data(0).toString();
+ // qDebug() << roomToReload;
+
+ _reloadWindow->ui->roomList->clear();
+ _reloadWindow->hide();
+
+ QList<QPair<QString, QPoint>> room = _rooms[roomToReload];
+ // qDebug() << " Room: " << room;
+ // qDebug() << "_rooms: " << _rooms;
+ for (QList<QPair<QString, QPoint>>::iterator it = room.begin(); it != room.end(); ++it)
+ {
+ QString computerId = (*it).first;
+ QPoint pos = (*it).second;
+
+ qDebug() << "ComputerID: " << computerId;
+ qDebug() << "Pos: " << pos;
+
+ // Transform to pixels for createFrame(computerId, position).
+ pos.setX(pos.x() * _tileWidth);
+ pos.setY(pos.y() * _tileHeight);
+
+ ConnectionFrame *cf = createFrame(computerId, pos);
+ cf->move(cf->getCurrentPosition());
+ onPlaceFrame(false, cf);
+ }
+ }
+}
+
/***************************************************************************//**
* Display popup which explains possible actions about the buttons.
*/
@@ -969,8 +1072,13 @@ void MainWindow::onClientAuthenticated(Client* client)
ConnectionFrame *existing = NULL;
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
{
+ // qDebug() << "Existing frame ip: " << (*it)->computerId();
+ // qDebug() << "New Clients ip: " << client->ip();
+ // qDebug() << ((*it)->computerId() == client->ip());
if ((*it)->computerId() == client->ip())
+ {
existing = *it;
+ }
if ((*it)->isTutor())
{
if ((*it)->client() != NULL)
@@ -994,6 +1102,7 @@ void MainWindow::onClientAuthenticated(Client* client)
// Clients ip already exists, but was not active.
if (existing != NULL)
{
+ // qDebug() << "Should go into this if clause.";
existing->setTutor(isTutor);
existing->assignClient(client);
tellClientCurrentSituation(client);
@@ -1027,7 +1136,7 @@ void MainWindow::onClientAuthenticated(Client* client)
y = 0;
qDebug("Move E");
cf->move(x * _tileWidth, y * _tileHeight);
- onPlaceFrame(cf);
+ onPlaceFrame(true, cf);
}
else
{
diff --git a/src/server/mainwindow/mainwindow.h b/src/server/mainwindow/mainwindow.h
index acecc28..f8d0164 100644
--- a/src/server/mainwindow/mainwindow.h
+++ b/src/server/mainwindow/mainwindow.h
@@ -11,6 +11,7 @@ class ConnectionFrame;
class ListenServer;
class DiscoveryListener;
class HelpWindow;
+class ReloadRoomWindow;
namespace Ui{
class MainWindow;
@@ -35,6 +36,7 @@ private:
Ui::MainWindow *ui;
SessionNameWindow *_sessionNameWindow;
HelpWindow *_helpWindow;
+ ReloadRoomWindow *_reloadWindow;
QLabel *_sessionNameLabel;
int _tbIconSize;
Qt::ToolBarArea _tbArea;
@@ -56,12 +58,14 @@ private:
None
} _mode;
int _streamingSource;
+ int _countSessionNameUpdate;
QList<ConnectionFrame*> _clientFrames;
ListenServer *_listenServer;
DiscoveryListener *_discoveryListener;
FileDownloader _fileDownloader;
QStringList _tutorList;
+ QMap<QString, QList<QPair<QString, QPoint> > > _rooms;
static const QString sStrTutorNdef;
static const QString sStrTutorOffline;
@@ -105,13 +109,16 @@ protected slots:
void onButtonStopProjection();
void onButtonSetAsTutor();
+ void onButtonReloadRoomConfig();
+ void onReloadRoomOk();
+ void onReloadRoomCancel();
void onButtonExit();
void onButtonHelp();
void DisableButtons();
void EnableButtons();
// connection frame
- void onPlaceFrame(ConnectionFrame* frame);
+ void onPlaceFrame(bool activateTrash, ConnectionFrame* frame);
void onFrameClicked(ConnectionFrame* frame);
// Net
void onClientConnected(Client* client);
diff --git a/src/server/reloadroomwindow/reloadroomwindow.cpp b/src/server/reloadroomwindow/reloadroomwindow.cpp
new file mode 100644
index 0000000..3070148
--- /dev/null
+++ b/src/server/reloadroomwindow/reloadroomwindow.cpp
@@ -0,0 +1,13 @@
+#include "reloadroomwindow.h"
+#include "ui_reloadroom.h"
+
+ReloadRoomWindow::ReloadRoomWindow(QWidget *parent) :
+ QDialog(parent), ui(new Ui::ReloadRoom)
+{
+ ui->setupUi(this);
+}
+
+ReloadRoomWindow::~ReloadRoomWindow()
+{
+ delete ui;
+}
diff --git a/src/server/reloadroomwindow/reloadroomwindow.h b/src/server/reloadroomwindow/reloadroomwindow.h
new file mode 100644
index 0000000..9ce0aba
--- /dev/null
+++ b/src/server/reloadroomwindow/reloadroomwindow.h
@@ -0,0 +1,25 @@
+#ifndef RELOADROOMWINDOW_H
+#define RELOADROOMWINDOW_H
+
+#include <QDialog>
+
+namespace Ui {
+class ReloadRoom;
+}
+
+class ReloadRoomWindow : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit ReloadRoomWindow(QWidget *parent = 0);
+ ~ReloadRoomWindow();
+ Ui::ReloadRoom *ui;
+
+ // void show();
+
+private:
+
+};
+
+#endif