win32: Implement format type selector in open file dialog
authorMichal Labedzki <michal.labedzki@tieto.com>
Wed, 26 Feb 2014 15:27:20 +0000 (16:27 +0100)
committerPascal Quantin <pascal.quantin@gmail.com>
Tue, 4 Mar 2014 18:31:48 +0000 (18:31 +0000)
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>
image/file_dlg_win32.rc
ui/gtk/capture_file_dlg.c
ui/qt/capture_file_dialog.cpp
ui/win32/file_dlg_win32.c
ui/win32/file_dlg_win32.h

index f500718c273fa14492ac65e07f81addf927f6d72..72295880aea22cbb5574f066c2f89df1addaee09 100644 (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
index 5125376efc4383dc4e6c14f5dcafe9363b8f7186..f7de3eea2323a248596b376ab81ccde9a80405c6 100644 (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 */
index 20625f64fddd3946fd6ef3463b2aab75eae054ce..2cf966f77d52ba49b6194ac8d40b7ed9dc6a0998 100644 (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);
index 1fdfb8ce73f7b37a8becdaf621446cd897bf27e0..f1f1d38cb0dd73b221e2d306e6eedf41eeda341d 100644 (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)
index 14ce1def16d66c8b1f321d438b6975d4f1b5e9e9..f26c1e69518a081c145bf431be44d15941f9417c 100644 (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