rebased to new devicemanager api

This commit is contained in:
nymea 2019-09-30 14:01:20 +02:00 committed by bernhard.trinnes
parent 2b6b47167d
commit 79774e5c67
2 changed files with 43 additions and 32 deletions

View File

@ -67,6 +67,7 @@ IntegrationPluginDenon::IntegrationPluginDenon()
{ {
} }
void IntegrationPluginDenon::init() void IntegrationPluginDenon::init()
{ {
m_notificationUrl = QUrl(configValue(denonPluginNotificationUrlParamTypeId).toString()); m_notificationUrl = QUrl(configValue(denonPluginNotificationUrlParamTypeId).toString());
@ -314,7 +315,7 @@ void IntegrationPluginDenon::executeAction(ThingActionInfo *info)
if (action.actionTypeId() == heosPlayerAlertActionTypeId) { if (action.actionTypeId() == heosPlayerAlertActionTypeId) {
heos->playUrl(playerId, m_notificationUrl); heos->playUrl(playerId, m_notificationUrl);
return Device::DeviceErrorNoError; return info->finish(Device::DeviceErrorNoError);
} }
if (action.actionTypeId() == heosPlayerVolumeActionTypeId) { if (action.actionTypeId() == heosPlayerVolumeActionTypeId) {
@ -753,56 +754,63 @@ void DevicePluginDenon::onPluginConfigurationChanged(const ParamTypeId &paramTyp
// Check advanced mode // Check advanced mode
if (paramTypeId == denonPluginNotificationUrlParamTypeId) { if (paramTypeId == denonPluginNotificationUrlParamTypeId) {
qCDebug(dcDenon()) << "Advanced mode" << (value.toBool() ? "enabled." : "disabled."); 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.value(result->device());
Heos *heos = m_heos.key(device);
if (!heos) { if (!heos) {
result.status = Device::DeviceErrorHardwareNotAvailable; result->finish(Device::DeviceErrorHardwareNotAvailable);
return result; return;
} }
//heos->browse(result);
return Device::DeviceErrorNoError;
} }
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.value(result->device());
Heos *heos = m_heos.key(device);
if (!heos) { if (!heos) {
result.status = Device::DeviceErrorHardwareNotAvailable; result->finish(Device::DeviceErrorHardwareNotAvailable);
return result; 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) { 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) { 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); });*/
} }

View File

@ -63,10 +63,11 @@ public:
void executeAction(ThingActionInfo *info) override; void executeAction(ThingActionInfo *info) override;
void thingRemoved(Thing *thing) override; void thingRemoved(Thing *thing) override;
Device::BrowseResult browseDevice(Device *device, Device::BrowseResult result, const QString &itemId, const QLocale &locale) override; void browseDevice(BrowseResult *result) override;
Device::BrowserItemResult browserItem(Device *device, Device::BrowserItemResult result, const QString &itemId, const QLocale &locale) override; void browserItem(BrowserItemResult *result) override;
Device::DeviceError executeBrowserItem(Device *device, const BrowserAction &browserAction) override; void executeBrowserItem(BrowserActionInfo *info) override;
Device::DeviceError executeBrowserItemAction(Device *device, const BrowserItemAction &browserItemAction) override; void executeBrowserItemAction(BrowserItemActionInfo *info) override;
private: private:
PluginTimer *m_pluginTimer = nullptr; PluginTimer *m_pluginTimer = nullptr;
ZeroConfServiceBrowser *m_serviceBrowser = nullptr; ZeroConfServiceBrowser *m_serviceBrowser = nullptr;
@ -82,7 +83,9 @@ private:
QHash<const Action *, int> m_asyncActions; QHash<const Action *, int> m_asyncActions;
QUrl m_notificationUrl; QUrl m_notificationUrl;
QHash<int, ActionId> m_pendingBrowserItemActions;s QHash<int, DeviceActionInfo*> m_pendingActions;
QHash<int, BrowserActionInfo*> m_pendingBrowserActions;
QHash<int, BrowserItemActionInfo*> m_pendingBrowserItemActions;
private slots: private slots:
void onPluginTimer(); void onPluginTimer();