2018-04-28 22:39:50 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-04-29 05:14:27 +00:00
|
|
|
#include "identitymanager.h"
|
2020-05-08 02:54:36 +00:00
|
|
|
#include "nvapp.h"
|
2021-07-03 04:34:54 +00:00
|
|
|
#include "nvaddress.h"
|
2018-04-29 05:14:27 +00:00
|
|
|
|
2018-06-24 07:14:23 +00:00
|
|
|
#include <Limelight.h>
|
|
|
|
|
2018-04-28 22:39:50 +00:00
|
|
|
#include <QUrl>
|
2018-09-29 10:01:49 +00:00
|
|
|
#include <QNetworkAccessManager>
|
|
|
|
#include <QNetworkReply>
|
2018-04-28 22:39:50 +00:00
|
|
|
|
2021-07-02 22:14:48 +00:00
|
|
|
class NvComputer;
|
|
|
|
|
2018-07-09 03:53:24 +00:00
|
|
|
class NvDisplayMode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool operator==(const NvDisplayMode& other) const
|
|
|
|
{
|
|
|
|
return width == other.width &&
|
|
|
|
height == other.height &&
|
|
|
|
refreshRate == other.refreshRate;
|
|
|
|
}
|
|
|
|
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
int refreshRate;
|
|
|
|
};
|
2021-03-03 00:14:15 +00:00
|
|
|
Q_DECLARE_TYPEINFO(NvDisplayMode, Q_PRIMITIVE_TYPE);
|
2018-07-09 03:53:24 +00:00
|
|
|
|
2018-04-29 00:08:05 +00:00
|
|
|
class GfeHttpResponseException : public std::exception
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GfeHttpResponseException(int statusCode, QString message) :
|
|
|
|
m_StatusCode(statusCode),
|
|
|
|
m_StatusMessage(message)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-09-29 10:11:17 +00:00
|
|
|
const char* what() const throw()
|
2018-04-29 00:08:05 +00:00
|
|
|
{
|
2018-04-29 05:14:27 +00:00
|
|
|
return m_StatusMessage.toLatin1();
|
2018-04-29 00:08:05 +00:00
|
|
|
}
|
|
|
|
|
2018-04-29 05:14:27 +00:00
|
|
|
const char* getStatusMessage() const
|
2018-04-29 00:08:05 +00:00
|
|
|
{
|
2018-04-29 05:14:27 +00:00
|
|
|
return m_StatusMessage.toLatin1();
|
2018-04-29 00:08:05 +00:00
|
|
|
}
|
|
|
|
|
2018-04-29 05:14:27 +00:00
|
|
|
int getStatusCode() const
|
2018-04-29 00:08:05 +00:00
|
|
|
{
|
|
|
|
return m_StatusCode;
|
|
|
|
}
|
|
|
|
|
2018-07-07 23:30:26 +00:00
|
|
|
QString toQString() const
|
|
|
|
{
|
|
|
|
return m_StatusMessage + " (Error " + QString::number(m_StatusCode) + ")";
|
|
|
|
}
|
|
|
|
|
2018-04-29 00:08:05 +00:00
|
|
|
private:
|
|
|
|
int m_StatusCode;
|
|
|
|
QString m_StatusMessage;
|
|
|
|
};
|
|
|
|
|
2018-09-29 10:01:49 +00:00
|
|
|
class QtNetworkReplyException : public std::exception
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
QtNetworkReplyException(QNetworkReply::NetworkError error, QString errorText) :
|
|
|
|
m_Error(error),
|
|
|
|
m_ErrorText(errorText)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-09-29 10:11:17 +00:00
|
|
|
const char* what() const throw()
|
2018-09-29 10:01:49 +00:00
|
|
|
{
|
|
|
|
return m_ErrorText.toLatin1();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* getErrorText() const
|
|
|
|
{
|
|
|
|
return m_ErrorText.toLatin1();
|
|
|
|
}
|
|
|
|
|
|
|
|
QNetworkReply::NetworkError getError() const
|
|
|
|
{
|
|
|
|
return m_Error;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString toQString() const
|
|
|
|
{
|
|
|
|
return m_ErrorText + " (Error " + QString::number(m_Error) + ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
QNetworkReply::NetworkError m_Error;
|
|
|
|
QString m_ErrorText;
|
|
|
|
};
|
|
|
|
|
2019-03-17 01:50:07 +00:00
|
|
|
class NvHTTP : public QObject
|
2018-04-28 22:39:50 +00:00
|
|
|
{
|
2019-03-17 01:50:07 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2018-04-28 22:39:50 +00:00
|
|
|
public:
|
2018-08-31 03:15:06 +00:00
|
|
|
enum NvLogLevel {
|
2019-01-20 05:32:35 +00:00
|
|
|
NVLL_NONE,
|
|
|
|
NVLL_ERROR,
|
|
|
|
NVLL_VERBOSE
|
2018-08-31 03:15:06 +00:00
|
|
|
};
|
|
|
|
|
2021-07-03 05:00:27 +00:00
|
|
|
explicit NvHTTP(NvAddress address, uint16_t httpsPort, QSslCertificate serverCert);
|
2018-04-28 22:39:50 +00:00
|
|
|
|
2021-07-02 22:14:48 +00:00
|
|
|
explicit NvHTTP(NvComputer* computer);
|
|
|
|
|
2018-06-27 04:47:01 +00:00
|
|
|
static
|
2018-04-29 00:08:05 +00:00
|
|
|
int
|
|
|
|
getCurrentGame(QString serverInfo);
|
|
|
|
|
|
|
|
QString
|
2019-12-30 23:51:23 +00:00
|
|
|
getServerInfo(NvLogLevel logLevel, bool fastFail = false);
|
2018-04-29 00:08:05 +00:00
|
|
|
|
2018-06-27 04:47:01 +00:00
|
|
|
static
|
2018-04-29 00:08:05 +00:00
|
|
|
void
|
|
|
|
verifyResponseStatus(QString xml);
|
|
|
|
|
2018-06-27 04:47:01 +00:00
|
|
|
static
|
2018-04-29 00:08:05 +00:00
|
|
|
QString
|
|
|
|
getXmlString(QString xml,
|
|
|
|
QString tagName);
|
|
|
|
|
2018-06-27 04:47:01 +00:00
|
|
|
static
|
2018-04-29 08:48:41 +00:00
|
|
|
QByteArray
|
|
|
|
getXmlStringFromHex(QString xml,
|
|
|
|
QString tagName);
|
|
|
|
|
2018-04-29 00:08:05 +00:00
|
|
|
QString
|
|
|
|
openConnectionToString(QUrl baseUrl,
|
|
|
|
QString command,
|
|
|
|
QString arguments,
|
2019-01-06 22:35:33 +00:00
|
|
|
int timeoutMs,
|
2019-01-20 05:32:35 +00:00
|
|
|
NvLogLevel logLevel = NvLogLevel::NVLL_VERBOSE);
|
2018-04-29 00:08:05 +00:00
|
|
|
|
2018-12-23 03:55:28 +00:00
|
|
|
void setServerCert(QSslCertificate serverCert);
|
|
|
|
|
2021-07-03 04:34:54 +00:00
|
|
|
void setAddress(NvAddress address);
|
|
|
|
void setHttpsPort(uint16_t port);
|
2019-08-01 05:07:20 +00:00
|
|
|
|
2021-07-03 04:34:54 +00:00
|
|
|
NvAddress address();
|
2019-08-01 05:07:20 +00:00
|
|
|
|
2021-07-02 22:14:48 +00:00
|
|
|
QSslCertificate serverCert();
|
|
|
|
|
|
|
|
uint16_t httpPort();
|
|
|
|
|
|
|
|
uint16_t httpsPort();
|
|
|
|
|
2018-06-27 04:47:01 +00:00
|
|
|
static
|
2018-04-29 02:01:00 +00:00
|
|
|
QVector<int>
|
2018-07-06 06:12:55 +00:00
|
|
|
parseQuad(QString quad);
|
2018-04-29 02:01:00 +00:00
|
|
|
|
2018-06-24 07:14:23 +00:00
|
|
|
void
|
|
|
|
quitApp();
|
|
|
|
|
|
|
|
void
|
2021-07-02 06:51:08 +00:00
|
|
|
resumeApp(PSTREAM_CONFIGURATION streamConfig,
|
|
|
|
QString& rtspSessionUrl);
|
2018-06-24 07:14:23 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
launchApp(int appId,
|
|
|
|
PSTREAM_CONFIGURATION streamConfig,
|
|
|
|
bool sops,
|
|
|
|
bool localAudio,
|
2021-07-02 06:51:08 +00:00
|
|
|
int gamepadMask,
|
|
|
|
QString& rtspSessionUrl);
|
2018-06-24 07:14:23 +00:00
|
|
|
|
2018-06-27 06:39:28 +00:00
|
|
|
QVector<NvApp>
|
|
|
|
getAppList();
|
|
|
|
|
2018-06-27 06:49:44 +00:00
|
|
|
QImage
|
|
|
|
getBoxArt(int appId);
|
|
|
|
|
2018-07-09 03:53:24 +00:00
|
|
|
static
|
|
|
|
QVector<NvDisplayMode>
|
|
|
|
getDisplayModeList(QString serverInfo);
|
|
|
|
|
2018-04-28 22:39:50 +00:00
|
|
|
QUrl m_BaseUrlHttp;
|
|
|
|
QUrl m_BaseUrlHttps;
|
2018-04-29 05:14:27 +00:00
|
|
|
private:
|
2019-03-17 01:50:07 +00:00
|
|
|
void
|
|
|
|
handleSslErrors(QNetworkReply* reply, const QList<QSslError>& errors);
|
|
|
|
|
2018-04-29 05:14:27 +00:00
|
|
|
QNetworkReply*
|
|
|
|
openConnection(QUrl baseUrl,
|
|
|
|
QString command,
|
|
|
|
QString arguments,
|
2019-01-06 22:35:33 +00:00
|
|
|
int timeoutMs,
|
2018-08-31 03:15:06 +00:00
|
|
|
NvLogLevel logLevel);
|
2018-04-29 05:14:27 +00:00
|
|
|
|
2021-07-03 04:34:54 +00:00
|
|
|
NvAddress m_Address;
|
2018-04-28 22:39:50 +00:00
|
|
|
QNetworkAccessManager m_Nam;
|
2018-12-22 02:08:07 +00:00
|
|
|
QSslCertificate m_ServerCert;
|
2018-04-28 22:39:50 +00:00
|
|
|
};
|