Commit Graph

340 Commits

Author SHA1 Message Date
John Thacker a9a7dcec21 Qt: Ensure that add frame comments trigger recoloring, count updates
Add functions to PacketListRecord to invalidate a single record's
colorization and column strings, used for a record is modified in a
way that needs to trigger redrawing, but we don't need to redraw
all packets.

Move the functionality for adding, deleting, and setting frame comments
into PacketListModel, operating on QModelIndexes (or on all physical
rows in the case of deleting all comments from a file.) Trigger
recolorization of any record with an updated comment.

Only set a block as modified when deleting comments if we actually
deleted comments. This avoids marking a file as modified if we
delete all comments from all frames, or all comments from selected
frames, when those comments do not actually have frames.

If cf_set_modified_block is used to modify a block that is already
modified, it can't update the comment count. In that case, return
false and have the callers update the comment count. (It already
has a return value, which is always true.) This avoids having the
GUI warning about saving into a format that doesn't support comments
when comments have been added and then removed.

Note that, unlike with time references and time shifts, there
are no fields (and hence no columns nor color filters) that depend
on whether other fields have comments. If for some reason some
were added, then the model data for all frames would have to be
updated instead. Since there aren't, we don't need to
redrawVisiblePackets, but we do need to drawCurrentPacket to ensure
the packet details are redissected.

Fix #12519
2023-02-17 20:49:11 -05:00
John Thacker a49c022773 Qt: Fix scrollbar vanishing when adding columns
Don't call resize in applyRecentColumnWidths(). It doesn't seem
to be necessary in Qt5 or Qt6 to stretch the packet list last column
when the main window is wider than the total columns, and it doesn't
seem to be necessary to get the horizontal scroll bar to appear if
the columns are wider than the window frame either.
(When adding and removing columns, resizing the main window, etc.,
the columns all behave as expected, including if the wide Info
column is removed).

Resizing the packet list makes the scrollbar (and minimap) disappear.
It reappears when selecting another packet, but since it's not
necessary to resize, don't.

Fix #13597
2023-02-15 13:22:42 +00:00
John Thacker 4f14745fce Qt: Fencepost error in minimap/intelligent scrollbar
The location of the next line should be based off one row larger
than the current row.

This fixes an issue where all the lines drawn in the intelligent
scrollbar are off by one - the color intended to be drawn for
the first packet never appears, the first packet corresponds to
the line for the second packet, etc., and there is a line at
the bottom that can never be colored in.

Fix #18850
2023-02-08 14:47:32 +00:00
John Thacker fd183cb40b Qt: Add ability to cancel sorting
Add the ability to cancel sorting. Since we now parse user inputs
during the sort, test and set the capture file read lock. Try to
sort in PacketList::captureFileReadFinished, since now sorting during
thawing won't happen if it's in the middle of a rescan.

Fix #17640
2023-02-07 00:03:24 +00:00
Gerald Combs cd9f7b64c7 Logray: Remove the "Follow Stream" dialog
We don't reassemble log data into streams, so remove the "Follow" dialog
(for now, at least).
2023-01-22 23:36:23 +00:00
John Thacker 199ecf2983 Qt: Clear selection, not current, in drawCurrentPacket
QItemSelectionModel tracks both the selected index and the
current index.

PacketList redraws when the *selected* index changes, not
the current index. Clearing the current index, and then marking
the same packet as selected and current fires currentChanged but
not selectionChanged. So drawCurrentPacket needs to call
clearSelection(), not clearCurrentIndex(), in order to trigger
a redissection of the currently selected packet and update
the packet details.

For example, if you mark or unmark the currently selected frame,
this causes the packet details to update. Cf 52955b9c43,
which fixed the same issue but for Find Packet.

Fix #14330.
2023-01-19 19:51:37 -05:00
Mikael Kanstrup c4db402db5 Add follow websocket stream support
The websocket protocol masking feature makes follow TCP stream
on websocket traffic show masked payload. To easily view unmasked
and reassembled websocket payload add follow websocket stream
support.
2023-01-19 03:14:18 +00:00
John Thacker da3a48f820 Qt: Add a pref for column text caching, and have it affect sorting
Introduce a preference for the number of rows whose column text can
be cached, and allow sorting of the packet list only when the
number of displayed rows can fit in the cache. This preference only has
an effect for sorting based on columns that require dissection and
caching the column text. This reduces the number of dissections from
O(N log N) to N. Subsequent sorts are even faster.

