gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r27336 - gnunet-gtk/src/fs


From: gnunet
Subject: [GNUnet-SVN] r27336 - gnunet-gtk/src/fs
Date: Thu, 30 May 2013 18:12:37 +0200

Author: grothoff
Date: 2013-05-30 18:12:37 +0200 (Thu, 30 May 2013)
New Revision: 27336

Modified:
   gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c
   gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.h
   gnunet-gtk/src/fs/gnunet-fs-gtk_open-directory.c
Log:
-theoretic --- untested --- fix for #2711, probes for entries in directories

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c     2013-05-30 15:20:02 UTC 
(rev 27335)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c     2013-05-30 16:12:37 UTC 
(rev 27336)
@@ -670,8 +670,9 @@
 
 
 /**
- * save_as - GNUNET_YES to open SaveAs dialog, GNUNET_NO to start downloading.
- * download_directly - GNUNET_YES to make SaveAs dialog initiate the download,
+ *
+ * @param save_as - GNUNET_YES to open SaveAs dialog, GNUNET_NO to start 
downloading.
+ * @param download_directly - GNUNET_YES to make SaveAs dialog initiate the 
download,
  *                     GNUNET_NO to only change names on the download panel.
  *                     Ingored if save_as is GNUNET_NO.
  */
@@ -728,14 +729,14 @@
   filename = gtk_entry_get_text (mctx->download_name_entry);
   downloaddir = gtk_file_chooser_get_filename 
(mctx->download_location_chooser);
 
-  de = GNUNET_malloc (sizeof (struct DownloadEntry));
+  de = GNUNET_new (struct DownloadEntry);
 
   if (gtk_tree_model_iter_parent (model, &parent_iter, &iter))
   {
     struct SearchResult *psr = NULL;
     gtk_tree_model_get (model, &parent_iter,
-                      SEARCH_TAB_MC_SEARCH_RESULT, &psr,
-                      -1);
+                       SEARCH_TAB_MC_SEARCH_RESULT, &psr,
+                       -1);
     if (psr)
       de->pde = psr->download;
   }
@@ -770,6 +771,7 @@
   }
 }
 
+
 /**
  * "Download" was selected in the current search context menu.
  *
@@ -785,6 +787,7 @@
   start_download2 (save_as, GNUNET_YES);
 }
 
+
 /**
  * This function is called when the user double-clicks on a search
  * result.  Begins the download, if necessary by opening the "save as"
@@ -812,8 +815,8 @@
  * @param user_data the main window context
  */
 void
-GNUNET_GTK_search_frame_download_download_button_clicked_cb (
-    GtkButton *button, gpointer user_data)
+GNUNET_GTK_search_frame_download_download_button_clicked_cb (GtkButton *button,
+                                                            gpointer user_data)
 {
   start_download2 (GNUNET_NO, GNUNET_NO);
 }
@@ -847,6 +850,7 @@
   start_download_ctx_menu_helper (spc, GNUNET_NO, GNUNET_NO);
 }
 
+
 /**
  * "Get root element of associated namespace X" was selected in the current 
search
  * context menu.
@@ -1423,8 +1427,10 @@
                         &downloaded_anonymity,
                         SEARCH_TAB_MC_SHOW_NS_ASSOCIATION, 
&show_ns_association,
                         -1);
-    search_result_new = GNUNET_malloc (sizeof (struct SearchResult));
+    search_result_new = GNUNET_new (struct SearchResult);
     search_result_new->tab = dst_tab;
+    search_result_new->probe = search_result_old->probe;
+    search_result_old->probe = NULL;
     search_result_new->download = search_result_old->download;
     if (NULL != search_result_old->download)
     {
@@ -1548,7 +1554,8 @@
   de->sr->download = NULL;
 
   /* create the target root */
-  de->sr = GNUNET_GTK_add_to_uri_tab (meta, uri);
+  de->sr = GNUNET_GTK_add_to_uri_tab (downloaded_anonymity,
+                                     meta, uri);
   de->sr->download = de;
 
   /* get positions of the 'new' root */
@@ -1637,6 +1644,7 @@
       if (NULL != meta)
        GNUNET_CONTAINER_meta_data_destroy (meta);
       gtk_tree_row_reference_free (sr->rr);
