Ticket #5736: patch-libmythupnp-filter-v2.diff
File patch-libmythupnp-filter-v2.diff, 5.4 KB (added by , 16 years ago) |
---|
-
upnpcds.h
105 105 } 106 106 107 107 void Add ( CDSObject *pObject ); 108 QString GetResultXML( );108 QString GetResultXML(FilterMap &filter); 109 109 }; 110 110 111 111 ////////////////////////////////////////////////////////////////////////////// -
upnpcdsobjects.cpp
161 161 // 162 162 ///////////////////////////////////////////////////////////////////////////// 163 163 164 QString CDSObject::toXml( void) const164 QString CDSObject::toXml( FilterMap &filter ) const 165 165 { 166 166 QString sXML; 167 167 QTextStream os( &sXML, QIODevice::WriteOnly ); 168 168 os.setCodec(QTextCodec::codecForName("UTF-8")); 169 toXml(os );169 toXml(os, filter); 170 170 os << flush; 171 171 return( sXML ); 172 172 } … … 175 175 // 176 176 ///////////////////////////////////////////////////////////////////////////// 177 177 178 void CDSObject::toXml(QTextStream &os ) const178 void CDSObject::toXml(QTextStream &os, FilterMap &filter) const 179 179 { 180 180 QString sEndTag = ""; 181 bool bFilter = false;181 bool bFilter = true; 182 182 183 // -=>TODO: Need to add Filter Support 183 if (filter.indexOf( "*" ) != -1) 184 bFilter = false; 184 185 185 // if (filter.find( "*" ) != filter.end())186 // bFilter = false;187 188 186 switch( m_eType ) 189 187 { 190 188 case OT_Container: … … 230 228 else 231 229 sName = pProp->m_sName; 232 230 233 if (pProp->m_bRequired || !bFilter ) //|| ( filter.find( sName ) != filter.end()) 231 if (pProp->m_bRequired || !bFilter 232 || ( filter.indexOf( sName ) != -1)) 234 233 { 235 234 os << "<" << sName << ">"; 236 235 os << pProp->m_sValue; … … 262 261 263 262 CDSObjects::const_iterator cit = m_children.begin(); 264 263 for (; cit != m_children.end(); ++cit) 265 (*cit)->toXml(os );264 (*cit)->toXml(os, filter); 266 265 267 266 // ---------------------------------------------------------------------- 268 267 // Close Element Tag -
upnpcds.cpp
31 31 // 32 32 ///////////////////////////////////////////////////////////////////////////// 33 33 34 QString UPnpCDSExtensionResults::GetResultXML( )34 QString UPnpCDSExtensionResults::GetResultXML(FilterMap &filter) 35 35 { 36 36 QString sXML; 37 37 38 38 CDSObjects::const_iterator it = m_List.begin(); 39 39 for (; it != m_List.end(); ++it) 40 sXML += (*it)->toXml( );40 sXML += (*it)->toXml(filter); 41 41 42 42 return sXML; 43 43 } … … 219 219 short nTotalMatches = 0; 220 220 short nUpdateID = 0; 221 221 QString sResultXML; 222 FilterMap filter = (FilterMap) request.m_sFilter.split(","); 222 223 223 224 VERBOSE(VB_UPNP, QString("UPnpCDS::HandleBrowse ObjectID=%1, ContainerId=%2") 224 225 .arg(request.m_sObjectId) … … 245 246 246 247 m_root.SetChildCount( m_extensions.count() ); 247 248 248 sResultXML = m_root.toXml( );249 sResultXML = m_root.toXml(filter); 249 250 250 251 break; 251 252 } … … 289 290 { 290 291 if (pResult->m_eErrorCode == UPnPResult_Success) 291 292 { 292 sResultXML += pResult->GetResultXML( );293 sResultXML += pResult->GetResultXML(filter); 293 294 nNumberReturned ++; 294 295 } 295 296 … … 328 329 nNumberReturned = pResult->m_List.count(); 329 330 nTotalMatches = pResult->m_nTotalMatches; 330 331 nUpdateID = pResult->m_nUpdateID; 331 sResultXML = pResult->GetResultXML( );332 sResultXML = pResult->GetResultXML(filter); 332 333 } 333 334 334 335 delete pResult; … … 459 460 460 461 if (eErrorCode == UPnPResult_Success) 461 462 { 463 FilterMap filter = (FilterMap) request.m_sFilter.split(","); 462 464 nNumberReturned = pResult->m_List.count(); 463 465 nTotalMatches = pResult->m_nTotalMatches; 464 466 nUpdateID = pResult->m_nUpdateID; 465 sResultXML = pResult->GetResultXML( );467 sResultXML = pResult->GetResultXML(filter); 466 468 //bSearchDone = true; 467 469 } 468 470 -
upnpcdsobjects.h
119 119 120 120 typedef QList<ContainerClass*> Classes; 121 121 122 typedef QStringList FilterMap; 123 122 124 ////////////////////////////////////////////////////////////////////////////// 123 125 124 126 class CDSObject … … 171 173 172 174 void SetPropValue( QString sName, QString sValue ); 173 175 QString GetPropValue( const QString &sName ) const; 176 QString toXml ( FilterMap &filter ) const; 177 void toXml ( QTextStream &os, FilterMap &filter ) const; 174 178 175 QString toXml ( void ) const;176 void toXml ( QTextStream &os ) const;177 178 179 long GetChildCount( void ) const; 179 180 void SetChildCount( long nCount ); 180 181