2018-04-28 22:39:50 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-04-29 05:14:27 +00:00
|
|
|
#include "identitymanager.h"
|
|
|
|
|
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
|
|
|
|
2018-06-27 06:39:28 +00:00
|
|
|
class NvApp
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool operator==(const NvApp& other) const
|
|
|
|
{
|
|
|
|
return id == other.id;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isInitialized()
|
|
|
|
{
|
2018-09-15 01:36:15 +00:00
|
|
|
return id != 0 && !name.isEmpty();
|
2018-06-27 06:39:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int id;
|
|
|
|
QString name;
|
|
|
|
bool hdrSupported;
|
|
|
|
};
|
|
|
|
|
2018-06-28 05:02:29 +00:00
|
|
|
Q_DECLARE_METATYPE(NvApp)
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2018-12-22 02:08:07 +00:00
|
|
|
explicit NvHTTP(QString address, QSslCertificate serverCert);
|
2018-04-28 22:39:50 +00:00
|
|
|
|
2018-06-27 04:47:01 +00:00
|
|
|
static
|
2018-04-29 00:08:05 +00:00
|
|
|
int
|
|
|
|
getCurrentGame(QString serverInfo);
|
|
|
|
|
|
|
|
QString
|
2018-08-31 03:15:06 +00:00
|
|
|
getServerInfo(NvLogLevel logLevel);
|
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);
|
|
|
|
|
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
|
|
|
|
resumeApp(PSTREAM_CONFIGURATION streamConfig);
|
|
|
|
|
|
|
|
void
|
|
|
|
launchApp(int appId,
|
|
|
|
PSTREAM_CONFIGURATION streamConfig,
|
|
|
|
bool sops,
|
|
|
|
bool localAudio,
|
|
|
|
int gamepadMask);
|
|
|
|
|
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
|
|
|
|
|
|
|
QString 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
|
|
|
};
|