diff options
Diffstat (limited to 'src/peerinfo/gnunet-peerinfo-gtk.c')
-rw-r--r-- | src/peerinfo/gnunet-peerinfo-gtk.c | 76 |
1 files changed, 65 insertions, 11 deletions
diff --git a/src/peerinfo/gnunet-peerinfo-gtk.c b/src/peerinfo/gnunet-peerinfo-gtk.c index 2a633d33..286a8895 100644 --- a/src/peerinfo/gnunet-peerinfo-gtk.c +++ b/src/peerinfo/gnunet-peerinfo-gtk.c | |||
@@ -31,6 +31,48 @@ | |||
31 | 31 | ||
32 | 32 | ||
33 | /** | 33 | /** |
34 | * Columns in the peerinfo model. | ||
35 | */ | ||
36 | enum PEERINFO_ModelColumns | ||
37 | { | ||
38 | /** | ||
39 | * A gchararray | ||
40 | */ | ||
41 | PEERINFO_MC_PEER_IDENTITY_STRING = 0, | ||
42 | |||
43 | /** | ||
44 | * A guint | ||
45 | */ | ||
46 | PEERINFO_MC_NUMBER_OF_ADDRESSES = 1, | ||
47 | |||
48 | /** | ||
49 | * A gchararray | ||
50 | */ | ||
51 | PEERINFO_MC_COUNTRY_NAME = 2, | ||
52 | |||
53 | /** | ||
54 | * A GdkPixbuf | ||
55 | */ | ||
56 | PEERINFO_MC_COUNTRY_FLAG = 3, | ||
57 | |||
58 | /** | ||
59 | * A guint64 | ||
60 | */ | ||
61 | PEERINFO_MC_BANDWIDTH_IN = 4, | ||
62 | |||
63 | /** | ||
64 | * A guint64 | ||
65 | */ | ||
66 | PEERINFO_MC_BANDWIDTH_OUT = 5, | ||
67 | |||
68 | /** | ||
69 | * A gchararray | ||
70 | */ | ||
71 | PEERINFO_MC_ADDRESS_AS_STRING = 6 | ||
72 | }; | ||
73 | |||
74 | |||
75 | /** | ||
34 | * Information we track for each peer outside of the model. | 76 | * Information we track for each peer outside of the model. |
35 | */ | 77 | */ |
36 | struct PeerInfo | 78 | struct PeerInfo |
@@ -186,7 +228,12 @@ peer_address_string_cb (void *cls, const char *address) | |||
186 | if (NULL == address) | 228 | if (NULL == address) |
187 | { | 229 | { |
188 | /* error */ | 230 | /* error */ |
189 | gtk_list_store_set (ls, &iter, 1, 1, 2, NULL, 3, NULL, 6, "<error>", -1); | 231 | gtk_list_store_set (ls, &iter, |
232 | PEERINFO_MC_NUMBER_OF_ADDRESSES, (guint) 1, | ||
233 | PEERINFO_MC_COUNTRY_NAME, NULL, | ||
234 | PEERINFO_MC_COUNTRY_FLAG, NULL, | ||
235 | PEERINFO_MC_ADDRESS_AS_STRING, "<error>", | ||
236 | -1); | ||
190 | } | 237 | } |
191 | else | 238 | else |
192 | { | 239 | { |
@@ -234,7 +281,11 @@ peer_address_cb (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
234 | GNUNET_assert (NULL != path); | 281 | GNUNET_assert (NULL != path); |
235 | GNUNET_assert (TRUE == gtk_tree_model_get_iter (tm, &iter, path)); | 282 | GNUNET_assert (TRUE == gtk_tree_model_get_iter (tm, &iter, path)); |
236 | gtk_tree_path_free (path); | 283 | gtk_tree_path_free (path); |
237 | gtk_list_store_set (ls, &iter, 1, 0, 2, NULL, 3, NULL, 6, "<disconnected>", | 284 | gtk_list_store_set (ls, &iter, |
285 | PEERINFO_MC_NUMBER_OF_ADDRESSES, (guint) 0, | ||
286 | PEERINFO_MC_COUNTRY_NAME, NULL, | ||
287 | PEERINFO_MC_COUNTRY_FLAG, NULL, | ||
288 | PEERINFO_MC_ADDRESS_AS_STRING, "<disconnected>", | ||
238 | -1); | 289 | -1); |
239 | return; | 290 | return; |
240 | } | 291 | } |
@@ -283,13 +334,14 @@ peerinfo_processor (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
283 | npid = (char *) &enc; | 334 | npid = (char *) &enc; |
284 | npid[4] = '\0'; | 335 | npid[4] = '\0'; |
285 | gtk_list_store_append (ls, &iter); | 336 | gtk_list_store_append (ls, &iter); |
286 | gtk_list_store_set (ls, &iter, 0, npid, 1, | 337 | gtk_list_store_set (ls, &iter, |
287 | 0 /* number of known addresses */ , | 338 | PEERINFO_MC_PEER_IDENTITY_STRING, npid, |
288 | 2, "" /* country name */ , | 339 | PEERINFO_MC_NUMBER_OF_ADDRESSES, (guint) 0, |
289 | 3, NULL /* country flag */ , | 340 | PEERINFO_MC_COUNTRY_NAME, "", |
290 | 4, (guint64) 0 /* bandwidth-in */ , | 341 | PEERINFO_MC_COUNTRY_FLAG, NULL, |
291 | 5, (guint64) 0 /* bandwidth-out */ , | 342 | PEERINFO_MC_BANDWIDTH_IN, (guint64) 0, |
292 | 6, "" /* addresses as strings */ , | 343 | PEERINFO_MC_BANDWIDTH_OUT, (guint64) 0, |
344 | PEERINFO_MC_ADDRESS_AS_STRING, "", | ||
293 | -1); | 345 | -1); |
294 | path = gtk_tree_model_get_path (tm, &iter); | 346 | path = gtk_tree_model_get_path (tm, &iter); |
295 | info = GNUNET_malloc (sizeof (struct PeerInfo)); | 347 | info = GNUNET_malloc (sizeof (struct PeerInfo)); |
@@ -344,8 +396,10 @@ status_cb (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
344 | GNUNET_assert (NULL != path); | 396 | GNUNET_assert (NULL != path); |
345 | GNUNET_assert (TRUE == gtk_tree_model_get_iter (tm, &iter, path)); | 397 | GNUNET_assert (TRUE == gtk_tree_model_get_iter (tm, &iter, path)); |
346 | gtk_tree_path_free (path); | 398 | gtk_tree_path_free (path); |
347 | gtk_list_store_set (ls, &iter, 4, (guint64) ntohl (bandwidth_in.value__), 5, | 399 | gtk_list_store_set (ls, &iter, |
348 | (guint64) ntohl (bandwidth_out.value__), -1); | 400 | PEERINFO_MC_BANDWIDTH_IN, (guint64) ntohl (bandwidth_in.value__), |
401 | PEERINFO_MC_BANDWIDTH_OUT, (guint64) ntohl (bandwidth_out.value__), | ||
402 | -1); | ||
349 | } | 403 | } |
350 | #endif | 404 | #endif |
351 | 405 | ||