summaryrefslogtreecommitdiffstats
path: root/src/server/mainwindow/mainwindow.cpp
diff options
context:
space:
mode:
authorBjörn Hagemeister2014-04-16 18:15:28 +0200
committerBjörn Hagemeister2014-04-16 18:15:28 +0200
commit6d6041f03cd0e70563f12d5332050588ad6858e7 (patch)
treec8777d1421062c15d99c804aa2aa56142822876b /src/server/mainwindow/mainwindow.cpp
parentChanged exit text to be "exit?" instead of "Beenden?". (diff)
downloadpvs2-6d6041f03cd0e70563f12d5332050588ad6858e7.tar.gz
pvs2-6d6041f03cd0e70563f12d5332050588ad6858e7.tar.xz
pvs2-6d6041f03cd0e70563f12d5332050588ad6858e7.zip
New feature. Download of tutor-ip-list and automated assingment.
TODO: Make source url configurable.
Diffstat (limited to 'src/server/mainwindow/mainwindow.cpp')
-rw-r--r--src/server/mainwindow/mainwindow.cpp45
1 files changed, 31 insertions, 14 deletions
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp
index 00ac706..b02cef8 100644
--- a/src/server/mainwindow/mainwindow.cpp
+++ b/src/server/mainwindow/mainwindow.cpp
@@ -27,6 +27,7 @@
#include "../net/client.h"
#include "../net/discoverylistener.h"
#include "../../shared/networkmessage.h"
+#include "../net/filedownloader.h"
// Others
#include "../../shared/settings.h"
#include "../util/util.h"
@@ -59,6 +60,10 @@ MainWindow::MainWindow(QWidget* parent) :
ui->action_Exit->setStatusTip(tr("Exit"));
ui->action_Lock->setStatusTip(tr("Lock or Unlock all Clients"));
+ // Initialize FileDownloader.
+ _fileDownloader.connectSlot(this, SLOT(onTutorListDownloaded(QByteArray&)));
+ _fileDownloader.downloadFile(QUrl("http://132.230.8.113/openslx/ips.txt"));
+
// Close button in tool bar
connect(ui->action_Exit, SIGNAL(triggered()), this, SLOT(onButtonExit()));
connect(ui->action_BroadcastScreen, SIGNAL(triggered()), this, SLOT(onButtonStudentToAll()));
@@ -287,6 +292,13 @@ void MainWindow::timerEvent(QTimerEvent* event)
* Slots
*/
+void MainWindow::onTutorListDownloaded(QByteArray& tutorList)
+{
+ // qDebug() << tutorList;
+ QString data = QString::fromUtf8(tutorList.constData(), tutorList.size());
+ _tutorList = data.split(QRegExp("[\r\n]"),QString::SkipEmptyParts);
+ qDebug() << _tutorList;
+}
void MainWindow::onPlaceFrame(ConnectionFrame* frame)
{
if (_tilesX <= 0 || _tilesY <= 0)
@@ -665,29 +677,35 @@ void MainWindow::onClientAuthenticated(Client* client)
connect(client, SIGNAL(vncServerStateChange(Client*)), this, SLOT(onVncServerStateChange(Client*)), Qt::QueuedConnection);
connect(client, SIGNAL(vncClientStateChange(Client*, int)), this, SLOT(onVncClientStateChange(Client*, int)), Qt::QueuedConnection);
bool hasActiveTutor = false;
- ConnectionFrame *deadTutor = NULL;
- bool anyClient = false;
ConnectionFrame *existing = NULL;
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
{
if ((*it)->computerId() == client->computerId())
existing = *it;
- if ((*it)->client() != NULL)
- anyClient = true;
if ((*it)->isTutor())
{
- if ((*it)->client() == NULL)
- deadTutor = *it;
- else
+ if ((*it)->client() != NULL)
hasActiveTutor = true;
}
}
- if (!anyClient && deadTutor != NULL)
- deadTutor->setTutor(false);
+
+ bool isTutor = false;
+ if (!hasActiveTutor)
+ {
+ for (int i = 0; i < _tutorList.size(); i++)
+ {
+ // Check if client is possible tutor
+ if (client->computerId()== _tutorList[i])
+ {
+ isTutor = true;
+ break;
+ }
+ }
+ }
+
if (existing != NULL)
{
- if (!anyClient && !hasActiveTutor)
- existing->setTutor(true);
+ existing->setTutor(isTutor);
existing->assignClient(client);
return;
}
@@ -720,9 +738,8 @@ void MainWindow::onClientAuthenticated(Client* client)
// Move to any free tile
placeFrameInFreeSlot(cf);
}
- // Make first active client tutor
- if (!anyClient && !hasActiveTutor)
- cf->setTutor(true);
+ // Set Tutor option
+ cf->setTutor(isTutor);
// Assign client instance
cf->assignClient(client);
// ################