mirror of
https://github.com/KDE/krfb
synced 2026-07-01 07:31:16 -07:00
Add and make use of ECM clang-format integration
This formats the code according to the KDE coding style and ensures it stays that way
This commit is contained in:
@@ -24,6 +24,8 @@ include(ECMQtDeclareLoggingCategory)
|
||||
include(ECMDeprecationSettings)
|
||||
include(FeatureSummary)
|
||||
include(CheckIncludeFile)
|
||||
include(KDEClangFormat)
|
||||
include(KDEGitCommitHooks)
|
||||
|
||||
check_include_file("linux/input.h" HAVE_LINUX_INPUT_H)
|
||||
|
||||
@@ -112,4 +114,9 @@ ecm_qt_install_logging_categories(
|
||||
DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR}
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h)
|
||||
kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})
|
||||
|
||||
kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)
|
||||
|
||||
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
|
||||
|
||||
@@ -13,13 +13,13 @@
|
||||
#include <QtGui/private/qtx11extras_p.h>
|
||||
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/extensions/XTest.h>
|
||||
#include <X11/keysym.h>
|
||||
|
||||
enum {
|
||||
LEFTSHIFT = 1,
|
||||
RIGHTSHIFT = 2,
|
||||
ALTGR = 4
|
||||
ALTGR = 4,
|
||||
};
|
||||
|
||||
class EventData
|
||||
@@ -66,9 +66,7 @@ void EventData::init()
|
||||
XDisplayKeycodes(dpy, &minkey, &maxkey);
|
||||
Q_ASSERT(minkey >= 8);
|
||||
Q_ASSERT(maxkey < 256);
|
||||
keymap = (KeySym *) XGetKeyboardMapping(dpy, minkey,
|
||||
(maxkey - minkey + 1),
|
||||
&syms_per_keycode);
|
||||
keymap = (KeySym *)XGetKeyboardMapping(dpy, minkey, (maxkey - minkey + 1), &syms_per_keycode);
|
||||
Q_ASSERT(keymap);
|
||||
|
||||
for (i = minkey; i <= maxkey; i++) {
|
||||
@@ -100,36 +98,36 @@ static void tweakModifiers(signed char mod, bool down)
|
||||
|
||||
if (isShift && mod != 1) {
|
||||
if (data->modifierState & LEFTSHIFT) {
|
||||
XTestFakeKeyEvent(data->dpy, data->leftShiftCode,
|
||||
down, CurrentTime);
|
||||
XTestFakeKeyEvent(data->dpy, data->leftShiftCode, down, CurrentTime);
|
||||
}
|
||||
|
||||
if (data->modifierState & RIGHTSHIFT) {
|
||||
XTestFakeKeyEvent(data->dpy, data->rightShiftCode,
|
||||
down, CurrentTime);
|
||||
XTestFakeKeyEvent(data->dpy, data->rightShiftCode, down, CurrentTime);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isShift && mod == 1) {
|
||||
XTestFakeKeyEvent(data->dpy, data->leftShiftCode,
|
||||
down, CurrentTime);
|
||||
XTestFakeKeyEvent(data->dpy, data->leftShiftCode, down, CurrentTime);
|
||||
}
|
||||
|
||||
if ((data->modifierState & ALTGR) && mod != 2) {
|
||||
XTestFakeKeyEvent(data->dpy, data->altGrCode,
|
||||
!down, CurrentTime);
|
||||
XTestFakeKeyEvent(data->dpy, data->altGrCode, !down, CurrentTime);
|
||||
}
|
||||
|
||||
if (!(data->modifierState & ALTGR) && mod == 2) {
|
||||
XTestFakeKeyEvent(data->dpy, data->altGrCode,
|
||||
down, CurrentTime);
|
||||
XTestFakeKeyEvent(data->dpy, data->altGrCode, down, CurrentTime);
|
||||
}
|
||||
}
|
||||
|
||||
void X11EventHandler::handleKeyboard(bool down, rfbKeySym keySym)
|
||||
{
|
||||
#define ADJUSTMOD(sym, state) \
|
||||
if(keySym==sym) { if(down) data->modifierState|=state; else data->modifierState&=~state; }
|
||||
if (keySym == sym) { \
|
||||
if (down) \
|
||||
data->modifierState |= state; \
|
||||
else \
|
||||
data->modifierState &= ~state; \
|
||||
}
|
||||
|
||||
if (QX11Info::isPlatformX11()) {
|
||||
ADJUSTMOD(XK_Shift_L, LEFTSHIFT);
|
||||
@@ -174,10 +172,7 @@ void X11EventHandler::handlePointer(int buttonMask, int x, int y)
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if ((data->buttonMask & (1 << i)) != (buttonMask & (1 << i))) {
|
||||
XTestFakeButtonEvent(data->dpy,
|
||||
i + 1,
|
||||
(buttonMask&(1 << i)) ? True : False,
|
||||
CurrentTime);
|
||||
XTestFakeButtonEvent(data->dpy, i + 1, (buttonMask & (1 << i)) ? True : False, CurrentTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,13 +16,10 @@ class X11EventHandler : public EventHandler
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit X11EventHandler(QObject *parent = nullptr)
|
||||
: EventHandler(parent)
|
||||
{
|
||||
};
|
||||
: EventHandler(parent) {};
|
||||
|
||||
void handleKeyboard(bool down, rfbKeySym key) override;
|
||||
void handlePointer(int buttonMask, int x, int y) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -29,4 +29,3 @@ EventHandler *X11EventsPlugin::eventHandler()
|
||||
}
|
||||
|
||||
#include "x11eventsplugin.moc"
|
||||
|
||||
|
||||
@@ -25,5 +25,4 @@ private:
|
||||
Q_DISABLE_COPY(X11EventsPlugin)
|
||||
};
|
||||
|
||||
|
||||
#endif // Header guard
|
||||
|
||||
@@ -42,7 +42,8 @@ EventData::EventData()
|
||||
void EventData::init()
|
||||
{
|
||||
dbusXdpRemoteDesktopService.reset(new OrgFreedesktopPortalRemoteDesktopInterface(QStringLiteral("org.freedesktop.portal.Desktop"),
|
||||
QStringLiteral("/org/freedesktop/portal/desktop"), QDBusConnection::sessionBus()));
|
||||
QStringLiteral("/org/freedesktop/portal/desktop"),
|
||||
QDBusConnection::sessionBus()));
|
||||
}
|
||||
|
||||
void XdpEventHandler::handleKeyboard(bool down, rfbKeySym keySym)
|
||||
|
||||
@@ -20,5 +20,3 @@ public:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -26,4 +26,3 @@ EventHandler *XdpEventsPlugin::eventHandler()
|
||||
}
|
||||
|
||||
#include "xdpeventsplugin.moc"
|
||||
|
||||
|
||||
@@ -27,6 +27,4 @@ private:
|
||||
Q_DISABLE_COPY(XdpEventsPlugin)
|
||||
};
|
||||
|
||||
|
||||
#endif // Header guard
|
||||
|
||||
|
||||
@@ -8,16 +8,16 @@
|
||||
#include "config-krfb.h"
|
||||
|
||||
// system
|
||||
#include <sys/mman.h>
|
||||
#include <cstring>
|
||||
#include <sys/mman.h>
|
||||
|
||||
// Qt
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QGuiApplication>
|
||||
#include <QRandomGenerator>
|
||||
#include <QScreen>
|
||||
#include <QSocketNotifier>
|
||||
#include <QDebug>
|
||||
#include <QRandomGenerator>
|
||||
|
||||
#include <KConfigGroup>
|
||||
#include <KSharedConfig>
|
||||
@@ -28,13 +28,13 @@
|
||||
// pipewire
|
||||
#include <climits>
|
||||
|
||||
#include "pw_framebuffer.h"
|
||||
#include "xdp_dbus_screencast_interface.h"
|
||||
#include "xdp_dbus_remotedesktop_interface.h"
|
||||
#include "krfb_fb_pipewire_debug.h"
|
||||
#include "pw_framebuffer.h"
|
||||
#include "screencasting.h"
|
||||
#include <PipeWireSourceStream>
|
||||
#include "xdp_dbus_remotedesktop_interface.h"
|
||||
#include "xdp_dbus_screencast_interface.h"
|
||||
#include <DmaBufHandler>
|
||||
#include <PipeWireSourceStream>
|
||||
|
||||
static const int BYTES_PER_PIXEL = 4;
|
||||
static const uint MIN_SUPPORTED_XDP_KDE_SC_VERSION = 1;
|
||||
@@ -66,7 +66,8 @@ const QDBusArgument &operator >> (const QDBusArgument &arg, PWFrameBuffer::Strea
|
||||
* @brief The PWFrameBuffer::Private class - private counterpart of PWFramebuffer class. This is the entity where
|
||||
* whole logic resides, for more info search for "d-pointer pattern" information.
|
||||
*/
|
||||
class PWFrameBuffer::Private {
|
||||
class PWFrameBuffer::Private
|
||||
{
|
||||
public:
|
||||
Private(PWFrameBuffer *q);
|
||||
~Private();
|
||||
@@ -138,10 +139,8 @@ void PWFrameBuffer::Private::initDbus()
|
||||
}
|
||||
|
||||
// create session
|
||||
auto sessionParameters = QVariantMap {
|
||||
{ QStringLiteral("session_handle_token"), QStringLiteral("krfb%1").arg(QRandomGenerator::global()->generate()) },
|
||||
{ QStringLiteral("handle_token"), QStringLiteral("krfb%1").arg(QRandomGenerator::global()->generate()) }
|
||||
};
|
||||
auto sessionParameters = QVariantMap{{QStringLiteral("session_handle_token"), QStringLiteral("krfb%1").arg(QRandomGenerator::global()->generate())},
|
||||
{QStringLiteral("handle_token"), QStringLiteral("krfb%1").arg(QRandomGenerator::global()->generate())}};
|
||||
auto sessionReply = dbusXdpRemoteDesktopService->CreateSession(sessionParameters);
|
||||
sessionReply.waitForFinished();
|
||||
if (!sessionReply.isValid()) {
|
||||
@@ -231,11 +230,9 @@ void PWFrameBuffer::Private::handleDevicesSelected(quint32 code, const QVariantM
|
||||
}
|
||||
|
||||
// select sources for the session
|
||||
auto selectionOptions = QVariantMap {
|
||||
{ QStringLiteral("types"), QVariant::fromValue<uint>(1) }, // only MONITOR is supported
|
||||
auto selectionOptions = QVariantMap{{QStringLiteral("types"), QVariant::fromValue<uint>(1)}, // only MONITOR is supported
|
||||
{QStringLiteral("multiple"), false},
|
||||
{ QStringLiteral("handle_token"), QStringLiteral("krfb%1").arg(QRandomGenerator::global()->generate()) }
|
||||
};
|
||||
{QStringLiteral("handle_token"), QStringLiteral("krfb%1").arg(QRandomGenerator::global()->generate())}};
|
||||
auto selectorReply = dbusXdpScreenCastService->SelectSources(sessionPath, selectionOptions);
|
||||
selectorReply.waitForFinished();
|
||||
if (!selectorReply.isValid()) {
|
||||
@@ -273,9 +270,7 @@ void PWFrameBuffer::Private::handleSourcesSelected(quint32 code, const QVariantM
|
||||
}
|
||||
|
||||
// start session
|
||||
auto startParameters = QVariantMap {
|
||||
{ QStringLiteral("handle_token"), QStringLiteral("krfb%1").arg(QRandomGenerator::global()->generate()) }
|
||||
};
|
||||
auto startParameters = QVariantMap{{QStringLiteral("handle_token"), QStringLiteral("krfb%1").arg(QRandomGenerator::global()->generate())}};
|
||||
auto startReply = dbusXdpRemoteDesktopService->Start(sessionPath, QString(), startParameters);
|
||||
startReply.waitForFinished();
|
||||
QDBusConnection::sessionBus().connect(QString(),
|
||||
@@ -286,7 +281,6 @@ void PWFrameBuffer::Private::handleSourcesSelected(quint32 code, const QVariantM
|
||||
SLOT(handleXdpRemoteDesktopStarted(uint, QVariantMap)));
|
||||
}
|
||||
|
||||
|
||||
void PWFrameBuffer::handleXdpRemoteDesktopStarted(quint32 code, const QVariantMap &results)
|
||||
{
|
||||
d->handleRemoteDesktopStarted(code, results);
|
||||
@@ -420,8 +414,8 @@ PWFrameBuffer::Private::~Private()
|
||||
}
|
||||
|
||||
PWFrameBuffer::PWFrameBuffer(QObject *parent)
|
||||
: FrameBuffer (parent),
|
||||
d(new Private(this))
|
||||
: FrameBuffer(parent)
|
||||
, d(new Private(this))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -448,7 +442,10 @@ void PWFrameBuffer::startVirtualMonitor(const QString& name, const QSize& resolu
|
||||
}
|
||||
|
||||
auto registry = new Registry(this);
|
||||
connect(registry, &KWayland::Client::Registry::interfaceAnnounced, this, [this, registry, name, dpr, resolution] (const QByteArray &interfaceName, quint32 wlname, quint32 version) {
|
||||
connect(registry,
|
||||
&KWayland::Client::Registry::interfaceAnnounced,
|
||||
this,
|
||||
[this, registry, name, dpr, resolution](const QByteArray &interfaceName, quint32 wlname, quint32 version) {
|
||||
if (interfaceName != "zkde_screencast_unstable_v1")
|
||||
return;
|
||||
|
||||
@@ -498,19 +495,18 @@ void PWFrameBuffer::getServerFormat(rfbPixelFormat &format)
|
||||
|
||||
void PWFrameBuffer::startMonitor()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void PWFrameBuffer::stopMonitor()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QVariant PWFrameBuffer::customProperty(const QString &property) const
|
||||
{
|
||||
if (property == QLatin1String("stream_node_id")) {
|
||||
return QVariant::fromValue<uint>(d->stream->nodeId());
|
||||
} if (property == QLatin1String("session_handle")) {
|
||||
}
|
||||
if (property == QLatin1String("session_handle")) {
|
||||
return QVariant::fromValue<QDBusObjectPath>(d->sessionPath);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
#define KRFB_FRAMEBUFFER_XCB_XCB_FRAMEBUFFER_H
|
||||
|
||||
#include "framebuffer.h"
|
||||
#include <QWidget>
|
||||
#include <QVariantMap>
|
||||
#include <QWidget>
|
||||
|
||||
/**
|
||||
* @brief The PWFrameBuffer class - framebuffer implementation based on XDG Desktop Portal ScreenCast interface.
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
|
||||
#include "pw_framebufferplugin.h"
|
||||
#include "pw_framebuffer.h"
|
||||
#include <KPluginFactory>
|
||||
@@ -16,12 +15,13 @@ PWFrameBufferPlugin::PWFrameBufferPlugin(QObject *parent, const QVariantList &ar
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
FrameBuffer *PWFrameBufferPlugin::frameBuffer(const QVariantMap &args)
|
||||
{
|
||||
auto pwfb = new PWFrameBuffer;
|
||||
if (args.contains(QLatin1String("name"))) {
|
||||
pwfb->startVirtualMonitor(args[QStringLiteral("name")].toString(), args[QStringLiteral("resolution")].toSize(), args[QStringLiteral("scale")].toDouble());
|
||||
pwfb->startVirtualMonitor(args[QStringLiteral("name")].toString(),
|
||||
args[QStringLiteral("resolution")].toSize(),
|
||||
args[QStringLiteral("scale")].toDouble());
|
||||
} else {
|
||||
// D-Bus is most important in XDG-Desktop-Portals init chain, no toys for us if something is wrong with XDP
|
||||
// PipeWire connectivity is initialized after D-Bus session is started
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#ifndef KRFB_FRAMEBUFFER_PW_PWFRAMEBUFFERPLUGIN_H
|
||||
#define KRFB_FRAMEBUFFER_PW_PWFRAMEBUFFERPLUGIN_H
|
||||
|
||||
|
||||
#include "framebufferplugin.h"
|
||||
|
||||
class FrameBuffer;
|
||||
@@ -25,5 +24,4 @@ private:
|
||||
Q_DISABLE_COPY(PWFrameBufferPlugin)
|
||||
};
|
||||
|
||||
|
||||
#endif // Header guard
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
#endif
|
||||
#include <KWayland/Client/registry.h>
|
||||
#include <QDebug>
|
||||
#include <QRect>
|
||||
#include <QPointer>
|
||||
#include <QRect>
|
||||
|
||||
using namespace KWayland::Client;
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
#include <QSharedPointer>
|
||||
#include <QList>
|
||||
#include <optional>
|
||||
|
||||
struct zkde_screencast_unstable_v1;
|
||||
|
||||
@@ -7,20 +7,20 @@
|
||||
#include "xcb_framebuffer.h"
|
||||
#include "krfb_fb_xcb_debug.h"
|
||||
|
||||
#include <xcb/xproto.h>
|
||||
#include <xcb/damage.h>
|
||||
#include <xcb/shm.h>
|
||||
#include <xcb/xcb_image.h>
|
||||
#include <xcb/xproto.h>
|
||||
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
|
||||
#include <QAbstractNativeEventFilter>
|
||||
#include <QApplication>
|
||||
#include <QGuiApplication>
|
||||
#include <QScreen>
|
||||
#include <QAbstractNativeEventFilter>
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
#include <QtGui/private/qtx11extras_p.h>
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
|
||||
class KrfbXCBEventFilter : public QAbstractNativeEventFilter
|
||||
{
|
||||
@@ -39,24 +39,21 @@ public:
|
||||
XCBFrameBuffer *fb_owner;
|
||||
};
|
||||
|
||||
|
||||
|
||||
KrfbXCBEventFilter::KrfbXCBEventFilter(XCBFrameBuffer *owner):
|
||||
xdamageBaseEvent(0), xdamageBaseError(0),
|
||||
xshmBaseEvent(0), xshmBaseError(0), xshmAvail(false),
|
||||
fb_owner(owner)
|
||||
KrfbXCBEventFilter::KrfbXCBEventFilter(XCBFrameBuffer *owner)
|
||||
: xdamageBaseEvent(0)
|
||||
, xdamageBaseError(0)
|
||||
, xshmBaseEvent(0)
|
||||
, xshmBaseError(0)
|
||||
, xshmAvail(false)
|
||||
, fb_owner(owner)
|
||||
{
|
||||
const xcb_query_extension_reply_t *xdamage_data = xcb_get_extension_data(
|
||||
QX11Info::connection(), &xcb_damage_id);
|
||||
const xcb_query_extension_reply_t *xdamage_data = xcb_get_extension_data(QX11Info::connection(), &xcb_damage_id);
|
||||
if (xdamage_data) {
|
||||
// also query extension version!
|
||||
// ATTENTION: if we don't do that, xcb_damage_create() will always FAIL!
|
||||
xcb_damage_query_version_reply_t *xdamage_version = xcb_damage_query_version_reply(
|
||||
QX11Info::connection(),
|
||||
xcb_damage_query_version(
|
||||
QX11Info::connection(),
|
||||
XCB_DAMAGE_MAJOR_VERSION,
|
||||
XCB_DAMAGE_MINOR_VERSION),
|
||||
xcb_damage_query_version_reply_t *xdamage_version =
|
||||
xcb_damage_query_version_reply(QX11Info::connection(),
|
||||
xcb_damage_query_version(QX11Info::connection(), XCB_DAMAGE_MAJOR_VERSION, XCB_DAMAGE_MINOR_VERSION),
|
||||
nullptr);
|
||||
if (!xdamage_version) {
|
||||
qWarning() << "xcb framebuffer: ERROR: Failed to get XDamage extension version!\n";
|
||||
@@ -64,8 +61,7 @@ KrfbXCBEventFilter::KrfbXCBEventFilter(XCBFrameBuffer *owner):
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
qCDebug(KRFB_FB_XCB) << "xcb framebuffer: XDamage extension version:" <<
|
||||
xdamage_version->major_version << "." << xdamage_version->minor_version;
|
||||
qCDebug(KRFB_FB_XCB) << "xcb framebuffer: XDamage extension version:" << xdamage_version->major_version << "." << xdamage_version->minor_version;
|
||||
#endif
|
||||
|
||||
free(xdamage_version);
|
||||
@@ -75,8 +71,7 @@ KrfbXCBEventFilter::KrfbXCBEventFilter(XCBFrameBuffer *owner):
|
||||
|
||||
// XShm presence is optional. If it is present, all image getting
|
||||
// operations will be faster, without XShm it will only be slower.
|
||||
const xcb_query_extension_reply_t *xshm_data = xcb_get_extension_data(
|
||||
QX11Info::connection(), &xcb_shm_id);
|
||||
const xcb_query_extension_reply_t *xshm_data = xcb_get_extension_data(QX11Info::connection(), &xcb_shm_id);
|
||||
if (xshm_data) {
|
||||
xshmAvail = true;
|
||||
xshmBaseEvent = xshm_data->first_event;
|
||||
@@ -93,12 +88,12 @@ KrfbXCBEventFilter::KrfbXCBEventFilter(XCBFrameBuffer *owner):
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool KrfbXCBEventFilter::nativeEventFilter(const QByteArray &eventType,
|
||||
void *message, qintptr *result) {
|
||||
bool KrfbXCBEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result)
|
||||
{
|
||||
Q_UNUSED(result); // "result" is only used on windows
|
||||
|
||||
if (xdamageBaseEvent == 0) return false; // no xdamage extension
|
||||
if (xdamageBaseEvent == 0)
|
||||
return false; // no xdamage extension
|
||||
|
||||
if (eventType == "xcb_generic_event_t") {
|
||||
auto ev = static_cast<xcb_generic_event_t *>(message);
|
||||
@@ -113,8 +108,8 @@ bool KrfbXCBEventFilter::nativeEventFilter(const QByteArray &eventType,
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
class XCBFrameBuffer::P {
|
||||
class XCBFrameBuffer::P
|
||||
{
|
||||
public:
|
||||
xcb_damage_damage_t damage;
|
||||
xcb_shm_segment_info_t shminfo;
|
||||
@@ -130,8 +125,8 @@ public:
|
||||
WId win;
|
||||
};
|
||||
|
||||
|
||||
static xcb_screen_t *get_xcb_screen(xcb_connection_t *conn, int screen_num) {
|
||||
static xcb_screen_t *get_xcb_screen(xcb_connection_t *conn, int screen_num)
|
||||
{
|
||||
xcb_screen_t *screen = nullptr;
|
||||
xcb_screen_iterator_t screens_iter = xcb_setup_roots_iterator(xcb_get_setup(conn));
|
||||
for (; screens_iter.rem; --screen_num, xcb_screen_next(&screens_iter))
|
||||
@@ -140,10 +135,9 @@ static xcb_screen_t *get_xcb_screen(xcb_connection_t *conn, int screen_num) {
|
||||
return screen;
|
||||
}
|
||||
|
||||
|
||||
|
||||
XCBFrameBuffer::XCBFrameBuffer(QObject *parent):
|
||||
FrameBuffer(parent), d(new XCBFrameBuffer::P)
|
||||
XCBFrameBuffer::XCBFrameBuffer(QObject *parent)
|
||||
: FrameBuffer(parent)
|
||||
, d(new XCBFrameBuffer::P)
|
||||
{
|
||||
d->running = false;
|
||||
d->damage = XCB_NONE;
|
||||
@@ -163,14 +157,10 @@ XCBFrameBuffer::XCBFrameBuffer(QObject *parent):
|
||||
QPlatformNativeInterface *native = qApp->platformNativeInterface();
|
||||
d->win = reinterpret_cast<WId>(native->nativeResourceForScreen(QByteArrayLiteral("rootwindow"), primaryScreen));
|
||||
qreal scaleFactor = primaryScreen->devicePixelRatio();
|
||||
d->area = { primaryScreen->geometry().topLeft() * scaleFactor,
|
||||
primaryScreen->geometry().bottomRight() * scaleFactor };
|
||||
d->area = {primaryScreen->geometry().topLeft() * scaleFactor, primaryScreen->geometry().bottomRight() * scaleFactor};
|
||||
|
||||
qCDebug(KRFB_FB_XCB) << "xcb framebuffer: Primary screen: " << primaryScreen->name()
|
||||
<< ", geometry: " << primaryScreen->geometry()
|
||||
<< ", device scaling: " << scaleFactor
|
||||
<< ", native size: " << d->area
|
||||
<< ", depth: " << primaryScreen->depth();
|
||||
qCDebug(KRFB_FB_XCB) << "xcb framebuffer: Primary screen: " << primaryScreen->name() << ", geometry: " << primaryScreen->geometry()
|
||||
<< ", device scaling: " << scaleFactor << ", native size: " << d->area << ", depth: " << primaryScreen->depth();
|
||||
} else {
|
||||
qWarning() << "xcb framebuffer: ERROR: Failed to get application's primary screen info!";
|
||||
return;
|
||||
@@ -186,10 +176,9 @@ XCBFrameBuffer::XCBFrameBuffer(QObject *parent):
|
||||
XCB_IMAGE_FORMAT_Z_PIXMAP);
|
||||
if (d->framebufferImage) {
|
||||
#ifdef _DEBUG
|
||||
qCDebug(KRFB_FB_XCB) << "xcb framebuffer: Got primary screen image. bpp: " << d->framebufferImage->bpp
|
||||
<< ", size (" << d->framebufferImage->width << d->framebufferImage->height << ")"
|
||||
<< ", depth: " << d->framebufferImage->depth
|
||||
<< ", padded width: " << d->framebufferImage->stride;
|
||||
qCDebug(KRFB_FB_XCB) << "xcb framebuffer: Got primary screen image. bpp: " << d->framebufferImage->bpp << ", size (" << d->framebufferImage->width
|
||||
<< d->framebufferImage->height << ")"
|
||||
<< ", depth: " << d->framebufferImage->depth << ", padded width: " << d->framebufferImage->stride;
|
||||
#endif
|
||||
this->fb = (char *)d->framebufferImage->data;
|
||||
} else {
|
||||
@@ -203,8 +192,7 @@ XCBFrameBuffer::XCBFrameBuffer(QObject *parent):
|
||||
// for image data storage - it will be allocated as shared memory.
|
||||
// "If base == 0 and bytes == ~0 and data == 0, no storage will be auto-allocated."
|
||||
// Width and height of the image = size of the capture area.
|
||||
d->updateTile = xcb_image_create_native(
|
||||
QX11Info::connection(),
|
||||
d->updateTile = xcb_image_create_native(QX11Info::connection(),
|
||||
d->area.width(), // width
|
||||
d->area.height(), // height
|
||||
XCB_IMAGE_FORMAT_Z_PIXMAP, // image format
|
||||
@@ -215,12 +203,10 @@ XCBFrameBuffer::XCBFrameBuffer(QObject *parent):
|
||||
if (d->updateTile) {
|
||||
#ifdef _DEBUG
|
||||
qCDebug(KRFB_FB_XCB) << "xcb framebuffer: Successfully created new empty image in native format"
|
||||
<< "\n size: " << d->updateTile->width << "x" << d->updateTile->height
|
||||
<< "(stride: " << d->updateTile->stride << ")"
|
||||
<< "\n size: " << d->updateTile->width << "x" << d->updateTile->height << "(stride: " << d->updateTile->stride << ")"
|
||||
<< "\n bpp, depth: " << d->updateTile->bpp << d->updateTile->depth // 32, 24
|
||||
<< "\n addr of base, data: " << d->updateTile->base << (void *)d->updateTile->data
|
||||
<< "\n size: " << d->updateTile->size
|
||||
<< "\n image byte order = " << d->updateTile->byte_order // == 0 .._LSB_FIRST
|
||||
<< "\n size: " << d->updateTile->size << "\n image byte order = " << d->updateTile->byte_order // == 0 .._LSB_FIRST
|
||||
<< "\n image bit order = " << d->updateTile->bit_order // == 1 .._MSB_FIRST
|
||||
<< "\n image plane_mask = " << d->updateTile->plane_mask; // == 16777215 == 0x00FFFFFF
|
||||
#endif
|
||||
@@ -244,8 +230,7 @@ XCBFrameBuffer::XCBFrameBuffer(QObject *parent):
|
||||
#endif
|
||||
|
||||
// will return 1 on success (yes!)
|
||||
int shmget_res = xcb_image_shm_get(
|
||||
QX11Info::connection(),
|
||||
int shmget_res = xcb_image_shm_get(QX11Info::connection(),
|
||||
d->win,
|
||||
d->updateTile,
|
||||
d->shminfo,
|
||||
@@ -277,16 +262,15 @@ XCBFrameBuffer::XCBFrameBuffer(QObject *parent):
|
||||
|
||||
#ifdef _DEBUG
|
||||
qCDebug(KRFB_FB_XCB) << "xcb framebuffer: XCBFrameBuffer(), xshm base event = " << d->x11EvtFilter->xshmBaseEvent
|
||||
<< ", xshm base error = " << d->x11EvtFilter->xdamageBaseError
|
||||
<< ", xdamage base event = " << d->x11EvtFilter->xdamageBaseEvent
|
||||
<< ", xshm base error = " << d->x11EvtFilter->xdamageBaseError << ", xdamage base event = " << d->x11EvtFilter->xdamageBaseEvent
|
||||
<< ", xdamage base error = " << d->x11EvtFilter->xdamageBaseError;
|
||||
#endif
|
||||
|
||||
QCoreApplication::instance()->installNativeEventFilter(d->x11EvtFilter);
|
||||
}
|
||||
|
||||
|
||||
XCBFrameBuffer::~XCBFrameBuffer() {
|
||||
XCBFrameBuffer::~XCBFrameBuffer()
|
||||
{
|
||||
// first - uninstall x11 event filter
|
||||
QCoreApplication::instance()->removeNativeEventFilter(d->x11EvtFilter);
|
||||
//
|
||||
@@ -316,40 +300,42 @@ XCBFrameBuffer::~XCBFrameBuffer() {
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
||||
int XCBFrameBuffer::depth() {
|
||||
int XCBFrameBuffer::depth()
|
||||
{
|
||||
if (d->framebufferImage) {
|
||||
return d->framebufferImage->depth;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int XCBFrameBuffer::height() {
|
||||
int XCBFrameBuffer::height()
|
||||
{
|
||||
if (d->framebufferImage) {
|
||||
return d->framebufferImage->height;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int XCBFrameBuffer::width() {
|
||||
int XCBFrameBuffer::width()
|
||||
{
|
||||
if (d->framebufferImage) {
|
||||
return d->framebufferImage->width;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int XCBFrameBuffer::paddedWidth() {
|
||||
int XCBFrameBuffer::paddedWidth()
|
||||
{
|
||||
if (d->framebufferImage) {
|
||||
return d->framebufferImage->stride;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void XCBFrameBuffer::getServerFormat(rfbPixelFormat &format) {
|
||||
if (!d->framebufferImage) return;
|
||||
void XCBFrameBuffer::getServerFormat(rfbPixelFormat &format)
|
||||
{
|
||||
if (!d->framebufferImage)
|
||||
return;
|
||||
|
||||
// get information about XCB visual params
|
||||
xcb_visualtype_t *root_visualtype = nullptr; // visual info
|
||||
@@ -374,7 +360,6 @@ void XCBFrameBuffer::getServerFormat(rfbPixelFormat &format) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// fill in format common info
|
||||
format.bitsPerPixel = d->framebufferImage->bpp;
|
||||
format.depth = d->framebufferImage->depth;
|
||||
@@ -385,7 +370,8 @@ void XCBFrameBuffer::getServerFormat(rfbPixelFormat &format) {
|
||||
|
||||
if (root_visualtype) {
|
||||
#ifdef _DEBUG
|
||||
qDebug("xcb framebuffer: Got info about root visual:\n"
|
||||
qDebug(
|
||||
"xcb framebuffer: Got info about root visual:\n"
|
||||
" bits per rgb value: %d\n"
|
||||
" red mask: %08x\n"
|
||||
" green mask: %08x\n"
|
||||
@@ -428,8 +414,11 @@ void XCBFrameBuffer::getServerFormat(rfbPixelFormat &format) {
|
||||
" Calculated greenShift = %d\n"
|
||||
" Calculated blueShift = %d\n"
|
||||
" Calculated max values: R%d G%d B%d",
|
||||
format.redShift, format.greenShift, format.blueShift
|
||||
format.redMax, format.greenMax, format.blueMax);
|
||||
format.redShift,
|
||||
format.greenShift,
|
||||
format.blueShift format.redMax,
|
||||
format.greenMax,
|
||||
format.blueMax);
|
||||
#endif
|
||||
} else {
|
||||
// some kind of fallback (unlikely code execution will go this way)
|
||||
@@ -461,14 +450,14 @@ void XCBFrameBuffer::getServerFormat(rfbPixelFormat &format) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function contents was taken from X11 framebuffer source code.
|
||||
* It simply several intersecting rectangles into one bigger rect.
|
||||
* Non-intersecting rects are treated as different rects and exist
|
||||
* separately in this->tiles QList.
|
||||
*/
|
||||
void XCBFrameBuffer::cleanupRects() {
|
||||
void XCBFrameBuffer::cleanupRects()
|
||||
{
|
||||
QList<QRect> cpy = tiles;
|
||||
bool inserted = false;
|
||||
tiles.clear();
|
||||
@@ -477,7 +466,8 @@ void XCBFrameBuffer::cleanupRects() {
|
||||
while (iter.hasNext()) {
|
||||
const QRect &r = iter.next();
|
||||
// skip rects not intersecting with primary monitor
|
||||
if (!r.intersects(d->area)) continue;
|
||||
if (!r.intersects(d->area))
|
||||
continue;
|
||||
// only take intersection of this rect with primary monitor rect
|
||||
QRect ri = r.intersected(d->area);
|
||||
|
||||
@@ -520,18 +510,17 @@ void XCBFrameBuffer::cleanupRects() {
|
||||
}
|
||||
// move update rects so that they are positioned relative to
|
||||
// framebuffer image, not whole screen
|
||||
tile.moveTo(tile.left() - d->area.left(),
|
||||
tile.top() - d->area.top());
|
||||
tile.moveTo(tile.left() - d->area.left(), tile.top() - d->area.top());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function is called by RfbServerManager::updateScreens()
|
||||
* approximately every 50ms (!!), driven by QTimer to get all
|
||||
* modified rectangles on the screen
|
||||
*/
|
||||
QList<QRect> XCBFrameBuffer::modifiedTiles() {
|
||||
QList<QRect> XCBFrameBuffer::modifiedTiles()
|
||||
{
|
||||
QList<QRect> ret;
|
||||
if (!d->running) {
|
||||
return ret;
|
||||
@@ -541,7 +530,6 @@ QList<QRect> XCBFrameBuffer::modifiedTiles() {
|
||||
|
||||
if (tiles.size() > 0) {
|
||||
if (d->x11EvtFilter->xshmAvail) {
|
||||
|
||||
// loop over all damage rectangles gathered up to this time
|
||||
QListIterator<QRect> iter(tiles);
|
||||
// foreach(const QRect &r, tiles) {
|
||||
@@ -552,8 +540,7 @@ QList<QRect> XCBFrameBuffer::modifiedTiles() {
|
||||
// now rects are positioned relative to framebufferImage,
|
||||
// but we need to get image from the whole screen, so
|
||||
// translate whe coordinates
|
||||
xcb_shm_get_image_cookie_t sgi_cookie = xcb_shm_get_image(
|
||||
QX11Info::connection(),
|
||||
xcb_shm_get_image_cookie_t sgi_cookie = xcb_shm_get_image(QX11Info::connection(),
|
||||
d->win,
|
||||
d->area.left() + r.left(),
|
||||
d->area.top() + r.top(),
|
||||
@@ -564,12 +551,10 @@ QList<QRect> XCBFrameBuffer::modifiedTiles() {
|
||||
d->shminfo.shmseg,
|
||||
0);
|
||||
|
||||
xcb_shm_get_image_reply_t *sgi_reply = xcb_shm_get_image_reply(
|
||||
QX11Info::connection(), sgi_cookie, nullptr);
|
||||
xcb_shm_get_image_reply_t *sgi_reply = xcb_shm_get_image_reply(QX11Info::connection(), sgi_cookie, nullptr);
|
||||
if (sgi_reply) {
|
||||
// create temporary image to get update rect contents into
|
||||
d->updateTile = xcb_image_create_native(
|
||||
QX11Info::connection(),
|
||||
d->updateTile = xcb_image_create_native(QX11Info::connection(),
|
||||
r.width(),
|
||||
r.height(),
|
||||
XCB_IMAGE_FORMAT_Z_PIXMAP,
|
||||
@@ -607,8 +592,7 @@ QList<QRect> XCBFrameBuffer::modifiedTiles() {
|
||||
for (const QRect &r : std::as_const(tiles)) {
|
||||
// I did not find XGetSubImage() analog in XCB!!
|
||||
// need function that copies pixels from one image to another
|
||||
xcb_image_t *damagedImage = xcb_image_get(
|
||||
QX11Info::connection(),
|
||||
xcb_image_t *damagedImage = xcb_image_get(QX11Info::connection(),
|
||||
d->win,
|
||||
r.left(),
|
||||
r.top(),
|
||||
@@ -643,14 +627,14 @@ QList<QRect> XCBFrameBuffer::modifiedTiles() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void XCBFrameBuffer::startMonitor() {
|
||||
if (d->running) return;
|
||||
void XCBFrameBuffer::startMonitor()
|
||||
{
|
||||
if (d->running)
|
||||
return;
|
||||
|
||||
d->running = true;
|
||||
d->damage = xcb_generate_id(QX11Info::connection());
|
||||
xcb_damage_create(QX11Info::connection(), d->damage, d->win,
|
||||
XCB_DAMAGE_REPORT_LEVEL_RAW_RECTANGLES);
|
||||
xcb_damage_create(QX11Info::connection(), d->damage, d->win, XCB_DAMAGE_REPORT_LEVEL_RAW_RECTANGLES);
|
||||
|
||||
// (currently) we do not call xcb_damage_subtract() EVER, because
|
||||
// RAW rectangles are reported. every time some area of the screen
|
||||
@@ -658,14 +642,14 @@ void XCBFrameBuffer::startMonitor() {
|
||||
// xcb_damage_subtract(QX11Info::connection(), d->damage, XCB_NONE, XCB_NONE);
|
||||
}
|
||||
|
||||
|
||||
void XCBFrameBuffer::stopMonitor() {
|
||||
if (!d->running) return;
|
||||
void XCBFrameBuffer::stopMonitor()
|
||||
{
|
||||
if (!d->running)
|
||||
return;
|
||||
d->running = false;
|
||||
xcb_damage_destroy(QX11Info::connection(), d->damage);
|
||||
}
|
||||
|
||||
|
||||
// void XCBFrameBuffer::acquireEvents() {} // this function was totally unused
|
||||
// in X11 framebuffer, but it was the only function where XDamageSubtract() was called?
|
||||
// Also it had a blocking event loop like:
|
||||
@@ -679,12 +663,10 @@ void XCBFrameBuffer::stopMonitor() {
|
||||
// This loop takes all available Xdamage events from queue, and ends if there are no
|
||||
// more such events in input queue.
|
||||
|
||||
|
||||
void XCBFrameBuffer::handleXDamageNotify(xcb_generic_event_t *xevent) {
|
||||
void XCBFrameBuffer::handleXDamageNotify(xcb_generic_event_t *xevent)
|
||||
{
|
||||
auto xdevt = (xcb_damage_notify_event_t *)xevent;
|
||||
|
||||
QRect r((int)xdevt->area.x, (int)xdevt->area.y,
|
||||
(int)xdevt->area.width, (int)xdevt->area.height);
|
||||
QRect r((int)xdevt->area.x, (int)xdevt->area.y, (int)xdevt->area.width, (int)xdevt->area.height);
|
||||
this->tiles.append(r);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
#include <QWidget>
|
||||
#include <xcb/xcb.h>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@author Alexey Min <alexey.min@gmail.com>
|
||||
*/
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
|
||||
#include "xcb_framebufferplugin.h"
|
||||
#include "xcb_framebuffer.h"
|
||||
#include <KPluginFactory>
|
||||
@@ -23,4 +22,3 @@ FrameBuffer *XCBFrameBufferPlugin::frameBuffer(const QVariantMap &args)
|
||||
}
|
||||
|
||||
#include "xcb_framebufferplugin.moc"
|
||||
|
||||
|
||||
@@ -7,11 +7,9 @@
|
||||
#ifndef KRFB_FRAMEBUFFER_XCB_XCBFRAMEBUFFERPLUGIN_H
|
||||
#define KRFB_FRAMEBUFFER_XCB_XCBFRAMEBUFFERPLUGIN_H
|
||||
|
||||
|
||||
#include "framebufferplugin.h"
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
class FrameBuffer;
|
||||
|
||||
class XCBFrameBufferPlugin : public FrameBufferPlugin
|
||||
@@ -27,5 +25,4 @@ private:
|
||||
Q_DISABLE_COPY(XCBFrameBufferPlugin)
|
||||
};
|
||||
|
||||
|
||||
#endif // Header guard
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
#include <QCheckBox>
|
||||
#include <QIcon>
|
||||
|
||||
#include <KConfigGroup>
|
||||
#include <KGuiItem>
|
||||
#include <KLocalizedString>
|
||||
#include <KStandardGuiItem>
|
||||
#include <KConfigGroup>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
#include <KGuiItem>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
template<typename UI>
|
||||
|
||||
@@ -53,4 +53,3 @@ public:
|
||||
//*********
|
||||
|
||||
#endif // CONNECTIONDIALOG_H
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
#define EVENTS_H
|
||||
|
||||
#include "framebuffer.h"
|
||||
#include "rfb.h"
|
||||
#include "krfbprivate_export.h"
|
||||
#include "rfb.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
@@ -29,6 +29,7 @@ public:
|
||||
|
||||
void setFrameBufferPlugin(const QSharedPointer<FrameBuffer> &frameBuffer);
|
||||
QSharedPointer<FrameBuffer> frameBuffer();
|
||||
|
||||
private:
|
||||
// Used to track framebuffer plugin which we need for xdp event plugin
|
||||
QSharedPointer<FrameBuffer> fb;
|
||||
|
||||
@@ -9,15 +9,14 @@
|
||||
|
||||
#include "eventsplugin.h"
|
||||
#include "krfbconfig.h"
|
||||
#include "rfbservermanager.h"
|
||||
#include "krfbdebug.h"
|
||||
#include "rfbservermanager.h"
|
||||
|
||||
#include <QGlobalStatic>
|
||||
|
||||
#include <KPluginFactory>
|
||||
#include <KPluginMetaData>
|
||||
|
||||
|
||||
class EventsManagerStatic
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -43,5 +43,4 @@ private:
|
||||
QList<QWeakPointer<EventHandler>> m_eventHandlers;
|
||||
};
|
||||
|
||||
|
||||
#endif // Header guard
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
|
||||
#include "krfbprivate_export.h"
|
||||
|
||||
#include <QtCore/QVariantList>
|
||||
#include <QWidget>
|
||||
#include <QtCore/QVariantList>
|
||||
|
||||
class EventHandler;
|
||||
|
||||
@@ -26,4 +26,3 @@ public:
|
||||
};
|
||||
|
||||
#endif // Header guard
|
||||
|
||||
|
||||
@@ -6,9 +6,8 @@
|
||||
|
||||
#include "framebuffer.h"
|
||||
|
||||
#include <config-krfb.h>
|
||||
#include <QCursor>
|
||||
|
||||
#include <config-krfb.h>
|
||||
|
||||
FrameBuffer::FrameBuffer(QObject *parent)
|
||||
: QObject(parent)
|
||||
|
||||
@@ -11,13 +11,12 @@
|
||||
|
||||
#include "krfbprivate_export.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
#include <QRect>
|
||||
#include <QList>
|
||||
#include <QVariant>
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
class FrameBuffer;
|
||||
/**
|
||||
@author Alessandro Praduroux <pradu@pradu.it>
|
||||
@@ -54,7 +53,6 @@ protected:
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(FrameBuffer)
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -11,13 +11,12 @@
|
||||
#include "krfbconfig.h"
|
||||
#include "krfbdebug.h"
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QGlobalStatic>
|
||||
#include <QGuiApplication>
|
||||
|
||||
#include <KPluginFactory>
|
||||
#include <KPluginMetaData>
|
||||
|
||||
|
||||
class FrameBufferManagerStatic
|
||||
{
|
||||
public:
|
||||
@@ -31,7 +30,8 @@ FrameBufferManager::FrameBufferManager()
|
||||
const auto platformFilter = [](const KPluginMetaData &pluginData) {
|
||||
return pluginData.value(QStringLiteral("X-KDE-OnlyShowOnQtPlatforms"), QStringList()).contains(QGuiApplication::platformName());
|
||||
};
|
||||
const QList<KPluginMetaData> plugins = KPluginMetaData::findPlugins(QStringLiteral("krfb/framebuffer"), platformFilter, KPluginMetaData::AllowEmptyMetaData);
|
||||
const QList<KPluginMetaData> plugins =
|
||||
KPluginMetaData::findPlugins(QStringLiteral("krfb/framebuffer"), platformFilter, KPluginMetaData::AllowEmptyMetaData);
|
||||
for (const KPluginMetaData &data : plugins) {
|
||||
const KPluginFactory::Result<FrameBufferPlugin> result = KPluginFactory::instantiatePlugin<FrameBufferPlugin>(data);
|
||||
if (result.plugin) {
|
||||
|
||||
@@ -43,6 +43,4 @@ private:
|
||||
QMap<WId, QWeakPointer<FrameBuffer>> m_frameBuffers;
|
||||
};
|
||||
|
||||
|
||||
#endif // Header guard
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <QVariantList>
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
class FrameBuffer;
|
||||
|
||||
class KRFBPRIVATE_EXPORT FrameBufferPlugin : public QObject
|
||||
@@ -28,4 +27,3 @@ public:
|
||||
};
|
||||
|
||||
#endif // Header guard
|
||||
|
||||
|
||||
@@ -7,38 +7,41 @@
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
#include "rfb.h"
|
||||
#include "invitationsrfbclient.h"
|
||||
#include "connectiondialog.h"
|
||||
#include "invitationsrfbserver.h"
|
||||
#include "krfbconfig.h"
|
||||
#include "sockethelpers.h"
|
||||
#include "connectiondialog.h"
|
||||
#include "krfbdebug.h"
|
||||
#include "rfb.h"
|
||||
#include "sockethelpers.h"
|
||||
|
||||
#include <KNotification>
|
||||
#include <KLocalizedString>
|
||||
#include <KNotification>
|
||||
|
||||
#include <KConfigGroup>
|
||||
#include <QSocketNotifier>
|
||||
#include <poll.h>
|
||||
#include <KConfigGroup>
|
||||
|
||||
struct PendingInvitationsRfbClient::Private
|
||||
struct PendingInvitationsRfbClient::Private {
|
||||
Private(rfbClientPtr client)
|
||||
: client(client)
|
||||
, askOnConnect(true)
|
||||
{
|
||||
Private(rfbClientPtr client) :
|
||||
client(client),
|
||||
askOnConnect(true)
|
||||
{}
|
||||
}
|
||||
|
||||
rfbClientPtr client;
|
||||
QSocketNotifier *notifier = nullptr;
|
||||
bool askOnConnect;
|
||||
};
|
||||
|
||||
static void clientGoneHookNoop(rfbClientPtr cl) { Q_UNUSED(cl); }
|
||||
static void clientGoneHookNoop(rfbClientPtr cl)
|
||||
{
|
||||
Q_UNUSED(cl);
|
||||
}
|
||||
|
||||
PendingInvitationsRfbClient::PendingInvitationsRfbClient(rfbClientPtr client, QObject *parent) :
|
||||
PendingRfbClient(client, parent),
|
||||
d(new Private(client))
|
||||
PendingInvitationsRfbClient::PendingInvitationsRfbClient(rfbClientPtr client, QObject *parent)
|
||||
: PendingRfbClient(client, parent)
|
||||
, d(new Private(client))
|
||||
{
|
||||
d->client->clientGoneHook = clientGoneHookNoop;
|
||||
}
|
||||
@@ -53,16 +56,11 @@ void PendingInvitationsRfbClient::processNewClient()
|
||||
QString host = peerAddress(m_rfbClient->sock) + QLatin1Char(':') + QString::number(peerPort(m_rfbClient->sock));
|
||||
|
||||
if (d->askOnConnect == false) {
|
||||
|
||||
KNotification::event(QStringLiteral("NewConnectionAutoAccepted"),
|
||||
i18n("Accepted connection from %1", host));
|
||||
KNotification::event(QStringLiteral("NewConnectionAutoAccepted"), i18n("Accepted connection from %1", host));
|
||||
accept(new InvitationsRfbClient(m_rfbClient, parent()));
|
||||
|
||||
} else {
|
||||
|
||||
KNotification::event(QStringLiteral("NewConnectionOnHold"),
|
||||
i18n("Received connection from %1, on hold (waiting for confirmation)",
|
||||
host));
|
||||
KNotification::event(QStringLiteral("NewConnectionOnHold"), i18n("Received connection from %1, on hold (waiting for confirmation)", host));
|
||||
|
||||
auto dialog = new InvitationsConnectionDialog(nullptr);
|
||||
dialog->setRemoteHost(host);
|
||||
@@ -79,16 +77,13 @@ bool PendingInvitationsRfbClient::checkPassword(const QByteArray & encryptedPass
|
||||
{
|
||||
qCDebug(KRFB) << "about to start authentication";
|
||||
|
||||
if(InvitationsRfbServer::instance->allowUnattendedAccess() && vncAuthCheckPassword(
|
||||
InvitationsRfbServer::instance->unattendedPassword().toLocal8Bit(),
|
||||
encryptedPassword) ) {
|
||||
if (InvitationsRfbServer::instance->allowUnattendedAccess()
|
||||
&& vncAuthCheckPassword(InvitationsRfbServer::instance->unattendedPassword().toLocal8Bit(), encryptedPassword)) {
|
||||
d->askOnConnect = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return vncAuthCheckPassword(
|
||||
InvitationsRfbServer::instance->desktopPassword().toLocal8Bit(),
|
||||
encryptedPassword);
|
||||
return vncAuthCheckPassword(InvitationsRfbServer::instance->desktopPassword().toLocal8Bit(), encryptedPassword);
|
||||
}
|
||||
|
||||
void PendingInvitationsRfbClient::dialogAccepted()
|
||||
|
||||
@@ -13,10 +13,11 @@ class InvitationsRfbClient : public RfbClient
|
||||
{
|
||||
public:
|
||||
explicit InvitationsRfbClient(rfbClientPtr client, QObject *parent = nullptr)
|
||||
: RfbClient(client, parent) {}
|
||||
: RfbClient(client, parent)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class PendingInvitationsRfbClient : public PendingRfbClient
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -11,14 +11,14 @@
|
||||
#include "invitationsrfbclient.h"
|
||||
#include "krfbconfig.h"
|
||||
#include "krfbdebug.h"
|
||||
#include <QTimer>
|
||||
#include <QApplication>
|
||||
#include <QHostInfo>
|
||||
#include <QRandomGenerator>
|
||||
#include <QTimer>
|
||||
|
||||
#include <KLocalizedString>
|
||||
#include <KUser>
|
||||
#include <KStringHandler>
|
||||
#include <KUser>
|
||||
#include <KWallet>
|
||||
|
||||
#include <KDNSSD/PublicService>
|
||||
@@ -35,10 +35,7 @@ InvitationsRfbServer *InvitationsRfbServer::instance;
|
||||
void InvitationsRfbServer::init()
|
||||
{
|
||||
instance = new InvitationsRfbServer;
|
||||
instance->m_publicService = new KDNSSD::PublicService(
|
||||
i18n("%1@%2 (shared desktop)",
|
||||
KUser().loginName(),
|
||||
QHostInfo::localHostName()),
|
||||
instance->m_publicService = new KDNSSD::PublicService(i18n("%1@%2 (shared desktop)", KUser().loginName(), QHostInfo::localHostName()),
|
||||
QStringLiteral("_rfb._tcp"),
|
||||
KrfbConfig::port());
|
||||
instance->setListeningAddress("0.0.0.0");
|
||||
@@ -114,8 +111,7 @@ InvitationsRfbServer::InvitationsRfbServer()
|
||||
m_desktopPassword = readableRandomString(4) + QLatin1Char('-') + readableRandomString(3);
|
||||
m_unattendedPassword = readableRandomString(4) + QLatin1Char('-') + readableRandomString(3);
|
||||
KConfigGroup krfbConfig(KSharedConfig::openConfig(), QStringLiteral("Security"));
|
||||
m_allowUnattendedAccess = krfbConfig.readEntry(
|
||||
"allowUnattendedAccess", QVariant(false)).toBool();
|
||||
m_allowUnattendedAccess = krfbConfig.readEntry("allowUnattendedAccess", QVariant(false)).toBool();
|
||||
}
|
||||
|
||||
InvitationsRfbServer::~InvitationsRfbServer()
|
||||
@@ -138,8 +134,7 @@ void InvitationsRfbServer::openKWallet()
|
||||
{
|
||||
m_wallet = Wallet::openWallet(Wallet::NetworkWallet(), 0, Wallet::Asynchronous);
|
||||
if (m_wallet) {
|
||||
connect(instance->m_wallet, &KWallet::Wallet::walletOpened,
|
||||
this, &InvitationsRfbServer::walletOpened);
|
||||
connect(instance->m_wallet, &KWallet::Wallet::walletOpened, this, &InvitationsRfbServer::walletOpened);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,14 +153,12 @@ void InvitationsRfbServer::walletOpened(bool opened)
|
||||
Q_ASSERT(m_wallet);
|
||||
|
||||
if (opened && m_wallet->hasFolder(s_krfbFolderName) && m_wallet->setFolder(s_krfbFolderName)) {
|
||||
if (m_wallet->readPassword(QStringLiteral("desktopSharingPassword"), desktopPassword) == 0 &&
|
||||
!desktopPassword.isEmpty()) {
|
||||
if (m_wallet->readPassword(QStringLiteral("desktopSharingPassword"), desktopPassword) == 0 && !desktopPassword.isEmpty()) {
|
||||
m_desktopPassword = desktopPassword;
|
||||
Q_EMIT passwordChanged(m_desktopPassword);
|
||||
}
|
||||
|
||||
if(m_wallet->readPassword(QStringLiteral("unattendedAccessPassword"), unattendedPassword) == 0 &&
|
||||
!unattendedPassword.isEmpty()) {
|
||||
if (m_wallet->readPassword(QStringLiteral("unattendedAccessPassword"), unattendedPassword) == 0 && !unattendedPassword.isEmpty()) {
|
||||
m_unattendedPassword = unattendedPassword;
|
||||
}
|
||||
|
||||
@@ -190,13 +183,7 @@ QString InvitationsRfbServer::readableRandomString(int length)
|
||||
r += 6;
|
||||
}
|
||||
char c = char(r);
|
||||
if ((c == 'i') ||
|
||||
(c == 'I') ||
|
||||
(c == '1') ||
|
||||
(c == 'l') ||
|
||||
(c == 'o') ||
|
||||
(c == 'O') ||
|
||||
(c == '0')) {
|
||||
if ((c == 'i') || (c == 'I') || (c == '1') || (c == 'l') || (c == 'o') || (c == 'O') || (c == '0')) {
|
||||
continue;
|
||||
}
|
||||
str += QLatin1Char(c);
|
||||
@@ -239,15 +226,13 @@ void InvitationsRfbServer::readPasswordFromConfig()
|
||||
QString unattendedPassword;
|
||||
KConfigGroup krfbConfig(KSharedConfig::openConfig(), QStringLiteral("Security"));
|
||||
|
||||
desktopPassword = KStringHandler::obscure(krfbConfig.readEntry(
|
||||
"desktopPassword", QString()));
|
||||
desktopPassword = KStringHandler::obscure(krfbConfig.readEntry("desktopPassword", QString()));
|
||||
if (!desktopPassword.isEmpty()) {
|
||||
m_desktopPassword = desktopPassword;
|
||||
Q_EMIT passwordChanged(m_desktopPassword);
|
||||
}
|
||||
|
||||
unattendedPassword = KStringHandler::obscure(krfbConfig.readEntry(
|
||||
"unattendedPassword", QString()));
|
||||
unattendedPassword = KStringHandler::obscure(krfbConfig.readEntry("unattendedPassword", QString()));
|
||||
if (!unattendedPassword.isEmpty()) {
|
||||
m_unattendedPassword = unattendedPassword;
|
||||
}
|
||||
|
||||
@@ -11,11 +11,13 @@
|
||||
|
||||
#include "rfbserver.h"
|
||||
|
||||
namespace KWallet {
|
||||
namespace KWallet
|
||||
{
|
||||
class Wallet;
|
||||
}
|
||||
|
||||
namespace KDNSSD {
|
||||
namespace KDNSSD
|
||||
{
|
||||
class PublicService;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,28 +4,29 @@
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QCommandLineParser>
|
||||
#include <QCommandLineOption>
|
||||
#include <QDebug>
|
||||
#include <QTimer>
|
||||
#include <KCrash>
|
||||
#include <KNotification>
|
||||
#include <KLocalizedString>
|
||||
#include <KWindowSystem>
|
||||
#include <KAboutData>
|
||||
#include "sockethelpers.h"
|
||||
#include "krfb_version.h"
|
||||
#include "rfbserver.h"
|
||||
#include <signal.h>
|
||||
#include "rfbservermanager.h"
|
||||
#include "sockethelpers.h"
|
||||
#include <KAboutData>
|
||||
#include <KCrash>
|
||||
#include <KLocalizedString>
|
||||
#include <KNotification>
|
||||
#include <KWindowSystem>
|
||||
#include <QApplication>
|
||||
#include <QCommandLineOption>
|
||||
#include <QCommandLineParser>
|
||||
#include <QDebug>
|
||||
#include <QTimer>
|
||||
#include <signal.h>
|
||||
|
||||
class VirtualMonitorRfbClient : public RfbClient
|
||||
{
|
||||
public:
|
||||
explicit VirtualMonitorRfbClient(rfbClientPtr client, QObject *parent = nullptr)
|
||||
: RfbClient(client, parent)
|
||||
{}
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class PendingVirtualMonitorRfbClient : public PendingRfbClient
|
||||
@@ -33,20 +34,24 @@ class PendingVirtualMonitorRfbClient : public PendingRfbClient
|
||||
public:
|
||||
explicit PendingVirtualMonitorRfbClient(rfbClientPtr client, QObject *parent = nullptr)
|
||||
: PendingRfbClient(client, parent)
|
||||
{}
|
||||
~PendingVirtualMonitorRfbClient() override {}
|
||||
{
|
||||
}
|
||||
~PendingVirtualMonitorRfbClient() override
|
||||
{
|
||||
}
|
||||
|
||||
static QByteArray password;
|
||||
|
||||
protected:
|
||||
void processNewClient() override {
|
||||
void processNewClient() override
|
||||
{
|
||||
qDebug() << "new client!";
|
||||
const QString host = peerAddress(m_rfbClient->sock) + QLatin1Char(':') + QString::number(peerPort(m_rfbClient->sock));
|
||||
|
||||
KNotification::event(QStringLiteral("NewConnectionAutoAccepted"),
|
||||
i18n("Creating a Virtual Monitor from %1", host));
|
||||
KNotification::event(QStringLiteral("NewConnectionAutoAccepted"), i18n("Creating a Virtual Monitor from %1", host));
|
||||
}
|
||||
bool checkPassword(const QByteArray & encryptedPassword) override {
|
||||
bool checkPassword(const QByteArray &encryptedPassword) override
|
||||
{
|
||||
bool b = vncAuthCheckPassword(password, encryptedPassword);
|
||||
if (b) {
|
||||
QTimer::singleShot(0, this, [this] {
|
||||
@@ -62,7 +67,8 @@ QByteArray PendingVirtualMonitorRfbClient::password;
|
||||
class VirtualMonitorRfbServer : public RfbServer
|
||||
{
|
||||
public:
|
||||
PendingRfbClient *newClient(rfbClientPtr client) override {
|
||||
PendingRfbClient *newClient(rfbClientPtr client) override
|
||||
{
|
||||
qDebug() << "new client request";
|
||||
return new PendingVirtualMonitorRfbClient(client, this);
|
||||
}
|
||||
@@ -90,12 +96,9 @@ int main(int argc, char *argv[])
|
||||
aboutData.addAuthor(i18n("George Kiagiadakis"), QString(), QStringLiteral("george.kiagiadakis@collabora.co.uk"));
|
||||
aboutData.addAuthor(i18n("Alessandro Praduroux"), i18n("KDE4 porting"), QStringLiteral("pradu@pradu.it"));
|
||||
aboutData.addAuthor(i18n("Tim Jansen"), i18n("Original author"), QStringLiteral("tim@tjansen.de"));
|
||||
aboutData.addCredit(i18n("Johannes E. Schindelin"),
|
||||
i18n("libvncserver"));
|
||||
aboutData.addCredit(i18n("Const Kaplinsky"),
|
||||
i18n("TightVNC encoder"));
|
||||
aboutData.addCredit(i18n("Tridia Corporation"),
|
||||
i18n("ZLib encoder"));
|
||||
aboutData.addCredit(i18n("Johannes E. Schindelin"), i18n("libvncserver"));
|
||||
aboutData.addCredit(i18n("Const Kaplinsky"), i18n("TightVNC encoder"));
|
||||
aboutData.addCredit(i18n("Tridia Corporation"), i18n("ZLib encoder"));
|
||||
aboutData.addCredit(i18n("AT&T Laboratories Boston"),
|
||||
i18n("original VNC encoders and "
|
||||
"protocol design"));
|
||||
@@ -111,7 +114,10 @@ int main(int argc, char *argv[])
|
||||
parser.addOption(nameOption);
|
||||
const QCommandLineOption passwordOption({QStringLiteral("password")}, i18n("Password for the client to connect to it"), i18n("password"));
|
||||
parser.addOption(passwordOption);
|
||||
const QCommandLineOption scaleOption({ QStringLiteral("scale") }, i18n("The device-pixel-ratio of the device, the scaling factor"), i18n("dpr"), QStringLiteral("1"));
|
||||
const QCommandLineOption scaleOption({QStringLiteral("scale")},
|
||||
i18n("The device-pixel-ratio of the device, the scaling factor"),
|
||||
i18n("dpr"),
|
||||
QStringLiteral("1"));
|
||||
parser.addOption(scaleOption);
|
||||
const QCommandLineOption portOption({QStringLiteral("port")}, i18n("The port we will be listening to"), i18n("number"), QStringLiteral("9999"));
|
||||
parser.addOption(portOption);
|
||||
@@ -149,7 +155,6 @@ int main(int argc, char *argv[])
|
||||
return 6;
|
||||
}
|
||||
|
||||
|
||||
if (parser.isSet(nameOption)) {
|
||||
RfbServerManager::s_pluginArgs = {
|
||||
{QStringLiteral("name"), parser.value(nameOption)},
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "invitationsrfbserver.h"
|
||||
#include "krfb_version.h"
|
||||
#include "krfbconfig.h"
|
||||
#include "krfbdebug.h"
|
||||
#include "mainwindow.h"
|
||||
#include "trayicon.h"
|
||||
#include "invitationsrfbserver.h"
|
||||
#include "krfbconfig.h"
|
||||
#include "krfb_version.h"
|
||||
#include "krfbdebug.h"
|
||||
|
||||
#include <KAboutData>
|
||||
#include <KCrash>
|
||||
@@ -18,20 +18,18 @@
|
||||
#include <KWindowSystem>
|
||||
|
||||
#include <QPixmap>
|
||||
#include <qwindowdefs.h>
|
||||
#include <QtGui/private/qtx11extras_p.h>
|
||||
#include <qwindowdefs.h>
|
||||
|
||||
#include <csignal>
|
||||
#include <X11/extensions/XTest.h>
|
||||
#include <QCommandLineParser>
|
||||
#include <QCommandLineOption>
|
||||
|
||||
#include <QCommandLineParser>
|
||||
#include <X11/extensions/XTest.h>
|
||||
#include <csignal>
|
||||
|
||||
static bool checkX11Capabilities()
|
||||
{
|
||||
int bp1, bp2, majorv, minorv;
|
||||
Bool r = XTestQueryExtension(QX11Info::display(), &bp1, &bp2,
|
||||
&majorv, &minorv);
|
||||
Bool r = XTestQueryExtension(QX11Info::display(), &bp1, &bp2, &majorv, &minorv);
|
||||
|
||||
if ((!r) || (((majorv * 1000) + minorv) < 2002)) {
|
||||
KMessageBox::error(nullptr,
|
||||
@@ -44,11 +42,11 @@ static bool checkX11Capabilities()
|
||||
return true;
|
||||
}
|
||||
|
||||
static void checkOldX11PluginConfig() {
|
||||
static void checkOldX11PluginConfig()
|
||||
{
|
||||
if (KrfbConfig::preferredFrameBufferPlugin() == QStringLiteral("x11")) {
|
||||
qCDebug(KRFB) << "Detected deprecated configuration: preferredFrameBufferPlugin = x11";
|
||||
KConfigSkeletonItem *config_item = KrfbConfig::self()->findItem(
|
||||
QStringLiteral("preferredFrameBufferPlugin"));
|
||||
KConfigSkeletonItem *config_item = KrfbConfig::self()->findItem(QStringLiteral("preferredFrameBufferPlugin"));
|
||||
if (config_item) {
|
||||
config_item->setProperty(QStringLiteral("xcb"));
|
||||
KrfbConfig::self()->save();
|
||||
@@ -63,8 +61,7 @@ static void checkWaylandPluginConfig()
|
||||
qWarning() << "Wayland: Detected invalid configuration: "
|
||||
"preferredFrameBufferPlugin is not pipewire: "
|
||||
<< KrfbConfig::preferredFrameBufferPlugin();
|
||||
KConfigSkeletonItem *config_item = KrfbConfig::self()->findItem(
|
||||
QStringLiteral("preferredFrameBufferPlugin"));
|
||||
KConfigSkeletonItem *config_item = KrfbConfig::self()->findItem(QStringLiteral("preferredFrameBufferPlugin"));
|
||||
if (config_item) {
|
||||
config_item->setProperty(QStringLiteral("pw"));
|
||||
KrfbConfig::self()->save();
|
||||
@@ -91,20 +88,13 @@ int main(int argc, char *argv[])
|
||||
"(c) 2000-2001, Const Kaplinsky\n"
|
||||
"(c) 2000, Tridia Corporation\n"
|
||||
"(c) 1999, AT&T Laboratories Boston\n"));
|
||||
aboutData.addAuthor(i18n("George Goldberg"),
|
||||
i18n("Telepathy tubes support"),
|
||||
QStringLiteral("george.goldberg@collabora.co.uk"));
|
||||
aboutData.addAuthor(i18n("George Kiagiadakis"),
|
||||
QString(),
|
||||
QStringLiteral("george.kiagiadakis@collabora.co.uk"));
|
||||
aboutData.addAuthor(i18n("George Goldberg"), i18n("Telepathy tubes support"), QStringLiteral("george.goldberg@collabora.co.uk"));
|
||||
aboutData.addAuthor(i18n("George Kiagiadakis"), QString(), QStringLiteral("george.kiagiadakis@collabora.co.uk"));
|
||||
aboutData.addAuthor(i18n("Alessandro Praduroux"), i18n("KDE4 porting"), QStringLiteral("pradu@pradu.it"));
|
||||
aboutData.addAuthor(i18n("Tim Jansen"), i18n("Original author"), QStringLiteral("tim@tjansen.de"));
|
||||
aboutData.addCredit(i18n("Johannes E. Schindelin"),
|
||||
i18n("libvncserver"));
|
||||
aboutData.addCredit(i18n("Const Kaplinsky"),
|
||||
i18n("TightVNC encoder"));
|
||||
aboutData.addCredit(i18n("Tridia Corporation"),
|
||||
i18n("ZLib encoder"));
|
||||
aboutData.addCredit(i18n("Johannes E. Schindelin"), i18n("libvncserver"));
|
||||
aboutData.addCredit(i18n("Const Kaplinsky"), i18n("TightVNC encoder"));
|
||||
aboutData.addCredit(i18n("Tridia Corporation"), i18n("ZLib encoder"));
|
||||
aboutData.addCredit(i18n("AT&T Laboratories Boston"),
|
||||
i18n("original VNC encoders and "
|
||||
"protocol design"));
|
||||
|
||||
@@ -8,34 +8,36 @@
|
||||
#include "invitationsrfbserver.h"
|
||||
|
||||
#include "krfbconfig.h"
|
||||
#include "ui_configtcp.h"
|
||||
#include "ui_configsecurity.h"
|
||||
#include "ui_configframebuffer.h"
|
||||
#include "ui_configsecurity.h"
|
||||
#include "ui_configtcp.h"
|
||||
|
||||
#include <KActionCollection>
|
||||
#include <KConfigDialog>
|
||||
#include <KLocalizedString>
|
||||
#include <KMessageBox>
|
||||
#include <KMessageWidget>
|
||||
#include <KStandardAction>
|
||||
#include <KActionCollection>
|
||||
#include <KNewPasswordDialog>
|
||||
#include <KPluginMetaData>
|
||||
#include <KStandardAction>
|
||||
|
||||
#include <QIcon>
|
||||
#include <QWidget>
|
||||
#include <QLineEdit>
|
||||
#include <QComboBox>
|
||||
#include <QSizePolicy>
|
||||
#include <QList>
|
||||
#include <QSet>
|
||||
#include <QNetworkInterface>
|
||||
#include <QHostInfo>
|
||||
#include <QIcon>
|
||||
#include <QLineEdit>
|
||||
#include <QList>
|
||||
#include <QMessageBox>
|
||||
#include <QNetworkInterface>
|
||||
#include <QSet>
|
||||
#include <QSizePolicy>
|
||||
#include <QWidget>
|
||||
|
||||
class TCP : public QWidget, public Ui::TCP
|
||||
{
|
||||
public:
|
||||
explicit TCP(QWidget *parent = nullptr) : QWidget(parent) {
|
||||
explicit TCP(QWidget *parent = nullptr)
|
||||
: QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
};
|
||||
@@ -43,7 +45,9 @@ public:
|
||||
class Security : public QWidget, public Ui::Security
|
||||
{
|
||||
public:
|
||||
explicit Security(QWidget *parent = nullptr) : QWidget(parent) {
|
||||
explicit Security(QWidget *parent = nullptr)
|
||||
: QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
walletWarning = new KMessageWidget(this);
|
||||
walletWarning->setText(i18n("Storing passwords in config file is insecure!"));
|
||||
@@ -64,7 +68,9 @@ public:
|
||||
class ConfigFramebuffer : public QWidget, public Ui::Framebuffer
|
||||
{
|
||||
public:
|
||||
ConfigFramebuffer(QWidget *parent = nullptr) : QWidget(parent) {
|
||||
ConfigFramebuffer(QWidget *parent = nullptr)
|
||||
: QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
// hide the line edit with framebuffer string
|
||||
kcfg_preferredFrameBufferPlugin->hide();
|
||||
@@ -74,11 +80,11 @@ public:
|
||||
cb_preferredFrameBufferPlugin->setCurrentText(KrfbConfig::preferredFrameBufferPlugin());
|
||||
// connect signals between combo<->lineedit
|
||||
// if we change selection in combo, lineedit is updated
|
||||
QObject::connect(cb_preferredFrameBufferPlugin, &QComboBox::currentTextChanged,
|
||||
kcfg_preferredFrameBufferPlugin, &QLineEdit::setText);
|
||||
QObject::connect(cb_preferredFrameBufferPlugin, &QComboBox::currentTextChanged, kcfg_preferredFrameBufferPlugin, &QLineEdit::setText);
|
||||
}
|
||||
|
||||
void fillFrameBuffersCombo() {
|
||||
void fillFrameBuffersCombo()
|
||||
{
|
||||
const QList<KPluginMetaData> plugins = KPluginMetaData::findPlugins(QStringLiteral("krfb/framebuffer"), {}, KPluginMetaData::AllowEmptyMetaData);
|
||||
for (const KPluginMetaData &metadata : plugins) {
|
||||
cb_preferredFrameBufferPlugin->addItem(metadata.pluginId());
|
||||
@@ -86,7 +92,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: KXmlGuiWindow(parent)
|
||||
{
|
||||
@@ -100,25 +105,17 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
auto mainWidget = new QWidget;
|
||||
m_ui.setupUi(mainWidget);
|
||||
m_ui.krfbIconLabel->setPixmap(QIcon::fromTheme(QStringLiteral("krfb")).pixmap(128));
|
||||
m_ui.enableUnattendedCheckBox->setChecked(
|
||||
InvitationsRfbServer::instance->allowUnattendedAccess());
|
||||
m_ui.enableUnattendedCheckBox->setChecked(InvitationsRfbServer::instance->allowUnattendedAccess());
|
||||
|
||||
setCentralWidget(mainWidget);
|
||||
|
||||
connect(m_ui.passwordEditButton, &QToolButton::clicked,
|
||||
this, &MainWindow::editPassword);
|
||||
connect(m_ui.enableSharingCheckBox, &QCheckBox::toggled,
|
||||
this, &MainWindow::toggleDesktopSharing);
|
||||
connect(m_ui.enableUnattendedCheckBox, &QCheckBox::toggled,
|
||||
InvitationsRfbServer::instance, &InvitationsRfbServer::toggleUnattendedAccess);
|
||||
connect(m_ui.unattendedPasswordButton, &QPushButton::clicked,
|
||||
this, &MainWindow::editUnattendedPassword);
|
||||
connect(m_ui.addressAboutButton, &QToolButton::clicked,
|
||||
this, &MainWindow::aboutConnectionAddress);
|
||||
connect(m_ui.unattendedAboutButton, &QToolButton::clicked,
|
||||
this, &MainWindow::aboutUnattendedMode);
|
||||
connect(InvitationsRfbServer::instance, &InvitationsRfbServer::passwordChanged,
|
||||
this, &MainWindow::passwordChanged);
|
||||
connect(m_ui.passwordEditButton, &QToolButton::clicked, this, &MainWindow::editPassword);
|
||||
connect(m_ui.enableSharingCheckBox, &QCheckBox::toggled, this, &MainWindow::toggleDesktopSharing);
|
||||
connect(m_ui.enableUnattendedCheckBox, &QCheckBox::toggled, InvitationsRfbServer::instance, &InvitationsRfbServer::toggleUnattendedAccess);
|
||||
connect(m_ui.unattendedPasswordButton, &QPushButton::clicked, this, &MainWindow::editUnattendedPassword);
|
||||
connect(m_ui.addressAboutButton, &QToolButton::clicked, this, &MainWindow::aboutConnectionAddress);
|
||||
connect(m_ui.unattendedAboutButton, &QToolButton::clicked, this, &MainWindow::aboutUnattendedMode);
|
||||
connect(InvitationsRfbServer::instance, &InvitationsRfbServer::passwordChanged, this, &MainWindow::passwordChanged);
|
||||
|
||||
// Figure out the address
|
||||
int port = KrfbConfig::port();
|
||||
@@ -127,20 +124,17 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
if (interface.flags() & QNetworkInterface::IsLoopBack)
|
||||
continue;
|
||||
|
||||
if(interface.flags() & QNetworkInterface::IsRunning &&
|
||||
!interface.addressEntries().isEmpty()) {
|
||||
if (interface.flags() & QNetworkInterface::IsRunning && !interface.addressEntries().isEmpty()) {
|
||||
const QString hostName = QHostInfo::localHostName();
|
||||
const QString ipAddress = interface.addressEntries().constFirst().ip().toString();
|
||||
const QString addressLabelText = hostName.isEmpty()
|
||||
? QStringLiteral("%1 : %2").arg(ipAddress).arg(port)
|
||||
: QStringLiteral("%1 (%2) : %3").arg(hostName, ipAddress).arg(port);
|
||||
const QString addressLabelText =
|
||||
hostName.isEmpty() ? QStringLiteral("%1 : %2").arg(ipAddress).arg(port) : QStringLiteral("%1 (%2) : %3").arg(hostName, ipAddress).arg(port);
|
||||
m_ui.addressDisplayLabel->setText(addressLabelText);
|
||||
}
|
||||
}
|
||||
|
||||
// Figure out the password
|
||||
m_ui.passwordDisplayLabel->setText(
|
||||
InvitationsRfbServer::instance->desktopPassword());
|
||||
m_ui.passwordDisplayLabel->setText(InvitationsRfbServer::instance->desktopPassword());
|
||||
|
||||
KStandardAction::quit(QCoreApplication::instance(), &QCoreApplication::quit, actionCollection());
|
||||
KStandardAction::preferences(this, &MainWindow::showConfiguration, actionCollection());
|
||||
@@ -164,17 +158,14 @@ void MainWindow::editPassword()
|
||||
m_passwordEditable = false;
|
||||
m_ui.passwordEditButton->setIcon(QIcon::fromTheme(QStringLiteral("document-properties")));
|
||||
m_ui.passwordGridLayout->removeWidget(m_passwordLineEdit);
|
||||
InvitationsRfbServer::instance->setDesktopPassword(
|
||||
m_passwordLineEdit->text());
|
||||
m_ui.passwordDisplayLabel->setText(
|
||||
InvitationsRfbServer::instance->desktopPassword());
|
||||
InvitationsRfbServer::instance->setDesktopPassword(m_passwordLineEdit->text());
|
||||
m_ui.passwordDisplayLabel->setText(InvitationsRfbServer::instance->desktopPassword());
|
||||
m_passwordLineEdit->setVisible(false);
|
||||
} else {
|
||||
m_passwordEditable = true;
|
||||
m_ui.passwordEditButton->setIcon(QIcon::fromTheme(QStringLiteral("document-save")));
|
||||
m_ui.passwordGridLayout->addWidget(m_passwordLineEdit, 0, 0);
|
||||
m_passwordLineEdit->setText(
|
||||
InvitationsRfbServer::instance->desktopPassword());
|
||||
m_passwordLineEdit->setText(InvitationsRfbServer::instance->desktopPassword());
|
||||
m_passwordLineEdit->setVisible(true);
|
||||
m_passwordLineEdit->setFocus(Qt::MouseFocusReason);
|
||||
}
|
||||
@@ -216,16 +207,20 @@ void MainWindow::passwordChanged(const QString& password)
|
||||
|
||||
void MainWindow::aboutConnectionAddress()
|
||||
{
|
||||
QMessageBox::about(this,
|
||||
QMessageBox::about(
|
||||
this,
|
||||
i18n("KDE Desktop Sharing"),
|
||||
i18n("This field contains the address of your computer and the port number, separated by a colon.\n\nThe address is just a hint - you can use any address that can reach your computer.\n\nDesktop Sharing tries to guess your address from your network configuration, but does not always succeed in doing so.\n\nIf your computer is behind a firewall it may have a different address or be unreachable for other computers."));
|
||||
i18n("This field contains the address of your computer and the port number, separated by a colon.\n\nThe address is just a hint - you can use any "
|
||||
"address that can reach your computer.\n\nDesktop Sharing tries to guess your address from your network configuration, but does not always "
|
||||
"succeed in doing so.\n\nIf your computer is behind a firewall it may have a different address or be unreachable for other computers."));
|
||||
}
|
||||
|
||||
void MainWindow::aboutUnattendedMode()
|
||||
{
|
||||
QMessageBox::about(this,
|
||||
i18n("KDE Desktop Sharing"),
|
||||
i18n("Any remote user with normal desktop sharing password will have to be authenticated.\n\nIf unattended access is on, and the remote user provides unattended mode password, desktop sharing access will be granted without explicit confirmation."));
|
||||
i18n("Any remote user with normal desktop sharing password will have to be authenticated.\n\nIf unattended access is on, and the remote "
|
||||
"user provides unattended mode password, desktop sharing access will be granted without explicit confirmation."));
|
||||
}
|
||||
|
||||
void MainWindow::showConfiguration()
|
||||
@@ -250,7 +245,8 @@ void MainWindow::showConfiguration()
|
||||
connect(dialog, &KConfigDialog::settingsChanged, this, [this]() {
|
||||
// check if framebuffer plugin config has changed
|
||||
if (s_prevFramebufferPlugin != KrfbConfig::preferredFrameBufferPlugin()) {
|
||||
KMessageBox::information(this, i18n("To apply framebuffer plugin setting, "
|
||||
KMessageBox::information(this,
|
||||
i18n("To apply framebuffer plugin setting, "
|
||||
"you need to restart the program."));
|
||||
}
|
||||
// check if kwallet config has changed
|
||||
|
||||
@@ -16,4 +16,3 @@
|
||||
#undef FALSE
|
||||
|
||||
#endif // Header guard
|
||||
|
||||
|
||||
@@ -8,20 +8,20 @@
|
||||
*/
|
||||
#include "rfbclient.h"
|
||||
#include "connectiondialog.h"
|
||||
#include "krfbconfig.h"
|
||||
#include "sockethelpers.h"
|
||||
#include "eventsmanager.h"
|
||||
#include "krfbconfig.h"
|
||||
#include "krfbdebug.h"
|
||||
#include "sockethelpers.h"
|
||||
#include <QSocketNotifier>
|
||||
#include <poll.h>
|
||||
#include <strings.h> //for bzero()
|
||||
#include "krfbdebug.h"
|
||||
|
||||
struct RfbClient::Private
|
||||
struct RfbClient::Private {
|
||||
Private(rfbClientPtr client)
|
||||
: controlEnabled(KrfbConfig::allowDesktopControl())
|
||||
, client(client)
|
||||
{
|
||||
Private(rfbClientPtr client) :
|
||||
controlEnabled(KrfbConfig::allowDesktopControl()),
|
||||
client(client)
|
||||
{}
|
||||
}
|
||||
|
||||
bool controlEnabled;
|
||||
rfbClientPtr client;
|
||||
@@ -31,10 +31,10 @@ struct RfbClient::Private
|
||||
};
|
||||
|
||||
RfbClient::RfbClient(rfbClientPtr client, QObject *parent)
|
||||
: QObject(parent), d(new Private(client))
|
||||
: QObject(parent)
|
||||
, d(new Private(client))
|
||||
{
|
||||
d->remoteAddressString = peerAddress(d->client->sock) + QLatin1Char(':') +
|
||||
QString::number(peerPort(d->client->sock));
|
||||
d->remoteAddressString = peerAddress(d->client->sock) + QLatin1Char(':') + QString::number(peerPort(d->client->sock));
|
||||
|
||||
d->notifier = new QSocketNotifier(client->sock, QSocketNotifier::Read, this);
|
||||
d->notifier->setEnabled(false);
|
||||
@@ -159,18 +159,19 @@ void RfbClient::update()
|
||||
//*************
|
||||
|
||||
PendingRfbClient::PendingRfbClient(rfbClientPtr client, QObject *parent)
|
||||
: QObject(parent), m_rfbClient(client)
|
||||
: QObject(parent)
|
||||
, m_rfbClient(client)
|
||||
, m_notifier(new QSocketNotifier(client->sock, QSocketNotifier::Read, this))
|
||||
{
|
||||
m_rfbClient->clientData = this;
|
||||
|
||||
m_notifier->setEnabled(true);
|
||||
connect(m_notifier, &QSocketNotifier::activated,
|
||||
this, &PendingRfbClient::onSocketActivated);
|
||||
connect(m_notifier, &QSocketNotifier::activated, this, &PendingRfbClient::onSocketActivated);
|
||||
}
|
||||
|
||||
PendingRfbClient::~PendingRfbClient()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
void PendingRfbClient::accept(RfbClient *newClient)
|
||||
{
|
||||
@@ -183,7 +184,10 @@ void PendingRfbClient::accept(RfbClient *newClient)
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
static void clientGoneHookNoop(rfbClientPtr cl) { Q_UNUSED(cl); }
|
||||
static void clientGoneHookNoop(rfbClientPtr cl)
|
||||
{
|
||||
Q_UNUSED(cl);
|
||||
}
|
||||
|
||||
void PendingRfbClient::reject()
|
||||
{
|
||||
@@ -218,8 +222,7 @@ bool PendingRfbClient::vncAuthCheckPassword(const QByteArray& password, const QB
|
||||
memset(passwd, 0, sizeof(passwd));
|
||||
|
||||
if (!password.isEmpty()) {
|
||||
strncpy(passwd, password.constData(),
|
||||
(MAXPWLEN <= password.size()) ? MAXPWLEN : password.size());
|
||||
strncpy(passwd, password.constData(), (MAXPWLEN <= password.size()) ? MAXPWLEN : password.size());
|
||||
}
|
||||
|
||||
rfbEncryptBytes(challenge, passwd);
|
||||
|
||||
@@ -59,7 +59,6 @@ private:
|
||||
Private *const d;
|
||||
};
|
||||
|
||||
|
||||
class PendingRfbClient : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -77,7 +76,6 @@ protected Q_SLOTS:
|
||||
void reject();
|
||||
|
||||
protected:
|
||||
|
||||
friend class RfbServer; // Following two methods are handled by RfbServer
|
||||
|
||||
/** This method is supposed to check if the provided \a encryptedPassword
|
||||
|
||||
@@ -7,16 +7,15 @@
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
#include "rfbserver.h"
|
||||
#include "rfbservermanager.h"
|
||||
#include "krfbdebug.h"
|
||||
#include <QSocketNotifier>
|
||||
#include "rfbservermanager.h"
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
#include <QPointer>
|
||||
#include <QSocketNotifier>
|
||||
#include <QtGui/private/qtx11extras_p.h>
|
||||
|
||||
struct RfbServer::Private
|
||||
{
|
||||
struct RfbServer::Private {
|
||||
QByteArray listeningAddress;
|
||||
int listeningPort;
|
||||
bool passwordRequired;
|
||||
@@ -26,7 +25,8 @@ struct RfbServer::Private
|
||||
};
|
||||
|
||||
RfbServer::RfbServer(QObject *parent)
|
||||
: QObject(parent), d(new Private)
|
||||
: QObject(parent)
|
||||
, d(new Private)
|
||||
{
|
||||
d->listeningAddress = "0.0.0.0";
|
||||
d->listeningPort = 0;
|
||||
@@ -115,9 +115,7 @@ bool RfbServer::start()
|
||||
d->screen->authPasswdData = (void *)nullptr;
|
||||
}
|
||||
|
||||
qCDebug(KRFB) << "Starting server. Listen port:" << listeningPort()
|
||||
<< "Listen Address:" << listeningAddress()
|
||||
<< "Password enabled:" << passwordRequired();
|
||||
qCDebug(KRFB) << "Starting server. Listen port:" << listeningPort() << "Listen Address:" << listeningAddress() << "Password enabled:" << passwordRequired();
|
||||
|
||||
rfbInitServer(d->screen);
|
||||
|
||||
@@ -136,8 +134,7 @@ bool RfbServer::start()
|
||||
}
|
||||
|
||||
if (QX11Info::isPlatformX11()) {
|
||||
connect(QApplication::clipboard(), &QClipboard::dataChanged,
|
||||
this, &RfbServer::krfbSendServerCutText);
|
||||
connect(QApplication::clipboard(), &QClipboard::dataChanged, this, &RfbServer::krfbSendServerCutText);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -220,8 +217,7 @@ void RfbServer::krfbSendServerCutText()
|
||||
{
|
||||
if (d->screen) {
|
||||
QString text = QApplication::clipboard()->text();
|
||||
rfbSendServerCutText(d->screen,
|
||||
text.toLocal8Bit().data(),text.length());
|
||||
rfbSendServerCutText(d->screen, text.toLocal8Bit().data(), text.length());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,8 +242,7 @@ rfbNewClientAction RfbServer::newClientHook(rfbClientPtr cl)
|
||||
auto server = static_cast<RfbServer *>(cl->screen->screenData);
|
||||
|
||||
PendingRfbClient *pendingClient = server->newClient(cl);
|
||||
connect(pendingClient, &PendingRfbClient::finished,
|
||||
server, &RfbServer::pendingClientFinished);
|
||||
connect(pendingClient, &PendingRfbClient::finished, server, &RfbServer::pendingClientFinished);
|
||||
|
||||
return RFB_CLIENT_ON_HOLD;
|
||||
}
|
||||
|
||||
@@ -8,20 +8,20 @@
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
#include "rfbservermanager.h"
|
||||
#include "rfbserver.h"
|
||||
#include "framebuffermanager.h"
|
||||
#include "sockethelpers.h"
|
||||
#include "krfbconfig.h"
|
||||
#include "krfbdebug.h"
|
||||
#include <QTimer>
|
||||
#include "rfbserver.h"
|
||||
#include "sockethelpers.h"
|
||||
#include <QApplication>
|
||||
#include <QGlobalStatic>
|
||||
#include <QHostInfo>
|
||||
#include <QTimer>
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
|
||||
#include <KLocalizedString>
|
||||
#include <KUser>
|
||||
#include <KNotification>
|
||||
#include <KUser>
|
||||
#include <KWindowSystem>
|
||||
#include <chrono>
|
||||
|
||||
@@ -69,9 +69,7 @@ static const char *mask =
|
||||
" xxxxx "
|
||||
" xxx ";
|
||||
|
||||
|
||||
struct RfbServerManagerStatic
|
||||
{
|
||||
struct RfbServerManagerStatic {
|
||||
RfbServerManager server;
|
||||
};
|
||||
|
||||
@@ -82,8 +80,7 @@ RfbServerManager* RfbServerManager::instance()
|
||||
return &s_instance->server;
|
||||
}
|
||||
|
||||
struct RfbServerManager::Private
|
||||
{
|
||||
struct RfbServerManager::Private {
|
||||
QSharedPointer<FrameBuffer> fb;
|
||||
rfbCursorPtr myCursor;
|
||||
QByteArray desktopName;
|
||||
@@ -92,9 +89,9 @@ struct RfbServerManager::Private
|
||||
QSet<RfbClient *> clients;
|
||||
};
|
||||
|
||||
|
||||
RfbServerManager::RfbServerManager()
|
||||
: QObject(), d(new Private)
|
||||
: QObject()
|
||||
, d(new Private)
|
||||
{
|
||||
init();
|
||||
}
|
||||
@@ -125,7 +122,8 @@ void RfbServerManager::init()
|
||||
d->myCursor = rfbMakeXCursor(19, 19, (char *)cur, (char *)mask);
|
||||
d->myCursor->cleanup = false;
|
||||
d->desktopName = QStringLiteral("%1@%2 (shared desktop)") // FIXME check if we can use utf8
|
||||
.arg(KUser().loginName(),QHostInfo::localHostName()).toLatin1();
|
||||
.arg(KUser().loginName(), QHostInfo::localHostName())
|
||||
.toLatin1();
|
||||
|
||||
connect(d->fb.data(), &FrameBuffer::frameBufferChanged, this, &RfbServerManager::updateFrameBuffer);
|
||||
connect(&d->rfbUpdateTimer, &QTimer::timeout, this, &RfbServerManager::updateScreens);
|
||||
@@ -222,8 +220,7 @@ void RfbServerManager::addClient(RfbClient* cc)
|
||||
}
|
||||
d->clients.insert(cc);
|
||||
|
||||
KNotification::event(QStringLiteral("UserAcceptsConnection"),
|
||||
i18n("The remote user %1 is now connected.", cc->name()));
|
||||
KNotification::event(QStringLiteral("UserAcceptsConnection"), i18n("The remote user %1 is now connected.", cc->name()));
|
||||
|
||||
Q_EMIT clientConnected(cc);
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#ifndef RFBSERVERMANAGER_H
|
||||
#define RFBSERVERMANAGER_H
|
||||
|
||||
#include "rfb.h"
|
||||
#include "framebuffer.h"
|
||||
#include "rfb.h"
|
||||
#include <QObject>
|
||||
#include <QVariantMap>
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
|
||||
#include "sockethelpers.h"
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
QString peerAddress(int sock)
|
||||
{
|
||||
@@ -86,4 +86,3 @@ unsigned short localPort(int sock)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,20 +8,20 @@
|
||||
#include "trayicon.h"
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "rfbservermanager.h"
|
||||
#include "rfbclient.h"
|
||||
#include "rfbservermanager.h"
|
||||
|
||||
#include <QIcon>
|
||||
#include <QMenu>
|
||||
|
||||
#include <KAboutApplicationDialog>
|
||||
#include <KActionCollection>
|
||||
#include <QDialog>
|
||||
#include <KConfigGroup>
|
||||
#include <KHelpMenu>
|
||||
#include <KLocalizedString>
|
||||
#include <KStandardAction>
|
||||
#include <KToggleAction>
|
||||
#include <KConfigGroup>
|
||||
#include <QDialog>
|
||||
|
||||
class ClientActions
|
||||
{
|
||||
@@ -52,10 +52,8 @@ ClientActions::ClientActions(RfbClient* client, QMenu* menu, QAction* before)
|
||||
m_enableControlAction->setChecked(client->controlEnabled());
|
||||
m_menu->insertAction(before, m_enableControlAction);
|
||||
|
||||
QObject::connect(m_enableControlAction, &KToggleAction::triggered,
|
||||
client, &RfbClient::setControlEnabled);
|
||||
QObject::connect(client, &RfbClient::controlEnabledChanged,
|
||||
m_enableControlAction, &KToggleAction::setChecked);
|
||||
QObject::connect(m_enableControlAction, &KToggleAction::triggered, client, &RfbClient::setControlEnabled);
|
||||
QObject::connect(client, &RfbClient::controlEnabledChanged, m_enableControlAction, &KToggleAction::setChecked);
|
||||
} else {
|
||||
m_enableControlAction = nullptr;
|
||||
}
|
||||
@@ -90,10 +88,8 @@ TrayIcon::TrayIcon(QWidget *mainWindow)
|
||||
setToolTipTitle(i18n("Desktop Sharing - disconnected"));
|
||||
setCategory(KStatusNotifierItem::ApplicationStatus);
|
||||
|
||||
connect(RfbServerManager::instance(), &RfbServerManager::clientConnected,
|
||||
this, &TrayIcon::onClientConnected);
|
||||
connect(RfbServerManager::instance(), &RfbServerManager::clientDisconnected,
|
||||
this, &TrayIcon::onClientDisconnected);
|
||||
connect(RfbServerManager::instance(), &RfbServerManager::clientConnected, this, &TrayIcon::onClientConnected);
|
||||
connect(RfbServerManager::instance(), &RfbServerManager::clientDisconnected, this, &TrayIcon::onClientDisconnected);
|
||||
|
||||
m_aboutAction = KStandardAction::aboutApp(this, &TrayIcon::showAbout, this);
|
||||
contextMenu()->addAction(m_aboutAction);
|
||||
|
||||
Reference in New Issue
Block a user