summaryrefslogtreecommitdiffstats
path: root/src/server/mainwindow
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/mainwindow')
-rw-r--r--src/server/mainwindow/mainwindow.cpp79
-rw-r--r--src/server/mainwindow/mainwindow.h6
2 files changed, 32 insertions, 53 deletions
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp
index 11071f6..5fdf3db 100644
--- a/src/server/mainwindow/mainwindow.cpp
+++ b/src/server/mainwindow/mainwindow.cpp
@@ -56,7 +56,7 @@ MainWindow::MainWindow(QString ipListUrl, QWidget* parent) :
_tutorFrame = NULL;
_selectedFrame = NULL;
- _mode = Mode::Idle;
+ _mode = Mode::Multicast;
_streamingSource = NULL;
_sessionNameWindow = new SessionNameWindow(this);
@@ -434,56 +434,37 @@ bool MainWindow::isValidClient(Client* client)
return false;
}
-
/***************************************************************************//**
- * @brief broadcast
- * @param from
- */
-void MainWindow::broadcast(Client *from)
-{
- _mode = Mode::Broadcast;
-
- // if there is a server running which is not "from" stop it.
- if (_streamingSource != NULL && _streamingSource != from)
- _streamingSource->stopVncServer();
- _streamingSource = from;
-
- // Server must not listen to anybody
- _streamingSource->stopVncClient();
-
- // 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() != _streamingSource)
- _watchers.insert((*it)->client()->id(), (*it)->client());
-
- if (_streamingSource->isActiveVncServer())
- // From is already active
- this->onVncServerStateChange(_streamingSource);
- else
- // Could not take shortcut, start VNC server on source
- _streamingSource->startVncServer();
-}
-
-
-/***************************************************************************//**
- * @brief MainWindow::unicast
+ * @brief MainWindow::changeProjection
* @param from
+ * @param mode
* @param to
- * @param blockOthers
*/
-void MainWindow::multicast(Client *from, Client *to, bool blockOthers)
+void MainWindow::changeProjection(Client *from, Mode mode, Client *to)
{
- // If first call in this mode clear the watchers
- if (_mode != (blockOthers ? Mode::LockedMulticast : Mode::Multicast)) {
- _watchers.clear();
- _mode = blockOthers ? Mode::LockedMulticast : Mode::Multicast;
+ if (mode == Mode::Broadcast)
+ {
+ // Set all clients as watchers
+ for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
+ if ((*it)->client() != NULL && (*it)->client() != _streamingSource)
+ _watchers.insert((*it)->client()->id(), (*it)->client());
+ }
+ else // mode != Mode::Broadcast
+ {
+ // If this is the first call in this mode clear the watchers
+ if ((mode == Mode::LockedMulticast && _mode != Mode::LockedMulticast)
+ || (mode == Mode::Multicast && _mode != Mode::Multicast))
+ _watchers.clear();
+
+ // If "to" already watches "from" stop it
+ if (_watchers.contains(to->id()))
+ _watchers.remove(to->id());
+ else // list "to" as watcher
+ _watchers.insert(to->id(), to);
}
- // If already watching drop it
- if (_watchers.contains(to->id()))
- _watchers.remove(to->id());
- else // List "to" as watcher
- _watchers.insert(to->id(), to);
+ // Set the mode
+ _mode = mode;
// if there is a server running which is not "from" stop it.
if (_streamingSource != NULL && _streamingSource != from)
@@ -519,7 +500,7 @@ void MainWindow::onButtonTutorToAll()
else if (_tutorFrame->client() == NULL)
QMessageBox::critical(this, tr("Projection"), sStrTutorOffline);
else
- broadcast(_tutorFrame->client());
+ changeProjection(_tutorFrame->client(), Mode::Broadcast);
}
/***************************************************************************//**
@@ -534,7 +515,7 @@ void MainWindow::onButtonStudentToAll()
if (_selectedFrame->client() == NULL)
QMessageBox::critical(this, tr("Projection"), sStrSourceOffline);
else
- broadcast(_selectedFrame->client());
+ changeProjection(_selectedFrame->client(), Mode::Broadcast);
}
/***************************************************************************//**
@@ -554,7 +535,7 @@ void MainWindow::onButtonTutorToStudent()
else if (_tutorFrame->client() == NULL)
QMessageBox::critical(this, tr("Projection"), sStrTutorOffline);
else
- multicast(_tutorFrame->client(), _selectedFrame->client());
+ changeProjection(_tutorFrame->client(), Mode::Multicast, _selectedFrame->client());
}
/***************************************************************************//**
@@ -574,7 +555,7 @@ void MainWindow::onButtonStudentToTutor()
else if (_tutorFrame->client() == NULL)
QMessageBox::critical(this, tr("Projection"), sStrTutorOffline);
else
- multicast(_selectedFrame->client(), _tutorFrame->client());
+ changeProjection(_selectedFrame->client(), Mode::Multicast, _tutorFrame->client());
}
@@ -594,7 +575,7 @@ void MainWindow::onButtonStudentToTutorExclusive()
else if (_tutorFrame->client() == NULL)
QMessageBox::critical(this, tr("Projection"), sStrTutorOffline);
else
- multicast(_tutorFrame->client(), _selectedFrame->client(), true);
+ changeProjection(_tutorFrame->client(), Mode::LockedMulticast, _selectedFrame->client());
}
diff --git a/src/server/mainwindow/mainwindow.h b/src/server/mainwindow/mainwindow.h
index 97d9dc3..6245155 100644
--- a/src/server/mainwindow/mainwindow.h
+++ b/src/server/mainwindow/mainwindow.h
@@ -48,9 +48,8 @@ private:
QList<QAction*> _lockingButtons;
static const qint64 _buttonBlockTime = 600;
- // Internal stuff
+ // Management stuff
enum class Mode {
- Idle,
Broadcast,
Multicast,
LockedMulticast
@@ -77,8 +76,7 @@ private:
bool loadPosition(QSettings& settings, const QString& id, int& x, int& y);
void savePosition(ConnectionFrame *cf);
bool isValidClient(Client* client);
- void broadcast(Client *from);
- void multicast(Client *from, Client *to, bool blockOthers = false);
+ void changeProjection(Client *from, Mode mode = Mode::Broadcast, Client *to = NULL);
void closeEvent(QCloseEvent *e);
void changeEvent(QEvent *e);