diff options
Diffstat (limited to 'src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c')
-rw-r--r-- | src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c | 80 |
1 files changed, 39 insertions, 41 deletions
diff --git a/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c b/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c index 7e2df958..666f58bf 100644 --- a/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c +++ b/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | (C) 2011, 2012 Christian Grothoff (and other contributing authors) | 3 | (C) 2011-2013 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -301,7 +301,8 @@ add_namespace_to_ts (void *cls, | |||
301 | { | 301 | { |
302 | GtkTreeStore *ts = cls; | 302 | GtkTreeStore *ts = cls; |
303 | char *root; | 303 | char *root; |
304 | char *ns_name, *unique_ns_name; | 304 | char *ns_name; |
305 | char *unique_ns_name; | ||
305 | struct GNUNET_CRYPTO_EccPublicKey *nsid; | 306 | struct GNUNET_CRYPTO_EccPublicKey *nsid; |
306 | char *description; | 307 | char *description; |
307 | int desc_is_a_dup; | 308 | int desc_is_a_dup; |
@@ -316,8 +317,8 @@ add_namespace_to_ts (void *cls, | |||
316 | GNUNET_FS_pseudonym_get_info (GNUNET_FS_GTK_get_configuration (), | 317 | GNUNET_FS_pseudonym_get_info (GNUNET_FS_GTK_get_configuration (), |
317 | pseudonym, NULL, NULL, | 318 | pseudonym, NULL, NULL, |
318 | &ns_name, NULL); | 319 | &ns_name, NULL); |
319 | unique_ns_name = GNUNET_FS_pseudonym_name_uniquify ( | 320 | unique_ns_name = GNUNET_FS_pseudonym_name_uniquify (GNUNET_FS_GTK_get_configuration (), |
320 | GNUNET_FS_GTK_get_configuration (), pseudonym, ns_name, NULL); | 321 | pseudonym, ns_name, NULL); |
321 | GNUNET_free (ns_name); | 322 | GNUNET_free (ns_name); |
322 | nsid = GNUNET_new (struct GNUNET_CRYPTO_EccPublicKey); | 323 | nsid = GNUNET_new (struct GNUNET_CRYPTO_EccPublicKey); |
323 | *nsid = *pseudonym; | 324 | *nsid = *pseudonym; |
@@ -355,27 +356,22 @@ GNUNET_GTK_main_window_refresh_ns_list (struct GNUNET_GTK_MainWindowContext *mai | |||
355 | { | 356 | { |
356 | GtkTreeIter iter; | 357 | GtkTreeIter iter; |
357 | GtkTreePath *treepath; | 358 | GtkTreePath *treepath; |
358 | struct GNUNET_CRYPTO_EccPublicKey *key = NULL; | 359 | GtkTreeModel *model; |
360 | struct GNUNET_CRYPTO_EccPublicKey *key; | ||
359 | struct GNUNET_CRYPTO_EccPublicKey *selected_ns_id; | 361 | struct GNUNET_CRYPTO_EccPublicKey *selected_ns_id; |
360 | 362 | gboolean found; | |
361 | gboolean found = FALSE; | 363 | gchar *value; |
362 | gchar *value = NULL; | ||
363 | 364 | ||
365 | key = NULL; | ||
364 | if (NULL != main_ctx->selected_ns_row) | 366 | if (NULL != main_ctx->selected_ns_row) |
365 | { | 367 | { |
366 | GtkTreeModel *model; | ||
367 | treepath = gtk_tree_row_reference_get_path (main_ctx->selected_ns_row); | 368 | treepath = gtk_tree_row_reference_get_path (main_ctx->selected_ns_row); |
368 | model = gtk_tree_view_get_model (main_ctx->ns_selector_treeview); | 369 | model = gtk_tree_view_get_model (main_ctx->ns_selector_treeview); |
369 | if (model) | 370 | if (gtk_tree_model_get_iter (model, &iter, treepath)) |
370 | { | 371 | gtk_tree_model_get (model, &iter, |
371 | if (gtk_tree_model_get_iter (model, &iter, treepath)) | 372 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_KEY, |
372 | { | 373 | &key, |
373 | gtk_tree_model_get (model, &iter, | 374 | -1); |
374 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_KEY, | ||
375 | &key, | ||
376 | -1); | ||
377 | } | ||
378 | } | ||
379 | gtk_tree_path_free (treepath); | 375 | gtk_tree_path_free (treepath); |
380 | gtk_tree_row_reference_free (main_ctx->selected_ns_row); | 376 | gtk_tree_row_reference_free (main_ctx->selected_ns_row); |
381 | main_ctx->selected_ns_row = NULL; | 377 | main_ctx->selected_ns_row = NULL; |
@@ -387,23 +383,20 @@ GNUNET_GTK_main_window_refresh_ns_list (struct GNUNET_GTK_MainWindowContext *mai | |||
387 | *selected_ns_id = *key; | 383 | *selected_ns_id = *key; |
388 | } | 384 | } |
389 | 385 | ||
390 | if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL ( | 386 | if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (main_ctx->search_ns_treestore), |
391 | main_ctx->search_ns_treestore), &iter)) | 387 | &iter)) |
392 | { | 388 | { |
393 | while (TRUE) | 389 | do |
394 | { | 390 | { |
395 | gtk_tree_model_get (GTK_TREE_MODEL (main_ctx->search_ns_treestore), &iter, | 391 | gtk_tree_model_get (GTK_TREE_MODEL (main_ctx->search_ns_treestore), &iter, |
396 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_KEY, | 392 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_KEY, |
397 | &key, | 393 | &key, |
398 | -1); | 394 | -1); |
399 | GNUNET_free_non_null (key); | 395 | GNUNET_free_non_null (key); |
400 | if (TRUE != gtk_tree_model_iter_next (GTK_TREE_MODEL ( | 396 | } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (main_ctx->search_ns_treestore), |
401 | main_ctx->search_ns_treestore), &iter)) | 397 | &iter)); |
402 | break; | ||
403 | } | ||
404 | } | 398 | } |
405 | gtk_tree_store_clear (main_ctx->search_ns_treestore); | 399 | gtk_tree_store_clear (main_ctx->search_ns_treestore); |
406 | |||
407 | gtk_tree_store_insert_with_values (main_ctx->search_ns_treestore, &iter, NULL, G_MAXINT, | 400 | gtk_tree_store_insert_with_values (main_ctx->search_ns_treestore, &iter, NULL, G_MAXINT, |
408 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_NAME, | 401 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_NAME, |
409 | "Any", | 402 | "Any", |
@@ -417,11 +410,15 @@ GNUNET_GTK_main_window_refresh_ns_list (struct GNUNET_GTK_MainWindowContext *mai | |||
417 | 410 | ||
418 | if (NULL != main_ctx->ns_discovery_handle) | 411 | if (NULL != main_ctx->ns_discovery_handle) |
419 | GNUNET_FS_pseudonym_discovery_callback_unregister (main_ctx->ns_discovery_handle); | 412 | GNUNET_FS_pseudonym_discovery_callback_unregister (main_ctx->ns_discovery_handle); |
420 | main_ctx->ns_discovery_handle = GNUNET_FS_pseudonym_discovery_callback_register (main_ctx->cfg, | 413 | main_ctx->ns_discovery_handle |
421 | add_namespace_to_ts, main_ctx->search_ns_treestore); | 414 | = GNUNET_FS_pseudonym_discovery_callback_register (main_ctx->cfg, |
422 | 415 | &add_namespace_to_ts, | |
423 | if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL ( | 416 | main_ctx->search_ns_treestore); |
424 | main_ctx->search_ns_treestore), &iter)) | 417 | |
418 | found = FALSE; | ||
419 | value = NULL; | ||
420 | if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (main_ctx->search_ns_treestore), | ||
421 | &iter)) | ||
425 | { | 422 | { |
426 | while (TRUE) | 423 | while (TRUE) |
427 | { | 424 | { |
@@ -431,20 +428,21 @@ GNUNET_GTK_main_window_refresh_ns_list (struct GNUNET_GTK_MainWindowContext *mai | |||
431 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_KEY, | 428 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_KEY, |
432 | &key, | 429 | &key, |
433 | -1); | 430 | -1); |
434 | if (selected_ns_id == NULL) | 431 | if (NULL == selected_ns_id) |
435 | found = TRUE; | 432 | found = TRUE; |
436 | else if (key != NULL && memcmp (key, selected_ns_id, sizeof (struct GNUNET_CRYPTO_EccPublicKey)) == 0) | 433 | if ( (key != NULL) && |
434 | (0 == memcmp (key, selected_ns_id, sizeof (struct GNUNET_CRYPTO_EccPublicKey))) ) | ||
437 | found = TRUE; | 435 | found = TRUE; |
438 | if (found || (TRUE != gtk_tree_model_iter_next (GTK_TREE_MODEL ( | 436 | if (found || |
439 | main_ctx->search_ns_treestore), &iter))) | 437 | (! gtk_tree_model_iter_next (GTK_TREE_MODEL (main_ctx->search_ns_treestore), |
438 | &iter))) | ||
440 | break; | 439 | break; |
441 | else | 440 | g_free (value); |
442 | g_free (value); | ||
443 | } | 441 | } |
444 | } | 442 | } |
445 | if ( (!found) && | 443 | if ( (!found) && |
446 | gtk_tree_model_get_iter_first (GTK_TREE_MODEL ( | 444 | gtk_tree_model_get_iter_first (GTK_TREE_MODEL (main_ctx->search_ns_treestore), |
447 | main_ctx->search_ns_treestore), &iter)) | 445 | &iter)) |
448 | { | 446 | { |
449 | gtk_tree_model_get (GTK_TREE_MODEL (main_ctx->search_ns_treestore), &iter, | 447 | gtk_tree_model_get (GTK_TREE_MODEL (main_ctx->search_ns_treestore), &iter, |
450 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_NAME, | 448 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_NAME, |
@@ -460,7 +458,7 @@ GNUNET_GTK_main_window_refresh_ns_list (struct GNUNET_GTK_MainWindowContext *mai | |||
460 | if (value != NULL) | 458 | if (value != NULL) |
461 | { | 459 | { |
462 | gtk_label_set_text (main_ctx->search_ns_label, value); | 460 | gtk_label_set_text (main_ctx->search_ns_label, value); |
463 | g_free(value); | 461 | g_free (value); |
464 | } | 462 | } |
465 | GNUNET_free_non_null (selected_ns_id); | 463 | GNUNET_free_non_null (selected_ns_id); |
466 | } | 464 | } |