aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt
diff options
context:
space:
mode:
authorHadriel Kaplan <hadrielk@yahoo.com>2014-03-04 06:19:01 -0500
committerAlexis La Goutte <alexis.lagoutte@gmail.com>2014-03-05 18:38:05 +0000
commit041f844d7228d1ac41cf9b5e4629d7b7adec0e1f (patch)
tree12397039ed87f6584903638f7783b26e04311d84 /ui/qt
parentf1f06014c41b195b3695827319cf43f4e39becca (diff)
Add command-line arg for input file format for tshark/wireshark
Now that we have the ability to choose input file format type in the GUI, we might as well have it in the command-line too. Plus it would help me in test-stuies if we had a commandline. So I've added a '-X read_format:Foo' for this. Using just '-X read_format:', or with a bad name, will make it print out the full list (in tshark); just like the '-F' does for output file formats. Note: I am *not* putting in code for Win32 GUI, because I can't compile that and I wouldn't have even done the GTK one if I could compile Qt originally. (I don't think we need to add any more features to GTK or Win32, just Qt from now on, right?) Change-Id: I2fe6481d186f63bd2303b9e591edf397a2e14b64 Reviewed-on: https://code.wireshark.org/review/493 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Diffstat (limited to 'ui/qt')
-rw-r--r--ui/qt/main.cpp19
-rw-r--r--ui/qt/main_window.h2
-rw-r--r--ui/qt/main_window_slots.cpp3
3 files changed, 17 insertions, 7 deletions
diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp
index 8b42e94b82..73283608bc 100644
--- a/ui/qt/main.cpp
+++ b/ui/qt/main.cpp
@@ -481,6 +481,8 @@ int main(int argc, char *argv[])
QString locale;
QString *cf_name = NULL;
+ QString *display_filter = NULL;
+ unsigned int in_file_type = WTAP_TYPE_AUTO;
// In Qt 5, C strings are treated always as UTF-8 when converted to
// QStrings; in Qt 4, the codec must be set to make that happen
@@ -497,8 +499,8 @@ int main(int argc, char *argv[])
main_w->show();
// We may not need a queued connection here but it would seem to make sense
// to force the issue.
- main_w->connect(&ws_app, SIGNAL(openCaptureFile(QString&)),
- main_w, SLOT(openCaptureFile(QString&)));
+ main_w->connect(&ws_app, SIGNAL(openCaptureFile(QString&,QString&,unsigned int)),
+ main_w, SLOT(openCaptureFile(QString&,QString&,unsigned int)));
// XXX Should the remaining code be in WiresharkApplcation::WiresharkApplication?
#ifdef HAVE_LIBPCAP
@@ -872,6 +874,10 @@ int main(int argc, char *argv[])
register_all_tap_listeners();
+ if (ex_opt_count("read_format") > 0) {
+ in_file_type = open_info_name_to_type(ex_opt_get_next("read_format"));
+ }
+
splash_update(RA_PREFERENCES, NULL, NULL);
prefs_p = ws_app.readConfigurationFiles (&gdp_path, &dp_path);
@@ -990,8 +996,13 @@ int main(int argc, char *argv[])
wsApp->allSystemsGo();
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_INFO, "Wireshark is up and ready to go");
- if (cf_name != NULL) {
- main_w->openCaptureFile(*cf_name);
+ /* user could specify filename, or display filter, or both */
+ if (cf_name != NULL || display_filter != NULL) {
+ if (display_filter == NULL)
+ display_filter = new QString();
+ if (cf_name == NULL)
+ cf_name = new QString();
+ main_w->openCaptureFile(*cf_name, *display_filter, in_file_type);
}
g_main_loop_new(NULL, FALSE);
diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h
index 3274986aef..e56eb62ba0 100644
--- a/ui/qt/main_window.h
+++ b/ui/qt/main_window.h
@@ -164,7 +164,7 @@ signals:
public slots:
// in main_window_slots.cpp
- void openCaptureFile(QString& cf_path = *new QString(), QString &display_filter = *new QString());
+ void openCaptureFile(QString& cf_path = *new QString(), QString &display_filter = *new QString(), const unsigned int type = WTAP_TYPE_AUTO);
void filterPackets(QString& new_filter = *new QString(), bool force = false);
void updateForUnsavedChanges();
void layoutPanes();
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp
index c12603180b..9e51feebae 100644
--- a/ui/qt/main_window_slots.cpp
+++ b/ui/qt/main_window_slots.cpp
@@ -95,12 +95,11 @@
const char *dfe_property_ = "display filter expression"; //TODO : Fix Translate
-void MainWindow::openCaptureFile(QString &cf_path, QString &display_filter)
+void MainWindow::openCaptureFile(QString &cf_path, QString &display_filter, unsigned int type)
{
QString file_name = "";
dfilter_t *rfcode = NULL;
int err;
- unsigned int type = WTAP_TYPE_AUTO;
testCaptureFileClose(false);