From 10252bd09c0e21c859071efab081a1957bdb2766 Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Sun, 21 Feb 2016 21:41:26 +0100 Subject: [PATCH] - controlapi/getmode: get right mode; allow json/xml output --- src/nhttpd/tuxboxapi/controlapi.cpp | 36 ++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/src/nhttpd/tuxboxapi/controlapi.cpp b/src/nhttpd/tuxboxapi/controlapi.cpp index 978e494ca..b3c31b8b4 100644 --- a/src/nhttpd/tuxboxapi/controlapi.cpp +++ b/src/nhttpd/tuxboxapi/controlapi.cpp @@ -385,13 +385,37 @@ void CControlAPI::SetModeCGI(CyhookHandler *hh) //----------------------------------------------------------------------------- void CControlAPI::GetModeCGI(CyhookHandler *hh) { - int mode = NeutrinoAPI->Zapit->getMode(); - if ( mode == CZapitClient::MODE_TV) - hh->WriteLn("tv"); - else if ( mode == CZapitClient::MODE_RADIO) - return hh->WriteLn("radio"); + hh->outStart(); + + std::string result = ""; + int mode = CNeutrinoApp::getInstance()->getMode(); + if (mode == NeutrinoMessages::mode_tv) + result = "tv"; + else if (mode == NeutrinoMessages::mode_radio) + result = "radio"; + else if (mode == NeutrinoMessages::mode_scart) + result = "scart"; + else if (mode == NeutrinoMessages::mode_standby) + result = "standby"; + else if (mode == NeutrinoMessages::mode_audio) + result = "audio"; + else if (mode == NeutrinoMessages::mode_pic) + result = "pic"; + else if (mode == NeutrinoMessages::mode_ts) + result = "ts"; + else if (mode == NeutrinoMessages::mode_webtv) + result = "webtv"; + else if (mode == NeutrinoMessages::mode_upnp) + result = "upnp"; else - return hh->WriteLn("unknown"); + result = "unknown"; + + if (hh->getOutType() != plain) + { + result = hh->outPair("mode", result, false); + result = hh->outCollection("getmode", result); + } + hh->SendResult(result); } //-----------------------------------------------------------------------------