summaryrefslogtreecommitdiffstats
path: root/src/client/connectwindow/connectwindow.cpp
diff options
context:
space:
mode:
authorBjörn Hagemeister2014-05-26 18:34:36 +0200
committerBjörn Hagemeister2014-05-26 18:34:36 +0200
commit494727e1e5f0e459153e8845168545ad4a72e598 (patch)
tree1d0328d6b7ea8d53aec693fa06681379cb20b998 /src/client/connectwindow/connectwindow.cpp
parentMerge branch 'master' of git.openslx.org:pvs2 (diff)
downloadpvs2-494727e1e5f0e459153e8845168545ad4a72e598.tar.gz
pvs2-494727e1e5f0e459153e8845168545ad4a72e598.tar.xz
pvs2-494727e1e5f0e459153e8845168545ad4a72e598.zip
Several changes:
Fixed segmentaion fault, which occured after streaming to all clients. Added sessionName as command line argument to client, so that it connects immediatly after running to given sessionName. If pvsclient shows connected status also display IP-Adress of the running pvsmanager.
Diffstat (limited to 'src/client/connectwindow/connectwindow.cpp')
-rw-r--r--src/client/connectwindow/connectwindow.cpp32
1 files changed, 23 insertions, 9 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*)));
}