Use win32_open_file in qtshark on Windows.

svn path=/trunk/; revision=43677
This commit is contained in:
Gerald Combs 2012-07-12 00:04:53 +00:00
parent c7c73e44b5
commit bdea70585d
9 changed files with 152 additions and 17 deletions

View File

@ -183,10 +183,11 @@ randpkt_LIBS= wiretap\wiretap-$(WTAP_VERSION).lib \
EXECUTABLES=wireshark.exe tshark.exe rawshark.exe \
capinfos.exe editcap.exe mergecap.exe text2pcap.exe randpkt.exe dumpcap.exe
RESOURCES=image\wireshark.res image\libwireshark.res image\tshark.res \
image\capinfos.res image\editcap.res image\mergecap.res \
image\text2pcap.res image\wiretap.res image\dumpcap.res \
image\rawshark.res image\libwsutil.res
RESOURCES=image\wireshark.res image\file_dlg_win32.res \
image\libwireshark.res image\tshark.res image\capinfos.res \
image\editcap.res image\mergecap.res image\text2pcap.res \
image\wiretap.res image\dumpcap.res image\rawshark.res \
image\libwsutil.res
all: $(LIBS_CHECK) config.h ui\qt\config.pri tools image codecs $(C_ARES_DLL) $(ADNS_DLL) $(ZLIB_DLL) wsutil wiretap epan $(EXECUTABLES) wireshark.bsc $(RESOURCES) doc help install-all
@ -286,10 +287,10 @@ $(RESOURCES): image
wiretap\wiretap-$(WTAP_VERSION).lib: image $(ZLIB_DLL) wiretap
wireshark.exe : $(LIBS_CHECK) config.h $(wireshark_OBJECTS) codecs epan gtk ui win32 image\wireshark.res wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib codecs\codecs.lib ui\libui.lib ui\gtk\libgtkui.lib ui\win32\libgtkui_win32.lib plugins
wireshark.exe : $(LIBS_CHECK) config.h $(wireshark_OBJECTS) codecs epan gtk ui win32 image\wireshark.res image\file_dlg_win32.res wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib codecs\codecs.lib ui\libui.lib ui\gtk\libgtkui.lib ui\win32\libgtkui_win32.lib plugins
@echo Linking $@
$(LINK) @<<
/OUT:wireshark.exe $(guiflags) $(guilibsdll) $(LDFLAGS) /LARGEADDRESSAWARE /SUBSYSTEM:windows $(wireshark_LIBS) $(GTK_LIBS) codecs\codecs.lib ui\gtk\libgtkui.lib ui\win32\libgtkui_win32.lib ui\libui.lib $(wireshark_OBJECTS) image\wireshark.res
/OUT:wireshark.exe $(guiflags) $(guilibsdll) $(LDFLAGS) /LARGEADDRESSAWARE /SUBSYSTEM:windows $(wireshark_LIBS) $(GTK_LIBS) codecs\codecs.lib ui\gtk\libgtkui.lib ui\win32\libgtkui_win32.lib ui\libui.lib $(wireshark_OBJECTS) image\wireshark.res image\file_dlg_win32.res
<<
!IFDEF MANIFEST_INFO_REQUIRED
mt.exe -nologo -manifest "wireshark.exe.manifest" -outputresource:wireshark.exe;1

View File

@ -1,7 +1,5 @@
#include "winver.h"
#include "file_dlg_win32.rc"
WIRESHARK_ICON1 ICON "wireshark.ico"
WIRESHARK_ICON2 ICON "wiresharkdoc.ico"

View File

