| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
Public Types | Public Slots | Signals | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
MainApplication Class Referenceabstract

Core application class handling global state, signals, and configurations. More...

`#include <main_application.h>`

Inheritance diagram for MainApplication:

## 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.

## Signals
void | appInitialized ()
| Signal emitted when application is fully initialized.
void | localInterfaceEvent (const char *ifname, int added, int up)
| Signal emitted for local interface events (add/remove/up/down).
void | openCaptureFile (QString cf_path, QString display_filter, unsigned int type)
| Signal emitted to open a specific capture file.
void | openCaptureOptions ()
| Signal emitted to open the capture options dialog.
void | recentPreferencesRead ()
| Signal emitted when recent preferences are read.
void | profileChanging ()
| Signal emitted while the configuration profile is changing.
void | profileNameChanged (const char *profile_name)
| Signal emitted when the configuration profile name has changed.
void | freezePacketList (bool changing_profile)
| Signal emitted to freeze or unfreeze packet list updates.
void | columnsChanged ()
| Signal emitted when columns are changed (recreates packet list). XXX This recreates the packet list. We might want to rename it accordingly.
void | captureFilterListChanged ()
| Signal emitted when capture filters are changed.
void | displayFilterListChanged ()
| Signal emitted when display filters are changed.
void | filterExpressionsChanged ()
| Signal emitted when filter expressions are changed.
void | packetDissectionChanged ()
| Signal emitted when packet dissection settings are changed.
void | preferencesChanged ()
| Signal emitted when preferences are changed.
void | addressResolutionChanged ()
| Signal emitted when address resolution settings change.
void | columnDataChanged ()
| Signal emitted when column data definitions change.
void | checkDisplayFilter ()
| Signal emitted to check display filter validity.
void | fieldsChanged ()
| Signal emitted when protocol fields change.
void | reloadLuaPlugins ()
| Signal emitted to initiate a Lua plugin reload.
void | aggregationChanged ()
| Signal emitted when aggregation values change.
void | openStatCommandDialog (const QString &menu_path, const char *arg, void *userdata)
| Signal emitted to open a specific stat command dialog.
void | openTapParameterDialog (const QString cfg_str, const QString arg, void *userdata)
| Signal emitted to open a tap parameter dialog.
void | captureActive (int)
| Signals activation and stop of a capture. The value provides the number of active captures.

## 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_

## Detailed Description

Core application class handling global state, signals, and configurations.

## Member Enumeration Documentation

## ◆ AppSignal

enum MainApplication::AppSignal

Enumeration of application-wide signals.

Enumerator
CaptureFilterListChanged | Capture filter list changed.
ColumnsChanged | Packet list columns changed.
DisplayFilterListChanged | Display filter list changed.
FieldsChanged | Protocol fields changed.
FilterExpressionsChanged | Filter expressions changed.
NameResolutionChanged | Name resolution configuration changed.
PacketDissectionChanged | Packet dissection preferences changed.
PreferencesChanged | General preferences changed.
RecentPreferencesRead | Recent preferences have been read.
FreezePacketList | Freeze the packet list updates.
AggregationChanged | Aggregation logic or values changed.

## ◆ MainMenuItem

enum MainApplication::MainMenuItem

Enumeration for standard main menu items.

Enumerator
FileOpenDialog | The file open dialog action.
CaptureOptionsDialog | The capture options dialog action.

## ◆ StatusInfo

enum MainApplication::StatusInfo

Enumeration for status bar information types.

Enumerator
FilterSyntax | Filter syntax status.
FieldStatus | Protocol field status.
FileStatus | File operations status.
BusyStatus | Application busy status.
ByteStatus | Byte loading/processing status.
TemporaryStatus | General temporary status message.

## Constructor & Destructor Documentation

## ◆ MainApplication()

MainApplication::MainApplication | ( | int & | argc,
|  | char ** | argv )
| explicit

Constructs the MainApplication.

Parameters

  argc | Reference to the argument count.
  argv | Array of argument strings.

## Member Function Documentation

## ◆ addDynamicMenuGroupItem()

void MainApplication::addDynamicMenuGroupItem | ( | int | group,
|  | QAction * | sg_action )

Adds an action item to a dynamic menu group.

Parameters

  group | The menu group ID.
  sg_action | The action to add.

