Compare commits

..

1 Commits

Author SHA1 Message Date
l10n daemon script
a668a3091f SVN_SILENT made messages (.desktop file) 2015-05-25 07:50:30 +00:00
53 changed files with 1182 additions and 593 deletions

View File

@@ -1,44 +1,32 @@
cmake_minimum_required(VERSION 2.8.12)
project(krfb)
include(FeatureSummary)
find_package(Qt5 REQUIRED COMPONENTS Core DBus Widgets X11Extras)
if(NOT INSIDE_KDENETWORK)
message("Not building inside KDENetwork, loading KDE CMake Macros.")
find_package(ECM 1.7.0 NO_MODULE REQUIRED)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
find_package(KDE4 REQUIRED)
include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDECompilerSettings)
include(ECMInstallIcons)
include(ECMAddAppIcon)
include(KDE4Defaults)
include(MacroLibrary)
find_package(KF5 REQUIRED COMPONENTS
I18n
Completion
Config
CoreAddons
Crash
DBusAddons
DNSSD
DocTools
Notifications
Wallet
WidgetsAddons
XmlGui
)
include(CheckIncludeFile)
include(CheckIncludeFiles)
include(CheckSymbolExists)
include(CheckFunctionExists)
include(CheckLibraryExists)
include(CheckPrototypeExists)
include(CheckTypeSize)
find_package(X11 REQUIRED)
if(WIN32)
set(CMAKE_REQUIRED_LIBRARIES ${KDEWIN32_LIBRARIES})
set(CMAKE_REQUIRED_INCLUDES ${KDEWIN32_INCLUDES})
endif(WIN32)
add_definitions(${QT_DEFINITIONS} ${QT_QTDBUS_DEFINITIONS})
add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} )
set(CMAKE_REQUIRED_DEFINITIONS ${_KDE4_PLATFORM_DEFINITIONS})
if(WIN32)
set(CMAKE_REQUIRED_LIBRARIES ${KDEWIN32_LIBRARIES})
set(CMAKE_REQUIRED_INCLUDES ${KDEWIN32_INCLUDES})
endif(WIN32)
add_definitions(${QT_DEFINITIONS} ${QT_QTDBUS_DEFINITIONS} ${KDE4_DEFINITIONS})
add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES})
endif(NOT INSIDE_KDENETWORK)
set(IS_KTP_INTERNAL_MODULE TRUE)
set(CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
${CMAKE_MODULE_PATH}
@@ -46,16 +34,14 @@ set(CMAKE_MODULE_PATH
find_package(LibVNCServer REQUIRED)
if (HAVE_XDAMAGE)
set(X11_Xdamage_FOUND 1)
else()
set(X11_Xdamage_FOUND 0)
endif()
if (HAVE_XSHM)
set(X11_XShm_FOUND 1)
else()
set(X11_XShm_FOUND 0)
endif()
macro_optional_find_package(TelepathyQt4)
macro_log_feature(TelepathyQt4_FOUND "telepathy-qt" "Telepathy Qt Bindings" "http://telepathy.freedesktop.org" FALSE "0.9" "Needed to build Telepathy Tubes support.")
macro_optional_find_package(KTp)
macro_log_feature(KTP_FOUND "KTP" "KDE Telepathy" "https://projects.kde.org/projects/extragear/network/telepathy" FALSE "" "Needed to build KDE IM Contacts Display in KRFB.")
macro_bool_to_01(X11_Xdamage_FOUND HAVE_XDAMAGE)
macro_bool_to_01(X11_XShm_FOUND HAVE_XSHM)
include_directories ("${CMAKE_CURRENT_BINARY_DIR}/krfb"
"${CMAKE_CURRENT_SOURCE_DIR}/krfb"
@@ -72,4 +58,6 @@ add_subdirectory(krfb)
add_subdirectory(framebuffers)
add_subdirectory(doc)
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
if (NOT INSIDE_KDENETWORK)
macro_display_feature_log()
endif ()

View File

@@ -0,0 +1,38 @@
# Try to find the KTp library
# KTP_FOUND
# KTP_INCLUDE_DIR
# KTP_LIBRARIES
# KTP_MODELS_LIBRARIES
# KTP_WIDGETS_LIBRARIES
# Copyright (c) 2011, Dario Freddi <drf@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
if (NOT IS_KTP_INTERNAL_MODULE)
message (FATAL_ERROR "KTp can be used just from internal components at this time")
endif (NOT IS_KTP_INTERNAL_MODULE)
SET (KTP_FIND_REQUIRED ${KTp_FIND_REQUIRED})
if (KTP_INCLUDE_DIRS AND KTP_LIBRARIES)
# Already in cache, be silent
set(KTP_FIND_QUIETLY TRUE)
endif (KTP_INCLUDE_DIRS AND KTP_LIBRARIES)
find_path(KTP_INCLUDE_DIR
NAMES KTp/presence.h
PATHS ${KDE4_INCLUDE_DIR}
)
find_library(KTP_LIBRARIES NAMES ktpcommoninternalsprivate )
find_library(KTP_MODELS_LIBRARIES NAMES ktpmodelsprivate )
find_library(KTP_WIDGETS_LIBRARIES NAMES ktpwidgetsprivate )
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(KTp DEFAULT_MSG
KTP_LIBRARIES
KTP_MODELS_LIBRARIES
KTP_INCLUDE_DIR)
mark_as_advanced(KTP_INCLUDE_DIRS KTP_LIBRARIES)

View File

@@ -6,7 +6,7 @@
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
INCLUDE(CheckStructHasMember)
INCLUDE(CheckPointerMember)
IF (LIBVNCSERVER_INCLUDE_DIR AND LIBVNCSERVER_LIBRARIES)
# Already in cache, be silent
@@ -25,7 +25,7 @@ FIND_LIBRARY(LIBVNCCLIENT_LIBRARIES NAMES vncclient libvncclient)
IF (LIBVNCSERVER_INCLUDE_DIR AND LIBVNCSERVER_LIBRARIES)
SET(CMAKE_REQUIRED_INCLUDES "${LIBVNCSERVER_INCLUDE_DIR}" "${CMAKE_REQUIRED_INCLUDES}")
CHECK_STRUCT_HAS_MEMBER("struct _rfbClient" GotXCutText rfb/rfbclient.h LIBVNCSERVER_FOUND)
CHECK_POINTER_MEMBER(rfbClient* GotXCutText rfb/rfbclient.h LIBVNCSERVER_FOUND)
ENDIF (LIBVNCSERVER_INCLUDE_DIR AND LIBVNCSERVER_LIBRARIES)
IF (LIBVNCSERVER_FOUND)

View File

@@ -1,2 +1,2 @@
########### install files ###############
kdoctools_create_handbook(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR krfb)
kde4_create_handbook(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR krfb)

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" ?>
<!DOCTYPE book PUBLIC "-//KDE//DTD DocBook XML V4.5-Based Variant V1.1//EN" "dtd/kdedbx45.dtd" [
<!DOCTYPE book PUBLIC "-//KDE//DTD DocBook XML V4.2-Based Variant V1.1//EN" "dtd/kdex.dtd" [
<!ENTITY kappname "&krfb;">
<!ENTITY package "kdenetwork">
<!ENTITY % addindex "IGNORE">

View File

@@ -7,18 +7,22 @@ set (krfb_framebuffer_qt_SRCS
qtframebufferplugin.cpp
)
add_library(krfb_framebuffer_qt
MODULE
kde4_add_plugin (krfb_framebuffer_qt
${krfb_framebuffer_qt_SRCS}
)
target_link_libraries (krfb_framebuffer_qt
Qt5::Core
Qt5::Gui
KF5::CoreAddons
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
${KDE4_KDEUI_LIBS}
krfbprivate
)
install (TARGETS krfb_framebuffer_qt
DESTINATION ${PLUGIN_INSTALL_DIR}/krfb
DESTINATION ${PLUGIN_INSTALL_DIR}
)
install (FILES krfb_framebuffer_qt.desktop
DESTINATION ${SERVICES_INSTALL_DIR}
)

View File

@@ -1,66 +0,0 @@
{
"Encoding": "UTF-8",
"KPlugin": {
"Description": "Qt based Framebuffer for KRfb.",
"Description[ca@valencia]": "«Framebuffer» basat en Qt per al KRfb.",
"Description[ca]": "«Framebuffer» basat en Qt per al KRfb.",
"Description[cs]": "Framebuffer založený na Qt pro KRfb.",
"Description[de]": "Qt-basierter Framebuffer für KRfb",
"Description[en_GB]": "Qt based Framebuffer for KRfb.",
"Description[es]": "Framebuffer basado en Qt para KRfb.",
"Description[fi]": "QT-perustainen Kehyspuskuri KRfb:lle",
"Description[gl]": "Framebuffer baseado en Qt para KRfb.",
"Description[it]": "Framebuffer basato su Qt per KRfb.",
"Description[ko]": "KRfb용 Qt 기반 프레임버퍼입니다.",
"Description[nl]": "Op Qt gebaseerd framebuffer voor KRfb.",
"Description[pl]": "Bufor ramki na podstawie Qt dla KRfb.",
"Description[pt]": "'Framebuffer' baseado no Qt para o KRfb.",
"Description[pt_BR]": "Framebuffer baseado no Qt para o KRfb.",
"Description[sk]": "Framebuffer založený na Qt pre KRfb.",
"Description[sl]": "Slikovni medpomnilnik za KRfb, ki temelji na Qt",
"Description[sr@ijekavian]": "Кадробафер за КРФБ на основу КуТу",
"Description[sr@ijekavianlatin]": "Kadrobafer za KRFB na osnovu Qtu",
"Description[sr@latin]": "Kadrobafer za KRFB na osnovu Qtu",
"Description[sr]": "Кадробафер за КРФБ на основу КуТу",
"Description[sv]": "X11-rambuffert för Krfb.",
"Description[uk]": "Заснований на Qt буфер кадрів для KRfb.",
"Description[x-test]": "xxQt based Framebuffer for KRfb.xx",
"Description[zh_CN]": "KRfb 的基于 Qt 的帧缓冲。",
"Description[zh_TW]": "KRfb 的 Qt-based Framebuffer",
"EnabledByDefault": true,
"Id": "qt",
"License": "GPL",
"Name": "Qt Framebuffer for KRfb",
"Name[ast]": "Framebuffer Qt pa KRfb",
"Name[ca@valencia]": "«Framebuffer» Qt per al KRfb.",
"Name[ca]": "«Framebuffer» Qt per al KRfb.",
"Name[cs]": "Qt Framebuffer pro KRfb",
"Name[de]": "Qt-Framebuffer für KRfb",
"Name[en_GB]": "Qt Framebuffer for KRfb",
"Name[es]": "Framebuffer de Qt para KRfb",
"Name[fi]": "QT-kehyspuskuri KRfb:lle",
"Name[gl]": "Framebuffer de Qt para KRfb",
"Name[it]": "Framebuffer Qt per KRfb",
"Name[ko]": "KRfb용 Qt 프레임버퍼",
"Name[nl]": "Qt-framebuffer voor KRfb",
"Name[pl]": "Bufor ramki Qt dla KRfb",
"Name[pt]": "'Framebuffer' do Qt para o KRfb",
"Name[pt_BR]": "Framebuffer do Qt para o KRfb",
"Name[sk]": "Qt Framebuffer pre KRfb",
"Name[sl]": "Slikovni medpomnilnik Qt za KRfb",
"Name[sr@ijekavian]": "КуТ‑ов кадробафер за КРФБ",
"Name[sr@ijekavianlatin]": "Qtov kadrobafer za KRFB",
"Name[sr@latin]": "Qtov kadrobafer za KRFB",
"Name[sr]": "КуТ‑ов кадробафер за КРФБ",
"Name[sv]": "X11-rambuffert för Krfb",
"Name[uk]": "Буфер кадрів на Qt для KRfb",
"Name[x-test]": "xxQt Framebuffer for KRfbxx",
"Name[zh_CN]": "KRfb 的 Qt 帧缓冲",
"Name[zh_TW]": "Krfb 的 Qt Framebuffer",
"ServiceTypes": [
"krfb/framebuffer"
],
"Version": "0.1",
"Website": "http://www.kde.org"
}
}

View File

@@ -22,9 +22,9 @@ QtFrameBuffer::QtFrameBuffer(WId id, QObject *parent)
: FrameBuffer(id, parent)
{
fbImage = QPixmap::grabWindow(win).toImage();
fb = new char[fbImage.byteCount()];
fb = new char[fbImage.numBytes()];
t = new QTimer(this);
connect(t, &QTimer::timeout, this, &QtFrameBuffer::updateFrameBuffer);
connect(t, SIGNAL(timeout()), SLOT(updateFrameBuffer()));
}
@@ -67,7 +67,6 @@ void QtFrameBuffer::getServerFormat(rfbPixelFormat &format)
void QtFrameBuffer::updateFrameBuffer()
{
QImage img = QPixmap::grabWindow(win).toImage();
#if 0 // This is actually slower than updating the whole desktop...
QSize imgSize = img.size();
@@ -75,6 +74,8 @@ void QtFrameBuffer::updateFrameBuffer()
// fbImage is the previous version of the image,
// img is the current one
#if 0 // This is actually slower than updating the whole desktop...
QImage map(imgSize, QImage::Format_Mono);
map.fill(0);
@@ -93,7 +94,7 @@ void QtFrameBuffer::updateFrameBuffer()
tiles.append(img.rect());
#endif
memcpy(fb, (const char *)img.bits(), img.byteCount());
memcpy(fb, (const char *)img.bits(), img.numBytes());
fbImage = img;
}

View File

@@ -25,13 +25,13 @@ public:
~QtFrameBuffer();
int depth() override;
int height() override;
int width() override;
int paddedWidth() override;
void getServerFormat(rfbPixelFormat &format) override;
void startMonitor() override;
void stopMonitor() override;
virtual int depth();
virtual int height();
virtual int width();
virtual int paddedWidth();
virtual void getServerFormat(rfbPixelFormat &format);
virtual void startMonitor();
virtual void stopMonitor();
public Q_SLOTS:
void updateFrameBuffer();

View File

@@ -22,10 +22,8 @@
#include "qtframebuffer.h"
#include <KPluginFactory>
#include <KGenericFactory>
K_PLUGIN_FACTORY_WITH_JSON(QtFrameBufferPluginFactory, "krfb_framebuffer_qt.json",
registerPlugin<QtFrameBufferPlugin>();)
QtFrameBufferPlugin::QtFrameBufferPlugin(QObject *parent, const QVariantList &args)
: FrameBufferPlugin(parent, args)
@@ -41,5 +39,9 @@ FrameBuffer *QtFrameBufferPlugin::frameBuffer(WId id)
return new QtFrameBuffer(id);
}
K_PLUGIN_FACTORY(factory, registerPlugin<QtFrameBufferPlugin>();) \
K_EXPORT_PLUGIN(factory("krfb_framebuffer_qt"))
#include "qtframebufferplugin.moc"

View File

@@ -23,7 +23,9 @@
#include "framebufferplugin.h"
#include <QWidget>
#include <kdemacros.h>
#include <QtGui/QWidget>
class FrameBuffer;
@@ -35,7 +37,7 @@ public:
QtFrameBufferPlugin(QObject *parent, const QVariantList &args);
virtual ~QtFrameBufferPlugin();
FrameBuffer *frameBuffer(WId id) override;
virtual FrameBuffer *frameBuffer(WId id);
private:
Q_DISABLE_COPY(QtFrameBufferPlugin)

View File

@@ -7,21 +7,25 @@ set (krfb_framebuffer_x11_SRCS
x11framebufferplugin.cpp
)
add_library(krfb_framebuffer_x11
MODULE
kde4_add_plugin (krfb_framebuffer_x11
${krfb_framebuffer_x11_SRCS}
)
target_link_libraries (krfb_framebuffer_x11
Qt5::Core
Qt5::Gui
${KDE4_KDEUI_LIBS}
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
${X11_X11_LIB}
${X11_Xdamage_LIB}
${X11_Xext_LIB}
KF5::CoreAddons
krfbprivate
)
install (TARGETS krfb_framebuffer_x11
DESTINATION ${PLUGIN_INSTALL_DIR}/krfb
DESTINATION ${PLUGIN_INSTALL_DIR}
)
install (FILES krfb_framebuffer_x11.desktop
DESTINATION ${SERVICES_INSTALL_DIR}
)

View File

@@ -5,7 +5,7 @@ Comment[ast]=Esquema de buffer pa KRfb basáu en XDamage/XShm
Comment[bg]=Основан на X11 XDamage/XShm фреймбуфер за KRfb.
Comment[bs]=X11 XDamage/XShm baziran framebafer za KRfb.
Comment[ca]=«Framebuffer» basat en XDamage/XShmQt del X11 per al KRfb.
Comment[ca@valencia]=«Framebuffer» basat en XDamage/XShmQt del X11 per al KRfb.
Comment[ca@valencia]=«Framebuffer» basat en XDamage/XShmQt de l'X11 per al KRfb.
Comment[cs]=Framebuffer založený na X11 XDamage/XShm pro KRfb.
Comment[da]=X11 XDamage/XShm-baseret framebuffer til KRfb.
Comment[de]=X11 XDamage/XShm-basierter Framebuffer für KRfb.
@@ -53,7 +53,7 @@ Name[ast]=Buffer de X11 pa KRfb
Name[bg]=X11 фреймбуфер за KRfb
Name[bs]=X11 frame bafer za KRfb
Name[ca]=«Framebuffer» del X11 per al KRfb.
Name[ca@valencia]=«Framebuffer» del X11 per al KRfb.
Name[ca@valencia]=«Framebuffer» de l'X11 per al KRfb.
Name[cs]=X11 Framebuffer pro KRfb
Name[da]=X11-framebuffer til KRfb
Name[de]=X11-Framebuffer für KRfb

View File

@@ -1,65 +0,0 @@
{
"Encoding": "UTF-8",
"KPlugin": {
"Description": "X11 XDamage/XShm based Framebuffer for KRfb.",
"Description[ca@valencia]": "«Framebuffer» basat en XDamage/XShmQt del X11 per al KRfb.",
"Description[ca]": "«Framebuffer» basat en XDamage/XShmQt del X11 per al KRfb.",
"Description[cs]": "Framebuffer založený na X11 XDamage/XShm pro KRfb.",
"Description[de]": "X11 XDamage/XShm-basierter Framebuffer für KRfb.",
"Description[en_GB]": "X11 XDamage/XShm based Framebuffer for KRfb.",
"Description[es]": "Framebuffer basado en XDamage/XShm de X11 para KRfb.",
"Description[fi]": "X11 XDamage/XShm-perustainen kehyspuskui KRfb:lle.",
"Description[gl]": "Framebuffer baseado en Xll XDamage/Xshm para XRfb.",
"Description[it]": "Framebuffer basato su XDamage/XShm di X11 per KRfb.",
"Description[ko]": "KRfb용 X11 XDamage/XShm 기반 프레임버퍼입니다.",
"Description[nl]": "Op X11 XDamage/XShm gebaseerd framebuffer voor KRfb.",
"Description[pl]": "Bufor ramki na podstawie X11 XDamage/XShm dla KRfb.",
"Description[pt]": "'Framebuffer' do X11, baseado no XDamage/XShm, para o KRfb.",
"Description[pt_BR]": "Framebuffer baseado no XDamage/XShm do X11 para o KRfb.",
"Description[sk]": "Framebuffer založený na X11 XDamage/XShm pre KRfb.",
"Description[sl]": "Slikovni medpomnilnik za KRfb, ki temelji na X11 XDamage/XShm",
"Description[sr@ijekavian]": "Кадробафер за КРФБ на основу Икс‑демиџа/Икс‑схма у Иксу11.",
"Description[sr@ijekavianlatin]": "Kadrobafer za KRFB na osnovu XDamagea/XShma u X11.",
"Description[sr@latin]": "Kadrobafer za KRFB na osnovu XDamagea/XShma u X11.",
"Description[sr]": "Кадробафер за КРФБ на основу Икс‑демиџа/Икс‑схма у Иксу11.",
"Description[sv]": "X11 XDamage/XShm-baserad rambuffert för Krfb.",
"Description[uk]": "Заснований на XDamage/XShm X11 буфер кадрів для KRfb.",
"Description[x-test]": "xxX11 XDamage/XShm based Framebuffer for KRfb.xx",
"Description[zh_CN]": "KRfb 的基于 X11 XDamage/XShm 的帧缓冲。",
"Description[zh_TW]": "KRfb 的 X11 XDamage/XShm based Framebuffer",
"EnabledByDefault": true,
"Id": "x11",
"License": "GPL",
"Name": "X11 Framebuffer for KRfb",
"Name[ca@valencia]": "«Framebuffer» del X11 per al KRfb.",
"Name[ca]": "«Framebuffer» del X11 per al KRfb.",
"Name[cs]": "X11 Framebuffer pro KRfb",
"Name[de]": "X11-Framebuffer für KRfb",
"Name[en_GB]": "X11 Framebuffer for KRfb",
"Name[es]": "Framebuffer X11 para KRfb",
"Name[fi]": "X11-kehyspuskuri KRfb:lle",
"Name[gl]": "Framebuffer de X11 para KRfb",
"Name[it]": "Framebuffer X11 per KRfb",
"Name[ko]": "KRfb용 X11 프레임버퍼",
"Name[nl]": "X11 framebuffer voor KRfb",
"Name[pl]": "Bufor ramki X11 dla KRfb",
"Name[pt]": "'Framebuffer' do X11 para o KRfb",
"Name[pt_BR]": "Framebuffer do X11 para o KRfb",
"Name[sk]": "X11 Framebuffer pre KRfb",
"Name[sl]": "Slikovni medpomnilnik X11 za KRfb",
"Name[sr@ijekavian]": "Икс11 кадробафер за КРФБ.",
"Name[sr@ijekavianlatin]": "X11 kadrobafer za KRFB.",
"Name[sr@latin]": "X11 kadrobafer za KRFB.",
"Name[sr]": "Икс11 кадробафер за КРФБ.",
"Name[sv]": "X11-rambuffert för Krfb",
"Name[uk]": "Буфер кадрів X11 для KRfb",
"Name[x-test]": "xxX11 Framebuffer for KRfbxx",
"Name[zh_CN]": "XRfb 的 X11 帧缓冲",
"Name[zh_TW]": "KRfb 的 X11 Framebuffer",
"ServiceTypes": [
"krfb/framebuffer"
],
"Version": "0.1",
"Website": "http://www.kde.org"
}
}

View File

@@ -16,7 +16,8 @@
#include <QApplication>
#include <QDesktopWidget>
#include <QDebug>
#include <KApplication>
#include <KDebug>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@@ -55,7 +56,7 @@ X11FrameBuffer::X11FrameBuffer(WId id, QObject *parent)
{
#ifdef HAVE_XSHM
d->useShm = XShmQueryExtension(QX11Info::display());
//qDebug() << "shm: " << d->useShm;
kDebug() << "shm: " << d->useShm;
#else
d->useShm = false;
#endif
@@ -93,7 +94,7 @@ X11FrameBuffer::X11FrameBuffer(WId id, QObject *parent)
;
}
qDebug() << "Got image. bpp: " << d->framebufferImage->bits_per_pixel
kDebug() << "Got image. bpp: " << d->framebufferImage->bits_per_pixel
<< ", depth: " << d->framebufferImage->depth
<< ", padded width: " << d->framebufferImage->bytes_per_line
<< " (sent: " << d->framebufferImage->width * 4 << ")"
@@ -102,7 +103,7 @@ X11FrameBuffer::X11FrameBuffer(WId id, QObject *parent)
fb = d->framebufferImage->data;
#ifdef HAVE_XDAMAGE
d->ev = new EvWidget(this);
qApp->installX11EventFilter(d->ev);
kapp->installX11EventFilter(d->ev);
#endif
}
@@ -111,7 +112,7 @@ X11FrameBuffer::~X11FrameBuffer()
{
XDestroyImage(d->framebufferImage);
#ifdef HAVE_XDAMAGE
qApp->removeX11EventFilter(d->ev);
kapp->removeX11EventFilter(d->ev);
#endif
#ifdef HAVE_XSHM
XShmDetach(QX11Info::display(), &d->shminfo);
@@ -206,25 +207,25 @@ void X11FrameBuffer::cleanupRects()
QList<QRect> cpy = tiles;
bool inserted = false;
tiles.clear();
// //qDebug() << "before cleanup: " << cpy.size();
// kDebug() << "before cleanup: " << cpy.size();
foreach(const QRect & r, cpy) {
if (tiles.size() > 0) {
for (int i = 0; i < tiles.size(); i++) {
// //qDebug() << r << tiles[i];
// kDebug() << r << tiles[i];
if (r.intersects(tiles[i])) {
tiles[i] |= r;
inserted = true;
break;
// //qDebug() << "merged into " << tiles[i];
// kDebug() << "merged into " << tiles[i];
}
}
if (!inserted) {
tiles.append(r);
// //qDebug() << "appended " << r;
// kDebug() << "appended " << r;
}
} else {
// //qDebug() << "appended " << r;
// kDebug() << "appended " << r;
tiles.append(r);
}
}
@@ -249,7 +250,7 @@ void X11FrameBuffer::cleanupRects()
}
}
// //qDebug() << "after cleanup: " << tiles.size();
// kDebug() << "after cleanup: " << tiles.size();
}
void X11FrameBuffer::acquireEvents()
@@ -257,13 +258,11 @@ void X11FrameBuffer::acquireEvents()
XEvent ev;
#ifdef HAVE_XDAMAGE
while (XCheckTypedEvent(QX11Info::display(), d->xdamageBaseEvent + XDamageNotify, &ev)) {
handleXDamage(&ev);
}
XDamageSubtract(QX11Info::display(), d->damage, None, None);
#endif
}
QList< QRect > X11FrameBuffer::modifiedTiles()
@@ -274,7 +273,7 @@ QList< QRect > X11FrameBuffer::modifiedTiles()
return ret;
}
qApp->processEvents(); // try to make sure every damage event goes trough;
kapp->processEvents(); // try to make sure every damage event goes trough;
cleanupRects();
QRect gl;
@@ -284,7 +283,7 @@ QList< QRect > X11FrameBuffer::modifiedTiles()
#ifdef HAVE_XSHM
foreach(const QRect & r, tiles) {
// //qDebug() << r;
// kDebug() << r;
gl |= r;
int y = r.y();
int x = r.x();
@@ -299,7 +298,7 @@ QList< QRect > X11FrameBuffer::modifiedTiles()
x = d->framebufferImage->width - d->updateTile->width;
}
// //qDebug() << "x: " << x << " (" << r.x() << ") y: " << y << " (" << r.y() << ") " << r;
// kDebug() << "x: " << x << " (" << r.x() << ") y: " << y << " (" << r.y() << ") " << r;
XShmGetImage(QX11Info::display(), win, d->updateTile, x, y, AllPlanes);
int pxsize = d->framebufferImage->bits_per_pixel / 8;
char *dest = fb + ((d->framebufferImage->bytes_per_line * y) + (x * pxsize));
@@ -337,8 +336,8 @@ QList< QRect > X11FrameBuffer::modifiedTiles()
}
}
// //qDebug() << "tot: " << gl;
// //qDebug() << tiles.size();
// kDebug() << "tot: " << gl;
// kDebug() << tiles.size();
ret = tiles;
tiles.clear();
return ret;

