2016-02-28 18:23:20 +00:00
|
|
|
/* wireshark_dialog.h
|
2014-12-22 23:51:36 +00:00
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef WIRESHARK_DIALOG_H
|
|
|
|
#define WIRESHARK_DIALOG_H
|
|
|
|
|
2015-08-24 19:30:56 +00:00
|
|
|
/*
|
|
|
|
* @file General dialog base class
|
|
|
|
*
|
|
|
|
* Base class which provides convenience methods for dialogs that handle
|
2015-08-26 19:48:56 +00:00
|
|
|
* capture files.
|
|
|
|
*
|
|
|
|
* This class attempts to destroy itself when closed. Doing this safely and
|
|
|
|
* properly can be a bit tricky while scanning and tapping packets since
|
2015-08-24 19:30:56 +00:00
|
|
|
*/
|
|
|
|
|
2015-08-26 19:48:56 +00:00
|
|
|
// "General" is a misnomer but we already have a class named
|
|
|
|
// "CaptureFileDialog". Suggestions for a better name from
|
|
|
|
// https://code.wireshark.org/review/#/c/9739/:
|
|
|
|
// BaseCaptureDialog, CaptureHelperDialog (or rename CaptureFileDialog to something else - WiresharkFileDialog).
|
|
|
|
// TapDialog might make sense as well.
|
|
|
|
|
2014-12-22 23:51:36 +00:00
|
|
|
#include "capture_file.h"
|
2016-02-28 18:23:20 +00:00
|
|
|
#include "geometry_state_dialog.h"
|
2014-12-22 23:51:36 +00:00
|
|
|
|
2016-02-28 18:23:20 +00:00
|
|
|
class WiresharkDialog : public GeometryStateDialog
|
2014-12-22 23:51:36 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
// XXX Unlike the entire QWidget API, parent is mandatory here.
|
2016-06-24 17:52:44 +00:00
|
|
|
explicit WiresharkDialog(QWidget &parent, CaptureFile &capture_file);
|
2014-12-22 23:51:36 +00:00
|
|
|
|
|
|
|
signals:
|
|
|
|
|
|
|
|
public slots:
|
2015-08-24 19:30:56 +00:00
|
|
|
/**
|
|
|
|
* @brief Mark the start of a code block that retaps packets. If the user
|
|
|
|
* closes the dialog while tapping, the dialog will not be destroyed until
|
|
|
|
* endRetapPackets is called.
|
|
|
|
*
|
|
|
|
* This is automatically called when tapping begins, but might need to be
|
|
|
|
* called explicilty if any member functions are called or variables are
|
|
|
|
* accessed after tapping is finished.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void beginRetapPackets() { retap_depth_++; }
|
|
|
|
/**
|
|
|
|
* @brief Mark the end of a code block that retaps packets. If the user
|
|
|
|
* has closed the dialog it will be desroyed at this point.
|
|
|
|
*
|
|
|
|
* This is automatically called when tapping ends, but might need to be
|
|
|
|
* called explicilty if any member functions are called or variables are
|
|
|
|
* accessed after tapping is finished.
|
|
|
|
*/
|
2015-12-06 21:29:53 +00:00
|
|
|
virtual void endRetapPackets();
|
2014-12-22 23:51:36 +00:00
|
|
|
|
|
|
|
protected:
|
2015-01-15 01:25:56 +00:00
|
|
|
virtual void keyPressEvent(QKeyEvent *event) { QDialog::keyPressEvent(event); }
|
2015-07-24 17:24:15 +00:00
|
|
|
virtual void accept();
|
|
|
|
virtual void reject();
|
|
|
|
|
2015-08-24 19:30:56 +00:00
|
|
|
/**
|
|
|
|
* @brief Set the window subtitle, e.g. "Foo Timeouts". The subtitle and
|
|
|
|
* file name will be added to the dialog window title.
|
|
|
|
* @param subtitle The subtitle to add. It should be unique, short, and
|
|
|
|
* descriptive.
|
|
|
|
*/
|
2014-12-22 23:51:36 +00:00
|
|
|
void setWindowSubtitle(const QString &subtitle);
|
2015-06-05 20:17:13 +00:00
|
|
|
const QString &windowSubtitle() { return subtitle_; }
|
2014-12-22 23:51:36 +00:00
|
|
|
virtual void updateWidgets();
|
|
|
|
|
2015-08-24 19:30:56 +00:00
|
|
|
// Capture file and tapping
|
2014-12-22 23:51:36 +00:00
|
|
|
CaptureFile &cap_file_;
|
2015-08-24 19:30:56 +00:00
|
|
|
/**
|
|
|
|
* @brief Convenience wrapper for register_tap_listener. Tap
|
|
|
|
* listeners registered via this function are automatically
|
|
|
|
* removed during destruction. They can also be explicitly
|
|
|
|
* removed using remove_tap_listener or removeTapListeners.
|
|
|
|
*
|
|
|
|
* Shows a warning dialog if registration is unsuccessful.
|
|
|
|
* @param tap_name A registered tap name.
|
|
|
|
* @param tap_data A unique pointer. Usually 'this'.
|
|
|
|
* @param filter A display filter.
|
|
|
|
* @param flags See register_tap_listener.
|
|
|
|
* @param tap_reset Reset callback.
|
|
|
|
* @param tap_packet Per-packet callback.
|
|
|
|
* @param tap_draw Draw callback.
|
|
|
|
*/
|
|
|
|
bool registerTapListener(const char *tap_name, void *tap_data,
|
|
|
|
const char *filter, guint flags,
|
|
|
|
void (*tap_reset)(void *tapdata),
|
|
|
|
gboolean (*tap_packet)(void *tapdata, struct _packet_info *pinfo, struct epan_dissect *edt, const void *data),
|
|
|
|
void (*tap_draw)(void *tap_data));
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Remove all tap listeners registered via registerTapListener.
|
|
|
|
*/
|
|
|
|
void removeTapListeners();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief true if the file has been closed, false otherwise.
|
|
|
|
*/
|
|
|
|
// XXX Needs a getter?
|
2014-12-22 23:51:36 +00:00
|
|
|
bool file_closed_;
|
|
|
|
|
2016-03-01 00:34:32 +00:00
|
|
|
/**
|
|
|
|
* @brief Check to see if the user has closed (and not minimized) the dialog.
|
|
|
|
* @return true if the dialog has been closed, false otherwise.
|
|
|
|
*/
|
|
|
|
bool dialogClosed() { return dialog_closed_; }
|
|
|
|
|
2014-12-22 23:51:36 +00:00
|
|
|
protected slots:
|
2015-08-24 19:30:56 +00:00
|
|
|
/**
|
|
|
|
* @brief Called when the capture file is about to close. This can be
|
|
|
|
* used to enable or disable widgets according to the state of
|
|
|
|
* file_closed_.
|
|
|
|
*/
|
2014-12-22 23:51:36 +00:00
|
|
|
virtual void captureFileClosing();
|
2015-09-25 09:05:45 +00:00
|
|
|
virtual void captureFileClosed();
|
2014-12-22 23:51:36 +00:00
|
|
|
|
|
|
|
private:
|
2014-12-29 22:12:43 +00:00
|
|
|
void setWindowTitleFromSubtitle();
|
2016-02-28 18:23:20 +00:00
|
|
|
|
2015-08-24 19:30:56 +00:00
|
|
|
void tryDeleteLater();
|
2014-12-22 23:51:36 +00:00
|
|
|
|
|
|
|
QString subtitle_;
|
2015-08-24 19:30:56 +00:00
|
|
|
QList<void *> tap_listeners_;
|
|
|
|
int retap_depth_;
|
2016-03-01 00:34:32 +00:00
|
|
|
bool dialog_closed_;
|
2014-12-22 23:51:36 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // WIRESHARK_DIALOG_H
|
2014-12-29 16:11:01 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines
|
|
|
|
*
|
|
|
|
* Local Variables:
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* ex: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
|
|
*/
|