aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/main_window.cpp
diff options
context:
space:
mode:
authorRoland Knall <roland.knall@br-automation.com>2015-06-05 11:19:37 +0200
committerAnders Broman <a.broman58@gmail.com>2015-06-25 16:23:08 +0000
commitacc581081e84c93e878a678fbb3655aba253607a (patch)
tree10ad9f0c0195475d01f42d64509e0c6ef53abb79 /ui/qt/main_window.cpp
parentd4aa1a1c24e984339806c4ddb000ea9f9b352659 (diff)
Plugin Interface: Add GUI callbacks
Rename ext_menubar to a more appropriate plugin_if. External menus can be implemented by plugins to present additional menus for deep-packet analysis. One side-effect of such menus being implemented as plugins is, that they are being executed in different threads and therefore can only use limited access to the main GUI. Also, there is no safe cross-gui (GTK and Qt) way for many features. This patch implements a first functionality, by which a plugin implemented using ext_menubar can apply a display filter to the main view. For now the implementation supports filtering, as well as saving a preference. Change-Id: Iffe4caa954bbeb8ce356352de4dae348a50efba9 Reviewed-on: https://code.wireshark.org/review/8773 Reviewed-by: Roland Knall <rknall@gmail.com> Petri-Dish: Anders Broman <a.broman58@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui/qt/main_window.cpp')
-rw-r--r--ui/qt/main_window.cpp44
1 files changed, 43 insertions, 1 deletions
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp
index abae150c71..35e110c39b 100644
--- a/ui/qt/main_window.cpp
+++ b/ui/qt/main_window.cpp
@@ -27,7 +27,7 @@
#include <wsutil/filesystem.h>
#include <epan/prefs.h>
#include <epan/stats_tree_priv.h>
-#include <epan/ext_menubar.h>
+#include <epan/plugin_if.h>
#ifdef HAVE_LIBPCAP
#include "ui/capture.h"
@@ -42,6 +42,7 @@
#include "ui/main_statusbar.h"
#include "ui/recent.h"
#include "ui/util.h"
+#include "ui/preference_utils.h"
#include "byte_view_tab.h"
#include "display_filter_edit.h"
@@ -83,6 +84,42 @@ void pipe_input_set_handler(gint source, gpointer user_data, ws_process_id *chil
gbl_cur_main_window_->setPipeInputHandler(source, user_data, child_process, input_cb);
}
+void plugin_if_mainwindow_apply_filter(gconstpointer user_data)
+{
+ if ( gbl_cur_main_window_ != NULL && user_data != NULL )
+ {
+ GHashTable * dataSet = (GHashTable *) user_data;
+
+ if ( g_hash_table_contains(dataSet, "filter_string" ) )
+ {
+ QString filter((const char *)g_hash_table_lookup(dataSet, "filter_string"));
+ gbl_cur_main_window_->filterPackets(filter);
+ }
+ }
+}
+
+void plugin_if_mainwindow_preference(gconstpointer user_data)
+{
+ if ( gbl_cur_main_window_ != NULL && user_data != NULL )
+ {
+ GHashTable * dataSet = (GHashTable *) user_data;
+ if ( g_hash_table_contains(dataSet, "pref_module" ) &&
+ g_hash_table_contains(dataSet, "pref_value" ) &&
+ g_hash_table_contains(dataSet, "pref_value" ) )
+ {
+ const char * module_name = (const char *)g_hash_table_lookup(dataSet, "pref_module");
+ const char * pref_name = (const char *)g_hash_table_lookup(dataSet, "pref_key");
+ const char * pref_value = (const char *)g_hash_table_lookup(dataSet, "pref_value");
+
+ if ( prefs_store_ext(module_name, pref_name, pref_value) )
+ {
+ wsApp->emitAppSignal(WiresharkApplication::PacketDissectionChanged);
+ wsApp->emitAppSignal(WiresharkApplication::PreferencesChanged);
+ }
+ }
+ }
+}
+
gpointer
simple_dialog(ESD_TYPE_E type, gint btn_mask, const gchar *msg_format, ...)
{
@@ -479,6 +516,11 @@ MainWindow::MainWindow(QWidget *parent) :
this->main_welcome_->getInterfaceTree(), SLOT(interfaceListChanged()));
#endif
+ /* Create plugin_if hooks */
+ plugin_if_register_gui_cb(PLUGIN_IF_FILTER_ACTION_APPLY, plugin_if_mainwindow_apply_filter );
+ 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);
+
main_ui_->mainStack->setCurrentWidget(main_welcome_);
}