Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
main_application.h
Go to the documentation of this file.
1
10#ifndef MAIN_APPLICATION_H
11#define MAIN_APPLICATION_H
12
13#include <config.h>
14
15#include "wsutil/feature_list.h"
16
17#include "epan/register.h"
18
19#include "ui/help_url.h"
20
21#include <QApplication>
22#include <QDir>
23#include <QFont>
24#include <QIcon>
25#include <QTimer>
26#include <QTranslator>
27
28#include "capture_event.h"
29
30struct _e_prefs;
31
32class QAction;
33class QSocketNotifier;
34
35class MainWindow;
36
37class MainApplication : public QApplication
38{
39 Q_OBJECT
40public:
41 explicit MainApplication(int &argc, char **argv);
43
44 enum AppSignal {
45 CaptureFilterListChanged,
46 ColorsChanged,
47 ColumnsChanged,
48 DisplayFilterListChanged,
49 FieldsChanged,
50 FilterExpressionsChanged,
51 LocalInterfacesChanged,
52 NameResolutionChanged,
53 PacketDissectionChanged,
54 PreferencesChanged,
55 ProfileChanging,
56 RecentPreferencesRead,
57 FreezePacketList,
58 AggregationVisiblity,
59 AggregationChanged
60 };
61
62 enum MainMenuItem {
63 FileOpenDialog,
64 CaptureOptionsDialog
65 };
66
67 enum StatusInfo {
68 FilterSyntax,
69 FieldStatus,
70 FileStatus,
71 BusyStatus,
72 ByteStatus,
73 TemporaryStatus
74 };
75
76 void registerUpdate(register_action_e action, const char *message);
77 void emitAppSignal(AppSignal signal);
78 // Emitting app signals (PacketDissectionChanged in particular) from
79 // dialogs on macOS can be problematic. Dialogs should call queueAppSignal
80 // instead.
81 // On macOS, nested event loops (e.g., calling a dialog with exec())
82 // that call processEvents (e.g., from PacketDissectionChanged, or
83 // anything with a ProgressFrame) caused issues off and on from 5.3.0
84 // until 5.7.1/5.8.0. It appears to be solved after some false starts:
85 // https://bugreports.qt.io/browse/QTBUG-53947
86 // https://bugreports.qt.io/browse/QTBUG-56746
87 // We also try to avoid exec / additional event loops as much as possible:
88 // e.g., commit f67eccedd9836e6ced1f57ae9889f57a5400a3d7
89 // (note it can show up in unexpected places, e.g. static functions like
90 // WiresharkFileDialog::getOpenFileName())
91 void queueAppSignal(AppSignal signal) { app_signals_ << signal; }
92 void emitStatCommandSignal(const QString &menu_path, const char *arg, void *userdata);
93 void emitTapParameterSignal(const QString cfg_abbr, const QString arg, void *userdata);
94 void addDynamicMenuGroupItem(int group, QAction *sg_action);
95 void appendDynamicMenuGroupItem(int group, QAction *sg_action);
96 void removeDynamicMenuGroupItem(int group, QAction *sg_action);
97 QList<QAction *> dynamicMenuGroupItems(int group);
98 QList<QAction *> addedMenuGroupItems(int group);
99 QList<QAction *> removedMenuGroupItems(int group);
100 void clearAddedMenuGroupItems();
101 void clearRemovedMenuGroupItems();
102
103 void allSystemsGo(const char* name_proper, const char* version);
104 void emitLocalInterfaceEvent(const char *ifname, int added, int up);
105
106 virtual void refreshLocalInterfaces();
107#ifdef HAVE_LIBPCAP
108 // This returns a deep copy of the cached interface list that must
109 // be freed with free_interface_list.
110 GList * getInterfaceList() const;
111 // This set the cached interface list to a deep copy of if_list.
112 void setInterfaceList(GList *if_list);
113#endif
114
115 struct _e_prefs * readConfigurationFiles(bool reset);
116 QDir openDialogInitialDir();
117 void setLastOpenDirFromFilename(QString file_name);
118 void helpTopicAction(topic_action_e action);
119 const QFont monospaceFont(bool zoomed = false) const;
120 void setMonospaceFont(const char *font_string);
121 int monospaceTextSize(const char *str);
122 void setConfigurationProfile(const char *profile_name, bool write_recent_file = true);
123 void reloadLuaPluginsDelayed();
124 bool isInitialized() { return initialized_; }
125 void setReloadingLua(bool is_reloading) { is_reloading_lua_ = is_reloading; }
126 bool isReloadingLua() { return is_reloading_lua_; }
127 const QIcon &normalIcon();
128 const QIcon &captureIcon();
129 const QString &windowTitleSeparator() const { return window_title_separator_; }
130 const QString windowTitleString(QStringList title_parts);
131 const QString windowTitleString(QString title_part) { return windowTitleString(QStringList() << title_part); }
132 void applyCustomColorsFromRecent();
133#if defined(HAVE_SOFTWARE_UPDATE) && defined(Q_OS_WIN)
134 void rejectSoftwareUpdate() { software_update_ok_ = false; }
135 bool softwareUpdateCanShutdown();
136 void softwareUpdateShutdownRequest();
137#endif
138 MainWindow *mainWindow();
139
140 QTranslator translator;
141 QTranslator translatorQt;
142 void loadLanguage(const QString language);
143
144 void doTriggerMenuItem(MainMenuItem menuItem);
145
146 void zoomTextFont(int zoomLevel);
147
148 void pushStatus(StatusInfo sinfo, const QString &message, const QString &messagetip = QString());
149 void popStatus(StatusInfo sinfo);
150
151 void gotoFrame(int frameNum);
152 // Maximum nested menu depth.
153 int maxMenuDepth(void) { return 5; }
154
155private:
156 bool initialized_;
157 bool is_reloading_lua_;
158 QFont mono_font_;
159 QFont zoomed_font_;
160 QTimer packet_data_timer_;
161 QTimer tap_update_timer_;
162 QList<QString> pending_open_files_;
163 QSocketNotifier *if_notifier_;
164 static QString window_title_separator_;
165 QList<AppSignal> app_signals_;
166 int active_captures_;
167 bool refresh_interfaces_pending_;
168
169#if defined(HAVE_SOFTWARE_UPDATE) && defined(Q_OS_WIN)
170 bool software_update_ok_;
171#endif
172
173 void storeCustomColorsInRecent();
174 void clearDynamicMenuGroupItems();
175
176protected:
177 bool event(QEvent *event);
178 virtual void initializeIcons() = 0;
179
180 QIcon normal_icon_;
181 QIcon capture_icon_;
182#ifdef HAVE_LIBPCAP
183 GList *cached_if_list_;
184#endif
185
186signals:
187 void appInitialized();
188 void localInterfaceEvent(const char *ifname, int added, int up);
189 void scanLocalInterfaces(GList *filter_list = nullptr);
190 void localInterfaceListChanged();
191 void openCaptureFile(QString cf_path, QString display_filter, unsigned int type);
192 void openCaptureOptions();
193 void recentPreferencesRead();
194 void splashUpdate(register_action_e action, const char *message);
195 void profileChanging();
196 void profileNameChanged(const char *profile_name);
197
198 void freezePacketList(bool changing_profile);
199 void columnsChanged(); // XXX This recreates the packet list. We might want to rename it accordingly.
200 void captureFilterListChanged();
201 void displayFilterListChanged();
202 void filterExpressionsChanged();
203 void packetDissectionChanged();
204 void colorsChanged();
205 void preferencesChanged();
206 void addressResolutionChanged();
207 void columnDataChanged();
208 void checkDisplayFilter();
209 void fieldsChanged();
210 void reloadLuaPlugins();
211 void aggregationVisiblity();
212 void aggregationChanged();
213#if defined(HAVE_SOFTWARE_UPDATE) && defined(Q_OS_WIN)
214 // Each of these are called from a separate thread.
215 void softwareUpdateRequested();
216 void softwareUpdateQuit();
217#endif
218
219 void openStatCommandDialog(const QString &menu_path, const char *arg, void *userdata);
220 void openTapParameterDialog(const QString cfg_str, const QString arg, void *userdata);
221
222 /* Signals activation and stop of a capture. The value provides the number of active captures */
223 void captureActive(int);
224
225 void zoomRegularFont(const QFont & font);
226 void zoomMonospaceFont(const QFont & font);
227
228public slots:
229 void captureEventHandler(CaptureEvent);
230
231 // Flush queued app signals. Should be called from the main window after
232 // each dialog that calls queueAppSignal closes.
233 void flushAppSignals();
234
235 void reloadDisplayFilterMacros();
236
237private slots:
238 void updateTaps();
239
240 void cleanup();
241 void ifChangeEventsAvailable();
242 void refreshPacketData();
243#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) && defined(Q_OS_WIN)
244 void colorSchemeChanged();
245#endif
246};
247
248extern MainApplication *mainApp;
249
254#endif // MAIN_APPLICATION_H
Definition capture_event.h:21
Definition main_application.h:38
Definition main_window.h:48
GList ** feature_list
Semi-opaque handle to a list of features or dependencies.
Definition feature_list.h:33
void gather_wireshark_runtime_info(feature_list l)
Definition main.cpp:253
void gather_wireshark_qt_compiled_info(feature_list l)
Definition main.cpp:212
Definition prefs.h:174