Wireshark 4.7.0
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:
StratosharkApplication WiresharkApplication

Public Types

enum  AppSignal {
  CaptureFilterListChanged , ColumnsChanged , DisplayFilterListChanged , FieldsChanged ,
  FilterExpressionsChanged , LocalInterfacesChanged , 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 scanLocalInterfaces (GList *filter_list=nullptr)
 Signal emitted to request a scan of local interfaces.
 
void localInterfaceListChanged ()
 Signal emitted when the local interface list changes.
 
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.
 
void zoomRegularFont (const QFont &font)
 Signal emitted to apply a new zoomed regular font.
 
void zoomMonospaceFont (const QFont &font)
 Signal emitted to apply a new zoomed monospace font.
 

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.
 
virtual void refreshLocalInterfaces ()
 Refreshes the local interfaces list.
 
struct _e_prefsreadConfigurationFiles (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.
 
const QFont monospaceFont (bool zoomed=false) const
 Retrieves the monospace font used by the application.
 
int monospaceTextSize (const char *str)
 Calculates the horizontal pixel size of a string using the monospace font.
 
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.
 
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.
 
MainWindowmainWindow ()
 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 zoomTextFont (int zoomLevel)
 Applies text zooming to application fonts.
 
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)
 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

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.

LocalInterfacesChanged 

Local interfaces 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

Enumeration for standard main menu items.

Enumerator
FileOpenDialog 

The file open dialog action.

CaptureOptionsDialog 

The capture options dialog action.

◆ 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
argcReference to the argument count.
argvArray 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
groupThe menu group ID.
sg_actionThe action to add.

◆ addedMenuGroupItems()

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

Retrieves items recently added to a dynamic menu group.

Parameters
groupThe 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
groupThe menu group ID.
sg_actionThe action to append.

◆ captureEventHandler

void MainApplication::captureEventHandler ( CaptureEvent  ev)
slot

Slot for handling capture events.

Parameters
evThe 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
menuItemThe MainMenuItem to trigger.

◆ dynamicMenuGroupItems()

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

Retrieves all action items for a dynamic menu group.

Parameters
groupThe menu group ID.
Returns
A list of QAction pointers.

◆ emitAppSignal()

void MainApplication::emitAppSignal ( AppSignal  signal)

Emits a specific application signal.

Parameters
signalThe AppSignal to emit.

◆ emitLocalInterfaceEvent()

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

Emits a signal regarding local interface status changes.

Parameters
ifnameThe name of the interface.
addedIndicator if the interface was added.
upIndicator 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_pathThe menu path associated with the command.
argThe argument string for the command.
userdataPointer 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_abbrConfiguration abbreviation string.
argTap argument string.
userdataPointer to additional user data.

◆ event()

bool MainApplication::event ( QEvent *  event)
protected

Core Qt event handler override.

Parameters
eventThe 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
frameNumThe frame number to navigate to.

◆ helpTopicAction()

void MainApplication::helpTopicAction ( topic_action_e  action)

Executes a help topic action.

Parameters
actionThe 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
languageThe 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.

◆ monospaceFont()

const QFont MainApplication::monospaceFont ( bool  zoomed = false) const

Retrieves the monospace font used by the application.

Parameters
zoomedTrue if the zoomed font is requested.
Returns
The requested QFont.

◆ monospaceTextSize()

int MainApplication::monospaceTextSize ( const char *  str)

Calculates the horizontal pixel size of a string using the monospace font.

Parameters
strThe string to measure.
Returns
The size in pixels.

◆ 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
sinfoThe 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
sinfoThe StatusInfo type.
messageThe text message to display.
messagetipOptional 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
signalThe AppSignal to queue.

◆ readConfigurationFiles()

_e_prefs * MainApplication::readConfigurationFiles ( bool  reset)

Reads application configuration files.

Parameters
resetWhether 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
groupThe 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
groupThe menu group ID.
sg_actionThe action to remove.

◆ setConfigurationProfile()

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

Sets the active configuration profile.

Parameters
profile_nameThe name of the profile.
write_recent_fileTrue 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_nameThe path to the file.

◆ setReloadingLua()

void MainApplication::setReloadingLua ( bool  is_reloading)
inline

Sets the flag indicating if Lua is currently reloading.

Parameters
is_reloadingTrue if reloading, false otherwise.

◆ 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_partThe 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_partsThe parts to combine into the title.
Returns
The combined window title string.

◆ zoomTextFont()

void MainApplication::zoomTextFont ( int  zoomLevel)

Applies text zooming to application fonts.

Parameters
zoomLevelThe level to zoom by.

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: