Wavelength
Privacy-focused, cross-platform, and open-source communication application
Loading...
Searching...
No Matches
WavelengthStateManager Class Referencefinal

Singleton class providing a centralized interface for querying and managing the state of wavelengths. More...

#include <wavelength_state_manager.h>

Inheritance diagram for WavelengthStateManager:
Collaboration diagram for WavelengthStateManager:

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 WavelengthStateManagerGetInstance ()
 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

WavelengthStateManageroperator= (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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ WavelengthStateManager() [1/2]

WavelengthStateManager::WavelengthStateManager ( QObject * parent = nullptr)
inlineexplicitprivate

Private constructor to enforce the singleton pattern.

Parameters
parentOptional parent QObject.
Here is the caller graph for this function:

◆ ~WavelengthStateManager()

WavelengthStateManager::~WavelengthStateManager ( )
overrideprivatedefault

Private destructor.

◆ WavelengthStateManager() [2/2]

WavelengthStateManager::WavelengthStateManager ( const WavelengthStateManager & )
privatedelete

Deleted copy constructor to prevent copying.

Here is the call graph for this function:

Member Function Documentation

◆ activeWavelengthChanged

void WavelengthStateManager::activeWavelengthChanged ( QString frequency)
signal

Emitted when the active wavelength changes via SetActiveWavelength().

Parameters
frequencyThe frequency identifier of the newly active wavelength.
Here is the caller graph for this function:

◆ AddActiveSessionData()

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

Parameters
frequencyThe frequency identifier.
keyThe key for the data item.
valueThe QVariant value to store.

◆ ClearAllSessionData()

void WavelengthStateManager::ClearAllSessionData ( )

Removes all session data for all frequencies.

◆ ClearSessionData()

void WavelengthStateManager::ClearSessionData ( const QString & frequency)

Removes all session data associated with a specific frequency.

Parameters
frequencyThe frequency identifier whose session data should be cleared.

◆ GetActiveSessionData()

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.

Parameters
frequencyThe frequency identifier.
keyThe key of the data item to retrieve.
default_valueOptional default value to return if the key or frequency is not found.
Returns
The stored QVariant value, or the default_value if not found.

◆ GetActiveWavelength()

QString WavelengthStateManager::GetActiveWavelength ( )
static

Gets the frequency identifier of the currently active wavelength.

Returns
The frequency string, or "-1" if no wavelength is active.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetInstance()

static WavelengthStateManager * WavelengthStateManager::GetInstance ( )
inlinestatic

Gets the singleton instance of the WavelengthStateManager.

Returns
Pointer to the singleton WavelengthStateManager instance.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetJoinedWavelengthCount()

int WavelengthStateManager::GetJoinedWavelengthCount ( )

Gets the total number of wavelengths the user is currently joined to.

Returns
The count of joined wavelengths.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetJoinedWavelengths()

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.

Returns
A QList<QString> containing the frequencies of joined wavelengths.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetWavelengthCreationTime()

QDateTime WavelengthStateManager::GetWavelengthCreationTime ( const QString & frequency)
static

Gets the creation timestamp of a specific wavelength.

Parameters
frequencyThe frequency identifier.
Returns
The QDateTime when the wavelength was created/registered.
Here is the call graph for this function:

◆ GetWavelengthInfo()

WavelengthInfo WavelengthStateManager::GetWavelengthInfo ( const QString & frequency,
bool * is_host = nullptr )
static

Retrieves detailed information about a specific wavelength from the registry.

Parameters
frequencyThe frequency identifier of the wavelength.
is_hostOptional output parameter; if provided, it's set to true if the current user is the host of this wavelength.
Returns
A WavelengthInfo struct containing details about the wavelength.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsActiveWavelengthHost()

bool WavelengthStateManager::IsActiveWavelengthHost ( )
static

Checks if the current user is the host of the currently active wavelength.

Returns
True if an active wavelength exists and the user is its host, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsConnecting()

bool WavelengthStateManager::IsConnecting ( const QString & frequency) const

Checks if the application is currently in the process of connecting to a specific wavelength.

Parameters
frequencyThe frequency identifier to check.
Returns
True if a connection attempt is in progress for this frequency, false otherwise.

◆ IsWavelengthConnected()

bool WavelengthStateManager::IsWavelengthConnected ( const QString & frequency)
static

Checks if the WebSocket connection for a specific wavelength is currently established and valid.

Parameters
frequencyThe frequency identifier to check.
Returns
True if the socket exists, is valid, and in the ConnectedState, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsWavelengthHost()

bool WavelengthStateManager::IsWavelengthHost ( const QString & frequency)
static

Checks if the current user is the host of a specific wavelength.

Parameters
frequencyThe frequency identifier to check.
Returns
True if the user is the host, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsWavelengthJoined()

bool WavelengthStateManager::IsWavelengthJoined ( const QString & frequency)
static

Checks if the user is currently considered joined to a specific wavelength (based on registry presence).

Parameters
frequencyThe frequency identifier to check.
Returns
True if the wavelength exists in the registry, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsWavelengthPasswordProtected()

bool WavelengthStateManager::IsWavelengthPasswordProtected ( const QString & frequency)
static

Checks if a specific wavelength is password protected.

Parameters
frequencyThe frequency identifier to check.
Returns
True if the wavelength requires a password, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

WavelengthStateManager & WavelengthStateManager::operator= ( const WavelengthStateManager & )
privatedelete

Deleted assignment operator to prevent assignment.

Here is the call graph for this function:

◆ RegisterJoinedWavelength()

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.

Parameters
frequencyThe frequency identifier of the joined wavelength.
Here is the caller graph for this function:

◆ SetActiveWavelength()

void WavelengthStateManager::SetActiveWavelength ( const QString & frequency)

Sets the specified frequency as the currently active wavelength. Updates the registry and emits the activeWavelengthChanged signal.

Parameters
frequencyThe frequency identifier to set as active.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetConnecting()

void WavelengthStateManager::SetConnecting ( const QString & frequency,
bool connecting )

Sets or clears the "connecting" status for a specific wavelength. Used to track ongoing connection attempts.

Parameters
frequencyThe frequency identifier.
connectingTrue to mark as connecting, false to clear the status.

◆ UnregisterJoinedWavelength()

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.

Parameters
frequencyThe frequency identifier of the wavelength being left.
Here is the caller graph for this function:

Member Data Documentation

◆ connecting_wavelengths_

QList<QString> WavelengthStateManager::connecting_wavelengths_ {}
private

List of frequencies currently undergoing a connection attempt.

◆ joined_wavelengths_

QList<QString> WavelengthStateManager::joined_wavelengths_ {}
private

List of frequencies the user is currently joined to (managed internally).

◆ session_data_

QMap<QString, QMap<QString, QVariant> > WavelengthStateManager::session_data_ {}
private

Stores temporary session data, keyed by frequency, then by data key.


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