1 /* wireshark_application.h
3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef WIRESHARK_APPLICATION_H
23 #define WIRESHARK_APPLICATION_H
29 #include "epan/register.h"
31 #include "ui/help_url.h"
33 #include <QApplication>
38 #include <QTranslator>
43 class QSocketNotifier;
47 // - Add from open file
48 // - Check current list
49 // - Signal updated item
51 typedef struct _recent_item_status {
58 class WiresharkApplication : public QApplication
62 explicit WiresharkApplication(int &argc, char **argv);
63 ~WiresharkApplication();
66 CaptureFilterListChanged,
68 DisplayFilterListChanged,
70 FilterExpressionsChanged,
71 LocalInterfacesChanged,
72 NameResolutionChanged,
73 PacketDissectionChanged,
75 RecentCapturesChanged,
84 void registerUpdate(register_action_e action, const char *message);
85 void emitAppSignal(AppSignal signal);
86 // Emitting app signals (PacketDissectionChanged in particular) from
87 // dialogs on macOS can be problematic. Dialogs should call queueAppSignal
89 void queueAppSignal(AppSignal signal) { app_signals_ << signal; }
90 // Flush queued app signals. Should be called from the main window after
91 // each dialog that calls queueAppSignal closes.
92 void flushAppSignals();
93 void emitStatCommandSignal(const QString &menu_path, const char *arg, void *userdata);
94 void emitTapParameterSignal(const QString cfg_abbr, const QString arg, void *userdata);
95 void addDynamicMenuGroupItem(int group, QAction *sg_action);
96 void appendDynamicMenuGroupItem(int group, QAction *sg_action);
97 void removeDynamicMenuGroupItem(int group, QAction *sg_action);
98 QList<QAction *> dynamicMenuGroupItems(int group);
99 QList<QAction *> addedMenuGroupItems(int group);
100 QList<QAction *> removedMenuGroupItems(int group);
101 void clearAddedMenuGroupItems();
102 void clearRemovedMenuGroupItems();
105 void refreshLocalInterfaces();
106 struct _e_prefs * readConfigurationFiles(bool reset);
107 QList<recent_item_status *> recentItems() const;
108 void addRecentItem(const QString filename, qint64 size, bool accessible);
109 void removeRecentItem(const QString &filename);
111 void setLastOpenDir(const char *dir_name);
112 void setLastOpenDir(QString *dir_str);
113 void helpTopicAction(topic_action_e action);
114 const QFont monospaceFont() const { return mono_font_; }
115 void setMonospaceFont(const char *font_string);
116 int monospaceTextSize(const char *str);
117 void setConfigurationProfile(const gchar *profile_name, bool write_recent = true);
118 void reloadLuaPluginsDelayed();
119 bool isInitialized() { return initialized_; }
120 void setReloadingLua(bool is_reloading) { is_reloading_lua_ = is_reloading; }
121 bool isReloadingLua() { return is_reloading_lua_; }
122 const QIcon &normalIcon();
123 const QIcon &captureIcon();
124 const QString &windowTitleSeparator() const { return window_title_separator_; }
125 const QString windowTitleString(QStringList title_parts);
126 const QString windowTitleString(QString title_part) { return windowTitleString(QStringList() << title_part); }
127 void applyCustomColorsFromRecent();
128 #ifdef HAVE_SOFTWARE_UPDATE
129 void rejectSoftwareUpdate() { software_update_ok_ = false; }
130 bool softwareUpdateCanShutdown();
131 void softwareUpdateShutdownRequest();
133 QWidget *mainWindow();
135 QTranslator translator;
136 QTranslator translatorQt;
137 void loadLanguage(const QString language);
139 void doTriggerMenuItem(MainMenuItem menuItem);
141 void zoomTextFont(int zoomLevel);
145 bool is_reloading_lua_;
147 QTimer recent_timer_;
148 QTimer addr_resolv_timer_;
149 QTimer tap_update_timer_;
150 QList<QString> pending_open_files_;
151 QSocketNotifier *if_notifier_;
154 static QString window_title_separator_;
155 QList<AppSignal> app_signals_;
156 int active_captures_;
157 #ifdef HAVE_SOFTWARE_UPDATE
158 bool software_update_ok_;
161 void storeCustomColorsInRecent();
163 unsigned int fileVersion(QString file_path);
166 void clearDynamicMenuGroupItems();
167 void initializeIcons();
170 bool event(QEvent *event);
173 void appInitialized();
174 void localInterfaceListChanged();
175 void openCaptureFile(QString cf_path, QString display_filter, unsigned int type);
176 void openCaptureOptions();
177 void recentPreferencesRead();
178 void updateRecentCaptureStatus(const QString &filename, qint64 size, bool accessible);
179 void splashUpdate(register_action_e action, const char *message);
180 void profileChanging();
181 void profileNameChanged(const gchar *profile_name);
183 void columnsChanged(); // XXX This recreates the packet list. We might want to rename it accordingly.
184 void captureFilterListChanged();
185 void displayFilterListChanged();
186 void filterExpressionsChanged();
187 void packetDissectionChanged();
188 void preferencesChanged();
189 void addressResolutionChanged();
190 void checkDisplayFilter();
191 void fieldsChanged();
192 void reloadLuaPlugins();
193 #ifdef HAVE_SOFTWARE_UPDATE
194 // Each of these are called from a separate thread.
195 void softwareUpdateRequested();
196 void softwareUpdateClose();
197 void softwareUpdateQuit();
200 void openStatCommandDialog(const QString &menu_path, const char *arg, void *userdata);
201 void openTapParameterDialog(const QString cfg_str, const QString arg, void *userdata);
203 /* Signals activation and stop of a capture. The value provides the number of active captures */
204 void captureActive(int);
206 void zoomMonospaceFont(const QFont & font);
209 void clearRecentCaptures();
210 void captureFileReadStarted();
211 void captureStarted();
212 void captureFinished();
217 void ifChangeEventsAvailable();
218 void itemStatusFinished(const QString filename = "", qint64 size = 0, bool accessible = false);
219 void refreshRecentCaptures(void);
220 void refreshAddressResolution(void);
223 extern WiresharkApplication *wsApp;
225 /** Global compile time version string */
226 extern void get_wireshark_qt_compiled_info(GString *str);
227 extern void get_gui_compiled_info(GString *str);
228 /** Global runtime version string */
229 extern void get_wireshark_runtime_info(GString *str);
230 #endif // WIRESHARK_APPLICATION_H
238 * indent-tabs-mode: nil
241 * ex: set shiftwidth=4 tabstop=8 expandtab:
242 * :indentSize=4:tabSize=8:noTabs=true: