gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r31850 - in gnunet-gtk: contrib src/peerinfo
Date: Thu, 9 Jan 2014 10:02:36 +0100

Author: grothoff
Date: 2014-01-09 10:02:36 +0100 (Thu, 09 Jan 2014)
New Revision: 31850

Modified:
   gnunet-gtk/contrib/gnunet_peerinfo_gtk_main_window.glade
   gnunet-gtk/src/peerinfo/Makefile.am
   gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c
Log:
-towards improved peerinfo data visualization with ats/transport/core state 
machines

Modified: gnunet-gtk/contrib/gnunet_peerinfo_gtk_main_window.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_peerinfo_gtk_main_window.glade    2014-01-09 
08:48:54 UTC (rev 31849)
+++ gnunet-gtk/contrib/gnunet_peerinfo_gtk_main_window.glade    2014-01-09 
09:02:36 UTC (rev 31850)
@@ -2,12 +2,34 @@
 <interface>
   <requires lib="gtk+" version="2.20"/>
   <!-- interface-naming-policy project-wide -->
-  <object class="GtkListStore" id="GNUNET_PEERINFO_GTK_list_store">
+  <object class="GtkAdjustment" id="adjustment4">
+    <property name="upper">100</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+    <property name="page_size">10</property>
+  </object>
+  <object class="GtkImage" id="connected_image_core">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="tooltip_text" translatable="yes">CORE</property>
+    <property name="stock">gtk-connect</property>
+  </object>
+  <object class="GtkImage" id="connected_image_neighbours">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="tooltip_text" translatable="yes">TRANSPORT</property>
+    <property name="stock">gtk-connect</property>
+  </object>
+  <object class="GtkImage" id="connected_image_plugin">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="tooltip_text" translatable="yes">PLUGIN</property>
+    <property name="stock">gtk-connect</property>
+  </object>
+  <object class="GtkTreeStore" id="GNUNET_PEERINFO_GTK_tree_store">
     <columns>
       <!-- column-name peer_identity -->
       <column type="gchararray"/>
-      <!-- column-name number_of_known_addresses -->
-      <column type="guint"/>
       <!-- column-name country_name -->
       <column type="gchararray"/>
       <!-- column-name country_flag -->
@@ -16,18 +38,66 @@
       <column type="guint"/>
       <!-- column-name bandwidth_out -->
       <column type="guint"/>
-      <!-- column-name addresses -->
-      <column type="gchararray"/>
-      <!-- column-name connectivity_led -->
+      <!-- column-name ats_connectivity_led -->
       <column type="GdkPixbuf"/>
-      <!-- column-name connected_status -->
+      <!-- column-name ats_selected_status -->
       <column type="gboolean"/>
+      <!-- column-name core_connectivity_led -->
+      <column type="GdkPixbuf"/>
+      <!-- column-name core_connected_status -->
+      <column type="gboolean"/>
       <!-- column-name is_friend -->
       <column type="gboolean"/>
       <!-- column-name peerinfo -->
       <column type="gpointer"/>
+      <!-- column-name plugin_name -->
+      <column type="gchararray"/>
+      <!-- column-name address_as_string -->
+      <column type="gchararray"/>
+      <!-- column-name neighbour_connectivity_led -->
+      <column type="GdkPixbuf"/>
+      <!-- column-name neighbour_connected_status -->
+      <column type="gboolean"/>
+      <!-- column-name neighbour_connectivity_timeout_as_string -->
+      <column type="gchararray"/>
+      <!-- column-name transport_neighbour_state_as_string -->
+      <column type="gchararray"/>
+      <!-- column-name transport_neighbour_state_timeout_as_string -->
+      <column type="gchararray"/>
+      <!-- column-name transport_validation_state_led -->
+      <column type="GdkPixbuf"/>
+      <!-- column-name transport_validation_is_valid -->
+      <column type="gboolean"/>
+      <!-- column-name transport_validation_timeout_as_string -->
+      <column type="gchararray"/>
+      <!-- column-name plugin_connectivity_led -->
+      <column type="GdkPixbuf"/>
+      <!-- column-name plugin_connectivity_status -->
+      <column type="gboolean"/>
+      <!-- column-name plugin_connectivity_timeout_as_string -->
+      <column type="gchararray"/>
+      <!-- column-name show_friend -->
+      <column type="gboolean"/>
     </columns>
   </object>
