aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/fs/namespace.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/fs/namespace.c')
-rw-r--r--src/plugins/fs/namespace.c168
1 files changed, 162 insertions, 6 deletions
diff --git a/src/plugins/fs/namespace.c b/src/plugins/fs/namespace.c
index 48d41958..c2062f4f 100644
--- a/src/plugins/fs/namespace.c
+++ b/src/plugins/fs/namespace.c
@@ -1,4 +1,4 @@
1/* 1 /*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2005 Christian Grothoff (and other contributing authors) 3 (C) 2005 Christian Grothoff (and other contributing authors)
4 4
@@ -206,6 +206,7 @@ static int updateView(const ECRS_FileInfo * fi,
206 NAMESPACE_SIZE, size, 206 NAMESPACE_SIZE, size,
207 NAMESPACE_URISTRING, uriString, 207 NAMESPACE_URISTRING, uriString,
208 NAMESPACE_URI, ECRS_dupUri(fi->uri), 208 NAMESPACE_URI, ECRS_dupUri(fi->uri),
209 NAMESPACE_META, ECRS_dupMetaData(fi->meta),
209 -1); 210 -1);
210 FREE(filename); 211 FREE(filename);
211 FREE(uriString); 212 FREE(uriString);
@@ -725,24 +726,144 @@ void namespaceDelete_clicked(GtkWidget * dummy1,
725 FREE(list); 726 FREE(list);
726} 727}
727 728
729typedef struct {
730 unsigned int anonymityLevel;
731 char * namespaceName;
732 cron_t updateInterval;
733 HashCode512 * lastId;
734 HashCode512 thisId;
735 HashCode512 * nextId;
736 struct ECRS_MetaData * meta;
737} IUC;
728 738
739/**
740 * Publish the selected file in the
741 * selected namespace.
742 */
743static void initiateUpload(GtkTreeModel * model,
744 GtkTreePath * path,
745 GtkTreeIter * iter,
746 gpointer data) {
747 IUC * cls = data;
748 struct ECRS_URI * resultURI;
749 struct ECRS_URI * dst;
750 struct ECRS_MetaData * ometa;
751 struct ECRS_MetaData * meta;
752 NamespaceList * list;
753 ECRS_FileInfo fi;
754
755 dst = NULL;
756 meta = cls->meta;
757 gtk_tree_model_get(model,
758 iter,
759 NAMESPACE_URI, &dst,
760 NAMESPACE_META, &ometa,
761 -1);
762 /* FIXME: we may want to optionally combine the metadata from the
763 original file ID (ometa) with the new metadata (cls->meta) here;
764 or if we limit us to one file at a time, show the original
765 metadata immediately with the dialog. */
766
767 if (dst == NULL) {
768 BREAK();
769 return;
770 }
771 if (OK == FSUI_addToNamespace(ctx,
772 cls->anonymityLevel,
773 cls->namespaceName,
774 cls->updateInterval,
775 cls->lastId,
776 &cls->thisId,
777 cls->nextId,
778 dst,
779 meta,
780 &resultURI)) {
781 list = head;
782 while ( (list != NULL) &&
783 (0 != strcmp(cls->namespaceName,
784 list->name)) )
785 list = list->next;
786 if (list == NULL) {
787 BREAK();
788 } else {
789 /* update namespace content list! */
790 fi.uri = resultURI;
791 fi.meta = meta;
792 addNamespaceContentToModel(list->model,
793 &fi,
794 &cls->thisId,
795 cls->nextId,
796 cls->updateInterval,
797 cls->updateInterval
798 + cronTime(NULL) );
799 }
800 ECRS_freeUri(resultURI);
801 } else {
802 infoMessage(YES,
803 _("Failed to insert content into namespace "
804 "(consult logs).\n"));
805 }
806}
729 807
730void on_namespaceInsertButton_clicked(GtkWidget * dummy1, 808void on_namespaceInsertButton_clicked(GtkWidget * dummy1,
731 GtkWidget * dummy2) { 809 GtkWidget * dummy2) {
732 const char * identifierName; 810 const char * identifierName;
811 NamespaceList * list;
733 GtkWidget * nameLine; 812 GtkWidget * nameLine;
813 GtkWidget * page;
814 GtkWidget * notebook;
734 GtkWidget * metaList; 815 GtkWidget * metaList;
735 GtkWidget * dialog; 816 GtkWidget * dialog;
736 GtkWidget * spin; 817 GtkWidget * spin;
818 GtkWidget * update;
737 GtkListStore * metamodel; 819 GtkListStore * metamodel;
738 GtkCellRenderer * renderer; 820 GtkCellRenderer * renderer;
739 GtkTreeIter iter; 821 GtkTreeIter iter;
740 struct ECRS_MetaData * meta; 822 struct ECRS_MetaData * meta;
741 EXTRACTOR_KeywordType type; 823 EXTRACTOR_KeywordType type;
742 char * mvalue; 824 char * mvalue;
743 HashCode512 identifier; 825 HashCode512 nextId;
826 GtkWidget * contentList;
827 GtkTreeSelection * selection;
828 IUC cls;
829 gint num;
830
831 contentList
832 = glade_xml_get_widget(getMainXML(),
833 "availableContentList");
834 selection
835 = gtk_tree_view_get_selection(GTK_TREE_VIEW(contentList));
836 if (0 == gtk_tree_selection_count_selected_rows(selection)) {
837 /* IMPROVE-ME: disable the menu item
838 as long as this may happen! */
839 dialog = gtk_message_dialog_new
840 (NULL,
841 GTK_DIALOG_MODAL,
842 GTK_MESSAGE_ERROR,
843 GTK_BUTTONS_CLOSE,
844 _("You must select some available content for publication first!"));
845 gtk_dialog_run(GTK_DIALOG(dialog));
846 gtk_widget_destroy(dialog);
847 return;
848 }
849
850 notebook
851 = glade_xml_get_widget(getMainXML(),
852 "localNamespacesNotebook");
853 num = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
854 GNUNET_ASSERT(num != -1);
855 page =gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),
856 num);
857 list = head;
858 while ( (list != NULL) &&
859 (list->namespacepage != page) )
860 list = list->next;
861 if (list == NULL) {
862 BREAK();
863 return;
864 }
865 cls.namespaceName = list->name;
744 866
745 /* FIXME */
746 metaXML 867 metaXML
747 = glade_xml_new(getGladeFileName(), 868 = glade_xml_new(getGladeFileName(),
748 "namespaceMetaDataDialog", 869 "namespaceMetaDataDialog",
@@ -792,7 +913,9 @@ void on_namespaceInsertButton_clicked(GtkWidget * dummy1,
792 &iter)); 913 &iter));
793 } 914 }
794 spin = glade_xml_get_widget(metaXML, 915 spin = glade_xml_get_widget(metaXML,
795 "namespaceAnonymityspinbutton"); 916 "anonymitySpinButton");
917 cls.anonymityLevel
918 = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin));
796 nameLine = glade_xml_get_widget(metaXML, 919 nameLine = glade_xml_get_widget(metaXML,
797 "namespaceContentIdentifierEntry"); 920 "namespaceContentIdentifierEntry");
798 identifierName = gtk_entry_get_text(GTK_ENTRY(nameLine)); 921 identifierName = gtk_entry_get_text(GTK_ENTRY(nameLine));
@@ -800,9 +923,32 @@ void on_namespaceInsertButton_clicked(GtkWidget * dummy1,
800 identifierName = ""; 923 identifierName = "";
801 hash(identifierName, 924 hash(identifierName,
802 strlen(identifierName), 925 strlen(identifierName),
803 &identifier); 926 &cls.thisId);
927 cls.lastId = NULL;
804 928
929 nameLine = glade_xml_get_widget(metaXML,
930 "nextIdentifierEntry");
931 identifierName = gtk_entry_get_text(GTK_ENTRY(nameLine));
932 if ( (identifierName == NULL) ||
933 (strlen(identifierName) == 0)) {
934 cls.nextId = NULL;
935 } else {
936 hash(identifierName,
937 strlen(identifierName),
938 &nextId);
939 cls.nextId = &nextId;
940 }
941 cls.meta = meta;
942 update = glade_xml_get_widget(metaXML,
943 "updateIntervalComboBoxEntry");
944 cls.updateInterval = 0; /* FIXME */
805 945
946 gtk_tree_selection_selected_foreach
947 (selection,
948 &initiateUpload,
949 &cls);
950
951 ECRS_freeMetaData(meta);
806 } 952 }
807 gtk_widget_destroy(dialog); 953 gtk_widget_destroy(dialog);
808 UNREF(metaXML); 954 UNREF(metaXML);
@@ -811,7 +957,16 @@ void on_namespaceInsertButton_clicked(GtkWidget * dummy1,
811 957
812void on_namespaceUpdateButton_clicked(GtkWidget * dummy1, 958void on_namespaceUpdateButton_clicked(GtkWidget * dummy1,
813 GtkWidget * dummy2) { 959 GtkWidget * dummy2) {
814 /* FIXME */ 960 GtkWidget * dialog;
961
962 dialog = gtk_message_dialog_new
963 (NULL,
964 GTK_DIALOG_MODAL,
965 GTK_MESSAGE_ERROR,
966 GTK_BUTTONS_CLOSE,
967 _("Not implemented!"));
968 gtk_dialog_run(GTK_DIALOG(dialog));
969 gtk_widget_destroy(dialog);
815} 970}
816 971
817 972
@@ -829,6 +984,7 @@ void fs_namespace_start() {
829 G_TYPE_STRING, /* name */ 984 G_TYPE_STRING, /* name */
830 G_TYPE_UINT64, /* size */ 985 G_TYPE_UINT64, /* size */
831 G_TYPE_STRING, /* uri-string */ 986 G_TYPE_STRING, /* uri-string */
987 G_TYPE_POINTER,
832 G_TYPE_POINTER); /* uri */ 988 G_TYPE_POINTER); /* uri */
833 gtk_tree_view_set_model(GTK_TREE_VIEW(contentList), 989 gtk_tree_view_set_model(GTK_TREE_VIEW(contentList),
834 GTK_TREE_MODEL(model)); 990 GTK_TREE_MODEL(model));