Hi Ola!

On Tue, 07 Nov 2006 11:23:44 +0100, Ola Lundqvist wrote:
> On Tue, Nov 07, 2006 at 10:56:38AM +0100, Luca Capello wrote:
>> On Tue, 07 Nov 2006 10:37:41 +0100, Ola Lundqvist wrote:
>>> The current solution is to have a -PasswordDialog option. I
>>> actually think this option should be changed to -XDialogs instead
>>> and apply to all input methods.
>> 
>> Completely agree.
>
> Nice.

At least for the ServerDialog and the PasswordDialog this is quite
simple and the attached patches seem to work.  It needs to be
checked, because as I already said, I'm a true beginner in C++, so
maybe it's not correct (or it misses something).

I tested it on xterm/ratpoison [1] and on openbox (sorry, no
DesktopEnvironment here...) and it seems to work as expected.

The set of sequential patches is against the Debian sources, thus
isn't suitable yet for inclusion in a debian package.  Here a small
ChangeLog:

  1) remove duplicated <termios.h>/<stdio.h> and move them to the
     beginning of include (together with "general" includes like
     <unistd.h>)
  2) s/UserPassDialog/XDialog/g
  3) code cleanup (this is basically to keep the upstream style on
     if/else statements and only one IMHO better line spacing)
  4) add XDialog check for vncServerName
  5) add a \n before prompting for server, username and password
     (which IMHO is "graphically" better on console [2])
  6) update the manpage (which as per #394072 [3] lacks the
     -PasswordDialog option and I don't think it's worth to fix that
     bug before fixing this one)

For the error dialog windows, the situation is different: from what I
can understand at a very fast code checking, we need to modify some
functions (*Exception) in common/rfb/ or common/rdr/.  Thus I need a
bit more time :-)

Any comments?

Thx, bye,
Gismo / Luca

Footnotes: 
[1] if you use the ratpoison exec command (or the menu entry provided
    together with the 9menu package), this obviously fails, because it
    execute a shell command and thus vncviewer thinks it's on the
    console (but you cannot see anything).  I don't know how to solve
    this problem :-(
[2] I don't know why a new line is printed after the Server: question
    and not after the Password: one and I even unsuccessfully tried to
    strip down the \n when fgets(vncServerName).  IMHO the best option
    would be to have "\nQuestion: \n", but these are minor stuff
[3] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=394072

--- vnc4-4.1.1+X4.3.0/unix/vncviewer/CConn.cxx	2006-11-06 18:52:04.000000000 +0100
+++ vnc4-4.1.1+X4.3.0_gismo-1/unix/vncviewer/CConn.cxx	2006-11-07 17:48:42.000000000 +0100
@@ -19,6 +19,8 @@
 // CConn.cxx
 //
 
+#include <termios.h>
+#include <stdio.h>
 #include <unistd.h>
 #include "CConn.h"
 #include <rfb/CMsgWriter.h>
@@ -37,8 +39,6 @@
 #include "ServerDialog.h"
 #include "PasswdDialog.h"
 #include "parameters.h"
-#include <termios.h>
-#include <stdio.h>
 
 using namespace rfb;
 
@@ -50,8 +50,6 @@
 StringParameter menuKey("MenuKey", "The key which brings up the popup menu",
                         "F8");
 StringParameter windowName("name", "The X window name", "");
-#include <termios.h>
-#include <stdio.h>
 
 CConn::CConn(Display* dpy_, int argc_, char** argv_, network::Socket* sock_,
              char* vncServerName, bool reverse)
--- vnc4-4.1.1+X4.3.0_gismo-1/unix/vncviewer/CConn.cxx	2006-11-07 18:15:41.000000000 +0100
+++ vnc4-4.1.1+X4.3.0_gismo-2/unix/vncviewer/CConn.cxx	2006-11-07 18:17:26.000000000 +0100
@@ -211,7 +211,7 @@
     return;
   }
 
