diff options
Diffstat (limited to 'src/plugins/fs/namespace.c')
-rw-r--r-- | src/plugins/fs/namespace.c | 194 |
1 files changed, 165 insertions, 29 deletions
diff --git a/src/plugins/fs/namespace.c b/src/plugins/fs/namespace.c index 674e6c8a..21d304e6 100644 --- a/src/plugins/fs/namespace.c +++ b/src/plugins/fs/namespace.c | |||
@@ -660,7 +660,7 @@ static void initiateUpload(GtkTreeModel * model, | |||
660 | } | 660 | } |
661 | } | 661 | } |
662 | 662 | ||
663 | void on_namespaceUpdateMetaDataDialogMetaDataAddButton_clicked(GtkWidget * dummy1, | 663 | void on_namespaceInsertMetaDataDialogMetaDataAddButton_clicked(GtkWidget * dummy1, |
664 | GtkWidget * dummy2) { | 664 | GtkWidget * dummy2) { |
665 | handleMetaDataListUpdate(metaXML, | 665 | handleMetaDataListUpdate(metaXML, |
666 | "namespaceInsertMetaTypeComboBox", | 666 | "namespaceInsertMetaTypeComboBox", |
@@ -671,14 +671,11 @@ void on_namespaceUpdateMetaDataDialogMetaDataAddButton_clicked(GtkWidget * dummy | |||
671 | void on_namespaceInsertButton_clicked(GtkWidget * dummy1, | 671 | void on_namespaceInsertButton_clicked(GtkWidget * dummy1, |
672 | GtkWidget * dummy2) { | 672 | GtkWidget * dummy2) { |
673 | const char * identifierName; | 673 | const char * identifierName; |
674 | const char * timeSpec; | ||
675 | NamespaceList * list; | 674 | NamespaceList * list; |
676 | GtkWidget * nameLine; | 675 | GtkWidget * nameLine; |
677 | GtkWidget * page; | 676 | GtkWidget * page; |
678 | GtkWidget * notebook; | 677 | GtkWidget * notebook; |
679 | GtkWidget * dialog; | 678 | GtkWidget * dialog; |
680 | GtkWidget * spin; | ||
681 | GtkWidget * update; | ||
682 | struct ECRS_MetaData * meta; | 679 | struct ECRS_MetaData * meta; |
683 | HashCode512 nextId; | 680 | HashCode512 nextId; |
684 | GtkWidget * contentList; | 681 | GtkWidget * contentList; |
@@ -738,19 +735,9 @@ void on_namespaceInsertButton_clicked(GtkWidget * dummy1, | |||
738 | gtk_dialog_set_default_response(GTK_DIALOG(dialog), | 735 | gtk_dialog_set_default_response(GTK_DIALOG(dialog), |
739 | GTK_RESPONSE_OK); | 736 | GTK_RESPONSE_OK); |
740 | if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) { | 737 | if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) { |
741 | update = glade_xml_get_widget(metaXML, | 738 | if (OK != tryParseTimeInterval(metaXML, |
742 | "updateIntervalComboBoxEntry"); | 739 | "updateIntervalComboBoxEntry", |
743 | timeSpec = gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(update)))); | 740 | &cls.updateInterval)) { |
744 | if (timeSpec == NULL) | ||
745 | timeSpec = ""; | ||
746 | if (0 == strcmp(_("--sporadic update--"), | ||
747 | timeSpec)) | ||
748 | cls.updateInterval = ECRS_SBLOCK_UPDATE_SPORADIC; | ||
749 | else if (0 == strcmp(_("--no update--"), | ||
750 | timeSpec)) | ||
751 | cls.updateInterval = ECRS_SBLOCK_UPDATE_NONE; | ||
752 | else if (OK != parseTime(timeSpec, | ||
753 | &cls.updateInterval)) { | ||
754 | gtk_widget_destroy(dialog); | 741 | gtk_widget_destroy(dialog); |
755 | UNREF(metaXML); | 742 | UNREF(metaXML); |
756 | metaXML = NULL; | 743 | metaXML = NULL; |
@@ -768,10 +755,9 @@ void on_namespaceInsertButton_clicked(GtkWidget * dummy1, | |||
768 | meta = getMetaDataFromList(metaXML, | 755 | meta = getMetaDataFromList(metaXML, |
769 | "metaDataTreeView", | 756 | "metaDataTreeView", |
770 | "namespaceInsertPreview"); | 757 | "namespaceInsertPreview"); |
771 | spin = glade_xml_get_widget(metaXML, | ||
772 | "anonymitySpinButton"); | ||
773 | cls.anonymityLevel | 758 | cls.anonymityLevel |
774 | = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin)); | 759 | = getAnonymityLevel(metaXML, |
760 | "anonymitySpinButton"); | ||
775 | nameLine = glade_xml_get_widget(metaXML, | 761 | nameLine = glade_xml_get_widget(metaXML, |
776 | "namespaceContentIdentifierEntry"); | 762 | "namespaceContentIdentifierEntry"); |
777 | identifierName = gtk_entry_get_text(GTK_ENTRY(nameLine)); | 763 | identifierName = gtk_entry_get_text(GTK_ENTRY(nameLine)); |
@@ -807,21 +793,171 @@ void on_namespaceInsertButton_clicked(GtkWidget * dummy1, | |||
807 | metaXML = NULL; | 793 | metaXML = NULL; |
808 | } | 794 | } |
809 | 795 | ||
796 | typedef struct { | ||
797 | unsigned int anonymityLevel; | ||
798 | char * namespaceName; | ||
799 | TIME_T updateInterval; | ||
800 | HashCode512 lastId; | ||
801 | HashCode512 thisId; | ||
802 | HashCode512 * nextId; | ||
803 | struct ECRS_MetaData * meta; | ||
804 | } UUC; | ||
810 | 805 | ||
811 | 806 | ||
812 | void on_namespaceUpdateButton_clicked(GtkWidget * dummy1, | 807 | void on_namespaceUpdateButton_clicked(GtkWidget * dummy1, |
813 | GtkWidget * dummy2) { | 808 | GtkWidget * dummy2) { |
809 | const char * identifierName; | ||
810 | NamespaceList * list; | ||
811 | GtkWidget * nameLine; | ||
812 | GtkWidget * page; | ||
813 | GtkWidget * notebook; | ||
814 | GtkWidget * dialog; | 814 | GtkWidget * dialog; |
815 | GtkWidget * spin; | ||
816 | GtkWidget * update; | ||
817 | struct ECRS_MetaData * meta; | ||
818 | HashCode512 nextId; | ||
819 | GtkWidget * contentList; | ||
820 | GtkTreeSelection * selection; | ||
821 | GtkTreeSelection * selectionNamespace; | ||
822 | UUC cls; | ||
823 | gint num; | ||
824 | char * oldName; | ||
825 | struct ECRS_URI * uri; | ||
815 | 826 | ||
816 | /* FIXME: implement update! */ | 827 | contentList |
817 | dialog = gtk_message_dialog_new | 828 | = glade_xml_get_widget(getMainXML(), |
818 | (NULL, | 829 | "availableContentList"); |
819 | GTK_DIALOG_MODAL, | 830 | selection |
820 | GTK_MESSAGE_ERROR, | 831 | = gtk_tree_view_get_selection(GTK_TREE_VIEW(contentList)); |
821 | GTK_BUTTONS_CLOSE, | 832 | if (0 == gtk_tree_selection_count_selected_rows(selection)) { |
822 | _("Not implemented!")); | 833 | /* IMPROVE-ME: disable the menu item |
823 | gtk_dialog_run(GTK_DIALOG(dialog)); | 834 | as long as this may happen! */ |
824 | gtk_widget_destroy(dialog); | 835 | dialog = gtk_message_dialog_new |
836 | (NULL, | ||
837 | GTK_DIALOG_MODAL, | ||
838 | GTK_MESSAGE_ERROR, | ||
839 | GTK_BUTTONS_CLOSE, | ||
840 | _("You must select some available content for publication first!")); | ||
841 | gtk_dialog_run(GTK_DIALOG(dialog)); | ||
842 | gtk_widget_destroy(dialog); | ||
843 | return; | ||
844 | } | ||
845 | |||
846 | notebook | ||
847 | = glade_xml_get_widget(getMainXML(), | ||
848 | "localNamespacesNotebook"); | ||
849 | num = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)); | ||
850 | GNUNET_ASSERT(num != -1); | ||
851 | page =gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), | ||
852 | num); | ||
853 | list = head; | ||
854 | while ( (list != NULL) && | ||
855 | (list->namespacepage != page) ) | ||
856 | list = list->next; | ||
857 | if (list == NULL) { | ||
858 | BREAK(); | ||
859 | return; | ||
860 | } | ||
861 | cls.namespaceName = list->name; | ||
862 | |||
863 | /* check that in namespace (updateable) content is selected! */ | ||
864 | selectionNamespace | ||
865 | = gtk_tree_view_get_selection(GTK_TREE_VIEW(list->treeview)); | ||
866 | if (0 == gtk_tree_selection_count_selected_rows(selectionNamespace)) { | ||
867 | /* IMPROVE-ME: disable the menu item | ||
868 | as long as this may happen! */ | ||
869 | dialog = gtk_message_dialog_new | ||
870 | (NULL, | ||
871 | GTK_DIALOG_MODAL, | ||
872 | GTK_MESSAGE_ERROR, | ||
873 | GTK_BUTTONS_CLOSE, | ||
874 | _("You must select some existing namespace content to be updated first!")); | ||
875 | gtk_dialog_run(GTK_DIALOG(dialog)); | ||
876 | gtk_widget_destroy(dialog); | ||
877 | return; | ||
878 | } | ||
879 | |||
880 | metaXML | ||
881 | = glade_xml_new(getGladeFileName(), | ||
882 | "namespaceUpdateDialog", | ||
883 | PACKAGE_NAME); | ||
884 | connectGladeWithPlugins(metaXML); | ||
885 | |||
886 | |||
887 | uri = NULL; // FIXME | ||
888 | oldName = STRDUP("FIXME"); // ECRS_uriToString(uri); | ||
889 | nameLine = glade_xml_get_widget(metaXML, | ||
890 | "identifierLabel"); | ||
891 | gtk_label_set_text(GTK_LABEL(nameLine), | ||
892 | oldName); | ||
893 | FREE(oldName); | ||
894 | /* FIXME: set next identifier label! */ | ||
895 | |||
896 | update = glade_xml_get_widget(metaXML, | ||
897 | "namespaceUpdateIntervalComboBoxEntry"); | ||
898 | /* FIXME: set update interval! */ | ||
899 | |||
900 | |||
901 | createMetaDataListTreeView(metaXML, | ||
902 | "namespaceUpdateMetaDataTreeView", | ||
903 | "namespaceUpdatePreviewImage", | ||
904 | NULL); | ||
905 | createMetaTypeComboBox(metaXML, | ||
906 | "namespaceUpdateMetaTypeComboBox"); | ||
907 | dialog = glade_xml_get_widget(metaXML, | ||
908 | "namespaceUpdateDialog"); | ||
909 | gtk_dialog_set_default_response(GTK_DIALOG(dialog), | ||
910 | GTK_RESPONSE_OK); | ||
911 | if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) { | ||
912 | if (OK != tryParseTimeInterval(metaXML, | ||
913 | "namespaceUpdateIntervalComboBoxEntry", | ||
914 | &cls.updateInterval)) { | ||
915 | gtk_widget_destroy(dialog); | ||
916 | UNREF(metaXML); | ||
917 | metaXML = NULL; | ||
918 | dialog = gtk_message_dialog_new | ||
919 | (NULL, | ||
920 | GTK_DIALOG_MODAL, | ||
921 | GTK_MESSAGE_ERROR, | ||
922 | GTK_BUTTONS_CLOSE, | ||
923 | _("Failed to parse given time interval!")); | ||
924 | gtk_dialog_run(GTK_DIALOG(dialog)); | ||
925 | gtk_widget_destroy(dialog); | ||
926 | return; | ||
927 | } | ||
928 | |||
929 | meta = getMetaDataFromList(metaXML, | ||
930 | "namespaceUpdateMetaDataTreeView", | ||
931 | "namespaceUpdatePreviewImage"); | ||
932 | spin = glade_xml_get_widget(metaXML, | ||
933 | "namespaceUpdateAnonymitySpinButton"); | ||
934 | cls.anonymityLevel | ||
935 | = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin)); | ||
936 | nameLine = glade_xml_get_widget(metaXML, | ||
937 | "nextIdentifierComboBoxEntry"); | ||
938 | identifierName = gtk_entry_get_text(GTK_ENTRY(nameLine)); | ||
939 | if ( (identifierName == NULL) || | ||
940 | (strlen(identifierName) == 0)) { | ||
941 | cls.nextId = NULL; | ||
942 | } else { | ||
943 | hash(identifierName, | ||
944 | strlen(identifierName), | ||
945 | &nextId); | ||
946 | cls.nextId = &nextId; | ||
947 | } | ||
948 | cls.meta = meta; | ||
949 | /* | ||
950 | FIXME: | ||
951 | gtk_tree_selection_selected_foreach | ||
952 | (selection, | ||
953 | &initiateUpload, | ||
954 | &cls); | ||
955 | */ | ||
956 | ECRS_freeMetaData(meta); | ||
957 | } | ||
958 | gtk_widget_destroy(dialog); | ||
959 | UNREF(metaXML); | ||
960 | metaXML = NULL; | ||
825 | } | 961 | } |
826 | 962 | ||
827 | void on_clearAvailableContentButton_clicked(GtkWidget * dummy1, | 963 | void on_clearAvailableContentButton_clicked(GtkWidget * dummy1, |