aboutsummaryrefslogtreecommitdiffstats
path: root/gtk/http_stat.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2004-03-27 11:13:03 +0000
committerGuy Harris <guy@alum.mit.edu>2004-03-27 11:13:03 +0000
commite85f05b0ec016d1b5bf9ef22d916fed2e711e814 (patch)
tree5c7ba3d8a6ca6cfef12e328b217f7c433b94982f /gtk/http_stat.c
parent9925eb8ff3c5f569096b9a84bfad817f5acf4295 (diff)
From Lars Roland: use the generic filter dialog for the SIP, HTTP, WSP,
and BOOTP taps. Get rid of the "dlg" variable in some of those taps - it's never set, so it's always null, and nothing useful is done with it if it's null. Make static some variables and functions not used outside the source file in which they're defined. svn path=/trunk/; revision=10500
Diffstat (limited to 'gtk/http_stat.c')
-rw-r--r--gtk/http_stat.c119
1 files changed, 12 insertions, 107 deletions
diff --git a/gtk/http_stat.c b/gtk/http_stat.c
index 98784315f1..e60f1db0f6 100644
--- a/gtk/http_stat.c
+++ b/gtk/http_stat.c
@@ -1,7 +1,7 @@
/* http_stat.c
* http_stat 2003 Jean-Michel FAYARD
*
- * $Id: http_stat.c,v 1.25 2004/03/13 14:07:14 ulfl Exp $
+ * $Id: http_stat.c,v 1.26 2004/03/27 11:13:02 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -42,6 +42,8 @@
#include "../packet-http.h"
#include "../globals.h"
#include "compat_macros.h"
+#include "../tap_dfilter_dlg.h"
+#include "tap_dfilter_dlg.h"
/* used to keep track of the statictics for an entire program interface */
@@ -82,9 +84,6 @@ typedef struct _http_request_methode_t {
httpstat_t *sp;
} http_request_methode_t;
-static GtkWidget *dlg=NULL;
-static GtkWidget *filter_entry;
-
static const value_string vals_status_code[] = {
{ 100, "Continue" },
{ 101, "Switching Protocols" },
@@ -392,7 +391,7 @@ gtk_httpstat_init(char *optarg)
*informational_fr, *success_fr, *redirection_fr,
*client_errors_fr, *server_errors_fr, *request_fr;
- if (!strncmp (optarg, "http,stat,", 10)){
+ if (strncmp (optarg, "http,stat,", 10) == 0){
filter=optarg+10;
} else {
filter=NULL;
@@ -502,118 +501,24 @@ gtk_httpstat_init(char *optarg)
g_string_free(error_string, TRUE);
return ;
}
- if (dlg)
- {
- gtk_widget_destroy( dlg );
- }
gtk_widget_show_all( sp->win );
http_init_hash(sp);
retap_packets(&cfile);
}
-
-
-static void
-httpstat_start_button_clicked(GtkWidget *item _U_, gpointer data _U_)
-{
- GString *str;
- char *filter;
-
- str = g_string_new("http,stat,");
- filter=(char *)gtk_entry_get_text(GTK_ENTRY(filter_entry));
- str = g_string_append(str, filter);
- gtk_httpstat_init(str->str);
- g_string_free(str, TRUE);
-}
-
-static void
-dlg_destroy_cb(void)
-{
- dlg=NULL;
-}
-
-static void
-dlg_cancel_cb(GtkWidget *cancel_bt _U_, gpointer parent_w)
-{
- gtk_widget_destroy(GTK_WIDGET(parent_w));
-}
-
-static void
-gtk_httpstat_cb(GtkWidget *w _U_, gpointer d _U_)
-{
- GtkWidget *dlg_box;
- GtkWidget *filter_box, *filter_label;
- GtkWidget *bbox, *start_button, *cancel_button;
-
- /* if the window is already open, bring it to front */
- if(dlg){
- gdk_window_raise(dlg->window);
- return;
- }
-
- dlg=dlg_window_new("Ethereal: Compute HTTP statistics");
- SIGNAL_CONNECT(dlg, "destroy", dlg_destroy_cb, NULL);
-
- dlg_box=gtk_vbox_new(FALSE, 10);
- gtk_container_border_width(GTK_CONTAINER(dlg_box), 10);
- gtk_container_add(GTK_CONTAINER(dlg), dlg_box);
- gtk_widget_show(dlg_box);
-
- /* Filter box */
- filter_box=gtk_hbox_new(FALSE, 3);
-
- /* Filter label */
- filter_label=gtk_label_new("Filter:");
- gtk_box_pack_start(GTK_BOX(filter_box), filter_label, FALSE, FALSE, 0);
- gtk_widget_show(filter_label);
-
- /* Filter entry */
- filter_entry=gtk_entry_new();
- WIDGET_SET_SIZE(filter_entry, 300, -1);
- gtk_box_pack_start(GTK_BOX(filter_box), filter_entry, TRUE, TRUE, 0);
- gtk_widget_show(filter_entry);
-
- gtk_box_pack_start(GTK_BOX(dlg_box), filter_box, TRUE, TRUE, 0);
- gtk_widget_show(filter_box);
-
- /* button box */
- bbox = dlg_button_row_new(ETHEREAL_STOCK_CREATE_STAT, GTK_STOCK_CANCEL, NULL);
- gtk_box_pack_start(GTK_BOX(dlg_box), bbox, FALSE, FALSE, 0);
- gtk_widget_show(bbox);
-
- start_button = OBJECT_GET_DATA(bbox, ETHEREAL_STOCK_CREATE_STAT);
- gtk_widget_grab_default(start_button );
- SIGNAL_CONNECT_OBJECT(start_button, "clicked",
- httpstat_start_button_clicked, NULL);
-
- cancel_button = OBJECT_GET_DATA(bbox, GTK_STOCK_CANCEL);
- SIGNAL_CONNECT(cancel_button, "clicked", dlg_cancel_cb, dlg);
-
- /* Catch the "activate" signal on the filter text entry, so that
- if the user types Return there, we act as if the "Create Stat"
- button had been selected, as happens if Return is typed if
- some widget that *doesn't* handle the Return key has the input
- focus. */
- dlg_set_activate(filter_entry, start_button);
-
- /* Catch the "key_press_event" signal in the window, so that we can
- catch the ESC key being pressed and act as if the "Cancel" button
- had been selected. */
- dlg_set_cancel(dlg, cancel_button);
-
- /* Give the initial focus to the "Filter" entry box. */
- gtk_widget_grab_focus(filter_entry);
-
- gtk_widget_show_all(dlg);
-}
-
+static tap_dfilter_dlg http_stat_dlg = {
+ "HTTP Packet Counter",
+ "http,stat",
+ gtk_httpstat_init,
+ -1
+};
void
register_tap_listener_gtkhttpstat(void)
{
- register_ethereal_tap("http,stat,", gtk_httpstat_init);
+ register_ethereal_tap("http,stat", gtk_httpstat_init);
register_tap_menu_item("HTTP", REGISTER_TAP_GROUP_NONE,
- gtk_httpstat_cb, NULL, NULL, NULL);
+ gtk_tap_dfilter_dlg_cb, NULL, NULL, &(http_stat_dlg));
}