2014-04-29 15:10:27 +00:00
|
|
|
/* conversation_dialog.cpp
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "conversation_dialog.h"
|
|
|
|
|
2016-01-08 13:25:17 +00:00
|
|
|
#include <epan/prefs.h>
|
2014-04-29 15:10:27 +00:00
|
|
|
#include <epan/dissectors/packet-tcp.h>
|
|
|
|
|
|
|
|
#include "ui/recent.h"
|
|
|
|
#include "ui/tap-tcp-stream.h"
|
2014-08-06 17:07:42 +00:00
|
|
|
#include "ui/traffic_table_ui.h"
|
|
|
|
|
|
|
|
#include "wsutil/str_util.h"
|
|
|
|
|
|
|
|
#include "qt_ui_utils.h"
|
2016-08-30 19:12:33 +00:00
|
|
|
#include "timeline_delegate.h"
|
2014-04-29 15:10:27 +00:00
|
|
|
#include "wireshark_application.h"
|
|
|
|
|
2015-02-08 20:24:19 +00:00
|
|
|
#include <QCheckBox>
|
2016-09-01 20:51:13 +00:00
|
|
|
#include <QDateTime>
|
2015-02-08 20:24:19 +00:00
|
|
|
#include <QDialogButtonBox>
|
2014-08-03 02:31:33 +00:00
|
|
|
#include <QPushButton>
|
2014-04-29 15:10:27 +00:00
|
|
|
|
|
|
|
// To do:
|
|
|
|
// - https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6727
|
|
|
|
// - Wide last column?
|
|
|
|
// + No arrows on unsorted columns
|
|
|
|
// - Add follow stream to context menu
|
|
|
|
// + Change "A <- B" to "B -> A"
|
|
|
|
// - Improper wildcard handling https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8010
|
|
|
|
// - TShark consolidation https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6310
|
|
|
|
// - Display filter entry?
|
|
|
|
// - Add follow, copy & graph actions to context menu.
|
|
|
|
|
|
|
|
// Bugs:
|
2016-06-22 17:56:30 +00:00
|
|
|
// - Slow for large numbers of items.
|
2014-04-29 15:10:27 +00:00
|
|
|
// - Name resolution doesn't do anything if its preference is disabled.
|
|
|
|
// - Columns don't resize correctly.
|
2014-07-23 17:38:55 +00:00
|
|
|
// - Closing the capture file clears conversation data.
|
2014-04-29 15:10:27 +00:00
|
|
|
|
|
|
|
// Fixed bugs:
|
|
|
|
// - Friendly unit displays https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9231
|
|
|
|
// - Misleading bps calculation https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8703
|
2016-09-01 20:51:13 +00:00
|
|
|
// - Show Absolute time in conversation tables https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=11618
|
|
|
|
// - The value of 'Rel start' and 'Duration' in "Conversations" no need too precise https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=12803
|
|
|
|
|
2014-04-29 15:10:27 +00:00
|
|
|
|
2016-06-22 17:56:30 +00:00
|
|
|
static const QString table_name_ = QObject::tr("Conversation");
|
2014-12-22 23:51:36 +00:00
|
|
|
ConversationDialog::ConversationDialog(QWidget &parent, CaptureFile &cf, int cli_proto_id, const char *filter) :
|
2014-08-06 17:07:42 +00:00
|
|
|
TrafficTableDialog(parent, cf, filter, table_name_)
|
2014-04-29 15:10:27 +00:00
|
|
|
{
|
2015-07-31 17:34:43 +00:00
|
|
|
follow_bt_ = buttonBox()->addButton(tr("Follow Stream" UTF8_HORIZONTAL_ELLIPSIS), QDialogButtonBox::ActionRole);
|
2014-04-29 15:10:27 +00:00
|
|
|
follow_bt_->setToolTip(tr("Follow a TCP or UDP stream."));
|
|
|
|
connect(follow_bt_, SIGNAL(clicked()), this, SLOT(followStream()));
|
|
|
|
|
2015-07-31 17:34:43 +00:00
|
|
|
graph_bt_ = buttonBox()->addButton(tr("Graph" UTF8_HORIZONTAL_ELLIPSIS), QDialogButtonBox::ActionRole);
|
2014-04-29 15:10:27 +00:00
|
|
|
graph_bt_->setToolTip(tr("Graph a TCP conversation."));
|
|
|
|
connect(graph_bt_, SIGNAL(clicked()), this, SLOT(graphTcp()));
|
|
|
|
|
2016-09-01 20:51:13 +00:00
|
|
|
absoluteTimeCheckBox()->show();
|
|
|
|
|
2015-08-24 19:33:49 +00:00
|
|
|
addProgressFrame(&parent);
|
|
|
|
|
2014-07-23 17:38:55 +00:00
|
|
|
QList<int> conv_protos;
|
2014-04-29 15:10:27 +00:00
|
|
|
for (GList *conv_tab = recent.conversation_tabs; conv_tab; conv_tab = conv_tab->next) {
|
2014-07-23 17:38:55 +00:00
|
|
|
int proto_id = proto_get_id_by_short_name((const char *)conv_tab->data);
|
|
|
|
if (proto_id > -1 && !conv_protos.contains(proto_id)) {
|
|
|
|
conv_protos.append(proto_id);
|
2014-04-29 15:10:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-23 17:38:55 +00:00
|
|
|
if (conv_protos.isEmpty()) {
|
2014-08-06 17:07:42 +00:00
|
|
|
conv_protos = defaultProtos();
|
2014-04-29 15:10:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Bring the command-line specified type to the front.
|
2014-08-06 17:07:42 +00:00
|
|
|
if (get_conversation_by_proto_id(cli_proto_id)) {
|
|
|
|
conv_protos.removeAll(cli_proto_id);
|
|
|
|
conv_protos.prepend(cli_proto_id);
|
2014-04-29 15:10:27 +00:00
|
|
|
}
|
|
|
|
|
2014-07-23 17:38:55 +00:00
|
|
|
// QTabWidget selects the first item by default.
|
|
|
|
foreach (int conv_proto, conv_protos) {
|
2014-08-06 17:07:42 +00:00
|
|
|
addTrafficTable(get_conversation_by_proto_id(conv_proto));
|
2014-04-29 15:10:27 +00:00
|
|
|
}
|
|
|
|
|
2014-08-06 17:07:42 +00:00
|
|
|
fillTypeMenu(conv_protos);
|
2014-04-29 15:10:27 +00:00
|
|
|
|
2016-09-13 11:37:11 +00:00
|
|
|
QPushButton *close_bt = buttonBox()->button(QDialogButtonBox::Close);
|
|
|
|
if (close_bt) {
|
|
|
|
close_bt->setDefault(true);
|
|
|
|
}
|
|
|
|
|
2014-04-29 15:10:27 +00:00
|
|
|
updateWidgets();
|
2016-06-23 20:10:52 +00:00
|
|
|
// currentTabChanged();
|
2014-04-29 15:10:27 +00:00
|
|
|
|
2015-07-29 17:36:46 +00:00
|
|
|
cap_file_.delayedRetapPackets();
|
2014-04-29 15:10:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ConversationDialog::~ConversationDialog()
|
|
|
|
{
|
|
|
|
prefs_clear_string_list(recent.conversation_tabs);
|
|
|
|
recent.conversation_tabs = NULL;
|
|
|
|
|
2014-08-06 17:07:42 +00:00
|
|
|
ConversationTreeWidget *cur_tree = qobject_cast<ConversationTreeWidget *>(trafficTableTabWidget()->currentWidget());
|
|
|
|
foreach (QAction *ca, traffic_type_menu_.actions()) {
|
2014-07-23 17:38:55 +00:00
|
|
|
int proto_id = ca->data().value<int>();
|
|
|
|
if (proto_id_to_tree_.contains(proto_id) && ca->isChecked()) {
|
|
|
|
char *title = g_strdup(proto_get_protocol_short_name(find_protocol_by_id(proto_id)));
|
|
|
|
if (proto_id_to_tree_[proto_id] == cur_tree) {
|
2014-04-29 15:10:27 +00:00
|
|
|
recent.conversation_tabs = g_list_prepend(recent.conversation_tabs, title);
|
|
|
|
} else {
|
|
|
|
recent.conversation_tabs = g_list_append(recent.conversation_tabs, title);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-21 21:23:02 +00:00
|
|
|
void ConversationDialog::captureFileClosing()
|
2014-04-29 15:10:27 +00:00
|
|
|
{
|
2014-12-21 21:23:02 +00:00
|
|
|
// Keep the dialog around but disable any controls that depend
|
|
|
|
// on a live capture file.
|
|
|
|
for (int i = 0; i < trafficTableTabWidget()->count(); i++) {
|
|
|
|
ConversationTreeWidget *cur_tree = qobject_cast<ConversationTreeWidget *>(trafficTableTabWidget()->widget(i));
|
2016-06-22 19:44:02 +00:00
|
|
|
disconnect(cur_tree, SIGNAL(filterAction(QString,FilterAction::Action,FilterAction::ActionType)),
|
|
|
|
this, SIGNAL(filterAction(QString,FilterAction::Action,FilterAction::ActionType)));
|
2014-04-29 15:10:27 +00:00
|
|
|
}
|
2014-12-21 21:23:02 +00:00
|
|
|
displayFilterCheckBox()->setEnabled(false);
|
|
|
|
enabledTypesPushButton()->setEnabled(false);
|
|
|
|
follow_bt_->setEnabled(false);
|
|
|
|
graph_bt_->setEnabled(false);
|
|
|
|
TrafficTableDialog::captureFileClosing();
|
2014-04-29 15:10:27 +00:00
|
|
|
}
|
|
|
|
|
2014-08-06 17:07:42 +00:00
|
|
|
bool ConversationDialog::addTrafficTable(register_ct_t* table)
|
2014-04-29 15:10:27 +00:00
|
|
|
{
|
2014-07-23 17:38:55 +00:00
|
|
|
int proto_id = get_conversation_proto_id(table);
|
2014-04-29 15:10:27 +00:00
|
|
|
|
2014-07-23 17:38:55 +00:00
|
|
|
if (!table || proto_id_to_tree_.contains(proto_id)) {
|
2014-04-29 15:10:27 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-07-23 17:38:55 +00:00
|
|
|
ConversationTreeWidget *conv_tree = new ConversationTreeWidget(this, table);
|
|
|
|
|
|
|
|
proto_id_to_tree_[proto_id] = conv_tree;
|
|
|
|
const char* table_name = proto_get_protocol_short_name(find_protocol_by_id(proto_id));
|
2014-04-29 15:10:27 +00:00
|
|
|
|
2014-08-06 17:07:42 +00:00
|
|
|
trafficTableTabWidget()->addTab(conv_tree, table_name);
|
2014-04-29 15:10:27 +00:00
|
|
|
|
2016-08-30 19:12:33 +00:00
|
|
|
conv_tree->setItemDelegateForColumn(CONV_COLUMN_START, new TimelineDelegate(conv_tree));
|
|
|
|
conv_tree->setItemDelegateForColumn(CONV_COLUMN_DURATION, new TimelineDelegate(conv_tree));
|
|
|
|
|
2014-04-29 15:10:27 +00:00
|
|
|
connect(conv_tree, SIGNAL(titleChanged(QWidget*,QString)),
|
|
|
|
this, SLOT(setTabText(QWidget*,QString)));
|
2016-06-22 19:44:02 +00:00
|
|
|
connect(conv_tree, SIGNAL(filterAction(QString,FilterAction::Action,FilterAction::ActionType)),
|
|
|
|
this, SIGNAL(filterAction(QString,FilterAction::Action,FilterAction::ActionType)));
|
2014-08-06 17:07:42 +00:00
|
|
|
connect(nameResolutionCheckBox(), SIGNAL(toggled(bool)),
|
2014-04-29 15:10:27 +00:00
|
|
|
conv_tree, SLOT(setNameResolutionEnabled(bool)));
|
2016-09-01 20:51:13 +00:00
|
|
|
connect(absoluteTimeCheckBox(), SIGNAL(toggled(bool)),
|
|
|
|
conv_tree, SLOT(updateStartTime(bool)));
|
|
|
|
|
2014-04-29 15:10:27 +00:00
|
|
|
|
|
|
|
// XXX Move to ConversationTreeWidget ctor?
|
2014-11-29 18:29:26 +00:00
|
|
|
QByteArray filter_utf8;
|
2014-04-29 15:10:27 +00:00
|
|
|
const char *filter = NULL;
|
2014-08-06 17:07:42 +00:00
|
|
|
if (displayFilterCheckBox()->isChecked()) {
|
2014-12-21 21:23:02 +00:00
|
|
|
filter = cap_file_.capFile()->dfilter;
|
2014-04-29 15:10:27 +00:00
|
|
|
} else if (!filter_.isEmpty()) {
|
2014-11-29 18:29:26 +00:00
|
|
|
filter_utf8 = filter_.toUtf8();
|
|
|
|
filter = filter_utf8.constData();
|
2014-04-29 15:10:27 +00:00
|
|
|
}
|
2014-07-23 17:38:55 +00:00
|
|
|
|
2014-08-06 17:07:42 +00:00
|
|
|
conv_tree->trafficTreeHash()->user_data = conv_tree;
|
2014-07-23 17:38:55 +00:00
|
|
|
|
2015-08-24 19:30:56 +00:00
|
|
|
registerTapListener(proto_get_protocol_filter_name(proto_id), conv_tree->trafficTreeHash(), filter, 0,
|
|
|
|
ConversationTreeWidget::tapReset,
|
|
|
|
get_conversation_packet_func(table),
|
|
|
|
ConversationTreeWidget::tapDraw);
|
2014-04-29 15:10:27 +00:00
|
|
|
|
2014-07-23 17:38:55 +00:00
|
|
|
return true;
|
2014-04-29 15:10:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
conv_item_t *ConversationDialog::currentConversation()
|
|
|
|
{
|
2014-08-06 17:07:42 +00:00
|
|
|
ConversationTreeWidget *cur_tree = qobject_cast<ConversationTreeWidget *>(trafficTableTabWidget()->currentWidget());
|
2014-04-29 15:10:27 +00:00
|
|
|
|
|
|
|
if (!cur_tree || cur_tree->selectedItems().count() < 1) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cur_tree->selectedItems()[0]->data(0, Qt::UserRole).value<conv_item_t *>();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConversationDialog::followStream()
|
|
|
|
{
|
2014-12-22 23:51:36 +00:00
|
|
|
if (file_closed_) {
|
2014-08-06 17:07:42 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-04-29 15:10:27 +00:00
|
|
|
conv_item_t *conv_item = currentConversation();
|
|
|
|
if (!conv_item) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString filter;
|
|
|
|
follow_type_t ftype = FOLLOW_TCP;
|
|
|
|
switch (conv_item->ptype) {
|
|
|
|
case PT_TCP:
|
|
|
|
filter = QString("tcp.stream eq %1").arg(conv_item->conv_id);
|
|
|
|
break;
|
|
|
|
case PT_UDP:
|
|
|
|
filter = QString("udp.stream eq %1").arg(conv_item->conv_id);
|
|
|
|
ftype = FOLLOW_UDP;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (filter.length() < 1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-06 17:07:42 +00:00
|
|
|
emit filterAction(filter, FilterAction::ActionApply, FilterAction::ActionTypePlain);
|
2015-07-29 17:36:46 +00:00
|
|
|
emit openFollowStreamDialog(ftype);
|
2014-04-29 15:10:27 +00:00
|
|
|
}
|
|
|
|
|
2014-08-06 17:07:42 +00:00
|
|
|
void ConversationDialog::graphTcp()
|
2014-04-29 15:10:27 +00:00
|
|
|
{
|
2014-12-22 23:51:36 +00:00
|
|
|
if (file_closed_) {
|
2014-04-29 15:10:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
conv_item_t *conv_item = currentConversation();
|
|
|
|
if (!conv_item) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// XXX The GTK+ code opens the TCP Stream dialog. We might want
|
|
|
|
// to open the IO Graph dialog instead.
|
|
|
|
QString filter;
|
|
|
|
if (conv_item->ptype == PT_TCP) {
|
|
|
|
filter = QString("tcp.stream eq %1").arg(conv_item->conv_id);
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-10-15 12:19:33 +00:00
|
|
|
// Apply the filter for this conversation.
|
2014-08-06 17:07:42 +00:00
|
|
|
emit filterAction(filter, FilterAction::ActionApply, FilterAction::ActionTypePlain);
|
2015-10-15 12:19:33 +00:00
|
|
|
// This action will now find a packet from the intended conversation/stream.
|
2014-04-29 15:10:27 +00:00
|
|
|
openTcpStreamGraph(GRAPH_TSEQ_TCPTRACE);
|
|
|
|
}
|
|
|
|
|
2016-06-23 20:10:52 +00:00
|
|
|
void ConversationDialog::currentTabChanged()
|
2014-04-29 15:10:27 +00:00
|
|
|
{
|
2014-08-06 17:07:42 +00:00
|
|
|
bool copy_enable = trafficTableTabWidget()->currentWidget() ? true : false;
|
2014-04-29 15:10:27 +00:00
|
|
|
bool follow_enable = false, graph_enable = false;
|
|
|
|
conv_item_t *conv_item = currentConversation();
|
|
|
|
|
2014-12-22 23:51:36 +00:00
|
|
|
if (!file_closed_ && conv_item) {
|
2014-04-29 15:10:27 +00:00
|
|
|
switch (conv_item->ptype) {
|
|
|
|
case PT_TCP:
|
|
|
|
graph_enable = true;
|
|
|
|
// Fall through
|
|
|
|
case PT_UDP:
|
|
|
|
follow_enable = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
copy_bt_->setEnabled(copy_enable);
|
|
|
|
follow_bt_->setEnabled(follow_enable);
|
|
|
|
graph_bt_->setEnabled(graph_enable);
|
2016-06-23 20:10:52 +00:00
|
|
|
|
|
|
|
TrafficTableDialog::currentTabChanged();
|
2014-04-29 15:10:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConversationDialog::on_displayFilterCheckBox_toggled(bool checked)
|
|
|
|
{
|
2014-12-22 23:51:36 +00:00
|
|
|
if (file_closed_) {
|
2014-04-29 15:10:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-11-29 18:29:26 +00:00
|
|
|
QByteArray filter_utf8;
|
2014-04-29 15:10:27 +00:00
|
|
|
const char *filter = NULL;
|
|
|
|
if (checked) {
|
2014-12-21 21:23:02 +00:00
|
|
|
filter = cap_file_.capFile()->dfilter;
|
2014-04-29 15:10:27 +00:00
|
|
|
} else if (!filter_.isEmpty()) {
|
2014-11-29 18:29:26 +00:00
|
|
|
filter_utf8 = filter_.toUtf8();
|
|
|
|
filter = filter_utf8.constData();
|
2014-04-29 15:10:27 +00:00
|
|
|
}
|
|
|
|
|
2014-08-06 17:07:42 +00:00
|
|
|
for (int i = 0; i < trafficTableTabWidget()->count(); i++) {
|
|
|
|
set_tap_dfilter(trafficTableTabWidget()->widget(i), filter);
|
2014-04-29 15:10:27 +00:00
|
|
|
}
|
|
|
|
|
2014-12-21 21:23:02 +00:00
|
|
|
cap_file_.retapPackets();
|
2014-04-29 15:10:27 +00:00
|
|
|
}
|
|
|
|
|
2014-08-06 17:07:42 +00:00
|
|
|
void ConversationDialog::on_buttonBox_helpRequested()
|
2014-04-29 15:10:27 +00:00
|
|
|
{
|
2014-08-06 17:07:42 +00:00
|
|
|
wsApp->helpTopicAction(HELP_STATS_CONVERSATIONS_DIALOG);
|
|
|
|
}
|
|
|
|
|
|
|
|
void init_conversation_table(struct register_ct* ct, const char *filter)
|
|
|
|
{
|
|
|
|
wsApp->emitStatCommandSignal("Conversations", filter, GINT_TO_POINTER(get_conversation_proto_id(ct)));
|
2014-04-29 15:10:27 +00:00
|
|
|
}
|
|
|
|
|
2014-08-06 17:07:42 +00:00
|
|
|
|
|
|
|
// ConversationTreeWidgetItem
|
|
|
|
// TrafficTableTreeWidgetItem / QTreeWidgetItem subclass that allows sorting
|
|
|
|
|
|
|
|
// Minimum bandwidth calculation duration
|
|
|
|
// https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8703
|
2016-06-22 17:56:30 +00:00
|
|
|
static const double min_bw_calc_duration_ = 5 / 1000.0; // seconds
|
|
|
|
static const char *bps_na_ = UTF8_EM_DASH;
|
2014-08-06 17:07:42 +00:00
|
|
|
|
|
|
|
class ConversationTreeWidgetItem : public TrafficTableTreeWidgetItem
|
|
|
|
{
|
|
|
|
public:
|
2016-06-23 20:10:52 +00:00
|
|
|
ConversationTreeWidgetItem(GArray *conv_array, guint conv_idx, bool *resolve_names_ptr) :
|
|
|
|
TrafficTableTreeWidgetItem(NULL),
|
2016-06-22 17:56:30 +00:00
|
|
|
conv_array_(conv_array),
|
|
|
|
conv_idx_(conv_idx),
|
2016-06-23 20:10:52 +00:00
|
|
|
resolve_names_ptr_(resolve_names_ptr)
|
2016-08-30 19:12:33 +00:00
|
|
|
{
|
|
|
|
QString timeline_tt = QObject::tr("Bars show the relative timeline for each conversation.");
|
|
|
|
setToolTip(CONV_COLUMN_START, timeline_tt);
|
|
|
|
setToolTip(CONV_COLUMN_DURATION, timeline_tt);
|
|
|
|
}
|
2016-06-22 17:56:30 +00:00
|
|
|
|
|
|
|
conv_item_t *convItem() {
|
|
|
|
return &g_array_index(conv_array_, conv_item_t, conv_idx_);
|
|
|
|
}
|
2014-08-06 17:07:42 +00:00
|
|
|
|
2016-06-23 20:10:52 +00:00
|
|
|
virtual QVariant data(int column, int role) const {
|
2016-08-30 19:12:33 +00:00
|
|
|
switch (role) {
|
|
|
|
case Qt::DisplayRole:
|
|
|
|
{
|
2016-06-23 20:10:52 +00:00
|
|
|
// Column text cooked representation.
|
|
|
|
conv_item_t *conv_item = &g_array_index(conv_array_, conv_item_t, conv_idx_);
|
|
|
|
|
|
|
|
bool resolve_names = false;
|
|
|
|
if (resolve_names_ptr_ && *resolve_names_ptr_) resolve_names = true;
|
|
|
|
double duration = nstime_to_sec(&conv_item->stop_time) - nstime_to_sec(&conv_item->start_time);
|
|
|
|
QString bps_ab = bps_na_, bps_ba = bps_na_;
|
|
|
|
|
|
|
|
switch (column) {
|
|
|
|
case CONV_COLUMN_PACKETS:
|
|
|
|
return QString("%L1").arg(conv_item->tx_frames + conv_item->rx_frames);
|
|
|
|
case CONV_COLUMN_BYTES:
|
|
|
|
return gchar_free_to_qstring(format_size(conv_item->tx_bytes + conv_item->rx_bytes, format_size_unit_none|format_size_prefix_si));
|
|
|
|
case CONV_COLUMN_PKT_AB:
|
|
|
|
return QString("%L1").arg(conv_item->tx_frames);
|
|
|
|
case CONV_COLUMN_BYTES_AB:
|
|
|
|
return gchar_free_to_qstring(format_size(conv_item->tx_bytes, format_size_unit_none|format_size_prefix_si));
|
|
|
|
case CONV_COLUMN_PKT_BA:
|
|
|
|
return QString("%L1").arg(conv_item->rx_frames);
|
|
|
|
case CONV_COLUMN_BYTES_BA:
|
|
|
|
return gchar_free_to_qstring(format_size(conv_item->rx_bytes, format_size_unit_none|format_size_prefix_si));
|
|
|
|
case CONV_COLUMN_START:
|
2016-09-01 20:51:13 +00:00
|
|
|
{
|
|
|
|
bool use_ns = treeWidget()->window()->property("nanosecond_precision").toBool();
|
|
|
|
int width = use_ns ? 9 : 6;
|
|
|
|
|
|
|
|
if (treeWidget()->window()->property("absolute_start_time").toBool()) {
|
|
|
|
nstime_t *abs_time = &conv_item->start_abs_time;
|
|
|
|
QDateTime abs_dt = QDateTime::fromMSecsSinceEpoch(nstime_to_msec(abs_time));
|
|
|
|
return QString("%1.%2")
|
|
|
|
// Mimic column-utils:set_abs_time as best we can
|
|
|
|
.arg(abs_dt.toString("hh:mm:ss"))
|
|
|
|
.arg(use_ns ? abs_time->nsecs : abs_time->nsecs / 1000, width, 10, QChar('0'));
|
|
|
|
}
|
|
|
|
|
|
|
|
return QString::number(nstime_to_sec(&conv_item->start_time), 'f', width);
|
|
|
|
}
|
2016-06-23 20:10:52 +00:00
|
|
|
case CONV_COLUMN_DURATION:
|
2016-09-01 20:51:13 +00:00
|
|
|
{
|
|
|
|
// The GTK+ UI uses 9 digit precision for the start time and 4 for the duration.
|
|
|
|
// Do the same here and above for non-nanosecond precision and add a couple
|
|
|
|
// of digits for nanosecond precision.
|
|
|
|
bool use_ns = treeWidget()->window()->property("nanosecond_precision").toBool();
|
|
|
|
int width = use_ns ? 6 : 4;
|
|
|
|
|
|
|
|
return QString::number(duration, 'f', width);
|
|
|
|
}
|
2016-06-23 20:10:52 +00:00
|
|
|
case CONV_COLUMN_BPS_AB:
|
|
|
|
if (duration > min_bw_calc_duration_) {
|
|
|
|
bps_ab = gchar_free_to_qstring(format_size((gint64) conv_item->tx_bytes * 8 / duration, format_size_unit_none|format_size_prefix_si));
|
|
|
|
}
|
|
|
|
return bps_ab;
|
|
|
|
case CONV_COLUMN_BPS_BA:
|
|
|
|
if (duration > min_bw_calc_duration_) {
|
|
|
|
bps_ba = gchar_free_to_qstring(format_size((gint64) conv_item->rx_bytes * 8 / duration, format_size_unit_none|format_size_prefix_si));
|
|
|
|
}
|
|
|
|
return bps_ba;
|
|
|
|
default:
|
|
|
|
return colData(column, resolve_names).toString();
|
|
|
|
}
|
2016-08-30 19:12:33 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Qt::UserRole:
|
|
|
|
{
|
|
|
|
if (column != CONV_COLUMN_START && column != CONV_COLUMN_DURATION) break;
|
|
|
|
|
|
|
|
ConversationTreeWidget *ctw = qobject_cast<ConversationTreeWidget *>(treeWidget());
|
|
|
|
if (!ctw) break;
|
|
|
|
|
|
|
|
conv_item_t *conv_item = &g_array_index(conv_array_, conv_item_t, conv_idx_);
|
|
|
|
double start_time = nstime_to_sec(&conv_item->start_time);
|
|
|
|
double stop_time = nstime_to_sec(&conv_item->stop_time);
|
|
|
|
|
|
|
|
double span_s = ctw->maxRelStopTime() - ctw->minRelStartTime();
|
|
|
|
if (span_s <= 0) break;
|
|
|
|
int start_px = ctw->columnWidth(CONV_COLUMN_START);
|
|
|
|
int column_px = start_px + ctw->columnWidth(CONV_COLUMN_DURATION);
|
|
|
|
|
|
|
|
struct timeline_span span_px;
|
|
|
|
span_px.start = ((start_time - ctw->minRelStartTime()) * column_px) / span_s;
|
|
|
|
span_px.width = ((stop_time - start_time) * column_px) / span_s;
|
|
|
|
|
|
|
|
if (column == CONV_COLUMN_DURATION) {
|
|
|
|
span_px.start -= start_px;
|
|
|
|
}
|
|
|
|
return qVariantFromValue(span_px);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
2014-08-06 17:07:42 +00:00
|
|
|
}
|
2016-06-23 20:10:52 +00:00
|
|
|
return QTreeWidgetItem::data(column, role);
|
2014-08-06 17:07:42 +00:00
|
|
|
}
|
|
|
|
|
2016-06-23 20:10:52 +00:00
|
|
|
// Column text raw representation.
|
2015-01-05 02:40:05 +00:00
|
|
|
// Return a QString, qulonglong, double, or invalid QVariant representing the raw column data.
|
2014-08-06 17:07:42 +00:00
|
|
|
QVariant colData(int col, bool resolve_names) const {
|
2016-06-22 17:56:30 +00:00
|
|
|
conv_item_t *conv_item = &g_array_index(conv_array_, conv_item_t, conv_idx_);
|
2014-08-06 17:07:42 +00:00
|
|
|
|
|
|
|
double duration = nstime_to_sec(&conv_item->stop_time) - nstime_to_sec(&conv_item->start_time);
|
|
|
|
double bps_ab = 0, bps_ba = 0;
|
|
|
|
if (duration > min_bw_calc_duration_) {
|
|
|
|
bps_ab = conv_item->tx_bytes * 8 / duration;
|
|
|
|
bps_ba = conv_item->rx_bytes * 8 / duration;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (col) {
|
|
|
|
case CONV_COLUMN_SRC_ADDR:
|
2015-01-05 02:40:05 +00:00
|
|
|
{
|
2016-01-20 03:11:16 +00:00
|
|
|
char* addr_str = get_conversation_address(NULL, &conv_item->src_address, resolve_names);
|
2015-01-05 02:40:05 +00:00
|
|
|
QString q_addr_str(addr_str);
|
|
|
|
wmem_free(NULL, addr_str);
|
|
|
|
return q_addr_str;
|
|
|
|
}
|
2014-08-06 17:07:42 +00:00
|
|
|
case CONV_COLUMN_SRC_PORT:
|
|
|
|
if (resolve_names) {
|
2016-01-20 03:11:16 +00:00
|
|
|
char* port_str = get_conversation_port(NULL, conv_item->src_port, conv_item->ptype, resolve_names);
|
2015-01-07 21:24:17 +00:00
|
|
|
QString q_port_str(port_str);
|
|
|
|
wmem_free(NULL, port_str);
|
|
|
|
return q_port_str;
|
2014-08-06 17:07:42 +00:00
|
|
|
} else {
|
|
|
|
return quint32(conv_item->src_port);
|
|
|
|
}
|
|
|
|
case CONV_COLUMN_DST_ADDR:
|
2015-01-05 02:40:05 +00:00
|
|
|
{
|
2016-01-20 03:11:16 +00:00
|
|
|
char* addr_str = get_conversation_address(NULL, &conv_item->dst_address, resolve_names);
|
2015-01-05 02:40:05 +00:00
|
|
|
QString q_addr_str(addr_str);
|
|
|
|
wmem_free(NULL, addr_str);
|
|
|
|
return q_addr_str;
|
|
|
|
}
|
2014-08-06 17:07:42 +00:00
|
|
|
case CONV_COLUMN_DST_PORT:
|
|
|
|
if (resolve_names) {
|
2016-01-20 03:11:16 +00:00
|
|
|
char* port_str = get_conversation_port(NULL, conv_item->dst_port, conv_item->ptype, resolve_names);
|
2015-01-07 21:24:17 +00:00
|
|
|
QString q_port_str(port_str);
|
|
|
|
wmem_free(NULL, port_str);
|
|
|
|
return q_port_str;
|
2014-08-06 17:07:42 +00:00
|
|
|
} else {
|
|
|
|
return quint32(conv_item->dst_port);
|
|
|
|
}
|
|
|
|
case CONV_COLUMN_PACKETS:
|
|
|
|
return quint64(conv_item->tx_frames + conv_item->rx_frames);
|
|
|
|
case CONV_COLUMN_BYTES:
|
|
|
|
return quint64(conv_item->tx_bytes + conv_item->rx_bytes);
|
|
|
|
case CONV_COLUMN_PKT_AB:
|
|
|
|
return quint64(conv_item->tx_frames);
|
|
|
|
case CONV_COLUMN_BYTES_AB:
|
|
|
|
return quint64(conv_item->tx_bytes);
|
|
|
|
case CONV_COLUMN_PKT_BA:
|
|
|
|
return quint64(conv_item->rx_frames);
|
|
|
|
case CONV_COLUMN_BYTES_BA:
|
|
|
|
return quint64(conv_item->rx_bytes);
|
|
|
|
case CONV_COLUMN_START:
|
|
|
|
return nstime_to_sec(&conv_item->start_time);
|
|
|
|
case CONV_COLUMN_DURATION:
|
|
|
|
return duration;
|
|
|
|
case CONV_COLUMN_BPS_AB:
|
|
|
|
return bps_ab;
|
|
|
|
case CONV_COLUMN_BPS_BA:
|
|
|
|
return bps_ba;
|
|
|
|
default:
|
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator< (const QTreeWidgetItem &other) const
|
|
|
|
{
|
2016-06-22 17:56:30 +00:00
|
|
|
const ConversationTreeWidgetItem *other_row = static_cast<const ConversationTreeWidgetItem *>(&other);
|
|
|
|
conv_item_t *conv_item = &g_array_index(conv_array_, conv_item_t, conv_idx_);
|
|
|
|
conv_item_t *other_item = &g_array_index(other_row->conv_array_, conv_item_t, other_row->conv_idx_);
|
2014-08-06 17:07:42 +00:00
|
|
|
|
|
|
|
int sort_col = treeWidget()->sortColumn();
|
|
|
|
double conv_duration = nstime_to_sec(&conv_item->stop_time) - nstime_to_sec(&conv_item->start_time);
|
|
|
|
double other_duration = nstime_to_sec(&other_item->stop_time) - nstime_to_sec(&other_item->start_time);
|
|
|
|
|
|
|
|
switch(sort_col) {
|
|
|
|
case CONV_COLUMN_SRC_ADDR:
|
|
|
|
return cmp_address(&conv_item->src_address, &other_item->src_address) < 0 ? true : false;
|
|
|
|
case CONV_COLUMN_SRC_PORT:
|
|
|
|
return conv_item->src_port < other_item->src_port;
|
|
|
|
case CONV_COLUMN_DST_ADDR:
|
|
|
|
return cmp_address(&conv_item->dst_address, &other_item->dst_address) < 0 ? true : false;
|
|
|
|
case CONV_COLUMN_DST_PORT:
|
|
|
|
return conv_item->dst_port < other_item->dst_port;
|
|
|
|
case CONV_COLUMN_PACKETS:
|
|
|
|
return (conv_item->tx_frames + conv_item->rx_frames) < (other_item->tx_frames + other_item->rx_frames);
|
|
|
|
case CONV_COLUMN_BYTES:
|
|
|
|
return (conv_item->tx_bytes + conv_item->rx_bytes) < (other_item->tx_bytes + other_item->rx_bytes);
|
|
|
|
case CONV_COLUMN_PKT_AB:
|
|
|
|
return conv_item->tx_frames < other_item->tx_frames;
|
|
|
|
case CONV_COLUMN_BYTES_AB:
|
|
|
|
return conv_item->tx_bytes < other_item->tx_bytes;
|
|
|
|
case CONV_COLUMN_PKT_BA:
|
|
|
|
return conv_item->rx_frames < other_item->rx_frames;
|
|
|
|
case CONV_COLUMN_BYTES_BA:
|
|
|
|
return conv_item->rx_bytes < other_item->rx_bytes;
|
|
|
|
case CONV_COLUMN_START:
|
|
|
|
return nstime_to_sec(&conv_item->start_time) < nstime_to_sec(&other_item->start_time);
|
|
|
|
case CONV_COLUMN_DURATION:
|
|
|
|
return conv_duration < other_duration;
|
|
|
|
case CONV_COLUMN_BPS_AB:
|
|
|
|
return conv_item->tx_bytes / conv_duration < other_item->tx_bytes / other_duration;
|
|
|
|
case CONV_COLUMN_BPS_BA:
|
|
|
|
return conv_item->rx_bytes / conv_duration < other_item->rx_bytes / other_duration;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2016-06-22 17:56:30 +00:00
|
|
|
private:
|
|
|
|
GArray *conv_array_;
|
|
|
|
guint conv_idx_;
|
2016-06-23 20:10:52 +00:00
|
|
|
bool *resolve_names_ptr_;
|
2014-08-06 17:07:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// ConversationTreeWidget
|
|
|
|
// TrafficTableTreeWidget / QTreeWidget subclass that allows tapping
|
|
|
|
|
|
|
|
ConversationTreeWidget::ConversationTreeWidget(QWidget *parent, register_ct_t* table) :
|
2016-08-30 19:12:33 +00:00
|
|
|
TrafficTableTreeWidget(parent, table),
|
|
|
|
min_rel_start_time_(0),
|
|
|
|
max_rel_stop_time_(0)
|
2014-04-29 15:10:27 +00:00
|
|
|
{
|
2014-08-06 17:07:42 +00:00
|
|
|
setColumnCount(CONV_NUM_COLUMNS);
|
2016-06-23 20:10:52 +00:00
|
|
|
setUniformRowHeights(true);
|
2014-08-06 17:07:42 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < CONV_NUM_COLUMNS; i++) {
|
|
|
|
headerItem()->setText(i, conv_column_titles[i]);
|
2014-04-29 15:10:27 +00:00
|
|
|
}
|
2014-08-06 17:07:42 +00:00
|
|
|
|
|
|
|
if (get_conversation_hide_ports(table_)) {
|
|
|
|
hideColumn(CONV_COLUMN_SRC_PORT);
|
|
|
|
hideColumn(CONV_COLUMN_DST_PORT);
|
|
|
|
} else if (!strcmp(proto_get_protocol_filter_name(get_conversation_proto_id(table_)), "ncp")) {
|
|
|
|
headerItem()->setText(CONV_COLUMN_SRC_PORT, conv_conn_a_title);
|
|
|
|
headerItem()->setText(CONV_COLUMN_DST_PORT, conv_conn_b_title);
|
|
|
|
}
|
|
|
|
|
|
|
|
int one_en = fontMetrics().height() / 2;
|
|
|
|
for (int i = 0; i < CONV_NUM_COLUMNS; i++) {
|
|
|
|
switch (i) {
|
|
|
|
case CONV_COLUMN_SRC_ADDR:
|
|
|
|
case CONV_COLUMN_DST_ADDR:
|
2014-09-05 03:42:42 +00:00
|
|
|
setColumnWidth(i, one_en * (int) strlen("000.000.000.000"));
|
2014-08-06 17:07:42 +00:00
|
|
|
break;
|
|
|
|
case CONV_COLUMN_SRC_PORT:
|
|
|
|
case CONV_COLUMN_DST_PORT:
|
2014-09-05 03:42:42 +00:00
|
|
|
setColumnWidth(i, one_en * (int) strlen("000000"));
|
2014-08-06 17:07:42 +00:00
|
|
|
break;
|
|
|
|
case CONV_COLUMN_PACKETS:
|
|
|
|
case CONV_COLUMN_PKT_AB:
|
|
|
|
case CONV_COLUMN_PKT_BA:
|
2014-09-05 03:42:42 +00:00
|
|
|
setColumnWidth(i, one_en * (int) strlen("00,000"));
|
2014-08-06 17:07:42 +00:00
|
|
|
break;
|
|
|
|
case CONV_COLUMN_BYTES:
|
|
|
|
case CONV_COLUMN_BYTES_AB:
|
|
|
|
case CONV_COLUMN_BYTES_BA:
|
2014-09-05 03:42:42 +00:00
|
|
|
setColumnWidth(i, one_en * (int) strlen("000,000"));
|
2014-08-06 17:07:42 +00:00
|
|
|
break;
|
|
|
|
case CONV_COLUMN_START:
|
2014-09-05 03:42:42 +00:00
|
|
|
setColumnWidth(i, one_en * (int) strlen("00.000"));
|
2014-08-06 17:07:42 +00:00
|
|
|
break;
|
|
|
|
case CONV_COLUMN_DURATION:
|
2014-09-05 03:42:42 +00:00
|
|
|
setColumnWidth(i, one_en * (int) strlen("00.000000"));
|
2014-08-06 17:07:42 +00:00
|
|
|
break;
|
|
|
|
case CONV_COLUMN_BPS_AB:
|
|
|
|
case CONV_COLUMN_BPS_BA:
|
2014-09-05 03:42:42 +00:00
|
|
|
setColumnWidth(i, one_en * (int) strlen("000 k"));
|
2014-08-06 17:07:42 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
setColumnWidth(i, one_en * 5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QMenu *submenu;
|
|
|
|
|
|
|
|
initDirectionMap();
|
|
|
|
|
|
|
|
FilterAction::Action cur_action = FilterAction::ActionApply;
|
|
|
|
submenu = ctx_menu_.addMenu(FilterAction::actionName(cur_action));
|
|
|
|
foreach (FilterAction::ActionType at, FilterAction::actionTypes()) {
|
|
|
|
QMenu *subsubmenu = submenu->addMenu(FilterAction::actionTypeName(at));
|
|
|
|
foreach (FilterAction::ActionDirection ad, FilterAction::actionDirections()) {
|
|
|
|
FilterAction *fa = new FilterAction(subsubmenu, cur_action, at, ad);
|
|
|
|
subsubmenu->addAction(fa);
|
|
|
|
connect(fa, SIGNAL(triggered()), this, SLOT(filterActionTriggered()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cur_action = FilterAction::ActionPrepare;
|
|
|
|
submenu = ctx_menu_.addMenu(FilterAction::actionName(cur_action));
|
|
|
|
foreach (FilterAction::ActionType at, FilterAction::actionTypes()) {
|
|
|
|
QMenu *subsubmenu = submenu->addMenu(FilterAction::actionTypeName(at));
|
|
|
|
foreach (FilterAction::ActionDirection ad, FilterAction::actionDirections()) {
|
|
|
|
FilterAction *fa = new FilterAction(subsubmenu, cur_action, at, ad);
|
|
|
|
subsubmenu->addAction(fa);
|
|
|
|
connect(fa, SIGNAL(triggered()), this, SLOT(filterActionTriggered()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cur_action = FilterAction::ActionFind;
|
|
|
|
submenu = ctx_menu_.addMenu(FilterAction::actionName(cur_action));
|
|
|
|
foreach (FilterAction::ActionDirection ad, FilterAction::actionDirections()) {
|
|
|
|
FilterAction *fa = new FilterAction(submenu, cur_action, FilterAction::ActionTypePlain, ad);
|
|
|
|
submenu->addAction(fa);
|
|
|
|
connect(fa, SIGNAL(triggered()), this, SLOT(filterActionTriggered()));
|
|
|
|
}
|
|
|
|
|
|
|
|
cur_action = FilterAction::ActionColorize;
|
|
|
|
submenu = ctx_menu_.addMenu(FilterAction::actionName(cur_action));
|
|
|
|
foreach (FilterAction::ActionDirection ad, FilterAction::actionDirections()) {
|
|
|
|
FilterAction *fa = new FilterAction(submenu, cur_action, FilterAction::ActionTypePlain, ad);
|
|
|
|
submenu->addAction(fa);
|
|
|
|
connect(fa, SIGNAL(triggered()), this, SLOT(filterActionTriggered()));
|
|
|
|
}
|
|
|
|
|
2016-06-23 20:10:52 +00:00
|
|
|
updateItems();
|
2014-04-29 15:10:27 +00:00
|
|
|
}
|
|
|
|
|
2014-08-06 17:07:42 +00:00
|
|
|
ConversationTreeWidget::~ConversationTreeWidget() {
|
|
|
|
reset_conversation_table_data(&hash_);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Callbacks for register_tap_listener
|
|
|
|
void ConversationTreeWidget::tapReset(void *conv_hash_ptr)
|
2014-04-29 15:10:27 +00:00
|
|
|
{
|
2014-08-06 17:07:42 +00:00
|
|
|
conv_hash_t *hash = (conv_hash_t*)conv_hash_ptr;
|
2016-06-22 17:56:30 +00:00
|
|
|
ConversationTreeWidget *conv_tree = qobject_cast<ConversationTreeWidget *>((ConversationTreeWidget *)hash->user_data);
|
2014-08-06 17:07:42 +00:00
|
|
|
if (!conv_tree) return;
|
|
|
|
|
|
|
|
conv_tree->clear();
|
|
|
|
reset_conversation_table_data(&conv_tree->hash_);
|
2016-08-30 19:12:33 +00:00
|
|
|
conv_tree->min_rel_start_time_ = 0;
|
|
|
|
conv_tree->max_rel_stop_time_ = 0;
|
2014-04-29 15:10:27 +00:00
|
|
|
}
|
|
|
|
|
2014-08-06 17:07:42 +00:00
|
|
|
void ConversationTreeWidget::tapDraw(void *conv_hash_ptr)
|
2014-04-29 15:10:27 +00:00
|
|
|
{
|
2014-08-06 17:07:42 +00:00
|
|
|
conv_hash_t *hash = (conv_hash_t*)conv_hash_ptr;
|
2016-06-22 17:56:30 +00:00
|
|
|
ConversationTreeWidget *conv_tree = qobject_cast<ConversationTreeWidget *>((ConversationTreeWidget *)hash->user_data);
|
2014-08-06 17:07:42 +00:00
|
|
|
if (!conv_tree) return;
|
|
|
|
|
2016-06-23 20:10:52 +00:00
|
|
|
conv_tree->updateItems();
|
2014-08-06 17:07:42 +00:00
|
|
|
}
|
|
|
|
|
2016-09-01 20:51:13 +00:00
|
|
|
void ConversationTreeWidget::updateStartTime(bool absolute)
|
|
|
|
{
|
|
|
|
headerItem()->setText(CONV_COLUMN_START, absolute
|
|
|
|
? conv_abs_start_title
|
|
|
|
: conv_column_titles[CONV_COLUMN_START]);
|
|
|
|
|
|
|
|
dataChanged(QModelIndex(), QModelIndex());
|
|
|
|
|
|
|
|
if (topLevelItemCount() > 0) {
|
|
|
|
resizeColumnToContents(CONV_COLUMN_START);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-06 17:07:42 +00:00
|
|
|
QMap<FilterAction::ActionDirection, conv_direction_e> fad_to_cd_;
|
|
|
|
|
|
|
|
void ConversationTreeWidget::initDirectionMap()
|
|
|
|
{
|
|
|
|
if (fad_to_cd_.size() > 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fad_to_cd_[FilterAction::ActionDirectionAToFromB] = CONV_DIR_A_TO_FROM_B;
|
|
|
|
fad_to_cd_[FilterAction::ActionDirectionAToB] = CONV_DIR_A_TO_B;
|
|
|
|
fad_to_cd_[FilterAction::ActionDirectionAFromB] = CONV_DIR_A_FROM_B;
|
|
|
|
fad_to_cd_[FilterAction::ActionDirectionAToFromAny] = CONV_DIR_A_TO_FROM_ANY;
|
|
|
|
fad_to_cd_[FilterAction::ActionDirectionAToAny] = CONV_DIR_A_TO_ANY;
|
|
|
|
fad_to_cd_[FilterAction::ActionDirectionAFromAny] = CONV_DIR_A_FROM_ANY;
|
|
|
|
fad_to_cd_[FilterAction::ActionDirectionAnyToFromB] = CONV_DIR_ANY_TO_FROM_B;
|
|
|
|
fad_to_cd_[FilterAction::ActionDirectionAnyToB] = CONV_DIR_ANY_TO_B;
|
|
|
|
fad_to_cd_[FilterAction::ActionDirectionAnyFromB] = CONV_DIR_ANY_FROM_B;
|
|
|
|
}
|
|
|
|
|
2016-06-23 20:10:52 +00:00
|
|
|
void ConversationTreeWidget::updateItems() {
|
|
|
|
bool resize = topLevelItemCount() < resizeThreshold();
|
2014-08-06 17:07:42 +00:00
|
|
|
title_ = proto_get_protocol_short_name(find_protocol_by_id(get_conversation_proto_id(table_)));
|
|
|
|
|
|
|
|
if (hash_.conv_array && hash_.conv_array->len > 0) {
|
|
|
|
title_.append(QString(" %1 %2").arg(UTF8_MIDDLE_DOT).arg(hash_.conv_array->len));
|
|
|
|
}
|
|
|
|
emit titleChanged(this, title_);
|
|
|
|
|
|
|
|
if (!hash_.conv_array) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
setSortingEnabled(false);
|
2016-06-23 20:10:52 +00:00
|
|
|
|
|
|
|
QList<QTreeWidgetItem *>new_items;
|
2014-08-06 17:07:42 +00:00
|
|
|
for (int i = topLevelItemCount(); i < (int) hash_.conv_array->len; i++) {
|
2016-06-23 20:10:52 +00:00
|
|
|
ConversationTreeWidgetItem *ctwi = new ConversationTreeWidgetItem(hash_.conv_array, i, &resolve_names_);
|
|
|
|
new_items << ctwi;
|
2014-08-06 17:07:42 +00:00
|
|
|
|
2016-08-30 19:12:33 +00:00
|
|
|
if (i == 0) {
|
|
|
|
min_rel_start_time_ = nstime_to_sec(&(ctwi->convItem()->start_time));
|
|
|
|
max_rel_stop_time_ = nstime_to_sec(&(ctwi->convItem()->stop_time));
|
|
|
|
}
|
|
|
|
|
2014-08-06 17:07:42 +00:00
|
|
|
for (int col = 0; col < columnCount(); col++) {
|
|
|
|
switch (col) {
|
|
|
|
case CONV_COLUMN_SRC_ADDR:
|
|
|
|
case CONV_COLUMN_DST_ADDR:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ctwi->setTextAlignment(col, Qt::AlignRight);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-06-23 20:10:52 +00:00
|
|
|
addTopLevelItems(new_items);
|
|
|
|
|
2016-08-30 19:12:33 +00:00
|
|
|
for (int i = 0; i < topLevelItemCount(); i++) {
|
|
|
|
ConversationTreeWidgetItem *ctwi = dynamic_cast<ConversationTreeWidgetItem *>(topLevelItem(i));
|
|
|
|
|
|
|
|
double item_rel_start = nstime_to_sec(&(ctwi->convItem()->start_time));
|
|
|
|
if (item_rel_start < min_rel_start_time_) {
|
|
|
|
min_rel_start_time_ = item_rel_start;
|
|
|
|
}
|
|
|
|
|
|
|
|
double item_rel_stop = nstime_to_sec(&(ctwi->convItem()->stop_time));
|
|
|
|
if (item_rel_stop > max_rel_stop_time_) {
|
|
|
|
max_rel_stop_time_ = item_rel_stop;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-06 17:07:42 +00:00
|
|
|
setSortingEnabled(true);
|
|
|
|
|
2016-06-23 20:10:52 +00:00
|
|
|
if (resize) {
|
|
|
|
for (int col = 0; col < columnCount(); col++) {
|
|
|
|
resizeColumnToContents(col);
|
|
|
|
}
|
2014-08-06 17:07:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConversationTreeWidget::filterActionTriggered()
|
|
|
|
{
|
|
|
|
ConversationTreeWidgetItem *ctwi = static_cast<ConversationTreeWidgetItem *>(currentItem());
|
|
|
|
FilterAction *fa = qobject_cast<FilterAction *>(QObject::sender());
|
|
|
|
|
|
|
|
if (!fa || !ctwi) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-06-22 17:56:30 +00:00
|
|
|
conv_item_t *conv_item = ctwi->convItem();
|
2014-08-06 17:07:42 +00:00
|
|
|
if (!conv_item) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-01-20 03:11:16 +00:00
|
|
|
char* tmp_str = get_conversation_filter(conv_item, fad_to_cd_[fa->actionDirection()]);
|
2015-01-10 19:20:06 +00:00
|
|
|
QString filter(tmp_str);
|
|
|
|
|
|
|
|
g_free(tmp_str);
|
2014-08-06 17:07:42 +00:00
|
|
|
emit filterAction(filter, fa->action(), fa->actionType());
|
2014-04-29 15:10:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines
|
|
|
|
*
|
|
|
|
* Local Variables:
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* ex: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
|
|
*/
|