Columns based on frame data are unaffected, as they sort much faster
as dissection is not required.

Set the size of the QCache introduced in 8c6854fb65 based
on this preference.

Send a temporary status message to the status bar if we try to sort
but there are too many rows, explaining why sorting did not happen and
that the layout preferences can be changed.

Ping #18741
2023-01-07 13:20:24 +00:00
Moshe Kaplan f413260df9 WSLUA: Add new lua function register_packet_menu()
This adds support to Wireshark for custom context menus for packets, so
that when a packet's context menu is opened (e.g., by right-clicking),
Wireshark can support doing things like "run a program" or
"open a URL" with a field from the packet as a parameter. Note that
this is similar to ArcSight's integration commands feature.

For example, it could be used like the following:

```
ROBTEX_URL = "https://www.robtex.com/dns-lookup/"
local function search_robtex(...)
    local fields = {...};

    for i, field in ipairs( fields ) do
        if (field.name == 'http.host') then
            browser_open_url(ROBTEX_URL .. field.value)
            break
        end
    end
end
register_packet_menu("Search host in Robtex", search_robtex, "http.host");
```

Fixes issue #14998
2022-12-07 18:47:14 +00:00
Gerald Combs 932f4ff893 Qt: Don't use QString::toLocal8Bit().
As the QString::toLocal8Bit() documentation says,

"On Unix systems this is equivalen to toUtf8(), on Windows the systems
current code page is being used."

This is problematic for the Packet Comments dialog, since the comments
need to be UTF-8 as per the pcapng specification. Use toUtf8() instead
there and in the Import Text dialog.

Remove the toLocal8Bit() calls from the Extcap Options dialog since they
weren'nt needed.

Blind attempt at fixing #18698.
2022-12-06 17:19:07 +00:00
Martin Mathieson b860351e7f Packet List: preserve horizontal scroll extent for PgUp/PgDn 2022-11-05 21:56:19 +00:00
John Thacker e449b560c0 epan: Properly generate filter expressions for custom columns
Properly generate filter expressions for custom columns by
using proto_construct_match_selected_string on each value and
then joining them together later instead of trying to split
the column expression value.

This ensures that escaping is done properly for display filter
strings, that commas internal to field values are not confused
with commas between occurrences, that for multifield columns
we can distinguish which field each value matches, etc.

It's not entirely clear whether AND or OR logic is appropriate
for multiple occurrences; currently OR is used.

Bump glib requirement to 2.54 for g_ptr_array_find_with_equal_func
(this doesn't drop support for any major distribution that already
meets our other library requirements, like Qt.)

Fix #18001.
2022-11-02 19:46:11 +00:00
John Thacker 2ad4b5bb3c Qt: Generate filter expressions for columns with multiple occurrences
Generate filter expressions for columns with multiple occurrences
by using the membership operator (which is semantically OR).
It's not clear if this approach makes more sense than AND;
there's use cases for both.

Don't do this for multifield custom columns, since we don't know
which values were found by which field. That takes changing
the column logic in several places.

Ping #18001
2022-10-31 16:03:24 +00:00
John Thacker c7a136a5c0 epan: Rearrange column includes
Move all the declarations of routines that are internal and
not for use by dissectors from column-utils.h column-info.h
Move the column max length defines into column-utils.h because
dissectors might need that

Since packet.h already includes column-utils.h, dissectors don't
need to include column-utils.h anymore.
Remove or downgrade a few other column header includes that are
unnecessary.
2022-08-13 19:37:28 +00:00
Guy Harris 20a013a8af Qt: fix speling. 2022-08-02 23:31:44 -07:00
Guy Harris 71f32ef2a8 Make sure we don't create comment options longer than 65535 bytes.
Check in both editcap and Wireshark to make sure that comments have
fewer than 65536 bytes before accepting them.

This shoudl fix #18235, although there should also be checks in
libwiretap to catch cases where the user interface code doesn't do the
check (it should be done in the UI so that the user gets notified
appropriately).
2022-08-02 16:38:49 -07:00
Roland Knall b90fb0da55 Qt: Fix jump on packetlist
If the packetlist is navigated via the up/down keys, the viewport
may jump, if the cell that is being navigated to, has content that
is greated than what is currently displayed

