aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-fs-gtk_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/gnunet-fs-gtk_common.c')
-rw-r--r--src/fs/gnunet-fs-gtk_common.c124
1 files changed, 123 insertions, 1 deletions
diff --git a/src/fs/gnunet-fs-gtk_common.c b/src/fs/gnunet-fs-gtk_common.c
index a987b25a..91858455 100644
--- a/src/fs/gnunet-fs-gtk_common.c
+++ b/src/fs/gnunet-fs-gtk_common.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2010 Christian Grothoff (and other contributing authors) 3 (C) 2010, 2012 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
@@ -24,6 +24,9 @@
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26#include "gnunet-fs-gtk_common.h" 26#include "gnunet-fs-gtk_common.h"
27#include "gnunet-fs-gtk_download-save-as.h"
28#include "gnunet-fs-gtk.h"
29#include "gnunet-fs-gtk_event-handler.h"
27 30
28/** 31/**
29 * Converts metadata specified by @data of size @data_len 32 * Converts metadata specified by @data of size @data_len
@@ -284,5 +287,124 @@ GNUNET_FS_GTK_get_description_from_metadata (const struct GNUNET_CONTAINER_MetaD
284} 287}
285 288
286 289
290/**
291 * A URI was selected (or pasted into the application). Run
292 * the appropriate action.
293 *
294 * @param uri the URI
295 */
296void
297GNUNET_FS_GTK_handle_uri (const struct GNUNET_FS_Uri *uri)
298{
299 GtkTreeIter iter;
300 GtkTreeModel *namespace_treestore;
301 GtkTreeView *namespace_tree;
302 gchar *value;
303 GtkLabel *sel_namespace_label;
304 GtkTreePath *treepath;
305 GtkEntry *query_entry;
306 GNUNET_HashCode *nsid;
307 GNUNET_HashCode want;
308
309 if (GNUNET_FS_uri_test_chk (uri) || GNUNET_FS_uri_test_loc (uri))
310 {
311 struct DownloadEntry *de;
312
313 de = GNUNET_malloc (sizeof (struct DownloadEntry));
314 de->uri = GNUNET_FS_uri_dup (uri);
315 GNUNET_FS_GTK_open_download_as_dialog (de);
316 return;
317 }
318 query_entry = GTK_ENTRY (GNUNET_FS_GTK_get_main_window_object ("main_window_search_entry"));
319 namespace_tree =
320 GTK_TREE_VIEW (GNUNET_FS_GTK_get_main_window_object
321 ("namespace_selector_treeview"));
322 namespace_treestore =
323 GTK_TREE_MODEL (GNUNET_FS_GTK_get_main_window_object
324 ("main_window_search_namespace_treestore"));
325 sel_namespace_label =
326 GTK_LABEL (GNUNET_FS_GTK_get_main_window_object ("main_window_search_selected_namespace_label"));
327
328 if (GNUNET_FS_uri_test_sks (uri))
329 {
330 /* select the namespace */
331 if (GNUNET_OK !=
332 GNUNET_FS_uri_sks_get_namespace (uri, &want))
333 {
334 GNUNET_break (0);
335 return;
336 }
337 if (! gtk_tree_model_get_iter_first (namespace_treestore, &iter))
338 {
339 GNUNET_break (0);
340 return;
341 }
342 gtk_tree_model_get (namespace_treestore, &iter,
343 1, &nsid,
344 -1);
345 while ( ( (NULL == nsid) ||
346 (0 != memcmp (nsid,
347 &want,
348 sizeof (GNUNET_HashCode))) ) &&
349 (gtk_tree_model_iter_next (namespace_treestore, &iter)) )
350 gtk_tree_model_get (namespace_treestore, &iter,
351 1, &nsid,
352 -1);
353 if ( (NULL == nsid) ||
354 (0 != memcmp (nsid,
355 &want,
356 sizeof (GNUNET_HashCode))) )
357 {
358 /* namespace unknown / not in list!? */
359 GNUNET_break (0);
360 return;
361 }
362 gtk_tree_selection_select_iter (gtk_tree_view_get_selection
363 (namespace_tree), &iter);
364 treepath = gtk_tree_model_get_path (namespace_treestore,
365 &iter);
366 if (GNUNET_GTK_get_tree_string (namespace_tree, treepath, 0, &value))
367 gtk_label_set_text (sel_namespace_label, value);
368 gtk_tree_path_free (treepath);
369
370 /* set search entry to the namespace identifier */
371 {
372 char *query_string;
373
374 query_string = GNUNET_FS_uri_sks_get_content_id (uri);
375 gtk_entry_set_text (query_entry,
376 query_string);
377 GNUNET_free (query_string);
378 }
379 return;
380 }
381
382 if (GNUNET_FS_uri_test_ksk (uri))
383 {
384 /* select "no" namespace, which should be the first entry
385 in the namespace */
386 if (gtk_tree_model_get_iter_first (namespace_treestore, &iter))
387 {
388 gtk_tree_selection_select_iter (gtk_tree_view_get_selection
389 (namespace_tree), &iter);
390 treepath = gtk_tree_model_get_path (namespace_treestore, &iter);
391 if (GNUNET_GTK_get_tree_string (namespace_tree, treepath, 0, &value))
392 gtk_label_set_text (sel_namespace_label, value);
393 gtk_tree_path_free (treepath);
394 }
395 /* set search entry to the query string */
396 {
397 char *query_string;
398
399 query_string = GNUNET_FS_uri_ksk_to_string_fancy (uri);
400 gtk_entry_set_text (query_entry,
401 query_string);
402 GNUNET_free (query_string);
403 }
404 return;
405 }
406 GNUNET_break (0);
407}
408
287 409
288/* end of gnunet-fs-gtk-common.c */ 410/* end of gnunet-fs-gtk-common.c */