diff options
author | Gerald Combs <gerald@wireshark.org> | 2016-06-30 14:55:19 -0700 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2016-07-01 02:10:22 +0000 |
commit | 5cf7fcdf0f62cf0d8617428141a26e6f280a45d0 (patch) | |
tree | 104b76a624fe278c5db96591e97d26912f64f5ea | |
parent | f860e8de525d721d6678896fc9ef415ea68e2ead (diff) |
Qt+Gtk: Fix the -t command line flag.
Add the time format to commandline_param_info_t and apply it when we've
finished application initialization.
Bug: 12489
Change-Id: Ice626198a610567e945a8e53c0c1093797e8208e
Reviewed-on: https://code.wireshark.org/review/16232
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r-- | ui/commandline.c | 21 | ||||
-rw-r--r-- | ui/commandline.h | 1 | ||||
-rw-r--r-- | ui/gtk/main_menubar.c | 10 | ||||
-rw-r--r-- | ui/qt/main_window.cpp | 1 | ||||
-rw-r--r-- | ui/qt/main_window.h | 1 | ||||
-rw-r--r-- | ui/qt/main_window_slots.cpp | 15 | ||||
-rw-r--r-- | ui/qt/wireshark_application.cpp | 2 | ||||
-rw-r--r-- | wireshark-qt.cpp | 1 |
8 files changed, 37 insertions, 15 deletions
diff --git a/ui/commandline.c b/ui/commandline.c index c3bb8ddac3..e936a327b9 100644 --- a/ui/commandline.c +++ b/ui/commandline.c @@ -387,6 +387,7 @@ void commandline_other_options(int argc, char *argv[], gboolean opt_reset) global_commandline_info.cf_name = NULL; global_commandline_info.rfilter = NULL; global_commandline_info.dfilter = NULL; + global_commandline_info.time_format = TS_NOT_SET; #ifdef HAVE_LIBPCAP global_commandline_info.start_capture = FALSE; global_commandline_info.list_link_layer_types = FALSE; @@ -537,25 +538,25 @@ void commandline_other_options(int argc, char *argv[], gboolean opt_reset) break; case 't': /* Time stamp type */ if (strcmp(optarg, "r") == 0) - timestamp_set_type(TS_RELATIVE); + global_commandline_info.time_format = TS_RELATIVE; else if (strcmp(optarg, "a") == 0) - timestamp_set_type(TS_ABSOLUTE); + global_commandline_info.time_format = TS_ABSOLUTE; else if (strcmp(optarg, "ad") == 0) - timestamp_set_type(TS_ABSOLUTE_WITH_YMD); + global_commandline_info.time_format = TS_ABSOLUTE_WITH_YMD; else if (strcmp(optarg, "adoy") == 0) - timestamp_set_type(TS_ABSOLUTE_WITH_YDOY); + global_commandline_info.time_format = TS_ABSOLUTE_WITH_YDOY; else if (strcmp(optarg, "d") == 0) - timestamp_set_type(TS_DELTA); + global_commandline_info.time_format = TS_DELTA; else if (strcmp(optarg, "dd") == 0) - timestamp_set_type(TS_DELTA_DIS); + global_commandline_info.time_format = TS_DELTA_DIS; else if (strcmp(optarg, "e") == 0) - timestamp_set_type(TS_EPOCH); + global_commandline_info.time_format = TS_EPOCH; else if (strcmp(optarg, "u") == 0) - timestamp_set_type(TS_UTC); + global_commandline_info.time_format = TS_UTC; else if (strcmp(optarg, "ud") == 0) - timestamp_set_type(TS_UTC_WITH_YMD); + global_commandline_info.time_format = TS_UTC_WITH_YMD; else if (strcmp(optarg, "udoy") == 0) - timestamp_set_type(TS_UTC_WITH_YDOY); + global_commandline_info.time_format = TS_UTC_WITH_YDOY; else { cmdarg_err("Invalid time stamp type \"%s\"", optarg); cmdarg_err_cont("It must be \"a\" for absolute, \"ad\" for absolute with YYYY-MM-DD date,"); diff --git a/ui/commandline.h b/ui/commandline.h index 0e14c60521..9d770fb678 100644 --- a/ui/commandline.h +++ b/ui/commandline.h @@ -47,6 +47,7 @@ typedef struct commandline_param_info gchar* cf_name; gchar* rfilter; gchar* dfilter; + ts_type time_format; GSList *disable_protocol_slist; GSList *enable_heur_slist; GSList *disable_heur_slist; diff --git a/ui/gtk/main_menubar.c b/ui/gtk/main_menubar.c index 9ad082c547..3b6035e519 100644 --- a/ui/gtk/main_menubar.c +++ b/ui/gtk/main_menubar.c @@ -38,6 +38,7 @@ #include "globals.h" #include <epan/color_filters.h> +#include "ui/commandline.h" #include "ui/main_statusbar.h" #include "ui/preference_utils.h" #include "ui/recent.h" @@ -3173,6 +3174,9 @@ menus_init(void) G_N_ELEMENTS(main_menu_bar_toggle_action_entries), /* the number of entries */ NULL); /* data to pass to the action callbacks */ + if (global_commandline_info.time_format != TS_NOT_SET) { + recent.gui_time_format = global_commandline_info.time_format; + } gtk_action_group_add_radio_actions (main_menu_bar_action_group, /* the action group */ main_menu_bar_radio_view_time_entries, /* an array of radio action descriptions */ G_N_ELEMENTS(main_menu_bar_radio_view_time_entries), /* the number of entries */ @@ -4248,9 +4252,9 @@ menu_recent_read_finished(void) #endif main_widgets_rearrange(); - /* don't change the time format, if we had a command line value */ - if (timestamp_get_type() != TS_NOT_SET) { - recent.gui_time_format = timestamp_get_type(); + /* Update the time format if we had a command line value. */ + if (global_commandline_info.time_format != TS_NOT_SET) { + recent.gui_time_format = global_commandline_info.time_format; } /* XXX Fix me */ diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp index d7de835af5..fb43642047 100644 --- a/ui/qt/main_window.cpp +++ b/ui/qt/main_window.cpp @@ -338,6 +338,7 @@ MainWindow::MainWindow(QWidget *parent) : //Otherwise unexpected problems may occur setFeaturesEnabled(false); connect(wsApp, SIGNAL(appInitialized()), this, SLOT(setFeaturesEnabled())); + connect(wsApp, SIGNAL(appInitialized()), this, SLOT(applyGlobalCommandLineOptions())); connect(wsApp, SIGNAL(appInitialized()), this, SLOT(zoomText())); connect(wsApp, SIGNAL(appInitialized()), this, SLOT(initViewColorizeMenu())); connect(wsApp, SIGNAL(appInitialized()), this, SLOT(addStatsPluginsToMenu())); diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h index 331afd4742..bc333dc9ec 100644 --- a/ui/qt/main_window.h +++ b/ui/qt/main_window.h @@ -324,6 +324,7 @@ private slots: void startInterfaceCapture(bool valid, const QString capture_filter); + void applyGlobalCommandLineOptions(); void setFeaturesEnabled(bool enabled = true); void on_actionDisplayFilterExpression_triggered(); diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index fcd3774daa..7d375c9b6a 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -494,6 +494,7 @@ void MainWindow::updateRecentActions() foreach (QAction* tpa, tp_actions.keys()) { if (recent.gui_time_precision == tp_actions[tpa]) { tpa->setChecked(true); + break; } } main_ui_->actionViewTimeDisplaySecondsWithHoursAndMinutes->setChecked(recent.gui_seconds_format == TS_SECONDS_HOUR_MIN_SEC); @@ -1378,6 +1379,20 @@ void MainWindow::startInterfaceCapture(bool valid, const QString capture_filter) startCapture(); } +void MainWindow::applyGlobalCommandLineOptions() +{ + if (global_commandline_info.time_format != TS_NOT_SET) { + foreach (QAction* tda, td_actions.keys()) { + if (global_commandline_info.time_format == td_actions[tda]) { + tda->setChecked(true); + recent.gui_time_format = global_commandline_info.time_format; + timestamp_set_type(global_commandline_info.time_format); + break; + } + } + } +} + void MainWindow::redissectPackets() { if (capture_file_.capFile()) { diff --git a/ui/qt/wireshark_application.cpp b/ui/qt/wireshark_application.cpp index 907f99d022..cf4f91dac5 100644 --- a/ui/qt/wireshark_application.cpp +++ b/ui/qt/wireshark_application.cpp @@ -360,7 +360,7 @@ void WiresharkApplication::setConfigurationProfile(const gchar *profile_name) test_for_directory(recent.gui_fileopen_remembered_dir) == EISDIR) { set_last_open_dir(recent.gui_fileopen_remembered_dir); } - timestamp_set_type (recent.gui_time_format); + timestamp_set_type(recent.gui_time_format); timestamp_set_precision(recent.gui_time_precision); timestamp_set_seconds_type (recent.gui_seconds_format); packet_list_enable_color(recent.packet_list_colorize); diff --git a/wireshark-qt.cpp b/wireshark-qt.cpp index 6acfee27a1..7bdf9466ee 100644 --- a/wireshark-qt.cpp +++ b/wireshark-qt.cpp @@ -606,7 +606,6 @@ int main(int argc, char *argv[]) * https://code.wireshark.org/review/gitweb?p=wireshark.git;a=commit;h=9e277ae6154fd04bf6a0a34ec5655a73e5a736a3 */ - // XXX Is there a better place to set the timestamp format & precision? timestamp_set_type(recent.gui_time_format); timestamp_set_precision(recent.gui_time_precision); timestamp_set_seconds_type (recent.gui_seconds_format); |