aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-fs-gtk_publish-dialog.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/gnunet-fs-gtk_publish-dialog.c')
-rw-r--r--src/fs/gnunet-fs-gtk_publish-dialog.c86
1 files changed, 50 insertions, 36 deletions
diff --git a/src/fs/gnunet-fs-gtk_publish-dialog.c b/src/fs/gnunet-fs-gtk_publish-dialog.c
index 14a855ea..975db8c0 100644
--- a/src/fs/gnunet-fs-gtk_publish-dialog.c
+++ b/src/fs/gnunet-fs-gtk_publish-dialog.c
@@ -1,10 +1,10 @@
1/* 1/*
2 This file is part of GNUnet 2 This file is part of GNUnet
3 (C) 2005, 2006, 2010, 2012 Christian Grothoff (and other contributing authors) 3 (C) 2005-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
7 by the Free Software Foundation; either version 2, or (at your 7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version. 8 option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
@@ -27,6 +27,8 @@
27#include "gnunet-fs-gtk_publish-edit-dialog.h" 27#include "gnunet-fs-gtk_publish-edit-dialog.h"
28#include <gnunet/gnunet_util_lib.h> 28#include <gnunet/gnunet_util_lib.h>
29#include <gnunet/gnunet_fs_service.h> 29#include <gnunet/gnunet_fs_service.h>
30#include <gnunet/gnunet_identity_service.h>
31
30 32
31#define MARKER_DIR_FILE_SIZE "-" 33#define MARKER_DIR_FILE_SIZE "-"
32 34
@@ -246,7 +248,7 @@ struct MainPublishingDialogContext
246 /** 248 /**
247 * Default namespace. May be NULL. 249 * Default namespace. May be NULL.
248 */ 250 */
249 struct GNUNET_FS_Namespace *ns; 251 struct GNUNET_IDENTITY_Ego *ns;
250 252
251 /** 253 /**
252 * Stores the value that was in identifier_entry previously. 254 * Stores the value that was in identifier_entry previously.
@@ -390,13 +392,13 @@ struct AddDirClientContext
390}; 392};
391 393
392 394
393static void clear_keywords_from_tm (struct MainPublishingDialogContext *ctx); 395static void
396clear_keywords_from_tm (struct MainPublishingDialogContext *ctx);
394 397
395 398
396/* ************************ editing operations inside the master dialog ********************* */ 399/* ************************ editing operations inside the master dialog ********************* */
397 400
398 401
399
400/** 402/**
401 * Check if two GtkTreeIters refer to the same element. 403 * Check if two GtkTreeIters refer to the same element.
402 * 404 *
@@ -406,9 +408,9 @@ static void clear_keywords_from_tm (struct MainPublishingDialogContext *ctx);
406 * @return GNUNET_YES if they are equal 408 * @return GNUNET_YES if they are equal
407 */ 409 */
408static int 410static int
409gtk_tree_iter_equals (GtkTreeModel * tm, 411gtk_tree_iter_equals (GtkTreeModel *tm,
410 GtkTreeIter * i1, 412 GtkTreeIter *i1,
411 GtkTreeIter * i2) 413 GtkTreeIter *i2)
412{ 414{
413 GtkTreePath *p1; 415 GtkTreePath *p1;
414 GtkTreePath *p2; 416 GtkTreePath *p2;
@@ -2041,8 +2043,6 @@ close_master_publish_dialog (struct MainPublishingDialogContext *ctx)
2041 gtk_widget_destroy (GTK_WIDGET (ctx->master_pubdialog)); 2043 gtk_widget_destroy (GTK_WIDGET (ctx->master_pubdialog));
2042 g_object_unref (G_OBJECT (ctx->builder)); 2044 g_object_unref (G_OBJECT (ctx->builder));
2043 GNUNET_free_non_null (ctx->ns_name); 2045 GNUNET_free_non_null (ctx->ns_name);
2044 if (ctx->ns)
2045 GNUNET_FS_namespace_delete (ctx->ns, GNUNET_NO);
2046 g_free (ctx->previous_id); 2046 g_free (ctx->previous_id);
2047 GNUNET_free (ctx); 2047 GNUNET_free (ctx);
2048 return GNUNET_YES; 2048 return GNUNET_YES;
@@ -2073,17 +2073,12 @@ insert_advertisement (void *cls, struct GNUNET_FS_FileInformation *fi,
2073 void **client_info) 2073 void **client_info)
2074{ 2074{
2075 struct MainPublishingDialogContext *ctx = cls; 2075 struct MainPublishingDialogContext *ctx = cls;
2076 2076 struct GNUNET_CRYPTO_EccPublicKey pub;
2077 struct GNUNET_FS_Uri *sks_uri; 2077 struct GNUNET_FS_Uri *sks_uri;
2078 char *emsg;
2079 char *sks_uri_string; 2078 char *sks_uri_string;
2080 2079
2081 emsg = NULL; 2080 GNUNET_IDENTITY_ego_get_public_key (ctx->ns, &pub);
2082 sks_uri = GNUNET_FS_uri_sks_create (ctx->ns, "/", &emsg); 2081 sks_uri = GNUNET_FS_uri_sks_create (&pub, "/");
2083 GNUNET_free_non_null (emsg);
2084 if (NULL == sks_uri)
2085 return GNUNET_SYSERR;
2086
2087 sks_uri_string = GNUNET_FS_uri_to_string (sks_uri); 2082 sks_uri_string = GNUNET_FS_uri_to_string (sks_uri);
2088 GNUNET_FS_uri_destroy (sks_uri); 2083 GNUNET_FS_uri_destroy (sks_uri);
2089 if (NULL == sks_uri_string) 2084 if (NULL == sks_uri_string)
@@ -2110,7 +2105,7 @@ GNUNET_GTK_master_publish_dialog_execute_button_clicked_cb (GtkButton * button,
2110{ 2105{
2111 struct MainPublishingDialogContext *ctx = user_data; 2106 struct MainPublishingDialogContext *ctx = user_data;
2112 gchar *namespace_id; 2107 gchar *namespace_id;
2113 struct GNUNET_FS_Namespace *ns; 2108 struct GNUNET_IDENTITY_Ego *ns;
2114 const gchar *namespace_uid; 2109 const gchar *namespace_uid;
2115 struct GNUNET_FS_FileInformation *fi; 2110 struct GNUNET_FS_FileInformation *fi;
2116 GtkTreeIter iter; 2111 GtkTreeIter iter;
@@ -2144,7 +2139,8 @@ GNUNET_GTK_master_publish_dialog_execute_button_clicked_cb (GtkButton * button,
2144 if (NULL != (id_entry_text = gtk_entry_get_text (GTK_ENTRY (ctx->identifier_entry)))) 2139 if (NULL != (id_entry_text = gtk_entry_get_text (GTK_ENTRY (ctx->identifier_entry))))
2145 namespace_id = g_strdup (id_entry_text); 2140 namespace_id = g_strdup (id_entry_text);
2146 else if (!do_global) 2141 else if (!do_global)
2147 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Global publication is disabled, but namespace_id is not available\n"); 2142 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2143 "Global publication is disabled, but namespace_id is not available\n");
2148 if ((NULL != namespace_id) && ('\0' == namespace_id[0])) 2144 if ((NULL != namespace_id) && ('\0' == namespace_id[0]))
2149 { 2145 {
2150 g_free (namespace_id); 2146 g_free (namespace_id);
@@ -2158,10 +2154,12 @@ GNUNET_GTK_master_publish_dialog_execute_button_clicked_cb (GtkButton * button,
2158 ns = ctx->ns; 2154 ns = ctx->ns;
2159 } 2155 }
2160 else if (!do_global) 2156 else if (!do_global)
2161 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Global publication is disabled, but namespace_id unavailable or zero-length\n"); 2157 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2158 "Global publication is disabled, but namespace_id unavailable or zero-length\n");
2162 } 2159 }
2163 else if (!do_global) 2160 else if (!do_global)
2164 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Global publication is disabled, ns is either NULL or disabled, yet 'Execute' was pressed\n"); 2161 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2162 "Global publication is disabled, ns is either NULL or disabled, yet 'Execute' was pressed\n");
2165 if ((!do_global) && (NULL == ns)) 2163 if ((!do_global) && (NULL == ns))
2166 { 2164 {
2167 g_free (namespace_id); 2165 g_free (namespace_id);
@@ -2179,7 +2177,8 @@ GNUNET_GTK_master_publish_dialog_execute_button_clicked_cb (GtkButton * button,
2179 GNUNET_FS_file_information_inspect (fi, insert_advertisement, ctx); 2177 GNUNET_FS_file_information_inspect (fi, insert_advertisement, ctx);
2180 /* FIXME-FEATURE-BUG-MINOR: should we convert namespace id and uid from UTF8? */ 2178 /* FIXME-FEATURE-BUG-MINOR: should we convert namespace id and uid from UTF8? */
2181 GNUNET_FS_publish_start (GNUNET_FS_GTK_get_fs_handle (), 2179 GNUNET_FS_publish_start (GNUNET_FS_GTK_get_fs_handle (),
2182 fi, ns, 2180 fi,
2181 GNUNET_IDENTITY_ego_get_private_key (ns),
2183 namespace_id, namespace_uid, 2182 namespace_id, namespace_uid,
2184 GNUNET_FS_PUBLISH_OPTION_NONE); 2183 GNUNET_FS_PUBLISH_OPTION_NONE);
2185 } 2184 }
@@ -2384,7 +2383,7 @@ struct UpdateableContext
2384 /** 2383 /**
2385 * Handle to the namespace. 2384 * Handle to the namespace.
2386 */ 2385 */
2387 struct GNUNET_FS_Namespace *ns; 2386 struct GNUNET_IDENTITY_Ego *ns;
2388 2387
2389 /** 2388 /**
2390 * Hash codes of identifiers already added to tree store. 2389 * Hash codes of identifiers already added to tree store.
@@ -2531,7 +2530,10 @@ add_updateable_to_ts (void *cls, const char *last_id,
2531 sc.ns = uc->ns; 2530 sc.ns = uc->ns;
2532 sc.seen = uc->seen; 2531 sc.seen = uc->seen;
2533 sc.update_called = GNUNET_NO; 2532 sc.update_called = GNUNET_NO;
2534 GNUNET_FS_namespace_list_updateable (uc->ns, next_id, &add_updateable_to_ts, 2533 GNUNET_FS_namespace_list_updateable (GNUNET_FS_GTK_get_fs_handle (),
2534 GNUNET_IDENTITY_ego_get_private_key (uc->ns),
2535 next_id,
2536 &add_updateable_to_ts,
2535 &sc); 2537 &sc);
2536 if ((sc.update_called == GNUNET_NO) && (next_id != NULL) && 2538 if ((sc.update_called == GNUNET_NO) && (next_id != NULL) &&
2537 (strlen (next_id) > 0)) 2539 (strlen (next_id) > 0))
@@ -2560,12 +2562,15 @@ add_updateable_to_ts (void *cls, const char *last_id,
2560 * @return GNUNET_YES, always. 2562 * @return GNUNET_YES, always.
2561 */ 2563 */
2562static int 2564static int
2563free_seen_paths (void *cls, const struct GNUNET_HashCode * key, void *value) 2565free_seen_paths (void *cls,
2566 const struct GNUNET_HashCode *key,
2567 void *value)
2564{ 2568{
2565 GNUNET_free_non_null (value); 2569 GNUNET_free_non_null (value);
2566 return GNUNET_YES; 2570 return GNUNET_YES;
2567} 2571}
2568 2572
2573
2569/** 2574/**
2570 * Add all updateable entries of the current namespace to the 2575 * Add all updateable entries of the current namespace to the
2571 * tree store. 2576 * tree store.
@@ -2575,7 +2580,8 @@ free_seen_paths (void *cls, const struct GNUNET_HashCode * key, void *value)
2575 * @param id identity of the namespace to add 2580 * @param id identity of the namespace to add
2576 */ 2581 */
2577static void 2582static void
2578add_namespace_to_ts (GtkTreeStore *ts, struct GNUNET_FS_Namespace *ns) 2583add_namespace_to_ts (GtkTreeStore *ts,
2584 struct GNUNET_IDENTITY_Ego *ns)
2579{ 2585{
2580 struct UpdateableContext uc; 2586 struct UpdateableContext uc;
2581 2587
@@ -2584,13 +2590,15 @@ add_namespace_to_ts (GtkTreeStore *ts, struct GNUNET_FS_Namespace *ns)
2584 uc.ns = ns; 2590 uc.ns = ns;
2585 uc.update_called = GNUNET_NO; 2591 uc.update_called = GNUNET_NO;
2586 uc.seen = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO); 2592 uc.seen = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO);
2587 GNUNET_FS_namespace_list_updateable (uc.ns, NULL, &add_updateable_to_ts, &uc); 2593 GNUNET_FS_namespace_list_updateable (GNUNET_FS_GTK_get_fs_handle (),
2594 GNUNET_IDENTITY_ego_get_private_key (uc.ns),
2595 NULL,
2596 &add_updateable_to_ts, &uc);
2588 GNUNET_CONTAINER_multihashmap_iterate (uc.seen, free_seen_paths, NULL); 2597 GNUNET_CONTAINER_multihashmap_iterate (uc.seen, free_seen_paths, NULL);
2589 GNUNET_CONTAINER_multihashmap_destroy (uc.seen); 2598 GNUNET_CONTAINER_multihashmap_destroy (uc.seen);
2590} 2599}
2591 2600
2592 2601
2593
2594/** 2602/**
2595 * Run the file-publishing operation (by opening the master publishing dialog). 2603 * Run the file-publishing operation (by opening the master publishing dialog).
2596 * 2604 *
@@ -2598,7 +2606,8 @@ add_namespace_to_ts (GtkTreeStore *ts, struct GNUNET_FS_Namespace *ns)
2598 * @param user_data builder of the main window 2606 * @param user_data builder of the main window
2599 */ 2607 */
2600void 2608void
2601GNUNET_GTK_main_menu_file_publish_activate_cb (GtkWidget * dummy, gpointer user_data) 2609GNUNET_GTK_main_menu_file_publish_activate_cb (GtkWidget * dummy,
2610 gpointer user_data)
2602{ 2611{
2603 struct MainPublishingDialogContext *ctx; 2612 struct MainPublishingDialogContext *ctx;
2604/* GtkTreeView *pseudonym_treeview;*/ 2613/* GtkTreeView *pseudonym_treeview;*/
@@ -2608,9 +2617,9 @@ GNUNET_GTK_main_menu_file_publish_activate_cb (GtkWidget * dummy, gpointer user_
2608 int own_enabled; 2617 int own_enabled;
2609 int global_enabled; 2618 int global_enabled;
2610 2619
2611 ctx = GNUNET_malloc (sizeof (struct MainPublishingDialogContext)); 2620 ctx = GNUNET_new (struct MainPublishingDialogContext);
2612 ctx->builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_publish_dialog.glade", ctx); 2621 ctx->builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_publish_dialog.glade", ctx);
2613 if (ctx->builder == NULL) 2622 if (NULL == ctx->builder)
2614 { 2623 {
2615 GNUNET_break (0); 2624 GNUNET_break (0);
2616 GNUNET_free (ctx); 2625 GNUNET_free (ctx);
@@ -2678,16 +2687,21 @@ GNUNET_GTK_main_menu_file_publish_activate_cb (GtkWidget * dummy, gpointer user_
2678 G_CALLBACK (identifiers_selection_changed_cb), ctx); 2687 G_CALLBACK (identifiers_selection_changed_cb), ctx);
2679 2688
2680 cfg = GNUNET_FS_GTK_get_configuration (); 2689 cfg = GNUNET_FS_GTK_get_configuration ();
2681 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, 2690#if FIXME_MIGRATE_TO_IDENTITY_SERVICE
2682 "gnunet-fs-gtk", "DEFAULT_NAMESPACE", &ctx->ns_name)) 2691 if (GNUNET_OK !=
2692 GNUNET_CONFIGURATION_get_value_string (cfg,
2693 "gnunet-fs-gtk",
2694 "DEFAULT_NAMESPACE",
2695 &ctx->ns_name))
2683 ctx->ns_name = NULL; 2696 ctx->ns_name = NULL;
2684 else 2697 else
2685 { 2698 {
2686 ctx->ns = GNUNET_FS_namespace_open_existing (GNUNET_FS_GTK_get_fs_handle (), ctx->ns_name); 2699 ctx->ns = GNUNET_FS_namespace_open_existing (GNUNET_FS_GTK_get_fs_handle (),
2700 ctx->ns_name);
2687 if (NULL == ctx->ns) 2701 if (NULL == ctx->ns)
2688 GNUNET_free (ctx->ns_name); 2702 GNUNET_free (ctx->ns_name);
2689 } 2703 }
2690 2704#endif
2691 have_ns = (NULL != ctx->ns); 2705 have_ns = (NULL != ctx->ns);
2692 2706
2693 gtk_widget_set_sensitive (ctx->own_checkbox, have_ns); 2707 gtk_widget_set_sensitive (ctx->own_checkbox, have_ns);