gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r33091 - in gnunet-gtk: contrib src/peerinfo


From: gnunet
Subject: [GNUnet-SVN] r33091 - in gnunet-gtk: contrib src/peerinfo
Date: Wed, 16 Apr 2014 11:26:58 +0200

Author: grothoff
Date: 2014-04-16 11:26:58 +0200 (Wed, 16 Apr 2014)
New Revision: 33091

Added:
   gnunet-gtk/contrib/black.png
   gnunet-gtk/contrib/blue.png
   gnunet-gtk/contrib/purple.png
   gnunet-gtk/contrib/yellow.png
Modified:
   gnunet-gtk/contrib/Makefile.am
   gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c
Log:
use new core monitoring API to show KX status, reset states on disconnect

Modified: gnunet-gtk/contrib/Makefile.am
===================================================================
--- gnunet-gtk/contrib/Makefile.am      2014-04-16 09:18:29 UTC (rev 33090)
+++ gnunet-gtk/contrib/Makefile.am      2014-04-16 09:26:58 UTC (rev 33091)
@@ -26,6 +26,10 @@
   publishing.gif \
   red.png \
   green.png \
+  blue.png \
+  black.png \
+  yellow.png \
+  purple.png \
   setup.png setup.svg \
   fs.png fs.svg \
   statistics.png statistics.svg \
@@ -75,9 +79,9 @@
   gnunet_namestore_edit_txt.glade \
   gnunet_namestore_edit_vpn.glade \
   gnunet_conversation_gtk_about_window.glade \
-  gnunet_conversation_gtk_main_window.glade 
- 
+  gnunet_conversation_gtk_main_window.glade
 
+
 install-data-local:
        @$(NORMAL_INSTALL)
        @list='$(IMAGES)'; test -n "$(pkgpixdir)" || list=; \

Added: gnunet-gtk/contrib/black.png
===================================================================
(Binary files differ)

Index: gnunet-gtk/contrib/black.png
===================================================================
--- gnunet-gtk/contrib/black.png        2014-04-16 09:18:29 UTC (rev 33090)
+++ gnunet-gtk/contrib/black.png        2014-04-16 09:26:58 UTC (rev 33091)

Property changes on: gnunet-gtk/contrib/black.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Added: gnunet-gtk/contrib/blue.png
===================================================================
(Binary files differ)

Index: gnunet-gtk/contrib/blue.png
===================================================================
--- gnunet-gtk/contrib/blue.png 2014-04-16 09:18:29 UTC (rev 33090)
+++ gnunet-gtk/contrib/blue.png 2014-04-16 09:26:58 UTC (rev 33091)

Property changes on: gnunet-gtk/contrib/blue.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Added: gnunet-gtk/contrib/purple.png
===================================================================
(Binary files differ)

Index: gnunet-gtk/contrib/purple.png
===================================================================
--- gnunet-gtk/contrib/purple.png       2014-04-16 09:18:29 UTC (rev 33090)
+++ gnunet-gtk/contrib/purple.png       2014-04-16 09:26:58 UTC (rev 33091)

Property changes on: gnunet-gtk/contrib/purple.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Added: gnunet-gtk/contrib/yellow.png
===================================================================
(Binary files differ)

Index: gnunet-gtk/contrib/yellow.png
===================================================================
--- gnunet-gtk/contrib/yellow.png       2014-04-16 09:18:29 UTC (rev 33090)
+++ gnunet-gtk/contrib/yellow.png       2014-04-16 09:26:58 UTC (rev 33091)

Property changes on: gnunet-gtk/contrib/yellow.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Modified: gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c
===================================================================
--- gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c       2014-04-16 09:18:29 UTC 
(rev 33090)
+++ gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c       2014-04-16 09:26:58 UTC 
(rev 33091)
@@ -312,7 +312,7 @@
 static struct GNUNET_ATS_PerformanceHandle *ats;
 
 /**
- * Map of peer identities to the respective PeerInfo for our view.
+ * Map of peer identities to the respective `struct PeerInfo` for our view.
  */
 static struct GNUNET_CONTAINER_MultiPeerMap *peer2info;
 
@@ -329,7 +329,7 @@
 /**
  * Monitoring core connectivity.
  */
-static struct GNUNET_CORE_Handle *core;
+static struct GNUNET_CORE_MonitorHandle *cm;
 
 /**
  * Should gnunet-peerinfo-gtk start in tray mode?
@@ -347,6 +347,21 @@
 static GdkPixbuf *led_red;
 
 /**
+ * Black status led (error)
+ */
+static GdkPixbuf *led_black;
+
+/**
+ * Yellow status led (connecting)
+ */
+static GdkPixbuf *led_yellow;
+
+/**
+ * Blue status led (reconnecting/rekeying/special operation)
+ */
+static GdkPixbuf *led_blue;
+
+/**
  * Main window tree store.
  */
 static GtkTreeStore *ts;
