summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2017-01-20 16:05:56 -0800
committerAnders Broman <a.broman58@gmail.com>2017-01-21 06:50:30 +0000
commit05fbb4826bcb182cc3895874a15585a96703ce1f (patch)
tree448763b393a9ba79c49df7d98c94a77a9e05849d
parent317649f94984cf3d17f2a57badebb78d7703cdb5 (diff)
downloadwireshark-05fbb4826bcb182cc3895874a15585a96703ce1f.tar.gz
Qt: Show merge progress.
Add "file merge" callback plumbing. Use it to display "Merging files" in the main statusbar. Make sure we have a usable window pointer when we merge files. Change-Id: I236b6edb30685f0b06703ab8304bc88ae592f83c Reviewed-on: https://code.wireshark.org/review/19716 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r--file.c17
-rw-r--r--file.h9
-rw-r--r--ui/gtk/capture_file_dlg.c6
-rw-r--r--ui/gtk/drag_and_drop.c2
-rw-r--r--ui/gtk/main_statusbar.c4
-rw-r--r--ui/qt/capture_file.cpp8
-rw-r--r--ui/qt/capture_file.h2
-rw-r--r--ui/qt/main_window.cpp10
-rw-r--r--ui/qt/main_window.h2
-rw-r--r--ui/qt/main_window_slots.cpp13
10 files changed, 58 insertions, 15 deletions
diff --git a/file.c b/file.c
index b5920fd569..547f2bf48c 100644
--- a/file.c
+++ b/file.c
@@ -1217,6 +1217,7 @@ read_packet(capture_file *cf, dfilter_t *dfcode, epan_dissect_t *edt,
typedef struct _callback_data_t {
+ gpointer pd_window;
gint64 f_len;
GTimeVal start_time;
progdlg_t *progbar;
@@ -1271,7 +1272,7 @@ merge_callback(merge_event event, int num _U_,
large file, we might take considerably longer than that standard
time in order to get to the next progress bar step). */
if (cb_data->progbar == NULL) {
- cb_data->progbar = delayed_create_progress_dlg(NULL, "Merging", "files",
+ cb_data->progbar = delayed_create_progress_dlg(cb_data->pd_window, "Merging", "files",
FALSE, &cb_data->stop_flag, &cb_data->start_time, 0.0f);
}
@@ -1323,19 +1324,23 @@ merge_callback(merge_event event, int num _U_,
cf_status_t
-cf_merge_files_to_tempfile(char **out_filenamep, int in_file_count,
- char *const *in_filenames, int file_type,
- gboolean do_append)
+cf_merge_files_to_tempfile(gpointer pd_window, char **out_filenamep,
+ int in_file_count, char *const *in_filenames,
+ int file_type, gboolean do_append)
{
int err = 0;
gchar *err_info = NULL;
guint err_fileno;
merge_result status;
merge_progress_callback_t cb;
+ callback_data_t *cb_data = g_new0(callback_data_t, 1);
/* prepare our callback routine */
+ cb_data->pd_window = pd_window;
cb.callback_func = merge_callback;
- cb.data = g_malloc0(sizeof(callback_data_t));
+ cb.data = cb_data;
+
+ cf_callback_invoke(cf_cb_file_merge_started, NULL);
/* merge the files */
status = merge_files_to_tempfile(out_filenamep, "wireshark", file_type,
@@ -1376,6 +1381,8 @@ cf_merge_files_to_tempfile(char **out_filenamep, int in_file_count,
g_free(err_info);
+ cf_callback_invoke(cf_cb_file_merge_finished, NULL);
+
if (status != MERGE_OK) {
/* Callers aren't expected to treat an error or an explicit abort
differently - we put up error dialogs ourselves, so they don't
diff --git a/file.h b/file.h
index c3c154c484..226da02444 100644
--- a/file.h
+++ b/file.h
@@ -73,6 +73,8 @@ typedef enum {
cf_cb_file_rescan_finished,
cf_cb_file_retap_started,
cf_cb_file_retap_finished,
+ cf_cb_file_merge_started, /* Qt only */
+ cf_cb_file_merge_finished, /* Qt only */
cf_cb_file_fast_save_finished, /* GTK+ only? */
cf_cb_packet_selected, /* GTK+ only. */
cf_cb_packet_unselected, /* GTK+ only. */
@@ -634,6 +636,7 @@ void cf_unignore_frame(capture_file *cf, frame_data *frame);
* Merge two or more capture files into a temporary file.
* @todo is this the right place for this function? It doesn't have to do a lot with capture_file.
*
+ * @param pd_window Window pointer suitable for use by delayed_create_progress_dlg.
* @param out_filenamep Points to a pointer that's set to point to the
* pathname of the temporary file; it's allocated with g_malloc()
* @param in_file_count the number of input files to merge
@@ -643,9 +646,9 @@ void cf_unignore_frame(capture_file *cf, frame_data *frame);
* @return one of cf_status_t
*/
cf_status_t
-cf_merge_files_to_tempfile(char **out_filenamep, int in_file_count,
- char *const *in_filenames, int file_type,
- gboolean do_append);
+cf_merge_files_to_tempfile(gpointer pd_window, char **out_filenamep,
+ int in_file_count, char *const *in_filenames,
+ int file_type, gboolean do_append);
/**
diff --git a/ui/gtk/capture_file_dlg.c b/ui/gtk/capture_file_dlg.c
index 56267d761e..3e1faa92b4 100644
--- a/ui/gtk/capture_file_dlg.c
+++ b/ui/gtk/capture_file_dlg.c
@@ -916,17 +916,17 @@ file_merge_cmd(GtkWidget *w _U_)
/* chronological order */
in_filenames[0] = cfile.filename;
in_filenames[1] = file_name->str;
- merge_status = cf_merge_files_to_tempfile(&tmpname, 2, in_filenames, file_type, FALSE);
+ merge_status = cf_merge_files_to_tempfile(top_level, &tmpname, 2, in_filenames, file_type, FALSE);
} else if (merge_type < 0) {
/* prepend file */
in_filenames[0] = file_name->str;
in_filenames[1] = cfile.filename;
- merge_status = cf_merge_files_to_tempfile(&tmpname, 2, in_filenames, file_type, TRUE);
+ merge_status = cf_merge_files_to_tempfile(top_level, &tmpname, 2, in_filenames, file_type, TRUE);
} else {
/* append file */
in_filenames[0] = cfile.filename;
in_filenames[1] = file_name->str;
- merge_status = cf_merge_files_to_tempfile(&tmpname, 2, in_filenames, file_type, TRUE);
+ merge_status = cf_merge_files_to_tempfile(top_level, &tmpname, 2, in_filenames, file_type, TRUE);
}
if (merge_status != CF_OK) {
diff --git a/ui/gtk/drag_and_drop.c b/ui/gtk/drag_and_drop.c
index 4c34d29258..84479d0908 100644
--- a/ui/gtk/drag_and_drop.c
+++ b/ui/gtk/drag_and_drop.c
@@ -208,7 +208,7 @@ dnd_open_file_cmd(gchar *cf_names_freeme)
}
} else {
/* merge the files in chronological order */
- if (cf_merge_files_to_tempfile(&tmpname, in_file_count, in_filenames,
+ if (cf_merge_files_to_tempfile(top_level, &tmpname, in_file_count, in_filenames,
WTAP_FILE_TYPE_SUBTYPE_PCAPNG, FALSE) == CF_OK) {
/* Merge succeeded; close the currently-open file and try
to open the merged capture file. */
diff --git a/ui/gtk/main_statusbar.c b/ui/gtk/main_statusbar.c
index 1cb241a294..53a36c7a16 100644
--- a/ui/gtk/main_statusbar.c
+++ b/ui/gtk/main_statusbar.c
@@ -1038,6 +1038,10 @@ statusbar_cf_callback(gint event, gpointer data, gpointer user_data _U_)
break;
case(cf_cb_file_retap_finished):
break;
+ case(cf_cb_file_merge_started):
+ break;
+ case(cf_cb_file_merge_finished):
+ break;
case(cf_cb_file_fast_save_finished):
break;
case(cf_cb_packet_selected):
diff --git a/ui/qt/capture_file.cpp b/ui/qt/capture_file.cpp
index 2c04a35261..791e875ca1 100644
--- a/ui/qt/capture_file.cpp
+++ b/ui/qt/capture_file.cpp
@@ -221,6 +221,14 @@ void CaptureFile::captureFileEvent(int event, gpointer data)
emit captureFileFlushTapsData();
emit captureFileRetapFinished();
break;
+ case(cf_cb_file_merge_started):
+ g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Merge started");
+ emit captureFileMergeStarted();
+ break;
+ case(cf_cb_file_merge_finished):
+ g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Merge finished");
+ emit captureFileMergeFinished();
+ break;
case(cf_cb_file_fast_save_finished):
// gtk/main.c calls main_cf_cb_file_rescan_finished. Should we do
diff --git a/ui/qt/capture_file.h b/ui/qt/capture_file.h
index 61487032c0..14215acaf1 100644
--- a/ui/qt/capture_file.h
+++ b/ui/qt/capture_file.h
@@ -101,6 +101,8 @@ signals:
void captureFileRescanFinished() const;
void captureFileRetapStarted() const;
void captureFileRetapFinished() const;
+ void captureFileMergeStarted() const;
+ void captureFileMergeFinished() const;
void captureFileClosing() const;
void captureFileClosed() const;
void captureFileSaveStarted(const QString &file_path) const;
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp
index 01a6e3dd2a..588353cd91 100644
--- a/ui/qt/main_window.cpp
+++ b/ui/qt/main_window.cpp
@@ -542,6 +542,10 @@ MainWindow::MainWindow(QWidget *parent) :
this, SLOT(captureFileRetapStarted()));
connect(&capture_file_, SIGNAL(captureFileRetapFinished()),
this, SLOT(captureFileRetapFinished()));
+ connect(&capture_file_, SIGNAL(captureFileMergeStarted()),
+ this, SLOT(captureFileMergeStarted()));
+ connect(&capture_file_, SIGNAL(captureFileMergeFinished()),
+ this, SLOT(captureFileMergeFinished()));
connect(&capture_file_, SIGNAL(captureFileFlushTapsData()),
this, SLOT(captureFileFlushTapsData()));
connect(&capture_file_, SIGNAL(captureFileClosing()),
@@ -1088,17 +1092,17 @@ void MainWindow::mergeCaptureFile()
/* chronological order */
in_filenames[0] = g_strdup(capture_file_.capFile()->filename);
in_filenames[1] = qstring_strdup(file_name);
- merge_status = cf_merge_files_to_tempfile(&tmpname, 2, in_filenames, file_type, FALSE);
+ merge_status = cf_merge_files_to_tempfile(this, &tmpname, 2, in_filenames, file_type, FALSE);
} else if (merge_dlg.mergeType() <= 0) {
/* prepend file */
in_filenames[0] = qstring_strdup(file_name);
in_filenames[1] = g_strdup(capture_file_.capFile()->filename);
- merge_status = cf_merge_files_to_tempfile(&tmpname, 2, in_filenames, file_type, TRUE);
+ merge_status = cf_merge_files_to_tempfile(this, &tmpname, 2, in_filenames, file_type, TRUE);
} else {
/* append file */
in_filenames[0] = g_strdup(capture_file_.capFile()->filename);
in_filenames[1] = qstring_strdup(file_name);
- merge_status = cf_merge_files_to_tempfile(&tmpname, 2, in_filenames, file_type, TRUE);
+ merge_status = cf_merge_files_to_tempfile(this, &tmpname, 2, in_filenames, file_type, TRUE);
}
g_free(in_filenames[0]);
diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h
index 440476a85e..ffbd8a3cf9 100644
--- a/ui/qt/main_window.h
+++ b/ui/qt/main_window.h
@@ -282,6 +282,8 @@ public slots:
void captureFileRescanStarted() { setMenusForCaptureFile(true); captureFileReadStarted(tr("Rescanning")); }
void captureFileRetapStarted();
void captureFileRetapFinished();
+ void captureFileMergeStarted();
+ void captureFileMergeFinished();
void captureFileFlushTapsData();
void captureFileClosing();
void captureFileClosed();
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp
index 4ae7dbe88c..083eb5fd43 100644
--- a/ui/qt/main_window_slots.cpp
+++ b/ui/qt/main_window_slots.cpp
@@ -756,6 +756,19 @@ void MainWindow::captureFileRetapFinished()
thaw();
}
+void MainWindow::captureFileMergeStarted()
+{
+ main_ui_->statusBar->popFileStatus();
+ QString msg = tr("Merging files");
+ QString msgtip = QString();
+ main_ui_->statusBar->pushFileStatus(msg, msgtip);
+}
+
+void MainWindow::captureFileMergeFinished()
+{
+ main_ui_->statusBar->popFileStatus();
+}
+
void MainWindow::captureFileFlushTapsData()
{
draw_tap_listeners(FALSE);