+  <object class="GtkAdjustment" id="adjustment3">
+    <property name="upper">100</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+    <property name="page_size">10</property>
+  </object>
+  <object class="GtkImage" id="connected_image_ats">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="tooltip_text" translatable="yes">ATS</property>
+    <property name="stock">gtk-connect</property>
+  </object>
+  <object class="GtkImage" id="validated_image">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="tooltip_text" translatable="yes">Address valid?</property>
+    <property name="stock">gtk-dialog-authentication</property>
+  </object>
   <object class="GtkWindow" id="GNUNET_PEERINFO_GTK_main_window">
     <property name="can_focus">False</property>
     <property name="title" translatable="yes">gnunet-peerinfo-gtk</property>
@@ -46,7 +116,6 @@
             <property name="can_focus">False</property>
             <child>
               <object class="GtkMenuItem" 
id="GNUNET_PEERINFO_GTK_main_menu_help">
-                <property name="use_action_appearance">False</property>
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="label" translatable="yes">_Help</property>
@@ -58,7 +127,6 @@
                     <child>
                       <object class="GtkImageMenuItem" 
id="GNUNET_PEERINFO_GTK_main_menu_help_about">
                         <property name="label">gtk-about</property>
-                        <property name="use_action_appearance">False</property>
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="tooltip_text" 
translatable="yes">Display information about this version of 
gnunet-peerinfo-gtk</property>
@@ -91,7 +159,7 @@
               <object class="GtkTreeView" 
id="GNUNET_PEERINFO_GTK_main_window_treeview">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property 
name="model">GNUNET_PEERINFO_GTK_list_store</property>
+                <property 
name="model">GNUNET_PEERINFO_GTK_tree_store</property>
                 <property name="hadjustment">adjustment3</property>
                 <property name="vadjustment">adjustment4</property>
                 <property name="reorderable">True</property>
@@ -127,6 +195,7 @@
                         <signal name="toggled" 
handler="GNUNET_PEERINFO_GTK_main_window_friends_cellrenderertoggle_toggled_cb" 
swapped="no"/>
                       </object>
                       <attributes>
+                        <attribute name="visible">24</attribute>
                         <attribute name="active">9</attribute>
                       </attributes>
                     </child>
@@ -136,12 +205,12 @@
                   <object class="GtkTreeViewColumn" 
id="GNUNET_PEERINFO_GTK_main_window_connectivity_treeviewcolumn">
                     <property name="spacing">2</property>
                     <property name="sizing">autosize</property>
-                    <property name="widget">connected_image</property>
+                    <property name="widget">connected_image_core</property>
                     <property name="reorderable">True</property>
                     <property name="sort_indicator">True</property>
                     <property name="sort_column_id">8</property>
                     <child>
-                      <object class="GtkCellRendererPixbuf" 
id="GNUNET_PEERINFO_GTK_main_window_led_cellrendererpixbuf"/>
+                      <object class="GtkCellRendererPixbuf" 
id="GNUNET_PEERINFO_GTK_main_window_core_led_cellrendererpixbuf"/>
                       <attributes>
                         <attribute name="pixbuf">7</attribute>
                       </attributes>
@@ -149,6 +218,91 @@
                   </object>
                 </child>
                 <child>
