Qt: Fix export of dissection

Exporting dissected bytes did not consider the
selection of packets on Windows, if multiple
packets had been selected

Bug: 16516
Change-Id: I9d914fe1fed22f842d73caea397a3f37ffc0d523
Reviewed-on: https://code.wireshark.org/review/36958
Reviewed-by: Roland Knall <rknall@gmail.com>
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
Roland Knall 2020-04-27 17:24:05 +02:00 committed by Gerald Combs
parent ca4cc6a34f
commit 7fcac9c955
4 changed files with 14 additions and 8 deletions

View File

@ -52,6 +52,8 @@ ExportDissectionDialog::ExportDissectionDialog(QWidget *parent, capture_file *ca
cap_file_(cap_file)
#if !defined(Q_OS_WIN)
, save_bt_(NULL)
#else
, sel_range_(selRange)
#endif /* Q_OS_WIN */
{
setWindowTitle(wsApp->windowTitleString(tr("Export Packet Dissections")));
@ -162,7 +164,7 @@ void ExportDissectionDialog::show()
WiresharkFileDialog::show();
}
#else // Q_OS_WIN
win32_export_file((HWND)parentWidget()->effectiveWinId(), windowTitle().toStdWString().c_str(), cap_file_, export_type_);
win32_export_file((HWND)parentWidget()->effectiveWinId(), windowTitle().toStdWString().c_str(), cap_file_, export_type_, sel_range_.toStdString().c_str());
#endif // Q_OS_WIN
}

View File

@ -58,6 +58,8 @@ private:
PacketFormatGroupBox packet_format_group_box_;
QPushButton *save_bt_;
#else
QString sel_range_;
#endif // Q_OS_WIN
};

View File

@ -467,7 +467,7 @@ win32_merge_file (HWND h_wnd, const wchar_t *title, GString *file_name, GString
}
void
win32_export_file(HWND h_wnd, const wchar_t *title, capture_file *cf, export_type_e export_type) {
win32_export_file(HWND h_wnd, const wchar_t *title, capture_file *cf, export_type_e export_type, const gchar *range_) {
OPENFILENAME *ofn;
TCHAR file_name[MAX_PATH] = _T("");
char *dirname;
@ -501,6 +501,12 @@ win32_export_file(HWND h_wnd, const wchar_t *title, capture_file *cf, export_typ
/* Fill in our print (and export) args */
/* init the printing range */
packet_range_init(&print_args.range, cf);
if (strlen(range_) > 0)
packet_range_convert_selection_str(&print_args.range, range_);
print_args.format = PR_FMT_TEXT;
print_args.to_file = TRUE;
print_args.cmd = NULL;
@ -1705,11 +1711,6 @@ export_file_hook_proc(HWND ef_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) {
switch(msg) {
case WM_INITDIALOG: {
OPENFILENAME *ofnp = (OPENFILENAME *) l_param;
capture_file *cf = (capture_file *) ofnp->lCustData;
/* init the printing range */
packet_range_init(&print_args.range, cf);
/* default to displayed packets */
print_args.range.process_filtered = TRUE;
range_handle_wm_initdialog(ef_hwnd, &print_args.range);

View File

@ -101,8 +101,9 @@ gboolean win32_merge_file (HWND h_wnd, const wchar_t *title, GString *file_name,
* @param h_wnd HWND of the parent window.
* @param cf capture_file Structure for the capture to be saved
* @param export_type The export type.
* @param range a possible range
*/
void win32_export_file (HWND h_wnd, const wchar_t *title, capture_file *cf, export_type_e export_type);
void win32_export_file (HWND h_wnd, const wchar_t *title, capture_file *cf, export_type_e export_type, const gchar *range);
/* Open dialog defines */
/* #define EWFD_FILTER_BTN 1000 */