@@ -487,10 +502,10 @@
     GNUNET_TRANSPORT_monitor_validation_entries_cancel (vmc);
     vmc = NULL;
   }
-  if (NULL != core)
+  if (NULL != cm)
   {
-    GNUNET_CORE_disconnect (core);
-    core = NULL;
+    GNUNET_CORE_monitor_stop (cm);
+    cm = NULL;
   }
   GNUNET_CONTAINER_multipeermap_iterate (peer2info, &free_paths, NULL);
   GNUNET_CONTAINER_multipeermap_destroy (peer2info);
@@ -690,7 +705,6 @@
                       PEERINFO_MC_PEER_IDENTITY_STRING, GNUNET_i2s (peer),
                       PEERINFO_MC_PEERINFO, info,
                       PEERINFO_MC_SHOW_FRIEND, TRUE,
-                      PEERINFO_MC_CORE_CONNECTIVITY_LED, led_red,
                       -1);
   path = gtk_tree_model_get_path (GTK_TREE_MODEL (ts), &iter);
   info->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (ts), path);
@@ -728,6 +742,33 @@
 
 
 /**
+ * ATS disconnected, remove ATS status information for all peers.
+ *
+ * @param cls NULL
+ * @param pid peer identity to reset
+ * @param value the `struct PeerInfo` for the peer
+ * @return #GNUNET_OK
+ */
+static int
+reset_ats_status (void *cls,
+                   const struct GNUNET_PeerIdentity *pid,
+                   void *value)
+{
+  struct PeerInfo *info = value;
+  GtkTreeIter iter;
+
+  get_iter_from_rr (info->rr, &iter);
+  gtk_tree_store_set (ts, &iter,
+                      PEERINFO_MC_ATS_CONNECTIVITY_LED, NULL,
+                      PEERINFO_MC_ATS_SELECTED_STATUS, FALSE,
+                     PEERINFO_MC_BANDWIDTH_IN, 0,
+                     PEERINFO_MC_BANDWIDTH_OUT, 0,
+                      -1);
+  return GNUNET_OK;
+}
+
+
+/**
  * Method called whenever a given peer has a QoS status change.
  *
  * @param cts closure
@@ -740,19 +781,28 @@
  * @param ats_count number of performance records in @a ats
  */
 static void
-status_cb (void *cts,
-          const struct GNUNET_HELLO_Address *address,
-          int address_active,
-           struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
-           struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
-           const struct GNUNET_ATS_Information *ats,
-          uint32_t ats_count)
+ats_status_cb (void *cts,
+               const struct GNUNET_HELLO_Address *address,
+               int address_active,
+               struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+               struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
+               const struct GNUNET_ATS_Information *ats,
+               uint32_t ats_count)
 {
   struct PeerInfo *info;
   struct PeerAddress *pa;
   struct PeerAddress *act;
   GtkTreeIter iter;
 
+  if (NULL == address)
+  {
+    /* state 'reset' / disconnect from service, reset everything */
+    GNUNET_CONTAINER_multipeermap_iterate (peer2info,
+                                           &reset_ats_status,
+                                           NULL);
+    return;
+  }
+
   info = get_peer_info (&address->peer);
   pa = get_address (info, address);
   pa->address_ats_active = address_active;
@@ -767,11 +817,13 @@
                      -1);
   act = NULL;
   for (pa = info->pa_head; NULL != pa; pa = pa->next)
