summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2012-07-18 16:40:34 +0000
committerGerald Combs <gerald@wireshark.org>2012-07-18 16:40:34 +0000
commit2643a5b02d2a195cf496c36ca4e1fe7befaa4a1b (patch)
tree341adfeb36c4c3e8b675d5429512fc2649ce0065
parente1bf3c011e78feb62a8583ef10f5d4c711cfdcaa (diff)
downloadwireshark-2643a5b02d2a195cf496c36ca4e1fe7befaa4a1b.tar.gz
Update qtshark to match the recent file dialog changes.
svn path=/trunk/; revision=43786
-rw-r--r--ui/qt/QtShark.pro1
-rw-r--r--ui/qt/capture_file_dialog.cpp29
-rw-r--r--ui/qt/capture_file_dialog.h6
-rw-r--r--ui/qt/main.cpp6
-rw-r--r--ui/qt/main_window.cpp93
-rw-r--r--ui/qt/progress_dialog.cpp4
6 files changed, 97 insertions, 42 deletions
diff --git a/ui/qt/QtShark.pro b/ui/qt/QtShark.pro
index f6139c4dfb..7a527743c9 100644
--- a/ui/qt/QtShark.pro
+++ b/ui/qt/QtShark.pro
@@ -116,6 +116,7 @@ SOURCES_WS_C = \
../../tempfile.c \
../../timestats.c \
../../u3.c \
+ ../../ui/alert_box.c \
../../ui/util.c \
../../version_info.c
diff --git a/ui/qt/capture_file_dialog.cpp b/ui/qt/capture_file_dialog.cpp
index 31e87486a8..6848f3c164 100644
--- a/ui/qt/capture_file_dialog.cpp
+++ b/ui/qt/capture_file_dialog.cpp
@@ -35,6 +35,8 @@
#include "ui/win32/file_dlg_win32.h"
#endif
+//#include <QDebug>
+
#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.
@@ -103,14 +105,33 @@ extern void topic_cb(gpointer *widget, int topic) {
// End stub routines
#endif // Q_WS_WIN
-CaptureFileDialog::CaptureFileDialog(QWidget *parent) :
- QFileDialog(parent)
+CaptureFileDialog::CaptureFileDialog(QWidget *parent, QString &fileName, QString &displayFilter) :
+ QFileDialog(parent), m_fileName(fileName), m_displayFilter(displayFilter)
{
+#if !defined(Q_WS_WIN)
+ setLabelText(QFileDialog::FileName, tr("Wireshark: Open Capture File"));
+ setNameFilters(build_file_open_type_list());
+ setFileMode(QFileDialog::ExistingFile);
+#endif
}
+
#ifdef Q_WS_WIN
-int CaptureFileDialog::exec(){
- return (int) win32_open_file(parentWidget()->effectiveWinId());
+int CaptureFileDialog::exec() {
+ GString *file_name = g_string_new(m_fileName.toUtf8().constData());
+ GString *display_filter = g_string_new(m_displayFilter.toUtf8().constData());
+ gboolean wof_status;
+
+ wof_status = win32_open_file(parentWidget()->effectiveWinId(), file_name, display_filter);
+ m_fileName.clear();
+ m_fileName.append(QString::fromUtf8(file_name->str));
+ m_displayFilter.clear();
+ m_displayFilter.append(QString::fromUtf8(display_filter->str));
+
+ g_string_free(file_name, TRUE);
+ g_string_free(display_filter, TRUE);
+
+ return (int) wof_status;
}
#endif
diff --git a/ui/qt/capture_file_dialog.h b/ui/qt/capture_file_dialog.h
index f31dc1291b..eb8a6a6cd2 100644
--- a/ui/qt/capture_file_dialog.h
+++ b/ui/qt/capture_file_dialog.h
@@ -54,7 +54,11 @@ class CaptureFileDialog : public QFileDialog
Q_OBJECT
public:
- explicit CaptureFileDialog(QWidget *parent = 0);
+ explicit CaptureFileDialog(QWidget *parent = NULL, QString &fileName = QString(), QString &displayFilter = QString());
+
+private:
+ QString &m_fileName;
+ QString &m_displayFilter;
signals:
diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp
index cff729cb5c..f15c936552 100644
--- a/ui/qt/main.cpp
+++ b/ui/qt/main.cpp
@@ -917,10 +917,10 @@ int main(int argc, char *argv[])
dissectors, and we must do it before we read the preferences, in
case any dissectors register preferences. */
epan_init(register_all_protocols,register_all_protocol_handoffs,
- NULL, NULL, NULL, NULL, NULL, NULL
+ NULL, NULL,
// splash_update, (gpointer) splash_win,
-// failure_alert_box,open_failure_alert_box,read_failure_alert_box,
-// write_failure_alert_box
+ failure_alert_box,open_failure_alert_box,read_failure_alert_box,
+ write_failure_alert_box
);
// splash_update(RA_LISTENERS, NULL, (gpointer)splash_win);
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp
index 1f1289a3fc..2cfa31038d 100644
--- a/ui/qt/main_window.cpp
+++ b/ui/qt/main_window.cpp
@@ -31,6 +31,7 @@
#include <wiretap/wtap.h>
+#include "ui/alert_box.h"
#include "ui/main_statusbar.h"
#include "wireshark_application.h"
@@ -150,6 +151,8 @@ void MainWindow::captureFileReadStarted(const capture_file *cf) {
ui->statusBar->popFileStatus();
QString msg = QString(tr("Loading: %1")).arg(get_basename(cf->filename));
ui->statusBar->pushFileStatus(msg);
+ ui->mainStack->setCurrentWidget(splitterV);
+ WiresharkApplication::processEvents();
}
void MainWindow::captureFileReadFinished(const capture_file *cf) {
@@ -283,51 +286,75 @@ build_file_save_type_list(GArray *savable_file_types) {
void MainWindow::openCaptureFile(QString &cfPath)
{
- dfilter_t *rfcode = NULL;
-
- if (cfPath.isEmpty()) {
- QStringList cfNames;
- CaptureFileDialog cfDlg(this);
-
- cfDlg.setLabelText(QFileDialog::FileName, tr("Wireshark: Open Capture File"));
- 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];
+ QString fileName = "";
+ QString displayFilter = "";
+ dfilter_t *rfcode = NULL;
+ int err;
+
+ capFile = NULL;
+
+ for (;;) {
+
+ if (cfPath.isEmpty()) {
+ CaptureFileDialog cfDlg(this, fileName, displayFilter);
+
+ if (cfDlg.exec()) {
+ if (dfilter_compile(displayFilter.toUtf8().constData(), &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);
+ QMessageBox::warning(this, tr("Invalid Display Filter"),
+ QString("The filter expression ") +
+ displayFilter +
+ QString(" isn't a valid display filter. (") +
+ dfilter_error_msg + QString(")."),
+ QMessageBox::Ok);
+ continue;
+ }
+ cfPath = fileName;
+ } else {
+ return;
}
-#endif // Q_WS_WIN
}
- }
-
-#ifndef Q_WS_WIN
- if (cfPath.length() > 0) {
- int err;
/* Try to open the capture file. */
if (cf_open(&cfile, cfPath.toUtf8().constData(), 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. */
+ 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);
+ cfPath.clear();
+ continue;
+ }
+
+ capFile = &cfile;
+
+ 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). */
capFile = NULL;
return;
- } else {
- ui->mainStack->setCurrentWidget(splitterV);
- capFile = &cfile;
- cf_read(&cfile, FALSE);
}
+ break;
}
-#endif // Q_WS_WIN
+ // get_dirname overwrites its path. Hopefully this isn't a problem.
+ set_last_open_dir(get_dirname(cfPath.toUtf8().data()));
+ dfComboBox->setEditText(displayFilter);
}
void MainWindow::recentActionTriggered() {
diff --git a/ui/qt/progress_dialog.cpp b/ui/qt/progress_dialog.cpp
index c5ee93886d..1c2f70ae32 100644
--- a/ui/qt/progress_dialog.cpp
+++ b/ui/qt/progress_dialog.cpp
@@ -31,6 +31,8 @@
#include "ui/progress_dlg.h"
+#include "wireshark_application.h"
+
progdlg_t *
delayed_create_progress_dlg(const gchar *task_title, const gchar *item_title,
gboolean terminate_is_stop, gboolean *stop_flag,
@@ -170,7 +172,7 @@ update_progress_dlg(progdlg_t *dlg, gfloat percentage, const gchar *status)
/*
* Flush out the update and process any input events.
*/
-// WiresharkApplication::processEvents();
+ WiresharkApplication::processEvents();
}
/*