aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2008-05-14 03:41:04 +0000
committerChristian Grothoff <christian@grothoff.org>2008-05-14 03:41:04 +0000
commit39455c7c438d9926c6bdf850f5abdf49335dd582 (patch)
tree8bc0ddbba90bdffd6327ab3b57db3939300874d4
parented83cbe72fe0b98f501e73ff58284582caf4dc43 (diff)
downloadgnunet-gtk-39455c7c438d9926c6bdf850f5abdf49335dd582.tar.gz
gnunet-gtk-39455c7c438d9926c6bdf850f5abdf49335dd582.zip
converting to new namespace / URI APIs
-rw-r--r--src/plugins/fs/fs.c7
-rw-r--r--src/plugins/fs/namespace.c11
-rw-r--r--src/plugins/fs/namespace_search.c7
-rw-r--r--src/plugins/fs/search.c39
-rw-r--r--src/plugins/fs/search.h13
5 files changed, 54 insertions, 23 deletions
diff --git a/src/plugins/fs/fs.c b/src/plugins/fs/fs.c
index 463f2b72..c14113d0 100644
--- a/src/plugins/fs/fs.c
+++ b/src/plugins/fs/fs.c
@@ -161,7 +161,12 @@ saveEventProcessor (void *cls)
161 case GNUNET_FSUI_search_stopped: 161 case GNUNET_FSUI_search_stopped:
162 fs_search_stopped (event->data.SearchStopped.sc.cctx); 162 fs_search_stopped (event->data.SearchStopped.sc.cctx);
163 break; 163 break;
164 164 case GNUNET_FSUI_search_update:
165 fs_search_update (event->data.SearchUpdate.sc.cctx,
166 &event->data.SearchUpdate.fi,
167 event->data.SearchUpdate.availability_rank,
168 event->data.SearchUpdate.applicability_rank);
169 break;
165 /* download events */ 170 /* download events */
166 case GNUNET_FSUI_download_aborted: 171 case GNUNET_FSUI_download_aborted:
167 fs_download_aborted (event->data.DownloadAborted.dc.cctx); 172 fs_download_aborted (event->data.DownloadAborted.dc.cctx);
diff --git a/src/plugins/fs/namespace.c b/src/plugins/fs/namespace.c
index e285039e..4a849582 100644
--- a/src/plugins/fs/namespace.c
+++ b/src/plugins/fs/namespace.c
@@ -433,7 +433,7 @@ addTabForNamespace (void *unused,
433 label); 433 label);
434 gtk_widget_show (notebook); 434 gtk_widget_show (notebook);
435 GNUNET_NS_namespace_list_contents 435 GNUNET_NS_namespace_list_contents
436 (ectx, cfg, namespaceName, &addNamespaceContentToModel, list->model); 436 (ectx, cfg, namespaceId, &addNamespaceContentToModel, list->model);
437 GNUNET_GTK_DEBUG_END (); 437 GNUNET_GTK_DEBUG_END ();
438 /* enable "delete" menu entry */ 438 /* enable "delete" menu entry */
439 439
@@ -562,7 +562,7 @@ namespaceDelete_clicked_fs (GtkWidget * dummy1, GtkWidget * dummy2)
562 if (GTK_RESPONSE_YES != ret) 562 if (GTK_RESPONSE_YES != ret)
563 return; 563 return;
564 gtk_notebook_remove_page (GTK_NOTEBOOK (notebook), num); 564 gtk_notebook_remove_page (GTK_NOTEBOOK (notebook), num);
565 GNUNET_NS_namespace_delete (ectx, cfg, list->name); 565 GNUNET_NS_namespace_delete (ectx, cfg, &list->id);
566 frame_destroy (list->treeview); 566 frame_destroy (list->treeview);
567 GNUNET_GTK_DEBUG_END (); 567 GNUNET_GTK_DEBUG_END ();
568} 568}
@@ -571,6 +571,7 @@ typedef struct
571{ 571{
572 unsigned int anonymityLevel; 572 unsigned int anonymityLevel;
573 char *namespaceName; 573 char *namespaceName;
574 GNUNET_HashCode nsid;
574 GNUNET_Int32Time updateInterval; 575 GNUNET_Int32Time updateInterval;
575 GNUNET_HashCode *lastId; 576 GNUNET_HashCode *lastId;
576 GNUNET_HashCode thisId; 577 GNUNET_HashCode thisId;
@@ -603,7 +604,7 @@ addToNamespaceCB (GtkTreeModel * model,
603 } 604 }
604 resultURI = GNUNET_NS_add_to_namespace (ectx, cfg, cls->anonymityLevel, 1000, /* FIXME: priority */ 605 resultURI = GNUNET_NS_add_to_namespace (ectx, cfg, cls->anonymityLevel, 1000, /* FIXME: priority */
605 GNUNET_get_time () + 2 * GNUNET_CRON_YEARS, /* FIXME: expiration */ 606 GNUNET_get_time () + 2 * GNUNET_CRON_YEARS, /* FIXME: expiration */
606 cls->namespaceName, 607 &cls->nsid,
607 cls->updateInterval, 608 cls->updateInterval,
608 cls->lastId, 609 cls->lastId,
609 &cls->thisId, cls->nextId, dst, 610 &cls->thisId, cls->nextId, dst,
@@ -688,6 +689,7 @@ on_namespaceInsertButton_clicked_fs (GtkWidget * dummy1, GtkWidget * dummy2)
688 return; 689 return;
689 } 690 }
690 cls.namespaceName = list->name; 691 cls.namespaceName = list->name;
692 cls.nsid = list->id;
691 693
692 metaXML 694 metaXML
693 = glade_xml_new (GNUNET_GTK_get_glade_filename (), 695 = glade_xml_new (GNUNET_GTK_get_glade_filename (),
@@ -796,6 +798,7 @@ on_namespaceUpdateButton_clicked_fs (GtkWidget * dummy1, GtkWidget * dummy2)
796 return; 798 return;
797 } 799 }
798 cls.namespaceName = list->name; 800 cls.namespaceName = list->name;
801 cls.nsid = list->id;
799 802
800 /* find out what we are updating */ 803 /* find out what we are updating */
801 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (list->treeview)); 804 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (list->treeview));
@@ -837,7 +840,7 @@ on_namespaceUpdateButton_clicked_fs (GtkWidget * dummy1, GtkWidget * dummy2)
837 if ((cls.updateInterval != GNUNET_ECRS_SBLOCK_UPDATE_SPORADIC) && 840 if ((cls.updateInterval != GNUNET_ECRS_SBLOCK_UPDATE_SPORADIC) &&
838 (GNUNET_OK == GNUNET_NS_compute_next_identifier (NULL, 841 (GNUNET_OK == GNUNET_NS_compute_next_identifier (NULL,
839 cfg, 842 cfg,
840 cls.namespaceName, 843 &cls.nsid,
841 &lastId, 844 &lastId,
842 &cls.thisId, 845 &cls.thisId,
843 cls.updateInterval, 846 cls.updateInterval,
diff --git a/src/plugins/fs/namespace_search.c b/src/plugins/fs/namespace_search.c
index 06dc4145..19fa561a 100644
--- a/src/plugins/fs/namespace_search.c
+++ b/src/plugins/fs/namespace_search.c
@@ -51,6 +51,7 @@ on_namespaceRatingSpinButton_changed_fs (GtkWidget * dummy,
51 char *description; 51 char *description;
52 int rating; 52 int rating;
53 int newrating; 53 int newrating;
54 GNUNET_HashCode nsid;
54 55
55 GNUNET_GTK_DEBUG_BEGIN (); 56 GNUNET_GTK_DEBUG_BEGIN ();
56 spin = 57 spin =
@@ -78,9 +79,11 @@ on_namespaceRatingSpinButton_changed_fs (GtkWidget * dummy,
78 { 79 {
79 if (encStr != NULL) 80 if (encStr != NULL)
80 { 81 {
82 GNUNET_enc_to_hash(encStr,
83 &nsid);
81 newrating = gtk_spin_button_get_value (GTK_SPIN_BUTTON (spin)); 84 newrating = gtk_spin_button_get_value (GTK_SPIN_BUTTON (spin));
82 rating = GNUNET_NS_namespace_rank (ectx, 85 rating = GNUNET_NS_namespace_rank (ectx,
83 cfg, encStr, 86 cfg, &nsid,
84 newrating - rating); 87 newrating - rating);
85 if (rating != newrating) 88 if (rating != newrating)
86 { 89 {
@@ -160,7 +163,7 @@ on_searchNamespaceComboBoxEntry_changed_fs (GtkWidget * dummy,
160 = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), 163 = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
161 "fssearchKeywordComboBoxEntry"); 164 "fssearchKeywordComboBoxEntry");
162 if (GNUNET_OK == 165 if (GNUNET_OK ==
163 GNUNET_NS_namespace_get_root (ectx, cfg, encStr, &root)) 166 GNUNET_NS_namespace_get_root (ectx, cfg, &ns, &root))
164 { 167 {
165 GNUNET_hash_to_enc (&root, &enc); 168 GNUNET_hash_to_enc (&root, &enc);
166 gtk_entry_set_text (GTK_ENTRY 169 gtk_entry_set_text (GTK_ENTRY
diff --git a/src/plugins/fs/search.c b/src/plugins/fs/search.c
index a1c79784..44da2589 100644
--- a/src/plugins/fs/search.c
+++ b/src/plugins/fs/search.c
@@ -194,6 +194,23 @@ fs_search_result_received (SearchList * searchContext,
194 updateSearchSummary (searchContext); 194 updateSearchSummary (searchContext);
195} 195}
196 196
197/**
198 * Update the applicability and availability rating
199 * for the given search result.
200 *
201 * @param info the search result (and metadata)
202 * @param availability_rank availability estimate
203 * @param applicability_rank relevance
204 */
205void fs_search_update (SearchList * searchContext,
206 const GNUNET_ECRS_FileInfo * info,
207 int availability_rank,
208 unsigned int applicability_rank)
209{
210 /* FIXME */
211}
212
213
197static int 214static int
198on_search_copy_uri_activate (void *cls, GtkWidget * searchEntry) 215on_search_copy_uri_activate (void *cls, GtkWidget * searchEntry)
199{ 216{
@@ -389,7 +406,6 @@ fs_search_started (struct GNUNET_FSUI_SearchList * fsui_list,
389 SearchList *list; 406 SearchList *list;
390 gint pages; 407 gint pages;
391 char *description; 408 char *description;
392 const char *dhead;
393 GtkTreeViewColumn *column; 409 GtkTreeViewColumn *column;
394 GtkCellRenderer *renderer; 410 GtkCellRenderer *renderer;
395 GtkNotebook *notebook; 411 GtkNotebook *notebook;
@@ -419,26 +435,18 @@ fs_search_started (struct GNUNET_FSUI_SearchList * fsui_list,
419 } 435 }
420 436
421 /* build new entry */ 437 /* build new entry */
422 description = GNUNET_ECRS_uri_to_string (uri); 438 if (GNUNET_ECRS_uri_test_ksk(uri))
439 description = GNUNET_ECRS_ksk_uri_to_human_readable_string (uri);
440 else
441 description = GNUNET_NS_sks_uri_to_human_readable_string (ectx, cfg, uri);
423 if (description == NULL) 442 if (description == NULL)
424 { 443 {
425 GNUNET_GE_BREAK (ectx, 0); 444 GNUNET_GE_BREAK (ectx, 0);
426 return NULL; 445 return NULL;
427 } 446 }
428 GNUNET_GE_ASSERT (ectx,
429 strlen (description) >= strlen (GNUNET_ECRS_URI_PREFIX));
430 dhead = &description[strlen (GNUNET_ECRS_URI_PREFIX)];
431 if (0 ==
432 strncmp (dhead, GNUNET_ECRS_SEARCH_INFIX,
433 strlen (GNUNET_ECRS_SEARCH_INFIX)))
434 dhead = &dhead[strlen (GNUNET_ECRS_SEARCH_INFIX)];
435 else if (0 == strncmp (dhead,
436 GNUNET_ECRS_SUBSPACE_INFIX,
437 strlen (GNUNET_ECRS_SUBSPACE_INFIX)))
438 dhead = &dhead[strlen (GNUNET_ECRS_SUBSPACE_INFIX)];
439 list = GNUNET_malloc (sizeof (SearchList)); 447 list = GNUNET_malloc (sizeof (SearchList));
440 memset (list, 0, sizeof (SearchList)); 448 memset (list, 0, sizeof (SearchList));
441 list->searchString = GNUNET_strdup (dhead); 449 list->searchString = description;
442 list->uri = GNUNET_ECRS_uri_duplicate (uri); 450 list->uri = GNUNET_ECRS_uri_duplicate (uri);
443 list->fsui_list = fsui_list; 451 list->fsui_list = fsui_list;
444 list->next = search_head; 452 list->next = search_head;
@@ -585,10 +593,9 @@ fs_search_started (struct GNUNET_FSUI_SearchList * fsui_list,
585 gtk_list_store_append (search_summary, &iter); 593 gtk_list_store_append (search_summary, &iter);
586 gtk_list_store_set (search_summary, 594 gtk_list_store_set (search_summary,
587 &iter, 595 &iter,
588 SEARCH_SUMMARY_NAME, dhead, 596 SEARCH_SUMMARY_NAME, description,
589 SEARCH_SUMMARY_RESULT_COUNT, 0, 597 SEARCH_SUMMARY_RESULT_COUNT, 0,
590 SEARCH_SUMMARY_INTERNAL, list, -1); 598 SEARCH_SUMMARY_INTERNAL, list, -1);
591 GNUNET_free (description);
592 path = gtk_tree_model_get_path (GTK_TREE_MODEL (search_summary), &iter); 599 path = gtk_tree_model_get_path (GTK_TREE_MODEL (search_summary), &iter);
593 list->summaryViewRowReference 600 list->summaryViewRowReference
594 = gtk_tree_row_reference_new (GTK_TREE_MODEL (search_summary), path); 601 = gtk_tree_row_reference_new (GTK_TREE_MODEL (search_summary), path);
diff --git a/src/plugins/fs/search.h b/src/plugins/fs/search.h
index 37c51818..bf280397 100644
--- a/src/plugins/fs/search.h
+++ b/src/plugins/fs/search.h
@@ -54,6 +54,19 @@ void fs_search_result_received (SearchList * searchContext,
54 const struct GNUNET_ECRS_URI *uri); 54 const struct GNUNET_ECRS_URI *uri);
55 55
56/** 56/**
57 * Update the applicability and availability rating
58 * for the given search result.
59 *
60 * @param info the search result (and metadata)
61 * @param availability_rank availability estimate
62 * @param applicability_rank relevance
63 */
64void fs_search_update (SearchList * searchContext,
65 const GNUNET_ECRS_FileInfo * info,
66 int availability_rank,
67 unsigned int applicability_rank);
68
69/**
57 * A search has been started. Open tab. 70 * A search has been started. Open tab.
58 * 71 *
59 * @return internal search context 72 * @return internal search context