aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-fs-gtk_main-window-search.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/gnunet-fs-gtk_main-window-search.c')
-rw-r--r--src/fs/gnunet-fs-gtk_main-window-search.c87
1 files changed, 85 insertions, 2 deletions
diff --git a/src/fs/gnunet-fs-gtk_main-window-search.c b/src/fs/gnunet-fs-gtk_main-window-search.c
index 3032b501..37bf81b1 100644
--- a/src/fs/gnunet-fs-gtk_main-window-search.c
+++ b/src/fs/gnunet-fs-gtk_main-window-search.c
@@ -298,6 +298,55 @@ main_window_search_entry_key_press_event_cb (GtkWidget * widget,
298 298
299 299
300/** 300/**
301 * Abort the given PSEU lookup.
302 *
303 * @param lctx lookup to abort.
304 */
305void
306abort_pseu_lookup (struct PseuLookupContext *lctx)
307{
308 struct GNUNET_GTK_MainWindowContext *main_ctx = lctx->main_ctx;
309
310 if (NULL != lctx->lr)
311 {
312 GNUNET_GNS_lookup_cancel (lctx->lr);
313 lctx->lr = NULL;
314 }
315 GNUNET_CONTAINER_DLL_remove (main_ctx->lctx_head,
316 main_ctx->lctx_tail,
317 lctx);
318 GNUNET_free (lctx);
319}
320
321
322/**
323 * Iterator called on obtained result for a GNS lookup for
324 * the PSEU lookup when "saving" a zone. The actual saving
325 * should already have happened via the shortening of GNS,
326 * so we only need to clean up.
327 *
328 * FIXME: this is a drastic simplification, as shortening
329 * may fail (name used, PSEU record not found); in those
330 * cases, we should _still_ do something here...
331 *
332 * @param cls closure with the `struct PseuLookupContext`
333 * @param rd_count number of records in @a rd
334 * @param rd the records in reply
335 */
336static void
337lookup_finished (void *cls,
338 uint32_t rd_count,
339 const struct GNUNET_NAMESTORE_RecordData *rd)
340{
341 struct PseuLookupContext *lctx = cls;
342
343 /* FIXME: might want to give visual feedback to the user here */
344 lctx->lr = NULL;
345 abort_pseu_lookup (lctx);
346}
347
348
349/**
301 * User clicked on the 'save' button in the search line of the main window. 350 * User clicked on the 'save' button in the search line of the main window.
302 * Store the selected namespace in the "sks-fs" zone. 351 * Store the selected namespace in the "sks-fs" zone.
303 * 352 *
@@ -310,9 +359,43 @@ GNUNET_FS_GTK_save_button_clicked_cb (GtkButton * button,
310 gpointer user_data) 359 gpointer user_data)
311{ 360{
312 struct GNUNET_GTK_MainWindowContext *main_ctx = user_data; 361 struct GNUNET_GTK_MainWindowContext *main_ctx = user_data;
362 GtkComboBox *widget;
363 const gchar *text;
364 struct GNUNET_CRYPTO_EccPublicKey pkey;
365 int ret;
366 struct PseuLookupContext *lctx;
313 367
314 GNUNET_break (0); 368 if (NULL == main_ctx->gns)
315 (void) main_ctx; 369 {
370 GNUNET_break (0);
371 return;
372 }
373 widget = GTK_COMBO_BOX (GNUNET_FS_GTK_get_main_window_object
374 ("main_window_search_namespace_combobox"));
375 text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (widget))));
376 ret = GNUNET_NAMESTORE_zkey_to_pkey (text, &pkey);
377 if (GNUNET_OK != ret)
378 {
379 GNUNET_break (0);
380 return;
381 }
382 lctx = GNUNET_new (struct PseuLookupContext);
383 lctx->main_ctx = main_ctx;
384 GNUNET_CONTAINER_DLL_insert (main_ctx->lctx_head,
385 main_ctx->lctx_tail,
386 lctx);
387 lctx->lr = GNUNET_GNS_lookup (main_ctx->gns,
388 GNUNET_GNS_MASTERZONE_STR,
389 &pkey,
390 GNUNET_NAMESTORE_TYPE_PSEU,
391 GNUNET_NO,
392 main_ctx->sks_zone /* FIXME: may want more explicit
393 control than using shortening here */,
394 &lookup_finished,
395 lctx);
396 /* give visual feedback that something is happening */
397 gtk_widget_set_sensitive (GTK_WIDGET (button),
398 FALSE);
316} 399}
317 400
318 401