|
|
|
|
@@ -63,11 +63,9 @@ void MainWindow::sendCommand(QString cmd)
|
|
|
|
|
|
|
|
|
|
void MainWindow::replyFinished(QNetworkReply* reply)
|
|
|
|
|
{
|
|
|
|
|
QString ans;
|
|
|
|
|
|
|
|
|
|
if(reply->error() == QNetworkReply::NoError) {
|
|
|
|
|
QByteArray data = reply->readAll();
|
|
|
|
|
ans = QString(data);
|
|
|
|
|
mAnswer = QString(data);
|
|
|
|
|
} else {
|
|
|
|
|
qDebug() << reply->url();
|
|
|
|
|
qDebug() << reply->errorString();
|
|
|
|
|
@@ -77,7 +75,7 @@ void MainWindow::replyFinished(QNetworkReply* reply)
|
|
|
|
|
|
|
|
|
|
// check power state
|
|
|
|
|
QRegularExpression regexPower("<Power_Control><Power>(.+)</Power></Power_Control>");
|
|
|
|
|
QRegularExpressionMatch matchPower = regexPower.match(ans);
|
|
|
|
|
QRegularExpressionMatch matchPower = regexPower.match(mAnswer);
|
|
|
|
|
if (matchPower.hasMatch()) {
|
|
|
|
|
if (matchPower.captured(1) == "On") mPowered = true;
|
|
|
|
|
else if (matchPower.captured(1) == "Off") mPowered = false;
|
|
|
|
|
@@ -85,14 +83,14 @@ void MainWindow::replyFinished(QNetworkReply* reply)
|
|
|
|
|
|
|
|
|
|
// check volume
|
|
|
|
|
QRegularExpression regexVolume("<Volume><Lvl><Val>(.+)</Val>");
|
|
|
|
|
QRegularExpressionMatch matchVolume = regexVolume.match(ans);
|
|
|
|
|
QRegularExpressionMatch matchVolume = regexVolume.match(mAnswer);
|
|
|
|
|
if (matchVolume.hasMatch()) {
|
|
|
|
|
mVolume = matchVolume.captured(1).toInt();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// check input
|
|
|
|
|
QRegularExpression regexInput("<Input><Input_Sel>(.+)</Input_Sel>");
|
|
|
|
|
QRegularExpressionMatch matchInput = regexInput.match(ans);
|
|
|
|
|
QRegularExpressionMatch matchInput = regexInput.match(mAnswer);
|
|
|
|
|
if (matchInput.hasMatch())
|
|
|
|
|
mInput = matchInput.captured(1);
|
|
|
|
|
|
|
|
|
|
@@ -225,7 +223,6 @@ void MainWindow::on_btn_spotify_clicked()
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_btn_airplay_clicked()
|
|
|
|
|
{
|
|
|
|
|
// TODO
|
|
|
|
|
sendCommand("<YAMAHA_AV cmd=\"PUT\"><Main_Zone><Input><Input_Sel>IPOD</Input_Sel></Input></Main_Zone></YAMAHA_AV>");
|
|
|
|
|
mInput = "IPOD";
|
|
|
|
|
}
|
|
|
|
|
|