From 2e827c8905db54f41a7cdca7b9e3b8f3b3d5da26 Mon Sep 17 00:00:00 2001 From: Bernhard Trinnes Date: Mon, 12 Aug 2019 19:13:12 +0200 Subject: [PATCH] changed to Sonos command API --- sonos/devicepluginsonos.cpp | 13 +++++-------- sonos/devicepluginsonos.h | 17 +++-------------- sonos/devicepluginsonos.json | 18 +++++++++++++++--- sonos/noson | 1 - sonos/sonos.pro | 5 ++--- 5 files changed, 25 insertions(+), 29 deletions(-) delete mode 160000 sonos/noson diff --git a/sonos/devicepluginsonos.cpp b/sonos/devicepluginsonos.cpp index 6e8ee10a..c9562d33 100644 --- a/sonos/devicepluginsonos.cpp +++ b/sonos/devicepluginsonos.cpp @@ -24,9 +24,6 @@ #include "devices/device.h" #include "plugininfo.h" - -#include - #include #include @@ -35,19 +32,19 @@ DevicePluginSonos::DevicePluginSonos() } + DevicePluginSonos::~DevicePluginSonos() { hardwareManager()->pluginTimerManager()->unregisterTimer(m_pluginTimer); } -void DevicePluginSonos::init() -{ - qDebug(dcSonos) << "Nymea sonos plug-in using libnoson Copyright (C) 2018 Jean-Luc Barriere"; - m_sonosSystem = new SONOS::System(nullptr, nullptr); -} Device::DeviceSetupStatus DevicePluginSonos::setupDevice(Device *device) { + if (!sonos) { + + } + if (device->deviceClassId() == sonosDeviceClassId) { if (!m_sonosSystem->Discover()) { return Device::DeviceSetupStatusFailure; diff --git a/sonos/devicepluginsonos.h b/sonos/devicepluginsonos.h index 1de68f50..2b4e9377 100644 --- a/sonos/devicepluginsonos.h +++ b/sonos/devicepluginsonos.h @@ -25,8 +25,7 @@ #include "devices/deviceplugin.h" #include "plugintimer.h" - -#include +#include "sonos.h" #include #include @@ -42,7 +41,6 @@ public: explicit DevicePluginSonos(); ~DevicePluginSonos() override; - void init() override; Device::DeviceSetupStatus setupDevice(Device *device) override; void postSetupDevice(Device *device) override; void deviceRemoved(Device *device) override; @@ -50,21 +48,12 @@ public: Device::DeviceError executeAction(Device *device, const Action &action) override; private: - SONOS::System *m_sonosSystem = nullptr; - PluginTimer *m_pluginTimer; - void updateZoneInfo(); - - void handleEventCB(void *handle); + Sonos *sonos = nullptr; private slots: void onPluginTimer(); - /*void onConnectionChanged(); - void onStateChanged(); - void onActionExecuted(int actionId, bool success); - void versionDataReceived(const QVariantMap &data); - void onSetupFinished(const QVariantMap &data); + void onConnectionChanged(); - void onPlaybackStatusChanged(const QString &playbackStatus);*/ }; #endif // DEVICEPLUGINSONOS_H diff --git a/sonos/devicepluginsonos.json b/sonos/devicepluginsonos.json index 4e239fb7..7992e42a 100644 --- a/sonos/devicepluginsonos.json +++ b/sonos/devicepluginsonos.json @@ -4,14 +4,26 @@ "displayName": "Sonos", "vendors": [ { + "id": "30a60752-d06f-4ec9-a4e1-9810a5d22fa3", "name": "sonos", - "displayName": "Sonos", + "displayName": "Sono", "deviceClasses": [ { "id": "22df416d-7732-44f1-b6b9-e41296211178", - "name": "sonos", - "displayName": "Sonos", + "name": "sonosGroup", + "displayName": "Sonos group", + "interfaces": ["gateway", "connectable"], + "createMethods": ["discovery"], + "paramTypes": [ + { + } + ] + }, + { + "id": "22df416d-7732-44f1-b6b9-e41296211178", + "name": "sonosGroup", + "displayName": "Sonos group", "interfaces": ["extendedvolumecontroller", "mediametadataprovider", "shufflerepeat", "connectable"], "createMethods": ["discovery"], "paramTypes": [ diff --git a/sonos/noson b/sonos/noson deleted file mode 160000 index 569f2b30..00000000 --- a/sonos/noson +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 569f2b3087d2ba39bfe796bd6dd20b767fb68eb7 diff --git a/sonos/sonos.pro b/sonos/sonos.pro index 33b7f741..a107f02e 100644 --- a/sonos/sonos.pro +++ b/sonos/sonos.pro @@ -2,15 +2,14 @@ include(../plugins.pri) QT += network -LIBS += -lnoson - TARGET = $$qtLibraryTarget(nymea_devicepluginsonos) SOURCES += \ devicepluginsonos.cpp \ + sonos.cpp \ HEADERS += \ devicepluginsonos.h \ - + sonos.h \