UI: Remove Win32 file dialog stuff specific to GTK

Remove "Export SSL Session Keys", "Import/Export Color Filters" and
"Export Raw Bytes" dialogs. These were only used by GTK+ as Qt has its
own implementation.

Change-Id: I0520a0f6e35d0f8a55c58e77f89c5229393c2b23
Reviewed-on: https://code.wireshark.org/review/30559
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Peter Wu 2018-11-09 18:04:05 +01:00 committed by Anders Broman
parent c0aad886ba
commit b0582230f3
5 changed files with 0 additions and 393 deletions

View File

@ -144,18 +144,3 @@ FONT 8, "MS Shell Dlg"
CONTROL "Each packet on a new page", EWFD_PKT_NEW_PAGE_CB, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 350, 80, 106, 10
}
WIRESHARK_EXPORTRAWFILENAME_TEMPLATE DIALOGEX 0, 0, 200, 18
STYLE WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | DS_3DLOOK | DS_CONTROL
FONT 8, "MS Shell Dlg"
{
LTEXT "-", EWFD_EXPORTRAW_ST, 5, 5, 180, 8
}
WIRESHARK_EXPORTSSLKEYSFILENAME_TEMPLATE DIALOGEX 0, 0, 200, 18
STYLE WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | DS_3DLOOK | DS_CONTROL
FONT 8, "MS Shell Dlg"
{
LTEXT "-", EWFD_EXPORTSSLKEYS_ST, 5, 5, 180, 8
}

View File

@ -277,7 +277,6 @@ topic_action_url(topic_action_e action)
url = user_guide_url("ChIOExportSection.html");
break;
case(HELP_EXPORT_BYTES_DIALOG):
case(HELP_EXPORT_BYTES_WIN32_DIALOG):
url = user_guide_url("ChIOExportSection.html#ChIOExportSelectedDialog");
break;
case(HELP_EXPORT_OBJECT_LIST):

View File

