aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2007-12-10 02:00:15 +0000
committerChristian Grothoff <christian@grothoff.org>2007-12-10 02:00:15 +0000
commitd1b156e17ce8b38ecf80bf509a5456a5428006e9 (patch)
treee93e911ac89363b19d70f6ab372c76f8aeaa2c2d
parentd8519e3d019e0368987318d6adceb9983cc435b1 (diff)
downloadgnunet-gtk-d1b156e17ce8b38ecf80bf509a5456a5428006e9.tar.gz
gnunet-gtk-d1b156e17ce8b38ecf80bf509a5456a5428006e9.zip
fixing Mantis 1299
-rw-r--r--src/plugins/daemon/Makefile.am1
-rw-r--r--src/plugins/daemon/daemon.c60
2 files changed, 52 insertions, 9 deletions
diff --git a/src/plugins/daemon/Makefile.am b/src/plugins/daemon/Makefile.am
index 57697a65..e2379ff5 100644
--- a/src/plugins/daemon/Makefile.am
+++ b/src/plugins/daemon/Makefile.am
@@ -14,6 +14,7 @@ libgnunetgtkmodule_daemon_la_SOURCES = \
14libgnunetgtkmodule_daemon_la_LIBADD = \ 14libgnunetgtkmodule_daemon_la_LIBADD = \
15 @GTK_LIBS@ @GNUNETGTK_LIBS@ \ 15 @GTK_LIBS@ @GNUNETGTK_LIBS@ \
16 $(top_builddir)/src/common/libgnunetgtk_common.la \ 16 $(top_builddir)/src/common/libgnunetgtk_common.la \
17 -lgnunetstats_api \
17 -lgnunetutil \ 18 -lgnunetutil \
18 -lgnunetgetoption_api 19 -lgnunetgetoption_api
19libgnunetgtkmodule_daemon_la_LDFLAGS = \ 20libgnunetgtkmodule_daemon_la_LDFLAGS = \
diff --git a/src/plugins/daemon/daemon.c b/src/plugins/daemon/daemon.c
index a8bc1cf8..cf8b4f43 100644
--- a/src/plugins/daemon/daemon.c
+++ b/src/plugins/daemon/daemon.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2005, 2006 Christian Grothoff (and other contributing authors) 3 (C) 2005, 2006, 2007 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -28,6 +28,7 @@
28#include "gnunetgtk_common.h" 28#include "gnunetgtk_common.h"
29#include <GNUnet/gnunet_directories.h> 29#include <GNUnet/gnunet_directories.h>
30#include <GNUnet/gnunet_getoption_lib.h> 30#include <GNUnet/gnunet_getoption_lib.h>
31#include <GNUnet/gnunet_stats_lib.h>
31#include <GNUnet/gnunet_util.h> 32#include <GNUnet/gnunet_util.h>
32#include <gtk/gtk.h> 33#include <gtk/gtk.h>
33 34
@@ -225,15 +226,56 @@ doUpdateMenus (void *arg)
225 return NULL; 226 return NULL;
226} 227}
227 228
229static int
230statsProcessor (const char *optName, unsigned long long value, void *data)
231{
232 unsigned long long * ret = data;
233
234 if (0 == strcmp ("# of connected peers",
235 optName))
236 *ret = value;
237 return GNUNET_OK;
238}
239
240
228static void 241static void
229cronCheckDaemon (void *dummy) 242cronCheckDaemon (void *dummy)
230{ 243{
244 static int did_warn;
231 int ret; 245 int ret;
246 unsigned long long value;
247 struct GNUNET_ClientServerConnection *sock;
232 248
233 if (GNUNET_OK == GNUNET_test_daemon_running (ectx, cfg)) 249 if (GNUNET_OK == GNUNET_test_daemon_running (ectx, cfg))
234 ret = 1; 250 {
251 ret = 1;
252 value = 0;
253 sock = GNUNET_client_connection_create (ectx, cfg);
254 if ( (sock == NULL) ||
255 (GNUNET_OK !=
256 GNUNET_STATS_get_statistics (ectx, sock, &statsProcessor, &value)) )
257 {
258 GNUNET_GTK_add_log_entry (_("WARNING: Failed to obtain connection statistics from gnunetd.\n"));
259 }
260 else
261 {
262 if (value == 0)
263 {
264 GNUNET_GTK_add_log_entry (_("WARNING: We are currently disconnected from the P2P network!\n"));
265 did_warn = 1;
266 }
267 else if (did_warn)
268 {
269 did_warn = 0;
270 GNUNET_GTK_add_log_entry (_("We are now connected to the P2P network.\n"));
271 }
272 }
273 GNUNET_client_connection_destroy (sock);
274 }
235 else 275 else
236 ret = 0; 276 {
277 ret = 0;
278 }
237 GNUNET_GTK_save_call (&doUpdateMenus, &ret); 279 GNUNET_GTK_save_call (&doUpdateMenus, &ret);
238} 280}
239 281
@@ -258,7 +300,7 @@ on_startDaemon_clicked_daemon (GtkWidget * widget, gpointer data)
258 } 300 }
259 else 301 else
260 { 302 {
261 GNUNET_GTK_add_log_entry (_("Launching gnunetd...")); 303 GNUNET_GTK_add_log_entry (_("Launching gnunetd...\n"));
262 chooser 304 chooser
263 = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), 305 = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
264 "gnunetdconfigFileChooserButton"); 306 "gnunetdconfigFileChooserButton");
@@ -266,11 +308,11 @@ on_startDaemon_clicked_daemon (GtkWidget * widget, gpointer data)
266 GNUNET_GE_BREAK (ectx, fn != NULL); 308 GNUNET_GE_BREAK (ectx, fn != NULL);
267 if (GNUNET_SYSERR != GNUNET_daemon_start (ectx, cfg, fn, GNUNET_YES)) 309 if (GNUNET_SYSERR != GNUNET_daemon_start (ectx, cfg, fn, GNUNET_YES))
268 { 310 {
269 GNUNET_GTK_add_log_entry (_("Launched gnunetd")); 311 GNUNET_GTK_add_log_entry (_("Launched gnunetd\n"));
270 } 312 }
271 else 313 else
272 { 314 {
273 GNUNET_GTK_add_log_entry (_("Launching gnunetd failed")); 315 GNUNET_GTK_add_log_entry (_("Launching gnunetd failed\n"));
274 } 316 }
275 if (fn != NULL) 317 if (fn != NULL)
276 g_free (fn); 318 g_free (fn);
@@ -302,13 +344,13 @@ on_stopDaemon_clicked_daemon (GtkWidget * widget, gpointer data)
302 (NULL, 344 (NULL,
303 GTK_DIALOG_MODAL, 345 GTK_DIALOG_MODAL,
304 GTK_MESSAGE_ERROR, 346 GTK_MESSAGE_ERROR,
305 GTK_BUTTONS_CLOSE, _("Error requesting shutdown of gnunetd.")); 347 GTK_BUTTONS_CLOSE, _("Error requesting shutdown of gnunetd.\n"));
306 gtk_dialog_run (GTK_DIALOG (dialog)); 348 gtk_dialog_run (GTK_DIALOG (dialog));
307 gtk_widget_destroy (dialog); 349 gtk_widget_destroy (dialog);
308 } 350 }
309 else 351 else
310 { 352 {
311 GNUNET_GTK_add_log_entry (_("Terminating gnunetd...")); 353 GNUNET_GTK_add_log_entry (_("Terminating gnunetd...\n"));
312 } 354 }
313 GNUNET_client_connection_destroy (sock); 355 GNUNET_client_connection_destroy (sock);
314 } 356 }
@@ -370,7 +412,7 @@ init_daemon (struct GNUNET_GE_Context *e, struct GNUNET_GC_Configuration *c)
370 else 412 else
371 { 413 {
372 GNUNET_GTK_add_log_entry (_ 414 GNUNET_GTK_add_log_entry (_
373 ("Configuration file for GNUnet daemon `%s' does not exist! Run `gnunet-setup -d'."), 415 ("Configuration file for GNUnet daemon `%s' does not exist! Run `gnunet-setup -d'.\n"),
374 daemon_config); 416 daemon_config);
375 } 417 }
376 GNUNET_free (daemon_config); 418 GNUNET_free (daemon_config);