Commit 6306bf85 authored by Jeremy Whiting's avatar Jeremy Whiting
Browse files

Initial port to Qt5/KF5.

Fixed FindLibVNCServer to use CheckStructHasMember.
Ported from kDebug to qDebug
Runs and seems to work, but probably missed some things.
parent cb43be43
cmake_minimum_required(VERSION 2.8.9)
cmake_minimum_required(VERSION 2.8.12)
project(krfb)
if(NOT INSIDE_KDENETWORK)
message("Not building inside KDENetwork, loading KDE CMake Macros.")
include(FeatureSummary)
find_package(Qt5 REQUIRED COMPONENTS Core DBus Widgets X11Extras)
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
Crash
CoreAddons
DNSSD
DocTools
KDELibs4Support
Wallet
WidgetsAddons
)
include(CheckIncludeFile)
include(CheckIncludeFiles)
include(CheckSymbolExists)
include(CheckFunctionExists)
include(CheckLibraryExists)
include(CheckPrototypeExists)
include(CheckTypeSize)
find_package(X11 REQUIRED)
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)
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(IS_KTP_INTERNAL_MODULE TRUE)
# set(IS_KTP_INTERNAL_MODULE TRUE)
set(CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
${CMAKE_MODULE_PATH}
......@@ -35,14 +43,22 @@ set(CMAKE_MODULE_PATH
find_package(LibVNCServer REQUIRED)
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(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_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)
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()
include_directories ("${CMAKE_CURRENT_BINARY_DIR}/krfb"
"${CMAKE_CURRENT_SOURCE_DIR}/krfb"
......@@ -58,7 +74,3 @@ endif(Q_WS_X11)
add_subdirectory(krfb)
add_subdirectory(framebuffers)
add_subdirectory(doc)
if (NOT INSIDE_KDENETWORK)
macro_display_feature_log()
endif ()
......@@ -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(CheckPointerMember)
INCLUDE(CheckStructHasMember)
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_POINTER_MEMBER(rfbClient* GotXCutText rfb/rfbclient.h LIBVNCSERVER_FOUND)
CHECK_STRUCT_HAS_MEMBER("struct _rfbClient" GotXCutText rfb/rfbclient.h LIBVNCSERVER_FOUND)
ENDIF (LIBVNCSERVER_INCLUDE_DIR AND LIBVNCSERVER_LIBRARIES)
IF (LIBVNCSERVER_FOUND)
......
########### install files ###############
kde4_create_handbook(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR krfb)
kdoctools_create_handbook(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR krfb)
......@@ -7,14 +7,15 @@ set (krfb_framebuffer_qt_SRCS
qtframebufferplugin.cpp
)
kde4_add_plugin (krfb_framebuffer_qt
add_library(krfb_framebuffer_qt
MODULE
${krfb_framebuffer_qt_SRCS}
)
target_link_libraries (krfb_framebuffer_qt
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
${KDE4_KDEUI_LIBS}
Qt5::Core
Qt5::Gui
KF5::KDELibs4Support
krfbprivate
)
......
......@@ -25,7 +25,7 @@
#include <kdemacros.h>
#include <QtGui/QWidget>
#include <QWidget>
class FrameBuffer;
......
......@@ -7,17 +7,19 @@ set (krfb_framebuffer_x11_SRCS
x11framebufferplugin.cpp
)
kde4_add_plugin (krfb_framebuffer_x11
add_library(krfb_framebuffer_x11
MODULE
${krfb_framebuffer_x11_SRCS}
)
target_link_libraries (krfb_framebuffer_x11
${KDE4_KDEUI_LIBS}
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
Qt5::Core
Qt5::Gui
${X11_X11_LIB}
${X11_Xdamage_LIB}
${X11_Xext_LIB}
KF5::KDELibs4Support
krfbprivate
)
......
......@@ -17,7 +17,7 @@
#include <QDesktopWidget>
#include <KApplication>
#include <KDebug>
#include <QDebug>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
......@@ -56,7 +56,7 @@ X11FrameBuffer::X11FrameBuffer(WId id, QObject *parent)
{
#ifdef HAVE_XSHM
d->useShm = XShmQueryExtension(QX11Info::display());
kDebug() << "shm: " << d->useShm;
//qDebug() << "shm: " << d->useShm;
#else
d->useShm = false;
#endif
......@@ -94,7 +94,7 @@ X11FrameBuffer::X11FrameBuffer(WId id, QObject *parent)
;
}
kDebug() << "Got image. bpp: " << d->framebufferImage->bits_per_pixel
qDebug() << "Got image. bpp: " << d->framebufferImage->bits_per_pixel
<< ", depth: " << d->framebufferImage->depth
<< ", padded width: " << d->framebufferImage->bytes_per_line
<< " (sent: " << d->framebufferImage->width * 4 << ")"
......@@ -207,25 +207,25 @@ void X11FrameBuffer::cleanupRects()
QList<QRect> cpy = tiles;
bool inserted = false;
tiles.clear();
// kDebug() << "before cleanup: " << cpy.size();
// //qDebug() << "before cleanup: " << cpy.size();
foreach(const QRect & r, cpy) {
if (tiles.size() > 0) {
for (int i = 0; i < tiles.size(); i++) {
// kDebug() << r << tiles[i];
// //qDebug() << r << tiles[i];
if (r.intersects(tiles[i])) {
tiles[i] |= r;
inserted = true;
break;
// kDebug() << "merged into " << tiles[i];
// //qDebug() << "merged into " << tiles[i];
}
}
if (!inserted) {
tiles.append(r);
// kDebug() << "appended " << r;
// //qDebug() << "appended " << r;
}
} else {
// kDebug() << "appended " << r;
// //qDebug() << "appended " << r;
tiles.append(r);
}
}
......@@ -250,7 +250,7 @@ void X11FrameBuffer::cleanupRects()
}
}
// kDebug() << "after cleanup: " << tiles.size();
// //qDebug() << "after cleanup: " << tiles.size();
}
void X11FrameBuffer::acquireEvents()
......@@ -258,11 +258,13 @@ 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()
......@@ -283,7 +285,7 @@ QList< QRect > X11FrameBuffer::modifiedTiles()
#ifdef HAVE_XSHM
foreach(const QRect & r, tiles) {
// kDebug() << r;
// //qDebug() << r;
gl |= r;
int y = r.y();
int x = r.x();
......@@ -298,7 +300,7 @@ QList< QRect > X11FrameBuffer::modifiedTiles()
x = d->framebufferImage->width - d->updateTile->width;
}
// kDebug() << "x: " << x << " (" << r.x() << ") y: " << y << " (" << r.y() << ") " << r;
// //qDebug() << "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));
......@@ -336,8 +338,8 @@ QList< QRect > X11FrameBuffer::modifiedTiles()
}
}
// kDebug() << "tot: " << gl;
// kDebug() << tiles.size();
// //qDebug() << "tot: " << gl;
// //qDebug() << tiles.size();
ret = tiles;
tiles.clear();
return ret;
......
......@@ -13,6 +13,7 @@
#include <QWidget>
class X11FrameBuffer;
typedef union _XEvent XEvent;
class EvWidget: public QWidget
{
......
......@@ -25,7 +25,7 @@
#include <kdemacros.h>
#include <QtGui/QWidget>
#include <QWidget>
class FrameBuffer;
......
[Project]
Manager=KDevCMakeManager
Name=krfb
......@@ -2,6 +2,8 @@ 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.
......@@ -11,21 +13,23 @@ set (krfbprivate_SRCS
framebufferplugin.cpp
)
kde4_add_library (krfbprivate
add_library (krfbprivate
SHARED
${krfbprivate_SRCS}
)
generate_export_header(krfbprivate BASE_NAME krfbprivate)
target_link_libraries (krfbprivate
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
Qt5::Core
Qt5::Widgets
Qt5::X11Extras
${X11_X11_LIB}
${LIBVNCSERVER_LIBRARIES}
)
set_target_properties (krfbprivate PROPERTIES
VERSION ${GENERIC_LIB_VERSION}
SOVERSION ${GENERIC_LIB_VERSION}
VERSION 5
SOVERSION 5.0
)
install (TARGETS krfbprivate
......@@ -75,11 +79,11 @@ if(TelepathyQt4_FOUND)
)
endif()
kde4_add_kcfg_files (krfb_SRCS
kconfig_add_kcfg_files (krfb_SRCS
krfbconfig.kcfgc
)
kde4_add_ui_files (krfb_SRCS
ki18n_wrap_ui (krfb_SRCS
ui/configtcp.ui
ui/configsecurity.ui
ui/connectionwidget.ui
......@@ -87,10 +91,10 @@ kde4_add_ui_files (krfb_SRCS
)
if(TelepathyQt4_FOUND)
kde4_add_ui_files(krfb_SRCS ui/tubesconnectionwidget.ui)
ki18n_wrap_ui(krfb_SRCS ui/tubesconnectionwidget.ui)
endif()
kde4_add_executable (krfb
add_executable (krfb
${krfb_SRCS}
)
......@@ -101,9 +105,11 @@ target_link_libraries (krfb
${X11_Xext_LIB}
${X11_X11_LIB}
${X11_Xdamage_LIB}
${QT_QTNETWORK_LIBRARY}
${KDE4_KDNSSD_LIBS}
${KDE4_KDEUI_LIBS}
Qt5::Network
KF5::DNSSD
KF5::KDELibs4Support
KF5::Wallet
KF5::WidgetsAddons
${LIBVNCSERVER_LIBRARIES}
)
......
......@@ -21,12 +21,11 @@
#include "connectiondialog.h"
#include <KIconLoader>
#include <KIcon>
#include <KLocale>
#include <KStandardGuiItem>
#include <QtGui/QCheckBox>
#include <QtGui/QLabel>
#include <QCheckBox>
template <typename UI>
ConnectionDialog<UI>::ConnectionDialog(QWidget *parent)
......
......@@ -24,9 +24,9 @@
#include "events.h"
#include <QtGui/QApplication>
#include <QtGui/QX11Info>
#include <QtGui/QDesktopWidget>
#include <QApplication>
#include <QX11Info>
#include <QDesktopWidget>
#include <KGlobal>
#include <X11/Xutil.h>
......
......@@ -12,19 +12,19 @@
#include "rfb.h"
#include <kdemacros.h>
#include "krfbprivate_export.h"
#include <QtCore/QObject>
#include <QtCore/QRect>
#include <QtCore/QList>
#include <QWidget>
#include <QtGui/QWidget>
class FrameBuffer;
/**
@author Alessandro Praduroux <pradu@pradu.it>
*/
class KDE_EXPORT FrameBuffer : public QObject
class KRFBPRIVATE_EXPORT FrameBuffer : public QObject
{
Q_OBJECT
public:
......
......@@ -23,7 +23,7 @@
#include "framebufferplugin.h"
#include "krfbconfig.h"
#include <KDebug>
#include <QDebug>
#include <KGlobal>
#include <KServiceTypeTrader>
......@@ -39,26 +39,26 @@ K_GLOBAL_STATIC(FrameBufferManagerStatic, frameBufferManagerStatic)
FrameBufferManager::FrameBufferManager()
{
kDebug();
//qDebug();
loadPlugins();
}
FrameBufferManager::~FrameBufferManager()
{
kDebug();
//qDebug();
}
FrameBufferManager *FrameBufferManager::instance()
{
kDebug();
//qDebug();
return &frameBufferManagerStatic->instance;
}
void FrameBufferManager::loadPlugins()
{
kDebug();
//qDebug();
// Load the all the plugin factories here, for use later.
KService::List offers = KServiceTypeTrader::self()->query("krfb/framebuffer");
......@@ -72,34 +72,34 @@ void FrameBufferManager::loadPlugins()
KPluginFactory *factory = KPluginLoader(service->library()).factory();
if (!factory) {
kWarning() << "KPluginFactory could not load the plugin:" << service->library();
qWarning() << "KPluginFactory could not load the plugin:" << service->library();
continue;
}
FrameBufferPlugin *plugin = factory->create<FrameBufferPlugin>(this);
if (plugin) {
kDebug() << "Loaded plugin:" << service->name();
//qDebug() << "Loaded plugin:" << service->name();
m_plugins.insert(service->library(), plugin);
} else {
kDebug() << error;
//qDebug() << error;
}
}
}
QSharedPointer<FrameBuffer> FrameBufferManager::frameBuffer(WId id)
{
kDebug();
//qDebug();
// 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) {
kDebug() << "Found cached frame buffer.";
//qDebug() << "Found cached frame buffer.";
return weakFrameBuffer.toStrongRef();
} else {
kDebug() << "Found deleted cached frame buffer. Don't use.";
//qDebug() << "Found deleted cached frame buffer. Don't use.";
m_frameBuffers.remove(id);
}
}
......@@ -110,7 +110,7 @@ QSharedPointer<FrameBuffer> FrameBufferManager::frameBuffer(WId id)
while (iter != m_plugins.constEnd()) {
if (iter.key() == KrfbConfig::preferredFrameBufferPlugin()) {
kDebug() << "Using FrameBuffer:" << KrfbConfig::preferredFrameBufferPlugin();
//qDebug() << "Using FrameBuffer:" << KrfbConfig::preferredFrameBufferPlugin();
QSharedPointer<FrameBuffer> frameBuffer(iter.value()->frameBuffer(id));
......@@ -125,7 +125,7 @@ QSharedPointer<FrameBuffer> FrameBufferManager::frameBuffer(WId id)
}
// No valid framebuffer plugin found.
kDebug() << "No valid framebuffer found. returning null.";
//qDebug() << "No valid framebuffer found. returning null.";
return QSharedPointer<FrameBuffer>();
}
......
......@@ -23,19 +23,19 @@
#include "framebuffer.h"
#include <kdemacros.h>
#include "krfbprivate_export.h"
#include <QtCore/QMap>
#include <QtCore/QObject>
#include <QtCore/QSharedPointer>
#include <QtCore/QWeakPointer>
#include <QtGui/QWidget>
#include <QWidget>
class FrameBufferPlugin;
class KPluginFactory;
class KDE_EXPORT FrameBufferManager : public QObject
class KRFBPRIVATE_EXPORT FrameBufferManager : public QObject
{
Q_OBJECT
friend class FrameBufferManagerStatic;
......
......@@ -21,15 +21,15 @@
#ifndef LIB_KRFB_FRAMEBUFFERPLUGIN_H
#define LIB_KRFB_FRAMEBUFFERPLUGIN_H
#include <kdemacros.h>
#include "krfbprivate_export.h"
#include <QtCore/QVariantList>
#include <QWidget>
#include <QtGui/QWidget>
class FrameBuffer;
class KDE_EXPORT FrameBufferPlugin : public QObject
class KRFBPRIVATE_EXPORT FrameBufferPlugin : public QObject
{
Q_OBJECT
......
......@@ -26,6 +26,8 @@
#include "connectiondialog.h"
#include <KNotification>
#include <KLocale>
#include <QDebug>
#include <QtCore/QSocketNotifier>
#include <poll.h>
......@@ -111,7 +113,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) {
kDebug() << "disconnected from socket signal";
qDebug() << "disconnected from socket signal";
d->notifier->setEnabled(false);
rfbClientConnectionGone(d->client);
break;
......@@ -122,7 +124,7 @@ void PendingInvitationsRfbClient::onSocketActivated()
bool PendingInvitationsRfbClient::checkPassword(const QByteArray & encryptedPassword)
{
QByteArray password ;
kDebug() << "about to start autentication";
qDebug() << "about to start autentication";
if(InvitationsRfbServer::instance->allowUnattendedAccess() && vncAuthCheckPassword(
InvitationsRfbServer::instance->unattendedPassword().toLocal8Bit(),
......
......@@ -23,16 +23,18 @@
#include "krfbconfig.h"
#include "rfbservermanager.h"
#include <QtCore/QTimer>
#include <QtGui/QApplication>
#include <QApplication>
#include <QtNetwork/QHostInfo>
#include <KNotification>
#include <QDebug>
#include <KLocale>
#include <KMessageBox>
#include <KUser>
#include <KRandom>
#include <KStringHandler>
#include <KWallet/Wallet>
#include <DNSSD/PublicService>
#include <KGlobal>
#include <dnssd/publicservice.h>
using KWallet::Wallet;
//static
......@@ -42,7 +44,7 @@ InvitationsRfbServer *InvitationsRfbServer::instance;
void InvitationsRfbServer::init()