fixed user login
This commit is contained in:
parent
081b32ae73
commit
19ca381444
@ -571,7 +571,6 @@ 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();
|
||||||
@ -586,7 +585,10 @@ void Heos::readData()
|
|||||||
//If the message doesn't contain result it is an event message
|
//If the message doesn't contain result it is an event message
|
||||||
success = dataMap.value("heos").toMap().value("result").toString().contains("success");
|
success = dataMap.value("heos").toMap().value("result").toString().contains("success");
|
||||||
if (!success) {
|
if (!success) {
|
||||||
qDebug(dcDenon()) << "Command:" << command << "was not successfull. Message:" << message.toString();
|
qCWarning(dcDenon()) << "Command:" << command << "was not successfull. Message:" << message.toString();
|
||||||
|
if (command == "system/sign_in") {
|
||||||
|
emit userChanged(false, "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -630,9 +632,9 @@ void Heos::readData()
|
|||||||
qDebug(dcDenon()) << "System command sign_in:" << message.toString();
|
qDebug(dcDenon()) << "System command sign_in:" << message.toString();
|
||||||
|
|
||||||
if (message.hasQueryItem("signed_in")) {
|
if (message.hasQueryItem("signed_in")) {
|
||||||
bool signedIn = true;
|
|
||||||
QString username = message.queryItemValue("un");
|
QString username = message.queryItemValue("un");
|
||||||
emit userChanged(signedIn, username);
|
emit userChanged(true, username);
|
||||||
|
|
||||||
} // otherwise it will be command under process and we will wait for the event
|
} // otherwise it will be command under process and we will wait for the event
|
||||||
} else if (command.contains("sign_out")) {
|
} else if (command.contains("sign_out")) {
|
||||||
|
|
||||||
|
|||||||
@ -65,9 +65,7 @@ void IntegrationPluginDenon::discoverThings(ThingDiscoveryInfo *info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!m_serviceBrowser) {
|
if (!m_serviceBrowser) {
|
||||||
m_serviceBrowser = hardwareManager()->zeroConfController()->createServiceBrowser();
|
m_serviceBrowser = hardwareManager()->zeroConfController()->createServiceBrowser();;
|
||||||
connect(m_serviceBrowser, &ZeroConfServiceBrowser::serviceEntryAdded, this, &IntegrationPluginDenon::onAvahiServiceEntryAdded);
|
|
||||||
connect(m_serviceBrowser, &ZeroConfServiceBrowser::serviceEntryRemoved, this, &IntegrationPluginDenon::onAvahiServiceEntryRemoved);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QTimer::singleShot(2000, info, [this, info](){
|
QTimer::singleShot(2000, info, [this, info](){
|
||||||
@ -172,7 +170,7 @@ void IntegrationPluginDenon::confirmPairing(ThingPairingInfo *info, const QStrin
|
|||||||
heos->deleteLater();
|
heos->deleteLater();
|
||||||
});
|
});
|
||||||
heos->connectDevice();
|
heos->connectDevice();
|
||||||
heos->setUserAccount(username, password);;
|
heos->setUserAccount(username, password);
|
||||||
|
|
||||||
pluginStorage()->beginGroup(info->thingId().toString());
|
pluginStorage()->beginGroup(info->thingId().toString());
|
||||||
pluginStorage()->setValue("username", username);
|
pluginStorage()->setValue("username", username);
|
||||||
@ -208,7 +206,6 @@ void IntegrationPluginDenon::setupThing(ThingSetupInfo *info)
|
|||||||
m_asyncAvrSetups.insert(denonConnection, info);
|
m_asyncAvrSetups.insert(denonConnection, info);
|
||||||
// In case the setup is cancelled before we finish it...
|
// In case the setup is cancelled before we finish it...
|
||||||
connect(info, &QObject::destroyed, this, [this, denonConnection]() { m_asyncAvrSetups.remove(denonConnection); });
|
connect(info, &QObject::destroyed, this, [this, denonConnection]() { m_asyncAvrSetups.remove(denonConnection); });
|
||||||
|
|
||||||
denonConnection->connectDevice();
|
denonConnection->connectDevice();
|
||||||
return;
|
return;
|
||||||
} else if (thing->thingClassId() == heosThingClassId) {
|
} else if (thing->thingClassId() == heosThingClassId) {
|
||||||
@ -224,23 +221,16 @@ void IntegrationPluginDenon::setupThing(ThingSetupInfo *info)
|
|||||||
Heos *heos;
|
Heos *heos;
|
||||||
if (m_unfinishedHeosConnections.contains(thing->id())) {
|
if (m_unfinishedHeosConnections.contains(thing->id())) {
|
||||||
heos = m_unfinishedHeosConnections.take(thing->id());
|
heos = m_unfinishedHeosConnections.take(thing->id());
|
||||||
|
m_heosConnections.insert(thing->id(), heos);
|
||||||
info->finish(Thing::ThingErrorNoError);
|
info->finish(Thing::ThingErrorNoError);
|
||||||
} else {
|
} else {
|
||||||
heos = createHeosConnection(address);
|
heos = createHeosConnection(address);
|
||||||
|
m_heosConnections.insert(thing->id(), heos);
|
||||||
m_asyncHeosSetups.insert(heos, info);
|
m_asyncHeosSetups.insert(heos, info);
|
||||||
// In case the setup is cancelled before we finish it...
|
// In case the setup is cancelled before we finish it...
|
||||||
connect(info, &QObject::destroyed, this, [this, heos]() { m_asyncHeosSetups.remove(heos); });
|
connect(info, &QObject::destroyed, this, [=]() {m_asyncHeosSetups.remove(heos);});
|
||||||
heos->connectDevice();
|
heos->connectDevice();
|
||||||
pluginStorage()->beginGroup(thing->id().toString());
|
|
||||||
if (pluginStorage()->contains("username")) {
|
|
||||||
QString username = pluginStorage()->value("username").toString();
|
|
||||||
QString password = pluginStorage()->value("password").toString();
|
|
||||||
heos->setUserAccount(username, password);
|
|
||||||
}
|
|
||||||
pluginStorage()->endGroup();
|
|
||||||
}
|
}
|
||||||
m_heosConnections.insert(thing->id(), heos);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} else if (thing->thingClassId() == heosPlayerThingClassId) {
|
} else if (thing->thingClassId() == heosPlayerThingClassId) {
|
||||||
info->finish(Thing::ThingErrorNoError);
|
info->finish(Thing::ThingErrorNoError);
|
||||||
@ -265,7 +255,6 @@ void IntegrationPluginDenon::thingRemoved(Thing *thing)
|
|||||||
Heos *heos = m_heosConnections.take(thing->id());
|
Heos *heos = m_heosConnections.take(thing->id());
|
||||||
heos->deleteLater();
|
heos->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginStorage()->remove(thing->id().toString());
|
pluginStorage()->remove(thing->id().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,8 +374,18 @@ void IntegrationPluginDenon::postSetupThing(Thing *thing)
|
|||||||
if (thing->thingClassId() == heosThingClassId) {
|
if (thing->thingClassId() == heosThingClassId) {
|
||||||
Heos *heos = m_heosConnections.value(thing->id());
|
Heos *heos = m_heosConnections.value(thing->id());
|
||||||
thing->setStateValue(heosConnectedStateTypeId, heos->connected());
|
thing->setStateValue(heosConnectedStateTypeId, heos->connected());
|
||||||
|
if (pluginStorage()->childGroups().contains(thing->id().toString())) {
|
||||||
|
pluginStorage()->beginGroup(thing->id().toString());
|
||||||
|
QString username = pluginStorage()->value("username").toString();
|
||||||
|
QString password = pluginStorage()->value("password").toString();
|
||||||
|
pluginStorage()->endGroup();
|
||||||
|
heos->setUserAccount(username, password);
|
||||||
|
} else {
|
||||||
|
qCWarning(dcDenon()) << "Plugin storage doesn't contain this deviceId";
|
||||||
|
}
|
||||||
heos->getPlayers();
|
heos->getPlayers();
|
||||||
heos->getGroups();
|
heos->getGroups();
|
||||||
|
|
||||||
} else if (thing->thingClassId() == heosPlayerThingClassId) {
|
} else if (thing->thingClassId() == heosPlayerThingClassId) {
|
||||||
thing->setStateValue(heosPlayerConnectedStateTypeId, true);
|
thing->setStateValue(heosPlayerConnectedStateTypeId, true);
|
||||||
Thing *heosThing = myThings().findById(thing->parentId());
|
Thing *heosThing = myThings().findById(thing->parentId());
|
||||||
@ -547,7 +546,6 @@ void IntegrationPluginDenon::onHeosConnectionChanged(bool status)
|
|||||||
Heos *heos = static_cast<Heos *>(sender());
|
Heos *heos = static_cast<Heos *>(sender());
|
||||||
heos->registerForChangeEvents(true);
|
heos->registerForChangeEvents(true);
|
||||||
if (status) {
|
if (status) {
|
||||||
|
|
||||||
if (m_asyncHeosSetups.contains(heos)) {
|
if (m_asyncHeosSetups.contains(heos)) {
|
||||||
ThingSetupInfo *info = m_asyncHeosSetups.take(heos);
|
ThingSetupInfo *info = m_asyncHeosSetups.take(heos);
|
||||||
info->finish(Thing::ThingErrorNoError);
|
info->finish(Thing::ThingErrorNoError);
|
||||||
@ -638,7 +636,6 @@ void IntegrationPluginDenon::onHeosPlayStateReceived(int playerId, PLAYER_STATE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void IntegrationPluginDenon::onHeosRepeatModeReceived(int playerId, REPEAT_MODE repeatMode)
|
void IntegrationPluginDenon::onHeosRepeatModeReceived(int playerId, REPEAT_MODE repeatMode)
|
||||||
{
|
{
|
||||||
foreach(Thing *thing, myThings().filterByParam(heosPlayerThingPlayerIdParamTypeId, playerId)) {
|
foreach(Thing *thing, myThings().filterByParam(heosPlayerThingPlayerIdParamTypeId, playerId)) {
|
||||||
@ -792,6 +789,7 @@ void IntegrationPluginDenon::onHeosBrowseRequestReceived(quint32 sequenceNumber,
|
|||||||
BrowseResult *result = m_pendingBrowseResult.take(identifier);
|
BrowseResult *result = m_pendingBrowseResult.take(identifier);
|
||||||
foreach(MediaObject media, mediaItems) {
|
foreach(MediaObject media, mediaItems) {
|
||||||
MediaBrowserItem item;
|
MediaBrowserItem item;
|
||||||
|
item.setIcon(BrowserItem::BrowserIconMusic);
|
||||||
qDebug(dcDenon()) << "Adding Item" << media.name << media.mediaId << media.containerId << media.mediaType;
|
qDebug(dcDenon()) << "Adding Item" << media.name << media.mediaId << media.containerId << media.mediaType;
|
||||||
item.setDisplayName(media.name);
|
item.setDisplayName(media.name);
|
||||||
if (media.mediaType == MEDIA_TYPE_CONTAINER) {
|
if (media.mediaType == MEDIA_TYPE_CONTAINER) {
|
||||||
@ -911,6 +909,8 @@ void IntegrationPluginDenon::onHeosUserChanged(bool signedIn, const QString &use
|
|||||||
{
|
{
|
||||||
Q_UNUSED(userName)
|
Q_UNUSED(userName)
|
||||||
Heos *heos = static_cast<Heos *>(sender());
|
Heos *heos = static_cast<Heos *>(sender());
|
||||||
|
|
||||||
|
//This is to check if the credentials are correct
|
||||||
if (m_unfinishedHeosPairings.contains(heos)) {
|
if (m_unfinishedHeosPairings.contains(heos)) {
|
||||||
ThingPairingInfo *info = m_unfinishedHeosPairings.take(heos);
|
ThingPairingInfo *info = m_unfinishedHeosPairings.take(heos);
|
||||||
if (signedIn) {
|
if (signedIn) {
|
||||||
@ -920,25 +920,15 @@ void IntegrationPluginDenon::onHeosUserChanged(bool signedIn, const QString &use
|
|||||||
m_unfinishedHeosConnections.remove(info->thingId());
|
m_unfinishedHeosConnections.remove(info->thingId());
|
||||||
heos->deleteLater();
|
heos->deleteLater();
|
||||||
}
|
}
|
||||||
}
|
} else if (m_heosConnections.values().contains(heos)) {
|
||||||
|
|
||||||
if (m_heosConnections.values().contains(heos)) {
|
|
||||||
Thing *thing = myThings().findById(m_heosConnections.key(heos));
|
Thing *thing = myThings().findById(m_heosConnections.key(heos));
|
||||||
thing->setStateValue(heosLoggedInStateTypeId, signedIn);
|
thing->setStateValue(heosLoggedInStateTypeId, signedIn);
|
||||||
thing->setStateValue(heosUserDisplayNameStateTypeId, userName);
|
thing->setStateValue(heosUserDisplayNameStateTypeId, userName);
|
||||||
|
} else {
|
||||||
|
qCDebug(dcDenon()) << "Unhandled user changed event" << signedIn << userName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntegrationPluginDenon::onAvahiServiceEntryAdded(const ZeroConfServiceEntry &serviceEntry)
|
|
||||||
{
|
|
||||||
qCDebug(dcDenon()) << "Avahi service entry added:" << serviceEntry;
|
|
||||||
}
|
|
||||||
|
|
||||||
void IntegrationPluginDenon::onAvahiServiceEntryRemoved(const ZeroConfServiceEntry &serviceEntry)
|
|
||||||
{
|
|
||||||
qCDebug(dcDenon()) << "Avahi service entry removed:" << serviceEntry;
|
|
||||||
}
|
|
||||||
|
|
||||||
void IntegrationPluginDenon::onPluginConfigurationChanged(const ParamTypeId ¶mTypeId, const QVariant &value)
|
void IntegrationPluginDenon::onPluginConfigurationChanged(const ParamTypeId ¶mTypeId, const QVariant &value)
|
||||||
{
|
{
|
||||||
qCDebug(dcDenon()) << "Plugin configuration changed";
|
qCDebug(dcDenon()) << "Plugin configuration changed";
|
||||||
|
|||||||
@ -126,8 +126,6 @@ private slots:
|
|||||||
void onHeosGroupsChanged();
|
void onHeosGroupsChanged();
|
||||||
void onHeosUserChanged(bool signedIn, const QString &userName);
|
void onHeosUserChanged(bool signedIn, const QString &userName);
|
||||||
|
|
||||||
void onAvahiServiceEntryAdded(const ZeroConfServiceEntry &serviceEntry);
|
|
||||||
void onAvahiServiceEntryRemoved(const ZeroConfServiceEntry &serviceEntry);
|
|
||||||
void onAvrConnectionChanged(bool status);
|
void onAvrConnectionChanged(bool status);
|
||||||
void onAvrSocketError();
|
void onAvrSocketError();
|
||||||
void onAvrVolumeChanged(int volume);
|
void onAvrVolumeChanged(int volume);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user