43
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Metadata of song for details view - private implementation.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <QString>
|
|
20 |
#include <QPixmap>
|
|
21 |
#include <QPainter>
|
|
22 |
#include <QBuffer>
|
|
23 |
#include <QPixmap>
|
|
24 |
#include <QTime>
|
|
25 |
#include <QIcon>
|
|
26 |
#include <QFile>
|
|
27 |
#include <QRegExp>
|
|
28 |
#include <QFileInfo>
|
|
29 |
#include <QDateTime>
|
|
30 |
#include <QDate>
|
|
31 |
|
|
32 |
#include <hbicon.h>
|
|
33 |
|
|
34 |
#include <mpxmedia.h>
|
|
35 |
#include <mpxmediacontainerdefs.h>
|
|
36 |
#include <mpxmediaarray.h>
|
|
37 |
#include <mpxmediageneraldefs.h>
|
|
38 |
#include <mpxmediamusicdefs.h>
|
|
39 |
#include <mpxmediaaudiodefs.h>
|
|
40 |
#include <mpxmediadrmdefs.h>
|
|
41 |
#include <thumbnailmanager_qt.h>
|
|
42 |
|
|
43 |
#include "mpsongdata_p.h"
|
|
44 |
#include "mptrace.h"
|
|
45 |
|
|
46 |
const int KUndefined = -1;
|
|
47 |
|
|
48 |
/*!
|
|
49 |
\class MpSongDataPrivate
|
|
50 |
\brief Music Player song metadata - private implementation.
|
|
51 |
|
|
52 |
Song data provide access to song metadata.
|
|
53 |
*/
|
|
54 |
|
|
55 |
/*!
|
|
56 |
Constructs a new MpSongDataPrivate.
|
|
57 |
*/
|
|
58 |
MpSongDataPrivate::MpSongDataPrivate( MpSongData *wrapper, ThumbnailManager *thumbnailManager )
|
|
59 |
: q_ptr( wrapper ),
|
|
60 |
mThumbnailManager(thumbnailManager),
|
|
61 |
mReqId( KUndefined ),
|
|
62 |
mAlbumArt()
|
|
63 |
{
|
|
64 |
TX_ENTRY
|
45
|
65 |
mDefaultAlbumArt = new HbIcon( "qtg_large_album_art" );
|
43
|
66 |
TX_EXIT
|
|
67 |
}
|
|
68 |
|
|
69 |
/*!
|
|
70 |
Constructs a new MpSongDataPrivate.
|
|
71 |
*/
|
|
72 |
MpSongDataPrivate::~MpSongDataPrivate()
|
|
73 |
{
|
|
74 |
TX_ENTRY
|
|
75 |
removeAlbumArtFile(); // TODO Remove when base64 is working
|
|
76 |
TX_EXIT
|
|
77 |
}
|
|
78 |
|
|
79 |
/*!
|
|
80 |
Returns the song title.
|
|
81 |
*/
|
|
82 |
QString MpSongDataPrivate::title() const
|
|
83 |
{
|
|
84 |
TX_LOG
|
|
85 |
return mTitle;
|
|
86 |
}
|
|
87 |
|
|
88 |
/*!
|
|
89 |
Returns the song album.
|
|
90 |
*/
|
|
91 |
QString MpSongDataPrivate::album() const
|
|
92 |
{
|
|
93 |
TX_LOG
|
|
94 |
return mAlbum;
|
|
95 |
}
|
|
96 |
|
|
97 |
/*!
|
|
98 |
Returns the song artist.
|
|
99 |
*/
|
|
100 |
QString MpSongDataPrivate::artist() const
|
|
101 |
{
|
|
102 |
TX_LOG
|
|
103 |
return mArtist;
|
|
104 |
}
|
|
105 |
|
|
106 |
/*!
|
|
107 |
Returns the comment.
|
|
108 |
*/
|
|
109 |
QString MpSongDataPrivate::comment() const
|
|
110 |
{
|
|
111 |
TX_LOG
|
|
112 |
return mComment;
|
|
113 |
}
|
|
114 |
|
|
115 |
/*!
|
|
116 |
Returns the song album art on \a icon.
|
|
117 |
*/
|
|
118 |
void MpSongDataPrivate::albumArt( HbIcon& icon ) const
|
|
119 |
{
|
|
120 |
TX_ENTRY
|
|
121 |
if ( !mAlbumArt || mAlbumArt->isNull() ) {
|
|
122 |
TX_LOG_ARGS( "Album art is NULL." );
|
|
123 |
icon = HbIcon();
|
|
124 |
} else {
|
|
125 |
TX_LOG_ARGS( "Album art is not NULL." );
|
|
126 |
icon = *mAlbumArt ;
|
|
127 |
}
|
|
128 |
TX_EXIT
|
|
129 |
}
|
|
130 |
|
|
131 |
/*!
|
|
132 |
Returns the release date.
|
|
133 |
*/
|
|
134 |
QString MpSongDataPrivate::year() const
|
|
135 |
{
|
|
136 |
TX_LOG
|
|
137 |
return mYear;
|
|
138 |
}
|
|
139 |
|
|
140 |
/*!
|
|
141 |
Returns the song genre.
|
|
142 |
*/
|
|
143 |
QString MpSongDataPrivate::genre() const
|
|
144 |
{
|
|
145 |
TX_LOG
|
45
|
146 |
QString localizedString(mGenre);
|
|
147 |
|
|
148 |
if ( mGenre == "Acoustic" ) {
|
|
149 |
localizedString = hbTrId( "txt_mus_dblist_genre_val_acoustic" );
|
|
150 |
}
|
|
151 |
else if ( mGenre == "Alternative" ) {
|
|
152 |
localizedString = hbTrId( "txt_mus_dblist_genre_val_alternative" );
|
|
153 |
}
|
|
154 |
else if ( mGenre == "Blues" ) {
|
|
155 |
localizedString = hbTrId( "txt_mus_dblist_genre_val_blues" );
|
|
156 |
}
|
|
157 |
else if ( mGenre == "Classical" ) {
|
|
158 |
localizedString = hbTrId( "txt_mus_dblist_genre_val_classical" );
|
|
159 |
}
|
|
160 |
else if ( mGenre == "Country" ) {
|
|
161 |
localizedString = hbTrId( "txt_mus_dblist_genre_val_country" );
|
|
162 |
}
|
|
163 |
else if ( mGenre == "Dance" ) {
|
|
164 |
localizedString = hbTrId( "txt_mus_dblist_genre_val_dance" );
|
|
165 |
}
|
|
166 |
else if ( mGenre == "Easy Listening" ) {
|
|
167 |
localizedString = hbTrId( "txt_mus_dblist_genre_val_easy_listening" );
|
|
168 |
}
|
|
169 |
else if ( mGenre == "Electronic" ) {
|
|
170 |
localizedString = hbTrId( "txt_mus_dblist_genre_val_electronic" );
|
|
171 |
}
|
|
172 |
else if ( mGenre == "Folk" ) {
|
|
173 |
localizedString = hbTrId( "txt_mus_dblist_genre_val_folk" );
|
|
174 |
}
|
|
175 |
else if ( mGenre == "Hip-Hop" ) {
|
|
176 |
localizedString = hbTrId( "txt_mus_dblist_genre_val_hiphop" );
|
|
177 |
}
|
|
178 |
else if ( mGenre == "Jazz" ) {
|
|
179 |
localizedString = hbTrId( "txt_mus_dblist_genre_val_jazz" );
|
|
180 |
}
|
|
181 |
else if ( mGenre == "Latin" ) {
|
|
182 |
localizedString = hbTrId( "txt_mus_dblist_genre_val_latin" );
|
|
183 |
}
|
|
184 |
else if ( mGenre == "Metal" ) {
|
|
185 |
localizedString = hbTrId( "txt_mus_dblist_genre_val_metal" );
|
|
186 |
}
|
|
187 |
else if ( mGenre == "New Age" ) {
|
|
188 |
localizedString = hbTrId( "txt_mus_dblist_genre_val_new_age" );
|
|
189 |
}
|
|
190 |
else if ( mGenre == "Other" ) {
|
|
191 |
localizedString = hbTrId( "txt_mus_dblist_genre_val_other" );
|
|
192 |
}
|
|
193 |
else if ( mGenre == "Pop" ) {
|
|
194 |
localizedString = hbTrId( "txt_mus_dblist_genre_val_pop" );
|
|
195 |
}
|
|
196 |
else if ( mGenre == "R&B" ) {
|
|
197 |
localizedString = hbTrId( "txt_mus_dblist_genre_val_rb" );
|
|
198 |
}
|
|
199 |
else if ( mGenre == "Rap" ) {
|
|
200 |
localizedString = hbTrId( "txt_mus_dblist_genre_val_rap" );
|
|
201 |
}
|
|
202 |
else if ( mGenre == "Reggae" ) {
|
|
203 |
localizedString = hbTrId( "txt_mus_dblist_genre_val_reggae" );
|
|
204 |
}
|
|
205 |
else if ( mGenre == "Rock" ) {
|
|
206 |
localizedString = hbTrId( "txt_mus_dblist_genre_val_rock" );
|
|
207 |
}
|
|
208 |
else if ( mGenre == "Soundtrack" ) {
|
|
209 |
localizedString = hbTrId( "txt_mus_dblist_genre_val_soundtrack" );
|
|
210 |
}
|
|
211 |
else if ( mGenre == "Spoken" ) {
|
|
212 |
localizedString = hbTrId( "txt_mus_dblist_genre_val_spoken" );
|
|
213 |
}
|
|
214 |
else if ( mGenre == "World" ) {
|
|
215 |
localizedString = hbTrId( "txt_mus_dblist_genre_val_world" );
|
|
216 |
}
|
|
217 |
TX_EXIT_ARGS( "Logical String = " << localizedString );
|
|
218 |
return localizedString;
|
43
|
219 |
}
|
|
220 |
|
|
221 |
/*!
|
|
222 |
Returns the song composer.
|
|
223 |
*/
|
|
224 |
QString MpSongDataPrivate::composer() const
|
|
225 |
{
|
|
226 |
TX_LOG
|
|
227 |
return mComposer;
|
|
228 |
}
|
|
229 |
|
|
230 |
/*!
|
|
231 |
Returns the album track.
|
|
232 |
*/
|
|
233 |
QString MpSongDataPrivate::albumTrack() const
|
|
234 |
{
|
|
235 |
TX_LOG
|
|
236 |
return mAlbumTrack;
|
|
237 |
}
|
|
238 |
|
|
239 |
/*!
|
|
240 |
Returns link
|
|
241 |
*/
|
|
242 |
QString MpSongDataPrivate::link() const
|
|
243 |
{
|
|
244 |
TX_LOG
|
|
245 |
return mLink;
|
|
246 |
}
|
|
247 |
|
|
248 |
/*!
|
|
249 |
Returns the file name
|
|
250 |
*/
|
|
251 |
QString MpSongDataPrivate::fileName() const
|
|
252 |
{
|
|
253 |
TX_LOG
|
|
254 |
return mFileName;
|
|
255 |
}
|
|
256 |
|
|
257 |
/*!
|
|
258 |
Returns the MIME type
|
|
259 |
*/
|
|
260 |
QString MpSongDataPrivate::mimeType() const
|
|
261 |
{
|
|
262 |
TX_LOG
|
|
263 |
return mMimeType;
|
|
264 |
}
|
|
265 |
|
|
266 |
/*!
|
|
267 |
Returns the duration
|
|
268 |
*/
|
|
269 |
QString MpSongDataPrivate::duration() const
|
|
270 |
{
|
|
271 |
TX_LOG
|
|
272 |
return mDuration;
|
|
273 |
}
|
|
274 |
|
|
275 |
/*!
|
|
276 |
Returns the bit rate
|
|
277 |
*/
|
|
278 |
QString MpSongDataPrivate::bitRate() const
|
|
279 |
{
|
|
280 |
TX_LOG
|
|
281 |
return mBitRate;
|
|
282 |
}
|
|
283 |
|
|
284 |
/*!
|
|
285 |
Returns the sampling rate
|
|
286 |
*/
|
|
287 |
QString MpSongDataPrivate::sampleRate() const
|
|
288 |
{
|
|
289 |
TX_LOG
|
|
290 |
return mSampleRate;
|
|
291 |
}
|
|
292 |
|
|
293 |
/*!
|
|
294 |
Returns the size
|
|
295 |
*/
|
|
296 |
QString MpSongDataPrivate::size() const
|
|
297 |
{
|
|
298 |
TX_LOG
|
|
299 |
return mSize;
|
|
300 |
}
|
|
301 |
|
|
302 |
/*!
|
|
303 |
Returns the modified time
|
|
304 |
*/
|
|
305 |
QString MpSongDataPrivate::modified() const
|
|
306 |
{
|
|
307 |
TX_LOG
|
|
308 |
return mModified;
|
|
309 |
}
|
|
310 |
|
|
311 |
/*!
|
|
312 |
Returns the copyright
|
|
313 |
*/
|
|
314 |
QString MpSongDataPrivate::copyright() const
|
|
315 |
{
|
|
316 |
TX_LOG
|
|
317 |
return mCopyright;
|
|
318 |
}
|
|
319 |
|
|
320 |
/*!
|
|
321 |
Returns the music URL
|
|
322 |
*/
|
|
323 |
QString MpSongDataPrivate::musicURL() const
|
|
324 |
{
|
|
325 |
TX_LOG
|
|
326 |
return mMusicURL;
|
|
327 |
}
|
|
328 |
|
|
329 |
/*!
|
|
330 |
Returns whether the song is protected
|
|
331 |
*/
|
|
332 |
bool MpSongDataPrivate::isDrmProtected() const
|
|
333 |
{
|
|
334 |
TX_LOG
|
|
335 |
return mDrmProtected;
|
|
336 |
}
|
|
337 |
|
|
338 |
/*!
|
|
339 |
Retrieve the album art in base64 encoding suitable for inline HTML display for sharing player.
|
|
340 |
*/
|
|
341 |
QString MpSongDataPrivate::albumArtBase64() const
|
|
342 |
{
|
|
343 |
/*
|
|
344 |
// Converts the current album art icon to a base64 string, and return the string.
|
|
345 |
TX_LOG
|
|
346 |
if ( mAlbumArt->isNull() ) {
|
|
347 |
TX_ENTRY_ARGS( "MpSongDataPrivate: album art isNull" )
|
|
348 |
return "nullimgcraptoberemoved";
|
|
349 |
}
|
|
350 |
TX_ENTRY_ARGS("MpSongDataPrivate: album art exists");
|
|
351 |
QByteArray array;
|
|
352 |
QBuffer buffer( &array );
|
|
353 |
buffer.open( QIODevice::WriteOnly );
|
|
354 |
mAlbumArt->pixmap().save( &buffer, "PNG" ); // writes pixmap into bytes in PNG format
|
|
355 |
buffer.close();
|
|
356 |
QString result = array.toBase64().constData();
|
|
357 |
TX_ENTRY_ARGS("MpSongDataPrivate: album art base64 length: " << result.length());
|
|
358 |
return result;
|
|
359 |
*/
|
|
360 |
// TODO: this is temporary solution until base64 defect in QT is fixed.
|
|
361 |
TX_LOG
|
|
362 |
QByteArray array;
|
|
363 |
|
|
364 |
// Remove old album art in case new one cannot be written.
|
|
365 |
removeAlbumArtFile();
|
|
366 |
|
|
367 |
QString sTimeStamp = QTime::currentTime().toString( "hhmmsszzz" );
|
|
368 |
QString sTempFileLocation = QString( "e:\\album_art_%1.png" ).arg( sTimeStamp );
|
|
369 |
|
|
370 |
( ( MpSongDataPrivate* ) this )->mTempAlbumArt = sTempFileLocation;
|
|
371 |
TX_LOG_ARGS( "Create album art file " << mTempAlbumArt );
|
|
372 |
|
|
373 |
QFile file( mTempAlbumArt );
|
|
374 |
file.open( QIODevice::WriteOnly );
|
|
375 |
if ( mAlbumArt && !mAlbumArt->isNull() && !mAlbumArt->qicon().isNull() )
|
|
376 |
{
|
|
377 |
QPixmap p = mAlbumArt->qicon().pixmap( QSize( 74, 74 ), QIcon::Normal, QIcon::Off );
|
|
378 |
p.save( &file, "PNG" );
|
|
379 |
//mAlbumArt->pixmap().save( &file, "PNG" ); // writes pixmap into bytes in PNG format
|
|
380 |
}
|
|
381 |
file.close();
|
|
382 |
return mTempAlbumArt;
|
|
383 |
}
|
|
384 |
|
|
385 |
/*!
|
|
386 |
Delete temporary album art file.
|
|
387 |
*/
|
|
388 |
void MpSongDataPrivate::removeAlbumArtFile() const
|
|
389 |
{
|
|
390 |
TX_ENTRY
|
|
391 |
if ( !mTempAlbumArt.isEmpty() )
|
|
392 |
{
|
|
393 |
TX_LOG_ARGS( "Remove album art file " << mTempAlbumArt );
|
|
394 |
QFile::remove( mTempAlbumArt );
|
|
395 |
( ( MpSongDataPrivate* ) this )->mTempAlbumArt = "";
|
|
396 |
}
|
|
397 |
else
|
|
398 |
{
|
|
399 |
TX_LOG_ARGS( "Album art filename is empty" );
|
|
400 |
}
|
|
401 |
TX_EXIT
|
|
402 |
}
|
|
403 |
|
|
404 |
/*!
|
|
405 |
Sets the \a link
|
|
406 |
*/
|
|
407 |
void MpSongDataPrivate::setLink( const QString &link )
|
|
408 |
{
|
|
409 |
TX_ENTRY_ARGS( "Link =" << link )
|
|
410 |
mLink = link;
|
|
411 |
TX_EXIT
|
|
412 |
}
|
|
413 |
|
|
414 |
/*!
|
|
415 |
\internal
|
|
416 |
New data from MPX collection.
|
|
417 |
*/
|
|
418 |
void MpSongDataPrivate::setMpxMedia( const CMPXMedia& aMedia )
|
|
419 |
{
|
|
420 |
TX_ENTRY
|
|
421 |
TRAPD(err, DoSetMpxMediaL(aMedia));
|
|
422 |
if ( err != KErrNone ) {
|
|
423 |
TX_LOG_ARGS("Error: " << err << "; should never get here.");
|
|
424 |
}
|
|
425 |
TX_EXIT
|
|
426 |
}
|
|
427 |
|
|
428 |
/*!
|
|
429 |
Returns the reserved length.
|
|
430 |
*/
|
|
431 |
int MpSongDataPrivate::reservedLength() const
|
|
432 |
{
|
|
433 |
return mLink.length() + mTitle.length() + mArtist.length();
|
|
434 |
}
|
|
435 |
|
|
436 |
/*!
|
|
437 |
Handles the album art thumbnail.
|
|
438 |
*/
|
|
439 |
void MpSongDataPrivate::thumbnailReady( QPixmap pixmap, void *data, int id, int error )
|
|
440 |
{
|
|
441 |
TX_ENTRY
|
|
442 |
Q_UNUSED( data );
|
|
443 |
if ( error == 0 && mReqId == id ) {
|
|
444 |
QIcon qicon;
|
|
445 |
QPixmap mCompositePixmap;
|
|
446 |
mReqId = KUndefined;
|
|
447 |
|
|
448 |
mCompositePixmap = QPixmap( 360, 360 );
|
|
449 |
mCompositePixmap.fill( Qt::transparent );
|
|
450 |
QPainter painter(&mCompositePixmap);
|
|
451 |
painter.setCompositionMode(QPainter::CompositionMode_Clear);
|
|
452 |
painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
|
|
453 |
painter.fillRect(mCompositePixmap.rect(), Qt::transparent);
|
|
454 |
painter.drawPixmap(QRect(0, 0,360,360), pixmap);
|
|
455 |
|
|
456 |
if ( !mCompositePixmap.isNull() ) {
|
|
457 |
qicon = QIcon( mCompositePixmap );
|
|
458 |
}
|
|
459 |
else {
|
|
460 |
qicon = QIcon( pixmap );
|
|
461 |
}
|
|
462 |
|
|
463 |
if ( mAlbumArt == mDefaultAlbumArt ) {
|
|
464 |
TX_LOG_ARGS( "Album art is default album art." )
|
|
465 |
delete mAlbumArt;
|
|
466 |
mAlbumArt = new HbIcon(qicon);
|
45
|
467 |
mDefaultAlbumArt = new HbIcon( "qtg_large_album_art" );
|
43
|
468 |
} else {
|
|
469 |
TX_LOG_ARGS( "Album art is NOT default album art." )
|
|
470 |
delete mAlbumArt;
|
|
471 |
mAlbumArt = new HbIcon(qicon);
|
|
472 |
}
|
|
473 |
|
|
474 |
emit q_ptr->albumArtReady();
|
|
475 |
}
|
|
476 |
else {
|
|
477 |
mReqId = KUndefined;
|
|
478 |
mAlbumArt = mDefaultAlbumArt;
|
|
479 |
emit q_ptr->albumArtReady();
|
|
480 |
}
|
|
481 |
|
|
482 |
TX_EXIT
|
|
483 |
}
|
|
484 |
|
|
485 |
/*!
|
|
486 |
\internal
|
|
487 |
*/
|
|
488 |
void MpSongDataPrivate::DoSetMpxMediaL( const CMPXMedia& aMedia )
|
|
489 |
{
|
|
490 |
TX_ENTRY
|
|
491 |
bool changed = false;
|
|
492 |
if ( aMedia.IsSupported( KMPXMediaGeneralTitle ) ) {
|
|
493 |
changed |= setTitle(
|
|
494 |
QString::fromUtf16(
|
|
495 |
aMedia.ValueText( KMPXMediaGeneralTitle ).Ptr(),
|
|
496 |
aMedia.ValueText( KMPXMediaGeneralTitle ).Length() ) );
|
|
497 |
} else {
|
|
498 |
changed |= setTitle( QString() );
|
|
499 |
}
|
|
500 |
|
|
501 |
if ( aMedia.IsSupported( KMPXMediaMusicArtist ) ) {
|
|
502 |
changed |= setArtist(
|
|
503 |
QString::fromUtf16(
|
|
504 |
aMedia.ValueText( KMPXMediaMusicArtist ).Ptr(),
|
|
505 |
aMedia.ValueText( KMPXMediaMusicArtist ).Length() ) );
|
|
506 |
} else {
|
|
507 |
changed |= setArtist( QString() );
|
|
508 |
}
|
|
509 |
|
|
510 |
if ( aMedia.IsSupported( KMPXMediaMusicAlbum ) ) {
|
|
511 |
changed |= setAlbum(
|
|
512 |
QString::fromUtf16(
|
|
513 |
aMedia.ValueText( KMPXMediaMusicAlbum ).Ptr(),
|
|
514 |
aMedia.ValueText( KMPXMediaMusicAlbum ).Length() ) );
|
|
515 |
} else {
|
|
516 |
changed |= setAlbum( QString() );
|
|
517 |
}
|
|
518 |
if ( changed ) {
|
|
519 |
emit q_ptr->playbackInfoChanged();
|
|
520 |
}
|
|
521 |
|
|
522 |
// call back will be called when Album art is retrieved
|
|
523 |
if ( aMedia.IsSupported( TMPXAttribute( KMPXMediaMusicAlbumArtFileName ) ) ) {
|
|
524 |
setAlbumArtUri(
|
|
525 |
QString::fromUtf16(
|
|
526 |
aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Ptr(),
|
|
527 |
aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Length() ) );
|
|
528 |
} else {
|
|
529 |
setAlbumArtUri( QString() );
|
|
530 |
}
|
|
531 |
|
|
532 |
// all following will be for song details
|
|
533 |
changed = false;
|
|
534 |
if ( aMedia.IsSupported( TMPXAttribute( KMPXMediaGeneralUri ) ) ) {
|
|
535 |
QString fullName = QString::fromUtf16(
|
|
536 |
aMedia.ValueText( KMPXMediaGeneralUri ).Ptr(),
|
|
537 |
aMedia.ValueText( KMPXMediaGeneralUri ).Length() );
|
|
538 |
|
|
539 |
TX_LOG_ARGS( "File name with path: " << fullName );
|
|
540 |
// get size & last modifed information from file system
|
|
541 |
QFileInfo info( fullName );
|
|
542 |
changed |= setSize( info.size() );
|
|
543 |
|
|
544 |
QDateTime lastModified = info.lastModified();
|
|
545 |
QDate date = lastModified.date();
|
|
546 |
int day = date.day();
|
|
547 |
int month = date.month();
|
|
548 |
int year = date.year();
|
|
549 |
QTime time = lastModified.time();
|
|
550 |
int sec = time.second();
|
|
551 |
int min = time.minute();
|
|
552 |
int hr = time.hour();
|
|
553 |
|
|
554 |
QString lastModifiedStr("%1.%2.%3 %4:%5:%6");
|
|
555 |
lastModifiedStr = lastModifiedStr.arg( day ).arg( month ).arg( year ).arg( hr ).arg( min ).arg( sec );
|
|
556 |
changed |= setModified( lastModifiedStr );
|
|
557 |
|
|
558 |
|
|
559 |
// get file name without suffix
|
|
560 |
QString file;
|
|
561 |
QRegExp rx("(.+)\\..+");
|
|
562 |
QString str = info.fileName();
|
|
563 |
TX_LOG_ARGS( "File name with suffix = " << str );
|
|
564 |
|
|
565 |
int pos = rx.indexIn( str );
|
|
566 |
if( pos > -1 ) {
|
|
567 |
file = rx.cap( 1 );
|
|
568 |
TX_LOG_ARGS( "File = " << file );
|
|
569 |
}
|
|
570 |
|
|
571 |
changed |= setFileName( file );
|
|
572 |
} else {
|
|
573 |
changed |= setFileName( QString() );
|
|
574 |
}
|
|
575 |
|
|
576 |
if ( aMedia.IsSupported( TMPXAttribute( KMPXMediaMusicComposer ) ) ) {
|
|
577 |
TX_LOG_ARGS( "Composer is supported " );
|
|
578 |
changed |= setComposer(
|
|
579 |
QString::fromUtf16(
|
|
580 |
aMedia.ValueText( KMPXMediaMusicComposer ).Ptr(),
|
|
581 |
aMedia.ValueText( KMPXMediaMusicComposer ).Length() ) );
|
|
582 |
} else {
|
|
583 |
changed |= setComposer( QString() );
|
|
584 |
}
|
|
585 |
|
|
586 |
if ( aMedia.IsSupported( TMPXAttribute( KMPXMediaMusicYear ) ) ) {
|
|
587 |
TInt64 yearInMicroSeconds = aMedia.ValueTObjectL<TInt64>( KMPXMediaMusicYear );
|
|
588 |
TX_LOG_ARGS( "year = " << yearInMicroSeconds );
|
|
589 |
TTime yearTime( yearInMicroSeconds );
|
|
590 |
changed |= setYear( yearTime.DateTime().Year() );
|
|
591 |
} else {
|
|
592 |
// to clear previous result
|
|
593 |
changed |= setYear( -1 );
|
|
594 |
}
|
|
595 |
|
|
596 |
if ( aMedia.IsSupported( TMPXAttribute( KMPXMediaMusicAlbumTrack ) ) ) {
|
|
597 |
changed |= setAlbumTrack(
|
|
598 |
QString::fromUtf16(
|
|
599 |
aMedia.ValueText( KMPXMediaMusicAlbumTrack ).Ptr(),
|
|
600 |
aMedia.ValueText( KMPXMediaMusicAlbumTrack ).Length() ) );
|
|
601 |
} else {
|
|
602 |
changed |= setAlbumTrack( QString() );
|
|
603 |
}
|
|
604 |
|
|
605 |
if ( aMedia.IsSupported( TMPXAttribute( KMPXMediaMusicGenre ) ) ) {
|
|
606 |
changed |= setGenre(
|
|
607 |
QString::fromUtf16(
|
|
608 |
aMedia.ValueText( KMPXMediaMusicGenre ).Ptr(),
|
|
609 |
aMedia.ValueText( KMPXMediaMusicGenre ).Length() ) );
|
|
610 |
} else {
|
|
611 |
changed |= setGenre( QString() );
|
|
612 |
}
|
|
613 |
|
|
614 |
if ( aMedia.IsSupported( TMPXAttribute( KMPXMediaGeneralMimeType ) ) ) {
|
|
615 |
QString type = QString::fromUtf16(
|
|
616 |
aMedia.ValueText( KMPXMediaGeneralMimeType ).Ptr(),
|
|
617 |
aMedia.ValueText( KMPXMediaGeneralMimeType ).Length() );
|
|
618 |
QString regularExpression(".+/(.+)");
|
|
619 |
QRegExp rx(regularExpression);
|
|
620 |
QString mimeType;
|
|
621 |
|
|
622 |
int pos = rx.indexIn( type );
|
|
623 |
if( pos > -1 ) {
|
|
624 |
mimeType = rx.cap( 1 );
|
|
625 |
mimeType = mimeType.toUpper();
|
|
626 |
TX_LOG_ARGS( "MIME type =" << mimeType );
|
|
627 |
}
|
|
628 |
|
|
629 |
changed |= setMimeType( mimeType );
|
|
630 |
} else {
|
|
631 |
changed |= setMimeType( QString() );
|
|
632 |
}
|
|
633 |
|
|
634 |
if ( aMedia.IsSupported( TMPXAttribute( KMPXMediaGeneralDuration ) ) ) {
|
|
635 |
TInt duration( aMedia.ValueTObjectL<TInt>( KMPXMediaGeneralDuration ) );
|
|
636 |
changed |= setDuration( duration / 1000 );
|
|
637 |
} else {
|
|
638 |
changed |= setDuration( -1 );
|
|
639 |
}
|
|
640 |
|
|
641 |
if ( aMedia.IsSupported( TMPXAttribute( KMPXMediaAudioBitrate ) ) ) {
|
|
642 |
TInt bitRate( aMedia.ValueTObjectL<TInt>( KMPXMediaAudioBitrate ) );
|
|
643 |
changed |= setBitRate( bitRate );
|
|
644 |
} else {
|
|
645 |
changed |= setBitRate( -1 );
|
|
646 |
}
|
|
647 |
|
|
648 |
if ( aMedia.IsSupported( TMPXAttribute( KMPXMediaAudioSamplerate ) ) ) {
|
|
649 |
TInt sampleRate( aMedia.ValueTObjectL<TInt>( KMPXMediaAudioSamplerate ) );
|
|
650 |
changed |= setSampleRate( sampleRate );
|
|
651 |
} else {
|
|
652 |
changed |= setSampleRate( -1 );
|
|
653 |
}
|
|
654 |
|
|
655 |
|
|
656 |
if ( aMedia.IsSupported( TMPXAttribute( KMPXMediaGeneralCopyright ) ) ) {
|
|
657 |
changed |= setCopyright(
|
|
658 |
QString::fromUtf16(
|
|
659 |
aMedia.ValueText( KMPXMediaGeneralCopyright ).Ptr(),
|
|
660 |
aMedia.ValueText( KMPXMediaGeneralCopyright ).Length() ) );
|
|
661 |
} else {
|
|
662 |
changed |= setCopyright( QString() );
|
|
663 |
}
|
|
664 |
|
|
665 |
if ( aMedia.IsSupported( TMPXAttribute( KMPXMediaMusicURL ) ) ) {
|
|
666 |
changed |= setMusicURL(
|
|
667 |
QString::fromUtf16(
|
|
668 |
aMedia.ValueText( KMPXMediaMusicURL ).Ptr(),
|
|
669 |
aMedia.ValueText( KMPXMediaMusicURL ).Length() ) );
|
|
670 |
} else {
|
|
671 |
changed |= setMusicURL( QString() );
|
|
672 |
}
|
|
673 |
|
|
674 |
if ( aMedia.IsSupported( TMPXAttribute( KMPXMediaDrmProtected ) ) ) {
|
|
675 |
TX_LOG_ARGS( "DRM is supported." );
|
|
676 |
changed |= setDrmProtected( aMedia.ValueTObjectL<TBool>( KMPXMediaDrmProtected ) );
|
|
677 |
} else {
|
|
678 |
changed |= setDrmProtected( false );
|
|
679 |
}
|
|
680 |
|
|
681 |
if ( changed ) {
|
|
682 |
emit q_ptr->songDetailInfoChanged();
|
|
683 |
}
|
|
684 |
TX_EXIT
|
|
685 |
}
|
|
686 |
|
|
687 |
/*!
|
|
688 |
Sets the song \a title, returns true if the value is new.
|
|
689 |
*/
|
|
690 |
bool MpSongDataPrivate::setTitle( const QString &title )
|
|
691 |
{
|
|
692 |
TX_ENTRY_ARGS( "title =" << title )
|
|
693 |
bool change = false;
|
|
694 |
if ( title != mTitle ) {
|
|
695 |
change = true;
|
|
696 |
mTitle = title;
|
|
697 |
}
|
|
698 |
TX_EXIT
|
|
699 |
return change;
|
|
700 |
}
|
|
701 |
|
|
702 |
/*!
|
|
703 |
Sets the song \a album, returns true if the value is new.
|
|
704 |
*/
|
|
705 |
bool MpSongDataPrivate::setAlbum( const QString &album )
|
|
706 |
{
|
|
707 |
TX_ENTRY_ARGS( "album =" << album )
|
|
708 |
bool change = false;
|
|
709 |
if ( album != mAlbum ) {
|
|
710 |
change = true;
|
|
711 |
mAlbum = album;
|
|
712 |
}
|
|
713 |
TX_EXIT
|
|
714 |
return change;
|
|
715 |
}
|
|
716 |
|
|
717 |
/*!
|
|
718 |
Sets the song \a artist, returns true if the value is new.
|
|
719 |
*/
|
|
720 |
bool MpSongDataPrivate::setArtist( const QString &artist )
|
|
721 |
{
|
|
722 |
TX_ENTRY_ARGS( "artist =" << artist )
|
|
723 |
bool change = false;
|
|
724 |
if ( artist != mArtist ) {
|
|
725 |
change = true;
|
|
726 |
mArtist = artist;
|
|
727 |
}
|
|
728 |
TX_EXIT
|
|
729 |
return change;
|
|
730 |
}
|
|
731 |
|
|
732 |
/*!
|
|
733 |
Sets the song \a comment, returns true if the value is new.
|
|
734 |
*/
|
|
735 |
bool MpSongDataPrivate::setComment( const QString &comment)
|
|
736 |
{
|
|
737 |
TX_ENTRY_ARGS( "comment =" << comment )
|
|
738 |
bool change = false;
|
|
739 |
if ( comment != mComment ) {
|
|
740 |
change = true;
|
|
741 |
mComment = comment;
|
|
742 |
}
|
|
743 |
TX_EXIT
|
|
744 |
return change;
|
|
745 |
}
|
|
746 |
|
|
747 |
/*!
|
|
748 |
Sets the song \a composer, returns true if the value is new.
|
|
749 |
*/
|
|
750 |
bool MpSongDataPrivate::setComposer( const QString &composer )
|
|
751 |
{
|
|
752 |
TX_ENTRY_ARGS( "composer =" << composer )
|
|
753 |
bool change = false;
|
|
754 |
if ( composer != mComposer ) {
|
|
755 |
change = true;
|
|
756 |
mComposer = composer;
|
|
757 |
}
|
|
758 |
TX_EXIT
|
|
759 |
return change;
|
|
760 |
}
|
|
761 |
|
|
762 |
/*!
|
|
763 |
Sets the song \a genre, returns true if the value is new.
|
|
764 |
*/
|
|
765 |
bool MpSongDataPrivate::setGenre( const QString &genre )
|
|
766 |
{
|
|
767 |
TX_ENTRY_ARGS( "genre =" << genre )
|
|
768 |
bool change = false;
|
|
769 |
if ( genre != mGenre ) {
|
|
770 |
change = true;
|
|
771 |
mGenre = genre;
|
|
772 |
}
|
|
773 |
TX_EXIT
|
|
774 |
return change;
|
|
775 |
}
|
|
776 |
|
|
777 |
/*!
|
|
778 |
Sets the song \a date, returns true if the value is new.
|
|
779 |
*/
|
|
780 |
bool MpSongDataPrivate::setYear( int year )
|
|
781 |
{
|
|
782 |
TX_ENTRY_ARGS( "year =" << year )
|
|
783 |
bool change = false;
|
|
784 |
if ( QString::number(year) != mYear ) {
|
|
785 |
change = true;
|
|
786 |
if ( year >= 0 && year < 9999 ) {
|
|
787 |
mYear = QString::number(year);
|
|
788 |
} else {
|
|
789 |
mYear = QString();
|
|
790 |
}
|
|
791 |
}
|
|
792 |
TX_EXIT
|
|
793 |
return change;
|
|
794 |
}
|
|
795 |
|
|
796 |
/*!
|
|
797 |
Sets the \a album track, returns true if the value is new.
|
|
798 |
*/
|
|
799 |
bool MpSongDataPrivate::setAlbumTrack( const QString &track )
|
|
800 |
{
|
|
801 |
TX_ENTRY_ARGS( "track =" << track )
|
|
802 |
bool change = false;
|
|
803 |
if ( track != mAlbumTrack ) {
|
|
804 |
change = true;
|
|
805 |
mAlbumTrack = track;
|
|
806 |
}
|
|
807 |
TX_EXIT
|
|
808 |
return change;
|
|
809 |
}
|
|
810 |
|
|
811 |
/*!
|
|
812 |
Sets the song \a albumArtUri.
|
|
813 |
*/
|
|
814 |
void MpSongDataPrivate::setAlbumArtUri( const QString &albumArtUri)
|
|
815 |
{
|
|
816 |
TX_ENTRY_ARGS( "albumArtUri = " << albumArtUri )
|
|
817 |
if ( !albumArtUri.isEmpty() ) {
|
|
818 |
TX_LOG_ARGS( "There is album art" );
|
|
819 |
bool ok = true;
|
|
820 |
if ( mReqId != KUndefined ) {
|
|
821 |
// There is already an outstanding request. Cancel it first.
|
|
822 |
bool ok = mThumbnailManager->cancelRequest( mReqId );
|
|
823 |
}
|
|
824 |
if ( ok ) {
|
|
825 |
mReqId = mThumbnailManager->getThumbnail( albumArtUri );
|
|
826 |
if ( mReqId == KUndefined ) {
|
|
827 |
// Request failed. Set default album art.
|
|
828 |
mAlbumArt = mDefaultAlbumArt;
|
|
829 |
emit q_ptr->albumArtReady();
|
|
830 |
}
|
|
831 |
}
|
|
832 |
}
|
|
833 |
else {
|
|
834 |
// No album art uri. Set default album art.
|
|
835 |
TX_LOG_ARGS( "There is No album art" );
|
|
836 |
mAlbumArt = mDefaultAlbumArt;
|
|
837 |
emit q_ptr->albumArtReady();
|
|
838 |
}
|
|
839 |
TX_EXIT
|
|
840 |
}
|
|
841 |
|
|
842 |
/*!
|
|
843 |
Sets the \a file name
|
|
844 |
*/
|
|
845 |
bool MpSongDataPrivate::setFileName( const QString &fileName )
|
|
846 |
{
|
|
847 |
TX_ENTRY_ARGS( "File name =" << fileName )
|
|
848 |
bool change = false;
|
|
849 |
if ( fileName != mFileName ) {
|
|
850 |
change = true;
|
|
851 |
mFileName = fileName;
|
|
852 |
}
|
|
853 |
TX_EXIT
|
|
854 |
return change;
|
|
855 |
}
|
|
856 |
|
|
857 |
/*!
|
|
858 |
Sets the \a MIME type
|
|
859 |
*/
|
|
860 |
bool MpSongDataPrivate::setMimeType( const QString &mimeType )
|
|
861 |
{
|
|
862 |
TX_ENTRY_ARGS( "Mime =" << mimeType )
|
|
863 |
bool change = false;
|
|
864 |
if ( mimeType != mMimeType ) {
|
|
865 |
change = true;
|
|
866 |
mMimeType = mimeType;
|
|
867 |
}
|
|
868 |
TX_EXIT
|
|
869 |
return change;
|
|
870 |
}
|
|
871 |
|
|
872 |
/*!
|
|
873 |
Sets the \a duration
|
|
874 |
*/
|
|
875 |
bool MpSongDataPrivate::setDuration( int duration )
|
|
876 |
{
|
|
877 |
TX_ENTRY_ARGS( "Duration =" << duration )
|
|
878 |
bool change = false;
|
|
879 |
QString timeFormatOne("%1:%2:%3");
|
|
880 |
QString timeFormatTwo("%1:%2");
|
|
881 |
if ( QString::number( duration ) != mDuration ) {
|
|
882 |
change = true;
|
|
883 |
if ( duration >= 3600 ) {
|
|
884 |
// more than one hours
|
|
885 |
QString hourStr, minStr, secStr;
|
|
886 |
int hour = duration / 3600;
|
|
887 |
int min = duration % 3600 / 60;
|
|
888 |
int sec = duration % 3600 % 60;
|
|
889 |
|
|
890 |
hourStr = hour >= 10 ? QString::number( hour ) : QString::number( hour ).prepend( "0" );
|
|
891 |
minStr = min >= 10 ? QString::number( min ) : QString::number( min ).prepend( "0" );
|
|
892 |
secStr = sec >= 10 ? QString::number( sec ) : QString::number( sec ).prepend( "0" );
|
|
893 |
mDuration = timeFormatOne.arg( hourStr ).arg( minStr ).arg( secStr );
|
|
894 |
} else if ( duration >= 60 && duration < 3600 ) {
|
|
895 |
// more than one min && less than one hour
|
|
896 |
QString minStr, secStr;
|
|
897 |
int min = duration / 60;
|
|
898 |
int sec = duration % 60;
|
|
899 |
|
|
900 |
minStr = min >= 10 ? QString::number( min ) : QString::number( min ).prepend( "0" );
|
|
901 |
secStr = sec >= 10 ? QString::number( sec ) : QString::number( sec ).prepend( "0" );
|
|
902 |
mDuration = timeFormatTwo.arg( minStr ).arg( secStr );
|
|
903 |
} else if ( duration > 0 && duration < 60 ) {
|
|
904 |
QString secStr;
|
|
905 |
secStr = duration >= 10 ? QString::number( duration ) : QString::number( duration ).prepend( "0" );
|
|
906 |
mDuration = secStr;
|
|
907 |
} else {
|
|
908 |
mDuration = QString();
|
|
909 |
}
|
|
910 |
}
|
|
911 |
TX_EXIT
|
|
912 |
return change;
|
|
913 |
}
|
|
914 |
|
|
915 |
/*!
|
|
916 |
Sets bit rate
|
|
917 |
*/
|
|
918 |
bool MpSongDataPrivate::setBitRate( int bitRate)
|
|
919 |
{
|
|
920 |
TX_ENTRY_ARGS( "Bit rate =" << bitRate )
|
|
921 |
bool change = false;
|
|
922 |
if ( QString::number( bitRate ) != mBitRate ) {
|
|
923 |
change = true;
|
|
924 |
if ( bitRate > 0 ) {
|
|
925 |
mBitRate = QString::number( bitRate / 1000 );
|
|
926 |
} else {
|
|
927 |
mBitRate = QString();
|
|
928 |
}
|
|
929 |
}
|
|
930 |
TX_EXIT
|
|
931 |
return change;
|
|
932 |
}
|
|
933 |
|
|
934 |
/*!
|
|
935 |
Sets sample rate
|
|
936 |
*/
|
|
937 |
bool MpSongDataPrivate::setSampleRate( int sampleRate )
|
|
938 |
{
|
|
939 |
TX_ENTRY_ARGS( "Sample rate =" << sampleRate )
|
|
940 |
bool change = false;
|
|
941 |
if ( QString::number( sampleRate ) != mSampleRate ) {
|
|
942 |
change = true;
|
|
943 |
if ( sampleRate > 0 ) {
|
|
944 |
mSampleRate = QString::number( sampleRate );
|
|
945 |
} else {
|
|
946 |
mSampleRate = QString();
|
|
947 |
}
|
|
948 |
}
|
|
949 |
TX_EXIT
|
|
950 |
return change;
|
|
951 |
}
|
|
952 |
|
|
953 |
/*!
|
|
954 |
Sets the \a size
|
|
955 |
*/
|
|
956 |
bool MpSongDataPrivate::setSize( int size )
|
|
957 |
{
|
|
958 |
TX_ENTRY_ARGS( "Size =" << size )
|
|
959 |
bool change = false;
|
|
960 |
if ( QString::number( size ) != mSize ) {
|
|
961 |
change = true;
|
45
|
962 |
mSize = QString::number( size ); // in bytes
|
43
|
963 |
}
|
|
964 |
TX_EXIT
|
|
965 |
return change;
|
|
966 |
}
|
|
967 |
|
|
968 |
/*!
|
|
969 |
Sets the \a modification information
|
|
970 |
*/
|
|
971 |
bool MpSongDataPrivate::setModified( const QString &modified )
|
|
972 |
{
|
|
973 |
TX_ENTRY_ARGS( "Modified =" << modified )
|
|
974 |
bool change = false;
|
|
975 |
if ( modified != mModified ) {
|
|
976 |
change = true;
|
|
977 |
mModified = modified;
|
|
978 |
}
|
|
979 |
TX_EXIT
|
|
980 |
return change;
|
|
981 |
}
|
|
982 |
|
|
983 |
/*!
|
|
984 |
Sets the \a copyright information
|
|
985 |
*/
|
|
986 |
bool MpSongDataPrivate::setCopyright( const QString ©right )
|
|
987 |
{
|
|
988 |
TX_ENTRY_ARGS( "Copyright =" << copyright )
|
|
989 |
bool change = false;
|
|
990 |
if ( copyright != mCopyright ) {
|
|
991 |
change = true;
|
|
992 |
mCopyright = copyright;
|
|
993 |
}
|
|
994 |
TX_EXIT
|
|
995 |
return change;
|
|
996 |
}
|
|
997 |
|
|
998 |
/*!
|
|
999 |
Sets the \a music URL
|
|
1000 |
*/
|
|
1001 |
bool MpSongDataPrivate::setMusicURL( const QString &musicURL )
|
|
1002 |
{
|
|
1003 |
TX_ENTRY_ARGS( "Music URL =" << musicURL )
|
|
1004 |
bool change = false;
|
|
1005 |
if ( musicURL != mMusicURL ) {
|
|
1006 |
change = true;
|
|
1007 |
mMusicURL = musicURL;
|
|
1008 |
}
|
|
1009 |
TX_EXIT
|
|
1010 |
return change;
|
|
1011 |
}
|
|
1012 |
|
|
1013 |
/*!
|
|
1014 |
Set whether the song is DRM protected
|
|
1015 |
*/
|
|
1016 |
bool MpSongDataPrivate::setDrmProtected( bool drmProtected )
|
|
1017 |
{
|
|
1018 |
TX_ENTRY_ARGS( "DRM protected =" << drmProtected )
|
|
1019 |
bool change = false;
|
|
1020 |
if ( drmProtected != mDrmProtected ) {
|
|
1021 |
change = true;
|
|
1022 |
mDrmProtected = drmProtected;
|
|
1023 |
}
|
|
1024 |
TX_EXIT
|
|
1025 |
return change;
|
|
1026 |
}
|
|
1027 |
|