Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
export_objects_model.h
Go to the documentation of this file.
1
12#ifndef EXPORT_OBJECTS_MODEL_H
13#define EXPORT_OBJECTS_MODEL_H
14
15#include <config.h>
16
17#include <epan/tap.h>
18#include <epan/export_object.h>
19
20#include <QAbstractTableModel>
21#include <QSortFilterProxyModel>
22#include <QList>
23#include <QSet>
24
32
37{
38public:
43 explicit ExportObjectEntry(export_object_entry_t *entry = nullptr) : entry(entry) {}
44
50 bool operator==(const ExportObjectEntry &other) const {
51 return eo_entry_equal(entry, other.entry);
52 }
53#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
58 QByteArray Data() const { return entry ? QByteArray::fromRawData(reinterpret_cast<const char*>(entry->payload_data), entry->payload_len) : QByteArray(); }
59#else
64 QByteArrayView Data() const { return entry ? QByteArrayView(entry->payload_data, entry->payload_len) : QByteArrayView(); }
65#endif
70 uint32_t PacketNum() const { return entry ? entry->pkt_num : 0; }
71
72private:
75};
76
83size_t qHash(const ExportObjectEntry& entry, size_t seed = 0);
84
88class ExportObjectModel : public QAbstractTableModel
89{
90 Q_OBJECT
91
92public:
98 ExportObjectModel(register_eo_t* eo, QObject *parent);
99
103 virtual ~ExportObjectModel();
104
116
122
129
133 void resetObjects();
134
141 bool saveEntry(const QModelIndex &index, QString filename);
142
148 void saveEntries(const QModelIndexList &indices, QString path);
149
154 void saveAllEntries(QString path);
155
160 const char* getTapListenerName();
161
166 void* getTapData();
167
172 tap_packet_cb getTapPacketFunc();
173
178 static void resetTap(void *tapdata);
179
183 void removeTap();
184
191 QVariant data(const QModelIndex &index, int role) const;
192
200 QVariant headerData(int section, Qt::Orientation orientation,
201 int role = Qt::DisplayRole) const;
202
208 int rowCount(const QModelIndex &parent = QModelIndex()) const;
209
215 int columnCount(const QModelIndex &parent = QModelIndex()) const;
216
217private:
219 QList<QVariant> objects_;
220
222 QSet<ExportObjectEntry> object_set_;
223
225 export_object_list_t export_object_list_;
226
228 export_object_list_gui_t eo_gui_data_;
229
231 register_eo_t* eo_;
232};
233
237class ExportObjectProxyModel : public QSortFilterProxyModel
238{
239public:
240
245 explicit ExportObjectProxyModel(QObject * parent = Q_NULLPTR);
246
251 void setContentFilterString(QString contentFilter);
252
257 void setTextFilterString(QString textFilter);
258
263 void setUniqueFilter(bool unique);
264
265protected:
272 bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const;
273
280 bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
281
282private:
284 QString contentFilter_;
285
287 QString textFilter_;
288
290 bool uniqueFilter_;
291
292};
293
294#endif // EXPORT_OBJECTS_MODEL_H
A wrapper class for an export object entry.
Definition export_objects_model.h:37
bool operator==(const ExportObjectEntry &other) const
Compares two ExportObjectEntry instances for equality.
Definition export_objects_model.h:50
QByteArrayView Data() const
Retrieves the payload data view for the entry.
Definition export_objects_model.h:64
ExportObjectEntry(export_object_entry_t *entry=nullptr)
Constructs a new ExportObjectEntry.
Definition export_objects_model.h:43
uint32_t PacketNum() const
Retrieves the packet number associated with the entry.
Definition export_objects_model.h:70
A table model managing a list of exportable objects extracted from network traffic.
Definition export_objects_model.h:89
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Retrieves the header data for a specific section and role.
Definition export_objects_model.cpp:112
void resetObjects()
Resets and clears all object entries from the model.
Definition export_objects_model.cpp:263
void addObjectEntry(export_object_entry_t *entry)
Adds a new export object entry to the model.
Definition export_objects_model.cpp:148
static void resetTap(void *tapdata)
Static callback used to reset the tap data.
Definition export_objects_model.cpp:281
tap_packet_cb getTapPacketFunc()
Retrieves the callback function used for processing tap packets.
Definition export_objects_model.cpp:299
virtual ~ExportObjectModel()
Destroys the ExportObjectModel.
Definition export_objects_model.cpp:59
void saveAllEntries(QString path)
Saves all entries in the model to a directory.
Definition export_objects_model.cpp:222
int rowCount(const QModelIndex &parent=QModelIndex()) const
Returns the number of rows under a given parent.
Definition export_objects_model.cpp:133
export_object_entry_t * objectEntry(int row)
Retrieves the export object entry at a specific row.
Definition export_objects_model.cpp:160
void saveEntries(const QModelIndexList &indices, QString path)
Saves multiple entries to a directory.
Definition export_objects_model.cpp:181
ExportObjectColumn
Enumerates the columns for the export object model.
Definition export_objects_model.h:108
@ colFilename
Definition export_objects_model.h:113
@ colHostname
Definition export_objects_model.h:110
@ colExportObjectMax
Definition export_objects_model.h:114
@ colPacket
Definition export_objects_model.h:109
@ colSize
Definition export_objects_model.h:112
@ colContent
Definition export_objects_model.h:111
const char * getTapListenerName()
Retrieves the name of the tap listener.
Definition export_objects_model.cpp:289
void removeTap()
Removes the associated tap listener.
Definition export_objects_model.cpp:304
void * getTapData()
Retrieves the tap data pointer.
Definition export_objects_model.cpp:294
bool saveEntry(const QModelIndex &index, QString filename)
Saves a specific entry to a file.
Definition export_objects_model.cpp:165
int columnCount(const QModelIndex &parent=QModelIndex()) const
Returns the number of columns under a given parent.
Definition export_objects_model.cpp:143
A proxy model used for sorting and filtering export objects.
Definition export_objects_model.h:238
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
Determines whether a row from the source model matches the active filters and should be displayed.
Definition export_objects_model.cpp:377
void setUniqueFilter(bool unique)
Sets the filter to determine whether to show only unique items.
Definition export_objects_model.cpp:364
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
Compares two source indices to determine their sort order.
Definition export_objects_model.cpp:317
void setTextFilterString(QString textFilter)
Sets the text filter string used for general searching.
Definition export_objects_model.cpp:351
void setContentFilterString(QString contentFilter)
Sets the filter string used for matching content types.
Definition export_objects_model.cpp:338
size_t qHash(const ExportObjectEntry &entry, size_t seed=0)
Computes the hash for an ExportObjectEntry.
Definition export_objects_model.cpp:43
Represents a single object extracted from a packet capture for export.
Definition export_object.h:21
uint8_t * payload_data
Definition export_object.h:27
uint32_t pkt_num
Definition export_object.h:22
size_t payload_len
Definition export_object.h:26
Abstracts the GUI-specific operations needed to manage a list of exported objects during dissection.
Definition export_object.h:54
GUI context data for the export object list.
Definition export_objects_model.h:28
class ExportObjectModel * model
Pointer to the export object model.
Definition export_objects_model.h:30
Definition export_object.c:19