summaryrefslogtreecommitdiffstats
path: root/ui/qt/funnel_statistics.cpp
blob: f5ed674563bdd97659181615e2ce5ea20ade156a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
/* funnel_statistics.cpp
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#include "config.h"

#include <glib.h>

#include "epan/color_filters.h"
#include "file.h"

#include "epan/funnel.h"
#include "epan/prefs.h"

#include <wsutil/wslog.h>

#include "ui/progress_dlg.h"
#include "ui/simple_dialog.h"
#include <ui/qt/main_window.h>
#include <ui/qt/io_console_dialog.h>

#include "funnel_statistics.h"
#include "funnel_string_dialog.h"
#include "funnel_text_dialog.h"

#include <QAction>
#include <QClipboard>
#include <QDebug>
#include <QDesktopServices>
#include <QMenu>
#include <QUrl>

#include "main_application.h"

// To do:
// - Handle menu paths. Do we create a new path (GTK+) or use the base element?
// - Add a FunnelGraphDialog class?

extern "C" {
static struct _funnel_text_window_t* text_window_new(funnel_ops_id_t *ops_id, const char* title);
static void string_dialog_new(funnel_ops_id_t *ops_id, const gchar* title, const gchar** field_names, const gchar** field_values, funnel_dlg_cb_t dialog_cb, void* dialog_cb_data, funnel_dlg_cb_data_free_t dialog_cb_data_free);

static void funnel_statistics_retap_packets(funnel_ops_id_t *ops_id);
static void funnel_statistics_copy_to_clipboard(GString *text);
static const gchar *funnel_statistics_get_filter(funnel_ops_id_t *ops_id);
static void funnel_statistics_set_filter(funnel_ops_id_t *ops_id, const char* filter_string);
static gchar* funnel_statistics_get_color_filter_slot(guint8 filter_num);
static void funnel_statistics_set_color_filter_slot(guint8 filter_num, const gchar* filter_string);
static gboolean funnel_statistics_open_file(funnel_ops_id_t *ops_id, const char* fname, const char* filter, char**);
static void funnel_statistics_reload_packets(funnel_ops_id_t *ops_id);
static void funnel_statistics_redissect_packets(funnel_ops_id_t *ops_id);
static void funnel_statistics_reload_lua_plugins(funnel_ops_id_t *ops_id);
static void funnel_statistics_apply_filter(funnel_ops_id_t *ops_id);
static gboolean browser_open_url(const gchar *url);
static void browser_open_data_file(const gchar *filename);
static struct progdlg *progress_window_new(funnel_ops_id_t *ops_id, const gchar* title, const gchar* task, gboolean terminate_is_stop, gboolean *stop_flag);
static void progress_window_update(struct progdlg *progress_dialog, float percentage, const gchar* status);
static void progress_window_destroy(struct progdlg *progress_dialog);
}

FunnelAction::FunnelAction(QObject *parent) :
        QAction(parent),
        callback_(nullptr),
        callback_data_(NULL),
        retap_(FALSE),
        packetCallback_(nullptr),
        packetData_(NULL)
{

}

FunnelAction::FunnelAction(QString title, funnel_menu_callback callback, gpointer callback_data, gboolean retap, QObject *parent = nullptr) :
        QAction(parent),
        title_(title),
        callback_(callback),
        callback_data_(callback_data),
        retap_(retap)
{
    // Use "&&" to get a real ampersand in the menu item.
    title.replace('&', "&&");

    setText(title);
    setObjectName(FunnelStatistics::actionName());
    packetRequiredFields_ = QSet<QString>();
}

FunnelAction::FunnelAction(QString title, funnel_packet_menu_callback callback, gpointer callback_data, gboolean retap, const char *packet_required_fields, QObject *parent = nullptr) :
        QAction(parent),
        title_(title),
        callback_data_(callback_data),
        retap_(retap),
        packetCallback_(callback),
        packetRequiredFields_(QSet<QString>())
{
    // Use "&&" to get a real ampersand in the menu item.
    title.replace('&', "&&");

    QStringList menuComponents = title.split(QString("/"));
    // Set the menu's text to the rightmost component, set the path to being everything to the left:
    setText("(empty)");
    packetSubmenu_ = "";
    if (!menuComponents.isEmpty())
    {
        setText(menuComponents.last());
        menuComponents.removeLast();
        packetSubmenu_ = menuComponents.join("/");
    }

    setObjectName(FunnelStatistics::actionName());
    setPacketRequiredFields(packet_required_fields);
}

FunnelAction::~FunnelAction(){
}

funnel_menu_callback FunnelAction::callback() const {
    return callback_;
}

QString FunnelAction::title() const {
    return title_;
}

void FunnelAction::triggerCallback() {
    if (callback_) {
        callback_(callback_data_);
    }
}

void FunnelAction::setPacketCallback(funnel_packet_menu_callback packet_callback) {
    packetCallback_ = packet_callback;
}

void FunnelAction::setPacketRequiredFields(const char *required_fields_str) {
    packetRequiredFields_.clear();
    // If multiple fields are required to be present, they're split by commas
    // Also remove leading and trailing spaces, in case someone writes
    // "http, dns" instead of "http,dns"
    QString requiredFieldsJoined = QString(required_fields_str);
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
    QStringList requiredFieldsSplit = requiredFieldsJoined.split(",", Qt::SkipEmptyParts);
#else
    QStringList requiredFieldsSplit = requiredFieldsJoined.split(",", QString::SkipEmptyParts);
#endif
    foreach (QString requiredField, requiredFieldsSplit) {
        QString trimmedFieldName = requiredField.trimmed();
        if (! trimmedFieldName.isEmpty()) {
            packetRequiredFields_.insert(trimmedFieldName);
        }
    }
}

const QSet<QString> FunnelAction::getPacketRequiredFields() {
    return packetRequiredFields_;
}


void FunnelAction::setPacketData(GPtrArray* finfos) {
    packetData_ = finfos;
}

void FunnelAction::addToMenu(QMenu * ctx_menu, QHash<QString, QMenu *> &menuTextToMenus) {
    QString submenusText = this->getPacketSubmenus();
    if (submenusText.isEmpty()) {
        ctx_menu->addAction(this);
    } else {
        // If the action has a submenu, ensure that the
        // the full submenu chain exists:
        QStringList menuComponents = submenusText.split("/");
        QString menuSubComponentsStringPrior = NULL;
        for (int menuIndex=0; menuIndex < menuComponents.size(); menuIndex++) {
            QStringList menuSubComponents = menuComponents.mid(0, menuIndex+1);
            QString menuSubComponentsString = menuSubComponents.join("/");
            if (!menuTextToMenus.contains(menuSubComponentsString)) {
                // Create a new menu object under the prior object
                QMenu *previousSubmenu = menuTextToMenus.value(menuSubComponentsStringPrior);
                QMenu *submenu = previousSubmenu->addMenu(menuComponents.at(menuIndex));
                menuTextToMenus.insert(menuSubComponentsString, submenu);
            }
            menuSubComponentsStringPrior = menuSubComponentsString;
        }
        // Then add the action to the relevant submenu
        QMenu *parentMenu = menuTextToMenus.value(submenusText);
        parentMenu->addAction(this);
    }

}

void FunnelAction::triggerPacketCallback() {
    if (packetCallback_) {
        packetCallback_(callback_data_, packetData_);
    }
}

bool FunnelAction::retap() {
    if (retap_) return true;
    return false;
}

QString FunnelAction::getPacketSubmenus() {
    return packetSubmenu_;
}

FunnelConsoleAction::FunnelConsoleAction(QString name,
                        funnel_console_eval_cb_t eval_cb,
                        funnel_console_open_cb_t open_cb,
                        funnel_console_close_cb_t close_cb,
                        void *callback_data, QObject *parent = nullptr) :
        FunnelAction(parent),
        eval_cb_(eval_cb),
        open_cb_(open_cb),
        close_cb_(close_cb),
        callback_data_(callback_data)
{
    // Use "&&" to get a real ampersand in the menu item.
    QString title = QString("%1 Console").arg(name).replace('&', "&&");

    setText(title);
    setObjectName(FunnelStatistics::actionName());
}

FunnelConsoleAction::~FunnelConsoleAction()
{
}

void FunnelConsoleAction::triggerCallback() {
    if (!dialog_) {
        dialog_ = new IOConsoleDialog(*qobject_cast<QWidget *>(parent()),
                                            this->text(),
                                            eval_cb_, open_cb_, close_cb_, callback_data_);
        dialog_->setAttribute(Qt::WA_DeleteOnClose);
    }

    if (dialog_->isMinimized()) {
        dialog_->showNormal();
    }
    else {
        dialog_->show();
    }
    dialog_->raise();
    dialog_->activateWindow();
}

static QHash<int, QList<FunnelAction *> > funnel_actions_;
const QString FunnelStatistics::action_name_ = "FunnelStatisticsAction";
static gboolean menus_registered = FALSE;

struct _funnel_ops_id_t {
    FunnelStatistics *funnel_statistics;
};

FunnelStatistics::FunnelStatistics(QObject *parent, CaptureFile &cf) :
    QObject(parent),
    capture_file_(cf),
    prepared_filter_(QString())
{
    funnel_ops_ = new(struct _funnel_ops_t);
    memset(funnel_ops_, 0, sizeof(struct _funnel_ops_t));
    funnel_ops_id_ = new(struct _funnel_ops_id_t);

    funnel_ops_id_->funnel_statistics = this;
    funnel_ops_->ops_id = funnel_ops_id_;
    funnel_ops_->new_text_window = text_window_new;
    funnel_ops_->set_text = text_window_set_text;
    funnel_ops_->append_text = text_window_append;
    funnel_ops_->prepend_text = text_window_prepend;
    funnel_ops_->clear_text = text_window_clear;
    funnel_ops_->get_text = text_window_get_text;
    funnel_ops_->set_close_cb = text_window_set_close_cb;
    funnel_ops_->set_editable = text_window_set_editable;
    funnel_ops_->destroy_text_window = text_window_destroy;
    funnel_ops_->add_button = text_window_add_button;
    funnel_ops_->new_dialog = string_dialog_new;
    funnel_ops_->close_dialogs = string_dialogs_close;
    funnel_ops_->retap_packets = funnel_statistics_retap_packets;
    funnel_ops_->copy_to_clipboard = funnel_statistics_copy_to_clipboard;
    funnel_ops_->get_filter = funnel_statistics_get_filter;
    funnel_ops_->set_filter = funnel_statistics_set_filter;
    funnel_ops_->get_color_filter_slot = funnel_statistics_get_color_filter_slot;
    funnel_ops_->set_color_filter_slot = funnel_statistics_set_color_filter_slot;
    funnel_ops_->open_file = funnel_statistics_open_file;
    funnel_ops_->reload_packets = funnel_statistics_reload_packets;
    funnel_ops_->redissect_packets = funnel_statistics_redissect_packets;
    funnel_ops_->reload_lua_plugins = funnel_statistics_reload_lua_plugins;
    funnel_ops_->apply_filter = funnel_statistics_apply_filter;
    funnel_ops_->browser_open_url = browser_open_url;
    funnel_ops_->browser_open_data_file = browser_open_data_file;
    funnel_ops_->new_progress_window = progress_window_new;
    funnel_ops_->update_progress = progress_window_update;
    funnel_ops_->destroy_progress_window = progress_window_destroy;

    funnel_set_funnel_ops(funnel_ops_);
}

FunnelStatistics::~FunnelStatistics()
{
    // At this point we're probably closing the program and will shortly
    // call epan_cleanup, which calls ProgDlg__gc and TextWindow__gc.
    // They in turn depend on funnel_ops_ being valid.
    memset(funnel_ops_id_, 0, sizeof(struct _funnel_ops_id_t));
    memset(funnel_ops_, 0, sizeof(struct _funnel_ops_t));
    // delete(funnel_ops_id_);
    // delete(funnel_ops_);
}

void FunnelStatistics::retapPackets()
{
    capture_file_.retapPackets();
}

struct progdlg *FunnelStatistics::progressDialogNew(const gchar *task_title, const gchar *item_title, gboolean terminate_is_stop, gboolean *stop_flag)
{
    return create_progress_dlg(parent(), task_title, item_title, terminate_is_stop, stop_flag);
}

const char *FunnelStatistics::displayFilter()
{
    return display_filter_.constData();
}

void FunnelStatistics::emitSetDisplayFilter(const QString filter)
{
    prepared_filter_ = filter;
    emit setDisplayFilter(filter, FilterAction::ActionPrepare, FilterAction::ActionTypePlain);
}

void FunnelStatistics::reloadPackets()
{
    capture_file_.reload();
}

void FunnelStatistics::redissectPackets()
{
    // This will trigger a packet redissection.
    mainApp->emitAppSignal(MainApplication::PacketDissectionChanged);
}

void FunnelStatistics::reloadLuaPlugins()
{
    mainApp->reloadLuaPluginsDelayed();
}

void FunnelStatistics::emitApplyDisplayFilter()
{
    emit setDisplayFilter(prepared_filter_, FilterAction::ActionApply, FilterAction::ActionTypePlain);
}

void FunnelStatistics::emitOpenCaptureFile(QString cf_path, QString filter)
{
    emit openCaptureFile(cf_path, filter);
}

void FunnelStatistics::funnelActionTriggered()
{
    FunnelAction *funnel_action = dynamic_cast<FunnelAction *>(sender());
    if (!funnel_action) return;

    funnel_action->triggerCallback();
}

void FunnelStatistics::displayFilterTextChanged(const QString &filter)
{
    display_filter_ = filter.toUtf8();
}

struct _funnel_text_window_t* text_window_new(funnel_ops_id_t *ops_id, const char* title)
{
    return FunnelTextDialog::textWindowNew(qobject_cast<QWidget *>(ops_id->funnel_statistics->parent()), title);
}

void string_dialog_new(funnel_ops_id_t *ops_id, const gchar* title, const gchar** field_names, const gchar** field_values, funnel_dlg_cb_t dialog_cb, void* dialog_cb_data, funnel_dlg_cb_data_free_t dialog_cb_data_free)
{
    QList<QPair<QString, QString>> field_list;
    for (int i = 0; field_names[i]; i++) {
        QPair<QString, QString> field = QPair<QString, QString>(QString(field_names[i]), QString(""));
        if (field_values != NULL && field_values[i])
        {
            field.second = QString(field_values[i]);
        }

        field_list << field;
    }
    FunnelStringDialog::stringDialogNew(qobject_cast<QWidget *>(ops_id->funnel_statistics->parent()), title, field_list, dialog_cb, dialog_cb_data, dialog_cb_data_free);
}

void funnel_statistics_retap_packets(funnel_ops_id_t *ops_id) {
    if (!ops_id || !ops_id->funnel_statistics) return;

    ops_id->funnel_statistics->retapPackets();
}

void funnel_statistics_copy_to_clipboard(GString *text) {
    mainApp->clipboard()->setText(text->str);
}

const gchar *funnel_statistics_get_filter(funnel_ops_id_t *ops_id) {
    if (!ops_id || !ops_id->funnel_statistics) return nullptr;

    return ops_id->funnel_statistics->displayFilter();
}

void funnel_statistics_set_filter(funnel_ops_id_t *ops_id, const char* filter_string) {
    if (!ops_id || !ops_id->funnel_statistics) return;

    ops_id->funnel_statistics->emitSetDisplayFilter(filter_string);
}

gchar* funnel_statistics_get_color_filter_slot(guint8 filter_num) {
    return color_filters_get_tmp(filter_num);
}

void funnel_statistics_set_color_filter_slot(guint8 filter_num, const gchar* filter_string) {
    gchar *err_msg = nullptr;
    if (!color_filters_set_tmp(filter_num, filter_string, FALSE, &err_msg)) {
        simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
        g_free(err_msg);
    }
}

gboolean funnel_statistics_open_file(funnel_ops_id_t *ops_id, const char* fname, const char* filter, char**) {
    // XXX We need to return a proper error value. We should probably move
    // MainWindow::openCaptureFile to CaptureFile and add error handling
    // there.
    if (!ops_id || !ops_id->funnel_statistics) return FALSE;

    QString cf_name(fname);
    QString cf_filter(filter);
    ops_id->funnel_statistics->emitOpenCaptureFile(cf_name, cf_filter);
    return TRUE;
}

void funnel_statistics_reload_packets(funnel_ops_id_t *ops_id) {
    if (!ops_id || !ops_id->funnel_statistics) return;

    ops_id->funnel_statistics->reloadPackets();
}

void funnel_statistics_redissect_packets(funnel_ops_id_t *ops_id) {
    if (!ops_id || !ops_id->funnel_statistics) return;

    ops_id->funnel_statistics->redissectPackets();
}

void funnel_statistics_reload_lua_plugins(funnel_ops_id_t *ops_id) {
    if (!ops_id || !ops_id->funnel_statistics) return;

    ops_id->funnel_statistics->reloadLuaPlugins();
}

void funnel_statistics_apply_filter(funnel_ops_id_t *ops_id) {
    if (!ops_id || !ops_id->funnel_statistics) return;

    ops_id->funnel_statistics->emitApplyDisplayFilter();
}

gboolean browser_open_url(const gchar *url) {
    return QDesktopServices::openUrl(QUrl(url)) ? TRUE : FALSE;
}

void browser_open_data_file(const gchar *filename) {
    QDesktopServices::openUrl(QUrl::fromLocalFile(filename));
}

struct progdlg *progress_window_new(funnel_ops_id_t *ops_id, const gchar* task_title, const gchar* item_title, gboolean terminate_is_stop, gboolean *stop_flag) {
    if (!ops_id || !ops_id->funnel_statistics) return nullptr;

    return ops_id->funnel_statistics->progressDialogNew(task_title, item_title, terminate_is_stop, stop_flag);
}

void progress_window_update(struct progdlg *progress_dialog, float percentage, const gchar* status) {
    update_progress_dlg(progress_dialog, percentage, status);
}

void progress_window_destroy(progdlg *progress_dialog) {
    destroy_progress_dlg(progress_dialog);
}

extern "C" {

void register_tap_listener_qt_funnel(void);

static void register_menu_cb(const char *name,
                             register_stat_group_t group,
                             funnel_menu_callback callback,
                             gpointer callback_data,
                             gboolean retap)
{
    FunnelAction *funnel_action = new FunnelAction(name, callback, callback_data, retap, mainApp);
    if (menus_registered) {
        mainApp->appendDynamicMenuGroupItem(group, funnel_action);
    } else {
        mainApp->addDynamicMenuGroupItem(group, funnel_action);
    }
    if (!funnel_actions_.contains(group)) {
        funnel_actions_[group] = QList<FunnelAction *>();
    }
    funnel_actions_[group] << funnel_action;
}

/*
 * Callback used to register packet menus in the GUI.
 *
 * Creates a new FunnelAction with the Lua
 * callback and stores it in the Wireshark GUI with
 * appendPacketMenu() so it can be retrieved when
 * the packet's context menu is open.
 *
 * @param name packet menu item's name
 * @param required_fields fields required to be present for the packet menu to be displayed
 * @param callback function called when the menu item is invoked. The function must take one argument and return nothing.
 * @param callback_data Lua state for the callback function
 * @param retap whether or not to rescan all packets
 */
static void register_packet_menu_cb(const char *name,
                             const char *required_fields,
                             funnel_packet_menu_callback callback,
                             gpointer callback_data,
                             gboolean retap)
{
    FunnelAction *funnel_action = new FunnelAction(name, callback, callback_data, retap, required_fields, mainApp);
    MainWindow * mainwindow = qobject_cast<MainWindow *>(mainApp->mainWindow());
    if (mainwindow) {
        mainwindow->appendPacketMenu(funnel_action);
    }
}

static void deregister_menu_cb(funnel_menu_callback callback)
{
    foreach (int group, funnel_actions_.keys()) {
        QList<FunnelAction *>::iterator it = funnel_actions_[group].begin();
        while (it != funnel_actions_[group].end()) {
            FunnelAction *funnel_action = *it;
            if (funnel_action->callback() == callback) {
                // Must set back to title to find the correct sub-menu in Tools
                funnel_action->setText(funnel_action->title());
                mainApp->removeDynamicMenuGroupItem(group, funnel_action);
                it = funnel_actions_[group].erase(it);
            } else {
                ++it;
            }
        }
    }
}

void
register_tap_listener_qt_funnel(void)
{
    funnel_register_all_menus(register_menu_cb);
    funnel_statistics_load_console_menus();
    menus_registered = TRUE;
}

