diff options
Diffstat (limited to 'src/peerinfo/gnunet-peerinfo-gtk.c')
-rw-r--r-- | src/peerinfo/gnunet-peerinfo-gtk.c | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/src/peerinfo/gnunet-peerinfo-gtk.c b/src/peerinfo/gnunet-peerinfo-gtk.c index 4feacefd..0894d482 100644 --- a/src/peerinfo/gnunet-peerinfo-gtk.c +++ b/src/peerinfo/gnunet-peerinfo-gtk.c | |||
@@ -334,6 +334,11 @@ static struct GNUNET_TRANSPORT_PeerMonitoringContext *pmc; | |||
334 | static struct GNUNET_TRANSPORT_ValidationMonitoringContext *vmc; | 334 | static struct GNUNET_TRANSPORT_ValidationMonitoringContext *vmc; |
335 | 335 | ||
336 | /** | 336 | /** |
337 | * Monitoring transport plugin sessions. | ||
338 | */ | ||
339 | struct GNUNET_TRANSPORT_PluginMonitor *pm; | ||
340 | |||
341 | /** | ||
337 | * Monitoring core connectivity. | 342 | * Monitoring core connectivity. |
338 | */ | 343 | */ |
339 | static struct GNUNET_CORE_MonitorHandle *cm; | 344 | static struct GNUNET_CORE_MonitorHandle *cm; |
@@ -518,6 +523,11 @@ shutdown_task (void *cts, | |||
518 | GNUNET_TRANSPORT_monitor_peers_cancel (pmc); | 523 | GNUNET_TRANSPORT_monitor_peers_cancel (pmc); |
519 | pmc = NULL; | 524 | pmc = NULL; |
520 | } | 525 | } |
526 | if (NULL != pm ) | ||
527 | { | ||
528 | GNUNET_TRANSPORT_monitor_plugins_cancel (pm); | ||
529 | pm = NULL; | ||
530 | } | ||
521 | if (NULL != vmc) | 531 | if (NULL != vmc) |
522 | { | 532 | { |
523 | GNUNET_TRANSPORT_monitor_validation_entries_cancel (vmc); | 533 | GNUNET_TRANSPORT_monitor_validation_entries_cancel (vmc); |
@@ -1056,6 +1066,83 @@ transport_peer_cb (void *cts, | |||
1056 | 1066 | ||
1057 | 1067 | ||
1058 | /** | 1068 | /** |
1069 | * Function called by the plugin with information about the | ||
1070 | * current sessions managed by the plugin (for monitoring). | ||
1071 | * | ||
1072 | * @param cls closure | ||
1073 | * @param session session handle this information is about, | ||
1074 | * NULL to indicate that we are "in sync" (initial | ||
1075 | * iteration complete) | ||
1076 | * @param session_ctx storage location where the application | ||
1077 | * can store data; will point to NULL on #GNUNET_TRANSPORT_SS_INIT, | ||
1078 | * and must be reset to NULL on #GNUNET_TRANSPORT_SS_DONE | ||
1079 | * @param sinfo information about the state of the session, | ||
1080 | * NULL if @a session is also NULL and we are | ||
1081 | * merely signalling that the initial iteration is over; | ||
1082 | * NULL with @a session being non-NULL if the monitor | ||
1083 | * was being cancelled while sessions were active | ||
1084 | */ | ||
1085 | static void | ||
1086 | transport_plugin_cb (void *cls, | ||
1087 | struct GNUNET_TRANSPORT_PluginSession *session, | ||
1088 | void **session_ctx, | ||
1089 | const struct GNUNET_TRANSPORT_SessionInfo *sinfo) | ||
1090 | { | ||
1091 | struct PeerInfo *info; | ||
1092 | GtkTreeIter iter; | ||
1093 | gboolean con; | ||
1094 | const char *tos; | ||
1095 | struct PeerAddress *pa; | ||
1096 | GdkPixbuf *led; | ||
1097 | |||
1098 | if (NULL == session) | ||
1099 | { | ||
1100 | /* initial iteration completed, ignore */ | ||
1101 | return; | ||
1102 | } | ||
1103 | if (NULL == sinfo) | ||
1104 | { | ||
1105 | /* in shutdown, ignore */ | ||
1106 | return; | ||
1107 | } | ||
1108 | switch (sinfo->state) | ||
1109 | { | ||
1110 | case GNUNET_TRANSPORT_SS_INIT: | ||
1111 | led = led_red; | ||
1112 | break; | ||
1113 | case GNUNET_TRANSPORT_SS_HANDSHAKE: | ||
1114 | led = led_yellow; | ||
1115 | break; | ||
1116 | case GNUNET_TRANSPORT_SS_UP: | ||
1117 | led = led_green; | ||
1118 | break; | ||
1119 | case GNUNET_TRANSPORT_SS_UPDATE: | ||
1120 | led = led_green; | ||
1121 | break; | ||
1122 | case GNUNET_TRANSPORT_SS_DONE: | ||
1123 | led = NULL; | ||
1124 | break; | ||
1125 | } | ||
1126 | if (NULL == sinfo->address) | ||
1127 | { | ||
1128 | GNUNET_break (0); // is this OK? | ||
1129 | return; | ||
1130 | } | ||
1131 | info = get_peer_info (&sinfo->address->peer); | ||
1132 | tos = GNUNET_STRINGS_absolute_time_to_string (sinfo->session_timeout); | ||
1133 | if (NULL == led) | ||
1134 | tos = NULL; | ||
1135 | pa = get_address (info, sinfo->address); | ||
1136 | get_iter_from_rr (pa->rr, &iter); | ||
1137 | gtk_tree_store_set (ts, &iter, | ||
1138 | PEERINFO_MC_PLUGIN_CONNECTIVITY_STATUS, (led_green == tos), | ||
1139 | PEERINFO_MC_PLUGIN_CONNECTIVITY_LED, led, | ||
1140 | PEERINFO_MC_PLUGIN_CONNECTIVITY_TIMEOUT_AS_STRING, tos, | ||
1141 | -1); | ||
1142 | } | ||
1143 | |||
1144 | |||
1145 | /** | ||
1059 | * Transport address validation monitor disconnected, reset | 1146 | * Transport address validation monitor disconnected, reset |
1060 | * address validation status information for all peers. | 1147 | * address validation status information for all peers. |
1061 | * | 1148 | * |
@@ -1548,6 +1635,9 @@ run (void *cts, | |||
1548 | GNUNET_TIME_UNIT_FOREVER_REL, | 1635 | GNUNET_TIME_UNIT_FOREVER_REL, |
1549 | &transport_peer_cb, | 1636 | &transport_peer_cb, |
1550 | NULL); | 1637 | NULL); |
1638 | pm = GNUNET_TRANSPORT_monitor_plugins (cfg, | ||
1639 | &transport_plugin_cb, | ||
1640 | NULL); | ||
1551 | vmc = GNUNET_TRANSPORT_monitor_validation_entries (cfg, | 1641 | vmc = GNUNET_TRANSPORT_monitor_validation_entries (cfg, |
1552 | NULL, | 1642 | NULL, |
1553 | GNUNET_NO, | 1643 | GNUNET_NO, |