summaryrefslogtreecommitdiffstats
path: root/src/server
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/server
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/server')
-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
6 files changed, 192 insertions, 38 deletions
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