+                  <object class="GtkTreeViewColumn" 
id="GNUNET_PEERINFO_GTK_main_window_plugin_treeviewcolumn">
+                    <property name="widget">connected_image_plugin</property>
+                    <property name="reorderable">True</property>
+                    <property name="sort_indicator">True</property>
+                    <property name="sort_column_id">22</property>
+                    <child>
+                      <object class="GtkCellRendererPixbuf" 
id="GNUNET_PEERINFO_GTK_main_window_plugin_led_cellrendererpixbuf"/>
+                      <attributes>
+                        <attribute name="pixbuf">21</attribute>
+                      </attributes>
+                    </child>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkTreeViewColumn" 
id="GNUNET_PEERINFO_GTK_main_window_core_timeout_treeviewcolumn">
+                    <property name="widget">connected_image_ats</property>
+                    <child>
+                      <object class="GtkCellRendererPixbuf" 
id="GNUNET_PEERINFO_GTK_main_window_ats_led_cellrendererpixbuf"/>
+                      <attributes>
+                        <attribute name="visible">6</attribute>
+                        <attribute name="pixbuf">5</attribute>
+                      </attributes>
+                    </child>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkTreeViewColumn" 
id="GNUNET_PEERINFO_GTK_main_window_transport_led_treeviewcolumn">
+                    <property 
name="widget">connected_image_neighbours</property>
+                    <property name="reorderable">True</property>
+                    <property name="sort_indicator">True</property>
+                    <property name="sort_column_id">14</property>
+                    <child>
+                      <object class="GtkCellRendererPixbuf" 
id="GNUNET_PEERINFO_GTK_main_window_transport_led_cellrendererpixbuf"/>
+                      <attributes>
+                        <attribute name="pixbuf">13</attribute>
+                      </attributes>
+                    </child>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkTreeViewColumn" 
id="GNUNET_PEERINFO_GTK_main_window_validation_led_treeviewcolumn">
+                    <property name="widget">validated_image</property>
+                    <property name="reorderable">True</property>
+                    <property name="sort_indicator">True</property>
+                    <property name="sort_column_id">19</property>
+                    <child>
+                      <object class="GtkCellRendererPixbuf" 
id="GNUNET_PEERINFO_GTK_main_window_valdiation_led_cellrendererpixbuf"/>
+                      <attributes>
+                        <attribute name="pixbuf">18</attribute>
+                      </attributes>
+                    </child>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkTreeViewColumn" 
id="GNUNET_PEERINFO_GTK_main_window_country_column">
+                    <property name="sizing">autosize</property>
+                    <property name="title">Country</property>
+                    <property name="clickable">True</property>
+                    <property name="reorderable">True</property>
+                    <property name="sort_indicator">True</property>
+                    <property name="sort_column_id">2</property>
+                    <child>
+                      <object class="GtkCellRendererPixbuf" 
id="GNUNET_PEERINFO_GTK_main_window_country_renderer"/>
+                      <attributes>
+                        <attribute name="pixbuf">3</attribute>
+                      </attributes>
+                    </child>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkTreeViewColumn" 
id="GNUNET_PEERINFO_GTK_main_window_address_treeviewcolumn">
+                    <property name="sizing">autosize</property>
+                    <property name="title">Address</property>
+                    <property name="expand">True</property>
+                    <property name="clickable">True</property>
+                    <property name="sort_column_id">12</property>
+                    <child>
+                      <object class="GtkCellRendererText" 
id="GNUNET_PEERINFO_GTK_main_window_address_cellrenderertext"/>
+                      <attributes>
+                        <attribute name="text">12</attribute>
+                      </attributes>
+                    </child>
+                  </object>
+                </child>
+                <child>
                   <object class="GtkTreeViewColumn" 
id="GNUNET_PEERINFO_GTK_main_window_bandwidth_column">
                     <property name="title">In</property>
                     <property name="clickable">True</property>
@@ -179,32 +333,27 @@
                   </object>
                 </child>
                 <child>
-                  <object class="GtkTreeViewColumn" 
id="GNUNET_PEERINFO_GTK_main_window_country_column">
-                    <property name="sizing">autosize</property>
-                    <property name="title">Country</property>
-                    <property name="clickable">True</property>
-                    <property name="reorderable">True</property>
-                    <property name="sort_indicator">True</property>
-                    <property name="sort_column_id">2</property>
+                  <object class="GtkTreeViewColumn" 
id="GNUNET_PEERINFO_GTK_main_window_plugin_name_treeviewcolumn">
+                    <property name="title" translatable="yes">Plugin</property>
                     <child>
-                      <object class="GtkCellRendererPixbuf" 
id="GNUNET_PEERINFO_GTK_main_window_country_renderer"/>
+                      <object class="GtkCellRendererText" 
id="cellrenderertext1"/>
                       <attributes>
-                        <attribute name="pixbuf">3</attribute>
+                        <attribute name="text">11</attribute>
                       </attributes>
                     </child>
                   </object>
                 </child>
                 <child>
-                  <object class="GtkTreeViewColumn" 
id="GNUNET_PEERINFO_GTK_main_window_address_treeviewcolumn">
+                  <object class="GtkTreeViewColumn" id="treeviewcolumn1">
                     <property name="sizing">autosize</property>
-                    <property name="title">Addresses</property>
-                    <property name="expand">True</property>
-                    <property name="clickable">True</property>
-                    <property name="sort_column_id">6</property>
+                    <property name="title" translatable="yes">State</property>
+                    <property name="reorderable">True</property>
+                    <property name="sort_indicator">True</property>
+                    <property name="sort_column_id">16</property>
                     <child>
