diff options
author | Gerald Combs <gerald@wireshark.org> | 2012-12-17 23:03:21 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2012-12-17 23:03:21 +0000 |
commit | 77e6140ba99ca1785972bb8455877fc33350990a (patch) | |
tree | 779b3abea24607c375535fd4b9ca5dadb0ea56b8 | |
parent | dc908733eaf62b0a3506dca52f2412b92a6cbf7c (diff) |
Implement the frame mark, ignore, and time reference actions. Update the
text of a few menu items.
svn path=/trunk/; revision=46576
-rw-r--r-- | frame_data_sequence.h | 10 | ||||
-rw-r--r-- | ui/gtk/main_menubar.c | 23 | ||||
-rw-r--r-- | ui/qt/main_status_bar.h | 3 | ||||
-rw-r--r-- | ui/qt/main_window.cpp | 6 | ||||
-rw-r--r-- | ui/qt/main_window.h | 16 | ||||
-rw-r--r-- | ui/qt/main_window.ui | 147 | ||||
-rw-r--r-- | ui/qt/main_window_slots.cpp | 290 | ||||
-rw-r--r-- | ui/qt/packet_list.cpp | 149 | ||||
-rw-r--r-- | ui/qt/packet_list.h | 12 | ||||
-rw-r--r-- | ui/qt/packet_list_model.cpp | 3 | ||||
-rw-r--r-- | ui/qt/packet_list_model.h | 1 | ||||
-rw-r--r-- | ui/qt/packet_list_record.cpp | 8 | ||||
-rw-r--r-- | ui/qt/packet_list_record.h | 14 |
13 files changed, 649 insertions, 33 deletions
diff --git a/frame_data_sequence.h b/frame_data_sequence.h index 5e1f08f2f0..8d686e7f8e 100644 --- a/frame_data_sequence.h +++ b/frame_data_sequence.h @@ -25,6 +25,10 @@ #ifndef __FRAME_DATA_SEQUENCE_H__ #define __FRAME_DATA_SEQUENCE_H__ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + typedef struct _frame_data_sequence frame_data_sequence; extern frame_data_sequence *new_frame_data_sequence(void); @@ -43,4 +47,8 @@ extern frame_data *frame_data_sequence_find(frame_data_sequence *fds, */ extern void free_frame_data_sequence(frame_data_sequence *fds); -#endif /* frame_data_sequence.h */ +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __FRAME_DATA_SEQUENCE_H__ */ diff --git a/ui/gtk/main_menubar.c b/ui/gtk/main_menubar.c index 3a06e39262..0f606eadd4 100644 --- a/ui/gtk/main_menubar.c +++ b/ui/gtk/main_menubar.c @@ -1502,23 +1502,24 @@ static const GtkActionEntry main_menu_bar_entries[] = { { "/Edit/FindNext", NULL, "Find Ne_xt", "<control>N", NULL, G_CALLBACK(find_next_cb) }, { "/Edit/FindPrevious", NULL, "Find Pre_vious", "<control>B", NULL, G_CALLBACK(find_previous_cb) }, - { "/Edit/MarkPacket", NULL, "_Mark Packet (toggle)", "<control>M", NULL, G_CALLBACK(packet_list_mark_frame_cb) }, - { "/Edit/ToggleMarkingOfAllDisplayedPackets", NULL, "Toggle Marking Of All Displayed Packets", "<shift><alt><control>M", NULL, G_CALLBACK(packet_list_toggle_mark_all_displayed_frames_cb) }, + { "/Edit/MarkPacket", NULL, "_Mark/Unmark Packet", "<control>M", NULL, G_CALLBACK(packet_list_mark_frame_cb) }, + /* XXX - Unused. Should this and its associated code be removed? */ + { "/Edit/ToggleMarkingOfAllDisplayedPackets", NULL, "Toggle Marking of All Displayed Packets", "<shift><alt><control>M", NULL, G_CALLBACK(packet_list_toggle_mark_all_displayed_frames_cb) }, { "/Edit/MarkAllDisplayedPackets", NULL, "Mark All Displayed Packets", "<shift><control>M", NULL, G_CALLBACK(packet_list_mark_all_displayed_frames_cb) }, { "/Edit/UnmarkAllDisplayedPackets", NULL, "_Unmark All Displayed Packets", "<alt><control>M", NULL, G_CALLBACK(packet_list_unmark_all_displayed_frames_cb) }, - { "/Edit/FindNextMark", NULL, "Find Next Mark", "<shift><control>N", NULL, G_CALLBACK(find_next_mark_cb) }, - { "/Edit/FindPreviousMark", NULL, "Find Previous Mark", "<shift><control>B", NULL, G_CALLBACK(find_prev_mark_cb) }, + { "/Edit/FindNextMark", NULL, "Next Mark", "<shift><control>N", NULL, G_CALLBACK(find_next_mark_cb) }, + { "/Edit/FindPreviousMark", NULL, "Previous Mark", "<shift><control>B", NULL, G_CALLBACK(find_prev_mark_cb) }, - { "/Edit/IgnorePacket", NULL, "_Ignore Packet (toggle)", "<control>X", NULL, G_CALLBACK(packet_list_ignore_frame_cb) }, + { "/Edit/IgnorePacket", NULL, "_Ignore/Unignore Packet", "<control>X", NULL, G_CALLBACK(packet_list_ignore_frame_cb) }, /* * XXX - this next one overrides /Edit/Copy/Description */ - { "/Edit/IgnoreAllDisplayedPackets", NULL, "_Ignore All Displayed Packets (toggle)","<alt><shift><control>X", NULL, G_CALLBACK(packet_list_ignore_all_displayed_frames_cb) }, - { "/Edit/Un-IgnoreAllPackets", NULL, "U_n-Ignore All Packets", "<shift><control>X", NULL, G_CALLBACK(packet_list_unignore_all_frames_cb) }, - { "/Edit/SetTimeReference", WIRESHARK_STOCK_TIME, "Set Time Reference (toggle)", "<control>T", NULL, G_CALLBACK(set_reftime_cb) }, - { "/Edit/Un-TimeReferenceAllPackets",NULL, "Un-Time Reference All Packets", "<alt><control>T", NULL, G_CALLBACK(packet_list_untime_reference_all_frames_cb) }, - { "/Edit/FindNextTimeReference", NULL, "Find Next Time Reference", "<alt><control>N", NULL, G_CALLBACK(find_next_ref_time_cb) }, - { "/Edit/FindPreviousTimeReference", NULL, "Find Previous Time Reference", "<alt><control>B", NULL, G_CALLBACK(find_previous_ref_time_cb) }, + { "/Edit/IgnoreAllDisplayedPackets", NULL, "Ignore All Displayed Packets", "<alt><shift><control>X", NULL, G_CALLBACK(packet_list_ignore_all_displayed_frames_cb) }, + { "/Edit/Un-IgnoreAllPackets", NULL, "U_nignore All Packets", "<shift><control>X", NULL, G_CALLBACK(packet_list_unignore_all_frames_cb) }, + { "/Edit/SetTimeReference", WIRESHARK_STOCK_TIME, "Set/Unset Time Reference", "<control>T", NULL, G_CALLBACK(set_reftime_cb) }, + { "/Edit/Un-TimeReferenceAllPackets",NULL, "Unset All Time References", "<alt><control>T", NULL, G_CALLBACK(packet_list_untime_reference_all_frames_cb) }, + { "/Edit/FindNextTimeReference", NULL, "Next Time Reference", "<alt><control>N", NULL, G_CALLBACK(find_next_ref_time_cb) }, + { "/Edit/FindPreviousTimeReference", NULL, "Previous Time Reference", "<alt><control>B", NULL, G_CALLBACK(find_previous_ref_time_cb) }, { "/Edit/TimeShift", WIRESHARK_STOCK_TIME, "Time Shift...", "<shift><control>T", NULL, G_CALLBACK(time_shift_cb) }, { "/Edit/ConfigurationProfiles", NULL, "_Configuration Profiles...", "<shift><control>A", NULL, G_CALLBACK(profile_dialog_cb) }, diff --git a/ui/qt/main_status_bar.h b/ui/qt/main_status_bar.h index 22d35e0c96..44f2ab6572 100644 --- a/ui/qt/main_status_bar.h +++ b/ui/qt/main_status_bar.h @@ -40,6 +40,7 @@ public: explicit MainStatusBar(QWidget *parent = 0); void showExpert(); void hideExpert(); + void expertUpdate(); private: QLabel expert_status_; @@ -49,8 +50,6 @@ private: LabelStack profile_status_; capture_file *cap_file_; - void expertUpdate(); - signals: public slots: diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp index eec9f720ff..733114ca2f 100644 --- a/ui/qt/main_window.cpp +++ b/ui/qt/main_window.cpp @@ -85,6 +85,7 @@ MainWindow::MainWindow(QWidget *parent) : main_ui_->setupUi(this); setMenusForCaptureFile(); setForCapturedPackets(false); + setMenusForSelectedPacket(); setMenusForSelectedTreeRow(); setForCaptureInProgress(false); setMenusForFileSet(false); @@ -230,6 +231,11 @@ MainWindow::MainWindow(QWidget *parent) : connect(main_ui_->actionViewCollapseAll, SIGNAL(triggered()), proto_tree_, SLOT(collapseAll())); + connect(packet_list_->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), + this, SLOT(setMenusForSelectedPacket())); + connect(packet_list_, SIGNAL(packetsChanged()), + this, SLOT(redissectPackets())); + connect(proto_tree_, SIGNAL(protoItemSelected(QString&)), main_ui_->statusBar, SLOT(pushFieldStatus(QString&))); diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h index e7c8bb52c0..9a3ea8a619 100644 --- a/ui/qt/main_window.h +++ b/ui/qt/main_window.h @@ -168,9 +168,13 @@ private slots: void updateRecentFiles(); void recentActionTriggered(); + void setMenusForSelectedPacket(); void setMenusForSelectedTreeRow(field_info *fi = NULL); void interfaceSelectionChanged(); + void redissectPackets(); + // We should probably move these to main_window_actions.cpp similar to + // gtk/main_menubar.c void on_actionFileOpen_triggered(); void on_actionFileMerge_triggered(); void on_actionFileImport_triggered(); @@ -203,6 +207,18 @@ private slots: void on_actionEditFindPacket_triggered(); void on_actionEditFindNext_triggered(); void on_actionEditFindPrevious_triggered(); + void on_actionEditMarkPacket_triggered(); + void on_actionEditMarkAllDisplayed_triggered(); + void on_actionEditUnmarkAllDisplayed_triggered(); + void on_actionEditFindNextMark_triggered(); + void on_actionEditFindPreviousMark_triggered(); + void on_actionEditIgnorePacket_triggered(); + void on_actionEditIgnoreAllDisplayed_triggered(); + void on_actionEditUnignoreAllDisplayed_triggered(); + void on_actionEditSetTimeReference_triggered(); + void on_actionEditUnsetAllTimeReferences_triggered(); + void on_actionEditNextTimeReference_triggered(); + void on_actionEditPreviousTimeReference_triggered(); void on_actionGoGoToPacket_triggered(); void resetPreviousFocus(); diff --git a/ui/qt/main_window.ui b/ui/qt/main_window.ui index 5c40f891d0..52792deb02 100644 --- a/ui/qt/main_window.ui +++ b/ui/qt/main_window.ui @@ -172,6 +172,21 @@ <addaction name="actionEditFindPacket"/> <addaction name="actionEditFindNext"/> <addaction name="actionEditFindPrevious"/> + <addaction name="separator"/> + <addaction name="actionEditMarkPacket"/> + <addaction name="actionEditMarkAllDisplayed"/> + <addaction name="actionEditUnmarkAllDisplayed"/> + <addaction name="actionEditNextMark"/> + <addaction name="actionEditPreviousMark"/> + <addaction name="separator"/> + <addaction name="actionEditIgnorePacket"/> + <addaction name="actionEditIgnoreAllDisplayed"/> + <addaction name="actionEditUnignoreAllDisplayed"/> + <addaction name="separator"/> + <addaction name="actionEditSetTimeReference"/> + <addaction name="actionEditUnsetAllTimeReferences"/> + <addaction name="actionEditNextTimeReference"/> + <addaction name="actionEditPreviousTimeReference"/> </widget> <widget class="QMenu" name="menuCapture"> <property name="title"> @@ -967,6 +982,138 @@ <string>Ctrl+B</string> </property> </action> + <action name="actionEditMarkPacket"> + <property name="text"> + <string>&Mark/Unmark Packet</string> + </property> + <property name="toolTip"> + <string>Mark or unmark this packet</string> + </property> + <property name="shortcut"> + <string>Ctrl+M</string> + </property> + </action> + <action name="actionEditMarkAllDisplayed"> + <property name="text"> + <string>Mark All Displayed</string> + </property> + <property name="toolTip"> + <string>Mark all displayed packets</string> + </property> + <property name="shortcut"> + <string>Ctrl+Shift+M</string> + </property> + </action> + <action name="actionEditUnmarkAllDisplayed"> + <property name="text"> + <string>Unmark All Displayed</string> + </property> + <property name="toolTip"> + <string>Unmark all displayed packets</string> + </property> + <property name="shortcut"> + <string>Meta+Alt+M</string> + </property> + </action> + <action name="actionEditNextMark"> + <property name="text"> + <string>Next Mark</string> + </property> + <property name="toolTip"> + <string>Go to the next marked packet</string> + </property> + <property name="shortcut"> + <string>Meta+Shift+N</string> + </property> + </action> + <action name="actionEditPreviousMark"> + <property name="text"> + <string>Previous Mark</string> + </property> + <property name="toolTip"> + <string>Go to the previous marked packet</string> + </property> + <property name="shortcut"> + <string>Meta+Shift+B</string> + </property> + </action> + <action name="actionEditIgnorePacket"> + <property name="text"> + <string>&Ignore/Unignore Packet</string> + </property> + <property name="toolTip"> + <string>Ignore or unignore this packet</string> + </property> + <property name="shortcut"> + <string>Meta+X</string> + </property> + </action> + <action name="actionEditIgnoreAllDisplayed"> + <property name="text"> + <string>Ignore All Displayed</string> + </property> + <property name="toolTip"> + <string>Ignore all displayed packets</string> + </property> + <property name="shortcut"> + <string>Meta+Alt+Shift+X</string> + </property> + </action> + <action name="actionEditUnignoreAllDisplayed"> + <property name="text"> + <string>Unignore All Displayed</string> + </property> + <property name="toolTip"> + <string>Unignore all displayed packets</string> + </property> + <property name="shortcut"> + <string>Meta+Shift+X</string> + </property> + </action> + <action name="actionEditSetTimeReference"> + <property name="text"> + <string>Set/Unset Time Reference</string> + </property> + <property name="toolTip"> + <string>Set or unset a time reference for this packet</string> + </property> + <property name="shortcut"> + <string>Ctrl+T</string> + </property> + </action> + <action name="actionEditUnsetAllTimeReferences"> + <property name="text"> + <string>Unset All Time References</string> + </property> + <property name="toolTip"> + <string>Remove all time references</string> + </property> + <property name="shortcut"> + <string>Ctrl+Alt+T</string> + </property> + </action> + <action name="actionEditNextTimeReference"> + <property name="text"> + <string>Next Time Reference</string> + </property> + <property name="toolTip"> + <string>Go to the next time reference</string> + </property> + <property name="shortcut"> + <string>Ctrl+Alt+N</string> + </property> + </action> + <action name="actionEditPreviousTimeReference"> + <property name="text"> + <string>Previous Time Reference</string> + </property> + <property name="toolTip"> + <string>Go to the previous time reference</string> + </property> + <property name="shortcut"> + <string>Ctrl+Alt+B</string> + </property> + </action> </widget> <layoutdefault spacing="6" margin="11"/> <customwidgets> diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index aca621c743..c9befc69d6 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -316,6 +316,7 @@ void MainWindow::captureFileClosing(const capture_file *cf) { setMenusForCaptureFile(true); setForCapturedPackets(false); + setMenusForSelectedPacket(); setForCaptureInProgress(false); // Reset expert info indicator @@ -534,6 +535,224 @@ void MainWindow::recentActionTriggered() { } } +void MainWindow::setMenusForSelectedPacket() +{ +// GList *list_entry = dissector_filter_list; +// guint i = 0; +// gboolean properties = FALSE; +// const char *abbrev = NULL; +// char *prev_abbrev; + +// /* Making the menu context-sensitive allows for easier selection of the +// desired item and has the added benefit, with large captures, of +// avoiding needless looping through huge lists for marked, ignored, +// or time-referenced packets. */ +// gboolean is_ssl = packet_is_ssl(cf->edt); + + /* We have one or more items in the packet list */ + gboolean have_frames = FALSE; + /* A frame is selected */ + gboolean frame_selected = FALSE; + /* We have marked frames. (XXX - why check frame_selected?) */ + gboolean have_marked = FALSE; + /* We have a marked frame other than the current frame (i.e., + we have at least one marked frame, and either there's more + than one marked frame or the current frame isn't marked). */ + gboolean another_is_marked = FALSE; + /* One or more frames are hidden by a display filter */ + gboolean have_filtered = FALSE; + /* One or more frames have been ignored */ + gboolean have_ignored = FALSE; + gboolean have_time_ref = FALSE; + /* We have a time reference frame other than the current frame (i.e., + we have at least one time reference frame, and either there's more + than one time reference frame or the current frame isn't a + time reference frame). (XXX - why check frame_selected?) */ + gboolean another_is_time_ref = FALSE; + + if (cap_file_) { + frame_selected = cap_file_->current_frame != NULL; + have_frames = cap_file_->count > 0; + have_marked = frame_selected && cap_file_->marked_count > 0; + another_is_marked = have_marked && + !(cap_file_->marked_count == 1 && cap_file_->current_frame->flags.marked); + have_filtered = cap_file_->displayed_count > 0 && cap_file_->displayed_count != cap_file_->count; + have_ignored = cap_file_->ignored_count > 0; + have_time_ref = cap_file_->ref_time_count > 0; + another_is_time_ref = frame_selected && have_time_ref && + !(cap_file_->ref_time_count == 1 && cap_file_->current_frame->flags.ref_time); + } +// if (cfile.edt && cfile.edt->tree) { +// GPtrArray *ga; +// header_field_info *hfinfo; +// field_info *v; +// guint ii; + +// ga = proto_all_finfos(cfile.edt->tree); + +// for (ii = ga->len - 1; ii > 0 ; ii -= 1) { + +// v = g_ptr_array_index (ga, ii); +// hfinfo = v->hfinfo; + +// if (!g_str_has_prefix(hfinfo->abbrev, "text") && +// !g_str_has_prefix(hfinfo->abbrev, "expert") && +// !g_str_has_prefix(hfinfo->abbrev, "malformed")) { + +// if (hfinfo->parent == -1) { +// abbrev = hfinfo->abbrev; +// } else { +// abbrev = proto_registrar_get_abbrev(hfinfo->parent); +// } +// properties = prefs_is_registered_protocol(abbrev); +// break; +// } +// } +// } + + main_ui_->actionEditMarkPacket->setEnabled(frame_selected); + main_ui_->actionEditMarkAllDisplayed->setEnabled(have_frames); + /* Unlike un-ignore, do not allow unmark of all frames when no frames are displayed */ + main_ui_->actionEditUnmarkAllDisplayed->setEnabled(have_marked); + main_ui_->actionEditNextMark->setEnabled(another_is_marked); + main_ui_->actionEditPreviousMark->setEnabled(another_is_marked); + +//#ifdef WANT_PACKET_EDITOR +// set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/EditPacket", +// frame_selected); +//#endif /* WANT_PACKET_EDITOR */ +// set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/AddEditPktComment", +// frame_selected); + + main_ui_->actionEditIgnorePacket->setEnabled(frame_selected); + main_ui_->actionEditIgnoreAllDisplayed->setEnabled(have_filtered); + /* Allow un-ignore of all frames even with no frames currently displayed */ + main_ui_->actionEditUnignoreAllDisplayed->setEnabled(have_ignored); + + main_ui_->actionEditSetTimeReference->setEnabled(frame_selected); + main_ui_->actionEditUnsetAllTimeReferences->setEnabled(have_time_ref); + main_ui_->actionEditNextTimeReference->setEnabled(another_is_time_ref); + main_ui_->actionEditPreviousTimeReference->setEnabled(another_is_time_ref); +// set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/TimeShift", +// cf->count > 0); + +// set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/ResizeAllColumns", +// frame_selected); +// set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/CollapseAll", +// frame_selected); +// set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/CollapseAll", +// frame_selected); +// set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/ExpandAll", +// frame_selected); +// set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ExpandAll", +// frame_selected); +// set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/ColorizeConversation", +// frame_selected); +// set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/ResetColoring1-10", +// tmp_color_filters_used()); +// set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/ShowPacketinNewWindow", +// frame_selected); +// set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ShowPacketinNewWindow", +// frame_selected); +// set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ManuallyResolveAddress", +// frame_selected ? ((cf->edt->pi.ethertype == ETHERTYPE_IP)||(cf->edt->pi.ethertype == ETHERTYPE_IPv6)) : FALSE); +// set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/SCTP", +// frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_SCTP) : FALSE); +// set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/FollowTCPStream", +// frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE); +// set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FollowTCPStream", +// frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE); +// set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/FollowUDPStream", +// frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_UDP) : FALSE); +// set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/FollowSSLStream", +// frame_selected ? is_ssl : FALSE); +// set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FollowSSLStream", +// frame_selected ? is_ssl : FALSE); +// set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ConversationFilter", +// frame_selected); +// set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ConversationFilter/Ethernet", +// frame_selected ? (cf->edt->pi.dl_src.type == AT_ETHER) : FALSE); +// set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ConversationFilter/IP", +// frame_selected ? ((cf->edt->pi.ethertype == ETHERTYPE_IP)||(cf->edt->pi.ethertype == ETHERTYPE_IPv6)) : FALSE); +// set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ConversationFilter/TCP", +// frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE); +// set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ConversationFilter/UDP", +// frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_UDP) : FALSE); +// set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FollowUDPStream", +// frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_UDP) : FALSE); +// set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ConversationFilter/PN-CBA", +// frame_selected ? (cf->edt->pi.profinet_type != 0 && cf->edt->pi.profinet_type < 10) : FALSE); +// set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation", +// frame_selected); +// set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation/Ethernet", +// frame_selected ? (cf->edt->pi.dl_src.type == AT_ETHER) : FALSE); +// set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation/IP", +// frame_selected ? ((cf->edt->pi.ethertype == ETHERTYPE_IP)||(cf->edt->pi.ethertype == ETHERTYPE_IPv6)) : FALSE); +// set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation/TCP", +// frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE); +// set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation/UDP", +// frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_UDP) : FALSE); +// set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation/PN-CBA", +// frame_selected ? (cf->edt->pi.profinet_type != 0 && cf->edt->pi.profinet_type < 10) : FALSE); +// set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/DecodeAs", +// frame_selected && decode_as_ok()); + +// if (properties) { +// prev_abbrev = g_object_get_data(G_OBJECT(ui_manager_packet_list_menu), "menu_abbrev"); +// if (!prev_abbrev || (strcmp(prev_abbrev, abbrev) != 0)) { +// /*No previous protocol or protocol changed - update Protocol Preferences menu*/ +// module_t *prefs_module_p = prefs_find_module(abbrev); +// rebuild_protocol_prefs_menu(prefs_module_p, properties, ui_manager_packet_list_menu, "/PacketListMenuPopup/ProtocolPreferences"); + +// g_object_set_data(G_OBJECT(ui_manager_packet_list_menu), "menu_abbrev", g_strdup(abbrev)); +// g_free (prev_abbrev); +// } +// } + +// set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ProtocolPreferences", +// properties); +// set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/DecodeAs", +// frame_selected && decode_as_ok()); +// set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/Copy", +// frame_selected); +// set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ApplyAsFilter", +// frame_selected); +// set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/PrepareaFilter", +// frame_selected); +// set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ResolveName", +// frame_selected && (gbl_resolv_flags.mac_name || gbl_resolv_flags.network_name || +// gbl_resolv_flags.transport_name || gbl_resolv_flags.concurrent_dns)); +// set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/FollowTCPStream", +// frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE); +// set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/FollowUDPStream", +// frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_UDP) : FALSE); +// set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/FollowSSLStream", +// frame_selected ? is_ssl : FALSE); +// set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/DecodeAs", +// frame_selected && decode_as_ok()); +// set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/NameResolution/ResolveName", +// frame_selected && (gbl_resolv_flags.mac_name || gbl_resolv_flags.network_name || +// gbl_resolv_flags.transport_name || gbl_resolv_flags.concurrent_dns)); +// set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ToolsMenu/FirewallACLRules", +// frame_selected); +// set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/StatisticsMenu/TCPStreamGraphMenu", +// tcp_graph_selected_packet_enabled(cf->current_frame,cf->edt, NULL)); + +// while (list_entry != NULL) { +// dissector_filter_t *filter_entry; +// gchar *path; + +// filter_entry = list_entry->data; +// path = g_strdup_printf("/Menubar/AnalyzeMenu/ConversationFilterMenu/Filters/filter-%u", i); + +// set_menu_sensitivity(ui_manager_main_menubar, path, +// menu_dissector_filter_spe_cb(/* frame_data *fd _U_*/ NULL, cf->edt, filter_entry)); +// g_free(path); +// i++; +// list_entry = g_list_next(list_entry); +// } +} + void MainWindow::setMenusForSelectedTreeRow(field_info *fi) { //gboolean properties; //gint id; @@ -676,6 +895,13 @@ void MainWindow::interfaceSelectionChanged() } } +void MainWindow::redissectPackets() +{ + if (cap_file_) + cf_redissect_packets(cap_file_); + main_ui_->statusBar->expertUpdate(); +} + // File Menu @@ -971,6 +1197,70 @@ void MainWindow::on_actionEditFindPrevious_triggered() main_ui_->searchFrame->findPrevious(); } +void MainWindow::on_actionEditMarkPacket_triggered() +{ + packet_list_->markFrame(); +} + +void MainWindow::on_actionEditMarkAllDisplayed_triggered() +{ + packet_list_->markAllDisplayedFrames(true); +} + +void MainWindow::on_actionEditUnmarkAllDisplayed_triggered() +{ + packet_list_->markAllDisplayedFrames(false); +} + +void MainWindow::on_actionEditFindNextMark_triggered() +{ + if (cap_file_) + cf_find_packet_marked(cap_file_, SD_FORWARD); +} + +void MainWindow::on_actionEditFindPreviousMark_triggered() +{ + if (cap_file_) + cf_find_packet_marked(cap_file_, SD_BACKWARD); +} + +void MainWindow::on_actionEditIgnorePacket_triggered() +{ + packet_list_->ignoreFrame(); +} + +void MainWindow::on_actionEditIgnoreAllDisplayed_triggered() +{ + packet_list_->ignoreAllDisplayedFrames(true); +} + +void MainWindow::on_actionEditUnignoreAllDisplayed_triggered() +{ + packet_list_->ignoreAllDisplayedFrames(false); +} + +void MainWindow::on_actionEditSetTimeReference_triggered() +{ + packet_list_->setTimeReference(); +} + +void MainWindow::on_actionEditUnsetAllTimeReferences_triggered() +{ + packet_list_->unsetAllTimeReferences(); +} + +void MainWindow::on_actionEditNextTimeReference_triggered() +{ + if (!cap_file_) return; + cf_find_packet_time_reference(cap_file_, SD_FORWARD); +} + +void MainWindow::on_actionEditPreviousTimeReference_triggered() +{ + if (!cap_file_) return; + cf_find_packet_time_reference(cap_file_, SD_BACKWARD); +} + // View Menu // Expand / collapse slots in proto_tree diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp index d19e9f5637..444a94f958 100644 --- a/ui/qt/packet_list.cpp +++ b/ui/qt/packet_list.cpp @@ -48,6 +48,7 @@ #include <QTextEdit> #include <QScrollBar> #include <QContextMenuEvent> +#include <QMessageBox> // If we ever add the ability to open multiple capture files we might be // able to use something like QMap<capture_file *, PacketList *> to match @@ -231,11 +232,11 @@ PacketList::PacketList(QWidget *parent) : packet_list_model_ = new PacketListModel(this, cap_file_); setModel(packet_list_model_); - packet_list_model_->setColorEnabled(true); // We don't yet fetch color settings. -// packet_list_model_->setColorEnabled(recent.packet_list_colorize); + packet_list_model_->setColorEnabled(recent.packet_list_colorize); -// " <menuitem name='MarkPacket' action='/MarkPacket'/>\n" -// " <menuitem name='IgnorePacket' action='/IgnorePacket'/>\n" + ctx_menu_.addAction(window()->findChild<QAction *>("actionEditMarkPacket")); + ctx_menu_.addAction(window()->findChild<QAction *>("actionEditIgnorePacket")); + ctx_menu_.addAction(window()->findChild<QAction *>("actionEditSetTimeReference")); // " <menuitem name='SetTimeReference' action='/Set Time Reference'/>\n" // " <menuitem name='TimeShift' action='/TimeShift'/>\n" // " <menuitem name='AddEditPktComment' action='/Edit/AddEditPktComment'/>\n" @@ -444,6 +445,46 @@ void PacketList::contextMenuEvent(QContextMenuEvent *event) } } +void PacketList::markFramesReady() +{ + packets_bar_update(); + updateAll(); +} + +void PacketList::setFrameMark(gboolean set, frame_data *fdata) +{ + if (set) + cf_mark_frame(cap_file_, fdata); + else + cf_unmark_frame(cap_file_, fdata); +} + +void PacketList::setFrameIgnore(gboolean set, frame_data *fdata) +{ + if (set) + cf_ignore_frame(cap_file_, fdata); + else + cf_unignore_frame(cap_file_, fdata); +} + +void PacketList::setFrameReftime(gboolean set, frame_data *fdata) +{ + if (!fdata || !cap_file_) return; + if (set) { + fdata->flags.ref_time=1; + cap_file_->ref_time_count++; + } else { + fdata->flags.ref_time=0; + cap_file_->ref_time_count--; + } + cf_reftime_packets(cap_file_); + if (!fdata->flags.ref_time && !fdata->flags.passed_dfilter) { + cap_file_->displayed_count--; + packet_list_model_->recreateVisibleRows(); + } + updateAll(); +} + // Redraw the packet list and detail void PacketList::updateAll() { update(); @@ -508,7 +549,7 @@ QString &PacketList::getFilterFromRowAndColumn() if (!cap_file_ || !packet_list_model_ || ctx_column_ < 0 || ctx_column_ >= cap_file_->cinfo.num_cols) return filter; - fdata = (frame_data *) packet_list_model_->getRowFdata(row); + fdata = packet_list_model_->getRowFdata(row); if (fdata != NULL) { epan_dissect_t edt; @@ -591,6 +632,104 @@ void PacketList::goToPacket(int packet) { } } +void PacketList::markFrame() +{ + int row = currentIndex().row(); + frame_data *fdata; + + if (!cap_file_ || !packet_list_model_) return; + + fdata = packet_list_model_->getRowFdata(row); + + setFrameMark(!fdata->flags.marked, fdata); + markFramesReady(); +} + +void PacketList::markAllDisplayedFrames(bool set) +{ + guint32 framenum; + frame_data *fdata; + + if (!cap_file_ || !packet_list_model_) return; + + for (framenum = 1; framenum <= cap_file_->count; framenum++) { + fdata = frame_data_sequence_find(cap_file_->frames, framenum); + if (fdata->flags.passed_dfilter) + setFrameMark(set, fdata); + } + markFramesReady(); +} + +void PacketList::ignoreFrame() +{ + int row = currentIndex().row(); + frame_data *fdata; + + if (!cap_file_ || !packet_list_model_) return; + + fdata = packet_list_model_->getRowFdata(row); + + setFrameIgnore(!fdata->flags.ignored, fdata); + emit packetsChanged(); +} + +void PacketList::ignoreAllDisplayedFrames(bool set) +{ + guint32 framenum; + frame_data *fdata; + + if (!cap_file_ || !packet_list_model_) return; + + for (framenum = 1; framenum <= cap_file_->count; framenum++) { + fdata = frame_data_sequence_find(cap_file_->frames, framenum); + if (!set || fdata->flags.passed_dfilter) + setFrameIgnore(set, fdata); + } + emit packetsChanged(); +} + +void PacketList::setTimeReference() +{ + if (!cap_file_) return; + + if (cap_file_->current_frame) { + if(recent.gui_time_format != TS_RELATIVE && cap_file_->current_frame->flags.ref_time==0) { + int ret = QMessageBox::question( + this, + tr("Change Time Display Format?"), + tr("Time References don't work well with the currently selected Time Display Format.\n" + "Do you want to switch to \"Seconds Since Beginning of Capture\" now?"), + QMessageBox::Yes | QMessageBox::No + ); + if (ret == QMessageBox::Yes) { + timestamp_set_type(TS_RELATIVE); + recent.gui_time_format = TS_RELATIVE; + cf_timestamp_auto_precision(cap_file_); + } + } else { + setFrameReftime(!cap_file_->current_frame->flags.ref_time, + cap_file_->current_frame); + } + } + updateAll(); +} + +void PacketList::unsetAllTimeReferences() +{ + if (!cap_file_) return; + + /* XXX: we might need a progressbar here */ + guint32 framenum; + frame_data *fdata; + for (framenum = 1; framenum <= cap_file_->count && cap_file_->ref_time_count > 0; framenum++) { + fdata = frame_data_sequence_find(cap_file_->frames, framenum); + if (fdata->flags.ref_time == 1) { + setFrameReftime(FALSE, fdata); + } + } + updateAll(); +} + /* * Editor modelines * diff --git a/ui/qt/packet_list.h b/ui/qt/packet_list.h index 36432f0bf5..7257b1fa50 100644 --- a/ui/qt/packet_list.h +++ b/ui/qt/packet_list.h @@ -62,7 +62,13 @@ private: QList<QAction *> filter_actions_; int ctx_column_; + void markFramesReady(); + void setFrameMark(gboolean set, frame_data *fdata); + void setFrameIgnore(gboolean set, frame_data *fdata); + void setFrameReftime(gboolean set, frame_data *fdata); + signals: + void packetsChanged(); public slots: void setCaptureFile(capture_file *cf); @@ -71,6 +77,12 @@ public slots: void goFirstPacket(); void goLastPacket(); void goToPacket(int packet); + void markFrame(); + void markAllDisplayedFrames(bool set); + void ignoreFrame(); + void ignoreAllDisplayedFrames(bool set); + void setTimeReference(); + void unsetAllTimeReferences(); }; #endif // PACKET_LIST_H diff --git a/ui/qt/packet_list_model.cpp b/ui/qt/packet_list_model.cpp index a5f24d17ea..c9a688457a 100644 --- a/ui/qt/packet_list_model.cpp +++ b/ui/qt/packet_list_model.cpp @@ -37,7 +37,6 @@ #include "wireshark_application.h" #include <QColor> - PacketListModel::PacketListModel(QObject *parent, capture_file *cf) : QAbstractItemModel(parent) { @@ -287,7 +286,7 @@ gint PacketListModel::appendPacket(frame_data *fdata) } frame_data *PacketListModel::getRowFdata(int row) { - if (row >= visible_rows_.count()) + if (row < 0 || row >= visible_rows_.size()) return NULL; PacketListRecord *record = visible_rows_[row]; if (!record) diff --git a/ui/qt/packet_list_model.h b/ui/qt/packet_list_model.h index 6f56054be0..d18c644f03 100644 --- a/ui/qt/packet_list_model.h +++ b/ui/qt/packet_list_model.h @@ -63,7 +63,6 @@ public: frame_data *getRowFdata(int row); int visibleIndexOf(frame_data *fdata) const; - signals: public slots: diff --git a/ui/qt/packet_list_record.cpp b/ui/qt/packet_list_record.cpp index 15905104fa..da8741f100 100644 --- a/ui/qt/packet_list_record.cpp +++ b/ui/qt/packet_list_record.cpp @@ -24,19 +24,19 @@ #include "packet_list_record.h" PacketListRecord::PacketListRecord(frame_data *frameData) : - col_text(NULL), col_text_len(NULL), fdata(frameData) + col_text_(NULL), col_text_len_(NULL), fdata_(frameData) { } QVariant PacketListRecord::data(int col_num, column_info *cinfo) const { - g_assert(fdata); + g_assert(fdata_); if (!cinfo) return QVariant(); if (col_based_on_frame_data(cinfo, col_num)) //{ - col_fill_in_frame_data(fdata, cinfo, col_num, FALSE); + col_fill_in_frame_data(fdata_, cinfo, col_num, FALSE); return cinfo->col_data[col_num]; // } else { // QString unknown; @@ -45,7 +45,7 @@ QVariant PacketListRecord::data(int col_num, column_info *cinfo) const } frame_data *PacketListRecord::getFdata() { - return fdata; + return fdata_; } /* diff --git a/ui/qt/packet_list_record.h b/ui/qt/packet_list_record.h index 8112191ac8..75db270cb8 100644 --- a/ui/qt/packet_list_record.h +++ b/ui/qt/packet_list_record.h @@ -43,22 +43,22 @@ public: private: /** The column text for some columns */ - gchar **col_text; + gchar **col_text_; /**< The length of the column text strings in 'col_text' */ - guint *col_text_len; + guint *col_text_len_; - frame_data *fdata; + frame_data *fdata_; /** Has this record been columnized? */ - gboolean columnized; + gboolean columnized_; /** Has this record been colorized? */ - gboolean colorized; + gboolean colorized_; /* admin stuff used by the custom list model */ /** position within the physical array */ - guint physical_pos; + guint physical_pos_; /** position within the visible array */ - gint visible_pos; + gint visible_pos_; }; |