1
/***************************************************************************
2
* Copyright (C) 2005 - 2007 by *
3
* Max Howell, Last.fm Ltd <max@last.fm> *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. *
19
***************************************************************************/
26
RadioMetaDataRequest::RadioMetaDataRequest()
27
: Request( TypeRadioMetaData, "RadioMetaData" )
28
, m_retry_timeout( 0 )
30
m_retry_timer.setSingleShot( true );
32
connect( &m_retry_timer, SIGNAL(timeout()), SLOT(start()) );
36
RadioMetaDataRequest::start()
38
get( basePath() + "/np.php?session=" + session() );
42
RadioMetaDataRequest::success( QByteArray data )
47
//TODO mxcl I need to be careful here, check usage before refactoring
49
if ( data.size() <= 0 )
51
LOGL( 3, "Get metadata for radio failed" );
52
m_track.populate( The::currentMetaData() );
54
//TODO mxcl error handling
57
QString result( data );
58
//LOGL( 4, "result: " << result );
60
track.setArtist( parameter( "artist", result ) );
61
track.setAlbum( parameter( "album", result ) );
62
track.setTrack( parameter( "track", result ) );
63
track.setAlbumPicUrl( parameter( "albumcover_medium", result ) );
64
track.setArtistPageUrl( parameter( "artist_url", result ) );
65
track.setAlbumPageUrl( parameter( "album_url", result ) );
66
track.setTrackPageUrl( parameter( "track_url", result ) );
67
track.setDuration( parameter( "trackduration", result ).toInt() );
68
track.setSource( MetaData::Radio );
70
int errCode = parameter( "error", result ).toInt(); //FIXME: check for possible error codes
71
bool discovery = parameter( "discovery", result ) != "-1";
72
m_stationFeed = parameter( "stationfeed", result );
74
stationName = parameter( "station", result );
77
Q_UNUSED( discovery );
80
if (track.sameAs( The::currentMetaData() ))
82
LOGL( 3, "Re-requesting metadata" );
88
LOGL(3, "got new track, populating The::webService()->currentTrack()" );
90
m_stationName = stationName;
91
m_track.populate( track );