-                      <object class="GtkCellRendererText" 
id="GNUNET_PEERINFO_GTK_main_window_addresses_cellrenderertext"/>
+                      <object class="GtkCellRendererText" 
id="cellrenderertext2"/>
                       <attributes>
-                        <attribute name="text">6</attribute>
+                        <attribute name="text">16</attribute>
                       </attributes>
                     </child>
                   </object>
@@ -221,21 +370,4 @@
       </object>
     </child>
   </object>
-  <object class="GtkAdjustment" id="adjustment3">
-    <property name="upper">100</property>
-    <property name="step_increment">1</property>
-    <property name="page_increment">10</property>
-    <property name="page_size">10</property>
-  </object>
-  <object class="GtkAdjustment" id="adjustment4">
-    <property name="upper">100</property>
-    <property name="step_increment">1</property>
-    <property name="page_increment">10</property>
-    <property name="page_size">10</property>
-  </object>
-  <object class="GtkImage" id="connected_image">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <property name="stock">gtk-connect</property>
-  </object>
 </interface>

Modified: gnunet-gtk/src/peerinfo/Makefile.am
===================================================================
--- gnunet-gtk/src/peerinfo/Makefile.am 2014-01-09 08:48:54 UTC (rev 31849)
+++ gnunet-gtk/src/peerinfo/Makefile.am 2014-01-09 09:02:36 UTC (rev 31850)
@@ -18,7 +18,7 @@
   $(top_builddir)/src/lib/libgnunetgtk.la \
   @GTK_LIBS@ \
   @GLADE_LIBS@ @GNUNET_LIBS@  @unique_LIBS@ \
-  -lgnunetutil -lgnunetpeerinfo -lgnunettransport -lgnunetats -lgnunetfriends \
+  -lgnunetutil -lgnunetpeerinfo -lgnunettransport -lgnunetats -lgnunetcore 
-lgnunetfriends \
   $(INTLLIBS)
 gnunet_peerinfo_gtk_LDFLAGS = \
   -export-dynamic

Modified: gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c
===================================================================
--- gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c       2014-01-09 08:48:54 UTC 
(rev 31849)
+++ gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c       2014-01-09 09:02:36 UTC 
(rev 31850)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2010, 2012, 2013 Christian Grothoff (and other contributing authors)
+     (C) 2010-2014 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
@@ -27,6 +27,7 @@
 #include <gnunet/gnunet_peerinfo_service.h>
 #include <gnunet/gnunet_transport_service.h>
 #include <gnunet/gnunet_ats_service.h>
+#include <gnunet/gnunet_core_service.h>
 #include <gnunet/gnunet_friends_lib.h>
 #include "gnunet-peerinfo-gtk-flags.h"
 
@@ -46,58 +47,168 @@
   PEERINFO_MC_PEER_IDENTITY_STRING = 0,
 
   /**
+   * A gchararray
+   */
+  PEERINFO_MC_COUNTRY_NAME = 1,
+
+  /**
+   * A GdkPixbuf
+   */
+  PEERINFO_MC_COUNTRY_FLAG = 2,
+
+  /**
    * A guint
    */
-  PEERINFO_MC_NUMBER_OF_ADDRESSES = 1,
+  PEERINFO_MC_BANDWIDTH_IN = 3,
 
   /**
+   * A guint
+   */
+  PEERINFO_MC_BANDWIDTH_OUT = 4,
+
+  /**
+   * A GdkPixbuf
+   */
+  PEERINFO_MC_ATS_CONNECTIVITY_LED = 5,
+
+  /**
+   * A gboolean
+   */
+  PEERINFO_MC_ATS_SELECTED_STATUS = 6,
+
+  /**
+   * A GdkPixbuf
+   */
+  PEERINFO_MC_CORE_CONNECTIVITY_LED = 7,
+
+  /**
+   * A gboolean
+   */
+  PEERINFO_MC_CORE_CONNECTED_STATUS = 8,
+
+  /**
+   * A gboolean
+   */
+  PEERINFO_MC_IS_FRIEND = 9,
+
+  /**
+   * A `struct PeerInfo *`
+   */
+  PEERINFO_MC_PEERINFO = 10,
+
+  /**
    * A gchararray
    */
-  PEERINFO_MC_COUNTRY_NAME = 2,
+  PEERINFO_MC_PLUGIN_NAME = 11,
 
   /**
+   * A gchararray
+   */
+  PEERINFO_MC_ADDRESS_AS_STRING = 12,
+
+  /**
    * A GdkPixbuf
    */
