1
0
mirror of https://github.com/KDE/krfb synced 2026-07-01 07:41:17 -07:00

sync for KDE cvs

svn path=/trunk/kdenetwork/krfb/; revision=146490
This commit is contained in:
Tim Jansen
2002-04-01 21:55:18 +00:00
parent ef7fdad0a0
commit e41e38f8e7
20 changed files with 759 additions and 351 deletions

View File

@@ -1,3 +1,8 @@
2002-04-01 Tim Jansen <tjansen@tjansen.de>
* Did too much stuff to keep everything here.. After the 0.7 release
I try to keep this ChangeLog more complete...
2002-03-29 Tim Jansen <tjansen@tjansen.de>
* Added invitations.

176
INSTALL
View File

@@ -1,167 +1,15 @@
Basic Installation
==================
Installation
============
These are generic installation instructions.
To compile, do the usual
./configure
make
# get superuser permissions, for example using su
make install
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, a file
`config.cache' that saves the results of its tests to speed up
reconfiguring, and a file `config.log' containing compiler output
(useful mainly for debugging `configure').
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If at some point `config.cache'
contains results you don't want to keep, you may remove or edit it.
The file `configure.in' is used to create `configure' by a program
called `autoconf'. You only need `configure.in' if you want to change
it or regenerate `configure' using a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes a while. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Type `make install' to install the programs and any data files and
documentation.
4. You can remove the program binaries and object files from the
source code directory by typing `make clean'.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. You can give `configure'
initial values for variables by setting them in the environment. Using
a Bourne-compatible shell, you can do that on the command line like
this:
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
Or on systems that have the `env' program, you can do it like this:
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not supports the `VPATH'
variable, you have to compile the package for one architecture at a time
in the source code directory. After you have installed the package for
one architecture, use `make distclean' before reconfiguring for another
architecture.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' can not figure out
automatically, but needs to determine by the type of host the package
will run on. Usually `configure' can figure that out, but if it prints
a message saying it can not guess the host type, give it the
`--host=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name with three fields:
CPU-COMPANY-SYSTEM
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the host type.
If you are building compiler tools for cross-compiling, you can also
use the `--target=TYPE' option to select the type of system they will
produce code for and the `--build=TYPE' option to select the type of
system on which you are compiling the package.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Operation Controls
==================
`configure' recognizes the following options to control how it
operates.
`--cache-file=FILE'
Use and save the results of the tests in FILE instead of
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
debugging `configure'.
`--help'
Print a summary of the options to `configure', and exit.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made.
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`--version'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`configure' also accepts some other, not widely useful, options.
This assumes that you already have KDE 3.0 running of course.
IMPORTANT
---------
After installing KRfb you must restart KDE in order to load the
kded module.

34
NOTES
View File

@@ -1,28 +1,30 @@
Comments on various aspects of KRfb:
- KRfb has been designed for three use cases:
* a user who needs help from an administrator or friend. The adminstrator can
connect to the user and change settings and so on while both are talking
on the telephone or using VoIP.
* a user who wants to show something to a friend, so he lets his friend
connect to his computer
* a user who needs help from an administrator. The adminstrator can connect
to the user and change settings and so on while both are talking
on the telephone or using VoIP.
* (advanced use case) somebody with several computers that are running
GUIs want to control them without going to them.
* (advanced use case) somebody with several computers that are running
GUIs want to control them.
- cases 1&2 are probably more mainstream and more important for novice users,
so KRfb is pre-configured for them. Case 3 is for advanced users and
so KRfb is pre-configured for them. Case 3 is for advanced users and
therefore a little bit more difficult to configure.
- by offering the connection-confirmation dialog KRfb avoids configuration
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 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.
limit functionality whereever possible.
- 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 RFBController class is a mess. The interactions between the threaded,
callback-using libvncserver and the event-driven, single thread qt GUI is
quite complicated and I can only hope that it works.
- most limitations and problems of KRfb are caused either by limitations of
Rfb (for example no proper authentication of users, no encryption) or
by lack of a framework in KDE or Linux in general (no discovery of running
KRfb servers, no way to connect through a NAT device). In the months I am going
to concentrate on improving the latter.
Do the following files when releasing a new version:
Change the following files when releasing a new version:
- configure.in.in: change the AM_INIT_AUTOMAKE macro
- krfb/main.cpp: change the VERSION macro
- kcm_krfb/kcm_krfb.cpp: change the VERSION macro

2
README
View File

@@ -13,10 +13,10 @@ For the latest information about KRfb visit http://www.tjansen.de/krfb
Guide to documentation:
INSTALL - Very short installation instructions
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
MODES_SECURITY - modes & security settings
ChangeLog - more detailed changes with dates

13
ROADMAP
View File

@@ -7,18 +7,13 @@ Version 0.6 (2002/02/18): Improved RFB backend
- dcop support
- knotify
Version 0.7 (2002/3/31): Better integration with KDE, improved GUI
Version 0.7 (2002/4/1): Better integration with KDE, improved GUI, invitations
- kded module 'kinetd' that listens on the Rfb port and starts KRfb
-> remove debug msgs, replace with knotify
-> better error handling
-> invitation support
- invitation support
- 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 from libvncserver
Version 0.8:
Future versions
- getting rid of stand-alone mode?
- i18n
- docs

View File

@@ -74,9 +74,9 @@ void KcmKRfb::configChanged() {
emit changed(true);
}
void KcmKRfb::checkKInetd(bool &available, bool &enabled) {
available = false;
enabled = false;
void KcmKRfb::checkKInetd(bool &kinetdAvailable, bool &krfbAvailable) {
kinetdAvailable = false;
krfbAvailable = false;
DCOPClient *d = KApplication::dcopClient();
@@ -84,15 +84,15 @@ void KcmKRfb::checkKInetd(bool &available, bool &enabled) {
QCString replyType;
QDataStream arg(sdata, IO_WriteOnly);
arg << QString("krfb");
if (!d->call ("kded", "kinetd", "isEnabled(QString)", sdata, replyType, rdata))
if (!d->call ("kded", "kinetd", "isInstalled(QString)", sdata, replyType, rdata))
return;
if (replyType != "bool")
return;
QDataStream answer(rdata, IO_ReadOnly);
answer >> enabled;
available = true;
answer >> krfbAvailable;
kinetdAvailable = true;
}
void KcmKRfb::setKInetd(bool enabled) {
@@ -108,22 +108,34 @@ void KcmKRfb::setKInetd(bool enabled) {
}
}
void KcmKRfb::setKInetd(const QDateTime &date) {
DCOPClient *d = KApplication::dcopClient();
QByteArray sdata;
QDataStream arg(sdata, IO_WriteOnly);
arg << QString("krfb");
arg << date;
if (!d->send ("kded", "kinetd", "setEnabled(QString,QDateTime)", sdata)) {
confWidget.runInBackgroundRB->setEnabled(false);
confWidget.runOnDemandRB->setChecked(true);
}
}
void KcmKRfb::load() {
bool kinetdAvailable, kinetdEnabled;
checkKInetd(kinetdAvailable, kinetdEnabled);
bool kinetdAvailable, krfbAvailable;
checkKInetd(kinetdAvailable, krfbAvailable);
if (!kinetdAvailable) {
KConfig c("krfbrc");
if (!krfbAvailable) {
confWidget.runInBackgroundRB->setEnabled(false);
confWidget.runOnDemandRB->setChecked(true);
}
else {
confWidget.runInBackgroundRB->setEnabled(true);
confWidget.runInBackgroundRB->setChecked(kinetdEnabled);
confWidget.runOnDemandRB->setChecked(!kinetdEnabled);
bool daemonMode = c.readBoolEntry("daemonMode", true);
confWidget.runInBackgroundRB->setChecked(daemonMode);
confWidget.runOnDemandRB->setChecked(!daemonMode);
}
KConfig c("krfbrc");
confWidget.allowUninvitedCB->setChecked(c.readBoolEntry("allowUninvited", false));
confWidget.confirmConnectionsCB->setChecked(c.readBoolEntry("confirmUninvitedConnection", false));
confWidget.allowDesktopControlCB->setChecked(c.readBoolEntry("allowDesktopControl", false));
@@ -133,19 +145,43 @@ void KcmKRfb::load() {
void KcmKRfb::save() {
KConfig c("krfbrc");
setKInetd(!confWidget.runOnDemandRB->isChecked());
c.writeEntry("allowUninvited", confWidget.allowUninvitedCB->isChecked());
bool allowUninvited = confWidget.allowUninvitedCB->isChecked();
bool daemonMode = !confWidget.runOnDemandRB->isChecked();
c.writeEntry("daemonMode", daemonMode);
c.writeEntry("allowUninvited", allowUninvited);
c.writeEntry("confirmUninvitedConnection", confWidget.confirmConnectionsCB->isChecked());
c.writeEntry("allowDesktopControl", confWidget.allowDesktopControlCB->isChecked());
c.writeEntry("uninvitedPassword", confWidget.passwordInput->text());
if (!daemonMode)
return;
if (allowUninvited) {
setKInetd(true);
return;
}
c.setGroup("invitations");
int num = c.readNumEntry("invitation_num", 0);
QDateTime lastExpiration;
for (int i = 0; i < num; i++) {
QDateTime e = c.readDateTimeEntry(QString("expiration%1").arg(i));
if ((e.isNull()) || (e < QDateTime::currentDateTime()))
continue;
if (e > lastExpiration)
lastExpiration = e;
}
if (lastExpiration.isNull())
setKInetd(false);
else
setKInetd(lastExpiration);
}
void KcmKRfb::defaults() {
bool kinetdAvailable, kinetdEnabled;
checkKInetd(kinetdAvailable, kinetdEnabled);
bool kinetdAvailable, krfbAvailable;
checkKInetd(kinetdAvailable, krfbAvailable);
if (!kinetdAvailable) {
if (!krfbAvailable) {
confWidget.runInBackgroundRB->setEnabled(false);
confWidget.runOnDemandRB->setChecked(true);
}

View File

@@ -20,6 +20,7 @@
#define _KCM_KRFB_H_
#include <qobject.h>
#include <qdatetime.h>
#include <kcmodule.h>
#include "configurationwidget.h"
@@ -28,8 +29,9 @@ class KcmKRfb : public KCModule {
private:
ConfigurationWidget confWidget;
KAboutData *about;
void checkKInetd(bool &available, bool &enabled);
void checkKInetd(bool&, bool&);
void setKInetd(bool enabled);
void setKInetd(const QDateTime &d);
public:
KcmKRfb(QWidget *p, const char *name, const QStringList &);
~KcmKRfb();

View File

@@ -14,10 +14,15 @@ kded_DATA = kinetd.desktop
EXTRA_DIST = $(libkded_kinetd_la_SOURCES)\
$(kded_DATA) \
$(kde_servicetypes_DATA)
$(kde_servicetypes_DATA) \
eventsrc
KDE_ICON = kinetd
install-data-local:
$(mkinstalldirs) $(kde_datadir)/kinetd
$(INSTALL_DATA) $(srcdir)/eventsrc $(kde_datadir)/kinetd/eventsrc
# set the include path for X, qt and KDE
INCLUDES= $(all_includes)

13
kinetd/eventsrc Normal file
View File

@@ -0,0 +1,13 @@
[!Global!]
IconName=kinetd
Comment=KInetD
[IncomingConnection]
Name=IncomingConnection
Comment=Got incoming connection
default_presentation=4
[ProcessFailed]
Name=ProcessFailed
Comment=Could not call process to handle connection
default_presentation=4

View File

@@ -16,36 +16,43 @@
* *
***************************************************************************/
/*
* TODOs:
* - get notified of changes in services
* - replace debug messages with knotify
*/
#include "kinetd.h"
#include <kservicetype.h>
#include <kdebug.h>
#include <kstandarddirs.h>
#include <kconfig.h>
#include <knotifyclient.h>
#include <ksockaddr.h>
#include <kextsock.h>
#include <klocale.h>
PortListener::PortListener(KService::Ptr s)
{
loadConfig(s);
port = portBase;
socket = new KServerSocket(port, false);
if (enabled)
acquirePort();
else
portNum = -1;
}
void PortListener::acquirePort() {
portNum = portBase;
socket = new KServerSocket(portNum, false);
while (!socket->bindAndListen()) {
port++;
if (port >= (portBase+autoPortRange)) {
portNum++;
if (portNum >= (portBase+autoPortRange)) {
kdDebug() << "Kinetd cannot load service "<<serviceName
<<": unable to get port" << endl;
valid = false;
portNum = -1;
enabled = false;
delete socket;
socket = 0;
return;
}
delete socket;
socket = new KServerSocket(port, false);
socket = new KServerSocket(portNum, false);
}
connect(socket, SIGNAL(accepted(KSocket*)),
SLOT(accepted(KSocket*)));
}
@@ -95,10 +102,19 @@ void PortListener::loadConfig(KService::Ptr s) {
config = new KConfig("kinetdrc");
config->setGroup("ListenerConfig");
enabled = config->readBoolEntry("enabled_" + serviceName, enabled);
QDateTime nullTime;
expirationTime = config->readDateTimeEntry("enabled_expiration_"+serviceName, &nullTime);
if ((!expirationTime.isNull()) && (expirationTime < QDateTime::currentDateTime()))
enabled = false;
}
void PortListener::accepted(KSocket *sock) {
kdDebug() << "got connection" << endl;
QString host, port;
KSocketAddress *ksa = KExtendedSocket::peerAddress(sock->socket());
KExtendedSocket::resolve(ksa, host, port);
KNotifyClient::event("IncomingConnection",
i18n("connection from %1").arg(host));
delete ksa;
if ((!enabled) ||
((!multiInstance) && process.isRunning())) {
@@ -109,12 +125,11 @@ void PortListener::accepted(KSocket *sock) {
process.clearArguments();
process << execPath << argument << QString::number(sock->socket());
if (!process.start(KProcess::DontCare)) {
kdDebug() << "kinetd: Process \"" << execPath << " " <<
argument << " "<< sock->socket() <<
"\" call failed" << endl;
KNotifyClient::event("ProcessFailed",
i18n("Call \"%1 %2 %3\" failed").arg(execPath)
.arg(argument)
.arg(sock->socket()));
}
else
kdDebug() << "kinetd: Calling process, ok" << endl;
delete sock;
}
@@ -127,17 +142,49 @@ bool PortListener::isEnabled() {
return enabled;
}
int PortListener::port() {
return portNum;
}
void PortListener::setEnabled(bool e) {
if (e == enabled)
return;
setEnabledInternal(e, QDateTime());
}
void PortListener::setEnabledInternal(bool e, const QDateTime &ex) {
expirationTime = ex;
if (e) {
if (portNum < 0)
acquirePort();
if (portNum < 0)
return;
}
else {
portNum = -1;
delete socket;
socket = 0;
}
enabled = e;
if (!config)
return;
config->setGroup("ListenerConfig");
config->writeEntry("enabled_" + serviceName, enabled);
config->writeEntry("enabled_expiration_"+serviceName, ex);
config->sync();
}
void PortListener::setEnabled(const QDateTime &ex) {
setEnabledInternal(true, ex);
}
QDateTime PortListener::expiration() {
return expirationTime;
}
QString PortListener::name() {
return serviceName;
}
@@ -154,6 +201,7 @@ KInetD::KInetD(QCString &n) :
KDEDModule(n)
{
portListeners.setAutoDelete(true);
connect(&expirationTimer, SIGNAL(timeout()), SLOT(setTimer()));
loadServiceList();
}
@@ -171,6 +219,17 @@ void KInetD::loadServiceList()
if (pl->isValid())
portListeners.append(pl);
}
setTimer();
}
void KInetD::setTimer() {
QDateTime nextEx = getNextExpirationTime(); // disables expired portlistener!
if (!nextEx.isNull())
expirationTimer.start(QDateTime::currentDateTime().secsTo(nextEx)*1000 + 30000,
false);
else
expirationTimer.stop();
}
PortListener *KInetD::getListenerByName(QString name)
@@ -184,6 +243,24 @@ PortListener *KInetD::getListenerByName(QString name)
return pl;
}
// gets next expiration timer, SIDEEFFECT: disables expired portlisteners while doing this
QDateTime KInetD::getNextExpirationTime()
{
PortListener *pl = portListeners.first();
QDateTime d;
while (pl) {
QDateTime d2 = pl->expiration();
if (!d2.isNull()) {
if (d2 < QDateTime::currentDateTime())
pl->setEnabled(false);
else if (d.isNull() || (d2 < d))
d = d2;
}
pl = portListeners.next();
}
return d;
}
QStringList KInetD::services()
{
QStringList list;
@@ -204,6 +281,21 @@ bool KInetD::isEnabled(QString service)
return pl->isEnabled();
}
int KInetD::port(QString service)
{
PortListener *pl = getListenerByName(service);
if (!pl)
return -1;
return pl->port();
}
bool KInetD::isInstalled(QString service)
{
PortListener *pl = getListenerByName(service);
return (pl != 0);
}
void KInetD::setEnabled(QString service, bool enable)
{
PortListener *pl = getListenerByName(service);
@@ -211,6 +303,17 @@ void KInetD::setEnabled(QString service, bool enable)
return;
pl->setEnabled(enable);
setTimer();
}
void KInetD::setEnabled(QString service, QDateTime expiration)
{
PortListener *pl = getListenerByName(service);
if (!pl)
return;
pl->setEnabled(expiration);
setTimer();
}

View File

@@ -25,17 +25,20 @@
#include <kprocess.h>
#include <qstringlist.h>
#include <qstring.h>
#include <qdatetime.h>
#include <qtimer.h>
class PortListener : public QObject {
Q_OBJECT
private:
bool valid;
QString serviceName;
int port, portBase, autoPortRange;
int portNum, portBase, autoPortRange;
bool multiInstance;
QCString execPath;
QString argument;
bool enabled;
QDateTime expirationTime;
KServerSocket *socket;
KProcess process;
@@ -43,6 +46,8 @@ private:
KConfig *config;
void loadConfig(KService::Ptr s);
void acquirePort();
void setEnabledInternal(bool e, const QDateTime &ex);
public:
PortListener(KService::Ptr s);
~PortListener();
@@ -50,7 +55,10 @@ public:
bool isValid();
QString name();
void setEnabled(bool enabled);
void setEnabled(const QDateTime &expiration);
QDateTime expiration();
bool isEnabled();
int port();
private slots:
void accepted(KSocket*);
@@ -85,8 +93,37 @@ k_dcop:
*/
void setEnabled(QString service, bool enable);
/**
* Enables the given service until the given time. Ignored if the given
* service does not exist.
* @param service name of a service as specified in its .desktop file
* @param expiration the time the service will be disabled at
*/
void setEnabled(QString service, QDateTime expiration);
/**
* Returns the port of the service, or -1 if not listening.
* @param service name of a service as specified in its .desktop file
* @return the port or -1 if no port used or service does not exist
*/
int port(QString service);
/**
* Tests whether the given service is installed..
* @param service name of a service as specified in its .desktop file
* @return true if installed, false otherwise
*/
bool isInstalled(QString service);
private:
QDateTime getNextExpirationTime();
QPtrList<PortListener> portListeners;
QTimer expirationTimer;
private slots:
void setTimer();
public:
KInetD(QCString &n);

View File

@@ -2,15 +2,15 @@ Begin3
Title: KDE Desktop Sharing (KRfb)
Version: 0.7
Entered-date:
Description: KRfb is a RFB (VNC) server that allows sharing a local
X11 session.
Keywords:
Author: Tim Jansen <tim@tjansen.de>
Maintained-by: Tim Jansen <tim@tjansen.de>
Primary-site: http://www.tjansen.de/krfb
Description: KRfb is a RFB (VNC) server for KDE that allows sharing a local
X11 session.
Keywords:
Author: Tim Jansen <tim@tjansen.de>
Maintained-by: Tim Jansen <tim@tjansen.de>
Primary-site: http://www.tjansen.de/krfb
Home-page: http://www.tjansen.de/krfb
Original-site: http://www.tjansen.de/krfb
Platforms: Linux and other Unices
KDE 2.2 or higher
KDE 3.0 or higher
Copying-policy: GPL
End

View File

@@ -4,7 +4,7 @@ bin_PROGRAMS = krfb
krfb_SOURCES = rfbcontroller.cc configuration.cc trayicon.cpp \
xupdatescanner.cc main.cpp configurationdialog.ui newconnectiondialog.ui \
krfbifaceimpl.cc krfbiface.skel manageinvitations.ui personalinvitation.ui \
invite.ui invitation.cc
invite.ui invitation.cc configuration_hostname.cpp
krfb_LDADD = ../libvncserver/libvncserver.a -lz -lpthread -ljpeg -lXtst \
$(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI) $(LIBSOCKET)

View File

@@ -18,7 +18,12 @@
#include "configuration.h"
#include <kglobal.h>
#include <klocale.h>
#include <kapplication.h>
#include <kprocess.h>
#include <qdatastream.h>
#include <dcopclient.h>
#include <qlabel.h>
#include <qpushbutton.h>
@@ -34,16 +39,14 @@ void InvitationDialog2::closeEvent(QCloseEvent *)
void PersonalInvitationDialog2::closeEvent(QCloseEvent *)
{ emit closed(); }
// TODO:
// get host address
// email inv
Configuration::Configuration(krfb_mode mode) :
m_mode(mode),
oneConnectionFlag(false)
oneConnectionFlag(false),
portNum(-1)
{
loadFromKConfig();
saveToDialogs();
doKinetdConf();
connect(confDlg.okButton, SIGNAL(clicked()), SLOT(configOkPressed()));
connect(confDlg.cancelButton, SIGNAL(clicked()), SLOT(configCancelPressed()));
@@ -80,6 +83,7 @@ Configuration::Configuration(krfb_mode mode) :
connect(&expirationTimer, SIGNAL(timeout()), SLOT(invalidateOldInvitations()));
expirationTimer.start(1000*60);
}
}
Configuration::Configuration(bool oneConnection, bool askOnConnect,
@@ -88,6 +92,7 @@ Configuration::Configuration(bool oneConnection, bool askOnConnect,
askOnConnectFlag(askOnConnect),
allowDesktopControlFlag(allowDesktopControl),
oneConnectionFlag(oneConnection),
portNum(-1),
passwordString(password)
{
}
@@ -95,10 +100,88 @@ Configuration::Configuration(bool oneConnection, bool askOnConnect,
Configuration::~Configuration() {
}
// special static method to determine daemon mode before constructor was invoked
bool Configuration::earlyDaemonMode() {
KConfig c("krfbrc");
return c.readBoolEntry("daemonMode", true);
}
void Configuration::setKInetd(bool enabled) {
DCOPClient *d = KApplication::dcopClient();
QByteArray sdata;
QDataStream arg(sdata, IO_WriteOnly);
arg << QString("krfb");
arg << enabled;
d->send ("kded", "kinetd", "setEnabled(QString,bool)", sdata);
}
void Configuration::setKInetd(const QDateTime &date) {
DCOPClient *d = KApplication::dcopClient();
QByteArray sdata;
QDataStream arg(sdata, IO_WriteOnly);
arg << QString("krfb");
arg << date;
d->send ("kded", "kinetd", "setEnabled(QString,QDateTime)", sdata);
}
void Configuration::setPortKInetd() {
DCOPClient *d = KApplication::dcopClient();
QByteArray sdata, rdata;
QCString replyType;
QDataStream arg(sdata, IO_WriteOnly);
arg << QString("krfb");
if (!d->call ("kded", "kinetd", "port(QString)", sdata, replyType, rdata))
return; // nicer error here
if (replyType != "int")
return; // nicer error here
QDataStream answer(rdata, IO_ReadOnly);
answer >> portNum;
}
void Configuration::removeInvitation(QValueList<Invitation>::iterator it) {
invitationList.remove(it);
doKinetdConf();
}
void Configuration::doKinetdConf() {
if (!daemonFlag)
return;
if (allowUninvitedFlag) {
setKInetd(true);
setPortKInetd();
return;
}
QDateTime lastExpiration;
QValueList<Invitation>::iterator it = invitationList.begin();
while (it != invitationList.end()) {
Invitation &ix = (*it);
QDateTime t = ix.expirationTime();
if (t > lastExpiration)
lastExpiration = t;
it++;
}
if (lastExpiration.isNull() || (lastExpiration < QDateTime::currentDateTime())) {
setKInetd(false);
portNum = -1;
}
else {
setKInetd(lastExpiration);
setPortKInetd();
}
}
void Configuration::loadFromKConfig() {
if (KRFB_STAND_ALONE_CMDARG == mode())
return;
KConfig c("krfbrc");
daemonFlag = c.readBoolEntry("daemonMode", true);
allowUninvitedFlag = c.readBoolEntry("allowUninvited", true);
askOnConnectFlag = c.readBoolEntry("confirmUninvitedConnection", true);
allowDesktopControlFlag = c.readBoolEntry("allowDesktopControl", false);
@@ -113,20 +196,25 @@ void Configuration::loadFromKConfig() {
confDlg.applyButton->setEnabled(false);
invalidateOldInvitations();
}
void Configuration::loadFromDialogs() {
bool oldAllowUninvitedFlag = allowUninvitedFlag;
allowUninvitedFlag = confDlg.allowUninvitedCB->isChecked();
askOnConnectFlag = confDlg.askOnConnectCB->isChecked();
allowDesktopControlFlag = confDlg.allowDesktopControlCB->isChecked();
showInvDlgOnStartupFlag = invDlg.dontShowOnStartupButton->isChecked();
showInvDlgOnStartupFlag = !invDlg.dontShowOnStartupButton->isChecked();
QString newPassword = confDlg.passwordInput->text();
if (passwordString != newPassword) {
passwordString = newPassword;
emit passwordChanged();
}
if (oldAllowUninvitedFlag != allowUninvitedFlag)
doKinetdConf();
}
void Configuration::saveToKConfig() {
@@ -134,6 +222,7 @@ void Configuration::saveToKConfig() {
return;
KConfig c("krfbrc");
c.writeEntry("daemonMode", daemonFlag);
c.writeEntry("confirmUninvitedConnection", askOnConnectFlag);
c.writeEntry("allowDesktopControl", allowDesktopControlFlag);
c.writeEntry("allowUninvited", allowUninvitedFlag);
@@ -156,7 +245,7 @@ void Configuration::saveToDialogs() {
confDlg.allowDesktopControlCB->setChecked(allowDesktopControlFlag);
confDlg.passwordInput->setText(passwordString);
invDlg.dontShowOnStartupButton->setChecked(showInvDlgOnStartupFlag);
invDlg.dontShowOnStartupButton->setChecked(!showInvDlgOnStartupFlag);
invalidateOldInvitations();
QValueList<Invitation>::iterator it = invitationList.begin();
@@ -216,10 +305,18 @@ bool Configuration::allowDesktopControl() const {
return allowDesktopControlFlag;
}
bool Configuration::allowUninvitedConnects() const {
return allowUninvitedFlag;
}
bool Configuration::showInvitationDialogOnStartup() const {
return showInvDlgOnStartupFlag;
}
bool Configuration::daemonMode() const {
return daemonFlag;
}
QString Configuration::password() const {
return passwordString;
}
@@ -257,10 +354,34 @@ void Configuration::setPassword(QString password)
saveToDialogs();
}
int Configuration::port() const
{
if ((portNum < 5900) || (portNum >= 6000))
return portNum;
else
return portNum - 5900;
}
void Configuration::setPort(int p) {
portNum = p;
}
// hostname is implemented in configuration_hostname.cpp
// QString Configuration::hostname()
////////////// config dialog //////////////////////////
void Configuration::showConfigDialog() {
confDlg.show();
if (m_mode == KRFB_KINETD_MODE) {
KProcess p;
p << "kcmshell" << "kcmkrfb";
p.start(KProcess::DontCare);
}
else {
loadFromKConfig();
saveToDialogs();
confDlg.show();
}
}
void Configuration::configOkPressed() {
@@ -292,25 +413,28 @@ void Configuration::showManageInvitationsDialog() {
void Configuration::invMngDlgClosed() {
invMngDlg.hide();
saveToKConfig();
}
void Configuration::invMngDlgDeleteOnePressed() {
QValueList<Invitation>::iterator it = invitationList.begin();
while (it != invitationList.end()) {
Invitation &ix = (*it);
KListViewItem *iv = ix.getViewItem();
if (iv && iv->isSelected())
it = invitationList.remove(it);
else
it++;
}
while (it != invitationList.end()) {
Invitation &ix = (*it);
KListViewItem *iv = ix.getViewItem();
if (iv && iv->isSelected())
it = invitationList.remove(it);
else
it++;
}
emit passwordChanged();
doKinetdConf();
}
void Configuration::invMngDlgDeleteAllPressed() {
invitationList.clear();
saveToKConfig();
emit passwordChanged();
doKinetdConf();
}
////////////// invitation dialog //////////////////////////
@@ -338,9 +462,14 @@ void Configuration::closeInvDlg() {
void Configuration::showPersonalInvitationDialog() {
closeInvDlg();
loadFromKConfig();
Invitation inv = createInvitation();
saveToDialogs();
saveToKConfig();
doKinetdConf();
invDlg.createInvitationButton->setEnabled(false);
persInvDlg.hostLabel->setText(QString("%1:%2").arg(hostname()).arg(port()));
persInvDlg.passwordLabel->setText(inv.password());
persInvDlg.expirationLabel->setText(
inv.expirationTime().toString(Qt::LocalDate));
@@ -357,9 +486,25 @@ void Configuration::persInvDlgClosed() {
void Configuration::inviteEmail() {
closeInvDlg();
loadFromKConfig();
Invitation inv = createInvitation();
saveToDialogs();
// TODO: start mail client
saveToKConfig();
doKinetdConf();
KApplication *app = KApplication::kApplication();
app->invokeMailer(QString::null, QString::null, QString::null,
i18n("Desktop Sharing (VNC) invitation"),
i18n("You have been invited to a VNC session. To connect start "
"a VNC client with the following parameters:\n\n"
"Host: %1:%2\n"
"Password: %3\n\n"
"For security reasons this invitation will expire on %4.")
.arg(hostname())
.arg(port())
.arg(inv.password())
.arg(inv.expirationTime().toString(Qt::LocalDate)));
emit invitationFinished();
}

View File

@@ -81,12 +81,18 @@ public:
bool allowDesktopControl, QString password);
~Configuration();
static bool earlyDaemonMode();
krfb_mode mode() const;
bool oneConnection() const;
bool askOnConnect() const;
bool allowDesktopControl() const;
bool allowUninvitedConnects() const;
bool showInvitationDialogOnStartup() const;
bool daemonMode() const;
QString password() const;
QString hostname() const;
int port() const;
void setOnceConnection(bool oneConnection);
void setAskOnConnect(bool askOnConnect);
@@ -95,6 +101,7 @@ public:
void reload();
QValueList<Invitation> &invitations();
void removeInvitation(QValueList<Invitation>::iterator it);
signals:
void passwordChanged();
void invitationFinished();
@@ -107,7 +114,7 @@ public slots:
void inviteEmail();
void invalidateOldInvitations();
void setPort(int);
private:
void loadFromKConfig();
void loadFromDialogs();
@@ -115,6 +122,10 @@ private:
void saveToDialogs();
Invitation createInvitation();
void closeInvDlg();
void setKInetd(const QDateTime &date);
void setKInetd(bool enabled);
void setPortKInetd();
void doKinetdConf();
krfb_mode m_mode;
@@ -128,8 +139,10 @@ private:
bool allowDesktopControlFlag;
bool allowUninvitedFlag;
bool oneConnectionFlag;
bool daemonFlag;
bool showInvDlgOnStartupFlag;
int portNum;
QString passwordString;
QValueList<Invitation> invitationList;
@@ -142,7 +155,7 @@ private slots:
void invMngDlgClosed();
void invMngDlgDeleteOnePressed();
void invMngDlgDeleteAllPressed();
void invDlgClosed();
void persInvDlgClosed();

View File

@@ -0,0 +1,143 @@
#include "configuration.h"
/*
* Most of this code has been taken from KPhone/libdissipate's SIPUtil class.
* Copyright (c) 2000 Billy Biggs <bbiggs@div8.net>
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/utsname.h>
#include <sys/socket.h>
#include <sys/time.h>
/* WirLab 29.1.2002 */
#include <sys/errno.h>
/* WirLab 31.1.2002 */
#include <features.h>
#include <net/if_arp.h>
#include <net/route.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <qmessagebox.h>
#include <qstring.h>
/*--*/
#include <netdb.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
static char *dissipate_our_fqdn = NULL;
/* max number of network interfaces*/
#define MAX_IF 5
/* Path to the route entry in proc filesystem */
#define PROCROUTE "/proc/net/route"
/* file containing the hostname of the machine */
/* This is the name for slackware and redhat */
#define HOSTFILE "/etc/HOSTNAME"
/* and this is the name for debian */
/* #define HOSTFILE "/etc/HOSTNAME" */
#ifndef SIOCGIFCOUNT
#define SIOCGIFCOUNT 0x8935
#endif
char iface[16];
/* This searches the proc routing entry for the interface the default gateway
 * is on, and returns the name of that interface.
 */
char *getdefaultdev()
{
FILE *fp = fopen( PROCROUTE, "r");
char buff[4096], gate_addr[128], net_addr[128];
char mask_addr[128];
int irtt, window, mss, num, metric, iflags, refcnt, use;
char i;
if( !fp ) {
return NULL;
}
i=0;
// cruise through the list, and find the gateway interface
while( fgets(buff, 1023, fp) ) {
num = sscanf(buff, "%s %s %s %X %d %d %d %s %d %d %d\n",
iface, net_addr, gate_addr, &iflags, &refcnt, &use, &metric,
&mask_addr, &mss, &window, &irtt);
i++;
if( i == 1) continue;
if( iflags & RTF_GATEWAY )
return iface;
}
fclose(fp);
/* didn't find a default gateway */
return NULL;
}
void findFqdn( void )
{
int sock, err, if_count, i, j = 0;
struct ifconf netconf;
char buffer[32*MAX_IF];
char if_name[10][21];
char if_addr[10][21];
char *default_ifName;
netconf.ifc_len = 32 * MAX_IF;
netconf.ifc_buf = buffer;
sock=socket( PF_INET, SOCK_DGRAM, 0 );
err=ioctl( sock, SIOCGIFCONF, &netconf );
if ( err < 0 ) printf( "Error in ioctl: %i.\n", errno );
close( sock );
if_count = netconf.ifc_len / 32;
for( i = 0; i < if_count; i++ ) {
if( strcmp( netconf.ifc_req[i].ifr_name, "lo" ) != 0 ) {
strncpy( if_name[j], netconf.ifc_req[i].ifr_name, 20 );
strncpy( if_addr[j], inet_ntoa(((struct sockaddr_in*)(&netconf.ifc_req[i].ifr_addr))->sin_addr), 20 );
j++;
}
}
if(j == 0) {
dissipate_our_fqdn = NULL;
return;
}
if(j == 1) {
dissipate_our_fqdn = strdup( if_addr[0] );
return;
}
default_ifName = getdefaultdev();
if( default_ifName != NULL) {
for( i = 0; i < j; i++ ) {
if( strcmp( if_name[i], default_ifName ) == 0 ) {
dissipate_our_fqdn = strdup( if_addr[i] );
return;
}
}
}
dissipate_our_fqdn = strdup( if_addr[0] );
}
QString Configuration::hostname() const
{
if ( dissipate_our_fqdn == NULL ) {
findFqdn();
}
return QString(dissipate_our_fqdn);
}

View File

@@ -19,9 +19,14 @@ default_presentation=4
[InvalidPassword]
Name=InvalidPassword
Comment=Invalid Password
Comment=The invalid password.
default_presentation=4
[InvalidPasswordInvitations]
Name=InvalidPasswordInvitations
Comment=The invited party sent an invalid password. Connection refused.
default_presentation=2
[NewConnectionOnHold]
Name=NewConnectionOnHold
Comment=Connection requested, user must accept
@@ -38,3 +43,8 @@ Comment=Busy, connection refused
default_presentation=4
default_logfile=
[UnexpectedConnection]
Name=UnexpectedConnection
Comment=Got unexpected connection, abort
default_presentation=4

View File

@@ -24,6 +24,7 @@
#include <kaction.h>
#include <kdebug.h>
#include <kapplication.h>
#include <knotifyclient.h>
#include <ksystemtray.h>
#include <kcmdlineargs.h>
#include <kaboutdata.h>
@@ -69,13 +70,13 @@ static KCmdLineOptions options[] =
/*
* KRfb can run in 4 different modes:
* - stand-alone
* + To get there call KRfb with kinetd disabled or not running
* + To get there call KRfb with kinetd disabled in KConfig (use KControl module)
* + traditional mode like <0.7 versions
* + uses non-kcm configuration dialog
* + invitation on start-up can be disabled
* - stand-alone with command line args
* + to get there call krfb any cmd line args (except --kinetd)
* + behaves like stand-alone, but without configuration
* + behaves like stand-alone, but without configuration & invitations
* - kinetd mode
* + started using the --kinetd argument
* + used for starting from kinetd
@@ -84,33 +85,36 @@ static KCmdLineOptions options[] =
* + config option calls kcontrol module
* - invitation mode
* + started when krfb is called while kinetd is enabled and no cmd line arg is given
* + displays only invitation dialog and finished then
* + does not accept connections, no tray icons
* + displays only invitation dialog and finishs then
* + does not accept connections, no tray icon
*
* TODO:
* - invitations (see configuration.cc for overview)
* - display kcm in kinetd mode
* - error on 'close connection' in kinetd mode
* - disable kinetd when no invitation valid
*/
bool checkKInetd() {
bool enabled;
void checkKInetd(bool &kinetdAvailable, bool &krfbAvailable) {
kinetdAvailable = false;
krfbAvailable = false;
DCOPClient *d = KApplication::dcopClient();
QByteArray sdata, rdata;
QCString replyType;
QDataStream arg(sdata, IO_WriteOnly);
arg << QString("krfb");
if (!d->call ("kded", "kinetd", "isEnabled(QString)", sdata, replyType, rdata))
return false;
if (!d->call ("kded", "kinetd", "isInstalled(QString)", sdata, replyType, rdata))
return;
if (replyType != "bool")
return false;
return;
QDataStream answer(rdata, IO_ReadOnly);
answer >> enabled;
return enabled;
answer >> krfbAvailable;
kinetdAvailable = true;
}
int main(int argc, char *argv[])
{
enum krfb_mode mode = KRFB_UNKNOWN_MODE;
@@ -170,10 +174,37 @@ int main(int argc, char *argv[])
fdString = args->getOption(ARG_KINETD);
mode = KRFB_KINETD_MODE;
}
if (mode == KRFB_UNKNOWN_MODE)
mode = checkKInetd() ? KRFB_INVITATION_MODE : KRFB_STAND_ALONE;
if (mode == KRFB_UNKNOWN_MODE) {
if (Configuration::earlyDaemonMode()) {
bool kinetdA, krfbA;
mode = KRFB_INVITATION_MODE;
checkKInetd(kinetdA, krfbA);
if (!kinetdA) {
KMessageBox::error(0,
i18n("Cannot find KInetD. "
"Have you re-started KDE after installation?"),
i18n("Desktop Sharing Error"));
return 1;
}
if (!krfbA) {
KMessageBox::error(0,
i18n("Cannot find KInetD service for Desktop Sharing (KRfb). "
"Have you re-started KDE after installation?"),
i18n("Desktop Sharing Error"));
return 1;
}
}
else
mode = KRFB_STAND_ALONE;
}
config = new Configuration(mode);
if ((mode == KRFB_KINETD_MODE) &&
(!config->allowUninvitedConnects()) &&
(config->invitations().size() == 0)) {
KNotifyClient::event("UnexpectedConnection");
return 1;
}
}
args->clear();
@@ -205,6 +236,8 @@ int main(int argc, char *argv[])
config, SLOT(showConfigDialog()));
QObject::connect(&trayicon, SIGNAL(showManageInvitations()),
config, SLOT(showManageInvitationsDialog()));
QObject::connect(&controller, SIGNAL(portProbed(int)),
config, SLOT(setPort(int)));
QObject::connect(&dcopiface, SIGNAL(connectionClosed()),
&controller, SLOT(closeConnection()));
@@ -248,6 +281,9 @@ int main(int argc, char *argv[])
else
controller.startServer();
if (config->showInvitationDialogOnStartup())
config->showInvitationDialog();
return app.exec();
}

View File

@@ -16,7 +16,7 @@
***************************************************************************/
/*
* Contains keyboard & pointer handling from libvncserver's x11vnc.c
* Contains keyboard & pointer handling from libvncserver's x11vnc.c
*/
#include "rfbcontroller.h"
@@ -61,7 +61,7 @@ public:
AppLocker() {
KApplication::kApplication()->lock();
}
~AppLocker() {
KApplication::kApplication()->unlock();
}
@@ -73,7 +73,7 @@ static enum rfbNewClientAction newClientHook(struct _rfbClientRec *cl)
return self->handleNewClient(cl);
}
static Bool passwordCheck(rfbClientPtr cl,
static Bool passwordCheck(rfbClientPtr cl,
char* encryptedPassword,
int len)
{
@@ -98,7 +98,7 @@ static void clientGoneHook(rfbClientPtr)
void ConnectionDialog::closeEvent(QCloseEvent *)
void ConnectionDialog::closeEvent(QCloseEvent *)
{
emit closed();
}
@@ -221,22 +221,33 @@ PointerEvent::PointerEvent(int b, int _x, int _y) :
void PointerEvent::exec() {
XTestFakeMotionEvent(dpy, 0, x, y, CurrentTime);
for(int i = 0; i < 5; i++)
for(int i = 0; i < 5; i++)
if ((buttonMask&(1<<i))!=(button_mask&(1<<i)))
XTestFakeButtonEvent(dpy,
i+1,
(button_mask&(1<<i))?True:False,
CurrentTime);
buttonMask = button_mask;
}
KNotifyEvent::KNotifyEvent(const QString &n, const QString &d) :
name(n),
desc(d) {
}
KNotifyEvent::~KNotifyEvent() {
}
void KNotifyEvent::exec() {
KNotifyClient::event(name, desc);
}
RFBController::RFBController(Configuration *c) :
allowRemoteControl(false),
connectionNum(0),
configuration(c),
closePending(false),
asyncKNotifyEvent(false)
closePending(false)
{
self = this;
connect(dialog.acceptConnectionButton, SIGNAL(clicked()),
@@ -333,7 +344,8 @@ void RFBController::startServer(int inetdFd, bool xtestGrab)
rfbInitServer(server);
state = RFB_WAITING;
emit portProbed(server->rfbPort);
if (inetdFd < 0)
emit portProbed(server->rfbPort);
if (xtestGrab) {
disabler.disable = false;
@@ -357,7 +369,7 @@ void RFBController::stopServer(bool xtestUngrab)
}
}
void RFBController::rebind()
void RFBController::rebind()
{
stopServer(false);
startServer(-1, false);
@@ -377,10 +389,10 @@ void RFBController::connectionAccepted(bool aRC)
emit sessionEstablished();
}
void RFBController::acceptConnection(bool aRC)
void RFBController::acceptConnection(bool aRC)
{
KNotifyClient::event("UserAcceptsConnection",
i18n("Connecting system: %1")
i18n("User accepts connection from %1")
.arg(remoteIp));
if (state != RFB_CONNECTING)
@@ -390,10 +402,10 @@ void RFBController::acceptConnection(bool aRC)
rfbStartOnHoldClient(server->rfbClientHead);
}
void RFBController::refuseConnection()
void RFBController::refuseConnection()
{
KNotifyClient::event("UserRefusesConnection",
i18n("Connecting system: %1")
i18n("User refuses connection from %1")
.arg(remoteIp));
if (state != RFB_CONNECTING)
@@ -403,7 +415,7 @@ void RFBController::refuseConnection()
}
// checks async events, returns true if client disconnected
bool RFBController::checkAsyncEvents()
bool RFBController::checkAsyncEvents()
{
bool closed = false;
asyncMutex.lock();
@@ -420,7 +432,7 @@ bool RFBController::checkAsyncEvents()
return closed;
}
void RFBController::connectionClosed()
void RFBController::connectionClosed()
{
KNotifyClient::event("ConnectionClosed",
i18n("Closed connection: %1.")
@@ -432,9 +444,13 @@ void RFBController::connectionClosed()
emit sessionFinished();
}
void RFBController::closeConnection()
void RFBController::closeConnection()
{
if (state == RFB_CONNECTED) {
if (server->inetdSock >= 0) {
close(server->inetdSock);
emit sessionFinished();
}
if (!checkAsyncEvents()) {
asyncMutex.lock();
if (!closePending)
@@ -494,9 +510,12 @@ bool checkPassword(const QString &p,
const char *response,
int len) {
if ((len == 0) && (p.length() == 0))
return true;
char passwd[MAXPWLEN];
char challenge[CHALLENGESIZE];
unsigned char challenge[CHALLENGESIZE];
memcpy(challenge, ochallenge, CHALLENGESIZE);
bzero(passwd, MAXPWLEN);
if (!p.isNull())
@@ -511,8 +530,12 @@ bool RFBController::handleCheckPassword(rfbClientPtr cl,
const char *response,
int len)
{
bool authd = checkPassword(configuration->password(),
cl->authChallenge, response, len);
bool authd = false;
if (configuration->allowUninvitedConnects())
authd = checkPassword(configuration->password(),
cl->authChallenge, response, len);
if (!authd) {
QValueList<Invitation>::iterator it =
@@ -522,7 +545,7 @@ bool RFBController::handleCheckPassword(rfbClientPtr cl,
cl->authChallenge, response, len) &&
(*it).isValid()) {
authd = true;
configuration->invitations().remove(it);
configuration->removeInvitation(it);
break;
}
it++;
@@ -530,47 +553,53 @@ bool RFBController::handleCheckPassword(rfbClientPtr cl,
}
if (!authd) {
QString host, port;
KExtendedSocket::resolve(KExtendedSocket::peerAddress(cl->sock),
host, port);
sendDelayedKNotifyEvent("InvalidPassword",
i18n("Connecting system: %1")
if (configuration->invitations().size() > 0) {
sendKNotifyEvent("InvalidPasswordInvitations",
i18n("Failed login attempt from %1: wrong password")
.arg(remoteIp));
}
else
sendKNotifyEvent("InvalidPassword",
i18n("Failed login attempt from %1: wrong password")
.arg(remoteIp));
return FALSE;
}
return TRUE;
}
enum rfbNewClientAction RFBController::handleNewClient(rfbClientPtr cl)
enum rfbNewClientAction RFBController::handleNewClient(rfbClientPtr cl)
{
int socket = cl->sock;
QString host, port;
KExtendedSocket::resolve(KExtendedSocket::peerAddress(socket),
host, port);
KSocketAddress *ksa = KExtendedSocket::peerAddress(socket);
if (ksa) {
KExtendedSocket::resolve(ksa, host, port);
delete ksa;
}
if ((connectionNum > 0) ||
(state != RFB_WAITING)) {
sendDelayedKNotifyEvent("TooManyConnections",
i18n("Connecting system: %1")
sendKNotifyEvent("TooManyConnections",
i18n("Connection refused from %1, already connected.")
.arg(host));
return RFB_CLIENT_REFUSE;
}
remoteIp = host;
state = RFB_CONNECTING;
if (!configuration->askOnConnect()) {
sendDelayedKNotifyEvent("NewConnectionAutoAccepted",
i18n("Connecting system: %1")
if ((!configuration->askOnConnect()) &&
(configuration->invitations().size() == 0)) {
sendKNotifyEvent("NewConnectionAutoAccepted",
i18n("Accepted uninvited connection from %1")
.arg(remoteIp));
connectionAccepted(configuration->allowDesktopControl());
return RFB_CLIENT_ACCEPT;
}
sendDelayedKNotifyEvent("NewConnectionOnHold",
i18n("Connecting system: %1")
sendKNotifyEvent("NewConnectionOnHold",
i18n("Got connection from %1, on hold (waiting for confirmation)")
.arg(remoteIp));
dialog.ipLabel->setText(remoteIp);
@@ -606,13 +635,11 @@ void RFBController::handlePointerEvent(int button_mask, int x, int y) {
}
void RFBController::passwordChanged() {
bool b = false;
bool authRequired = (!configuration->allowUninvitedConnects()) ||
(configuration->password().length() != 0) ||
(configuration->invitations().count() > 0);
if(configuration->password().length() == 0)
b = true;
if(configuration->invitations().count() > 0)
b = true;
server->rfbAuthPasswdData = (void*) (b ? 1 : 0);
server->rfbAuthPasswdData = (void*) (authRequired ? 1 : 0);
}
int RFBController::getPort()
@@ -620,34 +647,19 @@ int RFBController::getPort()
return server->rfbPort;
}
void RFBController::sendDelayedKNotifyEvent(QString name,
QString desc)
void RFBController::sendKNotifyEvent(const QString &n, const QString &d)
{
if (asyncKNotifyEvent)
return;
asyncKNotifyEventName = name;
asyncKNotifyEventDesc= desc;
asyncKNotifyEvent = true;
QTimer::singleShot(0, this, SLOT(sendKNotifyEvent()));
}
void RFBController::sendKNotifyEvent()
{
if (!asyncKNotifyEvent)
return;
KNotifyClient::event(asyncKNotifyEventName,
asyncKNotifyEventDesc);
asyncKNotifyEvent = false;
asyncMutex.lock();
asyncQueue.append(new KNotifyEvent(n, d));
asyncMutex.unlock();
}
bool RFBController::checkX11Capabilities() {
int bp1, bp2, majorv, minorv;
Bool r = XTestQueryExtension(qt_xdisplay(), &bp1, &bp2,
Bool r = XTestQueryExtension(qt_xdisplay(), &bp1, &bp2,
&majorv, &minorv);
if ((!r) || (((majorv*1000)+minorv) < 2002)) {
KMessageBox::error(0,
KMessageBox::error(0,
i18n("Your X11 Server does not support the required XTest extension version 2.2. Sharing your desktop is not possible."),
i18n("Desktop Sharing Error"));
return false;
@@ -655,7 +667,7 @@ bool RFBController::checkX11Capabilities() {
r = XShmQueryExtension(qt_xdisplay());
if (!r) {
KMessageBox::error(0,
KMessageBox::error(0,
i18n("Your X11 Server does not support the required XShm extension. You can only share a local desktop."),
i18n("Desktop Sharing Error"));
return false;

View File

@@ -93,12 +93,20 @@ public:
virtual void exec();
};
class KNotifyEvent : public VNCEvent {
QString name;
QString desc;
public:
KNotifyEvent(const QString &n, const QString &d);
virtual ~KNotifyEvent();
virtual void exec();
};
/**
* Manages sockets, drives the RGBConnection and triggers the connection
* dialog.
* The controller has three states: 'waiting for connection',
* 'waiting for confirmation' and 'connected'. In the first state socket and
* 'waiting for confirmation' and 'connected'. In the first state socket and
* connection are null, in the second socket is set and in the last both are
* set.
* @author Tim Jansen
@@ -138,9 +146,9 @@ signals:
private:
void stopServer(bool xtestUngrab = true);
void sendKNotifyEvent(const QString &name, const QString &desc);
bool checkAsyncEvents();
void sendDelayedKNotifyEvent(QString name, QString desc);
bool allowRemoteControl;
int connectionNum;
QString remoteIp;
@@ -157,15 +165,10 @@ private:
QMutex asyncMutex;
QPtrList<VNCEvent> asyncQueue;
bool closePending;
bool asyncKNotifyEvent;
QString asyncKNotifyEventName;
QString asyncKNotifyEventDesc;
private slots:
void idleSlot();
void dialogAccepted();
void dialogRefused();
void sendKNotifyEvent();
};
/*