aboutsummaryrefslogtreecommitdiff
path: root/src/fs_event_handler.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs_event_handler.c')
-rw-r--r--src/fs_event_handler.c45
1 files changed, 17 insertions, 28 deletions
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
111struct 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
129static struct DownloadEntry * 111static struct DownloadEntry *
130change_download_colour (struct DownloadEntry *de, 112change_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 */
295static struct DownloadEntry * 278static struct DownloadEntry *
296setup_download (struct DownloadEntry *pde, 279setup_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,