Move most of file_open_cmd to gtk_open_file. Make gtk_open_file

and win32_open_file behave similarly. _snwprintf is "banned". Use
StringCchPrintf instead. Tested on Windows. I'll test on OS X shortly.

svn path=/trunk/; revision=43756
This commit is contained in:
Gerald Combs 2012-07-16 20:46:13 +00:00
parent a3d1900fbd
commit 281e18d636
4 changed files with 221 additions and 172 deletions

View File

@ -421,28 +421,26 @@ preview_new(void)
return table;
}
#ifndef USE_WIN32_FILE_DIALOGS
/* Open a file */
static void
file_open_cmd(GtkWidget *w)
static gboolean
gtk_open_file(GtkWidget *w, GString *file_name, GString *display_filter)
{
#ifdef USE_WIN32_FILE_DIALOGS
win32_open_file(GDK_WINDOW_HWND(gtk_widget_get_window(top_level)));
#else /* USE_WIN32_FILE_DIALOGS */
GtkWidget *file_open_w;
GtkWidget *main_hb, *main_vb, *filter_hbox, *filter_bt, *filter_te,
*m_resolv_cb, *n_resolv_cb, *t_resolv_cb, *e_resolv_cb, *prev;
/* No Apply button, and "OK" just sets our text widget, it doesn't
activate it (i.e., it doesn't cause us to try to open the file). */
static construct_args_t args = {
"Wireshark: Read Filter",
"Wireshark: Display Filter",
FALSE,
FALSE,
TRUE
};
gchar *cf_name, *s;
const gchar *rfilter;
dfilter_t *rfcode = NULL;
int err;
gchar *cf_name;
if (!file_name || !display_filter)
return FALSE;
file_open_w = file_selection_new("Wireshark: Open Capture File",
FILE_SELECTION_OPEN);
@ -450,24 +448,28 @@ file_open_cmd(GtkWidget *w)
so we cannot use the correct gtk_window_set_default_size() to resize it */
gtk_widget_set_size_request(file_open_w, DEF_WIDTH, DEF_HEIGHT);
switch (prefs.gui_fileopen_style) {
case FO_STYLE_LAST_OPENED:
/* The user has specified that we should start out in the last directory
we looked in. If we've already opened a file, use its containing
directory, if we could determine it, as the directory, otherwise
use the "last opened" directory saved in the preferences file if
there was one. */
/* This is now the default behaviour in file_selection_new() */
break;
case FO_STYLE_SPECIFIED:
/* The user has specified that we should always start out in a
specified directory; if they've specified that directory,
start out by showing the files in that dir. */
if (prefs.gui_fileopen_dir[0] != '\0')
file_selection_set_current_folder(file_open_w, prefs.gui_fileopen_dir);
break;
if (file_name->len > 0) {
file_selection_set_current_folder(file_open_w, file_name->str);
} else {
switch (prefs.gui_fileopen_style) {
case FO_STYLE_LAST_OPENED:
/* The user has specified that we should start out in the last directory
we looked in. If we've already opened a file, use its containing
directory, if we could determine it, as the directory, otherwise
use the "last opened" directory saved in the preferences file if
there was one. */
/* This is now the default behaviour in file_selection_new() */
break;
case FO_STYLE_SPECIFIED:
/* The user has specified that we should always start out in a
specified directory; if they've specified that directory,
start out by showing the files in that dir. */
if (prefs.gui_fileopen_dir[0] != '\0')
file_selection_set_current_folder(file_open_w, prefs.gui_fileopen_dir);
break;
}
}
main_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
@ -496,6 +498,7 @@ file_open_cmd(GtkWidget *w)
gtk_widget_set_tooltip_text(filter_bt, "Open the \"Display Filter\" dialog, to edit/apply filters");
filter_te = gtk_entry_new();
gtk_entry_set_text(GTK_ENTRY(filter_te), display_filter->str);
g_object_set_data(G_OBJECT(filter_bt), E_FILT_TE_PTR_KEY, filter_te);
gtk_box_pack_start(GTK_BOX(filter_hbox), filter_te, TRUE, TRUE, 3);
g_signal_connect(filter_te, "changed",
@ -547,92 +550,120 @@ file_open_cmd(GtkWidget *w)
g_object_set_data(G_OBJECT(file_open_w), E_DFILTER_TE_KEY,
g_object_get_data(G_OBJECT(w), E_DFILTER_TE_KEY));
cf_name = file_selection_run(file_open_w);
if (cf_name == NULL) {
/* User cancelled or closed the dialog. */
return FALSE;
}
g_string_printf(file_name, "%s", cf_name);
g_free(cf_name);
g_string_printf(display_filter, "%s", gtk_entry_get_text(GTK_ENTRY(filter_te)));
/* Set the global resolving variable */
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_resolv_cb)))
gbl_resolv_flags.mac_name = TRUE;
else
gbl_resolv_flags.mac_name = FALSE;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(n_resolv_cb)))
gbl_resolv_flags.network_name = TRUE;
else
gbl_resolv_flags.network_name = FALSE;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(t_resolv_cb)))
gbl_resolv_flags.transport_name = TRUE;
else
gbl_resolv_flags.transport_name = FALSE;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(e_resolv_cb)))
gbl_resolv_flags.use_external_net_name_resolver = TRUE;
else
gbl_resolv_flags.use_external_net_name_resolver = FALSE;
/* We've crossed the Rubicon; get rid of the file selection box. */
window_destroy(GTK_WIDGET(file_open_w));
}
#endif /* USE_WIN32_FILE_DIALOGS */
/* Open a file */
/*
* <platform/>_open_file routines should upon entry...
* Set the path and fill in the filename if the path+filename is provided.
* Set the display filter if provided. Filter syntax should be checked.
* Set the name resolution check boxes to match the global settings.
* ...and upon exit...
* Return TRUE on "OK" and "FALSE" on "Cancel".
* Set the global name resolution preferences on "OK".
* Close the window.
*/
static void
file_open_cmd(GtkWidget *w)
{
GString *file_name = g_string_new("");
GString *display_filter = g_string_new("");
dfilter_t *rfcode = NULL;
int err;
/*
* Loop until the user either selects a file or gives up.
*/
for (;;) {
cf_name = file_selection_run(file_open_w);
if (cf_name == NULL) {
/* User cancelled or closed the dialog. */
return;
#ifdef USE_WIN32_FILE_DIALOGS
if (win32_open_file(GDK_WINDOW_HWND(gtk_widget_get_window(top_level)), file_name, display_filter)) {
#else /* USE_WIN32_FILE_DIALOGS */
if (gtk_open_file(top_level, file_name, display_filter)) {
#endif /* USE_WIN32_FILE_DIALOGS */
/* apply our filter */
if (dfilter_compile(display_filter->str, &rfcode)) {
cf_set_rfcode(&cfile, rfcode);
} else {
/* Not valid. Tell the user, and go back and run the file
selection box again once they dismiss the alert. */
bad_dfilter_alert_box(top_level, display_filter->str);
continue;
}
/* Try to open the capture file. */
if (cf_open(&cfile, file_name->str, FALSE, &err) != CF_OK) {
/* We couldn't open it; don't dismiss the open dialog box,
just leave it around so that the user can, after they
dismiss the alert box popped up for the open error,
try again. */
if (rfcode != NULL)
dfilter_free(rfcode);
rfcode = NULL;
continue;
}
switch (cf_read(&cfile, FALSE)) {
case CF_READ_OK:
case CF_READ_ERROR:
/* Just because we got an error, that doesn't mean we were unable
to read any of the file; we handle what we could get from the
file. */
break;
case CF_READ_ABORTED:
/* The user bailed out of re-reading the capture file; the
capture file has been closed - just free the capture file name
string and return (without changing the last containing
directory). */
g_string_free(file_name, TRUE);
g_string_free(display_filter, TRUE);
return;
}
/* Save the name of the containing directory specified in the path name,
if any; we can write over cf_name, which is a good thing, given that
"get_dirname()" does write over its argument. */
set_last_open_dir(get_dirname(file_name->str));
}
/* Get the specified read filter and try to compile it. */
rfilter = gtk_entry_get_text(GTK_ENTRY(filter_te));
if (!dfilter_compile(rfilter, &rfcode)) {
/* Not valid. Tell the user, and go back and run the file
selection box again once they dismiss the alert. */
bad_dfilter_alert_box(file_open_w, rfilter);
g_free(cf_name);
continue;
}
/* Try to open the capture file. */
if (cf_open(&cfile, cf_name, FALSE, &err) != CF_OK) {
/* We couldn't open it; don't dismiss the open dialog box,
just leave it around so that the user can, after they
dismiss the alert box popped up for the open error,
try again. */
if (rfcode != NULL)
dfilter_free(rfcode);
g_free(cf_name);
continue;
}
/* Attach the new read filter to "cf" ("cf_open()" succeeded, so
it closed the previous capture file, and thus destroyed any
previous read filter attached to "cf"). */
cfile.rfcode = rfcode;
/* Set the global resolving variable */
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_resolv_cb)))
gbl_resolv_flags.mac_name = TRUE;
else
gbl_resolv_flags.mac_name = FALSE;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(n_resolv_cb)))
gbl_resolv_flags.network_name = TRUE;
else
gbl_resolv_flags.network_name = FALSE;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(t_resolv_cb)))
gbl_resolv_flags.transport_name = TRUE;
else
gbl_resolv_flags.transport_name = FALSE;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(e_resolv_cb)))
gbl_resolv_flags.use_external_net_name_resolver = TRUE;
else
gbl_resolv_flags.use_external_net_name_resolver = FALSE;
/* We've crossed the Rubicon; get rid of the file selection box. */
window_destroy(GTK_WIDGET(file_open_w));
switch (cf_read(&cfile, FALSE)) {
case CF_READ_OK:
case CF_READ_ERROR:
/* Just because we got an error, that doesn't mean we were unable
to read any of the file; we handle what we could get from the
file. */
break;
case CF_READ_ABORTED:
/* The user bailed out of re-reading the capture file; the
capture file has been closed - just free the capture file name
string and return (without changing the last containing
directory). */
g_free(cf_name);
return;
}
/* Save the name of the containing directory specified in the path name,
if any; we can write over cf_name, which is a good thing, given that
"get_dirname()" does write over its argument. */
s = get_dirname(cf_name);
set_last_open_dir(s);
g_free(cf_name);
g_string_free(file_name, TRUE);
g_string_free(display_filter, TRUE);
return;
}
#endif /* USE_WIN32_FILE_DIALOGS */
}
void
@ -2205,3 +2236,16 @@ file_color_export_cmd_cb(GtkWidget *w _U_, gpointer filter_list)
}
#endif /* USE_WIN32_FILE_DIALOGS */
}
/*
* Editor modelines
*
* Local Variables:
* c-basic-offset: 2
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/

View File

@ -77,6 +77,15 @@ extern GtkWidget *file_selection_new(const gchar *title, file_selection_action_t
*/
extern gboolean file_selection_set_current_folder(GtkWidget *fs, const gchar *filename);
/** Set the current file for a file selection dialog.
*
* @param fs the file selection dialog from file_selection_new()
* @param filename the folder to set
* @return TRUE if the folder could be changed successfully
*/
#define file_selection_set_current_file(chooser, filename) \
gtk_file_chooser_set_filename(chooser, filename)
/** Set the "extra" widget for a file selection dialog. This is needed to support
* user-supplied options.
*

View File

@ -38,6 +38,7 @@
#include <windowsx.h>
#include <commdlg.h>
#include <richedit.h>
#include <strsafe.h>
#include <gtk/gtk.h>
@ -152,7 +153,7 @@ static print_args_t print_args;
* should arguably be modal to the window for the file
* being opened/saved/etc.).
*/
static HWND g_sf_hwnd = NULL;
static HWND g_sf_hwnd = NULL;
static char *dfilter_str = NULL;
/*
@ -162,17 +163,26 @@ static char *dfilter_str = NULL;
*/
gboolean
win32_open_file (HWND h_wnd) {
win32_open_file (HWND h_wnd, GString *file_name, GString *display_filter) {
OPENFILENAME *ofn;
TCHAR file_name[MAX_PATH] = _T("");
int err;
char *dirname;
dfilter_t *dfp;
int ofnsize;
TCHAR file_name_w[MAX_PATH] = _T("");
int ofnsize;
gboolean gofn_ok;
#if (_MSC_VER >= 1500)
OSVERSIONINFO osvi;
#endif
if (!file_name || !display_filter)
return FALSE;
if (file_name->len > 0) {
StringCchCopy(file_name_w, MAX_PATH, utf_8to16(file_name->str));
}
if (display_filter->len > 0) {
dfilter_str = g_strdup(display_filter->str);
}
/* Remarks on OPENFILENAME_SIZE_VERSION_400:
*
* MSDN states that OPENFILENAME_SIZE_VERSION_400 should be used with
@ -219,7 +229,7 @@ win32_open_file (HWND h_wnd) {
ofn->lpstrCustomFilter = NULL;
ofn->nMaxCustFilter = 0;
ofn->nFilterIndex = FILE_OPEN_DEFAULT;
ofn->lpstrFile = file_name;
ofn->lpstrFile = file_name_w;
ofn->nMaxFile = MAX_PATH;
ofn->lpstrFileTitle = NULL;
ofn->nMaxFileTitle = 0;
@ -236,32 +246,18 @@ win32_open_file (HWND h_wnd) {
ofn->lpfnHook = open_file_hook_proc;
ofn->lpTemplateName = _T("WIRESHARK_OPENFILENAME_TEMPLATE");
if (GetOpenFileName(ofn)) {
g_free( (void *) ofn->lpstrFilter);
g_free( (void *) ofn);
gofn_ok = GetOpenFileName(ofn);
if (cf_open(&cfile, utf_16to8(file_name), FALSE, &err) != CF_OK) {
return FALSE;
}
/* apply our filter */
if (dfilter_compile(dfilter_str, &dfp)) {
cf_set_rfcode(&cfile, dfp);
}
switch (cf_read(&cfile, FALSE)) {
case CF_READ_OK:
case CF_READ_ERROR:
dirname = get_dirname(utf_16to8(file_name));
set_last_open_dir(dirname);
return TRUE;
break;
}
} else {
g_free( (void *) ofn->lpstrFilter);
g_free( (void *) ofn);
if (gofn_ok) {
g_string_printf(file_name, "%s", utf_16to8(file_name_w));
g_string_printf(display_filter, "%s", dfilter_str ? dfilter_str : "");
}
return FALSE;
g_free( (void *) ofn->lpstrFilter);
g_free( (void *) ofn);
g_free(dfilter_str);
dfilter_str = NULL;
return gofn_ok;
}
typedef enum {
@ -1470,7 +1466,7 @@ preview_set_filename(HWND of_hwnd, gchar *preview_file) {
}
if(err != 0) {
_snwprintf(string_buff, PREVIEW_STR_MAX, _T("error after reading %u packets"), packet);
StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("error after reading %u packets"), packet);
cur_ctrl = GetDlgItem(of_hwnd, EWFD_PTX_PACKETS);
SetWindowText(cur_ctrl, string_buff);
wtap_close(wth);
@ -1479,9 +1475,9 @@ preview_set_filename(HWND of_hwnd, gchar *preview_file) {
/* packet count */
if(is_breaked) {
_snwprintf(string_buff, PREVIEW_STR_MAX, _T("more than %u packets (preview timeout)"), packet);
StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("more than %u packets (preview timeout)"), packet);
} else {
_snwprintf(string_buff, PREVIEW_STR_MAX, _T("%u"), packet);
StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("%u"), packet);
}
cur_ctrl = GetDlgItem(of_hwnd, EWFD_PTX_PACKETS);
SetWindowText(cur_ctrl, string_buff);
@ -1490,7 +1486,7 @@ preview_set_filename(HWND of_hwnd, gchar *preview_file) {
ti_time = (long)start_time;
ti_tm = localtime( &ti_time );
if(ti_tm) {
_snwprintf(string_buff, PREVIEW_STR_MAX,
StringCchPrintf(string_buff, PREVIEW_STR_MAX,
_T("%04d-%02d-%02d %02d:%02d:%02d"),
ti_tm->tm_year + 1900,
ti_tm->tm_mon + 1,
@ -1499,7 +1495,7 @@ preview_set_filename(HWND of_hwnd, gchar *preview_file) {
ti_tm->tm_min,
ti_tm->tm_sec);
} else {
_snwprintf(string_buff, PREVIEW_STR_MAX, _T("?"));
StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("?"));
}
cur_ctrl = GetDlgItem(of_hwnd, EWFD_PTX_FIRST_PKT);
SetWindowText(cur_ctrl, string_buff);
@ -1507,14 +1503,14 @@ preview_set_filename(HWND of_hwnd, gchar *preview_file) {
/* elapsed time */
elapsed_time = (unsigned int)(stop_time-start_time);
if(elapsed_time/86400) {
_snwprintf(string_buff, PREVIEW_STR_MAX, _T("%02u days %02u:%02u:%02u"),
StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("%02u days %02u:%02u:%02u"),
elapsed_time/86400, elapsed_time%86400/3600, elapsed_time%3600/60, elapsed_time%60);
} else {
_snwprintf(string_buff, PREVIEW_STR_MAX, _T("%02u:%02u:%02u"),
StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("%02u:%02u:%02u"),
elapsed_time%86400/3600, elapsed_time%3600/60, elapsed_time%60);
}
if(is_breaked) {
_snwprintf(string_buff, PREVIEW_STR_MAX, _T("unknown"));
StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("unknown"));
}
cur_ctrl = GetDlgItem(of_hwnd, EWFD_PTX_ELAPSED);
SetWindowText(cur_ctrl, string_buff);
@ -2066,9 +2062,9 @@ range_update_dynamics(HWND dlg_hwnd, packet_range_t *range) {
cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_ALL_PKTS_CAP);
EnableWindow(cur_ctrl, !filtered_active);
if (range->remove_ignored) {
_snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), cfile.count - range->ignored_cnt);
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), cfile.count - range->ignored_cnt);
} else {
_snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), cfile.count);
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), cfile.count);
}
SetWindowText(cur_ctrl, static_val);
@ -2079,9 +2075,9 @@ range_update_dynamics(HWND dlg_hwnd, packet_range_t *range) {
else
displayed_cnt = range->displayed_cnt;
if (range->remove_ignored) {
_snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), displayed_cnt - range->displayed_ignored_cnt);
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), displayed_cnt - range->displayed_ignored_cnt);
} else {
_snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), displayed_cnt);
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), displayed_cnt);
}
SetWindowText(cur_ctrl, static_val);
@ -2090,18 +2086,18 @@ range_update_dynamics(HWND dlg_hwnd, packet_range_t *range) {
cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_SEL_PKT_CAP);
EnableWindow(cur_ctrl, selected_num && !filtered_active);
if (range->remove_ignored && cfile.current_frame && cfile.current_frame->flags.ignored) {
_snwprintf(static_val, STATIC_LABEL_CHARS, _T("0"));
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("0"));
} else {
_snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), selected_num ? 1 : 0);
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), selected_num ? 1 : 0);
}
SetWindowText(cur_ctrl, static_val);
cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_SEL_PKT_DISP);
EnableWindow(cur_ctrl, selected_num && filtered_active);
if (range->remove_ignored && cfile.current_frame && cfile.current_frame->flags.ignored) {
_snwprintf(static_val, STATIC_LABEL_CHARS, _T("0"));
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("0"));
} else {
_snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), selected_num ? 1 : 0);
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), selected_num ? 1 : 0);
}
SetWindowText(cur_ctrl, static_val);
@ -2112,18 +2108,18 @@ range_update_dynamics(HWND dlg_hwnd, packet_range_t *range) {
cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_MARKED_CAP);
EnableWindow(cur_ctrl, cfile.marked_count && !filtered_active);
if (range->remove_ignored) {
_snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), cfile.marked_count - range->ignored_marked_cnt);
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), cfile.marked_count - range->ignored_marked_cnt);
} else {
_snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), cfile.marked_count);
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), cfile.marked_count);
}
SetWindowText(cur_ctrl, static_val);
cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_MARKED_DISP);
EnableWindow(cur_ctrl, cfile.marked_count && filtered_active);
if (range->remove_ignored) {
_snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->displayed_marked_cnt - range->displayed_ignored_marked_cnt);
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->displayed_marked_cnt - range->displayed_ignored_marked_cnt);
} else {
_snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->displayed_marked_cnt);
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->displayed_marked_cnt);
}
SetWindowText(cur_ctrl, static_val);
@ -2134,18 +2130,18 @@ range_update_dynamics(HWND dlg_hwnd, packet_range_t *range) {
cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_FIRST_LAST_CAP);
EnableWindow(cur_ctrl, range->mark_range_cnt && !filtered_active);
if (range->remove_ignored) {
_snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->mark_range_cnt - range->ignored_mark_range_cnt);
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->mark_range_cnt - range->ignored_mark_range_cnt);
} else {
_snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->mark_range_cnt);
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->mark_range_cnt);
}
SetWindowText(cur_ctrl, static_val);
cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_FIRST_LAST_DISP);
EnableWindow(cur_ctrl, range->displayed_mark_range_cnt && filtered_active);
if (range->remove_ignored) {
_snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->displayed_mark_range_cnt - range->displayed_ignored_mark_range_cnt);
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->displayed_mark_range_cnt - range->displayed_ignored_mark_range_cnt);
} else {
_snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->displayed_mark_range_cnt);
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->displayed_mark_range_cnt);
}
SetWindowText(cur_ctrl, static_val);
@ -2153,18 +2149,18 @@ range_update_dynamics(HWND dlg_hwnd, packet_range_t *range) {
cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_RANGE_CAP);
EnableWindow(cur_ctrl, !filtered_active);
if (range->remove_ignored) {
_snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->user_range_cnt - range->ignored_user_range_cnt);
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->user_range_cnt - range->ignored_user_range_cnt);
} else {
_snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->user_range_cnt);
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->user_range_cnt);
}
SetWindowText(cur_ctrl, static_val);
cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_RANGE_DISP);
EnableWindow(cur_ctrl, filtered_active);
if (range->remove_ignored) {
_snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->displayed_user_range_cnt - range->displayed_ignored_user_range_cnt);
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->displayed_user_range_cnt - range->displayed_ignored_user_range_cnt);
} else {
_snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->displayed_user_range_cnt);
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->displayed_user_range_cnt);
}
SetWindowText(cur_ctrl, static_val);
@ -2199,12 +2195,12 @@ range_update_dynamics(HWND dlg_hwnd, packet_range_t *range) {
cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_IGNORED_CAP);
EnableWindow(cur_ctrl, ignored_cnt && !filtered_active);
_snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), ignored_cnt);
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), ignored_cnt);
SetWindowText(cur_ctrl, static_val);
cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_IGNORED_DISP);
EnableWindow(cur_ctrl, displayed_ignored_cnt && filtered_active);
_snwprintf(static_val, STATIC_LABEL_CHARS, _T("%u"), displayed_ignored_cnt);
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), displayed_ignored_cnt);
SetWindowText(cur_ctrl, static_val);
}
@ -2465,7 +2461,7 @@ export_raw_file_hook_proc(HWND ef_hwnd, UINT msg, WPARAM w_param, LPARAM l_param
switch(msg) {
case WM_INITDIALOG:
_snwprintf(raw_msg, STATIC_LABEL_CHARS, _T("%d byte%s of raw binary data will be written"),
StringCchPrintf(raw_msg, STATIC_LABEL_CHARS, _T("%d byte%s of raw binary data will be written"),
ofnp->lCustData, utf_8to16(plurality(ofnp->lCustData, "", "s")));
cur_ctrl = GetDlgItem(ef_hwnd, EWFD_EXPORTRAW_ST);
SetWindowText(cur_ctrl, raw_msg);
@ -2497,7 +2493,7 @@ export_sslkeys_file_hook_proc(HWND ef_hwnd, UINT msg, WPARAM w_param, LPARAM l_p
switch(msg) {
case WM_INITDIALOG:
_snwprintf(sslkeys_msg, STATIC_LABEL_CHARS, _T("%d SSL Session Key%s will be written"),
StringCchPrintf(sslkeys_msg, STATIC_LABEL_CHARS, _T("%d SSL Session Key%s will be written"),
ofnp->lCustData, utf_8to16(plurality(ofnp->lCustData, "", "s")));
cur_ctrl = GetDlgItem(ef_hwnd, EWFD_EXPORTSSLKEYS_ST);
SetWindowText(cur_ctrl, sslkeys_msg);

View File

@ -42,7 +42,7 @@ typedef enum {
*
* @param h_wnd HWND of the parent window.
*/
gboolean win32_open_file (HWND h_wnd);
gboolean win32_open_file (HWND h_wnd, GString *file_name, GString *display_filter);
/** Open the "Save As" dialog box.
*