-  PEERINFO_MC_COUNTRY_FLAG = 3,
+  PEERINFO_MC_NEIGHBOUR_CONNECTIVITY_LED = 13,
 
   /**
-   * A guint64
+   * A gboolean
    */
-  PEERINFO_MC_BANDWIDTH_IN = 4,
+  PEERINFO_MC_NEIGHBOUR_CONNECTED_STATUS = 14,
 
   /**
-   * A guint64
+   * A gchararray
    */
-  PEERINFO_MC_BANDWIDTH_OUT = 5,
+  PEERINFO_MC_NEIGHBOUR_CONNECTIVITY_TIMEOUT_AS_STRING = 15,
 
   /**
    * A gchararray
    */
-  PEERINFO_MC_ADDRESS_AS_STRING = 6,
+  PEERINFO_MC_NEIGHBOUR_STATE_AS_STRING = 16,
 
   /**
+   * A gchararray
+   */
+  PEERINFO_MC_NEIGHBOUR_STATE_TIMEOUT_AS_STRING = 17,
+
+  /**
    * A GdkPixbuf
    */
-  PEERINFO_MC_CONNECTIVITY_LED = 7,
+  PEERINFO_MC_VALIDATION_STATE_LED = 18,
 
   /**
    * A gboolean
    */
-  PEERINFO_MC_CONNECTED_STATUS = 8,
+  PEERINFO_MC_VALIDATION_IS_VALID = 19,
 
   /**
+   * A gchararray
+   */
+  PEERINFO_MC_VALIDATION_TIMEOUT_AS_STRING = 20,
+
+  /**
    * A gboolean
    */
-  PEERINFO_MC_IS_FRIEND = 9,
+  PEERINFO_MC_PLUGIN_CONNECTIVITY_LED = 21,
 
   /**
-   * A `struct PeerInfo *`
+   * A gboolean
    */
-  PEERINFO_MC_PEERINFO = 10
+  PEERINFO_MC_PLUGIN_CONNECTIVITY_STATUS = 22,
+
+  /**
+   * A gchararray
+   */
+  PEERINFO_MC_PLUGIN_CONNECTIVITY_TIMEOUT_AS_STRING = 23,
+
+  /**
+   * A gboolean
+   */
+  PEERINFO_MC_SHOW_FRIEND = 24
+
 };
 
 
 /**
+ * Information about an address of the peer.
+ */
+struct PeerAddress
+{
+
+  /**
+   * DLL.
+   */ 
+  struct PeerAddress *next;
+
+  /**
+   * DLL.
+   */ 
+  struct PeerAddress *prev;
+
+  /**
+   * Reference to the peer in the view.
+   */
+  GtkTreeRowReference *rr;
+
+  /**
+   * Handle for address to string conversion.
+   */
+  struct GNUNET_TRANSPORT_AddressToStringContext *tos;
+
+  /**
+   * Binary address, allocated at the end of the struct.
+   */
+  const void *addr;
+
+  /**
+   * Number of bytes in @e addr.
+   */
+  size_t addr_len;
+
+};
+
+
+/**
  * Information we track for each peer outside of the model.
  */
 struct PeerInfo
@@ -113,19 +224,20 @@
   struct GNUNET_TRANSPORT_PeerIterateContext *palc;
 
   /**
-   * Handle for address to string conversion.
-   */
-  struct GNUNET_TRANSPORT_AddressToStringContext *tos;
-
-  /**
    * Identity of the peer for this entry.
    */
   struct GNUNET_PeerIdentity pid;
 
   /**
-   * Did we get any address?
-   */
-  int got_address;
+   * Head of DLL with addresses of this peer.
+   */ 
+  struct PeerAddress *pa_head;
+
+  /**
+   * Tail of DLL with addresses of this peer.
+   */ 
+  struct PeerAddress *pa_tail;
+
 };
 
 
@@ -150,6 +262,21 @@
 static struct GNUNET_CONTAINER_MultiPeerMap *peer2info;
 
 /**
+ * Monitoring transport neighbours
+ */
+static struct GNUNET_TRANSPORT_PeerMonitoringContext *pmc;
+
+/**
+ * Monitoring transport validation operations.
+ */
+static struct GNUNET_TRANSPORT_ValidationMonitoringContext *vmc;
+
+/**
+ * Monitoring core connectivity.
+ */
+static struct GNUNET_CORE_Handle *core;
+
+/**
  * Should gnunet-peerinfo-gtk start in tray mode?
  */
 static int tray_only;
