aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-02-26 15:25:29 +0000
committerChristian Grothoff <christian@grothoff.org>2012-02-26 15:25:29 +0000
commit6330fbcc48591bc026afcdbdf40c4a8704dd7f58 (patch)
treef13f153e22f3a946f207cd2ee037d0ad7aeb2a17
parent2b103004302403f2707b1094a65b40166cc90ace (diff)
downloadgnunet-gtk-6330fbcc48591bc026afcdbdf40c4a8704dd7f58.tar.gz
gnunet-gtk-6330fbcc48591bc026afcdbdf40c4a8704dd7f58.zip
LRN: Adds a way for GNUNET_FS_GTK_get_description_from_metadata() to
convey to you the fact that the description it returned is a placeholder, and that metadata didn't really have any description. This capability is not used at the moment (the code that used it was only present in early namespace manager draft).
-rw-r--r--src/fs/gnunet-fs-gtk_common.c12
-rw-r--r--src/fs/gnunet-fs-gtk_common.h5
-rw-r--r--src/fs/gnunet-fs-gtk_event-handler.c6
-rw-r--r--src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c30
-rw-r--r--src/fs/gnunet-fs-gtk_publish-dialog.c3
5 files changed, 24 insertions, 32 deletions
diff --git a/src/fs/gnunet-fs-gtk_common.c b/src/fs/gnunet-fs-gtk_common.c
index 91858455..8ca006e3 100644
--- a/src/fs/gnunet-fs-gtk_common.c
+++ b/src/fs/gnunet-fs-gtk_common.c
@@ -253,10 +253,13 @@ GNUNET_FS_GTK_mmap_and_scan (const char *filename,
253 * the respective meta data. 253 * the respective meta data.
254 * 254 *
255 * @param meta meta data to inspect 255 * @param meta meta data to inspect
256 * @param is_a_dup is set to GNUNET_YES if the result is a dup, and there was
257 * no description to be found. GNUNET_NO otherwise.
256 * @return description of the result in utf-8, never NULL 258 * @return description of the result in utf-8, never NULL
257 */ 259 */
258char * 260char *
259GNUNET_FS_GTK_get_description_from_metadata (const struct GNUNET_CONTAINER_MetaData *meta) 261GNUNET_FS_GTK_get_description_from_metadata (
262 const struct GNUNET_CONTAINER_MetaData *meta, int *is_a_dup)
260{ 263{
261 char *desc; 264 char *desc;
262 char *utf8_desc; 265 char *utf8_desc;
@@ -276,13 +279,20 @@ GNUNET_FS_GTK_get_description_from_metadata (const struct GNUNET_CONTAINER_MetaD
276 EXTRACTOR_METATYPE_KEYWORDS, 279 EXTRACTOR_METATYPE_KEYWORDS,
277 -1); 280 -1);
278 if (desc == NULL) 281 if (desc == NULL)
282 {
283 *is_a_dup = GNUNET_YES;
279 return GNUNET_strdup (_("no description supplied")); 284 return GNUNET_strdup (_("no description supplied"));
285 }
280 utf8_desc = 286 utf8_desc =
281 GNUNET_FS_GTK_dubious_meta_to_utf8 (EXTRACTOR_METAFORMAT_UTF8, desc, 287 GNUNET_FS_GTK_dubious_meta_to_utf8 (EXTRACTOR_METAFORMAT_UTF8, desc,
282 strlen (desc) + 1); 288 strlen (desc) + 1);
283 GNUNET_free (desc); 289 GNUNET_free (desc);
284 if (utf8_desc == NULL) 290 if (utf8_desc == NULL)
291 {
292 *is_a_dup = GNUNET_YES;
285 return GNUNET_strdup (_("no description supplied")); 293 return GNUNET_strdup (_("no description supplied"));
294 }
295 *is_a_dup = GNUNET_NO;
286 return utf8_desc; 296 return utf8_desc;
287} 297}
288 298
diff --git a/src/fs/gnunet-fs-gtk_common.h b/src/fs/gnunet-fs-gtk_common.h
index 9b13a7bd..b5048d7c 100644
--- a/src/fs/gnunet-fs-gtk_common.h
+++ b/src/fs/gnunet-fs-gtk_common.h
@@ -129,10 +129,13 @@ GNUNET_FS_GTK_dubious_meta_to_utf8 (enum EXTRACTOR_MetaFormat format,
129 * the respective meta data. 129 * the respective meta data.
130 * 130 *
131 * @param meta meta data to inspect 131 * @param meta meta data to inspect
132 * @param is_a_dup is set to GNUNET_YES if the result is a dup, and there was
133 * no description to be found. GNUNET_NO otherwise.
132 * @return description of the result in utf-8, never NULL 134 * @return description of the result in utf-8, never NULL
133 */ 135 */
134char * 136char *
135GNUNET_FS_GTK_get_description_from_metadata (const struct GNUNET_CONTAINER_MetaData *meta); 137GNUNET_FS_GTK_get_description_from_metadata (
138 const struct GNUNET_CONTAINER_MetaData *meta, int *is_a_dup);
136 139
137 140
138/** 141/**
diff --git a/src/fs/gnunet-fs-gtk_event-handler.c b/src/fs/gnunet-fs-gtk_event-handler.c
index 97592656..4017e10f 100644
--- a/src/fs/gnunet-fs-gtk_event-handler.c
+++ b/src/fs/gnunet-fs-gtk_event-handler.c
@@ -1456,6 +1456,7 @@ update_search_result (struct SearchResult *sr,
1456 guint percent_avail; 1456 guint percent_avail;
1457 GtkNotebook *notebook; 1457 GtkNotebook *notebook;
1458 gint page; 1458 gint page;
1459 int desc_is_a_dup;
1459 1460
1460 if (sr == NULL) 1461 if (sr == NULL)
1461 { 1462 {
@@ -1466,7 +1467,7 @@ update_search_result (struct SearchResult *sr,
1466 "Updating search result SR=%p with %d, %u, %u\n", 1467 "Updating search result SR=%p with %d, %u, %u\n",
1467 sr, availability_rank, 1468 sr, availability_rank,
1468 availability_certainty, applicability_rank); 1469 availability_certainty, applicability_rank);
1469 desc = GNUNET_FS_GTK_get_description_from_metadata (meta); 1470 desc = GNUNET_FS_GTK_get_description_from_metadata (meta, &desc_is_a_dup);
1470 mime = get_mimetype_from_metadata (meta); 1471 mime = get_mimetype_from_metadata (meta);
1471 pixbuf = GNUNET_FS_GTK_get_thumbnail_from_meta_data (meta); 1472 pixbuf = GNUNET_FS_GTK_get_thumbnail_from_meta_data (meta);
1472 tp = gtk_tree_row_reference_get_path (sr->rr); 1473 tp = gtk_tree_row_reference_get_path (sr->rr);
@@ -1549,6 +1550,7 @@ GNUNET_GTK_add_search_result (struct SearchTab *tab,
1549 GtkTreeModel *tm; 1550 GtkTreeModel *tm;
1550 GtkTreeStore *ts; 1551 GtkTreeStore *ts;
1551 uint64_t fsize; 1552 uint64_t fsize;
1553 int desc_is_a_dup;
1552 1554
1553 if (NULL == uri) 1555 if (NULL == uri)
1554 { 1556 {
@@ -1577,7 +1579,7 @@ GNUNET_GTK_add_search_result (struct SearchTab *tab,
1577 } 1579 }
1578 uris = GNUNET_FS_uri_to_string (uri); 1580 uris = GNUNET_FS_uri_to_string (uri);
1579 } 1581 }
1580 desc = GNUNET_FS_GTK_get_description_from_metadata (meta); 1582 desc = GNUNET_FS_GTK_get_description_from_metadata (meta, &desc_is_a_dup);
1581 pixbuf = GNUNET_FS_GTK_get_thumbnail_from_meta_data (meta); 1583 pixbuf = GNUNET_FS_GTK_get_thumbnail_from_meta_data (meta);
1582 1584
1583 sr = GNUNET_malloc (sizeof (struct SearchResult)); 1585 sr = GNUNET_malloc (sizeof (struct SearchResult));
diff --git a/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c b/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c
index 6c5e0f92..cb5dc461 100644
--- a/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c
+++ b/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c
@@ -329,6 +329,7 @@ add_namespace_to_ts (void *cls, const GNUNET_HashCode * pseudonym,
329 char *ns_name; 329 char *ns_name;
330 GNUNET_HashCode *nsid; 330 GNUNET_HashCode *nsid;
331 char *description; 331 char *description;
332 int desc_is_a_dup;
332 char *uris; 333 char *uris;
333 char *emsg; 334 char *emsg;
334 struct GNUNET_FS_Uri *uri; 335 struct GNUNET_FS_Uri *uri;
@@ -350,32 +351,7 @@ add_namespace_to_ts (void *cls, const GNUNET_HashCode * pseudonym,
350 root = GNUNET_FS_uri_sks_get_content_id (uri); 351 root = GNUNET_FS_uri_sks_get_content_id (uri);
351 GNUNET_FS_uri_destroy (uri); 352 GNUNET_FS_uri_destroy (uri);
352 } 353 }
353 description = 354 description = GNUNET_FS_GTK_get_description_from_metadata (md, &desc_is_a_dup);
354 GNUNET_CONTAINER_meta_data_get_first_by_types (md,
355 EXTRACTOR_METATYPE_TITLE,
356 EXTRACTOR_METATYPE_BOOK_TITLE,
357 EXTRACTOR_METATYPE_DESCRIPTION,
358 EXTRACTOR_METATYPE_SUMMARY,
359 EXTRACTOR_METATYPE_ALBUM,
360 EXTRACTOR_METATYPE_COMMENT,
361 EXTRACTOR_METATYPE_SUBJECT,
362 EXTRACTOR_METATYPE_KEYWORDS,
363 -1);
364 if (description == NULL)
365 description = GNUNET_strdup (_("no description supplied"));
366 else
367 {
368 char *utf8_desc = NULL;
369
370 utf8_desc =
371 GNUNET_FS_GTK_dubious_meta_to_utf8 (EXTRACTOR_METAFORMAT_UTF8,
372 description, strlen (description));
373 GNUNET_free (description);
374 if (utf8_desc != NULL)
375 description = utf8_desc;
376 else
377 description = NULL;
378 }
379 gtk_tree_store_insert_with_values (ts, &iter, NULL, G_MAXINT, 355 gtk_tree_store_insert_with_values (ts, &iter, NULL, G_MAXINT,
380 0, ns_name, 356 0, ns_name,
381 1, nsid, 357 1, nsid,
@@ -384,7 +360,7 @@ add_namespace_to_ts (void *cls, const GNUNET_HashCode * pseudonym,
384 -1); 360 -1);
385 GNUNET_free (ns_name); 361 GNUNET_free (ns_name);
386 GNUNET_free_non_null (root); 362 GNUNET_free_non_null (root);
387 GNUNET_free_non_null (description); 363 GNUNET_free (description);
388 return GNUNET_OK; 364 return GNUNET_OK;
389} 365}
390 366
diff --git a/src/fs/gnunet-fs-gtk_publish-dialog.c b/src/fs/gnunet-fs-gtk_publish-dialog.c
index 9486d363..00f7edf1 100644
--- a/src/fs/gnunet-fs-gtk_publish-dialog.c
+++ b/src/fs/gnunet-fs-gtk_publish-dialog.c
@@ -1903,6 +1903,7 @@ add_updateable_to_ts (void *cls, const char *last_id,
1903 GtkTreeIter iter; 1903 GtkTreeIter iter;
1904 GtkTreeIter titer; 1904 GtkTreeIter titer;
1905 char *desc; 1905 char *desc;
1906 int desc_is_a_dup;
1906 GNUNET_HashCode hc; 1907 GNUNET_HashCode hc;
1907 1908
1908 uc->update_called = GNUNET_YES; 1909 uc->update_called = GNUNET_YES;
@@ -1912,7 +1913,7 @@ add_updateable_to_ts (void *cls, const char *last_id,
1912 GNUNET_CONTAINER_multihashmap_put (uc->seen, &hc, "dummy", 1913 GNUNET_CONTAINER_multihashmap_put (uc->seen, &hc, "dummy",
1913 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); 1914 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
1914 /* FIXME-BUG-MAYBE: what if this put fails? Not convinced it cannot... */ 1915 /* FIXME-BUG-MAYBE: what if this put fails? Not convinced it cannot... */
1915 desc = GNUNET_FS_GTK_get_description_from_metadata (last_meta); 1916 desc = GNUNET_FS_GTK_get_description_from_metadata (last_meta, &desc_is_a_dup);
1916 gtk_tree_store_insert_with_values (uc->ts, &iter, uc->parent, G_MAXINT, 0, 1917 gtk_tree_store_insert_with_values (uc->ts, &iter, uc->parent, G_MAXINT, 0,
1917 uc->namespace_name, 1, 1918 uc->namespace_name, 1,
1918 GNUNET_FS_namespace_dup (uc->ns), 2, last_id, 1919 GNUNET_FS_namespace_dup (uc->ns), 2, last_id,