13 #ifndef __UPNPDEVICE_H__
14 #define __UPNPDEVICE_H__
16 #include <QDomDocument>
52 UPnpIcon() : m_nWidth(0), m_nHeight(0), m_nDepth(0) {}
57 for (
uint i = 0; i < padding; i++)
59 return QString(
"%0Icon %1 %2x%3^%4 %5")
60 .arg(pad).arg(m_sURL).arg(m_nWidth).arg(m_nHeight)
61 .arg(m_nDepth).arg(m_sMimeType);
81 for (
uint i = 0; i < padding; i++)
84 QString(
"%0Service %1\n").arg(pad).arg(m_sServiceType) +
85 QString(
"%0 id: %1\n").arg(pad).arg(m_sServiceId) +
86 QString(
"%0 SCPD URL: %1\n").arg(pad).arg(m_sSCPDURL) +
87 QString(
"%0 Control URL: %1\n").arg(pad).arg(m_sControlURL) +
88 QString(
"%0 Event Sub URL: %1").arg(pad).arg(m_sEventSubURL);
125 QString GetUDN(
void)
const;
127 void toMap(QHash<QString, QString> &map);
129 UPnpService GetService(
const QString &urn,
bool *found = NULL)
const;
153 void _InternalLoad( QDomNode oNode,
UPnpDevice *pCurDevice );
155 void ProcessIconList ( QDomNode oListNode,
UPnpDevice *pDevice );
156 void ProcessServiceList( QDomNode oListNode,
UPnpDevice *pDevice );
157 void ProcessDeviceList ( QDomNode oListNode,
UPnpDevice *pDevice );
159 void OutputDevice( QTextStream &os,
161 const QString &sUserAgent =
"" );
163 void SetStrValue (
const QDomNode &
n, QString &sValue );
164 void SetNumValue (
const QDomNode &
n,
int &nValue );
165 void SetBoolValue(
const QDomNode &
n,
bool &nValue );
167 QString FormatValue (
const QString &sName,
const QString &sValue );
168 QString FormatValue (
const QString &sName,
int nValue );
170 QString GetHostName ();
177 bool Load (
const QString &sFileName );
178 bool Load (
const QDomDocument &xmlDevDesc );
180 void GetValidXML(
const QString &sBaseAddress,
int nPort, QTextStream &os,
const QString &sUserAgent =
"" );
181 QString GetValidXML(
const QString &sBaseAddress,
int nPort );
183 QString FindDeviceUDN(
UPnpDevice *pDevice, QString sST );
185 UPnpDevice *FindDevice(
const QString &sURI );
190 void toMap(QHash<QString, QString> &map)
192 map[
"hostname"] = m_sHostName;
193 m_rootDevice.toMap(map);
218 if (m_pDeviceDesc != NULL)
219 delete m_pDeviceDesc;
238 const QString &sLocation,
241 m_pDeviceDesc( NULL ),
244 m_sLocation ( sLocation ),
245 m_ttExpires ( ttExpires )
253 int ExpiresInSecs(
void)
const
256 gettimeofday( (&ttNow), NULL );
258 return m_ttExpires.tv_sec - ttNow.tv_sec;
265 if (m_pDeviceDesc == NULL)
268 return m_pDeviceDesc;
273 QString GetFriendlyName(
void)
277 if ( pDevice == NULL)
282 if (sName ==
"mythtv: MythTV AV Media Server")
288 QString GetNameAndDetails(
void)
292 if ( pDevice == NULL)
293 return "<Unknown> (" + m_sLocation +
")";
300 void GetDeviceDetail(QHash<QString, QString> &map)
302 map[
"location"] = m_sLocation;
311 bool NeedSecurityPin(
void)
322 return QString(
"\nURI:%1\nUSN:%2\nDeviceXML:%3\n"
323 "Expires:%4\nMythTV PIN:%5")
324 .arg(m_sURI).arg(m_sUSN).arg(m_sLocation)
325 .arg(ExpiresInSecs()).arg(m_sSecurityPin);