diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-02-19 13:51:25 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-02-19 13:51:25 +0000 |
commit | 0c410e9fb4fe76096d22b1baee593751790320f6 (patch) | |
tree | aec7276468d6de48a213d88193c62e6900af7a8f | |
parent | 55ab5fda919279598fb252be095a87febba87a9d (diff) | |
download | gnunet-gtk-0c410e9fb4fe76096d22b1baee593751790320f6.tar.gz gnunet-gtk-0c410e9fb4fe76096d22b1baee593751790320f6.zip |
-move meta/uri into search result instead of just having it in tree model, benefit from resulting cleaner ownership of the data to eliminate leaks and possibly some crashes
-rw-r--r-- | src/fs/gnunet-fs-gtk_event-handler.c | 201 | ||||
-rw-r--r-- | src/fs/gnunet-fs-gtk_event-handler.h | 10 |
2 files changed, 122 insertions, 89 deletions
diff --git a/src/fs/gnunet-fs-gtk_event-handler.c b/src/fs/gnunet-fs-gtk_event-handler.c index 50694879..acde3fef 100644 --- a/src/fs/gnunet-fs-gtk_event-handler.c +++ b/src/fs/gnunet-fs-gtk_event-handler.c | |||
@@ -783,14 +783,12 @@ start_download2 (int save_as, int download_directly) | |||
783 | { | 783 | { |
784 | struct GNUNET_GTK_MainWindowContext *mctx = GNUNET_FS_GTK_get_main_context (); | 784 | struct GNUNET_GTK_MainWindowContext *mctx = GNUNET_FS_GTK_get_main_context (); |
785 | struct SearchTab *st = GNUNET_FS_GTK_get_current_search_tab (); | 785 | struct SearchTab *st = GNUNET_FS_GTK_get_current_search_tab (); |
786 | struct GNUNET_CONTAINER_MetaData *meta; | ||
787 | GtkTreeView *tv; | 786 | GtkTreeView *tv; |
788 | GtkTreeSelection *sel; | 787 | GtkTreeSelection *sel; |
789 | GtkTreeModel *model; | 788 | GtkTreeModel *model; |
790 | GtkTreeIter iter; | 789 | GtkTreeIter iter; |
791 | GtkTreeIter parent_iter; | 790 | GtkTreeIter parent_iter; |
792 | struct SearchResult *sr; | 791 | struct SearchResult *sr; |
793 | struct GNUNET_FS_Uri *uri; | ||
794 | GtkTreePath *path; | 792 | GtkTreePath *path; |
795 | const gchar *filename; | 793 | const gchar *filename; |
796 | gchar *downloaddir; | 794 | gchar *downloaddir; |
@@ -803,27 +801,25 @@ start_download2 (int save_as, int download_directly) | |||
803 | sel = gtk_tree_view_get_selection (tv); | 801 | sel = gtk_tree_view_get_selection (tv); |
804 | if (!gtk_tree_selection_get_selected (sel, &model, &iter)) | 802 | if (!gtk_tree_selection_get_selected (sel, &model, &iter)) |
805 | return; | 803 | return; |
806 | |||
807 | meta = NULL; | ||
808 | |||
809 | gtk_tree_model_get (model, &iter, | 804 | gtk_tree_model_get (model, &iter, |
810 | SEARCH_TAB_MC_METADATA, &meta, | ||
811 | SEARCH_TAB_MC_URI, &uri, | ||
812 | SEARCH_TAB_MC_SEARCH_RESULT, &sr, | 805 | SEARCH_TAB_MC_SEARCH_RESULT, &sr, |
813 | -1); | 806 | -1); |
814 | 807 | if (NULL == sr) | |
815 | if (uri == NULL) | 808 | { |
809 | GNUNET_break (0); | ||
816 | return; | 810 | return; |
817 | 811 | } | |
818 | if (GNUNET_FS_uri_test_ksk (uri) || | 812 | GNUNET_assert (NULL != sr->uri); |
819 | GNUNET_FS_uri_test_sks (uri)) | 813 | if (GNUNET_FS_uri_test_ksk (sr->uri) || |
814 | GNUNET_FS_uri_test_sks (sr->uri)) | ||
820 | { | 815 | { |
821 | GNUNET_FS_GTK_handle_uri (uri, 1); | 816 | GNUNET_FS_GTK_handle_uri (sr->uri, 1); |
822 | return; | 817 | return; |
823 | } | 818 | } |
824 | 819 | ||
825 | if (!((NULL == sr->download) && (NULL != uri) && | 820 | if (!((NULL == sr->download) && (NULL != sr->uri) && |
826 | ((GNUNET_FS_uri_test_chk (uri) || GNUNET_FS_uri_test_loc (uri))))) | 821 | ((GNUNET_FS_uri_test_chk (sr->uri) || |
822 | GNUNET_FS_uri_test_loc (sr->uri))))) | ||
827 | return; | 823 | return; |
828 | 824 | ||
829 | path = gtk_tree_model_get_path (model, &iter); | 825 | path = gtk_tree_model_get_path (model, &iter); |
@@ -845,7 +841,7 @@ start_download2 (int save_as, int download_directly) | |||
845 | /* else pde remains zero */ | 841 | /* else pde remains zero */ |
846 | setup_download_list_entry (de, de->pde, sr); | 842 | setup_download_list_entry (de, de->pde, sr); |
847 | 843 | ||
848 | de->uri = GNUNET_FS_uri_dup (uri); | 844 | de->uri = GNUNET_FS_uri_dup (sr->uri); |
849 | GNUNET_asprintf (&de->filename, | 845 | GNUNET_asprintf (&de->filename, |
850 | "%s%s%s", | 846 | "%s%s%s", |
851 | downloaddir, | 847 | downloaddir, |
@@ -858,7 +854,7 @@ start_download2 (int save_as, int download_directly) | |||
858 | else | 854 | else |
859 | de->anonymity = 1; | 855 | de->anonymity = 1; |
860 | de->is_recursive = recursive; | 856 | de->is_recursive = recursive; |
861 | de->is_directory = GNUNET_FS_meta_data_test_for_directory (meta); | 857 | de->is_directory = GNUNET_FS_meta_data_test_for_directory (sr->meta); |
862 | 858 | ||
863 | if (save_as == GNUNET_NO) | 859 | if (save_as == GNUNET_NO) |
864 | GNUNET_FS_GTK_download_context_start_download (de); | 860 | GNUNET_FS_GTK_download_context_start_download (de); |
@@ -1299,9 +1295,7 @@ search_list_popup (GtkTreeModel *tm, | |||
1299 | GtkWidget *child; | 1295 | GtkWidget *child; |
1300 | GtkTreePath *path; | 1296 | GtkTreePath *path; |
1301 | struct SearchResult *sr; | 1297 | struct SearchResult *sr; |
1302 | struct GNUNET_FS_Uri *uri; | ||
1303 | struct SearchListPopupContext *spc; | 1298 | struct SearchListPopupContext *spc; |
1304 | struct GNUNET_CONTAINER_MetaData *meta; | ||
1305 | int is_directory = GNUNET_NO; | 1299 | int is_directory = GNUNET_NO; |
1306 | struct UriPopulationContext uri_pop_ctx; | 1300 | struct UriPopulationContext uri_pop_ctx; |
1307 | 1301 | ||
@@ -1311,18 +1305,22 @@ search_list_popup (GtkTreeModel *tm, | |||
1311 | spc->rr = gtk_tree_row_reference_new (tm, path); | 1305 | spc->rr = gtk_tree_row_reference_new (tm, path); |
1312 | gtk_tree_path_free (path); | 1306 | gtk_tree_path_free (path); |
1313 | gtk_tree_model_get (tm, iter, | 1307 | gtk_tree_model_get (tm, iter, |
1314 | SEARCH_TAB_MC_URI, &uri, | ||
1315 | SEARCH_TAB_MC_METADATA, &meta, | ||
1316 | SEARCH_TAB_MC_SEARCH_RESULT, &sr, | 1308 | SEARCH_TAB_MC_SEARCH_RESULT, &sr, |
1317 | -1); | 1309 | -1); |
1318 | if (meta != NULL) | 1310 | if (NULL == sr) |
1319 | is_directory = GNUNET_FS_meta_data_test_for_directory (meta); | 1311 | { |
1312 | GNUNET_break (0); | ||
1313 | return; | ||
1314 | } | ||
1315 | if (NULL != sr->meta) | ||
1316 | is_directory = GNUNET_FS_meta_data_test_for_directory (sr->meta); | ||
1320 | 1317 | ||
1321 | spc->sr = sr; | 1318 | spc->sr = sr; |
1322 | menu = GTK_MENU (gtk_menu_new ()); | 1319 | menu = GTK_MENU (gtk_menu_new ()); |
1323 | if ( (NULL == sr->download) && | 1320 | if ( (NULL == sr->download) && |
1324 | (NULL != uri) && | 1321 | (NULL != sr->uri) && |
1325 | ( (GNUNET_FS_uri_test_chk (uri) || GNUNET_FS_uri_test_loc (uri))) ) | 1322 | ( (GNUNET_FS_uri_test_chk (sr->uri) || |
1323 | GNUNET_FS_uri_test_loc (sr->uri))) ) | ||
1326 | { | 1324 | { |
1327 | /* only display download menus if there is a URI */ | 1325 | /* only display download menus if there is a URI */ |
1328 | child = gtk_menu_item_new_with_label (_("_Download")); | 1326 | child = gtk_menu_item_new_with_label (_("_Download")); |
@@ -1364,7 +1362,7 @@ search_list_popup (GtkTreeModel *tm, | |||
1364 | /* check for embedded URIs */ | 1362 | /* check for embedded URIs */ |
1365 | uri_pop_ctx.counter = 0; | 1363 | uri_pop_ctx.counter = 0; |
1366 | uri_pop_ctx.menu = menu; | 1364 | uri_pop_ctx.menu = menu; |
1367 | find_embedded_uris (meta, | 1365 | find_embedded_uris (sr->meta, |
1368 | &populate_popup_with_uri_items, | 1366 | &populate_popup_with_uri_items, |
1369 | &uri_pop_ctx); | 1367 | &uri_pop_ctx); |
1370 | if (0 < uri_pop_ctx.counter) | 1368 | if (0 < uri_pop_ctx.counter) |
@@ -1387,7 +1385,7 @@ search_list_popup (GtkTreeModel *tm, | |||
1387 | gtk_widget_show (child); | 1385 | gtk_widget_show (child); |
1388 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), child); | 1386 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), child); |
1389 | } | 1387 | } |
1390 | if (NULL != uri) | 1388 | if (NULL != sr->uri) |
1391 | { | 1389 | { |
1392 | child = gtk_menu_item_new_with_label (_("_Copy URI to Clipboard")); | 1390 | child = gtk_menu_item_new_with_label (_("_Copy URI to Clipboard")); |
1393 | g_signal_connect (child, "activate", | 1391 | g_signal_connect (child, "activate", |
@@ -1633,13 +1631,11 @@ download_lost_parent (struct DownloadEntry *de) | |||
1633 | * @param iter parent of the subtree to check | 1631 | * @param iter parent of the subtree to check |
1634 | */ | 1632 | */ |
1635 | static void | 1633 | static void |
1636 | move_downloads_in_subtree (GtkTreeModel *tm, | 1634 | remove_results_in_subtree (GtkTreeModel *tm, |
1637 | GtkTreeIter *iter) | 1635 | GtkTreeIter *iter) |
1638 | { | 1636 | { |
1639 | GtkTreeIter child; | 1637 | GtkTreeIter child; |
1640 | struct SearchResult *sr; | 1638 | struct SearchResult *sr; |
1641 | struct GNUNET_CONTAINER_MetaData *meta; | ||
1642 | struct GNUNET_FS_Uri *uri; | ||
1643 | 1639 | ||
1644 | if (gtk_tree_model_iter_children (tm, | 1640 | if (gtk_tree_model_iter_children (tm, |
1645 | &child, | 1641 | &child, |
@@ -1647,21 +1643,12 @@ move_downloads_in_subtree (GtkTreeModel *tm, | |||
1647 | { | 1643 | { |
1648 | do | 1644 | do |
1649 | { | 1645 | { |
1650 | if (NULL != sr->download) | ||
1651 | { | ||
1652 | download_lost_parent (sr->download); | ||
1653 | continue; | ||
1654 | } | ||
1655 | gtk_tree_model_get (tm, &child, | 1646 | gtk_tree_model_get (tm, &child, |
1656 | SEARCH_TAB_MC_METADATA, &meta, | ||
1657 | SEARCH_TAB_MC_URI, &uri, | ||
1658 | SEARCH_TAB_MC_SEARCH_RESULT, &sr, | 1647 | SEARCH_TAB_MC_SEARCH_RESULT, &sr, |
1659 | -1); | 1648 | -1); |
1660 | move_downloads_in_subtree (tm, &child); | 1649 | remove_results_in_subtree (tm, &child); |
1661 | GNUNET_FS_uri_destroy (uri); | ||
1662 | if (NULL != meta) | ||
1663 | GNUNET_CONTAINER_meta_data_destroy (meta); | ||
1664 | gtk_tree_row_reference_free (sr->rr); | 1650 | gtk_tree_row_reference_free (sr->rr); |
1651 | sr->rr = NULL; | ||
1665 | if (NULL != sr->probe) | 1652 | if (NULL != sr->probe) |
1666 | { | 1653 | { |
1667 | GNUNET_FS_probe_stop (sr->probe); | 1654 | GNUNET_FS_probe_stop (sr->probe); |
@@ -1670,13 +1657,29 @@ move_downloads_in_subtree (GtkTreeModel *tm, | |||
1670 | pl_tail, | 1657 | pl_tail, |
1671 | sr); | 1658 | sr); |
1672 | } | 1659 | } |
1673 | GNUNET_free (sr); | ||
1674 | /* get ready for removal of the tree */ | 1660 | /* get ready for removal of the tree */ |
1675 | gtk_tree_store_set (GTK_TREE_STORE (tm), &child, | 1661 | gtk_tree_store_set (GTK_TREE_STORE (tm), &child, |
1676 | SEARCH_TAB_MC_METADATA, NULL, | 1662 | SEARCH_TAB_MC_METADATA, NULL, |
1677 | SEARCH_TAB_MC_URI, NULL, | 1663 | SEARCH_TAB_MC_URI, NULL, |
1678 | SEARCH_TAB_MC_SEARCH_RESULT, NULL, | 1664 | SEARCH_TAB_MC_SEARCH_RESULT, NULL, |
1679 | -1); | 1665 | -1); |
1666 | if (NULL != sr->download) | ||
1667 | { | ||
1668 | /* 'sr' still referenced from download; do not free */ | ||
1669 | sr->tab = NULL; | ||
1670 | continue; | ||
1671 | } | ||
1672 | if (NULL != sr->uri) | ||
1673 | { | ||
1674 | GNUNET_FS_uri_destroy (sr->uri); | ||
1675 | sr->uri = NULL; | ||
1676 | } | ||
1677 | if (NULL != sr->meta) | ||
1678 | { | ||
1679 | GNUNET_CONTAINER_meta_data_destroy (sr->meta); | ||
1680 | sr->meta = NULL; | ||
1681 | } | ||
1682 | GNUNET_free (sr); | ||
1680 | } | 1683 | } |
1681 | while (gtk_tree_model_iter_next (tm, &child)); | 1684 | while (gtk_tree_model_iter_next (tm, &child)); |
1682 | } | 1685 | } |
@@ -1697,39 +1700,37 @@ free_search_result (struct SearchResult *sr) | |||
1697 | GtkTreePath *tp; | 1700 | GtkTreePath *tp; |
1698 | GtkTreeModel *tm; | 1701 | GtkTreeModel *tm; |
1699 | GtkTreeIter iter; | 1702 | GtkTreeIter iter; |
1700 | struct GNUNET_FS_Uri *uri; | ||
1701 | struct GNUNET_CONTAINER_MetaData *meta; | ||
1702 | 1703 | ||
1703 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1704 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1704 | "Freeing a search result SR=%p\n", | 1705 | "Freeing a search result SR=%p\n", |
1705 | sr); | 1706 | sr); |
1706 | if ( (NULL == sr) || | 1707 | if (NULL == sr) |
1707 | (NULL == sr->rr) || | ||
1708 | (NULL == (tm = gtk_tree_row_reference_get_model (sr->rr))) || | ||
1709 | (NULL == (tp = gtk_tree_row_reference_get_path (sr->rr))) ) | ||
1710 | { | 1708 | { |
1711 | GNUNET_break (0); | 1709 | GNUNET_break (0); |
1712 | return; | 1710 | return; |
1713 | } | 1711 | } |
1714 | if (! gtk_tree_model_get_iter (tm, &iter, tp)) | 1712 | if ( (NULL != sr->rr) && |
1713 | (NULL != (tm = gtk_tree_row_reference_get_model (sr->rr))) && | ||
1714 | (NULL != (tp = gtk_tree_row_reference_get_path (sr->rr))) ) | ||
1715 | { | 1715 | { |
1716 | GNUNET_break (0); | 1716 | if (! gtk_tree_model_get_iter (tm, &iter, tp)) |
1717 | { | ||
1718 | GNUNET_break (0); | ||
1719 | gtk_tree_path_free (tp); | ||
1720 | return; | ||
1721 | } | ||
1722 | /* get ready for later removal of the tree */ | ||
1723 | gtk_tree_store_set (GTK_TREE_STORE (tm), &iter, | ||
1724 | SEARCH_TAB_MC_METADATA, NULL, | ||
1725 | SEARCH_TAB_MC_URI, NULL, | ||
1726 | SEARCH_TAB_MC_SEARCH_RESULT, NULL, | ||
1727 | -1); | ||
1717 | gtk_tree_path_free (tp); | 1728 | gtk_tree_path_free (tp); |
1718 | return; | ||
1719 | } | ||
1720 | gtk_tree_path_free (tp); | ||
1721 | gtk_tree_model_get (tm, &iter, | ||
1722 | SEARCH_TAB_MC_METADATA, &meta, | ||
1723 | SEARCH_TAB_MC_URI, &uri, | ||
1724 | -1); | ||
1725 | if (NULL != uri) | ||
1726 | GNUNET_FS_uri_destroy (uri); | ||
1727 | if (NULL != meta) | ||
1728 | GNUNET_CONTAINER_meta_data_destroy (meta); | ||
1729 | if (NULL != sr->rr) | ||
1730 | { | ||
1731 | gtk_tree_row_reference_free (sr->rr); | 1729 | gtk_tree_row_reference_free (sr->rr); |
1732 | sr->rr = NULL; | 1730 | sr->rr = NULL; |
1731 | remove_results_in_subtree (tm, &iter); | ||
1732 | GNUNET_FS_GTK_remove_treestore_subtree (GTK_TREE_STORE (tm), | ||
1733 | &iter); | ||
1733 | } | 1734 | } |
1734 | if (NULL != sr->probe) | 1735 | if (NULL != sr->probe) |
1735 | { | 1736 | { |
@@ -1739,9 +1740,23 @@ free_search_result (struct SearchResult *sr) | |||
1739 | pl_tail, | 1740 | pl_tail, |
1740 | sr); | 1741 | sr); |
1741 | } | 1742 | } |
1743 | if (NULL != sr->download) | ||
1744 | { | ||
1745 | /* 'sr' still referenced from download; do not free */ | ||
1746 | sr->tab = NULL; | ||
1747 | return; | ||
1748 | } | ||
1749 | if (NULL != sr->uri) | ||
1750 | { | ||
1751 | GNUNET_FS_uri_destroy (sr->uri); | ||
1752 | sr->uri = NULL; | ||
1753 | } | ||
1754 | if (NULL != sr->meta) | ||
1755 | { | ||
1756 | GNUNET_CONTAINER_meta_data_destroy (sr->meta); | ||
1757 | sr->meta = NULL; | ||
1758 | } | ||
1742 | GNUNET_free (sr); | 1759 | GNUNET_free (sr); |
1743 | move_downloads_in_subtree (tm, &iter); | ||
1744 | GNUNET_FS_GTK_remove_treestore_subtree (GTK_TREE_STORE (tm), &iter); | ||
1745 | } | 1760 | } |
1746 | 1761 | ||
1747 | 1762 | ||
@@ -1759,11 +1774,9 @@ GNUNET_FS_GTK_search_treeview_cursor_changed (GtkTreeView *tv, | |||
1759 | GtkTreeSelection *sel; | 1774 | GtkTreeSelection *sel; |
1760 | GtkTreeModel *model; | 1775 | GtkTreeModel *model; |
1761 | GtkTreeIter iter; | 1776 | GtkTreeIter iter; |
1762 | struct GNUNET_CONTAINER_MetaData *meta; | ||
1763 | GdkPixbuf *pixbuf; | 1777 | GdkPixbuf *pixbuf; |
1764 | GtkTreePath *selpath; | 1778 | GtkTreePath *selpath; |
1765 | struct SearchResult *sr; | 1779 | struct SearchResult *sr; |
1766 | struct GNUNET_FS_Uri *uri; | ||
1767 | struct GNUNET_GTK_MainWindowContext *mctx = GNUNET_FS_GTK_get_main_context (); | 1780 | struct GNUNET_GTK_MainWindowContext *mctx = GNUNET_FS_GTK_get_main_context (); |
1768 | 1781 | ||
1769 | gtk_list_store_clear (mctx->md_liststore); | 1782 | gtk_list_store_clear (mctx->md_liststore); |
@@ -1778,21 +1791,21 @@ GNUNET_FS_GTK_search_treeview_cursor_changed (GtkTreeView *tv, | |||
1778 | current_selected_search_result = NULL; | 1791 | current_selected_search_result = NULL; |
1779 | return; | 1792 | return; |
1780 | } | 1793 | } |
1781 | meta = NULL; | ||
1782 | pixbuf = NULL; | 1794 | pixbuf = NULL; |
1783 | |||
1784 | gtk_tree_model_get (model, &iter, | 1795 | gtk_tree_model_get (model, &iter, |
1785 | SEARCH_TAB_MC_METADATA, &meta, | ||
1786 | SEARCH_TAB_MC_PREVIEW, &pixbuf, | 1796 | SEARCH_TAB_MC_PREVIEW, &pixbuf, |
1787 | SEARCH_TAB_MC_URI, &uri, | ||
1788 | SEARCH_TAB_MC_SEARCH_RESULT, &sr, | 1797 | SEARCH_TAB_MC_SEARCH_RESULT, &sr, |
1789 | -1); | 1798 | -1); |
1790 | 1799 | if (NULL == sr) | |
1800 | return; | ||
1791 | selpath = gtk_tree_model_get_path (model, &iter); | 1801 | selpath = gtk_tree_model_get_path (model, &iter); |
1792 | if (current_selected_search_result == NULL || gtk_tree_path_compare (selpath, current_selected_search_result) != 0) | 1802 | if ( (NULL == current_selected_search_result) || |
1803 | (0 != gtk_tree_path_compare (selpath, current_selected_search_result)) ) | ||
1793 | { | 1804 | { |
1794 | if ((NULL == sr->download) && (NULL != uri) && | 1805 | if ( (NULL == sr->download) && |
1795 | ((GNUNET_FS_uri_test_chk (uri) || GNUNET_FS_uri_test_loc (uri)))) | 1806 | (NULL != sr->uri) && |
1807 | ( (GNUNET_FS_uri_test_chk (sr->uri) || | ||
1808 | GNUNET_FS_uri_test_loc (sr->uri)) ) ) | ||
1796 | { | 1809 | { |
1797 | char *download_directory; | 1810 | char *download_directory; |
1798 | char *filename; | 1811 | char *filename; |
@@ -1803,9 +1816,10 @@ GNUNET_FS_GTK_search_treeview_cursor_changed (GtkTreeView *tv, | |||
1803 | anonymity = -1; | 1816 | anonymity = -1; |
1804 | download_directory = NULL; | 1817 | download_directory = NULL; |
1805 | filename = get_suggested_filename_anonymity2 (model, &iter, | 1818 | filename = get_suggested_filename_anonymity2 (model, &iter, |
1806 | &download_directory, &anonymity); | 1819 | &download_directory, |
1820 | &anonymity); | ||
1807 | 1821 | ||
1808 | is_directory = GNUNET_FS_meta_data_test_for_directory (meta); | 1822 | is_directory = GNUNET_FS_meta_data_test_for_directory (sr->meta); |
1809 | gtk_widget_set_sensitive (GTK_WIDGET (mctx->download_recursive_checkbutton), is_directory); | 1823 | gtk_widget_set_sensitive (GTK_WIDGET (mctx->download_recursive_checkbutton), is_directory); |
1810 | 1824 | ||
1811 | /* TODO: make this configurable */ | 1825 | /* TODO: make this configurable */ |
@@ -1839,8 +1853,8 @@ GNUNET_FS_GTK_search_treeview_cursor_changed (GtkTreeView *tv, | |||
1839 | else | 1853 | else |
1840 | gtk_image_clear (mctx->preview_image); | 1854 | gtk_image_clear (mctx->preview_image); |
1841 | 1855 | ||
1842 | if (NULL != meta) | 1856 | if (NULL != sr->meta) |
1843 | GNUNET_CONTAINER_meta_data_iterate (meta, | 1857 | GNUNET_CONTAINER_meta_data_iterate (sr->meta, |
1844 | &GNUNET_FS_GTK_add_meta_data_to_list_store, | 1858 | &GNUNET_FS_GTK_add_meta_data_to_list_store, |
1845 | mctx->md_liststore); | 1859 | mctx->md_liststore); |
1846 | } | 1860 | } |
@@ -1979,6 +1993,8 @@ stop_downloads_in_subtree (GtkTreeModel *tm, | |||
1979 | gtk_tree_model_get (tm, &child, | 1993 | gtk_tree_model_get (tm, &child, |
1980 | SEARCH_TAB_MC_SEARCH_RESULT, &sr, | 1994 | SEARCH_TAB_MC_SEARCH_RESULT, &sr, |
1981 | -1); | 1995 | -1); |
1996 | if (NULL == sr) | ||
1997 | continue; | ||
1982 | if ( (NULL != sr->download) && | 1998 | if ( (NULL != sr->download) && |
1983 | (GNUNET_YES == sr->download->is_done) ) | 1999 | (GNUNET_YES == sr->download->is_done) ) |
1984 | { | 2000 | { |
@@ -2022,6 +2038,11 @@ GNUNET_FS_GTK_downloads_clear_button_clicked (GtkButton * button, | |||
2022 | gtk_tree_model_get (tm, &iter, | 2038 | gtk_tree_model_get (tm, &iter, |
2023 | SEARCH_TAB_MC_SEARCH_RESULT, &sr, | 2039 | SEARCH_TAB_MC_SEARCH_RESULT, &sr, |
2024 | -1); | 2040 | -1); |
2041 | if (NULL == sr) | ||
2042 | { | ||
2043 | GNUNET_break (0); | ||
2044 | continue; | ||
2045 | } | ||
2025 | if ( (NULL != sr->download) && | 2046 | if ( (NULL != sr->download) && |
2026 | (GNUNET_YES == sr->download->is_done) ) | 2047 | (GNUNET_YES == sr->download->is_done) ) |
2027 | { | 2048 | { |
@@ -2100,7 +2121,6 @@ update_search_result (struct SearchResult *sr, | |||
2100 | struct GNUNET_TIME_Relative probe_time) | 2121 | struct GNUNET_TIME_Relative probe_time) |
2101 | { | 2122 | { |
2102 | GtkTreeIter iter; | 2123 | GtkTreeIter iter; |
2103 | struct GNUNET_CONTAINER_MetaData *ometa; | ||
2104 | GtkTreeView *tv; | 2124 | GtkTreeView *tv; |
2105 | GtkTreePath *tp; | 2125 | GtkTreePath *tp; |
2106 | GtkTreeStore *ts; | 2126 | GtkTreeStore *ts; |
@@ -2129,17 +2149,18 @@ update_search_result (struct SearchResult *sr, | |||
2129 | desc = GNUNET_FS_GTK_get_description_from_metadata (meta, &desc_is_a_dup); | 2149 | desc = GNUNET_FS_GTK_get_description_from_metadata (meta, &desc_is_a_dup); |
2130 | mime = get_mimetype_from_metadata (meta); | 2150 | mime = get_mimetype_from_metadata (meta); |
2131 | pixbuf = GNUNET_FS_GTK_get_thumbnail_from_meta_data (meta); | 2151 | pixbuf = GNUNET_FS_GTK_get_thumbnail_from_meta_data (meta); |
2132 | gtk_tree_model_get (tm, &iter, | 2152 | if (NULL != sr->meta) |
2133 | SEARCH_TAB_MC_METADATA, &ometa, | 2153 | { |
2134 | -1); | 2154 | GNUNET_CONTAINER_meta_data_destroy (sr->meta); |
2135 | if (NULL != ometa) | 2155 | sr->meta = NULL; |
2136 | GNUNET_CONTAINER_meta_data_destroy (ometa); | 2156 | } |
2157 | sr->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); | ||
2137 | if (availability_certainty > 0) | 2158 | if (availability_certainty > 0) |
2138 | percent_avail = 50 + (gint) (availability_rank * 50.0 / availability_certainty); | 2159 | percent_avail = 50 + (gint) (availability_rank * 50.0 / availability_certainty); |
2139 | else | 2160 | else |
2140 | percent_avail = 50; | 2161 | percent_avail = 50; |
2141 | gtk_tree_store_set (ts, &iter, | 2162 | gtk_tree_store_set (ts, &iter, |
2142 | SEARCH_TAB_MC_METADATA, GNUNET_CONTAINER_meta_data_duplicate (meta), | 2163 | SEARCH_TAB_MC_METADATA, sr->meta, |
2143 | SEARCH_TAB_MC_PREVIEW, pixbuf, | 2164 | SEARCH_TAB_MC_PREVIEW, pixbuf, |
2144 | SEARCH_TAB_MC_PERCENT_AVAILABILITY, (guint) percent_avail, | 2165 | SEARCH_TAB_MC_PERCENT_AVAILABILITY, (guint) percent_avail, |
2145 | SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, (0 == availability_certainty) ? (gint) (probe_time.rel_value_us / GNUNET_FS_PROBE_UPDATE_FREQUENCY.rel_value_us) : -1, | 2166 | SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, (0 == availability_certainty) ? (gint) (probe_time.rel_value_us / GNUNET_FS_PROBE_UPDATE_FREQUENCY.rel_value_us) : -1, |
@@ -2153,7 +2174,7 @@ update_search_result (struct SearchResult *sr, | |||
2153 | { | 2174 | { |
2154 | get_download_list_entry (sr->download, &iter); | 2175 | get_download_list_entry (sr->download, &iter); |
2155 | gtk_tree_store_set (downloads_treestore, &iter, | 2176 | gtk_tree_store_set (downloads_treestore, &iter, |
2156 | SEARCH_TAB_MC_METADATA, GNUNET_CONTAINER_meta_data_duplicate (meta), | 2177 | SEARCH_TAB_MC_METADATA, sr->meta, |
2157 | SEARCH_TAB_MC_PREVIEW, pixbuf, | 2178 | SEARCH_TAB_MC_PREVIEW, pixbuf, |
2158 | SEARCH_TAB_MC_PERCENT_AVAILABILITY, (guint) percent_avail, | 2179 | SEARCH_TAB_MC_PERCENT_AVAILABILITY, (guint) percent_avail, |
2159 | SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, (0 == availability_certainty) ? (gint) (probe_time.rel_value_us / GNUNET_FS_PROBE_UPDATE_FREQUENCY.rel_value_us) : -1, | 2180 | SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, (0 == availability_certainty) ? (gint) (probe_time.rel_value_us / GNUNET_FS_PROBE_UPDATE_FREQUENCY.rel_value_us) : -1, |
@@ -2329,9 +2350,11 @@ GNUNET_GTK_add_search_result (struct SearchTab *tab, | |||
2329 | else | 2350 | else |
2330 | ts = downloads_treestore; | 2351 | ts = downloads_treestore; |
2331 | } | 2352 | } |
2353 | sr->uri = (uri == NULL) ? NULL : GNUNET_FS_uri_dup (uri); | ||
2354 | sr->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); | ||
2332 | gtk_tree_store_insert_with_values (ts, &iter, pitr, G_MAXINT, | 2355 | gtk_tree_store_insert_with_values (ts, &iter, pitr, G_MAXINT, |
2333 | SEARCH_TAB_MC_METADATA, GNUNET_CONTAINER_meta_data_duplicate (meta), | 2356 | SEARCH_TAB_MC_METADATA, sr->meta, |
2334 | SEARCH_TAB_MC_URI, (uri == NULL) ? NULL : GNUNET_FS_uri_dup (uri), | 2357 | SEARCH_TAB_MC_URI, sr->uri, |
2335 | SEARCH_TAB_MC_FILESIZE, fsize, | 2358 | SEARCH_TAB_MC_FILESIZE, fsize, |
2336 | SEARCH_TAB_MC_PREVIEW, pixbuf, | 2359 | SEARCH_TAB_MC_PREVIEW, pixbuf, |
2337 | SEARCH_TAB_MC_PERCENT_PROGRESS, 0, | 2360 | SEARCH_TAB_MC_PERCENT_PROGRESS, 0, |
diff --git a/src/fs/gnunet-fs-gtk_event-handler.h b/src/fs/gnunet-fs-gtk_event-handler.h index 2d120477..9261930f 100644 --- a/src/fs/gnunet-fs-gtk_event-handler.h +++ b/src/fs/gnunet-fs-gtk_event-handler.h | |||
@@ -207,6 +207,16 @@ struct SearchResult | |||
207 | struct SearchResult *prev; | 207 | struct SearchResult *prev; |
208 | 208 | ||
209 | /** | 209 | /** |
210 | * URI corresponding to the result. | ||
211 | */ | ||
212 | struct GNUNET_FS_Uri *uri; | ||
213 | |||
214 | /** | ||
215 | * Meta data associated with the result. | ||
216 | */ | ||
217 | struct GNUNET_CONTAINER_MetaData *meta; | ||
218 | |||
219 | /** | ||
210 | * Where in the tab is this result? | 220 | * Where in the tab is this result? |
211 | */ | 221 | */ |
212 | GtkTreeRowReference *rr; | 222 | GtkTreeRowReference *rr; |