diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-03-14 15:28:46 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-03-14 15:28:46 +0000 |
commit | 3ba3eef3bdfe7d4ddf478c852865a0e8204e6ecc (patch) | |
tree | 5257fb60feff3f635da3bf1933f39ecfe544a4c5 | |
parent | fcc7edc56d78b6df3ed51607604d7621494a2046 (diff) | |
download | gnunet-gtk-3ba3eef3bdfe7d4ddf478c852865a0e8204e6ecc.tar.gz gnunet-gtk-3ba3eef3bdfe7d4ddf478c852865a0e8204e6ecc.zip |
- adding gns context
-rw-r--r-- | src/gns/gnunet-gns-gtk.c | 80 | ||||
-rw-r--r-- | src/gns/gnunet-gns-gtk_zone.c | 19 |
2 files changed, 79 insertions, 20 deletions
diff --git a/src/gns/gnunet-gns-gtk.c b/src/gns/gnunet-gns-gtk.c index f2d6f219..59edb42b 100644 --- a/src/gns/gnunet-gns-gtk.c +++ b/src/gns/gnunet-gns-gtk.c | |||
@@ -46,10 +46,7 @@ static GNUNET_HashCode zone; | |||
46 | */ | 46 | */ |
47 | static struct GNUNET_CRYPTO_RsaPrivateKey *zone_pkey; | 47 | static struct GNUNET_CRYPTO_RsaPrivateKey *zone_pkey; |
48 | 48 | ||
49 | /** | 49 | |
50 | * Handle to the namestore. | ||
51 | */ | ||
52 | static struct GNUNET_NAMESTORE_Handle *ns; | ||
53 | 50 | ||
54 | /** | 51 | /** |
55 | * Name of our zone as a string. | 52 | * Name of our zone as a string. |
@@ -63,6 +60,19 @@ static char *zonekey_directory; | |||
63 | 60 | ||
64 | static GtkWidget *main_window; | 61 | static GtkWidget *main_window; |
65 | 62 | ||
63 | struct GNUNET_GNS_Context | ||
64 | { | ||
65 | /** | ||
66 | * Handle to the namestore. | ||
67 | */ | ||
68 | struct GNUNET_NAMESTORE_Handle *ns; | ||
69 | |||
70 | GtkBuilder builder; | ||
71 | |||
72 | |||
73 | }; | ||
74 | |||
75 | |||
66 | /** | 76 | /** |
67 | * Get cfg. | 77 | * Get cfg. |
68 | */ | 78 | */ |
@@ -235,10 +245,12 @@ GNUNET_GNS_GTK_public_key_copy_button_clicked_cb (GtkButton *button, | |||
235 | static void | 245 | static void |
236 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 246 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
237 | { | 247 | { |
238 | if (NULL != ns) | 248 | struct GNUNET_GNS_Context *gns = cls; |
249 | GNUNET_assert (gns != NULL); | ||
250 | if (NULL != gns->ns) | ||
239 | { | 251 | { |
240 | GNUNET_NAMESTORE_disconnect (ns, GNUNET_NO); | 252 | GNUNET_NAMESTORE_disconnect (gns->ns, GNUNET_NO); |
241 | ns = NULL; | 253 | gns->ns = NULL; |
242 | } | 254 | } |
243 | if (NULL != zone_pkey) | 255 | if (NULL != zone_pkey) |
244 | { | 256 | { |
@@ -250,6 +262,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
250 | GNUNET_free (zonekey_directory); | 262 | GNUNET_free (zonekey_directory); |
251 | zonekey_directory = NULL; | 263 | zonekey_directory = NULL; |
252 | } | 264 | } |
265 | GNUNET_free (gns); | ||
253 | } | 266 | } |
254 | 267 | ||
255 | 268 | ||
@@ -265,7 +278,7 @@ GNUNET_GNS_GTK_quit_imagemenuitem_activate_cb (GtkMenuItem *menuitem, | |||
265 | { | 278 | { |
266 | GNUNET_GTK_tray_icon_destroy (); | 279 | GNUNET_GTK_tray_icon_destroy (); |
267 | GNUNET_GTK_main_loop_quit (ml); | 280 | GNUNET_GTK_main_loop_quit (ml); |
268 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | 281 | GNUNET_SCHEDULER_add_now (&shutdown_task, user_data); |
269 | } | 282 | } |
270 | 283 | ||
271 | 284 | ||
@@ -283,10 +296,35 @@ GNUNET_GNS_GTK_main_window_delete_event_cb (GtkWidget *widget, | |||
283 | { | 296 | { |
284 | GNUNET_GTK_tray_icon_destroy (); | 297 | GNUNET_GTK_tray_icon_destroy (); |
285 | GNUNET_GTK_main_loop_quit (ml); | 298 | GNUNET_GTK_main_loop_quit (ml); |
286 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | 299 | GNUNET_SCHEDULER_add_now (&shutdown_task, user_data); |
300 | } | ||
301 | |||
302 | struct ZoneIteration_Context | ||
303 | { | ||
304 | GNUNET_HashCode zone; | ||
305 | struct GNUNET_NAMESTORE_ZoneIterator * it; | ||
306 | }; | ||
307 | |||
308 | void zone_iteration_proc (void *cls, | ||
309 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, | ||
310 | struct GNUNET_TIME_Absolute expire, | ||
311 | const char *name, | ||
312 | unsigned int rd_len, | ||
313 | const struct GNUNET_NAMESTORE_RecordData *rd, | ||
314 | const struct GNUNET_CRYPTO_RsaSignature *signature) | ||
315 | { | ||
316 | struct ZoneIteration_Context * zc_ctx = cls; | ||
317 | GNUNET_assert (zc_ctx != NULL); | ||
318 | if ((NULL == zone_key) && (NULL == name)) | ||
319 | { | ||
320 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Zone iteration done\n"); | ||
321 | return; | ||
322 | } | ||
323 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Zone iteration dummy\n"); | ||
287 | } | 324 | } |
288 | 325 | ||
289 | 326 | ||
327 | |||
290 | /** | 328 | /** |
291 | * Actual main function run right after GNUnet's scheduler | 329 | * Actual main function run right after GNUnet's scheduler |
292 | * is initialized. Initializes up GTK and Glade. | 330 | * is initialized. Initializes up GTK and Glade. |
@@ -298,7 +336,7 @@ static void | |||
298 | run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 336 | run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
299 | { | 337 | { |
300 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub; | 338 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub; |
301 | 339 | struct GNUNET_GNS_Context *gns = GNUNET_malloc (sizeof (struct GNUNET_GNS_Context)); | |
302 | char *keyfile; | 340 | char *keyfile; |
303 | char *label; | 341 | char *label; |
304 | 342 | ||
@@ -333,22 +371,30 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
333 | _("Failed to read or create private zone key\n")); | 371 | _("Failed to read or create private zone key\n")); |
334 | return; | 372 | return; |
335 | } | 373 | } |
336 | GNUNET_CRYPTO_rsa_key_get_public (zone_pkey, | 374 | GNUNET_CRYPTO_rsa_key_get_public (zone_pkey, &pub); |
337 | &pub); | ||
338 | GNUNET_CRYPTO_hash (&pub, sizeof (pub), &zone); | 375 | GNUNET_CRYPTO_hash (&pub, sizeof (pub), &zone); |
339 | 376 | ||
340 | ns = GNUNET_NAMESTORE_connect (get_configuration ()); | 377 | gns->ns = GNUNET_NAMESTORE_connect (get_configuration ()); |
341 | if (NULL == ns) | 378 | if (NULL == gns->ns) |
342 | { | 379 | { |
343 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 380 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
344 | _("Failed to connect to namestore\n")); | 381 | _("Failed to connect to namestore\n")); |
345 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | 382 | GNUNET_SCHEDULER_add_now (&shutdown_task, gns); |
346 | return; | 383 | return; |
347 | } | 384 | } |
348 | if (GNUNET_OK != GNUNET_GTK_main_loop_build_window (ml, NULL)) | 385 | |
386 | struct ZoneIteration_Context * zc_ctx = GNUNET_malloc (sizeof (struct ZoneIteration_Context)); | ||
387 | zc_ctx->zone = zone; | ||
388 | GNUNET_NAMESTORE_zone_iteration_start(gns->ns, &zone, | ||
389 | GNUNET_NAMESTORE_RF_NONE, | ||
390 | GNUNET_NAMESTORE_RF_NONE, | ||
391 | &zone_iteration_proc, | ||
392 | zc_ctx); | ||
393 | |||
394 | if (GNUNET_OK != GNUNET_GTK_main_loop_build_window (ml, gns)) | ||
349 | { | 395 | { |
350 | GNUNET_break (0); | 396 | GNUNET_break (0); |
351 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | 397 | GNUNET_SCHEDULER_add_now (&shutdown_task, gns); |
352 | return; | 398 | return; |
353 | } | 399 | } |
354 | zone_as_string = GNUNET_strdup (GNUNET_h2s_full (&zone)); | 400 | zone_as_string = GNUNET_strdup (GNUNET_h2s_full (&zone)); |
diff --git a/src/gns/gnunet-gns-gtk_zone.c b/src/gns/gnunet-gns-gtk_zone.c index 71160c1d..a6218623 100644 --- a/src/gns/gnunet-gns-gtk_zone.c +++ b/src/gns/gnunet-gns-gtk_zone.c | |||
@@ -24,7 +24,7 @@ | |||
24 | * @brief everything releated to the zone tree view | 24 | * @brief everything releated to the zone tree view |
25 | */ | 25 | */ |
26 | #include "gnunet_gtk.h" | 26 | #include "gnunet_gtk.h" |
27 | 27 | #include "gnunet-gns-gtk.h" | |
28 | 28 | ||
29 | 29 | ||
30 | 30 | ||
@@ -150,8 +150,21 @@ GNUNET_GNS_GTK_main_treeview_popup_menu_cb (GtkWidget *widget, | |||
150 | void | 150 | void |
151 | GNUNET_GNS_GTK_main_treeview_realize_cb (GtkWidget *widget, | 151 | GNUNET_GNS_GTK_main_treeview_realize_cb (GtkWidget *widget, |
152 | gpointer user_data) | 152 | gpointer user_data) |
153 | { | 153 | { |
154 | GNUNET_break (0); // FIXME, not implemented | 154 | /* |
155 | struct GNUNET_GNS_Context *gns=user_data; | ||
156 | GtkBuilder *builder = gns->builder; | ||
157 | GNUNET_assert (GTK_IS_BUILDER(user_data)); | ||
158 | |||
159 | GtkTreeModel * tm; | ||
160 | tm = GTK_TREE_MODEL(gtk_builder_get_object (builder, "GNUNET_GNS_GTK_treestore")); | ||
161 | GNUNET_assert (tm != NULL); | ||
162 | |||
163 | //gtk_tree | ||
164 | */ | ||
165 | GNUNET_break (0); | ||
166 | |||
167 | |||
155 | } | 168 | } |
156 | 169 | ||
157 | 170 | ||