|
Wavelength
Privacy-focused, cross-platform, and open-source communication application
|
Singleton class providing a centralized interface for querying and managing the state of wavelengths. More...
#include <wavelength_state_manager.h>
Signals | |
| void | activeWavelengthChanged (QString frequency) |
| Emitted when the active wavelength changes via SetActiveWavelength(). | |
Public Member Functions | |
| void | AddActiveSessionData (const QString &frequency, const QString &key, const QVariant &value) |
| Stores arbitrary session data associated with a specific frequency and key. Useful for temporary state related to a wavelength session (e.g., UI state). | |
| void | ClearAllSessionData () |
| Removes all session data for all frequencies. | |
| void | ClearSessionData (const QString &frequency) |
| Removes all session data associated with a specific frequency. | |
| QVariant | GetActiveSessionData (const QString &frequency, const QString &key, const QVariant &default_value=QVariant()) |
| Retrieves previously stored session data for a specific frequency and key. | |
| int | GetJoinedWavelengthCount () |
| Gets the total number of wavelengths the user is currently joined to. | |
| QList< QString > | GetJoinedWavelengths () |
| Gets a list of frequency identifiers for all wavelengths the user is currently joined to. Relies on internal tracking combined with registry validation. | |
| bool | IsConnecting (const QString &frequency) const |
| Checks if the application is currently in the process of connecting to a specific wavelength. | |
| void | RegisterJoinedWavelength (const QString &frequency) |
| Registers that the user has successfully joined a specific wavelength. Adds the frequency to an internal list if not already present. | |
| void | SetActiveWavelength (const QString &frequency) |
| Sets the specified frequency as the currently active wavelength. Updates the registry and emits the activeWavelengthChanged signal. | |
| void | SetConnecting (const QString &frequency, bool connecting) |
| Sets or clears the "connecting" status for a specific wavelength. Used to track ongoing connection attempts. | |
| void | UnregisterJoinedWavelength (const QString &frequency) |
| Unregisters that the user has left or been disconnected from a specific wavelength. Removes the frequency from the internal list. | |
Static Public Member Functions | |
| static QString | GetActiveWavelength () |
| Gets the frequency identifier of the currently active wavelength. | |
| static WavelengthStateManager * | GetInstance () |
| Gets the singleton instance of the WavelengthStateManager. | |
| static QDateTime | GetWavelengthCreationTime (const QString &frequency) |
| Gets the creation timestamp of a specific wavelength. | |
| static WavelengthInfo | GetWavelengthInfo (const QString &frequency, bool *is_host=nullptr) |
| Retrieves detailed information about a specific wavelength from the registry. | |
| static bool | IsActiveWavelengthHost () |
| Checks if the current user is the host of the currently active wavelength. | |
| static bool | IsWavelengthConnected (const QString &frequency) |
| Checks if the WebSocket connection for a specific wavelength is currently established and valid. | |
| static bool | IsWavelengthHost (const QString &frequency) |
| Checks if the current user is the host of a specific wavelength. | |
| static bool | IsWavelengthJoined (const QString &frequency) |
| Checks if the user is currently considered joined to a specific wavelength (based on registry presence). | |
| static bool | IsWavelengthPasswordProtected (const QString &frequency) |
| Checks if a specific wavelength is password protected. | |
Private Member Functions | |
| WavelengthStateManager & | operator= (const WavelengthStateManager &)=delete |
| Deleted assignment operator to prevent assignment. | |
| WavelengthStateManager (const WavelengthStateManager &)=delete | |
| Deleted copy constructor to prevent copying. | |
| WavelengthStateManager (QObject *parent=nullptr) | |
| Private constructor to enforce the singleton pattern. | |
| ~WavelengthStateManager () override=default | |
| Private destructor. | |
Private Attributes | |
| QList< QString > | connecting_wavelengths_ {} |
| List of frequencies currently undergoing a connection attempt. | |
| QList< QString > | joined_wavelengths_ {} |
| List of frequencies the user is currently joined to (managed internally). | |
| QMap< QString, QMap< QString, QVariant > > | session_data_ {} |
| Stores temporary session data, keyed by frequency, then by data key. | |
Singleton class providing a centralized interface for querying and managing the state of wavelengths.
This class acts as a facade over WavelengthRegistry and adds its own state tracking (like joined wavelengths, connecting status, and session data). It provides convenient methods to access information about specific wavelengths (info, host status, password protection, connection status) and the overall application state (active wavelength, joined wavelengths). It also manages temporary session data associated with specific frequencies.
|
inlineexplicitprivate |
Private constructor to enforce the singleton pattern.
| parent | Optional parent QObject. |
|
overrideprivatedefault |
Private destructor.
|
privatedelete |
Deleted copy constructor to prevent copying.
|
signal |
Emitted when the active wavelength changes via SetActiveWavelength().
| frequency | The frequency identifier of the newly active wavelength. |
| void WavelengthStateManager::AddActiveSessionData | ( | const QString & | frequency, |
| const QString & | key, | ||
| const QVariant & | value ) |
Stores arbitrary session data associated with a specific frequency and key. Useful for temporary state related to a wavelength session (e.g., UI state).
| frequency | The frequency identifier. |
| key | The key for the data item. |
| value | The QVariant value to store. |
| void WavelengthStateManager::ClearAllSessionData | ( | ) |
Removes all session data for all frequencies.
| void WavelengthStateManager::ClearSessionData | ( | const QString & | frequency | ) |
Removes all session data associated with a specific frequency.
| frequency | The frequency identifier whose session data should be cleared. |
| QVariant WavelengthStateManager::GetActiveSessionData | ( | const QString & | frequency, |
| const QString & | key, | ||
| const QVariant & | default_value = QVariant() ) |
Retrieves previously stored session data for a specific frequency and key.
| frequency | The frequency identifier. |
| key | The key of the data item to retrieve. |
| default_value | Optional default value to return if the key or frequency is not found. |
|
static |
Gets the frequency identifier of the currently active wavelength.
|
inlinestatic |
Gets the singleton instance of the WavelengthStateManager.
| int WavelengthStateManager::GetJoinedWavelengthCount | ( | ) |
Gets the total number of wavelengths the user is currently joined to.
| QList< QString > WavelengthStateManager::GetJoinedWavelengths | ( | ) |
Gets a list of frequency identifiers for all wavelengths the user is currently joined to. Relies on internal tracking combined with registry validation.
|
static |
Gets the creation timestamp of a specific wavelength.
| frequency | The frequency identifier. |
|
static |
Retrieves detailed information about a specific wavelength from the registry.
| frequency | The frequency identifier of the wavelength. |
| is_host | Optional output parameter; if provided, it's set to true if the current user is the host of this wavelength. |
|
static |
Checks if the current user is the host of the currently active wavelength.
| bool WavelengthStateManager::IsConnecting | ( | const QString & | frequency | ) | const |
Checks if the application is currently in the process of connecting to a specific wavelength.
| frequency | The frequency identifier to check. |
|
static |
Checks if the WebSocket connection for a specific wavelength is currently established and valid.
| frequency | The frequency identifier to check. |
|
static |
Checks if the current user is the host of a specific wavelength.
| frequency | The frequency identifier to check. |
|
static |
Checks if the user is currently considered joined to a specific wavelength (based on registry presence).
| frequency | The frequency identifier to check. |
|
static |
Checks if a specific wavelength is password protected.
| frequency | The frequency identifier to check. |
|
privatedelete |
Deleted assignment operator to prevent assignment.
| void WavelengthStateManager::RegisterJoinedWavelength | ( | const QString & | frequency | ) |
Registers that the user has successfully joined a specific wavelength. Adds the frequency to an internal list if not already present.
| frequency | The frequency identifier of the joined wavelength. |
| void WavelengthStateManager::SetActiveWavelength | ( | const QString & | frequency | ) |
Sets the specified frequency as the currently active wavelength. Updates the registry and emits the activeWavelengthChanged signal.
| frequency | The frequency identifier to set as active. |
| void WavelengthStateManager::SetConnecting | ( | const QString & | frequency, |
| bool | connecting ) |
Sets or clears the "connecting" status for a specific wavelength. Used to track ongoing connection attempts.
| frequency | The frequency identifier. |
| connecting | True to mark as connecting, false to clear the status. |
| void WavelengthStateManager::UnregisterJoinedWavelength | ( | const QString & | frequency | ) |
Unregisters that the user has left or been disconnected from a specific wavelength. Removes the frequency from the internal list.
| frequency | The frequency identifier of the wavelength being left. |
|
private |
List of frequencies currently undergoing a connection attempt.
|
private |
List of frequencies the user is currently joined to (managed internally).
|
private |
Stores temporary session data, keyed by frequency, then by data key.