Commit Graph

48 Commits

Author SHA1 Message Date
Anders Broman c19583b72c From Michael Mann:
Generic preferences implementation - Printing and Name Resolution.

svn path=/trunk/; revision=43579
2012-07-06 04:48:36 +00:00
Jakub Zawadzki bf81b42e1e Update Free Software Foundation address.
(COPYING will be updated in next commit)

svn path=/trunk/; revision=43536
2012-06-28 22:56:06 +00:00
Guy Harris c96179ed1e In the "Save As" dialog box, default to compressed if the file is
compressed and the default file format supports compression.

svn path=/trunk/; revision=43475
2012-06-25 17:56:29 +00:00
Guy Harris 16f582176b In the Windows capture file "Save As" dialog code, do the same sort of
checks for the inability to save comments that we do for UN*X.  This
should fix bug 7222, although the UI isn't currently as nice, as the
dialog boxes are Windows dialog boxes and we don't set the button labels
to reflect the actual choices being offered to the user.  (We may be
able to do that by using template resources to construct the message
boxes.)

svn path=/trunk/; revision=43444
2012-06-23 08:18:14 +00:00
Jakub Zawadzki 557ed446c9 Change #if USE_WIN32_FILE_DIALOGS to #ifdef
It should fix buldbot compilation error:
  capture_file_dlg.c(2107) : fatal error C1017: invalid integer constant expression

svn path=/trunk/; revision=43441
2012-06-22 08:22:11 +00:00
Guy Harris 204ea39c5d Move a bunch of common code in the file chooser dialog loops into a
routine to run a file chooser dialog.

On Windows, add to that code to resolve shell links ("shortcuts"),
adopted from the Sylpheed mail reader.  (That code requires a pile of
OLE stuff, so link with the OLE library.)

Make it a bit easier to configure ui/gtk/capture_file_dlg.c to use GTK+
dialogs on Windows, but continue to default to using the Win32 dialogs,
at least for now.

svn path=/trunk/; revision=43439
2012-06-21 22:21:02 +00:00
Guy Harris 3e7ea12e96 Clean up white space (no tabs).
svn path=/trunk/; revision=43397
2012-06-20 05:48:06 +00:00
Guy Harris 750d666e73 Handle the case where the user has added comments to a file that's not
in a format that supports comments and they do a "Save" by popping up a
similar question to the one we pop up in the "Save As" case and, if they
say "choose another format", pop up a "Save As" dialog box.

svn path=/trunk/; revision=43395
2012-06-20 04:44:14 +00:00
Guy Harris 06474b4330 If the file has an SHB comment or any packet comments, and the user
tries to do "Save As" in a format for which we don't support comments
(currently, we only support them for pcap-ng), ask whether they want to
discard the comments and save anyway or, *if* the file can be saved in a
format for which we *do* support comments, they want to save the file in
some other format.

Keep a count of packet comments so that we don't have to scan all the
frame_data structures to determine whether we have any comments.

svn path=/trunk/; revision=43392
2012-06-20 01:11:01 +00:00
Guy Harris 475b8d9bcd The GTK+ file chooser already *includes* UI code to ask the user whether
they want to overwrite an existing file; just use that.  (The Win32 file
chooser also does that itself.)  Just do UI for "do you want to
overwrite this {user-immutable,unwritable} file?".

svn path=/trunk/; revision=43381
2012-06-19 19:20:47 +00:00
Guy Harris c63aa61658 Have wtap_get_savable_file_types() take an array of encapsulations and
only return file types that could handle a single file with all those
encapsulations - this means that

	1) if there's more then one encapsulation, the file format has
to handle per-packet encapsulation;

	2) just because a file format handles per-packet encapsulation,
that doesn't mean that it can handle the *particular* encapsulations
being handed to it.

This fixes some cases where we were claiming that a file could be saved
in a format that doesn't actually support it (e.g., ISDN files being
reported as savable in pcap-NG format - there's no LINKTYPE_ value for
ISDN including B and D channels).

svn path=/trunk/; revision=43300
2012-06-17 01:32:50 +00:00
Guy Harris d86f0b5271 No pcap, no capture to stop.
svn path=/trunk/; revision=43249
2012-06-14 02:11:34 +00:00
Guy Harris 481c44b78b When stopping the capture before asking whether to save the results, run
the main loop until we're done reading the captured packets.  Hopefully
this clears up bug 7318 in Evan Huus's case; I can't reproduce that
myself.

svn path=/trunk/; revision=43248
2012-06-14 01:34:52 +00:00
Guy Harris 99536cc8da Distinguish between "failed" and "user stopped it" for "save as" and
"export specified packets".  For "failed", let the user try again with a
different file, in case it failed due to, for example, running out of
space or quota (probably the most likely failure mode for writing, and
trying to a different volume might be the best workaround).  For "user
stopped it", presumably they don't want to try again (the most likely
reason is "it was taking too damn long").
 
