diff options
-rw-r--r-- | ui/qt/CMakeLists.txt | 2 | ||||
-rw-r--r-- | ui/qt/io_graph_dialog.cpp | 23 | ||||
-rw-r--r-- | ui/qt/main.cpp | 145 | ||||
-rw-r--r-- | ui/qt/main_window.cpp | 10 | ||||
-rw-r--r-- | ui/qt/main_window.h | 8 | ||||
-rw-r--r-- | ui/qt/main_window_slots.cpp | 15 | ||||
-rw-r--r-- | ui/qt/stats_tree_dialog.cpp | 1 | ||||
-rw-r--r-- | ui/qt/wireshark_application.cpp | 5 | ||||
-rw-r--r-- | ui/qt/wireshark_application.h | 3 |
9 files changed, 145 insertions, 67 deletions
diff --git a/ui/qt/CMakeLists.txt b/ui/qt/CMakeLists.txt index c58063e66f..2aa44bbf33 100644 --- a/ui/qt/CMakeLists.txt +++ b/ui/qt/CMakeLists.txt @@ -132,7 +132,6 @@ set(WIRESHARK_QT_SRC font_color_preferences_frame.cpp import_text_dialog.cpp interface_tree.cpp - io_graph_dialog.cpp label_stack.cpp layout_preferences_frame.cpp lbm_lbtrm_transport_dialog.cpp @@ -182,6 +181,7 @@ set(WIRESHARK_QT_SRC ) set(WIRESHARK_QT_TAP_SRC + io_graph_dialog.cpp stats_tree_dialog.cpp ) diff --git a/ui/qt/io_graph_dialog.cpp b/ui/qt/io_graph_dialog.cpp index 01999721f8..008b52308b 100644 --- a/ui/qt/io_graph_dialog.cpp +++ b/ui/qt/io_graph_dialog.cpp @@ -22,6 +22,7 @@ #include "io_graph_dialog.h" #include "ui_io_graph_dialog.h" +#include <epan/stat_cmd_args.h> #include "epan/stats_tree_priv.h" #include "epan/uat-int.h" @@ -49,11 +50,14 @@ // - You can't manually set a graph color other than manually editing the io_graphs // UAT. We should add a "graph color" preference. // - We retap and redraw more than we should. -// - We don't use scroll bars. Should we? -// - We should automatically scroll during live captures. // - Smoothing doesn't seem to match GTK+ // - We don't register a tap listener ("-z io,stat", bottom of gtk/io_stat.c) +// To do: +// - Use scroll bars? +// - Scroll during live captures +// - Set ticks per pixel (e.g. pressing "2" sets 2 tpp). + const int name_col_ = 0; const int dfilter_col_ = 1; const int color_col_ = 2; @@ -2153,6 +2157,21 @@ void IOGraph::tapDraw(void *iog_ptr) } } +// Stat command + args + +static void +io_graph_init(const char *opt_arg _U_, void* userdata _U_) { + wsApp->emitStatCommandSignal("IOGraph", NULL, NULL); +} + +extern "C" { +void +register_tap_listener_qt_iostat(void) +{ + register_stat_cmd_arg("io,stat", io_graph_init, NULL); +} +} + /* * Editor modelines * diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp index e8c6d6b47e..c08d9717bb 100644 --- a/ui/qt/main.cpp +++ b/ui/qt/main.cpp @@ -797,65 +797,6 @@ int main(int argc, char *argv[]) main_w->connect(&ws_app, SIGNAL(openCaptureFile(QString&,QString&,unsigned int)), main_w, SLOT(openCaptureFile(QString&,QString&,unsigned int))); - while ((opt = getopt_long(argc, argv, optstring, long_options, NULL)) != -1) { - switch (opt) { - case 'r': - cf_name = new QString(optarg); - break; - case '?': - print_usage(FALSE); - exit(0); - break; - } - } - - if (!arg_error) { - argc -= optind; - argv += optind; - if (argc >= 1) { - if (cf_name != NULL) { - /* - * Input file name specified with "-r" *and* specified as a regular - * command-line argument. - */ - cmdarg_err("File name specified both with -r and regular argument"); - arg_error = TRUE; - } else { - /* - * Input file name not specified with "-r", and a command-line argument - * was specified; treat it as the input file name. - * - * Yes, this is different from tshark, where non-flag command-line - * arguments are a filter, but this works better on GUI desktops - * where a command can be specified to be run to open a particular - * file - yes, you could have "-r" as the last part of the command, - * but that's a bit ugly. - */ - cf_name = new QString(g_strdup(argv[0])); - - } - argc--; - argv++; - } - - if (argc != 0) { - /* - * Extra command line arguments were specified; complain. - */ - cmdarg_err("Invalid argument: %s", argv[0]); - arg_error = TRUE; - } - } - if (arg_error) { -#ifndef HAVE_LIBPCAP - if (capture_option_specified) { - cmdarg_err("This version of Wireshark was not built with support for capturing packets."); - } -#endif - print_usage(FALSE); - exit(1); - } - /* Init the "Open file" dialog directory */ /* (do this after the path settings are processed) */ @@ -1011,6 +952,80 @@ int main(int argc, char *argv[]) qtTranslator.load("qt_" + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath)); wsApp->installTranslator(&qtTranslator); + /* Now get our args */ + while ((opt = getopt_long(argc, argv, optstring, long_options, NULL)) != -1) { + switch (opt) { + case 'r': + cf_name = new QString(optarg); + break; + case 'z': + /* We won't call the init function for the stat this soon + as it would disallow MATE's fields (which are registered + by the preferences set callback) from being used as + part of a tap filter. Instead, we just add the argument + to a list of stat arguments. */ + if (!process_stat_cmd_arg(optarg)) { + cmdarg_err("Invalid -z argument."); + cmdarg_err_cont(" -z argument must be one of :"); + list_stat_cmd_args(); + exit(1); + } + break; + default: + case '?': + print_usage(FALSE); + exit(0); + break; + } + } + + if (!arg_error) { + argc -= optind; + argv += optind; + if (argc >= 1) { + if (cf_name != NULL) { + /* + * Input file name specified with "-r" *and* specified as a regular + * command-line argument. + */ + cmdarg_err("File name specified both with -r and regular argument"); + arg_error = TRUE; + } else { + /* + * Input file name not specified with "-r", and a command-line argument + * was specified; treat it as the input file name. + * + * Yes, this is different from tshark, where non-flag command-line + * arguments are a filter, but this works better on GUI desktops + * where a command can be specified to be run to open a particular + * file - yes, you could have "-r" as the last part of the command, + * but that's a bit ugly. + */ + cf_name = new QString(g_strdup(argv[0])); + + } + argc--; + argv++; + } + + if (argc != 0) { + /* + * Extra command line arguments were specified; complain. + */ + cmdarg_err("Invalid argument: %s", argv[0]); + arg_error = TRUE; + } + } + if (arg_error) { +#ifndef HAVE_LIBPCAP + if (capture_option_specified) { + cmdarg_err("This version of Wireshark was not built with support for capturing packets."); + } +#endif + print_usage(FALSE); + exit(1); + } + /* Removed thread code: * https://code.wireshark.org/review/gitweb?p=wireshark.git;a=commit;h=9e277ae6154fd04bf6a0a34ec5655a73e5a736a3 */ @@ -1103,7 +1118,19 @@ int main(int argc, char *argv[]) display_filter = new QString(); if (cf_name == NULL) cf_name = new QString(); + + // XXX We need to call cf_open + start_requested_stats + cf_read + // similar to gtk/main.c:3110. main_w->openCaptureFile(*cf_name, *display_filter, in_file_type); + + /* Open stat windows; we do so after creating the main window, + to avoid Qt warnings, and after successfully opening the + capture file, so we know we have something to compute stats + on, and after registering all dissectors, so that MATE will + have registered its field array and we can have a tap filter + with one of MATE's late-registered fields as part of the + filter. */ + start_requested_stats(); } g_main_loop_new(NULL, FALSE); diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp index 36cf1b0e03..52b9d72835 100644 --- a/ui/qt/main_window.cpp +++ b/ui/qt/main_window.cpp @@ -75,11 +75,11 @@ //menu_recent_file_write_all // If we ever add support for multiple windows this will need to be replaced. -static MainWindow *gbl_cur_main_window = NULL; +static MainWindow *gbl_cur_main_window_ = NULL; void pipe_input_set_handler(gint source, gpointer user_data, int *child_process, pipe_input_cb_t input_cb) { - gbl_cur_main_window->setPipeInputHandler(source, user_data, child_process, input_cb); + gbl_cur_main_window_->setPipeInputHandler(source, user_data, child_process, input_cb); } MainWindow::MainWindow(QWidget *parent) : @@ -96,7 +96,11 @@ MainWindow::MainWindow(QWidget *parent) : pipe_notifier_(NULL) #endif { - gbl_cur_main_window = this; + if (!gbl_cur_main_window_) { + connect(wsApp, SIGNAL(openStatCommandDialog(QString,const char*,void*)), + this, SLOT(openStatCommandDialog(QString,const char*,void*))); + } + gbl_cur_main_window_ = this; main_ui_->setupUi(this); setTitlebarForCaptureFile(); setMenusForCaptureFile(); diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h index 4fa4ae8580..725eb5b409 100644 --- a/ui/qt/main_window.h +++ b/ui/qt/main_window.h @@ -212,6 +212,13 @@ private slots: void addDisplayFilterButton(QString df_text); void displayFilterButtonClicked(); + /** Pass stat cmd arguments to a slot. + * @param slot Partial slot name, e.g. "StatisticsIOGraph". + * @param "-z" argument, e.g. "io,stat". + * @param userdata Optional user data. + */ + void openStatCommandDialog(const QString &menu_path, const char *arg, void *userdata); + // We should probably move these to main_window_actions.cpp similar to // gtk/main_menubar.c void on_actionFileOpen_triggered(); @@ -366,6 +373,7 @@ private slots: void on_actionStatisticsHTTPRequests_triggered(); void on_actionStatisticsHTTPLoadDistribution_triggered(); void on_actionStatisticsPacketLen_triggered(); + void statCommandIOGraph(const char *arg = NULL, void *userdata = NULL); void on_actionStatisticsIOGraph_triggered(); void on_actionStatisticsSametime_triggered(); diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index 3d3de8fac3..38bf02e62f 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -97,6 +97,7 @@ #include <QClipboard> #include <QMessageBox> +#include <QMetaObject> #include <QDebug> @@ -1189,6 +1190,12 @@ void MainWindow::displayFilterButtonClicked() } } +void MainWindow::openStatCommandDialog(const QString &menu_path, const char *arg, void *userdata) +{ + QString slot = QString("statCommand%1").arg(menu_path); + QMetaObject::invokeMethod(this, slot.toLatin1().constData(), Q_ARG(const char *, arg), Q_ARG(void *, userdata)); +} + // File Menu void MainWindow::on_actionFileOpen_triggered() @@ -2082,8 +2089,10 @@ void MainWindow::on_actionStatisticsPacketLen_triggered() openStatisticsTreeDialog("plen"); } -void MainWindow::on_actionStatisticsIOGraph_triggered() +void MainWindow::statCommandIOGraph(const char *arg, void *userdata) { + Q_UNUSED(arg); + Q_UNUSED(userdata); IOGraphDialog *iog_dialog = new IOGraphDialog(this, cap_file_); connect(iog_dialog, SIGNAL(goToPacket(int)), packet_list_, SLOT(goToPacket(int))); connect(this, SIGNAL(setCaptureFile(capture_file*)), @@ -2091,6 +2100,10 @@ void MainWindow::on_actionStatisticsIOGraph_triggered() iog_dialog->show(); } +void MainWindow::on_actionStatisticsIOGraph_triggered() +{ + statCommandIOGraph(NULL, NULL); +} void MainWindow::on_actionStatisticsSametime_triggered() { openStatisticsTreeDialog("sametime"); diff --git a/ui/qt/stats_tree_dialog.cpp b/ui/qt/stats_tree_dialog.cpp index a5af2987b5..e94d19ebc5 100644 --- a/ui/qt/stats_tree_dialog.cpp +++ b/ui/qt/stats_tree_dialog.cpp @@ -333,7 +333,6 @@ extern "C" { void register_tap_listener_stats_tree_stat(void) { - stats_tree_presentation(NULL, StatsTreeDialog::setupNode, NULL, diff --git a/ui/qt/wireshark_application.cpp b/ui/qt/wireshark_application.cpp index eaa0ba24f7..cda29e035e 100644 --- a/ui/qt/wireshark_application.cpp +++ b/ui/qt/wireshark_application.cpp @@ -617,6 +617,11 @@ void WiresharkApplication::emitAppSignal(AppSignal signal) } } +void WiresharkApplication::emitStatCommandSignal(const QString &menu_path, const char *arg, void *userdata) +{ + emit openStatCommandDialog(menu_path, arg, userdata); +} + void WiresharkApplication::allSystemsGo() { QString display_filter = NULL; diff --git a/ui/qt/wireshark_application.h b/ui/qt/wireshark_application.h index 120d552bce..6ac8359e60 100644 --- a/ui/qt/wireshark_application.h +++ b/ui/qt/wireshark_application.h @@ -71,6 +71,7 @@ public: void registerUpdate(register_action_e action, const char *message); void emitAppSignal(AppSignal signal); + void emitStatCommandSignal(const QString &menu_path, const char *arg, void *userdata); void allSystemsGo(); e_prefs * readConfigurationFiles(char **gdp_path, char **dp_path); QList<recent_item_status *> recentItems() const; @@ -127,6 +128,8 @@ signals: void captureFileClosing(const capture_file *cf); void captureFileClosed(const capture_file *cf); + void openStatCommandDialog(const QString &menu_path, const char *arg, void *userdata); + public slots: void clearRecentItems(); |