diff --git a/TODO b/TODO
index ba5f40e9..b128dcef 100644
--- a/TODO
+++ b/TODO
@@ -1,6 +1,7 @@
Todo:
- fix what's-this help in dialogs
-- remove help button?
+- remove help buttons?
+- add command-line args (one-connection, set-password, ask-on-connect)
Possible features:
diff --git a/krfb/XUpdateScanner.cc b/krfb/XUpdateScanner.cc
index 5d20d548..a83c3123 100644
--- a/krfb/XUpdateScanner.cc
+++ b/krfb/XUpdateScanner.cc
@@ -26,8 +26,6 @@
#include "XUpdateScanner.h"
-#define SHOW_MOUSE_POINTER 1
-
namespace rfb {
unsigned int scanlines[32] = { 0, 16, 8, 24,
@@ -194,7 +192,8 @@ char pointerMap[] =
" .. "
" ";
-void XUpdateScanner::searchUpdates( list< Hint > &hintList )
+void XUpdateScanner::searchUpdates( list< Hint > &hintList,
+ bool showMousePointer)
{
/*
count %= (blockWidth * blockHeight);
@@ -244,7 +243,7 @@ void XUpdateScanner::searchUpdates( list< Hint > &hintList )
}
- if ( SHOW_MOUSE_POINTER ) {
+ if ( showMousePointer ) {
Window root_return, child_return;
int root_x, root_y;
diff --git a/krfb/XUpdateScanner.h b/krfb/XUpdateScanner.h
index 2f87ad3c..7b1fd4be 100644
--- a/krfb/XUpdateScanner.h
+++ b/krfb/XUpdateScanner.h
@@ -44,7 +44,7 @@ class XUpdateScanner
~XUpdateScanner();
void checkTile( int x, int y, list< Hint > &hintList );
- void searchUpdates( list< Hint > &hintList );
+ void searchUpdates( list< Hint > &hintList, bool showMouse );
Display *dpy;
diff --git a/krfb/configuration.cc b/krfb/configuration.cc
index 32f50407..b9c4aa53 100644
--- a/krfb/configuration.cc
+++ b/krfb/configuration.cc
@@ -102,7 +102,7 @@ QString Configuration::password() const {
}
int Configuration::port() const {
- return (portNumber < 1023) ? (portNumber + 5900) : portNumber;
+ return (portNumber < 100) ? (portNumber + 5900) : portNumber;
}
void Configuration::showDialog() {
diff --git a/krfb/configurationdialog.ui b/krfb/configurationdialog.ui
index 99c36547..56909b66 100644
--- a/krfb/configurationdialog.ui
+++ b/krfb/configurationdialog.ui
@@ -11,8 +11,8 @@
0
0
- 386
- 278
+ 318
+ 284
@@ -80,7 +80,7 @@
whatsThis
- If this option is enabled you will be asked whenever a remote user wants to connect to your display. This allows to close windows that the remote user should not see or to deny the request completely. It is highly recommended when you work 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.
+ 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.
@@ -95,7 +95,7 @@
whatsThis
- If you allow this option 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 see what you are doing.
+ 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.
@@ -182,7 +182,7 @@
whatsThis
- Enter the display number/port here. Unless you have more than one server running on the machine just enter 0 here. Regular RFB/VNC port number 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.
+ 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.
@@ -289,21 +289,25 @@
margin
- 0
+ 4
spacing
- 5
+ 6
QPushButton
name
- helpButton
+ applyButton
text
- &Help
+ &Apply
+
+
+ whatsThis
+ Click this to apply the changes immediately.
@@ -327,21 +331,6 @@
-
- QPushButton
-
- name
- applyButton
-
-
- text
- &Apply
-
-
- whatsThis
- Click this to apply the changes immediately.
-
-
QPushButton
diff --git a/krfb/newconnectiondialog.ui b/krfb/newconnectiondialog.ui
index 5b4b3a99..267dd4bc 100644
--- a/krfb/newconnectiondialog.ui
+++ b/krfb/newconnectiondialog.ui
@@ -208,7 +208,7 @@ This means that he can see everything on your screen and, if the box below is en
whatsThis
- If you allow this option 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 see what you are doing.
+ 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.
@@ -249,17 +249,6 @@ This means that he can see everything on your screen and, if the box below is en
spacing
6
-
- QPushButton
-
- name
- PushButton8
-
-
- text
- Help
-
-
name
@@ -293,7 +282,7 @@ This means that he can see everything on your screen and, if the box below is en
whatsThis
- This button grant the request. The remote user can now see everything on your desktop and, if you enabled it, control your computer.
+ This button grants the request. The remote user can now watch your desktop and, if you selected it above, control your computer.
@@ -306,6 +295,10 @@ This means that he can see everything on your screen and, if the box below is en
text
Refuse connection
+
+ default
+ true
+
whatsThis
This button will refuse the connection. You should chose this unless you trust the requesting user.
diff --git a/krfb/rfbconnection.cc b/krfb/rfbconnection.cc
index e3f4053e..44ab502a 100644
--- a/krfb/rfbconnection.cc
+++ b/krfb/rfbconnection.cc
@@ -33,11 +33,13 @@
RFBConnection::RFBConnection(Display *_dpy,
int _fd,
const QString &cpassword,
- bool _allowInput) :
+ bool _allowInput,
+ bool _showMousePointer) :
Server(),
dpy(_dpy),
fd(_fd),
allowInput(_allowInput),
+ showMousePointer(_showMousePointer),
buttonMask(0)
{
memcpy(password, "\0\0\0\0\0\0\0\0", 8);
@@ -157,7 +159,7 @@ void RFBConnection::scanUpdates()
{
list hintList;
- scanner->searchUpdates(hintList);
+ scanner->searchUpdates(hintList, showMousePointer);
list::iterator i;
for (i = hintList.begin(); i != hintList.end(); i++)
handleHint(*i);
diff --git a/krfb/rfbconnection.h b/krfb/rfbconnection.h
index f83deb67..252fbdf8 100644
--- a/krfb/rfbconnection.h
+++ b/krfb/rfbconnection.h
@@ -51,7 +51,8 @@ class RFBConnection : public QObject, public Server {
Q_OBJECT
public:
RFBConnection(Display *dpy, int fd,
- const QString &cpassword, bool allowInput);
+ const QString &cpassword,
+ bool allowInput, bool showMouse);
~RFBConnection();
virtual void handleKeyEvent(KeyEvent &keyEvent);
virtual void handlePointerEvent(PointerEvent &pointerEvent);
@@ -67,6 +68,7 @@ private:
int fd;
int buttonMask;
bool allowInput;
+ bool showMousePointer;
XUpdateScanner *scanner;
diff --git a/krfb/rfbcontroller.cc b/krfb/rfbcontroller.cc
index 1b623c55..bc751b20 100644
--- a/krfb/rfbcontroller.cc
+++ b/krfb/rfbcontroller.cc
@@ -29,6 +29,8 @@
#include
#include
#include
+#include
+#include
#include
RFBController::RFBController(Configuration *c) :
@@ -37,6 +39,11 @@ RFBController::RFBController(Configuration *c) :
connection(0),
idleUpdateScheduled(false)
{
+ connect(dialog.acceptConnectionButton, SIGNAL(clicked()),
+ SLOT(dialogAccepted()));
+ connect(dialog.refuseConnectionButton, SIGNAL(clicked()),
+ SLOT(dialogRefused()));
+
startServer();
}
@@ -80,17 +87,27 @@ void RFBController::accepted(KSocket *s) {
fcntl(sockFd, F_SETFL, O_NONBLOCK);
socket = s;
- // TODO: ASK USER FOR PERMISSION HERE BEFORE GOING ON
- // TODO: also handle case if remote closes while dialog is shown
+ if (configuration->askOnConnect()) {
+ dialog.allowRemoteControlCB->setChecked(
+ configuration->allowDesktopControl());
+ dialog.show();
+ }
+ else {
+ acceptConnection(configuration->allowDesktopControl());
+ }
+}
+void RFBController::acceptConnection(bool allowDesktopControl) {
+ KSocket *s = socket;
connect(s, SIGNAL(readEvent(KSocket*)), SLOT(socketReadable()));
connect(s, SIGNAL(writeEvent(KSocket*)), SLOT(socketWritable()));
connect(s, SIGNAL(closeEvent(KSocket*)), SLOT(closeSession()));
s->enableRead(true);
s->enableWrite(true);
- connection = new RFBConnection(qt_xdisplay(), sockFd,
+ connection = new RFBConnection(qt_xdisplay(), s->socket(),
configuration->password(),
- configuration->allowDesktopControl());
+ allowDesktopControl,
+ configuration->showMousePointer());
emit sessionEstablished();
}
@@ -173,6 +190,26 @@ void RFBController::closeSession() {
connection = 0;
emit sessionFinished();
}
+ closeSocket();
+}
+
+void RFBController::dialogAccepted() {
+ ASSERT(socket);
+ ASSERT(!connection);
+
+ dialog.hide();
+ acceptConnection(dialog.allowRemoteControlCB->isChecked());
+}
+
+void RFBController::dialogRefused() {
+ ASSERT(socket);
+ ASSERT(!connection);
+
+ closeSocket();
+ dialog.hide();
+}
+
+void RFBController::closeSocket() {
delete socket;
socket = 0;
}
diff --git a/krfb/rfbcontroller.h b/krfb/rfbcontroller.h
index 19bb6e20..681f89ea 100644
--- a/krfb/rfbcontroller.h
+++ b/krfb/rfbcontroller.h
@@ -24,6 +24,7 @@
#define RFBCONTROLLER_H
#include "configuration.h"
+#include "newconnectiondialog.h"
#include
#include
// rfbconnection must be last because of X11 headers
@@ -58,11 +59,14 @@ private:
void startServer();
void checkWriteBuffer();
void prepareIdleUpdate();
+ void acceptConnection(bool ask);
+ void closeSocket();
Configuration *configuration;
KServerSocket *serversocket;
KSocket *socket;
RFBConnection *connection;
+ KRFBConnectionDialog dialog;
bool idleUpdateScheduled;
private slots:
@@ -70,6 +74,8 @@ private slots:
void accepted(KSocket*);
void socketReadable();
void socketWritable();
+ void dialogAccepted();
+ void dialogRefused();
};
#endif