Put "Exporting to: ...", not "Saving: ..." in the statusbar if we're
doing "export specified packets".

In process_specified_packets(), allow a null range pointer to be
specified, meaning "save 'em all"; that avoids the possibly-expensive
(with a large capture) operation of initializing the range.

If a "safe save" atop an existing file fails or is stopped, get rid of
the temporary file we created.

svn path=/trunk/; revision=43095
2012-06-05 02:46:54 +00:00
Guy Harris 00de07144d Use the modal version of the bad display filter alert box in the I/O
statistics window.

Get rid of the non-modal version (it's not being used any more), and
remove the now-redundant _modal from the modal version.

svn path=/trunk/; revision=43081
2012-06-04 20:08:59 +00:00
Guy Harris 5caadafaca And do the same with the color filter import and export dialogs (which
really don't belong here - they have nothing to do with capture files).

Absorb the test for the target file's existence into
file_target_exist_ui().

svn path=/trunk/; revision=43077
2012-06-04 19:37:04 +00:00
Guy Harris 0955936403 And do the same with the merge dialog.
svn path=/trunk/; revision=43076
2012-06-04 19:04:45 +00:00
Guy Harris 8ba4fe2413 Clean up indentation.
svn path=/trunk/; revision=43075
2012-06-04 18:41:36 +00:00
Guy Harris 1899e6ee34 Do with the open dialog what we've done with the save and "export
selected packets" dialog.

svn path=/trunk/; revision=43074
2012-06-04 18:40:45 +00:00
Guy Harris afa17a95b0 Make the "Export Selected Packets As..." code path more like the "Save
As..." code path.

Extract the code for the "do you want to overwrite this file" and "OK,
you do - are you aware it's {user-immutable, read-only}?" code paths
into a common routine for use by both of those and, potentially, other
save/export/etc. code paths in the future.

For "Save As", allow us to save atop the current capture file, as that's
just what "Save" does if there are unsaved changes, and "safe save"
makes that work.  *Don't* allow that for "Export Selected Packets
As...", however.

The file chooser is run as a modal dialog, so we don't need to worry
about creating more than one of them or about the number of marked
packets etc. being changed out from under us.  Get rid of a bunch of
static variables.

svn path=/trunk/; revision=43060
2012-06-04 10:27:59 +00:00
Guy Harris ab13375393 Clean up indentation.
svn path=/trunk/; revision=43056
2012-06-04 08:46:51 +00:00
Guy Harris 9c44d87610 Have a main_update_for_unsaved_changes() routine that, if changes are
made to the capture file (adding/removing/editing comments, for now) or
if a capture file with unsaved changes are unsaved, updates the menu
bar, the toolbar, *and* the titlebar, which now has a GNOME-style "*" to
indicate unsaved changes.

Make set_menus_for_capture_file() a private interface between main.c and
main_menubar.c, and have its callers, such as
main_update_for_unsaved_changes(), be responsible for updating the
toolbar as well.

svn path=/trunk/; revision=43051
2012-06-04 02:24:42 +00:00
Guy Harris 624b3f6d19 set_file_type_list() uses two items from the capture_file structure;
just pass it a pointer to a capture_file structure and have it use them
as it chooses.

svn path=/trunk/; revision=43049
2012-06-03 23:41:39 +00:00
Guy Harris dbfb305368 g_filename_display_basename() returns a g_mallocated string, so its
callers either need to free it or their callers need to free it or....

This means that cf_get_display_name() must always return a g_mallocated
string and its callers or... must free it.

For some of those callers, create a new set_window_title() routine to do
the work - they're all using the same pattern.

svn path=/trunk/; revision=43047
2012-06-03 22:03:05 +00:00
Guy Harris bfb179ba46 When allowing the user to save a capture file before closing it, if it's
a live capture:

	have the dialog note that what's being saved are captured
	packets;

	have the dialog note that the capture will be stopped if you
	close/quit;

	actually stop the capture before saving the file or closing it.

This should fix bug 7318 (it appears to do so in my tests).

svn path=/trunk/; revision=43045
2012-06-03 20:39:45 +00:00
Guy Harris 49ac36fd59 Use g_filename_display_basename() rather than get_basename() when we're
getting the basename for display purposes, so it's converted from the
GLib/GTK+ locale filename encoding to UTF-8.  (For Windows, the locale
filename encoding is UTF-8, and the internal encoding is UTF-16, so the
file names should *probably* all be valid UTF-8 - Windows may not
support invalid UTF-16 in file names.  For Qt, I'm not sure whether the
file dialogs ever return file names in some non-UTF-8 encoding.)

svn path=/trunk/; revision=43044
2012-06-03 19:31:59 +00:00
Guy Harris 19dfeda6d6 Note in a comment that we should perhaps handle safe-saving on top of a
symlink.

svn path=/trunk/; revision=43037
2012-06-03 17:35:34 +00:00
Guy Harris cd90f2b6f5 gedit, at least, says
The file "xxx" is read-only.

if you try to save over a file that has no read permission bits.

svn path=/trunk/; revision=43036
2012-06-03 17:25:08 +00:00
Anders Broman dbc4b09004 From Evan Huus Convert a bunch more GTK-2 calls to their cross-version ws_ equivalent
svn path=/trunk/; revision=43009
2012-06-02 23:53:04 +00:00
Guy Harris 68a4971594 If the user tries to save a capture file atop a file that has all its
write bits turned off or, on 4.4-Lite-based systems, has its "user
immutable" bit turned on, ask them if they really want to overwrite the
file (as those are both used to say "this file is precious, don't let me
easily accidentally trash it") and, if the "user immutable" bit is set,
turn it off first so that the move in the "safe save" won't fail.

svn path=/trunk/; revision=43006
2012-06-02 18:53:13 +00:00
Guy Harris 2e4f30d0f9 The only reason we need to do locale conversions is that path names as
returned by the file selection dialog are in the locale's character
encoding.  Just convert those, and use the formatting capabilities of
the GTK+ message dialog rather than formattting the message to a string
and translating it in its entirety.

Use g_filename_display_basename() to do the locale conversion while
we're at it.

svn path=/trunk/; revision=43005
2012-06-02 18:13:12 +00:00
Guy Harris 49216b1091 Clean up indentation.
svn path=/trunk/; revision=43004
2012-06-02 17:05:12 +00:00
Guy Harris 6014035703 Use GTK+'s GtkMessageDialog for the questions we ask in the process of
saving files, and run it modal (which we're already doing with the
GtkFileChooserDialog); this means less callback-based state machine
stuff, simplifying the code paths a bit.

If we're saving a file before closing it, don't bother reloading it
after saving it.

svn path=/trunk/; revision=42855
2012-05-25 21:25:55 +00:00
Guy Harris facd4aca9d Now that cf_save_packets() can avoid doing a "fast path" save if the
source isn't compressed and the target is (or vice versa), enable the
"compressed" checkbox in the Save As and Export Specified Packets
dialog.  Fix it to clear the checkbox if the selected file format
doesn't support gzipping.

svn path=/trunk/; revision=42822
2012-05-24 07:51:39 +00:00
Guy Harris cf6d9841e3 Keep track, in Wiretap, of whether the file is compressed, and provide
an API to fetch that.

When doing "Save" on a compressed file, write it out compressed.

In the Statistics -> Summary dialog and in capinfos, report whether the
file is gzip-compressed.

svn path=/trunk/; revision=42818
2012-05-24 05:05:29 +00:00
Guy Harris b655197a9d In the "Save As" and "Export Specified Packets" code path, do a "safe
save" if the destination file exists.

Don't forbid overwriting an existing file in either of those cases (we
still forbid overwriting the current capture file) - the GUI asks the
user whether they want to do the overwrite, and allows them to cancel
out of it - and don't remove the file before writing to it (doing so
makes the save *un*safe).

Attempt to do a save of an unedited temporary file by just moving the
file on Windows as well as on UN*X - ws_rename() will remove the target
if necessary on Windows (and won't do it as a separate operation before
attempting the rename), so it behaves like ws_rename() on UN*X (which is
just a wrapper around rename()).

svn path=/trunk/; revision=42816
2012-05-24 02:16:53 +00:00
Guy Harris ef163bb569 Separate callback to control the file type combo box in the "Export
Specified Packets" dialog.

svn path=/trunk/; revision=42795
2012-05-22 22:57:37 +00:00
Guy Harris 07835ce129 Do the "Save As always saves the entire capture, Export Specified
Packets saves specified packets" stuff for Windows.

svn path=/trunk/; revision=42794
2012-05-22 22:39:30 +00:00
Guy Harris c2bb7956c2 "Save As" always saves everything and, when the save is done, makes the
new file the current file, as is the case in most if not all other GUI
applications.

A new "Export Specified Packets" menu option allows you to specify which
packets to write out, with the default being the displayed packets (and
those on which the displayed packets depend for, e.g.  reassembly), and
never makes the resulting file the current file.

The two operations are conceptually distinct.  Lumping them into one
menu item, with the default for "Save As" being "displayed packets only"
and thus making it behave like the latter operation, was causing some
confusion; see, for example, bug 6640.

Make the dialog popped up if you try to "Save As" or "Export Specified
Packets" on top of an existing file ask the "do you want to do this?"
question in the main part of the message, and note in the secondary text
that doing that will overwrite what's in the file; that matches what
TextEdit on OS X and the GNOME text editor say.

svn path=/trunk/; revision=42792
2012-05-22 22:17:57 +00:00
Guy Harris ae7d57d5fa We're an editor now, as we let you add, delete, and edit frame comments,
so "Save" should, for non-temporary files, mean "save the current state
of the capture file on top of the existing file" without prompting for a
file name.

That means we have to do a "safe save" - i.e, write the capture out to a
new file and, if that succeeds, rename the new file on top of the old
file - as the actual packet data to write out is in the file we're
overwriting, not in memory.  (We'd want to do that anyway, of
course....)

Update some comments.

Clean up indentation slightly, and get rid of an unnecessary variable
(in all the cases where we use it, we assign it the same value, and that
value isn't modified out from under us before we use it).

Note that after a "Save", or a "Save As" that writes out all captured
packets, we shouldn't have to close the current file and open the new
file and reread it - we should be able to open the new file and update
the frame offsets in the frame_data structures.

Note that we need to do some a better job of reporting rename failures.

svn path=/trunk/; revision=42777
2012-05-22 10:36:40 +00:00
Guy Harris 4a9b825c49 Change the "user_saved" member of a capture_file structure to
"unsaved_changes", and have it be TRUE iff changes have been made to the
file since it was read - *not* if it's a temporary file from a live
capture.

Check the "is_tempfile" member, and the "unsaved_changes" member, when
appropriate.

Just have a set_toolbar_for_capture_file() routine that updates the
"save", "close", and "reload" toolbar as appropriate, given a
capture_file structure - absorb the function of
set_toolbar_for_unsaved_capture_file() into it.

svn path=/trunk/; revision=42721
2012-05-20 08:56:06 +00:00
Jeff Morriss 89cfdc3559 Fix https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=3315 -
make Save-As/Displayed/All-Packets save not only the displayed packets but
also any other packets needed (e.g., for reassembly) to fully dissect the
displayed packets.

This works only for the "All packets" case; choosing only the Selected packet,
the Marked packets, or a range of packets would require actually storing which
packets depend on which (too much memory) or going through the packet list many
times (too slow).  Also, this behavior is always the case: you can't save the
displayed packets without their dependencies (I don't see why this would be
desirable).

So far this is done for SCTP and things using the reassembly routines (TCP has
been tested).

The Win32 dialog was modified but hasn't been tested yet.

One confusing aspect of the UI is that the Displayed count in the Save-As
dialog does not match the number of displayed packets.  (I tried renaming the
button "Displayed + Dependencies" but it looked too big.)  The tooltip tries
to explain this and the fact that this works only in the All-Packets case;
suggestions for improvement are welcome.


Implementation details:

Dissectors (or the reassembly code) can list frames which were needed to
build the current frame's tree.  If the current frame passes the display
filter then each listed frame is marked as "depended upon" (this takes up the
last free frame_data flag).

When performing a Save-As/Displayed/All-Packets then choose packets which
passed the dfilter _or_ are depended upon.

svn path=/trunk/; revision=41216
2012-02-28 03:19:49 +00:00
Jörg Mayer a206a11e7e include "../util.h" -> include "ui/util.h"
svn path=/trunk/; revision=41048
2012-02-17 12:46:50 +00:00
Guy Harris c8854a7a5f Add a routine to Wiretap that takes a file type value and an
encapsulation value and returns a GArray containing all the file types
that could be used to save a file of that file type and that
encapsulation value (which could be WTAP_ENCAP_PER_PACKET), with the
input file type first if that can be used and pcap or pcap-ng first if
not and if one of them can be used, and with pcap and pcap-ng clustered
together if they're among the file types that can be used.

Use that routine for the GTK+ file save dialog.

svn path=/trunk/; revision=40685
2012-01-24 04:33:23 +00:00
Guy Harris dacb4133e8 Restructure the recent file code so that recent.c is GUI-independent;
move it to the top-level source directory for now, and move
ui/gtk/recent.h to the ui directory.

svn path=/trunk/; revision=40561
2012-01-18 19:38:34 +00:00
Guy Harris 21ddeed32b Reflect the move of the top-level win32 directory into the ui directory.
svn path=/trunk/; revision=40532
2012-01-16 01:29:08 +00:00
Guy Harris d7b2aad043 Move some headers for UI stuff, and the alert_box.c UI-specific file, to
the ui directory.  (Perhaps some other files that would be used by all
flavors of Wireshark, for any GUI toolkit or for someting such as
ncurses, and not for any command-line tool such as TShark, should be
moved there as well.)

Shuffle some #includes to put the "ui/XXX.h" includes together.

svn path=/trunk/; revision=40529
2012-01-16 01:07:52 +00:00
Jörg Mayer be706c6380 Move gtk to ui/gtk.
This looses the last checkin to gtk, will add this manually back.

svn path=/trunk/; revision=40518
2012-01-15 21:59:11 +00:00