View File

@@ -13,7 +13,6 @@
#include <QWidget>
class X11FrameBuffer;
typedef union _XEvent XEvent;
class EvWidget: public QWidget
{
@@ -41,14 +40,14 @@ public:
~X11FrameBuffer();
QList<QRect> modifiedTiles() override;
int depth() override;
int height() override;
int width() override;
int paddedWidth() override;
void getServerFormat(rfbPixelFormat &format) override;
void startMonitor() override;
void stopMonitor() override;
virtual QList<QRect> modifiedTiles();
virtual int depth();
virtual int height();
virtual int width();
virtual int paddedWidth();
virtual void getServerFormat(rfbPixelFormat &format);
virtual void startMonitor();
virtual void stopMonitor();
void handleXDamage(XEvent *event);

View File

@@ -22,10 +22,8 @@
#include "x11framebuffer.h"
#include <KPluginFactory>
#include <KGenericFactory>
K_PLUGIN_FACTORY_WITH_JSON(X11FrameBufferPluginFactory, "krfb_framebuffer_x11.json",
registerPlugin<X11FrameBufferPlugin>();)
X11FrameBufferPlugin::X11FrameBufferPlugin(QObject *parent, const QVariantList &args)
: FrameBufferPlugin(parent, args)
@@ -41,5 +39,9 @@ FrameBuffer *X11FrameBufferPlugin::frameBuffer(WId id)
return new X11FrameBuffer(id);
}
K_PLUGIN_FACTORY(factory, registerPlugin<X11FrameBufferPlugin>();) \
K_EXPORT_PLUGIN(factory("krfb_framebuffer_x11"))
#include "x11framebufferplugin.moc"

