diff options
author | Christian Grothoff <christian@grothoff.org> | 2008-06-07 06:08:00 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2008-06-07 06:08:00 +0000 |
commit | a71c46dbe1c295da0c1b70e39c99546bca5ba894 (patch) | |
tree | 7b4e12b3396167c939dc7c71effd498f52f5627e | |
parent | 68152aa48fd14c576793661167734ce07ea0ce37 (diff) | |
download | gnunet-gtk-a71c46dbe1c295da0c1b70e39c99546bca5ba894.tar.gz gnunet-gtk-a71c46dbe1c295da0c1b70e39c99546bca5ba894.zip |
update to new ns api'
'
-rw-r--r-- | po/Makefile.in | 2 | ||||
-rw-r--r-- | src/core/main.c | 3 | ||||
-rw-r--r-- | src/plugins/fs/collection.c | 25 | ||||
-rw-r--r-- | src/plugins/fs/fs.h | 2 | ||||
-rw-r--r-- | src/plugins/fs/meta.c | 35 | ||||
-rw-r--r-- | src/plugins/fs/namespace.c | 215 | ||||
-rw-r--r-- | src/plugins/fs/namespace_create.c | 19 | ||||
-rw-r--r-- | src/plugins/fs/namespace_search.c | 11 | ||||
-rw-r--r-- | src/plugins/fs/search.c | 48 |
9 files changed, 59 insertions, 301 deletions
diff --git a/po/Makefile.in b/po/Makefile.in index baba3cb0..71ecc80e 100644 --- a/po/Makefile.in +++ b/po/Makefile.in | |||
@@ -20,7 +20,7 @@ srcdir = . | |||
20 | top_srcdir = .. | 20 | top_srcdir = .. |
21 | 21 | ||
22 | 22 | ||
23 | prefix = /home/grothoff/ | 23 | prefix = /home/grothoff |
24 | exec_prefix = ${prefix} | 24 | exec_prefix = ${prefix} |
25 | datadir = ${prefix}/share | 25 | datadir = ${prefix}/share |
26 | localedir = $(datadir)/locale | 26 | localedir = $(datadir)/locale |
diff --git a/src/core/main.c b/src/core/main.c index 8b95c834..7715fa30 100644 --- a/src/core/main.c +++ b/src/core/main.c | |||
@@ -138,8 +138,7 @@ main (int argc, char *const *argv) | |||
138 | root = | 138 | root = |
139 | glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "mainWindow"); | 139 | glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "mainWindow"); |
140 | dataDir = GNUNET_get_installation_path (GNUNET_IPK_DATADIR); | 140 | dataDir = GNUNET_get_installation_path (GNUNET_IPK_DATADIR); |
141 | gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), | 141 | gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), dataDir); |
142 | dataDir); | ||
143 | GNUNET_free (dataDir); | 142 | GNUNET_free (dataDir); |
144 | gtk_window_maximize (GTK_WINDOW (root)); | 143 | gtk_window_maximize (GTK_WINDOW (root)); |
145 | gtk_widget_show (root); | 144 | gtk_widget_show (root); |
diff --git a/src/plugins/fs/collection.c b/src/plugins/fs/collection.c index b7a3939f..838d7644 100644 --- a/src/plugins/fs/collection.c +++ b/src/plugins/fs/collection.c | |||
@@ -65,13 +65,11 @@ on_collectionMetaDataValueEntry_activate_fs (GtkWidget * | |||
65 | void | 65 | void |
66 | createCollection_clicked_fs (GtkWidget * dummy1, GtkWidget * dummy2) | 66 | createCollection_clicked_fs (GtkWidget * dummy1, GtkWidget * dummy2) |
67 | { | 67 | { |
68 | const char *updateIntervalString; | ||
69 | GtkWidget *w; | 68 | GtkWidget *w; |
70 | GtkWidget *dialog; | 69 | GtkWidget *dialog; |
71 | GtkWidget *spin; | 70 | GtkWidget *spin; |
72 | struct GNUNET_MetaData *meta; | 71 | struct GNUNET_MetaData *meta; |
73 | struct GNUNET_ECRS_URI *root; | 72 | struct GNUNET_ECRS_URI *root; |
74 | GNUNET_Int32Time updateInterval; | ||
75 | 73 | ||
76 | metaXML | 74 | metaXML |
77 | = glade_xml_new (GNUNET_GTK_get_glade_filename (), | 75 | = glade_xml_new (GNUNET_GTK_get_glade_filename (), |
@@ -84,33 +82,12 @@ createCollection_clicked_fs (GtkWidget * dummy1, GtkWidget * dummy2) | |||
84 | gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); | 82 | gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); |
85 | if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) | 83 | if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) |
86 | { | 84 | { |
87 | updateIntervalString | ||
88 | = getEntryLineValue (metaXML, | ||
89 | "collectionUpdateIntervalComboBoxEntry"); | ||
90 | if (0 == strcmp (_("--sporadic update--"), updateIntervalString)) | ||
91 | updateInterval = GNUNET_ECRS_SBLOCK_UPDATE_SPORADIC; | ||
92 | else if (0 == strcmp (_("--no update--"), updateIntervalString)) | ||
93 | updateInterval = GNUNET_ECRS_SBLOCK_UPDATE_NONE; | ||
94 | else if (GNUNET_OK != parseTime (updateIntervalString, &updateInterval)) | ||
95 | { | ||
96 | gtk_widget_destroy (dialog); | ||
97 | UNREF (metaXML); | ||
98 | metaXML = NULL; | ||
99 | dialog = gtk_message_dialog_new | ||
100 | (NULL, | ||
101 | GTK_DIALOG_MODAL, | ||
102 | GTK_MESSAGE_ERROR, | ||
103 | GTK_BUTTONS_CLOSE, _("Failed to parse given time interval!")); | ||
104 | gtk_dialog_run (GTK_DIALOG (dialog)); | ||
105 | gtk_widget_destroy (dialog); | ||
106 | return; | ||
107 | } | ||
108 | meta = getMetaDataFromList (metaXML, | 85 | meta = getMetaDataFromList (metaXML, |
109 | "collectionMetaDataTreeView", NULL); | 86 | "collectionMetaDataTreeView", NULL); |
110 | spin = glade_xml_get_widget (metaXML, "collectionAnonymityLevel"); | 87 | spin = glade_xml_get_widget (metaXML, "collectionAnonymityLevel"); |
111 | root = NULL; | 88 | root = NULL; |
112 | if (GNUNET_OK == GNUNET_CO_collection_start (gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin)), 1000, /* priority */ | 89 | if (GNUNET_OK == GNUNET_CO_collection_start (gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin)), 1000, /* priority */ |
113 | updateInterval, meta)) | 90 | meta)) |
114 | { | 91 | { |
115 | w = | 92 | w = |
116 | glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), | 93 | glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), |
diff --git a/src/plugins/fs/fs.h b/src/plugins/fs/fs.h index 8f5a2b13..8e567071 100644 --- a/src/plugins/fs/fs.h +++ b/src/plugins/fs/fs.h | |||
@@ -122,8 +122,6 @@ enum | |||
122 | IN_NAMESPACE_MIMETYPE, | 122 | IN_NAMESPACE_MIMETYPE, |
123 | IN_NAMESPACE_LAST_STRING, | 123 | IN_NAMESPACE_LAST_STRING, |
124 | IN_NAMESPACE_NEXT_STRING, | 124 | IN_NAMESPACE_NEXT_STRING, |
125 | IN_NAMESPACE_PUB_FREQ_STRING, | ||
126 | IN_NAMESPACE_PUB_DATE_STRING, | ||
127 | IN_NAMESPACE_URI, | 125 | IN_NAMESPACE_URI, |
128 | IN_NAMESPACE_META, | 126 | IN_NAMESPACE_META, |
129 | IN_NAMESPACE_NUM | 127 | IN_NAMESPACE_NUM |
diff --git a/src/plugins/fs/meta.c b/src/plugins/fs/meta.c index 82713e8b..11ec6449 100644 --- a/src/plugins/fs/meta.c +++ b/src/plugins/fs/meta.c | |||
@@ -408,41 +408,6 @@ getKeywordURIFromList (GladeXML * xml, const char *name) | |||
408 | return keywordURI; | 408 | return keywordURI; |
409 | } | 409 | } |
410 | 410 | ||
411 | char * | ||
412 | updateIntervalToString (GNUNET_Int32Time interval) | ||
413 | { | ||
414 | if (interval == GNUNET_ECRS_SBLOCK_UPDATE_SPORADIC) | ||
415 | return strdup (_("--sporadic update--")); | ||
416 | if (interval == GNUNET_ECRS_SBLOCK_UPDATE_NONE) | ||
417 | return strdup (_("--no update--")); | ||
418 | return GNUNET_get_time_interval_as_fancy_string (interval * | ||
419 | GNUNET_CRON_SECONDS); | ||
420 | } | ||
421 | |||
422 | int | ||
423 | parseTimeInterval (const char *timeSpec, GNUNET_Int32Time * interval) | ||
424 | { | ||
425 | if (timeSpec == NULL) | ||
426 | return GNUNET_SYSERR; | ||
427 | if (0 == strcmp (_("--sporadic update--"), timeSpec)) | ||
428 | *interval = GNUNET_ECRS_SBLOCK_UPDATE_SPORADIC; | ||
429 | else if (0 == strcmp (_("--no update--"), timeSpec)) | ||
430 | *interval = GNUNET_ECRS_SBLOCK_UPDATE_NONE; | ||
431 | else | ||
432 | return parseTime (timeSpec, interval); | ||
433 | return GNUNET_OK; | ||
434 | } | ||
435 | |||
436 | int | ||
437 | tryParseTimeInterval (GladeXML * xml, | ||
438 | const char *intervalComboBoxEntry, | ||
439 | GNUNET_Int32Time * interval) | ||
440 | { | ||
441 | return parseTimeInterval (getEntryLineValue (xml, | ||
442 | intervalComboBoxEntry), | ||
443 | interval); | ||
444 | } | ||
445 | |||
446 | unsigned int | 411 | unsigned int |
447 | getSpinButtonValue (GladeXML * xml, const char *spinButtonName) | 412 | getSpinButtonValue (GladeXML * xml, const char *spinButtonName) |
448 | { | 413 | { |
diff --git a/src/plugins/fs/namespace.c b/src/plugins/fs/namespace.c index ac5a9aea..ad04505d 100644 --- a/src/plugins/fs/namespace.c +++ b/src/plugins/fs/namespace.c | |||
@@ -76,7 +76,7 @@ on_namespaceContentSelectionChanged (gpointer signal, gpointer cls) | |||
76 | int ncount; | 76 | int ncount; |
77 | GtkTreeSelection *ns; | 77 | GtkTreeSelection *ns; |
78 | GtkTreeIter iter; | 78 | GtkTreeIter iter; |
79 | char *freq; | 79 | char *next; |
80 | int ok; | 80 | int ok; |
81 | 81 | ||
82 | count = gtk_tree_selection_count_selected_rows (content_selection); | 82 | count = gtk_tree_selection_count_selected_rows (content_selection); |
@@ -91,12 +91,12 @@ on_namespaceContentSelectionChanged (gpointer signal, gpointer cls) | |||
91 | (ncount == 1) && | 91 | (ncount == 1) && |
92 | (TRUE == gtk_tree_selection_get_selected (ns, NULL, &iter))) | 92 | (TRUE == gtk_tree_selection_get_selected (ns, NULL, &iter))) |
93 | { | 93 | { |
94 | freq = NULL; | 94 | next = NULL; |
95 | gtk_tree_model_get (list->model, | 95 | gtk_tree_model_get (list->model, |
96 | &iter, IN_NAMESPACE_PUB_DATE_STRING, &freq, -1); | 96 | &iter, IN_NAMESPACE_NEXT_STRING, &next, -1); |
97 | if ((freq != NULL) && (0 != strcmp (freq, _("never")))) | 97 | if ((next != NULL) && (0 != strlen (next))) |
98 | ok = 1; | 98 | ok = 1; |
99 | GNUNET_free_non_null (freq); | 99 | GNUNET_free_non_null (next); |
100 | } | 100 | } |
101 | gtk_widget_set_sensitive (list->updateButton, ok); | 101 | gtk_widget_set_sensitive (list->updateButton, ok); |
102 | list = list->next; | 102 | list = list->next; |
@@ -134,8 +134,6 @@ makeNamespaceFrame (NamespaceList * entry) | |||
134 | G_TYPE_STRING, /* mime-type */ | 134 | G_TYPE_STRING, /* mime-type */ |
135 | G_TYPE_STRING, /* last-ID */ | 135 | G_TYPE_STRING, /* last-ID */ |
136 | G_TYPE_STRING, /* next-ID */ | 136 | G_TYPE_STRING, /* next-ID */ |
137 | G_TYPE_STRING, /* pub-freq */ | ||
138 | G_TYPE_STRING, /* next pub date */ | ||
139 | G_TYPE_POINTER, /* URI */ | 137 | G_TYPE_POINTER, /* URI */ |
140 | G_TYPE_POINTER); /* META */ | 138 | G_TYPE_POINTER); /* META */ |
141 | entry->model = GTK_TREE_MODEL (model); | 139 | entry->model = GTK_TREE_MODEL (model); |
@@ -217,42 +215,6 @@ makeNamespaceFrame (NamespaceList * entry) | |||
217 | renderer = gtk_cell_renderer_text_new (); | 215 | renderer = gtk_cell_renderer_text_new (); |
218 | col = | 216 | col = |
219 | gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (resultList), | 217 | gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (resultList), |
220 | -1, | ||
221 | _("Publication Frequency"), | ||
222 | renderer, "text", | ||
223 | IN_NAMESPACE_PUB_FREQ_STRING, | ||
224 | NULL); | ||
225 | column = gtk_tree_view_get_column (GTK_TREE_VIEW (resultList), col - 1); | ||
226 | gtk_tree_view_column_set_resizable (column, TRUE); | ||
227 | gtk_tree_view_column_set_clickable (column, TRUE); | ||
228 | gtk_tree_view_column_set_reorderable (column, TRUE); | ||
229 | gtk_tree_view_column_set_sort_column_id (column, | ||
230 | IN_NAMESPACE_PUB_FREQ_STRING); | ||
231 | /*gtk_tree_view_column_set_sort_indicator(column, TRUE); */ | ||
232 | gtk_tree_view_column_set_resizable (gtk_tree_view_get_column | ||
233 | (GTK_TREE_VIEW (resultList), col - 1), | ||
234 | TRUE); | ||
235 | renderer = gtk_cell_renderer_text_new (); | ||
236 | col = | ||
237 | gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (resultList), | ||
238 | -1, | ||
239 | _("Next Publication Date"), | ||
240 | renderer, "text", | ||
241 | IN_NAMESPACE_PUB_DATE_STRING, | ||
242 | NULL); | ||
243 | column = gtk_tree_view_get_column (GTK_TREE_VIEW (resultList), col - 1); | ||
244 | gtk_tree_view_column_set_reorderable (column, TRUE); | ||
245 | gtk_tree_view_column_set_resizable (column, TRUE); | ||
246 | gtk_tree_view_column_set_clickable (column, TRUE); | ||
247 | gtk_tree_view_column_set_sort_column_id (column, | ||
248 | IN_NAMESPACE_PUB_DATE_STRING); | ||
249 | /*gtk_tree_view_column_set_sort_indicator(column, TRUE); */ | ||
250 | gtk_tree_view_column_set_resizable (gtk_tree_view_get_column | ||
251 | (GTK_TREE_VIEW (resultList), col - 1), | ||
252 | TRUE); | ||
253 | renderer = gtk_cell_renderer_text_new (); | ||
254 | col = | ||
255 | gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (resultList), | ||
256 | -1, _("Last ID"), renderer, | 218 | -1, _("Last ID"), renderer, |
257 | "text", | 219 | "text", |
258 | IN_NAMESPACE_LAST_STRING, | 220 | IN_NAMESPACE_LAST_STRING, |
@@ -301,10 +263,7 @@ makeNamespaceFrame (NamespaceList * entry) | |||
301 | static int | 263 | static int |
302 | addNamespaceContentToModel (void *cls, | 264 | addNamespaceContentToModel (void *cls, |
303 | const GNUNET_ECRS_FileInfo * fi, | 265 | const GNUNET_ECRS_FileInfo * fi, |
304 | const GNUNET_HashCode * lastId, | 266 | const char *lastId, const char *nextId) |
305 | const GNUNET_HashCode * nextId, | ||
306 | GNUNET_Int32Time publicationFrequency, | ||
307 | GNUNET_Int32Time nextPublicationTime) | ||
308 | { | 267 | { |
309 | GtkListStore *model = GTK_LIST_STORE (cls); | 268 | GtkListStore *model = GTK_LIST_STORE (cls); |
310 | GtkTreeIter iter; | 269 | GtkTreeIter iter; |
@@ -312,10 +271,6 @@ addNamespaceContentToModel (void *cls, | |||
312 | char *desc; | 271 | char *desc; |
313 | char *mime; | 272 | char *mime; |
314 | char *uriString; | 273 | char *uriString; |
315 | GNUNET_EncName last; | ||
316 | GNUNET_EncName next; | ||
317 | char *freq; | ||
318 | char *date; | ||
319 | unsigned long long size; | 274 | unsigned long long size; |
320 | char *size_h; | 275 | char *size_h; |
321 | 276 | ||
@@ -357,21 +312,8 @@ addNamespaceContentToModel (void *cls, | |||
357 | else | 312 | else |
358 | size = 0; | 313 | size = 0; |
359 | uriString = GNUNET_ECRS_uri_to_string (fi->uri); | 314 | uriString = GNUNET_ECRS_uri_to_string (fi->uri); |
360 | GNUNET_hash_to_enc (lastId, &last); | 315 | if (nextId == NULL) |
361 | if (nextId != NULL) | 316 | nextId = ""; |
362 | GNUNET_hash_to_enc (nextId, &next); | ||
363 | else | ||
364 | memset (&next, 0, sizeof (GNUNET_EncName)); | ||
365 | if (publicationFrequency == GNUNET_ECRS_SBLOCK_UPDATE_SPORADIC) | ||
366 | date = GNUNET_strdup (_("unspecified")); | ||
367 | else if (publicationFrequency == GNUNET_ECRS_SBLOCK_UPDATE_NONE) | ||
368 | date = GNUNET_strdup (_("never")); | ||
369 | else | ||
370 | date = GNUNET_int32_time_to_string (&nextPublicationTime); | ||
371 | if (date[strlen (date) - 1] == '\n') | ||
372 | date[strlen (date) - 1] = '\0'; | ||
373 | |||
374 | freq = updateIntervalToString (publicationFrequency); | ||
375 | size_h = GNUNET_get_byte_size_as_fancy_string (size); | 317 | size_h = GNUNET_get_byte_size_as_fancy_string (size); |
376 | gtk_list_store_append (model, &iter); | 318 | gtk_list_store_append (model, &iter); |
377 | gtk_list_store_set (model, | 319 | gtk_list_store_set (model, |
@@ -381,18 +323,14 @@ addNamespaceContentToModel (void *cls, | |||
381 | IN_NAMESPACE_HSIZE, size_h, | 323 | IN_NAMESPACE_HSIZE, size_h, |
382 | IN_NAMESPACE_DESCRIPTION, desc, | 324 | IN_NAMESPACE_DESCRIPTION, desc, |
383 | IN_NAMESPACE_MIMETYPE, mime, | 325 | IN_NAMESPACE_MIMETYPE, mime, |
384 | IN_NAMESPACE_LAST_STRING, &last, | 326 | IN_NAMESPACE_LAST_STRING, &lastId, |
385 | IN_NAMESPACE_NEXT_STRING, &next, | 327 | IN_NAMESPACE_NEXT_STRING, &nextId, |
386 | IN_NAMESPACE_PUB_FREQ_STRING, freq, | ||
387 | IN_NAMESPACE_PUB_DATE_STRING, date, | ||
388 | IN_NAMESPACE_URI, GNUNET_ECRS_uri_duplicate (fi->uri), | 328 | IN_NAMESPACE_URI, GNUNET_ECRS_uri_duplicate (fi->uri), |
389 | IN_NAMESPACE_META, | 329 | IN_NAMESPACE_META, |
390 | GNUNET_meta_data_duplicate (fi->meta), -1); | 330 | GNUNET_meta_data_duplicate (fi->meta), -1); |
391 | GNUNET_free (size_h); | 331 | GNUNET_free (size_h); |
392 | GNUNET_free (filename); | 332 | GNUNET_free (filename); |
393 | GNUNET_free (uriString); | 333 | GNUNET_free (uriString); |
394 | GNUNET_free (freq); | ||
395 | GNUNET_free (date); | ||
396 | GNUNET_free (mime); | 334 | GNUNET_free (mime); |
397 | GNUNET_free (desc); | 335 | GNUNET_free (desc); |
398 | GNUNET_GTK_DEBUG_END (); | 336 | GNUNET_GTK_DEBUG_END (); |
@@ -574,10 +512,8 @@ typedef struct | |||
574 | unsigned int anonymityLevel; | 512 | unsigned int anonymityLevel; |
575 | char *namespaceName; | 513 | char *namespaceName; |
576 | GNUNET_HashCode nsid; | 514 | GNUNET_HashCode nsid; |
577 | GNUNET_Int32Time updateInterval; | 515 | const char *thisId; |
578 | GNUNET_HashCode *lastId; | 516 | const char *nextId; |
579 | GNUNET_HashCode thisId; | ||
580 | GNUNET_HashCode *nextId; | ||
581 | } IUC; | 517 | } IUC; |
582 | 518 | ||
583 | /** | 519 | /** |
@@ -607,9 +543,7 @@ addToNamespaceCB (GtkTreeModel * model, | |||
607 | resultURI = GNUNET_NS_add_to_namespace (ectx, cfg, cls->anonymityLevel, 1000, /* FIXME: priority */ | 543 | resultURI = GNUNET_NS_add_to_namespace (ectx, cfg, cls->anonymityLevel, 1000, /* FIXME: priority */ |
608 | GNUNET_get_time () + 2 * GNUNET_CRON_YEARS, /* FIXME: expiration */ | 544 | GNUNET_get_time () + 2 * GNUNET_CRON_YEARS, /* FIXME: expiration */ |
609 | &cls->nsid, | 545 | &cls->nsid, |
610 | cls->updateInterval, | 546 | cls->thisId, cls->nextId, dst, |
611 | cls->lastId, | ||
612 | &cls->thisId, cls->nextId, dst, | ||
613 | meta); | 547 | meta); |
614 | if (resultURI != NULL) | 548 | if (resultURI != NULL) |
615 | { | 549 | { |
@@ -626,12 +560,7 @@ addToNamespaceCB (GtkTreeModel * model, | |||
626 | fi.uri = dst; | 560 | fi.uri = dst; |
627 | fi.meta = meta; | 561 | fi.meta = meta; |
628 | addNamespaceContentToModel (list->model, | 562 | addNamespaceContentToModel (list->model, |
629 | &fi, | 563 | &fi, cls->thisId, cls->nextId); |
630 | &cls->thisId, | ||
631 | cls->nextId, | ||
632 | cls->updateInterval, | ||
633 | cls->updateInterval + | ||
634 | GNUNET_get_time_int32 (NULL)); | ||
635 | } | 564 | } |
636 | GNUNET_ECRS_uri_destroy (resultURI); | 565 | GNUNET_ECRS_uri_destroy (resultURI); |
637 | } | 566 | } |
@@ -665,14 +594,11 @@ void | |||
665 | on_namespaceInsertButton_clicked_fs (GtkWidget * dummy1, GtkWidget * dummy2) | 594 | on_namespaceInsertButton_clicked_fs (GtkWidget * dummy1, GtkWidget * dummy2) |
666 | { | 595 | { |
667 | 596 | ||
668 | const char *identifierName; | ||
669 | NamespaceList *list; | 597 | NamespaceList *list; |
670 | GtkWidget *nameLine; | 598 | GtkWidget *nameLine; |
671 | GtkWidget *page; | 599 | GtkWidget *page; |
672 | GtkWidget *notebook; | 600 | GtkWidget *notebook; |
673 | GtkWidget *dialog; | 601 | GtkWidget *dialog; |
674 | GtkWidget *updateIntervalComboBox; | ||
675 | GNUNET_HashCode nextId; | ||
676 | IUC cls; | 602 | IUC cls; |
677 | gint num; | 603 | gint num; |
678 | 604 | ||
@@ -699,53 +625,15 @@ on_namespaceInsertButton_clicked_fs (GtkWidget * dummy1, GtkWidget * dummy2) | |||
699 | GNUNET_GTK_connect_glade_with_plugins (metaXML); | 625 | GNUNET_GTK_connect_glade_with_plugins (metaXML); |
700 | dialog = glade_xml_get_widget (metaXML, "namespaceInsertDialog"); | 626 | dialog = glade_xml_get_widget (metaXML, "namespaceInsertDialog"); |
701 | gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); | 627 | gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); |
702 | |||
703 | updateIntervalComboBox = glade_xml_get_widget (metaXML, | ||
704 | "updateIntervalComboBoxEntry"); | ||
705 | gtk_combo_box_set_active (GTK_COMBO_BOX (updateIntervalComboBox), 0); | ||
706 | |||
707 | |||
708 | if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) | 628 | if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) |
709 | { | 629 | { |
710 | if (GNUNET_OK != tryParseTimeInterval (metaXML, | ||
711 | "updateIntervalComboBoxEntry", | ||
712 | &cls.updateInterval)) | ||
713 | { | ||
714 | /* this should be impossible - GNUNET_OK button is | ||
715 | deactivated while parse errors are there */ | ||
716 | gtk_widget_destroy (dialog); | ||
717 | UNREF (metaXML); | ||
718 | metaXML = NULL; | ||
719 | dialog = gtk_message_dialog_new | ||
720 | (NULL, | ||
721 | GTK_DIALOG_MODAL, | ||
722 | GTK_MESSAGE_ERROR, | ||
723 | GTK_BUTTONS_CLOSE, _("Failed to parse given time interval!")); | ||
724 | gtk_dialog_run (GTK_DIALOG (dialog)); | ||
725 | gtk_widget_destroy (dialog); | ||
726 | return; | ||
727 | } | ||
728 | cls.anonymityLevel | 630 | cls.anonymityLevel |
729 | = getSpinButtonValue (metaXML, "anonymitySpinButton"); | 631 | = getSpinButtonValue (metaXML, "anonymitySpinButton"); |
730 | nameLine = glade_xml_get_widget (metaXML, | 632 | nameLine = glade_xml_get_widget (metaXML, |
731 | "namespaceContentIdentifierEntry"); | 633 | "namespaceContentIdentifierEntry"); |
732 | identifierName = gtk_entry_get_text (GTK_ENTRY (nameLine)); | 634 | cls.thisId = gtk_entry_get_text (GTK_ENTRY (nameLine)); |
733 | if (identifierName == NULL) | ||
734 | identifierName = ""; | ||
735 | GNUNET_hash (identifierName, strlen (identifierName), &cls.thisId); | ||
736 | cls.lastId = NULL; | ||
737 | |||
738 | nameLine = glade_xml_get_widget (metaXML, "nextIdentifierEntry"); | 635 | nameLine = glade_xml_get_widget (metaXML, "nextIdentifierEntry"); |
739 | identifierName = gtk_entry_get_text (GTK_ENTRY (nameLine)); | 636 | cls.nextId = gtk_entry_get_text (GTK_ENTRY (nameLine)); |
740 | if ((identifierName == NULL) || (strlen (identifierName) == 0)) | ||
741 | { | ||
742 | cls.nextId = NULL; | ||
743 | } | ||
744 | else | ||
745 | { | ||
746 | GNUNET_hash (identifierName, strlen (identifierName), &nextId); | ||
747 | cls.nextId = &nextId; | ||
748 | } | ||
749 | GNUNET_GTK_tree_selection_selected_foreach | 637 | GNUNET_GTK_tree_selection_selected_foreach |
750 | (content_selection, &addToNamespaceCB, &cls); | 638 | (content_selection, &addToNamespaceCB, &cls); |
751 | } | 639 | } |
@@ -764,24 +652,16 @@ on_namespaceUpdateButton_clicked_fs (GtkWidget * dummy1, GtkWidget * dummy2) | |||
764 | { | 652 | { |
765 | NamespaceList *list; | 653 | NamespaceList *list; |
766 | GtkTreeIter iter; | 654 | GtkTreeIter iter; |
767 | GNUNET_HashCode nextId; | ||
768 | GNUNET_HashCode lastId; | ||
769 | GtkTreeSelection *selection; | 655 | GtkTreeSelection *selection; |
770 | IUC cls; | 656 | IUC cls; |
771 | char *last; | 657 | char *last; |
772 | char *next; | 658 | char *next; |
773 | char *freq; | ||
774 | GNUNET_EncName nextnext; | ||
775 | GtkWidget *nextEntryLine; | 659 | GtkWidget *nextEntryLine; |
776 | GtkWidget *identifierLabel; | 660 | GtkWidget *identifierLabel; |
777 | GtkWidget *updateIntervalComboBox; | ||
778 | GtkWidget *dialog; | 661 | GtkWidget *dialog; |
779 | GtkWidget *mdialog; | ||
780 | GtkWidget *notebook; | 662 | GtkWidget *notebook; |
781 | GtkWidget *page; | 663 | GtkWidget *page; |
782 | GtkTreeModel *model; | ||
783 | gint num; | 664 | gint num; |
784 | const char *nn_str; | ||
785 | 665 | ||
786 | GNUNET_GTK_DEBUG_BEGIN (); | 666 | GNUNET_GTK_DEBUG_BEGIN (); |
787 | /* find out which namespace this is about */ | 667 | /* find out which namespace this is about */ |
@@ -810,21 +690,12 @@ on_namespaceUpdateButton_clicked_fs (GtkWidget * dummy1, GtkWidget * dummy2) | |||
810 | return; | 690 | return; |
811 | } | 691 | } |
812 | gtk_tree_model_get (list->model, | 692 | gtk_tree_model_get (list->model, |
813 | &iter, | 693 | &iter, IN_NAMESPACE_NEXT_STRING, &next, -1); |
814 | IN_NAMESPACE_LAST_STRING, &last, | 694 | if ((last == NULL) || (next == NULL)) |
815 | IN_NAMESPACE_NEXT_STRING, &next, | ||
816 | IN_NAMESPACE_PUB_FREQ_STRING, &freq, -1); | ||
817 | if ((last == NULL) || (next == NULL) || (freq == NULL)) | ||
818 | { | 695 | { |
819 | GNUNET_GE_BREAK (NULL, 0); | 696 | GNUNET_GE_BREAK (NULL, 0); |
820 | return; | 697 | return; |
821 | } | 698 | } |
822 | if (GNUNET_OK != parseTimeInterval (freq, &cls.updateInterval)) | ||
823 | { | ||
824 | GNUNET_GE_BREAK (ectx, 0); | ||
825 | cls.updateInterval = GNUNET_ECRS_SBLOCK_UPDATE_SPORADIC; | ||
826 | } | ||
827 | |||
828 | /* create update dialog */ | 699 | /* create update dialog */ |
829 | metaXML | 700 | metaXML |
830 | = glade_xml_new (GNUNET_GTK_get_glade_filename (), | 701 | = glade_xml_new (GNUNET_GTK_get_glade_filename (), |
@@ -834,60 +705,15 @@ on_namespaceUpdateButton_clicked_fs (GtkWidget * dummy1, GtkWidget * dummy2) | |||
834 | gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); | 705 | gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); |
835 | identifierLabel = glade_xml_get_widget (metaXML, "identifierLabel"); | 706 | identifierLabel = glade_xml_get_widget (metaXML, "identifierLabel"); |
836 | gtk_label_set_text (GTK_LABEL (identifierLabel), next); | 707 | gtk_label_set_text (GTK_LABEL (identifierLabel), next); |
837 | GNUNET_enc_to_hash (last, &lastId); | 708 | cls.thisId = next; |
838 | cls.lastId = &lastId; | ||
839 | GNUNET_enc_to_hash (next, &cls.thisId); | ||
840 | |||
841 | nextEntryLine = glade_xml_get_widget (metaXML, "nextIdentifierEntry"); | 709 | nextEntryLine = glade_xml_get_widget (metaXML, "nextIdentifierEntry"); |
842 | if ((cls.updateInterval != GNUNET_ECRS_SBLOCK_UPDATE_SPORADIC) && | ||
843 | (GNUNET_OK == GNUNET_NS_compute_next_identifier (NULL, | ||
844 | cfg, | ||
845 | &cls.nsid, | ||
846 | &lastId, | ||
847 | &cls.thisId, | ||
848 | cls.updateInterval, | ||
849 | &nextId))) | ||
850 | { | ||
851 | GNUNET_hash_to_enc (&nextId, &nextnext); | ||
852 | gtk_entry_set_text (GTK_ENTRY (nextEntryLine), (char *) &nextnext); | ||
853 | gtk_widget_set_sensitive (nextEntryLine, FALSE); | ||
854 | } | ||
855 | /* set update interval in dialog to | ||
856 | the existing update interval */ | ||
857 | updateIntervalComboBox = glade_xml_get_widget (metaXML, | ||
858 | "namespaceUpdateIntervalComboBoxEntry"); | ||
859 | model = gtk_combo_box_get_model (GTK_COMBO_BOX (updateIntervalComboBox)); | ||
860 | gtk_list_store_insert (GTK_LIST_STORE (model), &iter, 0); | ||
861 | gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, freq, -1); | ||
862 | gtk_combo_box_set_active (GTK_COMBO_BOX (updateIntervalComboBox), 0); | ||
863 | |||
864 | /* run update dialog */ | 710 | /* run update dialog */ |
865 | if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_OK) | 711 | if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_OK) |
866 | goto CLEANUP; | 712 | goto CLEANUP; |
867 | gtk_widget_hide (dialog); | 713 | gtk_widget_hide (dialog); |
868 | 714 | ||
869 | /* get data from update dialog */ | 715 | /* get data from update dialog */ |
870 | nn_str = gtk_entry_get_text (GTK_ENTRY (nextEntryLine)); | 716 | cls.nextId = gtk_entry_get_text (GTK_ENTRY (nextEntryLine)); |
871 | if (nn_str == NULL) | ||
872 | nn_str = ""; | ||
873 | GNUNET_hash (nn_str, strlen (nn_str), &nextId); | ||
874 | cls.nextId = &nextId; | ||
875 | |||
876 | if (GNUNET_OK != tryParseTimeInterval (metaXML, | ||
877 | "namespaceUpdateIntervalComboBoxEntry", | ||
878 | &cls.updateInterval)) | ||
879 | { | ||
880 | /* This should be impossible since the | ||
881 | the GNUNET_OK button is deactivated while parse errors are present */ | ||
882 | mdialog = gtk_message_dialog_new | ||
883 | (NULL, | ||
884 | GTK_DIALOG_MODAL, | ||
885 | GTK_MESSAGE_ERROR, | ||
886 | GTK_BUTTONS_CLOSE, _("Failed to parse given time interval!")); | ||
887 | gtk_dialog_run (GTK_DIALOG (mdialog)); | ||
888 | gtk_widget_destroy (mdialog); | ||
889 | goto CLEANUP; | ||
890 | } | ||
891 | cls.anonymityLevel | 717 | cls.anonymityLevel |
892 | = getSpinButtonValue (metaXML, "namespaceUpdateAnonymitySpinButton"); | 718 | = getSpinButtonValue (metaXML, "namespaceUpdateAnonymitySpinButton"); |
893 | 719 | ||
@@ -900,7 +726,6 @@ CLEANUP: | |||
900 | metaXML = NULL; | 726 | metaXML = NULL; |
901 | free (last); | 727 | free (last); |
902 | free (next); | 728 | free (next); |
903 | free (freq); | ||
904 | GNUNET_GTK_DEBUG_END (); | 729 | GNUNET_GTK_DEBUG_END (); |
905 | } | 730 | } |
906 | 731 | ||
diff --git a/src/plugins/fs/namespace_create.c b/src/plugins/fs/namespace_create.c index b89f3ebd..5df9b5b2 100644 --- a/src/plugins/fs/namespace_create.c +++ b/src/plugins/fs/namespace_create.c | |||
@@ -193,7 +193,7 @@ on_namespaceKeywordEntry_changed_fs (gpointer dummy2, GtkWidget * searchEntry) | |||
193 | void | 193 | void |
194 | create_namespace_clicked_fs (GtkWidget * dummy1, GtkWidget * dummy2) | 194 | create_namespace_clicked_fs (GtkWidget * dummy1, GtkWidget * dummy2) |
195 | { | 195 | { |
196 | const char *namespaceName; | 196 | const char *rootName; |
197 | GtkWidget *nameLine; | 197 | GtkWidget *nameLine; |
198 | GtkWidget *dialog; | 198 | GtkWidget *dialog; |
199 | GtkWidget *spin; | 199 | GtkWidget *spin; |
@@ -201,7 +201,6 @@ create_namespace_clicked_fs (GtkWidget * dummy1, GtkWidget * dummy2) | |||
201 | struct GNUNET_ECRS_URI *keywordURI; | 201 | struct GNUNET_ECRS_URI *keywordURI; |
202 | struct GNUNET_ECRS_URI *root; | 202 | struct GNUNET_ECRS_URI *root; |
203 | GNUNET_HashCode namespaceId; | 203 | GNUNET_HashCode namespaceId; |
204 | GNUNET_HashCode rootEntry; | ||
205 | 204 | ||
206 | GNUNET_GTK_DEBUG_BEGIN (); | 205 | GNUNET_GTK_DEBUG_BEGIN (); |
207 | metaXML | 206 | metaXML |
@@ -241,15 +240,12 @@ create_namespace_clicked_fs (GtkWidget * dummy1, GtkWidget * dummy2) | |||
241 | "namespaceMetaDataDialogKeywordList"); | 240 | "namespaceMetaDataDialogKeywordList"); |
242 | spin = glade_xml_get_widget (metaXML, "namespaceAnonymityspinbutton"); | 241 | spin = glade_xml_get_widget (metaXML, "namespaceAnonymityspinbutton"); |
243 | nameLine = glade_xml_get_widget (metaXML, "namespaceRootEntry"); | 242 | nameLine = glade_xml_get_widget (metaXML, "namespaceRootEntry"); |
244 | namespaceName = gtk_entry_get_text (GTK_ENTRY (nameLine)); | 243 | rootName = gtk_entry_get_text (GTK_ENTRY (nameLine)); |
245 | if (namespaceName == NULL) | 244 | if (rootName == NULL) |
246 | namespaceName = "root"; /* do NOT translate "root"! */ | 245 | rootName = "root"; /* do NOT translate "root"! */ |
247 | GNUNET_hash (namespaceName, strlen (namespaceName), &rootEntry); | ||
248 | nameLine = glade_xml_get_widget (metaXML, "namespaceNameEntry"); | ||
249 | namespaceName = gtk_entry_get_text (GTK_ENTRY (nameLine)); | ||
250 | root = GNUNET_NS_namespace_create (ectx, cfg, gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin)), 1000, /* FIXME: priority */ | 246 | root = GNUNET_NS_namespace_create (ectx, cfg, gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin)), 1000, /* FIXME: priority */ |
251 | GNUNET_get_time () + 2 * GNUNET_CRON_YEARS, /* FIXME: expiration */ | 247 | GNUNET_get_time () + 2 * GNUNET_CRON_YEARS, /* FIXME: expiration */ |
252 | meta, keywordURI, &rootEntry); | 248 | meta, keywordURI, rootName); |
253 | if (root != NULL) | 249 | if (root != NULL) |
254 | { | 250 | { |
255 | GNUNET_ECRS_uri_get_namespace_from_sks (root, &namespaceId); | 251 | GNUNET_ECRS_uri_get_namespace_from_sks (root, &namespaceId); |
@@ -269,10 +265,7 @@ create_namespace_clicked_fs (GtkWidget * dummy1, GtkWidget * dummy2) | |||
269 | GTK_DIALOG_MODAL, | 265 | GTK_DIALOG_MODAL, |
270 | GTK_MESSAGE_ERROR, | 266 | GTK_MESSAGE_ERROR, |
271 | GTK_BUTTONS_CLOSE, | 267 | GTK_BUTTONS_CLOSE, |
272 | _("Failed to create namespace `%s'." | 268 | _("Failed to create namespace." "Consult logs.")); |
273 | "Consult logs, most likely error is" | ||
274 | " that a namespace with that name " | ||
275 | "already exists."), namespaceName); | ||
276 | gtk_dialog_run (GTK_DIALOG (dialog)); | 269 | gtk_dialog_run (GTK_DIALOG (dialog)); |
277 | gtk_widget_destroy (dialog); | 270 | gtk_widget_destroy (dialog); |
278 | } | 271 | } |
diff --git a/src/plugins/fs/namespace_search.c b/src/plugins/fs/namespace_search.c index afa37136..d81b27c5 100644 --- a/src/plugins/fs/namespace_search.c +++ b/src/plugins/fs/namespace_search.c | |||
@@ -128,8 +128,7 @@ on_searchNamespaceComboBoxEntry_changed_fs (GtkWidget * dummy, | |||
128 | char *encStr; | 128 | char *encStr; |
129 | char *descStr; | 129 | char *descStr; |
130 | GNUNET_HashCode ns; | 130 | GNUNET_HashCode ns; |
131 | GNUNET_HashCode root; | 131 | char *root; |
132 | GNUNET_EncName enc; | ||
133 | 132 | ||
134 | GNUNET_GTK_DEBUG_BEGIN (); | 133 | GNUNET_GTK_DEBUG_BEGIN (); |
135 | spin = | 134 | spin = |
@@ -161,13 +160,13 @@ on_searchNamespaceComboBoxEntry_changed_fs (GtkWidget * dummy, | |||
161 | keyword | 160 | keyword |
162 | = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), | 161 | = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), |
163 | "fssearchKeywordComboBoxEntry"); | 162 | "fssearchKeywordComboBoxEntry"); |
164 | if (GNUNET_OK == | 163 | root = GNUNET_NS_namespace_get_root (ectx, cfg, &ns); |
165 | GNUNET_NS_namespace_get_root (ectx, cfg, &ns, &root)) | 164 | if (root != NULL) |
166 | { | 165 | { |
167 | GNUNET_hash_to_enc (&root, &enc); | ||
168 | gtk_entry_set_text (GTK_ENTRY | 166 | gtk_entry_set_text (GTK_ENTRY |
169 | (gtk_bin_get_child (GTK_BIN (keyword))), | 167 | (gtk_bin_get_child (GTK_BIN (keyword))), |
170 | (const gchar *) &enc); | 168 | root); |
169 | GNUNET_free (root); | ||
171 | } | 170 | } |
172 | else | 171 | else |
173 | { | 172 | { |
diff --git a/src/plugins/fs/search.c b/src/plugins/fs/search.c index 11be760d..5ffcec2f 100644 --- a/src/plugins/fs/search.c +++ b/src/plugins/fs/search.c | |||
@@ -229,28 +229,30 @@ addEntryToSearchTree (SearchList * searchContext, | |||
229 | GNUNET_ECRS_uri_get_keyword_count_from_ksk | 229 | GNUNET_ECRS_uri_get_keyword_count_from_ksk |
230 | (searchContext->uri)); | 230 | (searchContext->uri)); |
231 | #ifdef HAVE_GIO | 231 | #ifdef HAVE_GIO |
232 | if (0 == strcmp(rawMime, GNUNET_DIRECTORY_MIME)) | 232 | if (0 == strcmp (rawMime, GNUNET_DIRECTORY_MIME)) |
233 | { | 233 | { |
234 | mime = GNUNET_strdup(_("Directory")); | 234 | mime = GNUNET_strdup (_("Directory")); |
235 | icon = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), | 235 | icon = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), |
236 | "folder", 16, 0, (GError **)NULL); | 236 | "folder", 16, 0, (GError **) NULL); |
237 | } | 237 | } |
238 | else | 238 | else |
239 | { | 239 | { |
240 | mime = g_content_type_get_description (rawMime); | 240 | mime = g_content_type_get_description (rawMime); |
241 | gicon = g_content_type_get_icon (rawMime); | 241 | gicon = g_content_type_get_icon (rawMime); |
242 | if (G_IS_THEMED_ICON (gicon)) | 242 | if (G_IS_THEMED_ICON (gicon)) |
243 | { | 243 | { |
244 | iconNames = (const gchar **)g_themed_icon_get_names | 244 | iconNames = (const gchar **) g_themed_icon_get_names |
245 | (G_THEMED_ICON (gicon)); | 245 | (G_THEMED_ICON (gicon)); |
246 | do { | 246 | do |
247 | icon = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), | 247 | { |
248 | iconNames[i], 16, 0, | 248 | icon = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), |
249 | (GError **)NULL); | 249 | iconNames[i], 16, 0, |
250 | i++; | 250 | (GError **) NULL); |
251 | } while ( (icon == NULL) && iconNames[i] ); | 251 | i++; |
252 | } | 252 | } |
253 | } | 253 | while ((icon == NULL) && iconNames[i]); |
254 | } | ||
255 | } | ||
254 | #else | 256 | #else |
255 | mime = rawMime; | 257 | mime = rawMime; |
256 | #endif | 258 | #endif |
@@ -712,9 +714,9 @@ fs_search_started (struct GNUNET_FSUI_SearchList * fsui_list, | |||
712 | g_signal_connect_swapped (list->treeview, | 714 | g_signal_connect_swapped (list->treeview, |
713 | "button-press-event", | 715 | "button-press-event", |
714 | G_CALLBACK (search_click_handler), list); | 716 | G_CALLBACK (search_click_handler), list); |
715 | list->tree = gtk_tree_store_new (SEARCH_NUM, G_TYPE_STRING, /* name */ | 717 | list->tree = gtk_tree_store_new (SEARCH_NUM, G_TYPE_STRING, /* name */ |
716 | #ifdef HAVE_GIO | 718 | #ifdef HAVE_GIO |
717 | GDK_TYPE_PIXBUF, /* icon */ | 719 | GDK_TYPE_PIXBUF, /* icon */ |
718 | #endif | 720 | #endif |
719 | G_TYPE_UINT64, /* size */ | 721 | G_TYPE_UINT64, /* size */ |
720 | G_TYPE_STRING, /* human-readable size */ | 722 | G_TYPE_STRING, /* human-readable size */ |