From a2fd531c81ba0e895dff319b0597e45b4206273f Mon Sep 17 00:00:00 2001 From: Björn Hagemeister Date: Mon, 28 Apr 2014 19:35:59 +0200 Subject: Adding comments for each method in the .cpp files and class definition in the .h files. --- src/server/clicklabel/clicklabel.cpp | 9 ++ src/server/clicklabel/clicklabel.h | 4 +- src/server/connectionframe/connectionframe.cpp | 87 ++++++++++++++ src/server/connectionframe/connectionframe.h | 4 + src/server/mainwindow/mainwindow.cpp | 160 +++++++++++++++++++++++++ src/server/mainwindow/mainwindow.h | 16 +++ src/server/net/listenserver.cpp | 10 +- src/server/net/listenserver.h | 3 + src/server/net/sslserver.cpp | 4 + src/server/net/sslserver.h | 3 + 10 files changed, 298 insertions(+), 2 deletions(-) (limited to 'src/server') diff --git a/src/server/clicklabel/clicklabel.cpp b/src/server/clicklabel/clicklabel.cpp index 2989542..0e49f08 100644 --- a/src/server/clicklabel/clicklabel.cpp +++ b/src/server/clicklabel/clicklabel.cpp @@ -1,5 +1,9 @@ #include "clicklabel.h" +/** + * Initialize ClickLabel. + * @param parent + */ ClickLabel::ClickLabel(QWidget *parent) : QLabel(parent) { QFont f(this->font()); @@ -8,6 +12,11 @@ ClickLabel::ClickLabel(QWidget *parent) : QLabel(parent) this->setMaximumHeight(22); } +/** + * Handle mouse release event. + * Emit Signal clicked(). + * @param e + */ void ClickLabel::mouseReleaseEvent(QMouseEvent* e) { emit clicked(); diff --git a/src/server/clicklabel/clicklabel.h b/src/server/clicklabel/clicklabel.h index 6a05152..297f1dd 100644 --- a/src/server/clicklabel/clicklabel.h +++ b/src/server/clicklabel/clicklabel.h @@ -4,7 +4,9 @@ #include #include - +/** + * Class for clickable part on sessionName. + */ class ClickLabel : public QLabel { Q_OBJECT diff --git a/src/server/connectionframe/connectionframe.cpp b/src/server/connectionframe/connectionframe.cpp index 7d9376c..b5b754f 100644 --- a/src/server/connectionframe/connectionframe.cpp +++ b/src/server/connectionframe/connectionframe.cpp @@ -24,6 +24,12 @@ static QIcon *term = NULL, *cam = NULL, *eye = NULL; static QString backgroundStyle("background-color: %1; margin: 1px; border: 1px solid black; border-radius: 6px"); +/** + * Initialize frame for connected client. + * @param parent + * @param width + * @param height + */ ConnectionFrame::ConnectionFrame(QWidget *parent, int width, int height) : QGroupBox(parent), _client(NULL), _timerId(0), _timerCounter(0), _selected(false), _isTutor(false) { @@ -79,6 +85,11 @@ ConnectionFrame::~ConnectionFrame() // } +/** + * Add icon to connection frame. + * @param icon + * @return Pointer to new Icon. + */ QLabel* ConnectionFrame::addIcon(const QIcon* icon) { QLabel *label = new QLabel(this); @@ -89,11 +100,21 @@ QLabel* ConnectionFrame::addIcon(const QIcon* icon) return label; } +/** + * Set size of connectionFrame. + * @param width + * @param height + */ void ConnectionFrame::setSize(int width, int height) { this->resize(width, height); } +/** + * Assign client to connectionFrame. + * Set hostName, userName and tutor status to display. + * @param client + */ void ConnectionFrame::assignClient(Client* client) { assert(_client == NULL); @@ -117,6 +138,9 @@ void ConnectionFrame::assignClient(Client* client) _client->setTutor(_isTutor); } +/** + * Show default thumg instead of remote screen in connectionFrame. + */ void ConnectionFrame::showDefaultThumb() { const int width = this->width() - 6; @@ -126,6 +150,11 @@ void ConnectionFrame::showDefaultThumb() //_imgScreen->setPixmap(_remoteScreen); } +/** + * Handle mouse release event on frame. + * Check if frame was clicked or moved, if not moved enough, the event is handled as click. + * @param event + */ void ConnectionFrame::mouseReleaseEvent(QMouseEvent* event) { event->accept(); @@ -147,18 +176,30 @@ void ConnectionFrame::mouseReleaseEvent(QMouseEvent* event) } } +/** + * Handle if mouse reaches frame. + * @param event + */ void ConnectionFrame::enterEvent(QEvent* event) { QApplication::setOverrideCursor(QCursor(Qt::OpenHandCursor)); event->accept(); } +/** + * Handle mouse leaves frame. + * @param event + */ void ConnectionFrame::leaveEvent(QEvent* event) { QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor)); event->accept(); } +/** + * Handle mouse press on frame. + * @param event + */ void ConnectionFrame::mousePressEvent(QMouseEvent *event) { if (event->button() == Qt::RightButton) @@ -178,6 +219,10 @@ void ConnectionFrame::mousePressEvent(QMouseEvent *event) event->accept(); } +/** + * Hanle mouse movement over frame. + * @param event + */ void ConnectionFrame::mouseMoveEvent(QMouseEvent *event) { QApplication::setOverrideCursor(QCursor(Qt::ClosedHandCursor)); @@ -185,12 +230,20 @@ void ConnectionFrame::mouseMoveEvent(QMouseEvent *event) event->accept(); } +/** + * Handle double click event on frame. + * @param event + */ void ConnectionFrame::mouseDoubleClickEvent(QMouseEvent* event) { emit doubleClicked(this); event->accept(); } +/** + * Draw remote screen in frame. + * @param event + */ void ConnectionFrame::paintEvent(QPaintEvent *event) { QGroupBox::paintEvent(event); @@ -201,6 +254,10 @@ void ConnectionFrame::paintEvent(QPaintEvent *event) event->accept(); } +/** + * Handle timer event. + * @param event + */ void ConnectionFrame::timerEvent(QTimerEvent* event) { if (_client == NULL) @@ -213,6 +270,10 @@ void ConnectionFrame::timerEvent(QTimerEvent* event) _client->requestThumb(width, height); } +/** + * Set frame as selected or not. + * @param selected + */ void ConnectionFrame::setSelection(bool selected) { if (_selected == selected) @@ -221,6 +282,10 @@ void ConnectionFrame::setSelection(bool selected) this->updateAppearance(); } +/** + * Set tutor status of frame. + * @param b + */ void ConnectionFrame::setTutor(bool b) { if (_isTutor != b && _client != NULL) @@ -229,6 +294,10 @@ void ConnectionFrame::setTutor(bool b) this->updateAppearance(); } +/** + * Update appearence of frame. + * Check tutor status, vnc status and set background or icon. + */ void ConnectionFrame::updateAppearance() { if (_client == NULL) @@ -261,6 +330,10 @@ void ConnectionFrame::updateAppearance() * Slots */ +/** + * Handle if client was disconnected. + * Kill timer and set appearence to default. + */ void ConnectionFrame::onClientDisconnected() { if (_timerId != 0) @@ -274,6 +347,11 @@ void ConnectionFrame::onClientDisconnected() this->updateAppearance(); } +/** + * Update thumb of specific client. + * @param client + * @param thumb + */ void ConnectionFrame::onThumbUpdated(Client* client, const QPixmap& thumb) { assert(client == _client); @@ -282,11 +360,20 @@ void ConnectionFrame::onThumbUpdated(Client* client, const QPixmap& thumb) this->repaint(); } +/** + * Update appearence if vnc server state has changed. + * @param client + */ void ConnectionFrame::onVncServerStateChange(Client* client) { this->updateAppearance(); } +/** + * Update appearence if vnc client state has changed. + * @param client + * @param lastSource + */ void ConnectionFrame::onVncClientStateChange(Client* client, int lastSource) { this->updateAppearance(); diff --git a/src/server/connectionframe/connectionframe.h b/src/server/connectionframe/connectionframe.h index 367810c..764c212 100644 --- a/src/server/connectionframe/connectionframe.h +++ b/src/server/connectionframe/connectionframe.h @@ -3,6 +3,10 @@ #include #include "../net/client.h" +/** + * Class for representing the clients of current session, with a specific frame + * displaying username and hostname for each one. + */ class ConnectionFrame : public QGroupBox { diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index 6534179..3ed2b57 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -35,6 +35,11 @@ // Auto-generated ui class #include "ui_mainwindow.h" +/** + * Initialize MainWindow and ListenServer. + * @param ipListUrl + * @param parent + */ MainWindow::MainWindow(QString ipListUrl, QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow), _tbIconSize(24), _tbArea(Qt::LeftToolBarArea) { @@ -107,6 +112,11 @@ MainWindow::~MainWindow() delete ui; } +/** + * Place the frames at possible Position. + * If current position out of range, place frame into next free cell. + * @param frame + */ void MainWindow::placeFrameInFreeSlot(ConnectionFrame* frame) { // Get occupied cell of each frame and store status in an array @@ -155,6 +165,12 @@ void MainWindow::placeFrameInFreeSlot(ConnectionFrame* frame) } } +/** + * Create new Frame. + * Create new frame and add to current available frame list. + * Also connect signals frameMoved() and clicked() with slots. + * @return ConnectionFrame* + */ ConnectionFrame* MainWindow::createFrame() { // Allocate and resize @@ -166,6 +182,14 @@ ConnectionFrame* MainWindow::createFrame() return cf; } +/** + * Load position. + * @param settings + * @param id + * @param x + * @param y + * @return If loadPosition was successfull. + */ bool MainWindow::loadPosition(QSettings& settings, const QString& id, int& x, int& y) { settings.beginGroup("client_position"); @@ -179,6 +203,10 @@ bool MainWindow::loadPosition(QSettings& settings, const QString& id, int& x, in return true; } +/** + * Save position of given connectionFrame. + * @param cf + */ void MainWindow::savePosition(ConnectionFrame *cf) { Client *client = cf->client(); @@ -195,6 +223,11 @@ void MainWindow::savePosition(ConnectionFrame *cf) * Overridden methods */ +/** + * Handle closeEvent. + * If user calls closing MainWindow, close, else ignore. + * @param e + */ void MainWindow::closeEvent(QCloseEvent* e) { int ret = QMessageBox::question(this, "Test", "Exit?", 0, 1, 2); @@ -204,11 +237,19 @@ void MainWindow::closeEvent(QCloseEvent* e) e->ignore(); } +/** + * Change Event. + * @param e + */ void MainWindow::changeEvent(QEvent* e) { QMainWindow::changeEvent(e); } +/** + * Resize event. + * @param e + */ void MainWindow::resizeEvent(QResizeEvent* e) { QMainWindow::resizeEvent(e); @@ -219,6 +260,12 @@ void MainWindow::resizeEvent(QResizeEvent* e) _timerTimeout = 8; } +/** + * Handle Mouse Release Event. + * Check if click was inside the frame and if that is the case, set the selection of each connected + * client to false. + * @param e + */ void MainWindow::mouseReleaseEvent(QMouseEvent* e) { // Try to figure out if the user clicked inside the "room" frame @@ -237,6 +284,10 @@ void MainWindow::mouseReleaseEvent(QMouseEvent* e) } } +/** + * Handle Timer EventtimerEvent. + * @param event + */ void MainWindow::timerEvent(QTimerEvent* event) { if (event->timerId() == _timerId) @@ -293,6 +344,11 @@ void MainWindow::timerEvent(QTimerEvent* event) * Slots */ +/** + * Extract information from downloaded tutorList. + * Split downloaded file by new line and store ips in _tutorList. + * @param tutorList + */ void MainWindow::onTutorListDownloaded(QByteArray& tutorList) { // qDebug() << tutorList; @@ -300,6 +356,11 @@ void MainWindow::onTutorListDownloaded(QByteArray& tutorList) _tutorList = data.split(QRegExp("[\r\n]"),QString::SkipEmptyParts); qDebug() << _tutorList; } + +/** + * Place Frame to from user specified position. + * @param frame + */ void MainWindow::onPlaceFrame(ConnectionFrame* frame) { if (_tilesX <= 0 || _tilesY <= 0) @@ -331,6 +392,10 @@ void MainWindow::onPlaceFrame(ConnectionFrame* frame) } } +/** + * Mark given frame after it was clicked on. + * @param frame + */ void MainWindow::onFrameClicked(ConnectionFrame* frame) { for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) @@ -342,22 +407,34 @@ void MainWindow::onFrameClicked(ConnectionFrame* frame) } } +/** + * Show session name, after it was clicked on. + */ void MainWindow::onSessionNameClick() { _sessionNameWindow->show(Global::sessionName()); } +/** + * Update session name. + */ void MainWindow::onSessionNameUpdate() { _sessionNameLabel->setText(tr("Session Name: %1 [click to edit]").arg(Global::sessionName())); } +/** + * OnButtonSettings. + */ void MainWindow::onButtonSettings() { // Move to any free tile placeFrameInFreeSlot(createFrame()); } +/** + * OnButtonChat. + */ void MainWindow::onButtonChat() { /* @@ -367,6 +444,12 @@ void MainWindow::onButtonChat() */ } +/** + * Check if given client is valid. + * And if that is the case return true. + * @param client + * @return If client is valid or not. + */ bool MainWindow::isValidClient(Client* client) { for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) @@ -378,6 +461,10 @@ bool MainWindow::isValidClient(Client* client) return false; } +/** + * Check if buttons are blocked. + * @return If buttons are blocked or not. + */ bool MainWindow::areButtonsBlocked() { bool result; @@ -388,6 +475,13 @@ bool MainWindow::areButtonsBlocked() return result; } +/** + * Handle VNC settings for a projection from "from" to "to". + * Check if projection source is active vnc client. + * Check if projection is One --> Many or One --> One. + * @param from + * @param to + */ void MainWindow::prepareForProjection(Client * const from, Client * const to) { // Projection source is never allowed to be an active VNC viewer @@ -469,6 +563,12 @@ void MainWindow::prepareForProjection(Client * const from, Client * const to) from->startVncServer(); } +/** + * Button projection from one student to all the others. + * First get which client is projectionSource and set this one as from. + * Set projection source for all clients,except the selected one, to false. + * Then call prepareForProjection(from, Null). + */ void MainWindow::onButtonStudentToAll() { if (areButtonsBlocked()) @@ -494,6 +594,11 @@ void MainWindow::onButtonStudentToAll() prepareForProjection(from, NULL); } +/** + * Handle projection from one student to tutor. + * Get the client to project from and get client, who is tutor, as to. + * Call prepareForProjection(from, to). + */ void MainWindow::onButtonStudentToTutor() { if (areButtonsBlocked()) @@ -530,6 +635,12 @@ void MainWindow::onButtonStudentToTutor() prepareForProjection(from, to); } +/** + * Handle projection from tutor to all. + * Get the client who is tutor and set the projectionSource of all + * clients, except the tutor ones, to false. + * Call prepareForProjection(from, to). + */ void MainWindow::onButtonTutorToAll() { if (areButtonsBlocked()) @@ -556,6 +667,11 @@ void MainWindow::onButtonTutorToAll() prepareForProjection(from, NULL); } +/** + * Handle the projection from Tutor to specific student. + * Set the client who is tutor as from and the selected client as to. + * Call prepareForProjection(from, to). + */ void MainWindow::onButtonTutorToStudent() { if (areButtonsBlocked()) @@ -592,6 +708,11 @@ void MainWindow::onButtonTutorToStudent() prepareForProjection(from, to); } +/** + * Handle Button StopProjection. + * Set ProjectionSource of each client to false and create a NetworkMessage to + * stop the active VNC Server and the active VNC Client(s). + */ void MainWindow::onButtonStopProjection() { if (areButtonsBlocked()) @@ -619,6 +740,12 @@ void MainWindow::onButtonStopProjection() } } +/** + * Handle button to lock or unlock screens of client(s). + * If already locked, do nothing, else create a NetworkMessage to lock (checked) or + * unlock (!checked) the client(s), except the tutor. + * @param checked + */ void MainWindow::onButtonLock(bool checked) { if (areButtonsBlocked()) @@ -639,11 +766,18 @@ void MainWindow::onButtonLock(bool checked) } } +/** + * On button exit, close application. + */ void MainWindow::onButtonExit() { this->close(); } +/** + * Handle button to set specific client as tutor. + * Unset active tutor and set selected client, if not inactive, as new tutor. + */ void MainWindow::onButtonSetAsTutor() { bool selected = false; @@ -669,6 +803,10 @@ void MainWindow::onButtonSetAsTutor() } } +/** + * Handle from ListenServer signaled new client connection. + * @param client + */ void MainWindow::onClientConnected(Client* client) { qDebug("ListenServer told MainWindow about new connection"); @@ -676,6 +814,11 @@ void MainWindow::onClientConnected(Client* client) connect(client, SIGNAL(authenticated(Client*)), this, SLOT(onClientAuthenticated(Client*))); } +/** + * Authenticate new Client client. + * @param client + * @param request + */ void MainWindow::onClientAuthenticating(Client* client, ClientLogin* request) { disconnect(client, SIGNAL(authenticating(Client*, ClientLogin*)), this, SLOT(onClientAuthenticating(Client*, ClientLogin*))); @@ -713,6 +856,11 @@ void MainWindow::onClientAuthenticating(Client* client, ClientLogin* request) request->name = check; } +/** + * After authenticating new client, check if that's the first one and set tutor if necessary. + * Also check the current VNC status and take these setting also for the new client. + * @param client + */ void MainWindow::onClientAuthenticated(Client* client) { disconnect(client, SIGNAL(authenticated(Client*)), this, SLOT(onClientAuthenticated(Client*))); @@ -814,6 +962,12 @@ void MainWindow::onClientAuthenticated(Client* client) } } +/** + * Handle if VNC Server State has changed. + * Check if VNC server has been started/stopped on some client and start VNC server/reset pending + * VNC projection information. + * @param client + */ void MainWindow::onVncServerStateChange(Client* client) { if (!isValidClient(client)) // Check here because this slot is connected queued @@ -869,6 +1023,12 @@ void MainWindow::onVncServerStateChange(Client* client) } } +/** + * Handle VNC client state change. + * Check if any vnc client is in use, and if that is not the case, stop VNC Server. + * @param client + * @param lastProjectionSource + */ void MainWindow::onVncClientStateChange(Client* client, int lastProjectionSource) { if (!isValidClient(client)) // Check here because this slot is connected queued diff --git a/src/server/mainwindow/mainwindow.h b/src/server/mainwindow/mainwindow.h index 4b23ae7..e5179ed 100644 --- a/src/server/mainwindow/mainwindow.h +++ b/src/server/mainwindow/mainwindow.h @@ -16,6 +16,10 @@ namespace Ui class MainWindow; } +/** + * Initializing MainWindow. + * Handle ButtonEvents and initialize ListenServer. + */ class MainWindow : public QMainWindow { Q_OBJECT @@ -24,6 +28,10 @@ private: Ui::MainWindow *ui; SessionNameWindow *_sessionNameWindow; QLabel *_sessionNameLabel; + + /** + * List of current clients in session. + */ QList _clientFrames; int _tbIconSize; Qt::ToolBarArea _tbArea; @@ -31,7 +39,15 @@ private: int _timerId, _timerTimeout; ListenServer *_listenServer; DiscoveryListener *_discoveryListener; + + /** + * Downloader for IP - List of possible tutors. + */ FileDownloader _fileDownloader; + + /** + * Stored List of possible tutor IPs. + */ QStringList _tutorList; // Magic numbers diff --git a/src/server/net/listenserver.cpp b/src/server/net/listenserver.cpp index d7c2693..c8392df 100644 --- a/src/server/net/listenserver.cpp +++ b/src/server/net/listenserver.cpp @@ -3,7 +3,11 @@ #include #define MAX_CLIENTS 50 - +/** + * Initialize listenServer to listen on specific port. + * And connect Signal newConnection() with Slot newClientConnection(). + * @param port + */ ListenServer::ListenServer(quint16 port) { if (!_server.listen(QHostAddress::Any, port) || !_server.isListening()) @@ -22,6 +26,10 @@ ListenServer::~ListenServer() * Slots */ +/** + * Handle new client connection. + * If there are not already to much clients, emit signal newClient(). + */ void ListenServer::newClientConnection() { QSslSocket* sock; diff --git a/src/server/net/listenserver.h b/src/server/net/listenserver.h index f237703..e0cece3 100644 --- a/src/server/net/listenserver.h +++ b/src/server/net/listenserver.h @@ -7,6 +7,9 @@ class Client; +/** + * Class for listing on new client connection. + */ class ListenServer : public QObject { Q_OBJECT diff --git a/src/server/net/sslserver.cpp b/src/server/net/sslserver.cpp index 70daea4..4ea3991 100644 --- a/src/server/net/sslserver.cpp +++ b/src/server/net/sslserver.cpp @@ -30,6 +30,10 @@ SslServer::~SslServer() killTimer((_tmr)); } +/** + * Handle incomming connection. + * @param socketDescriptor + */ void SslServer::incomingConnection(int socketDescriptor) { QSslSocket *serverSocket = new QSslSocket(NULL); diff --git a/src/server/net/sslserver.h b/src/server/net/sslserver.h index 400bf6a..cdb12de 100644 --- a/src/server/net/sslserver.h +++ b/src/server/net/sslserver.h @@ -23,6 +23,9 @@ class QSslSocket; +/** + * Class for handling ssl server connections. + */ class SslServer : public QTcpServer { Q_OBJECT -- cgit v1.2.3-55-g7522