fixed history and favorites browsing
This commit is contained in:
parent
99317f3405
commit
081b32ae73
@ -36,6 +36,9 @@
|
|||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||||
|
#include <QRandromGenerator>
|
||||||
|
#endif
|
||||||
|
|
||||||
Heos::Heos(const QHostAddress &hostAddress, QObject *parent) :
|
Heos::Heos(const QHostAddress &hostAddress, QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
@ -386,7 +389,7 @@ void Heos::groupVolumeDown(int groupId, int step)
|
|||||||
********************************/
|
********************************/
|
||||||
quint32 Heos::getMusicSources()
|
quint32 Heos::getMusicSources()
|
||||||
{
|
{
|
||||||
quint32 sequence = qrand();;
|
quint32 sequence = createRandomNumber();
|
||||||
QByteArray cmd = "heos://browse/get_music_sources?";
|
QByteArray cmd = "heos://browse/get_music_sources?";
|
||||||
QUrlQuery queryParams;
|
QUrlQuery queryParams;
|
||||||
queryParams.addQueryItem("SEQUENCE", QString::number(sequence));
|
queryParams.addQueryItem("SEQUENCE", QString::number(sequence));
|
||||||
@ -399,7 +402,7 @@ quint32 Heos::getMusicSources()
|
|||||||
|
|
||||||
quint32 Heos::getSourceInfo(const QString &sourceId)
|
quint32 Heos::getSourceInfo(const QString &sourceId)
|
||||||
{
|
{
|
||||||
quint32 sequence = qrand();
|
quint32 sequence = createRandomNumber();
|
||||||
QByteArray cmd = "heos://browse/get_source_info?";
|
QByteArray cmd = "heos://browse/get_source_info?";
|
||||||
QUrlQuery queryParams;
|
QUrlQuery queryParams;
|
||||||
queryParams.addQueryItem("sid", sourceId);
|
queryParams.addQueryItem("sid", sourceId);
|
||||||
@ -413,7 +416,7 @@ quint32 Heos::getSourceInfo(const QString &sourceId)
|
|||||||
|
|
||||||
quint32 Heos::getSearchCriteria(const QString &sourceId)
|
quint32 Heos::getSearchCriteria(const QString &sourceId)
|
||||||
{
|
{
|
||||||
quint32 sequence = qrand();
|
quint32 sequence = createRandomNumber();;
|
||||||
QByteArray cmd = "heos://browse/get_search_criteria?";
|
QByteArray cmd = "heos://browse/get_search_criteria?";
|
||||||
QUrlQuery queryParams;
|
QUrlQuery queryParams;
|
||||||
queryParams.addQueryItem("sid", sourceId);
|
queryParams.addQueryItem("sid", sourceId);
|
||||||
@ -426,7 +429,7 @@ quint32 Heos::getSearchCriteria(const QString &sourceId)
|
|||||||
|
|
||||||
quint32 Heos::browseSource(const QString &sourceId)
|
quint32 Heos::browseSource(const QString &sourceId)
|
||||||
{
|
{
|
||||||
quint32 sequence = qrand();
|
quint32 sequence = createRandomNumber();
|
||||||
QByteArray cmd = "heos://browse/browse?";
|
QByteArray cmd = "heos://browse/browse?";
|
||||||
QUrlQuery queryParams;
|
QUrlQuery queryParams;
|
||||||
queryParams.addQueryItem("sid", sourceId);
|
queryParams.addQueryItem("sid", sourceId);
|
||||||
@ -440,7 +443,7 @@ quint32 Heos::browseSource(const QString &sourceId)
|
|||||||
|
|
||||||
quint32 Heos::browseSourceContainers(const QString &sourceId, const QString &containerId)
|
quint32 Heos::browseSourceContainers(const QString &sourceId, const QString &containerId)
|
||||||
{
|
{
|
||||||
quint32 sequence = qrand();
|
quint32 sequence = createRandomNumber();;
|
||||||
QByteArray cmd = "heos://browse/browse?";
|
QByteArray cmd = "heos://browse/browse?";
|
||||||
QUrlQuery queryParams;
|
QUrlQuery queryParams;
|
||||||
queryParams.addQueryItem("sid", sourceId);
|
queryParams.addQueryItem("sid", sourceId);
|
||||||
@ -455,7 +458,7 @@ quint32 Heos::browseSourceContainers(const QString &sourceId, const QString &con
|
|||||||
|
|
||||||
quint32 Heos::playStation(int playerId, const QString &sourceId, const QString &containerId, const QString &mediaId, const QString &stationName)
|
quint32 Heos::playStation(int playerId, const QString &sourceId, const QString &containerId, const QString &mediaId, const QString &stationName)
|
||||||
{
|
{
|
||||||
quint32 sequence = qrand();
|
quint32 sequence = createRandomNumber();;
|
||||||
QByteArray cmd("heos://browse/play_stream?");
|
QByteArray cmd("heos://browse/play_stream?");
|
||||||
QUrlQuery queryParams;
|
QUrlQuery queryParams;
|
||||||
queryParams.addQueryItem("pid", QString::number(playerId));
|
queryParams.addQueryItem("pid", QString::number(playerId));
|
||||||
@ -481,7 +484,7 @@ quint32 Heos::playStation(int playerId, const QString &sourceId, const QString &
|
|||||||
|
|
||||||
quint32 Heos::playPresetStation(int playerId, int presetNumber)
|
quint32 Heos::playPresetStation(int playerId, int presetNumber)
|
||||||
{
|
{
|
||||||
quint32 sequence = qrand();
|
quint32 sequence = createRandomNumber();
|
||||||
QByteArray cmd("heos://browse/play_preset?");
|
QByteArray cmd("heos://browse/play_preset?");
|
||||||
QUrlQuery queryParams;
|
QUrlQuery queryParams;
|
||||||
queryParams.addQueryItem("pid", QString::number(playerId));
|
queryParams.addQueryItem("pid", QString::number(playerId));
|
||||||
@ -496,7 +499,7 @@ quint32 Heos::playPresetStation(int playerId, int presetNumber)
|
|||||||
|
|
||||||
quint32 Heos::playInputSource(int playerId, const QString &inputName)
|
quint32 Heos::playInputSource(int playerId, const QString &inputName)
|
||||||
{
|
{
|
||||||
quint32 sequence = qrand();
|
quint32 sequence = createRandomNumber();
|
||||||
QByteArray cmd("heos://browse/play_input?");
|
QByteArray cmd("heos://browse/play_input?");
|
||||||
QUrlQuery queryParams;
|
QUrlQuery queryParams;
|
||||||
queryParams.addQueryItem("pid", QString::number(playerId));
|
queryParams.addQueryItem("pid", QString::number(playerId));
|
||||||
@ -511,7 +514,7 @@ quint32 Heos::playInputSource(int playerId, const QString &inputName)
|
|||||||
|
|
||||||
quint32 Heos::playUrl(int playerId, const QUrl &mediaUrl)
|
quint32 Heos::playUrl(int playerId, const QUrl &mediaUrl)
|
||||||
{
|
{
|
||||||
quint32 sequence = qrand();
|
quint32 sequence = createRandomNumber();
|
||||||
QByteArray cmd("heos://browse/play_stream?");
|
QByteArray cmd("heos://browse/play_stream?");
|
||||||
QUrlQuery queryParams;
|
QUrlQuery queryParams;
|
||||||
queryParams.addQueryItem("pid", QString::number(playerId));
|
queryParams.addQueryItem("pid", QString::number(playerId));
|
||||||
@ -526,7 +529,7 @@ quint32 Heos::playUrl(int playerId, const QUrl &mediaUrl)
|
|||||||
|
|
||||||
quint32 Heos::addContainerToQueue(int playerId, const QString &sourceId, const QString &containerId, ADD_CRITERIA addCriteria)
|
quint32 Heos::addContainerToQueue(int playerId, const QString &sourceId, const QString &containerId, ADD_CRITERIA addCriteria)
|
||||||
{
|
{
|
||||||
quint32 sequence = qrand();
|
quint32 sequence = createRandomNumber();
|
||||||
QByteArray cmd("heos://browse/add_to_queue?");
|
QByteArray cmd("heos://browse/add_to_queue?");
|
||||||
QUrlQuery queryParams;
|
QUrlQuery queryParams;
|
||||||
queryParams.addQueryItem("pid", QString::number(playerId));
|
queryParams.addQueryItem("pid", QString::number(playerId));
|
||||||
@ -568,6 +571,7 @@ void Heos::readData()
|
|||||||
|
|
||||||
while (m_socket->canReadLine()) {
|
while (m_socket->canReadLine()) {
|
||||||
data = m_socket->readLine();
|
data = m_socket->readLine();
|
||||||
|
qDebug(dcDenon) << "Read data" << data;
|
||||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &error);
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &error);
|
||||||
if (error.error != QJsonParseError::NoError) {
|
if (error.error != QJsonParseError::NoError) {
|
||||||
qCWarning(dcDenon) << "failed to parse json :" << error.errorString();
|
qCWarning(dcDenon) << "failed to parse json :" << error.errorString();
|
||||||
@ -1157,3 +1161,14 @@ void Heos::readData()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
quint32 Heos::createRandomNumber()
|
||||||
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||||
|
return QRandomGenerator::global()->generate();
|
||||||
|
#else
|
||||||
|
return qrand();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -166,6 +166,8 @@ private slots:
|
|||||||
void onDisconnected();
|
void onDisconnected();
|
||||||
void onError(QAbstractSocket::SocketError socketError);
|
void onError(QAbstractSocket::SocketError socketError);
|
||||||
void readData();
|
void readData();
|
||||||
|
|
||||||
|
quint32 createRandomNumber();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -160,7 +160,7 @@ void IntegrationPluginDenon::confirmPairing(ThingPairingInfo *info, const QStrin
|
|||||||
if (info->thingClassId() == heosThingClassId) {
|
if (info->thingClassId() == heosThingClassId) {
|
||||||
|
|
||||||
if (username.isEmpty()) { //thing connection will be setup without an user account
|
if (username.isEmpty()) { //thing connection will be setup without an user account
|
||||||
info->finish(Thing::ThingErrorNoError);
|
return info->finish(Thing::ThingErrorNoError);
|
||||||
}
|
}
|
||||||
|
|
||||||
QHostAddress address(info->params().paramValue(heosThingIpParamTypeId).toString());
|
QHostAddress address(info->params().paramValue(heosThingIpParamTypeId).toString());
|
||||||
@ -599,6 +599,8 @@ void IntegrationPluginDenon::onHeosPlayersReceived(QList<HeosPlayer *> heosPlaye
|
|||||||
qCDebug(dcDenon) << "Found new heos player" << player->name();
|
qCDebug(dcDenon) << "Found new heos player" << player->name();
|
||||||
heosPlayerDescriptors.append(descriptor);
|
heosPlayerDescriptors.append(descriptor);
|
||||||
}
|
}
|
||||||
|
if (!heosPlayerDescriptors.isEmpty())
|
||||||
|
autoThingsAppeared(heosPlayerDescriptors);
|
||||||
|
|
||||||
foreach(Thing *existingThing, myThings().filterByParentId(thing->id())) {
|
foreach(Thing *existingThing, myThings().filterByParentId(thing->id())) {
|
||||||
bool playerAvailable = false;
|
bool playerAvailable = false;
|
||||||
@ -692,6 +694,11 @@ void IntegrationPluginDenon::onHeosMusicSourcesReceived(quint32 sequenceNumber,
|
|||||||
{
|
{
|
||||||
Q_UNUSED(sequenceNumber)
|
Q_UNUSED(sequenceNumber)
|
||||||
Heos *heos = static_cast<Heos *>(sender());
|
Heos *heos = static_cast<Heos *>(sender());
|
||||||
|
Thing *thing = myThings().findById(m_heosConnections.key(heos));
|
||||||
|
if (!thing) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bool loggedIn = thing->stateValue(heosLoggedInStateTypeId).toBool();
|
||||||
if (m_pendingGetSourcesRequest.contains(heos)) {
|
if (m_pendingGetSourcesRequest.contains(heos)) {
|
||||||
BrowseResult *result = m_pendingGetSourcesRequest.take(heos);
|
BrowseResult *result = m_pendingGetSourcesRequest.take(heos);
|
||||||
foreach(MusicSourceObject source, musicSources) {
|
foreach(MusicSourceObject source, musicSources) {
|
||||||
@ -732,13 +739,25 @@ void IntegrationPluginDenon::onHeosMusicSourcesReceived(quint32 sequenceNumber,
|
|||||||
} else if (source.name == "Playlists") {
|
} else if (source.name == "Playlists") {
|
||||||
item.setMediaIcon(MediaBrowserItem::MediaBrowserIconPlaylist);
|
item.setMediaIcon(MediaBrowserItem::MediaBrowserIconPlaylist);
|
||||||
} else if (source.name == "History") {
|
} else if (source.name == "History") {
|
||||||
//result->addItem(item);
|
|
||||||
item.setMediaIcon(MediaBrowserItem::MediaBrowserIconRecentlyPlayed);
|
item.setMediaIcon(MediaBrowserItem::MediaBrowserIconRecentlyPlayed);
|
||||||
|
item.setBrowsable(loggedIn);
|
||||||
|
if (!loggedIn) {
|
||||||
|
item.setDescription("Login required");
|
||||||
|
} else {
|
||||||
|
item.setDescription(source.serviceUsername);
|
||||||
|
}
|
||||||
|
result->addItem(item);
|
||||||
} else if (source.name == "AUX Input") {
|
} else if (source.name == "AUX Input") {
|
||||||
item.setMediaIcon(MediaBrowserItem::MediaBrowserIconAux);
|
item.setMediaIcon(MediaBrowserItem::MediaBrowserIconAux);
|
||||||
//result->addItem(item);
|
//result->addItem(item);
|
||||||
} else if (source.name == "Favorites") {
|
} else if (source.name == "Favorites") {
|
||||||
item.setIcon(BrowserItem::BrowserIconFavorites);
|
item.setIcon(BrowserItem::BrowserIconFavorites);
|
||||||
|
item.setBrowsable(loggedIn);
|
||||||
|
if (!loggedIn) {
|
||||||
|
item.setDescription("Login required");
|
||||||
|
} else {
|
||||||
|
item.setDescription(source.serviceUsername);
|
||||||
|
}
|
||||||
result->addItem(item);
|
result->addItem(item);
|
||||||
} else {
|
} else {
|
||||||
item.setThumbnail(source.image_url);
|
item.setThumbnail(source.image_url);
|
||||||
@ -752,6 +771,13 @@ void IntegrationPluginDenon::onHeosMusicSourcesReceived(quint32 sequenceNumber,
|
|||||||
void IntegrationPluginDenon::onHeosBrowseRequestReceived(quint32 sequenceNumber, const QString &sourceId, const QString &containerId, QList<MusicSourceObject> musicSources, QList<MediaObject> mediaItems)
|
void IntegrationPluginDenon::onHeosBrowseRequestReceived(quint32 sequenceNumber, const QString &sourceId, const QString &containerId, QList<MusicSourceObject> musicSources, QList<MediaObject> mediaItems)
|
||||||
{
|
{
|
||||||
Q_UNUSED(sequenceNumber)
|
Q_UNUSED(sequenceNumber)
|
||||||
|
Heos *heos = static_cast<Heos *>(sender());
|
||||||
|
Thing *thing = myThings().findById(m_heosConnections.key(heos));
|
||||||
|
if (!thing) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bool loggedIn = thing->stateValue(heosLoggedInStateTypeId).toBool();
|
||||||
|
|
||||||
QString identifier;
|
QString identifier;
|
||||||
if (containerId.isEmpty()) {
|
if (containerId.isEmpty()) {
|
||||||
identifier = sourceId;
|
identifier = sourceId;
|
||||||
@ -814,12 +840,19 @@ void IntegrationPluginDenon::onHeosBrowseRequestReceived(quint32 sequenceNumber,
|
|||||||
//result->addItem(item);
|
//result->addItem(item);
|
||||||
} else if (source.name == "History") {
|
} else if (source.name == "History") {
|
||||||
item.setMediaIcon(MediaBrowserItem::MediaBrowserIconRecentlyPlayed);
|
item.setMediaIcon(MediaBrowserItem::MediaBrowserIconRecentlyPlayed);
|
||||||
//result->addItem(item);
|
item.setBrowsable(loggedIn);
|
||||||
|
if (!loggedIn) {
|
||||||
|
item.setDescription("Login required");
|
||||||
|
}
|
||||||
} else if (source.name == "AUX Input") {
|
} else if (source.name == "AUX Input") {
|
||||||
item.setMediaIcon(MediaBrowserItem::MediaBrowserIconAux);
|
item.setMediaIcon(MediaBrowserItem::MediaBrowserIconAux);
|
||||||
//result->addItem(item);
|
//result->addItem(item);
|
||||||
} else if (source.name == "Favorites") {
|
} else if (source.name == "Favorites") {
|
||||||
item.setIcon(BrowserItem::BrowserIconFavorites);
|
item.setIcon(BrowserItem::BrowserIconFavorites);
|
||||||
|
item.setBrowsable(loggedIn);
|
||||||
|
if (!loggedIn) {
|
||||||
|
item.setDescription("Login required");
|
||||||
|
}
|
||||||
result->addItem(item);
|
result->addItem(item);
|
||||||
} else {
|
} else {
|
||||||
item.setThumbnail(source.image_url);
|
item.setThumbnail(source.image_url);
|
||||||
|
|||||||
@ -42,16 +42,17 @@
|
|||||||
{
|
{
|
||||||
"id": "fc1dee8b-8fcc-4ec2-8fe6-6be4f5f47a5c",
|
"id": "fc1dee8b-8fcc-4ec2-8fe6-6be4f5f47a5c",
|
||||||
"name": "connected",
|
"name": "connected",
|
||||||
"displayName": "connected",
|
"displayName": "Connected",
|
||||||
"displayNameEvent": "connected changed",
|
"displayNameEvent": "Connected changed",
|
||||||
"defaultValue": false,
|
"defaultValue": false,
|
||||||
"type": "bool"
|
"type": "bool",
|
||||||
|
"cached": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "power",
|
"displayName": "power",
|
||||||
"id": "1cdb6b54-6831-4900-95b2-c78f64497701",
|
"id": "1cdb6b54-6831-4900-95b2-c78f64497701",
|
||||||
"name": "power",
|
"name": "power",
|
||||||
"displayNameEvent": "power changed",
|
"displayNameEvent": "Power changed",
|
||||||
"displayNameAction": "Set power",
|
"displayNameAction": "Set power",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"defaultValue": false,
|
"defaultValue": false,
|
||||||
@ -201,15 +202,17 @@
|
|||||||
"displayName": "Connected",
|
"displayName": "Connected",
|
||||||
"displayNameEvent": "Connected changed",
|
"displayNameEvent": "Connected changed",
|
||||||
"defaultValue": false,
|
"defaultValue": false,
|
||||||
"type": "bool"
|
"type": "bool",
|
||||||
|
"cached": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "ab689a6e-eb71-4a41-a267-ba1afe7e2f56",
|
"id": "ab689a6e-eb71-4a41-a267-ba1afe7e2f56",
|
||||||
"name": "loggedIn",
|
"name": "loggedIn",
|
||||||
"displayName": "Logged in",
|
"displayName": "Logged in",
|
||||||
"displayNameEvent": "Logged in changed",
|
"displayNameEvent": "Logged in changed",
|
||||||
"defaultValue": true,
|
"defaultValue": false,
|
||||||
"type": "bool"
|
"type": "bool",
|
||||||
|
"cached": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "77756132-5fa4-409e-969e-d23bcee72356",
|
"id": "77756132-5fa4-409e-969e-d23bcee72356",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user