From 2b6b47167d382684566447d1ede2dd4c625b8a29 Mon Sep 17 00:00:00 2001 From: nymea Date: Mon, 30 Sep 2019 13:43:17 +0200 Subject: [PATCH] added browsable interface --- denon/integrationplugindenon.cpp | 50 +++++++++++++++++++++++++++++++ denon/integrationplugindenon.h | 5 ++++ denon/integrationplugindenon.json | 13 ++++++++ 3 files changed, 68 insertions(+) diff --git a/denon/integrationplugindenon.cpp b/denon/integrationplugindenon.cpp index ec1f6c89..eeab422f 100644 --- a/denon/integrationplugindenon.cpp +++ b/denon/integrationplugindenon.cpp @@ -756,3 +756,53 @@ void DevicePluginDenon::onPluginConfigurationChanged(const ParamTypeId ¶mTyp m_notificationUrl = value.toUrl(); } } + + + +Device::BrowseResult DevicePluginDenon::browseDevice(Device *device, Device::BrowseResult result, const QString &itemId, const QLocale &locale) +{ + Q_UNUSED(locale) + + Heos *heos = m_heos.key(device); + if (!heos) { + result.status = Device::DeviceErrorHardwareNotAvailable; + return result; + } + + + return Device::DeviceErrorNoError; +} + +Device::BrowserItemResult DevicePluginDenon::browserItem(Device *device, Device::BrowserItemResult result, const QString &itemId, const QLocale &locale) +{ + Q_UNUSED(locale) + + Heos *heos = m_heos.key(device); + if (!heos) { + result.status = Device::DeviceErrorHardwareNotAvailable; + return result; + } + + return heos->browserItem(itemId, result); +} + +Device::DeviceError DevicePluginDenon::executeBrowserItem(Device *device, const BrowserAction &browserAction) +{ + Heos *heos = m_heos.key(device); + if (!heos) { + return Device::DeviceErrorHardwareNotAvailable; + } + + return heos->launchBrowserItem(browserAction.itemId()); +} + +Device::DeviceError DevicePluginDenon::executeBrowserItemAction(Device *device, const BrowserItemAction &browserItemAction) +{ + Heos *kodi = m_heos.key(device); + if (!kodi) { + return Device::DeviceErrorHardwareNotAvailable; + } + + m_pendingBrowserItemActions.insert(id, browserItemAction.id()); + return Device::DeviceErrorAsync; +} diff --git a/denon/integrationplugindenon.h b/denon/integrationplugindenon.h index 6d0221cf..8db95839 100644 --- a/denon/integrationplugindenon.h +++ b/denon/integrationplugindenon.h @@ -63,6 +63,10 @@ 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; private: PluginTimer *m_pluginTimer = nullptr; ZeroConfServiceBrowser *m_serviceBrowser = nullptr; @@ -78,6 +82,7 @@ private: QHash m_asyncActions; QUrl m_notificationUrl; + QHash m_pendingBrowserItemActions;s private slots: void onPluginTimer(); diff --git a/denon/integrationplugindenon.json b/denon/integrationplugindenon.json index daac1f90..7d10edd5 100644 --- a/denon/integrationplugindenon.json +++ b/denon/integrationplugindenon.json @@ -210,6 +210,7 @@ "displayName": "Heos player", "createMethods": ["auto"], "interfaces": ["mediaplayer", "mediacontroller", "extendedvolumecontroller", "mediametadataprovider", "shufflerepeat", "alert", "connectable"], + "browsable": true, "paramTypes":[ { "id": "89629008-6ad8-4e92-863d-b86e0e012d0b", @@ -388,6 +389,18 @@ "name": "skipNext", "displayName": "Skip next" } + ], + "browserItemActionTypes": [ + { + "id": "34167b7d-c9d0-486c-b82b-0778d69599ea", + "name": "updateLibrary", + "displayName": "Update library" + }, + { + "id": "02bcfbbe-d929-439e-a04f-68ace25e93a7", + "name": "cleanLibrary", + "displayName": "Clean library" + } ] } ]