@ -82,6 +82,8 @@ win32:INCLUDEPATH += \
$${WIRESHARK_LIB_DIR}/AirPcap_Devpack_4_1_0_1622/Airpcap_Devpack/include \
$${WIRESHARK_LIB_DIR}/zlib125/include
# We have to manually trigger relinking each time one of these is modified.
# Is there any way to do this automatically?
SOURCES_WS_C = \
../../airpcap_loader.c \
../../ui/alert_box.c \
@ -118,7 +120,11 @@ SOURCES_WS_C = \
../../version_info.c
unix:SOURCES_WS_C += ../../capture-pcap-util-unix.c
win32:SOURCES_WS_C += ../../capture-wpcap.c ../../capture_wpcap_packet.c
win32:SOURCES_WS_C += \
../../capture-wpcap.c \
../../capture_wpcap_packet.c \
../../ui/win32/file_dlg_win32.c
SOURCES_QT_CPP = \
byte_view_tab.cpp \
@ -210,6 +216,7 @@ win32 {
OBJECTS_WS_C = $$SOURCES_WS_C
OBJECTS_WS_C ~= s/[.]c/.obj/g
OBJECTS_WS_C ~= s,/,\\,g
OBJECTS_WS_C += ../../image/file_dlg_win32.res
} else {
## XXX: Shouldn't need to (re)compile WS_C sources ??
SOURCES += $$SOURCES_WS_C
@ -252,7 +259,7 @@ win32 {
LIBS += $$OBJECTS_WS_C
LIBS += $$PA_OBJECTS
LIBS += \
wsock32.lib user32.lib shell32.lib comctl32.lib \
wsock32.lib user32.lib shell32.lib comctl32.lib comdlg32.lib \
-L../../epan -llibwireshark -L../../wsutil -llibwsutil -L../../wiretap -lwiretap-$${WTAP_VERSION} \
-L$${GLIB_DIR}/lib -lglib-2.0 -lgmodule-2.0
@ -291,7 +298,6 @@ win32 {
}
RESOURCES += \
toolbar.qrc \
welcome.qrc \

View File

@ -21,9 +21,96 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "capture_file_dialog.h"
#ifdef Q_WS_WIN
#include <glib.h>
#include <windows.h>
#include "packet_list_record.h"
#include "cfile.h"
#include "ui/win32/file_dlg_win32.h"
#endif
#ifdef Q_WS_WIN
// All of these routines are required by file_dlg_win32.c.
// We don't yet have a good place for them so we'll add them as stubs here.
extern "C" {
// From gtk/capture_dlg.[ch]
/* capture start confirmed by "Save unsaved capture", so do it now */
extern void capture_start_confirmed(void) {
}
// From gtk/drag_and_drop.[ch]
/** Open a new file coming from drag and drop.
* @param cf_names_freeme the selection data reported from GTK
*/
extern void dnd_open_file_cmd(gchar *cf_names_freeme) {
Q_UNUSED(cf_names_freeme);
}
// From gtk/menus.h & main_menubar.c
/** User pushed a recent file submenu item.
*
* @param widget parent widget
*/
extern void menu_open_recent_file_cmd(gpointer action){
Q_UNUSED(action)
}
/** One of the name resolution menu items changed. */
extern void menu_name_resolution_changed(void) {
}
// From gtk/export_sslkeys.[ch]
/** Callback for "Export SSL Session Keys" operation.
*
* @param w unused
* @param data unused
*/
extern void savesslkeys_cb(gpointer * w, gpointer data) {
Q_UNUSED(w);
Q_UNUSED(data);
}
/** Dump the SSL Session Keys to a StringInfo string
*
* @param session_hash contains all the SSL Session Keys
*/
extern gpointer ssl_export_sessions(GHashTable *session_hash) {
Q_UNUSED(session_hash);
return NULL;
}
// From gtk/help_dlg.[ch]
/** Open a specific topic (create a "Help" dialog box or open a webpage).
*
* @param widget parent widget (unused)
* @param topic the topic to display
*/
extern void topic_cb(gpointer *widget, int topic) {
Q_UNUSED(widget);
Q_UNUSED(topic);
}
}
// End stub routines
#endif // Q_WS_WIN
CaptureFileDialog::CaptureFileDialog(QWidget *parent) :
QFileDialog(parent)
{
}
#ifdef Q_WS_WIN
int CaptureFileDialog::exec(){
return (int) win32_open_file(parentWidget()->effectiveWinId());
}
#endif

View File

@ -60,6 +60,9 @@ signals:
public slots:
#if defined(Q_WS_WIN)
int exec();
#endif
};
#endif // CAPTURE_FILE_DIALOG_H

View File

@ -282,7 +282,7 @@ build_file_save_type_list(GArray *savable_file_types) {
#endif
void MainWindow::openCaptureFile(QString &cfPath)
{
{
dfilter_t *rfcode = NULL;
if (cfPath.isEmpty()) {
@ -290,18 +290,24 @@ void MainWindow::openCaptureFile(QString &cfPath)
CaptureFileDialog cfDlg(this);
cfDlg.setLabelText(QFileDialog::FileName, tr("Wireshark: Open Capture File"));
cfDlg.setDirectory("/Users/gcombs/Documents/Captures");
cfDlg.setNameFilters(build_file_open_type_list());
cfDlg.setFileMode(QFileDialog::ExistingFile);
if (cfDlg.exec()) {
#ifdef Q_WS_WIN
// XXX - This doesn't happen until after the file is loaded.
// We should catch an event from cf_read instead.
ui->mainStack->setCurrentWidget(splitterV);
#else // Q_WS_WIN
cfNames = cfDlg.selectedFiles();
if (cfNames.length() > 0) {
cfPath = cfNames[0];
}
#endif // Q_WS_WIN
}
}
#ifndef Q_WS_WIN
if (cfPath.length() > 0) {
int err;
@ -321,6 +327,7 @@ void MainWindow::openCaptureFile(QString &cfPath)
cf_read(&cfile, FALSE);
}
}
#endif // Q_WS_WIN
}
void MainWindow::recentActionTriggered() {

View File

@ -66,6 +66,10 @@ struct remote_host_t {
gboolean nocap_local;
};
// Referenced from ui/win32/file_dlg_win32.c and implemented in wireshark_application.cpp
extern void set_last_open_dir(const char *dirname);
extern gboolean main_do_quit(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -38,10 +38,16 @@
#include <QDir>
#include <QTimer>
#ifdef Q_WS_WIN
#include <QLibrary>
#include <QDebug>
#endif
WiresharkApplication *wsApp = NULL;
// XXX - Copied from ui/gtk/file_dlg.c
// MUST be UTF-8
static char *last_open_dir = NULL;
static bool updated_last_open_dir = FALSE;
static QList<recent_item_status *> recent_items;
@ -150,6 +156,10 @@ extern "C" void menu_recent_file_write_all(FILE *rf) {
}
}
extern gboolean main_do_quit(void) {
WiresharkApplication::quit();
return FALSE;
}
//
void WiresharkApplication::refreshRecentFiles(void) {
@ -272,6 +282,17 @@ WiresharkApplication::WiresharkApplication(int &argc, char **argv) :
Q_INIT_RESOURCE(toolbar);
Q_INIT_RESOURCE(welcome);
#ifdef Q_WS_WIN
/* RichEd20.DLL is needed for native file dialog filter entries. */
if (QLibrary::isLibrary("riched20.dll")) {
QLibrary riched20("riched20.dll");
riched20.load();
if (!riched20.isLoaded()) {
qDebug() << riched20.errorString();
}
}
#endif // Q_WS_WIN
recentTimer = new QTimer(this);
connect(recentTimer, SIGNAL(timeout()), this, SLOT(refreshRecentFiles()));
recentTimer->start(2000);

View File

@ -1,4 +1,4 @@
/* win32_file_dlg.h
/* file_dlg_win32.h
* Native Windows file dialog routines
*
* $Id$
@ -22,8 +22,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef __WIN32_FILE_DLG_H__
#define __WIN32_FILE_DLG_H__
#ifndef __FILE_DLG_WIN32_H__
#define __FILE_DLG_WIN32_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef enum {
export_type_text = 1,
@ -175,4 +179,8 @@ void file_set_save_marked_sensitive();
#define EWFD_PKT_BYTES_CB 1054
#define EWFD_PKT_NEW_PAGE_CB 1055
#endif /* win32-file-dlg.h */
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __FILE_DLG_WIN32_H__ */