/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright (C) 2019 Bernhard Trinnes * * * * This file is part of nymea. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; If not, see * * . * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "sonos.h" #include "extern-plugininfo.h" #include Sonos::Sonos(QObject *parent) { } void Sonos::authenticate(const QString &username, const QString &password) { //get oauth autherisation //get accesst token } void Sonos::getHouseholds() { QNetworkRequest request; request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader, "application/json"); request.setRawHeader("Authorization", "Bearer" + m_bearerToken); request.setUrl(m_baseControlUrl + "/households"); QNetworkReply *reply = QNetworkAccessManager.get(request); connect(reply, &QNetworkReply::finished, this [this] { int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); // Check HTTP status code if (status != 200 || reply->error() != QNetworkReply::NoError) { qCWarning(dcSonos()) << "Request error:" << status << reply->errorString(); return; } QJsonDocument data = reply->readAll(); if (!data.isObject()) return; QList households; emit householdObjectsReceived(households); }); } void Sonos::getPlayerVolume(int playerId) { QNetworkRequest request; QJsonObject object; object. }