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.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/fs/gnunet-fs-gtk-common.c b/src/fs/gnunet-fs-gtk-common.c
index e7cb07f1..1a250c62 100644
--- a/src/fs/gnunet-fs-gtk-common.c
+++ b/src/fs/gnunet-fs-gtk-common.c
@@ -48,13 +48,32 @@ GNUNET_FS_GTK_add_meta_data_to_list_store (void *cls, const char *plugin_name,
48 const char *data_mime_type, 48 const char *data_mime_type,
49 const char *data, size_t data_len) 49 const char *data, size_t data_len)
50{ 50{
51 gchar *data_to_insert = NULL;
52 gboolean freedata = FALSE;
51 GtkListStore *ls = GTK_LIST_STORE (cls); 53 GtkListStore *ls = GTK_LIST_STORE (cls);
52 54
53 if ((format == EXTRACTOR_METAFORMAT_UTF8) || 55 if (format == EXTRACTOR_METAFORMAT_UTF8)
54 (format == EXTRACTOR_METAFORMAT_C_STRING)) 56 {
57 if (g_utf8_validate (data, data_len, NULL))
58 data_to_insert = data;
59 else
60 format = EXTRACTOR_METAFORMAT_C_STRING;
61 }
62 if (format == EXTRACTOR_METAFORMAT_C_STRING)
63 {
64 gsize rd, wr;
65 data_to_insert = g_locale_to_utf8 (data, data_len, &rd, &wr, NULL);
66 freedata = TRUE;
67 }
68
69 if (data_to_insert)
70 {
55 gtk_list_store_insert_with_values (ls, NULL, G_MAXINT, 0, type, 1, format, 71 gtk_list_store_insert_with_values (ls, NULL, G_MAXINT, 0, type, 1, format,
56 2, EXTRACTOR_metatype_to_string (type), 72 2, EXTRACTOR_metatype_to_string (type),
57 3, data, -1); 73 3, data_to_insert, -1);
74 if (freedata)
75 g_free (data_to_insert);
76 }
58 return 0; 77 return 0;
59} 78}
60 79