Hi,
I've been hacking up a simple bitzi query engine to look up meta-data
about files are available on the Gnutella network. The patch is my ugly
GUI hacks to add "Search Meta Data" to the pop-up menu . I've only
implemented it in Gtk2, sorry but I'm not sure what I'm doing with Glade
et all..
The guts of the actual query are all in bitzi.c (new file) which
processes the GUI event and checks if a tree view item has an SHA1
associated and if so queues up a query to bitzi's XML web-service. The
queries are paced with a g_timeout hack so as not to hammer the service,
but its a crude hack.
The resultant XML ticket is then parsed with diagnostics printed to
stdout showing the results.
Now at the moment its not useful unless you like reading stdout to
figure out if the file you've found is worth downloading. Obviously we
need some GUI feedback to indicate the "goodness" of the file. While
given enough time I could hack something up I ain't no GUI designer so I
need some feedback
The plan is to populate the bitzi_data_t structure with data from the
ticket that can be attached to the GUI display element (result) so the
GUI functions can read it and alter the display accordingly. So
* Which elements are of interest?
* Should I be expanding record_t to include a pointer to bitzi_t's or
some other thing?
I'll be away on holiday for a few days so feel free to suggest things or
even play with the code yourself ;-)
--
Alex, homepage: http://www.bennee.com/~alex/
Is that a 286 or are you just running Windows?
? bitzi.c
? bitzi.h
? core.13633
? core.14179
? core.14238
? core.14565
? doxygen.conf
? getdate.c
? gtk-gnutella
? metadata_gui2.c
? output
Index: Jmakefile
===================================================================
RCS file: /cvsroot/gtk-gnutella/gtk-gnutella-current/src/Jmakefile,v
retrieving revision 1.19
diff -u -b -r1.19 Jmakefile
--- Jmakefile 15 Jul 2004 18:29:34 -0000 1.19
+++ Jmakefile 3 Aug 2004 19:37:40 -0000
@@ -84,6 +84,7 @@
base64.c \
bg.c \
bsched.c \
+ bitzi.c \
clock.c \
cobs.c \
common.c \
Index: Makefile.SH
===================================================================
RCS file: /cvsroot/gtk-gnutella/gtk-gnutella-current/src/Makefile.SH,v
retrieving revision 1.22
diff -u -b -r1.22 Makefile.SH
--- Makefile.SH 15 Jul 2004 18:29:34 -0000 1.22
+++ Makefile.SH 3 Aug 2004 19:37:44 -0000
@@ -108,6 +108,7 @@
fileinfo_gui2.c \
gnet_stats_gui2.c \
hcache_gui2.c \
+ metadata_gui2.c \
monitor_cb2.c\
monitor_gui2.c \
nodes_cb2.c \
@@ -169,6 +170,7 @@
base32.c \
base64.c \
bg.c \
+ bitzi.c \
bsched.c \
clock.c \
cobs.c \
@@ -319,6 +321,7 @@
base64.o \
bg.o \
bsched.o \
+ bitzi.o \
clock.o \
cobs.o \
common.o \
Index: callbacks.c
===================================================================
RCS file: /cvsroot/gtk-gnutella/gtk-gnutella-current/src/callbacks.c,v
retrieving revision 1.146
diff -u -b -r1.146 callbacks.c
--- callbacks.c 1 Jul 2004 12:23:12 -0000 1.146
+++ callbacks.c 3 Aug 2004 19:37:47 -0000
@@ -605,3 +605,6 @@
#endif /* USE_GTK2 */
/* vi: set ts=4 sw=4 cindent: */
+
+
+
Index: callbacks.h
===================================================================
RCS file: /cvsroot/gtk-gnutella/gtk-gnutella-current/src/callbacks.h,v
retrieving revision 1.80
diff -u -b -r1.80 callbacks.h
--- callbacks.h 26 Jun 2004 08:40:05 -0000 1.80
+++ callbacks.h 3 Aug 2004 19:37:48 -0000
@@ -199,3 +199,11 @@
#endif /* _callbacks_h_ */
+
+void
+on_search_meta_data_activate (GtkMenuItem *menuitem,
+ gpointer user_data);
+
+void
+on_search_meta_data_activate (GtkMenuItem *menuitem,
+ gpointer user_data);
Index: drop.c
===================================================================
RCS file: /cvsroot/gtk-gnutella/gtk-gnutella-current/src/drop.c,v
retrieving revision 1.3
diff -u -b -r1.3 drop.c
--- drop.c 2 Aug 2004 16:32:50 -0000 1.3
+++ drop.c 3 Aug 2004 19:37:49 -0000
@@ -157,7 +157,6 @@
/* Skip this parameter */
continue;
}
-
p = q + sizeof "http://" - 1;
if (gchar_to_ip_strict(p, &addr, (const gchar **) &ep)) {
p = ep;
@@ -171,7 +170,6 @@
continue;
}
}
-
if (*p == ':') {
gchar *ep2;
gint error;
Index: interface-glade1.c
===================================================================
RCS file: /cvsroot/gtk-gnutella/gtk-gnutella-current/src/interface-glade1.c,v
retrieving revision 1.137
diff -u -b -r1.137 interface-glade1.c
--- interface-glade1.c 10 Jul 2004 17:27:37 -0000 1.137
+++ interface-glade1.c 3 Aug 2004 19:38:27 -0000
@@ -11929,6 +11929,8 @@
GtkWidget *separator2;
GtkWidget *popup_search_toggle_tabs;
GtkWidget *popup_search_config_cols;
+ GtkWidget *separator19;
+ GtkWidget *search_meta_data;
GtkTooltips *tooltips;
tooltips = gtk_tooltips_new ();
@@ -12172,6 +12174,23 @@
gtk_widget_show (popup_search_config_cols);
gtk_container_add (GTK_CONTAINER (popup_search), popup_search_config_cols);
+ separator19 = gtk_menu_item_new ();
+ gtk_widget_set_name (separator19, "separator19");
+ gtk_widget_ref (separator19);
+ gtk_object_set_data_full (GTK_OBJECT (popup_search), "separator19", separator19,
+ (GtkDestroyNotify) gtk_widget_unref);
+ gtk_widget_show (separator19);
+ gtk_container_add (GTK_CONTAINER (popup_search), separator19);
+ gtk_widget_set_sensitive (separator19, FALSE);
+
+ search_meta_data = gtk_menu_item_new_with_label (_("Search Meta Data"));
+ gtk_widget_set_name (search_meta_data, "search_meta_data");
+ gtk_widget_ref (search_meta_data);
+ gtk_object_set_data_full (GTK_OBJECT (popup_search), "search_meta_data", search_meta_data,
+ (GtkDestroyNotify) gtk_widget_unref);
+ gtk_widget_show (search_meta_data);
+ gtk_container_add (GTK_CONTAINER (popup_search), search_meta_data);
+
gtk_signal_connect (GTK_OBJECT (popup_search_edit_filter), "activate",
GTK_SIGNAL_FUNC (on_popup_search_edit_filter_activate),
NULL);
@@ -12226,6 +12245,9 @@
gtk_signal_connect (GTK_OBJECT (popup_search_config_cols), "activate",
GTK_SIGNAL_FUNC (on_popup_search_config_cols_activate),
NULL);
+ gtk_signal_connect (GTK_OBJECT (search_meta_data), "activate",
+ GTK_SIGNAL_FUNC (on_search_meta_data_activate),
+ NULL);
gtk_object_set_data (GTK_OBJECT (popup_search), "tooltips", tooltips);
@@ -15150,7 +15172,7 @@
gtk_widget_show (label_about_title);
gtk_box_pack_start (GTK_BOX (hbox170), label_about_title, TRUE, TRUE, 0);
- label_about_rcsid = gtk_label_new (_("$Id: interface-glade1.c,v 1.137 2004/07/10 17:27:37 wyldfire Exp $"));
+ label_about_rcsid = gtk_label_new (_("$Id: gtk-gnutella.glade,v 1.221 2004/07/10 17:27:36 wyldfire Exp $"));
gtk_widget_set_name (label_about_rcsid, "label_about_rcsid");
gtk_widget_ref (label_about_rcsid);
gtk_object_set_data_full (GTK_OBJECT (dlg_about), "label_about_rcsid", label_about_rcsid,
Index: interface-glade2.c
===================================================================
RCS file: /cvsroot/gtk-gnutella/gtk-gnutella-current/src/interface-glade2.c,v
retrieving revision 1.126
diff -u -b -r1.126 interface-glade2.c
--- interface-glade2.c 1 Jul 2004 20:33:17 -0000 1.126
+++ interface-glade2.c 3 Aug 2004 19:38:56 -0000
@@ -462,52 +462,54 @@
{
GtkWidget *popup_search;
GtkWidget *popup_search_edit_filter;
- GtkWidget *image265;
+ GtkWidget *image369;
GtkWidget *separator13;
GtkWidget *popup_search_download;
- GtkWidget *image266;
+ GtkWidget *image370;
GtkWidget *drop1;
- GtkWidget *image267;
+ GtkWidget *image371;
GtkWidget *drop1_menu;
GtkWidget *popup_search_drop_name;
GtkWidget *popup_search_drop_sha1;
GtkWidget *popup_search_drop_host;
GtkWidget *globally_drop1;
- GtkWidget *image268;
+ GtkWidget *image372;
GtkWidget *globally_drop1_menu;
GtkWidget *popup_search_drop_name_global;
GtkWidget *popup_search_drop_sha1_global;
GtkWidget *popup_search_drop_host_global;
GtkWidget *separator14;
GtkWidget *auto_download_selected_by1;
- GtkWidget *image269;
+ GtkWidget *image373;
GtkWidget *auto_download_selected_by1_menu;
GtkWidget *popup_search_autodownload_sha1;
- GtkWidget *image270;
+ GtkWidget *image374;
GtkWidget *popup_search_autodownload_name;
- GtkWidget *image271;
+ GtkWidget *image375;
GtkWidget *separator3;
GtkWidget *popup_search_new_from_selected;
- GtkWidget *image272;
+ GtkWidget *image376;
GtkWidget *separator15;
GtkWidget *popup_search_expand_all;
- GtkWidget *image273;
+ GtkWidget *image377;
GtkWidget *popup_search_collapse_all;
- GtkWidget *image274;
+ GtkWidget *image378;
GtkWidget *separator17;
GtkWidget *popup_search_stop;
- GtkWidget *image275;
+ GtkWidget *image379;
GtkWidget *popup_search_resume;
- GtkWidget *image276;
+ GtkWidget *image380;
GtkWidget *popup_search_restart;
- GtkWidget *image277;
+ GtkWidget *image381;
GtkWidget *popup_search_duplicate;
- GtkWidget *image278;
+ GtkWidget *image382;
GtkWidget *separator2;
GtkWidget *popup_search_toggle_tabs;
- GtkWidget *image279;
+ GtkWidget *image383;
GtkWidget *popup_search_config_cols;
- GtkWidget *image280;
+ GtkWidget *image384;
+ GtkWidget *separator20;
+ GtkWidget *search_meta_data;
popup_search = gtk_menu_new ();
gtk_widget_set_name (popup_search, "popup_search");
@@ -517,12 +519,12 @@
gtk_widget_show (popup_search_edit_filter);
gtk_container_add (GTK_CONTAINER (popup_search), popup_search_edit_filter);
- image265 = gtk_image_new_from_stock ("gtk-properties", GTK_ICON_SIZE_MENU);
- gtk_widget_set_name (image265, "image265");
- gtk_widget_show (image265);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (popup_search_edit_filter), image265);
+ image369 = gtk_image_new_from_stock ("gtk-properties", GTK_ICON_SIZE_MENU);
+ gtk_widget_set_name (image369, "image369");
+ gtk_widget_show (image369);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (popup_search_edit_filter), image369);
- separator13 = gtk_menu_item_new ();
+ separator13 = gtk_separator_menu_item_new ();
gtk_widget_set_name (separator13, "separator13");
gtk_widget_show (separator13);
gtk_container_add (GTK_CONTAINER (popup_search), separator13);
@@ -533,20 +535,20 @@
gtk_widget_show (popup_search_download);
gtk_container_add (GTK_CONTAINER (popup_search), popup_search_download);
- image266 = gtk_image_new_from_stock ("gtk-save", GTK_ICON_SIZE_MENU);
- gtk_widget_set_name (image266, "image266");
- gtk_widget_show (image266);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (popup_search_download), image266);
+ image370 = gtk_image_new_from_stock ("gtk-save", GTK_ICON_SIZE_MENU);
+ gtk_widget_set_name (image370, "image370");
+ gtk_widget_show (image370);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (popup_search_download), image370);
drop1 = gtk_image_menu_item_new_with_mnemonic (_("Drop..."));
gtk_widget_set_name (drop1, "drop1");
gtk_widget_show (drop1);
gtk_container_add (GTK_CONTAINER (popup_search), drop1);
- image267 = gtk_image_new_from_stock ("gtk-delete", GTK_ICON_SIZE_MENU);
- gtk_widget_set_name (image267, "image267");
- gtk_widget_show (image267);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (drop1), image267);
+ image371 = gtk_image_new_from_stock ("gtk-delete", GTK_ICON_SIZE_MENU);
+ gtk_widget_set_name (image371, "image371");
+ gtk_widget_show (image371);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (drop1), image371);
drop1_menu = gtk_menu_new ();
gtk_widget_set_name (drop1_menu, "drop1_menu");
@@ -572,10 +574,10 @@
gtk_widget_show (globally_drop1);
gtk_container_add (GTK_CONTAINER (popup_search), globally_drop1);
- image268 = gtk_image_new_from_stock ("gtk-delete", GTK_ICON_SIZE_MENU);
- gtk_widget_set_name (image268, "image268");
- gtk_widget_show (image268);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (globally_drop1), image268);
+ image372 = gtk_image_new_from_stock ("gtk-delete", GTK_ICON_SIZE_MENU);
+ gtk_widget_set_name (image372, "image372");
+ gtk_widget_show (image372);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (globally_drop1), image372);
globally_drop1_menu = gtk_menu_new ();
gtk_widget_set_name (globally_drop1_menu, "globally_drop1_menu");
@@ -596,7 +598,7 @@
gtk_widget_show (popup_search_drop_host_global);
gtk_container_add (GTK_CONTAINER (globally_drop1_menu), popup_search_drop_host_global);
- separator14 = gtk_menu_item_new ();
+ separator14 = gtk_separator_menu_item_new ();
gtk_widget_set_name (separator14, "separator14");
gtk_widget_show (separator14);
gtk_container_add (GTK_CONTAINER (popup_search), separator14);
@@ -607,10 +609,10 @@
gtk_widget_show (auto_download_selected_by1);
gtk_container_add (GTK_CONTAINER (popup_search), auto_download_selected_by1);
- image269 = gtk_image_new_from_stock ("gtk-execute", GTK_ICON_SIZE_MENU);
- gtk_widget_set_name (image269, "image269");
- gtk_widget_show (image269);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (auto_download_selected_by1), image269);
+ image373 = gtk_image_new_from_stock ("gtk-execute", GTK_ICON_SIZE_MENU);
+ gtk_widget_set_name (image373, "image373");
+ gtk_widget_show (image373);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (auto_download_selected_by1), image373);
auto_download_selected_by1_menu = gtk_menu_new ();
gtk_widget_set_name (auto_download_selected_by1_menu, "auto_download_selected_by1_menu");
@@ -621,22 +623,22 @@
gtk_widget_show (popup_search_autodownload_sha1);
gtk_container_add (GTK_CONTAINER (auto_download_selected_by1_menu), popup_search_autodownload_sha1);
- image270 = gtk_image_new_from_stock ("gtk-execute", GTK_ICON_SIZE_MENU);
- gtk_widget_set_name (image270, "image270");
- gtk_widget_show (image270);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (popup_search_autodownload_sha1), image270);
+ image374 = gtk_image_new_from_stock ("gtk-execute", GTK_ICON_SIZE_MENU);
+ gtk_widget_set_name (image374, "image374");
+ gtk_widget_show (image374);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (popup_search_autodownload_sha1), image374);
popup_search_autodownload_name = gtk_image_menu_item_new_with_mnemonic (_("name"));
gtk_widget_set_name (popup_search_autodownload_name, "popup_search_autodownload_name");
gtk_widget_show (popup_search_autodownload_name);
gtk_container_add (GTK_CONTAINER (auto_download_selected_by1_menu), popup_search_autodownload_name);
- image271 = gtk_image_new_from_stock ("gtk-execute", GTK_ICON_SIZE_MENU);
- gtk_widget_set_name (image271, "image271");
- gtk_widget_show (image271);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (popup_search_autodownload_name), image271);
+ image375 = gtk_image_new_from_stock ("gtk-execute", GTK_ICON_SIZE_MENU);
+ gtk_widget_set_name (image375, "image375");
+ gtk_widget_show (image375);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (popup_search_autodownload_name), image375);
- separator3 = gtk_menu_item_new ();
+ separator3 = gtk_separator_menu_item_new ();
gtk_widget_set_name (separator3, "separator3");
gtk_widget_show (separator3);
gtk_container_add (GTK_CONTAINER (popup_search), separator3);
@@ -647,12 +649,12 @@
gtk_widget_show (popup_search_new_from_selected);
gtk_container_add (GTK_CONTAINER (popup_search), popup_search_new_from_selected);
- image272 = gtk_image_new_from_stock ("gtk-new", GTK_ICON_SIZE_MENU);
- gtk_widget_set_name (image272, "image272");
- gtk_widget_show (image272);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (popup_search_new_from_selected), image272);
+ image376 = gtk_image_new_from_stock ("gtk-new", GTK_ICON_SIZE_MENU);
+ gtk_widget_set_name (image376, "image376");
+ gtk_widget_show (image376);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (popup_search_new_from_selected), image376);
- separator15 = gtk_menu_item_new ();
+ separator15 = gtk_separator_menu_item_new ();
gtk_widget_set_name (separator15, "separator15");
gtk_widget_show (separator15);
gtk_container_add (GTK_CONTAINER (popup_search), separator15);
@@ -663,22 +665,22 @@
gtk_widget_show (popup_search_expand_all);
gtk_container_add (GTK_CONTAINER (popup_search), popup_search_expand_all);
- image273 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU);
- gtk_widget_set_name (image273, "image273");
- gtk_widget_show (image273);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (popup_search_expand_all), image273);
+ image377 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU);
+ gtk_widget_set_name (image377, "image377");
+ gtk_widget_show (image377);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (popup_search_expand_all), image377);
popup_search_collapse_all = gtk_image_menu_item_new_with_mnemonic (_("Collapse all"));
gtk_widget_set_name (popup_search_collapse_all, "popup_search_collapse_all");
gtk_widget_show (popup_search_collapse_all);
gtk_container_add (GTK_CONTAINER (popup_search), popup_search_collapse_all);
- image274 = gtk_image_new_from_stock ("gtk-remove", GTK_ICON_SIZE_MENU);
- gtk_widget_set_name (image274, "image274");
- gtk_widget_show (image274);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (popup_search_collapse_all), image274);
+ image378 = gtk_image_new_from_stock ("gtk-remove", GTK_ICON_SIZE_MENU);
+ gtk_widget_set_name (image378, "image378");
+ gtk_widget_show (image378);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (popup_search_collapse_all), image378);
- separator17 = gtk_menu_item_new ();
+ separator17 = gtk_separator_menu_item_new ();
gtk_widget_set_name (separator17, "separator17");
gtk_widget_show (separator17);
gtk_container_add (GTK_CONTAINER (popup_search), separator17);
@@ -689,42 +691,42 @@
gtk_widget_show (popup_search_stop);
gtk_container_add (GTK_CONTAINER (popup_search), popup_search_stop);
- image275 = gtk_image_new_from_stock ("gtk-stop", GTK_ICON_SIZE_MENU);
- gtk_widget_set_name (image275, "image275");
- gtk_widget_show (image275);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (popup_search_stop), image275);
+ image379 = gtk_image_new_from_stock ("gtk-stop", GTK_ICON_SIZE_MENU);
+ gtk_widget_set_name (image379, "image379");
+ gtk_widget_show (image379);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (popup_search_stop), image379);
popup_search_resume = gtk_image_menu_item_new_with_mnemonic (_("Resume this search"));
gtk_widget_set_name (popup_search_resume, "popup_search_resume");
gtk_widget_show (popup_search_resume);
gtk_container_add (GTK_CONTAINER (popup_search), popup_search_resume);
- image276 = gtk_image_new_from_stock ("gtk-go-forward", GTK_ICON_SIZE_MENU);
- gtk_widget_set_name (image276, "image276");
- gtk_widget_show (image276);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (popup_search_resume), image276);
+ image380 = gtk_image_new_from_stock ("gtk-go-forward", GTK_ICON_SIZE_MENU);
+ gtk_widget_set_name (image380, "image380");
+ gtk_widget_show (image380);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (popup_search_resume), image380);
popup_search_restart = gtk_image_menu_item_new_with_mnemonic (_("Restart this search"));
gtk_widget_set_name (popup_search_restart, "popup_search_restart");
gtk_widget_show (popup_search_restart);
gtk_container_add (GTK_CONTAINER (popup_search), popup_search_restart);
- image277 = gtk_image_new_from_stock ("gtk-redo", GTK_ICON_SIZE_MENU);
- gtk_widget_set_name (image277, "image277");
- gtk_widget_show (image277);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (popup_search_restart), image277);
+ image381 = gtk_image_new_from_stock ("gtk-redo", GTK_ICON_SIZE_MENU);
+ gtk_widget_set_name (image381, "image381");
+ gtk_widget_show (image381);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (popup_search_restart), image381);
popup_search_duplicate = gtk_image_menu_item_new_with_mnemonic (_("Duplicate this search"));
gtk_widget_set_name (popup_search_duplicate, "popup_search_duplicate");
gtk_widget_show (popup_search_duplicate);
gtk_container_add (GTK_CONTAINER (popup_search), popup_search_duplicate);
- image278 = gtk_image_new_from_stock ("gtk-copy", GTK_ICON_SIZE_MENU);
- gtk_widget_set_name (image278, "image278");
- gtk_widget_show (image278);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (popup_search_duplicate), image278);
+ image382 = gtk_image_new_from_stock ("gtk-copy", GTK_ICON_SIZE_MENU);
+ gtk_widget_set_name (image382, "image382");
+ gtk_widget_show (image382);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (popup_search_duplicate), image382);
- separator2 = gtk_menu_item_new ();
+ separator2 = gtk_separator_menu_item_new ();
gtk_widget_set_name (separator2, "separator2");
gtk_widget_show (separator2);
gtk_container_add (GTK_CONTAINER (popup_search), separator2);
@@ -735,20 +737,31 @@
gtk_widget_show (popup_search_toggle_tabs);
gtk_container_add (GTK_CONTAINER (popup_search), popup_search_toggle_tabs);
- image279 = gtk_image_new_from_stock ("gtk-index", GTK_ICON_SIZE_MENU);
- gtk_widget_set_name (image279, "image279");
- gtk_widget_show (image279);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (popup_search_toggle_tabs), image279);
+ image383 = gtk_image_new_from_stock ("gtk-index", GTK_ICON_SIZE_MENU);
+ gtk_widget_set_name (image383, "image383");
+ gtk_widget_show (image383);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (popup_search_toggle_tabs), image383);
popup_search_config_cols = gtk_image_menu_item_new_with_mnemonic (_("Configure columns"));
gtk_widget_set_name (popup_search_config_cols, "popup_search_config_cols");
gtk_widget_show (popup_search_config_cols);
gtk_container_add (GTK_CONTAINER (popup_search), popup_search_config_cols);
- image280 = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU);
- gtk_widget_set_name (image280, "image280");
- gtk_widget_show (image280);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (popup_search_config_cols), image280);
+ image384 = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU);
+ gtk_widget_set_name (image384, "image384");
+ gtk_widget_show (image384);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (popup_search_config_cols), image384);
+
+ separator20 = gtk_separator_menu_item_new ();
+ gtk_widget_set_name (separator20, "separator20");
+ gtk_widget_show (separator20);
+ gtk_container_add (GTK_CONTAINER (popup_search), separator20);
+ gtk_widget_set_sensitive (separator20, FALSE);
+
+ search_meta_data = gtk_menu_item_new_with_mnemonic (_("Search Meta Data"));
+ gtk_widget_set_name (search_meta_data, "search_meta_data");
+ gtk_widget_show (search_meta_data);
+ gtk_container_add (GTK_CONTAINER (popup_search), search_meta_data);
g_signal_connect ((gpointer) popup_search_edit_filter, "activate",
G_CALLBACK (on_popup_search_edit_filter_activate),
@@ -807,56 +820,61 @@
g_signal_connect ((gpointer) popup_search_config_cols, "activate",
G_CALLBACK (on_popup_search_config_cols_activate),
NULL);
+ g_signal_connect ((gpointer) search_meta_data, "activate",
+ G_CALLBACK (on_search_meta_data_activate),
+ NULL);
/* Store pointers to all widgets, for use by lookup_widget(). */
GLADE_HOOKUP_OBJECT_NO_REF (popup_search, popup_search, "popup_search");
GLADE_HOOKUP_OBJECT (popup_search, popup_search_edit_filter, "popup_search_edit_filter");
- GLADE_HOOKUP_OBJECT (popup_search, image265, "image265");
+ GLADE_HOOKUP_OBJECT (popup_search, image369, "image369");
GLADE_HOOKUP_OBJECT (popup_search, separator13, "separator13");
GLADE_HOOKUP_OBJECT (popup_search, popup_search_download, "popup_search_download");
- GLADE_HOOKUP_OBJECT (popup_search, image266, "image266");
+ GLADE_HOOKUP_OBJECT (popup_search, image370, "image370");
GLADE_HOOKUP_OBJECT (popup_search, drop1, "drop1");
- GLADE_HOOKUP_OBJECT (popup_search, image267, "image267");
+ GLADE_HOOKUP_OBJECT (popup_search, image371, "image371");
GLADE_HOOKUP_OBJECT (popup_search, drop1_menu, "drop1_menu");
GLADE_HOOKUP_OBJECT (popup_search, popup_search_drop_name, "popup_search_drop_name");
GLADE_HOOKUP_OBJECT (popup_search, popup_search_drop_sha1, "popup_search_drop_sha1");
GLADE_HOOKUP_OBJECT (popup_search, popup_search_drop_host, "popup_search_drop_host");
GLADE_HOOKUP_OBJECT (popup_search, globally_drop1, "globally_drop1");
- GLADE_HOOKUP_OBJECT (popup_search, image268, "image268");
+ GLADE_HOOKUP_OBJECT (popup_search, image372, "image372");
GLADE_HOOKUP_OBJECT (popup_search, globally_drop1_menu, "globally_drop1_menu");
GLADE_HOOKUP_OBJECT (popup_search, popup_search_drop_name_global, "popup_search_drop_name_global");
GLADE_HOOKUP_OBJECT (popup_search, popup_search_drop_sha1_global, "popup_search_drop_sha1_global");
GLADE_HOOKUP_OBJECT (popup_search, popup_search_drop_host_global, "popup_search_drop_host_global");
GLADE_HOOKUP_OBJECT (popup_search, separator14, "separator14");
GLADE_HOOKUP_OBJECT (popup_search, auto_download_selected_by1, "auto_download_selected_by1");
- GLADE_HOOKUP_OBJECT (popup_search, image269, "image269");
+ GLADE_HOOKUP_OBJECT (popup_search, image373, "image373");
GLADE_HOOKUP_OBJECT (popup_search, auto_download_selected_by1_menu, "auto_download_selected_by1_menu");
GLADE_HOOKUP_OBJECT (popup_search, popup_search_autodownload_sha1, "popup_search_autodownload_sha1");
- GLADE_HOOKUP_OBJECT (popup_search, image270, "image270");
+ GLADE_HOOKUP_OBJECT (popup_search, image374, "image374");
GLADE_HOOKUP_OBJECT (popup_search, popup_search_autodownload_name, "popup_search_autodownload_name");
- GLADE_HOOKUP_OBJECT (popup_search, image271, "image271");
+ GLADE_HOOKUP_OBJECT (popup_search, image375, "image375");
GLADE_HOOKUP_OBJECT (popup_search, separator3, "separator3");
GLADE_HOOKUP_OBJECT (popup_search, popup_search_new_from_selected, "popup_search_new_from_selected");
- GLADE_HOOKUP_OBJECT (popup_search, image272, "image272");
+ GLADE_HOOKUP_OBJECT (popup_search, image376, "image376");
GLADE_HOOKUP_OBJECT (popup_search, separator15, "separator15");
GLADE_HOOKUP_OBJECT (popup_search, popup_search_expand_all, "popup_search_expand_all");
- GLADE_HOOKUP_OBJECT (popup_search, image273, "image273");
+ GLADE_HOOKUP_OBJECT (popup_search, image377, "image377");
GLADE_HOOKUP_OBJECT (popup_search, popup_search_collapse_all, "popup_search_collapse_all");
- GLADE_HOOKUP_OBJECT (popup_search, image274, "image274");
+ GLADE_HOOKUP_OBJECT (popup_search, image378, "image378");
GLADE_HOOKUP_OBJECT (popup_search, separator17, "separator17");
GLADE_HOOKUP_OBJECT (popup_search, popup_search_stop, "popup_search_stop");
- GLADE_HOOKUP_OBJECT (popup_search, image275, "image275");
+ GLADE_HOOKUP_OBJECT (popup_search, image379, "image379");
GLADE_HOOKUP_OBJECT (popup_search, popup_search_resume, "popup_search_resume");
- GLADE_HOOKUP_OBJECT (popup_search, image276, "image276");
+ GLADE_HOOKUP_OBJECT (popup_search, image380, "image380");
GLADE_HOOKUP_OBJECT (popup_search, popup_search_restart, "popup_search_restart");
- GLADE_HOOKUP_OBJECT (popup_search, image277, "image277");
+ GLADE_HOOKUP_OBJECT (popup_search, image381, "image381");
GLADE_HOOKUP_OBJECT (popup_search, popup_search_duplicate, "popup_search_duplicate");
- GLADE_HOOKUP_OBJECT (popup_search, image278, "image278");
+ GLADE_HOOKUP_OBJECT (popup_search, image382, "image382");
GLADE_HOOKUP_OBJECT (popup_search, separator2, "separator2");
GLADE_HOOKUP_OBJECT (popup_search, popup_search_toggle_tabs, "popup_search_toggle_tabs");
- GLADE_HOOKUP_OBJECT (popup_search, image279, "image279");
+ GLADE_HOOKUP_OBJECT (popup_search, image383, "image383");
GLADE_HOOKUP_OBJECT (popup_search, popup_search_config_cols, "popup_search_config_cols");
- GLADE_HOOKUP_OBJECT (popup_search, image280, "image280");
+ GLADE_HOOKUP_OBJECT (popup_search, image384, "image384");
+ GLADE_HOOKUP_OBJECT (popup_search, separator20, "separator20");
+ GLADE_HOOKUP_OBJECT (popup_search, search_meta_data, "search_meta_data");
return popup_search;
}
@@ -1587,14 +1605,14 @@
gtk_misc_set_alignment (GTK_MISC (label492), 0, 0.5);
gtk_misc_set_padding (GTK_MISC (label492), 10, 0);
- label493 = gtk_label_new (_("Rapha\303\253l Manfredi"));
+ label493 = gtk_label_new (_("Raphaël Manfredi"));
gtk_widget_set_name (label493, "label493");
gtk_widget_show (label493);
gtk_box_pack_start (GTK_BOX (vbox88), label493, FALSE, FALSE, 0);
gtk_misc_set_alignment (GTK_MISC (label493), 0, 0.5);
gtk_misc_set_padding (GTK_MISC (label493), 10, 0);
- label494 = gtk_label_new (_("Rapha\303\253l Manfredi"));
+ label494 = gtk_label_new (_("Raphaël Manfredi"));
gtk_widget_set_name (label494, "label494");
gtk_widget_show (label494);
gtk_box_pack_start (GTK_BOX (vbox88), label494, FALSE, FALSE, 0);
@@ -1695,7 +1713,7 @@
gtk_container_set_border_width (GTK_CONTAINER (button_about_close), 6);
GTK_WIDGET_SET_FLAGS (button_about_close, GTK_CAN_DEFAULT);
- label538 = gtk_label_new (_("@(#) $Id: interface-glade2.c,v 1.126 2004/07/01 20:33:17 trancetip Exp $"));
+ label538 = gtk_label_new (_("@(#) $Id: gtk2-gnutella.glade,v 1.125 2004/07/01 20:36:17 trancetip Exp $"));
gtk_widget_set_name (label538, "label538");
gtk_box_pack_start (GTK_BOX (vbox67), label538, FALSE, FALSE, 0);
gtk_widget_set_sensitive (label538, FALSE);
/*
* Bitzi search code
*
* Alex Bennee <[EMAIL PROTECTED]>
* Copyright 2004, available under GPL V2
*/
#include <libxml/parser.h>
#include <libxml/tree.h>
#include "gui.h"
#include "search_gui.h" /* search_t */
#include "http.h" /* http async stuff */
#include "bitzi.h" /* bitzi metadata */
/*
* The bitzi_request_t structure ties together each Bitzi request
* which are stored in the request queue.
*
*/
typedef struct {
guchar *bitzi_url; /* request URL */
bitzi_data_t *bitzi_data; /* extracted data */
record_t *record; /* the record */
xmlParserCtxt *ctxt; /* libxml parser context */
} bitzi_request_t;
GSList *bitzi_request_queue=NULL;
bitzi_request_t *current_bitzi_request=NULL;
gpointer current_bitzi_request_handle;
/* declarations */
static gboolean do_metadata_query(gpointer ptr);
//static gboolean do_metadata_query(gpointer *ptr);
static void process_meta_data(bitzi_request_t *request);
/*
* bitzi_host_data_ind
*
* Populate callback: more data available. When called with 0 it stops
* the parsing of the document tree.
*/
static void bitzi_host_data_ind(gpointer handle, gchar *data, gint len)
{
int result;
if (len>0)
{
g_message("bitzi_host_data_ind: %d bytes",len);
result = xmlParseChunk(current_bitzi_request->ctxt, data, len,0);
if (result!=0)
g_warning("bitzi_host_data_ind, bad xml result %d",result);
} else {
g_message("bitzi_host_data_ind: end of data (len=%d)",len);
result = xmlParseChunk(current_bitzi_request->ctxt, data, 0, 1);
if (result!=0)
g_warning("bitzi_host_data_ind - end, bad xml result %d",result);
/* process what we had and clear up */
process_meta_data(current_bitzi_request);
g_message("processed current_bitzi_request=%p",current_bitzi_request);
current_bitzi_request = NULL;
current_bitzi_request_handle = NULL;
}
}
/*
* bitzi_host_error_ind
*
* HTTP request is being stopped.
*/
static void bitzi_host_error_ind(gpointer handle, http_errtype_t type, gpointer v)
{
g_warning("bitzi_host_error_ind: failed!");
g_assert(handle==current_bitzi_request_handle);
/* process what we had and clear up */
process_meta_data(current_bitzi_request);
current_bitzi_request = NULL;
current_bitzi_request_handle = NULL;
}
/*
* These XML parsing routines are hacked up versions of those from the
* libxml2 examples
*/
/*
* process_rdf_description
*
* Parse (and eventually fill in) the bitzi specific data
*
* The fields are defined at:
* schema: http://bitzi.com/developer/bitzi-ticket.rng
* notes: http://bitzi.com/openbits/datadump
*
* The ones we have most interest in are:
*
* bz:fileGoodness="2.1"
* bz:fileJudgement="Complete"
*
* Although the other could be used to verify size data and such
*/
static void process_rdf_description(xmlNode *a_node, bitzi_data_t *data)
{
xmlNode *cur_node = NULL;
xmlAttr *cur_attr = NULL;
/* process the attributes of the rdf:Description element */
for(cur_attr = a_node->properties; cur_attr; cur_attr = cur_attr->next)
{
g_message("process_rdf_description (attributes): name %s, type %d",
cur_attr->name,
cur_attr->type);
}
/* process all the child elements of rdf:Description */
for (cur_node = a_node->children; cur_node; cur_node = cur_node->next) {
g_message("process_rdf_description (children): name: %s, type %d",
cur_node->name,
cur_node->type);
}
}
/*
* process_bitzi_ticket
*
* Iterates through the XML/RDF ticket calling various process
* functions to read the data into the bitzi_data_t
*
* This function is recursive, if the element is not explicity know we
* just recurse down a level
*/
static void process_bitzi_ticket(xmlNode * a_node, bitzi_data_t *data)
{
xmlNode *cur_node = NULL;
for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
if (cur_node->type == XML_ELEMENT_NODE) {
g_message("node type: Element, name: %s, children %p", cur_node->name,cur_node->children);
if (xmlStrcmp(cur_node->name, (const xmlChar *) "Description")==0)
process_rdf_description(cur_node,data);
else
process_bitzi_ticket(cur_node->children,data);
}
}
}
/*
** process_metadata
**
** Walk the parsed document tree and free up the data
*/
static void process_meta_data(bitzi_request_t *request)
{
xmlDoc *doc = NULL; /* the resulting document tree */
xmlNode *root = NULL;
int result;
g_message("process_meta_data: %p", request);
g_assert(request!=NULL);
/* get the document and free context */
doc = request->ctxt->myDoc;
result = request->ctxt->wellFormed;
xmlFreeParserCtxt(request->ctxt);
/* Now we can have a look at the data */
if (!result)
{
g_message("process_meta_data: doc = %p, result = %d",doc, result);
} else {
/* this just dumps the data */
root = xmlDocGetRootElement(doc);
g_message("process_meta_data: root=%p",root);
/* FIXME: allocate and pass bitzi_data_t when ready */
process_bitzi_ticket(root, NULL);
/* free it */
xmlFreeDoc(doc);
}
/* free used memory by the request */
g_free(request->bitzi_url);
//g_free(request->bitzi_data);
g_free(request);
/* set the next query up as a timeout */
if (bitzi_request_queue!=NULL)
{
g_timeout_add(1*10000, (GSourceFunc) do_metadata_query, NULL);
}
}
/*
** do_metadata_query
**
** Send a meta-data query if none is currently active
**
** Called as a timeout or direct from the click events
*/
static gboolean do_metadata_query(gpointer ptr)
{
g_message("do_metadata_query");
if (current_bitzi_request == NULL &&
bitzi_request_queue != NULL)
{
current_bitzi_request = bitzi_request_queue->data;
bitzi_request_queue = g_slist_remove(bitzi_request_queue, current_bitzi_request);
/*
* Create the XML Parser
*/
current_bitzi_request->ctxt = xmlCreatePushParserCtxt(NULL, NULL,
NULL, 0, current_bitzi_request->bitzi_url);
g_assert(current_bitzi_request->ctxt!=NULL);
/*
* Launch the asynchronous request and attach parsing
* information.
*
* We care not about headers
*/
current_bitzi_request_handle = http_async_get(current_bitzi_request->bitzi_url,
NULL, bitzi_host_data_ind, bitzi_host_error_ind);
if (!current_bitzi_request_handle) {
g_warning("could not launch a \"GET %s\" request: %s",
current_bitzi_request->bitzi_url, http_async_strerror(http_async_errno));
} else {
g_message("do_metadata_query: request %s launched", current_bitzi_request->bitzi_url);
}
}
/* always dequeue the timeout */
return FALSE;
}
/*
* Queue on entry on the metadata search queue
*/
static void queue_metadata_search(record_t *rec, gpointer null_data)
{
bitzi_request_t *request;
gchar sha1_query[SHA1_BASE32_SIZE + sizeof("http://ticket.bitzi.com/rdf/urn:sha1:")];
g_assert(rec!=NULL);
if (rec->sha1!=NULL)
{
request = g_malloc(sizeof(bitzi_request_t));
request->record=rec;
gm_snprintf(sha1_query, sizeof(sha1_query),
"http://ticket.bitzi.com/rdf/urn:sha1:%s", sha1_base32(rec->sha1));
request->bitzi_url=g_strdup(sha1_query);
g_message("queue_metadat_search request=%s (%p)",request->bitzi_url,request->bitzi_url);
bitzi_request_queue = g_slist_append(bitzi_request_queue, request);
}
}
/*
** GUI Actions
*/
void
on_search_meta_data_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
search_t *search;
GtkTreeSelection *selection;
GSList *sl;
g_message("on_search_meta_data_active: called");
/* collect the list of files selected */
search = search_gui_get_current_search();
g_assert(search != NULL);
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(search->tree_view));
sl = tree_selection_collect_data(selection, gui_record_sha1_eq);
/* Queue up our requests */
g_message("on_search_meta_data: %d items",g_slist_position(sl,g_slist_last(sl))+1);
g_slist_foreach(sl, (GFunc) queue_metadata_search, NULL);
g_slist_free(sl);
/* Kick off requests if nothing happening */
if(current_bitzi_request==NULL)
do_metadata_query(NULL);
}
/*
** Bitzi Meta-data structure
**
*/
#include <libxml/tree.h>
#include <libxml/parser.h>
typedef struct {
xmlChar *judgement;
} bitzi_data_t;