[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r34404 - gnunet-gtk/src/peerinfo
From: |
gnunet |
Subject: |
[GNUnet-SVN] r34404 - gnunet-gtk/src/peerinfo |
Date: |
Mon, 10 Nov 2014 14:05:24 +0100 |
Author: grothoff
Date: 2014-11-10 14:05:24 +0100 (Mon, 10 Nov 2014)
New Revision: 34404
Modified:
gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c
Log:
plugin session monitoring support added
Modified: gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c
===================================================================
--- gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c 2014-11-07 18:13:30 UTC
(rev 34403)
+++ gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c 2014-11-10 13:05:24 UTC
(rev 34404)
@@ -334,6 +334,11 @@
static struct GNUNET_TRANSPORT_ValidationMonitoringContext *vmc;
/**
+ * Monitoring transport plugin sessions.
+ */
+struct GNUNET_TRANSPORT_PluginMonitor *pm;
+
+/**
* Monitoring core connectivity.
*/
static struct GNUNET_CORE_MonitorHandle *cm;
@@ -518,6 +523,11 @@
GNUNET_TRANSPORT_monitor_peers_cancel (pmc);
pmc = NULL;
}
+ if (NULL != pm )
+ {
+ GNUNET_TRANSPORT_monitor_plugins_cancel (pm);
+ pm = NULL;
+ }
if (NULL != vmc)
{
GNUNET_TRANSPORT_monitor_validation_entries_cancel (vmc);
@@ -1056,6 +1066,83 @@
/**
+ * Function called by the plugin with information about the
+ * current sessions managed by the plugin (for monitoring).
+ *
+ * @param cls closure
+ * @param session session handle this information is about,
+ * NULL to indicate that we are "in sync" (initial
+ * iteration complete)
+ * @param session_ctx storage location where the application
+ * can store data; will point to NULL on #GNUNET_TRANSPORT_SS_INIT,
+ * and must be reset to NULL on #GNUNET_TRANSPORT_SS_DONE
+ * @param sinfo information about the state of the session,
+ * NULL if @a session is also NULL and we are
+ * merely signalling that the initial iteration is over;
+ * NULL with @a session being non-NULL if the monitor
+ * was being cancelled while sessions were active
+ */
+static void
+transport_plugin_cb (void *cls,
+ struct GNUNET_TRANSPORT_PluginSession *session,
+ void **session_ctx,
+ const struct GNUNET_TRANSPORT_SessionInfo *sinfo)
+{
+ struct PeerInfo *info;
+ GtkTreeIter iter;
+ gboolean con;
+ const char *tos;
+ struct PeerAddress *pa;
+ GdkPixbuf *led;
+
+ if (NULL == session)
+ {
+ /* initial iteration completed, ignore */
+ return;
+ }
+ if (NULL == sinfo)
+ {
+ /* in shutdown, ignore */
+ return;
+ }
+ switch (sinfo->state)
+ {
+ case GNUNET_TRANSPORT_SS_INIT:
+ led = led_red;
+ break;
+ case GNUNET_TRANSPORT_SS_HANDSHAKE:
+ led = led_yellow;
+ break;
+ case GNUNET_TRANSPORT_SS_UP:
+ led = led_green;
+ break;
+ case GNUNET_TRANSPORT_SS_UPDATE:
+ led = led_green;
+ break;
+ case GNUNET_TRANSPORT_SS_DONE:
+ led = NULL;
+ break;
+ }
+ if (NULL == sinfo->address)
+ {
+ GNUNET_break (0); // is this OK?
+ return;
+ }
+ info = get_peer_info (&sinfo->address->peer);
+ tos = GNUNET_STRINGS_absolute_time_to_string (sinfo->session_timeout);
+ if (NULL == led)
+ tos = NULL;
+ pa = get_address (info, sinfo->address);
+ get_iter_from_rr (pa->rr, &iter);
+ gtk_tree_store_set (ts, &iter,
+ PEERINFO_MC_PLUGIN_CONNECTIVITY_STATUS, (led_green ==
tos),
+ PEERINFO_MC_PLUGIN_CONNECTIVITY_LED, led,
+ PEERINFO_MC_PLUGIN_CONNECTIVITY_TIMEOUT_AS_STRING, tos,
+ -1);
+}
+
+
+/**
* Transport address validation monitor disconnected, reset
* address validation status information for all peers.
*
@@ -1548,6 +1635,9 @@
GNUNET_TIME_UNIT_FOREVER_REL,
&transport_peer_cb,
NULL);
+ pm = GNUNET_TRANSPORT_monitor_plugins (cfg,
+ &transport_plugin_cb,
+ NULL);
vmc = GNUNET_TRANSPORT_monitor_validation_entries (cfg,
NULL,
GNUNET_NO,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r34404 - gnunet-gtk/src/peerinfo,
gnunet <=