~ubuntu-branches/ubuntu/lucid/lastfm/lucid

« back to all changes in this revision

Viewing changes to src/libUnicorn/TrackInfo.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Devid Filoni
  • Date: 2008-07-14 16:46:20 UTC
  • mfrom: (1.1.7 upstream) (3.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080714164620-67hoz9fs177wpgmr
Tags: 1:1.5.1.31879.dfsg-1ubuntu1
* Merge from Debian unstable (LP: #248100), remaining changes:
  - debian/rules: add dh_icons call
  + debian/control:
    - switch iceweasel to firefox in Recommends field
    - modify debhelper version to >= 5.0.51~
    - modify Maintainer to Ubuntu MOTU Developers

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
    setSource( (Source)e.namedItem( "source" ).toElement().text().toInt() );
64
64
    setAuthCode( e.namedItem( "authorisationKey" ).toElement().text() );
65
65
    m_ratingFlags = e.namedItem( "userActionFlags" ).toElement().text().toUInt();
 
66
    m_mediaDeviceId = e.namedItem( "mediaDeviceId" ).toElement().text();
66
67
 
67
68
    // this is necessary because the default return for toInt() is 0, and that
68
69
    // corresponds to Radio not Unknown :( oops.
92
93
{
93
94
    QDomElement item = document.createElement( "item" );
94
95
 
95
 
    QDomElement artist = document.createElement( "artist" );
96
 
    QDomText artistText = document.createTextNode( m_artist );
97
 
    artist.appendChild( artistText );
98
 
    item.appendChild( artist );
99
 
 
100
 
    QDomElement album = document.createElement( "album" );
101
 
    QDomText albumText = document.createTextNode( m_album );
102
 
    album.appendChild( albumText );
103
 
    item.appendChild( album );
104
 
 
105
 
    QDomElement title = document.createElement( "track" );
106
 
    QDomText titleText = document.createTextNode( m_track );
107
 
    title.appendChild( titleText );
108
 
    item.appendChild( title );
109
 
 
110
 
    QDomElement length = document.createElement( "duration" );
111
 
    QDomText lengthText = document.createTextNode( QString::number( m_duration ) );
112
 
    length.appendChild( lengthText );
113
 
    item.appendChild( length );
114
 
 
115
 
    QDomElement playtime = document.createElement( "timestamp" );
116
 
    QDomText playtimeText = document.createTextNode( QString::number( m_timeStamp ) );
117
 
    playtime.appendChild( playtimeText );
118
 
    item.appendChild( playtime );
119
 
 
120
 
    QDomElement playcount = document.createElement( "playcount" );
121
 
    QDomText playcountText = document.createTextNode( QString::number( m_playCount ) );
122
 
    playcount.appendChild( playcountText );
123
 
    item.appendChild( playcount );
124
 
 
125
 
    QDomElement filename = document.createElement( "filename" );
126
 
    QDomText filenameText = document.createTextNode( m_fileName );
127
 
    filename.appendChild( filenameText );
128
 
    item.appendChild( filename );
129
 
 
130
 
    QDomElement uniqueID = document.createElement( "uniqueID" );
131
 
    QDomText uniqueIDText = document.createTextNode( m_uniqueID );
132
 
    uniqueID.appendChild( uniqueIDText );
133
 
    item.appendChild( uniqueID );
134
 
 
135
 
    QDomElement source = document.createElement( "source" );
136
 
    QDomText sourceText = document.createTextNode( QString::number( m_source ) );
137
 
    source.appendChild( sourceText );
138
 
    item.appendChild( source );
139
 
 
140
 
    QDomElement authKey = document.createElement( "authorisationKey" );
141
 
    QDomText authKeyText = document.createTextNode( m_authCode );
142
 
    authKey.appendChild( authKeyText );
143
 
    item.appendChild( authKey );
144
 
 
145
 
    QDomElement userActionFlags = document.createElement( "userActionFlags" );
146
 
    QDomText userActionFlagsText = document.createTextNode( QString::number(m_ratingFlags) );
147
 
    userActionFlags.appendChild( userActionFlagsText );
148
 
    item.appendChild( userActionFlags );
149
 
 
150
 
    QDomElement pathKey = document.createElement( "path" );
151
 
    QDomText pathText = document.createTextNode( path() );
152
 
    pathKey.appendChild( pathText );
153
 
    item.appendChild( pathKey );
154
 
 
155
 
    QDomElement fpIdKey = document.createElement( "fpId" );
156
 
    QDomText fpIdText = document.createTextNode( fpId() );
157
 
    fpIdKey.appendChild( fpIdText );
158
 
    item.appendChild( fpIdKey );
159
 
 
160
 
    QDomElement mbIdKey = document.createElement( "mbId" );
161
 
    QDomText mbIdText = document.createTextNode( mbId() );
162
 
    mbIdKey.appendChild( mbIdText );
163
 
    item.appendChild( mbIdKey );
164
 
 
165
 
    QDomElement playerIdKey = document.createElement( "playerId" );
166
 
    QDomText playerIdText = document.createTextNode( playerId() );
167
 
    playerIdKey.appendChild( playerIdText );
168
 
    item.appendChild( playerIdKey );
 
96
    #define makeElement( tagname, getter ) \
 
97
    { \
 
98
        QDomElement e = document.createElement( tagname ); \
 
99
        e.appendChild( document.createTextNode( getter ) ); \
 
100
        item.appendChild( e ); \
 
101
    }
 
102
 
 
103
    makeElement( "artist", m_artist );
 
104
    makeElement( "album", m_album );
 
105
    makeElement( "track", m_track );
 
106
    makeElement( "duration", QString::number( m_duration ) );
 
107
    makeElement( "timestamp", QString::number( m_timeStamp ) );
 
108
    makeElement( "playcount", QString::number( m_playCount ) );
 
109
    makeElement( "filename", m_fileName );
 
110
    makeElement( "uniqueID", m_uniqueID );
 
111
    makeElement( "source", QString::number( m_source ) );
 
112
    makeElement( "authorisationKey", m_authCode );
 
113
    makeElement( "userActionFlags", QString::number(m_ratingFlags) );
 
114
    makeElement( "path", path() );
 
115
    makeElement( "fpId", fpId() );
 
116
    makeElement( "mbId", mbId() );
 
117
    makeElement( "playerId", playerId() );
 
118
    makeElement( "mediaDeviceId", m_mediaDeviceId );
169
119
 
170
120
    return item;
171
121
}
196
146
    if ( m_stopWatch == 0 ) setStopWatch( that.stopWatch() );
197
147
    if ( m_username.isEmpty() ) setUsername( that.username() );
198
148
    if ( m_fpId.isEmpty() ) setFpId( that.fpId() );
 
149
    if ( m_mediaDeviceId.isEmpty() ) setMediaDeviceId( that.mediaDeviceId() );
199
150
}
200
151
 
201
152
 
298
249
{
299
250
    switch (m_source)
300
251
    {
301
 
        case Radio:
302
 
            return "L";
303
 
 
304
 
        case Player:
305
 
        case MediaDevice:
306
 
            return "P";
307
 
 
308
 
        default:
309
 
            return "U";
 
252
        case Radio: return "L" + authCode();
 
253
        case Player: return "P" + playerId();
 
254
        case MediaDevice: return "P" + mediaDeviceId();
 
255
        default: return "U";
310
256
    }
311
257
}
312
258