3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * SPDX-License-Identifier: GPL-2.0-or-later
10 #ifndef CAPTURE_FILE_H
11 #define CAPTURE_FILE_H
18 #include "capture_event.h"
20 class CaptureFile
: public QObject
24 explicit CaptureFile(QObject
*parent
= 0, capture_file
*cap_file
= NULL
);
27 capture_file
*capFile() const { return isValid() ? cap_file_
: NULL
; }
28 void setCapFile(capture_file
*cap_file
) { cap_file_
= cap_file
; }
30 /** Check capture file validity
32 * @return true if the file is open, readable, and tappable. false if the file
37 /** Return the full pathname.
39 * @return The entire pathname, converted from the native OS's encoding
40 * to Unicode if necessary, or a null string if the conversion can't
43 const QString
filePath();
45 /** Return the plain filename.
47 * @return The last component of the pathname, including the extension,
48 * converted from the native OS's encoding to Unicode if necessary, or
49 * a null string if the conversion can't be done.
51 const QString
fileName();
53 /** Return the plain filename without an extension.
55 * @return The last component of the pathname, without the extension,
56 * converted from the native OS's encoding to Unicode if necessary, or
57 * a null string if the conversion can't be done.
59 const QString
fileBaseName();
61 /** Return a string representing the file suitable for use for
62 * display in the UI in places such as a main window title.
66 * the devices on which the capture was done, if the file is a
67 * temporary file for a capture;
69 * the last component of the capture file's name, converted
70 * from the native OS's encoding to Unicode if necessary (and
71 * with REPLACEMENT CHARACTER inserted if the string can't
74 * a null string, if there is no capture file.
76 const QString
fileDisplayName();
78 /** Return a string representing the file suitable for use in an
79 * auxiliary window title.
83 * the result of fileDisplayName(), if the file is open;
85 * the result of fileDisplayName() followed by [closing], if
86 * the file is being closed;
88 * the result of fileDisplayName() followed by [closed], if
89 * the file has been closed;
91 * [no capture file], if there is no capture file.
93 const QString
fileTitle();
95 /** Return the current packet information.
97 * @return A pointer to the current packet_info struct or NULL.
99 struct _packet_info
*packetInfo();
101 /** Timestamp precision for the current file.
102 * @return One of the WTAP_TSPREC_x values defined in wiretap/wtap.h,
103 * or WTAP_TSPREC_UNKNOWN if no file is open.
105 int timestampPrecision();
107 /** Reload the capture file
111 /** Return any set display filter
113 QString
displayFilter() const;
115 // XXX This shouldn't be needed.
116 static capture_file
*globalCapFile();
121 void captureEvent(CaptureEvent
);
124 /** Retap the capture file. Convenience wrapper for cf_retap_packets.
125 * Application events are processed periodically via update_progress_dlg.
129 /** Retap the capture file after the current batch of application events
130 * is processed. If you call this instead of retapPackets or
131 * cf_retap_packets in a dialog's constructor it will be displayed before
134 void delayedRetapPackets();
136 /** Cancel any tapping that might be in progress.
140 /** Sets the capture file's "stop_flag" member.
142 * @param stop_flag If true, stops the current capture file operation.
144 void setCaptureStopFlag(bool stop_flag
= true);
147 static void captureFileCallback(int event
, void *data
, void *user_data
);
149 static void captureCallback(int event
, capture_session
*cap_session
, void *user_data
);
152 void captureFileEvent(int event
, void *data
);
153 void captureSessionEvent(int event
, capture_session
*cap_session
);
154 const QString
&getFileBasename();
156 static QString no_capture_file_
;
158 capture_file
*cap_file_
;
162 #endif // CAPTURE_FILE_H