summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/client/connectwindow/connectwindow.cpp32
-rw-r--r--src/client/connectwindow/connectwindow.h3
-rw-r--r--src/client/main.cpp65
-rw-r--r--src/client/net/serverconnection.h4
-rw-r--r--src/client/toolbar/toolbar.cpp6
-rw-r--r--src/client/toolbar/toolbar.h2
-rw-r--r--src/server/mainwindow/mainwindow.cpp19
-rw-r--r--src/server/net/listenserver.cpp1
-rw-r--r--src/server/net/sslserver.cpp1
9 files changed, 89 insertions, 44 deletions
diff --git a/src/client/connectwindow/connectwindow.cpp b/src/client/connectwindow/connectwindow.cpp
index 4e92570..c8f7efd 100644
--- a/src/client/connectwindow/connectwindow.cpp
+++ b/src/client/connectwindow/connectwindow.cpp
@@ -97,7 +97,7 @@ void ConnectWindow::updateState()
{
_ui->btn_connection->setEnabled(true);
_ui->btn_connection->setText(tr("&Disconnect"));
- _ui->lblStatus->setText(tr("Connected."));
+ _ui->lblStatus->setText(tr("Connected to %1").arg(_connection->getPeerAdress()));
_ui->lineEditName->setEnabled(false);
_ui->stackedWidget->setCurrentIndex(1);
return;
@@ -175,7 +175,7 @@ void ConnectWindow::timerEvent(QTimerEvent* event)
_salt2[i] = qrand() & 0xff;
}
_packet.reset();
- _packet.setField(_HASH, genSha1(&_nameBytes, &salt1, &iplist));
+ _packet.setField(_HASH, genSha1(&_sessionNameBytes, &salt1, &iplist));
_packet.setField(_SALT1, salt1);
_packet.setField(_SALT2, _salt2);
_packet.setField(_IPLIST, iplist);
@@ -227,6 +227,24 @@ void ConnectWindow::showEvent(QShowEvent* event)
_ui->lineEditName->setFocus();
}
+/**
+ * Public function connect to session.
+ * Check if currently connected to server,
+ * if not --> connect to given sessionName.
+ * @param sessionName
+ */
+void ConnectWindow::connectToSession(const QByteArray sessionName)
+{
+ if (_connected || _state != Idle)
+ return;
+
+ _discoveryInterval = 800;
+ _sessionNameBytes = sessionName;
+ _timerDiscover = startTimer(_discoveryInterval);
+ _hashErrorCount = _hashSslErrorCount = _certErrorCount = _ipErrorCount = 0;
+ this->setState(Scanning);
+}
+
/*
* Slots
*/
@@ -255,11 +273,7 @@ void ConnectWindow::onBtnConnection()
else
{
// Connect (scan for session)
- _discoveryInterval = 800;
- _nameBytes = _ui->lineEditName->text().toUtf8();
- _timerDiscover = startTimer(_discoveryInterval);
- _hashErrorCount = _hashSslErrorCount = _certErrorCount = _ipErrorCount = 0;
- this->setState(Scanning);
+ connectToSession(_ui->lineEditName->text().toUtf8());
}
}
@@ -303,7 +317,7 @@ void ConnectWindow::onUdpReadyRead()
continue;
}
// If so, check if the submitted hash seems valid
- if (genSha1(&_nameBytes, &_salt2, &iplist, &port, &cert) != hash)
+ if (genSha1(&_sessionNameBytes, &_salt2, &iplist, &port, &cert) != hash)
{
// did not match local session name, or other data was spoofed
++_hashErrorCount;
@@ -312,7 +326,7 @@ void ConnectWindow::onUdpReadyRead()
continue;
}
// Otherwise it's a valid reply, try to connect
- _connection = new ServerConnection(addr.toString(), (quint16)QString::fromUtf8(port).toInt(), _nameBytes, cert);
+ _connection = new ServerConnection(addr.toString(), (quint16)QString::fromUtf8(port).toInt(), _sessionNameBytes, cert);
connect(_connection, SIGNAL(stateChange(ConnectWindow::ConnectionState)), this, SLOT(onConnectionStateChange(ConnectWindow::ConnectionState)));
connect(_connection, SIGNAL(destroyed(QObject*)), this, SLOT(onConnectionClosed(QObject*)));
}
diff --git a/src/client/connectwindow/connectwindow.h b/src/client/connectwindow/connectwindow.h
index 299a339..9319e45 100644
--- a/src/client/connectwindow/connectwindow.h
+++ b/src/client/connectwindow/connectwindow.h
@@ -63,7 +63,7 @@ private:
int _hashErrorCount, _hashSslErrorCount, _certErrorCount, _ipErrorCount;
int _discoveryInterval;
- QByteArray _nameBytes;
+ QByteArray _sessionNameBytes;
QByteArray _salt2;
QUdpSocket _discoverySocket;
NetworkMessage _packet;
@@ -76,6 +76,7 @@ public:
virtual ~ConnectWindow();
void setConnected(const bool connected);
+ void connectToSession(const QByteArray sessionName);
protected:
/*
diff --git a/src/client/main.cpp b/src/client/main.cpp
index cea9ae8..ebc6375 100644
--- a/src/client/main.cpp
+++ b/src/client/main.cpp
@@ -3,39 +3,46 @@
int main(int argc, char** argv)
{
- QApplication app(argc, argv);
- app.setOrganizationName("openslx");
- app.setOrganizationDomain("openslx.org");
- app.setApplicationName("pvsclient");
+ QByteArray sessionName;
+ if (argc != 2)
+ {
+ sessionName = "";
+ }
+ else
+ sessionName = argv[1];
+ QApplication app(argc, argv);
+ app.setOrganizationName("openslx");
+ app.setOrganizationDomain("openslx.org");
+ app.setApplicationName("pvsclient");
- qsrand((uint)QDateTime::currentMSecsSinceEpoch());
+ qsrand((uint)QDateTime::currentMSecsSinceEpoch());
- // Make sure settings directory exists
- do {
- USER_SETTINGS(settings);
- QFileInfo fi(settings.fileName());
- QDir path(fi.path());
- qDebug() << "Settings directory is " << fi.path();
- if (!path.exists())
- path.mkpath(path.absolutePath());
- // Now check if settings file exists. If not, copy system default (if available)
- if (!fi.exists())
+ // Make sure settings directory exists
+ do {
+ USER_SETTINGS(settings);
+ QFileInfo fi(settings.fileName());
+ QDir path(fi.path());
+ qDebug() << "Settings directory is " << fi.path();
+ if (!path.exists())
+ path.mkpath(path.absolutePath());
+ // Now check if settings file exists. If not, copy system default (if available)
+ if (!fi.exists())
+ {
+ SYSTEM_SETTINGS(sys);
+ QFileInfo sysfi(sys.fileName());
+ if (sysfi.exists())
{
- SYSTEM_SETTINGS(sys);
- QFileInfo sysfi(sys.fileName());
- if (sysfi.exists())
- {
- if (!QFile::copy(sys.fileName(), settings.fileName()))
- qDebug() << "Copying default settings from " << sys.fileName() << " to " << settings.fileName() << " failed.";
- }
+ if (!QFile::copy(sys.fileName(), settings.fileName()))
+ qDebug() << "Copying default settings from " << sys.fileName() << " to " << settings.fileName() << " failed.";
}
- } while (0);
+ }
+ } while (0);
- // use system locale as language to translate gui
- QTranslator translator;
- translator.load(":pvsclient");
- app.installTranslator(&translator);
+ // use system locale as language to translate gui
+ QTranslator translator;
+ translator.load(":pvsclient");
+ app.installTranslator(&translator);
- Toolbar pvsclient;
- return app.exec();
+ Toolbar pvsclient(sessionName);
+ return app.exec();
}
diff --git a/src/client/net/serverconnection.h b/src/client/net/serverconnection.h
index 6af2b15..a45d434 100644
--- a/src/client/net/serverconnection.h
+++ b/src/client/net/serverconnection.h
@@ -37,6 +37,10 @@ public:
return _socket != NULL && _socket->state() == QAbstractSocket::ConnectedState;
}
+ const inline QString getPeerAdress() const
+ {
+ return _socket->peerAddress().toString();
+ }
void sendMessage(NetworkMessage& message);
protected:
diff --git a/src/client/toolbar/toolbar.cpp b/src/client/toolbar/toolbar.cpp
index bfe4e24..88d4b2a 100644
--- a/src/client/toolbar/toolbar.cpp
+++ b/src/client/toolbar/toolbar.cpp
@@ -22,7 +22,7 @@
* another widget, this widget becomes a child window inside parent. The new
* widget is deleted when its parent is deleted.
*/
-Toolbar::Toolbar(QWidget *parent) :
+Toolbar::Toolbar(const QByteArray sessionName, QWidget *parent) :
QWidget(parent), _ui(new Ui::Toolbar), _hideTimer(this), _connection(NULL),
_blinkTimer(this),_cam32(":cam32.svg"), _beWatchedEye(":eye")
{
@@ -40,6 +40,10 @@ Toolbar::Toolbar(QWidget *parent) :
/* Create the connect window */
_connectWindow = new ConnectWindow(NULL);
+ if (!sessionName.isEmpty())
+ {
+ _connectWindow->connectToSession(sessionName);
+ }
// Connect the signals
connect(_connectWindow, SIGNAL(disconnect()), this, SLOT(onDoDisconnect()));
connect(_connectWindow, SIGNAL(connected(ServerConnection*)), this, SLOT(onConnected(ServerConnection*)));
diff --git a/src/client/toolbar/toolbar.h b/src/client/toolbar/toolbar.h
index f01e4ef..c85c501 100644
--- a/src/client/toolbar/toolbar.h
+++ b/src/client/toolbar/toolbar.h
@@ -30,7 +30,7 @@ class Toolbar : public QWidget
Q_OBJECT
public:
- explicit Toolbar(QWidget *parent = 0);
+ explicit Toolbar(const QByteArray sessionName, QWidget *parent = 0);
virtual ~Toolbar();
private:
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp
index 1efc87a..26508d2 100644
--- a/src/server/mainwindow/mainwindow.cpp
+++ b/src/server/mainwindow/mainwindow.cpp
@@ -56,6 +56,7 @@ MainWindow::MainWindow(QString ipListUrl, QWidget* parent) :
_tutorFrame = NULL;
_selectedFrame = NULL;
+ _streamingSource = NULL;
_sessionNameWindow = new SessionNameWindow(this);
_helpWindow = new HelpWindow(this);
@@ -703,11 +704,17 @@ void MainWindow::onClientConnected(Client* client)
/***************************************************************************//**
* Authenticate new Client client.
+ * Check if incoming client ip already exists,
+ * if yes --> return.
+ * Check if same name of client already exist,
+ * if yes --> name new client as name(x).
+ * x = number of clients with the same name.
* @param client
* @param request
*/
void MainWindow::onClientAuthenticating(Client* client, ClientLogin* request)
{
+ qDebug("onClientAuthenticating - Slot was called.");
disconnect(client, SIGNAL(authenticating(Client*, ClientLogin*)), this, SLOT(onClientAuthenticating(Client*, ClientLogin*)));
if (!request->accept) // Another receiver of that signal already rejected the client, so nothing to do
return;
@@ -744,12 +751,18 @@ void MainWindow::onClientAuthenticating(Client* client, ClientLogin* request)
}
/***************************************************************************//**
- * 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.
+ * New client was authenticated, make several checks.
+ * Check if new clients ip already exists,
+ * if yes --> not necessary to create new clientFrame.
+ * if not --> create a new one and adapt this one to current
+ * situation in class room(projection / lock screen).
+ * Check if avctiv tutor is available,
+ * if not --> check if new client is possible tutor.
* @param client
*/
void MainWindow::onClientAuthenticated(Client* client)
{
+ qDebug("Entering onClientAuthenticated - Slot.");
disconnect(client, SIGNAL(authenticated(Client*)), this, SLOT(onClientAuthenticated(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);
@@ -779,7 +792,7 @@ void MainWindow::onClientAuthenticated(Client* client)
}
}
}
-
+ // Clients ip already exists, but was not active.
if (existing != NULL)
{
existing->setTutor(isTutor);
diff --git a/src/server/net/listenserver.cpp b/src/server/net/listenserver.cpp
index 8eb3750..859ee33 100644
--- a/src/server/net/listenserver.cpp
+++ b/src/server/net/listenserver.cpp
@@ -32,6 +32,7 @@ ListenServer::~ListenServer()
*/
void ListenServer::newClientConnection()
{
+ qDebug("Listenserver::newClientConnection().");
QSslSocket* sock;
while ((sock = (QSslSocket*)_server.nextPendingConnection()) != NULL)
{
diff --git a/src/server/net/sslserver.cpp b/src/server/net/sslserver.cpp
index 4ea3991..65a40b4 100644
--- a/src/server/net/sslserver.cpp
+++ b/src/server/net/sslserver.cpp
@@ -36,6 +36,7 @@ SslServer::~SslServer()
*/
void SslServer::incomingConnection(int socketDescriptor)
{
+ qDebug("SslServer:incomingConnection.");
QSslSocket *serverSocket = new QSslSocket(NULL);
connect(serverSocket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(sslErrors(const QList<QSslError> &)));
QSslKey key;