Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit 7c90f8e80a6570cfa1ccead26079d82fc078bd3e 1 parent c3f130c
Mark Kendall authored
View
45 mythtv/programs/mythfrontend/mythfexml.cpp
@@ -166,20 +166,40 @@ void MythFEXML::SendMessage(HTTPRequest *pRequest)
void MythFEXML::SendAction(HTTPRequest *pRequest)
{
+ QStringMap* map = &pRequest->m_mapParams;
pRequest->m_eResponseType = ResponseTypeHTML;
- QString sText = pRequest->m_mapParams["action"];
- VERBOSE(VB_UPNP, QString("UPNP Action: ") + sText);
+ QString sText = map->value("action");
+ uint pcount = map->size();
- InitActions();
- if (!m_actionList.contains(sText))
- {
- VERBOSE(VB_GENERAL, QString("UPNP Action: %1 is invalid").arg(sText));
+ VERBOSE(VB_UPNP, QString("UPNP Action: %1 (total %2 params)")
+ .arg(sText).arg(pcount));
+
+ if (!IsValidAction(sText))
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);
- qApp->postEvent(window, (QEvent*)ke);
+ qApp->postEvent(GetMythMainWindow(), (QEvent*)ke);
}
static const QString PROCESS_ACTION =
@@ -331,6 +351,15 @@ void MythFEXML::GetRemote(HTTPRequest *pRequest)
"</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)
{
static bool initialised = false;
View
1  mythtv/programs/mythfrontend/mythfexml.h
@@ -55,6 +55,7 @@ class MythFEXML : public Eventing
void GetActionList ( HTTPRequest *pRequest );
void GetActionListTest( HTTPRequest *pRequest );
void GetRemote ( HTTPRequest *pRequest );
+ bool IsValidAction ( const QString &action );
void InitActions ( void );
public:
Please sign in to comment.
Something went wrong with that request. Please try again.