Skip to content

Commit

Permalink
Convert UPnpDeviceDesc::Retrieve() to use MythDownloadManager.
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-kristjansson committed Dec 21, 2012
1 parent 87da807 commit 7d705f1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 29 deletions.
4 changes: 2 additions & 2 deletions mythtv/libs/libmyth/backendselect.cpp
Expand Up @@ -137,7 +137,7 @@ void BackendSelection::AddItem(DeviceLocation *dev)
m_mutex.unlock(); m_mutex.unlock();


InfoMap infomap; InfoMap infomap;
dev->GetDeviceDetail(infomap, true); dev->GetDeviceDetail(infomap);


// We only want the version number, not the library version info // We only want the version number, not the library version info
infomap["version"] = infomap["modelnumber"].section('.', 0, 1); infomap["version"] = infomap["modelnumber"].section('.', 0, 1);
Expand Down Expand Up @@ -184,7 +184,7 @@ bool BackendSelection::ConnectBackend(DeviceLocation *dev)


stat = client.GetConnectionInfo(m_pinCode, m_DBparams, message); stat = client.GetConnectionInfo(m_pinCode, m_DBparams, message);


QString backendName = dev->GetFriendlyName(true); QString backendName = dev->GetFriendlyName();


if (backendName == "<Unknown>") if (backendName == "<Unknown>")
backendName = dev->m_sLocation; backendName = dev->m_sLocation;
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythupnp/upnp.cpp
Expand Up @@ -167,9 +167,9 @@ void UPnp::CleanUp()
// //
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////


UPnpDeviceDesc *UPnp::GetDeviceDesc( QString &sURL, bool bInQtThread ) UPnpDeviceDesc *UPnp::GetDeviceDesc( QString &sURL )
{ {
return UPnpDeviceDesc::Retrieve( sURL, bInQtThread ); return UPnpDeviceDesc::Retrieve( sURL );
} }


////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythupnp/upnp.h
Expand Up @@ -124,7 +124,7 @@ class UPNP_PUBLIC UPnp


HttpServer *GetHttpServer() { return m_pHttpServer; } HttpServer *GetHttpServer() { return m_pHttpServer; }


static UPnpDeviceDesc *GetDeviceDesc( QString &sURL, bool bInQtThread = true); static UPnpDeviceDesc *GetDeviceDesc( QString &sURL );