-  int popup = popupUserPassDialog;
+  int popup = popupXDialog;
   if (!popup) {
     if (user) {
       /* Get username */

--- vnc4-4.1.1+X4.3.0_gismo-1/unix/vncviewer/parameters.h	2006-11-07 18:14:28.000000000 +0100
+++ vnc4-4.1.1+X4.3.0_gismo-2/unix/vncviewer/parameters.h	2006-11-07 18:18:23.000000000 +0100
@@ -37,7 +37,7 @@
 extern rfb::BoolParameter sendPrimary;
 extern rfb::BoolParameter fullScreen;
 extern rfb::StringParameter geometry;
-extern rfb::BoolParameter popupUserPassDialog;
+extern rfb::BoolParameter popupXDialog;
 
 extern char aboutText[];
 extern char* programName;

--- vnc4-4.1.1+X4.3.0_gismo-1/unix/vncviewer/vncviewer.cxx	2006-11-07 18:14:28.000000000 +0100
+++ vnc4-4.1.1+X4.3.0_gismo-2/unix/vncviewer/vncviewer.cxx	2006-11-07 18:20:42.000000000 +0100
@@ -93,10 +93,10 @@
 
 BoolParameter listenMode("listen", "Listen for connections from VNC servers",
                          false);
-BoolParameter popupUserPassDialog("PasswordDialog",
-				  "Popup a user and password dialog. Default "
-				  "no when running from command line",
-				  !isatty(0));
+BoolParameter popupXDialog("XDialog",
+                           "Popup a user and password dialog. Default "
+                           "no when running from command line",
+                           !isatty(0));
 StringParameter geometry("geometry", "X geometry specification", "");
 StringParameter displayname("display", "The X display", "");
 
--- vnc4-4.1.1+X4.3.0_gismo-2/unix/vncviewer/CConn.cxx	2006-11-07 18:17:26.000000000 +0100
+++ vnc4-4.1.1+X4.3.0_gismo-3/unix/vncviewer/CConn.cxx	2006-11-07 18:09:38.000000000 +0100
@@ -224,8 +224,7 @@
 
     if (tcgetattr (fileno (stdin), &oldio) != 0) {
       popup = 1;
-    }
-    else {
+    } else {
       newio = oldio;
       newio.c_lflag &= ~ECHO;
       fprintf(stderr, "Password: ");
@@ -243,6 +242,7 @@
       (void) tcsetattr (fileno (stdin), TCSAFLUSH, &oldio);
     }
   }
+
   if (popup) {
     const char* secType = secTypeName(getCurrentCSecurity()->getType());
     const char* titlePrefix = "VNC Authentication";
--- vnc4-4.1.1+X4.3.0_gismo-3/unix/vncviewer/CConn.cxx	2006-11-07 18:09:38.000000000 +0100
+++ vnc4-4.1.1+X4.3.0_gismo-4/unix/vncviewer/CConn.cxx	2006-11-07 18:47:01.000000000 +0100
@@ -88,11 +88,20 @@
     if (vncServerName) {
       getHostAndPort(vncServerName, &serverHost, &serverPort);
     } else {
-      ServerDialog dlg(dpy, &options, &about);
-      if (!dlg.show() || dlg.entry.getText()[0] == 0) {
-        exit(1);
+      int popup = popupXDialog;
+      if (!popup) {
+        /* Get server */
+        fprintf(stderr, "Server: ");
+        vncServerName = new char[128];
+        fgets(vncServerName, 128, stdin);
+        getHostAndPort(vncServerName, &serverHost, &serverPort);
+      } else {
+        ServerDialog dlg(dpy, &options, &about);
+        if (!dlg.show() || dlg.entry.getText()[0] == 0) {
+          exit(1);
+        }
+        getHostAndPort(dlg.entry.getText(), &serverHost, &serverPort);
       }
-      getHostAndPort(dlg.entry.getText(), &serverHost, &serverPort);
     }
 
     sock = new network::TcpSocket(serverHost, serverPort);

--- vnc4-4.1.1+X4.3.0_gismo-3/unix/vncviewer/vncviewer.cxx	2006-11-07 18:24:12.000000000 +0100
+++ vnc4-4.1.1+X4.3.0_gismo-4/unix/vncviewer/vncviewer.cxx	2006-11-07 18:47:30.000000000 +0100
@@ -94,8 +94,9 @@
 BoolParameter listenMode("listen", "Listen for connections from VNC servers",
                          false);
 BoolParameter popupXDialog("XDialog",
-                           "Popup a user and password dialog. Default "
-                           "no when running from command line",
+                           "Popup an X dialog when asking for server, "
+                           "username and password. Default no when "
+                           "running from command line",
                            !isatty(0));
 StringParameter geometry("geometry", "X geometry specification", "");
 StringParameter displayname("display", "The X display", "");
--- vnc4-4.1.1+X4.3.0_gismo-4/unix/vncviewer/CConn.cxx	2006-11-07 19:43:39.000000000 +0100
+++ vnc4-4.1.1+X4.3.0_gismo-5/unix/vncviewer/CConn.cxx	2006-11-07 19:43:05.000000000 +0100
@@ -91,7 +91,7 @@
       int popup = popupXDialog;
       if (!popup) {
         /* Get server */
-        fprintf(stderr, "Server: ");
+        fprintf(stderr, "\nServer: ");
         vncServerName = new char[128];
         fgets(vncServerName, 128, stdin);
         getHostAndPort(vncServerName, &serverHost, &serverPort);
@@ -224,7 +224,7 @@
   if (!popup) {
     if (user) {
       /* Get username */
-      fprintf(stderr, "Username: ");
+      fprintf(stderr, "\nUsername: ");
       *user = new char[128];
       fgets(*user, 128, stdin);
       /* Remove \n at the end */
@@ -236,7 +236,7 @@
     } else {
       newio = oldio;
       newio.c_lflag &= ~ECHO;
-      fprintf(stderr, "Password: ");
+      fprintf(stderr, "\nPassword: ");
       /* Echo off */
       if (tcsetattr (fileno (stdin), TCSAFLUSH, &newio) != 0)
 	popup = 1;
--- vnc4-4.1.1+X4.3.0_gismo-5/unix/vncviewer/vncviewer.man	2006-11-07 08:36:01.000000000 +0100
+++ vnc4-4.1.1+X4.3.0_gismo-6/unix/vncviewer/vncviewer.man	2006-11-08 11:53:51.000000000 +0100
@@ -1,4 +1,4 @@
-.TH vncviewer 1 "03 Mar 2005" "RealVNC Ltd" "Virtual Network Computing"
+.TH vncviewer 1 "08 Nov 2006" "RealVNC Ltd" "Virtual Network Computing"
 .SH NAME
 vncviewer \- VNC viewer for X
 .SH SYNOPSIS
@@ -102,6 +102,11 @@
 .B vncconfig.
 
 .TP
+.B \-XDialog
+Popup an X dialog when asking for server, username and password.  Default is to
+not popup when vncviewer is start from command line.
+
+.TP
 .B \-passwd \fIpassword-file\fP
 If you are on a filesystem which gives you access to the password file used by
 the server, you can specify it here to avoid typing it in.  It will usually be

Attachment: pgpKVam97mOBG.pgp
Description: PGP signature

Reply via email to