void UPnpDeviceDesc::ProcessServiceList( QDomNode oListNode, UPnpDevice *pDevice ) { for ( QDomNode oNode = oListNode.firstChild(); !oNode.isNull(); oNode = oNode.nextSibling() ) { QDomElement e = oNode.toElement(); if (!e.isNull()) { if ( e.tagName() == "service" ) { UPnpService *pService = new UPnpService(); pDevice->m_listServices.append( pService ); SetStrValue( e.namedItem( "serviceType" ), pService->m_sServiceType ); SetStrValue( e.namedItem( "serviceId" ), pService->m_sServiceId ); SetStrValue( e.namedItem( "SCPDURL" ), pService->m_sSCPDURL ); SetStrValue( e.namedItem( "controlURL" ), pService->m_sControlURL ); SetStrValue( e.namedItem( "eventSubURL" ), pService->m_sEventSubURL ); VERBOSE(VB_UPNP, QString("ProcessServiceList adding service : %1 : %2 :") .arg(pService->m_sServiceType) .arg(pService->m_sServiceId )); } } } }
void IniHash::Load(const sys_char_t *fileName) { // Clear(); SysTextFileIn in; try { in.Open(fileName); } catch (csyserr *ex) { if (SysErrorIsFileNotFound(ex->code)) { ex->destroy(); return; } throw; } char buf[4096]; carray<char> section; while (in.GetLine(buf, sizeof(buf))) { char *s = buf; while (IsSpace(*s)) s++; if (!*s || *s == '#') continue; if (*s == '[') { s++; while (IsSpace(*s)) s++; char *t = s; while (*t && *t != ']') t++; if (*t != ']') continue; while ( t>s && IsSpace(*(t-1))) t--; *t = 0; section = new_char_str(s); } else { if (!section.ptr()) continue; char *t = s; while (*t && *t != '=') t++; if (*t != '=') continue; char *v = t + 1; while ( t>s && IsSpace(*(t-1))) t--; *t = 0; while (IsSpace(*v)) v++; t = v; while (*t) t++; while ( t>v && IsSpace(*(t-1))) t--; *t = 0; SetStrValue(section.ptr(), s, v); } } in.Close(); }
void UPnpDeviceDesc::ProcessIconList( QDomNode oListNode, UPnpDevice *pDevice ) { for ( QDomNode oNode = oListNode.firstChild(); !oNode.isNull(); oNode = oNode.nextSibling() ) { QDomElement e = oNode.toElement(); if (!e.isNull()) { if ( e.tagName() == "icon" ) { UPnpIcon *pIcon = new UPnpIcon(); pDevice->m_listIcons.append( pIcon ); SetStrValue( e.namedItem( "mimetype" ), pIcon->m_sMimeType ); SetNumValue( e.namedItem( "width" ), pIcon->m_nWidth ); SetNumValue( e.namedItem( "height" ), pIcon->m_nHeight ); SetNumValue( e.namedItem( "depth" ), pIcon->m_nDepth ); SetStrValue( e.namedItem( "url" ), pIcon->m_sURL ); } } } }
void UPnpDeviceDesc::_InternalLoad( QDomNode oNode, UPnpDevice *pCurDevice ) { QString pin = GetMythDB()->GetSetting( "SecurityPin", ""); pCurDevice->m_securityPin = (pin.isEmpty() || pin == "0000") ? false : true; for ( oNode = oNode.firstChild(); !oNode.isNull(); oNode = oNode.nextSibling() ) { QDomElement e = oNode.toElement(); if (!e.isNull()) { if ( e.tagName() == "deviceType" ) { SetStrValue( e, pCurDevice->m_sDeviceType ); continue; } if ( e.tagName() == "friendlyName" ) { SetStrValue( e, pCurDevice->m_sFriendlyName ); continue; } if ( e.tagName() == "manufacturer" ) { SetStrValue( e, pCurDevice->m_sManufacturer ); continue; } if ( e.tagName() == "manufacturerURL" ) { SetStrValue( e, pCurDevice->m_sManufacturerURL ); continue; } if ( e.tagName() == "modelDescription" ) { SetStrValue( e, pCurDevice->m_sModelDescription); continue; } if ( e.tagName() == "modelName" ) { SetStrValue( e, pCurDevice->m_sModelName ); continue; } if ( e.tagName() == "modelNumber" ) { SetStrValue( e, pCurDevice->m_sModelNumber ); continue; } if ( e.tagName() == "modelURL" ) { SetStrValue( e, pCurDevice->m_sModelURL ); continue; } if ( e.tagName() == "serialNumber" ) { SetStrValue( e, pCurDevice->m_sSerialNumber ); continue; } if ( e.tagName() == "UPC" ) { SetStrValue( e, pCurDevice->m_sUPC ); continue; } if ( e.tagName() == "presentationURL" ) { SetStrValue( e, pCurDevice->m_sPresentationURL ); continue; } if ( e.tagName() == "UDN" ) { SetStrValue( e, pCurDevice->m_sUDN ); continue; } if ( e.tagName() == "iconList" ) { ProcessIconList ( oNode, pCurDevice ); continue; } if ( e.tagName() == "serviceList" ) { ProcessServiceList( oNode, pCurDevice ); continue; } if ( e.tagName() == "deviceList" ) { ProcessDeviceList ( oNode, pCurDevice ); continue; } if ( e.tagName() == "mythtv:X_secure" ) { SetBoolValue( e, pCurDevice->m_securityPin ); continue; } if ( e.tagName() == "mythtv:X_protocol" ) { SetStrValue( e, pCurDevice->m_protocolVersion ); continue; } // Not one of the expected element names... add to extra list. QString sValue = ""; SetStrValue( e, sValue ); pCurDevice->m_lstExtra.push_back(NameValue(e.tagName(), sValue)); } } }
void IniHash::SetIntValue(const char *section, const char *var, int value){ char buf[64]; int_to_char<int>(value, buf); SetStrValue(section, var, buf); }
void UPnpDeviceDesc::_InternalLoad( QDomNode oNode, UPnpDevice *pCurDevice ) { QString pin = GetMythDB()->GetSetting( "SecurityPin", ""); pCurDevice->m_securityPin = !(pin.isEmpty() || pin == "0000"); for ( oNode = oNode.firstChild(); !oNode.isNull(); oNode = oNode.nextSibling() ) { QDomElement e = oNode.toElement(); if (e.isNull()) continue; // TODO: make this table driven (using offset within structure) if ( e.tagName() == "deviceType" ) SetStrValue( e, pCurDevice->m_sDeviceType); else if ( e.tagName() == "friendlyName" ) SetStrValue( e, pCurDevice->m_sFriendlyName ); else if ( e.tagName() == "manufacturer" ) SetStrValue( e, pCurDevice->m_sManufacturer ); else if ( e.tagName() == "manufacturerURL" ) SetStrValue( e, pCurDevice->m_sManufacturerURL ); else if ( e.tagName() == "modelDescription" ) SetStrValue( e, pCurDevice->m_sModelDescription); else if ( e.tagName() == "modelName" ) SetStrValue( e, pCurDevice->m_sModelName ); else if ( e.tagName() == "modelNumber" ) SetStrValue( e, pCurDevice->m_sModelNumber ); else if ( e.tagName() == "modelURL" ) SetStrValue( e, pCurDevice->m_sModelURL ); else if ( e.tagName() == "serialNumber" ) SetStrValue( e, pCurDevice->m_sSerialNumber ); else if ( e.tagName() == "UPC" ) SetStrValue( e, pCurDevice->m_sUPC ); else if ( e.tagName() == "presentationURL" ) SetStrValue( e, pCurDevice->m_sPresentationURL ); else if ( e.tagName() == "UDN" ) SetStrValue( e, pCurDevice->m_sUDN ); else if ( e.tagName() == "iconList" ) ProcessIconList( oNode, pCurDevice ); else if ( e.tagName() == "serviceList" ) ProcessServiceList( oNode, pCurDevice ); else if ( e.tagName() == "deviceList" ) ProcessDeviceList ( oNode, pCurDevice ); else if ( e.tagName() == "mythtv:X_secure" ) SetBoolValue( e, pCurDevice->m_securityPin ); else if ( e.tagName() == "mythtv:X_protocol" ) SetStrValue( e, pCurDevice->m_protocolVersion ); else { // Not one of the expected element names... add to extra list. QString sValue = ""; SetStrValue( e, sValue ); NameValue node = NameValue(e.tagName(), sValue); QDomNamedNodeMap attributes = e.attributes(); for (int i = 0; i < attributes.size(); i++) { node.AddAttribute(attributes.item(i).nodeName(), attributes.item(i).nodeValue(), true); // TODO Check whether all attributes are in fact requires for the device xml } pCurDevice->m_lstExtra.push_back(node); } } }