## ◆ addedMenuGroupItems()

QList< QAction * > MainApplication::addedMenuGroupItems | ( | int | group | ) |

Retrieves items recently added to a dynamic menu group.

Parameters

  group | The menu group ID.

Returns
  A list of added QAction pointers.

## ◆ appendDynamicMenuGroupItem()

void MainApplication::appendDynamicMenuGroupItem | ( | int | group,
|  | QAction * | sg_action )

Appends an action item to a dynamic menu group.

Parameters

  group | The menu group ID.
  sg_action | The action to append.

## ◆ captureEventHandler

void MainApplication::captureEventHandler | ( | CaptureEvent | ev | ) |
| slot

Slot for handling capture events.

Parameters

  ev | The capture event to process.

## ◆ captureIcon()

const QIcon & MainApplication::captureIcon | ( |  | ) |

Retrieves the capture application icon.

Returns
  The capture QIcon.

## ◆ doTriggerMenuItem()

void MainApplication::doTriggerMenuItem | ( | MainMenuItem | menuItem | ) |

Triggers a specific main menu item.

Parameters

  menuItem | The MainMenuItem to trigger.

## ◆ dynamicMenuGroupItems()

QList< QAction * > MainApplication::dynamicMenuGroupItems | ( | int | group | ) |

Retrieves all action items for a dynamic menu group.

Parameters

  group | The menu group ID.

Returns
  A list of QAction pointers.

## ◆ emitAppSignal()

void MainApplication::emitAppSignal | ( | AppSignal | signal | ) |

Emits a specific application signal.

Parameters

  signal | The AppSignal to emit.

## ◆ emitLocalInterfaceEvent()

void MainApplication::emitLocalInterfaceEvent | ( | const char * | ifname,
|  | int | added,
|  | int | up )

Emits a signal regarding local interface status changes.

Parameters

  ifname | The name of the interface.
  added | Indicator if the interface was added.
  up | Indicator if the interface is up.

## ◆ emitStatCommandSignal()

void MainApplication::emitStatCommandSignal | ( | const QString & | menu_path,
|  | const char * | arg,
|  | void * | userdata )

Emits a signal to execute a statistics command.

Parameters

  menu_path | The menu path associated with the command.
  arg | The argument string for the command.
  userdata | Pointer to additional user data.

## ◆ emitTapParameterSignal()

void MainApplication::emitTapParameterSignal | ( | const QString | cfg_abbr,
|  | const QString | arg,
|  | void * | userdata )

Emits a signal indicating tap parameters changed.

Parameters

  cfg_abbr | Configuration abbreviation string.
  arg | Tap argument string.
  userdata | Pointer to additional user data.

## ◆ event()

bool MainApplication::event | ( | QEvent * | event | ) |
| override protected

Core Qt event handler override.

Parameters

  event | The event to process.

Returns
  True if handled, false otherwise.

## ◆ flushAppSignals

void MainApplication::flushAppSignals | ( |  | ) |
| slot

Flushes queued app signals.

Should be called from the main window after each dialog that calls queueAppSignal closes.

## ◆ gotoFrame()

void MainApplication::gotoFrame | ( | int | frameNum | ) |

Triggers navigation to a specific frame number.

Parameters

  frameNum | The frame number to navigate to.

## ◆ helpTopicAction()

void MainApplication::helpTopicAction | ( | topic_action_e | action | ) |

Executes a help topic action.

Parameters

  action | The specific topic action to execute.

## ◆ isInitialized()

bool MainApplication::isInitialized | ( |  | ) |
| inline

Checks if the application is initialized.

Returns
  True if initialized, false otherwise.

## ◆ isReloadingLua()

bool MainApplication::isReloadingLua | ( |  | ) |
| inline

Checks if Lua plugins are currently reloading.

Returns
  True if reloading, false otherwise.

## ◆ loadLanguage()

void MainApplication::loadLanguage | ( | const QString | language | ) |

Loads a specific UI language.

Parameters

  language | The language code to load.

## ◆ mainWindow()

MainWindow * MainApplication::mainWindow | ( |  | ) |

Retrieves the main window instance.

Returns
  Pointer to the MainWindow.

## ◆ maxMenuDepth()

int MainApplication::maxMenuDepth | ( | void |  | ) |
| inline

