gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r11988 - gnunet-gtk/src


From: gnunet
Subject: [GNUnet-SVN] r11988 - gnunet-gtk/src
Date: Sun, 27 Jun 2010 17:43:05 +0200

Author: grothoff
Date: 2010-06-27 17:43:05 +0200 (Sun, 27 Jun 2010)
New Revision: 11988

Modified:
   gnunet-gtk/src/download.c
   gnunet-gtk/src/fs_event_handler.c
   gnunet-gtk/src/fs_event_handler.h
Log:
stuff

Modified: gnunet-gtk/src/download.c
===================================================================
--- gnunet-gtk/src/download.c   2010-06-27 15:18:48 UTC (rev 11987)
+++ gnunet-gtk/src/download.c   2010-06-27 15:43:05 UTC (rev 11988)
@@ -99,29 +99,33 @@
       de->ts = GTK_TREE_STORE (gtk_tree_row_reference_get_model (dc->rr));
     }
   if (dc->sr != NULL)
-    GNUNET_break (NULL !=
-                 GNUNET_FS_download_start_from_search (fs,
-                                                       dc->sr,
-                                                       dc->filename,
-                                                       NULL /* tempname */,
-                                                       0 /* offset */,
-                                                       len,
-                                                       anonymity,
-                                                       opt,
-                                                       de));
+    {
+      GNUNET_break (NULL !=
+                   GNUNET_FS_download_start_from_search (fs,
+                                                         dc->sr,
+                                                         dc->filename,
+                                                         NULL /* tempname */,
+                                                         0 /* offset */,
+                                                         len,
+                                                         anonymity,
+                                                         opt,
+                                                         de));
+    }
   else
-    GNUNET_break (NULL !=
-                 GNUNET_FS_download_start (fs,
-                                           dc->uri,
-                                           NULL /* meta */,
-                                           dc->filename,
-                                           NULL /* tempname */,
-                                           0 /* offset */,
-                                           len,
-                                           anonymity,
-                                           opt,
-                                           de,
-                                           NULL /* parent download ctx */));
+    {
+      GNUNET_break (NULL !=
+                   GNUNET_FS_download_start (fs,
+                                             dc->uri,
+                                             NULL /* meta */,
+                                             dc->filename,
+                                             NULL /* tempname */,
+                                             0 /* offset */,
+                                             len,
+                                             anonymity,
+                                             opt,
+                                             de,
+                                             NULL /* parent download ctx */));
+    }
   GNUNET_free (dc);
 }
 

Modified: gnunet-gtk/src/fs_event_handler.c
===================================================================
--- gnunet-gtk/src/fs_event_handler.c   2010-06-27 15:18:48 UTC (rev 11987)
+++ gnunet-gtk/src/fs_event_handler.c   2010-06-27 15:43:05 UTC (rev 11988)
@@ -77,11 +77,8 @@
   int is_top;
 };
 
-static struct PublishTab *publish_tab_head;
 
-static struct PublishTab *publish_tab_tail;
-
-struct SearchResult 
+struct SearchResult
 {
   /**
    * Where in the tab is this result?
@@ -108,6 +105,12 @@
 };
 
 
+
+static struct PublishTab *publish_tab_head;
+
+static struct PublishTab *publish_tab_tail;
+
+
 static struct DownloadEntry *
 change_download_colour (struct DownloadEntry *de,
                       const char *colour)
@@ -173,10 +176,103 @@
 }
 
 
+
+struct AddDirectoryEntryContext
+{
+
+  struct DownloadEntry *de;
+
+  int check_duplicates;
+
+};
+
+
+/**
+ * Function used to process entries in a directory.
+ *
+ * @param cls closure, our 'struct AddDirectoryEntryContext*'
+ * @param filename name of the file in the directory
+ * @param uri URI of the file
+ * @param metadata metadata for the file; metadata for
+ *        the directory if everything else is NULL/zero
+ * @param length length of the available data for the file
+ *           (of type size_t since data must certainly fit
+ *            into memory; if files are larger than size_t
+ *            permits, then they will certainly not be
+ *            embedded with the directory itself).
+ * @param data data available for the file (length bytes)
+ */
+static void 
+add_directory_entry (void *cls,
+                    const char *filename,
+                    const struct GNUNET_FS_Uri *uri,
+                    const struct GNUNET_CONTAINER_MetaData *meta,
+                    size_t length,
+                    const void *data)
+{
+  struct AddDirectoryEntryContext *ade = cls;
+  GtkTreeIter iter;
+
+  if (uri == NULL)
+    {
+      /* directory meta data itself */
+      /* FIXME: consider merging it in... */
+      return;
+    }
+  GNUNET_GTK_add_search_result (ade->de->tab,
+                               &iter,
+                               ade->de->sr,
+                               uri,
+                               meta,
+                               NULL,
+                               0);
+}
+
+
+
+/**
+ * Add search results from directory to the view
+ *
+ * @param de download entry to process
+ * @param check_duplicates check if enties already exist
+ * @param block_data directory data
+ * @param offset starting offset
+ * @param block_size size of block_data
+ */
+static void
+add_directory_entries (struct DownloadEntry *de,
+                      int check_duplicates,
+                      const void *block_data,
+                      uint64_t offset,
+                      uint64_t block_size)
+{
+  struct AddDirectoryEntryContext ade;
+
+  ade.de = de;
+  ade.check_duplicates = check_duplicates;
+  if (GNUNET_SYSERR ==
+      GNUNET_FS_directory_list_contents ((size_t) block_size,
+                                        block_data,
+                                        offset,
+                                        &add_directory_entry,
+                                        &ade))
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                 _("Metadata wrongly claims that this is a GNUnet 
directory!\n"));
+    }
+
+}
+                      
+
+
 static struct DownloadEntry *
 mark_download_progress (struct DownloadEntry *de,
                        uint64_t size,
-                       uint64_t completed)
+                       uint64_t completed,
+                       const void *block_data,
+                       uint64_t offset,
+                       uint64_t block_size,
+                       unsigned int depth)
 {
   GtkTreeIter iter;
   GtkTreePath *path;
@@ -193,10 +289,28 @@
   gtk_tree_store_set (de->ts, &iter,
                      4, (guint) ((size > 0) ? (100 * completed / size) : 100) 
/* progress */,
                      -1);
+  if ( (depth == 0) &&
+       (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (de->meta)) )
+    add_directory_entries (de, GNUNET_NO,
+                          block_data, offset, 0);
   return de;
 }
 
 
