diff options
Diffstat (limited to 'src/plugins/fs/search.c')
-rw-r--r-- | src/plugins/fs/search.c | 120 |
1 files changed, 61 insertions, 59 deletions
diff --git a/src/plugins/fs/search.c b/src/plugins/fs/search.c index a78dd430..70c40aa7 100644 --- a/src/plugins/fs/search.c +++ b/src/plugins/fs/search.c | |||
@@ -164,7 +164,7 @@ fs_search_result_received (SearchList * searchContext, | |||
164 | GtkTreeStore *model; | 164 | GtkTreeStore *model; |
165 | GtkTreeIter iter; | 165 | GtkTreeIter iter; |
166 | enum GNUNET_URITRACK_STATE state; | 166 | enum GNUNET_URITRACK_STATE state; |
167 | struct GNUNET_ECRS_URI * have; | 167 | struct GNUNET_ECRS_URI *have; |
168 | 168 | ||
169 | state = GNUNET_URITRACK_get_state (ectx, cfg, info->uri); | 169 | state = GNUNET_URITRACK_get_state (ectx, cfg, info->uri); |
170 | if ((state & (GNUNET_URITRACK_INSERTED | | 170 | if ((state & (GNUNET_URITRACK_INSERTED | |
@@ -175,20 +175,19 @@ fs_search_result_received (SearchList * searchContext, | |||
175 | GNUNET_YES))) | 175 | GNUNET_YES))) |
176 | return; | 176 | return; |
177 | model = GTK_TREE_STORE (gtk_tree_view_get_model (searchContext->treeview)); | 177 | model = GTK_TREE_STORE (gtk_tree_view_get_model (searchContext->treeview)); |
178 | /* Check that the entry does not already exist (for resume!) */ | 178 | /* Check that the entry does not already exist (for resume!) */ |
179 | if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter)) | 179 | if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter)) |
180 | { | 180 | { |
181 | do | 181 | do |
182 | { | 182 | { |
183 | have = NULL; | 183 | have = NULL; |
184 | gtk_tree_model_get (GTK_TREE_MODEL(model), | 184 | gtk_tree_model_get (GTK_TREE_MODEL (model), |
185 | &iter, SEARCH_URI, &have, -1); | 185 | &iter, SEARCH_URI, &have, -1); |
186 | if ( (have != NULL) && | 186 | if ((have != NULL) && (GNUNET_ECRS_uri_test_equal (have, uri))) |
187 | (GNUNET_ECRS_uri_test_equal(have, uri)) ) | 187 | return; /* duplicate */ |
188 | return; /* duplicate */ | 188 | } |
189 | } | 189 | while (gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter)); |
190 | while (gtk_tree_model_iter_next (GTK_TREE_MODEL(model), &iter)); | 190 | } |
191 | } | ||
192 | gtk_tree_store_append (model, &iter, NULL); | 191 | gtk_tree_store_append (model, &iter, NULL); |
193 | addEntryToSearchTree (searchContext, NULL, info, &iter); | 192 | addEntryToSearchTree (searchContext, NULL, info, &iter); |
194 | searchContext->resultsReceived++; | 193 | searchContext->resultsReceived++; |
@@ -310,7 +309,7 @@ on_save_search_activate (void *cls, GtkWidget * searchEntry) | |||
310 | meta = GNUNET_ECRS_meta_data_create (); | 309 | meta = GNUNET_ECRS_meta_data_create (); |
311 | GNUNET_ECRS_meta_data_insert (meta, EXTRACTOR_KEYWORDS, list->searchString); | 310 | GNUNET_ECRS_meta_data_insert (meta, EXTRACTOR_KEYWORDS, list->searchString); |
312 | GNUNET_ECRS_meta_data_insert (meta, EXTRACTOR_DESCRIPTION, | 311 | GNUNET_ECRS_meta_data_insert (meta, EXTRACTOR_DESCRIPTION, |
313 | _("Saved search results")); | 312 | _("Saved search results")); |
314 | GNUNET_ECRS_meta_data_insert (meta, EXTRACTOR_SOFTWARE, "gnunet-gtk"); | 313 | GNUNET_ECRS_meta_data_insert (meta, EXTRACTOR_SOFTWARE, "gnunet-gtk"); |
315 | if (GNUNET_OK != GNUNET_ECRS_directory_create (NULL, | 314 | if (GNUNET_OK != GNUNET_ECRS_directory_create (NULL, |
316 | &directory, &dir_len, | 315 | &directory, &dir_len, |
@@ -405,18 +404,17 @@ fs_search_started (struct GNUNET_FSUI_SearchList * fsui_list, | |||
405 | list = search_head; | 404 | list = search_head; |
406 | while (list != NULL) | 405 | while (list != NULL) |
407 | { | 406 | { |
408 | if ( (list->fsui_list == NULL) && | 407 | if ((list->fsui_list == NULL) && |
409 | (list->uri != NULL) && | 408 | (list->uri != NULL) && |
410 | (GNUNET_ECRS_uri_test_equal(list->uri, | 409 | (GNUNET_ECRS_uri_test_equal (list->uri, uri))) |
411 | uri)) ) | 410 | { |
412 | { | 411 | list->fsui_list = fsui_list; |
413 | list->fsui_list = fsui_list; | 412 | for (i = 0; i < resultCount; i++) |
414 | for (i = 0; i < resultCount; i++) | 413 | fs_search_result_received (list, &results[i], uri); |
415 | fs_search_result_received (list, &results[i], uri); | 414 | if (resultCount == 0) /* otherwise already done! */ |
416 | if (resultCount == 0) /* otherwise already done! */ | 415 | updateSearchSummary (list); |
417 | updateSearchSummary (list); | 416 | return list; |
418 | return list; | 417 | } |
419 | } | ||
420 | list = list->next; | 418 | list = list->next; |
421 | } | 419 | } |
422 | 420 | ||
@@ -643,12 +641,24 @@ freeIterSubtree (GtkTreeModel * tree, GtkTreeIter * iter) | |||
643 | void | 641 | void |
644 | fs_search_aborted (SearchList * list) | 642 | fs_search_aborted (SearchList * list) |
645 | { | 643 | { |
646 | gtk_widget_show(glade_xml_get_widget(list->searchXML, | 644 | gtk_widget_show (glade_xml_get_widget (list->searchXML, |
647 | "searchResumeButton")); | 645 | "searchResumeButton")); |
648 | gtk_widget_show(glade_xml_get_widget(list->searchXML, | 646 | gtk_widget_show (glade_xml_get_widget (list->searchXML, |
649 | "searchAbortButton")); | 647 | "searchAbortButton")); |
650 | gtk_widget_show(glade_xml_get_widget(list->searchXML, | 648 | gtk_widget_show (glade_xml_get_widget (list->searchXML, |
651 | "searchPauseButton")); | 649 | "searchPauseButton")); |
650 | } | ||
651 | |||
652 | void | ||
653 | fs_search_paused (SearchList * list) | ||
654 | { | ||
655 | /* nothing to be done */ | ||
656 | } | ||
657 | |||
658 | void | ||
659 | fs_search_restarted (SearchList * list) | ||
660 | { | ||
661 | /* nothing to be done */ | ||
652 | } | 662 | } |
653 | 663 | ||
654 | /** | 664 | /** |
@@ -666,14 +676,6 @@ fs_search_stopped (SearchList * list) | |||
666 | int index; | 676 | int index; |
667 | int i; | 677 | int i; |
668 | 678 | ||
669 | if (list->is_paused == GNUNET_YES) | ||
670 | { | ||
671 | /* if this was just a request to pause, | ||
672 | then simply ignore the FS-stopped event */ | ||
673 | list->fsui_list = NULL; | ||
674 | list->is_paused = GNUNET_NO; | ||
675 | return; | ||
676 | } | ||
677 | /* remove from linked list */ | 679 | /* remove from linked list */ |
678 | if (search_head == list) | 680 | if (search_head == list) |
679 | { | 681 | { |
@@ -760,8 +762,7 @@ static void * | |||
760 | search_start_helper (void *cls) | 762 | search_start_helper (void *cls) |
761 | { | 763 | { |
762 | FSSS *fsss = cls; | 764 | FSSS *fsss = cls; |
763 | GNUNET_FSUI_search_start (ctx, fsss->anonymity, | 765 | GNUNET_FSUI_search_start (ctx, fsss->anonymity, fsss->uri); |
764 | fsss->uri); | ||
765 | return NULL; | 766 | return NULL; |
766 | } | 767 | } |
767 | 768 | ||
@@ -896,7 +897,7 @@ on_fssearchbutton_clicked_fs (gpointer dummy2, GtkWidget * searchButton) | |||
896 | list = list->next; | 897 | list = list->next; |
897 | } | 898 | } |
898 | fsss.anonymity = getSpinButtonValue (GNUNET_GTK_get_main_glade_XML (), | 899 | fsss.anonymity = getSpinButtonValue (GNUNET_GTK_get_main_glade_XML (), |
899 | "searchAnonymitySelectionSpinButton"); | 900 | "searchAnonymitySelectionSpinButton"); |
900 | GNUNET_GTK_run_with_save_calls (search_start_helper, &fsss); | 901 | GNUNET_GTK_run_with_save_calls (search_start_helper, &fsss); |
901 | GNUNET_ECRS_uri_destroy (fsss.uri); | 902 | GNUNET_ECRS_uri_destroy (fsss.uri); |
902 | } | 903 | } |
@@ -942,7 +943,7 @@ on_closeSearchButton_clicked_fs (GtkWidget * searchPage, | |||
942 | if (list->fsui_list == NULL) | 943 | if (list->fsui_list == NULL) |
943 | { | 944 | { |
944 | /* open directory or paused search; | 945 | /* open directory or paused search; |
945 | close directly */ | 946 | close directly */ |
946 | fs_search_stopped (list); | 947 | fs_search_stopped (list); |
947 | } | 948 | } |
948 | else | 949 | else |
@@ -962,7 +963,7 @@ on_closeSearchButton_clicked_fs (GtkWidget * searchPage, | |||
962 | */ | 963 | */ |
963 | void | 964 | void |
964 | on_searchPauseButton_clicked_fs (GtkWidget * searchPage, | 965 | on_searchPauseButton_clicked_fs (GtkWidget * searchPage, |
965 | GtkWidget * pauseButton) | 966 | GtkWidget * pauseButton) |
966 | { | 967 | { |
967 | SearchList *list; | 968 | SearchList *list; |
968 | struct FCBC fcbc; | 969 | struct FCBC fcbc; |
@@ -975,13 +976,12 @@ on_searchPauseButton_clicked_fs (GtkWidget * searchPage, | |||
975 | list = list->next; | 976 | list = list->next; |
976 | } | 977 | } |
977 | GNUNET_GE_ASSERT (ectx, list != NULL); | 978 | GNUNET_GE_ASSERT (ectx, list != NULL); |
978 | gtk_widget_hide(pauseButton); | 979 | gtk_widget_hide (pauseButton); |
979 | gtk_widget_show(glade_xml_get_widget(list->searchXML, | 980 | gtk_widget_show (glade_xml_get_widget (list->searchXML, |
980 | "searchResumeButton")); | 981 | "searchResumeButton")); |
981 | if (list->fsui_list != NULL) | 982 | if (list->fsui_list != NULL) |
982 | { | 983 | { |
983 | list->is_paused = GNUNET_YES; | 984 | fcbc.method = &GNUNET_FSUI_search_pause; |
984 | fcbc.method = &GNUNET_FSUI_search_stop; | ||
985 | fcbc.argument = list->fsui_list; | 985 | fcbc.argument = list->fsui_list; |
986 | GNUNET_GTK_run_with_save_calls (&fsui_callback, &fcbc); | 986 | GNUNET_GTK_run_with_save_calls (&fsui_callback, &fcbc); |
987 | } | 987 | } |
@@ -992,10 +992,10 @@ on_searchPauseButton_clicked_fs (GtkWidget * searchPage, | |||
992 | */ | 992 | */ |
993 | void | 993 | void |
994 | on_searchResumeButton_clicked_fs (GtkWidget * searchPage, | 994 | on_searchResumeButton_clicked_fs (GtkWidget * searchPage, |
995 | GtkWidget * resumeButton) | 995 | GtkWidget * resumeButton) |
996 | { | 996 | { |
997 | FSSS fsss; | ||
998 | SearchList *list; | 997 | SearchList *list; |
998 | struct FCBC fcbc; | ||
999 | 999 | ||
1000 | list = search_head; | 1000 | list = search_head; |
1001 | while (list != NULL) | 1001 | while (list != NULL) |
@@ -1005,13 +1005,15 @@ on_searchResumeButton_clicked_fs (GtkWidget * searchPage, | |||
1005 | list = list->next; | 1005 | list = list->next; |
1006 | } | 1006 | } |
1007 | GNUNET_GE_ASSERT (ectx, list != NULL); | 1007 | GNUNET_GE_ASSERT (ectx, list != NULL); |
1008 | gtk_widget_hide(resumeButton); | 1008 | gtk_widget_hide (resumeButton); |
1009 | gtk_widget_show(glade_xml_get_widget(list->searchXML, | 1009 | gtk_widget_show (glade_xml_get_widget (list->searchXML, |
1010 | "searchPauseButton")); | 1010 | "searchPauseButton")); |
1011 | fsss.anonymity = getSpinButtonValue (GNUNET_GTK_get_main_glade_XML (), | 1011 | if (list->fsui_list != NULL) |
1012 | "searchAnonymitySelectionSpinButton"); | 1012 | { |
1013 | fsss.uri = list->uri; | 1013 | fcbc.method = &GNUNET_FSUI_search_restart; |
1014 | GNUNET_GTK_run_with_save_calls (search_start_helper, &fsss); | 1014 | fcbc.argument = list->fsui_list; |
1015 | GNUNET_GTK_run_with_save_calls (&fsui_callback, &fcbc); | ||
1016 | } | ||
1015 | } | 1017 | } |
1016 | 1018 | ||
1017 | /** | 1019 | /** |
@@ -1032,7 +1034,7 @@ on_abortSearchButton_clicked_fs (GtkWidget * searchPage, | |||
1032 | list = list->next; | 1034 | list = list->next; |
1033 | } | 1035 | } |
1034 | GNUNET_GE_ASSERT (ectx, list != NULL); | 1036 | GNUNET_GE_ASSERT (ectx, list != NULL); |
1035 | gtk_widget_hide(abortButton); | 1037 | gtk_widget_hide (abortButton); |
1036 | if (list->fsui_list != NULL) | 1038 | if (list->fsui_list != NULL) |
1037 | { | 1039 | { |
1038 | fcbc.method = &GNUNET_FSUI_search_abort; | 1040 | fcbc.method = &GNUNET_FSUI_search_abort; |