|
Wireshark 4.7.3
The Wireshark network protocol analyzer
|
Core application class handling global state, signals, and configurations. More...
#include <main_application.h>
Public Types | |
| enum | AppSignal { CaptureFilterListChanged , ColumnsChanged , DisplayFilterListChanged , FieldsChanged , FilterExpressionsChanged , NameResolutionChanged , PacketDissectionChanged , PreferencesChanged , RecentPreferencesRead , FreezePacketList , AggregationChanged } |
| Enumeration of application-wide signals. More... | |
| enum | MainMenuItem { FileOpenDialog , CaptureOptionsDialog } |
| Enumeration for standard main menu items. More... | |
| enum | StatusInfo { FilterSyntax , FieldStatus , FileStatus , BusyStatus , ByteStatus , TemporaryStatus } |
| Enumeration for status bar information types. More... | |
Public Slots | |
| void | captureEventHandler (CaptureEvent ev) |
| Slot for handling capture events. | |
| void | flushAppSignals () |
| Flushes queued app signals. | |
| void | reloadDisplayFilterMacros () |
| Reloads display filter macros. | |
Public Member Functions | |
| MainApplication (int &argc, char **argv) | |
| Constructs the MainApplication. | |
| ~MainApplication () | |
| Destroys the MainApplication. | |
| void | emitAppSignal (AppSignal signal) |
| Emits a specific application signal. | |
| void | queueAppSignal (AppSignal signal) |
| Queues an application signal to be emitted later. | |
| void | emitStatCommandSignal (const QString &menu_path, const char *arg, void *userdata) |
| Emits a signal to execute a statistics command. | |
| void | emitTapParameterSignal (const QString cfg_abbr, const QString arg, void *userdata) |
| Emits a signal indicating tap parameters changed. | |
| void | addDynamicMenuGroupItem (int group, QAction *sg_action) |
| Adds an action item to a dynamic menu group. | |
| void | appendDynamicMenuGroupItem (int group, QAction *sg_action) |
| Appends an action item to a dynamic menu group. | |
| void | removeDynamicMenuGroupItem (int group, QAction *sg_action) |
| Removes an action item from a dynamic menu group. | |
| QList< QAction * > | dynamicMenuGroupItems (int group) |
| Retrieves all action items for a dynamic menu group. | |
| QList< QAction * > | addedMenuGroupItems (int group) |
| Retrieves items recently added to a dynamic menu group. | |
| QList< QAction * > | removedMenuGroupItems (int group) |
| Retrieves items recently removed from a dynamic menu group. | |
| void | clearAddedMenuGroupItems () |
| Clears the list of tracked added menu group items. | |
| void | clearRemovedMenuGroupItems () |
| Clears the list of tracked removed menu group items. | |
| void | allSystemsGo () |
| Indicates that initial setup is complete and all systems are operational. | |
| void | emitLocalInterfaceEvent (const char *ifname, int added, int up) |
| Emits a signal regarding local interface status changes. | |
| struct _e_prefs * | readConfigurationFiles (bool reset) |
| Reads application configuration files. | |
| QDir | openDialogInitialDir () |
| Retrieves the initial directory for open dialogs. | |
| void | setLastOpenDirFromFilename (QString file_name) |
| Sets the last opened directory from a given filename. | |
| void | helpTopicAction (topic_action_e action) |
| Executes a help topic action. | |
| void | setConfigurationProfile (const char *profile_name, bool write_recent_file=true) |
| Sets the active configuration profile. | |
| void | reloadLuaPluginsDelayed () |
| Triggers a delayed reload of Lua plugins. | |
| bool | isInitialized () |
| Checks if the application is initialized. | |
| template<typename Func> | |
| void | whenInitialized (const QObject *context, Func &&fn) |
Runs fn once the application has finished initialization. | |
| void | setReloadingLua (bool is_reloading) |
| Sets the flag indicating if Lua is currently reloading. | |
| bool | isReloadingLua () |
| Checks if Lua plugins are currently reloading. | |
| const QIcon & | normalIcon () |
| Retrieves the normal application icon. | |
| const QIcon & | captureIcon () |
| Retrieves the capture application icon. | |
| const QString & | windowTitleSeparator () const |
| Retrieves the window title separator string. | |
| const QString | windowTitleString (QStringList title_parts) |
| Generates a window title from parts. | |
| const QString | windowTitleString (QString title_part) |
| Generates a window title with a single part. | |
| void | applyCustomColorsFromRecent () |
| Applies custom colors stored in recent files. | |
| MainWindow * | mainWindow () |
| Retrieves the main window instance. | |
| void | loadLanguage (const QString language) |
| Loads a specific UI language. | |
| void | doTriggerMenuItem (MainMenuItem menuItem) |
| Triggers a specific main menu item. | |
| void | pushStatus (StatusInfo sinfo, const QString &message, const QString &messagetip=QString()) |
| Pushes a message to the specified status bar section. | |
| void | popStatus (StatusInfo sinfo) |
| Pops the most recent status message of a given type. | |
| void | gotoFrame (int frameNum) |
| Triggers navigation to a specific frame number. | |
| int | maxMenuDepth (void) |
| Defines the maximum nested depth allowed for menus. | |
Public Attributes | |
| QTranslator | translator |
| QTranslator | translatorQt |
Protected Member Functions | |
| bool | event (QEvent *event) override |
| Core Qt event handler override. | |
| virtual void | initializeIcons ()=0 |
| Pure virtual method for initializing application icons. | |
Protected Attributes | |
| QIcon | normal_icon_ |
| QIcon | capture_icon_ |
Core application class handling global state, signals, and configurations.
Enumeration of application-wide signals.
|
explicit |
Constructs the MainApplication.
| argc | Reference to the argument count. |
| argv | Array of argument strings. |
| void MainApplication::addDynamicMenuGroupItem | ( | int | group, |
| QAction * | sg_action ) |
Adds an action item to a dynamic menu group.
| group | The menu group ID. |
| sg_action | The action to add. |
| QList< QAction * > MainApplication::addedMenuGroupItems | ( | int | group | ) |
Retrieves items recently added to a dynamic menu group.
| group | The menu group ID. |
| void MainApplication::appendDynamicMenuGroupItem | ( | int | group, |
| QAction * | sg_action ) |
Appends an action item to a dynamic menu group.
| group | The menu group ID. |
| sg_action | The action to append. |
|
slot |
Slot for handling capture events.
| ev | The capture event to process. |
| const QIcon & MainApplication::captureIcon | ( | ) |
Retrieves the capture application icon.
| void MainApplication::doTriggerMenuItem | ( | MainMenuItem | menuItem | ) |
Triggers a specific main menu item.
| menuItem | The MainMenuItem to trigger. |
| QList< QAction * > MainApplication::dynamicMenuGroupItems | ( | int | group | ) |
Retrieves all action items for a dynamic menu group.
| group | The menu group ID. |
| void MainApplication::emitAppSignal | ( | AppSignal | signal | ) |
Emits a specific application signal.
| signal | The AppSignal to emit. |
| void MainApplication::emitLocalInterfaceEvent | ( | const char * | ifname, |
| int | added, | ||
| int | up ) |
Emits a signal regarding local interface status changes.
| ifname | The name of the interface. |
| added | Indicator if the interface was added. |
| up | Indicator if the interface is up. |
| void MainApplication::emitStatCommandSignal | ( | const QString & | menu_path, |
| const char * | arg, | ||
| void * | userdata ) |
Emits a signal to execute a statistics command.
| menu_path | The menu path associated with the command. |
| arg | The argument string for the command. |
| userdata | Pointer to additional user data. |
| void MainApplication::emitTapParameterSignal | ( | const QString | cfg_abbr, |
| const QString | arg, | ||
| void * | userdata ) |
Emits a signal indicating tap parameters changed.
| cfg_abbr | Configuration abbreviation string. |
| arg | Tap argument string. |
| userdata | Pointer to additional user data. |
|
overrideprotected |
Core Qt event handler override.
| event | The event to process. |
|
slot |
Flushes queued app signals.
Should be called from the main window after each dialog that calls queueAppSignal closes.
| void MainApplication::gotoFrame | ( | int | frameNum | ) |
Triggers navigation to a specific frame number.
| frameNum | The frame number to navigate to. |
| void MainApplication::helpTopicAction | ( | topic_action_e | action | ) |
Executes a help topic action.
| action | The specific topic action to execute. |
|
inline |
Checks if the application is initialized.
|
inline |
Checks if Lua plugins are currently reloading.
| void MainApplication::loadLanguage | ( | const QString | language | ) |
Loads a specific UI language.
| language | The language code to load. |
| MainWindow * MainApplication::mainWindow | ( | ) |
Retrieves the main window instance.
|
inline |
Defines the maximum nested depth allowed for menus.
| const QIcon & MainApplication::normalIcon | ( | ) |
Retrieves the normal application icon.
| QDir MainApplication::openDialogInitialDir | ( | ) |
Retrieves the initial directory for open dialogs.
| void MainApplication::popStatus | ( | StatusInfo | sinfo | ) |
Pops the most recent status message of a given type.
| sinfo | The StatusInfo type to clear. |
| void MainApplication::pushStatus | ( | StatusInfo | sinfo, |
| const QString & | message, | ||
| const QString & | messagetip = QString() ) |
Pushes a message to the specified status bar section.
| sinfo | The StatusInfo type. |
| message | The text message to display. |
| messagetip | Optional tooltip for the status. |
|
inline |
Queues an application signal to be emitted later.
Emitting app signals (PacketDissectionChanged in particular) from dialogs on macOS can be problematic. Dialogs should call queueAppSignal instead. On macOS, nested event loops (e.g., calling a dialog with exec()) that call processEvents (e.g., from PacketDissectionChanged, or anything with a ProgressFrame) caused issues off and on from 5.3.0 until 5.7.1/5.8.0. It appears to be solved after some false starts: https://bugreports.qt.io/browse/QTBUG-53947 https://bugreports.qt.io/browse/QTBUG-56746 We also try to avoid exec / additional event loops as much as possible: e.g., commit f67eccedd9836e6ced1f57ae9889f57a5400a3d7 (note it can show up in unexpected places, e.g. static functions like WiresharkFileDialog::getOpenFileName())
| signal | The AppSignal to queue. |
| _e_prefs * MainApplication::readConfigurationFiles | ( | bool | reset | ) |
Reads application configuration files.
| reset | Whether to reset preferences to defaults. |
| QList< QAction * > MainApplication::removedMenuGroupItems | ( | int | group | ) |
Retrieves items recently removed from a dynamic menu group.
| group | The menu group ID. |
| void MainApplication::removeDynamicMenuGroupItem | ( | int | group, |
| QAction * | sg_action ) |
Removes an action item from a dynamic menu group.
| group | The menu group ID. |
| sg_action | The action to remove. |
| void MainApplication::setConfigurationProfile | ( | const char * | profile_name, |
| bool | write_recent_file = true ) |
Sets the active configuration profile.
| profile_name | The name of the profile. |
| write_recent_file | True to save the choice to recent files. |
| void MainApplication::setLastOpenDirFromFilename | ( | QString | file_name | ) |
Sets the last opened directory from a given filename.
| file_name | The path to the file. |
|
inline |
Sets the flag indicating if Lua is currently reloading.
| is_reloading | True if reloading, false otherwise. |
|
inline |
Runs fn once the application has finished initialization.
If initialization has already completed, fn is dispatched per the policy implemented below (see whenInitializedDispatch()). Otherwise it is connected to appInitialized() with context as the connection's receiver, so the connection is torn down automatically when context is destroyed and the callback runs on context's thread.
This replaces the open-coded if (mainApp->isInitialized()) doThing(); else connect(mainApp, &MainApplication::appInitialized, this, &Cls::doThing); pattern: late subscribers no longer have to branch by hand, so a slot can never be silently dropped by connecting after the signal already fired.
| context | Receiver object governing lifetime/thread of the callback. |
| fn | Zero-argument callable to run when initialization is complete. |
|
inline |
Retrieves the window title separator string.
|
inline |
Generates a window title with a single part.
| title_part | The part to prepend to the default title. |
| const QString MainApplication::windowTitleString | ( | QStringList | title_parts | ) |
Generates a window title from parts.
| title_parts | The parts to combine into the title. |
|
protected |
Icon for active capture state.
|
protected |
Icon for standard application state.
| QTranslator MainApplication::translator |
Main Qt application translator.
| QTranslator MainApplication::translatorQt |
Base Qt translator for standard strings.