@@ -204,12 +331,12 @@
 
 
 /**
- * Function called on each entry in the 'peer2info' map
+ * Function called on each entry in the #peer2info map
  * to free the associated path.
  *
  * @param cls unused
  * @param key peer identity
- * @param value the 'struct PeerInfo'
+ * @param value the `struct PeerInfo`
  * @return #GNUNET_OK (continue to iterate)
  */
 static int
@@ -218,16 +345,25 @@
            void *value)
 {
   struct PeerInfo *info = value;
+  struct PeerAddress *pa;
 
   if (NULL != info->palc)
   {
     GNUNET_TRANSPORT_peer_get_active_addresses_cancel (info->palc);
     info->palc = NULL;
   }
-  if (NULL != info->tos)
+  while (NULL != (pa = info->pa_head))
   {
-    GNUNET_TRANSPORT_address_to_string_cancel (info->tos);
-    info->tos = NULL;
+    GNUNET_CONTAINER_DLL_remove (info->pa_head,
+                                info->pa_tail,
+                                pa);
+    if (NULL != pa->tos)
+    {
+      GNUNET_TRANSPORT_address_to_string_cancel (pa->tos);
+      pa->tos = NULL;
+    } 
+    gtk_tree_row_reference_free (pa->rr);
+    GNUNET_free (pa);
   }
   gtk_tree_row_reference_free (info->rr);
   GNUNET_free (info);
@@ -242,7 +378,8 @@
  * @param tc scheduler context, unused
  */
 static void
-shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+shutdown_task (void *cls, 
+              const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   GNUNET_GTK_tray_icon_destroy ();
   GNUNET_GTK_main_loop_quit (ml);
@@ -257,6 +394,21 @@
     GNUNET_ATS_performance_done (ats);
     ats = NULL;
   }
+  if (NULL != pmc)
+  {
+    GNUNET_TRANSPORT_monitor_peers_cancel (pmc);
+    pmc = NULL;
+  }
+  if (NULL != vmc)
+  {
+    GNUNET_TRANSPORT_monitor_validation_entries_cancel (vmc);
+    vmc = NULL;
+  }
+  if (NULL != core)
+  {
+    GNUNET_CORE_disconnect (core);
+    core = NULL;
+  }
   GNUNET_CONTAINER_multipeermap_iterate (peer2info, &free_paths, NULL);
   GNUNET_CONTAINER_multipeermap_destroy (peer2info);
   peer2info = NULL;
@@ -264,43 +416,32 @@
 }
 
 
-
 /**
  * Function to call with the text format of an address
  *
- * @param cls the 'struct PeerInfo' for which this is a valid address
+ * @param cls the `struct PeerAddress` for the address
  * @param address address as a string, NULL on error
  */
 static void
-peer_address_string_cb (void *cls, const char *address)
+peer_address_string_cb (void *cls,
+                       const char *address)
 {
-  struct PeerInfo *info = cls;
+  struct PeerAddress *pa = cls;
   GtkTreeIter iter;
   GtkTreePath *path;
   char *country;
   const char *colon;
   const char *dot;
 
-  path = gtk_tree_row_reference_get_path (info->rr);
-  GNUNET_assert (NULL != path);
-  GNUNET_assert (TRUE == gtk_tree_model_get_iter (GTK_TREE_MODEL (ls), &iter, 
path));
-  gtk_tree_path_free (path);
   if (NULL == address)
   {
-    /* error */
-    if (GNUNET_NO == info->got_address)
-      gtk_list_store_set (ls, &iter,
-                         PEERINFO_MC_NUMBER_OF_ADDRESSES, (guint) 1,
-                         PEERINFO_MC_COUNTRY_NAME, NULL,
-                         PEERINFO_MC_COUNTRY_FLAG, NULL,
-                         PEERINFO_MC_ADDRESS_AS_STRING, "<no address>",
-                         PEERINFO_MC_CONNECTIVITY_LED, led_green,
-                         PEERINFO_MC_CONNECTED_STATUS, TRUE,
-                         -1);
     info->tos = NULL;
     return;
   }
-  /* last address, store information in model */
+  path = gtk_tree_row_reference_get_path (info->rr);
+  GNUNET_assert (NULL != path);
+  GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (ls), &iter, path));
+  gtk_tree_path_free (path);
   country = NULL;
   colon = strstr (address, ":");
   if (NULL != colon)