Defines the maximum nested depth allowed for menus.

Returns
  The maximum menu depth.

## ◆ normalIcon()

const QIcon & MainApplication::normalIcon | ( |  | ) |

Retrieves the normal application icon.

Returns
  The normal QIcon.

## ◆ openDialogInitialDir()

QDir MainApplication::openDialogInitialDir | ( |  | ) |

Retrieves the initial directory for open dialogs.

Returns
  The QDir representing the initial directory.

## ◆ popStatus()

void MainApplication::popStatus | ( | StatusInfo | sinfo | ) |

Pops the most recent status message of a given type.

Parameters

  sinfo | The StatusInfo type to clear.

## ◆ pushStatus()

void MainApplication::pushStatus | ( | StatusInfo | sinfo,
|  | const QString & | message,
|  | const QString & | messagetip = QString() )

Pushes a message to the specified status bar section.

Parameters

  sinfo | The StatusInfo type.
  message | The text message to display.
  messagetip | Optional tooltip for the status.

## ◆ queueAppSignal()

void MainApplication::queueAppSignal | ( | AppSignal | signal | ) |
| 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())

Parameters

  signal | The AppSignal to queue.

## ◆ readConfigurationFiles()

_e_prefs * MainApplication::readConfigurationFiles | ( | bool | reset | ) |

Reads application configuration files.

Parameters

  reset | Whether to reset preferences to defaults.

Returns
  Pointer to the read preferences structure.

## ◆ removedMenuGroupItems()

QList< QAction * > MainApplication::removedMenuGroupItems | ( | int | group | ) |

Retrieves items recently removed from a dynamic menu group.

Parameters

  group | The menu group ID.

Returns
  A list of removed QAction pointers.

## ◆ removeDynamicMenuGroupItem()

void MainApplication::removeDynamicMenuGroupItem | ( | int | group,
|  | QAction * | sg_action )

Removes an action item from a dynamic menu group.

Parameters

  group | The menu group ID.
  sg_action | The action to remove.

## ◆ setConfigurationProfile()

void MainApplication::setConfigurationProfile | ( | const char * | profile_name,
|  | bool | write_recent_file = true )

Sets the active configuration profile.

Parameters

  profile_name | The name of the profile.
  write_recent_file | True to save the choice to recent files.

## ◆ setLastOpenDirFromFilename()

void MainApplication::setLastOpenDirFromFilename | ( | QString | file_name | ) |

Sets the last opened directory from a given filename.

Parameters

  file_name | The path to the file.

## ◆ setReloadingLua()

void MainApplication::setReloadingLua | ( | bool | is_reloading | ) |
| inline

Sets the flag indicating if Lua is currently reloading.

Parameters

  is_reloading | True if reloading, false otherwise.

## ◆ whenInitialized()

template<typename Func>

void MainApplication::whenInitialized | ( | const QObject * | context,
|  | Func && | fn )
| 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.

Parameters

  context | Receiver object governing lifetime/thread of the callback.
  fn | Zero-argument callable to run when initialization is complete.

## ◆ windowTitleSeparator()

const QString & MainApplication::windowTitleSeparator | ( |  | ) | const
| inline

Retrieves the window title separator string.

Returns
  The separator string.

## ◆ windowTitleString() [1/2]

const QString MainApplication::windowTitleString | ( | QString | title_part | ) |
| inline

Generates a window title with a single part.

Parameters

  title_part | The part to prepend to the default title.

Returns
  The combined window title string.

## ◆ windowTitleString() [2/2]

const QString MainApplication::windowTitleString | ( | QStringList | title_parts | ) |

Generates a window title from parts.

Parameters

  title_parts | The parts to combine into the title.

Returns
  The combined window title string.

## Member Data Documentation

## ◆ capture_icon_

QIcon MainApplication::capture_icon_
| protected

Icon for active capture state.

## ◆ normal_icon_

QIcon MainApplication::normal_icon_
| protected

Icon for standard application state.

## ◆ translator

QTranslator MainApplication::translator

Main Qt application translator.

## ◆ translatorQt

QTranslator MainApplication::translatorQt

Base Qt translator for standard strings.

The documentation for this class was generated from the following files:

- /builds/wireshark/wireshark/ui/qt/main_application.h
- /builds/wireshark/wireshark/ui/qt/main_application.cpp