fixed memory leak
This commit is contained in:
parent
54f6e2c33f
commit
66b01ad1d1
@ -55,9 +55,8 @@ QHostAddress BluOS::hostAddress()
|
|||||||
return m_hostAddress;
|
return m_hostAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
QUuid BluOS::getStatus()
|
void BluOS::getStatus()
|
||||||
{
|
{
|
||||||
QUuid requestId = QUuid::createUuid();
|
|
||||||
QUrl url;
|
QUrl url;
|
||||||
url.setScheme("http");
|
url.setScheme("http");
|
||||||
url.setHost(m_hostAddress.toString());
|
url.setHost(m_hostAddress.toString());
|
||||||
@ -81,7 +80,7 @@ QUuid BluOS::getStatus()
|
|||||||
//qCDebug(dcBluOS()) << "Get Status:" << data;
|
//qCDebug(dcBluOS()) << "Get Status:" << data;
|
||||||
parseState(data);
|
parseState(data);
|
||||||
});
|
});
|
||||||
return requestId;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QUuid BluOS::setVolume(uint volume)
|
QUuid BluOS::setVolume(uint volume)
|
||||||
|
|||||||
@ -102,7 +102,7 @@ public:
|
|||||||
QHostAddress hostAddress();
|
QHostAddress hostAddress();
|
||||||
|
|
||||||
// Status Queries
|
// Status Queries
|
||||||
QUuid getStatus();
|
void getStatus();
|
||||||
|
|
||||||
// Volume Control
|
// Volume Control
|
||||||
QUuid setVolume(uint volume);
|
QUuid setVolume(uint volume);
|
||||||
|
|||||||
@ -100,8 +100,9 @@ void IntegrationPluginBluOS::setupThing(ThingSetupInfo *info)
|
|||||||
m_asyncSetup.insert(bluos, info);
|
m_asyncSetup.insert(bluos, info);
|
||||||
bluos->getStatus();
|
bluos->getStatus();
|
||||||
// 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, bluos]() {
|
connect(info, &ThingSetupInfo::aborted, this, [this, bluos] {
|
||||||
m_asyncSetup.remove(bluos);
|
m_asyncSetup.remove(bluos);
|
||||||
|
bluos->deleteLater();
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@ -111,7 +112,7 @@ void IntegrationPluginBluOS::setupThing(ThingSetupInfo *info)
|
|||||||
|
|
||||||
void IntegrationPluginBluOS::postSetupThing(Thing *thing)
|
void IntegrationPluginBluOS::postSetupThing(Thing *thing)
|
||||||
{
|
{
|
||||||
Q_UNUSED(thing);
|
Q_UNUSED(thing)
|
||||||
|
|
||||||
if (!m_pluginTimer) {
|
if (!m_pluginTimer) {
|
||||||
m_pluginTimer = hardwareManager()->pluginTimerManager()->registerTimer(10);
|
m_pluginTimer = hardwareManager()->pluginTimerManager()->registerTimer(10);
|
||||||
@ -222,6 +223,8 @@ void IntegrationPluginBluOS::browseThing(BrowseResult *result)
|
|||||||
if (thing->thingClassId() == bluosPlayerThingClassId) {
|
if (thing->thingClassId() == bluosPlayerThingClassId) {
|
||||||
BluOS *bluos = m_bluos.value(thing->id());
|
BluOS *bluos = m_bluos.value(thing->id());
|
||||||
if (!bluos) {
|
if (!bluos) {
|
||||||
|
qCWarning(dcBluOS()) << "Could not find any BluOS object that belongs to" << thing->name();
|
||||||
|
result->finish(Thing::ThingErrorHardwareNotAvailable, "BluOS connection not properly initialized");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (result->itemId() == "presets") {
|
if (result->itemId() == "presets") {
|
||||||
@ -270,6 +273,7 @@ void IntegrationPluginBluOS::browserItem(BrowserItemResult *result)
|
|||||||
if (thing->thingClassId() == bluosPlayerThingClassId) {
|
if (thing->thingClassId() == bluosPlayerThingClassId) {
|
||||||
BluOS *bluos = m_bluos.value(thing->id());
|
BluOS *bluos = m_bluos.value(thing->id());
|
||||||
if (!bluos) {
|
if (!bluos) {
|
||||||
|
qCWarning(dcBluOS()) << "Could not find any BluOS object that belongs to" << thing->name();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (result->itemId() == "presets") {
|
if (result->itemId() == "presets") {
|
||||||
@ -291,8 +295,10 @@ void IntegrationPluginBluOS::executeBrowserItem(BrowserActionInfo *info)
|
|||||||
Thing *thing = info->thing();
|
Thing *thing = info->thing();
|
||||||
if (thing->thingClassId() == bluosPlayerThingClassId) {
|
if (thing->thingClassId() == bluosPlayerThingClassId) {
|
||||||
BluOS *bluos = m_bluos.value(thing->id());
|
BluOS *bluos = m_bluos.value(thing->id());
|
||||||
if (!bluos)
|
if (!bluos) {
|
||||||
|
qCWarning(dcBluOS()) << "Could not find any BluOS object that belongs to" << thing->name();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (info->browserAction().itemId().startsWith("presets")) {
|
if (info->browserAction().itemId().startsWith("presets")) {
|
||||||
QUuid requestId;
|
QUuid requestId;
|
||||||
@ -302,8 +308,10 @@ void IntegrationPluginBluOS::executeBrowserItem(BrowserActionInfo *info)
|
|||||||
connect(info, &BrowserActionInfo::aborted, this, [this, requestId]{m_asyncExecuteBrowseItems.remove(requestId);});
|
connect(info, &BrowserActionInfo::aborted, this, [this, requestId]{m_asyncExecuteBrowseItems.remove(requestId);});
|
||||||
} else if (info->browserAction().itemId().startsWith("grouping")) {
|
} else if (info->browserAction().itemId().startsWith("grouping")) {
|
||||||
//TODO Grouping
|
//TODO Grouping
|
||||||
|
//Test devices are required
|
||||||
} else {
|
} else {
|
||||||
//TODO Sources
|
//TODO Sources
|
||||||
|
//Test services are required
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -319,12 +327,15 @@ void IntegrationPluginBluOS::onConnectionChanged(bool connected)
|
|||||||
info->thing()->setStateValue(bluosPlayerConnectedStateTypeId, true);
|
info->thing()->setStateValue(bluosPlayerConnectedStateTypeId, true);
|
||||||
info->finish(Thing::ThingErrorNoError);
|
info->finish(Thing::ThingErrorNoError);
|
||||||
} else {
|
} else {
|
||||||
|
bluos->deleteLater();
|
||||||
info->finish(Thing::ThingErrorSetupFailed);
|
info->finish(Thing::ThingErrorSetupFailed);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Thing *thing = myThings().findById(m_bluos.key(bluos));
|
Thing *thing = myThings().findById(m_bluos.key(bluos));
|
||||||
if (!thing)
|
if (!thing) {
|
||||||
|
qCWarning(dcBluOS()) << "Could not find any Thing that belongs to the BluOS object";
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
thing->setStateValue(bluosPlayerConnectedStateTypeId, connected);
|
thing->setStateValue(bluosPlayerConnectedStateTypeId, connected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -333,8 +344,10 @@ void IntegrationPluginBluOS::onStatusResponseReceived(const BluOS::StatusRespons
|
|||||||
{
|
{
|
||||||
BluOS *bluos = static_cast<BluOS*>(sender());
|
BluOS *bluos = static_cast<BluOS*>(sender());
|
||||||
Thing *thing = myThings().findById(m_bluos.key(bluos));
|
Thing *thing = myThings().findById(m_bluos.key(bluos));
|
||||||
if (!thing)
|
if (!thing){
|
||||||
|
qCWarning(dcBluOS()) << "Could not find any Thing that belongs to this BluOS object";
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
thing->setStateValue(bluosPlayerArtistStateTypeId, status.Artist);
|
thing->setStateValue(bluosPlayerArtistStateTypeId, status.Artist);
|
||||||
thing->setStateValue(bluosPlayerCollectionStateTypeId, status.Album);
|
thing->setStateValue(bluosPlayerCollectionStateTypeId, status.Album);
|
||||||
thing->setStateValue(bluosPlayerTitleStateTypeId, status.Title);
|
thing->setStateValue(bluosPlayerTitleStateTypeId, status.Title);
|
||||||
@ -398,8 +411,10 @@ void IntegrationPluginBluOS::onVolumeReceived(int volume, bool mute)
|
|||||||
{
|
{
|
||||||
BluOS *bluos = static_cast<BluOS*>(sender());
|
BluOS *bluos = static_cast<BluOS*>(sender());
|
||||||
Thing *thing = myThings().findById(m_bluos.key(bluos));
|
Thing *thing = myThings().findById(m_bluos.key(bluos));
|
||||||
if (!thing)
|
if (!thing){
|
||||||
|
qCWarning(dcBluOS()) << "Could not find any Thing that belongs to this BluOS object";
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
thing->setStateValue(bluosPlayerMuteStateTypeId, mute);
|
thing->setStateValue(bluosPlayerMuteStateTypeId, mute);
|
||||||
thing->setStateValue(bluosPlayerVolumeStateTypeId, volume);
|
thing->setStateValue(bluosPlayerVolumeStateTypeId, volume);
|
||||||
}
|
}
|
||||||
@ -417,8 +432,10 @@ void IntegrationPluginBluOS::onRepeatModeReceived(BluOS::RepeatMode mode)
|
|||||||
{
|
{
|
||||||
BluOS *bluos = static_cast<BluOS*>(sender());
|
BluOS *bluos = static_cast<BluOS*>(sender());
|
||||||
Thing *thing = myThings().findById(m_bluos.key(bluos));
|
Thing *thing = myThings().findById(m_bluos.key(bluos));
|
||||||
if (!thing)
|
if (!thing){
|
||||||
|
qCWarning(dcBluOS()) << "Could not find any Thing that belongs to this BluOS object";
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case BluOS::RepeatMode::All:
|
case BluOS::RepeatMode::All:
|
||||||
thing->setStateValue(bluosPlayerRepeatStateTypeId, "All");
|
thing->setStateValue(bluosPlayerRepeatStateTypeId, "All");
|
||||||
@ -437,10 +454,14 @@ void IntegrationPluginBluOS::onPresetsReceived(QUuid requestId, const QList<BluO
|
|||||||
{
|
{
|
||||||
BluOS *bluos = static_cast<BluOS*>(sender());
|
BluOS *bluos = static_cast<BluOS*>(sender());
|
||||||
Thing *thing = myThings().findById(m_bluos.key(bluos));
|
Thing *thing = myThings().findById(m_bluos.key(bluos));
|
||||||
if (!thing)
|
|
||||||
return;
|
|
||||||
if (m_asyncBrowseResults.contains(requestId)) {
|
if (m_asyncBrowseResults.contains(requestId)) {
|
||||||
BrowseResult *result = m_asyncBrowseResults.take(requestId);
|
BrowseResult *result = m_asyncBrowseResults.take(requestId);
|
||||||
|
if (!thing) {
|
||||||
|
qCWarning(dcBluOS()) << "Could not find any Thing that belongs to this browse result";
|
||||||
|
result->finish(Thing::ThingErrorHardwareNotAvailable);
|
||||||
|
return;
|
||||||
|
}
|
||||||
foreach(BluOS::Preset preset, presets) {
|
foreach(BluOS::Preset preset, presets) {
|
||||||
qCDebug(dcBluOS()) << "Preset added" << preset.Name << preset.Id << preset.Url;
|
qCDebug(dcBluOS()) << "Preset added" << preset.Name << preset.Id << preset.Url;
|
||||||
BrowserItem item("presets&"+QString::number(preset.Id), preset.Name, false, true);
|
BrowserItem item("presets&"+QString::number(preset.Id), preset.Name, false, true);
|
||||||
@ -451,7 +472,8 @@ void IntegrationPluginBluOS::onPresetsReceived(QUuid requestId, const QList<BluO
|
|||||||
}
|
}
|
||||||
if (m_asyncBrowseItemResults.contains(requestId)) {
|
if (m_asyncBrowseItemResults.contains(requestId)) {
|
||||||
BrowserItemResult *result = m_asyncBrowseItemResults.take(requestId);
|
BrowserItemResult *result = m_asyncBrowseItemResults.take(requestId);
|
||||||
Q_UNUSED(result)
|
result->finish(Thing::ThingErrorItemNotFound);
|
||||||
|
//For future browsing features
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -459,10 +481,14 @@ void IntegrationPluginBluOS::onSourcesReceived(QUuid requestId, const QList<BluO
|
|||||||
{
|
{
|
||||||
BluOS *bluos = static_cast<BluOS*>(sender());
|
BluOS *bluos = static_cast<BluOS*>(sender());
|
||||||
Thing *thing = myThings().findById(m_bluos.key(bluos));
|
Thing *thing = myThings().findById(m_bluos.key(bluos));
|
||||||
if (!thing)
|
|
||||||
return;
|
|
||||||
if (m_asyncBrowseResults.contains(requestId)) {
|
if (m_asyncBrowseResults.contains(requestId)) {
|
||||||
BrowseResult *result = m_asyncBrowseResults.take(requestId);
|
BrowseResult *result = m_asyncBrowseResults.take(requestId);
|
||||||
|
if (!thing) {
|
||||||
|
qCWarning(dcBluOS()) << "Could not find any Thing that belongs to this browse result";
|
||||||
|
result->finish(Thing::ThingErrorHardwareNotAvailable);
|
||||||
|
return;
|
||||||
|
}
|
||||||
foreach(BluOS::Source source, sources) {
|
foreach(BluOS::Source source, sources) {
|
||||||
qCDebug(dcBluOS()) << "Source added" << source.Text << source.BrowseKey << source.Type;
|
qCDebug(dcBluOS()) << "Source added" << source.Text << source.BrowseKey << source.Type;
|
||||||
MediaBrowserItem item;
|
MediaBrowserItem item;
|
||||||
@ -493,15 +519,18 @@ void IntegrationPluginBluOS::onSourcesReceived(QUuid requestId, const QList<BluO
|
|||||||
item.setMediaIcon(MediaBrowserItem::MediaBrowserIconAux);
|
item.setMediaIcon(MediaBrowserItem::MediaBrowserIconAux);
|
||||||
result->addItem(item);
|
result->addItem(item);
|
||||||
} else if (source.Text == "Radio Paradise") {
|
} else if (source.Text == "Radio Paradise") {
|
||||||
item.setMediaIcon(MediaBrowserItem::MediaBrowserIconRadioParadise);
|
//item.setMediaIcon(MediaBrowserItem::MediaBrowserIconRadioParadise);
|
||||||
//result->addItem(item);
|
//result->addItem(item);
|
||||||
|
//Needs testing before continuing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result->finish(Thing::ThingErrorNoError);
|
result->finish(Thing::ThingErrorNoError);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_asyncBrowseItemResults.contains(requestId)) {
|
if (m_asyncBrowseItemResults.contains(requestId)) {
|
||||||
BrowserItemResult *result = m_asyncBrowseItemResults.take(requestId);
|
BrowserItemResult *result = m_asyncBrowseItemResults.take(requestId);
|
||||||
Q_UNUSED(result)
|
result->finish(Thing::ThingErrorItemNotFound);
|
||||||
|
//For future browsing features
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -509,10 +538,15 @@ void IntegrationPluginBluOS::onBrowseResultReceived(QUuid requestId, const QList
|
|||||||
{
|
{
|
||||||
BluOS *bluos = static_cast<BluOS*>(sender());
|
BluOS *bluos = static_cast<BluOS*>(sender());
|
||||||
Thing *thing = myThings().findById(m_bluos.key(bluos));
|
Thing *thing = myThings().findById(m_bluos.key(bluos));
|
||||||
if (!thing)
|
|
||||||
return;
|
|
||||||
if (m_asyncBrowseResults.contains(requestId)) {
|
if (m_asyncBrowseResults.contains(requestId)) {
|
||||||
BrowseResult *result = m_asyncBrowseResults.take(requestId);
|
BrowseResult *result = m_asyncBrowseResults.take(requestId);
|
||||||
|
|
||||||
|
if (!thing) {
|
||||||
|
qCWarning(dcBluOS()) << "Could not find any Thing that belongs to this browse result";
|
||||||
|
result->finish(Thing::ThingErrorHardwareNotAvailable);
|
||||||
|
return;
|
||||||
|
}
|
||||||
foreach(BluOS::Source source, sources) {
|
foreach(BluOS::Source source, sources) {
|
||||||
qCDebug(dcBluOS()) << "Source added" << source.Text << source.BrowseKey << source.Type;
|
qCDebug(dcBluOS()) << "Source added" << source.Text << source.BrowseKey << source.Type;
|
||||||
MediaBrowserItem item;
|
MediaBrowserItem item;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user