Fixes #16363
2022-07-18 15:25:12 +02:00
Tomasz Moń d1f7aa5acb
Qt: Do not spin new event loop on menu show
There is no need for nesting event loops when showing menus. Show menus
asynchronously to limit possibilities of hard to debug problems related
to re-entering event loop.
2022-07-03 13:41:30 +02:00
Roland Knall 413b383224 Qt: Reduce PacketListHeader complexity
Propagating the capture_file was required for a single
function as was the cast for the model. Both are not
needed, as the functionality can be either moved to
PacketListModel or was already included in PacketList
2022-06-29 14:47:05 +02:00
Roland Knall c3b2cec3f2 Ui: Cleanup row number and select packet
Remove unneeded row number in capture file. The packet list is
the only object that should know the correct number, propagating
it further only complicates things. At the same time, rework
cf_select_packet to select the packet based on frame_data not on
the row (which can be unreliable).
2022-06-28 14:56:06 +02:00
Roland Knall f210edeaf0 Ui: Further simplify ws_ui_util
Remove duplicate functionality for jumping to packet and
remove unused function to move to the end. Furthermore
move the code for redraws of visible packets directly
into the calling code
2022-06-28 14:39:27 +02:00
Roland Knall ef8ed9dff9 Ui: Remove time column reformat callback
The code can be placed directly to packet list model
and does not need to be a generic callback
2022-06-28 14:23:05 +02:00
Roland Knall 1d42fcdd76 Ui: Remove call to recoloring
No callback needed, we can call the model directly
2022-06-28 14:06:49 +02:00
Roland Knall b6226cb136 Qt: Better handle sort restriction
Setting sorting enabled/disabled resorts the list. If this happens
too often, sometimes it can lead to the physical view models
not present anymore and therefore crashing.

Ping #18159
2022-06-28 10:12:24 +02:00
Gerald Combs 73770c61b4 Qt: Add a null pointer check.
Don't assume the main window has an SCTP menu.
2022-04-08 19:57:13 +00:00
Gerald Combs 80de95ca71 Qt: Split MainApplication out from WiresharkApplication.
Move WiresharkApplication.{cpp,h} to MainApplication.{cpp,h}. Add back
WiresharkApplication as a thin superclass of MainApplication, similar to
LogsharkApplication. Change all of our wsApp references to mainApp. We
will likely have to change many or most of them back, but that's a
commit for another time.
2022-04-04 09:39:27 -07:00
Gerald Combs 067b3805b7 Qt: Add float suffixes.
Fix

ui\qt\packet_list.cpp(2101,33): warning C4305: 'argument': truncation from 'double' to 'float' [c:\Users\gerald\Development\wireshark\build\ui\qt\qtui.vcxproj]
    ui\qt\packet_list.cpp(2101,33): warning C4305:         tick_color.setAlphaF(0.3); [c:\Users\gerald\Development\wireshark\build\ui\qt\qtui.vcxproj]
    ui\qt\packet_list.cpp(2101,33): warning C4305:         ^ [c:\Users\gerald\Development\wireshark\build\ui\qt\qtui.vcxproj]
2022-03-25 13:36:07 -07:00
Roland Knall f0e4cedd69 Qt: Fix most of Qt6 compile warnings and issues 2022-03-25 11:16:18 -07:00
Roland Knall 9d11321385 Qt: Disable Sorting for the packet List
Allows the sorting to be disabled to avoid painful recalculations if the
sorting has been clicked on by accident.

Fixes #16786
2022-03-17 16:52:53 +01:00
Roland Knall 33151dc928 Qt: Fix overlay scrollbar indicator
The indicator for selected packets is not reflecting the relative
size of that packet inside the map
2022-03-08 10:31:25 +00:00
John Thacker 52955b9c43 Qt: highlight when search result is in the current packet.
Calling setCurrentIndex with QItemSelectionModel::ClearAndSelect clears
the currentIndex, but not the selection, so it doesn't trigger
selectionChanged. However, highlighting depends on the selectionChanged
signal, not currentChanged(), and it's not emitted if we're still on the
same packet/row as the current selection (which can occur if searching
for something that occurs in exactly one packet in a capture.)

