summaryrefslogtreecommitdiff
path: root/ui/qt
diff options
context:
space:
mode:
authorPaul Offord <paul.offord@advance7.com>2016-01-07 07:39:14 +0000
committerRoland Knall <rknall@gmail.com>2016-01-15 11:39:58 +0000
commitd1cb746822a31dc2d3273984587ce1ad2756ee7c (patch)
treece3f96e154ffcb43022c5c80509df834ebb19b01 /ui/qt
parentca512cf47c17a4b83accb3efbb443dfd5106bed0 (diff)
downloadwireshark-d1cb746822a31dc2d3273984587ce1ad2756ee7c.tar.gz
plugin_if: Add function to get capture file info
This is an enhancement to allow a plugin to obtain capture file and other status information via a simple plugin_if call Added GTK port to this revision Bug: 11968 Change-Id: Ibcf4e8b43c6f3b48e971fa4020a07cc273234fb8 Reviewed-on: https://code.wireshark.org/review/13103 Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'ui/qt')
-rw-r--r--ui/qt/main_window.cpp58
-rw-r--r--ui/qt/main_window.h1
2 files changed, 59 insertions, 0 deletions
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp
index 4cb8cd93d2..8bfda67c0c 100644
--- a/ui/qt/main_window.cpp
+++ b/ui/qt/main_window.cpp
@@ -136,6 +136,61 @@ static void plugin_if_mainwindow_gotoframe(gconstpointer user_data)
}
}
+#ifdef HAVE_LIBPCAP
+
+static void plugin_if_mainwindow_get_ws_info(gconstpointer user_data)
+{
+ if (gbl_cur_main_window_ != NULL && user_data != NULL)
+ {
+ GHashTable * dataSet = (GHashTable *)user_data;
+ ws_info_t *ws_info = NULL;
+
+ if (g_hash_table_lookup_extended(dataSet, "ws_info", NULL, (void**)&ws_info))
+ {
+ CaptureFile *cfWrap = gbl_cur_main_window_->captureFile();
+ capture_file *cf = cfWrap->capFile();
+
+ ws_info->ws_info_supported = true;
+
+ if (cf != NULL)
+ {
+ ws_info->cf_state = cf->state;
+ ws_info->cf_count = cf->count;
+
+ if (ws_info->cf_filename != NULL)
+ g_free(ws_info->cf_filename);
+ ws_info->cf_filename = g_strdup(cf->filename);
+
+ if (cf->state == FILE_READ_DONE)
+ {
+ ws_info->cf_framenr = (cf->current_frame)->num;
+ ws_info->frame_passed_dfilter = ((cf->current_frame)->flags.passed_dfilter) == 0 ? FALSE : TRUE;
+ }
+ else
+ {
+ ws_info->cf_framenr = 0;
+ ws_info->frame_passed_dfilter = FALSE;
+ }
+ }
+ else if (ws_info->cf_state != FILE_CLOSED)
+ {
+ /* Initialise the ws_info structure */
+ ws_info->cf_count = 0;
+
+ if (ws_info->cf_filename != NULL)
+ g_free(ws_info->cf_filename);
+ ws_info->cf_filename = NULL;
+
+ ws_info->cf_framenr = 0;
+ ws_info->frame_passed_dfilter = false;
+ ws_info->cf_state = FILE_CLOSED;
+ }
+ }
+ }
+}
+
+#endif /* HAVE_LIBPCAP */
+
gpointer
simple_dialog(ESD_TYPE_E type, gint btn_mask, const gchar *msg_format, ...)
{
@@ -616,6 +671,9 @@ MainWindow::MainWindow(QWidget *parent) :
plugin_if_register_gui_cb(PLUGIN_IF_FILTER_ACTION_PREPARE, plugin_if_mainwindow_apply_filter );
plugin_if_register_gui_cb(PLUGIN_IF_PREFERENCE_SAVE, plugin_if_mainwindow_preference);
plugin_if_register_gui_cb(PLUGIN_IF_GOTO_FRAME, plugin_if_mainwindow_gotoframe);
+#ifdef HAVE_LIBPCAP
+ plugin_if_register_gui_cb(PLUGIN_IF_GET_WS_INFO, plugin_if_mainwindow_get_ws_info);
+#endif
main_ui_->mainStack->setCurrentWidget(main_welcome_);
}
diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h
index e0cbdcc668..ad483b408c 100644
--- a/ui/qt/main_window.h
+++ b/ui/qt/main_window.h
@@ -93,6 +93,7 @@ public:
virtual QMenu *createPopupMenu();
void gotoFrame(int packet_num);
+ CaptureFile *captureFile() { return &capture_file_; }
protected:
bool eventFilter(QObject *obj, QEvent *event);