From 0add30a88344c8429a19825e3ce0400420d7337f Mon Sep 17 00:00:00 2001 From: uwolfer Date: Thu, 21 Feb 2008 21:51:53 +0000 Subject: [PATCH] Ability to build a Qt-only version of the KRDC VNC backend. This way Qt-only probjects can use these files without changes, and thus backporting fixes or improvements will be a lot easier. Please see krdc/vnc/qtonly/README for more information. git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/KDE/kdenetwork@777906 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- krdc/remoteview.cpp | 19 ++++++++++++++---- krdc/remoteview.h | 20 +++++++++++++------ krdc/vnc/qtonly/README | 30 ++++++++++++++++++++++++++++ krdc/vnc/qtonly/krdc-vnc-qtonly.pro | 9 +++++++++ krdc/vnc/qtonly/main.cpp | 40 +++++++++++++++++++++++++++++++++++++ krdc/vnc/vncclientthread.cpp | 7 ++----- krdc/vnc/vncclientthread.h | 12 ++++++++++- krdc/vnc/vncview.cpp | 38 +++++++++++++++++++++++++++-------- krdc/vnc/vncview.h | 9 +++++++-- 9 files changed, 158 insertions(+), 26 deletions(-) create mode 100644 krdc/vnc/qtonly/README create mode 100644 krdc/vnc/qtonly/krdc-vnc-qtonly.pro create mode 100644 krdc/vnc/qtonly/main.cpp diff --git a/krdc/remoteview.cpp b/krdc/remoteview.cpp index 4ac67f925..b0b468d52 100644 --- a/krdc/remoteview.cpp +++ b/krdc/remoteview.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2002-2003 Tim Jansen -** Copyright (C) 2007 Urs Wolfer +** Copyright (C) 2007-2008 Urs Wolfer ** ** This file is part of KDE. ** @@ -24,9 +24,12 @@ #include "remoteview.h" +#ifndef QTONLY + #include + #include +#endif + #include -#include -#include RemoteView::RemoteView(QWidget *parent) : QWidget(parent), @@ -34,7 +37,9 @@ RemoteView::RemoteView(QWidget *parent) m_host(QString()), m_port(0), m_viewOnly(false), +#ifndef QTONLY m_wallet(0), +#endif m_dotCursorState(CursorOff) { } @@ -153,6 +158,7 @@ KUrl RemoteView::url() return m_url; } +#ifndef QTONLY QString RemoteView::readWalletPassword() { QString krdc_folder = "KRDC"; @@ -188,14 +194,19 @@ void RemoteView::saveWalletPassword(const QString &password) m_wallet->writePassword(m_url.prettyUrl(KUrl::RemoveTrailingSlash), password); } } +#endif QCursor RemoteView::localDotCursor() const { +#ifdef QTONLY + return QCursor(); //TODO +#else QBitmap cursorBitmap(KGlobal::dirs()->findResource("appdata", "pics/pointcursor.png")); QBitmap cursorMask(KGlobal::dirs()->findResource("appdata", "pics/pointcursormask.png")); return QCursor(cursorBitmap, cursorMask); +#endif } -#include "remoteview.moc" +#include "moc_remoteview.cpp" diff --git a/krdc/remoteview.h b/krdc/remoteview.h index e9a1891d4..3abc95ed4 100644 --- a/krdc/remoteview.h +++ b/krdc/remoteview.h @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2002-2003 Tim Jansen -** Copyright (C) 2007 Urs Wolfer +** Copyright (C) 2007-2008 Urs Wolfer ** ** This file is part of KDE. ** @@ -25,8 +25,13 @@ #ifndef REMOTEVIEW_H #define REMOTEVIEW_H -#include -#include +#ifdef QTONLY + #include + #define KUrl QUrl +#else + #include + #include +#endif #include @@ -341,14 +346,17 @@ protected: QCursor localDotCursor() const; - QString readWalletPassword(); - void saveWalletPassword(const QString &password); - QString m_host; int m_port; bool m_viewOnly; KUrl m_url; + +#ifndef QTONLY + QString readWalletPassword(); + void saveWalletPassword(const QString &password); KWallet::Wallet *m_wallet; +#endif + DotCursorState m_dotCursorState; }; diff --git a/krdc/vnc/qtonly/README b/krdc/vnc/qtonly/README new file mode 100644 index 000000000..e38fcb703 --- /dev/null +++ b/krdc/vnc/qtonly/README @@ -0,0 +1,30 @@ +Qt-only version of the KRDC VNC backend +======================================= + +In order to build it, you need the LibVNCClient (LibVNCServer) +library (version 0.9.1 or newer required): + http://sourceforge.net/project/showfiles.php?group_id=32584&package_id=24717 + +The following files from KRDC are required: + krdc/remoteview.{cpp,h} + krdc/vnc/vncview.{cpp,h} + krdc/vnc/vncclientthread.{cpp,h} + krdc/vnc/qtonly/main.cpp + krdc/vnc/qtonly/krdc-vnc-qtonly.pro + +Copy these files into a folder and run: + qmake + make + +In order to try it out, type: + ./krdc-vnc-qtonly vnc://:password@server:1 1 + (the last argument defines the quality as second argument (1-3, where 1 is + the best). Default is 2.) + +If you use these code in your project, make sure that QTONLY is defined (see +krdc-vnc-qtonly.pro). + +IMPORTANT NOTICE +================ +If you do any fixes or improvements in these files, please backport them to the original sources. +Please send a patch with the changes to . Thanks a lot! diff --git a/krdc/vnc/qtonly/krdc-vnc-qtonly.pro b/krdc/vnc/qtonly/krdc-vnc-qtonly.pro new file mode 100644 index 000000000..4d729e11e --- /dev/null +++ b/krdc/vnc/qtonly/krdc-vnc-qtonly.pro @@ -0,0 +1,9 @@ +TEMPLATE = app +TARGET = +DEPENDPATH += . +INCLUDEPATH += . +LIBS += -lvncclient +DEFINES += QTONLY + +HEADERS += remoteview.h vncclientthread.h vncview.h +SOURCES += main.cpp remoteview.cpp vncclientthread.cpp vncview.cpp diff --git a/krdc/vnc/qtonly/main.cpp b/krdc/vnc/qtonly/main.cpp new file mode 100644 index 000000000..bb753578b --- /dev/null +++ b/krdc/vnc/qtonly/main.cpp @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Urs Wolfer +** +** This file is part of KDE. +** +** 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 General Public License +** along with this program; see the file COPYING. If not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +** Boston, MA 02110-1301, USA. +** +****************************************************************************/ + +#include + +#include "vncview.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + if (QCoreApplication::arguments().count() < 2) { + qFatal("Please define an URL as argument. Example: vnc://:password@server:1\n" + "Optionally, you can define the quality as second argument (1-3, where 1 is the best). Default is 2."); + return 1; + } + VncView vncView(0, QCoreApplication::arguments().at(1)); + vncView.show(); + vncView.start(); + return app.exec(); +} diff --git a/krdc/vnc/vncclientthread.cpp b/krdc/vnc/vncclientthread.cpp index 98edf5fc6..ed053dfe4 100644 --- a/krdc/vnc/vncclientthread.cpp +++ b/krdc/vnc/vncclientthread.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2007 Urs Wolfer +** Copyright (C) 2007-2008 Urs Wolfer ** ** This file is part of KDE. ** @@ -23,9 +23,6 @@ #include "vncclientthread.h" -#include -#include - #include #include @@ -357,4 +354,4 @@ void VncClientThread::clientCut(const QString &text) m_eventQueue.enqueue(new ClientCutEvent(strdup(text.toUtf8()))); } -#include "vncclientthread.moc" +#include "moc_vncclientthread.cpp" diff --git a/krdc/vnc/vncclientthread.h b/krdc/vnc/vncclientthread.h index 3c3b338f4..f2bb3f233 100644 --- a/krdc/vnc/vncclientthread.h +++ b/krdc/vnc/vncclientthread.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2007 Urs Wolfer +** Copyright (C) 2007-2008 Urs Wolfer ** ** This file is part of KDE. ** @@ -24,6 +24,16 @@ #ifndef VNCCLIENTTHREAD_H #define VNCCLIENTTHREAD_H +#ifdef QTONLY + #include + #define kDebug(n) qDebug() + #define kBacktrace() "" + #define i18n tr +#else + #include + #include +#endif + #include "remoteview.h" #include diff --git a/krdc/vnc/vncview.cpp b/krdc/vnc/vncview.cpp index 123813e4b..2f7b0e8ac 100644 --- a/krdc/vnc/vncview.cpp +++ b/krdc/vnc/vncview.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2007 Urs Wolfer +** Copyright (C) 2007-2008 Urs Wolfer ** ** This file is part of KDE. ** @@ -23,10 +23,16 @@ #include "vncview.h" -#include -#include -#include -#include +#ifdef QTONLY + #include + #include + #define KMessageBox QMessageBox + #define error(parent, message, caption) \ + critical(parent, caption, message) +#else + #include + #include +#endif #include #include @@ -124,11 +130,15 @@ bool VncView::isQuitting() bool VncView::start() { - m_hostPreferences = new VncHostPreferences(m_url.prettyUrl(KUrl::RemoveTrailingSlash), false, this); - vncThread.setHost(m_host); vncThread.setPort(m_port); +#ifdef QTONLY + int quality = (QCoreApplication::arguments().count() > 2) ? QCoreApplication::arguments().at(2).toInt() : 2; + vncThread.setQuality((RemoteView::Quality)quality); +#else + m_hostPreferences = new VncHostPreferences(m_url.prettyUrl(KUrl::RemoveTrailingSlash), false, this); vncThread.setQuality(m_hostPreferences->quality()); +#endif setStatus(Connecting); @@ -147,6 +157,7 @@ void VncView::requestPassword() setStatus(Authenticating); +#ifndef QTONLY if (m_hostPreferences->walletSupport()) { QString walletPassword = readWalletPassword(); @@ -155,12 +166,20 @@ void VncView::requestPassword() return; } } +#endif if (!m_url.password().isNull()) { vncThread.setPassword(m_url.password()); return; } +#ifdef QTONLY + QString password = QInputDialog::getText(this, //krazy:exclude=qclasses + tr("Password required"), + tr("Please enter the password for the remote desktop:"), + QLineEdit::Password); + vncThread.setPassword(password); +#else KPasswordDialog dialog(this); dialog.setPixmap(KIcon("dialog-password").pixmap(48)); dialog.setPrompt(m_firstPasswordTry ? i18n("Access to the system requires a password.") @@ -169,6 +188,7 @@ void VncView::requestPassword() m_firstPasswordTry = false; vncThread.setPassword(dialog.password()); } +#endif } void VncView::outputErrorMessage(const QString &message) @@ -206,9 +226,11 @@ void VncView::updateImage(int x, int y, int w, int h) emit connected(); m_initDone = true; +#ifndef QTONLY if (m_hostPreferences->walletSupport()) { saveWalletPassword(vncThread.password()); } +#endif } if ((y == 0 && x == 0) && (m_frame.size() != size())) { @@ -453,4 +475,4 @@ void VncView::clipboardDataChanged() vncThread.clientCut(text); } -#include "vncview.moc" +#include "moc_vncview.cpp" diff --git a/krdc/vnc/vncview.h b/krdc/vnc/vncview.h index 08838266b..c438cb7bd 100644 --- a/krdc/vnc/vncview.h +++ b/krdc/vnc/vncview.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2007 Urs Wolfer +** Copyright (C) 2007-2008 Urs Wolfer ** ** This file is part of KDE. ** @@ -25,9 +25,12 @@ #define VNCVIEW_H #include "remoteview.h" -#include "vnchostpreferences.h" #include "vncclientthread.h" +#ifndef QTONLY + #include "vnchostpreferences.h" +#endif + #include extern "C" { @@ -73,7 +76,9 @@ private: bool m_quitFlag; bool m_firstPasswordTry; bool m_dontSendClipboard; +#ifndef QTONLY VncHostPreferences *m_hostPreferences; +#endif QImage m_frame; private slots: -- 2.11.4.GIT