diff options
author | Christian Grothoff <christian@grothoff.org> | 2005-08-25 08:33:42 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2005-08-25 08:33:42 +0000 |
commit | a06ad82800dbdc79bb37fc64d7cff59751001389 (patch) | |
tree | 207d3e36833a87210e7f40552a4e2f13f05e0d07 | |
parent | b325866879e0a3b3eaf28c6d97f11e02a2e76341 (diff) | |
download | gnunet-gtk-a06ad82800dbdc79bb37fc64d7cff59751001389.tar.gz gnunet-gtk-a06ad82800dbdc79bb37fc64d7cff59751001389.zip |
sync
-rw-r--r-- | src/plugins/fs/meta.c | 24 | ||||
-rw-r--r-- | src/plugins/fs/meta.h | 3 | ||||
-rw-r--r-- | src/plugins/fs/namespace.c | 91 |
3 files changed, 90 insertions, 28 deletions
diff --git a/src/plugins/fs/meta.c b/src/plugins/fs/meta.c index e51a426b..bd62b62b 100644 --- a/src/plugins/fs/meta.c +++ b/src/plugins/fs/meta.c | |||
@@ -393,15 +393,8 @@ char * updateIntervalToString(TIME_T interval) { | |||
393 | return timeIntervalToFancyString(interval * cronSECONDS); | 393 | return timeIntervalToFancyString(interval * cronSECONDS); |
394 | } | 394 | } |
395 | 395 | ||
396 | int tryParseTimeInterval(GladeXML * xml, | 396 | int parseTimeInterval(const char * timeSpec, |
397 | const char * intervalComboBoxEntry, | 397 | TIME_T * interval) { |
398 | TIME_T * interval) { | ||
399 | GtkWidget * update; | ||
400 | const char * timeSpec; | ||
401 | |||
402 | update = glade_xml_get_widget(xml, | ||
403 | intervalComboBoxEntry); | ||
404 | timeSpec = gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(update)))); | ||
405 | if (timeSpec == NULL) | 398 | if (timeSpec == NULL) |
406 | return SYSERR; | 399 | return SYSERR; |
407 | if (0 == strcmp(_("--sporadic update--"), | 400 | if (0 == strcmp(_("--sporadic update--"), |
@@ -416,6 +409,19 @@ int tryParseTimeInterval(GladeXML * xml, | |||
416 | return OK; | 409 | return OK; |
417 | } | 410 | } |
418 | 411 | ||
412 | int tryParseTimeInterval(GladeXML * xml, | ||
413 | const char * intervalComboBoxEntry, | ||
414 | TIME_T * interval) { | ||
415 | GtkWidget * update; | ||
416 | const char * timeSpec; | ||
417 | |||
418 | update = glade_xml_get_widget(xml, | ||
419 | intervalComboBoxEntry); | ||
420 | timeSpec = gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(update)))); | ||
421 | return parseTimeInterval(timeSpec, | ||
422 | interval); | ||
423 | } | ||
424 | |||
419 | unsigned int getAnonymityLevel(GladeXML * xml, | 425 | unsigned int getAnonymityLevel(GladeXML * xml, |
420 | const char * spinButtonName) { | 426 | const char * spinButtonName) { |
421 | GtkWidget * spin; | 427 | GtkWidget * spin; |
diff --git a/src/plugins/fs/meta.h b/src/plugins/fs/meta.h index 5e52709e..41bcbd69 100644 --- a/src/plugins/fs/meta.h +++ b/src/plugins/fs/meta.h | |||
@@ -64,6 +64,9 @@ int tryParseTimeInterval(GladeXML * xml, | |||
64 | const char * intervalComboBoxEntry, | 64 | const char * intervalComboBoxEntry, |
65 | TIME_T * interval); | 65 | TIME_T * interval); |
66 | 66 | ||
67 | int parseTimeInterval(const char * frequency, | ||
68 | TIME_T * interval); | ||
69 | |||
67 | unsigned int getAnonymityLevel(GladeXML * xml, | 70 | unsigned int getAnonymityLevel(GladeXML * xml, |
68 | const char * spinButtonName); | 71 | const char * spinButtonName); |
69 | 72 | ||
diff --git a/src/plugins/fs/namespace.c b/src/plugins/fs/namespace.c index ac0d42d0..5a4056ae 100644 --- a/src/plugins/fs/namespace.c +++ b/src/plugins/fs/namespace.c | |||
@@ -327,7 +327,10 @@ static int addNamespaceContentToModel(void * cls, | |||
327 | size = 0; | 327 | size = 0; |
328 | uriString = ECRS_uriToString(fi->uri); | 328 | uriString = ECRS_uriToString(fi->uri); |
329 | hash2enc(lastId, &last); | 329 | hash2enc(lastId, &last); |
330 | hash2enc(nextId, &next); | 330 | if (nextId != NULL) |
331 | hash2enc(nextId, &next); | ||
332 | else | ||
333 | memset(&next, 0, sizeof(EncName)); | ||
331 | if (publicationFrequency == ECRS_SBLOCK_UPDATE_SPORADIC) | 334 | if (publicationFrequency == ECRS_SBLOCK_UPDATE_SPORADIC) |
332 | date = STRDUP(_("unspecified")); | 335 | date = STRDUP(_("unspecified")); |
333 | else if (publicationFrequency == ECRS_SBLOCK_UPDATE_NONE) | 336 | else if (publicationFrequency == ECRS_SBLOCK_UPDATE_NONE) |
@@ -684,6 +687,7 @@ void on_namespaceInsertButton_clicked(GtkWidget * dummy1, | |||
684 | GtkTreeSelection * selection; | 687 | GtkTreeSelection * selection; |
685 | IUC cls; | 688 | IUC cls; |
686 | gint num; | 689 | gint num; |
690 | GtkTreeIter iter; | ||
687 | 691 | ||
688 | contentList | 692 | contentList |
689 | = glade_xml_get_widget(getMainXML(), | 693 | = glade_xml_get_widget(getMainXML(), |
@@ -703,6 +707,16 @@ void on_namespaceInsertButton_clicked(GtkWidget * dummy1, | |||
703 | gtk_widget_destroy(dialog); | 707 | gtk_widget_destroy(dialog); |
704 | return; | 708 | return; |
705 | } | 709 | } |
710 | if (FALSE == gtk_tree_selection_get_selected(selection, | ||
711 | NULL, | ||
712 | &iter)) { | ||
713 | BREAK(); | ||
714 | return; | ||
715 | } | ||
716 | gtk_tree_model_get(gtk_tree_view_get_model(GTK_TREE_VIEW(contentList)), | ||
717 | &iter, | ||
718 | NAMESPACE_META, &meta, | ||
719 | -1); | ||
706 | 720 | ||
707 | notebook | 721 | notebook |
708 | = glade_xml_get_widget(getMainXML(), | 722 | = glade_xml_get_widget(getMainXML(), |
@@ -729,7 +743,7 @@ void on_namespaceInsertButton_clicked(GtkWidget * dummy1, | |||
729 | createMetaDataListTreeView(metaXML, | 743 | createMetaDataListTreeView(metaXML, |
730 | "metaDataTreeView", | 744 | "metaDataTreeView", |
731 | "namespaceInsertPreview", | 745 | "namespaceInsertPreview", |
732 | NULL); | 746 | meta); |
733 | createMetaTypeComboBox(metaXML, | 747 | createMetaTypeComboBox(metaXML, |
734 | "namespaceInsertMetaTypeComboBox"); | 748 | "namespaceInsertMetaTypeComboBox"); |
735 | dialog = glade_xml_get_widget(metaXML, | 749 | dialog = glade_xml_get_widget(metaXML, |
@@ -836,6 +850,16 @@ void on_namespaceUpdateButton_clicked(GtkWidget * dummy1, | |||
836 | gtk_widget_destroy(dialog); | 850 | gtk_widget_destroy(dialog); |
837 | return; | 851 | return; |
838 | } | 852 | } |
853 | if (FALSE == gtk_tree_selection_get_selected(selection, | ||
854 | NULL, | ||
855 | &iter)) { | ||
856 | BREAK(); | ||
857 | return; | ||
858 | } | ||
859 | gtk_tree_model_get(gtk_tree_view_get_model(GTK_TREE_VIEW(contentList)), | ||
860 | &iter, | ||
861 | NAMESPACE_META, &meta, | ||
862 | -1); | ||
839 | 863 | ||
840 | notebook | 864 | notebook |
841 | = glade_xml_get_widget(getMainXML(), | 865 | = glade_xml_get_widget(getMainXML(), |
@@ -881,7 +905,6 @@ void on_namespaceUpdateButton_clicked(GtkWidget * dummy1, | |||
881 | IN_NAMESPACE_LAST_STRING, &last, | 905 | IN_NAMESPACE_LAST_STRING, &last, |
882 | IN_NAMESPACE_NEXT_STRING, &next, | 906 | IN_NAMESPACE_NEXT_STRING, &next, |
883 | IN_NAMESPACE_PUB_FREQ_STRING, &freq, | 907 | IN_NAMESPACE_PUB_FREQ_STRING, &freq, |
884 | IN_NAMESPACE_META, &meta, | ||
885 | -1); | 908 | -1); |
886 | metaXML | 909 | metaXML |
887 | = glade_xml_new(getGladeFileName(), | 910 | = glade_xml_new(getGladeFileName(), |
@@ -909,8 +932,34 @@ void on_namespaceUpdateButton_clicked(GtkWidget * dummy1, | |||
909 | } | 932 | } |
910 | nameLine = glade_xml_get_widget(metaXML, | 933 | nameLine = glade_xml_get_widget(metaXML, |
911 | "nextIdentifierEntry"); | 934 | "nextIdentifierEntry"); |
912 | gtk_entry_set_text(GTK_ENTRY(nameLine), | 935 | if (OK != parseTimeInterval(freq, |
913 | ""); /* FIXME: compute next for sporadic updates (extend libecrs?) */ | 936 | &cls.updateInterval)) { |
937 | BREAK(); | ||
938 | cls.updateInterval = ECRS_SBLOCK_UPDATE_SPORADIC; | ||
939 | } | ||
940 | if (cls.updateInterval == ECRS_SBLOCK_UPDATE_SPORADIC) { | ||
941 | gtk_entry_set_text(GTK_ENTRY(nameLine), | ||
942 | ""); | ||
943 | } else { | ||
944 | EncName updateName; | ||
945 | |||
946 | if (OK != FSUI_computeNextId(list->name, | ||
947 | &prevId, | ||
948 | &cls.thisId, | ||
949 | cls.updateInterval, | ||
950 | &nextId)) { | ||
951 | BREAK(); | ||
952 | UNREF(metaXML); | ||
953 | metaXML = NULL; | ||
954 | return; | ||
955 | } | ||
956 | hash2enc(&nextId, | ||
957 | &updateName); | ||
958 | gtk_entry_set_text(GTK_ENTRY(nameLine), | ||
959 | (const char*) &updateName); | ||
960 | gtk_entry_set_editable(GTK_ENTRY(nameLine), | ||
961 | FALSE); | ||
962 | } | ||
914 | 963 | ||
915 | update = glade_xml_get_widget(metaXML, | 964 | update = glade_xml_get_widget(metaXML, |
916 | "namespaceUpdateIntervalComboBoxEntry"); | 965 | "namespaceUpdateIntervalComboBoxEntry"); |
@@ -927,9 +976,22 @@ void on_namespaceUpdateButton_clicked(GtkWidget * dummy1, | |||
927 | gtk_dialog_set_default_response(GTK_DIALOG(dialog), | 976 | gtk_dialog_set_default_response(GTK_DIALOG(dialog), |
928 | GTK_RESPONSE_OK); | 977 | GTK_RESPONSE_OK); |
929 | if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) { | 978 | if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) { |
979 | const char * error = NULL; | ||
980 | nameLine = glade_xml_get_widget(metaXML, | ||
981 | "nextIdentifierEntry"); | ||
930 | if (OK != tryParseTimeInterval(metaXML, | 982 | if (OK != tryParseTimeInterval(metaXML, |
931 | "namespaceUpdateIntervalComboBoxEntry", | 983 | "namespaceUpdateIntervalComboBoxEntry", |
932 | &cls.updateInterval)) { | 984 | &cls.updateInterval)) { |
985 | error = _("Failed to parse given time interval!"); | ||
986 | } else { | ||
987 | identifierName = gtk_entry_get_text(GTK_ENTRY(nameLine)); | ||
988 | if ( (cls.updateInterval != ECRS_SBLOCK_UPDATE_NONE) && | ||
989 | ( (identifierName == NULL) || | ||
990 | (strlen(identifierName) == 0)) ) { | ||
991 | error = _("You must specify an identifier for the next publication."); | ||
992 | } | ||
993 | } | ||
994 | if (error != NULL) { | ||
933 | gtk_widget_destroy(dialog); | 995 | gtk_widget_destroy(dialog); |
934 | UNREF(metaXML); | 996 | UNREF(metaXML); |
935 | metaXML = NULL; | 997 | metaXML = NULL; |
@@ -938,12 +1000,15 @@ void on_namespaceUpdateButton_clicked(GtkWidget * dummy1, | |||
938 | GTK_DIALOG_MODAL, | 1000 | GTK_DIALOG_MODAL, |
939 | GTK_MESSAGE_ERROR, | 1001 | GTK_MESSAGE_ERROR, |
940 | GTK_BUTTONS_CLOSE, | 1002 | GTK_BUTTONS_CLOSE, |
941 | _("Failed to parse given time interval!")); | 1003 | error); |
942 | gtk_dialog_run(GTK_DIALOG(dialog)); | 1004 | gtk_dialog_run(GTK_DIALOG(dialog)); |
943 | gtk_widget_destroy(dialog); | 1005 | gtk_widget_destroy(dialog); |
944 | return; | 1006 | return; |
945 | } | 1007 | } |
946 | 1008 | hash(identifierName, | |
1009 | strlen(identifierName), | ||
1010 | &nextId); | ||
1011 | cls.nextId = &nextId; | ||
947 | cls.meta = getMetaDataFromList(metaXML, | 1012 | cls.meta = getMetaDataFromList(metaXML, |
948 | "namespaceUpdateMetaDataTreeView", | 1013 | "namespaceUpdateMetaDataTreeView", |
949 | "namespaceUpdatePreviewImage"); | 1014 | "namespaceUpdatePreviewImage"); |
@@ -951,18 +1016,6 @@ void on_namespaceUpdateButton_clicked(GtkWidget * dummy1, | |||
951 | "namespaceUpdateAnonymitySpinButton"); | 1016 | "namespaceUpdateAnonymitySpinButton"); |
952 | cls.anonymityLevel | 1017 | cls.anonymityLevel |
953 | = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin)); | 1018 | = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin)); |
954 | nameLine = glade_xml_get_widget(metaXML, | ||
955 | "nextIdentifierEntry"); | ||
956 | identifierName = gtk_entry_get_text(GTK_ENTRY(nameLine)); | ||
957 | if ( (identifierName == NULL) || | ||
958 | (strlen(identifierName) == 0)) { | ||
959 | cls.nextId = NULL; | ||
960 | } else { | ||
961 | hash(identifierName, | ||
962 | strlen(identifierName), | ||
963 | &nextId); | ||
964 | cls.nextId = &nextId; | ||
965 | } | ||
966 | 1019 | ||
967 | gtk_tree_selection_selected_foreach | 1020 | gtk_tree_selection_selected_foreach |
968 | (selection, | 1021 | (selection, |