[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r31862 - in gnunet-gtk: contrib src/peerinfo
From: |
gnunet |
Subject: |
[GNUnet-SVN] r31862 - in gnunet-gtk: contrib src/peerinfo |
Date: |
Thu, 9 Jan 2014 15:40:47 +0100 |
Author: grothoff
Date: 2014-01-09 15:40:47 +0100 (Thu, 09 Jan 2014)
New Revision: 31862
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:
updating gnunet-peerinfo-gtk to display more information about connectivity and
connection state processing (wip)
Modified: gnunet-gtk/contrib/gnunet_peerinfo_gtk_main_window.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_peerinfo_gtk_main_window.glade 2014-01-09
14:09:29 UTC (rev 31861)
+++ gnunet-gtk/contrib/gnunet_peerinfo_gtk_main_window.glade 2014-01-09
14:40:47 UTC (rev 31862)
@@ -2,30 +2,6 @@
<interface>
<requires lib="gtk+" version="2.20"/>
<!-- interface-naming-policy project-wide -->
- <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 -->
@@ -78,6 +54,8 @@
<column type="gchararray"/>
<!-- column-name show_friend -->
<column type="gboolean"/>
+ <!-- column-name peerinfo_address_expiration -->
+ <column type="gchararray"/>
</columns>
</object>
<object class="GtkAdjustment" id="adjustment3">
@@ -86,12 +64,36 @@
<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_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="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="GtkImage" id="validated_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -282,7 +284,7 @@
<child>
<object class="GtkCellRendererPixbuf"
id="GNUNET_PEERINFO_GTK_main_window_country_renderer"/>
<attributes>
- <attribute name="pixbuf">3</attribute>
+ <attribute name="pixbuf">2</attribute>
</attributes>
</child>
</object>
@@ -313,7 +315,7 @@
<child>
<object class="GtkCellRendererText"
id="GNUNET_PEERINFO_GTK_main_window_bandwidth_in_cellrenderertext"/>
<attributes>
- <attribute name="text">4</attribute>
+ <attribute name="text">3</attribute>
</attributes>
</child>
</object>
@@ -327,7 +329,7 @@
<child>
<object class="GtkCellRendererText"
id="GNUNET_PEERINFO_GTK_main_window_bandwidth_out_cellrenderertext"/>
<attributes>
- <attribute name="text">5</attribute>
+ <attribute name="text">4</attribute>
</attributes>
</child>
</object>
Modified: gnunet-gtk/src/peerinfo/Makefile.am
===================================================================
--- gnunet-gtk/src/peerinfo/Makefile.am 2014-01-09 14:09:29 UTC (rev 31861)
+++ gnunet-gtk/src/peerinfo/Makefile.am 2014-01-09 14:40:47 UTC (rev 31862)
@@ -18,7 +18,7 @@
$(top_builddir)/src/lib/libgnunetgtk.la \
@GTK_LIBS@ \
@GLADE_LIBS@ @GNUNET_LIBS@ @unique_LIBS@ \
- -lgnunetutil -lgnunetpeerinfo -lgnunettransport -lgnunetats -lgnunetcore
-lgnunetfriends \
+ -lgnunetutil -lgnunetpeerinfo -lgnunethello -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 14:09:29 UTC
(rev 31861)
+++ gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c 2014-01-09 14:40:47 UTC
(rev 31862)
@@ -147,7 +147,7 @@
PEERINFO_MC_VALIDATION_TIMEOUT_AS_STRING = 20,
/**
- * A gboolean
+ * A GdkPixbuf
*/
PEERINFO_MC_PLUGIN_CONNECTIVITY_LED = 21,
@@ -164,8 +164,13 @@
/**
* A gboolean
*/
- PEERINFO_MC_SHOW_FRIEND = 24
+ PEERINFO_MC_SHOW_FRIEND = 24,
+ /**
+ * A gchararray
+ */
+ PEERINFO_MC_PEERINFO_ADDRESS_EXPIRATION = 25
+
};
@@ -201,10 +206,40 @@
const void *addr;
/**
+ * Name of the plugin.
+ */
+ char *plugin;
+
+ /**
+ * Timeout for the current state in the state machine.
+ */
+ struct GNUNET_TIME_Absolute state_timeout;
+
+ /**
+ * State of this address in the transport state machine.
+ */
+ enum GNUNET_TRANSPORT_PeerState state;
+
+ /**
* Number of bytes in @e addr.
*/
size_t addr_len;
+ /**
+ * ATS bandwidth in for this address.
+ */
+ guint ats_in;
+
+ /**
+ * ATS bandwidth out for this address.
+ */
+ guint ats_out;
+
+ /**
+ * Is this address active in ATS?
+ */
+ gboolean address_ats_active;
+
};
@@ -292,9 +327,9 @@
static GdkPixbuf *led_red;
/**
- * Main window list store.
+ * Main window tree store.
*/
-static GtkListStore *ls;
+static GtkTreeStore *ts;
/**
* Map of all of our friends.
@@ -334,13 +369,13 @@
* Function called on each entry in the #peer2info map
* to free the associated path.
*
- * @param cls unused
+ * @param cts unused
* @param key peer identity
* @param value the `struct PeerInfo`
* @return #GNUNET_OK (continue to iterate)
*/
static int
-free_paths (void *cls,
+free_paths (void *cts,
const struct GNUNET_PeerIdentity *key,
void *value)
{
@@ -358,6 +393,7 @@
pa->tos = NULL;
}
gtk_tree_row_reference_free (pa->rr);
+ GNUNET_free_non_null (pa->plugin);
GNUNET_free (pa);
}
gtk_tree_row_reference_free (info->rr);
@@ -369,11 +405,11 @@
/**
* Task run on shutdown.
*
- * @param cls unused
+ * @param cts unused
* @param tc scheduler context, unused
*/
static void
-shutdown_task (void *cls,
+shutdown_task (void *cts,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
GNUNET_GTK_tray_icon_destroy ();
@@ -412,18 +448,36 @@
/**
+ * Convert a row reference to an iter.
+ *
+ * @param rr reference to a row (in our #ts)
+ * @param iter set to the iter corresponding to @a rr
+ */
+static void
+get_iter_from_rr (GtkTreeRowReference *rr,
+ GtkTreeIter *iter)
+{
+ GtkTreePath *path;
+
+ path = gtk_tree_row_reference_get_path (rr);
+ GNUNET_assert (NULL != path);
+ GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (ts), iter, path));
+ gtk_tree_path_free (path);
+}
+
+
+/**
* Function to call with the text format of an address
*
- * @param cls the `struct PeerAddress` for the address
+ * @param cts the `struct PeerAddress` for the address
* @param address address as a string, NULL on error
*/
static void
-peer_address_string_cb (void *cls,
+peer_address_string_cb (void *cts,
const char *address)
{
- struct PeerAddress *pa = cls;
+ struct PeerAddress *pa = cts;
GtkTreeIter iter;
- GtkTreePath *path;
char *country;
const char *colon;
const char *dot;
@@ -433,10 +487,7 @@
pa->tos = NULL;
return;
}
- path = gtk_tree_row_reference_get_path (pa->rr);
- GNUNET_assert (NULL != path);
- GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (ls), &iter, path));
- gtk_tree_path_free (path);
+ get_iter_from_rr (pa->rr, &iter);
country = NULL;
colon = strstr (address, ":");
if (NULL != colon)
@@ -447,7 +498,7 @@
if ('.' == *dot)
country = GNUNET_strndup (&dot[1], (colon - dot) - 1);
}
- gtk_list_store_set (ls, &iter,
+ gtk_tree_store_set (ts, &iter,
PEERINFO_MC_COUNTRY_NAME, country,
PEERINFO_MC_COUNTRY_FLAG, GNUNET_PEERINFO_GTK_get_flag
(country),
PEERINFO_MC_ADDRESS_AS_STRING, address,
@@ -456,100 +507,154 @@
}
+
/**
+ * Obtain the address entry for the given address at the given
+ * peer. If the address entry does not yet exist, create it.
+ *
+ * @param pi peer info of the peer
+ * @param addr peer's address
+ * @return address entry for the given address
+ */
+static struct PeerAddress *
+get_address (struct PeerInfo *pi,
+ const struct GNUNET_HELLO_Address *addr)
+{
+ static struct PeerAddress *pa;
+ GtkTreeIter iter;
+ GtkTreeIter aiter;
+ GtkTreePath *path;
+
+ for (pa = pi->pa_head; NULL != pa; pa = pa->next)
+ if ( (addr->address_length == pa->addr_len) &&
+ (0 == memcmp (addr,
+ pa->addr,
+ addr->address_length)) &&
+ (0 == strcmp (addr->transport_name,
+ pa->plugin)) )
+ return pa;
+ pa = GNUNET_malloc (sizeof (struct PeerAddress) + addr->address_length);
+ pa->plugin = GNUNET_strdup (addr->transport_name);
+ pa->addr = &pa[1];
+ memcpy (&pa[1], addr->address, addr->address_length);
+ pa->addr_len = addr->address_length;
+ GNUNET_CONTAINER_DLL_insert (pi->pa_head,
+ pi->pa_tail,
+ pa);
+ path = gtk_tree_row_reference_get_path (pi->rr);
+ GNUNET_assert (NULL != path);
+ GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (ts), &iter, path));
+ gtk_tree_path_free (path);
+ gtk_tree_store_append (ts, &aiter, &iter);
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (ts), &aiter);
+ pa->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (ts), path);
+ GNUNET_assert (NULL != pa->rr);
+ gtk_tree_path_free (path);
+ pa->tos = GNUNET_TRANSPORT_address_to_string (get_configuration (), addr,
+ GNUNET_NO,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &peer_address_string_cb, pa);
+
+ return pa;
+}
+
+
+/**
* Function to call with a binary format of an address
*
- * @param cls the `struct PeerInfo` for which this is a valid address
- * @param peer peer the update is about
- * @param address NULL on disconnect, otherwise 0-terminated printable UTF-8
string
+ * @param cts the `struct PeerInfo` for which this is a valid address
+ * @param address an address of the peer
+ * @param expiration expiration time for that address
+ * @return #GNUNET_OK (keep iterating)
*/
-static void
-peer_address_cb (void *cls,
- const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Address *address)
+static int
+peer_address_cb (void *cts,
+ const struct GNUNET_HELLO_Address *address,
+ struct GNUNET_TIME_Absolute expiration)
{
- struct PeerInfo *info = cls;
+ struct PeerInfo *info = cts;
struct PeerAddress *pa;
GtkTreeIter iter;
GtkTreePath *path;
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));
+ GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (ts), &iter, path));
gtk_tree_path_free (path);
- if (NULL == address)
- {
- /* disconnect */
- gtk_list_store_set (ls, &iter,
- // PEERINFO_MC_CONNECTIVITY_LED, led_red,
- // PEERINFO_MC_CONNECTED_STATUS, FALSE,
- -1);
- return;
- }
- gtk_list_store_set (ls, &iter,
- // 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);
- pa->tos =
- GNUNET_TRANSPORT_address_to_string (get_configuration (), address,
- GNUNET_NO,
- GNUNET_TIME_UNIT_FOREVER_REL,
- &peer_address_string_cb, pa);
-#endif
+ pa = get_address (info, address);
+ get_iter_from_rr (pa->rr, &iter);
+ gtk_tree_store_set (ts, &iter,
+ PEERINFO_MC_PEERINFO_ADDRESS_EXPIRATION,
GNUNET_STRINGS_absolute_time_to_string (expiration),
+ -1);
+ return GNUNET_OK;
}
/**
+ * Obtain the `struct PeerInfo` for the given peer; if it does
+ * not yet exist, add it.
+ *
+ * @param peer peer identity to get the `struct PeerInfo` for
+ * @return the corresponding struct
+ */
+static struct PeerInfo *
+get_peer_info (const struct GNUNET_PeerIdentity *peer)
+{
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ struct PeerInfo *info;
+
+ info = GNUNET_CONTAINER_multipeermap_get (peer2info, peer);
+ if (NULL != info)
+ return info;
+ info = GNUNET_new (struct PeerInfo);
+ info->pid = *peer;
+ gtk_tree_store_append (ts, &iter, NULL);
+ gtk_tree_store_set (ts, &iter,
+ PEERINFO_MC_PEER_IDENTITY_STRING, GNUNET_i2s (peer),
+ PEERINFO_MC_IS_FRIEND,
GNUNET_CONTAINER_multipeermap_contains (friends,
+
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);
+ GNUNET_assert (NULL != info->rr);
+ gtk_tree_path_free (path);
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CONTAINER_multipeermap_put (peer2info, peer, info,
+
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+ return info;
+}
+
+
+/**
* Function called for peers that we know about.
*
- * @param cls closure
+ * @param cts closure
* @param peer id of the peer, NULL for last call
* @param hello hello message for the peer (can be NULL)
* @param err_msg NULL if successful, otherwise contains error message
*/
static void
-peerinfo_processor (void *cls,
+peerinfo_processor (void *cts,
const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_HELLO_Message *hello,
const char *err_msg)
{
- GtkTreeIter iter;
struct PeerInfo *info;
- GtkTreePath *path;
- info = GNUNET_CONTAINER_multipeermap_get (peer2info, peer);
- if (NULL == info)
- {
- info = GNUNET_new (struct PeerInfo);
- info->pid = *peer;
- gtk_list_store_append (ls, &iter);
- gtk_list_store_set (ls, &iter,
- PEERINFO_MC_PEER_IDENTITY_STRING, GNUNET_i2s (peer),
- PEERINFO_MC_COUNTRY_NAME, "",
- PEERINFO_MC_COUNTRY_FLAG, NULL,
- 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,
- -1);
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (ls), &iter);
- info->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (ls), path);
- GNUNET_assert (NULL != info->rr);
- gtk_tree_path_free (path);
- GNUNET_CONTAINER_multipeermap_put (peer2info, peer, info,
-
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
- }
+ info = get_peer_info (peer);
+ GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO,
+ &peer_address_cb, info);
}
/**
* Method called whenever a given peer has a QoS status change.
*
- * @param cls closure
+ * @param cts closure
* @param address the address
* @param address_active is this address actively used to maintain a connection
* to a peer
@@ -559,7 +664,7 @@
* @param ats_count number of performance records in @a ats
*/
static void
-status_cb (void *cls,
+status_cb (void *cts,
const struct GNUNET_HELLO_Address *address,
int address_active,
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
@@ -568,45 +673,262 @@
uint32_t ats_count)
{
struct PeerInfo *info;
+ struct PeerAddress *pa;
+ struct PeerAddress *act;
GtkTreeIter iter;
- GtkTreePath *path;
- if (0 == address_active)
+ info = get_peer_info (&address->peer);
+ pa = get_address (info, address);
+ pa->address_ats_active = address_active;
+ pa->ats_in = (guint) ntohl (bandwidth_in.value__);
+ pa->ats_out = (guint) ntohl (bandwidth_out.value__);
+ get_iter_from_rr (pa->rr, &iter);
+ gtk_tree_store_set (ts, &iter,
+ PEERINFO_MC_ATS_CONNECTIVITY_LED,
(pa->address_ats_active) ? led_green : led_red,
+ PEERINFO_MC_ATS_SELECTED_STATUS, pa->address_ats_active,
+ PEERINFO_MC_BANDWIDTH_IN, pa->ats_in,
+ PEERINFO_MC_BANDWIDTH_OUT, pa->ats_out,
+ -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)
+ {
+ gtk_tree_store_set (ts, &iter,
+ PEERINFO_MC_ATS_CONNECTIVITY_LED, led_red,
+ PEERINFO_MC_ATS_SELECTED_STATUS, FALSE,
+ PEERINFO_MC_BANDWIDTH_IN, (guint) 0,
+ PEERINFO_MC_BANDWIDTH_OUT, (guint) 0,
+ -1);
+ }
+ else
+ {
+ gtk_tree_store_set (ts, &iter,
+ PEERINFO_MC_ATS_CONNECTIVITY_LED, led_green,
+ PEERINFO_MC_ATS_SELECTED_STATUS, TRUE,
+ PEERINFO_MC_BANDWIDTH_IN, act->ats_in,
+ PEERINFO_MC_BANDWIDTH_OUT, act->ats_out,
+ -1);
+ }
+}
+
+
+/**
+ * Function to call with information about a peer
+ *
+ * @param cts 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 *cts,
+ const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_HELLO_Address *address,
+ enum GNUNET_TRANSPORT_PeerState state,
+ struct GNUNET_TIME_Absolute state_timeout)
+{
+ struct PeerInfo *info;
+ struct PeerAddress *pa;
+ struct PeerAddress *act;
+ struct PeerAddress *pre;
+ GtkTreeIter iter;
+ gboolean con;
+ const char *tos;
+
+ info = get_peer_info (peer);
+ if (NULL == address)
+ {
+ GNUNET_break (0);
return;
- info = GNUNET_CONTAINER_multipeermap_get (peer2info, &address->peer);
- if (NULL == info)
+ }
+ pa = get_address (info, address);
+ pa->state = state;
+ pa->state_timeout = state_timeout;
+ con = (GNUNET_YES == GNUNET_TRANSPORT_is_connected (state));
+ get_iter_from_rr (pa->rr, &iter);
+ tos = GNUNET_STRINGS_absolute_time_to_string (state_timeout);
+ gtk_tree_store_set (ts, &iter,
+ PEERINFO_MC_NEIGHBOUR_CONNECTED_STATUS, con,
+ PEERINFO_MC_NEIGHBOUR_CONNECTIVITY_TIMEOUT_AS_STRING,
con ? tos : NULL,
+ PEERINFO_MC_NEIGHBOUR_CONNECTIVITY_LED, (con ? led_green
: led_red),
+ PEERINFO_MC_NEIGHBOUR_STATE_AS_STRING,
GNUNET_TRANSPORT_p2s (state),
+ PEERINFO_MC_NEIGHBOUR_STATE_TIMEOUT_AS_STRING, tos,
+ -1);
+ act = NULL;
+ pre = NULL;
+ for (pa = info->pa_head; NULL != pa; pa = pa->next)
{
- /* should rarely happen... */
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Entry for peer %s not found\n",
- GNUNET_i2s (&address->peer));
+ if (GNUNET_YES == GNUNET_TRANSPORT_is_connected (pa->state))
+ {
+ GNUNET_break (NULL == act);
+ act = pa;
+ }
+ else if (GNUNET_TRANSPORT_DISCONNECT_FINISHED != pa->state)
+ {
+ /* remember that we're at least still in the neighbours table */
+ pre = pa;
+ }
+ }
+
+ get_iter_from_rr (info->rr, &iter);
+ if (NULL == act)
+ {
+ if (NULL == pre)
+ {
+ /* peer is not even in neighbours table; remove the LED entirely */
+ 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);
+ }
+ else
+ {
+ /* mark peer as down with red LED */
+ 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, led_red,
+ PEERINFO_MC_NEIGHBOUR_STATE_AS_STRING, NULL,
+ PEERINFO_MC_NEIGHBOUR_STATE_TIMEOUT_AS_STRING, NULL,
+ -1);
+ }
+ }
+ else
+ {
+ /* mark peer as up, show details on top-level */
+ tos = GNUNET_STRINGS_absolute_time_to_string (state_timeout);
+ gtk_tree_store_set (ts, &iter,
+ PEERINFO_MC_NEIGHBOUR_CONNECTED_STATUS, TRUE,
+ PEERINFO_MC_NEIGHBOUR_CONNECTIVITY_TIMEOUT_AS_STRING,
tos,
+ PEERINFO_MC_NEIGHBOUR_CONNECTIVITY_LED, led_green,
+ PEERINFO_MC_NEIGHBOUR_STATE_AS_STRING,
GNUNET_TRANSPORT_p2s (act->state),
+ PEERINFO_MC_NEIGHBOUR_STATE_TIMEOUT_AS_STRING, tos,
+ -1);
+ }
+}
+
+
+/**
+ * Function to call with validation information about a peer
+ *
+ * @param cts 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 *cts,
+ const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_HELLO_Address *address,
+ struct GNUNET_TIME_Absolute valid_until,
+ struct GNUNET_TIME_Absolute next_validation)
+{
+ struct PeerInfo *info;
+ struct PeerAddress *pa;
+ GtkTreeIter iter;
+ const char *tos;
+ gboolean valid;
+
+ GNUNET_assert (NULL != peer);
+ info = get_peer_info (peer);
+ if (NULL == address)
+ {
+ /* disconnect, mark all as down */
+ 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;
}
- 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);
- gtk_list_store_set (ls, &iter,
- PEERINFO_MC_BANDWIDTH_IN, (guint) ntohl
(bandwidth_in.value__),
- PEERINFO_MC_BANDWIDTH_OUT, (guint) ntohl
(bandwidth_out.value__),
- -1);
+ valid = GNUNET_TIME_absolute_get_remaining (valid_until).rel_value_us > 0;
+ pa = get_address (info, address);
+ get_iter_from_rr (pa->rr, &iter);
+ tos = GNUNET_STRINGS_absolute_time_to_string (valid_until);
+ gtk_tree_store_set (ts, &iter,
+ PEERINFO_MC_VALIDATION_IS_VALID, valid,
+ PEERINFO_MC_VALIDATION_TIMEOUT_AS_STRING, tos,
+ PEERINFO_MC_VALIDATION_STATE_LED, (valid ? led_green :
led_red),
+ -1);
}
/**
+ * Method called whenever a given peer connects.
+ *
+ * @param cts closure
+ * @param peer peer identity this notification is about
+ */
+static void
+handle_core_connect (void *cts,
+ const struct GNUNET_PeerIdentity *peer)
+{
+ struct PeerInfo *info;
+ 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,
+ -1);
+}
+
+
+/**
+ * Method called whenever a peer disconnects.
+ *
+ * @param cts closure
+ * @param peer peer identity this notification is about
+ */
+static void
+handle_core_disconnect (void *cts,
+ const struct GNUNET_PeerIdentity *peer)
+{
+ struct PeerInfo *info;
+ 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_red,
+ PEERINFO_MC_CORE_CONNECTED_STATUS, FALSE,
+ -1);
+}
+
+
+/**
* Write a friend to the friends file.
*
- * @param cls the `struct GNUNET_FRIENDS_Writer`
+ * @param cts the `struct GNUNET_FRIENDS_Writer`
* @param friend friend to write to file
* @param value unused
* @return #GNUNET_OK if the writing succeeded
*/
static int
-write_friend (void *cls,
+write_friend (void *cts,
const struct GNUNET_PeerIdentity *friend,
void *value)
{
- struct GNUNET_FRIENDS_Writer *w = cls;
+ struct GNUNET_FRIENDS_Writer *w = cts;
return GNUNET_FRIENDS_write (w, friend);
}
@@ -651,27 +973,20 @@
gchar
*path,
gpointer user_data)
{
- GtkListStore *ls;
GtkTreeIter old;
struct PeerInfo *info;
gboolean oldvalue;
- ls = GTK_LIST_STORE (get_object ("GNUNET_PEERINFO_GTK_list_store"));
- if (NULL == ls)
+ if (! gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (ts), &old, path))
{
GNUNET_break (0);
return;
}
- if (! gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (ls), &old, path))
- {
- GNUNET_break (0);
- return;
- }
- gtk_tree_model_get (GTK_TREE_MODEL (ls), &old,
+ gtk_tree_model_get (GTK_TREE_MODEL (ts), &old,
PEERINFO_MC_PEERINFO, &info,
PEERINFO_MC_IS_FRIEND, &oldvalue,
-1);
- gtk_list_store_set (ls, &old,
+ gtk_tree_store_set (ts, &old,
PEERINFO_MC_IS_FRIEND, ! oldvalue,
-1);
if (oldvalue)
@@ -732,11 +1047,11 @@
/**
* Add a friend to our friends peer map.
*
- * @param cls NULL
+ * @param cts NULL
* @param friend the friend to add
*/
static void
-add_friend (void *cls,
+add_friend (void *cts,
const struct GNUNET_PeerIdentity *friend)
{
GNUNET_break (GNUNET_YES ==
@@ -748,86 +1063,19 @@
/**
- * 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.
*
- * @param cls NULL
+ * @param cts NULL
* @param tc schedule context
*/
static void
-run (void *cls,
+run (void *cts,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
GtkWidget *main_window;
- ml = cls;
+ ml = cts;
if (GNUNET_OK !=
GNUNET_GTK_main_loop_build_window (ml, NULL))
return;
@@ -866,13 +1114,14 @@
GNUNET_TIME_UNIT_FOREVER_REL,
&validation_monitor_cb,
NULL);
- ats = GNUNET_ATS_performance_init (get_configuration (), &status_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"));
main_window = GNUNET_GTK_plug_me ("GNUNET_PEERINFO_GTK_PLUG",
main_window);
- ls = GTK_LIST_STORE (get_object ("GNUNET_PEERINFO_GTK_list_store"));
- GNUNET_assert (NULL != ls);
+ ts = GTK_TREE_STORE (get_object ("GNUNET_PEERINFO_GTK_tree_store"));
+ GNUNET_assert (NULL != ts);
gtk_window_maximize (GTK_WINDOW (main_window));
if (NULL == getenv ("GNUNET_PEERINFO_GTK_PLUG"))
GNUNET_GTK_tray_icon_create (ml,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r31862 - in gnunet-gtk: contrib src/peerinfo,
gnunet <=