1999-09-09 04:25:49 +00:00
|
|
|
/* file_dlg.c
|
|
|
|
* Dialog boxes for handling files
|
|
|
|
*
|
2003-09-24 08:43:34 +00:00
|
|
|
* $Id: file_dlg.c,v 1.61 2003/09/24 08:43:34 guy Exp $
|
1999-09-09 04:25:49 +00:00
|
|
|
*
|
|
|
|
* Ethereal - Network traffic analyzer
|
Enable "Match Selected" only if there's a field selected *and* we can do
a "Match Selected" on it - we can't do a "Match Selected" if the field
has no value (e.g., FT_NULL) and has a length of 0.
If we unselect the current packet, we don't have a protocol tree, so we
don't have a currently selected field - clear the "Match Selected" menu
item and the display in the status line of information about the
currently selected field.
Move the low-level statusbar manipulation into "gtk/main.c", in routines
whose API doesn't expose anything GTK+-ish.
"close_cap_file()" calls one of those routines to clear out the status
bar, so it doesn't need to take a pointer to the statusbar widget as an
argument.
"clear_tree_and_hex_views()" is purely a display-manipulating routine;
move it to "gtk/proto_draw.c".
Extract from "tree_view_unselect_row_cb()" an "unselect_field()" routine
to do all the work that needs to be done if the currently selected
protocol tree row is unselected, and call it if the currently selected
packet list row is unselected (if it's unselected, there *is* no
protocol tree, so no row can be selected), as well as from
"tree_view_unselect_row_cb()".
Before pushing a new field-description message onto the statusbar, pop
the old one off.
Get rid of an unused variable (set, but not used).
svn path=/trunk/; revision=3513
2001-06-05 07:39:31 +00:00
|
|
|
* By Gerald Combs <gerald@ethereal.com>
|
1999-09-09 04:25:49 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-09-09 04:25:49 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-09-09 04:25:49 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-09-09 04:25:49 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
1999-09-01 03:04:24 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2002-09-05 18:48:52 +00:00
|
|
|
#include <gtk/gtk.h>
|
2001-10-24 07:18:39 +00:00
|
|
|
|
On Windows, use the directory in which the binary resides as the
directory in which global data files are stored. If an installed binary
is being run, that's the correct directory for them; if a build-tree
binary is being run, the "manuf" file will be there, and you can put
other data files there as well, if necessary.
Do the same with plugins, except that, if there's no
"plugins\\{version}" subdirectory of that directory, fall back on the
default installation directory, so you at least have a place where you
can put plugins for use by build-tree binaries. (Should we, instead,
have the Windows build procedure create a subdirectory of the "plugins"
source directory, with the plugin version number as its name, and copy
the plugins there, so you'd use the build-tree plugin binaries?)
Move "test_for_directory()" out of "util.c" and into
"epan/filesystem.c", with the other file system access portability
wrappers and convenience routines. Fix "util.h" not to declare it - or
other routines moved to "epan/filesystem.c" a while ago.
svn path=/trunk/; revision=3858
2001-08-21 06:39:18 +00:00
|
|
|
#include <epan/filesystem.h>
|
|
|
|
|
1999-09-01 03:04:24 +00:00
|
|
|
#include "globals.h"
|
1999-10-20 22:36:05 +00:00
|
|
|
#include "gtkglobals.h"
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/resolv.h>
|
1999-09-01 03:04:24 +00:00
|
|
|
#include "keys.h"
|
2000-02-12 06:46:54 +00:00
|
|
|
#include "filter_prefs.h"
|
Split "filter_dialog_cb()" into "filter_dialog_cb()", which pops up a
"global" dialog box when "Edit:Filters" is selected, so that the list of
filters can be edited, and "filter_browse_cb()", which pops up a dialog
box associated with a "Filter:" button and a text entry widget attached
to that button, so that a filter can be selected or saved (although it
also supports the same editing that the "global" dialog box does).
Have "filter_dialog_cb()" connect the window in which the "Filter:"
button lives and the filter dialog box, so that:
if the window in which the "Filter:" button lives goes away, so
does the filter dialog box (as it no longer has a text widget
into which it can stuff the selected filter);
if the "Filter:" button is clicked when there's already a filter
dialog box open, we just reactivate that existing dialog box
rather than popping up a new one.
Also keep a pointer to the "global" filter dialog box, so that we also
arrange that there's only one of them (by reactivating the existing on
if "Edit:Filters" is selected when there's already a "global" filter
dialog box open).
Keep around pointers to the dialog boxes that contain the "Filter:"
buttons, so that we can arrange that there be only one of them (that was
a side-effect of an earlier attempt at fixing the problems described
above, but it's still useful for keeping multiple competing dialog boxes
from being open - there's more of that to be done).
Make the pointer to the "Open Capture File" dialog box widget static to
"file_dlg.c" - nobody outside of "file_dlg.c cares about it.
svn path=/trunk/; revision=1774
2000-04-01 12:03:42 +00:00
|
|
|
#include "ui_util.h"
|
2000-01-03 06:59:25 +00:00
|
|
|
#include "simple_dialog.h"
|
1999-09-01 03:04:24 +00:00
|
|
|
#include "menu.h"
|
2000-02-12 06:58:42 +00:00
|
|
|
#include "file_dlg.h"
|
2000-05-08 07:13:40 +00:00
|
|
|
#include "dlg_utils.h"
|
2001-04-09 22:35:23 +00:00
|
|
|
#include "main.h"
|
2002-11-10 11:00:29 +00:00
|
|
|
#include "compat_macros.h"
|
2003-07-22 03:14:31 +00:00
|
|
|
#include "prefs.h"
|
2003-08-18 21:27:11 +00:00
|
|
|
#include "color.h"
|
|
|
|
#include "gtk/color_filters.h"
|
|
|
|
#include "gtk/color_dlg.h"
|
2000-01-25 05:48:47 +00:00
|
|
|
|
1999-09-01 03:04:24 +00:00
|
|
|
static void file_open_ok_cb(GtkWidget *w, GtkFileSelection *fs);
|
Split "filter_dialog_cb()" into "filter_dialog_cb()", which pops up a
"global" dialog box when "Edit:Filters" is selected, so that the list of
filters can be edited, and "filter_browse_cb()", which pops up a dialog
box associated with a "Filter:" button and a text entry widget attached
to that button, so that a filter can be selected or saved (although it
also supports the same editing that the "global" dialog box does).
Have "filter_dialog_cb()" connect the window in which the "Filter:"
button lives and the filter dialog box, so that:
if the window in which the "Filter:" button lives goes away, so
does the filter dialog box (as it no longer has a text widget
into which it can stuff the selected filter);
if the "Filter:" button is clicked when there's already a filter
dialog box open, we just reactivate that existing dialog box
rather than popping up a new one.
Also keep a pointer to the "global" filter dialog box, so that we also
arrange that there's only one of them (by reactivating the existing on
if "Edit:Filters" is selected when there's already a "global" filter
dialog box open).
Keep around pointers to the dialog boxes that contain the "Filter:"
buttons, so that we can arrange that there be only one of them (that was
a side-effect of an earlier attempt at fixing the problems described
above, but it's still useful for keeping multiple competing dialog boxes
from being open - there's more of that to be done).
Make the pointer to the "Open Capture File" dialog box widget static to
"file_dlg.c" - nobody outside of "file_dlg.c cares about it.
svn path=/trunk/; revision=1774
2000-04-01 12:03:42 +00:00
|
|
|
static void file_open_destroy_cb(GtkWidget *win, gpointer user_data);
|
1999-12-06 09:02:48 +00:00
|
|
|
static void select_file_type_cb(GtkWidget *w, gpointer data);
|
1999-09-01 03:04:24 +00:00
|
|
|
static void file_save_as_ok_cb(GtkWidget *w, GtkFileSelection *fs);
|
2000-04-10 18:40:13 +00:00
|
|
|
static void file_save_as_destroy_cb(GtkWidget *win, gpointer user_data);
|
2003-08-18 21:27:11 +00:00
|
|
|
static void file_color_import_ok_cb(GtkWidget *w, GtkFileSelection *fs);
|
|
|
|
static void file_color_import_destroy_cb(GtkWidget *win, gpointer user_data);
|
|
|
|
static void file_color_export_ok_cb(GtkWidget *w, GtkFileSelection *fs);
|
|
|
|
static void file_color_export_destroy_cb(GtkWidget *win, gpointer user_data);
|
1999-09-01 03:04:24 +00:00
|
|
|
|
2001-05-31 08:36:46 +00:00
|
|
|
#define E_FILE_M_RESOLVE_KEY "file_dlg_mac_resolve_key"
|
|
|
|
#define E_FILE_N_RESOLVE_KEY "file_dlg_network_resolve_key"
|
|
|
|
#define E_FILE_T_RESOLVE_KEY "file_dlg_transport_resolve_key"
|
2000-06-02 03:35:39 +00:00
|
|
|
|
2003-08-18 21:27:11 +00:00
|
|
|
#define ARGUMENT_CL "argument_cl"
|
|
|
|
|
Split "filter_dialog_cb()" into "filter_dialog_cb()", which pops up a
"global" dialog box when "Edit:Filters" is selected, so that the list of
filters can be edited, and "filter_browse_cb()", which pops up a dialog
box associated with a "Filter:" button and a text entry widget attached
to that button, so that a filter can be selected or saved (although it
also supports the same editing that the "global" dialog box does).
Have "filter_dialog_cb()" connect the window in which the "Filter:"
button lives and the filter dialog box, so that:
if the window in which the "Filter:" button lives goes away, so
does the filter dialog box (as it no longer has a text widget
into which it can stuff the selected filter);
if the "Filter:" button is clicked when there's already a filter
dialog box open, we just reactivate that existing dialog box
rather than popping up a new one.
Also keep a pointer to the "global" filter dialog box, so that we also
arrange that there's only one of them (by reactivating the existing on
if "Edit:Filters" is selected when there's already a "global" filter
dialog box open).
Keep around pointers to the dialog boxes that contain the "Filter:"
buttons, so that we can arrange that there be only one of them (that was
a side-effect of an earlier attempt at fixing the problems described
above, but it's still useful for keeping multiple competing dialog boxes
from being open - there's more of that to be done).
Make the pointer to the "Open Capture File" dialog box widget static to
"file_dlg.c" - nobody outside of "file_dlg.c cares about it.
svn path=/trunk/; revision=1774
2000-04-01 12:03:42 +00:00
|
|
|
/*
|
|
|
|
* Keep a static pointer to the current "Open Capture File" window, if
|
|
|
|
* any, so that if somebody tries to do "File:Open" while there's already
|
|
|
|
* an "Open Capture File" window up, we just pop up the existing one,
|
|
|
|
* rather than creating a new one.
|
|
|
|
*/
|
2000-04-10 18:40:13 +00:00
|
|
|
static GtkWidget *file_open_w;
|
Split "filter_dialog_cb()" into "filter_dialog_cb()", which pops up a
"global" dialog box when "Edit:Filters" is selected, so that the list of
filters can be edited, and "filter_browse_cb()", which pops up a dialog
box associated with a "Filter:" button and a text entry widget attached
to that button, so that a filter can be selected or saved (although it
also supports the same editing that the "global" dialog box does).
Have "filter_dialog_cb()" connect the window in which the "Filter:"
button lives and the filter dialog box, so that:
if the window in which the "Filter:" button lives goes away, so
does the filter dialog box (as it no longer has a text widget
into which it can stuff the selected filter);
if the "Filter:" button is clicked when there's already a filter
dialog box open, we just reactivate that existing dialog box
rather than popping up a new one.
Also keep a pointer to the "global" filter dialog box, so that we also
arrange that there's only one of them (by reactivating the existing on
if "Edit:Filters" is selected when there's already a "global" filter
dialog box open).
Keep around pointers to the dialog boxes that contain the "Filter:"
buttons, so that we can arrange that there be only one of them (that was
a side-effect of an earlier attempt at fixing the problems described
above, but it's still useful for keeping multiple competing dialog boxes
from being open - there's more of that to be done).
Make the pointer to the "Open Capture File" dialog box widget static to
"file_dlg.c" - nobody outside of "file_dlg.c cares about it.
svn path=/trunk/; revision=1774
2000-04-01 12:03:42 +00:00
|
|
|
|
1999-09-01 03:04:24 +00:00
|
|
|
/* Open a file */
|
|
|
|
void
|
2002-03-05 11:56:00 +00:00
|
|
|
file_open_cmd_cb(GtkWidget *w, gpointer data _U_)
|
In the process of destroying a filter editing dialog box, we get a
selection change event on the list of filters. Unfortunately, this can
happen after some other widgets in that dialog box have already been
destroyed - including some of the widgets that such a selection change
event can change.
This sometimes happened when "filter_prefs_delete()" hadn't been called,
so the mechanism we had been using, with a Boolean datum attached to the
dialog box, set in "filter_prefs_delete()" before we actually destroy
the dialog box, wasn't sufficient to keep that from happening.
Attach to the top-level window data items containing pointers to the
widgets changed when a filter is selected from the list, give each of
those widgets their own destroy callbacks, clear the pointer attached to
the top-level widget when the widget is destroyed, and don't do anything
to the widget when a filter is selected from the list if the pointer for
that widget is null, as that means the widget's been destroyed and we
*can't* do anything to it.
Not all filter editing dialogs created on behalf of a "Filter:" button
next to a text entry box should, when you click "OK", activate the text
entry box; if the text entry box is part of a dialog box with multiple
widgets, the user might not have filled in all of the items in that
dialog box, so you shouldn't activate it for them. Add a mechanism by
which, when creating a filter editing dialog box, you can specify
whether the "OK" button should just fill in the text entry box or should
fill it in and also activate it.
svn path=/trunk/; revision=2922
2001-01-21 01:45:07 +00:00
|
|
|
{
|
2001-05-31 08:36:46 +00:00
|
|
|
GtkWidget *main_vb, *filter_hbox, *filter_bt, *filter_te,
|
|
|
|
*m_resolv_cb, *n_resolv_cb, *t_resolv_cb;
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2001-05-31 08:36:46 +00:00
|
|
|
GtkAccelGroup *accel_group;
|
2002-11-03 17:38:45 +00:00
|
|
|
#endif
|
In the process of destroying a filter editing dialog box, we get a
selection change event on the list of filters. Unfortunately, this can
happen after some other widgets in that dialog box have already been
destroyed - including some of the widgets that such a selection change
event can change.
This sometimes happened when "filter_prefs_delete()" hadn't been called,
so the mechanism we had been using, with a Boolean datum attached to the
dialog box, set in "filter_prefs_delete()" before we actually destroy
the dialog box, wasn't sufficient to keep that from happening.
Attach to the top-level window data items containing pointers to the
widgets changed when a filter is selected from the list, give each of
those widgets their own destroy callbacks, clear the pointer attached to
the top-level widget when the widget is destroyed, and don't do anything
to the widget when a filter is selected from the list if the pointer for
that widget is null, as that means the widget's been destroyed and we
*can't* do anything to it.
Not all filter editing dialogs created on behalf of a "Filter:" button
next to a text entry box should, when you click "OK", activate the text
entry box; if the text entry box is part of a dialog box with multiple
widgets, the user might not have filled in all of the items in that
dialog box, so you shouldn't activate it for them. Add a mechanism by
which, when creating a filter editing dialog box, you can specify
whether the "OK" button should just fill in the text entry box or should
fill it in and also activate it.
svn path=/trunk/; revision=2922
2001-01-21 01:45:07 +00:00
|
|
|
/* No Apply button, and "OK" just sets our text widget, it doesn't
|
|
|
|
activate it (i.e., it doesn't cause us to try to open the file). */
|
2001-01-21 02:27:24 +00:00
|
|
|
static construct_args_t args = {
|
|
|
|
"Ethereal: Read Filter",
|
|
|
|
FALSE,
|
|
|
|
FALSE
|
|
|
|
};
|
1999-09-01 03:04:24 +00:00
|
|
|
|
2000-04-10 18:40:13 +00:00
|
|
|
if (file_open_w != NULL) {
|
Split "filter_dialog_cb()" into "filter_dialog_cb()", which pops up a
"global" dialog box when "Edit:Filters" is selected, so that the list of
filters can be edited, and "filter_browse_cb()", which pops up a dialog
box associated with a "Filter:" button and a text entry widget attached
to that button, so that a filter can be selected or saved (although it
also supports the same editing that the "global" dialog box does).
Have "filter_dialog_cb()" connect the window in which the "Filter:"
button lives and the filter dialog box, so that:
if the window in which the "Filter:" button lives goes away, so
does the filter dialog box (as it no longer has a text widget
into which it can stuff the selected filter);
if the "Filter:" button is clicked when there's already a filter
dialog box open, we just reactivate that existing dialog box
rather than popping up a new one.
Also keep a pointer to the "global" filter dialog box, so that we also
arrange that there's only one of them (by reactivating the existing on
if "Edit:Filters" is selected when there's already a "global" filter
dialog box open).
Keep around pointers to the dialog boxes that contain the "Filter:"
buttons, so that we can arrange that there be only one of them (that was
a side-effect of an earlier attempt at fixing the problems described
above, but it's still useful for keeping multiple competing dialog boxes
from being open - there's more of that to be done).
Make the pointer to the "Open Capture File" dialog box widget static to
"file_dlg.c" - nobody outside of "file_dlg.c cares about it.
svn path=/trunk/; revision=1774
2000-04-01 12:03:42 +00:00
|
|
|
/* There's already an "Open Capture File" dialog box; reactivate it. */
|
2000-04-10 18:40:13 +00:00
|
|
|
reactivate_window(file_open_w);
|
Split "filter_dialog_cb()" into "filter_dialog_cb()", which pops up a
"global" dialog box when "Edit:Filters" is selected, so that the list of
filters can be edited, and "filter_browse_cb()", which pops up a dialog
box associated with a "Filter:" button and a text entry widget attached
to that button, so that a filter can be selected or saved (although it
also supports the same editing that the "global" dialog box does).
Have "filter_dialog_cb()" connect the window in which the "Filter:"
button lives and the filter dialog box, so that:
if the window in which the "Filter:" button lives goes away, so
does the filter dialog box (as it no longer has a text widget
into which it can stuff the selected filter);
if the "Filter:" button is clicked when there's already a filter
dialog box open, we just reactivate that existing dialog box
rather than popping up a new one.
Also keep a pointer to the "global" filter dialog box, so that we also
arrange that there's only one of them (by reactivating the existing on
if "Edit:Filters" is selected when there's already a "global" filter
dialog box open).
Keep around pointers to the dialog boxes that contain the "Filter:"
buttons, so that we can arrange that there be only one of them (that was
a side-effect of an earlier attempt at fixing the problems described
above, but it's still useful for keeping multiple competing dialog boxes
from being open - there's more of that to be done).
Make the pointer to the "Open Capture File" dialog box widget static to
"file_dlg.c" - nobody outside of "file_dlg.c cares about it.
svn path=/trunk/; revision=1774
2000-04-01 12:03:42 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-09-24 08:43:34 +00:00
|
|
|
file_open_w = file_selection_new ("Ethereal: Open Capture File");
|
2002-11-10 11:00:29 +00:00
|
|
|
SIGNAL_CONNECT(file_open_w, "destroy", file_open_destroy_cb, NULL);
|
2000-06-02 03:35:39 +00:00
|
|
|
|
2002-11-10 11:00:29 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2001-05-31 08:36:46 +00:00
|
|
|
/* Accelerator group for the accelerators (or, as they're called in
|
|
|
|
Windows and, I think, in Motif, "mnemonics"; Alt+<key> is a mnemonic,
|
|
|
|
Ctrl+<key> is an accelerator). */
|
|
|
|
accel_group = gtk_accel_group_new();
|
|
|
|
gtk_window_add_accel_group(GTK_WINDOW(file_open_w), accel_group);
|
2002-11-03 17:38:45 +00:00
|
|
|
#endif
|
2001-05-31 08:36:46 +00:00
|
|
|
|
2000-07-31 04:53:40 +00:00
|
|
|
/* If we've opened a file, start out by showing the files in the directory
|
|
|
|
in which that file resided. */
|
|
|
|
if (last_open_dir)
|
2001-04-09 22:35:23 +00:00
|
|
|
gtk_file_selection_set_filename(GTK_FILE_SELECTION(file_open_w), last_open_dir);
|
2000-07-31 04:53:40 +00:00
|
|
|
|
2001-05-31 08:36:46 +00:00
|
|
|
/* Container for each row of widgets */
|
|
|
|
main_vb = gtk_vbox_new(FALSE, 3);
|
|
|
|
gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
|
|
|
|
gtk_box_pack_start(GTK_BOX(GTK_FILE_SELECTION(file_open_w)->action_area),
|
|
|
|
main_vb, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(main_vb);
|
1999-09-01 03:04:24 +00:00
|
|
|
|
|
|
|
filter_hbox = gtk_hbox_new(FALSE, 1);
|
|
|
|
gtk_container_border_width(GTK_CONTAINER(filter_hbox), 0);
|
2001-05-31 08:36:46 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(main_vb), filter_hbox, FALSE, FALSE, 0);
|
1999-09-01 03:04:24 +00:00
|
|
|
gtk_widget_show(filter_hbox);
|
|
|
|
|
|
|
|
filter_bt = gtk_button_new_with_label("Filter:");
|
2002-11-10 11:00:29 +00:00
|
|
|
SIGNAL_CONNECT(filter_bt, "clicked", display_filter_construct_cb, &args);
|
2003-01-15 05:20:19 +00:00
|
|
|
SIGNAL_CONNECT(filter_bt, "destroy", filter_button_destroy_cb, NULL);
|
1999-09-01 03:04:24 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(filter_hbox), filter_bt, FALSE, TRUE, 0);
|
|
|
|
gtk_widget_show(filter_bt);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
1999-09-01 03:04:24 +00:00
|
|
|
filter_te = gtk_entry_new();
|
2002-11-10 11:00:29 +00:00
|
|
|
OBJECT_SET_DATA(filter_bt, E_FILT_TE_PTR_KEY, filter_te);
|
1999-09-01 03:04:24 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(filter_hbox), filter_te, TRUE, TRUE, 3);
|
|
|
|
gtk_widget_show(filter_te);
|
|
|
|
|
2002-11-10 11:00:29 +00:00
|
|
|
OBJECT_SET_DATA(GTK_FILE_SELECTION(file_open_w)->ok_button,
|
|
|
|
E_RFILTER_TE_KEY, filter_te);
|
1999-09-01 03:04:24 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2001-05-31 08:36:46 +00:00
|
|
|
m_resolv_cb = dlg_check_button_new_with_label_with_mnemonic(
|
|
|
|
"Enable _MAC name resolution", accel_group);
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
m_resolv_cb = gtk_check_button_new_with_mnemonic(
|
|
|
|
"Enable _MAC name resolution");
|
|
|
|
#endif
|
2001-05-31 08:36:46 +00:00
|
|
|
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(m_resolv_cb),
|
2002-01-13 20:35:12 +00:00
|
|
|
g_resolv_flags & RESOLV_MAC);
|
2001-05-31 08:36:46 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(main_vb), m_resolv_cb, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(m_resolv_cb);
|
2002-11-10 11:00:29 +00:00
|
|
|
OBJECT_SET_DATA(GTK_FILE_SELECTION(file_open_w)->ok_button,
|
|
|
|
E_FILE_M_RESOLVE_KEY, m_resolv_cb);
|
2001-05-31 08:36:46 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2001-05-31 08:36:46 +00:00
|
|
|
n_resolv_cb = dlg_check_button_new_with_label_with_mnemonic(
|
|
|
|
"Enable _network name resolution", accel_group);
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
n_resolv_cb = gtk_check_button_new_with_mnemonic(
|
|
|
|
"Enable _network name resolution");
|
|
|
|
#endif
|
2001-05-31 08:36:46 +00:00
|
|
|
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(n_resolv_cb),
|
2002-01-13 20:35:12 +00:00
|
|
|
g_resolv_flags & RESOLV_NETWORK);
|
2001-05-31 08:36:46 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(main_vb), n_resolv_cb, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(n_resolv_cb);
|
2002-11-10 11:00:29 +00:00
|
|
|
OBJECT_SET_DATA(GTK_FILE_SELECTION(file_open_w)->ok_button,
|
2001-05-31 08:36:46 +00:00
|
|
|
E_FILE_N_RESOLVE_KEY, n_resolv_cb);
|
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2001-05-31 08:36:46 +00:00
|
|
|
t_resolv_cb = dlg_check_button_new_with_label_with_mnemonic(
|
|
|
|
"Enable _transport name resolution", accel_group);
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
t_resolv_cb = gtk_check_button_new_with_mnemonic(
|
|
|
|
"Enable _transport name resolution");
|
|
|
|
#endif
|
2001-05-31 08:36:46 +00:00
|
|
|
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(t_resolv_cb),
|
2002-01-13 20:35:12 +00:00
|
|
|
g_resolv_flags & RESOLV_TRANSPORT);
|
2001-05-31 08:36:46 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(main_vb), t_resolv_cb, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(t_resolv_cb);
|
2002-11-10 11:00:29 +00:00
|
|
|
OBJECT_SET_DATA(GTK_FILE_SELECTION(file_open_w)->ok_button,
|
2001-05-31 08:36:46 +00:00
|
|
|
E_FILE_T_RESOLVE_KEY, t_resolv_cb);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
/* Connect the ok_button to file_open_ok_cb function and pass along a
|
|
|
|
pointer to the file selection box widget */
|
2002-11-10 11:00:29 +00:00
|
|
|
SIGNAL_CONNECT(GTK_FILE_SELECTION(file_open_w)->ok_button, "clicked",
|
|
|
|
file_open_ok_cb, file_open_w);
|
2002-11-03 17:38:45 +00:00
|
|
|
|
2002-11-10 11:00:29 +00:00
|
|
|
OBJECT_SET_DATA(GTK_FILE_SELECTION(file_open_w)->ok_button,
|
|
|
|
E_DFILTER_TE_KEY, OBJECT_GET_DATA(w, E_DFILTER_TE_KEY));
|
2001-05-31 08:36:46 +00:00
|
|
|
|
1999-09-01 03:04:24 +00:00
|
|
|
/* Connect the cancel_button to destroy the widget */
|
2002-11-10 11:00:29 +00:00
|
|
|
SIGNAL_CONNECT_OBJECT(GTK_FILE_SELECTION(file_open_w)->cancel_button,
|
|
|
|
"clicked", (GtkSignalFunc)gtk_widget_destroy,
|
|
|
|
file_open_w);
|
1999-09-01 03:04:24 +00:00
|
|
|
|
2000-05-08 07:13:40 +00:00
|
|
|
/* 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(file_open_w, GTK_FILE_SELECTION(file_open_w)->cancel_button);
|
|
|
|
|
2000-04-10 18:40:13 +00:00
|
|
|
gtk_widget_show(file_open_w);
|
1999-09-01 03:04:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
file_open_ok_cb(GtkWidget *w, GtkFileSelection *fs) {
|
|
|
|
gchar *cf_name, *rfilter, *s;
|
2001-05-31 08:36:46 +00:00
|
|
|
GtkWidget *filter_te, *m_resolv_cb, *n_resolv_cb, *t_resolv_cb;
|
2001-02-01 20:21:25 +00:00
|
|
|
dfilter_t *rfcode = NULL;
|
1999-09-01 03:04:24 +00:00
|
|
|
int err;
|
|
|
|
|
|
|
|
cf_name = g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION (fs)));
|
2002-11-10 11:00:29 +00:00
|
|
|
filter_te = OBJECT_GET_DATA(w, E_RFILTER_TE_KEY);
|
|
|
|
rfilter = (gchar *)gtk_entry_get_text(GTK_ENTRY(filter_te));
|
2001-02-01 20:21:25 +00:00
|
|
|
if (!dfilter_compile(rfilter, &rfcode)) {
|
2002-09-09 20:39:01 +00:00
|
|
|
g_free(cf_name);
|
2000-07-20 05:10:02 +00:00
|
|
|
simple_dialog(ESD_TYPE_CRIT, NULL, dfilter_error_msg);
|
1999-10-12 05:01:07 +00:00
|
|
|
return;
|
1999-09-01 03:04:24 +00:00
|
|
|
}
|
|
|
|
|
2000-01-01 04:28:45 +00:00
|
|
|
/* Perhaps the user specified a directory instead of a file.
|
2000-07-31 04:53:40 +00:00
|
|
|
Check whether they did. */
|
|
|
|
if (test_for_directory(cf_name) == EISDIR) {
|
|
|
|
/* It's a directory - set the file selection box to display that
|
|
|
|
directory, don't try to open the directory as a capture file. */
|
2001-04-09 22:35:23 +00:00
|
|
|
set_last_open_dir(cf_name);
|
2002-09-09 20:39:01 +00:00
|
|
|
g_free(cf_name);
|
2001-04-09 22:35:23 +00:00
|
|
|
gtk_file_selection_set_filename(GTK_FILE_SELECTION(fs), last_open_dir);
|
2000-01-01 04:28:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-09-01 03:04:24 +00:00
|
|
|
/* Try to open the capture file. */
|
2003-09-15 22:48:42 +00:00
|
|
|
if ((err = cf_open(cf_name, FALSE, &cfile)) != 0) {
|
1999-09-01 03:04:24 +00:00
|
|
|
/* We couldn't open it; don't dismiss the open dialog box,
|
|
|
|
just leave it around so that the user can, after they
|
|
|
|
dismiss the alert box popped up for the open error,
|
|
|
|
try again. */
|
|
|
|
if (rfcode != NULL)
|
2001-02-01 20:21:25 +00:00
|
|
|
dfilter_free(rfcode);
|
2000-01-01 04:28:45 +00:00
|
|
|
g_free(cf_name);
|
1999-09-01 03:04:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-09-15 22:48:42 +00:00
|
|
|
/* Attach the new read filter to "cf" ("cf_open()" succeeded, so
|
1999-09-01 03:04:24 +00:00
|
|
|
it closed the previous capture file, and thus destroyed any
|
|
|
|
previous read filter attached to "cf"). */
|
2000-06-27 04:36:03 +00:00
|
|
|
cfile.rfcode = rfcode;
|
1999-09-01 03:04:24 +00:00
|
|
|
|
2000-06-02 03:35:39 +00:00
|
|
|
/* Set the global resolving variable */
|
2003-07-22 03:14:31 +00:00
|
|
|
g_resolv_flags = prefs.name_resolve & RESOLV_CONCURRENT;
|
2002-11-10 11:00:29 +00:00
|
|
|
m_resolv_cb = OBJECT_GET_DATA(w, E_FILE_M_RESOLVE_KEY);
|
2002-01-13 20:35:12 +00:00
|
|
|
g_resolv_flags |= GTK_TOGGLE_BUTTON (m_resolv_cb)->active ? RESOLV_MAC : RESOLV_NONE;
|
2002-11-10 11:00:29 +00:00
|
|
|
n_resolv_cb = OBJECT_GET_DATA(w, E_FILE_N_RESOLVE_KEY);
|
2002-01-13 20:35:12 +00:00
|
|
|
g_resolv_flags |= GTK_TOGGLE_BUTTON (n_resolv_cb)->active ? RESOLV_NETWORK : RESOLV_NONE;
|
2002-11-10 11:00:29 +00:00
|
|
|
t_resolv_cb = OBJECT_GET_DATA(w, E_FILE_T_RESOLVE_KEY);
|
2002-01-13 20:35:12 +00:00
|
|
|
g_resolv_flags |= GTK_TOGGLE_BUTTON (t_resolv_cb)->active ? RESOLV_TRANSPORT : RESOLV_NONE;
|
2000-06-02 03:35:39 +00:00
|
|
|
|
1999-09-01 03:04:24 +00:00
|
|
|
/* We've crossed the Rubicon; get rid of the file selection box. */
|
|
|
|
gtk_widget_hide(GTK_WIDGET (fs));
|
|
|
|
gtk_widget_destroy(GTK_WIDGET (fs));
|
|
|
|
|
2003-09-15 22:48:42 +00:00
|
|
|
switch (cf_read(&cfile, &err)) {
|
Add routines to Wiretap to allow a client of Wiretap to get:
a pointer to the "wtap_pkthdr" structure for an open capture
file;
a pointer to the "wtap_pseudo_header" union for an open capture
file;
a pointer to the packet buffer for an open capture file;
so that a program using "wtap_read()" in a loop can get at those items.
Keep, in a "capture_file" structure, an indicator of whether:
no file is open;
a file is open, and being read;
a file is open, and is being read, but the user tried to quit
out of reading the file (e.g., by doing "File/Quit");
a file is open, and has been completely read.
Abort if we try to close a capture that's being read if the user hasn't
tried to quit out of the read.
Have "File/Quit" check if a file is being read; if so, just set the
state indicator to "user tried to quit out of it", so that the code
reading the file can do what's appropriate to clean up, rather than
closing the file out from under that code and causing crashes.
Have "read_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
close the capture and return an indication that the read was aborted by
the user. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "continue_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
return an indication that the read was aborted by the user if that
happened. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "finish_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
close the capture and return an indication that the read was aborted by
the user if that happened. Otherwise, return an indication of whether
the read completely succeeded or failed in the middle (and, if it
failed, return the error code through a pointer).
Have their callers check whether the read was aborted or not and, if it
was, bail out in the appropriate fashion (exit if it's reading a file
specified by "-r" on the command line; exit the main loop if it's
reading a file specified with File->Open; kill the capture child if it's
"continue_tail_cap_file()"; exit the main loop if it's
"finish_tail_cap_file()".
svn path=/trunk/; revision=2095
2000-06-27 07:13:42 +00:00
|
|
|
|
|
|
|
case READ_SUCCESS:
|
|
|
|
case READ_ERROR:
|
|
|
|
/* Just because we got an error, that doesn't mean we were unable
|
|
|
|
to read any of the file; we handle what we could get from the
|
|
|
|
file. */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case READ_ABORTED:
|
2000-07-03 09:34:27 +00:00
|
|
|
/* The user bailed out of re-reading the capture file; the
|
|
|
|
capture file has been closed - just free the capture file name
|
|
|
|
string and return (without changing the last containing
|
|
|
|
directory). */
|
|
|
|
g_free(cf_name);
|
Add routines to Wiretap to allow a client of Wiretap to get:
a pointer to the "wtap_pkthdr" structure for an open capture
file;
a pointer to the "wtap_pseudo_header" union for an open capture
file;
a pointer to the packet buffer for an open capture file;
so that a program using "wtap_read()" in a loop can get at those items.
Keep, in a "capture_file" structure, an indicator of whether:
no file is open;
a file is open, and being read;
a file is open, and is being read, but the user tried to quit
out of reading the file (e.g., by doing "File/Quit");
a file is open, and has been completely read.
Abort if we try to close a capture that's being read if the user hasn't
tried to quit out of the read.
Have "File/Quit" check if a file is being read; if so, just set the
state indicator to "user tried to quit out of it", so that the code
reading the file can do what's appropriate to clean up, rather than
closing the file out from under that code and causing crashes.
Have "read_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
close the capture and return an indication that the read was aborted by
the user. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "continue_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
return an indication that the read was aborted by the user if that
happened. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "finish_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
close the capture and return an indication that the read was aborted by
the user if that happened. Otherwise, return an indication of whether
the read completely succeeded or failed in the middle (and, if it
failed, return the error code through a pointer).
Have their callers check whether the read was aborted or not and, if it
was, bail out in the appropriate fashion (exit if it's reading a file
specified by "-r" on the command line; exit the main loop if it's
reading a file specified with File->Open; kill the capture child if it's
"continue_tail_cap_file()"; exit the main loop if it's
"finish_tail_cap_file()".
svn path=/trunk/; revision=2095
2000-06-27 07:13:42 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2000-01-25 05:48:47 +00:00
|
|
|
/* Save the name of the containing directory specified in the path name,
|
|
|
|
if any; we can write over cf_name, which is a good thing, given that
|
|
|
|
"get_dirname()" does write over its argument. */
|
|
|
|
s = get_dirname(cf_name);
|
2001-04-09 22:35:23 +00:00
|
|
|
set_last_open_dir(s);
|
2003-07-18 20:55:11 +00:00
|
|
|
gtk_widget_grab_focus(packet_list);
|
2000-06-02 03:35:39 +00:00
|
|
|
|
1999-09-01 03:04:24 +00:00
|
|
|
g_free(cf_name);
|
|
|
|
}
|
|
|
|
|
Split "filter_dialog_cb()" into "filter_dialog_cb()", which pops up a
"global" dialog box when "Edit:Filters" is selected, so that the list of
filters can be edited, and "filter_browse_cb()", which pops up a dialog
box associated with a "Filter:" button and a text entry widget attached
to that button, so that a filter can be selected or saved (although it
also supports the same editing that the "global" dialog box does).
Have "filter_dialog_cb()" connect the window in which the "Filter:"
button lives and the filter dialog box, so that:
if the window in which the "Filter:" button lives goes away, so
does the filter dialog box (as it no longer has a text widget
into which it can stuff the selected filter);
if the "Filter:" button is clicked when there's already a filter
dialog box open, we just reactivate that existing dialog box
rather than popping up a new one.
Also keep a pointer to the "global" filter dialog box, so that we also
arrange that there's only one of them (by reactivating the existing on
if "Edit:Filters" is selected when there's already a "global" filter
dialog box open).
Keep around pointers to the dialog boxes that contain the "Filter:"
buttons, so that we can arrange that there be only one of them (that was
a side-effect of an earlier attempt at fixing the problems described
above, but it's still useful for keeping multiple competing dialog boxes
from being open - there's more of that to be done).
Make the pointer to the "Open Capture File" dialog box widget static to
"file_dlg.c" - nobody outside of "file_dlg.c cares about it.
svn path=/trunk/; revision=1774
2000-04-01 12:03:42 +00:00
|
|
|
static void
|
2003-01-15 05:20:19 +00:00
|
|
|
file_open_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
|
Split "filter_dialog_cb()" into "filter_dialog_cb()", which pops up a
"global" dialog box when "Edit:Filters" is selected, so that the list of
filters can be edited, and "filter_browse_cb()", which pops up a dialog
box associated with a "Filter:" button and a text entry widget attached
to that button, so that a filter can be selected or saved (although it
also supports the same editing that the "global" dialog box does).
Have "filter_dialog_cb()" connect the window in which the "Filter:"
button lives and the filter dialog box, so that:
if the window in which the "Filter:" button lives goes away, so
does the filter dialog box (as it no longer has a text widget
into which it can stuff the selected filter);
if the "Filter:" button is clicked when there's already a filter
dialog box open, we just reactivate that existing dialog box
rather than popping up a new one.
Also keep a pointer to the "global" filter dialog box, so that we also
arrange that there's only one of them (by reactivating the existing on
if "Edit:Filters" is selected when there's already a "global" filter
dialog box open).
Keep around pointers to the dialog boxes that contain the "Filter:"
buttons, so that we can arrange that there be only one of them (that was
a side-effect of an earlier attempt at fixing the problems described
above, but it's still useful for keeping multiple competing dialog boxes
from being open - there's more of that to be done).
Make the pointer to the "Open Capture File" dialog box widget static to
"file_dlg.c" - nobody outside of "file_dlg.c cares about it.
svn path=/trunk/; revision=1774
2000-04-01 12:03:42 +00:00
|
|
|
{
|
|
|
|
/* Note that we no longer have a "Open Capture File" dialog box. */
|
2000-04-10 18:40:13 +00:00
|
|
|
file_open_w = NULL;
|
Split "filter_dialog_cb()" into "filter_dialog_cb()", which pops up a
"global" dialog box when "Edit:Filters" is selected, so that the list of
filters can be edited, and "filter_browse_cb()", which pops up a dialog
box associated with a "Filter:" button and a text entry widget attached
to that button, so that a filter can be selected or saved (although it
also supports the same editing that the "global" dialog box does).
Have "filter_dialog_cb()" connect the window in which the "Filter:"
button lives and the filter dialog box, so that:
if the window in which the "Filter:" button lives goes away, so
does the filter dialog box (as it no longer has a text widget
into which it can stuff the selected filter);
if the "Filter:" button is clicked when there's already a filter
dialog box open, we just reactivate that existing dialog box
rather than popping up a new one.
Also keep a pointer to the "global" filter dialog box, so that we also
arrange that there's only one of them (by reactivating the existing on
if "Edit:Filters" is selected when there's already a "global" filter
dialog box open).
Keep around pointers to the dialog boxes that contain the "Filter:"
buttons, so that we can arrange that there be only one of them (that was
a side-effect of an earlier attempt at fixing the problems described
above, but it's still useful for keeping multiple competing dialog boxes
from being open - there's more of that to be done).
Make the pointer to the "Open Capture File" dialog box widget static to
"file_dlg.c" - nobody outside of "file_dlg.c cares about it.
svn path=/trunk/; revision=1774
2000-04-01 12:03:42 +00:00
|
|
|
}
|
|
|
|
|
1999-09-01 03:04:24 +00:00
|
|
|
/* Close a file */
|
|
|
|
void
|
2002-03-05 11:56:00 +00:00
|
|
|
file_close_cmd_cb(GtkWidget *widget _U_, gpointer data _U_) {
|
2003-09-15 22:48:42 +00:00
|
|
|
cf_close(&cfile);
|
1999-09-01 03:04:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
file_save_cmd_cb(GtkWidget *w, gpointer data) {
|
Allow the user to save either all of the current capture, or only the
packets that are currently being displayed from that capture.
Centralize the code to control whether "File:Save" and "File:Save As"
are enabled (and *always* have "File:Save As" enabled if you have a
capture; "File:Save" is enabled only if you have a live capture you've
not yet saved, although it does the same thing as "File:Save As").
Have the "save_file" member of a "capture_file" structure represent
*only* the file currently being *written* to by a capture, and, if there
is no capture currently in progress, have it be NULL; the name of the
file currently being *displayed" is in the "filename" member, and an
"is_tempfile" member indicates whether it's a temporary file for a live
capture or not.
Have "close_cap_file()" delete the current capture file if it's a
temporary capture file that hasn't been saved (in its entirety - saving
selected frames doesn't count). Do the same (if there *is* a current
capture file) when exiting.
The "Ready to load or capture" message is the only statusbar message in
the "main" context; "close_cap_file()" should never pop it, it should
only pop whatever message exists in the "file" context, and thus has no
need to take, as an argument, the context for the message it should pop.
Update the man page to reflect the new behavior of "File:Save" and
"File:Save As", and to reflect recent changes to "Display:Match Selected".
svn path=/trunk/; revision=1170
1999-11-30 20:50:15 +00:00
|
|
|
/* If the file's already been saved, do nothing. */
|
2000-06-27 04:36:03 +00:00
|
|
|
if (cfile.user_saved)
|
Allow the user to save either all of the current capture, or only the
packets that are currently being displayed from that capture.
Centralize the code to control whether "File:Save" and "File:Save As"
are enabled (and *always* have "File:Save As" enabled if you have a
capture; "File:Save" is enabled only if you have a live capture you've
not yet saved, although it does the same thing as "File:Save As").
Have the "save_file" member of a "capture_file" structure represent
*only* the file currently being *written* to by a capture, and, if there
is no capture currently in progress, have it be NULL; the name of the
file currently being *displayed" is in the "filename" member, and an
"is_tempfile" member indicates whether it's a temporary file for a live
capture or not.
Have "close_cap_file()" delete the current capture file if it's a
temporary capture file that hasn't been saved (in its entirety - saving
selected frames doesn't count). Do the same (if there *is* a current
capture file) when exiting.
The "Ready to load or capture" message is the only statusbar message in
the "main" context; "close_cap_file()" should never pop it, it should
only pop whatever message exists in the "file" context, and thus has no
need to take, as an argument, the context for the message it should pop.
Update the man page to reflect the new behavior of "File:Save" and
"File:Save As", and to reflect recent changes to "Display:Match Selected".
svn path=/trunk/; revision=1170
1999-11-30 20:50:15 +00:00
|
|
|
return;
|
1999-09-01 03:04:24 +00:00
|
|
|
|
Allow the user to save either all of the current capture, or only the
packets that are currently being displayed from that capture.
Centralize the code to control whether "File:Save" and "File:Save As"
are enabled (and *always* have "File:Save As" enabled if you have a
capture; "File:Save" is enabled only if you have a live capture you've
not yet saved, although it does the same thing as "File:Save As").
Have the "save_file" member of a "capture_file" structure represent
*only* the file currently being *written* to by a capture, and, if there
is no capture currently in progress, have it be NULL; the name of the
file currently being *displayed" is in the "filename" member, and an
"is_tempfile" member indicates whether it's a temporary file for a live
capture or not.
Have "close_cap_file()" delete the current capture file if it's a
temporary capture file that hasn't been saved (in its entirety - saving
selected frames doesn't count). Do the same (if there *is* a current
capture file) when exiting.
The "Ready to load or capture" message is the only statusbar message in
the "main" context; "close_cap_file()" should never pop it, it should
only pop whatever message exists in the "file" context, and thus has no
need to take, as an argument, the context for the message it should pop.
Update the man page to reflect the new behavior of "File:Save" and
"File:Save As", and to reflect recent changes to "Display:Match Selected".
svn path=/trunk/; revision=1170
1999-11-30 20:50:15 +00:00
|
|
|
/* Do a "Save As". */
|
|
|
|
file_save_as_cmd_cb(w, data);
|
1999-09-01 03:04:24 +00:00
|
|
|
}
|
|
|
|
|
1999-12-06 09:02:48 +00:00
|
|
|
/* XXX - can we make these not be static? */
|
|
|
|
static gboolean filtered;
|
2000-08-21 15:45:33 +00:00
|
|
|
static gboolean marked;
|
2003-08-18 21:27:11 +00:00
|
|
|
static gboolean color_marked;
|
1999-12-06 09:02:48 +00:00
|
|
|
static int filetype;
|
|
|
|
static GtkWidget *filter_cb;
|
2000-08-21 15:45:33 +00:00
|
|
|
static GtkWidget *mark_cb;
|
2003-08-18 21:27:11 +00:00
|
|
|
static GtkWidget *cfmark_cb;
|
1999-12-06 09:02:48 +00:00
|
|
|
static GtkWidget *ft_om;
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
can_save_with_wiretap(int ft)
|
|
|
|
{
|
|
|
|
/* To save a file with Wiretap, Wiretap has to handle that format,
|
|
|
|
and its code to handle that format must be able to write a file
|
|
|
|
with this file's encapsulation type. */
|
2000-06-27 04:36:03 +00:00
|
|
|
return wtap_dump_can_open(ft) && wtap_dump_can_write_encap(ft, cfile.lnk_t);
|
1999-12-06 09:02:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Generate a list of the file types we can save this file as.
|
|
|
|
|
|
|
|
"filetype" is the type it has now.
|
|
|
|
|
|
|
|
"encap" is the encapsulation for its packets (which could be
|
|
|
|
"unknown" or "per-packet").
|
|
|
|
|
|
|
|
"filtered" is TRUE if we're to save only the packets that passed
|
|
|
|
the display filter (in which case we have to save it using Wiretap)
|
|
|
|
and FALSE if we're to save the entire file (in which case, if we're
|
2002-08-28 21:04:11 +00:00
|
|
|
saving it in the type it has already, we can just copy it).
|
2000-08-21 15:45:33 +00:00
|
|
|
|
|
|
|
"marked" is TRUE if we have to save only the marked packets,
|
|
|
|
the same remark as "filtered" applies.
|
|
|
|
*/
|
1999-12-06 09:02:48 +00:00
|
|
|
static void
|
|
|
|
set_file_type_list(GtkWidget *option_menu)
|
|
|
|
{
|
|
|
|
GtkWidget *ft_menu, *ft_menu_item;
|
|
|
|
int ft;
|
|
|
|
guint index;
|
|
|
|
guint item_to_select;
|
|
|
|
|
|
|
|
/* Default to the first supported file type, if the file's current
|
|
|
|
type isn't supported. */
|
|
|
|
item_to_select = 0;
|
|
|
|
|
|
|
|
ft_menu = gtk_menu_new();
|
|
|
|
|
|
|
|
/* Check all file types. */
|
|
|
|
index = 0;
|
|
|
|
for (ft = 0; ft < WTAP_NUM_FILE_TYPES; ft++) {
|
2000-08-21 15:45:33 +00:00
|
|
|
if (filtered || marked || ft != cfile.cd_t) {
|
|
|
|
/* Filtered, marked or a different file type. We have to use Wiretap. */
|
1999-12-06 09:02:48 +00:00
|
|
|
if (!can_save_with_wiretap(ft))
|
|
|
|
continue; /* We can't. */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* OK, we can write it out in this type. */
|
|
|
|
ft_menu_item = gtk_menu_item_new_with_label(wtap_file_type_string(ft));
|
|
|
|
if (ft == filetype) {
|
|
|
|
/* Default to the same format as the file, if it's supported. */
|
|
|
|
item_to_select = index;
|
|
|
|
}
|
2002-11-10 11:00:29 +00:00
|
|
|
SIGNAL_CONNECT(ft_menu_item, "activate", select_file_type_cb,
|
|
|
|
GINT_TO_POINTER(ft));
|
1999-12-06 09:02:48 +00:00
|
|
|
gtk_menu_append(GTK_MENU(ft_menu), ft_menu_item);
|
|
|
|
gtk_widget_show(ft_menu_item);
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_option_menu_set_menu(GTK_OPTION_MENU(option_menu), ft_menu);
|
|
|
|
gtk_option_menu_set_history(GTK_OPTION_MENU(option_menu), item_to_select);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-03-05 11:56:00 +00:00
|
|
|
select_file_type_cb(GtkWidget *w _U_, gpointer data)
|
1999-12-06 09:02:48 +00:00
|
|
|
{
|
2002-11-10 11:00:29 +00:00
|
|
|
int new_filetype = GPOINTER_TO_INT(data);
|
1999-12-06 09:02:48 +00:00
|
|
|
|
|
|
|
if (filetype != new_filetype) {
|
2000-08-21 15:45:33 +00:00
|
|
|
/* We can select only the filtered or marked packets to be saved if we can
|
1999-12-06 09:02:48 +00:00
|
|
|
use Wiretap to save the file. */
|
|
|
|
gtk_widget_set_sensitive(filter_cb, can_save_with_wiretap(new_filetype));
|
|
|
|
filetype = new_filetype;
|
2001-12-06 02:21:26 +00:00
|
|
|
file_set_save_marked_sensitive();
|
1999-12-06 09:02:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-03-05 11:56:00 +00:00
|
|
|
toggle_filtered_cb(GtkWidget *widget, gpointer data _U_)
|
1999-12-06 09:02:48 +00:00
|
|
|
{
|
|
|
|
gboolean new_filtered;
|
|
|
|
|
|
|
|
new_filtered = GTK_TOGGLE_BUTTON (widget)->active;
|
|
|
|
|
|
|
|
if (filtered != new_filtered) {
|
|
|
|
/* They changed the state of the "filtered" button. */
|
|
|
|
filtered = new_filtered;
|
|
|
|
set_file_type_list(ft_om);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-08-21 15:45:33 +00:00
|
|
|
static void
|
2002-03-05 11:56:00 +00:00
|
|
|
toggle_marked_cb(GtkWidget *widget, gpointer data _U_)
|
2000-08-21 15:45:33 +00:00
|
|
|
{
|
|
|
|
gboolean new_marked;
|
|
|
|
|
|
|
|
new_marked = GTK_TOGGLE_BUTTON (widget)->active;
|
|
|
|
|
|
|
|
if (marked != new_marked) {
|
|
|
|
/* They changed the state of the "marked" button. */
|
|
|
|
marked = new_marked;
|
|
|
|
set_file_type_list(ft_om);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-04-10 18:40:13 +00:00
|
|
|
/*
|
|
|
|
* Keep a static pointer to the current "Save Capture File As" window, if
|
|
|
|
* any, so that if somebody tries to do "File:Save" or "File:Save As"
|
|
|
|
* while there's already a "Save Capture File As" window up, we just pop
|
|
|
|
* up the existing one, rather than creating a new one.
|
|
|
|
*/
|
|
|
|
static GtkWidget *file_save_as_w;
|
|
|
|
|
1999-09-01 03:04:24 +00:00
|
|
|
void
|
2002-03-05 11:56:00 +00:00
|
|
|
file_save_as_cmd_cb(GtkWidget *w _U_, gpointer data _U_)
|
1999-12-06 09:02:48 +00:00
|
|
|
{
|
|
|
|
GtkWidget *ok_bt, *main_vb, *ft_hb, *ft_lb;
|
|
|
|
|
2000-04-10 18:40:13 +00:00
|
|
|
if (file_save_as_w != NULL) {
|
|
|
|
/* There's already an "Save Capture File As" dialog box; reactivate it. */
|
|
|
|
reactivate_window(file_save_as_w);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-12-06 09:02:48 +00:00
|
|
|
/* Default to saving all packets, in the file's current format. */
|
|
|
|
filtered = FALSE;
|
2000-08-21 15:45:33 +00:00
|
|
|
marked = FALSE;
|
2000-06-27 04:36:03 +00:00
|
|
|
filetype = cfile.cd_t;
|
Allow the user to save either all of the current capture, or only the
packets that are currently being displayed from that capture.
Centralize the code to control whether "File:Save" and "File:Save As"
are enabled (and *always* have "File:Save As" enabled if you have a
capture; "File:Save" is enabled only if you have a live capture you've
not yet saved, although it does the same thing as "File:Save As").
Have the "save_file" member of a "capture_file" structure represent
*only* the file currently being *written* to by a capture, and, if there
is no capture currently in progress, have it be NULL; the name of the
file currently being *displayed" is in the "filename" member, and an
"is_tempfile" member indicates whether it's a temporary file for a live
capture or not.
Have "close_cap_file()" delete the current capture file if it's a
temporary capture file that hasn't been saved (in its entirety - saving
selected frames doesn't count). Do the same (if there *is* a current
capture file) when exiting.
The "Ready to load or capture" message is the only statusbar message in
the "main" context; "close_cap_file()" should never pop it, it should
only pop whatever message exists in the "file" context, and thus has no
need to take, as an argument, the context for the message it should pop.
Update the man page to reflect the new behavior of "File:Save" and
"File:Save As", and to reflect recent changes to "Display:Match Selected".
svn path=/trunk/; revision=1170
1999-11-30 20:50:15 +00:00
|
|
|
|
2003-09-24 08:43:34 +00:00
|
|
|
file_save_as_w = file_selection_new ("Ethereal: Save Capture File As");
|
2002-11-10 11:00:29 +00:00
|
|
|
SIGNAL_CONNECT(file_save_as_w, "destroy", file_save_as_destroy_cb, NULL);
|
1999-09-01 03:04:24 +00:00
|
|
|
|
2000-07-31 04:53:40 +00:00
|
|
|
/* If we've opened a file, start out by showing the files in the directory
|
|
|
|
in which that file resided. */
|
|
|
|
if (last_open_dir)
|
2001-04-09 22:35:23 +00:00
|
|
|
gtk_file_selection_set_filename(GTK_FILE_SELECTION(file_save_as_w), last_open_dir);
|
2000-07-31 04:53:40 +00:00
|
|
|
|
1999-09-01 03:04:24 +00:00
|
|
|
/* Connect the ok_button to file_save_as_ok_cb function and pass along a
|
|
|
|
pointer to the file selection box widget */
|
2000-04-10 18:40:13 +00:00
|
|
|
ok_bt = GTK_FILE_SELECTION (file_save_as_w)->ok_button;
|
2002-11-10 11:00:29 +00:00
|
|
|
SIGNAL_CONNECT(ok_bt, "clicked", file_save_as_ok_cb, file_save_as_w);
|
Allow the user to save either all of the current capture, or only the
packets that are currently being displayed from that capture.
Centralize the code to control whether "File:Save" and "File:Save As"
are enabled (and *always* have "File:Save As" enabled if you have a
capture; "File:Save" is enabled only if you have a live capture you've
not yet saved, although it does the same thing as "File:Save As").
Have the "save_file" member of a "capture_file" structure represent
*only* the file currently being *written* to by a capture, and, if there
is no capture currently in progress, have it be NULL; the name of the
file currently being *displayed" is in the "filename" member, and an
"is_tempfile" member indicates whether it's a temporary file for a live
capture or not.
Have "close_cap_file()" delete the current capture file if it's a
temporary capture file that hasn't been saved (in its entirety - saving
selected frames doesn't count). Do the same (if there *is* a current
capture file) when exiting.
The "Ready to load or capture" message is the only statusbar message in
the "main" context; "close_cap_file()" should never pop it, it should
only pop whatever message exists in the "file" context, and thus has no
need to take, as an argument, the context for the message it should pop.
Update the man page to reflect the new behavior of "File:Save" and
"File:Save As", and to reflect recent changes to "Display:Match Selected".
svn path=/trunk/; revision=1170
1999-11-30 20:50:15 +00:00
|
|
|
|
1999-12-06 09:02:48 +00:00
|
|
|
/* Container for each row of widgets */
|
|
|
|
main_vb = gtk_vbox_new(FALSE, 3);
|
|
|
|
gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
|
2000-04-10 18:40:13 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(GTK_FILE_SELECTION(file_save_as_w)->action_area),
|
1999-12-06 09:02:48 +00:00
|
|
|
main_vb, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(main_vb);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-09-10 08:49:11 +00:00
|
|
|
/*
|
|
|
|
* XXX - should this be sensitive only if the current display filter
|
|
|
|
* has rejected some packets, so that not all packets are currently
|
|
|
|
* being displayed, and if it has accepted some packets, so that some
|
|
|
|
* packets are currently being displayed?
|
2001-12-06 03:09:28 +00:00
|
|
|
*
|
|
|
|
* I'd say "no", as that complicates the UI code, and as one could,
|
|
|
|
* I guess, argue that the user may want to "save all the displayed
|
|
|
|
* packets" even if there aren't any, i.e. save an empty file.
|
2001-09-10 08:49:11 +00:00
|
|
|
*/
|
Allow the user to save either all of the current capture, or only the
packets that are currently being displayed from that capture.
Centralize the code to control whether "File:Save" and "File:Save As"
are enabled (and *always* have "File:Save As" enabled if you have a
capture; "File:Save" is enabled only if you have a live capture you've
not yet saved, although it does the same thing as "File:Save As").
Have the "save_file" member of a "capture_file" structure represent
*only* the file currently being *written* to by a capture, and, if there
is no capture currently in progress, have it be NULL; the name of the
file currently being *displayed" is in the "filename" member, and an
"is_tempfile" member indicates whether it's a temporary file for a live
capture or not.
Have "close_cap_file()" delete the current capture file if it's a
temporary capture file that hasn't been saved (in its entirety - saving
selected frames doesn't count). Do the same (if there *is* a current
capture file) when exiting.
The "Ready to load or capture" message is the only statusbar message in
the "main" context; "close_cap_file()" should never pop it, it should
only pop whatever message exists in the "file" context, and thus has no
need to take, as an argument, the context for the message it should pop.
Update the man page to reflect the new behavior of "File:Save" and
"File:Save As", and to reflect recent changes to "Display:Match Selected".
svn path=/trunk/; revision=1170
1999-11-30 20:50:15 +00:00
|
|
|
filter_cb = gtk_check_button_new_with_label("Save only packets currently being displayed");
|
1999-12-06 09:02:48 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(main_vb), filter_cb);
|
Allow the user to save either all of the current capture, or only the
packets that are currently being displayed from that capture.
Centralize the code to control whether "File:Save" and "File:Save As"
are enabled (and *always* have "File:Save As" enabled if you have a
capture; "File:Save" is enabled only if you have a live capture you've
not yet saved, although it does the same thing as "File:Save As").
Have the "save_file" member of a "capture_file" structure represent
*only* the file currently being *written* to by a capture, and, if there
is no capture currently in progress, have it be NULL; the name of the
file currently being *displayed" is in the "filename" member, and an
"is_tempfile" member indicates whether it's a temporary file for a live
capture or not.
Have "close_cap_file()" delete the current capture file if it's a
temporary capture file that hasn't been saved (in its entirety - saving
selected frames doesn't count). Do the same (if there *is* a current
capture file) when exiting.
The "Ready to load or capture" message is the only statusbar message in
the "main" context; "close_cap_file()" should never pop it, it should
only pop whatever message exists in the "file" context, and thus has no
need to take, as an argument, the context for the message it should pop.
Update the man page to reflect the new behavior of "File:Save" and
"File:Save As", and to reflect recent changes to "Display:Match Selected".
svn path=/trunk/; revision=1170
1999-11-30 20:50:15 +00:00
|
|
|
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(filter_cb), FALSE);
|
2002-11-10 11:00:29 +00:00
|
|
|
SIGNAL_CONNECT(filter_cb, "toggled", toggle_filtered_cb, NULL);
|
1999-12-06 09:02:48 +00:00
|
|
|
gtk_widget_set_sensitive(filter_cb, can_save_with_wiretap(filetype));
|
Allow the user to save either all of the current capture, or only the
packets that are currently being displayed from that capture.
Centralize the code to control whether "File:Save" and "File:Save As"
are enabled (and *always* have "File:Save As" enabled if you have a
capture; "File:Save" is enabled only if you have a live capture you've
not yet saved, although it does the same thing as "File:Save As").
Have the "save_file" member of a "capture_file" structure represent
*only* the file currently being *written* to by a capture, and, if there
is no capture currently in progress, have it be NULL; the name of the
file currently being *displayed" is in the "filename" member, and an
"is_tempfile" member indicates whether it's a temporary file for a live
capture or not.
Have "close_cap_file()" delete the current capture file if it's a
temporary capture file that hasn't been saved (in its entirety - saving
selected frames doesn't count). Do the same (if there *is* a current
capture file) when exiting.
The "Ready to load or capture" message is the only statusbar message in
the "main" context; "close_cap_file()" should never pop it, it should
only pop whatever message exists in the "file" context, and thus has no
need to take, as an argument, the context for the message it should pop.
Update the man page to reflect the new behavior of "File:Save" and
"File:Save As", and to reflect recent changes to "Display:Match Selected".
svn path=/trunk/; revision=1170
1999-11-30 20:50:15 +00:00
|
|
|
gtk_widget_show(filter_cb);
|
|
|
|
|
2001-09-10 08:49:11 +00:00
|
|
|
/*
|
2001-12-06 03:09:28 +00:00
|
|
|
* The argument above could, I guess, be applied to the marked packets,
|
|
|
|
* except that you can't easily tell whether there are any marked
|
|
|
|
* packets, so I could imagine users doing "Save only marked packets"
|
|
|
|
* when there aren't any marked packets, not knowing that they'd
|
|
|
|
* failed to mark them, so I'm more inclined to have the "Save only
|
|
|
|
* marked packets" toggle button enabled only if there are marked
|
|
|
|
* packets to save.
|
2001-09-10 08:49:11 +00:00
|
|
|
*/
|
2000-08-21 15:45:33 +00:00
|
|
|
mark_cb = gtk_check_button_new_with_label("Save only marked packets");
|
|
|
|
gtk_container_add(GTK_CONTAINER(main_vb), mark_cb);
|
2001-12-06 02:21:26 +00:00
|
|
|
marked = FALSE;
|
2000-08-21 15:45:33 +00:00
|
|
|
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(mark_cb), FALSE);
|
2002-11-10 11:00:29 +00:00
|
|
|
SIGNAL_CONNECT(mark_cb, "toggled", toggle_marked_cb, NULL);
|
2000-08-21 15:45:33 +00:00
|
|
|
gtk_widget_show(mark_cb);
|
|
|
|
|
1999-12-06 09:02:48 +00:00
|
|
|
/* File type row */
|
|
|
|
ft_hb = gtk_hbox_new(FALSE, 3);
|
|
|
|
gtk_container_add(GTK_CONTAINER(main_vb), ft_hb);
|
|
|
|
gtk_widget_show(ft_hb);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
1999-12-06 09:02:48 +00:00
|
|
|
ft_lb = gtk_label_new("File type:");
|
|
|
|
gtk_box_pack_start(GTK_BOX(ft_hb), ft_lb, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(ft_lb);
|
|
|
|
|
|
|
|
ft_om = gtk_option_menu_new();
|
|
|
|
|
|
|
|
/* Generate the list of file types we can save. */
|
|
|
|
set_file_type_list(ft_om);
|
|
|
|
gtk_box_pack_start(GTK_BOX(ft_hb), ft_om, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(ft_om);
|
1999-09-01 03:04:24 +00:00
|
|
|
|
2001-12-06 02:21:26 +00:00
|
|
|
/*
|
2001-12-06 03:09:28 +00:00
|
|
|
* Set the sensitivity of the "Save only marked packets" toggle
|
|
|
|
* button
|
2001-12-06 02:21:26 +00:00
|
|
|
*
|
2001-12-06 03:09:28 +00:00
|
|
|
* This has to be done after we create the file type menu option,
|
|
|
|
* as the routine that sets it also sets that menu.
|
2001-12-06 02:21:26 +00:00
|
|
|
*/
|
|
|
|
file_set_save_marked_sensitive();
|
|
|
|
|
1999-09-01 03:04:24 +00:00
|
|
|
/* Connect the cancel_button to destroy the widget */
|
2002-11-10 11:00:29 +00:00
|
|
|
SIGNAL_CONNECT_OBJECT(GTK_FILE_SELECTION(file_save_as_w)->cancel_button,
|
|
|
|
"clicked", (GtkSignalFunc)gtk_widget_destroy,
|
|
|
|
file_save_as_w);
|
1999-09-01 03:04:24 +00:00
|
|
|
|
2000-05-08 07:13:40 +00:00
|
|
|
/* 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(file_save_as_w, GTK_FILE_SELECTION(file_save_as_w)->cancel_button);
|
|
|
|
|
2000-04-10 18:40:13 +00:00
|
|
|
gtk_file_selection_set_filename(GTK_FILE_SELECTION(file_save_as_w), "");
|
2001-12-06 02:21:26 +00:00
|
|
|
|
2000-04-10 18:40:13 +00:00
|
|
|
gtk_widget_show(file_save_as_w);
|
1999-09-01 03:04:24 +00:00
|
|
|
}
|
|
|
|
|
2001-12-06 02:21:26 +00:00
|
|
|
/*
|
|
|
|
* Set the "Save only marked packets" toggle button as appropriate for
|
|
|
|
* the current output file type and count of marked packets.
|
2001-12-06 03:09:28 +00:00
|
|
|
*
|
2001-12-06 02:21:26 +00:00
|
|
|
* Called when the "Save As..." dialog box is created and when either
|
|
|
|
* the file type or the marked count changes.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
file_set_save_marked_sensitive(void)
|
|
|
|
{
|
2001-12-06 03:09:28 +00:00
|
|
|
if (file_save_as_w == NULL) {
|
|
|
|
/* We don't currently have a "Save As..." dialog box up. */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-12-06 02:21:26 +00:00
|
|
|
/* We can request that only the marked packets be saved only if we
|
|
|
|
can use Wiretap to save the file and if there *are* marked packets. */
|
|
|
|
if (can_save_with_wiretap(filetype) && cfile.marked_count != 0)
|
|
|
|
gtk_widget_set_sensitive(mark_cb, TRUE);
|
|
|
|
else {
|
|
|
|
/* Force the "Save only marked packets" toggle to "false", turn
|
|
|
|
off the flag it controls, and update the list of types we can
|
|
|
|
save the file as. */
|
|
|
|
marked = FALSE;
|
|
|
|
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(mark_cb), FALSE);
|
|
|
|
set_file_type_list(ft_om);
|
|
|
|
gtk_widget_set_sensitive(mark_cb, FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-01 03:04:24 +00:00
|
|
|
static void
|
2002-03-05 11:56:00 +00:00
|
|
|
file_save_as_ok_cb(GtkWidget *w _U_, GtkFileSelection *fs) {
|
Allow the user to save either all of the current capture, or only the
packets that are currently being displayed from that capture.
Centralize the code to control whether "File:Save" and "File:Save As"
are enabled (and *always* have "File:Save As" enabled if you have a
capture; "File:Save" is enabled only if you have a live capture you've
not yet saved, although it does the same thing as "File:Save As").
Have the "save_file" member of a "capture_file" structure represent
*only* the file currently being *written* to by a capture, and, if there
is no capture currently in progress, have it be NULL; the name of the
file currently being *displayed" is in the "filename" member, and an
"is_tempfile" member indicates whether it's a temporary file for a live
capture or not.
Have "close_cap_file()" delete the current capture file if it's a
temporary capture file that hasn't been saved (in its entirety - saving
selected frames doesn't count). Do the same (if there *is* a current
capture file) when exiting.
The "Ready to load or capture" message is the only statusbar message in
the "main" context; "close_cap_file()" should never pop it, it should
only pop whatever message exists in the "file" context, and thus has no
need to take, as an argument, the context for the message it should pop.
Update the man page to reflect the new behavior of "File:Save" and
"File:Save As", and to reflect recent changes to "Display:Match Selected".
svn path=/trunk/; revision=1170
1999-11-30 20:50:15 +00:00
|
|
|
gchar *cf_name;
|
2002-09-09 20:39:01 +00:00
|
|
|
gchar *dirname;
|
Allow the user to save either all of the current capture, or only the
packets that are currently being displayed from that capture.
Centralize the code to control whether "File:Save" and "File:Save As"
are enabled (and *always* have "File:Save As" enabled if you have a
capture; "File:Save" is enabled only if you have a live capture you've
not yet saved, although it does the same thing as "File:Save As").
Have the "save_file" member of a "capture_file" structure represent
*only* the file currently being *written* to by a capture, and, if there
is no capture currently in progress, have it be NULL; the name of the
file currently being *displayed" is in the "filename" member, and an
"is_tempfile" member indicates whether it's a temporary file for a live
capture or not.
Have "close_cap_file()" delete the current capture file if it's a
temporary capture file that hasn't been saved (in its entirety - saving
selected frames doesn't count). Do the same (if there *is* a current
capture file) when exiting.
The "Ready to load or capture" message is the only statusbar message in
the "main" context; "close_cap_file()" should never pop it, it should
only pop whatever message exists in the "file" context, and thus has no
need to take, as an argument, the context for the message it should pop.
Update the man page to reflect the new behavior of "File:Save" and
"File:Save As", and to reflect recent changes to "Display:Match Selected".
svn path=/trunk/; revision=1170
1999-11-30 20:50:15 +00:00
|
|
|
|
|
|
|
cf_name = g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(fs)));
|
2002-09-09 20:39:01 +00:00
|
|
|
|
|
|
|
/* Perhaps the user specified a directory instead of a file.
|
|
|
|
Check whether they did. */
|
|
|
|
if (test_for_directory(cf_name) == EISDIR) {
|
|
|
|
/* It's a directory - set the file selection box to display that
|
|
|
|
directory, and leave the selection box displayed. */
|
|
|
|
set_last_open_dir(cf_name);
|
|
|
|
g_free(cf_name);
|
|
|
|
gtk_file_selection_set_filename(GTK_FILE_SELECTION(fs), last_open_dir);
|
|
|
|
return;
|
|
|
|
}
|
Allow the user to save either all of the current capture, or only the
packets that are currently being displayed from that capture.
Centralize the code to control whether "File:Save" and "File:Save As"
are enabled (and *always* have "File:Save As" enabled if you have a
capture; "File:Save" is enabled only if you have a live capture you've
not yet saved, although it does the same thing as "File:Save As").
Have the "save_file" member of a "capture_file" structure represent
*only* the file currently being *written* to by a capture, and, if there
is no capture currently in progress, have it be NULL; the name of the
file currently being *displayed" is in the "filename" member, and an
"is_tempfile" member indicates whether it's a temporary file for a live
capture or not.
Have "close_cap_file()" delete the current capture file if it's a
temporary capture file that hasn't been saved (in its entirety - saving
selected frames doesn't count). Do the same (if there *is* a current
capture file) when exiting.
The "Ready to load or capture" message is the only statusbar message in
the "main" context; "close_cap_file()" should never pop it, it should
only pop whatever message exists in the "file" context, and thus has no
need to take, as an argument, the context for the message it should pop.
Update the man page to reflect the new behavior of "File:Save" and
"File:Save As", and to reflect recent changes to "Display:Match Selected".
svn path=/trunk/; revision=1170
1999-11-30 20:50:15 +00:00
|
|
|
|
|
|
|
/* Write out the packets (all, or only the ones that are currently
|
2000-08-21 15:45:33 +00:00
|
|
|
displayed or marked) to the file with the specified name. */
|
Allow the user to save either all of the current capture, or only the
packets that are currently being displayed from that capture.
Centralize the code to control whether "File:Save" and "File:Save As"
are enabled (and *always* have "File:Save As" enabled if you have a
capture; "File:Save" is enabled only if you have a live capture you've
not yet saved, although it does the same thing as "File:Save As").
Have the "save_file" member of a "capture_file" structure represent
*only* the file currently being *written* to by a capture, and, if there
is no capture currently in progress, have it be NULL; the name of the
file currently being *displayed" is in the "filename" member, and an
"is_tempfile" member indicates whether it's a temporary file for a live
capture or not.
Have "close_cap_file()" delete the current capture file if it's a
temporary capture file that hasn't been saved (in its entirety - saving
selected frames doesn't count). Do the same (if there *is* a current
capture file) when exiting.
The "Ready to load or capture" message is the only statusbar message in
the "main" context; "close_cap_file()" should never pop it, it should
only pop whatever message exists in the "file" context, and thus has no
need to take, as an argument, the context for the message it should pop.
Update the man page to reflect the new behavior of "File:Save" and
"File:Save As", and to reflect recent changes to "Display:Match Selected".
svn path=/trunk/; revision=1170
1999-11-30 20:50:15 +00:00
|
|
|
|
2003-09-15 22:48:42 +00:00
|
|
|
if (! cf_save(cf_name, &cfile, filtered, marked, filetype)) {
|
2002-09-09 20:39:01 +00:00
|
|
|
/* The write failed; don't dismiss the open dialog box,
|
|
|
|
just leave it around so that the user can, after they
|
|
|
|
dismiss the alert box popped up for the error, try again. */
|
|
|
|
g_free(cf_name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The write succeeded; get rid of the file selection box. */
|
|
|
|
gtk_widget_hide(GTK_WIDGET (fs));
|
|
|
|
gtk_widget_destroy(GTK_WIDGET (fs));
|
|
|
|
|
|
|
|
/* Save the directory name for future file dialogs. */
|
|
|
|
dirname = get_dirname(cf_name); /* Overwrites cf_name */
|
|
|
|
set_last_open_dir(dirname);
|
Allow the user to save either all of the current capture, or only the
packets that are currently being displayed from that capture.
Centralize the code to control whether "File:Save" and "File:Save As"
are enabled (and *always* have "File:Save As" enabled if you have a
capture; "File:Save" is enabled only if you have a live capture you've
not yet saved, although it does the same thing as "File:Save As").
Have the "save_file" member of a "capture_file" structure represent
*only* the file currently being *written* to by a capture, and, if there
is no capture currently in progress, have it be NULL; the name of the
file currently being *displayed" is in the "filename" member, and an
"is_tempfile" member indicates whether it's a temporary file for a live
capture or not.
Have "close_cap_file()" delete the current capture file if it's a
temporary capture file that hasn't been saved (in its entirety - saving
selected frames doesn't count). Do the same (if there *is* a current
capture file) when exiting.
The "Ready to load or capture" message is the only statusbar message in
the "main" context; "close_cap_file()" should never pop it, it should
only pop whatever message exists in the "file" context, and thus has no
need to take, as an argument, the context for the message it should pop.
Update the man page to reflect the new behavior of "File:Save" and
"File:Save As", and to reflect recent changes to "Display:Match Selected".
svn path=/trunk/; revision=1170
1999-11-30 20:50:15 +00:00
|
|
|
g_free(cf_name);
|
1999-09-01 03:04:24 +00:00
|
|
|
}
|
|
|
|
|
2000-04-10 18:40:13 +00:00
|
|
|
static void
|
2002-03-05 11:56:00 +00:00
|
|
|
file_save_as_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
|
2000-04-10 18:40:13 +00:00
|
|
|
{
|
|
|
|
/* Note that we no longer have a "Save Capture File As" dialog box. */
|
|
|
|
file_save_as_w = NULL;
|
|
|
|
}
|
|
|
|
|
1999-09-01 03:04:24 +00:00
|
|
|
/* Reload a file using the current read and display filters */
|
|
|
|
void
|
2002-03-05 11:56:00 +00:00
|
|
|
file_reload_cmd_cb(GtkWidget *w, gpointer data _U_) {
|
2002-11-10 11:00:29 +00:00
|
|
|
GtkWidget *filter_te = OBJECT_GET_DATA(w, E_DFILTER_TE_KEY);
|
Allow the user to save either all of the current capture, or only the
packets that are currently being displayed from that capture.
Centralize the code to control whether "File:Save" and "File:Save As"
are enabled (and *always* have "File:Save As" enabled if you have a
capture; "File:Save" is enabled only if you have a live capture you've
not yet saved, although it does the same thing as "File:Save As").
Have the "save_file" member of a "capture_file" structure represent
*only* the file currently being *written* to by a capture, and, if there
is no capture currently in progress, have it be NULL; the name of the
file currently being *displayed" is in the "filename" member, and an
"is_tempfile" member indicates whether it's a temporary file for a live
capture or not.
Have "close_cap_file()" delete the current capture file if it's a
temporary capture file that hasn't been saved (in its entirety - saving
selected frames doesn't count). Do the same (if there *is* a current
capture file) when exiting.
The "Ready to load or capture" message is the only statusbar message in
the "main" context; "close_cap_file()" should never pop it, it should
only pop whatever message exists in the "file" context, and thus has no
need to take, as an argument, the context for the message it should pop.
Update the man page to reflect the new behavior of "File:Save" and
"File:Save As", and to reflect recent changes to "Display:Match Selected".
svn path=/trunk/; revision=1170
1999-11-30 20:50:15 +00:00
|
|
|
gchar *filename;
|
|
|
|
gboolean is_tempfile;
|
Add routines to Wiretap to allow a client of Wiretap to get:
a pointer to the "wtap_pkthdr" structure for an open capture
file;
a pointer to the "wtap_pseudo_header" union for an open capture
file;
a pointer to the packet buffer for an open capture file;
so that a program using "wtap_read()" in a loop can get at those items.
Keep, in a "capture_file" structure, an indicator of whether:
no file is open;
a file is open, and being read;
a file is open, and is being read, but the user tried to quit
out of reading the file (e.g., by doing "File/Quit");
a file is open, and has been completely read.
Abort if we try to close a capture that's being read if the user hasn't
tried to quit out of the read.
Have "File/Quit" check if a file is being read; if so, just set the
state indicator to "user tried to quit out of it", so that the code
reading the file can do what's appropriate to clean up, rather than
closing the file out from under that code and causing crashes.
Have "read_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
close the capture and return an indication that the read was aborted by
the user. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "continue_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
return an indication that the read was aborted by the user if that
happened. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "finish_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
close the capture and return an indication that the read was aborted by
the user if that happened. Otherwise, return an indication of whether
the read completely succeeded or failed in the middle (and, if it
failed, return the error code through a pointer).
Have their callers check whether the read was aborted or not and, if it
was, bail out in the appropriate fashion (exit if it's reading a file
specified by "-r" on the command line; exit the main loop if it's
reading a file specified with File->Open; kill the capture child if it's
"continue_tail_cap_file()"; exit the main loop if it's
"finish_tail_cap_file()".
svn path=/trunk/; revision=2095
2000-06-27 07:13:42 +00:00
|
|
|
int err;
|
1999-09-01 03:04:24 +00:00
|
|
|
|
2000-06-27 04:36:03 +00:00
|
|
|
if (cfile.dfilter)
|
|
|
|
g_free(cfile.dfilter);
|
|
|
|
cfile.dfilter = g_strdup(gtk_entry_get_text(GTK_ENTRY(filter_te)));
|
Allow the user to save either all of the current capture, or only the
packets that are currently being displayed from that capture.
Centralize the code to control whether "File:Save" and "File:Save As"
are enabled (and *always* have "File:Save As" enabled if you have a
capture; "File:Save" is enabled only if you have a live capture you've
not yet saved, although it does the same thing as "File:Save As").
Have the "save_file" member of a "capture_file" structure represent
*only* the file currently being *written* to by a capture, and, if there
is no capture currently in progress, have it be NULL; the name of the
file currently being *displayed" is in the "filename" member, and an
"is_tempfile" member indicates whether it's a temporary file for a live
capture or not.
Have "close_cap_file()" delete the current capture file if it's a
temporary capture file that hasn't been saved (in its entirety - saving
selected frames doesn't count). Do the same (if there *is* a current
capture file) when exiting.
The "Ready to load or capture" message is the only statusbar message in
the "main" context; "close_cap_file()" should never pop it, it should
only pop whatever message exists in the "file" context, and thus has no
need to take, as an argument, the context for the message it should pop.
Update the man page to reflect the new behavior of "File:Save" and
"File:Save As", and to reflect recent changes to "Display:Match Selected".
svn path=/trunk/; revision=1170
1999-11-30 20:50:15 +00:00
|
|
|
|
2003-09-15 22:48:42 +00:00
|
|
|
/* If the file could be opened, "cf_open()" calls "cf_close()"
|
Allow the user to save either all of the current capture, or only the
packets that are currently being displayed from that capture.
Centralize the code to control whether "File:Save" and "File:Save As"
are enabled (and *always* have "File:Save As" enabled if you have a
capture; "File:Save" is enabled only if you have a live capture you've
not yet saved, although it does the same thing as "File:Save As").
Have the "save_file" member of a "capture_file" structure represent
*only* the file currently being *written* to by a capture, and, if there
is no capture currently in progress, have it be NULL; the name of the
file currently being *displayed" is in the "filename" member, and an
"is_tempfile" member indicates whether it's a temporary file for a live
capture or not.
Have "close_cap_file()" delete the current capture file if it's a
temporary capture file that hasn't been saved (in its entirety - saving
selected frames doesn't count). Do the same (if there *is* a current
capture file) when exiting.
The "Ready to load or capture" message is the only statusbar message in
the "main" context; "close_cap_file()" should never pop it, it should
only pop whatever message exists in the "file" context, and thus has no
need to take, as an argument, the context for the message it should pop.
Update the man page to reflect the new behavior of "File:Save" and
"File:Save As", and to reflect recent changes to "Display:Match Selected".
svn path=/trunk/; revision=1170
1999-11-30 20:50:15 +00:00
|
|
|
to get rid of state for the old capture file before filling in state
|
2003-09-15 22:48:42 +00:00
|
|
|
for the new capture file. "cf_close()" will remove the file if
|
Allow the user to save either all of the current capture, or only the
packets that are currently being displayed from that capture.
Centralize the code to control whether "File:Save" and "File:Save As"
are enabled (and *always* have "File:Save As" enabled if you have a
capture; "File:Save" is enabled only if you have a live capture you've
not yet saved, although it does the same thing as "File:Save As").
Have the "save_file" member of a "capture_file" structure represent
*only* the file currently being *written* to by a capture, and, if there
is no capture currently in progress, have it be NULL; the name of the
file currently being *displayed" is in the "filename" member, and an
"is_tempfile" member indicates whether it's a temporary file for a live
capture or not.
Have "close_cap_file()" delete the current capture file if it's a
temporary capture file that hasn't been saved (in its entirety - saving
selected frames doesn't count). Do the same (if there *is* a current
capture file) when exiting.
The "Ready to load or capture" message is the only statusbar message in
the "main" context; "close_cap_file()" should never pop it, it should
only pop whatever message exists in the "file" context, and thus has no
need to take, as an argument, the context for the message it should pop.
Update the man page to reflect the new behavior of "File:Save" and
"File:Save As", and to reflect recent changes to "Display:Match Selected".
svn path=/trunk/; revision=1170
1999-11-30 20:50:15 +00:00
|
|
|
it's a temporary file; we don't want that to happen (for one thing,
|
|
|
|
it'd prevent subsequent reopens from working). Remember whether it's
|
|
|
|
a temporary file, mark it as not being a temporary file, and then
|
|
|
|
reopen it as the type of file it was.
|
|
|
|
|
2003-09-15 22:48:42 +00:00
|
|
|
Also, "cf_close()" will free "cfile.filename", so we must make
|
Allow the user to save either all of the current capture, or only the
packets that are currently being displayed from that capture.
Centralize the code to control whether "File:Save" and "File:Save As"
are enabled (and *always* have "File:Save As" enabled if you have a
capture; "File:Save" is enabled only if you have a live capture you've
not yet saved, although it does the same thing as "File:Save As").
Have the "save_file" member of a "capture_file" structure represent
*only* the file currently being *written* to by a capture, and, if there
is no capture currently in progress, have it be NULL; the name of the
file currently being *displayed" is in the "filename" member, and an
"is_tempfile" member indicates whether it's a temporary file for a live
capture or not.
Have "close_cap_file()" delete the current capture file if it's a
temporary capture file that hasn't been saved (in its entirety - saving
selected frames doesn't count). Do the same (if there *is* a current
capture file) when exiting.
The "Ready to load or capture" message is the only statusbar message in
the "main" context; "close_cap_file()" should never pop it, it should
only pop whatever message exists in the "file" context, and thus has no
need to take, as an argument, the context for the message it should pop.
Update the man page to reflect the new behavior of "File:Save" and
"File:Save As", and to reflect recent changes to "Display:Match Selected".
svn path=/trunk/; revision=1170
1999-11-30 20:50:15 +00:00
|
|
|
a copy of it first. */
|
2001-11-09 00:08:30 +00:00
|
|
|
filename = g_strdup(cfile.filename);
|
2000-06-27 04:36:03 +00:00
|
|
|
is_tempfile = cfile.is_tempfile;
|
|
|
|
cfile.is_tempfile = FALSE;
|
2003-09-15 22:48:42 +00:00
|
|
|
if (cf_open(filename, is_tempfile, &cfile) == 0) {
|
|
|
|
switch (cf_read(&cfile, &err)) {
|
Add routines to Wiretap to allow a client of Wiretap to get:
a pointer to the "wtap_pkthdr" structure for an open capture
file;
a pointer to the "wtap_pseudo_header" union for an open capture
file;
a pointer to the packet buffer for an open capture file;
so that a program using "wtap_read()" in a loop can get at those items.
Keep, in a "capture_file" structure, an indicator of whether:
no file is open;
a file is open, and being read;
a file is open, and is being read, but the user tried to quit
out of reading the file (e.g., by doing "File/Quit");
a file is open, and has been completely read.
Abort if we try to close a capture that's being read if the user hasn't
tried to quit out of the read.
Have "File/Quit" check if a file is being read; if so, just set the
state indicator to "user tried to quit out of it", so that the code
reading the file can do what's appropriate to clean up, rather than
closing the file out from under that code and causing crashes.
Have "read_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
close the capture and return an indication that the read was aborted by
the user. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "continue_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
return an indication that the read was aborted by the user if that
happened. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "finish_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
close the capture and return an indication that the read was aborted by
the user if that happened. Otherwise, return an indication of whether
the read completely succeeded or failed in the middle (and, if it
failed, return the error code through a pointer).
Have their callers check whether the read was aborted or not and, if it
was, bail out in the appropriate fashion (exit if it's reading a file
specified by "-r" on the command line; exit the main loop if it's
reading a file specified with File->Open; kill the capture child if it's
"continue_tail_cap_file()"; exit the main loop if it's
"finish_tail_cap_file()".
svn path=/trunk/; revision=2095
2000-06-27 07:13:42 +00:00
|
|
|
|
|
|
|
case READ_SUCCESS:
|
|
|
|
case READ_ERROR:
|
|
|
|
/* Just because we got an error, that doesn't mean we were unable
|
|
|
|
to read any of the file; we handle what we could get from the
|
|
|
|
file. */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case READ_ABORTED:
|
2000-07-03 09:34:27 +00:00
|
|
|
/* The user bailed out of re-reading the capture file; the
|
|
|
|
capture file has been closed - just free the capture file name
|
|
|
|
string and return (without changing the last containing
|
|
|
|
directory). */
|
|
|
|
g_free(filename);
|
Add routines to Wiretap to allow a client of Wiretap to get:
a pointer to the "wtap_pkthdr" structure for an open capture
file;
a pointer to the "wtap_pseudo_header" union for an open capture
file;
a pointer to the packet buffer for an open capture file;
so that a program using "wtap_read()" in a loop can get at those items.
Keep, in a "capture_file" structure, an indicator of whether:
no file is open;
a file is open, and being read;
a file is open, and is being read, but the user tried to quit
out of reading the file (e.g., by doing "File/Quit");
a file is open, and has been completely read.
Abort if we try to close a capture that's being read if the user hasn't
tried to quit out of the read.
Have "File/Quit" check if a file is being read; if so, just set the
state indicator to "user tried to quit out of it", so that the code
reading the file can do what's appropriate to clean up, rather than
closing the file out from under that code and causing crashes.
Have "read_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
close the capture and return an indication that the read was aborted by
the user. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "continue_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
return an indication that the read was aborted by the user if that
happened. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "finish_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
close the capture and return an indication that the read was aborted by
the user if that happened. Otherwise, return an indication of whether
the read completely succeeded or failed in the middle (and, if it
failed, return the error code through a pointer).
Have their callers check whether the read was aborted or not and, if it
was, bail out in the appropriate fashion (exit if it's reading a file
specified by "-r" on the command line; exit the main loop if it's
reading a file specified with File->Open; kill the capture child if it's
"continue_tail_cap_file()"; exit the main loop if it's
"finish_tail_cap_file()".
svn path=/trunk/; revision=2095
2000-06-27 07:13:42 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
2000-06-27 04:36:03 +00:00
|
|
|
/* The open failed, so "cfile.is_tempfile" wasn't set to "is_tempfile".
|
|
|
|
Instead, the file was left open, so we should restore "cfile.is_tempfile"
|
Allow the user to save either all of the current capture, or only the
packets that are currently being displayed from that capture.
Centralize the code to control whether "File:Save" and "File:Save As"
are enabled (and *always* have "File:Save As" enabled if you have a
capture; "File:Save" is enabled only if you have a live capture you've
not yet saved, although it does the same thing as "File:Save As").
Have the "save_file" member of a "capture_file" structure represent
*only* the file currently being *written* to by a capture, and, if there
is no capture currently in progress, have it be NULL; the name of the
file currently being *displayed" is in the "filename" member, and an
"is_tempfile" member indicates whether it's a temporary file for a live
capture or not.
Have "close_cap_file()" delete the current capture file if it's a
temporary capture file that hasn't been saved (in its entirety - saving
selected frames doesn't count). Do the same (if there *is* a current
capture file) when exiting.
The "Ready to load or capture" message is the only statusbar message in
the "main" context; "close_cap_file()" should never pop it, it should
only pop whatever message exists in the "file" context, and thus has no
need to take, as an argument, the context for the message it should pop.
Update the man page to reflect the new behavior of "File:Save" and
"File:Save As", and to reflect recent changes to "Display:Match Selected".
svn path=/trunk/; revision=1170
1999-11-30 20:50:15 +00:00
|
|
|
ourselves.
|
1999-09-01 03:04:24 +00:00
|
|
|
|
2003-09-15 22:48:42 +00:00
|
|
|
XXX - change the menu? Presumably "cf_open()" will do that;
|
Allow the user to save either all of the current capture, or only the
packets that are currently being displayed from that capture.
Centralize the code to control whether "File:Save" and "File:Save As"
are enabled (and *always* have "File:Save As" enabled if you have a
capture; "File:Save" is enabled only if you have a live capture you've
not yet saved, although it does the same thing as "File:Save As").
Have the "save_file" member of a "capture_file" structure represent
*only* the file currently being *written* to by a capture, and, if there
is no capture currently in progress, have it be NULL; the name of the
file currently being *displayed" is in the "filename" member, and an
"is_tempfile" member indicates whether it's a temporary file for a live
capture or not.
Have "close_cap_file()" delete the current capture file if it's a
temporary capture file that hasn't been saved (in its entirety - saving
selected frames doesn't count). Do the same (if there *is* a current
capture file) when exiting.
The "Ready to load or capture" message is the only statusbar message in
the "main" context; "close_cap_file()" should never pop it, it should
only pop whatever message exists in the "file" context, and thus has no
need to take, as an argument, the context for the message it should pop.
Update the man page to reflect the new behavior of "File:Save" and
"File:Save As", and to reflect recent changes to "Display:Match Selected".
svn path=/trunk/; revision=1170
1999-11-30 20:50:15 +00:00
|
|
|
make sure it does! */
|
2000-06-27 04:36:03 +00:00
|
|
|
cfile.is_tempfile = is_tempfile;
|
Allow the user to save either all of the current capture, or only the
packets that are currently being displayed from that capture.
Centralize the code to control whether "File:Save" and "File:Save As"
are enabled (and *always* have "File:Save As" enabled if you have a
capture; "File:Save" is enabled only if you have a live capture you've
not yet saved, although it does the same thing as "File:Save As").
Have the "save_file" member of a "capture_file" structure represent
*only* the file currently being *written* to by a capture, and, if there
is no capture currently in progress, have it be NULL; the name of the
file currently being *displayed" is in the "filename" member, and an
"is_tempfile" member indicates whether it's a temporary file for a live
capture or not.
Have "close_cap_file()" delete the current capture file if it's a
temporary capture file that hasn't been saved (in its entirety - saving
selected frames doesn't count). Do the same (if there *is* a current
capture file) when exiting.
The "Ready to load or capture" message is the only statusbar message in
the "main" context; "close_cap_file()" should never pop it, it should
only pop whatever message exists in the "file" context, and thus has no
need to take, as an argument, the context for the message it should pop.
Update the man page to reflect the new behavior of "File:Save" and
"File:Save As", and to reflect recent changes to "Display:Match Selected".
svn path=/trunk/; revision=1170
1999-11-30 20:50:15 +00:00
|
|
|
}
|
2003-09-15 22:48:42 +00:00
|
|
|
/* "cf_open()" made a copy of the file name we handed it, so
|
Allow the user to save either all of the current capture, or only the
packets that are currently being displayed from that capture.
Centralize the code to control whether "File:Save" and "File:Save As"
are enabled (and *always* have "File:Save As" enabled if you have a
capture; "File:Save" is enabled only if you have a live capture you've
not yet saved, although it does the same thing as "File:Save As").
Have the "save_file" member of a "capture_file" structure represent
*only* the file currently being *written* to by a capture, and, if there
is no capture currently in progress, have it be NULL; the name of the
file currently being *displayed" is in the "filename" member, and an
"is_tempfile" member indicates whether it's a temporary file for a live
capture or not.
Have "close_cap_file()" delete the current capture file if it's a
temporary capture file that hasn't been saved (in its entirety - saving
selected frames doesn't count). Do the same (if there *is* a current
capture file) when exiting.
The "Ready to load or capture" message is the only statusbar message in
the "main" context; "close_cap_file()" should never pop it, it should
only pop whatever message exists in the "file" context, and thus has no
need to take, as an argument, the context for the message it should pop.
Update the man page to reflect the new behavior of "File:Save" and
"File:Save As", and to reflect recent changes to "Display:Match Selected".
svn path=/trunk/; revision=1170
1999-11-30 20:50:15 +00:00
|
|
|
we should free up our copy. */
|
|
|
|
g_free(filename);
|
|
|
|
}
|
2003-08-18 21:27:11 +00:00
|
|
|
|
|
|
|
/******************** Color Filters *********************************/
|
|
|
|
/*
|
|
|
|
* Keep a static pointer to the current "Color Export" window, if
|
|
|
|
* any, so that if somebody tries to do "Export"
|
|
|
|
* while there's already a "Color Export" window up, we just pop
|
|
|
|
* up the existing one, rather than creating a new one.
|
|
|
|
*/
|
|
|
|
static GtkWidget *file_color_import_w;
|
|
|
|
|
|
|
|
/* sets the file path to the global color filter file.
|
|
|
|
WARNING: called by both the import and the export dialog.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
color_global_cb(GtkWidget *widget _U_, gpointer data)
|
|
|
|
{
|
|
|
|
GtkWidget *fs_widget = data;
|
|
|
|
|
|
|
|
gchar *path;
|
|
|
|
|
|
|
|
/* decide what file to open (from dfilter code) */
|
|
|
|
path = get_datafile_path("colorfilters");
|
|
|
|
|
|
|
|
gtk_file_selection_set_filename (GTK_FILE_SELECTION(fs_widget), path);
|
|
|
|
|
|
|
|
g_free((gchar *)path);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Import color filters */
|
|
|
|
void
|
|
|
|
file_color_import_cmd_cb(GtkWidget *w _U_, gpointer data)
|
|
|
|
{
|
|
|
|
GtkWidget *main_vb, *cfglobal_but;
|
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
GtkAccelGroup *accel_group;
|
|
|
|
#endif
|
|
|
|
/* No Apply button, and "OK" just sets our text widget, it doesn't
|
|
|
|
activate it (i.e., it doesn't cause us to try to open the file). */
|
|
|
|
|
|
|
|
if (file_color_import_w != NULL) {
|
|
|
|
/* There's already an "Import Color Filters" dialog box; reactivate it. */
|
|
|
|
reactivate_window(file_color_import_w);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
file_color_import_w = gtk_file_selection_new ("Ethereal: Import Color Filters");
|
|
|
|
SIGNAL_CONNECT(file_color_import_w, "destroy", file_color_import_destroy_cb, NULL);
|
|
|
|
|
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
/* Accelerator group for the accelerators (or, as they're called in
|
|
|
|
Windows and, I think, in Motif, "mnemonics"; Alt+<key> is a mnemonic,
|
|
|
|
Ctrl+<key> is an accelerator). */
|
|
|
|
accel_group = gtk_accel_group_new();
|
|
|
|
gtk_window_add_accel_group(GTK_WINDOW(file_color_import_w), accel_group);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* If we've opened a file, start out by showing the files in the directory
|
|
|
|
in which that file resided. */
|
|
|
|
if (last_open_dir)
|
|
|
|
gtk_file_selection_set_filename(GTK_FILE_SELECTION(file_color_import_w), last_open_dir);
|
|
|
|
|
|
|
|
/* Container for each row of widgets */
|
|
|
|
main_vb = gtk_vbox_new(FALSE, 3);
|
|
|
|
gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
|
|
|
|
gtk_box_pack_start(GTK_BOX(GTK_FILE_SELECTION(file_color_import_w)->action_area),
|
|
|
|
main_vb, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(main_vb);
|
|
|
|
|
|
|
|
|
|
|
|
cfglobal_but = gtk_button_new_with_label("Global Color Filter File");
|
|
|
|
gtk_container_add(GTK_CONTAINER(main_vb), cfglobal_but);
|
|
|
|
SIGNAL_CONNECT(cfglobal_but, "clicked", color_global_cb, file_color_import_w);
|
|
|
|
gtk_widget_show(cfglobal_but);
|
|
|
|
|
|
|
|
/* Connect the ok_button to file_open_ok_cb function and pass along a
|
|
|
|
pointer to the file selection box widget */
|
|
|
|
SIGNAL_CONNECT(GTK_FILE_SELECTION(file_color_import_w)->ok_button, "clicked",
|
|
|
|
file_color_import_ok_cb, file_color_import_w);
|
|
|
|
|
|
|
|
OBJECT_SET_DATA(GTK_FILE_SELECTION(file_color_import_w)->ok_button,
|
|
|
|
ARGUMENT_CL, data);
|
|
|
|
|
|
|
|
/* Connect the cancel_button to destroy the widget */
|
|
|
|
SIGNAL_CONNECT_OBJECT(GTK_FILE_SELECTION(file_color_import_w)->cancel_button,
|
|
|
|
"clicked", (GtkSignalFunc)gtk_widget_destroy,
|
|
|
|
file_color_import_w);
|
|
|
|
|
|
|
|
/* 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(file_color_import_w, GTK_FILE_SELECTION(file_color_import_w)->cancel_button);
|
|
|
|
|
|
|
|
gtk_widget_show(file_color_import_w);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
file_color_import_ok_cb(GtkWidget *w, GtkFileSelection *fs) {
|
|
|
|
gchar *cf_name, *s;
|
|
|
|
gpointer argument;
|
|
|
|
|
|
|
|
argument = OBJECT_GET_DATA(w, ARGUMENT_CL); /* to be passed back into read_other_filters */
|
|
|
|
|
|
|
|
cf_name = g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION (fs)));
|
|
|
|
/* Perhaps the user specified a directory instead of a file.
|
|
|
|
Check whether they did. */
|
|
|
|
if (test_for_directory(cf_name) == EISDIR) {
|
|
|
|
/* It's a directory - set the file selection box to display that
|
|
|
|
directory, don't try to open the directory as a capture file. */
|
|
|
|
set_last_open_dir(cf_name);
|
|
|
|
g_free(cf_name);
|
|
|
|
gtk_file_selection_set_filename(GTK_FILE_SELECTION(fs), last_open_dir);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Try to open the capture file. */
|
|
|
|
|
|
|
|
if (!read_other_filters(cf_name, argument)) {
|
|
|
|
/* We couldn't open it; don't dismiss the open dialog box,
|
|
|
|
just leave it around so that the user can, after they
|
|
|
|
dismiss the alert box popped up for the open error,
|
|
|
|
try again. */
|
|
|
|
g_free(cf_name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We've crossed the Rubicon; get rid of the file selection box. */
|
|
|
|
gtk_widget_hide(GTK_WIDGET (fs));
|
|
|
|
gtk_widget_destroy(GTK_WIDGET (fs));
|
|
|
|
|
|
|
|
/* Save the name of the containing directory specified in the path name,
|
|
|
|
if any; we can write over cf_name, which is a good thing, given that
|
|
|
|
"get_dirname()" does write over its argument. */
|
|
|
|
s = get_dirname(cf_name);
|
|
|
|
set_last_open_dir(s);
|
|
|
|
gtk_widget_grab_focus(packet_list);
|
|
|
|
|
|
|
|
g_free(cf_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
file_color_import_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
|
|
|
|
{
|
|
|
|
/* Note that we no longer have a "Open Capture File" dialog box. */
|
|
|
|
file_color_import_w = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkWidget *file_color_export_w;
|
|
|
|
/*
|
|
|
|
* Set the "Export only marked filters" toggle button as appropriate for
|
|
|
|
* the current output file type and count of marked filters.
|
|
|
|
*
|
|
|
|
* Called when the "Export" dialog box is created and when the marked
|
|
|
|
* count changes.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
color_set_export_marked_sensitive(GtkWidget * cfmark_cb)
|
|
|
|
{
|
|
|
|
if (file_color_export_w == NULL) {
|
|
|
|
/* We don't currently have an "Export" dialog box up. */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We can request that only the marked filters be saved only if
|
|
|
|
there *are* marked filters. */
|
|
|
|
if (color_marked_count() != 0)
|
|
|
|
gtk_widget_set_sensitive(cfmark_cb, TRUE);
|
|
|
|
else {
|
|
|
|
/* Force the "Export only marked filters" toggle to "false", turn
|
|
|
|
off the flag it controls. */
|
|
|
|
color_marked = FALSE;
|
|
|
|
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(cfmark_cb), FALSE);
|
|
|
|
gtk_widget_set_sensitive(cfmark_cb, FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
color_toggle_marked_cb(GtkWidget *widget, gpointer data _U_)
|
|
|
|
{
|
|
|
|
color_marked = GTK_TOGGLE_BUTTON (widget)->active;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
file_color_export_cmd_cb(GtkWidget *w _U_, gpointer data _U_)
|
|
|
|
{
|
|
|
|
GtkWidget *ok_bt, *main_vb, *cfglobal_but;
|
|
|
|
|
|
|
|
if (file_color_export_w != NULL) {
|
|
|
|
/* There's already an "Color Filter Export" dialog box; reactivate it. */
|
|
|
|
reactivate_window(file_color_export_w);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Default to saving all packets, in the file's current format. */
|
|
|
|
filtered = FALSE;
|
|
|
|
color_marked = FALSE;
|
|
|
|
filetype = cfile.cd_t;
|
|
|
|
|
|
|
|
file_color_export_w = gtk_file_selection_new ("Ethereal: Export Color Filters");
|
|
|
|
SIGNAL_CONNECT(file_color_export_w, "destroy", file_color_export_destroy_cb, NULL);
|
|
|
|
|
|
|
|
/* If we've opened a file, start out by showing the files in the directory
|
|
|
|
in which that file resided. */
|
|
|
|
if (last_open_dir)
|
|
|
|
gtk_file_selection_set_filename(GTK_FILE_SELECTION(file_color_export_w), last_open_dir);
|
|
|
|
|
|
|
|
/* Connect the ok_button to file_export_ok_cb function and pass along a
|
|
|
|
pointer to the file selection box widget */
|
|
|
|
ok_bt = GTK_FILE_SELECTION (file_color_export_w)->ok_button;
|
|
|
|
SIGNAL_CONNECT(ok_bt, "clicked", file_color_export_ok_cb, file_color_export_w);
|
|
|
|
|
|
|
|
/* Container for each row of widgets */
|
|
|
|
main_vb = gtk_vbox_new(FALSE, 3);
|
|
|
|
gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
|
|
|
|
gtk_box_pack_start(GTK_BOX(GTK_FILE_SELECTION(file_color_export_w)->action_area),
|
|
|
|
main_vb, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(main_vb);
|
|
|
|
|
|
|
|
cfmark_cb = gtk_check_button_new_with_label("Export only marked filters");
|
|
|
|
gtk_container_add(GTK_CONTAINER(main_vb), cfmark_cb);
|
|
|
|
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(cfmark_cb), FALSE);
|
|
|
|
SIGNAL_CONNECT(cfmark_cb, "toggled", color_toggle_marked_cb, NULL);
|
|
|
|
gtk_widget_show(cfmark_cb);
|
|
|
|
color_set_export_marked_sensitive(cfmark_cb);
|
|
|
|
|
|
|
|
cfglobal_but = gtk_button_new_with_label("Global Color Filter File");
|
|
|
|
gtk_container_add(GTK_CONTAINER(main_vb), cfglobal_but);
|
|
|
|
SIGNAL_CONNECT(cfglobal_but, "clicked", color_global_cb, file_color_export_w);
|
|
|
|
gtk_widget_show(cfglobal_but);
|
|
|
|
|
|
|
|
/* Connect the cancel_button to destroy the widget */
|
|
|
|
SIGNAL_CONNECT_OBJECT(GTK_FILE_SELECTION(file_color_export_w)->cancel_button,
|
|
|
|
"clicked", (GtkSignalFunc)gtk_widget_destroy,
|
|
|
|
file_color_export_w);
|
|
|
|
|
|
|
|
/* 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(file_color_export_w, GTK_FILE_SELECTION(file_color_export_w)->cancel_button);
|
|
|
|
|
|
|
|
gtk_file_selection_set_filename(GTK_FILE_SELECTION(file_color_export_w), "");
|
|
|
|
|
|
|
|
gtk_widget_show(file_color_export_w);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
file_color_export_ok_cb(GtkWidget *w _U_, GtkFileSelection *fs) {
|
|
|
|
gchar *cf_name;
|
|
|
|
gchar *dirname;
|
|
|
|
|
|
|
|
cf_name = g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(fs)));
|
|
|
|
|
|
|
|
/* Perhaps the user specified a directory instead of a file.
|
|
|
|
Check whether they did. */
|
|
|
|
if (test_for_directory(cf_name) == EISDIR) {
|
|
|
|
/* It's a directory - set the file selection box to display that
|
|
|
|
directory, and leave the selection box displayed. */
|
|
|
|
set_last_open_dir(cf_name);
|
|
|
|
g_free(cf_name);
|
|
|
|
gtk_file_selection_set_filename(GTK_FILE_SELECTION(fs), last_open_dir);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write out the filters (all, or only the ones that are currently
|
|
|
|
displayed or marked) to the file with the specified name. */
|
|
|
|
|
|
|
|
if (!write_other_filters(cf_name, color_marked))
|
|
|
|
{
|
|
|
|
/* The write failed; don't dismiss the open dialog box,
|
|
|
|
just leave it around so that the user can, after they
|
|
|
|
dismiss the alert box popped up for the error, try again. */
|
|
|
|
|
|
|
|
g_free(cf_name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The write succeeded; get rid of the file selection box. */
|
|
|
|
gtk_widget_hide(GTK_WIDGET (fs));
|
|
|
|
gtk_widget_destroy(GTK_WIDGET (fs));
|
|
|
|
|
|
|
|
/* Save the directory name for future file dialogs. */
|
|
|
|
dirname = get_dirname(cf_name); /* Overwrites cf_name */
|
|
|
|
set_last_open_dir(dirname);
|
|
|
|
g_free(cf_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
file_color_export_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
|
|
|
|
{
|
|
|
|
file_color_export_w = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|