moonlight-qt/app/backend/nvhttp.h

132 lines
2.3 KiB
C
Raw Normal View History

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>
#include <QtNetwork/QNetworkAccessManager>
2018-06-27 06:39:28 +00:00
class NvApp
{
public:
bool operator==(const NvApp& other) const
{
return id == other.id;
}
bool isInitialized()
{
return id != 0 && !name.isNull();
}
int id;
QString name;
bool hdrSupported;
};
Q_DECLARE_METATYPE(NvApp)
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)
{
}
const char* what() const throw()
{
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;
}
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-04-28 22:39:50 +00:00
class NvHTTP
{
public:
2018-06-28 02:55:44 +00:00
explicit NvHTTP(QString address);
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
getServerInfo();
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,
bool enableTimeout);
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-04-28 22:39:50 +00:00
QUrl m_BaseUrlHttp;
QUrl m_BaseUrlHttps;
2018-04-29 05:14:27 +00:00
private:
QNetworkReply*
openConnection(QUrl baseUrl,
QString command,
QString arguments,
bool enableTimeout);
QString m_Address;
2018-04-28 22:39:50 +00:00
QNetworkAccessManager m_Nam;
};