forked from osmocom/wireshark
Qt: Add Conversation Filter sub menu
Apply conversation filters using the new color_dissector_filters.[ch] from g1f03180. Change-Id: I2e535bb3d5b95fd26226422daf9f83c452a95e3c Reviewed-on: https://code.wireshark.org/review/3558 Petri-Dish: Gerald Combs <gerald@wireshark.org> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
parent
486a530451
commit
3827c81473
|
@ -54,6 +54,7 @@ const QList<FilterAction::Action> FilterAction::actions() {
|
|||
<< ActionApply
|
||||
<< ActionPrepare
|
||||
<< ActionFind
|
||||
<< ActionConversation
|
||||
<< ActionColorize
|
||||
<< ActionWebLookup
|
||||
<< ActionCopy;
|
||||
|
@ -71,6 +72,9 @@ const QString FilterAction::actionName(Action action) {
|
|||
case ActionFind:
|
||||
return QObject::tr("Find");
|
||||
break;
|
||||
case ActionConversation:
|
||||
return QObject::tr("Conversation Filter");
|
||||
break;
|
||||
case ActionColorize:
|
||||
return QObject::tr("Colorize");
|
||||
break;
|
||||
|
|
|
@ -37,6 +37,7 @@ public:
|
|||
ActionApply,
|
||||
ActionPrepare,
|
||||
ActionFind,
|
||||
ActionConversation,
|
||||
ActionColorize,
|
||||
ActionWebLookup,
|
||||
ActionCopy
|
||||
|
|
|
@ -375,6 +375,8 @@ private slots:
|
|||
void on_actionAnalyzePAFAndNotSelected_triggered();
|
||||
void on_actionAnalyzePAFOrNotSelected_triggered();
|
||||
|
||||
void applyConversationFilter();
|
||||
|
||||
void on_actionAnalyzeDecodeAs_triggered();
|
||||
|
||||
void openFollowStreamDialog(follow_type_t type);
|
||||
|
|
|
@ -340,12 +340,18 @@
|
|||
<addaction name="actionAnalyzeFollowUDPStream"/>
|
||||
<addaction name="actionAnalyzeFollowSSLStream"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuConversationFilter">
|
||||
<property name="title">
|
||||
<string>Conversation Filter</string>
|
||||
</property>
|
||||
</widget>
|
||||
<addaction name="actionAnalyzeDisplayFilters"/>
|
||||
<addaction name="actionAnalyzeDisplayFilterMacros"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionAnalyzeCreateAColumn"/>
|
||||
<addaction name="menuApplyAsFilter"/>
|
||||
<addaction name="menuPrepareAFilter"/>
|
||||
<addaction name="menuConversationFilter"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionAnalyzeDecodeAs"/>
|
||||
<addaction name="separator"/>
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include <wsutil/str_util.h>
|
||||
|
||||
#include "epan/addr_resolv.h"
|
||||
#include "epan/color_dissector_filters.h"
|
||||
#include "epan/column.h"
|
||||
#include "epan/epan_dissect.h"
|
||||
#include "epan/filter_expressions.h"
|
||||
|
@ -110,6 +111,7 @@
|
|||
#include "time_shift_dialog.h"
|
||||
#include "voip_calls_dialog.h"
|
||||
#include "wireshark_application.h"
|
||||
#include "filter_action.h"
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QFileInfo>
|
||||
|
@ -952,16 +954,8 @@ 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;
|
||||
#if 0
|
||||
gboolean is_ip = FALSE, is_tcp = FALSE, is_udp = FALSE, is_sctp = FALSE;
|
||||
#else
|
||||
// gboolean is_ip = FALSE, is_tcp = FALSE, is_udp = FALSE, is_sctp = FALSE, is_ssl = FALSE;
|
||||
gboolean is_tcp = FALSE, is_sctp = FALSE;
|
||||
#endif
|
||||
|
||||
// /* Making the menu context-sensitive allows for easier selection of the
|
||||
// desired item and has the added benefit, with large captures, of
|
||||
|
@ -1089,16 +1083,23 @@ void MainWindow::setMenusForSelectedPacket()
|
|||
// 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 ? is_ip : FALSE);
|
||||
// set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ConversationFilter/TCP",
|
||||
// frame_selected ? is_tcp : FALSE);
|
||||
// set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ConversationFilter/UDP",
|
||||
// frame_selected ? is_udp : FALSE);
|
||||
|
||||
main_ui_->menuConversationFilter->clear();
|
||||
for (GList *color_list_entry = color_conv_filter_list; color_list_entry; color_list_entry = g_list_next(color_list_entry)) {
|
||||
color_conversation_filter_t* color_filter = (color_conversation_filter_t *)color_list_entry->data;
|
||||
QAction *conv_action = main_ui_->menuConversationFilter->addAction(color_filter->display_name);
|
||||
|
||||
bool enable = false;
|
||||
QString filter;
|
||||
if (capture_file_.capFile()->edt) {
|
||||
enable = color_filter->is_filter_valid(&capture_file_.capFile()->edt->pi);
|
||||
filter = color_filter->build_filter_string(&capture_file_.capFile()->edt->pi);
|
||||
}
|
||||
conv_action->setEnabled(enable);
|
||||
conv_action->setData(filter);
|
||||
connect(conv_action, SIGNAL(triggered()), this, SLOT(applyConversationFilter()));
|
||||
}
|
||||
|
||||
// set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FollowUDPStream",
|
||||
// frame_selected ? is_udp : FALSE);
|
||||
// set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ConversationFilter/PN-CBA",
|
||||
|
@ -1172,9 +1173,6 @@ void MainWindow::setMenusForSelectedPacket()
|
|||
}
|
||||
|
||||
void MainWindow::setMenusForSelectedTreeRow(field_info *fi) {
|
||||
//gboolean properties;
|
||||
//gint id;
|
||||
|
||||
// XXX Add commented items below
|
||||
|
||||
if (capture_file_.capFile()) {
|
||||
|
@ -1255,7 +1253,24 @@ void MainWindow::setMenusForSelectedTreeRow(field_info *fi) {
|
|||
main_ui_->actionAnalyzePAFAndNotSelected->setEnabled(can_match_selected);
|
||||
main_ui_->actionAnalyzePAFOrNotSelected->setEnabled(can_match_selected);
|
||||
|
||||
main_ui_->menuConversationFilter->clear();
|
||||
for (GList *color_list_entry = color_conv_filter_list; color_list_entry; color_list_entry = g_list_next(color_list_entry)) {
|
||||
color_conversation_filter_t* color_filter = (color_conversation_filter_t *)color_list_entry->data;
|
||||
QAction *conv_action = main_ui_->menuConversationFilter->addAction(color_filter->display_name);
|
||||
|
||||
bool enable = false;
|
||||
QString filter;
|
||||
if (capture_file_.capFile()->edt) {
|
||||
enable = color_filter->is_filter_valid(&capture_file_.capFile()->edt->pi);
|
||||
filter = color_filter->build_filter_string(&capture_file_.capFile()->edt->pi);
|
||||
}
|
||||
conv_action->setEnabled(enable);
|
||||
conv_action->setData(filter);
|
||||
connect(conv_action, SIGNAL(triggered()), this, SLOT(applyConversationFilter()));
|
||||
}
|
||||
|
||||
main_ui_->actionViewExpandSubtrees->setEnabled(capture_file_.capFile()->finfo_selected->tree_type != -1);
|
||||
|
||||
// prev_abbrev = g_object_get_data(G_OBJECT(ui_manager_tree_view_menu), "menu_abbrev");
|
||||
// if (!prev_abbrev || (strcmp (prev_abbrev, abbrev) != 0)) {
|
||||
// /* No previous protocol or protocol changed - update Protocol Preferences menu */
|
||||
|
@ -2215,6 +2230,18 @@ void MainWindow::on_actionAnalyzeCreateAColumn_triggered()
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::applyConversationFilter()
|
||||
{
|
||||
QAction *cfa = qobject_cast<QAction*>(sender());
|
||||
if (!cfa) return;
|
||||
|
||||
QString new_filter = cfa->data().toString();
|
||||
if (new_filter.isEmpty()) return;
|
||||
|
||||
df_combo_box_->lineEdit()->setText(new_filter);
|
||||
df_combo_box_->applyDisplayFilter();
|
||||
}
|
||||
|
||||
// XXX We could probably create the analyze and prepare actions
|
||||
// dynamically using FilterActions and consolidate the methods
|
||||
// below into one callback.
|
||||
|
|
|
@ -300,16 +300,17 @@ PacketList::PacketList(QWidget *parent) :
|
|||
submenu->addAction(window()->findChild<QAction *>("actionAnalyzePAFAndNotSelected"));
|
||||
submenu->addAction(window()->findChild<QAction *>("actionAnalyzePAFOrNotSelected"));
|
||||
|
||||
// action = window()->findChild<QAction *>("actionColorize_with_Filter");
|
||||
// submenu = new QMenu();
|
||||
// action->setMenu(submenu);
|
||||
// ctx_menu_.addAction(action);
|
||||
QMenu *main_conv_menu = window()->findChild<QMenu *>("menuConversationFilter");
|
||||
conv_menu_.setTitle(main_conv_menu->title());
|
||||
ctx_menu_.addMenu(&conv_menu_);
|
||||
|
||||
// " <menu name= 'ConversationFilter' action='/Conversation Filter'>\n"
|
||||
// " <menuitem name='Ethernet' action='/Conversation Filter/Ethernet'/>\n"
|
||||
// " <menuitem name='IP' action='/Conversation Filter/IP'/>\n"
|
||||
// " <menuitem name='TCP' action='/Conversation Filter/TCP'/>\n"
|
||||
// " <menuitem name='UDP' action='/Conversation Filter/UDP'/>\n"
|
||||
// " <menuitem name='PN-CBA' action='/Conversation Filter/PN-CBA'/>\n"
|
||||
//submenu = new QMenu(tr("Colorize with Filter"));
|
||||
// " <menu name= 'ColorizeConversation' action='/Colorize Conversation'>\n"
|
||||
// " <menu name= 'Ethernet' action='/Colorize Conversation/Ethernet'>\n"
|
||||
// " <menuitem name='Color1' action='/Colorize Conversation/Ethernet/Color 1'/>\n"
|
||||
|
@ -506,6 +507,12 @@ void PacketList::contextMenuEvent(QContextMenuEvent *event)
|
|||
if (cap_file_ != NULL && cap_file_->edt != NULL)
|
||||
proto_get_frame_protocols(cap_file_->edt->pi.layers, NULL, &is_tcp, &is_udp, &is_sctp, NULL);
|
||||
|
||||
QMenu *main_conv_menu = window()->findChild<QMenu *>("menuConversationFilter");
|
||||
conv_menu_.clear();
|
||||
foreach (action, main_conv_menu->actions()) {
|
||||
conv_menu_.addAction(action);
|
||||
}
|
||||
|
||||
action = window()->findChild<QAction *>("actionSCTP");
|
||||
if (cap_file_ != NULL && cap_file_->edt != NULL && is_sctp)
|
||||
action->setEnabled(TRUE);
|
||||
|
|
|
@ -83,6 +83,7 @@ private:
|
|||
ByteViewTab *byte_view_tab_;
|
||||
capture_file *cap_file_;
|
||||
QMenu ctx_menu_;
|
||||
QMenu conv_menu_;
|
||||
QAction *decode_as_;
|
||||
int ctx_column_;
|
||||
QByteArray column_state_;
|
||||
|
|
|
@ -195,6 +195,10 @@ ProtoTree::ProtoTree(QWidget *parent) :
|
|||
submenu->addAction(window()->findChild<QAction *>("actionAnalyzePAFAndNotSelected"));
|
||||
submenu->addAction(window()->findChild<QAction *>("actionAnalyzePAFOrNotSelected"));
|
||||
|
||||
QMenu *main_conv_menu = window()->findChild<QMenu *>("menuConversationFilter");
|
||||
conv_menu_.setTitle(main_conv_menu->title());
|
||||
ctx_menu_.addMenu(&conv_menu_);
|
||||
|
||||
// action = window()->findChild<QAction *>("actionColorize_with_Filter");
|
||||
// submenu = new QMenu();
|
||||
// action->setMenu(submenu);
|
||||
|
@ -276,6 +280,12 @@ void ProtoTree::contextMenuEvent(QContextMenuEvent *event)
|
|||
{
|
||||
if (ctx_menu_.isEmpty()) return; // We're in a PacketDialog
|
||||
|
||||
QMenu *main_conv_menu = window()->findChild<QMenu *>("menuConversationFilter");
|
||||
conv_menu_.clear();
|
||||
foreach (QAction *action, main_conv_menu->actions()) {
|
||||
conv_menu_.addAction(action);
|
||||
}
|
||||
|
||||
decode_as_->setData(qVariantFromValue(true));
|
||||
ctx_menu_.exec(event->globalPos());
|
||||
decode_as_->setData(QVariant());
|
||||
|
|
|
@ -46,6 +46,7 @@ protected:
|
|||
|
||||
private:
|
||||
QMenu ctx_menu_;
|
||||
QMenu conv_menu_;
|
||||
QAction *decode_as_;
|
||||
QFont mono_font_;
|
||||
|
||||
|
|
Loading…
Reference in New Issue