forked from osmocom/wireshark
Move the code to set the title on a window when a capture is in progress
to the "start live capture" callback, and call that from "do_capture()". When opening a capture file, don't pop up the "What do you want to do?" pane when closing any existing file you have open, as we're just going to put the regular view up right after that. svn path=/trunk/; revision=13332
This commit is contained in:
parent
641106f21d
commit
79a39eddbc
|
@ -414,27 +414,23 @@ do_capture(capture_options *capture_opts)
|
|||
{
|
||||
gboolean is_tempfile;
|
||||
gboolean ret;
|
||||
gchar *title;
|
||||
|
||||
/* open the output file (temporary/specified name/ringbuffer) and close the old one */
|
||||
if(!capture_open_output(capture_opts, &is_tempfile)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
title = g_strdup_printf("%s: Capturing - Ethereal",
|
||||
get_interface_descriptive_name(capture_opts->iface));
|
||||
if (capture_opts->sync_mode) {
|
||||
/* sync mode: do the capture in a child process */
|
||||
ret = sync_pipe_do_capture(capture_opts, is_tempfile);
|
||||
/* capture is still running */
|
||||
set_main_window_name(title);
|
||||
cf_callback_invoke(cf_cb_live_capture_started, capture_opts);
|
||||
} else {
|
||||
/* normal mode: do the capture synchronously */
|
||||
set_main_window_name(title);
|
||||
cf_callback_invoke(cf_cb_live_capture_started, capture_opts);
|
||||
ret = normal_do_capture(capture_opts, is_tempfile);
|
||||
/* capture is finished here */
|
||||
}
|
||||
g_free(title);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
39
file.c
39
file.c
|
@ -100,6 +100,8 @@ static guint32 firstsec, firstusec;
|
|||
static guint32 prevsec, prevusec;
|
||||
static guint32 cum_bytes = 0;
|
||||
|
||||
static void cf_reset_state(capture_file *cf);
|
||||
|
||||
static void read_packet(capture_file *cf, long offset);
|
||||
|
||||
static void rescan_packets(capture_file *cf, const char *action, const char *action_item,
|
||||
|
@ -141,8 +143,8 @@ static gboolean copy_binary_file(const char *from_filename, const char *to_fil
|
|||
|
||||
|
||||
/* one callback for now, we could have a list later */
|
||||
cf_callback_t cf_cb = NULL;
|
||||
gpointer cf_cb_user_data = NULL;
|
||||
static cf_callback_t cf_cb = NULL;
|
||||
static gpointer cf_cb_user_data = NULL;
|
||||
|
||||
void
|
||||
cf_callback_invoke(int event, gpointer data)
|
||||
|
@ -193,7 +195,7 @@ cf_open(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
|
|||
|
||||
/* The open succeeded. Close whatever capture file we had open,
|
||||
and fill in the information for this file. */
|
||||
cf_close(cf);
|
||||
cf_reset_state(cf);
|
||||
|
||||
/* Initialize all data structures used for dissection. */
|
||||
init_dissection();
|
||||
|
@ -247,9 +249,15 @@ fail:
|
|||
return CF_ERROR;
|
||||
}
|
||||
|
||||
/* Reset everything to a pristine state */
|
||||
void
|
||||
cf_close(capture_file *cf)
|
||||
/*
|
||||
* Reset the state for the currently closed file, but don't do the
|
||||
* UI callbacks; this is for use in "cf_open()", where we don't
|
||||
* want the UI to go from "file open" to "file closed" back to
|
||||
* "file open", we want it to go from "old file open" to "new file
|
||||
* open and being read".
|
||||
*/
|
||||
static void
|
||||
cf_reset_state(capture_file *cf)
|
||||
{
|
||||
/* Die if we're in the middle of reading a file. */
|
||||
g_assert(cf->state != FILE_READ_IN_PROGRESS);
|
||||
|
@ -297,14 +305,21 @@ cf_close(capture_file *cf)
|
|||
cf->esec = 0;
|
||||
cf->eusec = 0;
|
||||
|
||||
cf_callback_invoke(cf_cb_file_closed, cf);
|
||||
|
||||
reset_tap_listeners();
|
||||
|
||||
/* We have no file open. */
|
||||
cf->state = FILE_CLOSED;
|
||||
}
|
||||
|
||||
/* Reset everything to a pristine state */
|
||||
void
|
||||
cf_close(capture_file *cf)
|
||||
{
|
||||
cf_reset_state(cf);
|
||||
|
||||
cf_callback_invoke(cf_cb_file_closed, cf);
|
||||
}
|
||||
|
||||
cf_read_status_t
|
||||
cf_read(capture_file *cf)
|
||||
{
|
||||
|
@ -487,13 +502,7 @@ cf_read(capture_file *cf)
|
|||
cf_status_t
|
||||
cf_start_tail(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
|
||||
{
|
||||
cf_status_t cf_status;
|
||||
|
||||
cf_status = cf_open(cf, fname, is_tempfile, err);
|
||||
if (cf_status == CF_OK) {
|
||||
cf_callback_invoke(cf_cb_live_capture_started, cf);
|
||||
}
|
||||
return cf_status;
|
||||
return cf_open(cf, fname, is_tempfile, err);
|
||||
}
|
||||
|
||||
cf_read_status_t
|
||||
|
|
3
file.h
3
file.h
|
@ -72,6 +72,9 @@ typedef enum {
|
|||
|
||||
typedef void (*cf_callback_t) (gint event, gpointer data, gpointer user_data);
|
||||
|
||||
extern void
|
||||
cf_callback_invoke(int event, gpointer data);
|
||||
|
||||
extern void
|
||||
cf_callback_add(cf_callback_t func, gpointer user_data);
|
||||
|
||||
|
|
127
gtk/main.c
127
gtk/main.c
|
@ -191,7 +191,8 @@ capture_options *capture_opts = &global_capture_opts;
|
|||
|
||||
|
||||
static void create_main_window(gint, gint, gint, e_prefs*);
|
||||
static void file_quit_answered_cb(gpointer dialog _U_, gint btn, gpointer data _U_);
|
||||
static void show_main_window(gboolean);
|
||||
static void file_quit_answered_cb(gpointer dialog, gint btn, gpointer data);
|
||||
static void main_save_window_geometry(GtkWidget *widget);
|
||||
|
||||
#define E_DFILTER_CM_KEY "display_filter_combo"
|
||||
|
@ -1288,7 +1289,7 @@ set_display_filename(capture_file *cf)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
main_cf_cb_file_closed(capture_file *cf)
|
||||
{
|
||||
/* Destroy all windows, which refer to the
|
||||
|
@ -1315,7 +1316,7 @@ main_cf_cb_file_closed(capture_file *cf)
|
|||
main_set_for_capture_file(FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
main_cf_cb_file_read_start(capture_file *cf)
|
||||
{
|
||||
const gchar *name_ptr;
|
||||
|
@ -1328,7 +1329,7 @@ main_cf_cb_file_read_start(capture_file *cf)
|
|||
g_free(load_msg);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
main_cf_cb_file_read_finished(capture_file *cf)
|
||||
{
|
||||
statusbar_pop_file_msg();
|
||||
|
@ -1346,10 +1347,10 @@ main_cf_cb_file_read_finished(capture_file *cf)
|
|||
main_set_for_capture_file(TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
main_cf_cb_live_capture_started(capture_options *capture_opts)
|
||||
{
|
||||
gchar *capture_msg;
|
||||
gchar *capture_msg, *title;
|
||||
|
||||
/* Disable menu items that make no sense if you're currently running
|
||||
a capture. */
|
||||
|
@ -1365,11 +1366,16 @@ main_cf_cb_live_capture_started(capture_options *capture_opts)
|
|||
|
||||
g_free(capture_msg);
|
||||
|
||||
title = g_strdup_printf("%s: Capturing - Ethereal",
|
||||
get_interface_descriptive_name(capture_opts->iface));
|
||||
set_main_window_name(title);
|
||||
g_free(title);
|
||||
|
||||
/* Set up main window for a capture file. */
|
||||
main_set_for_capture_file(TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
main_cf_cb_live_capture_finished(capture_file *cf)
|
||||
{
|
||||
/* Pop the "<live capture in progress>" message off the status bar. */
|
||||
|
@ -1390,7 +1396,7 @@ main_cf_cb_live_capture_finished(capture_file *cf)
|
|||
main_set_for_capture_file(TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
main_cf_cb_packet_selected(gpointer data)
|
||||
{
|
||||
capture_file *cf = data;
|
||||
|
@ -1405,7 +1411,7 @@ main_cf_cb_packet_selected(gpointer data)
|
|||
set_menus_for_selected_packet(cf);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
main_cf_cb_packet_unselected(capture_file *cf)
|
||||
{
|
||||
/* Clear out the display of that packet. */
|
||||
|
@ -1415,14 +1421,14 @@ main_cf_cb_packet_unselected(capture_file *cf)
|
|||
set_menus_for_selected_packet(cf);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
main_cf_cb_field_unselected(capture_file *cf)
|
||||
{
|
||||
statusbar_pop_field_msg();
|
||||
set_menus_for_selected_tree_row(cf);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
main_cf_cb_file_safe_started(gchar * filename)
|
||||
{
|
||||
const gchar *name_ptr;
|
||||
|
@ -1436,21 +1442,21 @@ main_cf_cb_file_safe_started(gchar * filename)
|
|||
g_free(save_msg);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
main_cf_cb_file_safe_finished(gpointer data _U_)
|
||||
{
|
||||
/* Pop the "Saving:" message off the status bar. */
|
||||
statusbar_pop_file_msg();
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
main_cf_cb_file_safe_failed(gpointer data _U_)
|
||||
{
|
||||
/* Pop the "Saving:" message off the status bar. */
|
||||
statusbar_pop_file_msg();
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
main_cf_cb_file_safe_reload_finished(gpointer data _U_)
|
||||
{
|
||||
set_menus_for_unsaved_capture_file(FALSE);
|
||||
|
@ -2308,18 +2314,6 @@ main(int argc, char *argv[])
|
|||
/* the window can be sized only, if it's not already shown, so do it now! */
|
||||
main_load_window_geometry(top_level);
|
||||
|
||||
/*** we have finished all init things, show the main window ***/
|
||||
gtk_widget_show(top_level);
|
||||
|
||||
/* the window can be maximized only, if it's visible, so do it after show! */
|
||||
main_load_window_geometry(top_level);
|
||||
|
||||
/* process all pending GUI events before continue */
|
||||
while (gtk_events_pending()) gtk_main_iteration();
|
||||
|
||||
/* Pop up any queued-up alert boxes. */
|
||||
display_queued_messages();
|
||||
|
||||
/* If we were given the name of a capture file, read it in now;
|
||||
we defer it until now, so that, if we can't open it, and pop
|
||||
up an alert box, the alert box is more likely to come up on
|
||||
|
@ -2327,6 +2321,7 @@ main(int argc, char *argv[])
|
|||
alert box, so, if we get one of those, it's more likely to come
|
||||
up on top of us. */
|
||||
if (cf_name) {
|
||||
show_main_window(TRUE);
|
||||
if (rfilter != NULL) {
|
||||
if (!dfilter_compile(rfilter, &rfcode)) {
|
||||
bad_dfilter_alert_box(rfilter);
|
||||
|
@ -2379,43 +2374,45 @@ main(int argc, char *argv[])
|
|||
cfile.rfcode = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
#ifdef HAVE_LIBPCAP
|
||||
if (start_capture) {
|
||||
if (capture_opts->save_file != NULL) {
|
||||
/* Save the directory name for future file dialogs. */
|
||||
/* (get_dirname overwrites filename) */
|
||||
s = get_dirname(g_strdup(capture_opts->save_file));
|
||||
set_last_open_dir(s);
|
||||
g_free(s);
|
||||
}
|
||||
/* "-k" was specified; start a capture. */
|
||||
if (do_capture(capture_opts)) {
|
||||
/* The capture started. Open tap windows; we do so after creating
|
||||
the main window, to avoid GTK warnings, and after starting the
|
||||
capture, so we know we have something to tap. */
|
||||
if (tap_opt && tli) {
|
||||
(*tli->func)(tap_opt);
|
||||
g_free(tap_opt);
|
||||
if (start_capture) {
|
||||
if (capture_opts->save_file != NULL) {
|
||||
/* Save the directory name for future file dialogs. */
|
||||
/* (get_dirname overwrites filename) */
|
||||
s = get_dirname(g_strdup(capture_opts->save_file));
|
||||
set_last_open_dir(s);
|
||||
g_free(s);
|
||||
}
|
||||
/* "-k" was specified; start a capture. */
|
||||
show_main_window(TRUE);
|
||||
if (do_capture(capture_opts)) {
|
||||
/* The capture started. Open tap windows; we do so after creating
|
||||
the main window, to avoid GTK warnings, and after starting the
|
||||
capture, so we know we have something to tap. */
|
||||
if (tap_opt && tli) {
|
||||
(*tli->func)(tap_opt);
|
||||
g_free(tap_opt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
set_menus_for_capture_in_progress(FALSE);
|
||||
}
|
||||
|
||||
/* if the user didn't supplied a capture filter, use the one to filter out remote connections like SSH */
|
||||
if (!start_capture && (capture_opts->cfilter == NULL || strlen(capture_opts->cfilter) == 0)) {
|
||||
if (capture_opts->cfilter) {
|
||||
g_free(capture_opts->cfilter);
|
||||
else {
|
||||
show_main_window(FALSE);
|
||||
set_menus_for_capture_in_progress(FALSE);
|
||||
}
|
||||
capture_opts->cfilter = g_strdup(get_conn_cfilter());
|
||||
}
|
||||
|
||||
/* if the user didn't supplied a capture filter, use the one to filter out remote connections like SSH */
|
||||
if (!start_capture && (capture_opts->cfilter == NULL || strlen(capture_opts->cfilter) == 0)) {
|
||||
if (capture_opts->cfilter) {
|
||||
g_free(capture_opts->cfilter);
|
||||
}
|
||||
capture_opts->cfilter = g_strdup(get_conn_cfilter());
|
||||
}
|
||||
#else /* HAVE_LIBPCAP */
|
||||
set_menus_for_capture_in_progress(FALSE);
|
||||
show_main_window(FALSE);
|
||||
set_menus_for_capture_in_progress(FALSE);
|
||||
#endif /* HAVE_LIBPCAP */
|
||||
}
|
||||
|
||||
gtk_main();
|
||||
|
||||
|
@ -3177,3 +3174,21 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
|
|||
welcome_pane = welcome_new();
|
||||
gtk_widget_show(welcome_pane);
|
||||
}
|
||||
|
||||
static void
|
||||
show_main_window(gboolean doing_work)
|
||||
{
|
||||
main_set_for_capture_file(doing_work);
|
||||
|
||||
/*** we have finished all init things, show the main window ***/
|
||||
gtk_widget_show(top_level);
|
||||
|
||||
/* the window can be maximized only, if it's visible, so do it after show! */
|
||||
main_load_window_geometry(top_level);
|
||||
|
||||
/* process all pending GUI events before continue */
|
||||
while (gtk_events_pending()) gtk_main_iteration();
|
||||
|
||||
/* Pop up any queued-up alert boxes. */
|
||||
display_queued_messages();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue