diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/download.c | 16 | ||||
-rw-r--r-- | src/download.h | 5 | ||||
-rw-r--r-- | src/fs_event_handler.c | 45 | ||||
-rw-r--r-- | src/fs_event_handler.h | 22 |
4 files changed, 56 insertions, 32 deletions
diff --git a/src/download.c b/src/download.c index de63c40f..6eedde8d 100644 --- a/src/download.c +++ b/src/download.c | |||
@@ -25,6 +25,7 @@ | |||
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "download.h" | 27 | #include "download.h" |
28 | #include "fs_event_handler.h" | ||
28 | 29 | ||
29 | void | 30 | void |
30 | GNUNET_GTK_open_download_as_dialog (struct DownloadContext *dc) | 31 | GNUNET_GTK_open_download_as_dialog (struct DownloadContext *dc) |
@@ -35,6 +36,7 @@ GNUNET_GTK_open_download_as_dialog (struct DownloadContext *dc) | |||
35 | uint64_t len; | 36 | uint64_t len; |
36 | enum GNUNET_FS_DownloadOptions opt; | 37 | enum GNUNET_FS_DownloadOptions opt; |
37 | uint32_t anonymity; | 38 | uint32_t anonymity; |
39 | struct DownloadEntry *de; | ||
38 | 40 | ||
39 | builder = GNUNET_GTK_get_new_builder ("download_as.glade"); | 41 | builder = GNUNET_GTK_get_new_builder ("download_as.glade"); |
40 | if (builder == NULL) | 42 | if (builder == NULL) |
@@ -88,6 +90,14 @@ GNUNET_GTK_open_download_as_dialog (struct DownloadContext *dc) | |||
88 | len = GNUNET_FS_uri_chk_get_file_size (dc->uri); | 90 | len = GNUNET_FS_uri_chk_get_file_size (dc->uri); |
89 | gtk_widget_destroy (ad); | 91 | gtk_widget_destroy (ad); |
90 | g_object_unref (G_OBJECT (builder)); | 92 | g_object_unref (G_OBJECT (builder)); |
93 | de = GNUNET_malloc (sizeof (struct DownloadEntry)); | ||
94 | de->uri = dc->uri; | ||
95 | de->meta = dc->meta; | ||
96 | if (dc->rr != NULL) | ||
97 | { | ||
98 | de->rr = dc->rr; | ||
99 | de->ts = GTK_TREE_STORE (gtk_tree_row_reference_get_model (dc->rr)); | ||
100 | } | ||
91 | if (dc->sr != NULL) | 101 | if (dc->sr != NULL) |
92 | GNUNET_break (NULL != | 102 | GNUNET_break (NULL != |
93 | GNUNET_FS_download_start_from_search (fs, | 103 | GNUNET_FS_download_start_from_search (fs, |
@@ -98,7 +108,7 @@ GNUNET_GTK_open_download_as_dialog (struct DownloadContext *dc) | |||
98 | len, | 108 | len, |
99 | anonymity, | 109 | anonymity, |
100 | opt, | 110 | opt, |
101 | dc)); | 111 | de)); |
102 | else | 112 | else |
103 | GNUNET_break (NULL != | 113 | GNUNET_break (NULL != |
104 | GNUNET_FS_download_start (fs, | 114 | GNUNET_FS_download_start (fs, |
@@ -110,9 +120,9 @@ GNUNET_GTK_open_download_as_dialog (struct DownloadContext *dc) | |||
110 | len, | 120 | len, |
111 | anonymity, | 121 | anonymity, |
112 | opt, | 122 | opt, |
113 | dc, | 123 | de, |
114 | NULL /* parent download ctx */)); | 124 | NULL /* parent download ctx */)); |
115 | 125 | GNUNET_free (dc); | |
116 | } | 126 | } |
117 | 127 | ||
118 | /* end of download.c */ | 128 | /* end of download.c */ |
diff --git a/src/download.h b/src/download.h index 378bed01..e2c8767b 100644 --- a/src/download.h +++ b/src/download.h | |||
@@ -39,6 +39,11 @@ struct DownloadContext | |||
39 | struct GNUNET_FS_Uri *uri; | 39 | struct GNUNET_FS_Uri *uri; |
40 | 40 | ||
41 | /** | 41 | /** |
42 | * Meta data. | ||
43 | */ | ||
44 | struct GNUNET_CONTAINER_MetaData *meta; | ||
45 | |||
46 | /** | ||
42 | * Mime type. | 47 | * Mime type. |
43 | */ | 48 | */ |
44 | char *mime; | 49 | char *mime; |
diff --git a/src/fs_event_handler.c b/src/fs_event_handler.c index 6a8da393..035e2a48 100644 --- a/src/fs_event_handler.c +++ b/src/fs_event_handler.c | |||
@@ -108,24 +108,6 @@ struct SearchResult | |||
108 | }; | 108 | }; |
109 | 109 | ||
110 | 110 | ||
111 | struct DownloadEntry | ||
112 | { | ||
113 | struct DownloadEntry *pde; | ||
114 | |||
115 | struct SearchResult *sr; | ||
116 | |||
117 | struct GNUNET_FS_DownloadContext *dc; | ||
118 | |||
119 | struct GNUNET_FS_Uri *uri; | ||
120 | |||
121 | struct GNUNET_CONTAINER_MetaData *meta; | ||
122 | |||
123 | GtkTreeRowReference *rr; | ||
124 | |||
125 | GtkTreeStore *ts; | ||
126 | }; | ||
127 | |||
128 | |||
129 | static struct DownloadEntry * | 111 | static struct DownloadEntry * |
130 | change_download_colour (struct DownloadEntry *de, | 112 | change_download_colour (struct DownloadEntry *de, |
131 | const char *colour) | 113 | const char *colour) |
@@ -284,6 +266,7 @@ download_lost_parent (struct DownloadEntry *de, | |||
284 | /** | 266 | /** |
285 | * Setup a new download entry. | 267 | * Setup a new download entry. |
286 | * | 268 | * |
269 | * @param de existing download entry for the download, or NULL | ||
287 | * @param pde parent download entry, or NULL | 270 | * @param pde parent download entry, or NULL |
288 | * @param sr search result, or NULL | 271 | * @param sr search result, or NULL |
289 | * @param dc download context (for stopping) | 272 | * @param dc download context (for stopping) |
@@ -293,7 +276,8 @@ download_lost_parent (struct DownloadEntry *de, | |||
293 | * @param completed current progress | 276 | * @param completed current progress |
294 | */ | 277 | */ |
295 | static struct DownloadEntry * | 278 | static struct DownloadEntry * |
296 | setup_download (struct DownloadEntry *pde, | 279 | setup_download (struct DownloadEntry *de, |
280 | struct DownloadEntry *pde, | ||
297 | struct SearchResult *sr, | 281 | struct SearchResult *sr, |
298 | struct GNUNET_FS_DownloadContext *dc, | 282 | struct GNUNET_FS_DownloadContext *dc, |
299 | const struct GNUNET_FS_Uri *uri, | 283 | const struct GNUNET_FS_Uri *uri, |
@@ -301,17 +285,20 @@ setup_download (struct DownloadEntry *pde, | |||
301 | uint64_t size, | 285 | uint64_t size, |
302 | uint64_t completed) | 286 | uint64_t completed) |
303 | { | 287 | { |
304 | struct DownloadEntry *de; | ||
305 | GtkTreeIter iter; | 288 | GtkTreeIter iter; |
306 | GtkTreePath *path; | 289 | GtkTreePath *path; |
307 | struct SearchTab *tab; | 290 | struct SearchTab *tab; |
308 | 291 | ||
309 | de = GNUNET_malloc (sizeof (struct DownloadEntry)); | 292 | if (de == NULL) |
293 | { | ||
294 | de = GNUNET_malloc (sizeof (struct DownloadEntry)); | ||
295 | de->sr = sr; | ||
296 | de->dc = dc; | ||
297 | de->uri = GNUNET_FS_uri_dup (uri); | ||
298 | } | ||
310 | de->pde = pde; | 299 | de->pde = pde; |
311 | de->sr = sr; | 300 | if ( (meta != NULL) && |
312 | de->dc = dc; | 301 | (de->meta == NULL) ) |
313 | de->uri = GNUNET_FS_uri_dup (uri); | ||
314 | if (meta != NULL) | ||
315 | de->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); | 302 | de->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); |
316 | if (pde != NULL) | 303 | if (pde != NULL) |
317 | { | 304 | { |
@@ -323,7 +310,7 @@ setup_download (struct DownloadEntry *pde, | |||
323 | de->rr = gtk_tree_row_reference_copy (sr->rr); | 310 | de->rr = gtk_tree_row_reference_copy (sr->rr); |
324 | de->ts = sr->tab->ts; | 311 | de->ts = sr->tab->ts; |
325 | } | 312 | } |
326 | else | 313 | else if (de->rr == NULL) |
327 | { | 314 | { |
328 | tab = GNUNET_GTK_add_to_uri_tab (&iter, | 315 | tab = GNUNET_GTK_add_to_uri_tab (&iter, |
329 | NULL, | 316 | NULL, |
@@ -335,7 +322,7 @@ setup_download (struct DownloadEntry *pde, | |||
335 | de->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (de->ts), | 322 | de->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (de->ts), |
336 | path); | 323 | path); |
337 | gtk_tree_path_free (path); | 324 | gtk_tree_path_free (path); |
338 | } | 325 | } |
339 | path = gtk_tree_row_reference_get_path (de->rr); | 326 | path = gtk_tree_row_reference_get_path (de->rr); |
340 | if (TRUE != gtk_tree_model_get_iter (GTK_TREE_MODEL (de->ts), | 327 | if (TRUE != gtk_tree_model_get_iter (GTK_TREE_MODEL (de->ts), |
341 | &iter, path)) | 328 | &iter, path)) |
@@ -389,6 +376,7 @@ start_download (GtkTreeView *tree_view, | |||
389 | dlc->uri = GNUNET_FS_uri_dup (uri); | 376 | dlc->uri = GNUNET_FS_uri_dup (uri); |
390 | dlc->mime = mime; | 377 | dlc->mime = mime; |
391 | dlc->filename = GNUNET_FS_meta_data_suggest_filename (meta); | 378 | dlc->filename = GNUNET_FS_meta_data_suggest_filename (meta); |
379 | dlc->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); | ||
392 | dlc->rr = gtk_tree_row_reference_new (tm, path); | 380 | dlc->rr = gtk_tree_row_reference_new (tm, path); |
393 | dlc->sr = sr->result; | 381 | dlc->sr = sr->result; |
394 | dlc->anonymity = 1; /* FIXME: grab from search? */ | 382 | dlc->anonymity = 1; /* FIXME: grab from search? */ |
@@ -1291,7 +1279,8 @@ GNUNET_GTK_fs_event_handler (void *cls, | |||
1291 | close_publish_tab (info->value.publish.cctx); | 1279 | close_publish_tab (info->value.publish.cctx); |
1292 | return NULL; | 1280 | return NULL; |
1293 | case GNUNET_FS_STATUS_DOWNLOAD_START: | 1281 | case GNUNET_FS_STATUS_DOWNLOAD_START: |
1294 | return setup_download (info->value.download.pctx, | 1282 | return setup_download (info->value.download.cctx, |
1283 | info->value.download.pctx, | ||
1295 | info->value.download.sctx, | 1284 | info->value.download.sctx, |
1296 | info->value.download.dc, | 1285 | info->value.download.dc, |
1297 | info->value.download.uri, | 1286 | info->value.download.uri, |
diff --git a/src/fs_event_handler.h b/src/fs_event_handler.h index 68d0c3f8..63b3a5e9 100644 --- a/src/fs_event_handler.h +++ b/src/fs_event_handler.h | |||
@@ -67,10 +67,30 @@ struct SearchTab | |||
67 | 67 | ||
68 | }; | 68 | }; |
69 | 69 | ||
70 | |||
71 | struct SearchResult; | 70 | struct SearchResult; |
72 | 71 | ||
73 | 72 | ||
73 | struct DownloadEntry | ||
74 | { | ||
75 | struct DownloadEntry *pde; | ||
76 | |||
77 | struct SearchResult *sr; | ||
78 | |||
79 | struct GNUNET_FS_DownloadContext *dc; | ||
80 | |||
81 | struct GNUNET_FS_Uri *uri; | ||
82 | |||
83 | struct GNUNET_CONTAINER_MetaData *meta; | ||
84 | |||
85 | GtkTreeRowReference *rr; | ||
86 | |||
87 | GtkTreeStore *ts; | ||
88 | |||
89 | }; | ||
90 | |||
91 | |||
92 | |||
93 | |||
74 | /** | 94 | /** |
75 | * Setup a new top-level entry in the URI tab. If necessary, create | 95 | * Setup a new top-level entry in the URI tab. If necessary, create |
76 | * the URI tab first. | 96 | * the URI tab first. |