@@ -312,15 +453,11 @@
       country = GNUNET_strndup (&dot[1], (colon - dot) - 1);
   }
   gtk_list_store_set (ls, &iter,
-                     PEERINFO_MC_NUMBER_OF_ADDRESSES, 1,
                      PEERINFO_MC_COUNTRY_NAME, country,
                      PEERINFO_MC_COUNTRY_FLAG, GNUNET_PEERINFO_GTK_get_flag 
(country),
                      PEERINFO_MC_ADDRESS_AS_STRING, address,
-                     PEERINFO_MC_CONNECTIVITY_LED, led_green,
-                     PEERINFO_MC_CONNECTED_STATUS, TRUE,
                      -1);
   GNUNET_free_non_null (country);
-  info->got_address = GNUNET_YES;
 }
 
 
@@ -337,36 +474,36 @@
                  const struct GNUNET_HELLO_Address *address)
 {
   struct PeerInfo *info = cls;
+  struct PeerAddress *pa;
   GtkTreeIter iter;
   GtkTreePath *path;
 
   path = gtk_tree_row_reference_get_path (info->rr);
   GNUNET_assert (NULL != path);
-  GNUNET_assert (TRUE == gtk_tree_model_get_iter (GTK_TREE_MODEL (ls), &iter, 
path));
+  GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (ls), &iter, path));
   gtk_tree_path_free (path);
   if (NULL == address)
   {
     /* disconnect */
     gtk_list_store_set (ls, &iter,
-                       PEERINFO_MC_NUMBER_OF_ADDRESSES, (guint) 0,
-                       PEERINFO_MC_CONNECTIVITY_LED, led_red,
-                       PEERINFO_MC_CONNECTED_STATUS, FALSE,
+                       // PEERINFO_MC_CONNECTIVITY_LED, led_red,
+                       // PEERINFO_MC_CONNECTED_STATUS, FALSE,
                         -1);
     return;
   }
   gtk_list_store_set (ls, &iter,
-                     PEERINFO_MC_NUMBER_OF_ADDRESSES, 1,
-                     PEERINFO_MC_CONNECTIVITY_LED, led_green,
-                     PEERINFO_MC_CONNECTED_STATUS, TRUE,
+                     // PEERINFO_MC_CONNECTIVITY_LED, led_green,
+                     // PEERINFO_MC_CONNECTED_STATUS, TRUE,
                      -1);
+#if 0
   if (NULL != info->tos)
     GNUNET_TRANSPORT_address_to_string_cancel (info->tos);
-  info->got_address = GNUNET_NO;
-  info->tos =
-      GNUNET_TRANSPORT_address_to_string (get_configuration (), address,
-                                          GNUNET_NO,
-                                          GNUNET_TIME_UNIT_FOREVER_REL,
-                                          &peer_address_string_cb, info);
+  pa->tos =
+    GNUNET_TRANSPORT_address_to_string (get_configuration (), address,
+                                       GNUNET_NO,
+                                       GNUNET_TIME_UNIT_FOREVER_REL,
+                                       &peer_address_string_cb, pa);
+#endif
 }
 
 
@@ -396,14 +533,10 @@
     gtk_list_store_append (ls, &iter);
     gtk_list_store_set (ls, &iter,
                        PEERINFO_MC_PEER_IDENTITY_STRING, GNUNET_i2s (peer),
-                       PEERINFO_MC_NUMBER_OF_ADDRESSES, (guint) 0,
                         PEERINFO_MC_COUNTRY_NAME, "",
                         PEERINFO_MC_COUNTRY_FLAG, NULL,
-                        PEERINFO_MC_BANDWIDTH_IN, (guint64) 0,
-                        PEERINFO_MC_BANDWIDTH_OUT, (guint64) 0,
-                       PEERINFO_MC_ADDRESS_AS_STRING, "",
-                       PEERINFO_MC_CONNECTIVITY_LED, led_red,
-                       PEERINFO_MC_CONNECTED_STATUS, FALSE,
+                        PEERINFO_MC_BANDWIDTH_IN, (guint) 0,
+                        PEERINFO_MC_BANDWIDTH_OUT, (guint) 0,
                         PEERINFO_MC_IS_FRIEND, 
GNUNET_CONTAINER_multipeermap_contains (friends,
                                                                                
        peer),
                         PEERINFO_MC_PEERINFO, info,
@@ -542,8 +675,7 @@
     GNUNET_break (0);
     return;
   }