+  {
     if (pa->address_ats_active)
     {
       GNUNET_break (NULL == act);
       act = pa;
     }
+  }
   get_iter_from_rr (info->rr, &iter);
   if (NULL == act)
   {
@@ -803,6 +855,47 @@
 
 
 /**
+ * Transport peer monitor disconnected, reset
+ * transport peer status information for all peers.
+ *
+ * @param cls NULL
+ * @param pid peer identity to reset
+ * @param value the `struct PeerInfo` for the peer
+ * @return #GNUNET_OK
+ */
+static int
+reset_transport_peer_status (void *cls,
+                             const struct GNUNET_PeerIdentity *pid,
+                             void *value)
+{
+  struct PeerInfo *info = value;
+  GtkTreeIter iter;
+  struct PeerAddress *pa;
+
+  get_iter_from_rr (info->rr, &iter);
+  gtk_tree_store_set (ts, &iter,
+                      PEERINFO_MC_NEIGHBOUR_CONNECTED_STATUS, NULL,
+                      PEERINFO_MC_NEIGHBOUR_CONNECTIVITY_TIMEOUT_AS_STRING, 
NULL,
+                      PEERINFO_MC_NEIGHBOUR_CONNECTIVITY_LED, NULL,
+                      PEERINFO_MC_NEIGHBOUR_STATE_AS_STRING, NULL,
+                      PEERINFO_MC_NEIGHBOUR_STATE_TIMEOUT_AS_STRING, NULL,
+                      -1);
+  for (pa = info->pa_head; NULL != pa; pa = pa->next)
+  {
+    get_iter_from_rr (pa->rr, &iter);
+    gtk_tree_store_set (ts, &iter,
+                        PEERINFO_MC_NEIGHBOUR_CONNECTED_STATUS, FALSE,
+                        PEERINFO_MC_NEIGHBOUR_CONNECTIVITY_TIMEOUT_AS_STRING, 
NULL,
+                        PEERINFO_MC_NEIGHBOUR_CONNECTIVITY_LED, NULL,
+                        PEERINFO_MC_NEIGHBOUR_STATE_AS_STRING, NULL,
+                        PEERINFO_MC_NEIGHBOUR_STATE_TIMEOUT_AS_STRING, NULL,
+                        -1);
+  }
+  return GNUNET_OK;
+}
+
+
+/**
  * Function to call with information about a peer
  *
  * @param cts closure
@@ -825,6 +918,15 @@
   const char *tos;
   struct PeerAddress *pa;
 
+  if (NULL == peer)
+  {
+    /* disconnect notification, reset all state */
+    GNUNET_CONTAINER_multipeermap_iterate (peer2info,
+                                           &reset_transport_peer_status,
+                                           NULL);
+    return;
+  }
+
   info = get_peer_info (peer);
   info->state = state;
   info->state_timeout = state_timeout;
@@ -849,8 +951,6 @@
                         PEERINFO_MC_NEIGHBOUR_STATE_TIMEOUT_AS_STRING, NULL,
                         -1);
   }
