aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-fs-gtk-main_window_file_publish.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/gnunet-fs-gtk-main_window_file_publish.c')
-rw-r--r--src/fs/gnunet-fs-gtk-main_window_file_publish.c53
1 files changed, 45 insertions, 8 deletions
diff --git a/src/fs/gnunet-fs-gtk-main_window_file_publish.c b/src/fs/gnunet-fs-gtk-main_window_file_publish.c
index 16298427..7172e334 100644
--- a/src/fs/gnunet-fs-gtk-main_window_file_publish.c
+++ b/src/fs/gnunet-fs-gtk-main_window_file_publish.c
@@ -211,6 +211,7 @@ add_file_at_iter (gpointer data, const char *filename, const struct GNUNET_FS_Bl
211 GtkTreePath *path; 211 GtkTreePath *path;
212 uint64_t file_size; 212 uint64_t file_size;
213 const char *short_fn; 213 const char *short_fn;
214 char *short_fn_utf8;
214 struct GNUNET_CONTAINER_MetaData *meta; 215 struct GNUNET_CONTAINER_MetaData *meta;
215 struct GNUNET_FS_Uri *ksk_uri; 216 struct GNUNET_FS_Uri *ksk_uri;
216 GtkTreeStore *ts; 217 GtkTreeStore *ts;
@@ -248,10 +249,11 @@ add_file_at_iter (gpointer data, const char *filename, const struct GNUNET_FS_Bl
248 short_fn = filename; 249 short_fn = filename;
249 while (NULL != (ss = strstr (short_fn, DIR_SEPARATOR_STR))) 250 while (NULL != (ss = strstr (short_fn, DIR_SEPARATOR_STR)))
250 short_fn = 1 + ss; 251 short_fn = 1 + ss;
252 short_fn_utf8 = GNUNET_GTK_from_loc_to_utf8 ((char *) short_fn);
251 GNUNET_CONTAINER_meta_data_insert (meta, "<gnunet-gtk>", 253 GNUNET_CONTAINER_meta_data_insert (meta, "<gnunet-gtk>",
252 EXTRACTOR_METATYPE_FILENAME, 254 EXTRACTOR_METATYPE_FILENAME,
253 EXTRACTOR_METAFORMAT_UTF8, "text/plain", 255 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
254 short_fn, strlen (short_fn) + 1); 256 short_fn_utf8, strlen (short_fn_utf8) + 1);
255 ksk_uri = GNUNET_FS_uri_ksk_create_from_meta_data (meta); 257 ksk_uri = GNUNET_FS_uri_ksk_create_from_meta_data (meta);
256 gtk_tree_store_insert_before (ts, &pos, iter, NULL); 258 gtk_tree_store_insert_before (ts, &pos, iter, NULL);
257 path = gtk_tree_model_get_path (GTK_TREE_MODEL (ts), &pos); 259 path = gtk_tree_model_get_path (GTK_TREE_MODEL (ts), &pos);
@@ -268,8 +270,9 @@ add_file_at_iter (gpointer data, const char *filename, const struct GNUNET_FS_Bl
268 else 270 else
269 file_size_fancy = GNUNET_STRINGS_byte_size_fancy (file_size); 271 file_size_fancy = GNUNET_STRINGS_byte_size_fancy (file_size);
270 gtk_tree_store_set (ts, &pos, 0, file_size_fancy, 1, (gboolean) do_index, 2, 272 gtk_tree_store_set (ts, &pos, 0, file_size_fancy, 1, (gboolean) do_index, 2,
271 short_fn, 3, (guint) bo->anonymity_level, 4, 273 short_fn_utf8, 3, (guint) bo->anonymity_level, 4,
272 (guint) bo->content_priority, 5, fi, -1); 274 (guint) bo->content_priority, 5, fi, -1);
275 GNUNET_free_non_null (short_fn_utf8);
273 GNUNET_free (file_size_fancy); 276 GNUNET_free (file_size_fancy);
274 update_selectivity (data); 277 update_selectivity (data);
275} 278}
@@ -294,6 +297,7 @@ create_dir_at_iter (gpointer data, const char *name, const struct GNUNET_FS_Bloc
294 GtkTreeStore *ts; 297 GtkTreeStore *ts;
295 GtkBuilder *builder; 298 GtkBuilder *builder;
296 299
300
297 builder = GTK_BUILDER (data); 301 builder = GTK_BUILDER (data);
298 302
299 ts = GTK_TREE_STORE (gtk_builder_get_object 303 ts = GTK_TREE_STORE (gtk_builder_get_object
@@ -504,6 +508,7 @@ extract_file (struct AddDirContext *adc, const char *filename)
504 GNUNET_HashCode hc; 508 GNUNET_HashCode hc;
505 const char *short_fn; 509 const char *short_fn;
506 const char *ss; 510 const char *ss;
511 char *short_fn_utf8;
507 512
508 adc->dir_entry_count++; 513 adc->dir_entry_count++;
509 pd = GNUNET_malloc (sizeof (struct PublishData)); 514 pd = GNUNET_malloc (sizeof (struct PublishData));
@@ -515,11 +520,12 @@ extract_file (struct AddDirContext *adc, const char *filename)
515 short_fn = filename; 520 short_fn = filename;
516 while (NULL != (ss = strstr (short_fn, DIR_SEPARATOR_STR))) 521 while (NULL != (ss = strstr (short_fn, DIR_SEPARATOR_STR)))
517 short_fn = 1 + ss; 522 short_fn = 1 + ss;
523 short_fn_utf8 = GNUNET_GTK_from_loc_to_utf8 ((char *) short_fn);
518 GNUNET_CONTAINER_meta_data_insert (pd->meta, "<gnunet-gtk>", 524 GNUNET_CONTAINER_meta_data_insert (pd->meta, "<gnunet-gtk>",
519 EXTRACTOR_METATYPE_FILENAME, 525 EXTRACTOR_METATYPE_FILENAME,
520 EXTRACTOR_METAFORMAT_UTF8, "text/plain", 526 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
521 short_fn, strlen (short_fn) + 1); 527 short_fn, strlen (short_fn_utf8) + 1);
522 528 GNUNET_free_non_null (short_fn_utf8);
523 529
524 gtk_tree_store_insert_before (adc->ts, &pd->iter, adc->parent, NULL); 530 gtk_tree_store_insert_before (adc->ts, &pd->iter, adc->parent, NULL);
525 GNUNET_CRYPTO_hash (filename, strlen (filename), &hc); 531 GNUNET_CRYPTO_hash (filename, strlen (filename), &hc);
@@ -576,6 +582,7 @@ add_entry_to_ts (GtkTreeStore * ts, GtkTreeIter * iter, const char *filename,
576 struct GNUNET_FS_Uri *kill_ksk; 582 struct GNUNET_FS_Uri *kill_ksk;
577 const char *ss; 583 const char *ss;
578 const char *short_fn; 584 const char *short_fn;
585 char *short_fn_utf8;
579 struct stat sbuf; 586 struct stat sbuf;
580 587
581 if (0 != STAT (filename, &sbuf)) 588 if (0 != STAT (filename, &sbuf))
@@ -627,9 +634,11 @@ add_entry_to_ts (GtkTreeStore * ts, GtkTreeIter * iter, const char *filename,
627 short_fn = filename; 634 short_fn = filename;
628 while (NULL != (ss = strstr (short_fn, DIR_SEPARATOR_STR))) 635 while (NULL != (ss = strstr (short_fn, DIR_SEPARATOR_STR)))
629 short_fn = 1 + ss; 636 short_fn = 1 + ss;
637 short_fn_utf8 = GNUNET_GTK_from_loc_to_utf8 ((char *) short_fn);
630 gtk_tree_store_set (ts, iter, 0, file_size_fancy, 1, (gboolean) do_index, 2, 638 gtk_tree_store_set (ts, iter, 0, file_size_fancy, 1, (gboolean) do_index, 2,
631 short_fn, 3, (guint) bo->anonymity_level, 4, 639 short_fn_utf8, 3, (guint) bo->anonymity_level, 4,
632 (guint) bo->content_priority, 5, fi, -1); 640 (guint) bo->content_priority, 5, fi, -1);
641 GNUNET_free_non_null (short_fn_utf8);
633 GNUNET_free (file_size_fancy); 642 GNUNET_free (file_size_fancy);
634} 643}
635 644
@@ -774,8 +783,19 @@ scan_directory (void *cls, const char *filename)
774 } 783 }
775 else 784 else
776 { 785 {
786 char *filename_utf8;
787 const char *ss, *short_fn;
777 GNUNET_assert (mcm == NULL); 788 GNUNET_assert (mcm == NULL);
778 /* we're top-level */ 789 /* we're top-level */
790 short_fn = filename;
791 while (NULL != (ss = strstr (short_fn, DIR_SEPARATOR_STR)))
792 short_fn = 1 + ss;
793 filename_utf8 = GNUNET_GTK_from_loc_to_utf8 ((char *) short_fn);
794 GNUNET_CONTAINER_meta_data_insert (pd->meta, "<gnunet-gtk>",
795 EXTRACTOR_METATYPE_FILENAME,
796 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
797 filename_utf8, strlen (filename_utf8) + 1);
798 GNUNET_free_non_null (filename_utf8);
779 add_entry_to_ts (adc->ts, &pd->iter, filename, &adc->bo, adc->do_index, 799 add_entry_to_ts (adc->ts, &pd->iter, filename, &adc->bo, adc->do_index,
780 NULL, pd->meta); 800 NULL, pd->meta);
781 } 801 }
@@ -1384,7 +1404,7 @@ GNUNET_GTK_publish_directory_dialog_response_cb (GtkDialog *dialog,
1384 "GNUNET_GTK_publish_directory_dialog")); 1404 "GNUNET_GTK_publish_directory_dialog"));
1385 if (response_id == -5) 1405 if (response_id == -5)
1386 { 1406 {
1387 filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (ad)); 1407 filename = GNUNET_GTK_filechooser_get_filename_loc (GTK_FILE_CHOOSER (ad));
1388 sb = GTK_SPIN_BUTTON (gtk_builder_get_object (builder, 1408 sb = GTK_SPIN_BUTTON (gtk_builder_get_object (builder,
1389 "GNUNET_GTK_publish_directory_dialog_expiration_year_spin_button")); 1409 "GNUNET_GTK_publish_directory_dialog_expiration_year_spin_button"));
1390 if (!GNUNET_GTK_get_selected_anonymity_level (builder, 1410 if (!GNUNET_GTK_get_selected_anonymity_level (builder,
@@ -1539,6 +1559,18 @@ add_updateable_to_ts (void *cls, const char *last_id,
1539 EXTRACTOR_METATYPE_COMMENT, 1559 EXTRACTOR_METATYPE_COMMENT,
1540 EXTRACTOR_METATYPE_SUBJECT, 1560 EXTRACTOR_METATYPE_SUBJECT,
1541 -1); 1561 -1);
1562 if (desc == NULL)
1563 desc = GNUNET_strdup (_("no description supplied"));
1564 else
1565 {
1566 char *utf8_desc = NULL;
1567 utf8_desc = GNUNET_FS_GTK_dubious_meta_to_utf8 (EXTRACTOR_METAFORMAT_UTF8, desc, strlen (desc) + 1);
1568 GNUNET_free (desc);
1569 if (utf8_desc != NULL)
1570 desc = utf8_desc;
1571 else
1572 desc = NULL;
1573 }
1542 gtk_tree_store_insert_with_values (uc->ts, &iter, uc->parent, G_MAXINT, 0, 1574 gtk_tree_store_insert_with_values (uc->ts, &iter, uc->parent, G_MAXINT, 0,
1543 uc->namespace_name, 1, uc->ns, 2, last_id, 1575 uc->namespace_name, 1, uc->ns, 2, last_id,
1544 3, GNUNET_FS_uri_dup (last_uri), 4, 1576 3, GNUNET_FS_uri_dup (last_uri), 4,
@@ -1586,13 +1618,15 @@ add_namespace_to_ts (void *cls, const char *name, const GNUNET_HashCode * id)
1586 GtkTreeStore *ts = cls; 1618 GtkTreeStore *ts = cls;
1587 struct UpdateableContext uc; 1619 struct UpdateableContext uc;
1588 GtkTreeIter iter; 1620 GtkTreeIter iter;
1621 gchar *name_utf8;
1589 1622
1590 uc.parent = &iter; 1623 uc.parent = &iter;
1591 uc.namespace_name = name; 1624 uc.namespace_name = name;
1592 uc.ts = ts; 1625 uc.ts = ts;
1593 uc.ns = GNUNET_FS_namespace_create (GNUNET_FS_GTK_get_fs_handle (), name); 1626 uc.ns = GNUNET_FS_namespace_create (GNUNET_FS_GTK_get_fs_handle (), name);
1594 uc.update_called = GNUNET_NO; 1627 uc.update_called = GNUNET_NO;
1595 gtk_tree_store_insert_with_values (ts, &iter, NULL, G_MAXINT, 0, name, 1, 1628 name_utf8 = GNUNET_GTK_from_loc_to_utf8 ((char *) name);
1629 gtk_tree_store_insert_with_values (ts, &iter, NULL, G_MAXINT, 0, name_utf8, 1,
1596 uc.ns, 2, NULL /* last-id */ , 1630 uc.ns, 2, NULL /* last-id */ ,
1597 3, NULL /* last-uri */ , 1631 3, NULL /* last-uri */ ,
1598 4, NULL /* meta */ , 1632 4, NULL /* meta */ ,
@@ -1601,6 +1635,7 @@ add_namespace_to_ts (void *cls, const char *name, const GNUNET_HashCode * id)
1601 7, TRUE /* update editable */ , 1635 7, TRUE /* update editable */ ,
1602 8, TRUE /* current editable */ , 1636 8, TRUE /* current editable */ ,
1603 -1); 1637 -1);
1638 GNUNET_free_non_null (name_utf8);
1604 uc.seen = GNUNET_CONTAINER_multihashmap_create (128); 1639 uc.seen = GNUNET_CONTAINER_multihashmap_create (128);
1605 GNUNET_FS_namespace_list_updateable (uc.ns, NULL, &add_updateable_to_ts, &uc); 1640 GNUNET_FS_namespace_list_updateable (uc.ns, NULL, &add_updateable_to_ts, &uc);
1606 GNUNET_CONTAINER_multihashmap_destroy (uc.seen); 1641 GNUNET_CONTAINER_multihashmap_destroy (uc.seen);
@@ -1726,6 +1761,7 @@ hide_master_publish_dialog (gpointer user_data, gint ret)
1726 do 1761 do
1727 { 1762 {
1728 fi = get_file_information (tm, &iter); 1763 fi = get_file_information (tm, &iter);
1764 /* FIXME: should we convert namespace id and uid from UTF8? */
1729 GNUNET_FS_publish_start (GNUNET_FS_GTK_get_fs_handle (), fi, namespace, 1765 GNUNET_FS_publish_start (GNUNET_FS_GTK_get_fs_handle (), fi, namespace,
1730 namespace_id, namespace_uid, 1766 namespace_id, namespace_uid,
1731 GNUNET_FS_PUBLISH_OPTION_NONE); 1767 GNUNET_FS_PUBLISH_OPTION_NONE);
@@ -1801,7 +1837,6 @@ GNUNET_GTK_publish_file_dialog_response_cb (GtkDialog *dialog,
1801 if (response_id == -5) 1837 if (response_id == -5)
1802 { 1838 {
1803 /* OK */ 1839 /* OK */
1804 filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (ad));
1805 sb = GTK_SPIN_BUTTON (gtk_builder_get_object (builder, 1840 sb = GTK_SPIN_BUTTON (gtk_builder_get_object (builder,
1806 "GNUNET_GTK_publish_file_dialog_expiration_year_spin_button")); 1841 "GNUNET_GTK_publish_file_dialog_expiration_year_spin_button"));
1807 1842
@@ -1816,6 +1851,8 @@ GNUNET_GTK_publish_file_dialog_response_cb (GtkDialog *dialog,
1816 do_index = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON ( 1851 do_index = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (
1817 gtk_builder_get_object (builder, 1852 gtk_builder_get_object (builder,
1818 "GNUNET_GTK_publish_file_dialog_do_index_checkbutton"))); 1853 "GNUNET_GTK_publish_file_dialog_do_index_checkbutton")));
1854
1855 filename = GNUNET_GTK_filechooser_get_filename_loc (GTK_FILE_CHOOSER (ad));
1819 add_file_at_iter (user_data, filename, &bo, do_index, NULL); 1856 add_file_at_iter (user_data, filename, &bo, do_index, NULL);
1820 g_free (filename); 1857 g_free (filename);
1821 update_selectivity (user_data); 1858 update_selectivity (user_data);