mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +08:00
Ref T730, allow to update voice server URL
This commit is contained in:
committed by
Mat Sutcliffe
parent
c842820267
commit
e485824bfc
@@ -650,6 +650,12 @@ namespace BlackCore
|
||||
return {};
|
||||
}
|
||||
|
||||
bool CAfvClient::updateVoiceServerUrl(const QString &url)
|
||||
{
|
||||
if (m_connection) { return false; }
|
||||
return m_connection->updateVoiceServerUrl(url);
|
||||
}
|
||||
|
||||
void CAfvClient::initialize()
|
||||
{
|
||||
CLogMessage(this).info(u"Initialize AFV client in thread: %1") << CThreadUtils::threadInfo(this->thread());
|
||||
|
||||
@@ -199,6 +199,9 @@ namespace BlackCore
|
||||
QString getReceivingCallsignsCom2();
|
||||
//! @}
|
||||
|
||||
//! Update the voice server URL
|
||||
bool updateVoiceServerUrl(const QString &url);
|
||||
|
||||
signals:
|
||||
//! Receiving callsigns have been changed
|
||||
//! \remark callsigns I do receive
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "blackmisc/network/networkutils.h"
|
||||
#include "blackmisc/network/external/qjsonwebtoken.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/stringutils.h"
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
@@ -37,7 +38,7 @@ namespace BlackCore
|
||||
|
||||
CApiServerConnection::CApiServerConnection(const QString &address, QObject *parent) :
|
||||
QObject(parent),
|
||||
m_address(address)
|
||||
m_addressUrl(address)
|
||||
{
|
||||
CLogMessage(this).debug(u"ApiServerConnection instantiated");
|
||||
}
|
||||
@@ -51,7 +52,7 @@ namespace BlackCore
|
||||
m_networkVersion = networkVersion;
|
||||
m_isAuthenticated = false;
|
||||
|
||||
QUrl url(m_address);
|
||||
QUrl url(m_addressUrl);
|
||||
url.setPath("/api/v1/auth");
|
||||
|
||||
QJsonObject obj
|
||||
@@ -157,6 +158,13 @@ namespace BlackCore
|
||||
return {};
|
||||
}
|
||||
|
||||
bool CApiServerConnection::setUrl(const QString &url)
|
||||
{
|
||||
if (stringCompare(m_addressUrl, url, Qt::CaseInsensitive)) { return false; }
|
||||
m_addressUrl = url;
|
||||
return true;
|
||||
}
|
||||
|
||||
QByteArray CApiServerConnection::getWithResponse(const QNetworkRequest &request)
|
||||
{
|
||||
if (isShuttingDown()) { return {}; }
|
||||
@@ -240,7 +248,7 @@ namespace BlackCore
|
||||
|
||||
this->checkExpiry();
|
||||
|
||||
QUrl url(m_address);
|
||||
QUrl url(m_addressUrl);
|
||||
url.setPath(resource);
|
||||
QNetworkRequest request(url);
|
||||
request.setRawHeader("Authorization", "Bearer " + m_jwt);
|
||||
@@ -268,7 +276,7 @@ namespace BlackCore
|
||||
if (isShuttingDown()) { return; }
|
||||
if (!m_isAuthenticated) { return; }
|
||||
|
||||
QUrl url(m_address);
|
||||
QUrl url(m_addressUrl);
|
||||
url.setPath(resource);
|
||||
|
||||
QNetworkRequest request(url);
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#include "blackcore/afv/dto.h"
|
||||
#include "blackcore/application.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/logcategorylist.h"
|
||||
|
||||
#include <QString>
|
||||
@@ -71,6 +72,9 @@ namespace BlackCore
|
||||
//! All aliased stations
|
||||
QVector<StationDto> getAllAliasedStations();
|
||||
|
||||
//! Set the URL
|
||||
bool setUrl(const QString &url);
|
||||
|
||||
private:
|
||||
//! Post to resource
|
||||
template<typename TResponse>
|
||||
@@ -84,7 +88,7 @@ namespace BlackCore
|
||||
|
||||
this->checkExpiry();
|
||||
|
||||
QUrl url(m_address);
|
||||
QUrl url(m_addressUrl);
|
||||
url.setPath(resource);
|
||||
QNetworkRequest request(url);
|
||||
request.setRawHeader("Authorization", "Bearer " + m_jwt);
|
||||
@@ -107,7 +111,7 @@ namespace BlackCore
|
||||
|
||||
this->checkExpiry();
|
||||
|
||||
QUrl url(m_address);
|
||||
QUrl url(m_addressUrl);
|
||||
url.setPath(resource);
|
||||
QNetworkRequest request(url);
|
||||
request.setRawHeader("Authorization", "Bearer " + m_jwt);
|
||||
@@ -155,7 +159,7 @@ namespace BlackCore
|
||||
//! Application shutting down
|
||||
static bool isShuttingDown();
|
||||
|
||||
const QString m_address;
|
||||
QString m_addressUrl;
|
||||
QByteArray m_jwt;
|
||||
QString m_username;
|
||||
QString m_password;
|
||||
|
||||
@@ -96,6 +96,12 @@ namespace BlackCore
|
||||
return m_apiServerConnection->getAllAliasedStations();
|
||||
}
|
||||
|
||||
bool CClientConnection::updateVoiceServerUrl(const QString &url)
|
||||
{
|
||||
if (!m_apiServerConnection) { return false; }
|
||||
return m_apiServerConnection->setUrl(url);
|
||||
}
|
||||
|
||||
void CClientConnection::connectToVoiceServer()
|
||||
{
|
||||
QHostAddress localAddress(QHostAddress::AnyIPv4);
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace BlackCore
|
||||
}
|
||||
//! @}
|
||||
|
||||
//! Send voiceDTO to server
|
||||
//! Send voice DTO to server
|
||||
template<typename T>
|
||||
void sendToVoiceServer(const T &dto)
|
||||
{
|
||||
@@ -75,6 +75,9 @@ namespace BlackCore
|
||||
//! All aliased stations
|
||||
QVector<StationDto> getAllAliasedStations();
|
||||
|
||||
//! Update the voice server URL
|
||||
bool updateVoiceServerUrl(const QString &url);
|
||||
|
||||
signals:
|
||||
//! Audio has been received
|
||||
void audioReceived(const AudioRxOnTransceiversDto &dto);
|
||||
|
||||
Reference in New Issue
Block a user