aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/capture_file.cpp
diff options
context:
space:
mode:
authorGerald Combs <gerald@zing.org>2014-12-21 13:23:02 -0800
committerGerald Combs <gerald@wireshark.org>2014-12-22 18:12:31 +0000
commit5cdad9fe423662e2aea3d63540cd19b7e518b7c3 (patch)
tree16deed9efb4df400a81b564ec1aa5d9f5b1c9c61 /ui/qt/capture_file.cpp
parent30c3d394adbf8deff83854f01dc1082db9cac598 (diff)
Qt: Add methods to CaptureFile and WiresharkApplication.
Add isValid, fileTitle, and retapPackets methods to CaptureFile. Add application name and title separator convenience methods to WiresharkApplication. Convert traffic tables, conversations, and endpoints to use CaptureFile directly and to let the user know when the capture file is closed. Set the file dialog titles while we're here. Change-Id: I990392786d3833e1e0b3638aa2d34a5ada39fa13 Reviewed-on: https://code.wireshark.org/review/5957 Petri-Dish: Gerald Combs <gerald@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui/qt/capture_file.cpp')
-rw-r--r--ui/qt/capture_file.cpp30
1 files changed, 27 insertions, 3 deletions
diff --git a/ui/qt/capture_file.cpp b/ui/qt/capture_file.cpp
index 9aa1ee3efe..c395497457 100644
--- a/ui/qt/capture_file.cpp
+++ b/ui/qt/capture_file.cpp
@@ -35,15 +35,18 @@ capture_file cfile;
#include "ui/capture.h"
+#include <QFileInfo>
+
// To do:
-// - Add isValid or isOpen methods instead of checking capFile() for NULL.
// - Add getters and (if needed) setters:
-// - Base filename
// - Full filename
+QString CaptureFile::no_capture_file_ = QObject::tr("[no capture file]");
+
CaptureFile::CaptureFile(QObject *parent, capture_file *cap_file) :
QObject(parent),
- cap_file_(cap_file)
+ cap_file_(cap_file),
+ file_title_(no_capture_file_)
{
#ifdef HAVE_LIBPCAP
capture_callback_add(captureCallback, (gpointer) this);
@@ -56,6 +59,21 @@ CaptureFile::~CaptureFile()
cf_callback_remove(captureFileCallback, this);
}
+bool CaptureFile::isValid() const
+{
+ if (cap_file_ && cap_file_->state != FILE_CLOSED) { // XXX FILE_READ_IN_PROGRESS as well?
+ return true;
+ }
+ return false;
+}
+
+void CaptureFile::retapPackets()
+{
+ if (cap_file_) {
+ cf_retap_packets(cap_file_);
+ }
+}
+
capture_file *CaptureFile::globalCapFile()
{
return &cfile;
@@ -89,18 +107,24 @@ void CaptureFile::captureFileEvent(int event, gpointer data)
{
switch(event) {
case(cf_cb_file_opened):
+ {
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Opened");
cap_file_ = (capture_file *) data;
+ QFileInfo cfi(QString::fromUtf8(cap_file_->filename));
+ file_title_ = cfi.baseName();
emit captureFileOpened();
break;
+ }
case(cf_cb_file_closing):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Closing");
+ file_title_.append(tr(" [closed]"));
emit captureFileClosing();
break;
case(cf_cb_file_closed):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Closed");
emit captureFileClosed();
cap_file_ = NULL;
+ file_title_ = no_capture_file_;
break;
case(cf_cb_file_read_started):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Read started");