Permalink
Browse files

MythFrontend: Support additional parameters in http actions.

Currently only implemented for the SCREENSHOT action but will be
important for more advanced frontend control going forward.

This probably removes the need for the 'custom' GetScreenShot method, as
screenshots can now be triggered via:-

frontend-ip:6547/MythFE/GetScreenShot
frontend-ip:6547/MythFE/GetScreenShot?width=X&height=Y
frontend-ip:6547/MythFE/SendAction?action=SCREENSHOT
frontend-ip:6547/MythFE/SendAction?action=SCREENSHOT&width=X&height=Y
  • Loading branch information...
Mark Kendall
Mark Kendall committed May 12, 2011
1 parent c3f130c commit 7c90f8e80a6570cfa1ccead26079d82fc078bd3e
Showing with 38 additions and 8 deletions.
  1. +37 −8 mythtv/programs/mythfrontend/mythfexml.cpp
  2. +1 −0 mythtv/programs/mythfrontend/mythfexml.h
@@ -166,20 +166,40 @@ void MythFEXML::SendMessage(HTTPRequest *pRequest)
void MythFEXML::SendAction(HTTPRequest *pRequest) void MythFEXML::SendAction(HTTPRequest *pRequest)
{ {
QStringMap* map = &pRequest->m_mapParams;
pRequest->m_eResponseType = ResponseTypeHTML; pRequest->m_eResponseType = ResponseTypeHTML;
QString sText = pRequest->m_mapParams["action"]; QString sText = map->value("action");
VERBOSE(VB_UPNP, QString("UPNP Action: ") + sText); uint pcount = map->size();
InitActions(); VERBOSE(VB_UPNP, QString("UPNP Action: %1 (total %2 params)")
if (!m_actionList.contains(sText)) .arg(sText).arg(pcount));
{
VERBOSE(VB_GENERAL, QString("UPNP Action: %1 is invalid").arg(sText)); if (!IsValidAction(sText))
return; return;
if (pcount > 1)
{
bool valid = false;
QStringList args;
if (ACTION_SCREENSHOT == sText && 3 == pcount)
{
args << map->value("width");
args << map->value("height");
valid = true;
}
if (valid)
{
MythEvent* me = new MythEvent(sText, args);
qApp->postEvent(GetMythMainWindow(), me);
return;
}
VERBOSE(VB_UPNP, QString("Failed to validate extra paramaters - ignoring"));
} }
MythMainWindow *window = GetMythMainWindow();
QKeyEvent* ke = new QKeyEvent(QEvent::KeyPress, 0, Qt::NoModifier, sText); QKeyEvent* ke = new QKeyEvent(QEvent::KeyPress, 0, Qt::NoModifier, sText);
qApp->postEvent(window, (QEvent*)ke); qApp->postEvent(GetMythMainWindow(), (QEvent*)ke);
} }
static const QString PROCESS_ACTION = static const QString PROCESS_ACTION =
@@ -331,6 +351,15 @@ void MythFEXML::GetRemote(HTTPRequest *pRequest)
"</html>\n"; "</html>\n";
} }
bool MythFEXML::IsValidAction(const QString &action)
{
InitActions();
if (m_actionList.contains(action))
return true;
VERBOSE(VB_GENERAL, QString("UPNP Action: %1 is invalid").arg(action));
return false;
}
void MythFEXML::InitActions(void) void MythFEXML::InitActions(void)
{ {
static bool initialised = false; static bool initialised = false;
@@ -55,6 +55,7 @@ class MythFEXML : public Eventing
void GetActionList ( HTTPRequest *pRequest ); void GetActionList ( HTTPRequest *pRequest );
void GetActionListTest( HTTPRequest *pRequest ); void GetActionListTest( HTTPRequest *pRequest );
void GetRemote ( HTTPRequest *pRequest ); void GetRemote ( HTTPRequest *pRequest );
bool IsValidAction ( const QString &action );
void InitActions ( void ); void InitActions ( void );
public: public:

0 comments on commit 7c90f8e

Please sign in to comment.