aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/stats/functions.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/stats/functions.c')
-rw-r--r--src/plugins/stats/functions.c178
1 files changed, 93 insertions, 85 deletions
diff --git a/src/plugins/stats/functions.c b/src/plugins/stats/functions.c
index f7faaf0e..06a9772c 100644
--- a/src/plugins/stats/functions.c
+++ b/src/plugins/stats/functions.c
@@ -121,7 +121,7 @@ static int
121getConnectedNodesStat (const void *closure, gfloat ** data) 121getConnectedNodesStat (const void *closure, gfloat ** data)
122{ 122{
123 unsigned long long val; 123 unsigned long long val;
124 124
125 if (connectionGoal == 0) 125 if (connectionGoal == 0)
126 return GNUNET_SYSERR; 126 return GNUNET_SYSERR;
127 if (GNUNET_OK != 127 if (GNUNET_OK !=
@@ -483,124 +483,132 @@ updateDaemonStatus (void *delta)
483 static GdkPixbuf *iconDisconnected; 483 static GdkPixbuf *iconDisconnected;
484 static GdkPixbuf *iconConnected; 484 static GdkPixbuf *iconConnected;
485#endif 485#endif
486 486
487 if (once) 487 if (once)
488 { 488 {
489 statusConnexionsLabel = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), 489 statusConnexionsLabel =
490 "statusConnexionsLabel"); 490 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
491 statusConnexionsPic = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), 491 "statusConnexionsLabel");
492 "statusConnexionsPic"); 492 statusConnexionsPic =
493 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
494 "statusConnexionsPic");
493#if GTK_CHECK_VERSION (2,10,0) 495#if GTK_CHECK_VERSION (2,10,0)
494 char *iconFile; 496 char *iconFile;
495 char *finalPath; 497 char *finalPath;
496 char *instDir; 498 char *instDir;
497 char *dataDir; 499 char *dataDir;
498 500
499 instDir = GNUNET_get_installation_path (GNUNET_IPK_DATADIR); 501 instDir = GNUNET_get_installation_path (GNUNET_IPK_DATADIR);
500 dataDir = g_strconcat (instDir, "/../gnunet-gtk/", NULL); 502 dataDir = g_strconcat (instDir, "/../gnunet-gtk/", NULL);
501#if MINGW 503#if MINGW
502 finalPath = GNUNET_malloc (_MAX_PATH + 1); 504 finalPath = GNUNET_malloc (_MAX_PATH + 1);
503 plibc_conv_to_win_path (dataDir, finalPath); 505 plibc_conv_to_win_path (dataDir, finalPath);
504#else 506#else
505 finalPath = GNUNET_strdup (dataDir); 507 finalPath = GNUNET_strdup (dataDir);
506#endif 508#endif
507 GNUNET_free (instDir); 509 GNUNET_free (instDir);
508 g_free (dataDir); 510 g_free (dataDir);
509 iconFile = g_strconcat (finalPath, "tray-nodaemon.png", NULL); 511 iconFile = g_strconcat (finalPath, "tray-nodaemon.png", NULL);
510 iconNoDaemon = gdk_pixbuf_new_from_file (iconFile, NULL); 512 iconNoDaemon = gdk_pixbuf_new_from_file (iconFile, NULL);
511 g_free (iconFile); 513 g_free (iconFile);
512 iconFile = g_strconcat (finalPath, "tray-disconnected.png", NULL); 514 iconFile = g_strconcat (finalPath, "tray-disconnected.png", NULL);
513 iconDisconnected = gdk_pixbuf_new_from_file (iconFile, NULL); 515 iconDisconnected = gdk_pixbuf_new_from_file (iconFile, NULL);
514 g_free (iconFile); 516 g_free (iconFile);
515 iconFile = g_strconcat (finalPath, "tray-connected.png", NULL); 517 iconFile = g_strconcat (finalPath, "tray-connected.png", NULL);
516 iconConnected = gdk_pixbuf_new_from_file (iconFile, NULL); 518 iconConnected = gdk_pixbuf_new_from_file (iconFile, NULL);
517 g_free (iconFile); 519 g_free (iconFile);
518 GNUNET_free (finalPath); 520 GNUNET_free (finalPath);
519#endif 521#endif
520 522
521 once = FALSE; 523 once = FALSE;
522 } 524 }
523 if (GNUNET_OK == GNUNET_test_daemon_running (ectx, cfg)) 525 if (GNUNET_OK == GNUNET_test_daemon_running (ectx, cfg))
524 { 526 {
525 if (GNUNET_OK != getStatValue (&connected_peers, (GNUNET_CronTime *) delta, 527 if (GNUNET_OK !=
526 NULL, "# of connected peers", GNUNET_NO)) 528 getStatValue (&connected_peers, (GNUNET_CronTime *) delta, NULL,
527 { 529 "# of connected peers", GNUNET_NO))
528 if (last_status != -1)
529 { 530 {
530 GNUNET_GTK_add_log_entry (_("WARNING: Failed to obtain connection statistics from gnunetd.\n")); 531 if (last_status != -1)
531 gtk_label_set_text (GTK_LABEL(statusConnexionsLabel), 532 {
532 _("Unknown status")); 533 GNUNET_GTK_add_log_entry (_
533 gtk_image_set_from_stock (GTK_IMAGE(statusConnexionsPic), 534 ("WARNING: Failed to obtain connection statistics from gnunetd.\n"));
534 GTK_STOCK_DIALOG_ERROR, 1); 535 gtk_label_set_text (GTK_LABEL (statusConnexionsLabel),
536 _("Unknown status"));
537 gtk_image_set_from_stock (GTK_IMAGE (statusConnexionsPic),
538 GTK_STOCK_DIALOG_ERROR, 1);
535#if GTK_CHECK_VERSION (2,10,0) 539#if GTK_CHECK_VERSION (2,10,0)
536 gtk_status_icon_set_tooltip (GNUNET_GTK_get_trayIcon (), 540 gtk_status_icon_set_tooltip (GNUNET_GTK_get_trayIcon (),
537 _("Unknown status")); 541 _("Unknown status"));
538 gtk_status_icon_set_from_pixbuf (GNUNET_GTK_get_trayIcon(), 542 gtk_status_icon_set_from_pixbuf (GNUNET_GTK_get_trayIcon (),
539 iconNoDaemon); 543 iconNoDaemon);
540#endif 544#endif
541 last_status = -1; 545 last_status = -1;
546 }
542 } 547 }
543 }
544 else if (connected_peers > 0) 548 else if (connected_peers > 0)
545 { 549 {
546 if (last_status != connected_peers) 550 if (last_status != connected_peers)
547 { 551 {
548 if (connected_peers == 1) 552 if (connected_peers == 1)
549 { 553 {
550 gtk_label_set_text (GTK_LABEL(statusConnexionsLabel), 554 gtk_label_set_text (GTK_LABEL (statusConnexionsLabel),
551 _("Connected to 1 peer")); 555 _("Connected to 1 peer"));
552#if GTK_CHECK_VERSION (2,10,0) 556#if GTK_CHECK_VERSION (2,10,0)
553 gtk_status_icon_set_tooltip (GNUNET_GTK_get_trayIcon (), 557 gtk_status_icon_set_tooltip (GNUNET_GTK_get_trayIcon (),
554 _("GNUnet - Connected to 1 peer")); 558 _
559 ("GNUnet - Connected to 1 peer"));
555#endif 560#endif
556 } 561 }
557 else 562 else
558 { 563 {
559 label = g_strdup_printf (_("Connected to %Lu peers"), 564 label = g_strdup_printf (_("Connected to %Lu peers"),
560 connected_peers); 565 connected_peers);
561 gtk_label_set_text (GTK_LABEL(statusConnexionsLabel), label); 566 gtk_label_set_text (GTK_LABEL (statusConnexionsLabel),
562 g_free (label); 567 label);
568 g_free (label);
563#if GTK_CHECK_VERSION (2,10,0) 569#if GTK_CHECK_VERSION (2,10,0)
564 label = g_strdup_printf (_("GNUnet - Connected to %Lu peers"), 570 label =
571 g_strdup_printf (_("GNUnet - Connected to %Lu peers"),
565 connected_peers); 572 connected_peers);
566 gtk_status_icon_set_tooltip (GNUNET_GTK_get_trayIcon (), label); 573 gtk_status_icon_set_tooltip (GNUNET_GTK_get_trayIcon (),
567 g_free (label); 574 label);
575 g_free (label);
568#endif 576#endif
569 } 577 }
570#if GTK_CHECK_VERSION (2,10,0) 578#if GTK_CHECK_VERSION (2,10,0)
571 gtk_status_icon_set_from_pixbuf (GNUNET_GTK_get_trayIcon(), 579 gtk_status_icon_set_from_pixbuf (GNUNET_GTK_get_trayIcon (),
572 iconConnected); 580 iconConnected);
573#endif 581#endif
574 gtk_image_set_from_stock (GTK_IMAGE(statusConnexionsPic), 582 gtk_image_set_from_stock (GTK_IMAGE (statusConnexionsPic),
575 GTK_STOCK_NETWORK, 1); 583 GTK_STOCK_NETWORK, 1);
576 last_status = connected_peers; 584 last_status = connected_peers;
577 } 585 }
578 } 586 }
579 else if (last_status != 0) 587 else if (last_status != 0)
580 { 588 {
581 gtk_label_set_markup (GTK_LABEL(statusConnexionsLabel), 589 gtk_label_set_markup (GTK_LABEL (statusConnexionsLabel),
582 _("<b>Disconnected</b>")); 590 _("<b>Disconnected</b>"));
583 gtk_image_set_from_stock (GTK_IMAGE(statusConnexionsPic), 591 gtk_image_set_from_stock (GTK_IMAGE (statusConnexionsPic),
584 GTK_STOCK_DISCONNECT, 1); 592 GTK_STOCK_DISCONNECT, 1);
585#if GTK_CHECK_VERSION (2,10,0) 593#if GTK_CHECK_VERSION (2,10,0)
586 gtk_status_icon_set_tooltip (GNUNET_GTK_get_trayIcon (), 594 gtk_status_icon_set_tooltip (GNUNET_GTK_get_trayIcon (),
587 _("GNUnet - Disconnected")); 595 _("GNUnet - Disconnected"));
588 gtk_status_icon_set_from_pixbuf (GNUNET_GTK_get_trayIcon(), 596 gtk_status_icon_set_from_pixbuf (GNUNET_GTK_get_trayIcon (),
589 iconDisconnected); 597 iconDisconnected);
590#endif 598#endif
591 last_status = 0; 599 last_status = 0;
592 } 600 }
593 } 601 }
594 else if (last_status != -2) 602 else if (last_status != -2)
595 { 603 {
596 gtk_label_set_markup (GTK_LABEL(statusConnexionsLabel), 604 gtk_label_set_markup (GTK_LABEL (statusConnexionsLabel),
597 _("<b>Daemon not running</b>")); 605 _("<b>Daemon not running</b>"));
598 gtk_image_set_from_stock (GTK_IMAGE(statusConnexionsPic), 606 gtk_image_set_from_stock (GTK_IMAGE (statusConnexionsPic),
599 GTK_STOCK_NO, 1); 607 GTK_STOCK_NO, 1);
600#if GTK_CHECK_VERSION (2,10,0) 608#if GTK_CHECK_VERSION (2,10,0)
601 gtk_status_icon_set_tooltip (GNUNET_GTK_get_trayIcon (), 609 gtk_status_icon_set_tooltip (GNUNET_GTK_get_trayIcon (),
602 _("GNUnet - Daemon not running")); 610 _("GNUnet - Daemon not running"));
603 gtk_status_icon_set_from_pixbuf (GNUNET_GTK_get_trayIcon(), 611 gtk_status_icon_set_from_pixbuf (GNUNET_GTK_get_trayIcon (),
604 iconNoDaemon); 612 iconNoDaemon);
605#endif 613#endif
606 last_status = -2; 614 last_status = -2;