@ -97,7 +97,6 @@ typedef enum {
HELP_IMPORT_DIALOG,
HELP_SAVE_DIALOG,
HELP_EXPORT_FILE_WIN32_DIALOG,
HELP_EXPORT_BYTES_WIN32_DIALOG,
HELP_OPEN_WIN32_DIALOG,
HELP_MERGE_WIN32_DIALOG,
HELP_SAVE_WIN32_DIALOG,

View File

@ -28,13 +28,10 @@
#include "wsutil/filesystem.h"
#include "epan/prefs.h"
#include "epan/color_filters.h"
#include "ui/alert_box.h"
#include "ui/help_url.h"
#include "ui/last_open_dir.h"
#include "ui/simple_dialog.h"
#include "ui/ssl_key_export.h"
#include "ui/util.h"
#include "ui/ws_ui_util.h"
#include "ui/all_files_wildcard.h"
@ -72,32 +69,12 @@ static TCHAR *FILE_EXT_EXPORT[] =
_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")
#define FILE_RAW_DEFAULT 1
#define FILE_TYPES_SSLKEYS \
_T("SSL Session Keys (*.keys)\0") _T("*.keys\0") \
_T("All Files (") _T(ALL_FILES_WILDCARD) _T(")\0") _T(ALL_FILES_WILDCARD) _T("\0")
#define FILE_SSLKEYS_DEFAULT 1
#define FILE_TYPES_COLOR \
_T("Text Files (*.txt)\0") _T("*.txt\0") \
_T("All Files (") _T(ALL_FILES_WILDCARD) _T(")\0") _T(ALL_FILES_WILDCARD) _T("\0")
#define FILE_DEFAULT_COLOR 2
static UINT_PTR CALLBACK open_file_hook_proc(HWND of_hwnd, UINT ui_msg, WPARAM w_param, LPARAM l_param);
static UINT_PTR CALLBACK save_as_file_hook_proc(HWND of_hwnd, UINT ui_msg, WPARAM w_param, LPARAM l_param);
static UINT_PTR CALLBACK save_as_statstree_hook_proc(HWND of_hwnd, UINT ui_msg, WPARAM w_param, LPARAM l_param);
static UINT_PTR CALLBACK export_specified_packets_file_hook_proc(HWND of_hwnd, UINT ui_msg, WPARAM w_param, LPARAM l_param);
static UINT_PTR CALLBACK merge_file_hook_proc(HWND mf_hwnd, UINT ui_msg, WPARAM w_param, LPARAM l_param);
static UINT_PTR CALLBACK export_file_hook_proc(HWND of_hwnd, UINT ui_msg, WPARAM w_param, LPARAM l_param);
static UINT_PTR CALLBACK export_raw_file_hook_proc(HWND of_hwnd, UINT ui_msg, WPARAM w_param, LPARAM l_param);
static UINT_PTR CALLBACK export_sslkeys_file_hook_proc(HWND of_hwnd, UINT ui_msg, WPARAM w_param, LPARAM l_param);
static void range_update_dynamics(HWND sf_hwnd, packet_range_t *range);
static void range_handle_wm_initdialog(HWND dlg_hwnd, packet_range_t *range);
static void range_handle_wm_command(HWND dlg_hwnd, HWND ctrl, WPARAM w_param, packet_range_t *range);
@ -738,267 +715,6 @@ win32_export_file(HWND h_wnd, capture_file *cf, export_type_e export_type) {
g_free( (void *) ofn);
}
void
win32_export_raw_file(HWND h_wnd, capture_file *cf) {
OPENFILENAME *ofn;
TCHAR file_name[MAX_PATH] = _T("");
char *dirname;
const guint8 *data_p;
char *file_name8;
int fd;
int ofnsize = sizeof(OPENFILENAME);
if (!cf->finfo_selected) {
/* This shouldn't happen */
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "No bytes were selected.");
return;
}
ofn = g_malloc0(ofnsize);
ofn->lStructSize = ofnsize;
ofn->hwndOwner = h_wnd;
ofn->hInstance = (HINSTANCE) GetWindowLongPtr(h_wnd, GWLP_HINSTANCE);
ofn->lpstrFilter = FILE_TYPES_RAW;
ofn->lpstrCustomFilter = NULL;
ofn->nMaxCustFilter = 0;
ofn->nFilterIndex = FILE_RAW_DEFAULT;
ofn->lpstrFile = file_name;
ofn->nMaxFile = MAX_PATH;
ofn->lpstrFileTitle = NULL;
ofn->nMaxFileTitle = 0;
ofn->lpstrInitialDir = utf_8to16(get_last_open_dir());
ofn->lpstrTitle = _T("Wireshark: Export Raw Data");
ofn->Flags = OFN_ENABLESIZING | OFN_ENABLETEMPLATE | OFN_EXPLORER |
OFN_NOCHANGEDIR | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY |
OFN_PATHMUSTEXIST | OFN_ENABLEHOOK | OFN_SHOWHELP;
ofn->lpstrDefExt = NULL;
ofn->lCustData = cf->finfo_selected->length;
ofn->lpfnHook = export_raw_file_hook_proc;
ofn->lpTemplateName = _T("WIRESHARK_EXPORTRAWFILENAME_TEMPLATE");
/*
* XXX - The GTK+ code uses get_byte_view_data_and_length(). We just
* grab the info from cf->finfo_selected. Which is more "correct"?
*/
HANDLE save_da_ctx = set_thread_per_monitor_v2_awareness();
BOOL gsfn_ok = GetSaveFileName(ofn);
revert_thread_per_monitor_v2_awareness(save_da_ctx);
if (gsfn_ok) {
g_free( (void *) ofn);
file_name8 = utf_16to8(file_name);
data_p = tvb_get_ptr(cf->finfo_selected->ds_tvb, 0, -1) +
cf->finfo_selected->start;
fd = ws_open(file_name8, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0666);
if (fd == -1) {
open_failure_alert_box(file_name8, errno, TRUE);
return;
}
if (ws_write(fd, data_p, cf->finfo_selected->length) < 0) {
write_failure_alert_box(file_name8, errno);
ws_close(fd);
return;
}
if (ws_close(fd) < 0) {
write_failure_alert_box(file_name8, errno);
return;
}
/* Save the directory name for future file dialogs. */
dirname = get_dirname(file_name8); /* Overwrites cf_name */
set_last_open_dir(dirname);
} else {
g_free( (void *) ofn);
}
}
void
win32_export_sslkeys_file(HWND h_wnd) {
OPENFILENAME *ofn;
TCHAR file_name[MAX_PATH] = _T("");
char *dirname;
gchar *keylist = NULL;
char *file_name8;
int fd;
int ofnsize = sizeof(OPENFILENAME);
int keylist_size;
keylist_size = ssl_session_key_count();
if (keylist_size==0) {
/* This shouldn't happen */
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "No SSL Session Keys to export.");
return;
}
ofn = g_malloc0(ofnsize);
ofn->lStructSize = ofnsize;
ofn->hwndOwner = h_wnd;
ofn->hInstance = (HINSTANCE) GetWindowLongPtr(h_wnd, GWLP_HINSTANCE);
ofn->lpstrFilter = FILE_TYPES_SSLKEYS;
ofn->lpstrCustomFilter = NULL;
ofn->nMaxCustFilter = 0;
ofn->nFilterIndex = FILE_SSLKEYS_DEFAULT;
ofn->lpstrFile = file_name;
ofn->nMaxFile = MAX_PATH;
ofn->lpstrFileTitle = NULL;
ofn->nMaxFileTitle = 0;
ofn->lpstrInitialDir = utf_8to16(get_last_open_dir());
ofn->lpstrTitle = _T("Wireshark: Export SSL Session Keys");
ofn->Flags = OFN_ENABLESIZING | OFN_ENABLETEMPLATE | OFN_EXPLORER |
OFN_NOCHANGEDIR | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY |
OFN_PATHMUSTEXIST | OFN_ENABLEHOOK | OFN_SHOWHELP;
ofn->lpstrDefExt = NULL;
ofn->lCustData = keylist_size;
ofn->lpfnHook = export_sslkeys_file_hook_proc;
ofn->lpTemplateName = _T("WIRESHARK_EXPORTSSLKEYSFILENAME_TEMPLATE");
HANDLE save_da_ctx = set_thread_per_monitor_v2_awareness();
BOOL gsfn_ok = GetSaveFileName(ofn);
revert_thread_per_monitor_v2_awareness(save_da_ctx);
if (gsfn_ok) {
g_free( (void *) ofn);
file_name8 = utf_16to8(file_name);
keylist = ssl_export_sessions();
fd = ws_open(file_name8, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0666);
if (fd == -1) {
open_failure_alert_box(file_name8, errno, TRUE);
g_free(keylist);
return;
}
/*
* Thanks, Microsoft, for not using size_t for the third argument to
* _write(). Presumably this string will be <= 4GiB long....
*/
if (ws_write(fd, keylist, (unsigned int)strlen(keylist)) < 0) {
write_failure_alert_box(file_name8, errno);
ws_close(fd);
g_free(keylist);
return;
}
if (ws_close(fd) < 0) {
write_failure_alert_box(file_name8, errno);
g_free(keylist);
return;
}
/* Save the directory name for future file dialogs. */
dirname = get_dirname(file_name8); /* Overwrites cf_name */
set_last_open_dir(dirname);
} else {
g_free( (void *) ofn);
}
g_free(keylist);
}
void
win32_export_color_file(HWND h_wnd, capture_file *cf, gpointer filter_list) {
OPENFILENAME *ofn;
TCHAR file_name[MAX_PATH] = _T("");
gchar *dirname;
int ofnsize = sizeof(OPENFILENAME);
gchar *err_msg = NULL;
ofn = g_malloc0(ofnsize);
ofn->lStructSize = ofnsize;
ofn->hwndOwner = h_wnd;
ofn->hInstance = (HINSTANCE) GetWindowLongPtr(h_wnd, GWLP_HINSTANCE);
ofn->lpstrFilter = FILE_TYPES_COLOR;
ofn->lpstrCustomFilter = NULL;
ofn->nMaxCustFilter = 0;
ofn->nFilterIndex = FILE_DEFAULT_COLOR;
ofn->lpstrFile = file_name;
ofn->nMaxFile = MAX_PATH;
ofn->lpstrFileTitle = NULL;
ofn->nMaxFileTitle = 0;
ofn->lpstrInitialDir = utf_8to16(get_last_open_dir());
ofn->lpstrTitle = _T("Wireshark: Export Color Filters");
ofn->Flags = OFN_ENABLESIZING | OFN_EXPLORER |
OFN_NOCHANGEDIR | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY |
OFN_PATHMUSTEXIST | OFN_ENABLEHOOK;
ofn->lpstrDefExt = NULL;
ofn->lpfnHook = NULL;
ofn->lpTemplateName = NULL;
g_filetype = cf->cd_t;
/* XXX - Support marked filters */
HANDLE save_da_ctx = set_thread_per_monitor_v2_awareness();
BOOL gsfn_ok = GetSaveFileName(ofn);
revert_thread_per_monitor_v2_awareness(save_da_ctx);
if (gsfn_ok) {
g_free( (void *) ofn);
if (!color_filters_export(utf_16to8(file_name), filter_list, FALSE /* all filters */, &err_msg))
{
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
g_free(err_msg);
return;
}
/* Save the directory name for future file dialogs. */
dirname = get_dirname(utf_16to8(file_name)); /* Overwrites cf_name */
set_last_open_dir(dirname);
} else {
g_free( (void *) ofn);
}
}
void
win32_import_color_file(HWND h_wnd, gpointer color_filters) {
OPENFILENAME *ofn;
TCHAR file_name[MAX_PATH] = _T("");
gchar *dirname;
int ofnsize = sizeof(OPENFILENAME);
gchar *err_msg = NULL;
ofn = g_malloc0(ofnsize);
ofn->lStructSize = ofnsize;
ofn->hwndOwner = h_wnd;
ofn->hInstance = (HINSTANCE) GetWindowLongPtr(h_wnd, GWLP_HINSTANCE);
ofn->lpstrFilter = FILE_TYPES_COLOR;
ofn->lpstrCustomFilter = NULL;
ofn->nMaxCustFilter = 0;
ofn->nFilterIndex = FILE_DEFAULT_COLOR;
ofn->lpstrFile = file_name;
ofn->nMaxFile = MAX_PATH;
ofn->lpstrFileTitle = NULL;
ofn->nMaxFileTitle = 0;
ofn->lpstrInitialDir = utf_8to16(get_last_open_dir());
ofn->lpstrTitle = _T("Wireshark: Import Color Filters");
ofn->Flags = OFN_ENABLESIZING | OFN_EXPLORER |
OFN_NOCHANGEDIR | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY |
OFN_PATHMUSTEXIST | OFN_ENABLEHOOK;
ofn->lpstrDefExt = NULL;
ofn->lpfnHook = NULL;
ofn->lpTemplateName = NULL;
/* XXX - Support export limited to selected filters */
HANDLE save_da_ctx = set_thread_per_monitor_v2_awareness();
BOOL gofn_ok = GetOpenFileName(ofn);
revert_thread_per_monitor_v2_awareness(save_da_ctx);
if (gofn_ok) {
g_free( (void *) ofn);
if (!color_filters_import(utf_16to8(file_name), color_filters, &err_msg, color_filter_add_cb)) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
g_free(err_msg);
return;
}
/* Save the directory name for future file dialogs. */
dirname = get_dirname(utf_16to8(file_name)); /* Overwrites cf_name */
set_last_open_dir(dirname);
} else {
g_free( (void *) ofn);
}
}
/*
* Private routines
@ -2325,62 +2041,6 @@ export_file_hook_proc(HWND ef_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) {
return 0;
}
static UINT_PTR CALLBACK
export_raw_file_hook_proc(HWND ef_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) {
HWND cur_ctrl;
OPENFILENAME *ofnp = (OPENFILENAME *) l_param;
TCHAR raw_msg[STATIC_LABEL_CHARS];
OFNOTIFY *notify = (OFNOTIFY *) l_param;
switch(msg) {
case WM_INITDIALOG:
StringCchPrintf(raw_msg, STATIC_LABEL_CHARS, _T("%d byte%s of raw binary data will be written"),
(int)ofnp->lCustData, utf_8to16(plurality(ofnp->lCustData, "", "s")));
cur_ctrl = GetDlgItem(ef_hwnd, EWFD_EXPORTRAW_ST);
SetWindowText(cur_ctrl, raw_msg);
break;
case WM_NOTIFY:
switch (notify->hdr.code) {
case CDN_HELP:
topic_action(HELP_EXPORT_BYTES_WIN32_DIALOG);
break;
default:
break;
}
default:
break;
}
return 0;
}
static UINT_PTR CALLBACK
export_sslkeys_file_hook_proc(HWND ef_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) {
HWND cur_ctrl;
OPENFILENAME *ofnp = (OPENFILENAME *) l_param;
TCHAR sslkeys_msg[STATIC_LABEL_CHARS];
OFNOTIFY *notify = (OFNOTIFY *) l_param;
switch(msg) {
case WM_INITDIALOG:
StringCchPrintf(sslkeys_msg, STATIC_LABEL_CHARS, _T("%d SSL Session Key%s will be written"),
(int)ofnp->lCustData, utf_8to16(plurality(ofnp->lCustData, "", "s")));
cur_ctrl = GetDlgItem(ef_hwnd, EWFD_EXPORTSSLKEYS_ST);
SetWindowText(cur_ctrl, sslkeys_msg);
break;
case WM_NOTIFY:
switch (notify->hdr.code) {
case CDN_HELP:
topic_action(HELP_EXPORT_BYTES_WIN32_DIALOG);
break;
default:
break;
}
default:
break;
}
return 0;
}
/*
* Editor modelines
*

View File

@ -114,34 +114,6 @@ gboolean win32_merge_file (HWND h_wnd, GString *file_name, GString *display_filt
*/
void win32_export_file (HWND h_wnd, capture_file *cf, export_type_e export_type);
/** Open the "Export raw bytes" dialog box.
*
* @param h_wnd HWND of the parent window.
* @param cf capture_file Structure for the capture to be saved
*/
void win32_export_raw_file (HWND h_wnd, capture_file *cf);
/** Open the "Export SSL Session Keys" dialog box.
*
* @param h_wnd HWND of the parent window.
*/
void win32_export_sslkeys_file (HWND h_wnd);
/** Open the "Export Color Filters" dialog box
*
* @param h_wnd HWND of the parent window
* @param cf capture_file Structure for the capture to be saved
* @param filter_list the list to export
*/
void win32_export_color_file(HWND h_wnd, capture_file *cf, gpointer filter_list);
/** Open the "Import Color Filters" dialog box
*
* @param h_wnd HWND of the parent window
* @param color_filters the calling widget
*/
void win32_import_color_file(HWND h_wnd, gpointer color_filters);
/** Open the "Save As" dialog box for stats_tree statistics window.
*
* @param h_wnd HWND of the parent window.
@ -153,8 +125,6 @@ void win32_import_color_file(HWND h_wnd, gpointer color_filters);
gboolean win32_save_as_statstree(HWND h_wnd, GString *file_name,
int *file_type);
void file_set_save_marked_sensitive();
/* Open dialog defines */
/* #define EWFD_FILTER_BTN 1000 */
#define EWFD_FILTER_LBL 1000
@ -206,12 +176,6 @@ void file_set_save_marked_sensitive();
#define EWFD_RANGE_DISP 1019
#define EWFD_IGNORED_DISP 1020
/* Export raw dialog defines. */
#define EWFD_EXPORTRAW_ST 1000
/* Export SSL Session Keys dialog defines. */
#define EWFD_EXPORTSSLKEYS_ST 1000
/* Merge dialog defines. Overlays Open dialog defines above. */
#define EWFD_MERGE_PREPEND_BTN 1050
#define EWFD_MERGE_CHRONO_BTN 1051