mirror of
https://github.com/moonlight-stream/moonlight-qt
synced 2024-12-14 21:32:27 +00:00
Refactor NvPairingManager, NvComputer, and NvHTTP to reduce passing of addresses
This commit is contained in:
parent
bee8378795
commit
5afab126b3
9 changed files with 48 additions and 17 deletions
|
@ -106,7 +106,7 @@ void BoxArtManager::handleBoxArtLoadComplete(NvComputer* computer, NvApp app, QU
|
|||
|
||||
QUrl BoxArtManager::loadBoxArtFromNetwork(NvComputer* computer, int appId)
|
||||
{
|
||||
NvHTTP http(computer->activeAddress, computer->serverCert);
|
||||
NvHTTP http(computer);
|
||||
|
||||
QString cachePath = getFilePathForBoxArt(computer, appId);
|
||||
QImage image;
|
||||
|
|
|
@ -38,7 +38,7 @@ private:
|
|||
return false;
|
||||
}
|
||||
|
||||
NvComputer newState(address, serverInfo, QSslCertificate());
|
||||
NvComputer newState(http, serverInfo);
|
||||
|
||||
// Ensure the machine that responded is the one we intended to contact
|
||||
if (m_Computer->uuid != newState.uuid) {
|
||||
|
@ -54,7 +54,7 @@ private:
|
|||
{
|
||||
Q_ASSERT(m_Computer->activeAddress != nullptr);
|
||||
|
||||
NvHTTP http(m_Computer->activeAddress, m_Computer->serverCert);
|
||||
NvHTTP http(m_Computer);
|
||||
|
||||
QVector<NvApp> appList;
|
||||
|
||||
|
@ -470,7 +470,7 @@ signals:
|
|||
private:
|
||||
void run()
|
||||
{
|
||||
NvPairingManager pairingManager(m_Computer->activeAddress);
|
||||
NvPairingManager pairingManager(m_Computer);
|
||||
|
||||
try {
|
||||
NvPairingManager::PairState result = pairingManager.pair(m_Computer->appVersion, m_Pin, m_Computer->serverCert);
|
||||
|
@ -526,7 +526,7 @@ signals:
|
|||
private:
|
||||
void run()
|
||||
{
|
||||
NvHTTP http(m_Computer->activeAddress, m_Computer->serverCert);
|
||||
NvHTTP http(m_Computer);
|
||||
|
||||
try {
|
||||
if (m_Computer->currentGameId != 0) {
|
||||
|
@ -677,7 +677,7 @@ private:
|
|||
}
|
||||
|
||||
// Create initial newComputer using HTTP serverinfo with no pinned cert
|
||||
NvComputer* newComputer = new NvComputer(http.address(), serverInfo, QSslCertificate());
|
||||
NvComputer* newComputer = new NvComputer(http, serverInfo);
|
||||
|
||||
// Check if we have a record of this host UUID to pull the pinned cert
|
||||
NvComputer* existingComputer;
|
||||
|
@ -697,7 +697,7 @@ private:
|
|||
}
|
||||
|
||||
// Update the polled computer with the HTTPS information
|
||||
NvComputer httpsComputer(http.address(), serverInfo, QSslCertificate());
|
||||
NvComputer httpsComputer(http, serverInfo);
|
||||
newComputer->update(httpsComputer);
|
||||
}
|
||||
|
||||
|
|
|
@ -87,9 +87,9 @@ void NvComputer::sortAppList()
|
|||
});
|
||||
}
|
||||
|
||||
NvComputer::NvComputer(QString address, QString serverInfo, QSslCertificate serverCert)
|
||||
NvComputer::NvComputer(NvHTTP& http, QString serverInfo)
|
||||
{
|
||||
this->serverCert = serverCert;
|
||||
this->serverCert = http.serverCert();
|
||||
|
||||
this->hasCustomName = false;
|
||||
this->name = NvHTTP::getXmlString(serverInfo, "hostname");
|
||||
|
@ -142,7 +142,7 @@ NvComputer::NvComputer(QString address, QString serverInfo, QSslCertificate serv
|
|||
this->appVersion = NvHTTP::getXmlString(serverInfo, "appversion");
|
||||
this->gfeVersion = NvHTTP::getXmlString(serverInfo, "GfeVersion");
|
||||
this->gpuModel = NvHTTP::getXmlString(serverInfo, "gputype");
|
||||
this->activeAddress = address;
|
||||
this->activeAddress = http.address();
|
||||
this->state = NvComputer::CS_ONLINE;
|
||||
this->pendingQuit = false;
|
||||
this->isSupportedServerVersion = CompatFetcher::isGfeVersionSupported(this->gfeVersion);
|
||||
|
|
|
@ -21,7 +21,7 @@ private:
|
|||
bool pendingQuit;
|
||||
|
||||
public:
|
||||
explicit NvComputer(QString address, QString serverInfo, QSslCertificate serverCert);
|
||||
explicit NvComputer(NvHTTP& http, QString serverInfo);
|
||||
|
||||
explicit NvComputer(QSettings& settings);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "nvhttp.h"
|
||||
#include "nvcomputer.h"
|
||||
#include <Limelight.h>
|
||||
|
||||
#include <QDebug>
|
||||
|
@ -35,6 +35,12 @@ NvHTTP::NvHTTP(QString address, QSslCertificate serverCert) :
|
|||
connect(&m_Nam, &QNetworkAccessManager::sslErrors, this, &NvHTTP::handleSslErrors);
|
||||
}
|
||||
|
||||
NvHTTP::NvHTTP(NvComputer* computer) :
|
||||
NvHTTP(computer->activeAddress, computer->serverCert)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void NvHTTP::setServerCert(QSslCertificate serverCert)
|
||||
{
|
||||
m_ServerCert = serverCert;
|
||||
|
@ -55,6 +61,21 @@ QString NvHTTP::address()
|
|||
return m_Address;
|
||||
}
|
||||
|
||||
QSslCertificate NvHTTP::serverCert()
|
||||
{
|
||||
return m_ServerCert;
|
||||
}
|
||||
|
||||
uint16_t NvHTTP::httpPort()
|
||||
{
|
||||
return m_BaseUrlHttp.port();
|
||||
}
|
||||
|
||||
uint16_t NvHTTP::httpsPort()
|
||||
{
|
||||
return m_BaseUrlHttps.port();
|
||||
}
|
||||
|
||||
QVector<int>
|
||||
NvHTTP::parseQuad(QString quad)
|
||||
{
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
|
||||
class NvComputer;
|
||||
|
||||
class NvDisplayMode
|
||||
{
|
||||
public:
|
||||
|
@ -108,6 +110,8 @@ public:
|
|||
|
||||
explicit NvHTTP(QString address, QSslCertificate serverCert);
|
||||
|
||||
explicit NvHTTP(NvComputer* computer);
|
||||
|
||||
static
|
||||
int
|
||||
getCurrentGame(QString serverInfo);
|
||||
|
@ -142,6 +146,12 @@ public:
|
|||
|
||||
QString address();
|
||||
|
||||
QSslCertificate serverCert();
|
||||
|
||||
uint16_t httpPort();
|
||||
|
||||
uint16_t httpsPort();
|
||||
|
||||
static
|
||||
QVector<int>
|
||||
parseQuad(QString quad);
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
#define REQUEST_TIMEOUT_MS 5000
|
||||
|
||||
NvPairingManager::NvPairingManager(QString address) :
|
||||
m_Http(address, QSslCertificate())
|
||||
NvPairingManager::NvPairingManager(NvComputer* computer) :
|
||||
m_Http(computer)
|
||||
{
|
||||
QByteArray cert = IdentityManager::get()->getCertificate();
|
||||
BIO *bio = BIO_new_mem_buf(cert.data(), -1);
|
||||
|
|
|
@ -17,7 +17,7 @@ public:
|
|||
ALREADY_IN_PROGRESS
|
||||
};
|
||||
|
||||
explicit NvPairingManager(QString address);
|
||||
explicit NvPairingManager(NvComputer* computer);
|
||||
|
||||
~NvPairingManager();
|
||||
|
||||
|
|
|
@ -782,7 +782,7 @@ private:
|
|||
|
||||
// Perform a best-effort app quit
|
||||
if (shouldQuit) {
|
||||
NvHTTP http(m_Session->m_Computer->activeAddress, m_Session->m_Computer->serverCert);
|
||||
NvHTTP http(m_Session->m_Computer);
|
||||
|
||||
// Logging is already done inside NvHTTP
|
||||
try {
|
||||
|
@ -1029,7 +1029,7 @@ bool Session::startConnectionAsync()
|
|||
QString rtspSessionUrl;
|
||||
|
||||
try {
|
||||
NvHTTP http(m_Computer->activeAddress, m_Computer->serverCert);
|
||||
NvHTTP http(m_Computer);
|
||||
if (m_Computer->currentGameId != 0) {
|
||||
http.resumeApp(&m_StreamConfig, rtspSessionUrl);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue