gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r11985 - gnunet-gtk/src
Date: Sun, 27 Jun 2010 16:58:57 +0200

Author: grothoff
Date: 2010-06-27 16:58:57 +0200 (Sun, 27 Jun 2010)
New Revision: 11985

Modified:
   gnunet-gtk/src/download.c
   gnunet-gtk/src/download.h
   gnunet-gtk/src/fs_event_handler.c
   gnunet-gtk/src/fs_event_handler.h
Log:
associate download with entry in directory

Modified: gnunet-gtk/src/download.c
===================================================================
--- gnunet-gtk/src/download.c   2010-06-27 14:38:08 UTC (rev 11984)
+++ gnunet-gtk/src/download.c   2010-06-27 14:58:57 UTC (rev 11985)
@@ -25,6 +25,7 @@
  */
 
 #include "download.h"
+#include "fs_event_handler.h"
 
 void
 GNUNET_GTK_open_download_as_dialog (struct DownloadContext *dc)
@@ -35,6 +36,7 @@
   uint64_t len;
   enum GNUNET_FS_DownloadOptions opt;
   uint32_t anonymity;
+  struct DownloadEntry *de;
 
   builder = GNUNET_GTK_get_new_builder ("download_as.glade");
   if (builder == NULL)
@@ -88,6 +90,14 @@
   len = GNUNET_FS_uri_chk_get_file_size (dc->uri);
   gtk_widget_destroy (ad);
   g_object_unref (G_OBJECT (builder));
+  de = GNUNET_malloc (sizeof (struct DownloadEntry));
+  de->uri = dc->uri;
+  de->meta = dc->meta;
+  if (dc->rr != NULL)
+    {
+      de->rr = dc->rr;
+      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,
@@ -98,7 +108,7 @@
                                                        len,
                                                        anonymity,
                                                        opt,
-                                                       dc));
+                                                       de));
   else
     GNUNET_break (NULL !=
                  GNUNET_FS_download_start (fs,
@@ -110,9 +120,9 @@
                                            len,
                                            anonymity,
                                            opt,
-                                           dc,
+                                           de,
                                            NULL /* parent download ctx */));
-
+  GNUNET_free (dc);
 }
 
 /* end of download.c */

Modified: gnunet-gtk/src/download.h
===================================================================
--- gnunet-gtk/src/download.h   2010-06-27 14:38:08 UTC (rev 11984)
+++ gnunet-gtk/src/download.h   2010-06-27 14:58:57 UTC (rev 11985)
@@ -39,6 +39,11 @@
   struct GNUNET_FS_Uri *uri;
 
   /**
+   * Meta data.
+   */
+  struct GNUNET_CONTAINER_MetaData *meta;
+
+  /**
    * Mime type.
    */ 
   char *mime;

Modified: gnunet-gtk/src/fs_event_handler.c
===================================================================
--- gnunet-gtk/src/fs_event_handler.c   2010-06-27 14:38:08 UTC (rev 11984)
+++ gnunet-gtk/src/fs_event_handler.c   2010-06-27 14:58:57 UTC (rev 11985)
@@ -108,24 +108,6 @@
 };
 
 
-struct DownloadEntry
-{
-  struct DownloadEntry *pde;
-
-  struct SearchResult *sr;
-
-  struct GNUNET_FS_DownloadContext *dc;
-
-  struct GNUNET_FS_Uri *uri;
-
-  struct GNUNET_CONTAINER_MetaData *meta;
-
-  GtkTreeRowReference *rr;
-
-  GtkTreeStore *ts;
-};
-
-
 static struct DownloadEntry *
 change_download_colour (struct DownloadEntry *de,
                       const char *colour)
@@ -284,6 +266,7 @@
 /**
  * Setup a new download entry.
  *
+ * @param de existing download entry for the download, or NULL
  * @param pde parent download entry, or NULL
  * @param sr search result, or NULL
  * @param dc download context (for stopping)
@@ -293,7 +276,8 @@
  * @param completed current progress
  */
 static struct DownloadEntry *
-setup_download (struct DownloadEntry *pde,
+setup_download (struct DownloadEntry *de,
+               struct DownloadEntry *pde,
                struct SearchResult *sr,
                struct GNUNET_FS_DownloadContext *dc,
                const struct GNUNET_FS_Uri *uri,
@@ -301,17 +285,20 @@
                uint64_t size,
                uint64_t completed)
 {
-  struct DownloadEntry *de;
   GtkTreeIter iter;
   GtkTreePath *path;
   struct SearchTab *tab;
 
-  de = GNUNET_malloc (sizeof (struct DownloadEntry));
+  if (de == NULL)
+    {
+      de = GNUNET_malloc (sizeof (struct DownloadEntry));
+      de->sr = sr;
+      de->dc = dc;
+      de->uri = GNUNET_FS_uri_dup (uri);
+    }
   de->pde = pde;
-  de->sr = sr;
-  de->dc = dc;
-  de->uri = GNUNET_FS_uri_dup (uri);
-  if (meta != NULL)
+  if ( (meta != NULL) &&
+       (de->meta == NULL) )
     de->meta = GNUNET_CONTAINER_meta_data_duplicate (meta);
   if (pde != NULL)
     {
@@ -323,7 +310,7 @@
       de->rr = gtk_tree_row_reference_copy (sr->rr);      
       de->ts = sr->tab->ts;
     }
-  else
+  else if (de->rr == NULL)
     {
       tab = GNUNET_GTK_add_to_uri_tab (&iter,
                                       NULL,
@@ -335,7 +322,7 @@
       de->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (de->ts),
                                           path);
       gtk_tree_path_free (path);
-    }
+    }    
   path = gtk_tree_row_reference_get_path (de->rr);
   if (TRUE != gtk_tree_model_get_iter (GTK_TREE_MODEL (de->ts), 
                                       &iter, path))
@@ -389,6 +376,7 @@
   dlc->uri = GNUNET_FS_uri_dup (uri);
   dlc->mime = mime;
   dlc->filename = GNUNET_FS_meta_data_suggest_filename (meta);
+  dlc->meta = GNUNET_CONTAINER_meta_data_duplicate (meta);
   dlc->rr = gtk_tree_row_reference_new (tm, path);
   dlc->sr = sr->result;
   dlc->anonymity = 1; /* FIXME: grab from search? */
@@ -1291,7 +1279,8 @@
       close_publish_tab (info->value.publish.cctx);
       return NULL;
     case GNUNET_FS_STATUS_DOWNLOAD_START: 
-      return setup_download (info->value.download.pctx,
+      return setup_download (info->value.download.cctx,
+                            info->value.download.pctx,
                             info->value.download.sctx,
                             info->value.download.dc,
                             info->value.download.uri,

Modified: gnunet-gtk/src/fs_event_handler.h
===================================================================
--- gnunet-gtk/src/fs_event_handler.h   2010-06-27 14:38:08 UTC (rev 11984)
+++ gnunet-gtk/src/fs_event_handler.h   2010-06-27 14:58:57 UTC (rev 11985)
@@ -67,10 +67,30 @@
 
 };
 
-
 struct SearchResult;
 
 
+struct DownloadEntry
+{
+  struct DownloadEntry *pde;
+
+  struct SearchResult *sr;
+
+  struct GNUNET_FS_DownloadContext *dc;
+
+  struct GNUNET_FS_Uri *uri;
+
+  struct GNUNET_CONTAINER_MetaData *meta;
+
+  GtkTreeRowReference *rr;
+
+  GtkTreeStore *ts;
+
+};
+
+
+
+
 /**
  * Setup a new top-level entry in the URI tab.  If necessary, create
  * the URI tab first.




reply via email to

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