View File

@@ -23,7 +23,9 @@
#include "framebufferplugin.h"
#include <QWidget>
#include <kdemacros.h>
#include <QtGui/QWidget>
class FrameBuffer;
@@ -35,7 +37,7 @@ public:
X11FrameBufferPlugin(QObject *parent, const QVariantList &args);
virtual ~X11FrameBufferPlugin();
FrameBuffer *frameBuffer(WId id) override;
virtual FrameBuffer *frameBuffer(WId id);
private:
Q_DISABLE_COPY(X11FrameBufferPlugin)

View File

@@ -1,3 +0,0 @@
[Project]
Manager=KDevCMakeManager
Name=krfb

View File

@@ -2,8 +2,6 @@ configure_file (${CMAKE_CURRENT_SOURCE_DIR}/config-krfb.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/config-krfb.h
)
include(GenerateExportHeader)
#####################################
# First target: libkrfbprivate - a library
# for linking plugins against.
@@ -13,23 +11,21 @@ set (krfbprivate_SRCS
framebufferplugin.cpp
)
add_library (krfbprivate
kde4_add_library (krfbprivate
SHARED
${krfbprivate_SRCS}
)
generate_export_header(krfbprivate BASE_NAME krfbprivate)
target_link_libraries (krfbprivate
Qt5::Core
Qt5::Widgets
Qt5::X11Extras
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
${X11_X11_LIB}
${LIBVNCSERVER_LIBRARIES}
)
set_target_properties (krfbprivate PROPERTIES
VERSION 5
SOVERSION 5.0
VERSION ${GENERIC_LIB_VERSION}
SOVERSION ${GENERIC_LIB_VERSION}
)
install (TARGETS krfbprivate
@@ -46,6 +42,16 @@ install (FILES
# Second target: krfb - the app
# itself.
if(TelepathyQt4_FOUND)
add_definitions(-DKRFB_WITH_TELEPATHY_TUBES)
include_directories(${TELEPATHY_QT4_INCLUDE_DIR})
endif()
if(KTP_FOUND)
add_definitions(-DKRFB_WITH_KDE_TELEPATHY)
include_directories(${KTP_INCLUDE_DIR})
endif()
set (krfb_SRCS
connectiondialog.cpp
events.cpp
@@ -61,18 +67,30 @@ set (krfb_SRCS
invitationsrfbclient.cpp
)
kconfig_add_kcfg_files (krfb_SRCS
if(TelepathyQt4_FOUND)
set (krfb_SRCS
${krfb_SRCS}
tubesrfbserver.cpp
tubesrfbclient.cpp
)
endif()
kde4_add_kcfg_files (krfb_SRCS
krfbconfig.kcfgc
)
ki18n_wrap_ui (krfb_SRCS
kde4_add_ui_files (krfb_SRCS
ui/configtcp.ui
ui/configsecurity.ui
ui/connectionwidget.ui
ui/mainwidget.ui
)
add_executable (krfb
if(TelepathyQt4_FOUND)
kde4_add_ui_files(krfb_SRCS ui/tubesconnectionwidget.ui)
endif()
kde4_add_executable (krfb
${krfb_SRCS}
)
@@ -83,19 +101,26 @@ target_link_libraries (krfb
${X11_Xext_LIB}
${X11_X11_LIB}
${X11_Xdamage_LIB}
Qt5::Network
KF5::Completion
KF5::CoreAddons
KF5::DBusAddons
KF5::DNSSD
KF5::I18n
KF5::Notifications
KF5::Wallet
KF5::WidgetsAddons
KF5::XmlGui
${QT_QTNETWORK_LIBRARY}
${KDE4_KDNSSD_LIBS}
${KDE4_KDEUI_LIBS}
${LIBVNCSERVER_LIBRARIES}
)
if(TelepathyQt4_FOUND)
target_link_libraries(krfb
${TELEPATHY_QT4_LIBRARIES}
)
endif()
if(KTP_FOUND)
target_link_libraries(krfb
${KTP_LIBRARIES}
${KTP_MODELS_LIBRARIES}
${KTP_WIDGETS_LIBRARIES}
)
endif()
if (X11_XTest_FOUND)
target_link_libraries (krfb
${X11_XTest_LIB}
@@ -106,9 +131,18 @@ install (TARGETS krfb
${INSTALL_TARGETS_DEFAULT_ARGS}
)
if(TelepathyQt4_FOUND)
configure_file(org.freedesktop.Telepathy.Client.krfb_rfb_handler.service.in
org.freedesktop.Telepathy.Client.krfb_rfb_handler.service)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.freedesktop.Telepathy.Client.krfb_rfb_handler.service
DESTINATION ${DBUS_SERVICES_INSTALL_DIR})
install(FILES krfb_rfb_handler.client DESTINATION ${CMAKE_INSTALL_PREFIX}/share/telepathy/clients/)
endif()
########### install files ###############
install (PROGRAMS org.kde.krfb.desktop
install (PROGRAMS krfb.desktop
DESTINATION ${XDG_APPS_INSTALL_DIR}
)

View File

@@ -21,33 +21,20 @@
#include "connectiondialog.h"
#include <QCheckBox>
#include <QIcon>
#include <KLocalizedString>
#include <KIconLoader>
#include <KLocale>
#include <KStandardGuiItem>
#include <KConfigGroup>
#include <QDialogButtonBox>
#include <QPushButton>
#include <KGuiItem>
#include <QVBoxLayout>
#include <QtGui/QCheckBox>
#include <QtGui/QLabel>
template <typename UI>
ConnectionDialog<UI>::ConnectionDialog(QWidget *parent)
: QDialog(parent)
: KDialog(parent)
{
setWindowTitle(i18n("New Connection"));
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
QWidget *mainWidget = new QWidget(this);
QVBoxLayout *mainLayout = new QVBoxLayout;
setLayout(mainLayout);
mainLayout->addWidget(mainWidget);
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setDefault(true);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
connect(buttonBox, &QDialogButtonBox::accepted, this, &ConnectionDialog<UI>::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &ConnectionDialog<UI>::reject);
buttonBox->button(QDialogButtonBox::Cancel)->setDefault(true);
setCaption(i18n("New Connection"));
setButtons(Ok | Cancel);
setDefaultButton(Cancel);
setModal(true);
setMinimumSize(500, 200);
@@ -55,18 +42,17 @@ ConnectionDialog<UI>::ConnectionDialog(QWidget *parent)
m_connectWidget = new QWidget(this);
m_ui.setupUi(m_connectWidget);
m_ui.pixmapLabel->setPixmap(QIcon::fromTheme("krfb").pixmap(128));
m_ui.pixmapLabel->setPixmap(KIcon("krfb").pixmap(128));
KGuiItem accept = KStandardGuiItem::ok();
accept.setText(i18n("Accept Connection"));
KGuiItem::assign(okButton, accept);
setButtonGuiItem(Ok, accept);
KGuiItem refuse = KStandardGuiItem::cancel();
refuse.setText(i18n("Refuse Connection"));
KGuiItem::assign(buttonBox->button(QDialogButtonBox::Cancel), refuse);
setButtonGuiItem(Cancel, refuse);
mainLayout->addWidget(m_connectWidget);
mainLayout->addWidget(buttonBox);
setMainWidget(m_connectWidget);
}
//**********
@@ -83,4 +69,20 @@ void InvitationsConnectionDialog::setRemoteHost(const QString &host)
//**********
#ifdef KRFB_WITH_TELEPATHY_TUBES
TubesConnectionDialog::TubesConnectionDialog(QWidget *parent)
: ConnectionDialog<Ui::TubesConnectionWidget>(parent)
{
}
void TubesConnectionDialog::setContactName(const QString & name)
{
QString txt = i18n("You have requested to share your desktop with %1. If you proceed, "
"you will allow the remote user to watch your desktop.", name);
m_ui.mainTextLabel->setText(txt);
}
#endif // KRFB_WITH_TELEPATHY_TUBES
#include "connectiondialog.moc"

View File

@@ -23,10 +23,10 @@
#define CONNECTIONDIALOG_H
#include "ui_connectionwidget.h"
#include <QDialog>
#include <KDialog>
template <typename UI>
class ConnectionDialog : public QDialog
class ConnectionDialog : public KDialog
{
public:
ConnectionDialog(QWidget *parent);
@@ -65,5 +65,18 @@ public:
//*********
#ifdef KRFB_WITH_TELEPATHY_TUBES
# include "ui_tubesconnectionwidget.h"
class TubesConnectionDialog : public ConnectionDialog<Ui::TubesConnectionWidget>
{
Q_OBJECT
public:
TubesConnectionDialog(QWidget *parent);
void setContactName(const QString & name);
};
#endif // KRFB_WITH_TELEPATHY_TUBES
#endif // CONNECTIONDIALOG_H

View File

@@ -24,10 +24,10 @@
#include "events.h"
#include <QApplication>
#include <QX11Info>
#include <QDesktopWidget>
#include <QGlobalStatic>
#include <QtGui/QApplication>
#include <QtGui/QX11Info>
#include <QtGui/QDesktopWidget>
#include <KGlobal>
#include <X11/Xutil.h>
#include <X11/keysym.h>
@@ -60,7 +60,7 @@ private:
void init();
};
Q_GLOBAL_STATIC(EventData, data)
K_GLOBAL_STATIC(EventData, data)
EventData::EventData()
{

View File

@@ -12,19 +12,19 @@
#include "rfb.h"
#include "krfbprivate_export.h"
#include <kdemacros.h>
#include <QtCore/QObject>
#include <QtCore/QRect>
#include <QtCore/QList>
#include <QWidget>
#include <QtGui/QWidget>
class FrameBuffer;
/**
@author Alessandro Praduroux <pradu@pradu.it>
*/
class KRFBPRIVATE_EXPORT FrameBuffer : public QObject
class KDE_EXPORT FrameBuffer : public QObject
{
Q_OBJECT
public:

View File

@@ -23,12 +23,9 @@
#include "framebufferplugin.h"
#include "krfbconfig.h"
#include <QDebug>
#include <QGlobalStatic>
#include <KPluginFactory>
#include <KPluginLoader>
#include <KPluginMetaData>
#include <KDebug>
#include <KGlobal>
#include <KServiceTypeTrader>
#include <QtCore/QSharedPointer>
@@ -38,75 +35,71 @@ public:
FrameBufferManager instance;
};
Q_GLOBAL_STATIC(FrameBufferManagerStatic, frameBufferManagerStatic)
K_GLOBAL_STATIC(FrameBufferManagerStatic, frameBufferManagerStatic)
FrameBufferManager::FrameBufferManager()
{
//qDebug();
kDebug();
loadPlugins();
}
FrameBufferManager::~FrameBufferManager()
{
//qDebug();
kDebug();
}
FrameBufferManager *FrameBufferManager::instance()
{
//qDebug();
kDebug();
return &frameBufferManagerStatic->instance;
}
void FrameBufferManager::loadPlugins()
{
//qDebug();
kDebug();
const QVector<KPluginMetaData> plugins = KPluginLoader::findPlugins(QStringLiteral("krfb"), [](const KPluginMetaData & md) {
return md.serviceTypes().contains(QStringLiteral("krfb/framebuffer"));
});
// Load the all the plugin factories here, for use later.
KService::List offers = KServiceTypeTrader::self()->query("krfb/framebuffer");
QVectorIterator<KPluginMetaData> i(plugins);
i.toBack();
QSet<QString> unique;
while (i.hasPrevious()) {
KPluginMetaData data = i.previous();
// only load plugins once, even if found multiple times!
if (unique.contains(data.name()))
KService::List::const_iterator iter;
for (iter = offers.constBegin(); iter < offers.constEnd(); ++iter) {
QString error;
KService::Ptr service = *iter;
KPluginFactory *factory = KPluginLoader(service->library()).factory();
if (!factory) {
kWarning() << "KPluginFactory could not load the plugin:" << service->library();
continue;
KPluginFactory *factory = KPluginLoader(data.fileName()).factory();
if (!factory) {
qDebug() << "KPluginFactory could not load the plugin:" << data.fileName();
} else {
qDebug() << "found plugin at " << data.fileName();
}
FrameBufferPlugin *plugin = factory->create<FrameBufferPlugin>(this);
if (plugin) {
m_plugins.insert(data.pluginId(), plugin);
qDebug() << "Loaded plugin with name " << data.pluginId();
} else {
qDebug() << "unable to load pluign for " << data.fileName();
}
unique.insert (data.name());
}
FrameBufferPlugin *plugin = factory->create<FrameBufferPlugin>(this);
if (plugin) {
kDebug() << "Loaded plugin:" << service->name();
m_plugins.insert(service->library(), plugin);
} else {
kDebug() << error;
}
}
}
QSharedPointer<FrameBuffer> FrameBufferManager::frameBuffer(WId id)
{
//qDebug();
kDebug();
// See if there is still an existing framebuffer to this WId.
if (m_frameBuffers.contains(id)) {
QWeakPointer<FrameBuffer> weakFrameBuffer = m_frameBuffers.value(id);
if (weakFrameBuffer) {
//qDebug() << "Found cached frame buffer.";
kDebug() << "Found cached frame buffer.";
return weakFrameBuffer.toStrongRef();
} else {
//qDebug() << "Found deleted cached frame buffer. Don't use.";
kDebug() << "Found deleted cached frame buffer. Don't use.";
m_frameBuffers.remove(id);
}
}
@@ -117,7 +110,7 @@ QSharedPointer<FrameBuffer> FrameBufferManager::frameBuffer(WId id)
while (iter != m_plugins.constEnd()) {
if (iter.key() == KrfbConfig::preferredFrameBufferPlugin()) {
qDebug() << "Using FrameBuffer:" << KrfbConfig::preferredFrameBufferPlugin();
kDebug() << "Using FrameBuffer:" << KrfbConfig::preferredFrameBufferPlugin();
QSharedPointer<FrameBuffer> frameBuffer(iter.value()->frameBuffer(id));
@@ -132,7 +125,7 @@ QSharedPointer<FrameBuffer> FrameBufferManager::frameBuffer(WId id)
}
// No valid framebuffer plugin found.
qDebug() << "No valid framebuffer found. returning null.";
kDebug() << "No valid framebuffer found. returning null.";
return QSharedPointer<FrameBuffer>();
}

View File

@@ -23,19 +23,19 @@
#include "framebuffer.h"
#include "krfbprivate_export.h"
#include <kdemacros.h>
#include <QtCore/QMap>
#include <QtCore/QObject>
#include <QtCore/QSharedPointer>
#include <QtCore/QWeakPointer>
#include <QWidget>
#include <QtGui/QWidget>
class FrameBufferPlugin;
class KPluginFactory;
class KRFBPRIVATE_EXPORT FrameBufferManager : public QObject
class KDE_EXPORT FrameBufferManager : public QObject
{
Q_OBJECT
friend class FrameBufferManagerStatic;

View File

@@ -21,15 +21,15 @@
#ifndef LIB_KRFB_FRAMEBUFFERPLUGIN_H
#define LIB_KRFB_FRAMEBUFFERPLUGIN_H
#include "krfbprivate_export.h"
#include <kdemacros.h>
#include <QtCore/QVariantList>
#include <QWidget>
#include <QtGui/QWidget>
class FrameBuffer;
class KRFBPRIVATE_EXPORT FrameBufferPlugin : public QObject
class KDE_EXPORT FrameBufferPlugin : public QObject
{
Q_OBJECT
@@ -40,5 +40,6 @@ public:
virtual FrameBuffer *frameBuffer(WId id) = 0;
};
#endif // Header guard

View File

@@ -24,14 +24,10 @@
#include "krfbconfig.h"
#include "sockethelpers.h"
#include "connectiondialog.h"
#include <KNotification>
#include <KLocalizedString>
#include <QDebug>
#include <KLocale>
#include <QtCore/QSocketNotifier>
#include <poll.h>
#include <KConfigGroup>
struct PendingInvitationsRfbClient::Private
{
@@ -54,8 +50,8 @@ PendingInvitationsRfbClient::PendingInvitationsRfbClient(rfbClientPtr client, QO
d->client->clientGoneHook = clientGoneHookNoop;
d->notifier = new QSocketNotifier(client->sock, QSocketNotifier::Read, this);
d->notifier->setEnabled(true);
connect(d->notifier, &QSocketNotifier::activated,
this, &PendingInvitationsRfbClient::onSocketActivated);
connect(d->notifier, SIGNAL(activated(int)),
this, SLOT(onSocketActivated()));
}
PendingInvitationsRfbClient::~PendingInvitationsRfbClient()
@@ -83,8 +79,8 @@ void PendingInvitationsRfbClient::processNewClient()
dialog->setRemoteHost(host);
dialog->setAllowRemoteControl(KrfbConfig::allowDesktopControl());
connect(dialog, &InvitationsConnectionDialog::accepted, this, &PendingInvitationsRfbClient::dialogAccepted);
connect(dialog, &InvitationsConnectionDialog::rejected, this, &PendingInvitationsRfbClient::reject);
connect(dialog, SIGNAL(okClicked()), SLOT(dialogAccepted()));
connect(dialog, SIGNAL(cancelClicked()), SLOT(reject()));
dialog->show();
}
@@ -115,7 +111,7 @@ void PendingInvitationsRfbClient::onSocketActivated()
//the clientGoneHook which in turn will remove this RfbClient instance
//from the server manager and will call deleteLater() to delete it
if (d->client->sock == -1) {
qDebug() << "disconnected from socket signal";
kDebug() << "disconnected from socket signal";
d->notifier->setEnabled(false);
rfbClientConnectionGone(d->client);
break;
@@ -126,7 +122,7 @@ void PendingInvitationsRfbClient::onSocketActivated()
bool PendingInvitationsRfbClient::checkPassword(const QByteArray & encryptedPassword)
{
QByteArray password ;
qDebug() << "about to start autentication";
kDebug() << "about to start autentication";
if(InvitationsRfbServer::instance->allowUnattendedAccess() && vncAuthCheckPassword(
InvitationsRfbServer::instance->unattendedPassword().toLocal8Bit(),

View File

@@ -36,9 +36,9 @@ public:
virtual ~PendingInvitationsRfbClient();
protected Q_SLOTS:
void processNewClient() override;
virtual void processNewClient();
virtual void onSocketActivated();
bool checkPassword(const QByteArray & encryptedPassword) override;
virtual bool checkPassword(const QByteArray & encryptedPassword);
private Q_SLOTS:
void dialogAccepted();

View File

@@ -23,17 +23,16 @@
#include "krfbconfig.h"
#include "rfbservermanager.h"
#include <QtCore/QTimer>
#include <QApplication>
#include <QtGui/QApplication>
#include <QtNetwork/QHostInfo>
#include <QDebug>
#include <KLocalizedString>
#include <KNotification>
#include <KLocale>
#include <KMessageBox>
#include <KUser>
#include <KRandom>
#include <KStringHandler>
#include <KWallet/KWallet>
#include <dnssd/publicservice.h>
#include <KWallet/Wallet>
#include <DNSSD/PublicService>
using KWallet::Wallet;
//static
@@ -43,7 +42,7 @@ InvitationsRfbServer *InvitationsRfbServer::instance;
void InvitationsRfbServer::init()
{
instance = new InvitationsRfbServer;
instance->m_publicService = new KDNSSD::PublicService(
instance->m_publicService = new DNSSD::PublicService(
i18n("%1@%2 (shared desktop)",
KUser().loginName(),
QHostInfo::localHostName()),
@@ -53,16 +52,11 @@ void InvitationsRfbServer::init()
instance->setListeningPort(KrfbConfig::port());
instance->setPasswordRequired(true);
if (KrfbConfig::noWallet()) {
instance->walletOpened(false);
}
else {
instance->m_wallet = Wallet::openWallet(
Wallet::NetworkWallet(), 0, Wallet::Asynchronous);
if(instance->m_wallet) {
connect(instance->m_wallet, &KWallet::Wallet::walletOpened,
instance, &InvitationsRfbServer::walletOpened);
}
instance->m_wallet = Wallet::openWallet(
Wallet::NetworkWallet(), 0, Wallet::Asynchronous);
if(instance->m_wallet) {
connect(instance->m_wallet, SIGNAL(walletOpened(bool)),
instance, SLOT(walletOpened(bool)));
}
}
@@ -101,11 +95,11 @@ bool InvitationsRfbServer::start()
return false;
}
void InvitationsRfbServer::stop()
void InvitationsRfbServer::stop(bool disconnectClients)
{
if(m_publicService->isPublished())
m_publicService->stop();
RfbServer::stop();
RfbServer::stop(disconnectClients);
}
void InvitationsRfbServer::toggleUnattendedAccess(bool allow)
@@ -117,7 +111,8 @@ InvitationsRfbServer::InvitationsRfbServer()
{
m_desktopPassword = readableRandomString(4)+"-"+readableRandomString(3);
m_unattendedPassword = readableRandomString(4)+"-"+readableRandomString(3);
KConfigGroup krfbConfig(KSharedConfig::openConfig(),"Security");
KSharedConfigPtr config = KGlobal::config();
KConfigGroup krfbConfig(config,"Security");
m_allowUnattendedAccess = krfbConfig.readEntry(
"allowUnattendedAccess", QVariant(false)).toBool();
}
@@ -125,10 +120,11 @@ InvitationsRfbServer::InvitationsRfbServer()
InvitationsRfbServer::~InvitationsRfbServer()
{
stop();
KConfigGroup krfbConfig(KSharedConfig::openConfig(),"Security");
KSharedConfigPtr config = KGlobal::config();
KConfigGroup krfbConfig(config,"Security");
krfbConfig.writeEntry("allowUnattendedAccess",m_allowUnattendedAccess);
if(!KrfbConfig::noWallet()) {
if (m_wallet && m_wallet->isOpen()) {
if(m_wallet && m_wallet->isOpen()) {
if( (m_wallet->currentFolder()=="krfb") ||
((m_wallet->hasFolder("krfb") || m_wallet->createFolder("krfb")) &&
m_wallet->setFolder("krfb")) ) {
@@ -136,7 +132,6 @@ InvitationsRfbServer::~InvitationsRfbServer()
m_wallet->writePassword("desktopSharingPassword",m_desktopPassword);
m_wallet->writePassword("unattendedAccessPassword",m_unattendedPassword);
}
}
} else {
krfbConfig.writeEntry("desktopPassword",
@@ -175,8 +170,9 @@ void InvitationsRfbServer::walletOpened(bool opened)
} else {
qDebug() << "Could not open KWallet, Falling back to config file";
KConfigGroup krfbConfig(KSharedConfig::openConfig(),"Security");
kDebug() << "Could not open KWallet, Falling back to config file";
KSharedConfigPtr config = KGlobal::config();
KConfigGroup krfbConfig(config,"Security");
desktopPassword = KStringHandler::obscure(krfbConfig.readEntry(
"desktopPassword", QString()));

View File

@@ -26,7 +26,7 @@ namespace KWallet {
class Wallet;
}
namespace KDNSSD {
namespace DNSSD {
class PublicService;
}
@@ -47,20 +47,20 @@ Q_SIGNALS:
void passwordChanged(const QString&);
public Q_SLOTS:
bool start() override;
void stop() override;
void toggleUnattendedAccess(bool allow);
bool start();
void stop(bool disconnectClients=true);
void toggleUnattendedAccess(bool allow=true);
protected:
InvitationsRfbServer();
virtual ~InvitationsRfbServer();
PendingRfbClient* newClient(rfbClientPtr client) override;
virtual PendingRfbClient* newClient(rfbClientPtr client);
private Q_SLOTS:
void walletOpened(bool);
private:
KDNSSD::PublicService *m_publicService;
DNSSD::PublicService *m_publicService;
bool m_allowUnattendedAccess;
QString m_desktopPassword;
QString m_unattendedPassword;

View File

@@ -28,7 +28,7 @@ Comment[ja]=KRfb の フレームバッファプラグイン
Comment[kk]=KRfb кадр буфер плагині
Comment[km]=កម្មវិធី​ជំនួយ​ Frame Buffer សម្រាប់ KRfb
Comment[ko]=KRfb 프레임버퍼 플러그인
Comment[lt]=Frame Buffer papildiniai skirti KRfb
Comment[lt]=Frame Buffer priedai skirti KRfb
Comment[lv]=Kadru bufera sprudņi priekš KRfb
Comment[nb]=Rammebuffer-programtillegg for KRfb
Comment[nds]=Bildpuffer-Modulen för KRfb

View File

@@ -1,32 +0,0 @@
{
"KPlugin": {
"Description": "Frame Buffer plugins for KRfb",
"Description[ca@valencia]": "Connectors de «framebuffer» per al KRfb.",
"Description[ca]": "Connectors de «framebuffer» per al KRfb.",
"Description[cs]": "Moduly Frame bufferu pro KRfb",
"Description[da]": "Framebuffer-plugins til KRfb",
"Description[de]": "Framebuffer-Module für KRfb",
"Description[en_GB]": "Frame Buffer plugins for KRfb",
"Description[es]": "Complementos de framebuffer para KRfb",
"Description[fi]": "Kehyspuskuriliitännäinen kohteelle KRfb",
"Description[gl]": "Engadido de frame buffer para KRfb",
"Description[it]": "Estensioni del framebuffer per KRfb",
"Description[ko]": "KRfb 프레임버퍼 플러그인",
"Description[nl]": "Framebuffer-plugins voor KRfb",
"Description[pl]": "Wtyczki buforów ramek dla KRfb",
"Description[pt]": "'Plugins' do 'Framebuffer' para o KRfb",
"Description[pt_BR]": "Plugins de framebuffers para o KRfb",
"Description[sk]": "Frame Buffer modul pre KRfb",
"Description[sl]": "Vstavki slikovnih medpomnilnikov za KRfb",
"Description[sr@ijekavian]": "Прикључци кадробафера за КРФБ",
"Description[sr@ijekavianlatin]": "Priključci kadrobafera za KRFB",
"Description[sr@latin]": "Priključci kadrobafera za KRFB",
"Description[sr]": "Прикључци кадробафера за КРФБ",
"Description[sv]": "Insticksprogram med rambuffert för Krfb",
"Description[uk]": "Додатки буфера кадрів для KRfb",
"Description[x-test]": "xxFrame Buffer plugins for KRfbxx",
"Description[zh_CN]": "KRfb 的帧缓冲插件",
"Description[zh_TW]": "KRfb 的 Frame Buffer 外掛程式"
},
"X-KDE-ServiceType": "krfb/framebuffer"
}

View File

@@ -1,7 +1,7 @@
# KDE Config File
[Desktop Entry]
Type=Application
Exec=krfb -qwindowtitle %c %i
Exec=krfb -caption %c %i
Icon=krfb
X-DBUS-StartupType=Unique
X-DocPath=krfb/index.html
@@ -110,7 +110,7 @@ GenericName[ja]=デスクトップ共有
GenericName[kk]=Үстелді ортақтастыру
GenericName[km]=
GenericName[ko]=
GenericName[lt]=Dalinimasis darbalaukiu
GenericName[lt]=Dalinimasis darbastaliu
GenericName[lv]=Darbvirsmas koplietošana
GenericName[ml]=ിി
GenericName[mr]=
@@ -145,4 +145,3 @@ GenericName[zh_CN]=桌面共享
GenericName[zh_HK]=
GenericName[zh_TW]=
Categories=Qt;KDE;System;Network;RemoteAccess;
X-DBUS-ServiceName=org.kde.krfb

View File

@@ -3,12 +3,6 @@
"http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">
<kcfg>
<kcfgfile />
<group name="MainWindow">
<entry name="startMinimized" type="Bool">
<label>Start minimized</label>
<default>false</default>
</entry>
</group>
<group name="TCP">
<entry name="useDefaultPort" type="Bool">
<label>Use the default port for VNC (5900)</label>
@@ -24,10 +18,6 @@
</entry>
</group>
<group name="Security">
<entry name="noWallet" type="Bool">
<label>Do not store passwords in KWallet</label>
<default>false</default>
</entry>
<entry name="allowDesktopControl" type="Bool">
<label>Allow remote connections to manage the desktop.</label>
<default>true</default>
@@ -46,7 +36,7 @@
<group name="FrameBuffer">
<entry name="preferredFrameBufferPlugin" type="String">
<label>Preferred Frame Buffer Plugin</label>
<default>x11</default>
<default>krfb_framebuffer_x11</default>
</entry>
</group>
</kcfg>

View File

@@ -36,7 +36,7 @@ Comment[ja]=デスクトップ共有
Comment[kk]=Үстелді ортақтастыру
Comment[km]=ការ​ចែក​រំលែក​ផ្ទែ​តុ
Comment[ko]=데스크톱 공유
Comment[lt]=Dalinimasis darbalaukiu
Comment[lt]=Dalinimasis darbastaliu
Comment[lv]=Darbvirsmas koplietošana
Comment[mk]=Делење на работната површина
Comment[ml]=പണിയിടം പങ്കുവെക്കല്‍

View File

@@ -18,24 +18,27 @@
#include "mainwindow.h"
#include "trayicon.h"
#include "invitationsrfbserver.h"
#include "krfbconfig.h"
#include <KAboutApplicationDialog>
#include <KAboutData>
#include <KDBusService>
#include <KLocalizedString>
#include <KAction>
#include <KUniqueApplication>
#include <KCmdLineArgs>
#include <KDebug>
#include <KLocale>
#include <KMessageBox>
#include <KNotification>
#include <QDebug>
#include <QPixmap>
#include <qwindowdefs.h>
#include <QX11Info>
#include <QtGui/QPixmap>
#include <QtGui/qwindowdefs.h>
#ifdef KRFB_WITH_TELEPATHY_TUBES
# include "tubesrfbserver.h"
#endif
#include <signal.h>
#include <X11/extensions/XTest.h>
#include <QCommandLineParser>
#include <QCommandLineOption>
static const char KRFB_VERSION[] = "5.0";
static const char description[] = I18N_NOOP("VNC-compatible server to share "
"KDE desktops");
@@ -58,51 +61,39 @@ static bool checkX11Capabilities()
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
KLocalizedString::setApplicationDomain("krfb");
KAboutData aboutData("krfb",
i18n("Desktop Sharing"),
KRFB_VERSION,
i18n(description),
KAboutLicense::GPL,
i18n("(c) 2009-2010, Collabora Ltd.\n"
KAboutData aboutData("krfb", 0, ki18n("Desktop Sharing"), KDE_VERSION_STRING,
ki18n(description), KAboutData::License_GPL,
ki18n("(c) 2009-2010, Collabora Ltd.\n"
"(c) 2007, Alessandro Praduroux\n"
"(c) 2001-2003, Tim Jansen\n"
"(c) 2001, Johannes E. Schindelin\n"
"(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"),
aboutData.addAuthor(ki18n("George Goldberg"),
ki18n("Telepathy tubes support"),
"george.goldberg@collabora.co.uk");
aboutData.addAuthor(i18n("George Kiagiadakis"),
QString(),
aboutData.addAuthor(ki18n("George Kiagiadakis"),
KLocalizedString(),
"george.kiagiadakis@collabora.co.uk");
aboutData.addAuthor(i18n("Alessandro Praduroux"), i18n("KDE4 porting"), "pradu@pradu.it");
aboutData.addAuthor(i18n("Tim Jansen"), i18n("Original author"), "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("AT&T Laboratories Boston"),
i18n("original VNC encoders and "
aboutData.addAuthor(ki18n("Alessandro Praduroux"), ki18n("KDE4 porting"), "pradu@pradu.it");
aboutData.addAuthor(ki18n("Tim Jansen"), ki18n("Original author"), "tim@tjansen.de");
aboutData.addCredit(ki18n("Johannes E. Schindelin"),
ki18n("libvncserver"));
aboutData.addCredit(ki18n("Const Kaplinsky"),
ki18n("TightVNC encoder"));
aboutData.addCredit(ki18n("Tridia Corporation"),
ki18n("ZLib encoder"));
aboutData.addCredit(ki18n("AT&T Laboratories Boston"),
ki18n("original VNC encoders and "
"protocol design"));
QCommandLineParser parser;
KAboutData::setApplicationData(aboutData);
parser.addVersionOption();
parser.addHelpOption();
aboutData.setupCommandLine(&parser);
parser.process(app);
aboutData.processCommandLine(&parser);
KCmdLineArgs::init(argc, argv, &aboutData);
KDBusService service(KDBusService::Unique, &app);
parser.addOption(QCommandLineOption(QStringList() << QLatin1String("nodialog"), i18n("Do not show the invitations management dialog at startup")));
KCmdLineOptions options;
options.add("nodialog", ki18n("Do not show the invitations management dialog at startup"));
KCmdLineArgs::addCmdLineOptions(options);
KUniqueApplication app;
app.setQuitOnLastWindowClosed(false);
if (!checkX11Capabilities()) {
@@ -112,15 +103,17 @@ int main(int argc, char *argv[])
//init the core
InvitationsRfbServer::init();
#ifdef KRFB_WITH_TELEPATHY_TUBES
TubesRfbServer::init();
#endif
//init the GUI
MainWindow mainWindow;
TrayIcon trayicon(&mainWindow);
if (KrfbConfig::startMinimized()) {
mainWindow.hide();
} else if (app.isSessionRestored() && KMainWindow::canBeRestored(1)) {
if (app.isSessionRestored() && KMainWindow::canBeRestored(1)) {
mainWindow.restore(1, false);
} else if (!parser.isSet("nodialog")) {
} else if (KCmdLineArgs::parsedArgs()->isSet("dialog")) {
mainWindow.show();
}
@@ -131,3 +124,4 @@ int main(int argc, char *argv[])
return app.exec();
}

View File

@@ -15,18 +15,31 @@
#include "ui_configsecurity.h"
#include <KConfigDialog>
#include <KLocalizedString>
#include <KIcon>
#include <KLocale>
#include <KMessageBox>
#include <KStandardGuiItem>
#include <KSystemTimeZone>
#include <KToolInvocation>
#include <KStandardAction>
#include <KActionCollection>
#include <KLineEdit>
#include <KNewPasswordDialog>
#include <QIcon>
#include <QWidget>
#include <QSizePolicy>
#include <QtGui/QWidget>
#include <QtGui/QSizePolicy>
#include <QtNetwork/QNetworkInterface>
#ifdef KRFB_WITH_KDE_TELEPATHY
#include "tubesrfbserver.h"
#include <TelepathyQt/PendingReady>
#include <TelepathyQt/PendingChannelRequest>
#include <KTp/actions.h>
#include <KTp/Widgets/contact-view-widget.h>
#include <KTp/Models/contacts-list-model.h>
#include <KTp/Models/contacts-filter-model.h>
#endif
class TCP: public QWidget, public Ui::TCP
{
public:
@@ -56,26 +69,26 @@ MainWindow::MainWindow(QWidget *parent)
QWidget *mainWidget = new QWidget;
m_ui.setupUi(mainWidget);
m_ui.krfbIconLabel->setPixmap(QIcon::fromTheme("krfb").pixmap(128));
m_ui.krfbIconLabel->setPixmap(KIcon("krfb").pixmap(128));
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,SIGNAL(clicked()),
this,SLOT(editPassword()));
connect(m_ui.enableSharingCheckBox,SIGNAL(toggled(bool)),
this, SLOT(toggleDesktopSharing(bool)));
connect(m_ui.enableUnattendedCheckBox, SIGNAL(toggled(bool)),
InvitationsRfbServer::instance, SLOT(toggleUnattendedAccess(bool)));
connect(m_ui.unattendedPasswordButton, SIGNAL(clicked()),
this, SLOT(editUnattendedPassword()));
connect(m_ui.addressAboutButton, SIGNAL(clicked()),
this, SLOT(aboutConnectionAddress()));
connect(m_ui.unattendedAboutButton, SIGNAL(clicked()),
this, SLOT(aboutUnattendedMode()));
connect(InvitationsRfbServer::instance, SIGNAL(passwordChanged(const QString&)),
this, SLOT(passwordChanged(const QString&)));
// Figure out the address
int port = KrfbConfig::port();
@@ -95,15 +108,36 @@ MainWindow::MainWindow(QWidget *parent)
m_ui.passwordDisplayLabel->setText(
InvitationsRfbServer::instance->desktopPassword());
#ifdef KRFB_WITH_KDE_TELEPATHY
m_contactViewWidget = new KTp::ContactViewWidget(
TubesRfbServer::instance->contactsListModel(), this);
m_contactViewWidget->setEnabled(false);
connect(m_ui.enableSharingCheckBox, SIGNAL(toggled(bool)),
m_contactViewWidget, SLOT(setEnabled(bool)));
m_contactViewWidget->setIconSize(QSize(32,32));
m_contactViewWidget->setMinimumWidth(120);
m_contactViewWidget->setMaximumWidth(360);
m_contactViewWidget->setMinimumHeight(300);
m_contactViewWidget->contactFilterLineEdit()->setClickMessage(i18n("Search in Contacts..."));
m_contactViewWidget->filter()->setPresenceTypeFilterFlags(KTp::ContactsFilterModel::ShowOnlyConnected);
m_contactViewWidget->filter()->setTubesFilterStrings(QStringList("rfb"));
m_contactViewWidget->filter()->setCapabilityFilterFlags(KTp::ContactsFilterModel::FilterByTubes);
m_contactViewWidget->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
m_ui.tpContactsLayout->addWidget(m_contactViewWidget);
connect(m_contactViewWidget, SIGNAL(contactDoubleClicked(const Tp::AccountPtr &, const KTp::ContactPtr &)),
this, SLOT(onContactDoubleClicked(const Tp::AccountPtr &, const KTp::ContactPtr &)));
#endif
KStandardAction::quit(QCoreApplication::instance(), SLOT(quit()), actionCollection());
KStandardAction::preferences(this, SLOT(showConfiguration()), actionCollection());
setupGUI();
if (KrfbConfig::allowDesktopControl()) {
m_ui.enableSharingCheckBox->setChecked(true);
}
setAutoSaveSettings();
}
@@ -115,7 +149,7 @@ void MainWindow::editPassword()
{
if(m_passwordEditable) {
m_passwordEditable = false;
m_ui.passwordEditButton->setIcon(QIcon::fromTheme("document-properties"));
m_ui.passwordEditButton->setIcon(KIcon("document-properties"));
m_ui.passwordGridLayout->removeWidget(m_passwordLineEdit);
InvitationsRfbServer::instance->setDesktopPassword(
m_passwordLineEdit->text());
@@ -124,7 +158,7 @@ void MainWindow::editPassword()
m_passwordLineEdit->setVisible(false);
} else {
m_passwordEditable = true;
m_ui.passwordEditButton->setIcon(QIcon::fromTheme("document-save"));
m_ui.passwordEditButton->setIcon(KIcon("document-save"));
m_ui.passwordGridLayout->addWidget(m_passwordLineEdit,0,0);
m_passwordLineEdit->setText(
InvitationsRfbServer::instance->desktopPassword());
@@ -156,7 +190,7 @@ void MainWindow::toggleDesktopSharing(bool enable)
if(m_passwordEditable) {
m_passwordEditable = false;
m_passwordLineEdit->setVisible(false);
m_ui.passwordEditButton->setIcon(QIcon::fromTheme("document-properties"));
m_ui.passwordEditButton->setIcon(KIcon("document-properties"));
}
}
}
@@ -181,6 +215,25 @@ void MainWindow::aboutUnattendedMode()
i18n("KDE Desktop Sharing"));
}
#ifdef KRFB_WITH_KDE_TELEPATHY
void MainWindow::onContactDoubleClicked(const Tp::AccountPtr &account, const KTp::ContactPtr &contact)
{
Tp::PendingOperation *op = KTp::Actions::startDesktopSharing(account, contact);
connect(op, SIGNAL(finished(Tp::PendingOperation*)),
this, SLOT(pendingDesktopShareFinished(Tp::PendingOperation*)));
}
void MainWindow::pendingDesktopShareFinished(Tp::PendingOperation *operation)
{
if(operation->isError()) {
KMessageBox::error(this,
operation->errorName() + ": " + operation->errorMessage());
}
}
#endif
void MainWindow::showConfiguration()
{
if (KConfigDialog::showDialog("settings")) {
@@ -190,6 +243,7 @@ void MainWindow::showConfiguration()
KConfigDialog *dialog = new KConfigDialog(this, "settings", KrfbConfig::self());
dialog->addPage(new TCP, i18n("Network"), "network-workgroup");
dialog->addPage(new Security, i18n("Security"), "security-high");
dialog->setHelp(QString(), "krfb");
dialog->show();
}

View File

@@ -15,6 +15,17 @@
#include <KXmlGuiWindow>
#ifdef KRFB_WITH_KDE_TELEPATHY
#include <KTp/contact.h>
#include <TelepathyQt/PendingReady>
namespace KTp {
class ContactViewWidget;
}
namespace Tp {
class PendingOperation;
}
#endif
class KLineEdit;
class MainWindow : public KXmlGuiWindow
@@ -29,8 +40,8 @@ class MainWindow : public KXmlGuiWindow
void showConfiguration();
protected:
void readProperties(const KConfigGroup & group) override;
void saveProperties(KConfigGroup & group) override;
virtual void readProperties(const KConfigGroup & group);
virtual void saveProperties(KConfigGroup & group);
private Q_SLOTS:
void editPassword();
@@ -39,11 +50,19 @@ class MainWindow : public KXmlGuiWindow
void passwordChanged(const QString&);
void aboutConnectionAddress();
void aboutUnattendedMode();
#ifdef KRFB_WITH_KDE_TELEPATHY
void onContactDoubleClicked(const Tp::AccountPtr &, const KTp::ContactPtr &);
void pendingDesktopShareFinished(Tp::PendingOperation*);
#endif
private:
Ui::MainWidget m_ui;
bool m_passwordEditable;
KLineEdit *m_passwordLineEdit;
#ifdef KRFB_WITH_KDE_TELEPATHY
KTp::ContactViewWidget *m_contactViewWidget;
#endif
};
#endif

View File

@@ -0,0 +1,3 @@
[D-BUS Service]
Name=org.freedesktop.Telepathy.Client.krfb_rfb_handler
Exec=@CMAKE_INSTALL_PREFIX@/bin/krfb --nodialog

View File

@@ -23,7 +23,8 @@
#include "sockethelpers.h"
#include "events.h"
#include <QtCore/QSocketNotifier>
#include <QDebug>
#include <KDebug>
#include <KNotification>
#include <poll.h>
#include <strings.h> //for bzero()
@@ -48,12 +49,12 @@ RfbClient::RfbClient(rfbClientPtr client, QObject* parent)
d->notifier = new QSocketNotifier(client->sock, QSocketNotifier::Read, this);
d->notifier->setEnabled(false);
connect(d->notifier, &QSocketNotifier::activated, this, &RfbClient::onSocketActivated);
connect(d->notifier, SIGNAL(activated(int)), this, SLOT(onSocketActivated()));
}
RfbClient::~RfbClient()
{
//qDebug();
kDebug();
delete d;
}
@@ -139,7 +140,7 @@ void RfbClient::onSocketActivated()
//the clientGoneHook which in turn will remove this RfbClient instance
//from the server manager and will call deleteLater() to delete it
if (d->client->sock == -1) {
//qDebug() << "disconnected from socket signal";
kDebug() << "disconnected from socket signal";
d->notifier->setEnabled(false);
rfbClientConnectionGone(d->client);
break;
@@ -158,7 +159,7 @@ void RfbClient::update()
//the clientGoneHook which in turn will remove this RfbClient instance
//from the server manager and will call deleteLater() to delete it
if (d->client->sock == -1) {
//qDebug() << "disconnected during update";
kDebug() << "disconnected during update";
d->notifier->setEnabled(false);
rfbClientConnectionGone(d->client);
}
@@ -177,7 +178,7 @@ PendingRfbClient::~PendingRfbClient()
void PendingRfbClient::accept(RfbClient *newClient)
{
//qDebug() << "accepted connection";
kDebug() << "accepted connection";
m_rfbClient->clientData = newClient;
newClient->setOnHold(false);
@@ -190,7 +191,7 @@ static void clientGoneHookNoop(rfbClientPtr cl) { Q_UNUSED(cl); }
void PendingRfbClient::reject()
{
//qDebug() << "refused connection";
kDebug() << "refused connection";
//override the clientGoneHook that was previously set by RfbServer
m_rfbClient->clientGoneHook = clientGoneHookNoop;

View File

@@ -22,7 +22,7 @@
#include <QtCore/QSocketNotifier>
#include <QApplication>
#include <QClipboard>
#include <QDebug>
#include <KDebug>
struct RfbServer::Private
{
@@ -90,7 +90,6 @@ bool RfbServer::start()
if (!d->screen) {
d->screen = RfbServerManager::instance()->newScreen();
if (!d->screen) {
qDebug() << "Unable to get rbfserver screen";
return false;
}
@@ -123,31 +122,31 @@ bool RfbServer::start()
d->screen->authPasswdData = (void *)0;
}
qDebug() << "Starting server. Listen port:" << listeningPort()
kDebug() << "Starting server. Listen port:" << listeningPort()
<< "Listen Address:" << listeningAddress()
<< "Password enabled:" << passwordRequired();
rfbInitServer(d->screen);
if (!rfbIsActive(d->screen)) {
qDebug() << "Failed to start server";
kDebug() << "Failed to start server";
rfbShutdownServer(d->screen, false);
return false;
};
d->notifier = new QSocketNotifier(d->screen->listenSock, QSocketNotifier::Read, this);
d->notifier->setEnabled(true);
connect(d->notifier, &QSocketNotifier::activated, this, &RfbServer::onListenSocketActivated);
connect(QApplication::clipboard(), &QClipboard::dataChanged,
this, &RfbServer::krfbSendServerCutText);
connect(d->notifier, SIGNAL(activated(int)), this, SLOT(onListenSocketActivated()));
connect(QApplication::clipboard(), SIGNAL(dataChanged()),
this, SLOT(krfbSendServerCutText()));
return true;
}
void RfbServer::stop()
void RfbServer::stop(bool disconnectClients)
{
if (d->screen) {
rfbShutdownServer(d->screen, true);
rfbShutdownServer(d->screen, disconnectClients);
if (d->notifier) {
d->notifier->setEnabled(false);
d->notifier->deleteLater();
@@ -188,13 +187,13 @@ void krfb_rfbSetCursorPosition(rfbScreenInfoPtr screen, rfbClientPtr client, int
/* Inform all clients about this cursor movement. */
iterator = rfbGetClientIterator(screen);
while ((cl = rfbClientIteratorNext(iterator)) != NULL) {
cl->cursorWasMoved = true;
cl->cursorWasMoved = TRUE;
}
rfbReleaseClientIterator(iterator);
/* The cursor was moved by this client, so don't send CursorPos. */
if (client) {
client->cursorWasMoved = false;
client->cursorWasMoved = FALSE;
}
}
@@ -221,7 +220,7 @@ void RfbServer::onListenSocketActivated()
void RfbServer::pendingClientFinished(RfbClient *client)
{
//qDebug();
kDebug();
if (client) {
RfbServerManager::instance()->addClient(client);
client->getRfbClientPtr()->clientGoneHook = clientGoneHook;
@@ -231,12 +230,12 @@ void RfbServer::pendingClientFinished(RfbClient *client)
//static
rfbNewClientAction RfbServer::newClientHook(rfbClientPtr cl)
{
//qDebug() << "New client";
kDebug() << "New client";
RfbServer *server = static_cast<RfbServer*>(cl->screen->screenData);
PendingRfbClient *pendingClient = server->newClient(cl);
connect(pendingClient, &PendingRfbClient::finished,
server, &RfbServer::pendingClientFinished);
connect(pendingClient, SIGNAL(finished(RfbClient*)),
server, SLOT(pendingClientFinished(RfbClient*)));
return RFB_CLIENT_ON_HOLD;
}
@@ -244,7 +243,7 @@ rfbNewClientAction RfbServer::newClientHook(rfbClientPtr cl)
//static
void RfbServer::clientGoneHook(rfbClientPtr cl)
{
//qDebug() << "client gone";
kDebug() << "client gone";
RfbClient *client = static_cast<RfbClient*>(cl->clientData);
RfbServerManager::instance()->removeClient(client);
@@ -274,7 +273,7 @@ void RfbServer::pointerHook(int bm, int x, int y, rfbClientPtr cl)
}
//static
void RfbServer::clipboardHook(char *str, int len, rfbClientPtr /*cl*/)
void RfbServer::clipboardHook(char *str, int len, rfbClientPtr cl)
{
QApplication::clipboard()->setText(QString::fromLocal8Bit(str,len));
}

View File

@@ -41,7 +41,7 @@ public:
public Q_SLOTS:
virtual bool start();
virtual void stop();
virtual void stop(bool disconnectClients = true);
void updateScreen(const QList<QRect> & modifiedTiles);
void updateCursorPosition(const QPoint & position);

View File

@@ -25,13 +25,12 @@
#include "sockethelpers.h"
#include "krfbconfig.h"
#include <QtCore/QTimer>
#include <QApplication>
#include <QDesktopWidget>
#include <QGlobalStatic>
#include <QtGui/QApplication>
#include <QtGui/QDesktopWidget>
#include <QtNetwork/QHostInfo>
#include <QDebug>
#include <KLocalizedString>
#include <KGlobal>
#include <KDebug>
#include <KLocale>
#include <KUser>
#include <KNotification>
@@ -83,7 +82,7 @@ struct RfbServerManagerStatic
RfbServerManager server;
};
Q_GLOBAL_STATIC(RfbServerManagerStatic, s_instance)
K_GLOBAL_STATIC(RfbServerManagerStatic, s_instance)
RfbServerManager* RfbServerManager::instance()
{
@@ -115,7 +114,7 @@ RfbServerManager::~RfbServerManager()
void RfbServerManager::init()
{
//qDebug();
kDebug();
d->fb = FrameBufferManager::instance()->frameBuffer(QApplication::desktop()->winId());
d->myCursor = rfbMakeXCursor(19, 19, (char *) cur, (char *) mask);
@@ -123,8 +122,8 @@ void RfbServerManager::init()
d->desktopName = QString("%1@%2 (shared desktop)") //FIXME check if we can use utf8
.arg(KUser().loginName(),QHostInfo::localHostName()).toLatin1();
connect(&d->rfbUpdateTimer, &QTimer::timeout, this, &RfbServerManager::updateScreens);
connect(qApp, &QApplication::aboutToQuit, this, &RfbServerManager::cleanup);
connect(&d->rfbUpdateTimer, SIGNAL(timeout()), SLOT(updateScreens()));
connect(qApp, SIGNAL(aboutToQuit()), SLOT(cleanup()));
}
void RfbServerManager::updateScreens()
@@ -148,7 +147,7 @@ void RfbServerManager::updateScreens()
void RfbServerManager::cleanup()
{
//qDebug();
kDebug();
//copy because d->servers is going to be modified while we delete the servers
QSet<RfbServer*> servers = d->servers;
@@ -188,7 +187,7 @@ rfbScreenInfoPtr RfbServerManager::newScreen()
bpp = 4;
}
//qDebug() << "bpp: " << bpp;
kDebug() << "bpp: " << bpp;
rfbLogEnable(0);
@@ -207,7 +206,7 @@ rfbScreenInfoPtr RfbServerManager::newScreen()
void RfbServerManager::addClient(RfbClient* cc)
{
if (d->clients.size() == 0) {
//qDebug() << "Starting framebuffer monitor";
kDebug() << "Starting framebuffer monitor";
d->fb->startMonitor();
d->rfbUpdateTimer.start(50);
}
@@ -223,7 +222,7 @@ void RfbServerManager::removeClient(RfbClient* cc)
{
d->clients.remove(cc);
if (d->clients.size() == 0) {
//qDebug() << "Stopping framebuffer monitor";
kDebug() << "Stopping framebuffer monitor";
d->fb->stopMonitor();
d->rfbUpdateTimer.stop();
}

View File

@@ -24,7 +24,7 @@
#include <QtCore/QObject>
class RfbClient;
struct RfbServerManagerStatic;
class RfbServerManagerStatic;
class RfbServer;
class RfbServerManager : public QObject
@@ -56,7 +56,7 @@ private:
Q_DISABLE_COPY(RfbServerManager)
friend class RfbServer;
friend struct RfbServerManagerStatic;
friend class RfbServerManagerStatic;
struct Private;
Private *const d;

View File

@@ -22,51 +22,49 @@
#include "rfbservermanager.h"
#include "rfbclient.h"
#include <QIcon>
#include <QMenu>
#include <KAboutApplicationDialog>
#include <KActionCollection>
#include <QDialog>
#include <KHelpMenu>
#include <KLocalizedString>
#include <KDialog>
#include <KGlobal>
#include <KLocale>
#include <KMenu>
#include <KStandardAction>
#include <KToggleAction>
#include <KConfigGroup>
#include <KDebug>
class ClientActions
{
public:
ClientActions(RfbClient *client, QMenu *menu, QAction *before);
ClientActions(RfbClient *client, KMenu *menu, QAction *before);
virtual ~ClientActions();
private:
QMenu *m_menu;
KMenu *m_menu;
QAction *m_title;
QAction *m_disconnectAction;
QAction *m_enableControlAction;
QAction *m_separator;
};
ClientActions::ClientActions(RfbClient* client, QMenu* menu, QAction* before)
ClientActions::ClientActions(RfbClient* client, KMenu* menu, QAction* before)
: m_menu(menu)
{
m_title = m_menu->insertSection(before, client->name());
m_title = m_menu->addTitle(client->name(), before);
m_disconnectAction = new QAction(i18n("Disconnect"), m_menu);
m_disconnectAction = new KAction(i18n("Disconnect"), m_menu);
m_menu->insertAction(before, m_disconnectAction);
QObject::connect(m_disconnectAction, &QAction::triggered, client, &RfbClient::closeConnection);
QObject::connect(m_disconnectAction, SIGNAL(triggered()), client, SLOT(closeConnection()));
if (client->controlCanBeEnabled()) {
m_enableControlAction = new KToggleAction(i18n("Enable Remote Control"), m_menu);
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, SIGNAL(triggered(bool)),
client, SLOT(setControlEnabled(bool)));
QObject::connect(client, SIGNAL(controlEnabledChanged(bool)),
m_enableControlAction, SLOT(setChecked(bool)));
} else {
m_enableControlAction = NULL;
}
@@ -76,6 +74,8 @@ ClientActions::ClientActions(RfbClient* client, QMenu* menu, QAction* before)
ClientActions::~ClientActions()
{
kDebug();
m_menu->removeAction(m_title);
delete m_title;
@@ -96,22 +96,24 @@ ClientActions::~ClientActions()
TrayIcon::TrayIcon(QWidget *mainWindow)
: KStatusNotifierItem(mainWindow)
{
setIconByPixmap(QIcon::fromTheme("krfb").pixmap(22, 22, QIcon::Disabled));
setIconByPixmap(KIcon("krfb").pixmap(22, 22, KIcon::Disabled));
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(), SIGNAL(clientConnected(RfbClient*)),
this, SLOT(onClientConnected(RfbClient*)));
connect(RfbServerManager::instance(), SIGNAL(clientDisconnected(RfbClient*)),
this, SLOT(onClientDisconnected(RfbClient*)));
m_aboutAction = KStandardAction::aboutApp(this, SLOT(showAbout()), this);
m_aboutAction = KStandardAction::aboutApp(this, SLOT(showAbout()), actionCollection());
contextMenu()->addAction(m_aboutAction);
}
void TrayIcon::onClientConnected(RfbClient* client)
{
kDebug();
if (m_clientActions.isEmpty()) { //first client connected
setIconByName("krfb");
setToolTipTitle(i18n("Desktop Sharing - connected with %1", client->name()));
@@ -125,11 +127,13 @@ void TrayIcon::onClientConnected(RfbClient* client)
void TrayIcon::onClientDisconnected(RfbClient* client)
{
kDebug();
ClientActions *actions = m_clientActions.take(client);
delete actions;
if (m_clientActions.isEmpty()) {
setIconByPixmap(QIcon::fromTheme("krfb").pixmap(22, 22, QIcon::Disabled));
setIconByPixmap(KIcon("krfb").pixmap(22, 22, KIcon::Disabled));
setToolTipTitle(i18n("Desktop Sharing - disconnected"));
setStatus(KStatusNotifierItem::Passive);
} else if (m_clientActions.size() == 1) { //clients number dropped back to 1
@@ -140,8 +144,9 @@ void TrayIcon::onClientDisconnected(RfbClient* client)
void TrayIcon::showAbout()
{
KHelpMenu menu;
menu.aboutApplication();
KDialog *dlg = new KAboutApplicationDialog(KGlobal::mainComponent().aboutData());
dlg->setAttribute(Qt::WA_DeleteOnClose, true);
dlg->show();
}
#include "trayicon.moc"

View File

@@ -19,7 +19,9 @@
#define TRAYICON_H
#include <KStatusNotifierItem>
#include <KToggleAction>
class KDialog;
class RfbClient;
class ClientActions;
@@ -40,7 +42,7 @@ public Q_SLOTS:
void showAbout();
private:
QAction *m_aboutAction;
KAction *m_aboutAction;
QHash<RfbClient*, ClientActions*> m_clientActions;
};

87
krfb/tubesrfbclient.cpp Normal file
View File

@@ -0,0 +1,87 @@
/*
Copyright (C) 2009-2010 Collabora Ltd. <info@collabora.co.uk>
@author George Goldberg <george.goldberg@collabora.co.uk>
@author George Kiagiadakis <george.kiagiadakis@collabora.co.uk>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tubesrfbclient.h"
#include "krfbconfig.h"
#include "connectiondialog.h"
#include <KNotification>
#include <KLocale>
QString TubesRfbClient::name() const
{
return m_contact->alias();
}
//********
PendingTubesRfbClient::PendingTubesRfbClient(rfbClientPtr client, QObject* parent) :
PendingRfbClient(client, parent),
m_processNewClientCalled(false)
{
processNewClient();
}
void PendingTubesRfbClient::setContact(const Tp::ContactPtr & contact)
{
m_contact = contact;
if (m_processNewClientCalled) {
//processNewClient has already been called, so we need to act here
showConfirmationDialog();
}
}
void PendingTubesRfbClient::processNewClient()
{
if (!m_contact) {
//no associated contact yet, hold.
m_processNewClientCalled = true; //act when a contact is set
} else {
//we have a contact, begin handling
showConfirmationDialog();
}
}
void PendingTubesRfbClient::showConfirmationDialog()
{
QString name = m_contact->alias();
KNotification::event("NewConnectionOnHold",
i18n("Received connection from %1, on hold (waiting for confirmation)",
name));
TubesConnectionDialog *dialog = new TubesConnectionDialog(0);
dialog->setContactName(name);
dialog->setAllowRemoteControl(KrfbConfig::allowDesktopControl());
connect(dialog, SIGNAL(okClicked()), SLOT(dialogAccepted()));
connect(dialog, SIGNAL(cancelClicked()), SLOT(reject()));
dialog->show();
}
void PendingTubesRfbClient::dialogAccepted()
{
TubesConnectionDialog *dialog = qobject_cast<TubesConnectionDialog *>(sender());
Q_ASSERT(dialog);
TubesRfbClient *client = new TubesRfbClient(m_rfbClient, m_contact, parent());
client->setControlEnabled(dialog->allowRemoteControl());
accept(client);
}
#include "tubesrfbclient.moc"

60
krfb/tubesrfbclient.h Normal file
View File

@@ -0,0 +1,60 @@
/*
Copyright (C) 2010 Collabora Ltd. <info@collabora.co.uk>
@author George Kiagiadakis <george.kiagiadakis@collabora.co.uk>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TUBESRFBCLIENT_H
#define TUBESRFBCLIENT_H
#include "rfbclient.h"
#include <TelepathyQt/Contact>
class TubesRfbClient : public RfbClient
{
public:
TubesRfbClient(rfbClientPtr client,
const Tp::ContactPtr &contact, QObject *parent=0)
: RfbClient(client, parent), m_contact(contact)
{}
virtual QString name() const;
private:
Tp::ContactPtr m_contact;
};
//*********
class PendingTubesRfbClient : public PendingRfbClient
{
Q_OBJECT
public:
PendingTubesRfbClient(rfbClientPtr client, QObject* parent = 0);
void setContact(const Tp::ContactPtr & contact);
protected Q_SLOTS:
virtual void processNewClient();
private Q_SLOTS:
void showConfirmationDialog();
void dialogAccepted();
private:
Tp::ContactPtr m_contact;
bool m_processNewClientCalled;
};
#endif // TUBESRFBCLIENT_H

262
krfb/tubesrfbserver.cpp Normal file
View File

@@ -0,0 +1,262 @@
/*
Copyright (C) 2009-2011 Collabora Ltd. <info@collabora.co.uk>
@author George Goldberg <george.goldberg@collabora.co.uk>
@author George Kiagiadakis <george.kiagiadakis@collabora.co.uk>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tubesrfbserver.h"
#include "tubesrfbclient.h"
#include "sockethelpers.h"
#include <KDebug>
#include <KRandom>
#include <TelepathyQt/Debug>
#include <TelepathyQt/Contact>
#include <TelepathyQt/AccountFactory>
#include <TelepathyQt/ConnectionFactory>
#include <TelepathyQt/ContactFactory>
#include <TelepathyQt/ChannelFactory>
#include <TelepathyQt/OutgoingStreamTubeChannel>
#include <TelepathyQt/StreamTubeServer>
#ifdef KRFB_WITH_KDE_TELEPATHY
#include <TelepathyQt/AccountSet>
#include <TelepathyQt/AccountManager>
#include <TelepathyQt/PendingReady>
#include <KTp/Models/contacts-list-model.h>
#include <KTp/contact-factory.h>
#endif
struct TubesRfbServer::Private
{
Tp::StreamTubeServerPtr stubeServer;
QHash<quint16, Tp::ContactPtr> contactsPerPort;
QHash<quint16, PendingTubesRfbClient*> clientsPerPort;
};
//static
TubesRfbServer *TubesRfbServer::instance;
//static
void TubesRfbServer::init()
{
instance = new TubesRfbServer;
//RfbServerManager takes care of deletion
instance->startAndCheck();
}
TubesRfbServer::TubesRfbServer(QObject *parent)
: RfbServer(parent), d(new Private)
{
kDebug() << "starting";
Tp::enableDebug(true);
Tp::enableWarnings(true);
Tp::registerTypes();
Tp::AccountFactoryPtr accountFactory = Tp::AccountFactory::create(
QDBusConnection::sessionBus(),
Tp::Features() << Tp::Account::FeatureCore
<< Tp::Account::FeatureAvatar
<< Tp::Account::FeatureCapabilities
<< Tp::Account::FeatureProtocolInfo
<< Tp::Account::FeatureProfile);
Tp::ConnectionFactoryPtr connectionFactory = Tp::ConnectionFactory::create(
QDBusConnection::sessionBus(),
Tp::Features() << Tp::Connection::FeatureCore
<< Tp::Connection::FeatureSelfContact);
Tp::ChannelFactoryPtr channelFactory = Tp::ChannelFactory::create(
QDBusConnection::sessionBus());
#ifdef KRFB_WITH_KDE_TELEPATHY
Tp::ContactFactoryPtr contactFactory = KTp::ContactFactory::create(
Tp::Features() << Tp::Contact::FeatureAlias
<<Tp::Contact::FeatureAvatarToken
<<Tp::Contact::FeatureAvatarData
<<Tp::Contact::FeatureSimplePresence
<<Tp::Contact::FeatureCapabilities
<<Tp::Contact::FeatureClientTypes);
m_accountManager = Tp::AccountManager::create(
QDBusConnection::sessionBus(),
accountFactory,
connectionFactory,
channelFactory,
contactFactory);
d->stubeServer = Tp::StreamTubeServer::create(
m_accountManager,
QStringList() << QLatin1String("rfb"),
QStringList(),
QLatin1String("krfb_rfb_handler"),
true);
connect(m_accountManager->becomeReady(),
SIGNAL(finished(Tp::PendingOperation*)),
this,
SLOT(onAccountManagerReady()));
m_contactsListModel = new KTp::ContactsListModel(this);
#else
Tp::ContactFactoryPtr contactFactory = Tp::ContactFactory::create(
Tp::Contact::FeatureAlias);
d->stubeServer = Tp::StreamTubeServer::create(
QStringList() << QLatin1String("rfb"),
QStringList(),
QLatin1String("krfb_rfb_handler"),
true,
accountFactory,
connectionFactory,
channelFactory,
contactFactory);
#endif //KRFB_WITH_KDE_TELEPATHY
connect(d->stubeServer.data(),
SIGNAL(tubeRequested(Tp::AccountPtr,Tp::OutgoingStreamTubeChannelPtr,
QDateTime,Tp::ChannelRequestHints)),
SLOT(onTubeRequested()));
connect(d->stubeServer.data(),
SIGNAL(tubeClosed(Tp::AccountPtr,Tp::OutgoingStreamTubeChannelPtr,QString,QString)),
SLOT(onTubeClosed()));
connect(d->stubeServer.data(),
SIGNAL(newTcpConnection(QHostAddress,quint16,Tp::AccountPtr,
Tp::ContactPtr,Tp::OutgoingStreamTubeChannelPtr)),
SLOT(onNewTcpConnection(QHostAddress,quint16,Tp::AccountPtr,
Tp::ContactPtr,Tp::OutgoingStreamTubeChannelPtr)));
connect(d->stubeServer.data(),
SIGNAL(tcpConnectionClosed(QHostAddress,quint16,Tp::AccountPtr,Tp::ContactPtr,
QString,QString,Tp::OutgoingStreamTubeChannelPtr)),
SLOT(onTcpConnectionClosed(QHostAddress,quint16,Tp::AccountPtr,Tp::ContactPtr,
QString,QString,Tp::OutgoingStreamTubeChannelPtr)));
// Pick a random port in the private range (4915265535)
setListeningPort((KRandom::random() % 16383) + 49152);
// Listen only on the loopback network interface
setListeningAddress("127.0.0.1");
setPasswordRequired(false);
}
TubesRfbServer::~TubesRfbServer()
{
kDebug();
stop();
delete d;
}
#ifdef KRFB_WITH_KDE_TELEPATHY
KTp::ContactsListModel *TubesRfbServer::contactsListModel()
{
return m_contactsListModel;
}
#endif
void TubesRfbServer::startAndCheck()
{
if (!start()) {
//try a few times with different ports
bool ok = false;
for (int i=0; !ok && i<5; i++) {
setListeningPort((KRandom::random() % 16383) + 49152);
ok = start();
}
if (!ok) {
kError() << "Failed to start tubes rfb server";
return;
}
}
//TODO listeningAddress() should be a QHostAddress
d->stubeServer->exportTcpSocket(QHostAddress(QString::fromAscii(listeningAddress())),
listeningPort());
}
void TubesRfbServer::onTubeRequested()
{
kDebug() << "Got a tube";
}
void TubesRfbServer::onTubeClosed()
{
kDebug() << "tube closed";
}
void TubesRfbServer::onNewTcpConnection(const QHostAddress & sourceAddress,
quint16 sourcePort,
const Tp::AccountPtr & account,
const Tp::ContactPtr & contact,
const Tp::OutgoingStreamTubeChannelPtr & tube)
{
Q_UNUSED(account);
Q_UNUSED(tube);
kDebug() << "CM signaled tube connection from" << sourceAddress << ":" << sourcePort;
d->contactsPerPort[sourcePort] = contact;
if (d->clientsPerPort.contains(sourcePort)) {
kDebug() << "client already exists";
d->clientsPerPort[sourcePort]->setContact(contact);
}
}
void TubesRfbServer::onTcpConnectionClosed(const QHostAddress& sourceAddress,
quint16 sourcePort,
const Tp::AccountPtr& account,
const Tp::ContactPtr& contact,
const QString& error,
const QString& message,
const Tp::OutgoingStreamTubeChannelPtr& tube)
{
Q_UNUSED(account);
Q_UNUSED(contact);
Q_UNUSED(tube);
kDebug() << "Connection from" << sourceAddress << ":" << sourcePort << "closed."
<< error << message;
d->clientsPerPort.remove(sourcePort);
d->contactsPerPort.remove(sourcePort);
}
PendingRfbClient* TubesRfbServer::newClient(rfbClientPtr client)
{
PendingTubesRfbClient *c = new PendingTubesRfbClient(client, this);
quint16 port = peerPort(client->sock);
kDebug() << "new tube client on port" << port;
d->clientsPerPort[port] = c;
if (d->contactsPerPort.contains(port)) {
kDebug() << "already have a contact";
c->setContact(d->contactsPerPort[port]);
}
return c;
}
#ifdef KRFB_WITH_KDE_TELEPATHY
void TubesRfbServer::onAccountManagerReady()
{
m_contactsListModel->setAccountManager(m_accountManager);
}
#endif
#include "tubesrfbserver.moc"

86
krfb/tubesrfbserver.h Normal file
View File

@@ -0,0 +1,86 @@
/*
Copyright (C) 2009-2011 Collabora Ltd. <info@collabora.co.uk>
@author George Goldberg <george.goldberg@collabora.co.uk>
@author George Kiagiadakis <george.kiagiadakis@collabora.co.uk>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TUBESRFBSERVER_H
#define TUBESRFBSERVER_H
#include "rfbserver.h"
#include <QtNetwork/QHostAddress>
#include <TelepathyQt/Types>
#ifdef KRFB_WITH_KDE_TELEPATHY
namespace KTp {
class ContactsListModel;
}
#endif
class TubesRfbServer : public RfbServer
{
Q_OBJECT
public:
static TubesRfbServer *instance;
static void init();
virtual ~TubesRfbServer();
#ifdef KRFB_WITH_KDE_TELEPATHY
KTp::ContactsListModel *contactsListModel();
#endif
protected:
TubesRfbServer(QObject *parent = 0);
virtual PendingRfbClient* newClient(rfbClientPtr client);
private Q_SLOTS:
void startAndCheck();
void onTubeRequested();
void onTubeClosed();
void onNewTcpConnection(
const QHostAddress &sourceAddress,
quint16 sourcePort,
const Tp::AccountPtr &account,
const Tp::ContactPtr &contact,
const Tp::OutgoingStreamTubeChannelPtr &tube);
void onTcpConnectionClosed(
const QHostAddress &sourceAddress,
quint16 sourcePort,
const Tp::AccountPtr &account,
const Tp::ContactPtr &contact,
const QString &error,
const QString &message,
const Tp::OutgoingStreamTubeChannelPtr &tube);
#ifdef KRFB_WITH_KDE_TELEPATHY
void onAccountManagerReady();
#endif
private:
struct Private;
Private *const d;
#ifdef KRFB_WITH_KDE_TELEPATHY
KTp::ContactsListModel *m_contactsListModel;
Tp::AccountManagerPtr m_accountManager;
#endif
};
#endif // TUBESRFBSERVER_H

View File

@@ -442,7 +442,7 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="unattendedPasswordButton">
<widget class="KPushButton" name="unattendedPasswordButton">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
@@ -486,6 +486,11 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KPushButton</class>
<extends>QPushButton</extends>
<header>kpushbutton.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>enableSharingCheckBox</tabstop>

View File

@@ -0,0 +1,114 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TubesConnectionWidget</class>
<widget class="QWidget" name="TubesConnectionWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>162</height>
</rect>
</property>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="pixmapLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>128</width>
<height>128</height>
</size>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout">
<item>
<widget class="QLabel" name="TextLabel5">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>13</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Confirmation</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
<property name="indent">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="mainTextLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="lineWidth">
<number>-1</number>
</property>
<property name="midLineWidth">
<number>5</number>
</property>
<property name="text">
<string/>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="margin">
<number>0</number>
</property>
<property name="indent">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbAllowRemoteControl">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="whatsThis">
<string>If you turn this option on, the remote user can enter keystrokes and use your mouse pointer. This gives them full control over your computer, so be careful. When the option is disabled the remote user can only watch your screen.</string>
</property>
<property name="text">
<string>Allow remote user to &amp;control keyboard and mouse</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>