1 /*
2  *  funnel.h
3  *
4  * EPAN's GUI mini-API
5  *
6  * (c) 2006, Luis E. Garcia Ontanon <luis@ontanon.org>
7  *
8  * Wireshark - Network traffic analyzer
9  * By Gerald Combs <gerald@wireshark.org>
10  * Copyright 1998 Gerald Combs
11  *
12  * SPDX-License-Identifier: GPL-2.0-or-later
13  */
14 #ifndef __FUNNEL_H__
15 #define __FUNNEL_H__
16 
17 #include <glib.h>
18 #include <epan/stat_groups.h>
19 #include "ws_symbol_export.h"
20 #include <ws_log_defs.h>
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif /* __cplusplus */
25 
26 typedef struct _funnel_ops_id_t funnel_ops_id_t; /* Opaque pointer to ops instance */
27 typedef struct _funnel_text_window_t funnel_text_window_t ;
28 
29 typedef void (*text_win_close_cb_t)(void*);
30 
31 typedef void (*funnel_dlg_cb_t)(gchar** user_input, void* data);
32 typedef void (*funnel_dlg_cb_data_free_t)(void* data);
33 
34 typedef gboolean (*funnel_bt_cb_t)(funnel_text_window_t* tw, void* data);
35 
36 typedef void (* funnel_menu_callback)(gpointer);
37 typedef void (* funnel_menu_callback_data_free)(gpointer);
38 
39 typedef struct _funnel_bt_t {
40 	funnel_text_window_t* tw;
41 	funnel_bt_cb_t func;
42 	void* data;
43 	void (*free_fcn)(void*);
44 	void (*free_data_fcn)(void*);
45 } funnel_bt_t;
46 
47 struct progdlg;
48 
49 typedef struct _funnel_ops_t {
50     funnel_ops_id_t *ops_id;
51     funnel_text_window_t* (*new_text_window)(const char* label);
52     void (*set_text)(funnel_text_window_t*  win, const char* text);
53     void (*append_text)(funnel_text_window_t*  win, const char* text);
54     void (*prepend_text)(funnel_text_window_t*  win, const char* text);
55     void (*clear_text)(funnel_text_window_t*  win);
56     const char* (*get_text)(funnel_text_window_t*  win);
57     void (*set_close_cb)(funnel_text_window_t*  win, text_win_close_cb_t cb, void* data);
58     void (*set_editable)(funnel_text_window_t*  win, gboolean editable);
59     void (*destroy_text_window)(funnel_text_window_t*  win);
60     void (*add_button)(funnel_text_window_t*  win, funnel_bt_t* cb, const char* label);
61 
62     void (*new_dialog)(const gchar* title,
63                     const gchar** field_names,
64                     const gchar** field_values,
65                     funnel_dlg_cb_t dlg_cb,
66                     void* data,
67                     funnel_dlg_cb_data_free_t dlg_cb_data_free);
68 
69     void (*close_dialogs)(void);
70 
71     void (*logger)(const gchar *log_domain,
72                    enum ws_log_level log_level,
73                    const gchar *message,
74                    gpointer user_data);
75 
76 
77     void (*retap_packets)(funnel_ops_id_t *ops_id);
78     void (*copy_to_clipboard)(GString *str);
79 
80     const gchar * (*get_filter)(funnel_ops_id_t *ops_id);
81     void (*set_filter)(funnel_ops_id_t *ops_id, const char* filter);
82     gchar * (*get_color_filter_slot)(guint8 filt_nr);
83     void (*set_color_filter_slot)(guint8 filt_nr, const gchar* filter);
84     gboolean (*open_file)(funnel_ops_id_t *ops_id, const char* fname, const char* filter, char** error);
85     void (*reload_packets)(funnel_ops_id_t *ops_id);
86     void (*redissect_packets)(funnel_ops_id_t *ops_id);
87     void (*reload_lua_plugins)(funnel_ops_id_t *ops_id);
88     void (*apply_filter)(funnel_ops_id_t *ops_id);
89 
90     gboolean (*browser_open_url)(const gchar *url);
91     void (*browser_open_data_file)(const gchar *filename);
92 
93     struct progdlg* (*new_progress_window)(funnel_ops_id_t *ops_id, const gchar* label, const gchar* task, gboolean terminate_is_stop, gboolean *stop_flag);
94     void (*update_progress)(struct progdlg*, float pr, const gchar* task);
95     void (*destroy_progress_window)(struct progdlg*);
96 } funnel_ops_t;
97 
98 WS_DLL_PUBLIC const funnel_ops_t* funnel_get_funnel_ops(void);
99 WS_DLL_PUBLIC void funnel_set_funnel_ops(const funnel_ops_t*);
100 
101 WS_DLL_PUBLIC void funnel_register_menu(const char *name,
102                                  register_stat_group_t group,
103                                  funnel_menu_callback callback,
104                                  gpointer callback_data,
105                                  funnel_menu_callback_data_free callback_data_free,
106                                  gboolean retap);
107 void funnel_deregister_menus(void (*callback)(gpointer));
108 
109 typedef void (*funnel_registration_cb_t)(const char *name,
110                                          register_stat_group_t group,
111                                          funnel_menu_callback callback,
112                                          gpointer callback_data,
113                                          gboolean retap);
114 typedef void (*funnel_deregistration_cb_t)(funnel_menu_callback callback);
115 
116 WS_DLL_PUBLIC void funnel_register_all_menus(funnel_registration_cb_t r_cb);
117 WS_DLL_PUBLIC void funnel_reload_menus(funnel_deregistration_cb_t d_cb,
118                                        funnel_registration_cb_t r_cb);
119 WS_DLL_PUBLIC void funnel_cleanup(void);
120 
121 extern void initialize_funnel_ops(void);
122 
123 extern void funnel_dump_all_text_windows(void);
124 
125 #ifdef __cplusplus
126 }
127 #endif /* __cplusplus */
128 
129 #endif /* __FUNNEL_H__ */
130