static QString GetResultDesc( UPnPResultCode eCode ); static QString GetResultDesc( UPnPResultCode eCode );
static void FormatErrorResponse( HTTPRequest *pRequest, static void FormatErrorResponse( HTTPRequest *pRequest,
Expand Down
19 changes: 7 additions & 12 deletions mythtv/libs/libmythupnp/upnpdevice.cpp
Expand Up @@ -12,7 +12,7 @@


#include "upnp.h" #include "upnp.h"
#include "upnpdevice.h" #include "upnpdevice.h"
#include "httpcomms.h" #include "mythdownloadmanager.h"
#include "mythlogging.h" #include "mythlogging.h"
#include "mythversion.h" // for MYTH_BINARY_VERSION #include "mythversion.h" // for MYTH_BINARY_VERSION


Expand Down Expand Up @@ -635,22 +635,17 @@ UPnpDevice *UPnpDeviceDesc::FindDevice( UPnpDevice *pDevice,
// //
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////


UPnpDeviceDesc *UPnpDeviceDesc::Retrieve( QString &sURL, bool bInQtThread ) UPnpDeviceDesc *UPnpDeviceDesc::Retrieve( QString &sURL )
{ {
UPnpDeviceDesc *pDevice = NULL; UPnpDeviceDesc *pDevice = NULL;


LOG(VB_UPNP, LOG_DEBUG, QString("UPnpDeviceDesc::Retrieve( %1, %2 )") LOG(VB_UPNP, LOG_DEBUG, QString("UPnpDeviceDesc::Retrieve( %1 )")
.arg(sURL) .arg(bInQtThread)); .arg(sURL));


QString sXml = HttpComms::getHttp( sURL, QString sXml;
10000, // ms bool ok = GetMythDownloadManager()->download(sURL, sXml);
3, // retries
0, // redirects
false, // allow gzip
NULL, // login
bInQtThread );


if (sXml.startsWith( QString("<?xml") )) if (ok && sXml.startsWith( QString("<?xml") ))
{ {
QString sErrorMsg; QString sErrorMsg;


Expand Down
23 changes: 11 additions & 12 deletions mythtv/libs/libmythupnp/upnpdevice.h
Expand Up @@ -185,7 +185,7 @@ class UPNP_PUBLIC UPnpDeviceDesc
UPnpDevice *FindDevice( const QString &sURI ); UPnpDevice *FindDevice( const QString &sURI );


static UPnpDevice *FindDevice( UPnpDevice *pDevice, const QString &sURI ); static UPnpDevice *FindDevice( UPnpDevice *pDevice, const QString &sURI );
static UPnpDeviceDesc *Retrieve ( QString &sURL, bool bInQtThread = true ); static UPnpDeviceDesc *Retrieve ( QString &sURL );


void toMap(QHash<QString, QString> &map) void toMap(QHash<QString, QString> &map)
{ {
Expand Down Expand Up @@ -260,19 +260,19 @@ class UPNP_PUBLIC DeviceLocation : public ReferenceCounter


// ================================================================== // ==================================================================


UPnpDeviceDesc *GetDeviceDesc( bool bInQtThread = true ) UPnpDeviceDesc *GetDeviceDesc(void)
{ {
if (m_pDeviceDesc == NULL) if (m_pDeviceDesc == NULL)
m_pDeviceDesc = UPnpDeviceDesc::Retrieve( m_sLocation, bInQtThread ); m_pDeviceDesc = UPnpDeviceDesc::Retrieve( m_sLocation );


return m_pDeviceDesc; return m_pDeviceDesc;
} }


// ================================================================== // ==================================================================


QString GetFriendlyName( bool bInQtThread = true ) QString GetFriendlyName(void)
{ {
UPnpDeviceDesc *pDevice = GetDeviceDesc( bInQtThread ); UPnpDeviceDesc *pDevice = GetDeviceDesc();


if ( pDevice == NULL) if ( pDevice == NULL)
return "<Unknown>"; return "<Unknown>";
Expand All @@ -285,9 +285,9 @@ class UPNP_PUBLIC DeviceLocation : public ReferenceCounter
return sName; return sName;
} }


QString GetNameAndDetails( bool bInQtThread = true ) QString GetNameAndDetails(void)
{ {
UPnpDeviceDesc *pDevice = GetDeviceDesc( bInQtThread ); UPnpDeviceDesc *pDevice = GetDeviceDesc();


if ( pDevice == NULL) if ( pDevice == NULL)
return "<Unknown> (" + m_sLocation + ")"; return "<Unknown> (" + m_sLocation + ")";
Expand All @@ -297,21 +297,20 @@ class UPNP_PUBLIC DeviceLocation : public ReferenceCounter
+ pDevice->m_rootDevice.m_sUDN; + pDevice->m_rootDevice.m_sUDN;
} }


void GetDeviceDetail(QHash<QString, QString> &map, void GetDeviceDetail(QHash<QString, QString> &map)
bool bInQtThread = true)
{ {
map["location"] = m_sLocation; map["location"] = m_sLocation;


UPnpDeviceDesc *pDevice = GetDeviceDesc(bInQtThread); UPnpDeviceDesc *pDevice = GetDeviceDesc();
if (!pDevice) if (!pDevice)
return; return;


pDevice->toMap(map); pDevice->toMap(map);
} }


bool NeedSecurityPin( bool bInQtThread = true ) bool NeedSecurityPin(void)
{ {
UPnpDeviceDesc *pDevice = GetDeviceDesc(bInQtThread); UPnpDeviceDesc *pDevice = GetDeviceDesc();
if (!pDevice) if (!pDevice)
return false; return false;


Expand Down

0 comments on commit 7d705f1

Please sign in to comment.