win32: Implement format type selector in open file dialog

Change-Id: Idef1829fcc2b7b08783e5288bb6486ce19c4779b
Reviewed-on: https://code.wireshark.org/review/405
Reviewed-by: Evan Huus <eapache@gmail.com>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
This commit is contained in:
Michal Labedzki 2014-02-26 16:27:20 +01:00 committed by Pascal Quantin
parent e6a45008d3
commit 6a4049535a
5 changed files with 21 additions and 6 deletions

View File

@ -11,6 +11,7 @@ FONT 8, "MS Shell Dlg"
LTEXT "Read filter:", EWFD_FILTER_LBL, 67, 2, 49, 14
CONTROL "", EWFD_FILTER_EDIT, RICHEDIT_CLASS, ES_AUTOHSCROLL, 112, 0, 88, 12, WS_EX_CLIENTEDGE
COMBOBOX EWFD_FORMAT_TYPE, 67, 15, 135, 8, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CHECKBOX "MAC name resolution", EWFD_MAC_NR_CB, 67, 30, 100, 8, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
CHECKBOX "Transport name resolution", EWFD_TRANS_NR_CB, 67, 45, 100, 8, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
CHECKBOX "Network name resolution", EWFD_NET_NR_CB, 67, 60, 100, 8, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP

View File

@ -692,7 +692,7 @@ file_open_cmd(capture_file *cf, GtkWidget *w _U_)
*/
for (;;) {
#ifdef USE_WIN32_FILE_DIALOGS
if (win32_open_file(GDK_WINDOW_HWND(gtk_widget_get_window(top_level)), file_name, display_filter)) {
if (win32_open_file(GDK_WINDOW_HWND(gtk_widget_get_window(top_level)), file_name, &type, display_filter)) {
#else /* USE_WIN32_FILE_DIALOGS */
if (gtk_open_file(top_level, file_name, &type, display_filter)) {
#endif /* USE_WIN32_FILE_DIALOGS */

View File

@ -230,15 +230,13 @@ bool CaptureFileDialog::isCompressed() {
}
int CaptureFileDialog::open(QString &file_name, unsigned int &type) {
Q_UNUSED(type) // XXX Remove when type supporte is added to win32_open_file.
GString *fname = g_string_new(file_name.toUtf8().constData());
GString *dfilter = g_string_new(display_filter_.toUtf8().constData());
gboolean wof_status;
// XXX Add a widget->HWND routine to qt_ui_utils and use it instead.
wof_status = win32_open_file((HWND)parentWidget()->effectiveWinId(), fname, dfilter);
wof_status = win32_open_file((HWND)parentWidget()->effectiveWinId(), fname, &type, dfilter);
file_name = fname->str;
//type = format_type_.currentIndex();
display_filter_ = dfilter->str;
g_string_free(fname, TRUE);

View File

@ -125,6 +125,7 @@ static print_args_t print_args;
*/
static HWND g_sf_hwnd = NULL;
static char *g_dfilter_str = NULL;
static unsigned int g_format_type = WTAP_TYPE_AUTO;
static int
win32_get_ofnsize()
@ -192,7 +193,7 @@ win32_get_ofnsize()
*/
gboolean
win32_open_file (HWND h_wnd, GString *file_name, GString *display_filter) {
win32_open_file (HWND h_wnd, GString *file_name, unsigned int *type, GString *display_filter) {
OPENFILENAME *ofn;
TCHAR file_name16[MAX_PATH] = _T("");
int ofnsize;
@ -243,6 +244,7 @@ win32_open_file (HWND h_wnd, GString *file_name, GString *display_filter) {
if (gofn_ok) {
g_string_printf(file_name, "%s", utf_16to8(file_name16));
g_string_printf(display_filter, "%s", g_dfilter_str ? g_dfilter_str : "");
*type = g_format_type;
}
g_free( (void *) ofn->lpstrFilter);
@ -1334,6 +1336,7 @@ open_file_hook_proc(HWND of_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) {
HWND cur_ctrl, parent;
OFNOTIFY *notify = (OFNOTIFY *) l_param;
TCHAR sel_name[MAX_PATH];
gint i;
switch(msg) {
case WM_INITDIALOG:
@ -1343,6 +1346,13 @@ open_file_hook_proc(HWND of_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) {
SetWindowText(cur_ctrl, utf_8to16(g_dfilter_str));
}
cur_ctrl = GetDlgItem(of_hwnd, EWFD_FORMAT_TYPE);
SendMessage(cur_ctrl, CB_ADDSTRING, 0, (WPARAM) _T("Automatic"));
for (i = 0; open_routines[i].name != NULL; i += 1) {
SendMessage(cur_ctrl, CB_ADDSTRING, 0, (WPARAM) utf_8to16(open_routines[i].name));
}
SendMessage(cur_ctrl, CB_SETCURSEL, 0, 0);
/* Fill in our resolution values */
cur_ctrl = GetDlgItem(of_hwnd, EWFD_MAC_NR_CB);
SendMessage(cur_ctrl, BM_SETCHECK, gbl_resolv_flags.mac_name, 0);
@ -1364,6 +1374,9 @@ open_file_hook_proc(HWND of_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) {
g_free(g_dfilter_str);
g_dfilter_str = filter_tb_get(cur_ctrl);
cur_ctrl = GetDlgItem(of_hwnd, EWFD_FORMAT_TYPE);
g_format_type = SendMessage(cur_ctrl, CB_GETCURSEL, 0, 0);
/* Fetch our resolution values */
cur_ctrl = GetDlgItem(of_hwnd, EWFD_MAC_NR_CB);
if (SendMessage(cur_ctrl, BM_GETCHECK, 0, 0) == BST_CHECKED)

View File

@ -33,9 +33,10 @@ extern "C" {
*
* @param h_wnd HWND of the parent window.
* @param file_name File name
* @param type File type
* @param display_filter a display filter
*/
gboolean win32_open_file (HWND h_wnd, GString *file_name, GString *display_filter);
gboolean win32_open_file (HWND h_wnd, GString *file_name, unsigned int *type, GString *display_filter);
/** Verify that our proposed capture file format supports comments. If it can't
* ask the user what to do and return his or her response.
@ -167,6 +168,8 @@ void file_set_save_marked_sensitive();
#define EWFD_PTX_FIRST_PKT 1014
#define EWFD_PTX_ELAPSED 1015
#define EWFD_FORMAT_TYPE 1016
/* Save as and export dialog defines */
#define EWFD_GZIP_CB 1040