|
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: Wrapper for mpx collection framework utilities - private implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <QStringList> |
|
19 #include <QRegExp> |
|
20 #include <QFileInfo> |
|
21 #include <QDateTime> |
|
22 #include <QTime> |
|
23 #include <QDate> |
|
24 |
|
25 #include <s32strm.h> |
|
26 #include <s32mem.h> |
|
27 #include <apgcli.h> |
|
28 #include <apacmdln.h> |
|
29 |
|
30 #include <mpxplaybackutility.h> |
|
31 #include <mpxcollectionutility.h> |
|
32 #include <mpxharvesterutility.h> |
|
33 #include <mpxcollectionpath.h> |
|
34 #include <mpxcollectionmessage.h> |
|
35 #include <mpxcollectionplaylist.h> |
|
36 #include <mpxmessagecontainerdefs.h> |
|
37 #include <mpxmediacollectiondetaildefs.h> |
|
38 #include <mpxmediamusicdefs.h> |
|
39 #include <mpxmediageneraldefs.h> |
|
40 #include <mpxmediaaudiodefs.h> |
|
41 #include <mpxmediadrmdefs.h> |
|
42 #include <mpxcollectionplugin.hrh> |
|
43 #include <mpxmessagegeneraldefs.h> |
|
44 #include <mpxmediacontainerdefs.h> |
|
45 #include <mpxcollectionmessagedefs.h> |
|
46 #include <mpxparameter.h> |
|
47 #include <mpxcollectionhelperfactory.h> |
|
48 #include <mpxcollectionuihelper.h> |
|
49 #include <mpxcollectionopenutility.h> |
|
50 #include <mpxmediaarray.h> |
|
51 #include <mpxmedia.h> |
|
52 #include <mpxlog.h> |
|
53 |
|
54 #include "mpmpxcollectionframeworkwrapper_p.h" |
|
55 #include "mpmpxcollectionframeworkwrapper.h" |
|
56 #include "mpmpxcollectiondata.h" |
|
57 #include "mpcommondefs.h" |
|
58 #include "mptrace.h" |
|
59 #include "mpsettingsmanager.h" |
|
60 #include "mpsongdata.h" |
|
61 |
|
62 const TInt KIncrementalDelay = 0; |
|
63 const TInt KIncrementalFetchBlockSize = 1000; |
|
64 |
|
65 const TInt KMPXChunkSize = 100; // number of songs added in each chunk, IncAddL |
|
66 _LIT( KPlaylistPath, "C:\\Data\\Playlists\\" ); // Todo |
|
67 |
|
68 /*! |
|
69 \class MpMpxCollectionFrameworkWrapperPrivate |
|
70 \brief Wrapper for mpx framework utilities - private implementation. |
|
71 |
|
72 This is a private implementation of the mpx framework wrapper utilties interface. |
|
73 */ |
|
74 |
|
75 /*! |
|
76 \internal |
|
77 */ |
|
78 MpMpxCollectionFrameworkWrapperPrivate::MpMpxCollectionFrameworkWrapperPrivate( MpMpxCollectionFrameworkWrapper *wrapper ) |
|
79 : q_ptr( wrapper ), |
|
80 iCollectionUtility( 0 ), |
|
81 iCollectionUiHelper( 0 ), |
|
82 iIncrementalOpenUtil( 0 ), |
|
83 iIsolatedCollectionHelper( 0 ), |
|
84 iPlaybackUtility( 0 ), |
|
85 iCollectionData( 0 ), |
|
86 iIsolatedCollectionData( 0 ), |
|
87 iFirstIncrementalOpen( EFalse ), |
|
88 iUserPlaylists( 0 ), |
|
89 iRepeatFeature( ETrue ), |
|
90 iShuffleFeature( ETrue ), |
|
91 iReopen( EFalse ), |
|
92 iShuffleAll( EFalse ), |
|
93 iRestoreDefaultPath( EFalse ), |
|
94 iRestorePathIndex( 0 ), |
|
95 iSongData( 0 ) |
|
96 { |
|
97 TX_LOG |
|
98 } |
|
99 |
|
100 /*! |
|
101 \internal |
|
102 */ |
|
103 MpMpxCollectionFrameworkWrapperPrivate::~MpMpxCollectionFrameworkWrapperPrivate() |
|
104 { |
|
105 TX_ENTRY |
|
106 delete iCollectionData; |
|
107 delete iIsolatedCollectionData; |
|
108 |
|
109 if ( iCollectionUtility ) { |
|
110 iCollectionUtility->Collection().CancelRequest(); |
|
111 iCollectionUtility->Close(); |
|
112 } |
|
113 |
|
114 if ( iCollectionUiHelper ) { |
|
115 iCollectionUiHelper->Close(); |
|
116 } |
|
117 |
|
118 if ( iPlaybackUtility ) { |
|
119 iPlaybackUtility->Close(); |
|
120 } |
|
121 |
|
122 delete iIncrementalOpenUtil; |
|
123 delete iIsolatedCollectionHelper; |
|
124 delete iUserPlaylists; |
|
125 |
|
126 TX_EXIT |
|
127 } |
|
128 |
|
129 /*! |
|
130 \internal |
|
131 */ |
|
132 void MpMpxCollectionFrameworkWrapperPrivate::init( TUid hostUid, MpSongData *songData ) |
|
133 { |
|
134 TX_ENTRY |
|
135 iHostUid = hostUid; |
|
136 iSongData = songData; |
|
137 TRAPD( err, DoInitL() ); |
|
138 if ( err != KErrNone ) { |
|
139 TX_LOG_ARGS( "Error: " << err << "; should never get here." ); |
|
140 } |
|
141 TX_EXIT |
|
142 } |
|
143 |
|
144 /*! |
|
145 \internal |
|
146 */ |
|
147 void MpMpxCollectionFrameworkWrapperPrivate::openCollection( TCollectionContext context ) |
|
148 { |
|
149 TRAPD( err, DoOpenCollectionL( context ) ); |
|
150 if ( err != KErrNone ) { |
|
151 TX_LOG_ARGS( "Error: " << err << "; should never get here." ); |
|
152 } |
|
153 } |
|
154 |
|
155 /*! |
|
156 \internal |
|
157 */ |
|
158 void MpMpxCollectionFrameworkWrapperPrivate::openCollectionItem( int index ) |
|
159 { |
|
160 TRAPD( err, DoOpenCollectionItemL( index ) ); |
|
161 if ( err != KErrNone ) { |
|
162 TX_LOG_ARGS( "Error: " << err << "; should never get here." ); |
|
163 } |
|
164 } |
|
165 |
|
166 /*! |
|
167 \internal |
|
168 */ |
|
169 void MpMpxCollectionFrameworkWrapperPrivate::reopenCollection() |
|
170 { |
|
171 TRAPD( err, DoReopenCollectionL() ); |
|
172 if ( err == KErrNone ) { |
|
173 iReopen = ETrue; |
|
174 } |
|
175 else { |
|
176 TX_LOG_ARGS( "Error: " << err << "; should never get here." ); |
|
177 } |
|
178 } |
|
179 |
|
180 /*! |
|
181 \internal |
|
182 */ |
|
183 void MpMpxCollectionFrameworkWrapperPrivate::back() |
|
184 { |
|
185 TRAPD( err, DoBackL() ); |
|
186 if ( err != KErrNone ) { |
|
187 TX_LOG_ARGS( "Error: " << err << "; should never get here." ); |
|
188 } |
|
189 } |
|
190 /*! |
|
191 \internal |
|
192 */ |
|
193 void MpMpxCollectionFrameworkWrapperPrivate::findPlaylists( QStringList &playlists ) |
|
194 { |
|
195 TRAPD( err, DoFindPlaylistsL( playlists ) ); |
|
196 if ( err != KErrNone ) { |
|
197 TX_LOG_ARGS( "Error: " << err << "; should never get here." ); |
|
198 } |
|
199 } |
|
200 |
|
201 /*! |
|
202 \internal |
|
203 */ |
|
204 void MpMpxCollectionFrameworkWrapperPrivate::createPlaylist( QString &playlistName, QList<int> &selection, MpMpxCollectionData* collectionData ) |
|
205 { |
|
206 TRAPD( err, DoCreatePlaylistL( playlistName, selection, collectionData ) ); |
|
207 if ( err != KErrNone ) { |
|
208 TX_LOG_ARGS( "Error: " << err << "; should never get here." ); |
|
209 } |
|
210 } |
|
211 |
|
212 /*! |
|
213 \internal |
|
214 */ |
|
215 void MpMpxCollectionFrameworkWrapperPrivate::saveToPlaylist( int playlistIndex, QList<int> &selection ) |
|
216 { |
|
217 TRAPD( err, DoSaveToPlaylistL( playlistIndex, selection ) ); |
|
218 if ( err != KErrNone ) { |
|
219 TX_LOG_ARGS( "Error: " << err << "; should never get here." ); |
|
220 } |
|
221 } |
|
222 |
|
223 /*! |
|
224 \internal |
|
225 */ |
|
226 void MpMpxCollectionFrameworkWrapperPrivate::saveToCurrentPlaylist( QList<int> &selection, MpMpxCollectionData *collectionData ) |
|
227 { |
|
228 TRAPD( err, DoSaveToCurrentPlaylistL( selection, collectionData ) ); |
|
229 if ( err != KErrNone ) { |
|
230 TX_LOG_ARGS( "Error: " << err << "; should never get here." ); |
|
231 } |
|
232 } |
|
233 |
|
234 /*! |
|
235 \internal |
|
236 */ |
|
237 void MpMpxCollectionFrameworkWrapperPrivate::deleteSongs( QList<int> &selection ) |
|
238 { |
|
239 TCollectionContext context = iCollectionData->context(); |
|
240 int err; |
|
241 if ( context == ECollectionContextArtistAlbumsTBone |
|
242 || context == ECollectionContextAlbumsTBone ) { |
|
243 TRAP( err, DoDeleteAlbumSongsL( selection ) ); |
|
244 } |
|
245 else { |
|
246 TRAP( err, DoDeleteSongsL( selection ) ); |
|
247 } |
|
248 if ( err == KErrNone ) { |
|
249 // send signal that deleting has started. |
|
250 emit q_ptr->deleteStarted(iCollectionData->context(), selection.count()); |
|
251 } |
|
252 else{ |
|
253 TX_LOG_ARGS( "Error: " << err << "; should never get here." ); |
|
254 } |
|
255 } |
|
256 |
|
257 /*! |
|
258 \internal |
|
259 */ |
|
260 void MpMpxCollectionFrameworkWrapperPrivate::renamePlaylist( QString &newName, int index ) |
|
261 { |
|
262 TRAPD( err, DoRenamePlaylistL( newName, index ) ); |
|
263 if ( err != KErrNone ) { |
|
264 TX_LOG_ARGS( "Error: " << err << "; should never get here." ); |
|
265 } |
|
266 } |
|
267 |
|
268 /*! |
|
269 \internal |
|
270 */ |
|
271 void MpMpxCollectionFrameworkWrapperPrivate::renamePlaylist( QString &newName ) |
|
272 { |
|
273 TRAPD( err, DoRenamePlaylistL( newName ) ); |
|
274 if ( err != KErrNone ) { |
|
275 TX_LOG_ARGS( "Error: " << err << "; should never get here." ); |
|
276 } |
|
277 } |
|
278 /*! |
|
279 \internal |
|
280 */ |
|
281 void MpMpxCollectionFrameworkWrapperPrivate::setShuffle( bool active ) |
|
282 { |
|
283 TRAPD( err, DoSetShuffleL( active ) ); |
|
284 if ( err != KErrNone ) { |
|
285 TX_LOG_ARGS( "Error: " << err << "; should never get here." ); |
|
286 } |
|
287 } |
|
288 |
|
289 /*! |
|
290 \internal |
|
291 */ |
|
292 void MpMpxCollectionFrameworkWrapperPrivate::previewItem( int index ) |
|
293 { |
|
294 TCollectionContext context = iCollectionData->context(); |
|
295 int err; |
|
296 if ( context == ECollectionContextArtistAlbumsTBone |
|
297 || context == ECollectionContextAlbumsTBone ) { |
|
298 TRAP( err, DoPreviewAlbumSongL( index ) ); |
|
299 } |
|
300 else { |
|
301 TRAP( err, DoPreviewSongL( index ) ); |
|
302 } |
|
303 if ( err != KErrNone ) { |
|
304 TX_LOG_ARGS( "Error: " << err << "; should never get here." ); |
|
305 } |
|
306 } |
|
307 |
|
308 /*! |
|
309 \internal |
|
310 */ |
|
311 void MpMpxCollectionFrameworkWrapperPrivate::openIsolatedCollection( TCollectionContext context ) |
|
312 { |
|
313 TRAPD( err, DoOpenIsolatedCollectionL( context ) ); |
|
314 if ( err != KErrNone ) { |
|
315 TX_LOG_ARGS( "Error: " << err << "; should never get here." ); |
|
316 } |
|
317 } |
|
318 |
|
319 /*! |
|
320 \internal |
|
321 */ |
|
322 void MpMpxCollectionFrameworkWrapperPrivate::releaseIsolatedCollection() |
|
323 { |
|
324 delete iIsolatedCollectionHelper; |
|
325 iIsolatedCollectionHelper = 0; |
|
326 delete iIsolatedCollectionData; |
|
327 iIsolatedCollectionData = 0; |
|
328 } |
|
329 |
|
330 /*! |
|
331 \internal |
|
332 */ |
|
333 void MpMpxCollectionFrameworkWrapperPrivate::reorderPlaylist( int playlistId, int songId, int originalOrdinal, int newOrdinal ) |
|
334 { |
|
335 TRAPD( err, DoReorderPlaylistL( playlistId, songId, originalOrdinal, newOrdinal ) ); |
|
336 if ( err != KErrNone ) { |
|
337 TX_LOG_ARGS( "Error: " << err << "; should never get here." ); |
|
338 } |
|
339 } |
|
340 |
|
341 /*! |
|
342 \internal |
|
343 */ |
|
344 void MpMpxCollectionFrameworkWrapperPrivate::cancel() |
|
345 { |
|
346 iCollectionUiHelper->Cancel(); |
|
347 } |
|
348 |
|
349 /*! |
|
350 \internal |
|
351 */ |
|
352 void MpMpxCollectionFrameworkWrapperPrivate::findAlbumSongs( int index ) |
|
353 { |
|
354 TRAPD( err, DoFindAlbumSongsL( index ) ); |
|
355 if ( err != KErrNone ) { |
|
356 TX_LOG_ARGS( "Error: " << err << "; should never get here." ); |
|
357 } |
|
358 } |
|
359 |
|
360 /*! |
|
361 \internal |
|
362 */ |
|
363 void MpMpxCollectionFrameworkWrapperPrivate::playAlbumSongs( int albumIndex, int songIndex, MpMpxCollectionData* collectionData ) |
|
364 { |
|
365 TRAPD( err, DoPlayAlbumSongsL( albumIndex, songIndex, collectionData ? collectionData : iCollectionData ) ); |
|
366 if ( err != KErrNone ) { |
|
367 TX_LOG_ARGS( "Error: " << err << "; should never get here." ); |
|
368 } |
|
369 } |
|
370 |
|
371 /*! |
|
372 \internal |
|
373 */ |
|
374 MpMpxCollectionData *MpMpxCollectionFrameworkWrapperPrivate::collectionData() |
|
375 { |
|
376 return iCollectionData; |
|
377 } |
|
378 |
|
379 /*! |
|
380 \internal |
|
381 */ |
|
382 void MpMpxCollectionFrameworkWrapperPrivate::openShuffleAllSongsPath() |
|
383 { |
|
384 TX_ENTRY |
|
385 TRAPD( err, DoOpenCollectionL(ECollectionContextAllSongs) ); |
|
386 if ( err != KErrNone ) { |
|
387 TX_LOG_ARGS( "Error: " << err << "; should never get here." ); |
|
388 } |
|
389 else { |
|
390 iShuffleAll = ETrue; |
|
391 } |
|
392 TX_EXIT |
|
393 } |
|
394 |
|
395 /*! |
|
396 \internal |
|
397 */ |
|
398 void MpMpxCollectionFrameworkWrapperPrivate::retrieveSongDetails( int index ) |
|
399 { |
|
400 TX_ENTRY |
|
401 TRAPD( err, DoRetrieveSongDetailsL(index) ); |
|
402 if ( err != KErrNone ) { |
|
403 TX_LOG_ARGS( "Error: " << err << "; should never get here." ); |
|
404 } |
|
405 TX_EXIT |
|
406 } |
|
407 |
|
408 /*! |
|
409 \internal |
|
410 */ |
|
411 void MpMpxCollectionFrameworkWrapperPrivate::savePath( QByteArray &data ) |
|
412 { |
|
413 TX_ENTRY |
|
414 TRAPD( err, DoSavePathL( data ) ); |
|
415 if ( err != KErrNone ) { |
|
416 TX_LOG_ARGS( "Error: " << err << "; should never get here." ); |
|
417 } |
|
418 TX_EXIT |
|
419 |
|
420 } |
|
421 |
|
422 /*! |
|
423 \internal |
|
424 */ |
|
425 void MpMpxCollectionFrameworkWrapperPrivate::restorePath( const QByteArray &data ) |
|
426 { |
|
427 TX_ENTRY |
|
428 TRAPD( err, DoRestorePathL( data ) ); |
|
429 if ( err != KErrNone ) { |
|
430 TX_LOG_ARGS( "Error: " << err << "; should never get here." ); |
|
431 } |
|
432 TX_EXIT |
|
433 } |
|
434 |
|
435 |
|
436 /*! |
|
437 \internal |
|
438 Result of open or re-open operation to the Collection Framework. |
|
439 */ |
|
440 void MpMpxCollectionFrameworkWrapperPrivate::HandleOpenL( |
|
441 const CMPXMedia& aEntries, |
|
442 TInt aIndex, |
|
443 TBool aComplete, |
|
444 TInt aError ) |
|
445 { |
|
446 Q_UNUSED( aIndex ); |
|
447 TX_UNUSED( aComplete ); |
|
448 TX_ENTRY_ARGS( "aError=" << aError << "aComplete=" << aComplete ); |
|
449 if ( aError == KErrNone ) { |
|
450 if ( iFirstIncrementalOpen ) { |
|
451 iFirstIncrementalOpen = EFalse; |
|
452 if( iShuffleAll ) { |
|
453 iShuffleAll = EFalse; |
|
454 TX_LOG_ARGS( "Path is ready" ); |
|
455 DoPlayAllSongsPlaylistL(); |
|
456 } |
|
457 iCollectionData->setMpxMedia( aEntries, iReopen ); |
|
458 iReopen = EFalse; |
|
459 } |
|
460 else { |
|
461 iCollectionData->incrementalOpenUpdate(); |
|
462 } |
|
463 } |
|
464 else { |
|
465 TX_LOG_ARGS( "Error: " << aError << "; should never get here." ); |
|
466 } |
|
467 TX_EXIT |
|
468 } |
|
469 |
|
470 /*! |
|
471 \internal |
|
472 */ |
|
473 void MpMpxCollectionFrameworkWrapperPrivate::HandleOpenL( |
|
474 const CMPXCollectionPlaylist& aPlaylist, |
|
475 TInt aError ) |
|
476 { |
|
477 TX_ENTRY_ARGS( "aError=" << aError ); |
|
478 |
|
479 if ( aError == KErrNone ) { |
|
480 //TODO: all calls to playback utility should be done via the engine and trough the playback FW wrapper. |
|
481 createPlaybackUtilityL(); |
|
482 iPlaybackUtility->InitL( aPlaylist, ETrue ); |
|
483 emit q_ptr->collectionPlaylistOpened(); |
|
484 } |
|
485 else { |
|
486 TX_LOG_ARGS( "Error: " << aError << "; should never get here." ); |
|
487 } |
|
488 TX_EXIT |
|
489 } |
|
490 |
|
491 /*! |
|
492 \internal |
|
493 */ |
|
494 void MpMpxCollectionFrameworkWrapperPrivate::HandleCollectionMessage( |
|
495 CMPXMessage* aMsg, |
|
496 TInt aErr ) |
|
497 { |
|
498 TX_ENTRY_ARGS( "aErr=" << aErr ); |
|
499 if ( aErr == KErrNone && aMsg ) |
|
500 { |
|
501 TRAP_IGNORE( DoHandleCollectionMessageL( *aMsg ) ); |
|
502 } |
|
503 TX_EXIT |
|
504 } |
|
505 |
|
506 /*! |
|
507 \internal |
|
508 */ |
|
509 void MpMpxCollectionFrameworkWrapperPrivate::HandleCollectionMediaL( |
|
510 const CMPXMedia& aMedia, |
|
511 TInt aError ) |
|
512 { |
|
513 TX_ENTRY |
|
514 if ( KErrNone != aError ){ |
|
515 TX_LOG_ARGS( "Error: " << aError << "; should never get here." ); |
|
516 TX_EXIT |
|
517 return; |
|
518 } |
|
519 iSongData->setMpxMedia( aMedia ); |
|
520 TX_EXIT |
|
521 } |
|
522 |
|
523 /*! |
|
524 \internal |
|
525 Handles the completion of any collection helper event. |
|
526 */ |
|
527 void MpMpxCollectionFrameworkWrapperPrivate::HandleOperationCompleteL( |
|
528 TCHelperOperation aOperation, |
|
529 TInt aErr, |
|
530 void* aArgument ) |
|
531 { |
|
532 TX_ENTRY_ARGS( "aErr=" << aErr ); |
|
533 switch( aOperation ) { |
|
534 case EDeleteOp: |
|
535 emit q_ptr->songsDeleted( KErrNone == aErr ); |
|
536 break; |
|
537 case EAddOp: |
|
538 emit q_ptr->playlistSaved( KErrNone == aErr ); |
|
539 break; |
|
540 case ERenameOp: |
|
541 emit q_ptr->playlistsRenamed( KErrNone == aErr ); |
|
542 break; |
|
543 default: |
|
544 break; |
|
545 } |
|
546 |
|
547 if ( aArgument ) { |
|
548 delete ( CBase* )aArgument; |
|
549 } |
|
550 } |
|
551 |
|
552 /*! |
|
553 \internal |
|
554 */ |
|
555 void MpMpxCollectionFrameworkWrapperPrivate::HandleIsolatedOpenL( const CMPXMedia& aEntries, TInt aError ) |
|
556 { |
|
557 TX_ENTRY_ARGS( "aError=" << aError ); |
|
558 if ( aError == KErrNone ) { |
|
559 if ( iIsolatedCollectionData ) { |
|
560 delete iIsolatedCollectionData; |
|
561 iIsolatedCollectionData = 0; |
|
562 } |
|
563 iIsolatedCollectionData = new MpMpxCollectionData(); |
|
564 iIsolatedCollectionData->setMpxMedia( aEntries ); |
|
565 emit q_ptr->isolatedCollectionOpened( iIsolatedCollectionData ); |
|
566 } |
|
567 else { |
|
568 TX_LOG_ARGS( "Error: " << aError << "; should never get here." ); |
|
569 } |
|
570 TX_EXIT |
|
571 } |
|
572 |
|
573 /*! |
|
574 \internal |
|
575 */ |
|
576 void MpMpxCollectionFrameworkWrapperPrivate::HandleIsolatedOpenRestorePathL( const CMPXCollectionPath& aPath, TInt aError ) |
|
577 { |
|
578 TX_ENTRY_ARGS( "aError=" << aError ); |
|
579 if ( aError == KErrNone ) { |
|
580 CMPXCollectionPath* cpath = CMPXCollectionPath::NewL( aPath ); |
|
581 CleanupStack::PushL( cpath ); |
|
582 if ( cpath->Count() <= 0 ) { |
|
583 //There are no entries on the path |
|
584 if ( !iRestoreDefaultPath ) { |
|
585 //Try restoring default path if not already tried |
|
586 //This is a special case where a playlist's songs where on the MMC and it was removed |
|
587 iRestoreDefaultPath = ETrue; |
|
588 iRestorePathIndex = 0; |
|
589 CMPXCollectionPath* cpath = iCollectionUiHelper->MusicAllSongsPathL(); |
|
590 CleanupStack::PushL( cpath ); |
|
591 iIsolatedCollectionHelper->OpenCollectionL( *cpath, iRestorePathIndex, CMpMpxIsolatedCollectionHelper::RestorePathMode ); |
|
592 CleanupStack::PopAndDestroy( cpath ); |
|
593 } |
|
594 else { |
|
595 //emit signal to go back to collection view because there is no music |
|
596 emit q_ptr->restorePathFailed(); |
|
597 } |
|
598 } |
|
599 else if ( iRestorePathIndex ) { |
|
600 //If RestorePathIndex equals zero there is no need to check with previous index |
|
601 //just go and create playlist below |
|
602 if ( iRestorePathIndex == cpath->IndexOfId( iRestorePathIndexId ) ) { |
|
603 //Song is in path and maintains previous position |
|
604 cpath->Set( iRestorePathIndex ); |
|
605 CMPXCollectionPlaylist* playList = CMPXCollectionPlaylist::NewL( *cpath ); |
|
606 CleanupStack::PushL( playList ); |
|
607 createPlaybackUtilityL(); |
|
608 iPlaybackUtility->InitL( *playList, EFalse ); |
|
609 CleanupStack::PopAndDestroy( playList ); |
|
610 } |
|
611 else { |
|
612 //Re open path starting at the beginning of the collection |
|
613 iRestorePathIndex = 0; |
|
614 cpath->Back(); |
|
615 iIsolatedCollectionHelper->OpenCollectionL( *cpath, iRestorePathIndex, CMpMpxIsolatedCollectionHelper::RestorePathMode ); |
|
616 } |
|
617 } |
|
618 else { |
|
619 //We create a playlist right away since there is no need to check the index for the first element |
|
620 CMPXCollectionPlaylist* playList = CMPXCollectionPlaylist::NewL( *cpath ); |
|
621 CleanupStack::PushL( playList ); |
|
622 createPlaybackUtilityL(); |
|
623 iPlaybackUtility->InitL( *playList, EFalse ); |
|
624 CleanupStack::PopAndDestroy( playList ); |
|
625 } |
|
626 CleanupStack::PopAndDestroy( cpath ); |
|
627 } |
|
628 else if ( aError == KErrNotFound ) { |
|
629 //Path not found (e.g. MMC removed) try restoring default path |
|
630 iRestoreDefaultPath = ETrue; |
|
631 iRestorePathIndex = 0; |
|
632 CMPXCollectionPath* cpath = iCollectionUiHelper->MusicAllSongsPathL(); |
|
633 CleanupStack::PushL( cpath ); |
|
634 iIsolatedCollectionHelper->OpenCollectionL( *cpath, iRestorePathIndex, CMpMpxIsolatedCollectionHelper::RestorePathMode ); |
|
635 CleanupStack::PopAndDestroy( cpath ); |
|
636 } |
|
637 else { |
|
638 //Open path failed |
|
639 TX_LOG_ARGS( "Error: " << aError << "; should never get here." ); |
|
640 } |
|
641 TX_EXIT |
|
642 } |
|
643 |
|
644 /*! |
|
645 \internal |
|
646 */ |
|
647 void MpMpxCollectionFrameworkWrapperPrivate::HandleFindAllL( const CMPXMedia& aResults, TBool aComplete, TInt aError ) |
|
648 { |
|
649 Q_UNUSED( aComplete ); |
|
650 TX_ENTRY_ARGS( "aError=" << aError ); |
|
651 |
|
652 if ( aError == KErrNone ) { |
|
653 iCollectionData->setAlbumContent( aResults ); |
|
654 } |
|
655 } |
|
656 |
|
657 /*! |
|
658 \internal |
|
659 */ |
|
660 void MpMpxCollectionFrameworkWrapperPrivate::DoInitL() |
|
661 { |
|
662 TX_ENTRY |
|
663 iCollectionUtility = MMPXCollectionUtility::NewL( this, iHostUid ); |
|
664 iCollectionUiHelper = CMPXCollectionHelperFactory:: NewCollectionUiHelperL( iHostUid ); |
|
665 iIncrementalOpenUtil = CMPXCollectionOpenUtility::NewL( this, iHostUid ); |
|
666 iCollectionData = new MpMpxCollectionData(); |
|
667 TX_EXIT |
|
668 } |
|
669 |
|
670 /*! |
|
671 \internal |
|
672 */ |
|
673 void MpMpxCollectionFrameworkWrapperPrivate::DoOpenCollectionL( |
|
674 TCollectionContext aContext ) |
|
675 { |
|
676 TX_ENTRY_ARGS( "aContext=" << aContext ); |
|
677 |
|
678 switch ( aContext ) { |
|
679 case ECollectionContextAllSongs: |
|
680 { |
|
681 CMPXCollectionPath* cpath = iCollectionUiHelper->MusicAllSongsPathL(); |
|
682 CleanupStack::PushL( cpath ); |
|
683 iCollectionUtility->Collection().OpenL( *cpath ); |
|
684 CleanupStack::PopAndDestroy( cpath ); |
|
685 break; |
|
686 } |
|
687 case ECollectionContextArtists: |
|
688 { |
|
689 CMPXCollectionPath* cpath = iCollectionUiHelper->MusicMenuPathL(); |
|
690 CleanupStack::PushL( cpath ); |
|
691 cpath->AppendL( BrowseArtist ); |
|
692 iCollectionUtility->Collection().OpenL( *cpath ); |
|
693 CleanupStack::PopAndDestroy( cpath ); |
|
694 break; |
|
695 } |
|
696 case ECollectionContextAlbums: |
|
697 { |
|
698 CMPXCollectionPath* cpath = iCollectionUiHelper->MusicMenuPathL(); |
|
699 CleanupStack::PushL( cpath ); |
|
700 cpath->AppendL( BrowseAlbum ); |
|
701 iCollectionUtility->Collection().OpenL( *cpath ); |
|
702 CleanupStack::PopAndDestroy( cpath ); |
|
703 break; |
|
704 } |
|
705 case ECollectionContextPlaylists: |
|
706 { |
|
707 CMPXCollectionPath* cpath = iCollectionUiHelper->MusicPlaylistPathL(); |
|
708 CleanupStack::PushL( cpath ); |
|
709 iCollectionUtility->Collection().OpenL( *cpath ); |
|
710 CleanupStack::PopAndDestroy( cpath ); |
|
711 break; |
|
712 } |
|
713 case ECollectionContextAlbumsMediaWall: |
|
714 { |
|
715 CMPXCollectionPath* cpath = iCollectionUiHelper->MusicMenuPathL(); |
|
716 CleanupStack::PushL( cpath ); |
|
717 cpath->AppendL( BrowseAlbumMediaWall ); |
|
718 iCollectionUtility->Collection().OpenL( *cpath ); |
|
719 CleanupStack::PopAndDestroy( cpath ); |
|
720 break; |
|
721 } |
|
722 default: |
|
723 TX_LOG_ARGS( "Error: Unexpected context; should never get here." ); |
|
724 break; |
|
725 } |
|
726 TX_EXIT |
|
727 } |
|
728 |
|
729 /*! |
|
730 \internal |
|
731 */ |
|
732 void MpMpxCollectionFrameworkWrapperPrivate::DoOpenCollectionItemL( TInt aIndex ) |
|
733 { |
|
734 TX_ENTRY_ARGS( "aIndex=" << aIndex ); |
|
735 iCollectionUtility->Collection().OpenL( aIndex ); |
|
736 TX_EXIT |
|
737 } |
|
738 |
|
739 /*! |
|
740 \internal |
|
741 */ |
|
742 void MpMpxCollectionFrameworkWrapperPrivate::DoIncrementalOpenL() |
|
743 { |
|
744 TX_ENTRY |
|
745 // Cancel any reads |
|
746 iIncrementalOpenUtil->Stop(); |
|
747 |
|
748 // Start the read |
|
749 iFirstIncrementalOpen = ETrue; |
|
750 RArray<TMPXAttribute> attrs; |
|
751 CleanupClosePushL( attrs ); |
|
752 TArray<TMPXAttribute> ary = attrs.Array(); |
|
753 iIncrementalOpenUtil->SetDelay( KIncrementalDelay ); |
|
754 iIncrementalOpenUtil->StartL( ary, KIncrementalFetchBlockSize, |
|
755 0, CMPXCollectionOpenUtility::EFetchDown ); |
|
756 CleanupStack::PopAndDestroy( &attrs ); |
|
757 TX_EXIT |
|
758 } |
|
759 |
|
760 /*! |
|
761 \internal |
|
762 */ |
|
763 void MpMpxCollectionFrameworkWrapperPrivate::DoReopenCollectionL() |
|
764 { |
|
765 TX_ENTRY |
|
766 CMPXCollectionPath* cpath = iCollectionUtility->Collection().PathL(); |
|
767 CleanupStack::PushL( cpath ); |
|
768 cpath->Back(); |
|
769 iCollectionUtility->Collection().OpenL( *cpath ); |
|
770 CleanupStack::PopAndDestroy( cpath ); |
|
771 TX_EXIT |
|
772 } |
|
773 |
|
774 /*! |
|
775 \internal |
|
776 */ |
|
777 void MpMpxCollectionFrameworkWrapperPrivate::DoBackL() |
|
778 { |
|
779 TX_ENTRY |
|
780 iCollectionUtility->Collection().BackL(); |
|
781 TX_EXIT |
|
782 } |
|
783 |
|
784 /*! |
|
785 \internal |
|
786 */ |
|
787 void MpMpxCollectionFrameworkWrapperPrivate::DoFindPlaylistsL( QStringList &playlists ) |
|
788 { |
|
789 TX_ENTRY |
|
790 delete iUserPlaylists; |
|
791 iUserPlaylists = NULL; |
|
792 |
|
793 RArray<TMPXAttribute> attrs; |
|
794 CleanupClosePushL( attrs ); |
|
795 attrs.AppendL( KMPXMediaGeneralId ); |
|
796 attrs.AppendL( KMPXMediaGeneralTitle ); |
|
797 |
|
798 CMPXMedia* criteria = CMPXMedia::NewL(); |
|
799 CleanupStack::PushL( criteria ); |
|
800 criteria->SetTObjectValueL<TMPXGeneralType>( |
|
801 KMPXMediaGeneralType, EMPXGroup ); |
|
802 criteria->SetTObjectValueL<TMPXGeneralCategory>( |
|
803 KMPXMediaGeneralCategory, EMPXPlaylist ); |
|
804 |
|
805 // Look up collection UID and set to criteria |
|
806 RArray<TUid> ary; |
|
807 CleanupClosePushL( ary ); |
|
808 ary.AppendL( TUid::Uid( EMPXCollectionPluginMusic ) ); |
|
809 TUid musicCollection = iCollectionUtility->CollectionIDL( ary.Array() ); |
|
810 CleanupStack::PopAndDestroy( &ary ); |
|
811 |
|
812 criteria->SetTObjectValueL<TUid>( KMPXMediaGeneralCollectionId, musicCollection ); |
|
813 |
|
814 iUserPlaylists = iCollectionUtility->Collection().FindAllL( *criteria, attrs.Array() ); |
|
815 CleanupStack::PopAndDestroy( criteria ); |
|
816 CleanupStack::PopAndDestroy( &attrs ); |
|
817 |
|
818 if ( iUserPlaylists ) { |
|
819 const CMPXMediaArray* mediaArray = |
|
820 iUserPlaylists->Value<CMPXMediaArray>( KMPXMediaArrayContents ); |
|
821 User::LeaveIfNull( const_cast<CMPXMediaArray*>( mediaArray ) ); |
|
822 TInt count = mediaArray->Count(); |
|
823 for ( TInt i = 0; i < count; i++ ) { |
|
824 CMPXMedia* media( mediaArray->AtL( i ) ); |
|
825 const TDesC& titleText = media->ValueText( KMPXMediaGeneralTitle ); |
|
826 if ( titleText.Compare( KNullDesC ) != 0 ) { |
|
827 playlists += QString::fromUtf16( titleText.Ptr(), titleText.Length() ); |
|
828 } |
|
829 } |
|
830 } |
|
831 TX_EXIT |
|
832 } |
|
833 |
|
834 /*! |
|
835 \internal |
|
836 */ |
|
837 void MpMpxCollectionFrameworkWrapperPrivate::DoCreatePlaylistL( QString &playlistName, QList<int> &selection, MpMpxCollectionData* collectionData ) |
|
838 { |
|
839 TX_ENTRY_ARGS( "playlistName=" << playlistName ); |
|
840 CMPXMedia* tracks = CMPXMedia::NewL(); |
|
841 CleanupStack::PushL( tracks ); |
|
842 |
|
843 TPtrC ptr( reinterpret_cast<const TText*>( playlistName.constData() ) ); |
|
844 tracks->SetTextValueL( KMPXMediaGeneralTitle, ptr ); |
|
845 tracks->SetTextValueL( KMPXMediaGeneralUri, KPlaylistPath ); |
|
846 //if collection data is not provided we use the browsing collection. |
|
847 PreparePlaylistMediaL( *tracks, selection, collectionData ? collectionData : iCollectionData ); |
|
848 |
|
849 iCollectionUiHelper->IncAddL( *tracks, this, KMPXChunkSize ); |
|
850 CleanupStack::PopAndDestroy( tracks ); |
|
851 TX_EXIT |
|
852 } |
|
853 |
|
854 /*! |
|
855 \internal |
|
856 */ |
|
857 void MpMpxCollectionFrameworkWrapperPrivate::DoSaveToPlaylistL( TMPXItemId playlistId, QList<int> &selection, MpMpxCollectionData *collectionData ) |
|
858 { |
|
859 TX_ENTRY_ARGS( "playlistId=" << int( playlistId ) ); |
|
860 |
|
861 CMPXMedia* tracks = CMPXMedia::NewL(); |
|
862 CleanupStack::PushL( tracks ); |
|
863 |
|
864 RArray<TUid> ary; |
|
865 CleanupClosePushL( ary ); |
|
866 ary.AppendL( TUid::Uid( EMPXCollectionPluginMusic ) ); |
|
867 TUid musicCollection = iCollectionUtility->CollectionIDL( ary.Array() ); |
|
868 CleanupStack::PopAndDestroy( &ary ); |
|
869 |
|
870 tracks->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, playlistId ); |
|
871 tracks->SetTObjectValueL<TUid>( KMPXMediaGeneralCollectionId, musicCollection ); |
|
872 PreparePlaylistMediaL( *tracks, selection, collectionData ); |
|
873 |
|
874 iCollectionUiHelper->IncAddL( *tracks, this, KMPXChunkSize ); |
|
875 CleanupStack::PopAndDestroy( tracks ); |
|
876 TX_EXIT |
|
877 } |
|
878 |
|
879 /*! |
|
880 \internal |
|
881 */ |
|
882 void MpMpxCollectionFrameworkWrapperPrivate::DoSaveToPlaylistL( int playlistIndex, QList<int> &selection ) |
|
883 { |
|
884 TX_ENTRY_ARGS( "playlistIndex=" << playlistIndex ); |
|
885 |
|
886 const CMPXMediaArray* mediaArray = iUserPlaylists->Value<CMPXMediaArray>( KMPXMediaArrayContents ); |
|
887 User::LeaveIfNull( const_cast<CMPXMediaArray*>( mediaArray ) ); |
|
888 CMPXMedia* media( mediaArray->AtL( playlistIndex ) ); |
|
889 TMPXItemId playlistId = media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ); |
|
890 DoSaveToPlaylistL( playlistId, selection, iCollectionData ); |
|
891 TX_EXIT |
|
892 } |
|
893 |
|
894 /*! |
|
895 \internal |
|
896 */ |
|
897 void MpMpxCollectionFrameworkWrapperPrivate::DoSaveToCurrentPlaylistL( QList<int> &selection, MpMpxCollectionData *collectionData ) |
|
898 { |
|
899 TX_ENTRY |
|
900 |
|
901 const CMPXMedia& container = iCollectionData->containerMedia(); |
|
902 if ( container.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType) != EMPXItem && |
|
903 container.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory) != EMPXPlaylist) { |
|
904 User::Leave( KErrArgument ); |
|
905 } |
|
906 TMPXItemId playlistId( container.ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) ); |
|
907 DoSaveToPlaylistL( playlistId, selection, collectionData ); |
|
908 TX_EXIT |
|
909 } |
|
910 |
|
911 /*! |
|
912 \internal |
|
913 */ |
|
914 void MpMpxCollectionFrameworkWrapperPrivate::DoDeleteSongsL( QList<int> &selection ) |
|
915 { |
|
916 int count = selection.count(); |
|
917 TX_ENTRY_ARGS( "selection count=" << count ); |
|
918 |
|
919 CMPXCollectionPath* path( iCollectionUtility->Collection().PathL() ); |
|
920 CleanupStack::PushL( path ); |
|
921 |
|
922 if (count > 1) { |
|
923 for ( TInt i = 0; i < count; i++ ){ |
|
924 path->SelectL( selection.at( i ) ); |
|
925 } |
|
926 } |
|
927 else { |
|
928 path->Set( selection.at(0) ); |
|
929 } |
|
930 |
|
931 iCollectionUiHelper->DeleteL( *path, this ); |
|
932 CleanupStack::PopAndDestroy( path ); |
|
933 TX_EXIT |
|
934 } |
|
935 |
|
936 /*! |
|
937 \internal |
|
938 */ |
|
939 void MpMpxCollectionFrameworkWrapperPrivate::DoDeleteAlbumSongsL( QList<int> &selection ) |
|
940 { |
|
941 int count = selection.count(); |
|
942 TX_ENTRY_ARGS( "selection count=" << count ); |
|
943 |
|
944 CMPXCollectionPath* path( iCollectionUtility->Collection().PathL() ); |
|
945 CleanupStack::PushL( path ); |
|
946 MPX_DEBUG_PATH( *path ); |
|
947 |
|
948 CMPXMediaArray *mediaArray; |
|
949 const CMPXMedia& container = iCollectionData->containerMedia(); |
|
950 mediaArray = const_cast<CMPXMediaArray*>( container.Value<CMPXMediaArray>( KMPXMediaArrayContents ) ); |
|
951 int currentAlbumIndex = iCollectionData->currentAlbumIndex(); |
|
952 CMPXMedia* album( mediaArray->AtL( currentAlbumIndex ) ); |
|
953 if ( album->IsSupported(KMPXMediaArrayContents) ) { |
|
954 const CMPXMediaArray* songs = album->Value<CMPXMediaArray>(KMPXMediaArrayContents); |
|
955 User::LeaveIfNull(const_cast<CMPXMediaArray*>(songs)); |
|
956 int index = selection.at(0); |
|
957 CMPXMedia* song = songs->AtL(index); |
|
958 |
|
959 TMPXItemId id( song->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) ); |
|
960 path->AppendL( id ); // Append the song ID to be deleted |
|
961 path->Set( 0 ); // Select 1st song |
|
962 |
|
963 iCollectionUiHelper->DeleteL( *path, this ); |
|
964 } |
|
965 CleanupStack::PopAndDestroy( path ); |
|
966 TX_EXIT |
|
967 } |
|
968 |
|
969 /*! |
|
970 \internal |
|
971 */ |
|
972 void MpMpxCollectionFrameworkWrapperPrivate::DoRenamePlaylistL( QString &newName, int index ) |
|
973 { |
|
974 TX_ENTRY |
|
975 CMPXMediaArray *mediaArray; |
|
976 const CMPXMedia& container = iCollectionData->containerMedia(); |
|
977 mediaArray = const_cast<CMPXMediaArray*>( container.Value<CMPXMediaArray>( KMPXMediaArrayContents ) ); |
|
978 CMPXMedia* currentPlaylistMedia( mediaArray->AtL( index ) ); |
|
979 TMPXItemId id( currentPlaylistMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) ); |
|
980 DoRenamePlaylistL( id, newName ); |
|
981 TX_EXIT |
|
982 } |
|
983 |
|
984 /*! |
|
985 \internal |
|
986 */ |
|
987 void MpMpxCollectionFrameworkWrapperPrivate::DoRenamePlaylistL( QString &newName ) |
|
988 { |
|
989 TX_ENTRY |
|
990 const CMPXMedia& container = iCollectionData->containerMedia(); |
|
991 TMPXItemId id( container.ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) ); |
|
992 DoRenamePlaylistL( id, newName ); |
|
993 TX_EXIT |
|
994 } |
|
995 |
|
996 /*! |
|
997 \internal |
|
998 */ |
|
999 void MpMpxCollectionFrameworkWrapperPrivate::DoRenamePlaylistL( TMPXItemId id, QString &newName ) |
|
1000 { |
|
1001 CMPXMedia* media = CMPXMedia::NewL(); |
|
1002 CleanupStack::PushL( media ); |
|
1003 media->SetTObjectValueL<TMPXGeneralType>( |
|
1004 KMPXMediaGeneralType, EMPXItem ); |
|
1005 media->SetTObjectValueL<TMPXGeneralCategory>( |
|
1006 KMPXMediaGeneralCategory, EMPXPlaylist ); |
|
1007 media->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, id ); |
|
1008 TPtrC ptr( reinterpret_cast<const TText*>( newName.constData() ) ); |
|
1009 media->SetTextValueL( KMPXMediaGeneralTitle, ptr ); |
|
1010 iCollectionUiHelper->RenameL( *media, this ); |
|
1011 CleanupStack::PopAndDestroy( media ); |
|
1012 } |
|
1013 |
|
1014 /*! |
|
1015 \internal |
|
1016 */ |
|
1017 void MpMpxCollectionFrameworkWrapperPrivate::DoSetShuffleL( bool active ) |
|
1018 { |
|
1019 TX_ENTRY |
|
1020 if ( iPlaybackUtility ) { |
|
1021 iPlaybackUtility->SetL( EPbPropertyRandomMode, active ); |
|
1022 } |
|
1023 TX_EXIT |
|
1024 } |
|
1025 |
|
1026 /*! |
|
1027 \internal |
|
1028 */ |
|
1029 void MpMpxCollectionFrameworkWrapperPrivate::DoPreviewSongL( int index ) |
|
1030 { |
|
1031 TX_ENTRY |
|
1032 |
|
1033 // Get the current path |
|
1034 CMPXCollectionPath* cpath = iCollectionUtility->Collection().PathL(); |
|
1035 CleanupStack::PushL( cpath ); |
|
1036 MPX_DEBUG_PATH( *cpath ); |
|
1037 cpath->Back(); |
|
1038 |
|
1039 TMPXItemId id( iCollectionData->itemId(index) ); |
|
1040 cpath->AppendL( id ); // Top level items of songs |
|
1041 cpath->Set( 0 ); // Select 1st song |
|
1042 |
|
1043 CMPXCollectionPlaylist* playList = CMPXCollectionPlaylist::NewL( *cpath ); |
|
1044 CleanupStack::PushL( playList ); |
|
1045 playList->SetToFirst(); |
|
1046 //TODO: all calls to playback utility should be done via the engine and trough the playback FW wrapper. |
|
1047 createPlaybackUtilityL(); |
|
1048 iPlaybackUtility->InitL( *playList, ETrue ); |
|
1049 emit q_ptr->collectionPlaylistOpened(); |
|
1050 |
|
1051 CleanupStack::PopAndDestroy( playList ); |
|
1052 CleanupStack::PopAndDestroy( cpath ); |
|
1053 TX_EXIT |
|
1054 } |
|
1055 |
|
1056 /*! |
|
1057 \internal |
|
1058 */ |
|
1059 void MpMpxCollectionFrameworkWrapperPrivate::DoPreviewAlbumSongL( int index ) |
|
1060 { |
|
1061 TX_ENTRY |
|
1062 //TODO: all calls to playback utility should be done via the engine and trough the playback FW wrapper. |
|
1063 if ( !iPlaybackUtility ) { |
|
1064 iPlaybackUtility = MMPXPlaybackUtility::UtilityL( iHostUid ); |
|
1065 } |
|
1066 |
|
1067 // Get the current path |
|
1068 CMPXCollectionPath* cpath = iCollectionUtility->Collection().PathL(); |
|
1069 CleanupStack::PushL( cpath ); |
|
1070 MPX_DEBUG_PATH( *cpath ); |
|
1071 |
|
1072 CMPXMediaArray *mediaArray; |
|
1073 const CMPXMedia& container = iCollectionData->containerMedia(); |
|
1074 mediaArray = const_cast<CMPXMediaArray*>( container.Value<CMPXMediaArray>( KMPXMediaArrayContents ) ); |
|
1075 int currentAlbumIndex = iCollectionData->currentAlbumIndex(); |
|
1076 CMPXMedia* album( mediaArray->AtL( currentAlbumIndex ) ); |
|
1077 if ( album->IsSupported(KMPXMediaArrayContents) ) { |
|
1078 const CMPXMediaArray* songs = album->Value<CMPXMediaArray>(KMPXMediaArrayContents); |
|
1079 User::LeaveIfNull(const_cast<CMPXMediaArray*>(songs)); |
|
1080 CMPXMedia* song = songs->AtL(index); |
|
1081 |
|
1082 TMPXItemId id( song->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) ); |
|
1083 cpath->AppendL( id ); // Top level items of songs |
|
1084 cpath->Set( 0 ); // Select 1st song |
|
1085 |
|
1086 CMPXCollectionPlaylist* playList = CMPXCollectionPlaylist::NewL( *cpath ); |
|
1087 CleanupStack::PushL( playList ); |
|
1088 playList->SetToFirst(); |
|
1089 //TODO: all calls to playback utility should be done via the engine and trough the playback FW wrapper. |
|
1090 iPlaybackUtility->InitL( *playList, ETrue ); |
|
1091 emit q_ptr->collectionPlaylistOpened(); |
|
1092 |
|
1093 CleanupStack::PopAndDestroy( playList ); |
|
1094 } |
|
1095 CleanupStack::PopAndDestroy( cpath ); |
|
1096 TX_EXIT |
|
1097 } |
|
1098 |
|
1099 /*! |
|
1100 \internal |
|
1101 */ |
|
1102 void MpMpxCollectionFrameworkWrapperPrivate::DoOpenIsolatedCollectionL( TCollectionContext context ) |
|
1103 { |
|
1104 |
|
1105 if ( ECollectionContextAllSongs == context ) { |
|
1106 CMPXCollectionPath* cpath = iCollectionUiHelper->MusicAllSongsPathL(); |
|
1107 CleanupStack::PushL( cpath ); |
|
1108 if ( !iIsolatedCollectionHelper ) { |
|
1109 iIsolatedCollectionHelper = CMpMpxIsolatedCollectionHelper::NewL( this ); |
|
1110 } |
|
1111 iIsolatedCollectionHelper->OpenCollectionL( *cpath ); |
|
1112 CleanupStack::PopAndDestroy( cpath ); |
|
1113 } |
|
1114 } |
|
1115 |
|
1116 /*! |
|
1117 \internal |
|
1118 */ |
|
1119 void MpMpxCollectionFrameworkWrapperPrivate::DoReorderPlaylistL( int playlistId, int songId, int originalOrdinal, int newOrdinal ) |
|
1120 { |
|
1121 iCollectionUiHelper->ReorderPlaylistL( playlistId, songId, originalOrdinal, newOrdinal, this ); |
|
1122 } |
|
1123 |
|
1124 /*! |
|
1125 \internal |
|
1126 */ |
|
1127 void MpMpxCollectionFrameworkWrapperPrivate::DoFindAlbumSongsL( int index ) |
|
1128 { |
|
1129 const CMPXMedia& container = iCollectionData->containerMedia(); |
|
1130 const CMPXMediaArray* mediaArray = container.Value<CMPXMediaArray>( KMPXMediaArrayContents ); |
|
1131 CMPXMedia* album( mediaArray->AtL( index ) ); |
|
1132 |
|
1133 // Obtain the artistId from the container |
|
1134 TMPXItemId artistId = container.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId); |
|
1135 |
|
1136 // Fetch the songs for the selected album and the artist |
|
1137 // Specifying artistId is necessary to search for songs in the artist’s unknown album. |
|
1138 TMPXItemId albumId = album->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId); |
|
1139 CMPXMedia* findCriteria = CMPXMedia::NewL(); |
|
1140 CleanupStack::PushL( findCriteria ); |
|
1141 findCriteria->SetTObjectValueL<TMPXGeneralType>( KMPXMediaGeneralType, EMPXGroup ); |
|
1142 findCriteria->SetTObjectValueL<TMPXGeneralCategory>( KMPXMediaGeneralCategory, EMPXSong ); |
|
1143 findCriteria->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, albumId ); |
|
1144 findCriteria->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralContainerId, artistId ); |
|
1145 RArray<TMPXAttribute> attrs; |
|
1146 CleanupClosePushL( attrs ); |
|
1147 attrs.AppendL( TMPXAttribute( KMPXMediaIdGeneral, |
|
1148 EMPXMediaGeneralTitle | |
|
1149 EMPXMediaGeneralUri | |
|
1150 EMPXMediaGeneralId | |
|
1151 EMPXMediaGeneralType | |
|
1152 EMPXMediaGeneralCategory | |
|
1153 EMPXMediaGeneralFlags ) ); |
|
1154 attrs.AppendL( KMPXMediaMusicAlbumTrack ); |
|
1155 |
|
1156 iCollectionUtility->Collection().FindAllL( *findCriteria, attrs.Array(), *this ); |
|
1157 CleanupStack::PopAndDestroy( &attrs ); |
|
1158 CleanupStack::PopAndDestroy( findCriteria ); |
|
1159 } |
|
1160 |
|
1161 /*! |
|
1162 \internal |
|
1163 */ |
|
1164 void MpMpxCollectionFrameworkWrapperPrivate::DoPlayAlbumSongsL( int albumIndex, int songIndex, MpMpxCollectionData* collectionData ) |
|
1165 { |
|
1166 TX_ENTRY |
|
1167 |
|
1168 RArray<TMPXItemId> ids; |
|
1169 CleanupClosePushL(ids); |
|
1170 |
|
1171 CMPXCollectionPath* cpath; |
|
1172 |
|
1173 //Following check is for a use case for media wall, where it is required |
|
1174 //to play songs that are browsed by an isolated collection. |
|
1175 if ( collectionData->context() == ECollectionContextAlbumsMediaWall ) { |
|
1176 //Get the Media Wall path. |
|
1177 cpath = iCollectionUiHelper->MusicMenuPathL(); |
|
1178 CleanupStack::PushL( cpath ); |
|
1179 //TODO: change to BrowseAlbumMediaWall befor when merging with olveras changes. |
|
1180 cpath->AppendL( BrowseAlbum ); |
|
1181 const TMPXItemId albumId = collectionData->itemId( albumIndex ); |
|
1182 //Append the selected album. |
|
1183 RArray<TMPXItemId> items; |
|
1184 CleanupClosePushL(items); |
|
1185 items.AppendL(albumId); |
|
1186 cpath->AppendL(items.Array()); |
|
1187 CleanupStack::PopAndDestroy( &items ); |
|
1188 cpath->Set( 0 ); // Set the album. |
|
1189 |
|
1190 } |
|
1191 else { |
|
1192 // Get the current path |
|
1193 cpath = iCollectionUtility->Collection().PathL(); |
|
1194 CleanupStack::PushL( cpath ); |
|
1195 cpath->Set(albumIndex); // Set the selected album |
|
1196 } |
|
1197 MPX_DEBUG_PATH( *cpath ); |
|
1198 |
|
1199 CMPXMediaArray *mediaArray; |
|
1200 const CMPXMedia& container = collectionData->containerMedia(); |
|
1201 mediaArray = const_cast<CMPXMediaArray*>( container.Value<CMPXMediaArray>( KMPXMediaArrayContents ) ); |
|
1202 CMPXMedia* album( mediaArray->AtL( albumIndex ) ); |
|
1203 const CMPXMediaArray* songs = album->Value<CMPXMediaArray>(KMPXMediaArrayContents); |
|
1204 User::LeaveIfNull(const_cast<CMPXMediaArray*>(songs)); |
|
1205 |
|
1206 TInt count = songs->Count(); |
|
1207 for ( TInt i = 0; i < count; ++i ) { |
|
1208 CMPXMedia* song = songs->AtL(i); |
|
1209 const TMPXItemId id = song->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId); |
|
1210 ids.AppendL(id); |
|
1211 } |
|
1212 |
|
1213 cpath->AppendL(ids.Array()); // Top level items of songs |
|
1214 cpath->Set(songIndex); // Set the selected song |
|
1215 MPX_DEBUG_PATH(*cpath); |
|
1216 |
|
1217 CMPXCollectionPlaylist* playList = CMPXCollectionPlaylist::NewL( *cpath ); |
|
1218 CleanupStack::PushL( playList ); |
|
1219 |
|
1220 //TODO: all calls to playback utility should be done via the engine and trough the playback FW wrapper. |
|
1221 createPlaybackUtilityL(); |
|
1222 iPlaybackUtility->InitL( *playList, ETrue ); |
|
1223 emit q_ptr->collectionPlaylistOpened(); |
|
1224 |
|
1225 CleanupStack::PopAndDestroy( playList ); |
|
1226 CleanupStack::PopAndDestroy( cpath ); |
|
1227 CleanupStack::PopAndDestroy( &ids ); |
|
1228 TX_EXIT |
|
1229 } |
|
1230 |
|
1231 /*! |
|
1232 \internal |
|
1233 */ |
|
1234 void MpMpxCollectionFrameworkWrapperPrivate::setRepeatFeatureEnabled( bool enable ) |
|
1235 { |
|
1236 iRepeatFeature = enable; |
|
1237 } |
|
1238 |
|
1239 /*! |
|
1240 \internal |
|
1241 */ |
|
1242 void MpMpxCollectionFrameworkWrapperPrivate::setShuffleFeatureEnabled( bool enable ) |
|
1243 { |
|
1244 iShuffleFeature = enable; |
|
1245 } |
|
1246 |
|
1247 /*! |
|
1248 \internal |
|
1249 */ |
|
1250 void MpMpxCollectionFrameworkWrapperPrivate::DoHandleCollectionMessageL( |
|
1251 const CMPXMessage& aMsg ) |
|
1252 { |
|
1253 TX_ENTRY |
|
1254 TMPXMessageId id( aMsg.ValueTObjectL<TMPXMessageId>( KMPXMessageGeneralId ) ); |
|
1255 if ( KMPXMessageGeneral == id ) { |
|
1256 TInt event( aMsg.ValueTObjectL<TInt>( KMPXMessageGeneralEvent ) ); |
|
1257 TInt type( aMsg.ValueTObjectL<TInt>( KMPXMessageGeneralType ) ); |
|
1258 TInt data( aMsg.ValueTObjectL<TInt>( KMPXMessageGeneralData ) ); |
|
1259 TX_LOG_ARGS( "event=" << event << ", type=" << type << ", data=" << data ); |
|
1260 |
|
1261 if ( event == TMPXCollectionMessage::EPathChanged && |
|
1262 type == EMcPathChangedByOpen && |
|
1263 data == EMcContainerOpened ) { |
|
1264 // Incremental Open when browsing to the next level |
|
1265 DoIncrementalOpenL(); |
|
1266 } |
|
1267 else if ( event == TMPXCollectionMessage::EPathChanged && |
|
1268 type == EMcPathChangedByOpen && |
|
1269 data == EMcItemOpened ) { |
|
1270 // Opened a song |
|
1271 // This will result in HandleOpenL with CMPXCollectionPlaylist |
|
1272 iCollectionUtility->Collection().OpenL(); |
|
1273 } |
|
1274 } |
|
1275 else if( id == KMPXMessageIdItemChanged ) { |
|
1276 TInt eventType( aMsg.ValueTObjectL<TMPXChangeEventType>( KMPXMessageChangeEventType ) ); |
|
1277 |
|
1278 if ( eventType == EMPXItemDeleted || eventType == EMPXItemInserted ) { |
|
1279 emit q_ptr->containerContentsChanged(); |
|
1280 } |
|
1281 } |
|
1282 TX_EXIT |
|
1283 } |
|
1284 |
|
1285 |
|
1286 /*! |
|
1287 \internal |
|
1288 */ |
|
1289 void MpMpxCollectionFrameworkWrapperPrivate::PreparePlaylistMediaL( |
|
1290 CMPXMedia& aMedia, |
|
1291 QList<int> &selection, |
|
1292 MpMpxCollectionData *collectionData ) |
|
1293 { |
|
1294 int count = selection.count(); |
|
1295 TX_ENTRY_ARGS( "selection count=" << count ); |
|
1296 |
|
1297 const CMPXMediaArray* mediaArray = 0; |
|
1298 |
|
1299 if ( ( collectionData->context() == ECollectionContextArtistAlbumsTBone ) || |
|
1300 ( collectionData->context() == ECollectionContextAlbumsTBone ) ) { |
|
1301 //There is no need to find the track information, for TBone we cash it under the media itself. |
|
1302 //Fetching song data from container media. |
|
1303 CMPXMedia* album; |
|
1304 const CMPXMediaArray* albumsArray; |
|
1305 albumsArray = collectionData->containerMedia().Value<CMPXMediaArray>( KMPXMediaArrayContents ); |
|
1306 int index = collectionData->currentAlbumIndex(); |
|
1307 if ( index >= 0 ) { |
|
1308 album = albumsArray->AtL( collectionData->currentAlbumIndex() ); |
|
1309 mediaArray = album->Value<CMPXMediaArray>( KMPXMediaArrayContents ); |
|
1310 } |
|
1311 } |
|
1312 else { |
|
1313 const CMPXMedia& container = collectionData->containerMedia(); |
|
1314 mediaArray = container.Value<CMPXMediaArray>( KMPXMediaArrayContents ); |
|
1315 } |
|
1316 |
|
1317 User::LeaveIfNull( const_cast<CMPXMediaArray*>( mediaArray ) ); |
|
1318 CMPXMediaArray* tracksArray( CMPXMediaArray::NewL() ); |
|
1319 CleanupStack::PushL( tracksArray ); |
|
1320 |
|
1321 CMPXCollectionPath* path( iCollectionUtility->Collection().PathL() ); |
|
1322 CleanupStack::PushL( path ); |
|
1323 TMPXItemId collectionId( path->Id( 0 ) ); |
|
1324 CleanupStack::PopAndDestroy( path ); |
|
1325 |
|
1326 if ( collectionData->context() == ECollectionContextAlbums || |
|
1327 collectionData->context() == ECollectionContextArtistAlbums || |
|
1328 collectionData->context() == ECollectionContextArtists ) { |
|
1329 //Container, it is possible to append multiple containers to a playlist. |
|
1330 //Currently we are just using single selection from the ui. |
|
1331 for ( TInt i = 0; i < count; i++ ) { |
|
1332 CMPXMedia* results; |
|
1333 CMPXMedia* container( mediaArray->AtL( selection[i] ) ); |
|
1334 // Fetch the songs for the selected container |
|
1335 TMPXItemId containerId = container->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ); |
|
1336 CMPXMedia* findCriteria = CMPXMedia::NewL(); |
|
1337 CleanupStack::PushL( findCriteria ); |
|
1338 findCriteria->SetTObjectValueL<TMPXGeneralType>( KMPXMediaGeneralType, EMPXGroup ); |
|
1339 findCriteria->SetTObjectValueL<TMPXGeneralCategory>( KMPXMediaGeneralCategory, EMPXSong ); |
|
1340 findCriteria->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, containerId ); |
|
1341 RArray<TMPXAttribute> attrs; |
|
1342 CleanupClosePushL( attrs ); |
|
1343 attrs.AppendL( TMPXAttribute( KMPXMediaIdGeneral, |
|
1344 EMPXMediaGeneralTitle | |
|
1345 EMPXMediaGeneralId ) ); |
|
1346 results = iCollectionUtility->Collection().FindAllL( *findCriteria, attrs.Array() ); |
|
1347 CleanupStack::PopAndDestroy( &attrs ); |
|
1348 CleanupStack::PopAndDestroy( findCriteria ); |
|
1349 CleanupStack::PushL( results ); |
|
1350 |
|
1351 const CMPXMediaArray* resultsArray = results->Value<CMPXMediaArray>( KMPXMediaArrayContents ); |
|
1352 User::LeaveIfNull( resultsArray ); |
|
1353 for ( int j = 0 ; j < resultsArray->Count();j++ ) { |
|
1354 CMPXMedia* media( resultsArray->AtL( j ) ); |
|
1355 CMPXMedia* entry = CMPXMedia::NewL(); |
|
1356 CleanupStack::PushL( entry ); |
|
1357 entry->SetTextValueL( KMPXMediaGeneralTitle, |
|
1358 media->ValueText( KMPXMediaGeneralTitle ) ); |
|
1359 entry->SetTObjectValueL( KMPXMediaGeneralType, EMPXItem ); |
|
1360 entry->SetTObjectValueL( KMPXMediaGeneralCategory, EMPXSong ); |
|
1361 entry->SetTObjectValueL( KMPXMediaGeneralId, |
|
1362 media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) ); |
|
1363 entry->SetTObjectValueL( KMPXMediaGeneralCollectionId, collectionId ); |
|
1364 CleanupStack::Pop( entry ); |
|
1365 tracksArray->AppendL( entry ); |
|
1366 } |
|
1367 CleanupStack::PopAndDestroy( results ); |
|
1368 } |
|
1369 |
|
1370 } |
|
1371 else { |
|
1372 //Tracks |
|
1373 for ( TInt i = 0; i < count; i++ ) { |
|
1374 CMPXMedia* media( mediaArray->AtL( selection.at( i ) ) ); |
|
1375 CMPXMedia* entry = CMPXMedia::NewL(); |
|
1376 CleanupStack::PushL( entry ); |
|
1377 entry->SetTextValueL( KMPXMediaGeneralTitle, |
|
1378 media->ValueText( KMPXMediaGeneralTitle ) ); |
|
1379 entry->SetTObjectValueL( KMPXMediaGeneralType, EMPXItem ); |
|
1380 entry->SetTObjectValueL( KMPXMediaGeneralCategory, EMPXSong ); |
|
1381 entry->SetTObjectValueL( KMPXMediaGeneralId, |
|
1382 media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) ); |
|
1383 entry->SetTObjectValueL( KMPXMediaGeneralCollectionId, collectionId ); |
|
1384 CleanupStack::Pop( entry ); |
|
1385 tracksArray->AppendL( entry ); |
|
1386 } |
|
1387 } |
|
1388 aMedia.SetTObjectValueL<TMPXGeneralType>( KMPXMediaGeneralType, EMPXItem ); |
|
1389 aMedia.SetTObjectValueL<TMPXGeneralCategory>( KMPXMediaGeneralCategory, EMPXPlaylist ); |
|
1390 aMedia.SetCObjectValueL( KMPXMediaArrayContents, tracksArray ); |
|
1391 aMedia.SetTObjectValueL( KMPXMediaArrayCount, tracksArray->Count() ); |
|
1392 |
|
1393 emit q_ptr->aboutToAddSongs( tracksArray->Count() ); |
|
1394 |
|
1395 CleanupStack::PopAndDestroy( tracksArray ); |
|
1396 TX_EXIT |
|
1397 } |
|
1398 |
|
1399 /*! |
|
1400 \internal |
|
1401 TODO: all calls to playback utility should be done via the engine and trough the playback FW wrapper. |
|
1402 */ |
|
1403 void MpMpxCollectionFrameworkWrapperPrivate::createPlaybackUtilityL() |
|
1404 { |
|
1405 if ( !iPlaybackUtility ) { |
|
1406 |
|
1407 iPlaybackUtility = MMPXPlaybackUtility::UtilityL( iHostUid ); |
|
1408 |
|
1409 if ( iShuffleFeature ) { |
|
1410 iPlaybackUtility->SetL( EPbPropertyRandomMode, MpSettingsManager::shuffle() ? ETrue : EFalse ); |
|
1411 } |
|
1412 if ( iRepeatFeature ) { |
|
1413 iPlaybackUtility->SetL( EPbPropertyRepeatMode, MpSettingsManager::repeat() ? EPbRepeatAll : EPbRepeatOff ); |
|
1414 } |
|
1415 } |
|
1416 } |
|
1417 |
|
1418 /*! |
|
1419 \internal |
|
1420 */ |
|
1421 void MpMpxCollectionFrameworkWrapperPrivate::DoPlayAllSongsPlaylistL() |
|
1422 { |
|
1423 TX_ENTRY |
|
1424 CMPXCollectionPath* cpath = iCollectionUtility->Collection().PathL(); |
|
1425 CleanupStack::PushL( cpath ); |
|
1426 CMPXCollectionPlaylist* playList = CMPXCollectionPlaylist::NewL( *cpath ); |
|
1427 CleanupStack::PushL( playList ); |
|
1428 playList->SetShuffleL( true, false ); |
|
1429 MpSettingsManager::setShuffle( true ); |
|
1430 createPlaybackUtilityL(); |
|
1431 iPlaybackUtility->InitL( *playList, ETrue ); |
|
1432 CleanupStack::PopAndDestroy( playList ); |
|
1433 CleanupStack::PopAndDestroy( cpath ); |
|
1434 TX_EXIT |
|
1435 } |
|
1436 |
|
1437 /*! |
|
1438 \internal |
|
1439 */ |
|
1440 void MpMpxCollectionFrameworkWrapperPrivate::DoRetrieveSongDetailsL( int index ) |
|
1441 { |
|
1442 TX_ENTRY |
|
1443 RArray<TMPXAttribute> requestedAttr; |
|
1444 CleanupClosePushL( requestedAttr ); |
|
1445 requestedAttr.AppendL( TMPXAttribute( KMPXMediaGeneralTitle ) ); |
|
1446 requestedAttr.AppendL( TMPXAttribute( KMPXMediaMusicArtist ) ); |
|
1447 requestedAttr.AppendL( TMPXAttribute( KMPXMediaMusicAlbum ) ); |
|
1448 requestedAttr.AppendL( TMPXAttribute( KMPXMediaGeneralUri ) ); |
|
1449 requestedAttr.AppendL( TMPXAttribute( KMPXMediaMusicAlbumArtFileName ) ); |
|
1450 requestedAttr.AppendL( TMPXAttribute( KMPXMediaGeneralMimeType ) ); |
|
1451 requestedAttr.AppendL( TMPXAttribute( KMPXMediaMusicAlbumTrack ) ); |
|
1452 requestedAttr.AppendL( TMPXAttribute( KMPXMediaMusicComposer ) ); |
|
1453 requestedAttr.AppendL( TMPXAttribute( KMPXMediaMusicYear ) ); |
|
1454 requestedAttr.AppendL( TMPXAttribute( KMPXMediaMusicGenre ) ); |
|
1455 requestedAttr.AppendL( TMPXAttribute( KMPXMediaGeneralDuration ) ); |
|
1456 requestedAttr.AppendL( TMPXAttribute( KMPXMediaAudioBitrate ) ); |
|
1457 requestedAttr.AppendL( TMPXAttribute( KMPXMediaAudioSamplerate ) ); |
|
1458 requestedAttr.AppendL( TMPXAttribute( KMPXMediaGeneralCopyright ) ); |
|
1459 requestedAttr.AppendL( TMPXAttribute( KMPXMediaMusicURL ) ); |
|
1460 requestedAttr.AppendL( TMPXAttribute( KMPXMediaDrmProtected ) ); |
|
1461 |
|
1462 CMPXCollectionPath* cpath = iCollectionUtility->Collection().PathL(); |
|
1463 CleanupStack::PushL( cpath ); |
|
1464 TCollectionContext context = iCollectionData->context(); |
|
1465 if ( context == ECollectionContextArtistAlbumsTBone |
|
1466 || context == ECollectionContextAlbumsTBone ) { |
|
1467 CMPXMediaArray *mediaArray; |
|
1468 const CMPXMedia& container = iCollectionData->containerMedia(); |
|
1469 mediaArray = const_cast<CMPXMediaArray*>( container.Value<CMPXMediaArray>( KMPXMediaArrayContents ) ); |
|
1470 int currentAlbumIndex = iCollectionData->currentAlbumIndex(); |
|
1471 CMPXMedia* album( mediaArray->AtL( currentAlbumIndex ) ); |
|
1472 if ( album->IsSupported(KMPXMediaArrayContents) ) { |
|
1473 const CMPXMediaArray* songs = album->Value<CMPXMediaArray>(KMPXMediaArrayContents); |
|
1474 User::LeaveIfNull(const_cast<CMPXMediaArray*>(songs)); |
|
1475 CMPXMedia* song = songs->AtL(index); |
|
1476 TMPXItemId id( song->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) ); |
|
1477 cpath->AppendL( id ); // Top level items of songs |
|
1478 cpath->Set( 0 ); // Select 1st song |
|
1479 } |
|
1480 } |
|
1481 else { |
|
1482 cpath->Set( index ); |
|
1483 } |
|
1484 iCollectionUtility->Collection().MediaL( *cpath, requestedAttr.Array() ); |
|
1485 CleanupStack::PopAndDestroy( cpath ); |
|
1486 CleanupStack::PopAndDestroy( &requestedAttr ); |
|
1487 TX_EXIT |
|
1488 } |
|
1489 |
|
1490 /*! |
|
1491 \internal |
|
1492 */ |
|
1493 void MpMpxCollectionFrameworkWrapperPrivate::DoSavePathL( QByteArray &data ) |
|
1494 { |
|
1495 TX_ENTRY |
|
1496 CBufFlat* buffer = CBufFlat::NewL( 256 ); |
|
1497 CleanupStack::PushL( buffer ); |
|
1498 TBufBuf bufBuf; |
|
1499 bufBuf.Set( *buffer, 0, TBufBuf::EWrite ); |
|
1500 |
|
1501 RWriteStream writeStream( &bufBuf ); |
|
1502 writeStream.PushL(); |
|
1503 |
|
1504 if ( iPlaybackUtility ) { |
|
1505 MMPXSource* source = iPlaybackUtility->Source(); |
|
1506 CMPXCollectionPlaylist* playList( NULL ); |
|
1507 if( source ) { |
|
1508 playList = source->PlaylistL(); |
|
1509 if ( playList ) { |
|
1510 CleanupStack::PushL( playList ); |
|
1511 const CMPXCollectionPath& cpath = playList->Path(); |
|
1512 writeStream << cpath; |
|
1513 writeStream.CommitL(); |
|
1514 CleanupStack::PopAndDestroy( playList ); |
|
1515 } |
|
1516 } |
|
1517 } |
|
1518 data.append(reinterpret_cast<const char*>(buffer->Ptr(0).Ptr()) ,buffer->Ptr(0).Length()); |
|
1519 CleanupStack::PopAndDestroy( 2, buffer ); //writeStream and buffer |
|
1520 TX_EXIT |
|
1521 } |
|
1522 |
|
1523 /*! |
|
1524 \internal |
|
1525 */ |
|
1526 void MpMpxCollectionFrameworkWrapperPrivate::DoRestorePathL( const QByteArray &data ) |
|
1527 { |
|
1528 TX_ENTRY |
|
1529 int dataSize = data.size(); |
|
1530 if ( dataSize > 0 ) { |
|
1531 TPtrC8 activityDataDescriptor( reinterpret_cast<const unsigned char*> ( data.constData() ), data.size() ); |
|
1532 |
|
1533 //Take a copy of the data |
|
1534 CBufFlat* buffer = CBufFlat::NewL( dataSize ); |
|
1535 CleanupStack::PushL( buffer ); |
|
1536 buffer->InsertL( 0, activityDataDescriptor, dataSize ); |
|
1537 |
|
1538 TBufBuf bufBuf; |
|
1539 bufBuf.Set( *buffer, 0, TBufBuf::ERead ); |
|
1540 RReadStream readStream( &bufBuf ); |
|
1541 readStream.PushL(); |
|
1542 |
|
1543 CMPXCollectionPath* cpath( NULL ); |
|
1544 cpath = CMPXCollectionPath::NewL(readStream); |
|
1545 CleanupStack::PushL(cpath); |
|
1546 iRestorePathIndex = 0; |
|
1547 if( cpath->Levels() ) { |
|
1548 iRestorePathIndexId = cpath->Id(); |
|
1549 iRestorePathIndex = cpath->Index(); |
|
1550 cpath->Back(); |
|
1551 } |
|
1552 if ( !iIsolatedCollectionHelper ) { |
|
1553 iIsolatedCollectionHelper = CMpMpxIsolatedCollectionHelper::NewL( this ); |
|
1554 } |
|
1555 iIsolatedCollectionHelper->OpenCollectionL( *cpath, iRestorePathIndex, CMpMpxIsolatedCollectionHelper::RestorePathMode ); |
|
1556 |
|
1557 CleanupStack::PopAndDestroy( cpath ); |
|
1558 CleanupStack::PopAndDestroy( 2, buffer ); //readStream and buffer |
|
1559 } |
|
1560 TX_EXIT |
|
1561 } |
|
1562 |
|
1563 //EOF |