diff options
Diffstat (limited to 'src/fs/gnunet-fs-gtk-main_window_adv_pseudonym.c')
-rw-r--r-- | src/fs/gnunet-fs-gtk-main_window_adv_pseudonym.c | 78 |
1 files changed, 42 insertions, 36 deletions
diff --git a/src/fs/gnunet-fs-gtk-main_window_adv_pseudonym.c b/src/fs/gnunet-fs-gtk-main_window_adv_pseudonym.c index 9b76f2ab..77ae7353 100644 --- a/src/fs/gnunet-fs-gtk-main_window_adv_pseudonym.c +++ b/src/fs/gnunet-fs-gtk-main_window_adv_pseudonym.c | |||
@@ -66,20 +66,22 @@ selection_changed_cb (GtkTreeSelection * ts, gpointer user_data) | |||
66 | gtk_widget_set_sensitive (ok_button, FALSE); | 66 | gtk_widget_set_sensitive (ok_button, FALSE); |
67 | } | 67 | } |
68 | 68 | ||
69 | struct namespace_data_struct | 69 | struct NamespaceAdvertisementContext |
70 | { | 70 | { |
71 | struct GNUNET_FS_Namespace *ns; | 71 | struct GNUNET_FS_Namespace *ns; |
72 | int do_index; | 72 | int do_index; |
73 | char *short_fn; | 73 | const char *short_fn; |
74 | guint anonymity_level; | 74 | guint anonymity_level; |
75 | guint priority; | 75 | guint priority; |
76 | gchar *root; | 76 | const char *root; |
77 | struct GNUNET_FS_FileInformation *fip; | ||
77 | }; | 78 | }; |
78 | 79 | ||
80 | |||
79 | /** | 81 | /** |
80 | * Function called on entries in a GNUNET_FS_FileInformation publish-structure. | 82 | * Function called on entries in a GNUNET_FS_FileInformation publish-structure. |
81 | * | 83 | * |
82 | * @param cls closure | 84 | * @param cls closure, a 'struct NamespaceAdvertisementContext *' |
83 | * @param fi the entry in the publish-structure | 85 | * @param fi the entry in the publish-structure |
84 | * @param length length of the file or directory | 86 | * @param length length of the file or directory |
85 | * @param meta metadata for the file or directory (can be modified) | 87 | * @param meta metadata for the file or directory (can be modified) |
@@ -91,41 +93,44 @@ struct namespace_data_struct | |||
91 | * this entry from the directory, GNUNET_SYSERR | 93 | * this entry from the directory, GNUNET_SYSERR |
92 | * to abort the iteration | 94 | * to abort the iteration |
93 | */ | 95 | */ |
94 | int | 96 | static int |
95 | advertise_namespace (void *cls, struct GNUNET_FS_FileInformation *fi, | 97 | advertise_namespace (void *cls, struct GNUNET_FS_FileInformation *fi, |
96 | uint64_t length, struct GNUNET_CONTAINER_MetaData *meta, | 98 | uint64_t length, struct GNUNET_CONTAINER_MetaData *meta, |
97 | struct GNUNET_FS_Uri **uri, struct GNUNET_FS_BlockOptions *bo, | 99 | struct GNUNET_FS_Uri **uri, struct GNUNET_FS_BlockOptions *bo, |
98 | int *do_index, void **client_info) | 100 | int *do_index, void **client_info) |
99 | { | 101 | { |
100 | struct namespace_data_struct *nds; | 102 | struct NamespaceAdvertisementContext *nds = cls; |
101 | nds = (struct namespace_data_struct *) cls; | 103 | |
102 | GNUNET_FS_namespace_advertise (GNUNET_FS_GTK_get_fs_handle (), *uri, | 104 | GNUNET_FS_namespace_advertise (GNUNET_FS_GTK_get_fs_handle (), *uri, |
103 | nds->ns, meta, bo, nds->root, NULL, NULL); | 105 | nds->ns, meta, bo, nds->root, NULL, NULL); |
104 | return GNUNET_SYSERR; | 106 | return GNUNET_SYSERR; |
105 | } | 107 | } |
106 | 108 | ||
107 | void | 109 | |
108 | adv_pseudonym_edit_publish_dialog_cb (gpointer cls, int *do_index, char **short_fn, | 110 | static void |
109 | guint * anonymity_level, guint * priority, gchar *root, | 111 | adv_pseudonym_edit_publish_dialog_cb (gpointer cls, |
110 | struct GNUNET_FS_FileInformation *fip, gint ret) | 112 | int do_index, |
113 | const char *short_fn, | ||
114 | guint anonymity_level, | ||
115 | guint priority, | ||
116 | const char *root, | ||
117 | gint ret) | ||
111 | { | 118 | { |
112 | struct namespace_data_struct *nds; | 119 | struct NamespaceAdvertisementContext *nds = cls; |
113 | nds = (struct namespace_data_struct *) cls; | ||
114 | 120 | ||
115 | if (ret == GTK_RESPONSE_OK) | 121 | if (ret == GTK_RESPONSE_OK) |
116 | { | 122 | { |
117 | nds->do_index = *do_index; | 123 | nds->do_index = do_index; |
118 | nds->short_fn = *short_fn; | 124 | nds->short_fn = short_fn; |
119 | nds->anonymity_level = *anonymity_level; | 125 | nds->anonymity_level = anonymity_level; |
120 | nds->priority = *priority; | 126 | nds->priority = priority; |
121 | nds->root = root; | 127 | nds->root = root; |
122 | GNUNET_FS_file_information_inspect (fip, | 128 | GNUNET_FS_file_information_inspect (nds->fip, |
123 | advertise_namespace, nds); | 129 | &advertise_namespace, nds); |
124 | } | 130 | } |
125 | g_free (nds->root); | ||
126 | GNUNET_FS_namespace_delete (nds->ns, GNUNET_NO); | 131 | GNUNET_FS_namespace_delete (nds->ns, GNUNET_NO); |
127 | g_free (nds); | 132 | GNUNET_FS_file_information_destroy (nds->fip, NULL, NULL); |
128 | GNUNET_FS_file_information_destroy (fip, NULL, NULL); | 133 | GNUNET_free (nds); |
129 | } | 134 | } |
130 | 135 | ||
131 | void | 136 | void |
@@ -141,12 +146,11 @@ GNUNET_GTK_select_pseudonym_dialog_response_cb (GtkDialog *dialog, | |||
141 | struct GNUNET_FS_Namespace *ns; | 146 | struct GNUNET_FS_Namespace *ns; |
142 | struct GNUNET_FS_Namespace *nso; | 147 | struct GNUNET_FS_Namespace *nso; |
143 | GtkWindow *transient; | 148 | GtkWindow *transient; |
144 | struct namespace_data_struct *nds; | 149 | struct NamespaceAdvertisementContext *nds; |
145 | struct GNUNET_FS_FileInformation *fip; | ||
146 | struct GNUNET_CONTAINER_MetaData *meta; | 150 | struct GNUNET_CONTAINER_MetaData *meta; |
147 | builder = GTK_BUILDER (user_data); | ||
148 | struct GNUNET_FS_BlockOptions bo; | 151 | struct GNUNET_FS_BlockOptions bo; |
149 | 152 | ||
153 | builder = GTK_BUILDER (user_data); | ||
150 | ad = GTK_WIDGET (gtk_builder_get_object | 154 | ad = GTK_WIDGET (gtk_builder_get_object |
151 | (builder, "GNUNET_GTK_select_pseudonym_dialog")); | 155 | (builder, "GNUNET_GTK_select_pseudonym_dialog")); |
152 | 156 | ||
@@ -178,7 +182,7 @@ GNUNET_GTK_select_pseudonym_dialog_response_cb (GtkDialog *dialog, | |||
178 | 182 | ||
179 | meta = GNUNET_CONTAINER_meta_data_create (); | 183 | meta = GNUNET_CONTAINER_meta_data_create (); |
180 | 184 | ||
181 | nds = g_new0 (struct namespace_data_struct, 1); | 185 | nds = GNUNET_malloc (sizeof (struct NamespaceAdvertisementContext)); |
182 | nds->ns = ns; | 186 | nds->ns = ns; |
183 | nds->do_index = FALSE; | 187 | nds->do_index = FALSE; |
184 | nds->short_fn = NULL; | 188 | nds->short_fn = NULL; |
@@ -188,14 +192,16 @@ GNUNET_GTK_select_pseudonym_dialog_response_cb (GtkDialog *dialog, | |||
188 | /* This is a bogus fileinfo. It's needed because edit_publish_dialog | 192 | /* This is a bogus fileinfo. It's needed because edit_publish_dialog |
189 | * was written to work with fileinfo, and return a fileinfo. | 193 | * was written to work with fileinfo, and return a fileinfo. |
190 | */ | 194 | */ |
191 | memset (&bo, 0, sizeof (bo)); | 195 | nds->fip = GNUNET_FS_file_information_create_empty_directory (NULL, NULL, |
192 | fip = GNUNET_FS_file_information_create_empty_directory (NULL, NULL, | 196 | NULL, meta, &bo); |
193 | NULL, meta, &bo); | 197 | memset (&bo, 0, sizeof (bo)); |
194 | GNUNET_CONTAINER_meta_data_destroy (meta); | 198 | GNUNET_CONTAINER_meta_data_destroy (meta); |
195 | 199 | GNUNET_FS_GTK_edit_publish_dialog (builder, transient, | |
196 | GNUNET_FS_GTK_edit_publish_dialog (builder, transient, &nds->do_index, | 200 | nds->do_index, |
197 | &nds->short_fn, &nds->anonymity_level, &nds->priority, | 201 | nds->short_fn, |
198 | fip, FALSE, &adv_pseudonym_edit_publish_dialog_cb, nds); | 202 | nds->anonymity_level, |
203 | nds->priority, | ||
204 | nds->fip, FALSE, &adv_pseudonym_edit_publish_dialog_cb, nds); | ||
199 | } | 205 | } |
200 | 206 | ||
201 | void | 207 | void |