Since packet_list_select_row_from_data() cares about where the data
is within the packet, it needs to clear the selection.  Fix #8269
2022-02-11 18:21:35 +00:00
Gerald Combs 6d319297ae Qt: Add a common hover color. 2022-01-03 19:03:46 +00:00
João Valverde 504de90a3c wsutil: Split format_size() enum
Use an enum to select units and a bit flag for the other options,
currently only prefix type.
2021-11-29 22:13:32 +00:00
Tomasz Moń 890555b8bd Qt: Qt6.2 compatibility fixes
Wireshark successfully compiles on Windows with Qt6.2 with following
cmake options:
  -DUSE_qt6=ON -DDISABLE_ERROR=ON

QCustomPlot QT 6.2 patch is taken from QCustomPlot forum post by miccs.
2021-11-29 04:55:12 +00:00
David Perry 389a603fdb Allow adding comments to all selected packets
Allow the user to select multiple packets, and

* add the same comment to all selected packets
* remove all comments from selected packets

A new comment is added to each packet, now that we support multiple
comments per packet.

This is one potential way to address #8713.
2021-09-10 20:47:12 +00:00
Guy Harris dd5907d2a3 Consistently refer to blocks that have been modified as "modified".
"User" sounds as if the blocks belong to the user; at most, the current
user might have modified them directly, but they might also have, for
example, run a Lua script that, unknown to them, modified comments.
Also, a file might have "user comments" added by a previous user, who
them wrote the file and and provided it to the current user.

"Modified" seems a bit clearer than "changed".
2021-07-08 00:05:35 -07:00
David Perry 73087d6fb4 Use wtap_blocks for packet comments
Mostly functioning proof of concept for #14329. This work is intended to
allow Wireshark to support multiple packet comments per packet.

Uses and expands upon the `wtap_block` API in `wiretap/wtap_opttypes.h`.
It attaches a `wtap_block` structure to `wtap_rec` in place of its
current `opt_comment` and `packet_verdict` members to hold OPT_COMMENT
and OPT_PKT_VERDICT option values.
2021-07-07 18:40:24 +00:00
João Valverde 8cf9791679 Replace some lingering references to g_log() 2021-06-19 02:34:36 +00:00
Jim Young d42042fcbb Qt: Add checkbox for enabling/disabling packet-list hover_style
At times the presence of the packet-list hover_style colorization can make
it difficult to determine the state of the packet directly under the mouse
cursor. This forces the user to move the mouse cursor away from the
packet-list row to reveal the next colorization state. The packet-list row
colorization style precedence, from highest to lowest, is: hover_style,
Selected, Ignored, Marked and then coloring rules.

This patch adds a new 'Packet List settings:' checkbox option 'Enable
mouse-over colorization'. By default the supporting preference
`gui.packet_list_hover_style.enabled` will be enabled (TRUE). When this
checkbox is disabled, the packet-list hover_style (mouse-over)
colorization will not be used.
2021-04-21 08:36:27 +00:00
Jim Young 56c540159d packet_list: Promptly reflect changes to frame.marked field
Add redrawVisiblePackets() to respond to user triggered event to
promptly trigger updates to the frame.marked field text when displayed
in the packet list.

Without this patch, if frame.marked is added as a custom column, updates
to the packet lists's frame.marked field text of packets will not be
immediately reflected in the packet list until some other event such as
adding a packet comment or ignoring a frame ultimately triggers
redrawVisiblePackets().
2021-04-04 17:18:13 +00:00
Jirka Novak e75e1fb580 Follow SIP Call: Added Follow SIP Call to Follow menu
Changes:
- epan/follow.c: follow_conv_filter_func has new parameter
  epan_dissect_t *edt, so filter can be generated based on decoded tree
of packet below the cursor
- menu Follow/SIP Call is enabled when sip packet is selected
- value of sip.Call-ID is used as filter for SIP call
- for sharkd it generates filter just 'sip.Call-ID' with no value
2021-03-27 09:02:14 +00:00
Gerald Combs d3f17ee08a Remove modelines in ui/qt.
Remove the editor modeline blocks from most of the source files in ui/qt
by running

    perl -i -p0e 's{ \n+ /[ *\n]+ editor \s+ modelines .* shiftwidth= .* \*/ \s+ } {\n}gsix' $( ag -g '\.(cpp|h)' )

then cleaning up the remaining files by hand.

This *shouldn't* affect anyone since

- All of the source files in ui/qt use 4 space indentation, which
  matches the default in our top-level .editorconfig

- The one notable editor that's likely to be used on these files and
  *doesn't* support EditorConfig (Qt Creator) defaults to 4 space
  indentation.
