Qt: expose CaptureEvent definition for MOC

All WiresharkDialog instances have a "captureEvent(CaptureEvent)" method
that requires the definition of "CaptureEvent" from capture_file.h.
By luck, this definition is available for CMake builds due to the
generated MOC headers being included in the right order, but this cannot
be relied on. On an autotools build with less luck:

    main_status_bar.moc.cpp: In static member function ‘static void MainStatusBar::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)’:
    main_status_bar.moc.cpp:241:86: error: invalid use of incomplete type ‘class CaptureEvent’
             case 28: _t->captureEventHandler((*reinterpret_cast< CaptureEvent(*)>(_a[1]))); break;

Create a new header file to limit exposure of the CaptureFile class.

Change-Id: I4ab609f13b9438797e39e7b98f367da35536979b
Fixes: v2.9.0rc0-186-g57bf7e4347 ("Qt: Fix memory leak for CaptureEvent")
Reviewed-on: https://code.wireshark.org/review/27003
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Peter Wu 2018-04-18 12:37:20 +02:00 committed by Anders Broman
parent 8740ac8d4c
commit ad71a91540
3 changed files with 84 additions and 57 deletions

81
ui/qt/capture_event.h Normal file
View File

@ -0,0 +1,81 @@
/* capture_event.h
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef CAPTURE_EVENT_H
#define CAPTURE_EVENT_H
#include <QEvent>
typedef struct _capture_session capture_session;
struct _packet_info;
class CaptureEvent
{
public:
enum Context {
#ifdef HAVE_LIBPCAP
Capture = 0x0001,
Update = 0x0100 | Capture,
Fixed = 0x0200 | Capture,
#endif
File = 0x0002,
Reload = 0x0100 | File,
Rescan = 0x0200 | File,
Save = 0x0400 | File,
Retap = 0x0800 | File,
Merge = 0x1000 | File
};
enum EventType {
Opened = 0x0001,
Started = 0x0002,
Finished = 0x0004,
Closing = 0x0008,
Closed = 0x0010,
Failed = 0x0020,
Stopped = 0x0040,
Flushed = 0x0080,
Prepared = 0x0100,
Continued = 0x0200,
Stopping = 0x0400
};
CaptureEvent(Context ctx, EventType evt);
CaptureEvent(Context ctx, EventType evt, QString file);
CaptureEvent(Context ctx, EventType evt, capture_session * session);
CaptureEvent(const CaptureEvent &ce);
Context captureContext() const;
EventType eventType() const;
QString filePath() const;
capture_session * capSession() const;
private:
Context _ctx;
EventType _evt;
QString _filePath;
capture_session * _session;
};
#endif // CAPTURE_EVENT_H
/*
* 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:
*/

View File

@ -10,67 +10,13 @@
#define CAPTURE_FILE_H
#include <QObject>
#include <QEvent>
#include <config.h>
#include <glib.h>
#include "cfile.h"
typedef struct _capture_session capture_session;
struct _packet_info;
class CaptureEvent
{
public:
enum Context {
#ifdef HAVE_LIBPCAP
Capture = 0x0001,
Update = 0x0100 | Capture,
Fixed = 0x0200 | Capture,
#endif
File = 0x0002,
Reload = 0x0100 | File,
Rescan = 0x0200 | File,
Save = 0x0400 | File,
Retap = 0x0800 | File,
Merge = 0x1000 | File
};
enum EventType {
Opened = 0x0001,
Started = 0x0002,
Finished = 0x0004,
Closing = 0x0008,
Closed = 0x0010,
Failed = 0x0020,
Stopped = 0x0040,
Flushed = 0x0080,
Prepared = 0x0100,
Continued = 0x0200,
Stopping = 0x0400
};
CaptureEvent(Context ctx, EventType evt);
CaptureEvent(Context ctx, EventType evt, QString file);
CaptureEvent(Context ctx, EventType evt, capture_session * session);
CaptureEvent(const CaptureEvent &ce);
Context captureContext() const;
EventType eventType() const;
QString filePath() const;
capture_session * capSession() const;
private:
Context _ctx;
EventType _evt;
QString _filePath;
capture_session * _session;
};
#include "capture_event.h"
class CaptureFile : public QObject
{

View File

@ -25,13 +25,13 @@
#include <QTimer>
#include <QTranslator>
#include "capture_event.h"
struct _e_prefs;
class QAction;
class QSocketNotifier;
class CaptureEvent;
// Recent items:
// - Read from prefs
// - Add from open file