void
funnel_statistics_reload_menus(void)
{
    funnel_reload_menus(deregister_menu_cb, register_menu_cb);
    funnel_statistics_load_packet_menus();
}


/**
 * Returns whether the packet menus have been modified since they were last registered
 *
 * @return TRUE if the packet menus were modified since the last registration
 */
gboolean
funnel_statistics_packet_menus_modified(void)
{
    return funnel_packet_menus_modified();
}

/*
 * Loads all registered_packet_menus into the
 * Wireshark GUI.
 */
void
funnel_statistics_load_packet_menus(void)
{
    funnel_register_all_packet_menus(register_packet_menu_cb);
}

static void register_console_menu_cb(const char *name,
                                         funnel_console_eval_cb_t eval_cb,
                                         funnel_console_open_cb_t open_cb,
                                         funnel_console_close_cb_t close_cb,
                                         void *callback_data)
{
    FunnelConsoleAction *funnel_action = new FunnelConsoleAction(name, eval_cb,
                                                                open_cb,
                                                                close_cb,
                                                                callback_data,
                                                                mainApp);
    if (menus_registered) {
        mainApp->appendDynamicMenuGroupItem(REGISTER_TOOLS_GROUP_UNSORTED, funnel_action);
    } else {
        mainApp->addDynamicMenuGroupItem(REGISTER_TOOLS_GROUP_UNSORTED, funnel_action);
    }
    if (!funnel_actions_.contains(REGISTER_TOOLS_GROUP_UNSORTED)) {
        funnel_actions_[REGISTER_TOOLS_GROUP_UNSORTED] = QList<FunnelAction *>();
    }
    funnel_actions_[REGISTER_TOOLS_GROUP_UNSORTED] << funnel_action;
}

/*
 * Loads all registered console menus into the
 * Wireshark GUI.
 */
void
funnel_statistics_load_console_menus(void)
{
    funnel_register_all_console_menus(register_console_menu_cb);
}

} // extern "C"