-  if (NULL == address)
-    return;
   pa = get_address (info, address);
   get_iter_from_rr (pa->rr, &iter);
   gtk_tree_store_set (ts, &iter,
@@ -864,6 +964,37 @@
 
 
 /**
+ * Transport address validation monitor disconnected, reset
+ * address validation status information for all peers.
+ *
+ * @param cls NULL
+ * @param pid peer identity to reset
+ * @param value the `struct PeerInfo` for the peer
+ * @return #GNUNET_OK
+ */
+static int
+reset_address_validation_status (void *cls,
+                                 const struct GNUNET_PeerIdentity *pid,
+                                 void *value)
+{
+  struct PeerInfo *info = value;
+  GtkTreeIter iter;
+  struct PeerAddress *pa;
+
+  for (pa = info->pa_head; NULL != pa; pa = pa->next)
+  {
+    get_iter_from_rr (pa->rr, &iter);
+    gtk_tree_store_set (ts, &iter,
+                        PEERINFO_MC_VALIDATION_IS_VALID, FALSE,
+                        PEERINFO_MC_VALIDATION_TIMEOUT_AS_STRING, NULL,
+                        PEERINFO_MC_VALIDATION_STATE_LED, NULL,
+                        -1);
+  }
+  return GNUNET_OK;
+}
+
+
+/**
  * Function to call with validation information about a peer
  *
  * @param cts closure
@@ -890,7 +1021,14 @@
   const char *tos;
   gboolean valid;
 
-  GNUNET_assert (NULL != peer);
+  if (NULL == peer)
+  {
+    /* disconnect notification, reset all validation state */
+    GNUNET_CONTAINER_multipeermap_iterate (peer2info,
+                                           &reset_address_validation_status,
+                                           NULL);
+    return;
+  }
   info = get_peer_info (peer);
   if (NULL == address)
   {
@@ -919,45 +1057,88 @@
 
 
 /**
- * Method called whenever a given peer connects.
+ * Core disconnected, remove CORE KX status information for all peers.
  *
- * @param cts closure
- * @param peer peer identity this notification is about
+ * @param cls NULL
+ * @param pid peer identity to reset
+ * @param value the `struct PeerInfo` for the peer
+ * @return #GNUNET_OK
  */
-static void
-handle_core_connect (void *cts,
-                    const struct GNUNET_PeerIdentity *peer)
+static int
+reset_core_status (void *cls,
+                   const struct GNUNET_PeerIdentity *pid,
+                   void *value)
 {
-  struct PeerInfo *info;
+  struct PeerInfo *info = value;
   GtkTreeIter iter;
 
-  info = get_peer_info (peer);
   get_iter_from_rr (info->rr, &iter);
   gtk_tree_store_set (ts, &iter,
-                      PEERINFO_MC_CORE_CONNECTIVITY_LED, led_green,
-                      PEERINFO_MC_CORE_CONNECTED_STATUS, TRUE,
+                      PEERINFO_MC_CORE_CONNECTIVITY_LED, NULL,
+                      PEERINFO_MC_CORE_CONNECTED_STATUS, FALSE,
                       -1);
+  return GNUNET_OK;
 }
 
 
 /**
- * Method called whenever a peer disconnects.
+ * Method called whenever CORE KX state changes for a peer.
  *
  * @param cts closure
  * @param peer peer identity this notification is about
+ * @param state current key exchange state of the peer
+ * @param timeout when does the current state expire
  */
 static void
-handle_core_disconnect (void *cts,
-                       const struct GNUNET_PeerIdentity *peer)
+handle_core_monitor_event (void *cts,
+                           const struct GNUNET_PeerIdentity *peer,
+                           enum GNUNET_CORE_KxState state,
+                           struct GNUNET_TIME_Absolute timeout)
 {
   struct PeerInfo *info;
   GtkTreeIter iter;
+  GdkPixbuf *led;
+  gboolean status;
 
+  switch (state)
+  {
+  case GNUNET_CORE_KX_STATE_DOWN:
+    led = led_black;
+    status = FALSE;
+    break;
+  case GNUNET_CORE_KX_STATE_KEY_SENT:
+    led = led_yellow;
+    status = FALSE;
+    break;
+  case GNUNET_CORE_KX_STATE_KEY_RECEIVED:
+    led = led_yellow;
+    status = FALSE;
+    break;
+  case GNUNET_CORE_KX_STATE_UP:
+    led = led_green;
+    status = FALSE;
+    break;
+  case GNUNET_CORE_KX_STATE_REKEY_SENT:
+    led = led_blue;
+    status = FALSE;
+    break;
+  case GNUNET_CORE_KX_PEER_DISCONNECT:
+    led = NULL;
+    status = FALSE;
+    break;
+  case GNUNET_CORE_KX_ITERATION_FINISHED:
+    return;
+  case GNUNET_CORE_KX_CORE_DISCONNECT:
+    GNUNET_CONTAINER_multipeermap_iterate (peer2info,
+                                           &reset_core_status,
+                                           NULL);
+    return;
+  }
   info = get_peer_info (peer);
   get_iter_from_rr (info->rr, &iter);
   gtk_tree_store_set (ts, &iter,
-                      PEERINFO_MC_CORE_CONNECTIVITY_LED, led_red,
-                      PEERINFO_MC_CORE_CONNECTED_STATUS, FALSE,
+                      PEERINFO_MC_CORE_CONNECTIVITY_LED, led,
+                      PEERINFO_MC_CORE_CONNECTED_STATUS, status,
                       -1);
 }
 
@@ -1210,6 +1391,9 @@
   cfg = get_configuration ();
   led_green = load_led ("green");
   led_red = load_led ("red");
+  led_black = load_led ("black");
+  led_yellow = load_led ("yellow");
+  led_blue = load_led ("blue");
   GNUNET_GTK_set_icon_search_path ();
   GNUNET_GTK_setup_nls ();
   can_edit_friends =
@@ -1239,14 +1423,9 @@
        FALSE);
   }
   peer2info = GNUNET_CONTAINER_multipeermap_create (256, GNUNET_NO);
-  core = GNUNET_CORE_connect (cfg,
-                             NULL,
-                             NULL,
-                             &handle_core_connect,
-                             &handle_core_disconnect,
-                             NULL, GNUNET_NO,
-                             NULL, GNUNET_NO,
-                             NULL);
+  cm = GNUNET_CORE_monitor_start (cfg,
+                                  &handle_core_monitor_event,
+                                  NULL);
   pnc = GNUNET_PEERINFO_notify (cfg,
                                GNUNET_NO,
                                &peerinfo_processor, NULL);
@@ -1263,7 +1442,7 @@
                                                     &validation_monitor_cb,
                                                     NULL);
   ats = GNUNET_ATS_performance_init (cfg,
-                                     &status_cb, NULL);
+                                     &ats_status_cb, NULL);
   tvc_core_connectivity = GTK_TREE_VIEW_COLUMN (get_object 
("GNUNET_PEERINFO_GTK_main_window_core_connectivity_treeviewcolumn"));
   tvc_ats_connectivity = GTK_TREE_VIEW_COLUMN (get_object 
("GNUNET_PEERINFO_GTK_main_window_ats_connectivity_treeviewcolumn"));
   tvc_plugin_connectivity = GTK_TREE_VIEW_COLUMN (get_object 
("GNUNET_PEERINFO_GTK_main_window_plugin_connectivity_treeviewcolumn"));




reply via email to

[Prev in Thread] Current Thread [Next in Thread]