diff --git a/denon/integrationplugindenon.cpp b/denon/integrationplugindenon.cpp index eeab422f..b83914da 100644 --- a/denon/integrationplugindenon.cpp +++ b/denon/integrationplugindenon.cpp @@ -67,6 +67,7 @@ IntegrationPluginDenon::IntegrationPluginDenon() { } + void IntegrationPluginDenon::init() { m_notificationUrl = QUrl(configValue(denonPluginNotificationUrlParamTypeId).toString()); @@ -314,7 +315,7 @@ void IntegrationPluginDenon::executeAction(ThingActionInfo *info) if (action.actionTypeId() == heosPlayerAlertActionTypeId) { heos->playUrl(playerId, m_notificationUrl); - return Device::DeviceErrorNoError; + return info->finish(Device::DeviceErrorNoError); } if (action.actionTypeId() == heosPlayerVolumeActionTypeId) { @@ -753,56 +754,63 @@ void DevicePluginDenon::onPluginConfigurationChanged(const ParamTypeId ¶mTyp // Check advanced mode if (paramTypeId == denonPluginNotificationUrlParamTypeId) { qCDebug(dcDenon()) << "Advanced mode" << (value.toBool() ? "enabled." : "disabled."); - m_notificationUrl = value.toUrl(); + m_notificationUrl = value.toUrl(); } } -Device::BrowseResult DevicePluginDenon::browseDevice(Device *device, Device::BrowseResult result, const QString &itemId, const QLocale &locale) +void DevicePluginDenon::browseDevice(BrowseResult *result) { - Q_UNUSED(locale) - - Heos *heos = m_heos.key(device); + Heos *heos = m_heos.value(result->device()); if (!heos) { - result.status = Device::DeviceErrorHardwareNotAvailable; - return result; + result->finish(Device::DeviceErrorHardwareNotAvailable); + return; } - - return Device::DeviceErrorNoError; + //heos->browse(result); } -Device::BrowserItemResult DevicePluginDenon::browserItem(Device *device, Device::BrowserItemResult result, const QString &itemId, const QLocale &locale) +void DevicePluginDenon::browserItem(BrowserItemResult *result) { - Q_UNUSED(locale) - - Heos *heos = m_heos.key(device); + Heos *heos = m_heos.value(result->device()); if (!heos) { - result.status = Device::DeviceErrorHardwareNotAvailable; - return result; + result->finish(Device::DeviceErrorHardwareNotAvailable); + return; } - return heos->browserItem(itemId, result); + return; } -Device::DeviceError DevicePluginDenon::executeBrowserItem(Device *device, const BrowserAction &browserAction) +void DevicePluginDenon::executeBrowserItem(BrowserActionInfo *info) { - Heos *heos = m_heos.key(device); + Heos *heos = m_heos.value(info->device()); if (!heos) { - return Device::DeviceErrorHardwareNotAvailable; + info->finish(Device::DeviceErrorHardwareNotAvailable); + return; } - - return heos->launchBrowserItem(browserAction.itemId()); + /* + int id = kodi->launchBrowserItem(info->browserAction().itemId()); + if (id == -1) { + return info->finish(Device::DeviceErrorHardwareFailure); + } + m_pendingBrowserActions.insert(id, info); + connect(info, &QObject::destroyed, this, [this, id](){ m_pendingBrowserActions.remove(id); });*/ } -Device::DeviceError DevicePluginDenon::executeBrowserItemAction(Device *device, const BrowserItemAction &browserItemAction) +void DevicePluginDenon::executeBrowserItemAction(BrowserItemActionInfo *info) { - Heos *kodi = m_heos.key(device); + Heos *kodi = m_heos.value(info->device()); if (!kodi) { - return Device::DeviceErrorHardwareNotAvailable; + info->finish(Device::DeviceErrorHardwareNotAvailable); + return; } - m_pendingBrowserItemActions.insert(id, browserItemAction.id()); - return Device::DeviceErrorAsync; + + /*int id = kodi->executeBrowserItemAction(info->browserItemAction().itemId(), info->browserItemAction().actionTypeId()); + if (id == -1) { + return info->finish(Device::DeviceErrorHardwareFailure); + } + m_pendingBrowserItemActions.insert(id, info); + connect(info, &QObject::destroyed, this, [this, id](){ m_pendingBrowserItemActions.remove(id); });*/ } diff --git a/denon/integrationplugindenon.h b/denon/integrationplugindenon.h index 8db95839..bc245de2 100644 --- a/denon/integrationplugindenon.h +++ b/denon/integrationplugindenon.h @@ -63,10 +63,11 @@ public: void executeAction(ThingActionInfo *info) override; void thingRemoved(Thing *thing) override; - Device::BrowseResult browseDevice(Device *device, Device::BrowseResult result, const QString &itemId, const QLocale &locale) override; - Device::BrowserItemResult browserItem(Device *device, Device::BrowserItemResult result, const QString &itemId, const QLocale &locale) override; - Device::DeviceError executeBrowserItem(Device *device, const BrowserAction &browserAction) override; - Device::DeviceError executeBrowserItemAction(Device *device, const BrowserItemAction &browserItemAction) override; + void browseDevice(BrowseResult *result) override; + void browserItem(BrowserItemResult *result) override; + void executeBrowserItem(BrowserActionInfo *info) override; + void executeBrowserItemAction(BrowserItemActionInfo *info) override; + private: PluginTimer *m_pluginTimer = nullptr; ZeroConfServiceBrowser *m_serviceBrowser = nullptr; @@ -82,7 +83,9 @@ private: QHash m_asyncActions; QUrl m_notificationUrl; - QHash m_pendingBrowserItemActions;s + QHash m_pendingActions; + QHash m_pendingBrowserActions; + QHash m_pendingBrowserItemActions; private slots: void onPluginTimer();