Allow removal of GUI prompt on fatal errors

Add a new parameter 'alertOnFatalError' which guards
the displaying of the GUI alert on fatal errors, and
thus when false just gives the textual error.

Now I can do:

  while true
  do
    vncviewer alertOnFatalError=false vm:0
    sleep 1
  done

and it'll reappear when my VM appears without me getting error
dialogs.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
--
diff --git a/vncviewer/CConn.cxx b/vncviewer/CConn.cxx
index addc30d..2e97ec2 100644
--- a/vncviewer/CConn.cxx
+++ b/vncviewer/CConn.cxx
@@ -110,7 +110,8 @@
       vlog.info(_("connected to host %s port %d"), serverHost, serverPort);
     } catch (rdr::Exception& e) {
       vlog.error("%s", e.str());
-      fl_alert("%s", e.str());
+      if (alertOnFatalError)
+        fl_alert("%s", e.str());
       exit_vncviewer();
       return;
     }
diff --git a/vncviewer/parameters.cxx b/vncviewer/parameters.cxx
index ad82f27..9385b98 100644
--- a/vncviewer/parameters.cxx
+++ b/vncviewer/parameters.cxx
@@ -59,6 +59,10 @@
                               "Show the dot cursor when the server sends an "
                               "invisible cursor", false);
 
+BoolParameter alertOnFatalError("AlertOnFatalError",
+                                "Give a dialog on connection problems rather "
+                                "than exiting immediately", true);
+
 StringParameter passwordFile("PasswordFile",
                              "Password file for VNC authentication", "");
 AliasParameter passwd("passwd", "Alias for PasswordFile", &passwordFile);
@@ -174,7 +178,8 @@
   &sendPrimary,
 #endif
   &menuKey,
-  &fullscreenSystemKeys
+  &fullscreenSystemKeys,
+  &alertOnFatalError
 };
 
 // Encoding Table
diff --git a/vncviewer/parameters.h b/vncviewer/parameters.h
index 682b6d6..9ce56b9 100644
--- a/vncviewer/parameters.h
+++ b/vncviewer/parameters.h
@@ -60,6 +60,7 @@
 extern rfb::StringParameter menuKey;
 
 extern rfb::BoolParameter fullscreenSystemKeys;
+extern rfb::BoolParameter alertOnFatalError;
 
 #ifndef WIN32
 extern rfb::StringParameter via;
diff --git a/vncviewer/vncviewer.cxx b/vncviewer/vncviewer.cxx
index de2b423..0ca46af 100644
--- a/vncviewer/vncviewer.cxx
+++ b/vncviewer/vncviewer.cxx
@@ -494,7 +494,9 @@
     defaultServerName = loadViewerParameters(NULL);
   } catch (rfb::Exception& e) {
     defaultServerName = "";
-    fl_alert("%s", e.str());
+    vlog.error("%s", e.str());
+    if (alertOnFatalError)
+      fl_alert("%s", e.str());
   }
   
   int i = 1;
@@ -532,7 +534,8 @@
     // TRANSLATORS: "Parameters" are command line arguments, or settings
     // from a file or the Windows registry.
     vlog.error(_("Parameters -listen and -via are incompatible"));
-    fl_alert(_("Parameters -listen and -via are incompatible"));
+    if (alertOnFatalError)
+      fl_alert(_("Parameters -listen and -via are incompatible"));
     exit_vncviewer();
     return 1;
   }
@@ -580,7 +583,8 @@
       }
     } catch (rdr::Exception& e) {
       vlog.error("%s", e.str());
-      fl_alert("%s", e.str());
+      if (alertOnFatalError)
+        fl_alert("%s", e.str());
       exit_vncviewer();
       return 1; 
     }
@@ -609,7 +613,7 @@
 
   delete cc;
 
-  if (exitError != NULL)
+  if (exitError != NULL && alertOnFatalError)
     fl_alert("%s", exitError);
 
   return 0;
diff --git a/vncviewer/vncviewer.man b/vncviewer/vncviewer.man
index b1450d1..e48a0c4 100644
--- a/vncviewer/vncviewer.man
+++ b/vncviewer/vncviewer.man
@@ -275,6 +275,10 @@
 \fIR\fR, and \fIG\fR taken the values of the local port number, the remote
 host, the port number on the remote host, and the gateway machine
 respectively.
+.
+.TP
+.B \-AlertOnFatalError
+Display a dialog with any fatal error before exiting. Default is on.
 
 .SH FILES
 .TP