aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/fs/search.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/fs/search.c')
-rw-r--r--src/plugins/fs/search.c90
1 files changed, 45 insertions, 45 deletions
diff --git a/src/plugins/fs/search.c b/src/plugins/fs/search.c
index 9c89226d..cd9dd14a 100644
--- a/src/plugins/fs/search.c
+++ b/src/plugins/fs/search.c
@@ -68,7 +68,7 @@ void addEntryToSearchTree(GtkTreeStore * model,
68 unsigned char * thumb; 68 unsigned char * thumb;
69 size_t ts; 69 size_t ts;
70 GdkPixbuf * pixbuf; 70 GdkPixbuf * pixbuf;
71 GdkPixbufLoader * loader; 71 GdkPixbufLoader * loader;
72 unsigned long long size; 72 unsigned long long size;
73 73
74 mime = ECRS_getFromMetaData(meta, 74 mime = ECRS_getFromMetaData(meta,
@@ -98,11 +98,11 @@ void addEntryToSearchTree(GtkTreeStore * model,
98 EXTRACTOR_UNKNOWN, 98 EXTRACTOR_UNKNOWN,
99 -1); 99 -1);
100 if (name == NULL) 100 if (name == NULL)
101 name = STRDUP(_("no name given")); 101 name = STRDUP(_("no name given"));
102 if (ECRS_isFileUri(uri)) { 102 if (ECRS_isFileUri(uri)) {
103 size = ECRS_fileSize(uri); 103 size = ECRS_fileSize(uri);
104 } else { 104 } else {
105 size = 0; 105 size = 0;
106 } 106 }
107 thumb = NULL; 107 thumb = NULL;
108 ts = ECRS_getThumbnailFromMetaData(meta, 108 ts = ECRS_getThumbnailFromMetaData(meta,
@@ -112,7 +112,7 @@ void addEntryToSearchTree(GtkTreeStore * model,
112 gdk_pixbuf_loader_write(loader, 112 gdk_pixbuf_loader_write(loader,
113 (const guchar*) thumb, 113 (const guchar*) thumb,
114 ts, 114 ts,
115 NULL); 115 NULL);
116 pixbuf = gdk_pixbuf_loader_get_pixbuf(loader); 116 pixbuf = gdk_pixbuf_loader_get_pixbuf(loader);
117 gdk_pixbuf_loader_close(loader, 117 gdk_pixbuf_loader_close(loader,
118 NULL); 118 NULL);
@@ -137,7 +137,7 @@ void addEntryToSearchTree(GtkTreeStore * model,
137 FREE(name); 137 FREE(name);
138 FREENONNULL(thumb); 138 FREENONNULL(thumb);
139} 139}
140 140
141 141
142GtkWidget * getAnonymityButtonFromTM(GtkTreeModel * model) { 142GtkWidget * getAnonymityButtonFromTM(GtkTreeModel * model) {
143 SearchList * list; 143 SearchList * list;
@@ -155,7 +155,7 @@ GtkWidget * getAnonymityButtonFromTM(GtkTreeModel * model) {
155/** 155/**
156 * Recursively free the (internal) model data fields 156 * Recursively free the (internal) model data fields
157 * (uri and meta) from the search tree model. 157 * (uri and meta) from the search tree model.
158 */ 158 */
159static void freeIterSubtree(GtkTreeModel * tree, 159static void freeIterSubtree(GtkTreeModel * tree,
160 GtkTreeIter * iter) { 160 GtkTreeIter * iter) {
161 GtkTreeIter child; 161 GtkTreeIter child;
@@ -185,8 +185,8 @@ static void freeIterSubtree(GtkTreeModel * tree,
185 freeIterSubtree(tree, &child); 185 freeIterSubtree(tree, &child);
186 } while (gtk_tree_model_iter_next(tree, 186 } while (gtk_tree_model_iter_next(tree,
187 iter)); 187 iter));
188 188
189 189
190} 190}
191 191
192/** 192/**
@@ -203,7 +203,7 @@ void on_namespaceRatingSpinButton_changed(GtkWidget * dummy,
203 char * description; 203 char * description;
204 int rating; 204 int rating;
205 int newrating; 205 int newrating;
206 206
207 spin 207 spin
208 = glade_xml_get_widget(getMainXML(), 208 = glade_xml_get_widget(getMainXML(),
209 "namespaceRatingSpinButton"); 209 "namespaceRatingSpinButton");
@@ -212,13 +212,13 @@ void on_namespaceRatingSpinButton_changed(GtkWidget * dummy,
212 "searchNamespaceComboBoxEntry"); 212 "searchNamespaceComboBoxEntry");
213 model = gtk_combo_box_get_model(GTK_COMBO_BOX(ncbe)); 213 model = gtk_combo_box_get_model(GTK_COMBO_BOX(ncbe));
214 if (TRUE == gtk_combo_box_get_active_iter(GTK_COMBO_BOX(ncbe), 214 if (TRUE == gtk_combo_box_get_active_iter(GTK_COMBO_BOX(ncbe),
215 &iter)) { 215 &iter)) {
216 gtk_tree_model_get(model, 216 gtk_tree_model_get(model,
217 &iter, 217 &iter,
218 NS_SEARCH_DESCRIPTION, &description, 218 NS_SEARCH_DESCRIPTION, &description,
219 NS_SEARCH_ENCNAME, &encStr, 219 NS_SEARCH_ENCNAME, &encStr,
220 NS_SEARCH_RATING, &rating, 220 NS_SEARCH_RATING, &rating,
221 -1); 221 -1);
222 if ( (description != NULL) && 222 if ( (description != NULL) &&
223 (0 == strcmp(description, 223 (0 == strcmp(description,
224 _("globally"))) ) { 224 _("globally"))) ) {
@@ -241,16 +241,16 @@ void on_namespaceRatingSpinButton_changed(GtkWidget * dummy,
241 &iter, 241 &iter,
242 NS_SEARCH_RATING, rating, 242 NS_SEARCH_RATING, rating,
243 -1); 243 -1);
244 } 244 }
245 } 245 }
246 } else { 246 } else {
247 /* FIXME: if enc2hash succeeds, we may want to keep this 247 /* FIXME: if enc2hash succeeds, we may want to keep this
248 active */ 248 active */
249 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), 249 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin),
250 0); 250 0);
251 gtk_widget_set_sensitive(spin, 251 gtk_widget_set_sensitive(spin,
252 FALSE); 252 FALSE);
253 } 253 }
254} 254}
255 255
256/** 256/**
@@ -327,7 +327,7 @@ void on_searchResults_destroy(GtkWidget * dummy,
327 GtkWidget * treeview) { 327 GtkWidget * treeview) {
328 GtkTreeStore * tree; 328 GtkTreeStore * tree;
329 GtkTreeIter iter; 329 GtkTreeIter iter;
330 330
331 tree = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(treeview))); 331 tree = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(treeview)));
332 if (! gtk_tree_model_get_iter_first(GTK_TREE_MODEL(tree), 332 if (! gtk_tree_model_get_iter_first(GTK_TREE_MODEL(tree),
333 &iter)) 333 &iter))
@@ -359,13 +359,13 @@ static void addSearchResultToModel(const ECRS_FileInfo * info,
359 path = gtk_tree_row_reference_get_path(row); 359 path = gtk_tree_row_reference_get_path(row);
360 model = GTK_TREE_STORE 360 model = GTK_TREE_STORE
361 (gtk_tree_view_get_model 361 (gtk_tree_view_get_model
362 (GTK_TREE_VIEW(treeview))); 362 (GTK_TREE_VIEW(treeview)));
363 if (path != NULL) { 363 if (path != NULL) {
364 gtk_tree_model_get_iter(GTK_TREE_MODEL(model), 364 gtk_tree_model_get_iter(GTK_TREE_MODEL(model),
365 &parent, 365 &parent,
366 path); 366 path);
367 pparent = &parent; 367 pparent = &parent;
368 } else 368 } else
369 pparent = NULL; 369 pparent = NULL;
370 gtk_tree_store_insert(model, 370 gtk_tree_store_insert(model,
371 &iter, 371 &iter,
@@ -387,10 +387,10 @@ static void addSearchResultToModel(const ECRS_FileInfo * info,
387 */ 387 */
388void displaySearchResult(const ECRS_FileInfo * info, 388void displaySearchResult(const ECRS_FileInfo * info,
389 const struct ECRS_URI * uri, 389 const struct ECRS_URI * uri,
390 GtkTreeRowReference * row) { 390 GtkTreeRowReference * row) {
391 SearchList * list; 391 SearchList * list;
392 struct ECRS_URI * euri; 392 struct ECRS_URI * euri;
393 unsigned int count; 393 unsigned int count;
394 GtkTreeIter iter; 394 GtkTreeIter iter;
395 395
396 list = head; 396 list = head;
@@ -407,13 +407,13 @@ void displaySearchResult(const ECRS_FileInfo * info,
407 addSearchResultToModel(info, 407 addSearchResultToModel(info,
408 list->treeview, 408 list->treeview,
409 row); 409 row);
410 410
411 if (! gtk_tree_model_get_iter_first(GTK_TREE_MODEL(summary), 411 if (! gtk_tree_model_get_iter_first(GTK_TREE_MODEL(summary),
412 &iter)) { 412 &iter)) {
413 BREAK(); 413 BREAK();
414 return; 414 return;
415 } 415 }
416 416
417 do { 417 do {
418 gtk_tree_model_get(GTK_TREE_MODEL(summary), 418 gtk_tree_model_get(GTK_TREE_MODEL(summary),
419 &iter, 419 &iter,
@@ -454,10 +454,10 @@ void on_closeSearchButton_clicked(GtkWidget * searchPage,
454 prev = list; 454 prev = list;
455 list = list->next; 455 list = list->next;
456 } 456 }
457 457
458 if (list == NULL) 458 if (list == NULL)
459 return; 459 return;
460 460
461 uri = list->uri; 461 uri = list->uri;
462 FSUI_stopSearch(ctx, 462 FSUI_stopSearch(ctx,
463 uri); 463 uri);
@@ -466,7 +466,7 @@ void on_closeSearchButton_clicked(GtkWidget * searchPage,
466 else 466 else
467 prev->next = list->next; 467 prev->next = list->next;
468 FREE(list); 468 FREE(list);
469 469
470 notebook 470 notebook
471 = glade_xml_get_widget(getMainXML(), 471 = glade_xml_get_widget(getMainXML(),
472 "downloadNotebook"); 472 "downloadNotebook");
@@ -519,7 +519,7 @@ static GtkWidget * makeResultFrame(GtkWidget ** treeview,
519 519
520 searchXML 520 searchXML
521 = glade_xml_new(getGladeFileName(), 521 = glade_xml_new(getGladeFileName(),
522 "searchResultsFrame", 522 "searchResultsFrame",
523 PACKAGE_NAME); 523 PACKAGE_NAME);
524 connectGladeWithPlugins(searchXML); 524 connectGladeWithPlugins(searchXML);
525 window = glade_xml_get_widget(searchXML, 525 window = glade_xml_get_widget(searchXML,
@@ -534,8 +534,8 @@ static GtkWidget * makeResultFrame(GtkWidget ** treeview,
534 gtk_tree_store_new(SEARCH_NUM, 534 gtk_tree_store_new(SEARCH_NUM,
535 G_TYPE_STRING, /* name */ 535 G_TYPE_STRING, /* name */
536 G_TYPE_UINT64, /* size */ 536 G_TYPE_UINT64, /* size */
537 G_TYPE_STRING, /* mime-type */ 537 G_TYPE_STRING, /* mime-type */
538 G_TYPE_STRING, /* meta-data (some) */ 538 G_TYPE_STRING, /* meta-data (some) */
539 GDK_TYPE_PIXBUF, /* preview */ 539 GDK_TYPE_PIXBUF, /* preview */
540 G_TYPE_POINTER, /* url */ 540 G_TYPE_POINTER, /* url */
541 G_TYPE_POINTER, /* meta */ 541 G_TYPE_POINTER, /* meta */
@@ -547,7 +547,7 @@ static GtkWidget * makeResultFrame(GtkWidget ** treeview,
547 -1, 547 -1,
548 _("Name"), 548 _("Name"),
549 renderer, 549 renderer,
550 "text", SEARCH_NAME, 550 "text", SEARCH_NAME,
551 NULL); 551 NULL);
552 renderer = gtk_cell_renderer_text_new(); 552 renderer = gtk_cell_renderer_text_new();
553 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList), 553 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList),
@@ -652,7 +652,7 @@ void on_fssearchbutton_clicked(gpointer dummy2,
652 652
653 if ( (descStr != NULL) && 653 if ( (descStr != NULL) &&
654 (0 == strcmp(descStr, 654 (0 == strcmp(descStr,
655 _("globally"))) ) { 655 _("globally"))) ) {
656 ns = NULL; 656 ns = NULL;
657 } else { 657 } else {
658 GNUNET_ASSERT(strlen(ns) == sizeof(EncName) - 1); 658 GNUNET_ASSERT(strlen(ns) == sizeof(EncName) - 1);
@@ -660,7 +660,7 @@ void on_fssearchbutton_clicked(gpointer dummy2,
660 descStr = ns; 660 descStr = ns;
661 } 661 }
662 } 662 }
663 if (ns != NULL) { 663 if (ns != NULL) {
664 char * ustring; 664 char * ustring;
665 665
666 ustring = MALLOC(strlen(ss) + sizeof(EncName) + 666 ustring = MALLOC(strlen(ss) + sizeof(EncName) +
@@ -679,9 +679,9 @@ void on_fssearchbutton_clicked(gpointer dummy2,
679 } 679 }
680 FREE(ustring); 680 FREE(ustring);
681 } else { 681 } else {
682 uri = FSUI_parseCharKeywordURI(ss); 682 uri = FSUI_parseCharKeywordURI(ss);
683 } 683 }
684 if (uri == NULL) 684 if (uri == NULL)
685 return; 685 return;
686 if (ns == NULL) { 686 if (ns == NULL) {
687 tabtxt = STRDUP(ss); 687 tabtxt = STRDUP(ss);
@@ -701,7 +701,7 @@ void on_fssearchbutton_clicked(gpointer dummy2,
701 pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); 701 pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook));
702 while (list != NULL) { 702 while (list != NULL) {
703 if (ECRS_equalsUri(list->uri, 703 if (ECRS_equalsUri(list->uri,
704 uri)) { 704 uri)) {
705 for (i=0;i<pages;i++) { 705 for (i=0;i<pages;i++) {
706 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), 706 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),
707 i); 707 i);
@@ -722,7 +722,7 @@ void on_fssearchbutton_clicked(gpointer dummy2,
722 list->searchpage 722 list->searchpage
723 = makeResultFrame(&list->treeview, 723 = makeResultFrame(&list->treeview,
724 &spin); 724 &spin);
725 list->next 725 list->next
726 = head; 726 = head;
727 list->uri 727 list->uri
728 = uri; 728 = uri;
@@ -768,7 +768,7 @@ static int addNamespace(void * arg,
768 struct ECRS_MetaData * dmd; 768 struct ECRS_MetaData * dmd;
769 char * desc; 769 char * desc;
770 size_t n; 770 size_t n;
771 771
772 hash2enc(namespaceId, 772 hash2enc(namespaceId,
773 &enc); 773 &enc);
774 if (md == NULL) { 774 if (md == NULL) {
@@ -792,7 +792,7 @@ static int addNamespace(void * arg,
792 if (desc == NULL) 792 if (desc == NULL)
793 desc = STRDUP(""); 793 desc = STRDUP("");
794 } 794 }
795 795
796 n = strlen(desc) + 64; 796 n = strlen(desc) + 64;
797 name = MALLOC(n); 797 name = MALLOC(n);
798 SNPRINTF(name, 798 SNPRINTF(name,
@@ -810,7 +810,7 @@ static int addNamespace(void * arg,
810 NS_SEARCH_METADATA, dmd, 810 NS_SEARCH_METADATA, dmd,
811 NS_SEARCH_RATING, rating, 811 NS_SEARCH_RATING, rating,
812 -1); 812 -1);
813 FREE(name); 813 FREE(name);
814 return OK; 814 return OK;
815} 815}
816 816
@@ -822,8 +822,8 @@ static void updateNCBModelSafe(void * unused) {
822 GtkWidget * searchNamespaceCB; 822 GtkWidget * searchNamespaceCB;
823 GtkListStore * model; 823 GtkListStore * model;
824 GtkTreeIter iter; 824 GtkTreeIter iter;
825 825
826 model = gtk_list_store_new(NS_SEARCH_NUM, 826 model = gtk_list_store_new(NS_SEARCH_NUM,
827 G_TYPE_STRING, /* what we show */ 827 G_TYPE_STRING, /* what we show */
828 G_TYPE_STRING, /* EncName of namespace */ 828 G_TYPE_STRING, /* EncName of namespace */
829 G_TYPE_POINTER, 829 G_TYPE_POINTER,
@@ -834,7 +834,7 @@ static void updateNCBModelSafe(void * unused) {
834 &iter, 834 &iter,
835 NS_SEARCH_DESCRIPTION, _("globally"), 835 NS_SEARCH_DESCRIPTION, _("globally"),
836 NS_SEARCH_ENCNAME, NULL, 836 NS_SEARCH_ENCNAME, NULL,
837 NS_SEARCH_METADATA, NULL, 837 NS_SEARCH_METADATA, NULL,
838 NS_SEARCH_RATING, 0, 838 NS_SEARCH_RATING, 0,
839 -1); 839 -1);
840 FSUI_listNamespaces(ctx, 840 FSUI_listNamespaces(ctx,
@@ -891,7 +891,7 @@ int openTabForSearch(void * unused,
891 else if (0 == strncmp(dhead, 891 else if (0 == strncmp(dhead,
892 ECRS_SUBSPACE_INFIX, 892 ECRS_SUBSPACE_INFIX,
893 strlen(ECRS_SUBSPACE_INFIX))) 893 strlen(ECRS_SUBSPACE_INFIX)))
894 dhead = &dhead[strlen(ECRS_SUBSPACE_INFIX)]; 894 dhead = &dhead[strlen(ECRS_SUBSPACE_INFIX)];
895 label = gtk_label_new(dhead); 895 label = gtk_label_new(dhead);
896 896
897 gtk_list_store_append(summary, 897 gtk_list_store_append(summary,
@@ -944,7 +944,7 @@ void fs_search_start() {
944 = glade_xml_get_widget(getMainXML(), 944 = glade_xml_get_widget(getMainXML(),
945 "fssearchKeywordComboBoxEntry"); 945 "fssearchKeywordComboBoxEntry");
946 946
947 model = gtk_list_store_new(NS_SEARCH_NUM, 947 model = gtk_list_store_new(NS_SEARCH_NUM,
948 G_TYPE_STRING, /* what we show */ 948 G_TYPE_STRING, /* what we show */
949 G_TYPE_STRING, /* EncName of namespace */ 949 G_TYPE_STRING, /* EncName of namespace */
950 G_TYPE_POINTER, 950 G_TYPE_POINTER,
@@ -1017,7 +1017,7 @@ void fs_search_stop() {
1017 &iter, 1017 &iter,
1018 SEARCH_URI, NULL, 1018 SEARCH_URI, NULL,
1019 SEARCH_META, NULL, 1019 SEARCH_META, NULL,
1020 -1); 1020 -1);
1021 if (u != NULL) 1021 if (u != NULL)
1022 ECRS_freeUri(u); 1022 ECRS_freeUri(u);
1023 if (m != NULL) 1023 if (m != NULL)
@@ -1045,7 +1045,7 @@ void fs_search_stop() {
1045 -1); 1045 -1);
1046 } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(summary), 1046 } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(summary),
1047 &iter)); 1047 &iter));
1048 } 1048 }
1049} 1049}
1050 1050
1051/* end of search.c */ 1051/* end of search.c */