2021-03-08 18:11:32 +00:00
Thomas Dreibholz 2e7f2ffb7a
Added "Follow DCCP stream" feature.
This pull request includes:
* The "Follow DCCP stream" feature.
* Updated docbook documentation for the "Follow DCCP stream" feature.
* Test for the feature.
* Corresponding packet trace for the test.
2021-02-22 12:48:46 +01:00
Martin Kaiser 0f0b340aa5 PacketList: mouseMoveEvent: fix memory leak
We allocate a QMimeData object at the beginning of PacketList::mouseMoveEvent.
Usually, this object is passed to a QDrag object by calling drag->setMimeData.
In this case, the QDrag object owns the mime data object and frees it when
it's no longer required.

If the mime data object contains no data that can be dragged and dropped, we
reach the end of PacketList::mouseMoveEvent without anyone taking care of
the mime object. We have to free it ourselves in this case.

The problem can be reproduced if you add a custom column for an element that
does not exist in your capture file. Left-click onto the empty column and
drag the empty column entry somewhere. An asan build will then show the
memory leak

Indirect leak of 240 byte(s) in 2 object(s) allocated from:
    #0 0x7f351e153d30 in operator new(unsigned long) (...)
    #1 0x7f3500b79802 in QMimeData::QMimeData() (...)

Indirect leak of 32 byte(s) in 2 object(s) allocated from:
    #0 0x7f351e153d30 in operator new(unsigned long) (...)
    #1 0x5635156dfbc7 in PacketList::mouseMoveEvent(QMouseEvent*) ...
    #2 0x7f3502eb94d7 in QWidget::event(QEvent*) (...)
2021-02-21 13:29:11 +00:00
Stig Bjørlykke 7980f25f99 Qt: Fetch OverlayScrollBar sliderPosition from the real ScrollBar
In OverlayScrollBar return the real ScrollBar sliderPosition to ensure
the correct value is used when handling the actionTriggered signal in
vScrollBarActionTriggered().

This improves turning on and off auto scroll during capture when page
stepping using the packet list slider, because the value is propagated
after this signal.
2021-01-05 08:04:14 +00:00
Pascal Quantin fb2414ae6d Qt: fix some Qt 5.15.2 deprecation warnings 2020-11-25 07:23:21 +00:00
Gerald Combs 1c2fd68e26 Qt: Fix saving+restoring frozen packet list rows.
Use the packet list selection model to save and restore selected rows
when freezing and thawing. Fixes #16770.
2020-10-28 15:36:07 +00:00
Gerald Combs d2da4c7afb Qt: Use … instead of UTF8_HORIZONTAL_ELLIPSIS in translated strings.
Run

$ gsed -i -e 's/\(tr *(.*".*\)" *UTF8_HORIZONTAL_ELLIPSIS/\1…"/' $( ag -l 'tr *\(.*" *UTF8_HORIZONTAL_ELLIPSIS' )
$ gsed -i -e 's/\(tr *( *\)UTF8_HORIZONTAL_ELLIPSIS *"/\1"…/' $( ag -l 'tr *\( *UTF8_HORIZONTAL_ELLIPSIS *"' )

in ui/qt. As discussed in #16812, the UTF8_ macros were required at one
time because we only allowed ASCII in our source code. However, that
requirement has since been relaxed and Qt's translation framework
doesn't handle concatenating strings and macros very well.
2020-10-01 06:40:14 +00:00
Stig Bjørlykke a6d8a2c118 Qt: List all protocols in PacketList "Protocol Preferences"
Show all protocols which has preferences in the packet list context
menu "Protocol Preferences".

Change-Id: I72e2ed95db36cc6d817ca44db214782f075d55d6
Reviewed-on: https://code.wireshark.org/review/37666
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2020-07-03 06:12:40 +00:00
Tomasz Moń 63a8ac5210 Qt: Respect user preference to hide packet list
Instead of hiding whole packet list widget when freezing, hide only the
header. This prevents unwanted column resizes while keeping the widget
on screen while capture file is loading.

Prevent flickering by showing master_split_ only after all widgets are
in correct place.

Ping-Bug: 16063
Ping-Bug: 16491
Change-Id: I3bb0763c44b23b1e4118003502d4bf3903591f34
Reviewed-on: https://code.wireshark.org/review/37159
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-05-08 04:07:35 +00:00