aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-01-18 15:42:16 +0000
committerChristian Grothoff <christian@grothoff.org>2012-01-18 15:42:16 +0000
commit99a1454bffe0e113344a70646fe8bac9f242c572 (patch)
tree3dd6443266a2a9e3ccc83beef131e31bded57f5d
parent979b48bd4b7356fb4ce4d9f2d6fd54d4aaa1b934 (diff)
downloadgnunet-gtk-99a1454bffe0e113344a70646fe8bac9f242c572.tar.gz
gnunet-gtk-99a1454bffe0e113344a70646fe8bac9f242c572.zip
-LRN: bugfix: Move-callback-make-it-public-use-it-in-URI-opener
-rw-r--r--src/fs/gnunet-fs-gtk-download.c63
-rw-r--r--src/fs/gnunet-fs-gtk-download.h3
-rw-r--r--src/fs/gnunet-fs-gtk-event_handler.c67
-rw-r--r--src/fs/gnunet-fs-gtk-main_window_file_download.c1
4 files changed, 69 insertions, 65 deletions
diff --git a/src/fs/gnunet-fs-gtk-download.c b/src/fs/gnunet-fs-gtk-download.c
index dc5b2310..8c4f8ee6 100644
--- a/src/fs/gnunet-fs-gtk-download.c
+++ b/src/fs/gnunet-fs-gtk-download.c
@@ -158,4 +158,67 @@ GNUNET_FS_GTK_open_download_as_dialog (struct DownloadContext *dc)
158 gtk_window_present (GTK_WINDOW (ad)); 158 gtk_window_present (GTK_WINDOW (ad));
159} 159}
160 160
161void
162GNUNET_FS_GTK_default_open_download_as_callback (struct DownloadContext *dc)
163{
164 enum GNUNET_FS_DownloadOptions opt;
165 struct GNUNET_FS_Handle *fs;
166 struct DownloadEntry *de;
167 uint64_t len;
168
169 GtkTreeIter iter;
170 GtkTreePath *path;
171
172 fs = GNUNET_FS_GTK_get_fs_handle ();
173 opt = GNUNET_FS_DOWNLOAD_OPTION_NONE;
174 if (dc->is_recursive)
175 opt |= GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE;
176 len = GNUNET_FS_uri_chk_get_file_size (dc->uri);
177
178 de = GNUNET_malloc (sizeof (struct DownloadEntry));
179 de->uri = dc->uri;
180 dc->uri = NULL;
181 de->meta = dc->meta;
182 dc->meta = NULL;
183 if (dc->rr != NULL)
184 {
185 /* We're going to free "dc" very soon */
186 de->rr = gtk_tree_row_reference_copy (dc->rr);
187 de->ts = GTK_TREE_STORE (gtk_tree_row_reference_get_model (dc->rr));
188
189 path = gtk_tree_row_reference_get_path (de->rr);
190 GNUNET_assert (NULL != path);
191 if (gtk_tree_model_get_iter (GTK_TREE_MODEL (de->ts), &iter, path))
192 {
193 /* Store filename and anonymity as specified by the user.
194 * These will be re-used when this is a directory, and the user
195 * downloads its children.
196 */
197 gtk_tree_store_set (de->ts, &iter, 15, dc->filename, 16, dc->anonymity, -1);
198 }
199 gtk_tree_path_free (path);
200
201 }
202 if (dc->sr != NULL)
203 {
204 GNUNET_break (NULL !=
205 GNUNET_FS_download_start_from_search (fs, dc->sr,
206 dc->filename,
207 NULL /* tempname */ ,
208 0 /* offset */ ,
209 len, dc->anonymity, opt,
210 de));
211 }
212 else
213 {
214 GNUNET_break (NULL !=
215 GNUNET_FS_download_start (fs, de->uri, NULL /* meta */ ,
216 dc->filename, NULL /* tempname */ ,
217 0 /* offset */ ,
218 len, dc->anonymity, opt, de,
219 NULL /* parent download ctx */ ));
220 }
221 GNUNET_GTK_save_as_dialog_free_download_context (dc);
222}
223
161/* end of gnunet-fs-gtk-download.c */ 224/* end of gnunet-fs-gtk-download.c */
diff --git a/src/fs/gnunet-fs-gtk-download.h b/src/fs/gnunet-fs-gtk-download.h
index 9d4af3e4..0780afa1 100644
--- a/src/fs/gnunet-fs-gtk-download.h
+++ b/src/fs/gnunet-fs-gtk-download.h
@@ -96,6 +96,9 @@ GNUNET_GTK_save_as_dialog_free_download_context (struct DownloadContext *dc);
96 96
97 97
98void 98void
99GNUNET_FS_GTK_default_open_download_as_callback (struct DownloadContext *dc);
100
101void
99GNUNET_FS_GTK_open_download_as_dialog (struct DownloadContext *dc); 102GNUNET_FS_GTK_open_download_as_dialog (struct DownloadContext *dc);
100 103
101 104
diff --git a/src/fs/gnunet-fs-gtk-event_handler.c b/src/fs/gnunet-fs-gtk-event_handler.c
index 32852aef..607e5813 100644
--- a/src/fs/gnunet-fs-gtk-event_handler.c
+++ b/src/fs/gnunet-fs-gtk-event_handler.c
@@ -909,69 +909,6 @@ get_suggested_filename_anonymity (GtkTreeModel *tm, GtkTreeIter *iter, int top,
909 return NULL; 909 return NULL;
910} 910}
911 911
912static void
913open_download_as_callback (struct DownloadContext *dc)
914{
915 enum GNUNET_FS_DownloadOptions opt;
916 struct GNUNET_FS_Handle *fs;
917 struct DownloadEntry *de;
918 uint64_t len;
919
920 GtkTreeIter iter;
921 GtkTreePath *path;
922
923 fs = GNUNET_FS_GTK_get_fs_handle ();
924 opt = GNUNET_FS_DOWNLOAD_OPTION_NONE;
925 if (dc->is_recursive)
926 opt |= GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE;
927 len = GNUNET_FS_uri_chk_get_file_size (dc->uri);
928
929 de = GNUNET_malloc (sizeof (struct DownloadEntry));
930 de->uri = dc->uri;
931 dc->uri = NULL;
932 de->meta = dc->meta;
933 dc->meta = NULL;
934 if (dc->rr != NULL)
935 {
936 /* We're going to free "dc" very soon */
937 de->rr = gtk_tree_row_reference_copy (dc->rr);
938 de->ts = GTK_TREE_STORE (gtk_tree_row_reference_get_model (dc->rr));
939
940 path = gtk_tree_row_reference_get_path (de->rr);
941 GNUNET_assert (NULL != path);
942 if (gtk_tree_model_get_iter (GTK_TREE_MODEL (de->ts), &iter, path))
943 {
944 /* Store filename and anonymity as specified by the user.
945 * These will be re-used when this is a directory, and the user
946 * downloads its children.
947 */
948 gtk_tree_store_set (de->ts, &iter, 15, dc->filename, 16, dc->anonymity, -1);
949 }
950 gtk_tree_path_free (path);
951
952 }
953 if (dc->sr != NULL)
954 {
955 GNUNET_break (NULL !=
956 GNUNET_FS_download_start_from_search (fs, dc->sr,
957 dc->filename,
958 NULL /* tempname */ ,
959 0 /* offset */ ,
960 len, dc->anonymity, opt,
961 de));
962 }
963 else
964 {
965 GNUNET_break (NULL !=
966 GNUNET_FS_download_start (fs, de->uri, NULL /* meta */ ,
967 dc->filename, NULL /* tempname */ ,
968 0 /* offset */ ,
969 len, dc->anonymity, opt, de,
970 NULL /* parent download ctx */ ));
971 }
972 GNUNET_GTK_save_as_dialog_free_download_context (dc);
973}
974
975/** 912/**
976 * Tell FS to start a download. Begins by opening the 913 * Tell FS to start a download. Begins by opening the
977 * "save as" window. 914 * "save as" window.
@@ -1086,10 +1023,10 @@ start_download (GtkTreeView * tree_view, GtkTreePath * path,
1086 dc->anonymity = anonymity; 1023 dc->anonymity = anonymity;
1087 dc->is_recursive = sdc->recursive; 1024 dc->is_recursive = sdc->recursive;
1088 dc->tab = tab; 1025 dc->tab = tab;
1089 dc->cb = &open_download_as_callback; 1026 dc->cb = &GNUNET_FS_GTK_default_open_download_as_callback;
1090 if (local_parents && have_a_suggestion) 1027 if (local_parents && have_a_suggestion)
1091 /* Skip the dialog, call directly */ 1028 /* Skip the dialog, call directly */
1092 open_download_as_callback (dc); 1029 GNUNET_FS_GTK_default_open_download_as_callback (dc);
1093 else 1030 else
1094 GNUNET_FS_GTK_open_download_as_dialog (dc); 1031 GNUNET_FS_GTK_open_download_as_dialog (dc);
1095} 1032}
diff --git a/src/fs/gnunet-fs-gtk-main_window_file_download.c b/src/fs/gnunet-fs-gtk-main_window_file_download.c
index 667bf086..ec0191b4 100644
--- a/src/fs/gnunet-fs-gtk-main_window_file_download.c
+++ b/src/fs/gnunet-fs-gtk-main_window_file_download.c
@@ -117,6 +117,7 @@ GNUNET_GTK_open_url_dialog_execute_button_clicked_cb (GtkButton * button,
117 dc = GNUNET_malloc (sizeof (struct DownloadContext)); 117 dc = GNUNET_malloc (sizeof (struct DownloadContext));
118 dc->uri = uri; 118 dc->uri = uri;
119 dc->anonymity = anonymity_level; 119 dc->anonymity = anonymity_level;
120 dc->cb = GNUNET_FS_GTK_default_open_download_as_callback;
120 GNUNET_FS_GTK_open_download_as_dialog (dc); 121 GNUNET_FS_GTK_open_download_as_dialog (dc);
121 return; 122 return;
122 } 123 }