Fixed "Detected Host IP" notifications.
authorshort <>
Fri, 21 May 2004 07:05:11 +0000 (07:05 +0000)
committershort <>
Fri, 21 May 2004 07:05:11 +0000 (07:05 +0000)
src/network.c
src/ui-gnome.c
src/ui-gnome.glade

index ad650b8..00592eb 100644 (file)
@@ -176,8 +176,6 @@ static gboolean client_touch_timeout(struct client *client)
        if (client==probe) {
                network_stop();
                /* Never destroy 'client' now - it has been destroyed by network_stop()! */
-               if (network_notify_hostip)
-                       (*network_notify_hostip)(0);
                }
        else {
                client_destroy(client);
@@ -577,6 +575,8 @@ err_sock_gsource_destroy:
        client_touch(probe);    /* timeout */
 
        write_daemon_running(getpid());
+       if (network_notify_hostip)
+               (*network_notify_hostip)(0);
        return TRUE;
 }
 
@@ -591,7 +591,7 @@ int errno_save;
                }
        if (daemon_pid==getpid()) {
                sock_gsource_destroy();
-               return TRUE;
+               goto ok;
                }
        errno=0;
        kill(daemon_pid,SIGKILL);
@@ -601,5 +601,8 @@ int errno_save;
                                (int)daemon_pid,strerror(errno_save)));
                return FALSE;
                }
+ok:
+       if (network_notify_hostip)
+               (*network_notify_hostip)(0);
        return TRUE;
 }
index df2d745..56d4d26 100644 (file)
@@ -38,6 +38,7 @@
 #include <libgnomeui/gnome-app-util.h>
 
 #include "network.h"
+#include "packet.h"
 
 
 /* Config: */
@@ -52,6 +53,7 @@ static GtkButton *ButtonStop;
 static GtkHBox *PortHBox;
 static GnomeAppBar *AppBar;
 static GtkEntry *PortEntry;
+static GtkEntry *HostIPEntry;
 
 
 static void state_start_stop(void)
@@ -139,6 +141,19 @@ void on_ButtonHide_clicked(GtkButton *button,gpointer user_data)
        gtk_widget_destroy(GTK_WIDGET(App));
 }
 
+static void ui_gnome_network_notify_hostip(guint32 hostip_guint32)
+{
+       if (!hostip_guint32) {
+               if (is_daemon_running()==(pid_t)-1)
+                       gtk_entry_set_text(HostIPEntry,_("(unknown; Start the daemon)"));
+               else
+                       gtk_entry_set_text(HostIPEntry,_("(unknown; detecting...)"));
+               }
+       else {
+               gtk_entry_set_text(HostIPEntry,HOSTIP_GUINT32_TO_STRING(hostip_guint32));
+               }
+}
+
 static void ui_gnome_g_log_handler(const gchar *log_domain,GLogLevelFlags log_level,const gchar *message,gpointer user_data)
 {
 GtkWidget *dialog;
@@ -170,6 +185,7 @@ gboolean ui_gnome_init(void)
        PortHBox=GTK_HBOX(lookup_widget(GTK_WIDGET(App),"PortHBox"));
        AppBar=GNOME_APPBAR(lookup_widget(GTK_WIDGET(App),"AppBar"));
        PortEntry=GTK_ENTRY(lookup_widget(GTK_WIDGET(App),"PortEntry"));
+       HostIPEntry=GTK_ENTRY(lookup_widget(GTK_WIDGET(App),"HostIPEntry"));
 
        /* ui_gnome_g_log_handler() needs 'App'. */
        g_log_set_handler(
@@ -181,11 +197,16 @@ gboolean ui_gnome_init(void)
                        ui_gnome_g_log_handler, /* log_func */
                        NULL);  /* user_data */
 
+       ui_gnome_network_notify_hostip(0);
+
        gtk_widget_show_all(GTK_WIDGET(App));
        g_timeout_add(
                        DAEMON_CHECK_INTERVAL_MS,       /* interval */
                        daemon_check_timeout_func,      /* function */
                        NULL);  /* data; unused */
+
+       network_notify_hostip=ui_gnome_network_notify_hostip;
+
        return TRUE;
 }
 
index 2f66579..e37e9e8 100644 (file)
@@ -230,7 +230,7 @@ Generally you cannot use this program in firewalled networks although try to ask
                  <property name="editable">False</property>
                  <property name="visibility">True</property>
                  <property name="max_length">0</property>
-                 <property name="text" translatable="yes">123.456.789.123</property>
+                 <property name="text" translatable="yes"></property>
                  <property name="has_frame">True</property>
                  <property name="invisible_char" translatable="yes">*</property>
                  <property name="activates_default">False</property>