-  if (TRUE !=
-      gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (ls), &old, path))
+  if (! gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (ls), &old, path))
   {
     GNUNET_break (0);
     return;
@@ -629,6 +761,73 @@
 
 
 /**
+ * Function to call with information about a peer
+ *
+ * @param cls closure
+ * @param peer peer this update is about,
+ *      NULL if this is the final last callback for a iteration operation
+ * @param address address, NULL for disconnect notification in monitor mode
+ * @param state current state this peer is in
+ * @param state_timeout timeout for the current state of the peer
+ */
+static void
+transport_peer_cb (void *cls,
+                  const struct GNUNET_PeerIdentity *peer,
+                  const struct GNUNET_HELLO_Address *address,
+                  enum GNUNET_TRANSPORT_PeerState state,
+                  struct GNUNET_TIME_Absolute state_timeout)
+{
+}
+
+
+/**
+ * Function to call with validation information about a peer
+ *
+ * @param cls closure
+ * @param peer peer this update is about,
+ *      NULL if this is the final last callback for a iteration operation
+ * @param address address, NULL for disconnect notification in monitor mode
+ * @param valid_until when does this address expire
+ * @param next_validation time of the next validation operation
+ *
+ */
+static void
+validation_monitor_cb (void *cls,
+                      const struct GNUNET_PeerIdentity *peer,
+                      const struct GNUNET_HELLO_Address *address,
+                      struct GNUNET_TIME_Absolute valid_until,
+                      struct GNUNET_TIME_Absolute next_validation)
+{
+}
+
+
+/**
+ * Method called whenever a given peer connects.
+ *
+ * @param cls closure
+ * @param peer peer identity this notification is about
+ */
+static void
+handle_core_connect (void *cls,
+                    const struct GNUNET_PeerIdentity *peer)
+{
+}
+
+
+/**
+ * Method called whenever a peer disconnects.
+ *
+ * @param cls closure
+ * @param peer peer identity this notification is about
+ */
+static void
+handle_core_disconnect (void *cls,
+                       const struct GNUNET_PeerIdentity *peer)
+{
+}
+
+
+/**
  * Actual main function run right after GNUnet's scheduler
  * is initialized.  Initializes up GTK and Glade.
  *
@@ -636,7 +835,8 @@
  * @param tc schedule context
  */
 static void
-run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+run (void *cls,
+     const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   GtkWidget *main_window;
 
@@ -656,17 +856,29 @@
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                 _("Failed to parse list of friends\n"));
   peer2info = GNUNET_CONTAINER_multipeermap_create (256, GNUNET_NO);
-  pnc =
-      GNUNET_PEERINFO_notify (get_configuration (),
-                             GNUNET_NO,
-                             &peerinfo_processor, NULL);
-  if (NULL == pnc)
-  {
-    fprintf (stderr,
-             _("Failed to initialize communication with peerinfo service!\n"));
-    GNUNET_SCHEDULER_shutdown ();
-    return;
-  }
+  core = GNUNET_CORE_connect (get_configuration (),
+                             NULL,
+                             NULL,
+                             &handle_core_connect,
+                             &handle_core_disconnect,
+                             NULL, GNUNET_NO,
+                             NULL, GNUNET_NO,
+                             NULL);
+  pnc = GNUNET_PEERINFO_notify (get_configuration (),
+                               GNUNET_NO,
+                               &peerinfo_processor, NULL);
+  pmc = GNUNET_TRANSPORT_monitor_peers (get_configuration (),
+                                       NULL,
+                                       GNUNET_NO,
+                                       GNUNET_TIME_UNIT_FOREVER_REL,
+                                       &transport_peer_cb,
+                                       NULL);
+  vmc = GNUNET_TRANSPORT_monitor_validation_entries (get_configuration (),
+                                                    NULL,
+                                                    GNUNET_NO,
+                                                    
GNUNET_TIME_UNIT_FOREVER_REL,
+                                                    &validation_monitor_cb,
+                                                    NULL);
   ats = GNUNET_ATS_performance_init (get_configuration (), &status_cb, NULL);
   /* setup main window */
   main_window = GTK_WIDGET (get_object ("GNUNET_PEERINFO_GTK_main_window"));




reply via email to

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