1 /****************************************************************************************
2  * Copyright (c) 2007 Casey Link <unnamedrambler@gmail.com>                             *
3  *                                                                                      *
4  * This program is free software; you can redistribute it and/or modify it under        *
5  * the terms of the GNU General Public License as published by the Free Software        *
6  * Foundation; either version 2 of the License, or (at your option) any later           *
7  * version.                                                                             *
8  *                                                                                      *
9  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
10  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
11  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
12  *                                                                                      *
13  * You should have received a copy of the GNU General Public License along with         *
14  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
15  ****************************************************************************************/
16 
17 #include "Mp3tunesLockerMeta.h"
18 #include "core/support/Debug.h"
19 
20 ////////////////////////////////////////////////////////////////////////
21 //ARTIST
Mp3tunesLockerArtist(mp3tunes_locker_artist_t * artist)22 Mp3tunesLockerArtist::Mp3tunesLockerArtist(  mp3tunes_locker_artist_t *artist )
23     : m_artistId( 0 )
24     , m_artistName()
25     , m_artistSize( 0 )
26     , m_albumCount( 0 )
27     , m_trackCount( 0 )
28 {
29     if( !artist ) return;
30 
31     m_artistId = artist->artistId;
32     m_artistName = artist->artistName;
33     m_artistSize = artist->artistSize;
34     m_albumCount = artist->albumCount;
35     m_trackCount = artist->trackCount;
36 }
37 
~Mp3tunesLockerArtist()38 Mp3tunesLockerArtist::~Mp3tunesLockerArtist()
39 {}
40 
artistId() const41 int Mp3tunesLockerArtist::artistId() const
42 {
43     return m_artistId;
44 }
45 
artistName() const46 QString Mp3tunesLockerArtist::artistName() const
47 {
48     return m_artistName;
49 }
50 
artistSize() const51 int Mp3tunesLockerArtist::artistSize() const
52 {
53     return m_artistSize;
54 }
55 
albumCount() const56 int Mp3tunesLockerArtist::albumCount() const
57 {
58     return m_albumCount;
59 }
60 
trackCount() const61 int Mp3tunesLockerArtist::trackCount() const
62 {
63     return m_trackCount;
64 }
65 ////////////////////////////////////////////////////////////////////////
66 //ALBUM
Mp3tunesLockerAlbum(mp3tunes_locker_album_t * album)67 Mp3tunesLockerAlbum::Mp3tunesLockerAlbum(  mp3tunes_locker_album_t *album )
68     : m_albumId( 0 )
69     , m_albumTitle()
70     , m_artistId( 0 )
71     , m_artistName()
72     , m_trackCount( 0 )
73     , m_albumSize( 0 )
74     , m_hasArt( false )
75 {
76     if( !album ) return;
77 
78     m_albumId = album->albumId;
79     m_albumTitle = album->albumTitle;
80     m_artistId = album->artistId;
81     m_artistName = album->artistName;
82     m_trackCount = album->trackCount;
83     m_albumSize = album->albumSize;
84     m_hasArt = album->hasArt;
85 }
86 
~Mp3tunesLockerAlbum()87 Mp3tunesLockerAlbum::~Mp3tunesLockerAlbum()
88 {}
89 
albumId() const90 int Mp3tunesLockerAlbum::albumId() const
91 {
92     return m_albumId;
93 }
94 
albumTitle() const95 QString Mp3tunesLockerAlbum::albumTitle() const
96 {
97     return m_albumTitle;
98 }
99 
artistId() const100 int Mp3tunesLockerAlbum::artistId() const
101 {
102     return m_artistId;
103 }
104 
artistName() const105 QString Mp3tunesLockerAlbum::artistName() const
106 {
107     return m_artistName;
108 }
109 
trackCount() const110 int Mp3tunesLockerAlbum::trackCount() const
111 {
112     return m_trackCount;
113 }
114 
albumSize() const115 int Mp3tunesLockerAlbum::albumSize() const
116 {
117     return m_albumSize;
118 }
119 
hasArt() const120 bool Mp3tunesLockerAlbum::hasArt() const
121 {
122     return m_hasArt;
123 }
124 ////////////////////////////////////////////////////////////////////////
125 //TRACK
Mp3tunesLockerTrack(mp3tunes_locker_track_t * track)126 Mp3tunesLockerTrack::Mp3tunesLockerTrack(  mp3tunes_locker_track_t *track )
127     : m_trackId( 0 )
128     , m_trackTitle()
129     , m_trackNumber( 0 )
130     , m_trackLength( 0.0 )
131     , m_trackFileName()
132     , m_trackFileKey()
133     , m_trackFileSize( 0 )
134     , m_downloadUrl()
135     , m_playUrl()
136     , m_albumId( 0 )
137     , m_albumTitle()
138     , m_albumYear( 0 )
139     , m_artistName()
140     , m_artistId( 0 )
141 {
142     if ( !track ) return;
143 
144     m_trackTitle = track->trackTitle;
145     m_trackNumber = track->trackNumber;
146     m_trackLength = track->trackLength;
147     m_trackFileName = track->trackFileName;
148     m_trackFileKey = track->trackFileKey;
149     m_trackFileSize = track->trackFileSize;
150     m_downloadUrl = track->downloadURL;
151     m_playUrl = track->playURL;
152     m_albumId = track->albumId;
153     m_albumTitle = track->albumTitle;
154     m_albumYear = track->albumYear;
155     m_artistName = track->artistName;
156     m_artistId = track->artistId;
157 }
158 
~Mp3tunesLockerTrack()159 Mp3tunesLockerTrack::~Mp3tunesLockerTrack()
160 {}
161 
trackId() const162 int Mp3tunesLockerTrack::trackId() const
163 {
164     return m_trackId;
165 }
166 
trackTitle() const167 QString Mp3tunesLockerTrack::trackTitle() const
168 {
169     return m_trackTitle;
170 }
171 
trackNumber() const172 int Mp3tunesLockerTrack::trackNumber() const
173 {
174     return m_trackNumber;
175 }
176 
trackLength() const177 float Mp3tunesLockerTrack::trackLength() const
178 {
179     return m_trackLength;
180 }
181 
trackFileName() const182 QString Mp3tunesLockerTrack::trackFileName() const
183 {
184     return m_trackFileName;
185 }
186 
trackFileKey() const187 QString Mp3tunesLockerTrack::trackFileKey() const
188 {
189     return m_trackFileKey;
190 }
191 
trackFileSize() const192 int Mp3tunesLockerTrack::trackFileSize() const
193 {
194     return m_trackFileSize;
195 }
196 
downloadUrl() const197 QString Mp3tunesLockerTrack::downloadUrl() const
198 {
199     return m_downloadUrl;
200 }
201 
playUrl() const202 QString Mp3tunesLockerTrack::playUrl() const
203 {
204     return m_playUrl;
205 }
206 
albumId() const207 int Mp3tunesLockerTrack::albumId() const
208 {
209     return m_albumId;
210 }
211 
albumTitle() const212 QString Mp3tunesLockerTrack::albumTitle() const
213 {
214     return m_albumTitle;
215 }
216 
albumYear() const217 int Mp3tunesLockerTrack::albumYear() const
218 {
219     return m_albumYear;
220 }
221 
artistName() const222 QString Mp3tunesLockerTrack::artistName() const
223 {
224     return m_artistName;
225 }
226 
artistId() const227 int Mp3tunesLockerTrack::artistId() const
228 {
229     return m_artistId;
230 }
231 ////////////////////////////////////////////////////////////////////////
232 //PLAYLIST
Mp3tunesLockerPlaylist(mp3tunes_locker_playlist_t * playlist)233 Mp3tunesLockerPlaylist::Mp3tunesLockerPlaylist(  mp3tunes_locker_playlist_t *playlist )
234 {
235     m_playlist = ( mp3tunes_locker_playlist_t * ) malloc( sizeof( *playlist ) );
236     memcpy( m_playlist, playlist, sizeof( *playlist ) );
237 
238     m_playlist->playlistId = ( char * ) malloc( strlen( playlist->playlistId ) + 1 );
239     strcpy( m_playlist->playlistId, playlist->playlistId );
240 
241     m_playlist->playlistTitle = ( char * ) malloc( strlen( playlist->playlistTitle ) + 1 );
242     strcpy( m_playlist->playlistTitle, playlist->playlistTitle );
243 
244     m_playlist->title = ( char * ) malloc( strlen( playlist->title ) + 1 );
245     strcpy( m_playlist->title, playlist->title );
246 
247     m_playlist->fileName = ( char * ) malloc( strlen( playlist->fileName ) + 1 );
248     strcpy( m_playlist->fileName, playlist->fileName );
249 }
~Mp3tunesLockerPlaylist()250 Mp3tunesLockerPlaylist::~Mp3tunesLockerPlaylist()
251 {
252     free(m_playlist->fileName);
253     free(m_playlist->title);
254     free(m_playlist->playlistTitle);
255     free(m_playlist->playlistId);
256     free(m_playlist);
257 }
258 
playlistId() const259 QString Mp3tunesLockerPlaylist::playlistId() const
260 {
261     return QString( m_playlist->playlistId );
262 }
263 
playlistTitle() const264 QString Mp3tunesLockerPlaylist::playlistTitle() const{
265     return QString( m_playlist->playlistTitle );
266 }
267 
title() const268 QString Mp3tunesLockerPlaylist::title() const
269 {
270     return QString( m_playlist->title );
271 }
272 
fileName() const273 QString Mp3tunesLockerPlaylist::fileName() const
274 {
275     return QString( m_playlist->fileName );
276 }
277 
fileCount() const278 int Mp3tunesLockerPlaylist::fileCount() const
279 {
280     return m_playlist->fileCount;
281 }
282 
playlistSize() const283 int Mp3tunesLockerPlaylist::playlistSize() const
284 {
285     return m_playlist->playlistSize;
286 }
287