diff options
Diffstat (limited to 'src/fs/gnunet-fs-gtk_event-handler.c')
-rw-r--r-- | src/fs/gnunet-fs-gtk_event-handler.c | 514 |
1 files changed, 309 insertions, 205 deletions
diff --git a/src/fs/gnunet-fs-gtk_event-handler.c b/src/fs/gnunet-fs-gtk_event-handler.c index ced65438..376e6a16 100644 --- a/src/fs/gnunet-fs-gtk_event-handler.c +++ b/src/fs/gnunet-fs-gtk_event-handler.c | |||
@@ -829,6 +829,266 @@ close_search_tab (struct SearchTab *tab) | |||
829 | 829 | ||
830 | 830 | ||
831 | /** | 831 | /** |
832 | * Copy all of the children of 'src_iter' from the 'src_model' to | ||
833 | * become children of 'dst_iter' in the 'dst_model'. The models are | ||
834 | * both 'GNUNET_GTK_file_sharing_result_tree_store' models. | ||
835 | * | ||
836 | * Note that we also need to update the 'struct SearchResult' | ||
837 | * and (if it exists) the respective 'struct DownloadEntry' | ||
838 | * to refer to the new model. | ||
839 | * | ||
840 | * @param src_model source model | ||
841 | * @param src_iter parent of the nodes to move | ||
842 | * @param dst_tab destination tab | ||
843 | * @param dst_iter new parent of the entries we are moving | ||
844 | */ | ||
845 | static void | ||
846 | copy_children (GtkTreeModel * src_model, GtkTreeIter * src_iter, | ||
847 | struct SearchTab *dst_tab, | ||
848 | GtkTreeIter * dst_iter) | ||
849 | { | ||
850 | GtkTreeIter src_child; | ||
851 | GtkTreeIter dst_child; | ||
852 | GtkTreePath *path; | ||
853 | struct GNUNET_CONTAINER_MetaData *meta; | ||
854 | struct GNUNET_FS_Uri *uri; | ||
855 | guint64 filesize, completed; | ||
856 | GdkPixbuf *preview; | ||
857 | guint percent_progress; | ||
858 | guint percent_availability; | ||
859 | gchar *filename; | ||
860 | gchar *uri_as_string; | ||
861 | gchar *status_colour; | ||
862 | struct SearchResult *search_result_old; | ||
863 | struct SearchResult *search_result_new; | ||
864 | gchar *mimetype; | ||
865 | guint applicability_rank; | ||
866 | guint availability_certainty; | ||
867 | gint availability_rank; | ||
868 | gchar *downloaded_filename; | ||
869 | gint downloaded_anonymity; | ||
870 | |||
871 | if (! gtk_tree_model_iter_children (src_model, &src_child, src_iter)) | ||
872 | return; | ||
873 | do | ||
874 | { | ||
875 | gtk_tree_model_get (src_model, &src_child, | ||
876 | 0, &meta, | ||
877 | 1, &uri, | ||
878 | 2, &filesize, | ||
879 | 3, &preview, | ||
880 | 4, &percent_progress, | ||
881 | 5, &percent_availability, | ||
882 | 6, &filename, | ||
883 | 7, &uri_as_string, | ||
884 | 8, &status_colour, | ||
885 | 9, &search_result_old, | ||
886 | 10, &mimetype, | ||
887 | 11, &applicability_rank, | ||
888 | 12, &availability_certainty, | ||
889 | 13, &availability_rank, | ||
890 | 14, &completed, | ||
891 | 15, &downloaded_filename, | ||
892 | 16, &downloaded_anonymity, | ||
893 | -1); | ||
894 | search_result_new = GNUNET_malloc (sizeof (struct SearchResult)); | ||
895 | search_result_new->tab = dst_tab; | ||
896 | search_result_new->download = search_result_old->download; | ||
897 | if (NULL != search_result_old->download) | ||
898 | { | ||
899 | search_result_old->download = NULL; | ||
900 | search_result_new->download->sr = search_result_new; | ||
901 | } | ||
902 | gtk_tree_store_insert_with_values (dst_tab->ts, &dst_child, | ||
903 | dst_iter, G_MAXINT, | ||
904 | 0, GNUNET_CONTAINER_meta_data_duplicate (meta), | ||
905 | 1, GNUNET_FS_uri_dup (uri), | ||
906 | 2, filesize, | ||
907 | 3, preview, | ||
908 | 4, percent_progress, | ||
909 | 5, percent_availability, | ||
910 | 6, filename, | ||
911 | 7, uri_as_string, | ||
912 | 8, status_colour, | ||
913 | 9, search_result_new, | ||
914 | 10, mimetype, | ||
915 | 11, applicability_rank, | ||
916 | 12, availability_certainty, | ||
917 | 13, availability_rank, | ||
918 | 14, completed, | ||
919 | 15, downloaded_filename, | ||
920 | 16, downloaded_anonymity, | ||
921 | -1); | ||
922 | g_free (filename); | ||
923 | g_free (downloaded_filename); | ||
924 | g_free (uri_as_string); | ||
925 | g_free (status_colour); | ||
926 | g_free (mimetype); | ||
927 | if (preview != NULL) | ||
928 | g_object_unref (preview); | ||
929 | |||
930 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (dst_tab->ts), &dst_child); | ||
931 | search_result_new->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (dst_tab->ts), path); | ||
932 | gtk_tree_path_free (path); | ||
933 | |||
934 | copy_children (src_model, &src_child, dst_tab, &dst_child); | ||
935 | } | ||
936 | while (gtk_tree_model_iter_next (src_model, &src_child)); | ||
937 | } | ||
938 | |||
939 | |||
940 | /** | ||
941 | * Handle the case where an active download lost its | ||
942 | * search parent by moving it to the URI tab. | ||
943 | * | ||
944 | * @param de download where the parent (i.e. search) was lost | ||
945 | */ | ||
946 | static void | ||
947 | download_lost_parent (struct DownloadEntry *de) | ||
948 | { | ||
949 | GtkTreeIter iter; | ||
950 | GtkTreePath *path; | ||
951 | GtkTreeModel *tm_old; | ||
952 | GtkTreeIter iter_old; | ||
953 | GtkTreeModel *model; | ||
954 | struct GNUNET_CONTAINER_MetaData *meta; | ||
955 | struct GNUNET_FS_Uri *uri; | ||
956 | guint64 completed; | ||
957 | guint percent_progress; | ||
958 | guint percent_availability; | ||
959 | gchar *filename; | ||
960 | gchar *status_colour; | ||
961 | guint applicability_rank; | ||
962 | guint availability_certainty; | ||
963 | gint availability_rank; | ||
964 | gchar *downloaded_filename; | ||
965 | gint downloaded_anonymity; | ||
966 | |||
967 | /* find the 'old' root */ | ||
968 | tm_old = GTK_TREE_MODEL (de->sr->tab->ts); | ||
969 | path = gtk_tree_row_reference_get_path (de->sr->rr); | ||
970 | if (! gtk_tree_model_get_iter (tm_old, &iter_old, path)) | ||
971 | { | ||
972 | GNUNET_break (0); | ||
973 | gtk_tree_path_free (path); | ||
974 | return; | ||
975 | } | ||
976 | gtk_tree_path_free (path); | ||
977 | gtk_tree_model_get (tm_old, &iter_old, | ||
978 | 0, &meta, | ||
979 | 1, &uri, | ||
980 | 4, &percent_progress, | ||
981 | 5, &percent_availability, | ||
982 | 6, &filename, | ||
983 | 8, &status_colour, | ||
984 | 11, &applicability_rank, | ||
985 | 12, &availability_certainty, | ||
986 | 13, &availability_rank, | ||
987 | 14, &completed, | ||
988 | 15, &downloaded_filename, | ||
989 | 16, &downloaded_anonymity, | ||
990 | -1); | ||
991 | GNUNET_assert (GNUNET_YES == GNUNET_FS_uri_test_equal (uri, de->uri)); | ||
992 | GNUNET_assert (de->sr->download == de); | ||
993 | de->sr->download = NULL; | ||
994 | |||
995 | /* create the target root */ | ||
996 | de->sr = GNUNET_GTK_add_to_uri_tab (meta, uri); | ||
997 | de->sr->download = de; | ||
998 | |||
999 | /* get positions of the 'new' root */ | ||
1000 | model = GTK_TREE_MODEL (de->sr->tab->ts); | ||
1001 | path = gtk_tree_row_reference_get_path (de->sr->rr); | ||
1002 | if (! gtk_tree_model_get_iter (model, &iter, path)) | ||
1003 | { | ||
1004 | GNUNET_break (0); | ||
1005 | gtk_tree_path_free (path); | ||
1006 | return; | ||
1007 | } | ||
1008 | gtk_tree_path_free (path); | ||
1009 | |||
1010 | gtk_tree_store_set (de->sr->tab->ts, &iter, | ||
1011 | 4, percent_progress, | ||
1012 | 5, percent_availability, | ||
1013 | 6, filename, | ||
1014 | 8, status_colour, | ||
1015 | 11, applicability_rank, | ||
1016 | 12, availability_certainty, | ||
1017 | 13, availability_rank, | ||
1018 | 14, completed, | ||
1019 | 15, downloaded_filename, | ||
1020 | 16, downloaded_anonymity, | ||
1021 | -1); | ||
1022 | g_free (filename); | ||
1023 | g_free (downloaded_filename); | ||
1024 | g_free (status_colour); | ||
1025 | |||
1026 | /* finally, move all children over as well */ | ||
1027 | copy_children (tm_old, &iter_old, de->sr->tab, &iter); | ||
1028 | } | ||
1029 | |||
1030 | |||
1031 | /** | ||
1032 | * Moves all of the downloads in the given subtree to the URI tab | ||
1033 | * and cleans up the state of the other entries from the view. | ||
1034 | * The subtree itself will be removed from the tree view later. | ||
1035 | * | ||
1036 | * @param tm tree model | ||
1037 | * @param iter parent of the subtree to check | ||
1038 | */ | ||
1039 | static void | ||
1040 | move_downloads_in_subtree (GtkTreeModel *tm, | ||
1041 | GtkTreeIter *iter) | ||
1042 | { | ||
1043 | GtkTreeIter child; | ||
1044 | struct SearchResult *sr; | ||
1045 | struct GNUNET_CONTAINER_MetaData *meta; | ||
1046 | struct GNUNET_FS_Uri *uri; | ||
1047 | |||
1048 | if (gtk_tree_model_iter_children (tm, | ||
1049 | iter, | ||
1050 | &child)) | ||
1051 | { | ||
1052 | do | ||
1053 | { | ||
1054 | gtk_tree_model_get (tm, &child, | ||
1055 | 0, &meta, | ||
1056 | 1, &uri, | ||
1057 | 9, &sr, | ||
1058 | -1); | ||
1059 | if (NULL != sr->download) | ||
1060 | { | ||
1061 | if (sr->download->is_done == GNUNET_YES) | ||
1062 | { | ||
1063 | /* got a finished download, stop it */ | ||
1064 | GNUNET_FS_download_stop (sr->download->dc, GNUNET_YES); | ||
1065 | } | ||
1066 | else | ||
1067 | { | ||
1068 | /* got an active download, move to URI tab! */ | ||
1069 | download_lost_parent (sr->download); | ||
1070 | } | ||
1071 | } | ||
1072 | GNUNET_assert (NULL == sr->download); | ||
1073 | move_downloads_in_subtree (tm, &child); | ||
1074 | GNUNET_FS_uri_destroy (uri); | ||
1075 | if (NULL != meta) | ||
1076 | GNUNET_CONTAINER_meta_data_destroy (meta); | ||
1077 | gtk_tree_row_reference_free (sr->rr); | ||
1078 | GNUNET_free (sr); | ||
1079 | /* get ready for removal of the tree */ | ||
1080 | gtk_tree_store_set (GTK_TREE_STORE (tm), &child, | ||
1081 | 0, NULL, | ||
1082 | 1, NULL, | ||
1083 | 9, NULL, | ||
1084 | -1); | ||
1085 | } | ||
1086 | while (TRUE == gtk_tree_model_iter_next (tm, &child)); | ||
1087 | } | ||
1088 | } | ||
1089 | |||
1090 | |||
1091 | /** | ||
832 | * Free a particular search result and remove the respective | 1092 | * Free a particular search result and remove the respective |
833 | * entries from the respective tree store. This function | 1093 | * entries from the respective tree store. This function |
834 | * is called when a search is stopped to clean up the state | 1094 | * is called when a search is stopped to clean up the state |
@@ -869,8 +1129,9 @@ free_search_result (struct SearchResult *sr) | |||
869 | if (meta != NULL) | 1129 | if (meta != NULL) |
870 | GNUNET_CONTAINER_meta_data_destroy (meta); | 1130 | GNUNET_CONTAINER_meta_data_destroy (meta); |
871 | gtk_tree_row_reference_free (sr->rr); | 1131 | gtk_tree_row_reference_free (sr->rr); |
872 | (void) gtk_tree_store_remove (GTK_TREE_STORE (tm), &iter); | ||
873 | GNUNET_free (sr); | 1132 | GNUNET_free (sr); |
1133 | move_downloads_in_subtree (tm, &iter); | ||
1134 | GNUNET_FS_GTK_remove_treestore_subtree (GTK_TREE_STORE (tm), &iter); | ||
874 | } | 1135 | } |
875 | 1136 | ||
876 | 1137 | ||
@@ -1036,6 +1297,47 @@ GNUNET_FS_GTK_search_result_play_button_clicked (GtkButton * button, gpointer us | |||
1036 | 1297 | ||
1037 | 1298 | ||
1038 | /** | 1299 | /** |
1300 | * Stops all of the downloads in the given subtree. | ||
1301 | * | ||
1302 | * @param tm tree model | ||
1303 | * @param iter parent of the subtree to check | ||
1304 | * @return GNUNET_YES if there are no active downloads left in the subtree | ||
1305 | */ | ||
1306 | static int | ||
1307 | stop_downloads_in_subtree (GtkTreeModel *tm, | ||
1308 | GtkTreeIter *iter) | ||
1309 | { | ||
1310 | GtkTreeIter child; | ||
1311 | struct SearchResult *sr; | ||
1312 | int ret; | ||
1313 | |||
1314 | ret = GNUNET_YES; | ||
1315 | if (gtk_tree_model_iter_children (tm, | ||
1316 | iter, | ||
1317 | &child)) | ||
1318 | { | ||
1319 | do | ||
1320 | { | ||
1321 | gtk_tree_model_get (tm, &child, 9, &sr, -1); | ||
1322 | if ( (NULL != sr->download) && | ||
1323 | (sr->download->is_done == GNUNET_YES) ) | ||
1324 | { | ||
1325 | /* got a finished download, stop it */ | ||
1326 | GNUNET_FS_download_stop (sr->download->dc, GNUNET_YES); | ||
1327 | } | ||
1328 | if ( (NULL != sr->download) || | ||
1329 | (NULL != sr->result) ) | ||
1330 | ret = GNUNET_NO; | ||
1331 | if (GNUNET_YES != stop_downloads_in_subtree (tm, &child)) | ||
1332 | ret = GNUNET_NO; | ||
1333 | } | ||
1334 | while (TRUE == gtk_tree_model_iter_next (tm, &child)); | ||
1335 | } | ||
1336 | return ret; | ||
1337 | } | ||
1338 | |||
1339 | |||
1340 | /** | ||
1039 | * User clicked on the 'clean' button of a search tab. | 1341 | * User clicked on the 'clean' button of a search tab. |
1040 | * Stop completed downloads (or those that failed). Should | 1342 | * Stop completed downloads (or those that failed). Should |
1041 | * iterate over the underlying tree store and stop all | 1343 | * iterate over the underlying tree store and stop all |
@@ -1057,10 +1359,8 @@ GNUNET_FS_GTK_search_result_clear_button_clicked (GtkButton * button, gpointer u | |||
1057 | tm = GTK_TREE_MODEL (tab->ts); | 1359 | tm = GTK_TREE_MODEL (tab->ts); |
1058 | if (TRUE != gtk_tree_model_get_iter_first (tm, &iter)) | 1360 | if (TRUE != gtk_tree_model_get_iter_first (tm, &iter)) |
1059 | return; | 1361 | return; |
1060 | /* FIXME-BUG: this is a tree, what about cleaning up | ||
1061 | of the children? */ | ||
1062 | do | 1362 | do |
1063 | { | 1363 | { |
1064 | gtk_tree_model_get (tm, &iter, 9, &sr, -1); | 1364 | gtk_tree_model_get (tm, &iter, 9, &sr, -1); |
1065 | if ( (sr->download != NULL) && | 1365 | if ( (sr->download != NULL) && |
1066 | (sr->download->is_done == GNUNET_YES) ) | 1366 | (sr->download->is_done == GNUNET_YES) ) |
@@ -1069,12 +1369,16 @@ GNUNET_FS_GTK_search_result_clear_button_clicked (GtkButton * button, gpointer u | |||
1069 | GNUNET_FS_download_stop (sr->download->dc, GNUNET_YES); | 1369 | GNUNET_FS_download_stop (sr->download->dc, GNUNET_YES); |
1070 | } | 1370 | } |
1071 | if ( (NULL == sr->download) && | 1371 | if ( (NULL == sr->download) && |
1072 | (NULL == sr->result) ) | 1372 | (NULL == sr->result) && |
1373 | (GNUNET_YES == stop_downloads_in_subtree (tm, &iter)) ) | ||
1073 | { | 1374 | { |
1074 | /* no active download and no associated FS-API search result; | 1375 | /* no active download and no associated FS-API search result; |
1075 | so this must be some left-over entry from an opened | 1376 | so this must be some left-over entry from an opened |
1076 | directory; clean it up */ | 1377 | directory; clean it up */ |
1077 | free_search_result (sr); | 1378 | free_search_result (sr); |
1379 | /* the above call clobbered our 'iter', restart from the beginning... */ | ||
1380 | if (TRUE != gtk_tree_model_get_iter_first (tm, &iter)) | ||
1381 | return; | ||
1078 | } | 1382 | } |
1079 | } | 1383 | } |
1080 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); | 1384 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); |
@@ -1822,206 +2126,6 @@ mark_download_completed (struct DownloadEntry *de, uint64_t size) | |||
1822 | 2126 | ||
1823 | 2127 | ||
1824 | /** | 2128 | /** |
1825 | * Copy all of the children of 'src_iter' from the 'src_model' to | ||
1826 | * become children of 'dst_iter' in the 'dst_model'. The models are | ||
1827 | * both 'GNUNET_GTK_file_sharing_result_tree_store' models. | ||
1828 | * | ||
1829 | * Note that we also need to update the 'struct SearchResult' | ||
1830 | * and (if it exists) the respective 'struct DownloadEntry' | ||
1831 | * to refer to the new model. | ||
1832 | * | ||
1833 | * @param src_model source model | ||
1834 | * @param src_iter parent of the nodes to move | ||
1835 | * @param dst_tab destination tab | ||
1836 | * @param dst_iter new parent of the entries we are moving | ||
1837 | */ | ||
1838 | static void | ||
1839 | copy_children (GtkTreeModel * src_model, GtkTreeIter * src_iter, | ||
1840 | struct SearchTab *dst_tab, | ||
1841 | GtkTreeIter * dst_iter) | ||
1842 | { | ||
1843 | GtkTreeIter src_child; | ||
1844 | GtkTreeIter dst_child; | ||
1845 | GtkTreePath *path; | ||
1846 | struct GNUNET_CONTAINER_MetaData *meta; | ||
1847 | struct GNUNET_FS_Uri *uri; | ||
1848 | guint64 filesize, completed; | ||
1849 | GdkPixbuf *preview; | ||
1850 | guint percent_progress; | ||
1851 | guint percent_availability; | ||
1852 | gchar *filename; | ||
1853 | gchar *uri_as_string; | ||
1854 | gchar *status_colour; | ||
1855 | struct SearchResult *search_result_old; | ||
1856 | struct SearchResult *search_result_new; | ||
1857 | gchar *mimetype; | ||
1858 | guint applicability_rank; | ||
1859 | guint availability_certainty; | ||
1860 | gint availability_rank; | ||
1861 | gchar *downloaded_filename; | ||
1862 | gint downloaded_anonymity; | ||
1863 | |||
1864 | if (! gtk_tree_model_iter_children (src_model, &src_child, src_iter)) | ||
1865 | return; | ||
1866 | do | ||
1867 | { | ||
1868 | gtk_tree_model_get (src_model, &src_child, | ||
1869 | 0, &meta, | ||
1870 | 1, &uri, | ||
1871 | 2, &filesize, | ||
1872 | 3, &preview, | ||
1873 | 4, &percent_progress, | ||
1874 | 5, &percent_availability, | ||
1875 | 6, &filename, | ||
1876 | 7, &uri_as_string, | ||
1877 | 8, &status_colour, | ||
1878 | 9, &search_result_old, | ||
1879 | 10, &mimetype, | ||
1880 | 11, &applicability_rank, | ||
1881 | 12, &availability_certainty, | ||
1882 | 13, &availability_rank, | ||
1883 | 14, &completed, | ||
1884 | 15, &downloaded_filename, | ||
1885 | 16, &downloaded_anonymity, | ||
1886 | -1); | ||
1887 | search_result_new = GNUNET_malloc (sizeof (struct SearchResult)); | ||
1888 | search_result_new->tab = dst_tab; | ||
1889 | search_result_new->download = search_result_old->download; | ||
1890 | if (NULL != search_result_old->download) | ||
1891 | { | ||
1892 | search_result_old->download = NULL; | ||
1893 | search_result_new->download->sr = search_result_new; | ||
1894 | } | ||
1895 | gtk_tree_store_insert_with_values (dst_tab->ts, &dst_child, | ||
1896 | dst_iter, G_MAXINT, | ||
1897 | 0, GNUNET_CONTAINER_meta_data_duplicate (meta), | ||
1898 | 1, GNUNET_FS_uri_dup (uri), | ||
1899 | 2, filesize, | ||
1900 | 3, preview, | ||
1901 | 4, percent_progress, | ||
1902 | 5, percent_availability, | ||
1903 | 6, filename, | ||
1904 | 7, uri_as_string, | ||
1905 | 8, status_colour, | ||
1906 | 9, search_result_new, | ||
1907 | 10, mimetype, | ||
1908 | 11, applicability_rank, | ||
1909 | 12, availability_certainty, | ||
1910 | 13, availability_rank, | ||
1911 | 14, completed, | ||
1912 | 15, downloaded_filename, | ||
1913 | 16, downloaded_anonymity, | ||
1914 | -1); | ||
1915 | g_free (filename); | ||
1916 | g_free (downloaded_filename); | ||
1917 | g_free (uri_as_string); | ||
1918 | g_free (status_colour); | ||
1919 | g_free (mimetype); | ||
1920 | if (preview != NULL) | ||
1921 | g_object_unref (preview); | ||
1922 | |||
1923 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (dst_tab->ts), &dst_child); | ||
1924 | search_result_new->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (dst_tab->ts), path); | ||
1925 | gtk_tree_path_free (path); | ||
1926 | |||
1927 | copy_children (src_model, &src_child, dst_tab, &dst_child); | ||
1928 | } | ||
1929 | while (gtk_tree_model_iter_next (src_model, &src_child)); | ||
1930 | } | ||
1931 | |||
1932 | |||
1933 | /** | ||
1934 | * Handle the case where an active download lost its | ||
1935 | * search parent by moving it to the URI tab. | ||
1936 | * | ||
1937 | * @param de download where the parent (i.e. search) was lost | ||
1938 | */ | ||
1939 | static void | ||
1940 | download_lost_parent (struct DownloadEntry *de) | ||
1941 | { | ||
1942 | GtkTreeIter iter; | ||
1943 | GtkTreePath *path; | ||
1944 | GtkTreeModel *tm_old; | ||
1945 | GtkTreeIter iter_old; | ||
1946 | GtkTreeModel *model; | ||
1947 | struct GNUNET_CONTAINER_MetaData *meta; | ||
1948 | struct GNUNET_FS_Uri *uri; | ||
1949 | guint64 completed; | ||
1950 | guint percent_progress; | ||
1951 | guint percent_availability; | ||
1952 | gchar *filename; | ||
1953 | gchar *status_colour; | ||
1954 | guint applicability_rank; | ||
1955 | guint availability_certainty; | ||
1956 | gint availability_rank; | ||
1957 | gchar *downloaded_filename; | ||
1958 | gint downloaded_anonymity; | ||
1959 | |||
1960 | /* find the 'old' root */ | ||
1961 | tm_old = GTK_TREE_MODEL (de->sr->tab->ts); | ||
1962 | path = gtk_tree_row_reference_get_path (de->sr->rr); | ||
1963 | if (! gtk_tree_model_get_iter (tm_old, &iter_old, path)) | ||
1964 | { | ||
1965 | GNUNET_break (0); | ||
1966 | gtk_tree_path_free (path); | ||
1967 | return; | ||
1968 | } | ||
1969 | gtk_tree_path_free (path); | ||
1970 | gtk_tree_model_get (tm_old, &iter_old, | ||
1971 | 0, &meta, | ||
1972 | 1, &uri, | ||
1973 | 4, &percent_progress, | ||
1974 | 5, &percent_availability, | ||
1975 | 6, &filename, | ||
1976 | 8, &status_colour, | ||
1977 | 11, &applicability_rank, | ||
1978 | 12, &availability_certainty, | ||
1979 | 13, &availability_rank, | ||
1980 | 14, &completed, | ||
1981 | 15, &downloaded_filename, | ||
1982 | 16, &downloaded_anonymity, | ||
1983 | -1); | ||
1984 | GNUNET_assert (GNUNET_YES == GNUNET_FS_uri_test_equal (uri, de->uri)); | ||
1985 | GNUNET_assert (de->sr->download == de); | ||
1986 | de->sr->download = NULL; | ||
1987 | |||
1988 | /* create the target root */ | ||
1989 | de->sr = GNUNET_GTK_add_to_uri_tab (meta, uri); | ||
1990 | de->sr->download = de; | ||
1991 | |||
1992 | /* get positions of the 'new' root */ | ||
1993 | model = GTK_TREE_MODEL (de->sr->tab->ts); | ||
1994 | path = gtk_tree_row_reference_get_path (de->sr->rr); | ||
1995 | if (! gtk_tree_model_get_iter (model, &iter, path)) | ||
1996 | { | ||
1997 | GNUNET_break (0); | ||
1998 | gtk_tree_path_free (path); | ||
1999 | return; | ||
2000 | } | ||
2001 | gtk_tree_path_free (path); | ||
2002 | |||
2003 | gtk_tree_store_set (de->sr->tab->ts, &iter, | ||
2004 | 4, percent_progress, | ||
2005 | 5, percent_availability, | ||
2006 | 6, filename, | ||
2007 | 8, status_colour, | ||
2008 | 11, applicability_rank, | ||
2009 | 12, availability_certainty, | ||
2010 | 13, availability_rank, | ||
2011 | 14, completed, | ||
2012 | 15, downloaded_filename, | ||
2013 | 16, downloaded_anonymity, | ||
2014 | -1); | ||
2015 | g_free (filename); | ||
2016 | g_free (downloaded_filename); | ||
2017 | g_free (status_colour); | ||
2018 | |||
2019 | /* finally, move all children over as well */ | ||
2020 | copy_children (tm_old, &iter_old, de->sr->tab, &iter); | ||
2021 | } | ||
2022 | |||
2023 | |||
2024 | /** | ||
2025 | * Setup a new download entry. | 2129 | * Setup a new download entry. |
2026 | * | 2130 | * |
2027 | * @param de existing download entry for the download, or NULL (in which case we create a fresh one) | 2131 | * @param de existing download entry for the download, or NULL (in which case we create a fresh one) |