summaryrefslogtreecommitdiff
path: root/epan
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2015-07-03 15:52:49 -0500
committerGerald Combs <gerald@wireshark.org>2015-07-07 20:49:30 +0000
commite91ca72a445d51b71f958f140e2eb89747f499ff (patch)
tree8447adabdba8623cd8e045bc7a3d3d73fca54130 /epan
parente9622175f7aee7dbeff6e97c9ac6ab78460e239a (diff)
downloadwireshark-e91ca72a445d51b71f958f140e2eb89747f499ff.tar.gz
Qt: Add initial Lua support.
Add a FunnelStatistics class, which is the main interface between the Qt UI and the Funnel API. Add FunnelTextDialog, which implements the text_window, ProgDlg, menu, and other routines. Add FunnelStringDialog, which implements dlg_new. We currently only support "Tools" menu items (MENU_TOOLS_UNSORTED, aka REGISTER_TOOLS_GROUP_UNSORTED). Add a disabled placeholder to the "Tools" menu in case we don't load any scripts. Use "struct progdlg" instead of needlessly casting to funnel_progress_window_t. To do: - Add support for MENU_STAT_UNSORTED, MENU_STAT_GENERIC, etc. - Make the firewall config generator a Lua script? - Add FunnelGraphDialog? It seems like it would be useful to make QCustomPlot accessible to Lua scripts. Ping-Bug: 9845 Change-Id: Iefff02e9032ed1853666f7902509ed08b431e7a7 Reviewed-on: https://code.wireshark.org/review/9523 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'epan')
-rw-r--r--epan/funnel.c1
-rw-r--r--epan/funnel.h52
-rw-r--r--epan/wslua/wslua.h2
-rw-r--r--epan/wslua/wslua_gui.c14
4 files changed, 41 insertions, 28 deletions
diff --git a/epan/funnel.c b/epan/funnel.c
index 876f84b57e..02cd4f1171 100644
--- a/epan/funnel.c
+++ b/epan/funnel.c
@@ -37,6 +37,7 @@ typedef struct _funnel_menu_t {
struct _funnel_menu_t* next;
} funnel_menu_t;
+/* XXX This assumes one main window and one capture file. */
static const funnel_ops_t* ops = NULL;
static funnel_menu_t* menus = NULL;
diff --git a/epan/funnel.h b/epan/funnel.h
index 3d66f54c63..b7e2ac1d01 100644
--- a/epan/funnel.h
+++ b/epan/funnel.h
@@ -23,17 +23,22 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef _FUNNEL_H
-#define _FUNNEL_H
+#ifndef __FUNNEL_H__
+#define __FUNNEL_H__
#include <glib.h>
#include <epan/stat_groups.h>
#include "ws_symbol_export.h"
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+typedef struct _funnel_ops_id_t funnel_ops_id_t; /* Opaque pointer to ops instance */
typedef struct _funnel_progress_window_t funnel_progress_window_t ;
typedef struct _funnel_text_window_t funnel_text_window_t ;
-typedef struct _funnel_tree_window_t funnel_tree_window_t ;
-typedef struct _funnel_node_t funnel_node_t ;
+typedef struct _funnel_tree_window_t funnel_tree_window_t ; /* XXX Unused? */
+typedef struct _funnel_node_t funnel_node_t ; /* XXX Unused? */
typedef void (*text_win_close_cb_t)(void*);
@@ -49,17 +54,20 @@ typedef struct _funnel_bt_t {
void (*free_data_fcn)(void*);
} funnel_bt_t;
+struct progdlg;
+
typedef struct _funnel_ops_t {
- funnel_text_window_t* (*new_text_window)(const gchar* label);
- void (*set_text)(funnel_text_window_t* win, const gchar* text);
- void (*append_text)(funnel_text_window_t* win, const gchar* text);
- void (*prepend_text)(funnel_text_window_t* win, const gchar* text);
+ funnel_ops_id_t *ops_id;
+ funnel_text_window_t* (*new_text_window)(const char* label);
+ void (*set_text)(funnel_text_window_t* win, const char* text);
+ void (*append_text)(funnel_text_window_t* win, const char* text);
+ void (*prepend_text)(funnel_text_window_t* win, const char* text);
void (*clear_text)(funnel_text_window_t* win);
- const gchar* (*get_text)(funnel_text_window_t* win);
+ const char* (*get_text)(funnel_text_window_t* win);
void (*set_close_cb)(funnel_text_window_t* win, text_win_close_cb_t cb, void* data);
void (*set_editable)(funnel_text_window_t* win, gboolean editable);
void (*destroy_text_window)(funnel_text_window_t* win);
- void (*add_button)(funnel_text_window_t* win, funnel_bt_t* cb, const gchar* label);
+ void (*add_button)(funnel_text_window_t* win, funnel_bt_t* cb, const char* label);
void (*new_dialog)(const gchar* title,
const gchar** fieldnames,
@@ -73,22 +81,22 @@ typedef struct _funnel_ops_t {
gpointer user_data);
- void (*retap_packets)(void);
+ void (*retap_packets)(funnel_ops_id_t *ops_id);
void (*copy_to_clipboard)(GString *str);
- gchar * (*get_filter)(void);
- void (*set_filter)(const char*);
+ const gchar * (*get_filter)(funnel_ops_id_t *ops_id);
+ void (*set_filter)(funnel_ops_id_t *ops_id, const char* filter);
void (*set_color_filter_slot)(guint8 flit_nr, const gchar* filter);
- gboolean (*open_file)(const char* fname, const char* filter, char** error);
- void (*reload)(void);
- void (*apply_filter)(void);
+ gboolean (*open_file)(funnel_ops_id_t *ops_id, const char* fname, const char* filter, char** error);
+ void (*reload)(funnel_ops_id_t *ops_id);
+ void (*apply_filter)(funnel_ops_id_t *ops_id);
gboolean (*browser_open_url)(const gchar *url);
void (*browser_open_data_file)(const gchar *filename);
- funnel_progress_window_t* (*new_progress_window)(const gchar* label, const gchar* task, gboolean terminate_is_stop, gboolean *stop_flag);
- void (*update_progress)(funnel_progress_window_t*, float pr, const gchar* task);
- void (*destroy_progress_window)(funnel_progress_window_t*);
+ struct progdlg* (*new_progress_window)(funnel_ops_id_t *ops_id, const gchar* label, const gchar* task, gboolean terminate_is_stop, gboolean *stop_flag);
+ void (*update_progress)(struct progdlg*, float pr, const gchar* task);
+ void (*destroy_progress_window)(struct progdlg*);
} funnel_ops_t;
WS_DLL_PUBLIC const funnel_ops_t* funnel_get_funnel_ops(void);
@@ -112,4 +120,8 @@ extern void initialize_funnel_ops(void);
extern void funnel_dump_all_text_windows(void);
-#endif
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __FUNNEL_H__ */
diff --git a/epan/wslua/wslua.h b/epan/wslua/wslua.h
index 80a333618e..8d41607ee3 100644
--- a/epan/wslua/wslua.h
+++ b/epan/wslua/wslua.h
@@ -295,7 +295,7 @@ struct _wslua_dir {
};
struct _wslua_progdlg {
- funnel_progress_window_t* pw;
+ struct progdlg* pw;
char* title;
char* task;
gboolean stopped;
diff --git a/epan/wslua/wslua_gui.c b/epan/wslua/wslua_gui.c
index c505eb15f6..0586293aa3 100644
--- a/epan/wslua/wslua_gui.c
+++ b/epan/wslua/wslua_gui.c
@@ -292,7 +292,7 @@ WSLUA_CONSTRUCTOR ProgDlg_new(lua_State* L) { /* Creates a new `ProgDlg` progres
pd->stopped = FALSE;
if (ops->new_progress_window) {
- pd->pw = ops->new_progress_window(pd->title,pd->task,TRUE,&(pd->stopped));
+ pd->pw = ops->new_progress_window(ops->ops_id, pd->title, pd->task, TRUE, &(pd->stopped));
} else {
WSLUA_ERROR(ProgDlg_new, "GUI not available");
return 0;
@@ -697,7 +697,7 @@ WSLUA_FUNCTION wslua_retap_packets(lua_State* L) {
Rescan all packets and just run taps - don't reconstruct the display.
*/
if ( ops->retap_packets ) {
- ops->retap_packets();
+ ops->retap_packets(ops->ops_id);
} else {
WSLUA_ERROR(wslua_retap_packets, "GUI not available");
}
@@ -737,7 +737,7 @@ WSLUA_FUNCTION wslua_open_capture_file(lua_State* L) { /* Open and display a cap
return 0;
}
- if (! ops->open_file(fname,filter,&error) ) {
+ if (! ops->open_file(ops->ops_id, fname, filter, &error) ) {
lua_pushboolean(L,FALSE);
if (error) {
@@ -761,7 +761,7 @@ WSLUA_FUNCTION wslua_get_filter(lua_State* L) { /* Get the main filter text. */
return 0;
}
- filter_str = ops->get_filter();
+ filter_str = ops->get_filter(ops->ops_id);
lua_pushstring(L,filter_str);
return 1;
@@ -776,7 +776,7 @@ WSLUA_FUNCTION wslua_set_filter(lua_State* L) { /* Set the main filter text. */
return 0;
}
- ops->set_filter(filter_str);
+ ops->set_filter(ops->ops_id, filter_str);
return 0;
}
@@ -803,7 +803,7 @@ WSLUA_FUNCTION wslua_apply_filter(lua_State* L) { /* Apply the filter in the mai
return 0;
}
- ops->apply_filter();
+ ops->apply_filter(ops->ops_id);
return 0;
}
@@ -816,7 +816,7 @@ WSLUA_FUNCTION wslua_reload(lua_State* L) { /* Reload the current capture file.
return 0;
}
- ops->reload();
+ ops->reload(ops->ops_id);
return 0;
}