When the network is down or the remote host is unreachable or the ssh or telnet services are not running in the remote host, etc. gnome-remote-shell finishes without any error message. It is confused for the user who don't know what happened. I attach to the mail a proposed patch to fix it -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Carlos Garcia Campos a.k.a. KaL elkalmail yahoo es carlosgc gnome org Grupo Linups - Secretaria Usuarios de SL/Linux de la UPSAM http://www.linups.org =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= PGP key: http://pgp.rediris.es:11371/pks/lookup?op=get&search=0x523E6462
? gnome-remote-shell.c.diff
Index: gnome-remote-shell.c
===================================================================
RCS file: /cvs/gnome/gnome-network/network-utilities/gnome-remote-shell.c,v
retrieving revision 1.15
diff -u -u -r1.15 gnome-remote-shell.c
--- gnome-remote-shell.c 26 Aug 2003 20:29:45 -0000 1.15
+++ gnome-remote-shell.c 31 Aug 2003 20:30:53 -0000
@@ -56,6 +56,7 @@
void port_default_toggled_cb (GtkToggleButton *button, gpointer user_data);
void radio_button_toggled_cb (GtkToggleButton *button, gpointer user_data);
+static gboolean check_network_status (const gchar *host, gint port);
static void activate_shell (void);
static void set_spin_from_config (GtkWidget *spin, const gchar *key, gint default_value);
static gboolean validate_host (const gchar *host);
@@ -112,6 +113,40 @@
}
}
+static gboolean
+check_network_status (const gchar *host, gint port)
+{
+ struct sockaddr_in *addr;
+ struct hostent *hostname;
+ gint sd;
+ gchar *msgerror;
+
+ hostname = gethostbyname (host);
+
+ addr = (struct sockaddr_in *) g_malloc (sizeof (struct sockaddr_in));
+
+ sd = socket (AF_INET, SOCK_STREAM, 0);
+ addr->sin_family = AF_INET;
+ addr->sin_port = g_htons (port);
+ addr->sin_addr = *(struct in_addr *) hostname->h_addr;
+
+ errno = 0;
+ if (connect (sd, (struct sockaddr *) addr, sizeof (struct sockaddr_in)) != 0)
+ {
+ msgerror = (gchar *) strerror (errno);
+ msgerror = g_locale_to_utf8 (msgerror, strlen (msgerror), NULL, NULL, NULL);
+ gnome_error_dialog_parented (_(msgerror), GTK_WINDOW (dialog));
+ g_free (addr);
+
+ return FALSE;
+ }
+ shutdown (sd, 2);
+
+ g_free (addr);
+
+ return TRUE;
+}
+
static void
activate_shell (void)
{
@@ -120,7 +155,7 @@
gchar *cmd;
const gchar *host = NULL, *user = NULL;
gchar *term_app, *parm_exec, *parm_title;
- gdouble port;
+ gint port;
gchar *geometry;
/*
@@ -128,7 +163,7 @@
* Use the default port if the checkbutton is active
* (22 for secure shell, 23 for telnet)
*/
- port = gtk_spin_button_get_value (GTK_SPIN_BUTTON (port_entry));
+ port = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (port_entry));
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (port_default))) {
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ssh_method)))
@@ -148,7 +183,10 @@
if (validate_host(host) == FALSE)
return;
-
+
+ if (check_network_status (host, port) == FALSE)
+ return;
+
/*
* Get the terminal preferences from GConf.
*/
@@ -174,14 +212,14 @@
if (strlen(term_app) >= 14 && !strncmp(term_app, "gnome-terminal", 14)) {
geometry = g_strdup_printf (
"--geometry=%dx%d",
- (gint) gtk_spin_button_get_value (GTK_SPIN_BUTTON (window_width)),
- (gint) gtk_spin_button_get_value (GTK_SPIN_BUTTON (window_height)));
+ gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (window_width)),
+ gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (window_height)));
parm_title = g_strdup_printf ("-t");
} else {
geometry = g_strdup_printf (
"-geometry %dx%d",
- (gint) gtk_spin_button_get_value (GTK_SPIN_BUTTON (window_width)),
- (gint) gtk_spin_button_get_value (GTK_SPIN_BUTTON (window_height)));
+ gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (window_width)),
+ gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (window_height)));
parm_title = g_strdup_printf ("-T");
}
@@ -193,20 +231,20 @@
return;
}
- if (port > 0.0) {
+ if (port > 0) {
cmd = g_strdup_printf (
"%s %s %s \"%s %s - Secure shell\" %s \"ssh -p %d -X %s %s\"",
- term_app, geometry, parm_title, user, host, parm_exec, (gint) port, user, host);
+ term_app, geometry, parm_title, user, host, parm_exec, port, user, host);
} else {
cmd = g_strdup_printf (
"%s %s %s \"%s %s - Secure shell\" %s \"ssh -X %s %s\"",
term_app, geometry, parm_title, user, host, parm_exec, user, host);
}
} else {
- if (port > 0.0) {
+ if (port > 0) {
cmd = g_strdup_printf (
"%s %s %s \"%s - Remote shell\" %s \"telnet %s %d\"",
- term_app, geometry, parm_title, host, parm_exec, host, (gint) port);
+ term_app, geometry, parm_title, host, parm_exec, host, port);
} else {
cmd = g_strdup_printf (
"%s %s %s \"%s - Remote shell\" %s \"telnet %s\"",
Attachment:
signature.asc
Description: Esta parte del mensaje =?ISO-8859-1?Q?est=E1?= firmada digitalmente