Wavelength
Privacy-focused, cross-platform, and open-source communication application
Loading...
Searching...
No Matches
session_coordinator.h
Go to the documentation of this file.
1#ifndef WAVELENGTH_SESSION_COORDINATOR_H
2#define WAVELENGTH_SESSION_COORDINATOR_H
3
4#include <QObject>
5#include <QDebug>
6
7struct WavelengthInfo;
8
17class SessionCoordinator final : public QObject {
18 Q_OBJECT
19
20public:
26 static SessionCoordinator instance;
27 return &instance;
28 }
29
34
39
44 void Initialize();
45
54 static bool CreateWavelength(const QString &frequency,
55 bool is_password_protected, const QString &password);
56
64 static bool JoinWavelength(const QString &frequency, const QString &password = QString());
65
70 static void LeaveWavelength();
71
77 static void CloseWavelength(const QString &frequency);
78
85 static bool SendMessage(const QString &message);
86
93 static bool SendFile(const QString &file_path);
94
102 static WavelengthInfo GetWavelengthInfo(const QString &frequency, bool *is_host = nullptr);
103
109 static QString GetActiveWavelength();
110
116 static void SetActiveWavelength(const QString &frequency);
117
123 static bool IsActiveWavelengthHost();
124
130 static QList<QString> GetJoinedWavelengths();
131
137 static int GetJoinedWavelengthCount();
138
145 static bool IsWavelengthPasswordProtected(const QString &frequency);
146
153 static bool IsWavelengthHost(const QString &frequency);
154
161 static bool IsWavelengthJoined(const QString &frequency);
162
169 static bool IsWavelengthConnected(const QString &frequency);
170
176 static QString GetRelayServerAddress();
177
183 static void SetRelayServerAddress(const QString &address);
184
190 static QString GetRelayServerUrl();
191
192signals:
194 void wavelengthCreated(QString frequency);
195
197 void wavelengthJoined(QString frequency);
198
200 void wavelengthLeft(QString frequency);
201
203 void wavelengthClosed(QString frequency);
204
206 void messageReceived(QString frequency, const QString &message);
207
209 void messageSent(QString frequency, const QString &message);
210
212 void connectionError(const QString &error_message);
213
215 void authenticationFailed(QString frequency);
216
218 void userKicked(QString frequency, const QString &reason);
219
221 void activeWavelengthChanged(QString frequency);
222
224 void pttGranted(QString frequency);
225
227 void pttDenied(QString frequency, QString reason);
228
230 void pttStartReceiving(QString frequency, QString sender_id);
231
233 void pttStopReceiving(QString frequency);
234
236 void audioDataReceived(QString frequency, const QByteArray &audio_data);
237
239 void remoteAudioAmplitudeUpdate(QString frequency, qreal amplitude);
240
241private slots:
247 void onWavelengthCreated(const QString &frequency);
248
254 void onWavelengthJoined(const QString &frequency);
255
261 void onWavelengthLeft(const QString &frequency);
262
268 void onWavelengthClosed(const QString &frequency);
269
276 void onMessageReceived(const QString &frequency, const QString &message);
277
284 void onMessageSent(const QString &frequency, const QString &message);
285
291 void onConnectionError(const QString &errorMessage);
292
298 void onAuthenticationFailed(const QString &frequency);
299
305 void onActiveWavelengthChanged(const QString &frequency);
306
312 static void onConfigChanged(const QString &key) {
313 qDebug() << "Configuration changed:" << key;
314 }
315
317 void onPttGranted(const QString &frequency) {
318 emit pttGranted(frequency);
319 }
320
322 void onPttDenied(const QString &frequency, const QString &reason) {
323 emit pttDenied(frequency, reason);
324 }
325
327 void onPttStartReceiving(const QString &frequency, const QString &sender_id) {
328 emit pttStartReceiving(frequency, sender_id);
329 }
330
332 void onPttStopReceiving(const QString &frequency) {
333 emit pttStopReceiving(frequency);
334 }
335
337 void onAudioDataReceived(const QString &frequency, const QByteArray &audio_data) {
338 emit audioDataReceived(frequency, audio_data);
339 }
340
342 void onRemoteAudioAmplitudeUpdate(const QString &frequency, const qreal amplitude) {
343 emit remoteAudioAmplitudeUpdate(frequency, amplitude);
344 }
345
346private:
351 explicit SessionCoordinator(QObject *parent = nullptr) : QObject(parent) {
352 }
353
357 ~SessionCoordinator() override = default;
358
363 void ConnectSignals();
364
369 static void LoadConfig();
370};
371
372#endif // WAVELENGTH_SESSION_COORDINATOR_H
void onMessageSent(const QString &frequency, const QString &message)
Slot triggered when a message is sent. Relays the signal and publishes the event via WavelengthEventB...
Definition session_coordinator.cpp:147
static SessionCoordinator * GetInstance()
Gets the singleton instance of the WavelengthSessionCoordinator.
Definition session_coordinator.h:25
void ConnectSignals()
Connects signals between the various Wavelength components. Called during Initialize().
Definition session_coordinator.cpp:172
void wavelengthCreated(QString frequency)
Emitted when a wavelength is successfully created. Relayed from WavelengthCreator.
static void CloseWavelength(const QString &frequency)
Closes a specific wavelength (only if the current user is the host). Unregisters the wavelength local...
Definition session_coordinator.cpp:52
void remoteAudioAmplitudeUpdate(QString frequency, qreal amplitude)
Emitted when remote audio amplitude updates are received. Relayed from WavelengthMessageService.
static QString GetActiveWavelength()
Gets the frequency identifier of the currently active wavelength. Delegates the call to WavelengthSta...
Definition session_coordinator.cpp:69
void messageReceived(QString frequency, const QString &message)
Emitted when a message is received. Relayed from WavelengthMessageProcessor/Joiner.
void Initialize()
Initializes the coordinator and its underlying components. Connects signals between various Wavelengt...
Definition session_coordinator.cpp:15
static bool IsWavelengthJoined(const QString &frequency)
Checks if the user is considered joined to a specific wavelength (based on registry presence)....
Definition session_coordinator.cpp:97
static WavelengthInfo GetWavelengthInfo(const QString &frequency, bool *is_host=nullptr)
Retrieves detailed information about a specific wavelength. Delegates the call to WavelengthStateMana...
Definition session_coordinator.cpp:65
void onAuthenticationFailed(const QString &frequency)
Slot triggered when authentication fails during join. Relays the signal and publishes the event via W...
Definition session_coordinator.cpp:159
void onConnectionError(const QString &errorMessage)
Slot triggered when a connection error occurs. Relays the signal and publishes the event via Waveleng...
Definition session_coordinator.cpp:153
void activeWavelengthChanged(QString frequency)
Emitted when the active wavelength changes. Relayed from WavelengthStateManager.
static int GetJoinedWavelengthCount()
Gets the count of wavelengths the user is currently joined to. Delegates the call to WavelengthStateM...
Definition session_coordinator.cpp:81
static void SetActiveWavelength(const QString &frequency)
Sets the specified frequency as the currently active wavelength. Delegates the call to WavelengthStat...
Definition session_coordinator.cpp:93
void messageSent(QString frequency, const QString &message)
Emitted when a message is successfully sent. Relayed from WavelengthMessageService.
void onWavelengthCreated(const QString &frequency)
Slot triggered when a wavelength is created. Relays the signal and publishes the event via Wavelength...
Definition session_coordinator.cpp:117
static bool IsActiveWavelengthHost()
Checks if the current user is the host of the currently active wavelength. Delegates the call to Wave...
Definition session_coordinator.cpp:73
static bool SendMessage(const QString &message)
Sends a text message to the currently active wavelength. Delegates the call to WavelengthMessageServi...
Definition session_coordinator.cpp:57
void onActiveWavelengthChanged(const QString &frequency)
Slot triggered when the active wavelength changes. Relays the signal and publishes the event via Wave...
Definition session_coordinator.cpp:165
void onAudioDataReceived(const QString &frequency, const QByteArray &audio_data)
Relays the audioDataReceived signal.
Definition session_coordinator.h:337
void pttGranted(QString frequency)
Emitted when PTT transmission is granted. Relayed from WavelengthMessageService.
void wavelengthLeft(QString frequency)
Emitted when the user leaves the active wavelength. Relayed from WavelengthLeaver.
static bool JoinWavelength(const QString &frequency, const QString &password=QString())
Initiates joining an existing wavelength. Delegates the call to WavelengthJoiner and registers the wa...
Definition session_coordinator.cpp:32
void onWavelengthClosed(const QString &frequency)
Slot triggered when a wavelength is closed. Relays the signal and publishes the event via WavelengthE...
Definition session_coordinator.cpp:135
SessionCoordinator(const SessionCoordinator &)=delete
Deleted copy constructor to prevent copying.
static void SetRelayServerAddress(const QString &address)
Sets the relay server address in the configuration. Delegates the call to WavelengthConfig.
Definition session_coordinator.cpp:109
void onPttStartReceiving(const QString &frequency, const QString &sender_id)
Relays the pttStartReceiving signal.
Definition session_coordinator.h:327
static bool SendFile(const QString &file_path)
Sends a file to the currently active wavelength. Delegates the call to WavelengthMessageService.
Definition session_coordinator.cpp:61
static bool IsWavelengthPasswordProtected(const QString &frequency)
Checks if a specific wavelength is password protected. Delegates the call to WavelengthStateManager.
Definition session_coordinator.cpp:85
void pttDenied(QString frequency, QString reason)
Emitted when PTT transmission is denied. Relayed from WavelengthMessageService.
void onRemoteAudioAmplitudeUpdate(const QString &frequency, const qreal amplitude)
Relays the remoteAudioAmplitudeUpdate signal.
Definition session_coordinator.h:342
void wavelengthClosed(QString frequency)
Emitted when a wavelength is closed (by host or server). Relayed from multiple components.
void onWavelengthLeft(const QString &frequency)
Slot triggered when the active wavelength is left. Relays the signal and publishes the event via Wave...
Definition session_coordinator.cpp:129
void onPttDenied(const QString &frequency, const QString &reason)
Relays the pttDenied signal.
Definition session_coordinator.h:322
SessionCoordinator & operator=(const SessionCoordinator &)=delete
Deleted assignment operator to prevent assignment.
void wavelengthJoined(QString frequency)
Emitted when a wavelength is successfully joined. Relayed from WavelengthJoiner.
void pttStartReceiving(QString frequency, QString sender_id)
Emitted when another user starts PTT transmission. Relayed from WavelengthMessageService.
~SessionCoordinator() override=default
Private destructor.
static void onConfigChanged(const QString &key)
Slot triggered when a configuration setting changes. Logs the change.
Definition session_coordinator.h:312
SessionCoordinator(QObject *parent=nullptr)
Private constructor to enforce the singleton pattern.
Definition session_coordinator.h:351
void userKicked(QString frequency, const QString &reason)
Emitted when the current user is kicked from a frequency. Relayed from WavelengthMessageProcessor.
void onMessageReceived(const QString &frequency, const QString &message)
Slot triggered when a message is received. Relays the signal and publishes the event via WavelengthEv...
Definition session_coordinator.cpp:141
static bool CreateWavelength(const QString &frequency, bool is_password_protected, const QString &password)
Initiates the creation of a new wavelength. Delegates the call to WavelengthCreator and registers the...
Definition session_coordinator.cpp:20
static void LoadConfig()
Loads the application configuration using WavelengthConfig. Sets default values if the configuration ...
Definition session_coordinator.cpp:232
void pttStopReceiving(QString frequency)
Emitted when another user stops PTT transmission. Relayed from WavelengthMessageService.
static QString GetRelayServerAddress()
Gets the configured relay server address. Delegates the call to WavelengthConfig.
Definition session_coordinator.cpp:105
static void LeaveWavelength()
Leaves the currently active wavelength. Unregisters the wavelength locally and delegates the call to ...
Definition session_coordinator.cpp:42
void onWavelengthJoined(const QString &frequency)
Slot triggered when a wavelength is joined. Relays the signal and publishes the event via WavelengthE...
Definition session_coordinator.cpp:123
void audioDataReceived(QString frequency, const QByteArray &audio_data)
Emitted when raw audio data is received. Relayed from WavelengthMessageService.
void onPttStopReceiving(const QString &frequency)
Relays the pttStopReceiving signal.
Definition session_coordinator.h:332
void connectionError(const QString &error_message)
Emitted when a connection error occurs. Relayed from WavelengthCreator/Joiner.
static QList< QString > GetJoinedWavelengths()
Gets a list of frequencies the user is currently joined to. Delegates the call to WavelengthStateMana...
Definition session_coordinator.cpp:77
static QString GetRelayServerUrl()
Gets the full URL (ws://address:port) of the relay server. Delegates the call to WavelengthConfig.
Definition session_coordinator.cpp:113
static bool IsWavelengthHost(const QString &frequency)
Checks if the current user is the host of a specific wavelength. Delegates the call to WavelengthStat...
Definition session_coordinator.cpp:89
void onPttGranted(const QString &frequency)
Relays the pttGranted signal.
Definition session_coordinator.h:317
void authenticationFailed(QString frequency)
Emitted when authentication fails during join. Relayed from WavelengthJoiner.
static bool IsWavelengthConnected(const QString &frequency)
Checks if the WebSocket connection for a specific wavelength is established and valid....
Definition session_coordinator.cpp:101
Structure holding information about a specific wavelength (frequency).
Definition wavelength_registry.h:13