// -------------------------------------------------------------------------------- // int guTuneInReadStationsThread::AddStations( const wxString &url, guRadioStations * stations, const long minbitrate ) { wxString Content = GetTuneInUrl( url ); //guLogMessage( wxT( "AddStations: %s" ), url.c_str() ); if( !Content.IsEmpty() ) { wxStringInputStream Ins( Content ); wxXmlDocument XmlDoc( Ins ); wxXmlNode * XmlNode = XmlDoc.GetRoot(); if( XmlNode ) { if( XmlNode->GetName() == wxT( "opml" ) ) { XmlNode = XmlNode->GetChildren(); while( XmlNode && !TestDestroy() ) { //guLogMessage( wxT( "XmlNode: '%s'" ), XmlNode->GetName().c_str() ); if( XmlNode->GetName() == wxT( "outline" ) ) { wxString Type; XmlNode->GetAttribute( wxT( "type" ), &Type ); if( Type == wxT( "" ) ) { ReadStations( XmlNode->GetChildren(), stations, minbitrate ); } else { ReadStations( XmlNode, stations, minbitrate ); break; } } else if( XmlNode->GetName() == wxT( "body" ) ) { XmlNode = XmlNode->GetChildren(); continue; } XmlNode = XmlNode->GetNext(); } } } } if( !TestDestroy() ) { SortStations(); wxCommandEvent Event( wxEVT_MENU, ID_RADIO_UPDATED ); wxPostEvent( m_RadioPanel, Event ); return stations->Count(); } return 0; }
OIArrayPtr COI_ARRAY::read() { string array_name = ReadKey<string>("ARRNAME"); string frame = ReadKey<string>("FRAME"); vector<double> xyz = ReadXYZ(); vector<OIStationPtr> stations = ReadStations(); // Now create an OIStationPtr and return it OIArrayPtr tmp(new COIArray(array_name, frame, xyz, stations)); return tmp; }
// -------------------------------------------------------------------------------- // void guTuneInReadStationsThread::ReadStations( wxXmlNode * xmlnode, guRadioStations * stations, const long minbitrate ) { // wxString MoreStationsUrl; while( xmlnode && !TestDestroy() ) { wxString Type; wxString Name; wxString Url; xmlnode->GetAttribute( wxT( "type" ), &Type ); if( Type == wxT( "" ) ) { ReadStations( xmlnode->GetChildren(), stations, minbitrate ); } else if( Type == wxT( "link" ) ) { xmlnode->GetAttribute( wxT( "text" ), &Name ); xmlnode->GetAttribute( wxT( "URL" ), &Url ); //guLogMessage( wxT( "ReadStations -> Type : '%s' Name : '%s' " ), Type.c_str(), Name.c_str() ); if( Name == wxT( "Find by Name" ) ) { } else if( Name == wxT( "More Stations" ) ) { //MoreStationsUrl = Url; m_MoreStations.Add( Url ); } else { //guLogMessage( wxT( "AddPendingItem '%s' '%s'" ), Name.c_str(), Url.c_str() ); m_TuneInProvider->AddPendingItem( Name + wxT( "|" ) + Url ); wxCommandEvent Event( wxEVT_MENU, ID_RADIO_CREATE_TREE_ITEM ); wxPostEvent( m_RadioPanel, Event ); Sleep( 20 ); } } else if( Type == wxT( "audio" ) ) { // <outline type="audio" // text="Talk Radio Europe (Cartagena)" // URL="http://opml.radiotime.com/Tune.ashx?id=s111270" // bitrate="64" // reliability="96" // guide_id="s111270" // subtext="your voice in spain" // genre_id="g32" // formats="mp3" // item="station" // image="http://radiotime-logos.s3.amazonaws.com/s111270q.png" // now_playing_id="s111270" // preset_id="s111270"/> guRadioStation * RadioStation = new guRadioStation(); long lBitRate = 0; wxString BitRate; xmlnode->GetAttribute( wxT( "bitrate" ), &BitRate ); if( !BitRate.IsEmpty() ) { BitRate.ToLong( &lBitRate ); } xmlnode->GetAttribute( wxT( "text" ), &RadioStation->m_Name ); if( ( BitRate.IsEmpty() || ( lBitRate >= minbitrate ) ) && SearchFilterTexts( m_TuneInProvider->GetSearchTexts(), RadioStation->m_Name.Lower() ) ) { RadioStation->m_BitRate = lBitRate; RadioStation->m_Id = -1; RadioStation->m_SCId = wxNOT_FOUND; xmlnode->GetAttribute( wxT( "URL" ), &RadioStation->m_Link ); xmlnode->GetAttribute( wxT( "formats" ), &RadioStation->m_Type ); xmlnode->GetAttribute( wxT( "subtext" ), &RadioStation->m_NowPlaying ); RadioStation->m_Source = guRADIO_SOURCE_TUNEIN; RadioStation->m_Listeners = 0; stations->Add( RadioStation ); //guLogMessage( wxT( "Adding station %s" ), RadioStation->m_Name.c_str() ); } else { delete RadioStation; } } xmlnode = xmlnode->GetNext(); } if( !TestDestroy() ) { SortStations(); wxCommandEvent Event( wxEVT_MENU, ID_RADIO_UPDATED ); wxPostEvent( m_RadioPanel, Event ); } }