From 617167cae5a8ae02a3b061fa1d81a4ec3dc698c2 Mon Sep 17 00:00:00 2001 From: Tim Jansen Date: Sun, 17 Feb 2002 00:33:31 +0000 Subject: [PATCH] preparation for 0.6.0; knotify commit (not working yet) svn path=/trunk/kdenetwork/krfb/; revision=136908 --- ChangeLog | 4 + DCOP-INTERFACE | 24 +++ NOTES | 6 +- README | 12 +- ROADMAP | 14 +- TODO | 2 - kinetd/kinetd.cpp | 61 +++++++ kinetd/kinetd.desktop | 13 ++ kinetd/kinetd.h | 44 ++++++ kinetd/portlistener.h | 44 ++++++ krfb/Makefile.am | 5 +- krfb/configuration.cc | 36 +---- krfb/configuration.h | 6 +- krfb/configurationdialog.ui | 306 +++++++++++------------------------- krfb/eventsrc | 40 +++++ krfb/krfbiface.h | 1 - krfb/krfbifaceimpl.cc | 19 ++- krfb/krfbifaceimpl.h | 37 +++++ krfb/main.cpp | 16 +- krfb/rfbcontroller.cc | 64 ++++++-- krfb/rfbcontroller.h | 3 + libvncserver/TODO.krfb | 2 + 22 files changed, 458 insertions(+), 301 deletions(-) create mode 100644 DCOP-INTERFACE create mode 100644 kinetd/kinetd.cpp create mode 100644 kinetd/kinetd.desktop create mode 100644 kinetd/kinetd.h create mode 100644 kinetd/portlistener.h create mode 100644 krfb/eventsrc create mode 100644 krfb/krfbifaceimpl.h create mode 100644 libvncserver/TODO.krfb diff --git a/ChangeLog b/ChangeLog index e8812e5..5179037 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2002-02-17 Tim Jansen + + * rfbcontroller.cc: added KNotify support + 2002-02-14 Tim Jansen * integrated DCOP interface patch by Ian Reinhart diff --git a/DCOP-INTERFACE b/DCOP-INTERFACE new file mode 100644 index 0000000..8a3a039 --- /dev/null +++ b/DCOP-INTERFACE @@ -0,0 +1,24 @@ +DCOP Interfaces: +// Disconnects the current session +void disconnect() +// Exits the application +void exit() +// Will the application quit after one connection +bool oneConnection() +// Set the application to quite after one connection +void setOneConnection(bool) +// Will the application ask the user for permission +// when a new connection arrives +bool askOnConnect() +// Set the application to ask for permission on new connections +void setAskOnConnect(bool) +// Is the desktop controlable from remote clients +bool allowDesktopControl() +// Set the desktop to be controlable from remote clients +void setAllowDesktopControl(bool) +// Set the password to connect to your system +void setPassword(QString) +// What port will clients connect on +int port() + + diff --git a/NOTES b/NOTES index 4df23dd..01f89f6 100644 --- a/NOTES +++ b/NOTES @@ -15,14 +15,14 @@ Some comments on various aspects of KRfb: issues like setting a password - design goal of KRfb is to make it as easy to use as possible. I tried to limit functionality whereever possible. -- the original x0rfbserver has a features for selecting the port number - automatically. I skipped that because it is too complicated on the client - side, but I this will change when there are mechanisms for inviting people. - the command line args are intended for starting KRfb from a system like Jabber, thats the reason why there is no preferences dialog when command line args have been used and it's also the reason for --one-connection - the newconnection-dialog is extra large and has the pixmap on the left side to capture the attention of the user before allowing a connection. +- the auto-port-selection feature is somewhat inconvenient when you have + more than one VNC server running (you cannot know the port). Problems + willbe solved in a future version when there is an invitation feature. tim@tjansen.de diff --git a/README b/README index 1b7398c..33931e6 100644 --- a/README +++ b/README @@ -2,18 +2,20 @@ KRfb ==== KRfb is a small server for the RFB protocol, better known as VNC. Unlike most -other Unix/Linux RFB servers, KRfb (and x0rfbserver) allows you -to share your X11 session instead of creating a new X11 session. -It is based on x0rfbserver, available from -http://www.hexonet.de/software/x0rfbserver/. +other Unix/Linux RFB servers, KRfb allows you to share your X11 session +instead of creating a new X11 session. +It was originally based on x0rfbserver +(ttp://www.hexonet.de/software/x0rfbserver/), but there is not much code of +x0rfbserver left. Since version 0.6 it uses libvncserver +(http://libvncserver.sf.net) as backend. For the latest information about KRfb visit http://www.tjansen.de/krfb Guide to documentation: -README_KDE3 - docs for using it under KDE3 ROADMAP - KRfb roadmap, progress and future features TODO - unscheduled things to be done NOTES - reasons for various decisions +DCOP-INTERFACE - short documentation of the DCOP interface ChangeLog - more detailed changes with dates diff --git a/ROADMAP b/ROADMAP index 7b1fe6a..6065c60 100644 --- a/ROADMAP +++ b/ROADMAP @@ -2,19 +2,19 @@ Version 0.5 (2002/01/02): First release - first release - port x0rfbserver with simplified KDE/Qt interface - -Version 0.6 (2002/02/20): Improve RFB backend +Version 0.6 (2002/02/17): Improved RFB backend - replace x0rfbserver's backend with libvncserver -<- knotify +- knotify -Version 0.7 (2002/??/??): Better integration with KDE, more end-user friendly +Version 0.7: Better integration with KDE, improved GUI - i18n -- kded module 'kinetd' to listening on the Rfb port that then starts KRfb -- kcontrol module to configure the kded thing +- kded module 'kinetd' that listens on the Rfb port and starts KRfb +- kcontrol module - on startup a dialog appears that allows the user to invite somebody using email (and later other mechanisms). Dialog can be turned off forever, of course +- remove STDOUT/STDERR logging -Version 0.8 (2002/??/??): +Version 0.8: - docs diff --git a/TODO b/TODO index 51f90aa..aa9e628 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,4 @@ Todo: -- big endian support (testers needed) -- write screen recording app using the lib - SLP support (or UPnP, or whatever KDE will use) - look into adding extension to xfree to improve speed (get noticed of screen updates) diff --git a/kinetd/kinetd.cpp b/kinetd/kinetd.cpp new file mode 100644 index 0000000..02aa2b0 --- /dev/null +++ b/kinetd/kinetd.cpp @@ -0,0 +1,61 @@ + +/*************************************************************************** + kinetd.cpp + -------------- + begin : Mon Feb 11 2002 + copyright : (C) 2002 by Tim Jansen + email : tim@tjansen.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include "kinetd.h" +#include +#include + +PortListener::PortListener(KService::Ptr s) { + +} + + +class KInetD : public KDEDModule { + KInetD::KInetD(QCString &n) : + KDEDModule(n) + { + portListeners.setAutoDelete(true); + loadServiceList(); + } + + void KInetD::loadServiceList() + { + portListeners.clear(); + + KService::List kinetdModules = + KServiceType::offers("KInetDModule"); + for(KService::List::ConstIterator it = kinetdModules.begin(); + it != kinetdModules.end(); + it++) { + KService::Ptr s = *it; + portListeners.append(new PortListener(s)); + } + + } +} + + + + +extern "C" { + KDEDModule *create_kinetd(QCString *name) + { + return new KInetD(name); + } +} + diff --git a/kinetd/kinetd.desktop b/kinetd/kinetd.desktop new file mode 100644 index 0000000..3356ccc --- /dev/null +++ b/kinetd/kinetd.desktop @@ -0,0 +1,13 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=Service + +ServiceTypes=KDEDModule +X-KDE-ModuleType=Library +X-KDE-Library=kinetd +X-KDE-FactoryName=kinetd +X-KDE-Kded-autoload=true +X-KDE-Kded-load-on-demand=false + +Name=KDE Print Deamon +Comment=A Print Daemon for KDE diff --git a/kinetd/kinetd.h b/kinetd/kinetd.h new file mode 100644 index 0000000..59103cb --- /dev/null +++ b/kinetd/kinetd.h @@ -0,0 +1,44 @@ + +/*************************************************************************** + kinetd.h + ------------ + begin : Mon Feb 11 2002 + copyright : (C) 2002 by Tim Jansen + email : tim@tjansen.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef _KINETD_H_ +#define _KINETD_H_ + +#include +#include "portlistener.h" + + +class KInetD : public KDEDModule { + Q_OBJECT + K_DCOP + private: + QPtrList portListeners; + + public: + KInetD(QCString &n); + loadServiceList(); + + + + k_dcop: + void reloadPortListenerList(); + PortListener *findPortListener(QString name); +} + + +#endif diff --git a/kinetd/portlistener.h b/kinetd/portlistener.h new file mode 100644 index 0000000..ffaac66 --- /dev/null +++ b/kinetd/portlistener.h @@ -0,0 +1,44 @@ + +/*************************************************************************** + kinetd.h + ------------ + begin : Mon Feb 11 2002 + copyright : (C) 2002 by Tim Jansen + email : tim@tjansen.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef _KINETD_H_ +#define _KINETD_H_ + +#include + +class PortListener : public DCOPObject { + K_DCOP +private: + QString serviceName; + int port; + QCString execPath; + + public: + PortListener(KService::Ptr s); + + + + + + k_dcop: + + +} + + +#endif diff --git a/krfb/Makefile.am b/krfb/Makefile.am index adc7089..af8c9b0 100644 --- a/krfb/Makefile.am +++ b/krfb/Makefile.am @@ -9,11 +9,13 @@ krfb_LDADD = ../libvncserver/libvncserver.a -lz -lpthread -ljpeg -lXtst \ EXTRA_DIST = $(krfb_SOURCES) krfb.desktop lo32-app-krfb.png \ lo16-app-krfb.png rfbcontroller.h eyes-closed24.png eyes-open24.png \ - XUpdateScanner.h trayicon.h configuration.h krfbiface.h krfbiface.kidl + XUpdateScanner.h trayicon.h configuration.h krfbiface.h krfbiface.kidl \ + eventsrc install-data-local: $(mkinstalldirs) $(kde_appsdir)/Applications/ $(INSTALL_DATA) $(srcdir)/krfb.desktop $(kde_appsdir)/Applications/krfb.desktop + $(INSTALL_DATA) $(srcdir)/eventsrc $(kde_datadir)/krfb/eventsrc $(mkinstalldirs) $(kde_datadir)/krfb/pics $(INSTALL_DATA) $(srcdir)/eyes-closed24.png $(kde_datadir)/krfb/pics/eyes-closed24.png $(INSTALL_DATA) $(srcdir)/eyes-open24.png $(kde_datadir)/krfb/pics/eyes-open24.png @@ -21,6 +23,7 @@ install-data-local: uninstall-local: -rm -f $(kde_appsdir)/Applications/krfb.desktop + -rm -f $(kde_datadir)/krfb/eventsrc -rm -f $(kde_datadir)/krfb/pics/eyes-open24.png -rm -f $(kde_datadir)/krfb/pics/eyes-closed24.png diff --git a/krfb/configuration.cc b/krfb/configuration.cc index d9318cd..a260d40 100644 --- a/krfb/configuration.cc +++ b/krfb/configuration.cc @@ -36,10 +36,6 @@ Configuration::Configuration() : loadFromKConfig(); saveToDialog(); - portValidator = new QIntValidator(0, 65535, - confDlg.displayNumberInput); - confDlg.displayNumberInput->setValidator(portValidator); - connect(confDlg.okButton, SIGNAL(clicked()), SLOT(okPressed())); connect(confDlg.cancelButton, SIGNAL(clicked()), @@ -50,18 +46,13 @@ Configuration::Configuration() : } Configuration::Configuration(bool oneConnection, bool askOnConnect, - bool allowDesktopControl, QString password, - int port) : + bool allowDesktopControl, QString password) : preconfiguredFlag(true), askOnConnectFlag(askOnConnect), allowDesktopControlFlag(allowDesktopControl), oneConnectionFlag(oneConnection), passwordString(password) { - if ((port >= 5900) && (port < 6000)) - portNumber = port-5900; - else - portNumber = port; } @@ -76,7 +67,6 @@ void Configuration::loadFromKConfig() { allowDesktopControlFlag = config->readBoolEntry("allowDesktopControl", false); passwordString = config->readEntry("password", ""); - portNumber = config->readNumEntry("port", 0); } void Configuration::loadFromDialog() { @@ -87,11 +77,6 @@ void Configuration::loadFromDialog() { passwordString = newPassword; emit passwordChanged(); } - int p = confDlg.displayNumberInput->text().toInt(); - if (p != portNumber) { - portNumber = p; - emit portChanged(); - } } void Configuration::saveToKConfig() { @@ -101,14 +86,12 @@ void Configuration::saveToKConfig() { config->writeEntry("askOnConnect", askOnConnectFlag); config->writeEntry("allowDesktopControl", allowDesktopControlFlag); config->writeEntry("password", passwordString); - config->writeEntry("port", portNumber); } void Configuration::saveToDialog() { confDlg.askOnConnectCB->setChecked(askOnConnectFlag); confDlg.allowDesktopControlCB->setChecked(allowDesktopControlFlag); confDlg.passwordInput->setText(passwordString); - confDlg.displayNumberInput->setText(QString().setNum(portNumber)); } bool Configuration::preconfigured() const { @@ -131,10 +114,6 @@ QString Configuration::password() const { return passwordString; } -int Configuration::port() const { - return (portNumber < 100) ? (portNumber + 5900) : portNumber; -} - void Configuration::setOnceConnection(bool oneConnection) { oneConnectionFlag = oneConnection; @@ -164,19 +143,6 @@ void Configuration::setPassword(QString password) saveToDialog(); } -void Configuration::setPort(int port) -{ - int oldPort = portNumber; - if ((port >= 5900) && (port < 6000)) - portNumber = port-5900; - else - portNumber = port; - if (oldPort != portNumber) - emit portChanged(); - saveToKConfig(); - saveToDialog(); -} - void Configuration::showDialog() { confDlg.show(); } diff --git a/krfb/configuration.h b/krfb/configuration.h index 40e325f..a22c60a 100644 --- a/krfb/configuration.h +++ b/krfb/configuration.h @@ -42,7 +42,7 @@ class Configuration : public QObject { public: Configuration(); Configuration(bool oneConnection, bool askOnConnect, - bool allowDesktopControl, QString password, int port); + bool allowDesktopControl, QString password); ~Configuration(); bool preconfigured() const; @@ -50,16 +50,13 @@ public: bool askOnConnect() const; bool allowDesktopControl() const; QString password() const; - int port() const; void setOnceConnection(bool oneConnection); void setAskOnConnect(bool askOnConnect); void setAllowDesktopControl(bool allowDesktopControl); void setPassword(QString password); - void setPort(int port); signals: - void portChanged(); void passwordChanged(); public slots: @@ -79,7 +76,6 @@ private: bool allowDesktopControlFlag; bool oneConnectionFlag; QString passwordString; - int portNumber; private slots: void okPressed(); diff --git a/krfb/configurationdialog.ui b/krfb/configurationdialog.ui index 4afee8a..7df8991 100644 --- a/krfb/configurationdialog.ui +++ b/krfb/configurationdialog.ui @@ -1,357 +1,239 @@ - + ConfigurationDialog - - QDialog - - name + + ConfigurationDialog - - geometry + 0 0 - 321 - 257 + 360 + 236 - - sizePolicy + 0 0 + 0 + 0 - - caption + Desktop Sharing: Configuration - - icon + image0 - - margin + + unnamed + + 11 - - spacing + 6 - - QFrame - - name + + Frame7 - - sizePolicy + 5 0 + 0 + 0 - - frameShape + NoFrame - - frameShadow + Plain - - layoutMargin + - - margin + + unnamed + + 6 - - spacing + 6 - - QCheckBox - - name + + askOnConnectCB - - text + Confirm connection &before accepting - - whatsThis + If this option is enabled you will be asked whenever a remote user tries to connect to your display. This allows you to deny the request or to remove things that the remote user should not see before he connects. It is highly recommended to turn this on while you are working on this computer. If you do not enable this option your only hint that somebody is connected is the small icon in your panel showing an open eye. - - QCheckBox - - name + + allowDesktopControlCB - - text + Allow &remote client to control the desktop - - whatsThis + If you turn this option on the remote user can enter keystrokes and use your mouse pointer. This gives him full control over your computer, so be careful. When the option is disabled the remote user can only watch your screen. - - QFrame - - name - Frame5 - - - sizePolicy - - 5 - 0 - - - - frameShape - NoFrame - - - frameShadow - Plain - - - layoutMargin - - - - margin - 6 - - - spacing - 6 - - - QLabel - - name - TextLabel2 - - - sizePolicy - - 1 - 0 - - - - text - Display number: - - - - QLineEdit - - name - displayNumberInput - - - maxLength - 5 - - - toolTip - Display number - - - whatsThis - Enter the display number/port here. Unless you have more than one server running on the machine just enter 0. -Regular RFB/VNC port numbers are between 0 and 99. If you enter a higher number it will be used as TCP port. Note that ports below 1024 require root privileges. - - - - - - QFrame - - name + + Frame4 - - sizePolicy + 5 0 + 0 + 0 - - frameShape + NoFrame - - frameShadow + Plain - - layoutMargin + - - margin + + unnamed + + 6 - - spacing + 6 - - QLabel - - name + + TextLabel1 - - sizePolicy + 1 0 + 0 + 0 - - text + Password: - - QLineEdit - - name + + passwordInput - - maxLength + 9 - - echoMode + Password - - whatsThis + If you want to protect your system with a password enter one here. It is highly recommended that you either do this or enable "ask before remote client connects". - - QFrame - - name + + Frame6 - - sizePolicy + 5 0 + 0 + 0 - - frameShape + NoFrame - - frameShadow + Plain - - layoutMargin + - - layoutSpacing + - - margin + + unnamed + + 4 - - spacing + 6 - - QPushButton - - name + + applyButton - - text + &Apply - - whatsThis + Click this to apply the changes immediately. - - name + Spacer2 - - orientation + Horizontal - - sizeType + Expanding - - sizeHint + 20 20 - - QPushButton - - name + + okButton - - text + &Ok - - default + true - - whatsThis + Apply changes and close window. - - QPushButton - - name + + cancelButton - - text + &Cancel - - whatsThis + Discard all changes and close window. @@ -360,9 +242,9 @@ Regular RFB/VNC port numbers are between 0 and 99. If you enter a higher number - - image0 + 789cad93db4ac4301086effb14a1b95b64b76b150a8b8fa0782988173393367b54d0f542c477377fd2405b7b5a7066cbe6231f49864c560bf5f478af16abe4e34ce79d28d9d2bb5a98cfd3e9ebf9e5ee3b49f36be57eeb1bb54eaf9274a9443dbcbd96186fdd58672e8a0c5845148f65c4aa02ee0216356a609e218106785b2081022cb2a25e99809421817b8f8591b0d40128d8c9cfb2c71c093c02ab2aceda80085fce44cc75f444788746e3126778a3863374de3e87eb1c7458c8b061599aa530f739cce21c32e23e12a87f1c16f642486858aaed10a662f83149c761c25cac387886db0e79a30c375d064fa8ed88336cad38c95a0babed38c3c2d9baa825aba5e344456b48deb1badfc149fec369eea53b0e249415ce5cee82d2bdaf66ed5ee9bd777794a0ecd17483fd132f63acc7e6f4e19833a3e78964f2ed1c8e42c70354d7af840f23ff7fc11b9cf1de876a8a91fe6c925fbe975961 + diff --git a/krfb/eventsrc b/krfb/eventsrc new file mode 100644 index 0000000..4b22d51 --- /dev/null +++ b/krfb/eventsrc @@ -0,0 +1,40 @@ +[!Global!] +IconName=krfb +Comment=Desktop Sharing + +[UserAcceptsConnection] +Name=UserAcceptsConnection +Comment=User accepts connection +default_presentation=4 + +[UserRefusesConnection] +Name=UserRefusesConnection +Comment=User refuses connection +default_presentation=4 + +[ConnectionClosed] +Name=ConnectionClosed +Comment=Connection closed +default_presentation=4 + +[InvalidPassword] +Name=InvalidPassword +Comment=Invalid Password +default_presentation=4 + +[NewConnectionOnHold] +Name=NewConnectionOnHold +Comment=Connection requested, user must accept +default_presentation=4 + +[NewConnectionAutoAccepted] +Name=NewConnectionAutoAccepted +Comment=New connection automatically established +default_presentation=4 + +[TooManyConnections] +Name=TooManyConnections +Comment=Busy, connection refused +default_presentation=4 +default_logfile= + diff --git a/krfb/krfbiface.h b/krfb/krfbiface.h index 76cbf62..2c7cb17 100644 --- a/krfb/krfbiface.h +++ b/krfb/krfbiface.h @@ -19,6 +19,5 @@ k_dcop: virtual void setAllowDesktopControl(bool) = 0; virtual void setPassword(QString) = 0; virtual int port() = 0; - virtual void setPort(int) = 0; }; #endif diff --git a/krfb/krfbifaceimpl.cc b/krfb/krfbifaceimpl.cc index c0eccb4..28ebf8c 100644 --- a/krfb/krfbifaceimpl.cc +++ b/krfb/krfbifaceimpl.cc @@ -11,7 +11,8 @@ KRfbIfaceImpl::KRfbIfaceImpl(Configuration *c) : DCOPObject("krfbIface"), - configuration(c) + configuration(c), + portNum(0) { } @@ -60,10 +61,16 @@ void KRfbIfaceImpl::setPassword(QString password) } int KRfbIfaceImpl::port() { - return configuration->port(); -} -void KRfbIfaceImpl::setPort(int port) -{ - configuration->setPort(port); + return portNum; } +/* + * Note that setPort() is not a DCOP function, but a slot that's + * connected to RFBController to get the autoprobed port. + */ +void KRfbIfaceImpl::setPort(int p) +{ + portNum = p; +} + + diff --git a/krfb/krfbifaceimpl.h b/krfb/krfbifaceimpl.h new file mode 100644 index 0000000..b73378d --- /dev/null +++ b/krfb/krfbifaceimpl.h @@ -0,0 +1,37 @@ +#ifndef __KRFB_IFACE_IMPL_H +#define __KRFB_IFACE_IMPL_H + +#include +#include "configuration.h" +#include "krfbiface.h" + +class KRfbIfaceImpl : public QObject, public virtual krfbIface +{ + Q_OBJECT +private: + Configuration *configuration; + int portNum; +public: + KRfbIfaceImpl(Configuration *c); +signals: + void connectionClosed(); + void exitApp(); + +public slots: + void setPort(int p); + +public: + void disconnect(); +// void setWindowID(int); + void exit(); + + bool oneConnection(); + void setOneConnection(bool); + bool askOnConnect(); + void setAskOnConnect(bool); + bool allowDesktopControl(); + void setAllowDesktopControl(bool); + void setPassword(QString); + int port(); +}; +#endif diff --git a/krfb/main.cpp b/krfb/main.cpp index ada9654..766ae07 100644 --- a/krfb/main.cpp +++ b/krfb/main.cpp @@ -39,7 +39,6 @@ static const char *description = I18N_NOOP("VNC-compatible server to share " "KDE desktops"); -#define ARG_PORT "port" #define ARG_ONE_SESSION "one-session" #define ARG_PASSWORD "password" #define ARG_DONT_CONFIRM_CONNECT "dont-confirm-connect" @@ -47,8 +46,6 @@ static const char *description = I18N_NOOP("VNC-compatible server to share " static KCmdLineOptions options[] = { - { "p", 0, 0}, - { ARG_PORT " ", I18N_NOOP("Set the port number the server is listening on."), "0"}, { "o", 0, 0}, { ARG_ONE_SESSION, I18N_NOOP("Terminate when the first session is finished."), 0}, { "w", 0, 0}, @@ -63,7 +60,6 @@ static KCmdLineOptions options[] = int main(int argc, char *argv[]) { - int r; KAboutData aboutData( "krfb", I18N_NOOP("Desktop Sharing"), VERSION, description, KAboutData::License_GPL, "(c) 2001-2002, Tim Jansen\n" @@ -99,8 +95,7 @@ int main(int argc, char *argv[]) Configuration *config; KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); - if (args->isSet(ARG_PORT) || - args->isSet(ARG_ONE_SESSION) || + if (args->isSet(ARG_ONE_SESSION) || args->isSet(ARG_PASSWORD) || args->isSet(ARG_REMOTE_CONTROL) || args->isSet(ARG_DONT_CONFIRM_CONNECT)) { @@ -109,9 +104,8 @@ int main(int argc, char *argv[]) bool askOnConnect = !args->isSet(ARG_DONT_CONFIRM_CONNECT); bool allowDesktopControl = args->isSet(ARG_REMOTE_CONTROL); QString password = args->getOption(ARG_PASSWORD); - int port = args->getOption(ARG_PORT).toInt(); config = new Configuration(oneConnection, askOnConnect, - allowDesktopControl, password, port); + allowDesktopControl, password); } else config = new Configuration(); @@ -140,13 +134,15 @@ int main(int argc, char *argv[]) QObject::connect(&dcopiface, SIGNAL(exitApp()), &app, SLOT(quit())); - QObject::connect(config, SIGNAL(portChanged()), - &controller, SLOT(rebind())); QObject::connect(config, SIGNAL(passwordChanged()), &controller, SLOT(passwordChanged())); + QObject::connect(&controller, SIGNAL(portProbed(int)), + &dcopiface, SLOT(setPort(int))); + QObject::connect(&controller, SIGNAL(sessionEstablished()), &trayicon, SLOT(openConnection())); + if (config->oneConnection()) { QObject::connect(&controller, SIGNAL(sessionRefused()), &app, SLOT(quit())); diff --git a/krfb/rfbcontroller.cc b/krfb/rfbcontroller.cc index dd552a3..effd01b 100644 --- a/krfb/rfbcontroller.cc +++ b/krfb/rfbcontroller.cc @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -311,8 +312,7 @@ void RFBController::startServer(bool xtestGrab) } server->frameBuffer = fb; - server->rfbPort = configuration->port(); - //server->udpPort = configuration->port(); + server->autoPort = TRUE; server->kbdAddEvent = keyboardHook; server->ptrAddEvent = pointerHook; @@ -330,6 +330,8 @@ void RFBController::startServer(bool xtestGrab) rfbInitServer(server); state = RFB_WAITING; + emit portProbed(server->rfbPort); + if (xtestGrab) { disabler.disable = false; XTestGrabControl(qt_xdisplay(), true); @@ -374,7 +376,10 @@ void RFBController::connectionAccepted(bool aRC) void RFBController::acceptConnection(bool aRC) { -// todo: knotify + KNotifyClient::event("UserAcceptsConnection", + i18n("Connecting system: %1") + .arg(remoteIp)); + if (state != RFB_CONNECTING) return; @@ -384,7 +389,10 @@ void RFBController::acceptConnection(bool aRC) void RFBController::refuseConnection() { -// todo: knotify + KNotifyClient::event("UserRefusesConnection", + i18n("Connecting system: %1") + .arg(remoteIp)); + if (state != RFB_CONNECTING) return; rfbRefuseOnHoldClient(server->rfbClientHead); @@ -411,7 +419,10 @@ bool RFBController::checkAsyncEvents() void RFBController::connectionClosed() { -// todo: knotify + KNotifyClient::event("ConnectionClosed", + i18n("Closed connection: %1.") + .arg(remoteIp)); + idleTimer.stop(); connectionNum--; state = RFB_WAITING; @@ -490,7 +501,14 @@ bool RFBController::handleCheckPassword(rfbClientPtr cl, vncEncryptBytes(cl->authChallenge, passwd); if (memcmp(cl->authChallenge, response, len) != 0) { - // TODO: knotify + QString host, port; + KExtendedSocket::resolve(KExtendedSocket::peerAddress(cl->sock), + host, port); + + KNotifyClient::event("InvalidPassword", + i18n("Connecting system: %1") + .arg(remoteIp)); + return FALSE; } return TRUE; @@ -500,22 +518,35 @@ enum rfbNewClientAction RFBController::handleNewClient(rfbClientPtr cl) { int socket = cl->sock; - if ((connectionNum > 0) || - (state != RFB_WAITING)) - return RFB_CLIENT_REFUSE; + QString host, port; + KExtendedSocket::resolve(KExtendedSocket::peerAddress(socket), + host, port); + if ((connectionNum > 0) || + (state != RFB_WAITING)) { + KNotifyClient::event("TooManyConnections", + i18n("Connecting system: %1") + .arg(host)); + return RFB_CLIENT_REFUSE; + } + + remoteIp = host; state = RFB_CONNECTING; if (!configuration->askOnConnect()) { + KNotifyClient::event("NewConnectionAutoAccepted", + i18n("Connecting system: %1") + .arg(remoteIp)); + connectionAccepted(configuration->allowDesktopControl()); return RFB_CLIENT_ACCEPT; } -// TODO: knotify - QString host, port; - KExtendedSocket::resolve(KExtendedSocket::peerAddress(socket), - host, port); - dialog.ipLabel->setText(host); + KNotifyClient::event("NewConnectionOnHold", + i18n("Connecting system: %1") + .arg(remoteIp)); + + dialog.ipLabel->setText(remoteIp); dialog.allowRemoteControlCB->setChecked(configuration->allowDesktopControl()); dialog.setFixedSize(dialog.sizeHint()); dialog.show(); @@ -552,6 +583,11 @@ void RFBController::passwordChanged() { ((configuration->password().length() == 0) ? 0 : 1); } +int RFBController::getPort() +{ + return server->rfbPort; +} + bool RFBController::checkX11Capabilities() { int bp1, bp2, majorv, minorv; Bool r = XTestQueryExtension(qt_xdisplay(), &bp1, &bp2, diff --git a/krfb/rfbcontroller.h b/krfb/rfbcontroller.h index b1fadb4..50f0874 100644 --- a/krfb/rfbcontroller.h +++ b/krfb/rfbcontroller.h @@ -120,6 +120,7 @@ public: void handlePointerEvent(int button_mask, int x, int y); enum rfbNewClientAction handleNewClient(rfbClientPtr cl); void handleClientGone(); + int getPort(); static bool checkX11Capabilities(); @@ -132,6 +133,7 @@ signals: void sessionEstablished(); void sessionFinished(); void sessionRefused(); + void portProbed(int); private: void startServer(bool xtestGrab = true); @@ -140,6 +142,7 @@ private: bool allowRemoteControl; int connectionNum; + QString remoteIp; QTimer idleTimer; Configuration *configuration; diff --git a/libvncserver/TODO.krfb b/libvncserver/TODO.krfb new file mode 100644 index 0000000..9a3a36a --- /dev/null +++ b/libvncserver/TODO.krfb @@ -0,0 +1,2 @@ +- fix 24 bit encodings +- replace stderr/stdout logs \ No newline at end of file