summaryrefslogtreecommitdiffstats
path: root/src/server/mainwindow
diff options
context:
space:
mode:
authorManuel Schneider2014-05-22 15:45:23 +0200
committerManuel Schneider2014-05-22 15:45:23 +0200
commit7878fe9db26439acd1163b2f487cfdb3415f59ac (patch)
treeab684395e0522179f6742c897ddfb2b8c51f2b00 /src/server/mainwindow
parentStop suggesting the user to be recorded: (diff)
downloadpvs2-7878fe9db26439acd1163b2f487cfdb3415f59ac.tar.gz
pvs2-7878fe9db26439acd1163b2f487cfdb3415f59ac.tar.xz
pvs2-7878fe9db26439acd1163b2f487cfdb3415f59ac.zip
First approach for an exclusive unicast. T.b.c.
Diffstat (limited to 'src/server/mainwindow')
-rw-r--r--src/server/mainwindow/mainwindow.cpp68
-rw-r--r--src/server/mainwindow/mainwindow.h27
2 files changed, 62 insertions, 33 deletions
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp
index 5059516..1efc87a 100644
--- a/src/server/mainwindow/mainwindow.cpp
+++ b/src/server/mainwindow/mainwindow.cpp
@@ -439,28 +439,27 @@ bool MainWindow::isValidClient(Client* client)
*/
void MainWindow::broadcast(Client *from)
{
- // Projection source is never allowed to be an active VNC viewer
- if (from->isActiveVncClient())
- from->stopVncClient();
+ _state = State::Broadcast;
- // Tell all clients to listen to server
- for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it){
- if ((*it)->client() != NULL)
- (*it)->client()->setBroadcastSource(false);
- }
+ // if there is a server running which is not "from" stop it.
+ if (_streamingSource != NULL && _streamingSource != from)
+ _streamingSource->stopVncServer();
+ _streamingSource = from;
- from->setDesiredProjectionSource(0);
- from->setBroadcastSource(true);
+ // Server must not listen to itself
+ _streamingSource->setDesiredProjectionSource(0);
// Set desired projection source on all clients, if not "from" or oflline
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
- if ((*it)->client() != NULL && (*it)->client()->id() != from->id())
- (*it)->client()->setDesiredProjectionSource(from->id());
+ if ((*it)->client() != NULL && (*it)->client() != _streamingSource)
+ (*it)->client()->setDesiredProjectionSource(_streamingSource->id());
- if (from->isActiveVncServer()) // From is already active
- this->onVncServerStateChange(from);
- else // Could not take shortcut, (re)start VNC server on source
- from->startVncServer();
+ if (_streamingSource->isActiveVncServer())
+ // From is already active
+ this->onVncServerStateChange(_streamingSource);
+ else
+ // Could not take shortcut, start VNC server on source
+ _streamingSource->startVncServer();
}
@@ -472,6 +471,13 @@ void MainWindow::broadcast(Client *from)
*/
void MainWindow::unicast(Client *from, Client *to, bool blockOthers)
{
+ _state = blockOthers ? State::ExclusiveUnicast : State::Unicast;
+
+ // if there is a server running which is not "from" stop it.
+ if (_streamingSource != NULL && _streamingSource != from)
+ _streamingSource->stopVncServer();
+ _streamingSource = from;
+
// Projection source is never allowed to be an active VNC viewer
if (from->isActiveVncClient())
from->stopVncClient();
@@ -484,6 +490,13 @@ void MainWindow::unicast(Client *from, Client *to, bool blockOthers)
to->setBroadcastSource(false);
to->setDesiredProjectionSource(from->id());
+ if (blockOthers) {
+ // Set lock others
+ for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
+ if ((*it)->client() != NULL && (*it)->client() != from && (*it)->client() != to)
+ (*it)->client()->lockScreen(true);
+ }
+
if (from->isActiveVncServer()) // From is already active
this->onVncServerStateChange(from);
else // Could not take shortcut, (re)start VNC server on source
@@ -601,6 +614,8 @@ void MainWindow::onButtonStudentToTutorExclusive()
*/
void MainWindow::onButtonStopProjection()
{
+ _state = State::Idle;
+
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
{
Client *c = (**it).client();
@@ -809,16 +824,17 @@ void MainWindow::onClientAuthenticated(Client* client)
if (ui->action_Lock->isChecked())
client->lockScreen(true);
- // Same for VNC projections
- for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
- {
- Client *c = (**it).client();
- if (c != NULL && c != client && c->isActiveVncServer() && c->isBroadcastSource())
- {
- client->startVncClient(c);
- client->setDesiredProjectionSource(c->id());
- break;
- }
+ switch (_state) {
+ case State::Idle:break;
+ case State::Unicast:break;
+ case State::ExclusiveUnicast:
+ client->lockScreen(true);
+ break;
+ case State::Broadcast:
+ client->setDesiredProjectionSource(_streamingSource->id());
+ client->startVncClient(_streamingSource);
+ break;
+ default:break;
}
}
diff --git a/src/server/mainwindow/mainwindow.h b/src/server/mainwindow/mainwindow.h
index 4f40a67..b246265 100644
--- a/src/server/mainwindow/mainwindow.h
+++ b/src/server/mainwindow/mainwindow.h
@@ -30,10 +30,11 @@ public:
~MainWindow();
private:
+
// Ui stuff
Ui::MainWindow *ui;
SessionNameWindow *_sessionNameWindow;
- HelpWindow *_helpWindow;
+ HelpWindow *_helpWindow;
QLabel *_sessionNameLabel;
int _tbIconSize;
Qt::ToolBarArea _tbArea;
@@ -48,11 +49,20 @@ private:
static const qint64 _buttonBlockTime = 600;
// Internal stuff
+ enum class State {
+ Idle,
+ Unicast,
+ ExclusiveUnicast,
+ Broadcast
+ } _state;
+
+ Client * _streamingSource;
+
QList<ConnectionFrame*> _clientFrames;
- ListenServer *_listenServer;
- DiscoveryListener *_discoveryListener;
- FileDownloader _fileDownloader;
- QStringList _tutorList;
+ ListenServer *_listenServer;
+ DiscoveryListener *_discoveryListener;
+ FileDownloader _fileDownloader;
+ QStringList _tutorList;
static const QString sStrTutorNdef;
static const QString sStrTutorOffline;
@@ -80,15 +90,18 @@ protected slots:
void onTutorListDownloaded(QByteArray& tutorList);
void onSessionNameClick();
void onSessionNameUpdate();
+
+ void onButtonLock(bool checked);
void onButtonStudentToAll();
void onButtonStudentToTutor();
void onButtonStudentToTutorExclusive();
void onButtonTutorToAll();
void onButtonTutorToStudent();
void onButtonStopProjection();
- void onButtonLock(bool checked);
- void onButtonExit();
+
void onButtonSetAsTutor();
+
+ void onButtonExit();
void onButtonHelp();
void DisableButtons();
void EnableButtons();