[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r19693 - gnunet-gtk/src/fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r19693 - gnunet-gtk/src/fs |
Date: |
Sat, 4 Feb 2012 23:27:13 +0100 |
Author: grothoff
Date: 2012-02-04 23:27:13 +0100 (Sat, 04 Feb 2012)
New Revision: 19693
Modified:
gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c
Log:
-partial fix for #2080
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c 2012-02-04 21:28:49 UTC
(rev 19692)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c 2012-02-04 22:27:13 UTC
(rev 19693)
@@ -1649,7 +1649,6 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Adding directory entry `%s'\n",
filename);
-
if (NULL == uri)
{
/* directory meta data itself */
@@ -1690,6 +1689,7 @@
* the contents.
*
* @param de download entry that is progressing
+ * @param filename name of the downloaded file on disk (possibly a temporary
file)
* @param size overall size of the download
* @param completed number of bytes we have completed
* @param block_data current block we've downloaded
@@ -1698,7 +1698,9 @@
* @param depth depth of the block in the ECRS tree
*/
static void
-mark_download_progress (struct DownloadEntry *de, uint64_t size,
+mark_download_progress (struct DownloadEntry *de,
+ const char *filename,
+ uint64_t size,
uint64_t completed, const void *block_data,
uint64_t offset, uint64_t block_size,
unsigned int depth)
@@ -1731,26 +1733,48 @@
size) : 100) /* availability ==
progress */,
14, completed,
-1);
- if ( (depth == 0) &&
- (block_size > 0) &&
- (GNUNET_YES == de->is_directory) )
+ if (completed < size)
{
- /* got a data block of a directory, list its contents */
- struct AddDirectoryEntryContext ade;
-
- ade.tab = de->sr->tab;
- ade.prr = de->sr->rr;
- ade.check_duplicates = GNUNET_NO;
- if (GNUNET_SYSERR ==
- GNUNET_FS_directory_list_contents ((size_t) block_size, block_data,
- offset, &add_directory_entry, &ade))
+ /* partial completion, consider looking at the block */
+ if ( (depth == 0) &&
+ (block_size > 0) &&
+ (GNUNET_YES == de->is_directory) )
{
- /* Mime type was wrong, this is not a directory, update model! */
- de->is_directory = GNUNET_SYSERR;
- gtk_tree_store_set (de->sr->tab->ts, &iter,
- 10, "" /* unknown mime type */, -1);
+ /* got a data block of a directory, list its contents */
+ struct AddDirectoryEntryContext ade;
+
+ ade.tab = de->sr->tab;
+ ade.prr = de->sr->rr;
+ ade.check_duplicates = GNUNET_NO;
+ if (GNUNET_SYSERR ==
+ GNUNET_FS_directory_list_contents ((size_t) block_size, block_data,
+ offset, &add_directory_entry,
&ade))
+ {
+ /* Mime type was wrong, this is not a directory, update model! */
+ de->is_directory = GNUNET_SYSERR;
+ gtk_tree_store_set (de->sr->tab->ts, &iter,
+ 10, "" /* unknown mime type */, -1);
+ }
}
}
+ else
+ {
+ /* full completion, look at the entire file */
+ if ( (GNUNET_NO != de->is_directory) &&
+ (filename != NULL) )
+ {
+ struct AddDirectoryEntryContext ade;
+
+ /* download was for a directory (and we have a temp file for scanning);
+ add contents of the directory to the view */
+ ade.tab = de->sr->tab;
+ ade.prr = de->sr->rr;
+ ade.check_duplicates = GNUNET_YES;
+ if (GNUNET_OK !=
+ GNUNET_FS_GTK_mmap_and_scan (filename, &add_directory_entry, &ade))
+ de->is_directory = GNUNET_NO;
+ }
+ }
}
@@ -1784,37 +1808,15 @@
/**
* FS-API notified us that we're done with a download. Update the
- * view accordingly. If the download is a directory, try to display
- * the contents.
+ * view accordingly.
*
* @param de download that has finished
* @param size overall size of the file
- * @param filename name of the downloaded file on disk (possibly a temporary
file)
*/
static void
-mark_download_completed (struct DownloadEntry *de, uint64_t size,
- const char *filename)
+mark_download_completed (struct DownloadEntry *de, uint64_t size)
{
- struct AddDirectoryEntryContext ade;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Marking download completed for DE=%p, %llu-byte `%s'\n",
- de, size, filename);
-
de->is_done = GNUNET_YES;
- mark_download_progress (de, size, size, NULL, 0, 0, 0);
- if ( (GNUNET_NO != de->is_directory) &&
- (filename != NULL) )
- {
- /* download was for a directory (and we have a temp file for scanning);
- add contents of the directory to the view */
- ade.tab = de->sr->tab;
- ade.prr = de->sr->rr;
- ade.check_duplicates = GNUNET_YES;
- if (GNUNET_OK !=
- GNUNET_FS_GTK_mmap_and_scan (filename, &add_directory_entry, &ade))
- de->is_directory = GNUNET_NO;
- }
change_download_color (de, "green");
}
@@ -1924,7 +1926,7 @@
copy_children (src_model, &src_child, dst_tab, &dst_child);
}
- while (TRUE == gtk_tree_model_iter_next (src_model, &src_child));
+ while (gtk_tree_model_iter_next (src_model, &src_child));
}
@@ -2073,6 +2075,40 @@
GNUNET_assert (sr == de->sr);
}
}
+ if ( (NULL == de->sr) &&
+ (NULL != pde) )
+ {
+ /* child download, find appropriate search result from parent! */
+ GtkTreePath *path;
+ GtkTreeModel *tm;
+ GtkTreeIter iter;
+ GtkTreeIter child;
+ struct GNUNET_FS_Uri *uri;
+
+ tm = GTK_TREE_MODEL (pde->sr->tab->ts);
+ path = gtk_tree_row_reference_get_path (pde->sr->rr);
+ if ( (! gtk_tree_model_get_iter (tm, &iter, path)) ||
+ (! gtk_tree_model_iter_children (tm, &child, &iter)) )
+ {
+ GNUNET_break (0);
+ }
+ else
+ {
+ do
+ {
+ gtk_tree_model_get (tm, &child, 1, &uri,
+ 9, &de->sr,
+ -1);
+ if (GNUNET_YES == GNUNET_FS_uri_test_equal (de->uri,
+ uri))
+ break;
+ de->sr = NULL;
+ }
+ while (gtk_tree_model_iter_next (tm, &child));
+ GNUNET_break (NULL != de->sr);
+ }
+ gtk_tree_path_free (path);
+ }
if (NULL == de->sr)
{
/* Stand-alone download with no 'row'/search result affiliated
@@ -2080,13 +2116,30 @@
download in the URI tab */
de->sr = GNUNET_GTK_add_to_uri_tab (meta, uri);
de->sr->download = de;
+ path = gtk_tree_row_reference_get_path (de->sr->rr);
+ if (! gtk_tree_model_get_iter (GTK_TREE_MODEL (de->sr->tab->ts), &iter,
path))
+ {
+ GNUNET_break (0);
+ gtk_tree_path_free (path);
+ return de;
+ }
}
- path = gtk_tree_row_reference_get_path (de->sr->rr);
- if (! gtk_tree_model_get_iter (GTK_TREE_MODEL (de->sr->tab->ts), &iter,
path))
+ else
{
- GNUNET_break (0);
- gtk_tree_path_free (path);
- return de;
+ struct GNUNET_CONTAINER_MetaData *meta;
+
+ /* get metadata from existing tab, might have a mime type */
+ path = gtk_tree_row_reference_get_path (de->sr->rr);
+ if (! gtk_tree_model_get_iter (GTK_TREE_MODEL (de->sr->tab->ts), &iter,
path))
+ {
+ GNUNET_break (0);
+ gtk_tree_path_free (path);
+ return de;
+ }
+ gtk_tree_model_get (GTK_TREE_MODEL (de->sr->tab->ts), &iter,
+ 0, &meta,
+ -1);
+ de->is_directory = GNUNET_FS_meta_data_test_for_directory (meta);
}
gtk_tree_path_free (path);
gtk_tree_store_set (de->sr->tab->ts, &iter,
@@ -2500,6 +2553,7 @@
return NULL;
case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
mark_download_progress (info->value.download.cctx,
+ info->value.download.filename,
info->value.download.size,
info->value.download.completed,
info->value.download.specifics.progress.data,
@@ -2516,8 +2570,7 @@
return info->value.download.cctx;
case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
mark_download_completed (info->value.download.cctx,
- info->value.download.size,
- info->value.download.filename);
+ info->value.download.size);
return info->value.download.cctx;
case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
stop_download (info->value.download.cctx);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r19693 - gnunet-gtk/src/fs,
gnunet <=