1
0
mirror of https://github.com/KDE/krfb synced 2026-07-01 15:51:18 -07:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Oleg Chernovskiy
bcef3a1bcd Review comments: redo notifiers as QPointers 2018-05-30 09:43:34 +03:00
Oleg Chernovskiy
c4bc3ee3df Fix IPv6 connectivity
Summary:
IPv6 is supported by LibVNCServer but for compatibility reasons its
socket is backed by another file descriptor.

This commit adds tracking IPv6 listen socket in the same way we now
track IPv4 one.

Differential Revision: https://phabricator.kde.org/D13209
2018-05-30 00:07:27 +03:00

View File

@@ -22,6 +22,7 @@
#include <QtCore/QSocketNotifier>
#include <QApplication>
#include <QClipboard>
#include <QPointer>
#include <QDebug>
struct RfbServer::Private
@@ -30,7 +31,8 @@ struct RfbServer::Private
int listeningPort;
bool passwordRequired;
rfbScreenInfoPtr screen;
QSocketNotifier *notifier;
QPointer<QSocketNotifier> ipv4notifier;
QPointer<QSocketNotifier> ipv6notifier;
};
RfbServer::RfbServer(QObject *parent)
@@ -40,7 +42,6 @@ RfbServer::RfbServer(QObject *parent)
d->listeningPort = 0;
d->passwordRequired = true;
d->screen = NULL;
d->notifier = NULL;
RfbServerManager::instance()->registerServer(this);
}
@@ -135,9 +136,13 @@ bool RfbServer::start()
return false;
};
d->notifier = new QSocketNotifier(d->screen->listenSock, QSocketNotifier::Read, this);
d->notifier->setEnabled(true);
connect(d->notifier, &QSocketNotifier::activated, this, &RfbServer::onListenSocketActivated);
d->ipv4notifier = new QSocketNotifier(d->screen->listenSock, QSocketNotifier::Read, this);
connect(d->ipv4notifier, &QSocketNotifier::activated, this, &RfbServer::onListenSocketActivated);
if (d->screen->listen6Sock > 0) {
// we're also listening on additional IPv6 socket, get events from there
d->ipv6notifier = new QSocketNotifier(d->screen->listen6Sock, QSocketNotifier::Read, this);
connect(d->ipv6notifier, &QSocketNotifier::activated, this, &RfbServer::onListenSocketActivated);
}
connect(QApplication::clipboard(), &QClipboard::dataChanged,
this, &RfbServer::krfbSendServerCutText);
@@ -148,10 +153,11 @@ void RfbServer::stop()
{
if (d->screen) {
rfbShutdownServer(d->screen, true);
if (d->notifier) {
d->notifier->setEnabled(false);
d->notifier->deleteLater();
d->notifier = NULL;
for (auto notifier : {d->ipv4notifier, d->ipv6notifier}) {
if (notifier) {
notifier->setEnabled(false);
notifier->deleteLater();
}
}
}
}