summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohann Latocha2011-03-29 15:40:53 +0200
committerJohann Latocha2011-03-29 15:40:53 +0200
commitcd32084b65687798b7a87818ff6d9f9557fd2d65 (patch)
tree0a8f949ca6c62d8bd1205686e7d6e0498e6b02c5
parentMerge branch 'master' of openslx.org:pvs (diff)
downloadpvs-cd32084b65687798b7a87818ff6d9f9557fd2d65.tar.gz
pvs-cd32084b65687798b7a87818ff6d9f9557fd2d65.tar.xz
pvs-cd32084b65687798b7a87818ff6d9f9557fd2d65.zip
Autoconnection implemented:
Insert into ~/.config/openslx/pvs.conf [Connection] host=<host> port=<port> fingerprint=<fingerprint> sessionname=<sessionname>
-rw-r--r--src/core/pvsConnectionManager.cpp9
-rw-r--r--src/net/pvsServerConnection.cpp2
-rw-r--r--src/pvs.cpp14
3 files changed, 22 insertions, 3 deletions
diff --git a/src/core/pvsConnectionManager.cpp b/src/core/pvsConnectionManager.cpp
index d1442dd..703d1c4 100644
--- a/src/core/pvsConnectionManager.cpp
+++ b/src/core/pvsConnectionManager.cpp
@@ -41,9 +41,12 @@ PVSConnectionManager::PVSConnectionManager()
if (!(_pvsServer.startListen(SERVER_PORT_INT)))
ConsoleLog writeError(QString("Server listening failed!"));
setUpdateRate(500);
- _sdBroadcaster.setFingerprint(
- CertManager::getCertificate("manager").digest(QCryptographicHash::Sha1)
- );
+
+ QByteArray fingerprint = CertManager::getCertificate("manager").digest(QCryptographicHash::Sha1);
+ _sdBroadcaster.setFingerprint(fingerprint);
+ qDebug() << "Fingerprint: " << fingerprint.toHex();
+ qDebug() << "Sessionname: " << getSessionName();
+
_timerId = startTimer(1000);
}
diff --git a/src/net/pvsServerConnection.cpp b/src/net/pvsServerConnection.cpp
index d187ce3..2ec2e5d 100644
--- a/src/net/pvsServerConnection.cpp
+++ b/src/net/pvsServerConnection.cpp
@@ -36,6 +36,8 @@ bool PVSServerConnection::connectToServer(PVSDiscoveredServer* server, QString p
if (port < 1 || port > 65535) port = SERVER_PORT_INT;
ConsoleLog writeNetwork("Connecting to host:");
ConsoleLog writeNetwork(host.toString().toUtf8().data());
+ ConsoleLog writeNetwork("Fingerprint is:");
+ ConsoleLog writeNetwork(QString(server->getFingerprint().toHex()));
timerStop();
if (_socket != NULL)
{
diff --git a/src/pvs.cpp b/src/pvs.cpp
index cf45dd7..296c8a4 100644
--- a/src/pvs.cpp
+++ b/src/pvs.cpp
@@ -92,6 +92,20 @@ PVS::PVS() :
sigaction(SIGQUIT, &act, 0);
initializeInputEventHandling();
+
+ // Read Config and try to autoconnect to given host
+ QHostAddress host(_settings.value("Connection/host").toString());
+ int port = _settings.value("Connection/port").toInt();
+ QByteArray fingerprint = QByteArray::fromHex(_settings.value("Connection/fingerprint").toByteArray());
+ QString name = _settings.value("Connection/sessionname").toString();
+ if (!host.isNull() && port > 0 && fingerprint != "" && name != "")
+ {
+ qDebug() << "Autoconnecting to " << host.toString();
+ PVSDiscoveredServer* server = new PVSDiscoveredServer(this, host, port, fingerprint, name);
+ connectToHost(server, "");
+ }
+ else
+ qDebug() << "No Config for autoconnection found";
}
PVS::~PVS()