summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2012-09-19 23:06:39 +0000
committerGerald Combs <gerald@wireshark.org>2012-09-19 23:06:39 +0000
commit3e05236eff6c7f3638f7a1b94ca9a1f398e673a1 (patch)
tree317abd2f993a717080c6588a4923168c7b1413f8
parentb5d6160447cc53a5be566ba4c341d6c948098f13 (diff)
downloadwireshark-3e05236eff6c7f3638f7a1b94ca9a1f398e673a1.tar.gz
Add gzip support to the Win32 "Save As" dialog. Don't crash in the Win32
merge dialog if we cancel. Adjust the size and location of the controls in the Win32 open and merge file templates. svn path=/trunk/; revision=45014
-rw-r--r--image/file_dlg_win32.rc81
-rw-r--r--ui/gtk/capture_file_dlg.c12
-rw-r--r--ui/win32/file_dlg_win32.c78
-rw-r--r--ui/win32/file_dlg_win32.h4
4 files changed, 109 insertions, 66 deletions
diff --git a/image/file_dlg_win32.rc b/image/file_dlg_win32.rc
index 5fc7a27441..a40fc4dc8d 100644
--- a/image/file_dlg_win32.rc
+++ b/image/file_dlg_win32.rc
@@ -2,34 +2,41 @@
#include "richedit.h"
#include "../ui/win32/file_dlg_win32.h"
-WIRESHARK_OPENFILENAME_TEMPLATE DIALOGEX 0, 0, 368, 94
+WIRESHARK_OPENFILENAME_TEMPLATE DIALOGEX 0, 0, 421, 90
STYLE WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | DS_3DLOOK | DS_CONTROL
FONT 8, "MS Shell Dlg"
{
// Filter button/entry
// PUSHBUTTON "Filter:", EWFD_FILTER_BTN, 7, 4, 35, 14
- LTEXT "Display filter:", EWFD_FILTER_LBL, 7, 7, 49, 14
- CONTROL "", EWFD_FILTER_EDIT, RICHEDIT_CLASS, ES_AUTOHSCROLL, 52, 5, 88, 12, WS_EX_CLIENTEDGE
-
- CHECKBOX "MAC name resolution", EWFD_MAC_NR_CB, 7, 32, 100, 8, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- CHECKBOX "Transport name resolution", EWFD_TRANS_NR_CB, 7, 47, 100, 8, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- CHECKBOX "Network name resolution", EWFD_NET_NR_CB, 7, 62, 100, 8, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
- CHECKBOX "Use external network name resolver", EWFD_EXTERNAL_NR_CB, 7, 77, 135, 8, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
-
- LTEXT "Format:", EWFD_PT_FORMAT, 164, 4, 40, 8
- LTEXT "-", EWFD_PTX_FORMAT, 211, 4, 150, 8
- LTEXT "Size:", EWFD_PT_SIZE, 164, 19, 40, 8
- LTEXT "-", EWFD_PTX_SIZE, 211, 19, 150, 8
- LTEXT "Packets:", EWFD_PT_PACKETS, 164, 34, 40, 8
- LTEXT "-", EWFD_PTX_PACKETS, 211, 34, 150, 8
- LTEXT "First Packet:", EWFD_PT_FIRST_PKT, 164, 49, 40, 8
- LTEXT "-", EWFD_PTX_FIRST_PKT, 211, 49, 150, 8
- LTEXT "Elapsed:", EWFD_PT_ELAPSED, 164, 64, 40, 8
- LTEXT "-", EWFD_PTX_ELAPSED, 211, 64, 150, 8
+ LTEXT "Display filter:", EWFD_FILTER_LBL, 67, 2, 49, 14
+ CONTROL "", EWFD_FILTER_EDIT, RICHEDIT_CLASS, ES_AUTOHSCROLL, 112, 0, 88, 12, WS_EX_CLIENTEDGE
+
+ 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
+ CHECKBOX "Use external network name resolver", EWFD_EXTERNAL_NR_CB, 67, 75, 135, 8, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+
+ LTEXT "Format:", EWFD_PT_FORMAT, 224, 2, 40, 8
+ LTEXT "-", EWFD_PTX_FORMAT, 271, 2, 150, 8
+ LTEXT "Size:", EWFD_PT_SIZE, 224, 17, 40, 8
+ LTEXT "-", EWFD_PTX_SIZE, 271, 17, 150, 8
+ LTEXT "Packets:", EWFD_PT_PACKETS, 224, 32, 40, 8
+ LTEXT "-", EWFD_PTX_PACKETS, 271, 32, 150, 8
+ LTEXT "First Packet:", EWFD_PT_FIRST_PKT, 224, 47, 40, 8
+ LTEXT "-", EWFD_PTX_FIRST_PKT, 271, 47, 150, 8
+ LTEXT "Elapsed:", EWFD_PT_ELAPSED, 224, 62, 40, 8
+ LTEXT "-", EWFD_PTX_ELAPSED, 271, 62, 150, 8
// 164/211, 79, 40/150, 8
}
+WIRESHARK_SAVEASFILENAME_TEMPLATE DIALOGEX 0, 0, 167, 15
+STYLE WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | DS_3DLOOK | DS_CONTROL
+FONT 8, "MS Shell Dlg"
+{
+ CHECKBOX "Compress with gzip", EWFD_GZIP_CB, 67, 0, 100, 8, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+}
+
WIRESHARK_EXPORT_SPECIFIED_PACKETS_FILENAME_TEMPLATE DIALOGEX 0, 0, 368, 128
STYLE WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | DS_3DLOOK | DS_CONTROL
FONT 8, "MS Shell Dlg"
@@ -62,29 +69,29 @@ FONT 8, "MS Shell Dlg"
LTEXT "0", EWFD_IGNORED_DISP, 170, 105, 41, 8, SS_RIGHT
}
-WIRESHARK_MERGEFILENAME_TEMPLATE DIALOGEX 0, 0, 368, 94
+WIRESHARK_MERGEFILENAME_TEMPLATE DIALOGEX 0, 0, 421, 77
STYLE WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | DS_3DLOOK | DS_CONTROL
FONT 8, "MS Shell Dlg"
{
// Filter button/entry
// PUSHBUTTON "Filter:", EWFD_FILTER_BTN, 7, 4, 35, 14
- LTEXT "Display filter:", EWFD_FILTER_LBL, 7, 7, 49, 14
- CONTROL "", EWFD_FILTER_EDIT, RICHEDIT_CLASS, ES_AUTOHSCROLL, 52, 5, 88, 12, WS_EX_CLIENTEDGE
-
- CONTROL "Prepend packets to existing file", EWFD_MERGE_PREPEND_BTN, "Button", BS_AUTORADIOBUTTON | WS_GROUP, 7, 32, 120, 8
- CONTROL "Merge packets chronologically", EWFD_MERGE_CHRONO_BTN, "Button", BS_AUTORADIOBUTTON, 7, 47, 120, 8
- CONTROL "Append packets to existing file", EWFD_MERGE_APPEND_BTN, "Button", BS_AUTORADIOBUTTON, 7, 62, 120, 8
-
- LTEXT "Format:", EWFD_PT_FORMAT, 164, 4, 40, 8
- LTEXT "-", EWFD_PTX_FORMAT, 211, 4, 150, 8
- LTEXT "Size:", EWFD_PT_SIZE, 164, 19, 40, 8
- LTEXT "-", EWFD_PTX_SIZE, 211, 19, 150, 8
- LTEXT "Packets:", EWFD_PT_PACKETS, 164, 34, 40, 8
- LTEXT "-", EWFD_PTX_PACKETS, 211, 34, 150, 8
- LTEXT "First Packet:", EWFD_PT_FIRST_PKT, 164, 49, 40, 8
- LTEXT "-", EWFD_PTX_FIRST_PKT, 211, 49, 150, 8
- LTEXT "Elapsed:", EWFD_PT_ELAPSED, 164, 64, 40, 8
- LTEXT "-", EWFD_PTX_ELAPSED, 211, 64, 150, 8
+ LTEXT "Display filter:", EWFD_FILTER_LBL, 67, 2, 49, 14
+ CONTROL "", EWFD_FILTER_EDIT, RICHEDIT_CLASS, ES_AUTOHSCROLL, 112, 0, 88, 12, WS_EX_CLIENTEDGE
+
+ CONTROL "Prepend packets to existing file", EWFD_MERGE_PREPEND_BTN, "Button", BS_AUTORADIOBUTTON | WS_GROUP, 67, 30, 120, 8
+ CONTROL "Merge packets chronologically", EWFD_MERGE_CHRONO_BTN, "Button", BS_AUTORADIOBUTTON, 67, 45, 120, 8
+ CONTROL "Append packets to existing file", EWFD_MERGE_APPEND_BTN, "Button", BS_AUTORADIOBUTTON, 67, 60, 120, 8
+
+ LTEXT "Format:", EWFD_PT_FORMAT, 224, 2, 40, 8
+ LTEXT "-", EWFD_PTX_FORMAT, 271, 2, 150, 8
+ LTEXT "Size:", EWFD_PT_SIZE, 224, 17, 40, 8
+ LTEXT "-", EWFD_PTX_SIZE, 271, 17, 150, 8
+ LTEXT "Packets:", EWFD_PT_PACKETS, 224, 32, 40, 8
+ LTEXT "-", EWFD_PTX_PACKETS, 271, 32, 150, 8
+ LTEXT "First Packet:", EWFD_PT_FIRST_PKT, 224, 47, 40, 8
+ LTEXT "-", EWFD_PTX_FIRST_PKT, 271, 47, 150, 8
+ LTEXT "Elapsed:", EWFD_PT_ELAPSED, 224, 62, 40, 8
+ LTEXT "-", EWFD_PTX_ELAPSED, 271, 62, 150, 8
// 164/211, 79, 40/150, 8
}
diff --git a/ui/gtk/capture_file_dlg.c b/ui/gtk/capture_file_dlg.c
index 4566061aca..2048eccb23 100644
--- a/ui/gtk/capture_file_dlg.c
+++ b/ui/gtk/capture_file_dlg.c
@@ -845,12 +845,14 @@ file_merge_cmd(GtkWidget *w _U_)
int file_type;
cf_status_t merge_status;
char *in_filenames[2];
- char *tmpname;
+ char *tmpname = NULL;
/*
* Loop until the user either selects a file or gives up.
*/
for (;;) {
+ g_string_truncate(file_name, 0);
+ g_string_truncate(display_filter, 0);
#ifdef USE_WIN32_FILE_DIALOGS
if (win32_merge_file(GDK_WINDOW_HWND(gtk_widget_get_window(top_level)), file_name, display_filter, &merge_type)) {
#else /* USE_WIN32_FILE_DIALOGS */
@@ -890,8 +892,6 @@ file_merge_cmd(GtkWidget *w _U_)
if (rfcode != NULL)
dfilter_free(rfcode);
g_free(tmpname);
- g_string_free(file_name, TRUE);
- g_string_free(display_filter, TRUE);
continue;
}
@@ -937,8 +937,10 @@ file_merge_cmd(GtkWidget *w _U_)
/* Save the name of the containing directory specified in the path name,
if any; we can write over cf_merged_name, which is a good thing, given that
"get_dirname()" does write over its argument. */
- set_last_open_dir(get_dirname(tmpname));
- g_free(tmpname);
+ if (tmpname) {
+ set_last_open_dir(get_dirname(tmpname));
+ g_free(tmpname);
+ }
g_string_free(file_name, TRUE);
g_string_free(display_filter, TRUE);
return;
diff --git a/ui/win32/file_dlg_win32.c b/ui/win32/file_dlg_win32.c
index 4a3c0070ba..9c0f6b0650 100644
--- a/ui/win32/file_dlg_win32.c
+++ b/ui/win32/file_dlg_win32.c
@@ -139,6 +139,7 @@ static TCHAR *build_file_save_type_list(GArray *savable_file_types,
gboolean must_support_comments);
static int filetype;
+static gboolean use_compression;
static packet_range_t g_range;
static merge_action_e g_merge_action;
static print_args_t print_args;
@@ -375,8 +376,8 @@ win32_save_as_file(HWND h_wnd, capture_file *cf,
GArray *savable_file_types;
OPENFILENAME *ofn;
TCHAR file_name16[MAX_PATH] = _T("");
- GString *file_name8;
- gchar *file_last_dot;
+ GString *file_name8, *file_suffix;
+ gchar *file_name_lower;
GSList *extensions_list, *extension;
gboolean add_extension;
gchar *dirname;
@@ -389,6 +390,7 @@ win32_save_as_file(HWND h_wnd, capture_file *cf,
savable_file_types = wtap_get_savable_file_types(cf->cd_t, cf->linktypes);
if (savable_file_types == NULL)
return FALSE; /* shouldn't happen - the "Save As..." item should be disabled if we can't save the file */
+ use_compression = FALSE;
/*
* Loop until the user either selects a file or gives up.
@@ -427,12 +429,12 @@ win32_save_as_file(HWND h_wnd, capture_file *cf,
ofn->nMaxFileTitle = 0;
ofn->lpstrInitialDir = utf_8to16(get_last_open_dir());
ofn->lpstrTitle = _T("Wireshark: Save file as");
- ofn->Flags = OFN_ENABLESIZING | OFN_EXPLORER |
+ ofn->Flags = OFN_ENABLESIZING | OFN_ENABLETEMPLATE | OFN_EXPLORER |
OFN_NOCHANGEDIR | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY |
OFN_PATHMUSTEXIST | OFN_ENABLEHOOK | OFN_SHOWHELP;
ofn->lpstrDefExt = NULL;
ofn->lpfnHook = save_as_file_hook_proc;
- ofn->lpTemplateName = NULL;
+ ofn->lpTemplateName = _T("WIRESHARK_SAVEASFILENAME_TEMPLATE");
if (!GetSaveFileName(ofn)) {
/* User cancelled or closed the dialog, or an error occurred. */
@@ -492,38 +494,49 @@ win32_save_as_file(HWND h_wnd, capture_file *cf,
* extensions for the file type.
*/
file_name8 = g_string_new(utf_16to8(file_name16));
- file_last_dot = strrchr(file_name8->str,'.');
+ file_name_lower = g_utf8_strdown(file_name8->str, -1);
+ file_suffix = g_string_new("");
extensions_list = wtap_get_file_extensions_list(filetype, FALSE);
if (extensions_list != NULL) {
/* We have one or more extensions for this file type.
Start out assuming we need to add the default one. */
add_extension = TRUE;
- if (file_last_dot != NULL) {
- /* Skip past the dot. */
- file_last_dot++;
-
- /* OK, see if the file has one of those extensions. */
- for (extension = extensions_list; extension != NULL;
- extension = g_slist_next(extension)) {
- if (g_ascii_strcasecmp((char *)extension->data,
- file_last_dot) == 0) {
- /*
- * The file name has one of the extensions for
- * this file type.
- */
- add_extension = FALSE;
- break;
- }
+
+ /* OK, see if the file has one of those extensions. */
+ for (extension = extensions_list; extension != NULL;
+ extension = g_slist_next(extension)) {
+ g_string_printf(file_suffix, ".%s", extension);
+ if (g_str_has_suffix(file_name_lower, file_suffix->str)) {
+ /*
+ * The file name has one of the extensions for
+ * this file type.
+ */
+ add_extension = FALSE;
+ break;
+ }
+ g_string_append(file_suffix, ".gz");
+ if (g_str_has_suffix(file_name_lower, file_suffix->str)) {
+ /*
+ * The file name has one of the extensions for
+ * this file type.
+ */
+ add_extension = FALSE;
+ break;
}
}
} else {
/* We have no extensions for this file type. Don't add one. */
add_extension = FALSE;
}
+ g_free(file_name_lower);
+ g_string_free(file_suffix, TRUE);
if (add_extension) {
if (wtap_default_file_extension(filetype) != NULL) {
g_string_append_printf(file_name8, ".%s",
wtap_default_file_extension(filetype));
+ if (use_compression) {
+ g_string_append(file_name8, ".gz");
+ }
}
}
@@ -545,7 +558,7 @@ win32_save_as_file(HWND h_wnd, capture_file *cf,
* presumably should rarely fail in this case.
*/
switch (cf_save_packets(&cfile, file_name8->str, filetype,
- FALSE/*compressed */,
+ use_compression,
discard_comments,
dont_reopen)) {
case CF_WRITE_OK:
@@ -1843,6 +1856,9 @@ save_as_file_hook_proc(HWND sf_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) {
/* Fill in the file format list */
/*build_file_format_list(sf_hwnd);*/
+ /* Fill in the compression checkbox */
+ cur_ctrl = GetDlgItem(sf_hwnd, EWFD_GZIP_CB);
+ SendMessage(cur_ctrl, BM_SETCHECK, use_compression, 0);
break;
case WM_COMMAND:
@@ -1868,7 +1884,16 @@ save_as_file_hook_proc(HWND sf_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) {
cur_ctrl = GetDlgItem(sf_hwnd, EWFD_DISPLAYED_BTN);
EnableWindow(cur_ctrl, FALSE);
}
- filetype = new_filetype;
+ filetype = new_filetype;
+ cur_ctrl = GetDlgItem(sf_hwnd, EWFD_GZIP_CB);
+ if (wtap_dump_can_compress(file_type) {
+ EnableWindow(cur_ctrl);
+ } else {
+ use_compression = FALSE;
+ DisableWindow(cur_ctrl);
+ }
+ SendMessage(cur_ctrl, BM_SETCHECK, use_compression, 0);
+
}
}
}
@@ -1889,6 +1914,13 @@ save_as_file_hook_proc(HWND sf_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) {
char *file_name8_selected;
int selected_size;
+ /* Fetch our compression value */
+ cur_ctrl = GetDlgItem(sf_hwnd, EWFD_GZIP_CB);
+ if (SendMessage(cur_ctrl, BM_GETCHECK, 0, 0) == BST_CHECKED)
+ use_compression = TRUE;
+ else
+ use_compression = FALSE;
+
/* Check if trying to do 'save as' to the currently open file */
parent = GetParent(sf_hwnd);
selected_size = CommDlg_OpenSave_GetFilePath(parent, file_name16_selected, MAX_PATH);
diff --git a/ui/win32/file_dlg_win32.h b/ui/win32/file_dlg_win32.h
index 405e72e29e..4131b972c7 100644
--- a/ui/win32/file_dlg_win32.h
+++ b/ui/win32/file_dlg_win32.h
@@ -131,8 +131,10 @@ void file_set_save_marked_sensitive();
#define EWFD_PTX_FIRST_PKT 1014
#define EWFD_PTX_ELAPSED 1015
+/* Save as dialog defines */
+#define EWFD_GZIP_CB 1000
-/* Save dialog defines */
+/* Export dialog defines */
#define EWFD_CAPTURED_BTN 1000
#define EWFD_DISPLAYED_BTN 1001
#define EWFD_ALL_PKTS_BTN 1002