+      GNUNET_break (NULL == sr->probe);
       GNUNET_free (sr);
       /* get ready for removal of the tree */
       gtk_tree_store_set (GTK_TREE_STORE (tm), &child,
@@ -1694,6 +1702,8 @@
   if (meta != NULL)
     GNUNET_CONTAINER_meta_data_destroy (meta);
   gtk_tree_row_reference_free (sr->rr);
+  if (NULL != sr->probe)
+    GNUNET_FS_probe_stop (sr->probe);
   GNUNET_free (sr);
   move_downloads_in_subtree (tm, &iter);
   GNUNET_FS_GTK_remove_treestore_subtree (GTK_TREE_STORE (tm), &iter);
@@ -2141,12 +2151,14 @@
   return GNUNET_SYSERR;
 }
 
+
 /**
  * Add a search result to the given search tab.  This function is called 
  * not only for 'normal' search results but also for directories that
  * are being opened and if the user manually enters a URI.
  *
- * @param tab search tab to extend, never NULL
+ * @param tab search tab to extend, never NULL 
+ * @param anonymity anonymity level to use for probes for this result
  * @param parent_rr reference to parent entry in search tab, NULL for normal
  *                  search results, 
  * @param uri uri to add, can be NULL for top-level entry of a directory 
opened from disk
@@ -2161,6 +2173,7 @@
  */
 struct SearchResult *
 GNUNET_GTK_add_search_result (struct SearchTab *tab, 
+                             uint32_t anonymity,
                               GtkTreeRowReference *parent_rr,
                               const struct GNUNET_FS_Uri *uri,
                               const struct GNUNET_CONTAINER_MetaData *meta,
@@ -2220,8 +2233,14 @@
 
   find_embedded_sks (meta, see_if_there_are_any_sks_uris, 
&show_ns_association);
 
-  sr = GNUNET_malloc (sizeof (struct SearchResult));
+  sr = GNUNET_new (struct SearchResult);
   sr->result = result;
+  if (NULL == result)
+    sr->probe = GNUNET_FS_probe (GNUNET_FS_GTK_get_fs_handle (),
+                                uri,
+                                meta,
+                                sr,
+                                anonymity);
   sr->tab = tab;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Allocated a search result SR=%p\n",
@@ -2384,6 +2403,7 @@
  * of the search tab accordingly.
  *
  * @param tab the search tab where the new result should be added
+ * @param anonymity anonymity level to use for probes for this result
  * @param parent parent search result (if this is a namespace update result), 
or NULL
  * @param uri URI of the search result
  * @param meta meta data for the result
@@ -2394,6 +2414,7 @@
  */
 static struct SearchResult *
 process_search_result (struct SearchTab *tab, 
+                      uint32_t anonymity,
                       struct SearchResult *parent,
                        const struct GNUNET_FS_Uri *uri,
                        const struct GNUNET_CONTAINER_MetaData *meta,
@@ -2402,7 +2423,8 @@
 {
   struct SearchResult *sr;
 
-  sr = GNUNET_GTK_add_search_result (tab, 
+  sr = GNUNET_GTK_add_search_result (tab,
+                                    anonymity,
                                      (parent != NULL) ? parent->rr : NULL,
                                     uri,
                                      meta, result, applicability_rank);
@@ -2555,12 +2577,14 @@
  * Setup a new top-level entry in the URI/orphan tab.  If necessary, create
  * the URI tab first.
  *
+ * @param anonymity anonymity level to use for probes
  * @param meta metadata for the new entry
  * @param uri URI for the new entry
  * @return the search result that was set up
  */
 struct SearchResult *
-GNUNET_GTK_add_to_uri_tab (const struct GNUNET_CONTAINER_MetaData *meta,
+GNUNET_GTK_add_to_uri_tab (uint32_t anonymity,
+                          const struct GNUNET_CONTAINER_MetaData *meta,
                            const struct GNUNET_FS_Uri *uri)
 {
   struct GNUNET_GTK_MainWindowContext *mctx = GNUNET_FS_GTK_get_main_context 
();
@@ -2579,7 +2603,9 @@
       gtk_notebook_set_current_page (mctx->notebook, page);
       break;
     }
-  return GNUNET_GTK_add_search_result (uri_tab, NULL, uri, meta, NULL, 0);
+  return GNUNET_GTK_add_search_result (uri_tab,
+                                      anonymity,
+                                      NULL, uri, meta, NULL, 0);
 }
 
 
@@ -2678,6 +2704,11 @@
   GtkTreeRowReference *prr;
 
   /**
+   * Anonymity level to use for probes in this directory.
+   */
+  uint32_t anonymity;
+  
+  /**
    * Do we need to check if the given entry already exists to
    * avoid adding it twice?  Set to YES if 'add_directory_entry'
    * is called upon directory completion (so we might see all
@@ -2757,7 +2788,10 @@
       while (TRUE == gtk_tree_model_iter_next (tm, &iter));
     }
   }
-  GNUNET_GTK_add_search_result (ade->tab, ade->prr, uri, meta, NULL,
+  GNUNET_GTK_add_search_result (ade->tab, 
+                               ade->anonymity,
+                               ade->prr, 
+                               uri, meta, NULL,
                                 0);
 }
 
@@ -2821,6 +2855,7 @@
       ade.tab = de->sr->tab;
       ade.prr = de->sr->rr;
       ade.check_duplicates = GNUNET_NO;
+      ade.anonymity = de->anonymity; 
       if (GNUNET_SYSERR ==
          GNUNET_FS_directory_list_contents ((size_t) block_size, block_data,
                                             offset, &add_directory_entry, 
&ade))
@@ -2927,6 +2962,7 @@
  * @param de existing download entry for the download, or NULL (in which case 
we create a fresh one)
  * @param pde parent download entry, or NULL
  * @param sr search result, or NULL
+ * @param anonymity anonymity level for the download
  * @param dc download context (for stopping)
  * @param uri the URI, must not be NULL
  * @param filename filename on disk
@@ -2937,7 +2973,9 @@
  */
 static struct DownloadEntry *
 setup_download (struct DownloadEntry *de, struct DownloadEntry *pde,
-                struct SearchResult *sr, struct GNUNET_FS_DownloadContext *dc,
+                struct SearchResult *sr, 
+               uint32_t anonymity,
+               struct GNUNET_FS_DownloadContext *dc,
                 const struct GNUNET_FS_Uri *uri, const char *filename,
                 const struct GNUNET_CONTAINER_MetaData *meta, uint64_t size,
                 uint64_t completed)
@@ -3023,7 +3061,8 @@
     /* Stand-alone download with no 'row'/search result affiliated
        with the download so far; create a fresh entry for this
        download in the URI tab */
-    de->sr = GNUNET_GTK_add_to_uri_tab (meta, uri);
+    de->sr = GNUNET_GTK_add_to_uri_tab (anonymity,
+                                       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))
@@ -3700,7 +3739,9 @@
     return NULL;
   case GNUNET_FS_STATUS_DOWNLOAD_START:
     return setup_download (info->value.download.cctx, 
info->value.download.pctx,
-                           info->value.download.sctx, info->value.download.dc,
+                           info->value.download.sctx, 
+                          info->value.download.anonymity,
+                          info->value.download.dc,
                            info->value.download.uri,
                            info->value.download.filename,
                            info->value.download.specifics.start.meta,
@@ -3709,7 +3750,9 @@
   case GNUNET_FS_STATUS_DOWNLOAD_RESUME:
     ret =
         setup_download (info->value.download.cctx, info->value.download.pctx,
-                        info->value.download.sctx, info->value.download.dc,
+                        info->value.download.sctx, 
+                       info->value.download.anonymity,
+                       info->value.download.dc,
                         info->value.download.uri, 
info->value.download.filename,
                         info->value.download.specifics.resume.meta,
                         info->value.download.size,
@@ -3771,7 +3814,9 @@
     return ret;
   case GNUNET_FS_STATUS_SEARCH_RESUME_RESULT:
     ret =
-        process_search_result (info->value.search.cctx, 
info->value.search.pctx,
+        process_search_result (info->value.search.cctx, 
+                              info->value.search.anonymity,
+                              info->value.search.pctx,
                                info->value.search.specifics.resume_result.uri,
                                info->value.search.specifics.resume_result.meta,
                                info->value.search.specifics.resume_result.
@@ -3794,6 +3839,7 @@
     return NULL;
   case GNUNET_FS_STATUS_SEARCH_RESULT:
     return process_search_result (info->value.search.cctx,
+                                 info->value.search.anonymity,
                                   info->value.search.pctx,
                                   info->value.search.specifics.result.uri,
                                   info->value.search.specifics.result.meta,

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.h
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.h     2013-05-30 15:20:02 UTC 
(rev 27335)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.h     2013-05-30 16:12:37 UTC 
(rev 27336)
@@ -204,6 +204,13 @@
   struct GNUNET_FS_SearchResult *result;
 
   /**
+   * Associated search result we generated for probing;
+   * thus, we need to run "GNUNET_FS_probe_cancel" on it
+   * once we are done.  Only used if 'result' is NULL.
+   */
+  struct GNUNET_FS_SearchResult *probe;
+
+  /**
    * Associated download, or NULL for none.
    */
   struct DownloadEntry *download;
@@ -214,12 +221,14 @@
  * Setup a new top-level entry in the URI/orphan tab.  If necessary, create
  * the URI tab first.
  *
+ * @param anonymity anonymity level to use for probes
  * @param meta metadata for the new entry
  * @param uri URI for the new entry
  * @return the search result that was set up
  */
 struct SearchResult *
-GNUNET_GTK_add_to_uri_tab (const struct GNUNET_CONTAINER_MetaData *meta,
+GNUNET_GTK_add_to_uri_tab (uint32_t anonymity,
+                          const struct GNUNET_CONTAINER_MetaData *meta,
                            const struct GNUNET_FS_Uri *uri);
 
 
@@ -227,6 +236,7 @@
  * Add a search result to the given search tab.
  *
  * @param tab search tab to extend, never NULL
+ * @param anonymity anonymity level to use for probes for this result
  * @param parent_rr reference to parent entry in search tab, NULL for normal
  *                  search results, 
  * @param uri uri to add, can be NULL for top-level entry of a directory 
opened from disk
@@ -241,6 +251,7 @@
  */
 struct SearchResult *
 GNUNET_GTK_add_search_result (struct SearchTab *tab, 
+                             uint32_t anonymity,
                               GtkTreeRowReference *parent_rr,
                               const struct GNUNET_FS_Uri *uri,
                               const struct GNUNET_CONTAINER_MetaData *meta,

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_open-directory.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_open-directory.c    2013-05-30 15:20:02 UTC 
(rev 27335)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_open-directory.c    2013-05-30 16:12:37 UTC 
(rev 27336)
@@ -40,6 +40,11 @@
    * Reference to the directorie's search result.
    */
   struct SearchResult *sr;
+  
+  /**
+   * Anonymity level to use for probes in the directory.
+   */
+  uint32_t anonymity;
 
 };
 
@@ -78,7 +83,8 @@
                                        EXTRACTOR_METAFORMAT_UTF8, "text/plain",
                                        acc->filename,
                                        strlen (acc->filename) + 1);
-    acc->sr = GNUNET_GTK_add_to_uri_tab (dmeta, NULL);
+    acc->sr = GNUNET_GTK_add_to_uri_tab (acc->anonymity,
+                                        dmeta, NULL);
     GNUNET_CONTAINER_meta_data_destroy (dmeta);
     return;
   }
@@ -89,6 +95,7 @@
   }
   GNUNET_assert (NULL !=
                  GNUNET_GTK_add_search_result (acc->sr->tab, 
+                                              acc->anonymity,
                                               acc->sr->rr, 
                                               uri,
                                                meta, NULL, 0));
@@ -103,7 +110,7 @@
  * @param user_data the builder of the dialog
  */
 void
-GNUNET_GTK_open_directory_dialog_response_cb (GtkDialog * dialog,
+GNUNET_GTK_open_directory_dialog_response_cb (GtkDialog *dialog,
                                               gint response_id,
                                               gpointer user_data)
 {
@@ -122,6 +129,7 @@
   g_object_unref (G_OBJECT (builder));
   acc.filename = filename;
   acc.sr = NULL;
+  acc.anonymity = 1; // FIXME, might want to add this to dialog to allow user 
to set it.
   GNUNET_FS_GTK_mmap_and_scan (filename, &add_child, &acc);
   GNUNET_free (filename);
 }




reply via email to

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