[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r5839 - gnunet-gtk/src/plugins/daemon
From: |
gnunet |
Subject: |
[GNUnet-SVN] r5839 - gnunet-gtk/src/plugins/daemon |
Date: |
Sun, 9 Dec 2007 19:00:15 -0700 (MST) |
Author: grothoff
Date: 2007-12-09 19:00:15 -0700 (Sun, 09 Dec 2007)
New Revision: 5839
Modified:
gnunet-gtk/src/plugins/daemon/Makefile.am
gnunet-gtk/src/plugins/daemon/daemon.c
Log:
fixing Mantis 1299
Modified: gnunet-gtk/src/plugins/daemon/Makefile.am
===================================================================
--- gnunet-gtk/src/plugins/daemon/Makefile.am 2007-12-09 23:34:22 UTC (rev
5838)
+++ gnunet-gtk/src/plugins/daemon/Makefile.am 2007-12-10 02:00:15 UTC (rev
5839)
@@ -14,6 +14,7 @@
libgnunetgtkmodule_daemon_la_LIBADD = \
@GTK_LIBS@ @GNUNETGTK_LIBS@ \
$(top_builddir)/src/common/libgnunetgtk_common.la \
+ -lgnunetstats_api \
-lgnunetutil \
-lgnunetgetoption_api
libgnunetgtkmodule_daemon_la_LDFLAGS = \
Modified: gnunet-gtk/src/plugins/daemon/daemon.c
===================================================================
--- gnunet-gtk/src/plugins/daemon/daemon.c 2007-12-09 23:34:22 UTC (rev
5838)
+++ gnunet-gtk/src/plugins/daemon/daemon.c 2007-12-10 02:00:15 UTC (rev
5839)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2005, 2006 Christian Grothoff (and other contributing authors)
+ (C) 2005, 2006, 2007 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -28,6 +28,7 @@
#include "gnunetgtk_common.h"
#include <GNUnet/gnunet_directories.h>
#include <GNUnet/gnunet_getoption_lib.h>
+#include <GNUnet/gnunet_stats_lib.h>
#include <GNUnet/gnunet_util.h>
#include <gtk/gtk.h>
@@ -225,15 +226,56 @@
return NULL;
}
+static int
+statsProcessor (const char *optName, unsigned long long value, void *data)
+{
+ unsigned long long * ret = data;
+
+ if (0 == strcmp ("# of connected peers",
+ optName))
+ *ret = value;
+ return GNUNET_OK;
+}
+
+
static void
cronCheckDaemon (void *dummy)
{
+ static int did_warn;
int ret;
+ unsigned long long value;
+ struct GNUNET_ClientServerConnection *sock;
if (GNUNET_OK == GNUNET_test_daemon_running (ectx, cfg))
- ret = 1;
+ {
+ ret = 1;
+ value = 0;
+ sock = GNUNET_client_connection_create (ectx, cfg);
+ if ( (sock == NULL) ||
+ (GNUNET_OK !=
+ GNUNET_STATS_get_statistics (ectx, sock, &statsProcessor, &value))
)
+ {
+ GNUNET_GTK_add_log_entry (_("WARNING: Failed to obtain connection
statistics from gnunetd.\n"));
+ }
+ else
+ {
+ if (value == 0)
+ {
+ GNUNET_GTK_add_log_entry (_("WARNING: We are currently
disconnected from the P2P network!\n"));
+ did_warn = 1;
+ }
+ else if (did_warn)
+ {
+ did_warn = 0;
+ GNUNET_GTK_add_log_entry (_("We are now connected to the P2P
network.\n"));
+ }
+ }
+ GNUNET_client_connection_destroy (sock);
+ }
else
- ret = 0;
+ {
+ ret = 0;
+ }
GNUNET_GTK_save_call (&doUpdateMenus, &ret);
}
@@ -258,7 +300,7 @@
}
else
{
- GNUNET_GTK_add_log_entry (_("Launching gnunetd..."));
+ GNUNET_GTK_add_log_entry (_("Launching gnunetd...\n"));
chooser
= glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
"gnunetdconfigFileChooserButton");
@@ -266,11 +308,11 @@
GNUNET_GE_BREAK (ectx, fn != NULL);
if (GNUNET_SYSERR != GNUNET_daemon_start (ectx, cfg, fn, GNUNET_YES))
{
- GNUNET_GTK_add_log_entry (_("Launched gnunetd"));
+ GNUNET_GTK_add_log_entry (_("Launched gnunetd\n"));
}
else
{
- GNUNET_GTK_add_log_entry (_("Launching gnunetd failed"));
+ GNUNET_GTK_add_log_entry (_("Launching gnunetd failed\n"));
}
if (fn != NULL)
g_free (fn);
@@ -302,13 +344,13 @@
(NULL,
GTK_DIALOG_MODAL,
GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE, _("Error requesting shutdown of gnunetd."));
+ GTK_BUTTONS_CLOSE, _("Error requesting shutdown of gnunetd.\n"));
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
}
else
{
- GNUNET_GTK_add_log_entry (_("Terminating gnunetd..."));
+ GNUNET_GTK_add_log_entry (_("Terminating gnunetd...\n"));
}
GNUNET_client_connection_destroy (sock);
}
@@ -370,7 +412,7 @@
else
{
GNUNET_GTK_add_log_entry (_
- ("Configuration file for GNUnet daemon `%s'
does not exist! Run `gnunet-setup -d'."),
+ ("Configuration file for GNUnet daemon `%s'
does not exist! Run `gnunet-setup -d'.\n"),
daemon_config);
}
GNUNET_free (daemon_config);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r5839 - gnunet-gtk/src/plugins/daemon,
gnunet <=