fixed history and favorites browsing
parent
99317f3405
commit
081b32ae73
|
|
@ -36,6 +36,9 @@
|
|||
#include <QJsonDocument>
|
||||
#include <QUrlQuery>
|
||||
#include <QTimer>
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||
#include <QRandromGenerator>
|
||||
#endif
|
||||
|
||||
Heos::Heos(const QHostAddress &hostAddress, QObject *parent) :
|
||||
QObject(parent),
|
||||
|
|
@ -386,7 +389,7 @@ void Heos::groupVolumeDown(int groupId, int step)
|
|||
********************************/
|
||||
quint32 Heos::getMusicSources()
|
||||
{
|
||||
quint32 sequence = qrand();;
|
||||
quint32 sequence = createRandomNumber();
|
||||
QByteArray cmd = "heos://browse/get_music_sources?";
|
||||
QUrlQuery queryParams;
|
||||
queryParams.addQueryItem("SEQUENCE", QString::number(sequence));
|
||||
|
|
@ -399,7 +402,7 @@ quint32 Heos::getMusicSources()
|
|||
|
||||
quint32 Heos::getSourceInfo(const QString &sourceId)
|
||||
{
|
||||
quint32 sequence = qrand();
|
||||
quint32 sequence = createRandomNumber();
|
||||
QByteArray cmd = "heos://browse/get_source_info?";
|
||||
QUrlQuery queryParams;
|
||||
queryParams.addQueryItem("sid", sourceId);
|
||||
|
|
@ -413,7 +416,7 @@ quint32 Heos::getSourceInfo(const QString &sourceId)
|
|||
|
||||
quint32 Heos::getSearchCriteria(const QString &sourceId)
|
||||
{
|
||||
quint32 sequence = qrand();
|
||||
quint32 sequence = createRandomNumber();;
|
||||
QByteArray cmd = "heos://browse/get_search_criteria?";
|
||||
QUrlQuery queryParams;
|
||||
queryParams.addQueryItem("sid", sourceId);
|
||||
|
|
@ -426,7 +429,7 @@ quint32 Heos::getSearchCriteria(const QString &sourceId)
|
|||
|
||||
quint32 Heos::browseSource(const QString &sourceId)
|
||||
{
|
||||
quint32 sequence = qrand();
|
||||
quint32 sequence = createRandomNumber();
|
||||
QByteArray cmd = "heos://browse/browse?";
|
||||
QUrlQuery queryParams;
|
||||
queryParams.addQueryItem("sid", sourceId);
|
||||
|
|
@ -440,7 +443,7 @@ quint32 Heos::browseSource(const QString &sourceId)
|
|||
|
||||
quint32 Heos::browseSourceContainers(const QString &sourceId, const QString &containerId)
|
||||
{
|
||||
quint32 sequence = qrand();
|
||||
quint32 sequence = createRandomNumber();;
|
||||
QByteArray cmd = "heos://browse/browse?";
|
||||
QUrlQuery queryParams;
|
||||
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 sequence = qrand();
|
||||
quint32 sequence = createRandomNumber();;
|
||||
QByteArray cmd("heos://browse/play_stream?");
|
||||
QUrlQuery queryParams;
|
||||
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 sequence = qrand();
|
||||
quint32 sequence = createRandomNumber();
|
||||
QByteArray cmd("heos://browse/play_preset?");
|
||||
QUrlQuery queryParams;
|
||||
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 sequence = qrand();
|
||||
quint32 sequence = createRandomNumber();
|
||||
QByteArray cmd("heos://browse/play_input?");
|
||||
QUrlQuery queryParams;
|
||||
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 sequence = qrand();
|
||||
quint32 sequence = createRandomNumber();
|
||||
QByteArray cmd("heos://browse/play_stream?");
|
||||
QUrlQuery queryParams;
|
||||
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 sequence = qrand();
|
||||
quint32 sequence = createRandomNumber();
|
||||
QByteArray cmd("heos://browse/add_to_queue?");
|
||||
QUrlQuery queryParams;
|
||||
queryParams.addQueryItem("pid", QString::number(playerId));
|
||||
|
|
@ -568,6 +571,7 @@ void Heos::readData()
|
|||
|
||||
while (m_socket->canReadLine()) {
|
||||
data = m_socket->readLine();
|
||||
qDebug(dcDenon) << "Read data" << data;
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &error);
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
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 onError(QAbstractSocket::SocketError socketError);
|
||||
void readData();
|
||||
|
||||
quint32 createRandomNumber();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ void IntegrationPluginDenon::confirmPairing(ThingPairingInfo *info, const QStrin
|
|||
if (info->thingClassId() == heosThingClassId) {
|
||||
|
||||
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());
|
||||
|
|
@ -599,6 +599,8 @@ void IntegrationPluginDenon::onHeosPlayersReceived(QList<HeosPlayer *> heosPlaye
|
|||
qCDebug(dcDenon) << "Found new heos player" << player->name();
|
||||
heosPlayerDescriptors.append(descriptor);
|
||||
}
|
||||
if (!heosPlayerDescriptors.isEmpty())
|
||||
autoThingsAppeared(heosPlayerDescriptors);
|
||||
|
||||
foreach(Thing *existingThing, myThings().filterByParentId(thing->id())) {
|
||||
bool playerAvailable = false;
|
||||
|
|
@ -692,6 +694,11 @@ void IntegrationPluginDenon::onHeosMusicSourcesReceived(quint32 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();
|
||||
if (m_pendingGetSourcesRequest.contains(heos)) {
|
||||
BrowseResult *result = m_pendingGetSourcesRequest.take(heos);
|
||||
foreach(MusicSourceObject source, musicSources) {
|
||||
|
|
@ -732,13 +739,25 @@ void IntegrationPluginDenon::onHeosMusicSourcesReceived(quint32 sequenceNumber,
|
|||
} else if (source.name == "Playlists") {
|
||||
item.setMediaIcon(MediaBrowserItem::MediaBrowserIconPlaylist);
|
||||
} else if (source.name == "History") {
|
||||
//result->addItem(item);
|
||||
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") {
|
||||
item.setMediaIcon(MediaBrowserItem::MediaBrowserIconAux);
|
||||
//result->addItem(item);
|
||||
} else if (source.name == "Favorites") {
|
||||
item.setIcon(BrowserItem::BrowserIconFavorites);
|
||||
item.setBrowsable(loggedIn);
|
||||
if (!loggedIn) {
|
||||
item.setDescription("Login required");
|
||||
} else {
|
||||
item.setDescription(source.serviceUsername);
|
||||
}
|
||||
result->addItem(item);
|
||||
} else {
|
||||
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)
|
||||
{
|
||||
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;
|
||||
if (containerId.isEmpty()) {
|
||||
identifier = sourceId;
|
||||
|
|
@ -814,12 +840,19 @@ void IntegrationPluginDenon::onHeosBrowseRequestReceived(quint32 sequenceNumber,
|
|||
//result->addItem(item);
|
||||
} else if (source.name == "History") {
|
||||
item.setMediaIcon(MediaBrowserItem::MediaBrowserIconRecentlyPlayed);
|
||||
//result->addItem(item);
|
||||
item.setBrowsable(loggedIn);
|
||||
if (!loggedIn) {
|
||||
item.setDescription("Login required");
|
||||
}
|
||||
} else if (source.name == "AUX Input") {
|
||||
item.setMediaIcon(MediaBrowserItem::MediaBrowserIconAux);
|
||||
//result->addItem(item);
|
||||
} else if (source.name == "Favorites") {
|
||||
item.setIcon(BrowserItem::BrowserIconFavorites);
|
||||
item.setBrowsable(loggedIn);
|
||||
if (!loggedIn) {
|
||||
item.setDescription("Login required");
|
||||
}
|
||||
result->addItem(item);
|
||||
} else {
|
||||
item.setThumbnail(source.image_url);
|
||||
|
|
|
|||
|
|
@ -42,16 +42,17 @@
|
|||
{
|
||||
"id": "fc1dee8b-8fcc-4ec2-8fe6-6be4f5f47a5c",
|
||||
"name": "connected",
|
||||
"displayName": "connected",
|
||||
"displayNameEvent": "connected changed",
|
||||
"displayName": "Connected",
|
||||
"displayNameEvent": "Connected changed",
|
||||
"defaultValue": false,
|
||||
"type": "bool"
|
||||
"type": "bool",
|
||||
"cached": false
|
||||
},
|
||||
{
|
||||
"displayName": "power",
|
||||
"id": "1cdb6b54-6831-4900-95b2-c78f64497701",
|
||||
"name": "power",
|
||||
"displayNameEvent": "power changed",
|
||||
"displayNameEvent": "Power changed",
|
||||
"displayNameAction": "Set power",
|
||||
"type": "bool",
|
||||
"defaultValue": false,
|
||||
|
|
@ -201,15 +202,17 @@
|
|||
"displayName": "Connected",
|
||||
"displayNameEvent": "Connected changed",
|
||||
"defaultValue": false,
|
||||
"type": "bool"
|
||||
"type": "bool",
|
||||
"cached": false
|
||||
},
|
||||
{
|
||||
"id": "ab689a6e-eb71-4a41-a267-ba1afe7e2f56",
|
||||
"name": "loggedIn",
|
||||
"displayName": "Logged in",
|
||||
"displayNameEvent": "Logged in changed",
|
||||
"defaultValue": true,
|
||||
"type": "bool"
|
||||
"defaultValue": false,
|
||||
"type": "bool",
|
||||
"cached": false
|
||||
},
|
||||
{
|
||||
"id": "77756132-5fa4-409e-969e-d23bcee72356",
|
||||
|
|
|
|||
Loading…
Reference in New Issue