diff options
author | Martin Kaiser <wireshark@kaiser.cx> | 2014-11-22 12:58:43 +0100 |
---|---|---|
committer | Alexis La Goutte <alexis.lagoutte@gmail.com> | 2014-11-26 16:01:52 +0000 |
commit | 449bc19ba9dd11431a3b4be547b1f37981fe77b9 (patch) | |
tree | 3456c576b2f14c42b8c1a4a48b135189f82787c0 /ui | |
parent | 691f647acdfee71ef37453f146674999a2b43b6c (diff) |
Qt: support the -R option to set a read filter on the command line
rename display_filter to read_filter in some places to make it clear
what it's used for
modify MainWindow::openCaptureFile() so that a read filter can be set
when the file name is passed in cf_path, not only when it's chosen from
a file selection dialogue
don't display the read filter string in the filter toolbar
Change-Id: Ie8dc94cbd1ff7e61ce1e2a55518a28297daa5d51
Reviewed-on: https://code.wireshark.org/review/5446
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Diffstat (limited to 'ui')
-rw-r--r-- | ui/qt/main.cpp | 7 | ||||
-rw-r--r-- | ui/qt/main_window_slots.cpp | 47 |
2 files changed, 30 insertions, 24 deletions
diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp index 696a3dff71..183adf236a 100644 --- a/ui/qt/main.cpp +++ b/ui/qt/main.cpp @@ -502,7 +502,7 @@ int main(int argc, char *argv[]) char badopt; guint go_to_packet = 0; - QString dfilter; + QString dfilter, read_filter; cmdarg_err_init(wireshark_cmdarg_err, wireshark_cmdarg_err_cont); @@ -583,7 +583,6 @@ int main(int argc, char *argv[]) QString locale; QString cf_name; - QString display_filter; int optind_initial; unsigned int in_file_type = WTAP_TYPE_AUTO; @@ -1021,7 +1020,7 @@ int main(int argc, char *argv[]) cf_name = optarg; break; case 'R': /* Read file filter */ - /* Not supported yet */ + read_filter = QString(optarg); break; case 't': /* Time stamp type */ if (strcmp(optarg, "r") == 0) @@ -1348,7 +1347,7 @@ int main(int argc, char *argv[]) start_requested_stats(); // XXX The GTK+ UI does error checking here. - main_w->openCaptureFile(cf_name, display_filter, in_file_type); + main_w->openCaptureFile(cf_name, read_filter, in_file_type); if (!dfilter.isEmpty()) main_w->filterPackets(dfilter, false); if(go_to_packet != 0) { diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index caf635c3aa..de4c3970c3 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -109,18 +109,22 @@ const char *dfe_property_ = "display filter expression"; //TODO : Fix Translate -void MainWindow::openCaptureFile(QString& cf_path, QString& display_filter, unsigned int type) +void MainWindow::openCaptureFile(QString& cf_path, QString& read_filter, unsigned int type) { QString file_name = ""; dfilter_t *rfcode = NULL; int err; + gboolean name_param; + + // was a file name given as function parameter? + name_param = !cf_path.isEmpty(); testCaptureFileClose(false); for (;;) { if (cf_path.isEmpty()) { - CaptureFileDialog open_dlg(this, cap_file_, display_filter); + CaptureFileDialog open_dlg(this, cap_file_, read_filter); switch (prefs.gui_fileopen_style) { @@ -143,26 +147,33 @@ void MainWindow::openCaptureFile(QString& cf_path, QString& display_filter, unsi } if (open_dlg.open(file_name, type)) { - if (dfilter_compile(display_filter.toUtf8().constData(), &rfcode)) { - cf_set_rfcode(&cfile, rfcode); - } else { - /* Not valid. Tell the user, and go back and run the file - selection box again once they dismiss the alert. */ - //bad_dfilter_alert_box(top_level, display_filter->str); - QMessageBox::warning(this, tr("Invalid Display Filter"), - QString("The filter expression ") + - display_filter + - QString(" isn't a valid display filter. (") + - dfilter_error_msg + QString(")."), - QMessageBox::Ok); - continue; - } cf_path = file_name; } else { return; } } + if (dfilter_compile(read_filter.toUtf8().constData(), &rfcode)) { + cf_set_rfcode(&cfile, rfcode); + } else { + /* Not valid. Tell the user, and go back and run the file + selection box again once they dismiss the alert. */ + //bad_dfilter_alert_box(top_level, read_filter->str); + QMessageBox::warning(this, tr("Invalid Display Filter"), + QString("The filter expression ") + + read_filter + + QString(" isn't a valid display filter. (") + + dfilter_error_msg + QString(")."), + QMessageBox::Ok); + + if (!name_param) { + // go back to the selection dialogue only if the file + // was selected from this dialogue + cf_path.clear(); + continue; + } + } + /* Try to open the capture file. This closes the current file if it succeeds. */ cfile.window = this; if (cf_open(&cfile, cf_path.toUtf8().constData(), type, FALSE, &err) != CF_OK) { @@ -198,10 +209,6 @@ void MainWindow::openCaptureFile(QString& cf_path, QString& display_filter, unsi } // get_dirname overwrites its path. Hopefully this isn't a problem. wsApp->setLastOpenDir(get_dirname(cf_path.toUtf8().data())); - if(display_filter != NULL) - { - df_combo_box_->setEditText(display_filter); - } main_ui_->statusBar->showExpert(); } |