+static struct DownloadEntry *
+mark_download_completed (struct DownloadEntry *de,
+                        uint64_t size)
+{
+  (void) mark_download_progress (de, size, size, NULL, 0, 0, 0);
+  if (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (de->meta))
+    {
+      GNUNET_break (0);
+    }
+  (void) change_download_colour (de, "green");
+  return de;
+}
+
+
 static struct PublishEntry *
 mark_publish_progress (struct PublishEntry *pe,
                        uint64_t size,
@@ -247,7 +361,10 @@
   de->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (de->ts),
                                       path);
   gtk_tree_path_free (path);
-  mark_download_progress (de, size, completed);
+  mark_download_progress (de, size, completed,
+                         NULL, 0, 0, 0);
+  /* FIXME: need to also move sub-downloads ---
+     this could be a recursive download! */
   if (size > completed)
     {
       if (is_active)
@@ -287,7 +404,6 @@
 {
   GtkTreeIter iter;
   GtkTreePath *path;
-  struct SearchTab *tab;
 
   if (de == NULL)
     {
@@ -312,11 +428,11 @@
     }
   else if (de->rr == NULL)
     {
-      tab = GNUNET_GTK_add_to_uri_tab (&iter,
-                                      NULL,
-                                      meta,
-                                      uri);
-      de->ts = tab->ts;
+      de->tab = GNUNET_GTK_add_to_uri_tab (&iter,
+                                          NULL,
+                                          meta,
+                                          uri);
+      de->ts = de->tab->ts;
       path = gtk_tree_model_get_path (GTK_TREE_MODEL (de->ts),
                                      &iter);
       de->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (de->ts),
@@ -1293,16 +1409,20 @@
     case GNUNET_FS_STATUS_DOWNLOAD_SUSPEND: 
       stop_download (info->value.download.cctx, GNUNET_YES);
       return NULL;
-    case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: 
+    case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:       
       return mark_download_progress (info->value.download.cctx,
                                     info->value.download.size,
-                                    info->value.download.completed);
+                                    info->value.download.completed,
+                                    
info->value.download.specifics.progress.data,
+                                    
info->value.download.specifics.progress.offset,
+                                    
info->value.download.specifics.progress.data_len,
+                                    
info->value.download.specifics.progress.depth);
     case GNUNET_FS_STATUS_DOWNLOAD_ERROR: 
       return change_download_colour (info->value.download.cctx,
                                     "red");
     case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: 
-      return change_download_colour (info->value.download.cctx,
-                                    "green");
+      return mark_download_completed (info->value.download.cctx,
+                                     info->value.download.size);
     case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
       stop_download (info->value.download.cctx, GNUNET_NO);
       return NULL;

Modified: gnunet-gtk/src/fs_event_handler.h
===================================================================
--- gnunet-gtk/src/fs_event_handler.h   2010-06-27 15:18:48 UTC (rev 11987)
+++ gnunet-gtk/src/fs_event_handler.h   2010-06-27 15:43:05 UTC (rev 11988)
@@ -67,6 +67,7 @@
 
 };
 
+
 struct SearchResult;
 
 
@@ -86,6 +87,7 @@
 
   GtkTreeStore *ts;
 
+  struct SearchTab *tab;
 };
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]