aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2008-05-27 00:32:22 +0000
committerChristian Grothoff <christian@grothoff.org>2008-05-27 00:32:22 +0000
commit96a16b9caeb8c887059a17d4c13bad8558d62d8e (patch)
treef106f818f15f005d7b3332f9fba9f788f352f625
parent8793688fb3bedea05c68cea6b542b4f92f118e0d (diff)
downloadgnunet-gtk-96a16b9caeb8c887059a17d4c13bad8558d62d8e.tar.gz
gnunet-gtk-96a16b9caeb8c887059a17d4c13bad8558d62d8e.zip
adding search result rankings to model
-rw-r--r--src/plugins/fs/fs.c8
-rw-r--r--src/plugins/fs/fs.h3
-rw-r--r--src/plugins/fs/search.c43
-rw-r--r--src/plugins/fs/search.h1
4 files changed, 51 insertions, 4 deletions
diff --git a/src/plugins/fs/fs.c b/src/plugins/fs/fs.c
index c14113d0..24550810 100644
--- a/src/plugins/fs/fs.c
+++ b/src/plugins/fs/fs.c
@@ -122,6 +122,7 @@ saveEventProcessor (void *cls)
122{ 122{
123 const GNUNET_FSUI_Event *event = cls; 123 const GNUNET_FSUI_Event *event = cls;
124 void *ret; 124 void *ret;
125 unsigned int i;
125 126
126 ret = NULL; 127 ret = NULL;
127 switch (event->type) 128 switch (event->type)
@@ -157,6 +158,12 @@ saveEventProcessor (void *cls)
157 event->data.SearchResumed.fisSize, 158 event->data.SearchResumed.fisSize,
158 event->data.SearchResumed.fis, 159 event->data.SearchResumed.fis,
159 event->data.SearchResumed.state); 160 event->data.SearchResumed.state);
161 for (i=0;i<event->data.SearchResumed.fisSize;i++)
162 fs_search_update(ret,
163 &event->data.SearchResumed.fis[i],
164 event->data.SearchResumed.availability_rank[i],
165 event->data.SearchResumed.availability_certainty[i],
166 event->data.SearchResumed.applicability_rank[i]);
160 break; 167 break;
161 case GNUNET_FSUI_search_stopped: 168 case GNUNET_FSUI_search_stopped:
162 fs_search_stopped (event->data.SearchStopped.sc.cctx); 169 fs_search_stopped (event->data.SearchStopped.sc.cctx);
@@ -165,6 +172,7 @@ saveEventProcessor (void *cls)
165 fs_search_update (event->data.SearchUpdate.sc.cctx, 172 fs_search_update (event->data.SearchUpdate.sc.cctx,
166 &event->data.SearchUpdate.fi, 173 &event->data.SearchUpdate.fi,
167 event->data.SearchUpdate.availability_rank, 174 event->data.SearchUpdate.availability_rank,
175 event->data.SearchUpdate.availability_certainty,
168 event->data.SearchUpdate.applicability_rank); 176 event->data.SearchUpdate.applicability_rank);
169 break; 177 break;
170 /* download events */ 178 /* download events */
diff --git a/src/plugins/fs/fs.h b/src/plugins/fs/fs.h
index e41aefe9..62262d34 100644
--- a/src/plugins/fs/fs.h
+++ b/src/plugins/fs/fs.h
@@ -64,6 +64,9 @@ enum
64 SEARCH_INTERNAL, 64 SEARCH_INTERNAL,
65 SEARCH_INTERNAL_PARENT, 65 SEARCH_INTERNAL_PARENT,
66 SEARCH_STATUS, 66 SEARCH_STATUS,
67 SEARCH_AVAILABILITY_RANK,
68 SEARCH_AVAILABILITY_CERTAINTY,
69 SEARCH_APPLICABILITY_RANK,
67 SEARCH_NUM, 70 SEARCH_NUM,
68}; 71};
69 72
diff --git a/src/plugins/fs/search.c b/src/plugins/fs/search.c
index 9628a6bb..1b33b5af 100644
--- a/src/plugins/fs/search.c
+++ b/src/plugins/fs/search.c
@@ -172,7 +172,7 @@ fs_search_result_received (SearchList * searchContext,
172 (GNUNET_YES == GNUNET_GC_get_configuration_value_yesno (cfg, 172 (GNUNET_YES == GNUNET_GC_get_configuration_value_yesno (cfg,
173 "GNUNET-GTK", 173 "GNUNET-GTK",
174 "DISABLE-OWN", 174 "DISABLE-OWN",
175 GNUNET_YES))) 175 GNUNET_NO)))
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!) */
@@ -205,9 +205,39 @@ fs_search_result_received (SearchList * searchContext,
205void fs_search_update (SearchList * searchContext, 205void fs_search_update (SearchList * searchContext,
206 const GNUNET_ECRS_FileInfo * info, 206 const GNUNET_ECRS_FileInfo * info,
207 int availability_rank, 207 int availability_rank,
208 unsigned int availability_certainty,
208 unsigned int applicability_rank) 209 unsigned int applicability_rank)
209{ 210{
210 /* FIXME */ 211 GtkTreeStore *model;
212 GtkTreeIter iter;
213 struct GNUNET_ECRS_URI *have;
214
215 model = GTK_TREE_STORE (gtk_tree_view_get_model (searchContext->treeview));
216 /* find existing entry */
217 if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter))
218 {
219 do
220 {
221 have = NULL;
222 gtk_tree_model_get (GTK_TREE_MODEL (model),
223 &iter, SEARCH_URI, &have, -1);
224 if ( (have != NULL) &&
225 (GNUNET_ECRS_uri_test_equal (have, info->uri)) )
226 {
227 /* gotcha! */
228 gtk_tree_store_set(searchContext->tree,
229 &iter,
230 SEARCH_AVAILABILITY_RANK, availability_rank,
231 SEARCH_AVAILABILITY_CERTAINTY, availability_certainty,
232 SEARCH_APPLICABILITY_RANK, applicability_rank,
233 -1);
234 return; /* done! */
235 }
236 }
237 while (gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter));
238 }
239 /* not found!? */
240 GNUNET_GE_BREAK(NULL, 0);
211} 241}
212 242
213 243
@@ -466,7 +496,8 @@ fs_search_started (struct GNUNET_FSUI_SearchList * fsui_list,
466 g_signal_connect_swapped (list->treeview, 496 g_signal_connect_swapped (list->treeview,
467 "button-press-event", 497 "button-press-event",
468 G_CALLBACK (search_click_handler), list); 498 G_CALLBACK (search_click_handler), list);
469 list->tree = gtk_tree_store_new (SEARCH_NUM, G_TYPE_STRING, /* name */ 499 list->tree = gtk_tree_store_new (SEARCH_NUM,
500 G_TYPE_STRING, /* name */
470 G_TYPE_UINT64, /* size */ 501 G_TYPE_UINT64, /* size */
471 G_TYPE_STRING, /* human-readable size */ 502 G_TYPE_STRING, /* human-readable size */
472 G_TYPE_STRING, /* mime-type */ 503 G_TYPE_STRING, /* mime-type */
@@ -478,7 +509,11 @@ fs_search_started (struct GNUNET_FSUI_SearchList * fsui_list,
478 G_TYPE_STRING, /* fg-color */ 509 G_TYPE_STRING, /* fg-color */
479 G_TYPE_POINTER, /* internal: search list */ 510 G_TYPE_POINTER, /* internal: search list */
480 G_TYPE_POINTER, /* internal: download parent list */ 511 G_TYPE_POINTER, /* internal: download parent list */
481 G_TYPE_STRING); /* status */ 512 G_TYPE_STRING, /* status */
513 G_TYPE_INT, /* availability rank */
514 G_TYPE_UINT, /* availability certainty */
515 G_TYPE_UINT /* applicability rank */
516 );
482 517
483 gtk_tree_view_set_model (list->treeview, GTK_TREE_MODEL (list->tree)); 518 gtk_tree_view_set_model (list->treeview, GTK_TREE_MODEL (list->tree));
484 gtk_tree_selection_set_mode (gtk_tree_view_get_selection (list->treeview), 519 gtk_tree_selection_set_mode (gtk_tree_view_get_selection (list->treeview),
diff --git a/src/plugins/fs/search.h b/src/plugins/fs/search.h
index bf280397..546c7bfd 100644
--- a/src/plugins/fs/search.h
+++ b/src/plugins/fs/search.h
@@ -64,6 +64,7 @@ void fs_search_result_received (SearchList * searchContext,
64void fs_search_update (SearchList * searchContext, 64void fs_search_update (SearchList * searchContext,
65 const GNUNET_ECRS_FileInfo * info, 65 const GNUNET_ECRS_FileInfo * info,
66 int availability_rank, 66 int availability_rank,
67 unsigned int availability_certainty,
67 unsigned int applicability_rank); 68 unsigned int applicability_rank);
68 69
69/** 70/**