summaryrefslogtreecommitdiffstats
path: root/src/server
diff options
context:
space:
mode:
authorSimon Rettberg2018-07-24 13:08:25 +0200
committerSimon Rettberg2018-07-24 13:08:25 +0200
commit9ba63d1460db41c219b638212b42476164fcfdff (patch)
tree55e3249c18c50ec8e90278e639732988845c990c /src/server
parent[server] Fix logic error (diff)
downloadpvs2-9ba63d1460db41c219b638212b42476164fcfdff.tar.gz
pvs2-9ba63d1460db41c219b638212b42476164fcfdff.tar.xz
pvs2-9ba63d1460db41c219b638212b42476164fcfdff.zip
Update code style, fix compiler warnings
- Use nullptr instead of NULL for better warnings in case of mistakes - Get rid of VLAs which are not in C++11 actually - Fix implicit signed <-> unsigned mismatches by adding checks and casts
Diffstat (limited to 'src/server')
-rw-r--r--src/server/connectionframe/connectionframe.cpp24
-rw-r--r--src/server/connectionframe/connectionframe.h2
-rw-r--r--src/server/mainwindow/mainwindow.cpp137
-rw-r--r--src/server/mainwindow/mainwindow.h6
-rw-r--r--src/server/net/certmanager.cpp2
-rw-r--r--src/server/net/client.cpp2
-rw-r--r--src/server/net/listenserver.cpp2
-rw-r--r--src/server/net/sslserver.cpp10
-rw-r--r--src/server/serverapp/serverapp.cpp6
-rw-r--r--src/server/util/platform/screensaver.cpp6
10 files changed, 100 insertions, 97 deletions
diff --git a/src/server/connectionframe/connectionframe.cpp b/src/server/connectionframe/connectionframe.cpp
index 875e031..e8d8349 100644
--- a/src/server/connectionframe/connectionframe.cpp
+++ b/src/server/connectionframe/connectionframe.cpp
@@ -58,7 +58,7 @@ static QString style_disconnected(
QGroupBox { background-color: #7F7F7F; margin: 1px; border-radius: 4px}"
);
-static QIcon *term = NULL, *cam = NULL, *eye = NULL, *lock = NULL;
+static QIcon *term = nullptr, *cam = nullptr, *eye = nullptr, *lock = nullptr;
bool ConnectionFrame::paintDisabled = false;
@@ -69,13 +69,13 @@ bool ConnectionFrame::paintDisabled = false;
* @param height
*/
ConnectionFrame::ConnectionFrame(MainWindow* main, QWidget *parent, bool fromRoomplan) :
- QGroupBox(parent), _client(NULL), _timerId(0), _timerCounter(0), _isSelected(false), _isTutor(false),
+ QGroupBox(parent), _client(nullptr), _timerId(0), _timerCounter(0), _isSelected(false), _isTutor(false),
_isFromRoomplan(fromRoomplan), _mainWindow(main)
{
//defines the ui-stuff
// load icons first
- if (term == NULL) {
+ if (term == nullptr) {
term = new QIcon(":terminal");
cam = new QIcon(":cf_cam");
eye = new QIcon(":cf_eye");
@@ -88,7 +88,7 @@ ConnectionFrame::ConnectionFrame(MainWindow* main, QWidget *parent, bool fromRoo
_mainLayout->setAlignment(Qt::AlignHCenter);
this->setStyleSheet(style_student);
- _iconLayout = new QBoxLayout(QBoxLayout::RightToLeft, NULL);
+ _iconLayout = new QBoxLayout(QBoxLayout::RightToLeft, nullptr);
_iconLayout->setSpacing(1);
_iconLayout->setMargin(3);
@@ -124,7 +124,7 @@ ConnectionFrame::ConnectionFrame(MainWindow* main, QWidget *parent, bool fromRoo
ConnectionFrame::~ConnectionFrame()
{
- if (_client != NULL) {
+ if (_client != nullptr) {
_client->deleteLater();
}
_iconLayout->deleteLater();
@@ -145,7 +145,7 @@ void ConnectionFrame::updateGeometry()
{
const QRect rect = _mainWindow->calcFrameGeometry(this);
setGeometry(rect);
- if (this->_client == NULL)
+ if (this->_client == nullptr)
showDefaultThumb();
}
@@ -171,7 +171,7 @@ QLabel* ConnectionFrame::addIcon(const QIcon* icon)
*/
void ConnectionFrame::assignClient(Client* client)
{
- assert(_client == NULL);
+ assert(_client == nullptr);
connect( client, SIGNAL(disconnected()), this, SLOT(onClientDisconnected()) );
connect( client, SIGNAL(thumbUpdated(Client*, const QImage&)), this, SLOT(onThumbUpdated(Client*, const QImage&)) );
connect( client, SIGNAL(vncServerStateChange(Client*)), this, SLOT(updateAppearance()));
@@ -206,7 +206,7 @@ void ConnectionFrame::calcDesiredThumbSize(const QSize &frameSize)
void ConnectionFrame::updateLabels()
{
_lblHostName->setText(_computerId);
- if (_client == NULL) {
+ if (_client == nullptr) {
_lblUserName->setText(QString());
_lblUserName->hide();
} else {
@@ -331,7 +331,7 @@ void ConnectionFrame::paintEvent(QPaintEvent *event)
*/
void ConnectionFrame::timerEvent(QTimerEvent* /* event */ )
{
- if (_client == NULL)
+ if (_client == nullptr)
return;
++_timerCounter;
if (_client->isActiveVncServer() && _timerCounter % 5 != 0)
@@ -357,7 +357,7 @@ void ConnectionFrame::setSelection(bool selected)
*/
void ConnectionFrame::setTutor(bool b)
{
- if (_isTutor != b && _client != NULL)
+ if (_isTutor != b && _client != nullptr)
_client->setTutor(b);
_isTutor = b;
this->updateAppearance();
@@ -369,7 +369,7 @@ void ConnectionFrame::setTutor(bool b)
*/
void ConnectionFrame::updateAppearance()
{
- if (_client == NULL) {
+ if (_client == nullptr) {
// Unconnected Frame
if (_isSelected) {
this->setStyleSheet(style_selectedStudent);
@@ -426,7 +426,7 @@ void ConnectionFrame::onClientDisconnected()
killTimer(_timerId);
_timerId = 0;
}
- _client = NULL;
+ _client = nullptr;
updateLabels();
updateAppearance();
showDefaultThumb();
diff --git a/src/server/connectionframe/connectionframe.h b/src/server/connectionframe/connectionframe.h
index 898d97a..ba5f235 100644
--- a/src/server/connectionframe/connectionframe.h
+++ b/src/server/connectionframe/connectionframe.h
@@ -66,7 +66,7 @@ public:
inline bool isSelected() { return _isSelected; }
const QString& computerId() const { return _computerId; }
- void setComputerId(QString computerId) { if (_client != NULL) return; _computerId = computerId; updateLabels(); }
+ void setComputerId(QString computerId) { if (_client != nullptr) return; _computerId = computerId; updateLabels(); }
Client* client() const { return _client; }
inline bool isTutor() { return _isTutor; }
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp
index 5daade4..dcf8973 100644
--- a/src/server/mainwindow/mainwindow.cpp
+++ b/src/server/mainwindow/mainwindow.cpp
@@ -190,7 +190,7 @@ void MainWindow::clientCountChanged()
for (auto it = _clientFrames.begin(); it != _clientFrames.end(); ++it) {
Client* c = (*it)->client();
- if (c != NULL) {
+ if (c != nullptr) {
bool b = c->isExamMode();
examClientCount += b ? 1 : 0;
clientCount++;
@@ -262,7 +262,7 @@ int distance(QPointF a, QPointF b)
QPoint MainWindow::closestFreeSlot(QPoint preferredPixels, ConnectionFrame* toIgnore)
{
const bool pickFirstOne = ( preferredPixels == QPoint(-1, -1) );
- if (!pickFirstOne && toIgnore != NULL) {
+ if (!pickFirstOne && toIgnore != nullptr) {
// Check if we're already in the desired location and skip all the checks
QPoint desired = QPoint(preferredPixels.x() / getTileWidthPx(), preferredPixels.y() / getTileHeightPx());
if (desired == toIgnore->getGridPosition()) {
@@ -270,8 +270,9 @@ QPoint MainWindow::closestFreeSlot(QPoint preferredPixels, ConnectionFrame* toIg
}
}
const QSize& clientSize = serverApp->getCurrentRoom()->clientSize;
- bool grid[_tilesX][_tilesY];
- memset(grid, 0, sizeof(bool) * _tilesX * _tilesY); /* set everything to false */
+#define GRID(X,Y) (grid[X * _tilesX + Y])
+ bool *grid = new bool[_tilesX * _tilesY];
+ memset(grid, 0, sizeof(bool) * size_t(_tilesX * _tilesY)); /* set everything to false */
/* fill grid */
for (auto it = _clientFrames.begin(); it != _clientFrames.end(); ++it) {
@@ -282,7 +283,7 @@ QPoint MainWindow::closestFreeSlot(QPoint preferredPixels, ConnectionFrame* toIg
for (int x = p.x(); x < p.x() + clientSize.width(); x++) {
for (int y = p.y(); y < p.y() + clientSize.height(); y++) {
- grid[x][y] = true;
+ GRID(x, y) = true;
}
}
}
@@ -295,7 +296,7 @@ QPoint MainWindow::closestFreeSlot(QPoint preferredPixels, ConnectionFrame* toIg
bool isFree = true;
for (int dx = 0; dx < clientSize.width(); dx++) {
for (int dy = 0; dy < clientSize.height(); dy++) {
- if (grid[x + dx][y + dy]) {
+ if (GRID(x + dx, y + dy)) {
isFree = false;
goto endLoop; // double-break
}
@@ -311,6 +312,8 @@ endLoop: ;
}
}
endSearch: ;
+#undef GRID
+ delete[] grid;
/* among all the free positions, find the closest */
int min_distance = 1000000;
QPoint bestPosition = QPoint(0, 0);
@@ -342,7 +345,7 @@ void MainWindow::placeFrameInFreeSlot(ConnectionFrame* frame, QPoint preferredPi
ConnectionFrame* MainWindow::createFrame(const QString &computerId, const QPoint* gridPosition, bool fromRoomplan)
{
ConnectionFrame *cf = new ConnectionFrame(this, ui->frmRoom, fromRoomplan);
- if (gridPosition == NULL) {
+ if (gridPosition == nullptr) {
placeFrameInFreeSlot(cf);
} else {
cf->setGridPosition(*gridPosition);
@@ -378,47 +381,47 @@ void MainWindow::tellClientCurrentSituation(Client* client)
* Returns connected client which belongs to given id.
* Iterating over ConnectionFrames and comparing id to given id.
* @param id
- * @return Client with given id, if not NULL.
+ * @return Client with given id, if not nullptr.
*/
Client* MainWindow::getClientFromId(int id)
{
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) {
- if ((*it)->client() != NULL) {
+ if ((*it)->client() != nullptr) {
if ((*it)->client()->id() == id)
return (*it)->client();
}
}
- return NULL;
+ return nullptr;
}
/***************************************************************************//**
* Return the Frame, which is currently beeing Tutor.
* Iterating over all ConnectionFrames, and looking for flag _isTutor.
* @return Frame with flag _isTutor = true,
- * else NULL if no Tutor is available.
+ * else nullptr if no Tutor is available.
*/
ConnectionFrame* MainWindow::getTutorFrame()
{
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) {
- if (((*it) != NULL) && ((*it)->isTutor()))
+ if (((*it) != nullptr) && ((*it)->isTutor()))
return (*it);
}
- return NULL;
+ return nullptr;
}
/***************************************************************************//**
* Return the Frame, which is currently selected by user.
* Iterating over all ConnectionFrame and looking for flag _isSelected.
* @return Frame with flag _isSelected = true,
- * else NULL if no frame is selected.
+ * else nullptr if no frame is selected.
*/
ConnectionFrame* MainWindow::getSelectedFrame()
{
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) {
- if (((*it) != NULL) && ((*it)->isSelected()))
+ if (((*it) != nullptr) && ((*it)->isSelected()))
return (*it);
}
- return NULL;
+ return nullptr;
}
/*
@@ -527,7 +530,7 @@ void MainWindow::resizeEvent(QResizeEvent* /* e */ )
}
/* update background image label */
- if (_backgroundImage != NULL) {
+ if (_backgroundImage != nullptr) {
int w = ui->frmRoom->width() - 5; /* to make sure that we don't enlarge the window */
int h = ui->frmRoom->height() - 5;
ui->imageLabel->hide();
@@ -553,10 +556,10 @@ void MainWindow::unlockContextButtons()
(*it)->setEnabled(true);
}
/* and disable some again based on special rules */
- if (getSelectedFrame()->client() != NULL) {
+ if (getSelectedFrame()->client() != nullptr) {
ui->action_DeleteClient->setEnabled(false);
}
- if (getSelectedFrame()->client() == NULL) {
+ if (getSelectedFrame()->client() == nullptr) {
ui->action_SetAsTutor->setEnabled(false);
ui->action_StudentToTutorExclusive->setEnabled(false);
ui->action_StudentToTutor->setEnabled(false);
@@ -583,7 +586,7 @@ void MainWindow::mouseReleaseEvent(QMouseEvent* e)
const QSize frame(ui->frmRoom->size());
if (frame.width() > pos.x() && frame.height() > pos.y()) {
lockContextButtons();
- if (getSelectedFrame() != NULL) {
+ if (getSelectedFrame() != nullptr) {
getSelectedFrame()->setSelection(false);
}
}
@@ -598,13 +601,13 @@ void MainWindow::reset(bool lock)
// Unlock all clients
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
- if ((*it)->client() != NULL) {
+ if ((*it)->client() != nullptr) {
(*it)->client()->lockScreen(lock);
(*it)->client()->removeAttention();
}
// Stop server (Clients get stopped on ACK)
- if (getClientFromId(_streamingSource) != NULL)
+ if (getClientFromId(_streamingSource) != nullptr)
getClientFromId(_streamingSource)->stopVncServer();
}
@@ -623,7 +626,7 @@ void MainWindow::onPlaceFrame(ConnectionFrame* connectionFrame)
const QPoint preferredPixels = connectionFrame->pos();
placeFrameInFreeSlot(connectionFrame, preferredPixels);
- //resizeEvent(NULL);
+ //resizeEvent(nullptr);
}
/***************************************************************************//**
@@ -638,7 +641,7 @@ void MainWindow::onFrameClicked(ConnectionFrame* frame)
// If another frame has been selected, unselect it
// Set the ui selected and set a new reference
- if (getSelectedFrame() != NULL) {
+ if (getSelectedFrame() != nullptr) {
getSelectedFrame()->setSelection(false);
}
frame->setSelection(true);
@@ -698,14 +701,14 @@ void MainWindow::startVncServerIfNecessary(int from)
Client* ns = getClientFromId(from);
// if there is a server running which is not "from" stop it.
- if (os != NULL && _streamingSource != from)
+ if (os != nullptr && _streamingSource != from)
os->stopVncServer();
// Set new streaming source
_streamingSource = from;
// If streaming source is already active avoid a restart
- if (ns != NULL) {
+ if (ns != nullptr) {
if (ns->isActiveVncServer()) {
this->onVncServerStateChange(ns);
} else { // Could not take shortcut, (re)start VNC server on source
@@ -737,11 +740,11 @@ void MainWindow::onReloadRoomCancel()
void MainWindow::reloadCurrentRoom()
{
/* delete old image */
- if (_backgroundImage != NULL) {delete _backgroundImage; }
- _backgroundImage = NULL;
+ if (_backgroundImage != nullptr) {delete _backgroundImage; }
+ _backgroundImage = nullptr;
const Room *room = serverApp->getCurrentRoom();
- if (room != NULL) {
+ if (room != nullptr) {
/* set tiles */
_tilesX = room->gridSize.width();
_tilesY = room->gridSize.height();
@@ -756,7 +759,7 @@ void MainWindow::reloadCurrentRoom()
onPlaceFrame(cf);
if (computerId == room->tutorIP) {
qDebug() << "set computer with id " << computerId << " as tutor per configuration";
- if (getTutorFrame() != NULL) {
+ if (getTutorFrame() != nullptr) {
getTutorFrame()->setTutor(false);
}
cf->setTutor(true);
@@ -785,12 +788,12 @@ void MainWindow::reloadCurrentRoom()
}
/* and force a resize event (this scales the image) */
- resizeEvent(NULL);
+ resizeEvent(nullptr);
}
void MainWindow::onReloadRoomOk()
{
- if (_reloadWindow->ui->roomList->currentItem() == NULL) {
+ if (_reloadWindow->ui->roomList->currentItem() == nullptr) {
QMessageBox::critical(this, "Warning", tr("No item selected, please select room!"), 0, 1);
return;
}
@@ -855,9 +858,9 @@ void MainWindow::onButtonTutorToAll()
{
ui->action_Lock->setChecked(false);
- if (getTutorFrame() == NULL)
+ if (getTutorFrame() == nullptr)
QMessageBox::critical(this, tr("Projection"), sStrTutorNdef);
- else if (getTutorFrame()->client() == NULL)
+ else if (getTutorFrame()->client() == nullptr)
QMessageBox::critical(this, tr("Projection"), sStrTutorOffline);
else if (_clientFrames.size() == 1)
QMessageBox::critical(this, tr("Projection"), sStrNoDestAv);
@@ -870,7 +873,7 @@ void MainWindow::onButtonTutorToAll()
// Set all clients as watchers of tutor. Except for the tutors desired source, which hase to be none
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
- if ((*it)->client() != NULL)
+ if ((*it)->client() != nullptr)
(*it)->client()->setDesiredProjectionSource((*it)->client() == getTutorFrame()->client() ? NO_SOURCE : getTutorFrame()->client()->id());
disableButtons();
@@ -887,21 +890,21 @@ void MainWindow::onButtonTutorToStudent()
{
ui->action_Lock->setChecked(false);
- if (getSelectedFrame() == NULL)
+ if (getSelectedFrame() == nullptr)
QMessageBox::critical(this, tr("Projection"), sStrDestNdef);
- else if (getTutorFrame() == NULL)
+ else if (getTutorFrame() == nullptr)
QMessageBox::critical(this, tr("Projection"), sStrTutorNdef);
else if (getSelectedFrame() == getTutorFrame())
QMessageBox::critical(this, tr("Projection"), sStrSourceDestSame);
- else if (getSelectedFrame()->client() == NULL)
+ else if (getSelectedFrame()->client() == nullptr)
QMessageBox::critical(this, tr("Projection"), sStrDestOffline);
- else if (getTutorFrame()->client() == NULL)
+ else if (getTutorFrame()->client() == nullptr)
QMessageBox::critical(this, tr("Projection"), sStrTutorOffline);
else {
// If this is the first call in this mode clear the watchers
if (_mode != Mode::Multicast) {
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
- if ((*it)->client() != NULL)
+ if ((*it)->client() != nullptr)
(*it)->client()->setDesiredProjectionSource(NO_SOURCE);
}
@@ -925,15 +928,15 @@ void MainWindow::onButtonStudentToTutor()
{
ui->action_Lock->setChecked(false);
- if (getSelectedFrame() == NULL)
+ if (getSelectedFrame() == nullptr)
QMessageBox::critical(this, tr("Projection"), sStrSourceNdef);
- else if (getTutorFrame() == NULL)
+ else if (getTutorFrame() == nullptr)
QMessageBox::critical(this, tr("Projection"), sStrTutorNdef);
else if (getTutorFrame() == getSelectedFrame())
QMessageBox::critical(this, tr("Projection"), sStrSourceDestSame);
- else if (getSelectedFrame()->client() == NULL)
+ else if (getSelectedFrame()->client() == nullptr)
QMessageBox::critical(this, tr("Projection"), sStrSourceOffline);
- else if (getTutorFrame()->client() == NULL)
+ else if (getTutorFrame()->client() == nullptr)
QMessageBox::critical(this, tr("Projection"), sStrTutorOffline);
else {
// If this is not the first run in this mode and the current source is selected, stop the streaming.
@@ -946,7 +949,7 @@ void MainWindow::onButtonStudentToTutor()
// Unset all clients desired sources. Except the tutors desired source, this has to be the selecteds frame
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
- if ((*it)->client() != NULL)
+ if ((*it)->client() != nullptr)
(*it)->client()->setDesiredProjectionSource(getTutorFrame()->client()->id() == (*it)->client()->id() ? getSelectedFrame()->client()->id() : NO_SOURCE);
disableButtons();
@@ -963,15 +966,15 @@ void MainWindow::onButtonStudentToTutorExclusive()
{
ui->action_Lock->setChecked(false);
- if (getSelectedFrame() == NULL)
+ if (getSelectedFrame() == nullptr)
QMessageBox::critical(this, tr("Projection"), sStrSourceNdef);
- else if (getTutorFrame() == NULL)
+ else if (getTutorFrame() == nullptr)
QMessageBox::critical(this, tr("Projection"), sStrTutorNdef);
else if (getTutorFrame() == getSelectedFrame())
QMessageBox::critical(this, tr("Projection"), sStrSourceDestSame);
- else if (getSelectedFrame()->client() == NULL)
+ else if (getSelectedFrame()->client() == nullptr)
QMessageBox::critical(this, tr("Projection"), sStrSourceOffline);
- else if (getTutorFrame()->client() == NULL)
+ else if (getTutorFrame()->client() == nullptr)
QMessageBox::critical(this, tr("Projection"), sStrTutorOffline);
else {
Client *selectedClient = getSelectedFrame()->client();
@@ -986,7 +989,7 @@ void MainWindow::onButtonStudentToTutorExclusive()
// Unset all clients desired sources. Except the tutors desired source, this has to be the selecteds frame
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
- if ((*it)->client() != NULL)
+ if ((*it)->client() != nullptr)
(*it)->client()->setDesiredProjectionSource(tutorClient->id() == (*it)->client()->id() ? selectedClient->id() : NO_SOURCE);
disableButtons();
@@ -1022,14 +1025,14 @@ void MainWindow::onButtonLock(bool checked)
void MainWindow::onButtonLockSingle()
{
// If no frame is selected, warning.
- if (getSelectedFrame() == NULL) {
+ if (getSelectedFrame() == nullptr) {
QMessageBox::critical(this, tr("Selection"), tr("No client is selected."));
return;
}
Client *client = getSelectedFrame()->client();
// If frame of inactive client has been selected unselect it
- if (client == NULL) {
+ if (client == nullptr) {
QMessageBox::critical(this, tr("Selection"), tr("The selected client is not connected."));
return;
} else { // If selected client is locked, first unlock
@@ -1038,7 +1041,7 @@ void MainWindow::onButtonLockSingle()
if (!newState) {
// If no more clients are locked, reset button
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) {
- if ((*it)->client() == NULL)
+ if ((*it)->client() == nullptr)
continue;
if ((*it)->client()->isLocked())
return;
@@ -1063,13 +1066,13 @@ void MainWindow::onButtonExit()
void MainWindow::onButtonSetAsTutor()
{
// If no frame is selected, warning.
- if (getSelectedFrame() == NULL) {
+ if (getSelectedFrame() == nullptr) {
QMessageBox::critical(this, tr("Selection"), tr("No client is selected."));
return;
}
// If frame of inactive client has been selected unselect it
- if (getSelectedFrame()->client() == NULL) {
+ if (getSelectedFrame()->client() == nullptr) {
QMessageBox::critical(this, tr("Selection"), tr("The selected client is not connected."));
return;
} else { // If selected client is locked, first unlock
@@ -1081,7 +1084,7 @@ void MainWindow::onButtonSetAsTutor()
return;
// Else unset the old and set the new tutor
- if (getTutorFrame() != NULL) {
+ if (getTutorFrame() != nullptr) {
getTutorFrame()->setTutor(false);
}
getSelectedFrame()->setTutor(true);
@@ -1122,7 +1125,7 @@ void MainWindow::onClientAuthenticating(Client* client, ClientLogin* request)
inuse = false;
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) {
Client *c = (**it).client();
- if (c == NULL)
+ if (c == nullptr)
continue;
if (!c->isAuthed())
continue;
@@ -1158,8 +1161,8 @@ void MainWindow::onClientAuthenticated(Client* client)
disconnect(client, SIGNAL(authenticated(Client*)), this, SLOT(onClientAuthenticated(Client*)));
connect(client, SIGNAL(vncServerStateChange(Client*)), this, SLOT(onVncServerStateChange(Client*)));
connect(client, SIGNAL(vncClientStateChange(Client*)), this, SLOT(onVncClientStateChange(Client*)));
- ConnectionFrame *existing = NULL;
- ConnectionFrame *cf = NULL;
+ ConnectionFrame *existing = nullptr;
+ ConnectionFrame *cf = nullptr;
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) {
if ((*it)->computerId() == client->ip()) {
existing = *it;
@@ -1167,7 +1170,7 @@ void MainWindow::onClientAuthenticated(Client* client)
}
// Clients ip already exists, but was not active.
- if (existing != NULL) {
+ if (existing != nullptr) {
cf = existing;
} else {
cf = createFrame();
@@ -1193,7 +1196,7 @@ void MainWindow::onVncServerStateChange(Client* client)
if (client->isActiveVncServer()) {
// apply the desired projection sources
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
- if ( (*it)->client() != NULL) { // Ignore offline clients
+ if ( (*it)->client() != nullptr) { // Ignore offline clients
if ( (*it)->client()->desiredProjectionSource() == client->id() )
(*it)->client()->startVncClient(client);
else
@@ -1206,7 +1209,7 @@ void MainWindow::onVncServerStateChange(Client* client)
} else {
// VNC server stopped on some client or failed to start - reset local pending projection information
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) {
- if ((*it)->client() != NULL) {
+ if ((*it)->client() != nullptr) {
if ((*it)->client()->desiredProjectionSource() == client->id()) {
(*it)->client()->setDesiredProjectionSource(NO_SOURCE);
(*it)->client()->stopVncClient();
@@ -1234,7 +1237,7 @@ void MainWindow::onVncServerStateChange(Client* client)
*/
void MainWindow::onVncClientStateChange(Client* client)
{
- if (client != NULL) {
+ if (client != nullptr) {
// VNC Client stopped -> remove from watchers
if (!client->isActiveVncClient()) {
// Only unset a desired Projection source if it has not changed meanwhile
@@ -1252,7 +1255,7 @@ void MainWindow::onVncClientStateChange(Client* client)
*/
bool serverHasWatchers = false;
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
- if ((*it)->client() != NULL)
+ if ((*it)->client() != nullptr)
if ((*it)->client()->desiredProjectionSource() == client->projectionSource()) {
serverHasWatchers = true;
break;
@@ -1260,7 +1263,7 @@ void MainWindow::onVncClientStateChange(Client* client)
if ( !serverHasWatchers ) {
Client* c = getClientFromId(client->projectionSource());
- if (c != NULL)
+ if (c != nullptr)
c->stopVncServer();
}
}
@@ -1296,11 +1299,11 @@ void MainWindow::onDeleteClient()
{
// If no frame is selected, warning.
ConnectionFrame* frame = getSelectedFrame();
- if (frame == NULL) {
+ if (frame == nullptr) {
QMessageBox::critical(this, tr("Selection"), tr("No client is selected."));
return;
}
- if (frame->client() != NULL) {
+ if (frame->client() != nullptr) {
QMessageBox::critical(this, tr("Selection"), tr("This client is still connected."));
return;
}
diff --git a/src/server/mainwindow/mainwindow.h b/src/server/mainwindow/mainwindow.h
index 4e99747..43804a7 100644
--- a/src/server/mainwindow/mainwindow.h
+++ b/src/server/mainwindow/mainwindow.h
@@ -44,8 +44,8 @@ private:
Qt::ToolBarArea _tbArea;
int _tilesX;
int _tilesY;
- QImage* _backgroundImage = NULL;
- QLabel* _examModeLabel = NULL;
+ QImage* _backgroundImage = nullptr;
+ QLabel* _examModeLabel = nullptr;
/* virtual columns to preserve the aspect ratio of the loaded room */
@@ -79,7 +79,7 @@ private:
QPoint closestFreeSlot(QPoint preferredPixels, ConnectionFrame* toIgnore);
void placeFrameInFreeSlot(ConnectionFrame* frame, QPoint preferred = QPoint(-1, -1));
- ConnectionFrame* createFrame(const QString &computerId = QString(), const QPoint *gridPosition = NULL, bool fromRoomplan = false);
+ ConnectionFrame* createFrame(const QString &computerId = QString(), const QPoint *gridPosition = nullptr, bool fromRoomplan = false);
void savePosition(ConnectionFrame *cf);
void startVncServerIfNecessary(int from);
void tellClientCurrentSituation(Client* client);
diff --git a/src/server/net/certmanager.cpp b/src/server/net/certmanager.cpp
index a7df6cc..a503088 100644
--- a/src/server/net/certmanager.cpp
+++ b/src/server/net/certmanager.cpp
@@ -66,7 +66,7 @@ bool getPrivateKeyAndCert(const QString &name, QSslKey &key, QSslCertificate &ce
void fatal()
{
- QMessageBox::critical(NULL, QCoreApplication::trUtf8("OpenSSL error", "CertManager"),
+ QMessageBox::critical(nullptr, QCoreApplication::trUtf8("OpenSSL error", "CertManager"),
QCoreApplication::trUtf8("Could not generate certificates for secure connections.\n"
"PVS will not work.\n\n"
"Press OK to quit.", "CertManager"));
diff --git a/src/server/net/client.cpp b/src/server/net/client.cpp
index c11cb63..9e96dec 100644
--- a/src/server/net/client.cpp
+++ b/src/server/net/client.cpp
@@ -19,7 +19,7 @@ int Client::_clientIdCounter = 0;
/******************************************************************************/
Client::Client(QTcpSocket* socket) : _socket(socket)
{
- assert(socket != NULL);
+ assert(socket != nullptr);
_authed = 0;
_projectionSource = 0;
_desiredSource = 0;
diff --git a/src/server/net/listenserver.cpp b/src/server/net/listenserver.cpp
index 0a585c7..628b62d 100644
--- a/src/server/net/listenserver.cpp
+++ b/src/server/net/listenserver.cpp
@@ -31,7 +31,7 @@ ListenServer::~ListenServer()
void ListenServer::newClientConnection()
{
QTcpSocket* sock;
- while ((sock = _server.nextPendingConnection()) != NULL) {
+ while ((sock = _server.nextPendingConnection()) != nullptr) {
Client* client = new Client(sock); // TODO: what happens with disconnected clients
emit newClient(client);
}
diff --git a/src/server/net/sslserver.cpp b/src/server/net/sslserver.cpp
index 0e0639e..c11f0ae 100644
--- a/src/server/net/sslserver.cpp
+++ b/src/server/net/sslserver.cpp
@@ -20,7 +20,7 @@
#include "certmanager.h"
#include <unistd.h>
-SslServer::SslServer() : QTcpServer(NULL)
+SslServer::SslServer() : QTcpServer(nullptr)
{
_tmr = startTimer(5123);
}
@@ -43,10 +43,10 @@ void SslServer::incomingConnection(qintptr socketDescriptor)
if (++certFails > 5) {
CertManager::fatal();
}
- ::close(socketDescriptor);
+ ::close((int)socketDescriptor);
return;
}
- QSslSocket *serverSocket = new QSslSocket(NULL);
+ QSslSocket *serverSocket = new QSslSocket(nullptr);
connect(serverSocket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(sslErrors(const QList<QSslError> &)));
connect(serverSocket, SIGNAL(disconnected()), this, SLOT(sock_closed()));
connect(serverSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(sock_error(QAbstractSocket::SocketError)));
@@ -70,7 +70,7 @@ void SslServer::incomingConnection(qintptr socketDescriptor)
}
}
-void SslServer::sslErrors(const QList<QSslError> &errors)
+void SslServer::sslErrors(const QList<QSslError>& /* errors */)
{
/*
qDebug() << "Client caused sslErrors before connection:";
@@ -134,6 +134,6 @@ QTcpSocket* SslServer::nextPendingConnection()
return sock;
}
}
- return NULL;
+ return nullptr;
}
diff --git a/src/server/serverapp/serverapp.cpp b/src/server/serverapp/serverapp.cpp
index 7ee06e0..f680f89 100644
--- a/src/server/serverapp/serverapp.cpp
+++ b/src/server/serverapp/serverapp.cpp
@@ -7,7 +7,7 @@ static QSize minimalGridSize(const QMap<QString, QPoint>& clientPositions, QSize
ServerApp::ServerApp(int& argc, char** argv)
: QApplication(argc, argv),
- _mainWindow(NULL),
+ _mainWindow(nullptr),
_managerOnly(false),
_isExam(false)
{
@@ -132,8 +132,8 @@ const Room* ServerApp::getCurrentRoom()
if (_rooms.contains(_currentRoom)) {
return _rooms[_currentRoom];
} else {
- static Room* defaultRoom = NULL;
- if (defaultRoom == NULL) {
+ static Room* defaultRoom = nullptr;
+ if (defaultRoom == nullptr) {
defaultRoom = new Room(QMap<QString,
QPoint>(), QSize(8, 6), QSize(1, 1), "", "");
}
diff --git a/src/server/util/platform/screensaver.cpp b/src/server/util/platform/screensaver.cpp
index efffba9..cdd6ee1 100644
--- a/src/server/util/platform/screensaver.cpp
+++ b/src/server/util/platform/screensaver.cpp
@@ -14,17 +14,17 @@
namespace {
- Display *display = NULL;
+ Display *display = nullptr;
bool extensionSupported = false;
bool dpmsSupported = false;
bool init()
{
- if (display != NULL) {
+ if (display != nullptr) {
return true;
}
display = QX11Info::display();
- if (display == NULL) {
+ if (display == nullptr) {
return false;
}
#ifdef X11_Xscreensaver_FOUND