packet export: Add default file extension

Adds a default file extension when exporting packet dissection
in various formats:

text       -> txt
postscript -> ps
csv        -> csv
pdml       -> pdml
psml       -> psml
c arrays   -> c
json       -> json

Change-Id: Ie5d942a3c694abd8edf9df184f6e219d4b870a1b
Reviewed-on: https://code.wireshark.org/review/28490
Reviewed-by: Graham Bloice <graham.bloice@trihedral.com>
Petri-Dish: Graham Bloice <graham.bloice@trihedral.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
This commit is contained in:
Graham Bloice 2018-06-27 19:28:49 +01:00 committed by Pascal Quantin
parent 5d97cee7da
commit d8459d8930
2 changed files with 27 additions and 1 deletions

View File

@ -33,6 +33,19 @@
#include <epan/prefs.h>
#include "wireshark_application.h"
#if !defined(Q_OS_WIN)
static const QStringList export_extensions = QStringList()
<< ""
<< "txt"
<< ""
<< "csv"
<< "psml"
<< "pdml"
<< "c"
<< "json";
#endif
ExportDissectionDialog::ExportDissectionDialog(QWidget *parent, capture_file *cap_file, export_type_e export_type):
QFileDialog(parent),
export_type_(export_type),
@ -242,6 +255,7 @@ void ExportDissectionDialog::exportTypeChanged(QString name_filter)
}
checkValidity();
setDefaultSuffix(export_extensions[export_type_]);
}
void ExportDissectionDialog::checkValidity()

View File

@ -60,6 +60,18 @@ typedef enum {
_T("C Arrays (packet bytes) (*.c)\0") _T("*.c\0") \
_T("JSON (*.json)\0") _T("*.json\0")
static TCHAR *FILE_EXT_EXPORT[] =
{
_T(""), /* export type starts at 1 */
_T("txt"),
_T("ps"),
_T("csv"),
_T("psml"),
_T("pdml"),
_T("c"),
_T("json")
};
#define FILE_TYPES_RAW \
_T("Raw data (*.bin, *.dat, *.raw)\0") _T("*.bin;*.dat;*.raw\0") \
_T("All Files (") _T(ALL_FILES_WILDCARD) _T(")\0") _T(ALL_FILES_WILDCARD) _T("\0")
@ -645,7 +657,7 @@ win32_export_file(HWND h_wnd, capture_file *cf, export_type_e export_type) {
ofn->Flags = OFN_ENABLESIZING | OFN_ENABLETEMPLATE | OFN_EXPLORER |
OFN_NOCHANGEDIR | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY |
OFN_PATHMUSTEXIST | OFN_ENABLEHOOK | OFN_SHOWHELP;
ofn->lpstrDefExt = NULL;
ofn->lpstrDefExt = FILE_EXT_EXPORT[export_type];
ofn->lCustData = (LPARAM) cf;
ofn->lpfnHook = export_file_hook_proc;
ofn->lpTemplateName = _T("WIRESHARK_EXPORTFILENAME_TEMPLATE");