mirror of
https://github.com/KDE/krfb
synced 2026-07-01 07:31:16 -07:00
Format project
Command used to format: git ls-files | grep -E '\.(cpp|h|hpp|c)$' | xargs clang-format -i --style file
This commit is contained in:
@@ -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
|
||||
@@ -129,7 +129,12 @@ static void tweakModifiers(signed char mod, bool down)
|
||||
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);
|
||||
|
||||
@@ -14,15 +14,15 @@
|
||||
class X11EventHandler : public EventHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit X11EventHandler(QObject *parent = nullptr)
|
||||
: EventHandler(parent)
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
void handleKeyboard(bool down, rfbKeySym key) override;
|
||||
void handlePointer(int buttonMask, int x, int y) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -22,11 +22,11 @@ X11EventsPlugin::X11EventsPlugin(QObject *parent, const QVariantList &args)
|
||||
EventHandler *X11EventsPlugin::eventHandler()
|
||||
{
|
||||
// works only under X11
|
||||
if(!QX11Info::isPlatformX11())
|
||||
if (!QX11Info::isPlatformX11()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new X11EventHandler();
|
||||
}
|
||||
|
||||
#include "x11eventsplugin.moc"
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ class EventHandler;
|
||||
class X11EventsPlugin : public EventsPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
X11EventsPlugin(QObject *parent, const QVariantList &args);
|
||||
|
||||
@@ -25,5 +26,4 @@ private:
|
||||
Q_DISABLE_COPY(X11EventsPlugin)
|
||||
};
|
||||
|
||||
|
||||
#endif // Header guard
|
||||
|
||||
@@ -14,11 +14,10 @@
|
||||
class XdpEventHandler : public EventHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
void handleKeyboard(bool down, rfbKeySym key) override;
|
||||
void handlePointer(int buttonMask, int x, int y) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -26,4 +26,3 @@ EventHandler *XdpEventsPlugin::eventHandler()
|
||||
}
|
||||
|
||||
#include "xdpeventsplugin.moc"
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ class EventHandler;
|
||||
class XdpEventsPlugin : public EventsPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
XdpEventsPlugin(QObject *parent, const QVariantList &args);
|
||||
|
||||
@@ -27,6 +28,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();
|
||||
@@ -140,8 +141,7 @@ 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()) }
|
||||
};
|
||||
{QStringLiteral("handle_token"), QStringLiteral("krfb%1").arg(QRandomGenerator::global()->generate())}};
|
||||
auto sessionReply = dbusXdpRemoteDesktopService->CreateSession(sessionParameters);
|
||||
sessionReply.waitForFinished();
|
||||
if (!sessionReply.isValid()) {
|
||||
@@ -234,8 +234,7 @@ void PWFrameBuffer::Private::handleDevicesSelected(quint32 code, const QVariantM
|
||||
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()) {
|
||||
@@ -274,8 +273,7 @@ void PWFrameBuffer::Private::handleSourcesSelected(quint32 code, const QVariantM
|
||||
|
||||
// start session
|
||||
auto startParameters = QVariantMap{
|
||||
{ QStringLiteral("handle_token"), QStringLiteral("krfb%1").arg(QRandomGenerator::global()->generate()) }
|
||||
};
|
||||
{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 +284,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 +417,8 @@ PWFrameBuffer::Private::~Private()
|
||||
}
|
||||
|
||||
PWFrameBuffer::PWFrameBuffer(QObject *parent)
|
||||
: FrameBuffer (parent),
|
||||
d(new Private(this))
|
||||
: FrameBuffer(parent)
|
||||
, d(new Private(this))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -449,8 +446,9 @@ 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) {
|
||||
if (interfaceName != "zkde_screencast_unstable_v1")
|
||||
if (interfaceName != "zkde_screencast_unstable_v1") {
|
||||
return;
|
||||
}
|
||||
|
||||
auto screencasting = new Screencasting(registry, wlname, version, this);
|
||||
auto r = screencasting->createVirtualMonitorStream(name, resolution, dpr, Screencasting::Metadata);
|
||||
@@ -498,19 +496,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.
|
||||
@@ -20,8 +20,10 @@
|
||||
class PWFrameBuffer : public FrameBuffer
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using Stream = struct {
|
||||
using Stream = struct
|
||||
{
|
||||
uint nodeId;
|
||||
QVariantMap map;
|
||||
};
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
|
||||
#include "pw_framebufferplugin.h"
|
||||
#include "pw_framebuffer.h"
|
||||
#include <KPluginFactory>
|
||||
@@ -16,7 +15,6 @@ PWFrameBufferPlugin::PWFrameBufferPlugin(QObject *parent, const QVariantList &ar
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
FrameBuffer *PWFrameBufferPlugin::frameBuffer(const QVariantMap &args)
|
||||
{
|
||||
auto pwfb = new PWFrameBuffer;
|
||||
|
||||
@@ -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;
|
||||
@@ -17,9 +17,11 @@ namespace KWayland
|
||||
{
|
||||
namespace Client
|
||||
{
|
||||
|
||||
class PlasmaWindow;
|
||||
class Registry;
|
||||
class Output;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +31,7 @@ class ScreencastingStreamPrivate;
|
||||
class ScreencastingStream : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ScreencastingStream(QObject *parent);
|
||||
~ScreencastingStream() override;
|
||||
@@ -48,6 +51,7 @@ private:
|
||||
class Screencasting : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Screencasting(QObject *parent = nullptr);
|
||||
explicit Screencasting(KWayland::Client::Registry *registry, int id, int version, QObject *parent = nullptr);
|
||||
|
||||
@@ -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,12 +39,13 @@ 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);
|
||||
@@ -64,8 +65,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);
|
||||
@@ -93,12 +93,14 @@ KrfbXCBEventFilter::KrfbXCBEventFilter(XCBFrameBuffer *owner):
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool KrfbXCBEventFilter::nativeEventFilter(const QByteArray &eventType,
|
||||
void *message, qintptr *result) {
|
||||
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 +115,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,20 +132,21 @@ 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))
|
||||
if (screen_num == 0)
|
||||
for (; screens_iter.rem; --screen_num, xcb_screen_next(&screens_iter)) {
|
||||
if (screen_num == 0) {
|
||||
screen = screens_iter.data;
|
||||
}
|
||||
}
|
||||
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;
|
||||
@@ -285,8 +288,8 @@ XCBFrameBuffer::XCBFrameBuffer(QObject *parent):
|
||||
QCoreApplication::instance()->installNativeEventFilter(d->x11EvtFilter);
|
||||
}
|
||||
|
||||
|
||||
XCBFrameBuffer::~XCBFrameBuffer() {
|
||||
XCBFrameBuffer::~XCBFrameBuffer()
|
||||
{
|
||||
// first - uninstall x11 event filter
|
||||
QCoreApplication::instance()->removeNativeEventFilter(d->x11EvtFilter);
|
||||
//
|
||||
@@ -296,13 +299,16 @@ XCBFrameBuffer::~XCBFrameBuffer() {
|
||||
}
|
||||
if (d->x11EvtFilter->xshmAvail) {
|
||||
// detach shared memory
|
||||
if (d->shminfo.shmseg != XCB_NONE)
|
||||
if (d->shminfo.shmseg != XCB_NONE) {
|
||||
xcb_shm_detach(QX11Info::connection(), d->shminfo.shmseg); // detach from X server
|
||||
if (d->shminfo.shmaddr)
|
||||
}
|
||||
if (d->shminfo.shmaddr) {
|
||||
shmdt(d->shminfo.shmaddr); // detach addr from our address space
|
||||
if (d->shminfo.shmid != XCB_NONE)
|
||||
}
|
||||
if (d->shminfo.shmid != XCB_NONE) {
|
||||
shmctl(d->shminfo.shmid, IPC_RMID, nullptr); // mark shm segment as removed
|
||||
}
|
||||
}
|
||||
// and delete image used for shared mem
|
||||
if (d->updateTile) {
|
||||
d->updateTile->base = nullptr;
|
||||
@@ -316,40 +322,43 @@ 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 +383,6 @@ void XCBFrameBuffer::getServerFormat(rfbPixelFormat &format) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// fill in format common info
|
||||
format.bitsPerPixel = d->framebufferImage->bpp;
|
||||
format.depth = d->framebufferImage->depth;
|
||||
@@ -428,8 +436,7 @@ 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 +468,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 +484,9 @@ 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);
|
||||
|
||||
@@ -525,13 +534,13 @@ void XCBFrameBuffer::cleanupRects() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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 +550,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) {
|
||||
@@ -643,9 +651,11 @@ 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());
|
||||
@@ -658,14 +668,15 @@ 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 +690,11 @@ 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);
|
||||
this->tiles.append(r);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,14 +10,13 @@
|
||||
#include <QWidget>
|
||||
#include <xcb/xcb.h>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@author Alexey Min <alexey.min@gmail.com>
|
||||
*/
|
||||
class XCBFrameBuffer : public FrameBuffer
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit XCBFrameBuffer(QObject *parent = nullptr);
|
||||
~XCBFrameBuffer() override;
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -17,7 +17,9 @@ class ConnectionDialog : public QDialog
|
||||
{
|
||||
public:
|
||||
explicit ConnectionDialog(QWidget *parent);
|
||||
~ConnectionDialog() override {};
|
||||
~ConnectionDialog() override
|
||||
{
|
||||
}
|
||||
|
||||
void setAllowRemoteControl(bool b);
|
||||
bool allowRemoteControl();
|
||||
@@ -45,6 +47,7 @@ bool ConnectionDialog<UI>::allowRemoteControl()
|
||||
class InvitationsConnectionDialog : public ConnectionDialog<Ui::ConnectionWidget>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit InvitationsConnectionDialog(QWidget *parent);
|
||||
void setRemoteHost(const QString &host);
|
||||
@@ -53,4 +56,3 @@ public:
|
||||
//*********
|
||||
|
||||
#endif // CONNECTIONDIALOG_H
|
||||
|
||||
|
||||
@@ -13,14 +13,15 @@
|
||||
#define EVENTS_H
|
||||
|
||||
#include "framebuffer.h"
|
||||
#include "rfb.h"
|
||||
#include "krfbprivate_export.h"
|
||||
#include "rfb.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class KRFBPRIVATE_EXPORT EventHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EventHandler(QObject *parent = nullptr);
|
||||
~EventHandler() override = default;
|
||||
@@ -29,6 +30,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
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
/* This file is part of the KDE project
|
||||
SPDX-FileCopyrightText: 2016 Oleg Chernovskiy <kanedias@xaker.ru>
|
||||
|
||||
|
||||
@@ -10,14 +10,15 @@
|
||||
|
||||
#include "krfbprivate_export.h"
|
||||
|
||||
#include <QtCore/QVariantList>
|
||||
#include <QWidget>
|
||||
#include <QtCore/QVariantList>
|
||||
|
||||
class EventHandler;
|
||||
|
||||
class KRFBPRIVATE_EXPORT EventsPlugin : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
EventsPlugin(QObject *parent, const QVariantList &args);
|
||||
~EventsPlugin() override;
|
||||
@@ -26,4 +27,3 @@ public:
|
||||
};
|
||||
|
||||
#endif // Header guard
|
||||
|
||||
|
||||
@@ -6,11 +6,10 @@
|
||||
|
||||
#include "framebuffer.h"
|
||||
|
||||
#include <config-krfb.h>
|
||||
#include <QCursor>
|
||||
#include <QGuiApplication>
|
||||
#include <QScreen>
|
||||
|
||||
#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>
|
||||
@@ -25,6 +24,7 @@ class FrameBuffer;
|
||||
class KRFBPRIVATE_EXPORT FrameBuffer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FrameBuffer(QObject *parent = nullptr);
|
||||
|
||||
@@ -54,7 +54,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:
|
||||
|
||||
@@ -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,42 @@
|
||||
|
||||
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
|
||||
{
|
||||
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,13 +57,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));
|
||||
accept(new InvitationsRfbClient(m_rfbClient, parent()));
|
||||
|
||||
} else {
|
||||
|
||||
KNotification::event(QStringLiteral("NewConnectionOnHold"),
|
||||
i18n("Received connection from %1, on hold (waiting for confirmation)",
|
||||
host));
|
||||
@@ -79,9 +81,7 @@ 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;
|
||||
}
|
||||
|
||||
@@ -13,13 +13,15 @@ class InvitationsRfbClient : public RfbClient
|
||||
{
|
||||
public:
|
||||
explicit InvitationsRfbClient(rfbClientPtr client, QObject *parent = nullptr)
|
||||
: RfbClient(client, parent) {}
|
||||
: RfbClient(client, parent)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class PendingInvitationsRfbClient : public PendingRfbClient
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PendingInvitationsRfbClient(rfbClientPtr client, QObject *parent = nullptr);
|
||||
~PendingInvitationsRfbClient() override;
|
||||
|
||||
@@ -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>
|
||||
@@ -87,8 +87,9 @@ bool InvitationsRfbServer::allowUnattendedAccess() const
|
||||
bool InvitationsRfbServer::start()
|
||||
{
|
||||
if (RfbServer::start()) {
|
||||
if(KrfbConfig::publishService())
|
||||
if (KrfbConfig::publishService()) {
|
||||
m_publicService->publishAsync();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -96,8 +97,9 @@ bool InvitationsRfbServer::start()
|
||||
|
||||
void InvitationsRfbServer::stop()
|
||||
{
|
||||
if(m_publicService->isPublished())
|
||||
if (m_publicService->isPublished()) {
|
||||
m_publicService->stop();
|
||||
}
|
||||
RfbServer::stop();
|
||||
}
|
||||
|
||||
@@ -115,7 +117,8 @@ InvitationsRfbServer::InvitationsRfbServer()
|
||||
m_unattendedPassword = readableRandomString(4) + QLatin1Char('-') + readableRandomString(3);
|
||||
KConfigGroup krfbConfig(KSharedConfig::openConfig(), QStringLiteral("Security"));
|
||||
m_allowUnattendedAccess = krfbConfig.readEntry(
|
||||
"allowUnattendedAccess", QVariant(false)).toBool();
|
||||
"allowUnattendedAccess", QVariant(false))
|
||||
.toBool();
|
||||
}
|
||||
|
||||
InvitationsRfbServer::~InvitationsRfbServer()
|
||||
@@ -158,14 +161,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 +191,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);
|
||||
|
||||
@@ -11,17 +11,24 @@
|
||||
|
||||
#include "rfbserver.h"
|
||||
|
||||
namespace KWallet {
|
||||
namespace KWallet
|
||||
{
|
||||
|
||||
class Wallet;
|
||||
|
||||
}
|
||||
|
||||
namespace KDNSSD {
|
||||
namespace KDNSSD
|
||||
{
|
||||
|
||||
class PublicService;
|
||||
|
||||
}
|
||||
|
||||
class InvitationsRfbServer : public RfbServer
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static InvitationsRfbServer *instance;
|
||||
static void init();
|
||||
|
||||
@@ -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,25 @@ 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));
|
||||
}
|
||||
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 +68,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);
|
||||
}
|
||||
|
||||
@@ -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,14 +18,13 @@
|
||||
#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()
|
||||
{
|
||||
@@ -44,7 +43,8 @@ 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(
|
||||
|
||||
@@ -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();
|
||||
@@ -78,7 +84,8 @@ public:
|
||||
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 +93,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: KXmlGuiWindow(parent)
|
||||
{
|
||||
@@ -124,11 +130,11 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
int port = KrfbConfig::port();
|
||||
const QList<QNetworkInterface> interfaceList = QNetworkInterface::allInterfaces();
|
||||
for (const QNetworkInterface &interface : interfaceList) {
|
||||
if(interface.flags() & QNetworkInterface::IsLoopBack)
|
||||
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()
|
||||
|
||||
@@ -16,4 +16,3 @@
|
||||
#undef FALSE
|
||||
|
||||
#endif // Header guard
|
||||
|
||||
|
||||
@@ -8,20 +8,21 @@
|
||||
*/
|
||||
#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
|
||||
{
|
||||
Private(rfbClientPtr client) :
|
||||
controlEnabled(KrfbConfig::allowDesktopControl()),
|
||||
client(client)
|
||||
{}
|
||||
Private(rfbClientPtr client)
|
||||
: controlEnabled(KrfbConfig::allowDesktopControl())
|
||||
, client(client)
|
||||
{
|
||||
}
|
||||
|
||||
bool controlEnabled;
|
||||
rfbClientPtr client;
|
||||
@@ -31,10 +32,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,7 +160,8 @@ 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;
|
||||
@@ -170,7 +172,8 @@ PendingRfbClient::PendingRfbClient(rfbClientPtr client, QObject *parent)
|
||||
}
|
||||
|
||||
PendingRfbClient::~PendingRfbClient()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
void PendingRfbClient::accept(RfbClient *newClient)
|
||||
{
|
||||
@@ -183,7 +186,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()
|
||||
{
|
||||
|
||||
@@ -19,6 +19,7 @@ class RfbClient : public QObject
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool controlEnabled READ controlEnabled WRITE setControlEnabled NOTIFY controlEnabledChanged)
|
||||
Q_PROPERTY(bool onHold READ isOnHold WRITE setOnHold NOTIFY holdStatusChanged)
|
||||
|
||||
public:
|
||||
explicit RfbClient(rfbClientPtr client, QObject *parent = nullptr);
|
||||
~RfbClient() override;
|
||||
@@ -59,10 +60,10 @@ private:
|
||||
Private *const d;
|
||||
};
|
||||
|
||||
|
||||
class PendingRfbClient : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PendingRfbClient(rfbClientPtr client, QObject *parent = nullptr);
|
||||
~PendingRfbClient() override;
|
||||
@@ -77,7 +78,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,12 +7,12 @@
|
||||
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
|
||||
@@ -27,7 +27,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;
|
||||
@@ -203,8 +204,9 @@ void krfb_rfbSetCursorPosition(rfbScreenInfoPtr screen, rfbClientPtr client, int
|
||||
rfbClientIteratorPtr iterator;
|
||||
rfbClientPtr cl;
|
||||
|
||||
if (x == screen->cursorX || y == screen->cursorY)
|
||||
if (x == screen->cursorX || y == screen->cursorY) {
|
||||
return;
|
||||
}
|
||||
|
||||
LOCK(screen->cursorMutex);
|
||||
screen->cursorX = x;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
class RfbServer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RfbServer(QObject *parent = nullptr);
|
||||
~RfbServer() override;
|
||||
|
||||
@@ -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,7 +69,6 @@ static const char *mask =
|
||||
" xxxxx "
|
||||
" xxx ";
|
||||
|
||||
|
||||
struct RfbServerManagerStatic
|
||||
{
|
||||
RfbServerManager server;
|
||||
@@ -92,9 +91,9 @@ struct RfbServerManager::Private
|
||||
QSet<RfbClient *> clients;
|
||||
};
|
||||
|
||||
|
||||
RfbServerManager::RfbServerManager()
|
||||
: QObject(), d(new Private)
|
||||
: QObject()
|
||||
, d(new Private)
|
||||
{
|
||||
init();
|
||||
}
|
||||
@@ -125,7 +124,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);
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#ifndef RFBSERVERMANAGER_H
|
||||
#define RFBSERVERMANAGER_H
|
||||
|
||||
#include "rfb.h"
|
||||
#include "framebuffer.h"
|
||||
#include "rfb.h"
|
||||
#include <QObject>
|
||||
#include <QVariantMap>
|
||||
|
||||
@@ -21,6 +21,7 @@ class RfbServer;
|
||||
class RfbServerManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static RfbServerManager *instance();
|
||||
|
||||
|
||||
@@ -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,8 +8,8 @@
|
||||
#include "trayicon.h"
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "rfbservermanager.h"
|
||||
#include "rfbclient.h"
|
||||
#include "rfbservermanager.h"
|
||||
|
||||
#include <QIcon>
|
||||
#include <QMenu>
|
||||
@@ -17,11 +17,11 @@
|
||||
#include <KAboutApplicationDialog>
|
||||
#include <KAboutData>
|
||||
#include <KActionCollection>
|
||||
#include <QDialog>
|
||||
#include <KConfigGroup>
|
||||
#include <KLocalizedString>
|
||||
#include <KStandardAction>
|
||||
#include <KToggleAction>
|
||||
#include <KConfigGroup>
|
||||
#include <QDialog>
|
||||
|
||||
class ClientActions
|
||||
{
|
||||
|
||||
@@ -21,6 +21,7 @@ class ClientActions;
|
||||
class TrayIcon : public KStatusNotifierItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TrayIcon(QWidget *mainWindow);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user