aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-fs-gtk-main_window_file_publish.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/gnunet-fs-gtk-main_window_file_publish.c')
-rw-r--r--src/fs/gnunet-fs-gtk-main_window_file_publish.c69
1 files changed, 47 insertions, 22 deletions
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 6aa622c5..948078a1 100644
--- a/src/fs/gnunet-fs-gtk-main_window_file_publish.c
+++ b/src/fs/gnunet-fs-gtk-main_window_file_publish.c
@@ -86,6 +86,9 @@ struct AddDirClientContext
86 GtkTextView *progress_dialog_textview; 86 GtkTextView *progress_dialog_textview;
87 GtkTextBuffer *progress_dialog_textbuffer; 87 GtkTextBuffer *progress_dialog_textbuffer;
88 GtkTextMark *progress_dialog_textmark; 88 GtkTextMark *progress_dialog_textmark;
89
90 unsigned int done;
91 unsigned int total;
89}; 92};
90 93
91void 94void
@@ -821,8 +824,11 @@ add_item (struct AddDirClientContext *adcc, GtkTreeStore *ts,
821 GNUNET_CONTAINER_meta_data_delete (item->meta, 824 GNUNET_CONTAINER_meta_data_delete (item->meta,
822 EXTRACTOR_METATYPE_MIMETYPE, NULL, 0); 825 EXTRACTOR_METATYPE_MIMETYPE, NULL, 0);
823 GNUNET_FS_meta_data_make_directory (item->meta); 826 GNUNET_FS_meta_data_make_directory (item->meta);
824 GNUNET_FS_uri_ksk_add_keyword (item->ksk_uri, GNUNET_FS_DIRECTORY_MIME, 827 if (NULL == item->ksk_uri)
825 GNUNET_NO); 828 item->ksk_uri = GNUNET_FS_uri_ksk_create (GNUNET_FS_DIRECTORY_MIME, NULL);
829 else
830 GNUNET_FS_uri_ksk_add_keyword (item->ksk_uri, GNUNET_FS_DIRECTORY_MIME,
831 GNUNET_NO);
826 fi = GNUNET_FS_file_information_create_empty_directory ( 832 fi = GNUNET_FS_file_information_create_empty_directory (
827 GNUNET_FS_GTK_get_fs_handle (), row_reference, item->ksk_uri, 833 GNUNET_FS_GTK_get_fs_handle (), row_reference, item->ksk_uri,
828 item->meta, &adcc->directory_scan_bo, item->filename); 834 item->meta, &adcc->directory_scan_bo, item->filename);
@@ -834,8 +840,6 @@ add_item (struct AddDirClientContext *adcc, GtkTreeStore *ts,
834 item->ksk_uri, item->meta, adcc->directory_scan_do_index, 840 item->ksk_uri, item->meta, adcc->directory_scan_do_index,
835 &adcc->directory_scan_bo); 841 &adcc->directory_scan_bo);
836 } 842 }
837 GNUNET_CONTAINER_meta_data_destroy (item->meta);
838 GNUNET_FS_uri_destroy (item->ksk_uri);
839 if (item->is_directory) 843 if (item->is_directory)
840 file_size_fancy = GNUNET_strdup (MARKER_DIR_FILE_SIZE); 844 file_size_fancy = GNUNET_strdup (MARKER_DIR_FILE_SIZE);
841 else 845 else
@@ -850,8 +854,6 @@ add_item (struct AddDirClientContext *adcc, GtkTreeStore *ts,
850 6, (guint64) adcc->directory_scan_bo.expiration_time.abs_value, 854 6, (guint64) adcc->directory_scan_bo.expiration_time.abs_value,
851 7, (guint) adcc->directory_scan_bo.replication_level, -1); 855 7, (guint) adcc->directory_scan_bo.replication_level, -1);
852 GNUNET_free (file_size_fancy); 856 GNUNET_free (file_size_fancy);
853 GNUNET_free (item->short_filename);
854 GNUNET_free (item->filename);
855} 857}
856 858
857 859
@@ -877,7 +879,7 @@ add_share_items_to_treestore (struct AddDirClientContext *adcc,
877 sibling_iter = &last_added; 879 sibling_iter = &last_added;
878 if (item->is_directory) 880 if (item->is_directory)
879 add_share_items_to_treestore (adcc, 881 add_share_items_to_treestore (adcc,
880 item, 882 item->children_head,
881 sibling_iter); 883 sibling_iter);
882 } 884 }
883} 885}
@@ -929,36 +931,58 @@ directory_scan_cb (void *cls,
929{ 931{
930 struct AddDirClientContext *adcc = cls; 932 struct AddDirClientContext *adcc = cls;
931 char *s; 933 char *s;
934 gdouble fraction;
932 935
933 gtk_progress_bar_pulse (adcc->progress_dialog_bar); 936 gtk_progress_bar_pulse (adcc->progress_dialog_bar);
934 switch (reason) 937 switch (reason)
935 { 938 {
936 case GNUNET_FS_DIRSCANNER_FILE_START: 939 case GNUNET_FS_DIRSCANNER_FILE_START:
937 if (filename != NULL) 940 GNUNET_assert (filename != NULL);
941 if (is_directory)
938 { 942 {
939 if (is_directory) 943 GNUNET_asprintf (&s, _("Scanning directory `%s'.\n"), filename);
940 GNUNET_asprintf (&s, _("Scanning directory `%s'.\n"), filename);
941 else
942 GNUNET_asprintf (&s, _("Scanning file `%s'.\n"), filename);
943 insert_progress_dialog_text (adcc, s); 944 insert_progress_dialog_text (adcc, s);
944 GNUNET_free (s); 945 GNUNET_free (s);
945 } 946 }
947 else
948 adcc->total++;
946 break; 949 break;
947 case GNUNET_FS_DIRSCANNER_FILE_IGNORED: 950 case GNUNET_FS_DIRSCANNER_FILE_IGNORED:
948 if (filename != NULL) 951 GNUNET_assert (filename != NULL);
949 { 952 GNUNET_asprintf (&s,
950 GNUNET_asprintf (&s, 953 _("Failed to scan `%s' (access error). Skipping.\n"),
951 _("Failed to scan `%s', because it does not exist.\n"), 954 filename);
952 filename); 955 insert_progress_dialog_text (adcc, s);
953 insert_progress_dialog_text (adcc, s); 956 GNUNET_free (s);
954 GNUNET_free (s);
955 }
956 break; 957 break;
957 case GNUNET_FS_DIRSCANNER_ALL_COUNTED: 958 case GNUNET_FS_DIRSCANNER_ALL_COUNTED:
958 // FIXME... 959 fraction = (adcc->total == 0) ? 1.0 : (1.0 * adcc->done) / adcc->total;
960 GNUNET_asprintf (&s, "%u/%u (%3f%%)",
961 adcc->done,
962 adcc->total,
963 100.0 * fraction);
964 gtk_progress_bar_set_text (adcc->progress_dialog_bar,
965 s);
966 GNUNET_free (s);
967 gtk_progress_bar_set_fraction (adcc->progress_dialog_bar,
968 fraction);
959 break; 969 break;
960 case GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED: 970 case GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED:
961 // FIXME... 971 GNUNET_asprintf (&s, _("Processed file `%s'.\n"), filename);
972 insert_progress_dialog_text (adcc, s);
973 GNUNET_free (s);
974 adcc->done++;
975 GNUNET_assert (adcc->done <= adcc->total);
976 fraction = (adcc->total == 0) ? 1.0 : (1.0 * adcc->done) / adcc->total;
977 GNUNET_asprintf (&s, "%u/%u (%3f%%)",
978 adcc->done,
979 adcc->total,
980 100.0 * fraction);
981 gtk_progress_bar_set_text (adcc->progress_dialog_bar,
982 s);
983 GNUNET_free (s);
984 gtk_progress_bar_set_fraction (adcc->progress_dialog_bar,
985 fraction);
962 break; 986 break;
963 case GNUNET_FS_DIRSCANNER_INTERNAL_ERROR: 987 case GNUNET_FS_DIRSCANNER_INTERNAL_ERROR:
964 insert_progress_dialog_text (adcc, _("Operation failed (press cancel)\n")); 988 insert_progress_dialog_text (adcc, _("Operation failed (press cancel)\n"));
@@ -1026,6 +1050,7 @@ scan_file_or_directory (struct MainPublishingDialogContext *ctx,
1026 &iter, FALSE); 1050 &iter, FALSE);
1027 1051
1028 gtk_window_set_transient_for (GTK_WINDOW (adcc->progress_dialog), adcc->ctx->master_pubdialog); 1052 gtk_window_set_transient_for (GTK_WINDOW (adcc->progress_dialog), adcc->ctx->master_pubdialog);
1053 gtk_window_set_title (GTK_WINDOW (adcc->progress_dialog), filename);
1029 gtk_window_present (GTK_WINDOW (adcc->progress_dialog)); 1054 gtk_window_present (GTK_WINDOW (adcc->progress_dialog));
1030 1055
1031 update_selectivity (ctx); 1056 update_selectivity (ctx);