Rename the tap_dfilter_dlg.[ch] files to reflect that they can do more
[obnox/wireshark/wip.git] / gtk / smb2_stat.c
index 76b87900ce6cdd57d6c9bfd38f6eeb47206c56f0..3a327f30731cd99ac1d132bd5b61150e14ec352a 100644 (file)
@@ -3,8 +3,8 @@
  *
  * $Id$
  *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
  * Copyright 1998 Gerald Combs
  *
  * This program is free software; you can redistribute it and/or
@@ -29,7 +29,6 @@
 #ifdef HAVE_SYS_TYPES_H
 # include <sys/types.h>
 #endif
-
 #include <string.h>
 
 #include <gtk/gtk.h>
 #include <epan/packet_info.h>
 #include <epan/epan.h>
 #include <epan/value_string.h>
-
 #include <epan/tap.h>
 #include <epan/dissectors/packet-smb2.h>
-#include "../register.h"
+
 #include "../timestats.h"
-#include "compat_macros.h"
 #include "../simple_dialog.h"
-#include "gui_utils.h"
-#include "dlg_utils.h"
 #include "../file.h"
 #include "../globals.h"
-#include "filter_dlg.h"
-#include "service_response_time_table.h"
 #include "../stat_menu.h"
-#include "../tap_dfilter_dlg.h"
-#include "gtkglobals.h"
+
+#include "gtk/gui_utils.h"
+#include "gtk/dlg_utils.h"
+#include "gtk/filter_dlg.h"
+#include "gtk/service_response_time_table.h"
+#include "gtk/tap_param_dlg.h"
+#include "gtk/gtkglobals.h"
+#include "gtk/main.h"
 
 
 /* used to keep track of the statistics for an entire program interface */
@@ -112,8 +111,6 @@ smb2stat_draw(void *pss)
 }
 
 
-void protect_thread_critical_region(void);
-void unprotect_thread_critical_region(void);
 static void
 win_destroy_cb(GtkWindow *win _U_, gpointer data)
 {
@@ -134,7 +131,7 @@ gtk_smb2stat_init(const char *optarg, void *userdata _U_)
        smb2stat_t *ss;
        const char *filter=NULL;
        GtkWidget *label;
-       char filter_string[256];
+       char *filter_string;
        GString *error_string;
        int i;
        GtkWidget *vbox;
@@ -142,14 +139,15 @@ gtk_smb2stat_init(const char *optarg, void *userdata _U_)
        GtkWidget *close_bt;
 
        if(!strncmp(optarg,"smb2,srt,",9)){
-               filter=optarg+8;
+               filter=optarg+9;
        } else {
                filter=NULL;
        }
 
        ss=g_malloc(sizeof(smb2stat_t));
 
-       ss->win=window_new(GTK_WINDOW_TOPLEVEL, "smb2-stat");
+       ss->win = dlg_window_new("smb2-stat");  /* transient_for top_level */
+       gtk_window_set_destroy_with_parent (GTK_WINDOW(ss->win), TRUE);
        gtk_window_set_default_size(GTK_WINDOW(ss->win), 550, 400);
        smb2stat_set_title(ss);
 
@@ -160,8 +158,10 @@ gtk_smb2stat_init(const char *optarg, void *userdata _U_)
        label=gtk_label_new("SMB2 Service Response Time statistics");
        gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
 
-       g_snprintf(filter_string,255,"Filter:%s",filter?filter:"");
+       filter_string = g_strdup_printf("Filter: %s", filter ? filter : "");
        label=gtk_label_new(filter_string);
+       g_free(filter_string);
+       gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
        gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
 
        label=gtk_label_new("SMB2 Commands");
@@ -172,13 +172,13 @@ gtk_smb2stat_init(const char *optarg, void *userdata _U_)
 
        init_srt_table(&ss->smb2_srt_table, 256, vbox, "smb2.cmd");
        for(i=0;i<256;i++){
-               init_srt_table_row(&ss->smb2_srt_table, i, val_to_str(i, smb2_cmd_vals, "Unknown(0x%02x)"));
+               init_srt_table_row(&ss->smb2_srt_table, i, val_to_str_ext(i, &smb2_cmd_vals_ext, "Unknown(0x%02x)"));
        }
 
 
-       error_string=register_tap_listener("smb2", ss, filter, smb2stat_reset, smb2stat_packet, smb2stat_draw);
+       error_string=register_tap_listener("smb2", ss, filter, 0, smb2stat_reset, smb2stat_packet, smb2stat_draw);
        if(error_string){
-               simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, error_string->str);
+               simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str);
                g_string_free(error_string, TRUE);
                g_free(ss);
                return;
@@ -188,23 +188,30 @@ gtk_smb2stat_init(const char *optarg, void *userdata _U_)
        bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
        gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
 
-       close_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CLOSE);
+       close_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
        window_set_cancel_button(ss->win, close_bt, window_cancel_button_cb);
 
-       SIGNAL_CONNECT(ss->win, "delete_event", window_delete_event_cb, NULL);
-       SIGNAL_CONNECT(ss->win, "destroy", win_destroy_cb, ss);
+       g_signal_connect(ss->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
+       g_signal_connect(ss->win, "destroy", G_CALLBACK(win_destroy_cb), ss);
 
        gtk_widget_show_all(ss->win);
        window_present(ss->win);
-       
-       cf_retap_packets(&cfile, FALSE);
+
+       cf_retap_packets(&cfile);
+       gdk_window_raise(ss->win->window);
 }
 
-static tap_dfilter_dlg smb2_stat_dlg = {
+static tap_param smb2_stat_params[] = {
+       { PARAM_FILTER, "Filter", NULL }
+};
+
+static tap_param_dlg smb2_stat_dlg = {
        "SMB2 SRT Statistics",
        "smb2,srt",
        gtk_smb2stat_init,
-       -1
+       -1,
+       G_N_ELEMENTS(smb2_stat_params),
+       smb2_stat_params
 };
 
 void