Skip to content

Commit

Permalink
Remove old service API code from backend
Browse files Browse the repository at this point in the history
Service APIs have all been rewritten in services v2.
Change soapclient code that is used with upnp to find
backend the first time. This was still using the old API.

Refs #915
  • Loading branch information
bennettpeter committed Dec 9, 2024
1 parent ec39b20 commit 077327d
Show file tree
Hide file tree
Showing 37 changed files with 14 additions and 12,086 deletions.
2 changes: 1 addition & 1 deletion mythtv/libs/libmythupnp/mythxmlclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ UPnPResultCode MythXMLClient::GetConnectionInfo( const QString &sPin, DatabasePa
// Is this a valid response?
// --------------------------------------------------------------

QDomNode oNode = xmlResults.namedItem( "GetConnectionInfoResult" );
QDomNode oNode = xmlResults.namedItem( "ConnectionInfo" );

if (UPnPResult_Success == nErrCode && !oNode.isNull())
{
Expand Down
106 changes: 13 additions & 93 deletions mythtv/libs/libmythupnp/soapclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,12 @@ QDomDocument SOAPClient::SendSOAPRequest(const QString &sMethod,
{
QUrl url(m_url);

url.setPath(m_sControlPath);
QString path = m_sControlPath;
path.append("/");
path.append(sMethod);

// Service url port is 6 less than upnp port (see MediaServer::Init)
url.setPort(m_url.port() - 6);

nErrCode = UPnPResult_Success;
sErrDesc = "";
Expand Down Expand Up @@ -215,44 +220,21 @@ QDomDocument SOAPClient::SendSOAPRequest(const QString &sMethod,
// --------------------------------------------------------------

QByteArray aBuffer;
QTextStream os( &aBuffer );

#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
os.setCodec("UTF-8");
#else
os.setEncoding(QStringConverter::Utf8);
#endif

os << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";
os << "<s:Envelope "
" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\""
" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n";
os << " <s:Body>\r\n";
os << " <u:" << sMethod << " xmlns:u=\"" << m_sNamespace << "\">\r\n";

// --------------------------------------------------------------
// Add parameters from list
// --------------------------------------------------------------

QUrlQuery query;
for (QStringMap::iterator it = list.begin(); it != list.end(); ++it)
{
os << " <" << it.key() << ">";
os << HTTPRequest::Encode( *it );
os << "</" << it.key() << ">\r\n";
{
query.addQueryItem(it.key(),*it);
}

os << " </u:" << sMethod << ">\r\n";
os << " </s:Body>\r\n";
os << "</s:Envelope>\r\n";

os.flush();
url.setPath(path);
url.setQuery(query);

// --------------------------------------------------------------
// Perform Request
// --------------------------------------------------------------

LOG(VB_UPNP, LOG_DEBUG,
QString("SOAPClient(%1) sending:\n %2").arg(url.toString(), aBuffer.constData()));
QString("SOAPClient(%1) sending:\n %2").arg(url.toString() /*, aBuffer.constData()*/ ));

QString sXml;

Expand Down Expand Up @@ -289,68 +271,6 @@ QDomDocument SOAPClient::SendSOAPRequest(const QString &sMethod,
QString::number(nErrCode), sErrDesc, sXml));
return xmlResult;
}

// --------------------------------------------------------------
// Is this a valid response?
// --------------------------------------------------------------

QString sResponseName = sMethod + "Response";
QDomNodeList oNodeList =
doc.elementsByTagNameNS(m_sNamespace, sResponseName);

if (oNodeList.count() == 0)
{
// --------------------------------------------------------------
// Must be a fault... parse it to return reason
// --------------------------------------------------------------

nErrCode = GetNodeValue(
doc, "Envelope/Body/Fault/detail/UPnPResult/errorCode", 500);
sErrDesc = GetNodeValue(
doc, "Envelope/Body/Fault/detail/UPnPResult/errorDescription", "");
if (sErrDesc.isEmpty())
sErrDesc = QString("Unknown #%1").arg(nErrCode);

QDomNode oNode = FindNode( "Envelope/Body/Fault", doc );

oNode = xmlResult.importNode( oNode, true );
xmlResult.appendChild( oNode );

return xmlResult;
}

QDomNode oMethod = oNodeList.item(0);
if (oMethod.isNull())
return xmlResult;

QDomNode oNode = oMethod.firstChild();
for (; !oNode.isNull(); oNode = oNode.nextSibling())
{
QDomElement e = oNode.toElement();
if (e.isNull())
continue;

QString sName = e.tagName();
QString sValue = "";

QDomText oText = oNode.firstChild().toText();

if (!oText.isNull())
sValue = oText.nodeValue();

list.insert(QUrl::fromPercentEncoding(sName.toUtf8()),
QUrl::fromPercentEncoding(sValue.toUtf8()));
}

// Create copy of oMethod that can be used with xmlResult.

oMethod = xmlResult.importNode( oMethod.firstChild(), true );

// importNode does not attach the new nodes to the document,
// do it here.

xmlResult.appendChild( oMethod );

return xmlResult;
return doc;
}

29 changes: 0 additions & 29 deletions mythtv/programs/mythbackend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,35 +43,6 @@ add_executable(
recordingextender.h
scheduler.cpp
scheduler.h
serviceHosts/captureServiceHost.h
serviceHosts/channelServiceHost.h
serviceHosts/contentServiceHost.h
serviceHosts/dvrServiceHost.h
serviceHosts/guideServiceHost.h
serviceHosts/imageServiceHost.h
serviceHosts/musicServiceHost.h
serviceHosts/mythServiceHost.h
serviceHosts/videoServiceHost.h
services/capture.cpp
services/capture.h
services/channel.cpp
services/channel.h
services/content.cpp
services/content.h
services/dvr.cpp
services/dvr.h
services/guide.cpp
services/guide.h
services/image.cpp
services/image.h
services/music.cpp
services/music.h
services/myth.cpp
services/myth.h
services/serviceUtil.cpp
services/serviceUtil.h
services/video.cpp
services/video.h
servicesv2/preformat.h
servicesv2/v2artworkInfo.h
servicesv2/v2artworkInfoList.h
Expand Down
44 changes: 0 additions & 44 deletions mythtv/programs/mythbackend/mediaserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@
#include "upnpcdstv.h"
#include "upnpcdsvideo.h"

#include "serviceHosts/mythServiceHost.h"
#include "serviceHosts/guideServiceHost.h"
#include "serviceHosts/contentServiceHost.h"
#include "serviceHosts/dvrServiceHost.h"
#include "serviceHosts/channelServiceHost.h"
#include "serviceHosts/videoServiceHost.h"
#include "serviceHosts/musicServiceHost.h"
#include "serviceHosts/captureServiceHost.h"
#include "serviceHosts/imageServiceHost.h"

//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -133,17 +124,6 @@ void MediaServer::Init(bool bIsMaster, bool bDisableUPnp /* = false */)
pHttpServer->RegisterExtension( new HttpConfig() );
pHttpServer->RegisterExtension( new InternetContent ( m_sSharePath ));

pHttpServer->RegisterExtension( new MythServiceHost ( m_sSharePath ));
pHttpServer->RegisterExtension( new GuideServiceHost ( m_sSharePath ));
pHttpServer->RegisterExtension( new ContentServiceHost( m_sSharePath ));
pHttpServer->RegisterExtension( new DvrServiceHost ( m_sSharePath ));
pHttpServer->RegisterExtension( new ChannelServiceHost( m_sSharePath ));
pHttpServer->RegisterExtension( new VideoServiceHost ( m_sSharePath ));
pHttpServer->RegisterExtension( new MusicServiceHost ( m_sSharePath ));
pHttpServer->RegisterExtension( new CaptureServiceHost( m_sSharePath ));
pHttpServer->RegisterExtension( new ImageServiceHost ( m_sSharePath ));


// ------------------------------------------------------------------
// Register Service Types with Scripting Engine
//
Expand All @@ -153,30 +133,6 @@ void MediaServer::Init(bool bIsMaster, bool bDisableUPnp /* = false */)
// classes. - dblain
// ------------------------------------------------------------------

#if CONFIG_QTSCRIPT
QScriptEngine* pEngine = pHtmlServer->ScriptEngine();

pEngine->globalObject().setProperty("Myth" ,
pEngine->scriptValueFromQMetaObject< ScriptableMyth >() );
pEngine->globalObject().setProperty("Guide" ,
pEngine->scriptValueFromQMetaObject< ScriptableGuide >() );
pEngine->globalObject().setProperty("Content",
pEngine->scriptValueFromQMetaObject< ScriptableContent >() );
pEngine->globalObject().setProperty("Dvr" ,
pEngine->scriptValueFromQMetaObject< ScriptableDvr >() );
pEngine->globalObject().setProperty("Channel",
pEngine->scriptValueFromQMetaObject< ScriptableChannel >() );
pEngine->globalObject().setProperty("Video" ,
pEngine->scriptValueFromQMetaObject< ScriptableVideo >() );
pEngine->globalObject().setProperty("Music" ,
pEngine->scriptValueFromQMetaObject< ScriptableVideo >() );
pEngine->globalObject().setProperty("Capture" ,
pEngine->scriptValueFromQMetaObject< ScriptableCapture >() );
pEngine->globalObject().setProperty("Image" ,
pEngine->scriptValueFromQMetaObject< ScriptableImage >() );
#endif

// ------------------------------------------------------------------

if (bDisableUPnp)
{
Expand Down
16 changes: 0 additions & 16 deletions mythtv/programs/mythbackend/mythbackend.pro
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,6 @@ HEADERS += internetContent.h mythbackend_main_helpers.h backendcontext.h
HEADERS += httpconfig.h mythsettings.h mythbackend_commandlineparser.h
HEADERS += recordingextender.h

HEADERS += serviceHosts/mythServiceHost.h serviceHosts/guideServiceHost.h
HEADERS += serviceHosts/contentServiceHost.h serviceHosts/dvrServiceHost.h
HEADERS += serviceHosts/channelServiceHost.h serviceHosts/videoServiceHost.h
HEADERS += serviceHosts/captureServiceHost.h serviceHosts/imageServiceHost.h
HEADERS += serviceHosts/musicServiceHost.h

HEADERS += services/myth.h services/guide.h services/content.h services/dvr.h
HEADERS += services/serviceUtil.h services/channel.h services/video.h
HEADERS += services/capture.h services/image.h services/music.h


SOURCES += autoexpire.cpp encoderlink.cpp filetransfer.cpp httpstatus.cpp
SOURCES += mythbackend.cpp mainserver.cpp playbacksock.cpp scheduler.cpp
SOURCES += backendhousekeeper.cpp
Expand All @@ -49,11 +38,6 @@ SOURCES += internetContent.cpp mythbackend_main_helpers.cpp backendcontext.cpp
SOURCES += httpconfig.cpp mythsettings.cpp mythbackend_commandlineparser.cpp
SOURCES += recordingextender.cpp

SOURCES += services/myth.cpp services/guide.cpp services/content.cpp
SOURCES += services/dvr.cpp services/channel.cpp services/video.cpp
SOURCES += services/serviceUtil.cpp services/capture.cpp
SOURCES += services/image.cpp services/music.cpp

HEADERS += servicesv2/v2myth.h servicesv2/v2connectionInfo.h servicesv2/v2wolInfo.h
HEADERS += servicesv2/v2databaseInfo.h servicesv2/v2versionInfo.h
HEADERS += servicesv2/v2storageGroupDir.h servicesv2/v2storageGroupDirList.h
Expand Down
57 changes: 0 additions & 57 deletions mythtv/programs/mythbackend/serviceHosts/captureServiceHost.h

This file was deleted.

59 changes: 0 additions & 59 deletions mythtv/programs/mythbackend/serviceHosts/channelIconServiceHost.h

This file was deleted.

Loading

0 comments on commit 077327d

Please sign in to comment.