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