Skip to content

Commit

Permalink
Update the MNV related MythXML methods to include serving up javascri…
Browse files Browse the repository at this point in the history
…pt-wrapped HTML pages.

Another patch by Jonatan Martens, and completes the set allowing us to natively control flash players where applicable.
  • Loading branch information
Robert McNamara committed Dec 7, 2010
1 parent 7ac2b5f commit 5b7b93d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
32 changes: 32 additions & 0 deletions mythtv/programs/mythbackend/mythxml.cpp
Expand Up @@ -123,6 +123,7 @@ MythXMLMethod MythXML::GetMethod( const QString &sURI )
if (sURI == "GetVideoArt" ) return MXML_GetVideoArt;
if (sURI == "GetInternetSearch" ) return MXML_GetInternetSearch;
if (sURI == "GetInternetSources" ) return MXML_GetInternetSources;
if (sURI == "GetInternetContent" ) return MXML_GetInternetContent;

return MXML_Unknown;
}
Expand Down Expand Up @@ -229,6 +230,9 @@ bool MythXML::ProcessRequest( HttpWorkerThread *pThread, HTTPRequest *pRequest )
case MXML_GetInternetSources :
GetInternetSources( pRequest );
return true;
case MXML_GetInternetContent :
GetInternetContent( pRequest );
return true;

case MXML_GetConnectionInfo :
GetConnectionInfo( pRequest );
Expand Down Expand Up @@ -1662,6 +1666,34 @@ void MythXML::GetInternetSources( HTTPRequest *pRequest )
pRequest->FormatActionResponse( list );
}

void MythXML::GetInternetContent( HTTPRequest *pRequest )
{
pRequest->m_eResponseType = ResponseTypeHTML;

QString grabber = pRequest->m_mapParams[ "Grabber" ];

if (grabber.isEmpty())
return;

QString contentDir = QString("%1internetcontent/").arg(GetShareDir());
QString htmlFile(contentDir + grabber);

// Try to prevent directory traversal
QFileInfo fileInfo(htmlFile);
if (fileInfo.canonicalFilePath().startsWith(contentDir) &&
QFile::exists( htmlFile ))
{
pRequest->m_eResponseType = ResponseTypeFile;
pRequest->m_nResponseStatus = 200;
pRequest->m_sFileName = htmlFile;
}
else
{
pRequest->FormatRawResponse( QString("<HTML>File %1 does "
"not exist!</HTML>").arg(htmlFile) );
}
}

/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
Expand Down
8 changes: 5 additions & 3 deletions mythtv/programs/mythbackend/mythxml.h
Expand Up @@ -54,10 +54,11 @@ typedef enum
MXML_GetVideoArt = 17,
MXML_GetInternetSearch = 18,
MXML_GetInternetSources = 19,
MXML_GetInternetContent = 20,

MXML_GetFile = 20,
MXML_GetFileList = 21,
MXML_GetFileLinks = 22,
MXML_GetFile = 21,
MXML_GetFileList = 22,
MXML_GetFileLinks = 23,

} MythXMLMethod;

Expand Down Expand Up @@ -127,6 +128,7 @@ class MythXML : public Eventing

void GetInternetSearch( HTTPRequest *pRequest );
void GetInternetSources( HTTPRequest *pRequest );
void GetInternetContent( HTTPRequest *pRequest );

void GetDeviceDesc ( HTTPRequest *pRequest );
void GetFile ( HTTPRequest *pRequest, QString sFileName );
Expand Down

0 comments on commit 5b7b93d

Please sign in to comment.