summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/gtk/capture_file_dlg.c31
-rw-r--r--ui/gtk/drag_and_drop.c4
-rw-r--r--ui/gtk/file_import_dlg.c2
-rw-r--r--ui/gtk/fileset_dlg.c2
-rw-r--r--ui/gtk/funnel_stat.c2
-rw-r--r--ui/gtk/main.c4
-rw-r--r--ui/gtk/main_menubar.c4
-rw-r--r--ui/qt/capture_file_dialog.cpp18
-rw-r--r--ui/qt/capture_file_dialog.h5
-rw-r--r--ui/qt/main.cpp2
-rw-r--r--ui/qt/main_window.cpp2
-rw-r--r--ui/qt/main_window_slots.cpp5
-rw-r--r--ui/tap_export_pdu.c2
-rw-r--r--ui/win32/file_dlg_win32.c2
14 files changed, 63 insertions, 22 deletions
diff --git a/ui/gtk/capture_file_dlg.c b/ui/gtk/capture_file_dlg.c
index 9e852629f2..e79e8deced 100644
--- a/ui/gtk/capture_file_dlg.c
+++ b/ui/gtk/capture_file_dlg.c
@@ -139,7 +139,7 @@ preview_set_filename(GtkWidget *prev, const gchar *cf_name)
return NULL;
}
- wth = wtap_open_offline(cf_name, &err, &err_info, TRUE);
+ wth = wtap_open_offline(cf_name, WTAP_TYPE_AUTO, &err, &err_info, TRUE);
if (wth == NULL) {
label = (GtkWidget *)g_object_get_data(G_OBJECT(prev), PREVIEW_FORMAT_KEY);
if (err == WTAP_ERR_FILE_UNKNOWN_FORMAT) {
@@ -474,11 +474,14 @@ preview_new(void)
/* Open a file */
static gboolean
-gtk_open_file(GtkWidget *w, GString *file_name, GString *display_filter)
+gtk_open_file(GtkWidget *w, GString *file_name, gint *type, GString *display_filter)
{
GtkWidget *file_open_w;
GtkWidget *main_hb, *main_vb, *filter_hbox, *filter_bt, *filter_te;
GtkWidget *m_resolv_cb, *n_resolv_cb, *t_resolv_cb, *e_resolv_cb, *prev;
+ GtkWidget *format_type_co;
+ GtkCellRenderer *cell;
+ gint i;
/* No Apply button, and "OK" just sets our text widget, it doesn't
activate it (i.e., it doesn't cause us to try to open the file). */
@@ -542,6 +545,21 @@ gtk_open_file(GtkWidget *w, GString *file_name, GString *display_filter)
gtk_box_pack_start(GTK_BOX(main_hb), main_vb, FALSE, FALSE, 0);
gtk_widget_show(main_vb);
+ format_type_co = gtk_combo_box_text_new();
+ cell = gtk_cell_renderer_text_new();
+ gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(format_type_co), cell, TRUE);
+
+ gtk_widget_set_tooltip_text(format_type_co, "Format type of capture file");
+ gtk_box_pack_start(GTK_BOX(main_vb), format_type_co, FALSE, FALSE, 0);
+
+ gtk_combo_box_text_append_text((GtkComboBoxText *) format_type_co, (const gchar *) "Automatic");
+ for (i = 0; open_routines[i].name != NULL; i += 1) {
+ gtk_combo_box_text_append_text((GtkComboBoxText *) format_type_co, open_routines[i].name);
+ }
+
+ gtk_combo_box_set_active((GtkComboBox *) format_type_co, 0);
+ gtk_widget_show(format_type_co);
+
/* Filter row */
filter_hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1, FALSE);
gtk_container_set_border_width(GTK_CONTAINER(filter_hbox), 0);
@@ -639,6 +657,8 @@ gtk_open_file(GtkWidget *w, GString *file_name, GString *display_filter)
else
gbl_resolv_flags.use_external_net_name_resolver = FALSE;
+ *type = gtk_combo_box_get_active((GtkComboBox *) format_type_co);
+
/* We've crossed the Rubicon; get rid of the file selection box. */
window_destroy(GTK_WIDGET(file_open_w));
@@ -666,6 +686,7 @@ file_open_cmd(capture_file *cf, GtkWidget *w _U_)
GString *display_filter = g_string_new("");
dfilter_t *rfcode = NULL;
int err;
+ int type = WTAP_TYPE_AUTO;
/*
* Loop until the user either selects a file or gives up.
@@ -674,7 +695,7 @@ file_open_cmd(capture_file *cf, GtkWidget *w _U_)
#ifdef USE_WIN32_FILE_DIALOGS
if (win32_open_file(GDK_WINDOW_HWND(gtk_widget_get_window(top_level)), file_name, display_filter)) {
#else /* USE_WIN32_FILE_DIALOGS */
- if (gtk_open_file(top_level, file_name, display_filter)) {
+ if (gtk_open_file(top_level, file_name, &type, display_filter)) {
#endif /* USE_WIN32_FILE_DIALOGS */
/* Only close the old file now that we know we want to open another one. */
@@ -690,7 +711,7 @@ file_open_cmd(capture_file *cf, GtkWidget *w _U_)
}
/* Try to open the capture file. */
- if (cf_open(&cfile, file_name->str, FALSE, &err) != CF_OK) {
+ if (cf_open(&cfile, file_name->str, type, FALSE, &err) != CF_OK) {
/* We couldn't open it; don't dismiss the open dialog box,
just leave it around so that the user can, after they
dismiss the alert box popped up for the open error,
@@ -971,7 +992,7 @@ file_merge_cmd(GtkWidget *w _U_)
cf_close(&cfile);
/* Try to open the merged capture file. */
- if (cf_open(&cfile, tmpname, TRUE /* temporary file */, &err) != CF_OK) {
+ if (cf_open(&cfile, tmpname, WTAP_TYPE_AUTO, TRUE /* temporary file */, &err) != CF_OK) {
/* We couldn't open it; fail. */
if (rfcode != NULL)
dfilter_free(rfcode);
diff --git a/ui/gtk/drag_and_drop.c b/ui/gtk/drag_and_drop.c
index 93e438a698..78db218385 100644
--- a/ui/gtk/drag_and_drop.c
+++ b/ui/gtk/drag_and_drop.c
@@ -204,7 +204,7 @@ dnd_open_file_cmd(gchar *cf_names_freeme)
if (in_file_count == 1) {
/* open and read the capture file (this will close an existing file) */
- if (cf_open(&cfile, in_filenames[0], FALSE, &err) == CF_OK) {
+ if (cf_open(&cfile, in_filenames[0], WTAP_TYPE_AUTO, FALSE, &err) == CF_OK) {
/* XXX - add this to the menu if the read fails? */
cf_read(&cfile, FALSE);
add_menu_recent_capture_file(in_filenames[0]);
@@ -219,7 +219,7 @@ dnd_open_file_cmd(gchar *cf_names_freeme)
/* Merge succeeded; close the currently-open file and try
to open the merged capture file. */
cf_close(&cfile);
- if (cf_open(&cfile, tmpname, TRUE /* temporary file */, &err) == CF_OK) {
+ if (cf_open(&cfile, tmpname, WTAP_TYPE_AUTO, TRUE /* temporary file */, &err) == CF_OK) {
g_free(tmpname);
cf_read(&cfile, FALSE);
} else {
diff --git a/ui/gtk/file_import_dlg.c b/ui/gtk/file_import_dlg.c
index 5ad8a80ce5..a59ac082c2 100644
--- a/ui/gtk/file_import_dlg.c
+++ b/ui/gtk/file_import_dlg.c
@@ -541,7 +541,7 @@ file_import_open(text_import_info_t *info)
write_failure_alert_box(capfile_name, err);
}
- if (cf_open(&cfile, capfile_name, TRUE /* temporary file */, &err) != CF_OK) {
+ if (cf_open(&cfile, capfile_name, WTAP_TYPE_AUTO, TRUE /* temporary file */, &err) != CF_OK) {
open_failure_alert_box(capfile_name, err, FALSE);
goto end;
}
diff --git a/ui/gtk/fileset_dlg.c b/ui/gtk/fileset_dlg.c
index fbfa866772..3123c226c4 100644
--- a/ui/gtk/fileset_dlg.c
+++ b/ui/gtk/fileset_dlg.c
@@ -79,7 +79,7 @@ fs_open_entry(fileset_entry *entry)
/* close the old and open the new file */
cf_close(&cfile);
- if (cf_open(&cfile, fname, FALSE, &err) == CF_OK) {
+ if (cf_open(&cfile, fname, WTAP_TYPE_AUTO, FALSE, &err) == CF_OK) {
cf_read(&cfile, FALSE);
}
diff --git a/ui/gtk/funnel_stat.c b/ui/gtk/funnel_stat.c
index cc0cde0026..313a38a1a5 100644
--- a/ui/gtk/funnel_stat.c
+++ b/ui/gtk/funnel_stat.c
@@ -518,7 +518,7 @@ static gboolean funnel_open_file(const char* fname, const char* filter, const ch
}
- if (cf_open(&cfile, fname, FALSE, &err) != CF_OK) {
+ if (cf_open(&cfile, fname, WTAP_TYPE_AUTO, FALSE, &err) != CF_OK) {
*err_str = g_strerror(err);
if (rfcode != NULL) dfilter_free(rfcode);
return FALSE;
diff --git a/ui/gtk/main.c b/ui/gtk/main.c
index a5e706dc9d..8748f0500f 100644
--- a/ui/gtk/main.c
+++ b/ui/gtk/main.c
@@ -2523,6 +2523,8 @@ main(int argc, char *argv[])
g_free(init_progfile_dir_error);
}
+ init_open_routines();
+
#ifdef HAVE_PLUGINS
/* Register all the plugin types we have. */
epan_register_plugin_types(); /* Types known to libwireshark */
@@ -3088,7 +3090,7 @@ main(int argc, char *argv[])
}
}
if (!rfilter_parse_failed) {
- if (cf_open(&cfile, cf_name, FALSE, &err) == CF_OK) {
+ if (cf_open(&cfile, cf_name, WTAP_TYPE_AUTO, FALSE, &err) == CF_OK) {
/* "cf_open()" succeeded, so it closed the previous
capture file, and thus destroyed any previous read filter
attached to "cf". */
diff --git a/ui/gtk/main_menubar.c b/ui/gtk/main_menubar.c
index e8b119e3b8..3d5f681001 100644
--- a/ui/gtk/main_menubar.c
+++ b/ui/gtk/main_menubar.c
@@ -4323,7 +4323,7 @@ menu_open_filename(gchar *cf_name)
recent_files_list = (GList *)g_object_get_data(G_OBJECT(submenu_recent_files), "recent-files-list");
/* XXX: ask user to remove item, it's maybe only a temporary problem */
/* open and read the capture file (this will close an existing file) */
- if (cf_open(&cfile, cf_name, FALSE, &err) == CF_OK) {
+ if (cf_open(&cfile, cf_name, WTAP_TYPE_AUTO, FALSE, &err) == CF_OK) {
cf_read(&cfile, FALSE);
}else{
recent_files_list = remove_present_file_name(recent_files_list, cf_name);
@@ -4351,7 +4351,7 @@ menu_open_recent_file_cmd(GtkAction *action)
#endif
/* open and read the capture file (this will close an existing file) */
- if (cf_open(&cfile, cf_name, FALSE, &err) == CF_OK) {
+ if (cf_open(&cfile, cf_name, WTAP_TYPE_AUTO, FALSE, &err) == CF_OK) {
cf_read(&cfile, FALSE);
} else {
submenu_recent_files = gtk_ui_manager_get_widget(ui_manager_main_menubar, MENU_RECENT_FILES_PATH);
diff --git a/ui/qt/capture_file_dialog.cpp b/ui/qt/capture_file_dialog.cpp
index 68cd033e1d..bb78faf3fb 100644
--- a/ui/qt/capture_file_dialog.cpp
+++ b/ui/qt/capture_file_dialog.cpp
@@ -231,7 +231,7 @@ bool CaptureFileDialog::isCompressed() {
return compressed_;
}
-int CaptureFileDialog::open(QString &file_name) {
+int CaptureFileDialog::open(QString &file_name, unsigned int &type) {
GString *fname = g_string_new(file_name.toUtf8().constData());
GString *dfilter = g_string_new(display_filter_.toUtf8().constData());
gboolean wof_status;
@@ -239,6 +239,7 @@ int CaptureFileDialog::open(QString &file_name) {
// XXX Add a widget->HWND routine to qt_ui_utils and use it instead.
wof_status = win32_open_file((HWND)parentWidget()->effectiveWinId(), fname, dfilter);
file_name = fname->str;
+ type = format_type_.currentIndex();
display_filter_ = dfilter->str;
g_string_free(fname, TRUE);
@@ -499,6 +500,15 @@ void CaptureFileDialog::addDisplayFilterEdit() {
last_row_++;
}
+void CaptureFileDialog::addFormatTypeSelector(QVBoxLayout &v_box) {
+ format_type_.addItem("Automatic");
+ for (int i = 0; open_routines[i].name != NULL; i += 1) {
+ format_type_.addItem(open_routines[i].name);
+ }
+
+ v_box.addWidget(&format_type_, 0, Qt::AlignTop);
+}
+
void CaptureFileDialog::addResolutionControls(QVBoxLayout &v_box) {
mac_res_.setText(tr("&MAC name resolution"));
mac_res_.setChecked(gbl_resolv_flags.mac_name);
@@ -548,11 +558,12 @@ QDialogButtonBox *CaptureFileDialog::addHelpButton(topic_action_e help_topic)
return button_box;
}
-int CaptureFileDialog::open(QString &file_name) {
+int CaptureFileDialog::open(QString &file_name, unsigned int &type) {
setWindowTitle(tr("Wireshark: Open Capture File"));
setNameFilters(buildFileOpenTypeList());
setFileMode(QFileDialog::ExistingFile);
+ addFormatTypeSelector(left_v_box_);
addDisplayFilterEdit();
addResolutionControls(left_v_box_);
addPreview(right_v_box_);
@@ -569,6 +580,7 @@ int CaptureFileDialog::open(QString &file_name) {
if (QFileDialog::exec() && selectedFiles().length() > 0) {
file_name = selectedFiles()[0];
+ type = format_type_.currentIndex();
display_filter_.append(display_filter_edit_->text());
gbl_resolv_flags.mac_name = mac_res_.isChecked();
@@ -761,7 +773,7 @@ void CaptureFileDialog::preview(const QString & path)
return;
}
- wth = wtap_open_offline(path.toUtf8().data(), &err, &err_info, TRUE);
+ wth = wtap_open_offline(path.toUtf8().data(), WTAP_TYPE_AUTO, &err, &err_info, TRUE);
if (wth == NULL) {
if(err == WTAP_ERR_FILE_UNKNOWN_FORMAT) {
preview_format_.setText(tr("unknown file format"));
diff --git a/ui/qt/capture_file_dialog.h b/ui/qt/capture_file_dialog.h
index 54f9e1d341..becaed6a58 100644
--- a/ui/qt/capture_file_dialog.h
+++ b/ui/qt/capture_file_dialog.h
@@ -41,6 +41,7 @@
#include <QRadioButton>
#include <QCheckBox>
#include <QDialogButtonBox>
+#include <QComboBox>
class CaptureFileDialog : public QFileDialog
{
@@ -87,6 +88,7 @@ private:
#if !defined(Q_OS_WIN)
void addMergeControls(QVBoxLayout &v_box);
+ void addFormatTypeSelector(QVBoxLayout &v_box);
void addDisplayFilterEdit();
void addPreview(QVBoxLayout &v_box);
QString fileExtensionType(int et, bool extension_globs = true);
@@ -110,6 +112,7 @@ private:
QRadioButton merge_chrono_;
QRadioButton merge_append_;
+ QComboBox format_type_;
QHash<QString, int>type_hash_;
void addResolutionControls(QVBoxLayout &v_box);
@@ -143,7 +146,7 @@ signals:
public slots:
int exec();
- int open(QString &file_name);
+ int open(QString &file_name, unsigned int &type);
check_savability_t saveAs(QString &file_name, bool must_support_comments);
check_savability_t exportSelectedPackets(QString &file_name, packet_range_t *range);
int merge(QString &file_name);
diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp
index 33c3f660f9..eb9cb47524 100644
--- a/ui/qt/main.cpp
+++ b/ui/qt/main.cpp
@@ -832,6 +832,8 @@ int main(int argc, char *argv[])
init_report_err(failure_alert_box, open_failure_alert_box,
read_failure_alert_box, write_failure_alert_box);
+ init_open_routines();
+
#ifdef HAVE_PLUGINS
/* Register all the plugin types we have. */
epan_register_plugin_types(); /* Types known to libwireshark */
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp
index 165bfc6aec..136ad37c1c 100644
--- a/ui/qt/main_window.cpp
+++ b/ui/qt/main_window.cpp
@@ -643,7 +643,7 @@ void MainWindow::mergeCaptureFile()
/* Try to open the merged capture file. */
cfile.window = this;
- if (cf_open(&cfile, tmpname, TRUE /* temporary file */, &err) != CF_OK) {
+ if (cf_open(&cfile, tmpname, WTAP_TYPE_AUTO, TRUE /* temporary file */, &err) != CF_OK) {
/* We couldn't open it; fail. */
cfile.window = NULL;
if (rfcode != NULL)
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp
index 0d40c33855..0fc02c7e4e 100644
--- a/ui/qt/main_window_slots.cpp
+++ b/ui/qt/main_window_slots.cpp
@@ -102,6 +102,7 @@ void MainWindow::openCaptureFile(QString &cf_path, QString &display_filter)
QString file_name = "";
dfilter_t *rfcode = NULL;
int err;
+ unsigned int type;
testCaptureFileClose(false);
@@ -130,7 +131,7 @@ void MainWindow::openCaptureFile(QString &cf_path, QString &display_filter)
break;
}
- if (open_dlg.open(file_name)) {
+ if (open_dlg.open(file_name, type)) {
if (dfilter_compile(display_filter.toUtf8().constData(), &rfcode)) {
cf_set_rfcode(&cfile, rfcode);
} else {
@@ -153,7 +154,7 @@ void MainWindow::openCaptureFile(QString &cf_path, QString &display_filter)
/* Try to open the capture file. */
cfile.window = this;
- if (cf_open(&cfile, cf_path.toUtf8().constData(), FALSE, &err) != CF_OK) {
+ if (cf_open(&cfile, cf_path.toUtf8().constData(), type, FALSE, &err) != CF_OK) {
/* We couldn't open it; don't dismiss the open dialog box,
just leave it around so that the user can, after they
dismiss the alert box popped up for the open error,
diff --git a/ui/tap_export_pdu.c b/ui/tap_export_pdu.c
index 9362e6765e..1a7a66c074 100644
--- a/ui/tap_export_pdu.c
+++ b/ui/tap_export_pdu.c
@@ -162,7 +162,7 @@ exp_pdu_file_open(exp_pdu_t *exp_pdu_tap_data)
remove_tap_listener(exp_pdu_tap_data);
- if (cf_open(&cfile, capfile_name, TRUE /* temporary file */, &err) != CF_OK) {
+ if (cf_open(&cfile, capfile_name, WTAP_TYPE_AUTO, TRUE /* temporary file */, &err) != CF_OK) {
open_failure_alert_box(capfile_name, err, FALSE);
goto end;
}
diff --git a/ui/win32/file_dlg_win32.c b/ui/win32/file_dlg_win32.c
index b4d3996ea2..d6bc34825c 100644
--- a/ui/win32/file_dlg_win32.c
+++ b/ui/win32/file_dlg_win32.c
@@ -1157,7 +1157,7 @@ preview_set_file_info(HWND of_hwnd, gchar *preview_file) {
return FALSE;
}
- wth = wtap_open_offline(preview_file, &err, &err_info, TRUE);
+ wth = wtap_open_offline(preview_file, WTAP_TYPE_AUTO, &err, &err_info, TRUE);
if (cur_ctrl && wth == NULL) {
if(err == WTAP_ERR_FILE_UNKNOWN_FORMAT) {
SetWindowText(cur_ctrl, _T("unknown file format"));