diff options
-rw-r--r-- | src/fs/gnunet-fs-gtk-edit_publish_dialog.c | 319 | ||||
-rw-r--r-- | src/fs/gnunet-fs-gtk-edit_publish_dialog.h | 26 | ||||
-rw-r--r-- | src/fs/gnunet-fs-gtk-main_window_adv_pseudonym.c | 40 | ||||
-rw-r--r-- | src/fs/gnunet-fs-gtk-main_window_file_publish.c | 75 |
4 files changed, 252 insertions, 208 deletions
diff --git a/src/fs/gnunet-fs-gtk-edit_publish_dialog.c b/src/fs/gnunet-fs-gtk-edit_publish_dialog.c index 61832925..a689b06d 100644 --- a/src/fs/gnunet-fs-gtk-edit_publish_dialog.c +++ b/src/fs/gnunet-fs-gtk-edit_publish_dialog.c | |||
@@ -73,11 +73,6 @@ struct EditPublicationDialogContext | |||
73 | GtkComboBox *anonymity_combo; | 73 | GtkComboBox *anonymity_combo; |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * Liststore of the 'anonymity_combo' with the anonymity levels. | ||
77 | */ | ||
78 | GtkListStore *anonymity_liststore; | ||
79 | |||
80 | /** | ||
81 | * Liststore of possible publication types. | 76 | * Liststore of possible publication types. |
82 | */ | 77 | */ |
83 | GtkListStore *pubtypes_liststore; | 78 | GtkListStore *pubtypes_liststore; |
@@ -147,11 +142,6 @@ struct EditPublicationDialogContext | |||
147 | void *cb_cls; | 142 | void *cb_cls; |
148 | 143 | ||
149 | /** | 144 | /** |
150 | * Short name of the file being published (or NULL). | ||
151 | */ | ||
152 | char *short_fn; | ||
153 | |||
154 | /** | ||
155 | * Briefly used temporary meta data set. | 145 | * Briefly used temporary meta data set. |
156 | */ | 146 | */ |
157 | struct GNUNET_CONTAINER_MetaData *md; | 147 | struct GNUNET_CONTAINER_MetaData *md; |
@@ -175,9 +165,8 @@ struct EditPublicationDialogContext | |||
175 | 165 | ||
176 | /** | 166 | /** |
177 | * Is it allowed for the user to supply keywords in this dialog? | 167 | * Is it allowed for the user to supply keywords in this dialog? |
178 | * FIXME: why 'gboolean'? | ||
179 | */ | 168 | */ |
180 | gboolean allow_no_keywords; | 169 | int allow_no_keywords; |
181 | 170 | ||
182 | }; | 171 | }; |
183 | 172 | ||
@@ -191,7 +180,6 @@ static void | |||
191 | free_edit_dialog_context (struct EditPublicationDialogContext *ctx) | 180 | free_edit_dialog_context (struct EditPublicationDialogContext *ctx) |
192 | { | 181 | { |
193 | gtk_widget_destroy (GTK_WIDGET (ctx->edit_publication_window)); | 182 | gtk_widget_destroy (GTK_WIDGET (ctx->edit_publication_window)); |
194 | GNUNET_free_non_null (ctx->short_fn); | ||
195 | // FIXME-LEAK: destroy builder! | 183 | // FIXME-LEAK: destroy builder! |
196 | GNUNET_free (ctx); | 184 | GNUNET_free (ctx); |
197 | } | 185 | } |
@@ -652,7 +640,7 @@ GNUNET_GTK_edit_publication_cancel_button_clicked_cb (GtkButton * button, | |||
652 | { | 640 | { |
653 | struct EditPublicationDialogContext *ctx = user_data; | 641 | struct EditPublicationDialogContext *ctx = user_data; |
654 | 642 | ||
655 | ctx->cb (ctx->cb_cls, GNUNET_SYSERR, NULL, NULL, NULL, GTK_RESPONSE_CANCEL); | 643 | ctx->cb (ctx->cb_cls, GTK_RESPONSE_CANCEL, NULL); |
656 | free_edit_dialog_context (ctx); | 644 | free_edit_dialog_context (ctx); |
657 | } | 645 | } |
658 | 646 | ||
@@ -672,17 +660,25 @@ GNUNET_GTK_edit_publication_window_delete_event_cb (GtkWidget * widget, | |||
672 | { | 660 | { |
673 | struct EditPublicationDialogContext *ctx = user_data; | 661 | struct EditPublicationDialogContext *ctx = user_data; |
674 | 662 | ||
675 | ctx->cb (ctx->cb_cls, GNUNET_SYSERR, NULL, NULL, NULL, GTK_RESPONSE_CANCEL); | 663 | ctx->cb (ctx->cb_cls, GTK_RESPONSE_CANCEL, NULL); |
676 | free_edit_dialog_context (ctx); | 664 | free_edit_dialog_context (ctx); |
677 | return TRUE; | 665 | return TRUE; |
678 | } | 666 | } |
679 | 667 | ||
680 | 668 | ||
681 | /** | 669 | /** |
682 | * Copy binary meta data from to the new container and also | 670 | * Copy binary meta data from to the new container and also preserve |
683 | * preserve all entries that were not changed. | 671 | * all entries that were not changed. In particular, all binary meta |
672 | * data is removed if the preview was changed, otherwise it is all | ||
673 | * kept. Similarly, if values are still in the liststore, they are | ||
674 | * fully kept (including plugin name and original format). "Keeping" | ||
675 | * a value means that it is added to the 'md' meta data in the dialog | ||
676 | * context. | ||
684 | * | 677 | * |
685 | * @param cls closure, a 'struct FileInformationUpdateContext' | 678 | * @param cls closure, a 'struct FileInformationUpdateContext'; |
679 | * contains the 'new' meta data to construct in the 'md' | ||
680 | * field and the liststore to check the current value | ||
681 | * against in 'meta_liststore'. | ||
686 | * @param plugin_name name of the plugin that produced this value; | 682 | * @param plugin_name name of the plugin that produced this value; |
687 | * special values can be used (i.e. '<zlib>' for zlib being | 683 | * special values can be used (i.e. '<zlib>' for zlib being |
688 | * used in the main libextractor library and yielding | 684 | * used in the main libextractor library and yielding |
@@ -752,7 +748,8 @@ preserve_meta_items (void *cls, const char *plugin_name, | |||
752 | 748 | ||
753 | 749 | ||
754 | /** | 750 | /** |
755 | * Function called to update the information in FI. | 751 | * Function called to update the information in FI based on the changes made in |
752 | * the edit dialog. | ||
756 | * | 753 | * |
757 | * @param cls closure with a 'struct FileInformationUpdateContext *' | 754 | * @param cls closure with a 'struct FileInformationUpdateContext *' |
758 | * @param fi the entry in the publish-structure | 755 | * @param fi the entry in the publish-structure |
@@ -774,55 +771,58 @@ file_information_update (void *cls, struct GNUNET_FS_FileInformation *fi, | |||
774 | { | 771 | { |
775 | struct EditPublicationDialogContext *ctx = cls; | 772 | struct EditPublicationDialogContext *ctx = cls; |
776 | GtkTreeIter iter; | 773 | GtkTreeIter iter; |
777 | struct GNUNET_FS_Uri *nxt; | 774 | gint year; |
778 | struct GNUNET_FS_Uri *mrg; | ||
779 | gchar *value; | ||
780 | guint ntype; | ||
781 | guint nformat; | ||
782 | gchar *fn; | ||
783 | char *data; | ||
784 | gsize data_size; | ||
785 | const char *mime; | ||
786 | GFile *f; | ||
787 | GFileInfo *finfo; | ||
788 | char *sfn; | ||
789 | 775 | ||
776 | /* gather publishing options */ | ||
790 | *do_index = gtk_toggle_button_get_active (ctx->index_checkbutton); | 777 | *do_index = gtk_toggle_button_get_active (ctx->index_checkbutton); |
778 | GNUNET_break (GNUNET_GTK_get_selected_anonymity_combo_level (ctx->anonymity_combo, | ||
779 | &bo->anonymity_level)); | ||
780 | bo->content_priority = gtk_spin_button_get_value (ctx->priority_spin); | ||
781 | bo->replication_level = gtk_spin_button_get_value (ctx->replication_spin); | ||
782 | year = gtk_spin_button_get_value (ctx->expiration_year_spin); | ||
783 | bo->expiration_time = GNUNET_FS_year_to_time (year); | ||
791 | 784 | ||
792 | /* update URI */ | 785 | /* update keyword-URI */ |
793 | if (NULL != (*uri)) | 786 | if (NULL != (*uri)) |
794 | GNUNET_FS_uri_destroy (*uri); | 787 | GNUNET_FS_uri_destroy (*uri); |
795 | *uri = NULL; | 788 | *uri = NULL; |
796 | nxt = NULL; | 789 | if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ctx->keywords_liststore), &iter)) |
797 | mrg = NULL; | ||
798 | |||
799 | if (TRUE == gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ctx->keywords_liststore), &iter)) | ||
800 | { | 790 | { |
801 | do | 791 | do |
802 | { | 792 | { |
793 | gchar *value; | ||
794 | |||
803 | gtk_tree_model_get (GTK_TREE_MODEL (ctx->keywords_liststore), &iter, 0, &value, -1); | 795 | gtk_tree_model_get (GTK_TREE_MODEL (ctx->keywords_liststore), &iter, 0, &value, -1); |
804 | nxt = GNUNET_FS_uri_ksk_create_from_args (1, (const char **) &value); | 796 | if (NULL == *uri) |
805 | mrg = GNUNET_FS_uri_ksk_merge (nxt, *uri); | 797 | *uri = GNUNET_FS_uri_ksk_create_from_args (1, (const char **) &value); |
806 | GNUNET_FS_uri_destroy (nxt); | 798 | else |
807 | if (NULL != *uri) | 799 | GNUNET_FS_uri_ksk_add_keyword (*uri, value, GNUNET_NO); |
808 | GNUNET_FS_uri_destroy (*uri); | ||
809 | *uri = mrg; | ||
810 | g_free (value); | 800 | g_free (value); |
811 | } | 801 | } |
812 | while (TRUE == gtk_tree_model_iter_next (GTK_TREE_MODEL (ctx->keywords_liststore), &iter)); | 802 | while (gtk_tree_model_iter_next (GTK_TREE_MODEL (ctx->keywords_liststore), &iter)); |
813 | } | 803 | } |
814 | 804 | ||
815 | /* update meta */ | 805 | /* update meta data; first, we copy the unchanged values from the original meta data */ |
816 | ctx->md = GNUNET_CONTAINER_meta_data_create (); | 806 | ctx->md = GNUNET_CONTAINER_meta_data_create (); |
817 | GNUNET_CONTAINER_meta_data_iterate (meta, | 807 | GNUNET_CONTAINER_meta_data_iterate (meta, |
818 | &preserve_meta_items, | 808 | &preserve_meta_items, |
819 | ctx); | 809 | ctx); |
820 | 810 | /* clear original meta data */ | |
821 | GNUNET_CONTAINER_meta_data_clear (meta); | 811 | GNUNET_CONTAINER_meta_data_clear (meta); |
822 | if (TRUE == gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ctx->meta_liststore), &iter)) | 812 | /* add all of the 'preserved' values */ |
813 | GNUNET_CONTAINER_meta_data_merge (meta, ctx->md); | ||
814 | GNUNET_CONTAINER_meta_data_destroy (ctx->md); | ||
815 | ctx->md = NULL; | ||
816 | /* now add all of the values from the model; adding will simply do | ||
817 | nothing for values that are already in the set because they were preserved */ | ||
818 | if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ctx->meta_liststore), &iter)) | ||
823 | { | 819 | { |
824 | do | 820 | do |
825 | { | 821 | { |
822 | guint ntype; | ||
823 | guint nformat; | ||
824 | gchar *value; | ||
825 | |||
826 | gtk_tree_model_get (GTK_TREE_MODEL (ctx->meta_liststore), &iter, 0, &ntype, 1, &nformat, 3, &value, -1); | 826 | gtk_tree_model_get (GTK_TREE_MODEL (ctx->meta_liststore), &iter, 0, &ntype, 1, &nformat, 3, &value, -1); |
827 | if (ntype > 0) | 827 | if (ntype > 0) |
828 | GNUNET_CONTAINER_meta_data_insert (ctx->md, "<user>", ntype, nformat, | 828 | GNUNET_CONTAINER_meta_data_insert (ctx->md, "<user>", ntype, nformat, |
@@ -830,11 +830,19 @@ file_information_update (void *cls, struct GNUNET_FS_FileInformation *fi, | |||
830 | strlen (value) + 1); | 830 | strlen (value) + 1); |
831 | g_free (value); | 831 | g_free (value); |
832 | } | 832 | } |
833 | while (TRUE == gtk_tree_model_iter_next (GTK_TREE_MODEL (ctx->meta_liststore), &iter)); | 833 | while (gtk_tree_model_iter_next (GTK_TREE_MODEL (ctx->meta_liststore), &iter)); |
834 | } | 834 | } |
835 | GNUNET_CONTAINER_meta_data_merge (meta, ctx->md); | 835 | |
836 | /* finally, if we got a new preview, add it as well */ | ||
836 | if (ctx->preview_changed == GNUNET_YES) | 837 | if (ctx->preview_changed == GNUNET_YES) |
837 | { | 838 | { |
839 | gchar *fn; | ||
840 | char *data; | ||
841 | gsize data_size; | ||
842 | const char *mime; | ||
843 | GFile *f; | ||
844 | GFileInfo *finfo; | ||
845 | |||
838 | fn = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER | 846 | fn = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER |
839 | (gtk_builder_get_object | 847 | (gtk_builder_get_object |
840 | (ctx->builder, | 848 | (ctx->builder, |
@@ -843,7 +851,7 @@ file_information_update (void *cls, struct GNUNET_FS_FileInformation *fi, | |||
843 | finfo = | 851 | finfo = |
844 | g_file_query_info (f, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, 0, NULL, | 852 | g_file_query_info (f, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, 0, NULL, |
845 | NULL); | 853 | NULL); |
846 | if (FALSE == g_file_load_contents (f, NULL, &data, &data_size, NULL, NULL)) | 854 | if (! g_file_load_contents (f, NULL, &data, &data_size, NULL, NULL)) |
847 | { | 855 | { |
848 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 856 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
849 | _("Could not load preview `%s' into memory\n"), fn); | 857 | _("Could not load preview `%s' into memory\n"), fn); |
@@ -862,18 +870,6 @@ file_information_update (void *cls, struct GNUNET_FS_FileInformation *fi, | |||
862 | g_object_unref (f); | 870 | g_object_unref (f); |
863 | g_free (fn); | 871 | g_free (fn); |
864 | } | 872 | } |
865 | GNUNET_CONTAINER_meta_data_destroy (ctx->md); | ||
866 | ctx->md = NULL; | ||
867 | |||
868 | /* update short_fn */ | ||
869 | sfn = GNUNET_CONTAINER_meta_data_get_first_by_types (meta, | ||
870 | EXTRACTOR_METATYPE_FILENAME, | ||
871 | -1); | ||
872 | if (NULL != sfn) | ||
873 | { | ||
874 | GNUNET_free_non_null (ctx->short_fn); | ||
875 | ctx->short_fn = sfn; | ||
876 | } | ||
877 | return GNUNET_SYSERR; /* only visit top-level item */ | 873 | return GNUNET_SYSERR; /* only visit top-level item */ |
878 | } | 874 | } |
879 | 875 | ||
@@ -891,31 +887,25 @@ GNUNET_GTK_edit_publication_confirm_button_clicked_cb (GtkButton * button, | |||
891 | gpointer user_data) | 887 | gpointer user_data) |
892 | { | 888 | { |
893 | struct EditPublicationDialogContext *ctx = user_data; | 889 | struct EditPublicationDialogContext *ctx = user_data; |
894 | struct GNUNET_FS_BlockOptions bo; | ||
895 | gint year; | ||
896 | 890 | ||
891 | /* push back changes to file-information */ | ||
897 | GNUNET_FS_file_information_inspect (ctx->fip, | 892 | GNUNET_FS_file_information_inspect (ctx->fip, |
898 | &file_information_update, | 893 | &file_information_update, |
899 | ctx); | 894 | ctx); |
900 | GNUNET_break (GNUNET_GTK_get_selected_anonymity_combo_level (ctx->anonymity_combo, | 895 | /* call our continuation */ |
901 | &bo.anonymity_level)); | ||
902 | bo.content_priority = gtk_spin_button_get_value (ctx->priority_spin); | ||
903 | bo.replication_level = gtk_spin_button_get_value (ctx->replication_spin); | ||
904 | year = gtk_spin_button_get_value (ctx->expiration_year_spin); | ||
905 | bo.expiration_time = GNUNET_FS_year_to_time (year); | ||
906 | ctx->cb (ctx->cb_cls, | 896 | ctx->cb (ctx->cb_cls, |
907 | gtk_toggle_button_get_active (ctx->index_checkbutton), | 897 | GTK_RESPONSE_OK, |
908 | ctx->short_fn, | 898 | gtk_entry_get_text (ctx->root_entry)); |
909 | &bo, | 899 | /* free resources from the edit dialog */ |
910 | gtk_entry_get_text (ctx->root_entry), | ||
911 | GTK_RESPONSE_OK); | ||
912 | free_edit_dialog_context (ctx); | 900 | free_edit_dialog_context (ctx); |
913 | } | 901 | } |
914 | 902 | ||
915 | 903 | ||
904 | |||
916 | /* ****************** code for initialization of the dialog ******************** */ | 905 | /* ****************** code for initialization of the dialog ******************** */ |
917 | 906 | ||
918 | 907 | ||
908 | |||
919 | /** | 909 | /** |
920 | * Add each of the keywords to the keyword list store. | 910 | * Add each of the keywords to the keyword list store. |
921 | * | 911 | * |
@@ -931,18 +921,20 @@ add_keyword (void *cls, const char *keyword, int is_mandatory) | |||
931 | GtkTreeIter iter; | 921 | GtkTreeIter iter; |
932 | 922 | ||
933 | ls = GTK_LIST_STORE (cls); | 923 | ls = GTK_LIST_STORE (cls); |
934 | gtk_list_store_insert_with_values (ls, &iter, G_MAXINT, 0, keyword, 1, FALSE, | 924 | gtk_list_store_insert_with_values (ls, &iter, G_MAXINT, |
925 | 0, keyword, | ||
926 | 1, FALSE, | ||
935 | -1); | 927 | -1); |
936 | return GNUNET_OK; | 928 | return GNUNET_OK; |
937 | } | 929 | } |
938 | 930 | ||
939 | 931 | ||
940 | /** | 932 | /** |
941 | * Function called to extract the information from FI. | 933 | * Function called to extract the information from FI to populate the edit dialog. |
942 | * | 934 | * |
943 | * @param cls closure | 935 | * @param cls the 'struct EditPublicationDialogContext' |
944 | * @param fi the entry in the publish-structure | 936 | * @param fi the entry in the publish-structure (unused) |
945 | * @param length length of the file or directory | 937 | * @param length length of the file or directory (unused) |
946 | * @param meta metadata for the file or directory (can be modified) | 938 | * @param meta metadata for the file or directory (can be modified) |
947 | * @param uri pointer to the keywords that will be used for this entry (can be modified) | 939 | * @param uri pointer to the keywords that will be used for this entry (can be modified) |
948 | * @param bo block options | 940 | * @param bo block options |
@@ -951,19 +943,34 @@ add_keyword (void *cls, const char *keyword, int is_mandatory) | |||
951 | * @return GNUNET_SYSERR (aborts after first call) | 943 | * @return GNUNET_SYSERR (aborts after first call) |
952 | */ | 944 | */ |
953 | static int | 945 | static int |
954 | file_information_extract (void *cls, struct GNUNET_FS_FileInformation *fi, | 946 | file_information_import (void *cls, |
955 | uint64_t length, | 947 | struct GNUNET_FS_FileInformation *fi, |
956 | struct GNUNET_CONTAINER_MetaData *meta, | 948 | uint64_t length, |
957 | struct GNUNET_FS_Uri **uri, | 949 | struct GNUNET_CONTAINER_MetaData *meta, |
958 | struct GNUNET_FS_BlockOptions *bo, int *do_index, | 950 | struct GNUNET_FS_Uri **uri, |
959 | void **client_info) | 951 | struct GNUNET_FS_BlockOptions *bo, int *do_index, |
952 | void **client_info) | ||
960 | { | 953 | { |
961 | struct EditPublicationDialogContext *ctx = cls; | 954 | struct EditPublicationDialogContext *ctx = cls; |
962 | GdkPixbuf *pixbuf; | 955 | GdkPixbuf *pixbuf; |
956 | char *short_fn; | ||
963 | int year; | 957 | int year; |
964 | 958 | ||
959 | /* import options */ | ||
960 | year = (int) GNUNET_FS_time_to_year (bo->expiration_time); | ||
961 | gtk_spin_button_set_value (ctx->expiration_year_spin, year); | ||
962 | GNUNET_GTK_select_anonymity_combo_level (ctx->anonymity_combo, | ||
963 | bo->anonymity_level); | ||
964 | gtk_spin_button_set_value (ctx->priority_spin, bo->content_priority); | ||
965 | gtk_spin_button_set_value (ctx->replication_spin, bo->replication_level); | ||
966 | gtk_toggle_button_set_active (ctx->index_checkbutton, *do_index); | ||
967 | |||
968 | |||
969 | /* import keywords */ | ||
965 | if (NULL != *uri) | 970 | if (NULL != *uri) |
966 | GNUNET_FS_uri_ksk_get_keywords (*uri, &add_keyword, ctx->keywords_liststore); | 971 | GNUNET_FS_uri_ksk_get_keywords (*uri, &add_keyword, ctx->keywords_liststore); |
972 | |||
973 | /* import meta data */ | ||
967 | if (NULL != meta) | 974 | if (NULL != meta) |
968 | { | 975 | { |
969 | GNUNET_CONTAINER_meta_data_iterate (meta, | 976 | GNUNET_CONTAINER_meta_data_iterate (meta, |
@@ -975,43 +982,41 @@ file_information_extract (void *cls, struct GNUNET_FS_FileInformation *fi, | |||
975 | gtk_image_set_from_pixbuf (ctx->preview_image, pixbuf); | 982 | gtk_image_set_from_pixbuf (ctx->preview_image, pixbuf); |
976 | } | 983 | } |
977 | } | 984 | } |
978 | year = (int) GNUNET_FS_time_to_year (bo->expiration_time); | 985 | |
979 | gtk_spin_button_set_value (ctx->expiration_year_spin, year); | 986 | /* Also update window title based on filename */ |
980 | GNUNET_GTK_select_anonymity_combo_level (ctx->anonymity_combo, | 987 | short_fn = GNUNET_CONTAINER_meta_data_get_first_by_types (meta, |
981 | bo->anonymity_level); | 988 | EXTRACTOR_METATYPE_FILENAME, |
982 | gtk_spin_button_set_value (ctx->priority_spin, bo->content_priority); | 989 | -1); |
983 | gtk_spin_button_set_value (ctx->replication_spin, bo->replication_level); | 990 | if (NULL == short_fn) |
984 | gtk_toggle_button_set_active (ctx->index_checkbutton, *do_index); | 991 | { |
992 | gtk_window_set_title (ctx->edit_publication_window, _("<unnamed>")); | ||
993 | } | ||
994 | else | ||
995 | { | ||
996 | /* FIXME: ensure that short_fn is UTF-8 encoded */ | ||
997 | gtk_window_set_title (ctx->edit_publication_window, short_fn); | ||
998 | GNUNET_free (short_fn); | ||
999 | } | ||
985 | return GNUNET_SYSERR; /* only visit top-level item */ | 1000 | return GNUNET_SYSERR; /* only visit top-level item */ |
986 | } | 1001 | } |
987 | 1002 | ||
988 | 1003 | ||
989 | void | ||
990 | GNUNET_GTK_edit_publication_window_realize_cb (GtkWidget *widget, struct EditPublicationDialogContext *ctx) | ||
991 | { | ||
992 | GtkTreeSelection *meta_selection; | ||
993 | GtkTreeSelection *keywords_selection; | ||
994 | |||
995 | /* FIXME: these can be set by (modern) versions of Glade */ | ||
996 | keywords_selection = gtk_tree_view_get_selection (ctx->keywords_treeview); | ||
997 | meta_selection = gtk_tree_view_get_selection (ctx->meta_treeview); | ||
998 | |||
999 | g_signal_connect (G_OBJECT (keywords_selection), "changed", | ||
1000 | G_CALLBACK (keywords_selection_changed_cb), ctx); | ||
1001 | |||
1002 | g_signal_connect (G_OBJECT (meta_selection), "changed", | ||
1003 | G_CALLBACK (metadata_selection_changed_cb), ctx); | ||
1004 | } | ||
1005 | |||
1006 | /** | 1004 | /** |
1007 | * Open the dialog to edit file information data. | 1005 | * Open the dialog to edit file information data. |
1008 | * short_fn MUST be UTF-8-encoded | 1006 | * |
1007 | * @param parent parent window of the dialog | ||
1008 | * @param fip information about the file information that is to be edited | ||
1009 | * @param allow_no_keywords is it OK to close the dialog without any keywords? | ||
1010 | * also used to indicate that this is a namespace operation | ||
1011 | * (FIXME: overloaded/badly-named argument) | ||
1012 | * @param anon_liststore liststore with anonymity options (FIXME: bad sharing) | ||
1013 | * @param cb function to call when the dialog is closed | ||
1014 | * @param cb_cls closure for 'cb' | ||
1009 | */ | 1015 | */ |
1010 | void | 1016 | void |
1011 | GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, | 1017 | GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, |
1012 | const char *short_fn, | ||
1013 | struct GNUNET_FS_FileInformation *fip, | 1018 | struct GNUNET_FS_FileInformation *fip, |
1014 | gboolean allow_no_keywords, | 1019 | int allow_no_keywords, |
1015 | GtkListStore *anon_liststore, | 1020 | GtkListStore *anon_liststore, |
1016 | GNUNET_FS_GTK_EditPublishDialogCallback cb, | 1021 | GNUNET_FS_GTK_EditPublishDialogCallback cb, |
1017 | gpointer cb_cls) | 1022 | gpointer cb_cls) |
@@ -1022,8 +1027,17 @@ GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, | |||
1022 | GtkLabel *index_label; | 1027 | GtkLabel *index_label; |
1023 | GtkLabel *root_label; | 1028 | GtkLabel *root_label; |
1024 | struct EditPublicationDialogContext *ctx; | 1029 | struct EditPublicationDialogContext *ctx; |
1030 | GtkTreeSelection *meta_selection; | ||
1031 | GtkTreeSelection *keywords_selection; | ||
1025 | 1032 | ||
1026 | ctx = GNUNET_malloc (sizeof (struct EditPublicationDialogContext)); | 1033 | ctx = GNUNET_malloc (sizeof (struct EditPublicationDialogContext)); |
1034 | ctx->fip = fip; | ||
1035 | ctx->preview_changed = GNUNET_NO; | ||
1036 | ctx->allow_no_keywords = allow_no_keywords; | ||
1037 | ctx->is_directory = GNUNET_FS_file_information_is_directory (fip); | ||
1038 | ctx->cb = cb; | ||
1039 | ctx->cb_cls = cb_cls; | ||
1040 | ctx->meta_combo_selected_type_id = -1; | ||
1027 | ctx->builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_edit_publication.glade", ctx); | 1041 | ctx->builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_edit_publication.glade", ctx); |
1028 | 1042 | ||
1029 | if (ctx->builder == NULL) | 1043 | if (ctx->builder == NULL) |
@@ -1031,7 +1045,8 @@ GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, | |||
1031 | GNUNET_free (ctx); | 1045 | GNUNET_free (ctx); |
1032 | return; | 1046 | return; |
1033 | } | 1047 | } |
1034 | ctx->meta_combo_selected_type_id = -1; | 1048 | |
1049 | /* obtain various widgets for use later */ | ||
1035 | ctx->pubtypes_liststore = | 1050 | ctx->pubtypes_liststore = |
1036 | GTK_LIST_STORE (gtk_builder_get_object | 1051 | GTK_LIST_STORE (gtk_builder_get_object |
1037 | (ctx->builder, "GNUNET_GTK_publication_types_liststore")); | 1052 | (ctx->builder, "GNUNET_GTK_publication_types_liststore")); |
@@ -1046,7 +1061,8 @@ GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, | |||
1046 | (ctx->builder, | 1061 | (ctx->builder, |
1047 | "GNUNET_GTK_edit_publication_keyword_list_tree_view")); | 1062 | "GNUNET_GTK_edit_publication_keyword_list_tree_view")); |
1048 | ctx->edit_publication_window = | 1063 | ctx->edit_publication_window = |
1049 | GTK_WINDOW (gtk_builder_get_object (ctx->builder, "GNUNET_GTK_edit_publication_window")); | 1064 | GTK_WINDOW (gtk_builder_get_object (ctx->builder, |
1065 | "GNUNET_GTK_edit_publication_window")); | ||
1050 | ctx->keywords_liststore = GTK_LIST_STORE (gtk_builder_get_object | 1066 | ctx->keywords_liststore = GTK_LIST_STORE (gtk_builder_get_object |
1051 | (ctx->builder, "GNUNET_GTK_publication_keywords_liststore")); | 1067 | (ctx->builder, "GNUNET_GTK_publication_keywords_liststore")); |
1052 | ctx->keyword_entry = | 1068 | ctx->keyword_entry = |
@@ -1061,11 +1077,8 @@ GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, | |||
1061 | ctx->meta_liststore = GTK_LIST_STORE (gtk_builder_get_object | 1077 | ctx->meta_liststore = GTK_LIST_STORE (gtk_builder_get_object |
1062 | (ctx->builder, | 1078 | (ctx->builder, |
1063 | "GNUNET_GTK_publication_metadata_liststore")); | 1079 | "GNUNET_GTK_publication_metadata_liststore")); |
1064 | |||
1065 | ctx->root_entry = GTK_ENTRY (gtk_builder_get_object | 1080 | ctx->root_entry = GTK_ENTRY (gtk_builder_get_object |
1066 | (ctx->builder, "GNUNET_GTK_edit_publication_root_entry")); | 1081 | (ctx->builder, "GNUNET_GTK_edit_publication_root_entry")); |
1067 | |||
1068 | |||
1069 | ctx->expiration_year_spin = GTK_SPIN_BUTTON | 1082 | ctx->expiration_year_spin = GTK_SPIN_BUTTON |
1070 | (gtk_builder_get_object | 1083 | (gtk_builder_get_object |
1071 | (ctx->builder, | 1084 | (ctx->builder, |
@@ -1083,32 +1096,17 @@ GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, | |||
1083 | (ctx->builder, | 1096 | (ctx->builder, |
1084 | "GNUNET_GTK_edit_publication_index_checkbutton")); | 1097 | "GNUNET_GTK_edit_publication_index_checkbutton")); |
1085 | ctx->anonymity_combo = GTK_COMBO_BOX (gtk_builder_get_object (ctx->builder, | 1098 | ctx->anonymity_combo = GTK_COMBO_BOX (gtk_builder_get_object (ctx->builder, |
1086 | "GNUNET_GTK_edit_publication_anonymity_combobox")); | 1099 | "GNUNET_GTK_edit_publication_anonymity_combobox")); |
1087 | gtk_combo_box_set_model (ctx->anonymity_combo, GTK_TREE_MODEL (anon_liststore)); | ||
1088 | ctx->anonymity_liststore = anon_liststore; | ||
1089 | 1100 | ||
1101 | /* Basic initialization of widgets models and visibility */ | ||
1102 | gtk_combo_box_set_model (ctx->anonymity_combo, | ||
1103 | GTK_TREE_MODEL (anon_liststore)); | ||
1090 | GNUNET_FS_GTK_setup_expiration_year_adjustment (ctx->builder); | 1104 | GNUNET_FS_GTK_setup_expiration_year_adjustment (ctx->builder); |
1091 | /* indexing does not apply to directories */ | ||
1092 | gtk_widget_set_visible (GTK_WIDGET (ctx->index_checkbutton), | ||
1093 | !GNUNET_FS_file_information_is_directory (fip)); | ||
1094 | index_label = GTK_LABEL (gtk_builder_get_object | ||
1095 | (ctx->builder, "GNUNET_GTK_edit_publication_index_label")); | ||
1096 | gtk_widget_set_visible (GTK_WIDGET (index_label), | ||
1097 | !GNUNET_FS_file_information_is_directory (fip)); | ||
1098 | gtk_widget_set_visible (GTK_WIDGET (ctx->root_entry), | ||
1099 | !allow_no_keywords); | ||
1100 | root_label = GTK_LABEL (gtk_builder_get_object | ||
1101 | (ctx->builder, "GNUNET_GTK_edit_publication_root_label")); | ||
1102 | gtk_widget_set_visible (GTK_WIDGET (root_label), | ||
1103 | !allow_no_keywords); | ||
1104 | 1105 | ||
1106 | /* FIXME-UNCLEAN: are the following three even required anymore? */ | ||
1105 | gtk_list_store_clear (ctx->keywords_liststore); | 1107 | gtk_list_store_clear (ctx->keywords_liststore); |
1106 | gtk_list_store_clear (ctx->meta_liststore); | 1108 | gtk_list_store_clear (ctx->meta_liststore); |
1107 | 1109 | gtk_entry_set_text (ctx->keyword_entry, ""); | |
1108 | if (NULL != short_fn) | ||
1109 | gtk_window_set_title (ctx->edit_publication_window, short_fn); | ||
1110 | else | ||
1111 | gtk_window_set_title (ctx->edit_publication_window, _("<unnamed>")); | ||
1112 | 1110 | ||
1113 | pubtypes_combo = | 1111 | pubtypes_combo = |
1114 | GTK_COMBO_BOX (gtk_builder_get_object | 1112 | GTK_COMBO_BOX (gtk_builder_get_object |
@@ -1121,19 +1119,42 @@ GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, | |||
1121 | else | 1119 | else |
1122 | gtk_combo_box_set_active (pubtypes_combo, 0); | 1120 | gtk_combo_box_set_active (pubtypes_combo, 0); |
1123 | 1121 | ||
1124 | if (NULL != short_fn) | 1122 | /* indexing does not apply to directories */ |
1125 | ctx->short_fn = GNUNET_strdup (short_fn); | 1123 | gtk_widget_set_visible (GTK_WIDGET (ctx->index_checkbutton), |
1126 | ctx->fip = fip; | 1124 | ! ctx->is_directory); |
1127 | ctx->preview_changed = GNUNET_NO; | 1125 | index_label = GTK_LABEL (gtk_builder_get_object |
1128 | ctx->allow_no_keywords = allow_no_keywords; | 1126 | (ctx->builder, |
1129 | ctx->is_directory = GNUNET_FS_file_information_is_directory (fip); | 1127 | "GNUNET_GTK_edit_publication_index_label")); |
1130 | ctx->cb = cb; | 1128 | gtk_widget_set_visible (GTK_WIDGET (index_label), |
1131 | ctx->cb_cls = cb_cls; | 1129 | ! ctx->is_directory); |
1132 | |||
1133 | GNUNET_FS_file_information_inspect (fip, &file_information_extract, ctx); | ||
1134 | 1130 | ||
1135 | gtk_entry_set_text (ctx->keyword_entry, ""); | 1131 | /* show root label only if we must have keywords, which is also only the |
1132 | case for namespaces (FIXME-UNCLEAN: overloaded use of the argument) */ | ||
1133 | gtk_widget_set_visible (GTK_WIDGET (ctx->root_entry), | ||
1134 | !allow_no_keywords); | ||
1135 | root_label = GTK_LABEL (gtk_builder_get_object | ||
1136 | (ctx->builder, "GNUNET_GTK_edit_publication_root_label")); | ||
1137 | gtk_widget_set_visible (GTK_WIDGET (root_label), | ||
1138 | !allow_no_keywords); | ||
1139 | |||
1140 | /* FIXME-UNCLEAN: what if we already have keywords? Again, does not really | ||
1141 | apply to namespace-case, but this seems a bit ugly */ | ||
1136 | gtk_widget_set_sensitive (ctx->confirm_button, allow_no_keywords ? TRUE : FALSE); | 1142 | gtk_widget_set_sensitive (ctx->confirm_button, allow_no_keywords ? TRUE : FALSE); |
1143 | |||
1144 | |||
1145 | /* FIXME: these signal handlers can be set by (modern) versions of Glade */ | ||
1146 | keywords_selection = gtk_tree_view_get_selection (ctx->keywords_treeview); | ||
1147 | g_signal_connect (G_OBJECT (keywords_selection), "changed", | ||
1148 | G_CALLBACK (keywords_selection_changed_cb), ctx); | ||
1149 | meta_selection = gtk_tree_view_get_selection (ctx->meta_treeview); | ||
1150 | g_signal_connect (G_OBJECT (meta_selection), "changed", | ||
1151 | G_CALLBACK (metadata_selection_changed_cb), ctx); | ||
1152 | |||
1153 | /* import meta data and options */ | ||
1154 | GNUNET_FS_file_information_inspect (fip, &file_information_import, ctx); | ||
1155 | |||
1156 | |||
1157 | /* Finally, display window */ | ||
1137 | gtk_window_set_transient_for (ctx->edit_publication_window, parent); | 1158 | gtk_window_set_transient_for (ctx->edit_publication_window, parent); |
1138 | gtk_window_present (ctx->edit_publication_window); | 1159 | gtk_window_present (ctx->edit_publication_window); |
1139 | } | 1160 | } |
diff --git a/src/fs/gnunet-fs-gtk-edit_publish_dialog.h b/src/fs/gnunet-fs-gtk-edit_publish_dialog.h index 68514031..63111bbf 100644 --- a/src/fs/gnunet-fs-gtk-edit_publish_dialog.h +++ b/src/fs/gnunet-fs-gtk-edit_publish_dialog.h | |||
@@ -34,29 +34,31 @@ | |||
34 | * Function called when the edit publish dialog has been closed. | 34 | * Function called when the edit publish dialog has been closed. |
35 | * | 35 | * |
36 | * @param cls closure | 36 | * @param cls closure |
37 | * @param do_index index flag set? | ||
38 | * @param short_fn short filename | ||
39 | * @param anonymity_level anonymity degree chosen for publishing | ||
40 | * @param priority replication setting (rename!) | ||
41 | * @param root namespace root, NULL for file publishing | ||
42 | * @param ret GTK_RESPONSE_OK if the dialog was closed with "OK" | 37 | * @param ret GTK_RESPONSE_OK if the dialog was closed with "OK" |
38 | * @param root namespace root, NULL for file publishing | ||
43 | */ | 39 | */ |
44 | typedef void (*GNUNET_FS_GTK_EditPublishDialogCallback) (gpointer cls, | 40 | typedef void (*GNUNET_FS_GTK_EditPublishDialogCallback) (gpointer cls, |
45 | int do_index, | 41 | int ret, |
46 | const char *short_fn, | 42 | const char *root); |
47 | const struct GNUNET_FS_BlockOptions *bo, | ||
48 | const char *root, | ||
49 | int ret); | ||
50 | 43 | ||
51 | 44 | ||
52 | /** | 45 | /** |
53 | * Open the dialog to edit file information data. | 46 | * Open the dialog to edit file information data. |
47 | * | ||
48 | * @param parent parent window of the dialog | ||
49 | * @param fip information about the file information that is to be edited | ||
50 | * @param allow_no_keywords is it OK to close the dialog without any keywords? | ||
51 | * also used to indicate that this is a namespace operation | ||
52 | * (FIXME: overloaded/badly-named argument) | ||
53 | * @param anon_liststore liststore with anonymity options (FIXME: bad sharing) | ||
54 | * @param cb function to call when the dialog is closed | ||
55 | * @param cb_cls closure for 'cb' | ||
54 | */ | 56 | */ |
55 | void | 57 | void |
56 | GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, | 58 | GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, |
57 | const char *short_fn, | ||
58 | struct GNUNET_FS_FileInformation *fip, | 59 | struct GNUNET_FS_FileInformation *fip, |
59 | gboolean allow_no_keywords, GtkListStore *anon_liststore, | 60 | int allow_no_keywords, |
61 | GtkListStore *anon_liststore, | ||
60 | GNUNET_FS_GTK_EditPublishDialogCallback cb, | 62 | GNUNET_FS_GTK_EditPublishDialogCallback cb, |
61 | gpointer cls); | 63 | gpointer cls); |
62 | 64 | ||
diff --git a/src/fs/gnunet-fs-gtk-main_window_adv_pseudonym.c b/src/fs/gnunet-fs-gtk-main_window_adv_pseudonym.c index d6008f77..0c6849a9 100644 --- a/src/fs/gnunet-fs-gtk-main_window_adv_pseudonym.c +++ b/src/fs/gnunet-fs-gtk-main_window_adv_pseudonym.c | |||
@@ -26,6 +26,8 @@ | |||
26 | #include "gnunet-fs-gtk.h" | 26 | #include "gnunet-fs-gtk.h" |
27 | #include "gnunet-fs-gtk-edit_publish_dialog.h" | 27 | #include "gnunet-fs-gtk-edit_publish_dialog.h" |
28 | 28 | ||
29 | |||
30 | |||
29 | gboolean | 31 | gboolean |
30 | GNUNET_GTK_select_pseudonym_dialog_delete_event_cb (GtkWidget * widget, | 32 | GNUNET_GTK_select_pseudonym_dialog_delete_event_cb (GtkWidget * widget, |
31 | GdkEvent * event, | 33 | GdkEvent * event, |
@@ -35,6 +37,7 @@ GNUNET_GTK_select_pseudonym_dialog_delete_event_cb (GtkWidget * widget, | |||
35 | return TRUE; | 37 | return TRUE; |
36 | } | 38 | } |
37 | 39 | ||
40 | |||
38 | /** | 41 | /** |
39 | * Callback with information about local (!) namespaces. | 42 | * Callback with information about local (!) namespaces. |
40 | * Contains the names of the local namespace and the global | 43 | * Contains the names of the local namespace and the global |
@@ -74,12 +77,10 @@ selection_changed_cb (GtkTreeSelection * ts, gpointer user_data) | |||
74 | gtk_widget_set_sensitive (ok_button, FALSE); | 77 | gtk_widget_set_sensitive (ok_button, FALSE); |
75 | } | 78 | } |
76 | 79 | ||
80 | |||
77 | struct NamespaceAdvertisementContext | 81 | struct NamespaceAdvertisementContext |
78 | { | 82 | { |
79 | struct GNUNET_FS_Namespace *ns; | 83 | struct GNUNET_FS_Namespace *ns; |
80 | int do_index; | ||
81 | const char *short_fn; | ||
82 | struct GNUNET_FS_BlockOptions bo; | ||
83 | const char *root; | 84 | const char *root; |
84 | struct GNUNET_FS_FileInformation *fip; | 85 | struct GNUNET_FS_FileInformation *fip; |
85 | }; | 86 | }; |
@@ -116,26 +117,24 @@ advertise_namespace (void *cls, struct GNUNET_FS_FileInformation *fi, | |||
116 | 117 | ||
117 | 118 | ||
118 | static void | 119 | static void |
119 | adv_pseudonym_edit_publish_dialog_cb (gpointer cls, int do_index, | 120 | adv_pseudonym_edit_publish_dialog_cb (gpointer cls, |
120 | const char *short_fn, | 121 | gint ret, |
121 | const struct GNUNET_FS_BlockOptions *bo, | 122 | const char *root) |
122 | const char *root, gint ret) | ||
123 | { | 123 | { |
124 | struct NamespaceAdvertisementContext *nds = cls; | 124 | struct NamespaceAdvertisementContext *nds = cls; |
125 | 125 | ||
126 | if (ret == GTK_RESPONSE_OK) | 126 | if (ret == GTK_RESPONSE_OK) |
127 | { | 127 | { |
128 | nds->do_index = do_index; | ||
129 | nds->short_fn = short_fn; | ||
130 | nds->bo = *bo; | ||
131 | nds->root = root; | 128 | nds->root = root; |
132 | GNUNET_FS_file_information_inspect (nds->fip, &advertise_namespace, nds); | 129 | GNUNET_FS_file_information_inspect (nds->fip, &advertise_namespace, nds); |
130 | nds->root = NULL; | ||
133 | } | 131 | } |
134 | GNUNET_FS_namespace_delete (nds->ns, GNUNET_NO); | 132 | GNUNET_FS_namespace_delete (nds->ns, GNUNET_NO); |
135 | GNUNET_FS_file_information_destroy (nds->fip, NULL, NULL); | 133 | GNUNET_FS_file_information_destroy (nds->fip, NULL, NULL); |
136 | GNUNET_free (nds); | 134 | GNUNET_free (nds); |
137 | } | 135 | } |
138 | 136 | ||
137 | |||
139 | void | 138 | void |
140 | GNUNET_GTK_select_pseudonym_dialog_response_cb (GtkDialog * dialog, | 139 | GNUNET_GTK_select_pseudonym_dialog_response_cb (GtkDialog * dialog, |
141 | gint response_id, | 140 | gint response_id, |
@@ -153,6 +152,7 @@ GNUNET_GTK_select_pseudonym_dialog_response_cb (GtkDialog * dialog, | |||
153 | GtkListStore *anon_liststore; | 152 | GtkListStore *anon_liststore; |
154 | struct NamespaceAdvertisementContext *nds; | 153 | struct NamespaceAdvertisementContext *nds; |
155 | struct GNUNET_CONTAINER_MetaData *meta; | 154 | struct GNUNET_CONTAINER_MetaData *meta; |
155 | struct GNUNET_FS_BlockOptions bo; | ||
156 | 156 | ||
157 | builder = GTK_BUILDER (user_data); | 157 | builder = GTK_BUILDER (user_data); |
158 | ad = GTK_WIDGET (gtk_builder_get_object | 158 | ad = GTK_WIDGET (gtk_builder_get_object |
@@ -189,28 +189,27 @@ GNUNET_GTK_select_pseudonym_dialog_response_cb (GtkDialog * dialog, | |||
189 | 189 | ||
190 | nds = GNUNET_malloc (sizeof (struct NamespaceAdvertisementContext)); | 190 | nds = GNUNET_malloc (sizeof (struct NamespaceAdvertisementContext)); |
191 | nds->ns = ns; | 191 | nds->ns = ns; |
192 | nds->do_index = FALSE; | ||
193 | nds->short_fn = NULL; | ||
194 | nds->bo.anonymity_level = 1; | ||
195 | nds->bo.content_priority = 1000; | ||
196 | nds->root = NULL; | ||
197 | /* This is a bogus fileinfo. It's needed because edit_publish_dialog | 192 | /* This is a bogus fileinfo. It's needed because edit_publish_dialog |
198 | * was written to work with fileinfo, and return a fileinfo. | 193 | * was written to work with fileinfo, and return a fileinfo. |
199 | */ | 194 | */ |
200 | memset (&nds->bo, 0, sizeof (struct GNUNET_FS_BlockOptions)); | 195 | memset (&bo, 0, sizeof (struct GNUNET_FS_BlockOptions)); |
201 | nds->bo.expiration_time = | 196 | bo.expiration_time = |
202 | GNUNET_FS_year_to_time (GNUNET_FS_get_current_year () + 2); | 197 | GNUNET_FS_year_to_time (GNUNET_FS_get_current_year () + 2); |
203 | nds->bo.anonymity_level = 1; | 198 | bo.anonymity_level = 1; |
199 | bo.content_priority = 1000; | ||
204 | nds->fip = | 200 | nds->fip = |
205 | GNUNET_FS_file_information_create_empty_directory (NULL, NULL, NULL, meta, | 201 | GNUNET_FS_file_information_create_empty_directory (NULL, NULL, NULL, meta, |
206 | &nds->bo, NULL); | 202 | &bo, NULL); |
207 | GNUNET_CONTAINER_meta_data_destroy (meta); | 203 | GNUNET_CONTAINER_meta_data_destroy (meta); |
208 | GNUNET_FS_GTK_edit_publish_dialog (transient, | 204 | GNUNET_FS_GTK_edit_publish_dialog (transient, |
209 | nds->short_fn, nds->fip, FALSE, anon_liststore, | 205 | nds->fip, |
206 | GNUNET_NO, | ||
207 | anon_liststore, | ||
210 | &adv_pseudonym_edit_publish_dialog_cb, | 208 | &adv_pseudonym_edit_publish_dialog_cb, |
211 | nds); | 209 | nds); |
212 | } | 210 | } |
213 | 211 | ||
212 | |||
214 | void | 213 | void |
215 | GNUNET_GTK_select_pseudonym_dialog_realize_cb (GtkWidget * widget, | 214 | GNUNET_GTK_select_pseudonym_dialog_realize_cb (GtkWidget * widget, |
216 | gpointer user_data) | 215 | gpointer user_data) |
@@ -228,6 +227,7 @@ GNUNET_GTK_select_pseudonym_dialog_realize_cb (GtkWidget * widget, | |||
228 | G_CALLBACK (selection_changed_cb), user_data); | 227 | G_CALLBACK (selection_changed_cb), user_data); |
229 | } | 228 | } |
230 | 229 | ||
230 | |||
231 | /** | 231 | /** |
232 | * Advertise pseudonym selected. | 232 | * Advertise pseudonym selected. |
233 | */ | 233 | */ |
diff --git a/src/fs/gnunet-fs-gtk-main_window_file_publish.c b/src/fs/gnunet-fs-gtk-main_window_file_publish.c index 29435940..57a5eb6a 100644 --- a/src/fs/gnunet-fs-gtk-main_window_file_publish.c +++ b/src/fs/gnunet-fs-gtk-main_window_file_publish.c | |||
@@ -1037,44 +1037,66 @@ GNUNET_GTK_master_publish_dialog_add_button_clicked_cb (GtkWidget * dummy, | |||
1037 | 1037 | ||
1038 | struct EditPublishContext | 1038 | struct EditPublishContext |
1039 | { | 1039 | { |
1040 | struct GNUNET_FS_FileInformation *fip; | ||
1041 | |||
1040 | GtkTreeModel *tm; | 1042 | GtkTreeModel *tm; |
1043 | |||
1041 | GtkTreeIter iter; | 1044 | GtkTreeIter iter; |
1042 | }; | 1045 | }; |
1043 | 1046 | ||
1044 | 1047 | ||
1045 | /** | 1048 | /** |
1049 | * Update tree view based on the information from the | ||
1050 | * GNUNET_FS_FileInformation publish-structure. | ||
1051 | * | ||
1052 | * @param cls closure, a 'struct EditPublishContext *' | ||
1053 | * @param fi the entry in the publish-structure | ||
1054 | * @param length length of the file or directory | ||
1055 | * @param meta metadata for the file or directory (can be modified) | ||
1056 | * @param uri pointer to the keywords that will be used for this entry (can be modified) | ||
1057 | * @param bo block options (can be modified) | ||
1058 | * @param do_index should we index (can be modified) | ||
1059 | * @param client_info pointer to client context set upon creation (can be modified) | ||
1060 | * @return GNUNET_OK to continue, GNUNET_NO to remove | ||
1061 | * this entry from the directory, GNUNET_SYSERR | ||
1062 | * to abort the iteration | ||
1063 | */ | ||
1064 | static int | ||
1065 | update_treeview_after_edit (void *cls, struct GNUNET_FS_FileInformation *fi, | ||
1066 | uint64_t length, struct GNUNET_CONTAINER_MetaData *meta, | ||
1067 | struct GNUNET_FS_Uri **uri, | ||
1068 | struct GNUNET_FS_BlockOptions *bo, int *do_index, | ||
1069 | void **client_info) | ||
1070 | { | ||
1071 | struct EditPublishContext *epc = cls; | ||
1072 | |||
1073 | gtk_tree_store_set (GTK_TREE_STORE (epc->tm), &epc->iter, | ||
1074 | 1, *do_index, | ||
1075 | 3, (guint) bo->anonymity_level, | ||
1076 | 4, (guint) bo->content_priority, | ||
1077 | 6, (guint64) bo->expiration_time.abs_value, | ||
1078 | 7, (guint) bo->replication_level, | ||
1079 | -1); | ||
1080 | return GNUNET_SYSERR; | ||
1081 | } | ||
1082 | |||
1083 | |||
1084 | /** | ||
1046 | * Function called when the edit publish dialog has been closed. | 1085 | * Function called when the edit publish dialog has been closed. |
1047 | * | 1086 | * |
1048 | * @param cls closure | 1087 | * @param cls closure |
1049 | * @param do_index index flag set? | ||
1050 | * @param short_fn short filename | ||
1051 | * @param bo block options for publishing | ||
1052 | * @param root always NULL here | ||
1053 | * @param ret GTK_RESPONSE_OK if the dialog was closed with "OK" | 1088 | * @param ret GTK_RESPONSE_OK if the dialog was closed with "OK" |
1089 | * @param root unused (namespace root name) | ||
1054 | */ | 1090 | */ |
1055 | static void | 1091 | static void |
1056 | master_publish_edit_publish_dialog_cb (gpointer cls, int do_index, | 1092 | master_publish_edit_publish_dialog_cb (gpointer cls, |
1057 | const char *short_fn, | 1093 | gint ret, |
1058 | const struct GNUNET_FS_BlockOptions *bo, | 1094 | const char *root) |
1059 | const char *root, | ||
1060 | gint ret) | ||
1061 | { | 1095 | { |
1062 | struct EditPublishContext *cbargs = cls; | 1096 | struct EditPublishContext *cbargs = cls; |
1063 | struct GNUNET_FS_FileInformation *fi; | ||
1064 | 1097 | ||
1065 | if (ret == GTK_RESPONSE_OK) | 1098 | if (ret == GTK_RESPONSE_OK) |
1066 | { | 1099 | GNUNET_FS_file_information_inspect (cbargs->fip, &update_treeview_after_edit, cbargs); |
1067 | gtk_tree_store_set (GTK_TREE_STORE (cbargs->tm), &cbargs->iter, | ||
1068 | 1, do_index, | ||
1069 | 2, short_fn, | ||
1070 | 3, (guint) bo->anonymity_level, | ||
1071 | 4, (guint) bo->content_priority, | ||
1072 | 6, (guint64) bo->expiration_time.abs_value, | ||
1073 | 7, (guint) bo->replication_level, | ||
1074 | -1); | ||
1075 | gtk_tree_model_get (cbargs->tm, &cbargs->iter, 5, &fi, -1); | ||
1076 | GNUNET_FS_file_information_set_filename (fi, short_fn); | ||
1077 | } | ||
1078 | GNUNET_free (cbargs); | 1100 | GNUNET_free (cbargs); |
1079 | } | 1101 | } |
1080 | 1102 | ||
@@ -1084,8 +1106,6 @@ GNUNET_GTK_master_publish_dialog_edit_button_clicked_cb (GtkWidget * dummy, | |||
1084 | struct MainPublishingDialogContext *ctx) | 1106 | struct MainPublishingDialogContext *ctx) |
1085 | { | 1107 | { |
1086 | struct EditPublishContext *cbargs; | 1108 | struct EditPublishContext *cbargs; |
1087 | char *short_fn; | ||
1088 | struct GNUNET_FS_FileInformation *fip; | ||
1089 | GtkListStore *anon_liststore; | 1109 | GtkListStore *anon_liststore; |
1090 | 1110 | ||
1091 | anon_liststore = GTK_LIST_STORE (gtk_builder_get_object (ctx->main_window_builder, | 1111 | anon_liststore = GTK_LIST_STORE (gtk_builder_get_object (ctx->main_window_builder, |
@@ -1099,13 +1119,14 @@ GNUNET_GTK_master_publish_dialog_edit_button_clicked_cb (GtkWidget * dummy, | |||
1099 | return; | 1119 | return; |
1100 | } | 1120 | } |
1101 | gtk_tree_model_get (ctx->file_info_treemodel, &cbargs->iter, | 1121 | gtk_tree_model_get (ctx->file_info_treemodel, &cbargs->iter, |
1102 | 2, &short_fn, | 1122 | 5, &cbargs->fip, |
1103 | 5, &fip, | ||
1104 | -1); | 1123 | -1); |
1105 | /* FIXME: can we just give our anon_liststore out like this? What about | 1124 | /* FIXME: can we just give our anon_liststore out like this? What about |
1106 | (unintended) sharing of state? */ | 1125 | (unintended) sharing of state? */ |
1107 | GNUNET_FS_GTK_edit_publish_dialog (ctx->master_pubdialog, | 1126 | GNUNET_FS_GTK_edit_publish_dialog (ctx->master_pubdialog, |
1108 | short_fn, fip, TRUE, anon_liststore, | 1127 | cbargs->fip, |
1128 | GNUNET_YES, | ||
1129 | anon_liststore, | ||
1109 | &master_publish_edit_publish_dialog_cb, | 1130 | &master_publish_edit_publish_dialog_cb, |
1110 | cbargs); | 1131 | cbargs); |
1111 | } | 1132 | } |