|
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 framework utilities. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <xqsharablefile.h> |
|
19 #include <EqualizerConstants.h> |
|
20 |
|
21 #include "mpengine.h" |
|
22 #include "mpmpxharvesterframeworkwrapper.h" |
|
23 #include "mpmpxcollectionframeworkwrapper.h" |
|
24 #include "mpmpxplaybackframeworkwrapper.h" |
|
25 #include "mpaudioeffectsframeworkwrapper.h" |
|
26 #include "mpequalizerframeworkwrapper.h" |
|
27 #include "mptrace.h" |
|
28 #include "mpsettingsmanager.h" |
|
29 #include "mpsongscanner.h" |
|
30 #include "mpsongdata.h" |
|
31 |
|
32 /*! |
|
33 \class MpEngine |
|
34 \brief Engine for musicplayer - mpx framework utilities. |
|
35 |
|
36 MP Engine provides Qt style interface to the MPX framework |
|
37 utilities. Its implementation is hidden using private class data pattern. |
|
38 */ |
|
39 |
|
40 /*! |
|
41 ------------------------------------------------------------------------------- |
|
42 Harvesting related signals |
|
43 ------------------------------------------------------------------------------- |
|
44 */ |
|
45 |
|
46 /*! |
|
47 \fn void libraryAboutToUpdate() |
|
48 |
|
49 This signal is emitted when a scan operation has been requested or |
|
50 when MTP synchronization starts. |
|
51 |
|
52 */ |
|
53 |
|
54 /*! |
|
55 \fn void libraryUpdated() |
|
56 |
|
57 This signal is emitted when library has changed. |
|
58 |
|
59 \sa handleScanEnded() |
|
60 \sa handleDiskEvent() |
|
61 \sa handleUsbMtpEndEvent() |
|
62 |
|
63 */ |
|
64 |
|
65 /*! |
|
66 \fn void usbBlocked( bool blocked ) |
|
67 |
|
68 This signal is emitted to update the usb blocking state |
|
69 due a previous usb event received. |
|
70 |
|
71 \sa handleUsbEvent() |
|
72 |
|
73 */ |
|
74 |
|
75 /*! |
|
76 \fn void unableToCotinueDueUSB() |
|
77 |
|
78 This signal is emitted if usb blocking verification returns true. |
|
79 |
|
80 \sa verifyUsbBlocking() |
|
81 |
|
82 */ |
|
83 |
|
84 /*! |
|
85 \fn void usbSynchronizationStarted() |
|
86 |
|
87 This signal is emitted when usb is connected in MassStorage mode or MTP mode and synchronizing. |
|
88 |
|
89 */ |
|
90 |
|
91 /*! |
|
92 \fn void usbSynchronizationFinished() |
|
93 |
|
94 This signal is emitted when usb in synchronizing state is disconnected. |
|
95 |
|
96 */ |
|
97 |
|
98 |
|
99 /*! |
|
100 ------------------------------------------------------------------------------- |
|
101 Collection related signals |
|
102 ------------------------------------------------------------------------------- |
|
103 */ |
|
104 |
|
105 /*! |
|
106 \fn void collectionPlaylistOpened() |
|
107 |
|
108 This signal is emitted when A new collection playlist is opened and |
|
109 playback is initialized. |
|
110 |
|
111 */ |
|
112 |
|
113 /*! |
|
114 \fn void playlistSaved( bool success ) |
|
115 |
|
116 This signal is emitted when playlist save operation is completed, it |
|
117 indicates the operation \a success . |
|
118 |
|
119 */ |
|
120 |
|
121 /*! |
|
122 \fn void aboutToAddSongs( int count ) |
|
123 |
|
124 Signal emitted up on a notification from MPX Collection wrapper, |
|
125 when play list is prepared and about to be added. |
|
126 \a count Indicates number of songs to be added. |
|
127 |
|
128 */ |
|
129 |
|
130 /*! |
|
131 \fn void deleteStarted(TCollectionContext context, int Count) |
|
132 |
|
133 This signal is emitted when song delete operation has started. |
|
134 \a context The context where delete operation is taking place. |
|
135 \a Count Number of items to delete. |
|
136 |
|
137 */ |
|
138 |
|
139 /*! |
|
140 \fn void songsDeleted( bool success ) |
|
141 |
|
142 This signal is emitted when song delete operation is completed, it |
|
143 indicates the operation \a success . |
|
144 |
|
145 */ |
|
146 |
|
147 /*! |
|
148 \fn void playlistsRenamed( bool success ) |
|
149 |
|
150 This signal is emitted when playlist rename operation is completed, it |
|
151 indicates the operation \a success . |
|
152 |
|
153 */ |
|
154 |
|
155 /*! |
|
156 \fn void isolatedCollectionOpened( MpMpxCollectionData* collectionData ) |
|
157 |
|
158 This signal is emitted when an isolated collection is opened on \a context |
|
159 |
|
160 */ |
|
161 |
|
162 /*! |
|
163 \fn void restorePathFailed() |
|
164 |
|
165 This signal is emitted when an the previous path cannot be restored |
|
166 (i.e. no music in collection). |
|
167 |
|
168 */ |
|
169 |
|
170 /*! |
|
171 \fn void containerContentsChanged() |
|
172 |
|
173 This signal is emitted when items are removed or inserted on the current |
|
174 container. |
|
175 |
|
176 */ |
|
177 |
|
178 /*! |
|
179 ------------------------------------------------------------------------------- |
|
180 Playback related signals |
|
181 ------------------------------------------------------------------------------- |
|
182 */ |
|
183 |
|
184 /*! |
|
185 \fn void volumePropertyChanged( MpCommon::MpVolumeProperty, int value ); |
|
186 |
|
187 This signal is emitted when framework receives a volume related property notification, |
|
188 such as EPbPropertyVolume, EPbPropertyMaxVolume, EPbPropertyMute. |
|
189 */ |
|
190 |
|
191 /*! |
|
192 \fn void corruptedStop(); |
|
193 |
|
194 This signal is emitted when framework determines the corrupted song is the last |
|
195 song of the playlist. |
|
196 */ |
|
197 |
|
198 /*! |
|
199 Constructs music player engine. |
|
200 */ |
|
201 MpEngine::MpEngine() |
|
202 : mMpxHarvesterWrapper(0), |
|
203 mSongScanner(0), |
|
204 mMpxCollectionWrapper(0), |
|
205 mMpxPlaybackWrapper(0), |
|
206 mAudioEffectsWrapper(0), |
|
207 mEqualizerWrapper(0), |
|
208 mCurrentPresetIndex(0), |
|
209 mSongData(0), |
|
210 mUsbBlockingState(USB_NotConnected), |
|
211 mPreviousUsbState(USB_NotConnected), |
|
212 mHandleMediaCommands(true) |
|
213 { |
|
214 TX_LOG |
|
215 } |
|
216 |
|
217 /*! |
|
218 Destructs music player engine. |
|
219 */ |
|
220 MpEngine::~MpEngine() |
|
221 { |
|
222 TX_ENTRY |
|
223 delete mMpxPlaybackWrapper; |
|
224 delete mMpxHarvesterWrapper; |
|
225 delete mMpxCollectionWrapper; |
|
226 delete mAudioEffectsWrapper; |
|
227 delete mEqualizerWrapper; |
|
228 delete mSongScanner; |
|
229 delete mSongData; |
|
230 TX_EXIT |
|
231 } |
|
232 |
|
233 /*! |
|
234 Initialize engine |
|
235 */ |
|
236 void MpEngine::initialize( TUid hostUid, EngineMode mode ) |
|
237 { |
|
238 TX_ENTRY_ARGS("hostUid=" << hostUid.iUid << ", mode=" << mode); |
|
239 mHostUid = hostUid; |
|
240 |
|
241 if ( StandAlone == mode ) { |
|
242 mSongData = new MpSongData(); |
|
243 |
|
244 // Harvesting Wrapper |
|
245 mMpxHarvesterWrapper = new MpMpxHarvesterFrameworkWrapper( mHostUid ); |
|
246 connect( mMpxHarvesterWrapper, SIGNAL( scanStarted() ), |
|
247 this, SLOT( handleScanStarted() ), |
|
248 Qt::QueuedConnection ); |
|
249 connect( mMpxHarvesterWrapper, SIGNAL( scanEnded(int, int) ), |
|
250 this, SLOT( handleScanEnded(int, int) ), |
|
251 Qt::QueuedConnection ); |
|
252 qRegisterMetaType<MpxDiskEvents>("MpxDiskEvents"); |
|
253 connect( mMpxHarvesterWrapper, SIGNAL( diskEvent(MpxDiskEvents) ), |
|
254 this, SLOT( handleDiskEvent(MpxDiskEvents) ), |
|
255 Qt::QueuedConnection ); |
|
256 qRegisterMetaType<MpxUsbEvents>("MpxUsbEvents"); |
|
257 connect( mMpxHarvesterWrapper, SIGNAL( usbEvent(MpxUsbEvents) ), |
|
258 this, SLOT( handleUsbEvent(MpxUsbEvents) ), |
|
259 Qt::QueuedConnection ); |
|
260 |
|
261 // Collection Wrapper |
|
262 mMpxCollectionWrapper = new MpMpxCollectionFrameworkWrapper( mHostUid, mSongData ); |
|
263 connect( mMpxCollectionWrapper, SIGNAL( collectionPlaylistOpened() ), |
|
264 this, SIGNAL( collectionPlaylistOpened() ), |
|
265 Qt::QueuedConnection ); |
|
266 connect( mMpxCollectionWrapper, SIGNAL( aboutToAddSongs(int) ), |
|
267 this, SIGNAL( aboutToAddSongs(int) ) ); |
|
268 connect( mMpxCollectionWrapper, SIGNAL( playlistSaved(bool) ), |
|
269 this, SIGNAL( playlistSaved(bool) ), |
|
270 Qt::QueuedConnection ); |
|
271 connect( mMpxCollectionWrapper, SIGNAL( playlistsRenamed(bool) ), |
|
272 this, SIGNAL( playlistsRenamed(bool) ), |
|
273 Qt::QueuedConnection ); |
|
274 connect( mMpxCollectionWrapper, SIGNAL( isolatedCollectionOpened(MpMpxCollectionData*) ), |
|
275 this, SIGNAL( isolatedCollectionOpened(MpMpxCollectionData*) ), |
|
276 Qt::QueuedConnection ); |
|
277 connect( mMpxCollectionWrapper, SIGNAL( containerContentsChanged() ), |
|
278 this, SIGNAL( containerContentsChanged() ), |
|
279 Qt::QueuedConnection ); |
|
280 connect( mMpxCollectionWrapper, SIGNAL( deleteStarted(TCollectionContext, int) ), |
|
281 this, SLOT( handleDeleteStarted(TCollectionContext, int) ) ); |
|
282 connect( mMpxCollectionWrapper, SIGNAL( songsDeleted(bool) ), |
|
283 this, SLOT( handleDeleteEnded(bool) ), |
|
284 Qt::QueuedConnection ); |
|
285 connect( mMpxCollectionWrapper, SIGNAL( restorePathFailed() ), |
|
286 this, SIGNAL( restorePathFailed() ), |
|
287 Qt::QueuedConnection ); |
|
288 // Equalizer wrapper; this needs to be created before playback wrapper. |
|
289 mEqualizerWrapper = new MpEqualizerFrameworkWrapper(); |
|
290 connect( mEqualizerWrapper, SIGNAL( equalizerReady() ), |
|
291 this, SLOT( handleEqualizerReady() ), |
|
292 Qt::QueuedConnection ); |
|
293 |
|
294 // Playback Wrapper |
|
295 mMpxPlaybackWrapper = new MpMpxPlaybackFrameworkWrapper( mHostUid, mSongData ); |
|
296 connect( this, SIGNAL( libraryUpdated() ), |
|
297 mMpxPlaybackWrapper, SLOT( closeCurrentPlayback() ) ); |
|
298 connect( mMpxPlaybackWrapper, SIGNAL ( corruptedStop() ), |
|
299 this, SIGNAL( corruptedStop() )); |
|
300 connect( mMpxPlaybackWrapper, SIGNAL( volumePropertyChanged( MpCommon::MpVolumeProperty, int ) ), |
|
301 this, SIGNAL( volumePropertyChanged( MpCommon::MpVolumeProperty, int ) ) ); |
|
302 |
|
303 // AudioEffects wrapper |
|
304 mAudioEffectsWrapper = new MpAudioEffectsFrameworkWrapper(); |
|
305 } |
|
306 else if ( Fetch == mode ) { |
|
307 // Harvesting Wrapper |
|
308 mMpxHarvesterWrapper = new MpMpxHarvesterFrameworkWrapper( mHostUid ); |
|
309 connect( mMpxHarvesterWrapper, SIGNAL( scanStarted() ), |
|
310 this, SLOT( handleScanStarted() ), |
|
311 Qt::QueuedConnection ); |
|
312 connect( mMpxHarvesterWrapper, SIGNAL( scanEnded(int, int) ), |
|
313 this, SLOT( handleScanEnded(int, int) ), |
|
314 Qt::QueuedConnection ); |
|
315 qRegisterMetaType<MpxDiskEvents>("MpxDiskEvents"); |
|
316 connect( mMpxHarvesterWrapper, SIGNAL( diskEvent(MpxDiskEvents) ), |
|
317 this, SLOT( handleDiskEvent(MpxDiskEvents) ), |
|
318 Qt::QueuedConnection ); |
|
319 qRegisterMetaType<MpxUsbEvents>("MpxUsbEvents"); |
|
320 connect( mMpxHarvesterWrapper, SIGNAL( usbEvent(MpxUsbEvents) ), |
|
321 this, SLOT( handleUsbEvent(MpxUsbEvents) ), |
|
322 Qt::QueuedConnection ); |
|
323 |
|
324 // Collection Wrapper |
|
325 mMpxCollectionWrapper = new MpMpxCollectionFrameworkWrapper( mHostUid, 0 ); |
|
326 connect( mMpxCollectionWrapper, SIGNAL( collectionPlaylistOpened() ), |
|
327 this, SIGNAL( collectionPlaylistOpened() ), |
|
328 Qt::QueuedConnection ); |
|
329 // Disabling these since fetch mode plays only one song at a time. |
|
330 mMpxCollectionWrapper->setRepeatFeatureEnabled( false ); |
|
331 mMpxCollectionWrapper->setShuffleFeatureEnabled( false ); |
|
332 |
|
333 // Playback Wrapper |
|
334 mMpxPlaybackWrapper = new MpMpxPlaybackFrameworkWrapper( mHostUid, 0 ); |
|
335 connect( this, SIGNAL( libraryUpdated() ), |
|
336 mMpxPlaybackWrapper, SLOT( closeCurrentPlayback() ) ); |
|
337 connect( mMpxPlaybackWrapper, SIGNAL ( corruptedStop() ), |
|
338 this, SIGNAL( corruptedStop() )); |
|
339 connect( mMpxPlaybackWrapper, SIGNAL( volumePropertyChanged( MpCommon::MpVolumeProperty, int ) ), |
|
340 this, SIGNAL( volumePropertyChanged( MpCommon::MpVolumeProperty, int ) ) ); |
|
341 |
|
342 } |
|
343 else if ( MediaBrowsing == mode ) { |
|
344 // Collection Wrapper |
|
345 mMpxCollectionWrapper = new MpMpxCollectionFrameworkWrapper( mHostUid, 0 ); |
|
346 connect( mMpxCollectionWrapper, SIGNAL( collectionPlaylistOpened() ), |
|
347 this, SIGNAL( collectionPlaylistOpened() ), |
|
348 Qt::QueuedConnection ); |
|
349 connect( mMpxCollectionWrapper, SIGNAL( containerContentsChanged() ), |
|
350 this, SIGNAL( containerContentsChanged() ), |
|
351 Qt::QueuedConnection ); |
|
352 } |
|
353 else if ( Embedded == mode ) { |
|
354 mSongData = new MpSongData(); |
|
355 // Playback Wrapper |
|
356 mMpxPlaybackWrapper = new MpMpxPlaybackFrameworkWrapper( mHostUid, mSongData ); |
|
357 connect( mMpxPlaybackWrapper, SIGNAL( volumePropertyChanged( MpCommon::MpVolumeProperty, int ) ), |
|
358 this, SIGNAL( volumePropertyChanged( MpCommon::MpVolumeProperty, int ) ) ); |
|
359 |
|
360 } |
|
361 TX_EXIT |
|
362 } |
|
363 |
|
364 /*! |
|
365 ------------------------------------------------------------------------------- |
|
366 Harvesting related |
|
367 ------------------------------------------------------------------------------- |
|
368 */ |
|
369 |
|
370 /*! |
|
371 \ |
|
372 Used to verify if an action can be executed depending on USB blocking state. |
|
373 If not, a notification note might be displayed. |
|
374 */ |
|
375 bool MpEngine::verifyUsbBlocking( bool notify ) |
|
376 { |
|
377 TX_ENTRY |
|
378 bool result( false ); |
|
379 if ( mUsbBlockingState == USB_Connected ) { |
|
380 result = true; |
|
381 if ( notify ) { |
|
382 emit unableToCotinueDueUSB(); |
|
383 } |
|
384 } |
|
385 TX_EXIT |
|
386 return result; |
|
387 } |
|
388 |
|
389 /*! |
|
390 \ |
|
391 Request Harvester to check if there are any system events active. |
|
392 */ |
|
393 void MpEngine::checkForSystemEvents() |
|
394 { |
|
395 TX_ENTRY |
|
396 mMpxHarvesterWrapper->checkForSystemEvents(); |
|
397 TX_EXIT |
|
398 } |
|
399 |
|
400 /*! |
|
401 \ |
|
402 Returs the current songScanner instance |
|
403 */ |
|
404 MpSongScanner *MpEngine::songScanner() |
|
405 { |
|
406 return mSongScanner; |
|
407 } |
|
408 /*! |
|
409 Slot to be called to start Refresh library process. |
|
410 If scanning is already ongoing, this request is ignored. |
|
411 */ |
|
412 void MpEngine::refreshLibrary( bool automaticRequest ) |
|
413 { |
|
414 TX_ENTRY |
|
415 if ( !verifyUsbBlocking( true ) ) { |
|
416 if ( !mSongScanner ) { |
|
417 mSongScanner = new MpSongScanner( mMpxHarvesterWrapper ); |
|
418 } |
|
419 emit libraryAboutToUpdate(); |
|
420 mSongScanner->scan( automaticRequest ); |
|
421 } |
|
422 TX_EXIT |
|
423 } |
|
424 |
|
425 /*! |
|
426 Slot to be called when song scanning starts. |
|
427 */ |
|
428 void MpEngine::handleScanStarted() { |
|
429 TX_ENTRY |
|
430 mHandleMediaCommands = false; |
|
431 TX_EXIT |
|
432 } |
|
433 |
|
434 /*! |
|
435 Slot to be called when song scanning ends. |
|
436 */ |
|
437 void MpEngine::handleScanEnded( int count, int error ) { |
|
438 TX_ENTRY |
|
439 Q_UNUSED( count ); |
|
440 Q_UNUSED( error ); |
|
441 mHandleMediaCommands = true; |
|
442 emit libraryUpdated(); |
|
443 TX_EXIT |
|
444 } |
|
445 |
|
446 /*! |
|
447 Slot to be called when disk event is received from MPX framework. |
|
448 */ |
|
449 void MpEngine::handleDiskEvent( MpxDiskEvents event ) |
|
450 { |
|
451 TX_ENTRY_ARGS("event=" << event); |
|
452 switch ( event ) { |
|
453 case DiskFormatStarted: |
|
454 mHandleMediaCommands = false; |
|
455 break; |
|
456 case DiskFormatEnded: |
|
457 mHandleMediaCommands = true; |
|
458 break; |
|
459 case DiskRemoved: |
|
460 if ( mUsbBlockingState != USB_Synchronizing ) { |
|
461 emit libraryUpdated(); |
|
462 } |
|
463 break; |
|
464 case DiskInserted: |
|
465 if ( mUsbBlockingState == USB_NotConnected ) { |
|
466 refreshLibrary( true ); |
|
467 } |
|
468 else if ( mUsbBlockingState == USB_Connected ) { |
|
469 emit libraryUpdated(); |
|
470 } |
|
471 break; |
|
472 default: |
|
473 break; |
|
474 } |
|
475 TX_EXIT |
|
476 } |
|
477 |
|
478 /*! |
|
479 Slot to be called when USB event is received from MPX framework. |
|
480 */ |
|
481 void MpEngine::handleUsbEvent( MpxUsbEvents event ) |
|
482 { |
|
483 TX_ENTRY_ARGS("event=" << event); |
|
484 switch ( event ) { |
|
485 case UsbMassStorageStarted: |
|
486 handleUsbMassStorageStartEvent(); |
|
487 break; |
|
488 case UsbMassStorageEnded: |
|
489 handleUsbMassStorageEndEvent(); |
|
490 break; |
|
491 case UsbMtpStarted: |
|
492 handleUsbMtpStartEvent(); |
|
493 break; |
|
494 case UsbMtpEnded: |
|
495 handleUsbMtpEndEvent(); |
|
496 break; |
|
497 case UsbMtpNotActive: |
|
498 handleUsbMtpNotActive(); |
|
499 default: |
|
500 break; |
|
501 } |
|
502 TX_EXIT |
|
503 } |
|
504 |
|
505 /*! |
|
506 To be called when EMcMsgUSBMassStorageStart event is received. |
|
507 */ |
|
508 void MpEngine::handleUsbMassStorageStartEvent() |
|
509 { |
|
510 TX_ENTRY |
|
511 mHandleMediaCommands = false; |
|
512 |
|
513 changeUsbBlockingState( USB_Synchronizing ); |
|
514 emit usbBlocked(true); |
|
515 emit usbSynchronizationStarted(); |
|
516 |
|
517 TX_EXIT |
|
518 } |
|
519 |
|
520 /*! |
|
521 To be called when EMcMsgUSBMassStorageEnd event is received. |
|
522 */ |
|
523 void MpEngine::handleUsbMassStorageEndEvent() |
|
524 { |
|
525 TX_ENTRY |
|
526 mHandleMediaCommands = true; |
|
527 |
|
528 changeUsbBlockingState( USB_NotConnected ); |
|
529 emit usbBlocked(false); |
|
530 emit usbSynchronizationFinished(); |
|
531 refreshLibrary(); |
|
532 |
|
533 TX_EXIT |
|
534 } |
|
535 |
|
536 /*! |
|
537 To be called when EMcMsgUSBMTPStart event is received. |
|
538 */ |
|
539 void MpEngine::handleUsbMtpStartEvent() |
|
540 { |
|
541 TX_ENTRY |
|
542 mHandleMediaCommands = false; |
|
543 |
|
544 changeUsbBlockingState( USB_Synchronizing ); |
|
545 emit usbBlocked(true); |
|
546 |
|
547 //Cancel any ongoing operation. |
|
548 emit libraryAboutToUpdate(); |
|
549 |
|
550 emit usbSynchronizationStarted(); |
|
551 |
|
552 TX_EXIT |
|
553 } |
|
554 |
|
555 /*! |
|
556 To be called when EMcMsgUSBMTPEnd event is received. |
|
557 */ |
|
558 void MpEngine::handleUsbMtpEndEvent() |
|
559 { |
|
560 TX_ENTRY |
|
561 mHandleMediaCommands = true; |
|
562 |
|
563 changeUsbBlockingState( USB_NotConnected ); |
|
564 emit usbBlocked(false); |
|
565 |
|
566 if ( mPreviousUsbState == USB_Synchronizing ) { |
|
567 emit usbSynchronizationFinished(); |
|
568 emit libraryUpdated(); |
|
569 } |
|
570 TX_EXIT |
|
571 } |
|
572 |
|
573 /*! |
|
574 To be called when EMcMsgUSBMTPNotActive event is received. |
|
575 */ |
|
576 void MpEngine::handleUsbMtpNotActive() |
|
577 { |
|
578 TX_ENTRY |
|
579 changeUsbBlockingState( USB_Connected ); |
|
580 emit usbBlocked(true); |
|
581 TX_EXIT |
|
582 } |
|
583 |
|
584 /*! |
|
585 Internal |
|
586 Update the new and previous usb blocking state |
|
587 */ |
|
588 void MpEngine::changeUsbBlockingState( UsbBlockingState state ) |
|
589 { |
|
590 TX_ENTRY |
|
591 mPreviousUsbState = mUsbBlockingState; |
|
592 mUsbBlockingState = state; |
|
593 TX_EXIT |
|
594 } |
|
595 |
|
596 /*! |
|
597 ------------------------------------------------------------------------------- |
|
598 Collection related |
|
599 ------------------------------------------------------------------------------- |
|
600 */ |
|
601 |
|
602 /*! |
|
603 Opens the collection for the given \a context. |
|
604 |
|
605 \sa collectionOpened() |
|
606 */ |
|
607 void MpEngine::openCollection( TCollectionContext context ) |
|
608 { |
|
609 mMpxCollectionWrapper->openCollection( context ); |
|
610 } |
|
611 |
|
612 /*! |
|
613 Opens the collection at a specific \a index. |
|
614 |
|
615 \sa collectionOpened(), playlistOpened() |
|
616 */ |
|
617 void MpEngine::openCollectionItem( int index ) |
|
618 { |
|
619 mMpxCollectionWrapper->openCollectionItem( index ); |
|
620 } |
|
621 |
|
622 /*! |
|
623 Navigates back to the container of the current items. |
|
624 |
|
625 \sa collectionOpened() |
|
626 */ |
|
627 void MpEngine::back() |
|
628 { |
|
629 mMpxCollectionWrapper->back(); |
|
630 } |
|
631 |
|
632 /*! |
|
633 Loads the user created \a playLists. |
|
634 |
|
635 */ |
|
636 void MpEngine::findPlaylists( QStringList &playlists ) |
|
637 { |
|
638 mMpxCollectionWrapper->findPlaylists( playlists ); |
|
639 } |
|
640 |
|
641 /*! |
|
642 Creates a new playlist with name \a playlistName and adds \a selection and optionally uses \a collectionData. |
|
643 */ |
|
644 void MpEngine::createPlaylist( QString &playlistName, QList<int> &selection, MpMpxCollectionData* collectionData ) |
|
645 { |
|
646 if ( !verifyUsbBlocking( true ) ) { |
|
647 mMpxCollectionWrapper->createPlaylist( playlistName, selection, collectionData ); |
|
648 } |
|
649 } |
|
650 |
|
651 /*! |
|
652 Adds \a selection to the playlist specified in \a playlistIndex. |
|
653 */ |
|
654 void MpEngine::saveToPlaylist( int playlistIndex, QList<int> &selection ) |
|
655 { |
|
656 if ( !verifyUsbBlocking( true ) ) { |
|
657 mMpxCollectionWrapper->saveToPlaylist( playlistIndex, selection ); |
|
658 } |
|
659 } |
|
660 |
|
661 /*! |
|
662 Rename a playlist by \a index with \a name. |
|
663 */ |
|
664 void MpEngine::renamePlaylist( QString &newName, int index ) |
|
665 { |
|
666 if ( !verifyUsbBlocking( true ) ) { |
|
667 mMpxCollectionWrapper->renamePlaylist( newName, index ); |
|
668 } |
|
669 } |
|
670 |
|
671 /*! |
|
672 Adds \a selection to the current playlist from the specified \a collectionData. |
|
673 */ |
|
674 void MpEngine::saveToCurrentPlaylist( QList<int> &selection, MpMpxCollectionData *collectionData ) |
|
675 { |
|
676 if ( !verifyUsbBlocking( true ) ) { |
|
677 mMpxCollectionWrapper->saveToCurrentPlaylist( selection, collectionData ); |
|
678 } |
|
679 } |
|
680 |
|
681 /*! |
|
682 Rename a playlist with \a name. |
|
683 */ |
|
684 void MpEngine::renamePlaylist( QString &newName ) |
|
685 { |
|
686 if ( !verifyUsbBlocking( true ) ) { |
|
687 mMpxCollectionWrapper->renamePlaylist( newName ); |
|
688 } |
|
689 } |
|
690 |
|
691 /*! |
|
692 Deletes \a selection from the collection. |
|
693 */ |
|
694 void MpEngine::deleteSongs( QList<int> &selection ) |
|
695 { |
|
696 if ( !verifyUsbBlocking( true ) ) { |
|
697 mMpxCollectionWrapper->deleteSongs( selection ); |
|
698 } |
|
699 } |
|
700 |
|
701 |
|
702 |
|
703 /*! |
|
704 Initiate a playback preview for the selected item. |
|
705 */ |
|
706 void MpEngine::previewItem( int index ) |
|
707 { |
|
708 mMpxCollectionWrapper->previewItem( index ); |
|
709 } |
|
710 |
|
711 |
|
712 /*! |
|
713 Opens the an isolated collection with \a context. |
|
714 \sa isolatedCollectionOpened() |
|
715 */ |
|
716 void MpEngine::openIsolatedCollection( TCollectionContext context ) |
|
717 { |
|
718 if ( !verifyUsbBlocking( true ) ) { |
|
719 mMpxCollectionWrapper->openIsolatedCollection( context ); |
|
720 } |
|
721 } |
|
722 |
|
723 /*! |
|
724 Releases the resources used for the isolated collection. |
|
725 */ |
|
726 void MpEngine::releaseIsolatedCollection() |
|
727 { |
|
728 mMpxCollectionWrapper->releaseIsolatedCollection(); |
|
729 } |
|
730 |
|
731 /*! |
|
732 Finds all songs beloging to the album specified by the \a index. |
|
733 */ |
|
734 void MpEngine::findAlbumSongs( int index ) |
|
735 { |
|
736 mMpxCollectionWrapper->findAlbumSongs(index); |
|
737 } |
|
738 |
|
739 /*! |
|
740 Plays album with \a albumIndex starting with the songs with \a songIndex. |
|
741 */ |
|
742 void MpEngine::playAlbumSongs( int albumIndex, int songIndex, MpMpxCollectionData* collectionData ) |
|
743 { |
|
744 mMpxCollectionWrapper->playAlbumSongs(albumIndex, songIndex, collectionData); |
|
745 } |
|
746 |
|
747 /*! |
|
748 Returns pointer to MpMpxCollectionData, which is the collection data. |
|
749 */ |
|
750 MpMpxCollectionData *MpEngine::collectionData() |
|
751 { |
|
752 return mMpxCollectionWrapper->collectionData(); |
|
753 } |
|
754 |
|
755 /*! |
|
756 Slot to be called to reopen the collection in its current state. |
|
757 |
|
758 \sa collectionOpened() |
|
759 */ |
|
760 void MpEngine::reopenCollection() |
|
761 { |
|
762 mMpxCollectionWrapper->reopenCollection(); |
|
763 } |
|
764 |
|
765 /*! |
|
766 Slot to be called to request a reorder operation , indicates that |
|
767 the item with \a playlistId , \a songId is to be moved from |
|
768 \a originalOrdinal to \a newOrdinal. |
|
769 */ |
|
770 void MpEngine::reorderPlaylist( int playlistId, int songId, int originalOrdinal, int newOrdinal ) |
|
771 { |
|
772 mMpxCollectionWrapper->reorderPlaylist( playlistId, songId, originalOrdinal, newOrdinal ); |
|
773 } |
|
774 |
|
775 /*! |
|
776 Slot to be called when song deleting starts. |
|
777 */ |
|
778 void MpEngine::handleDeleteStarted( TCollectionContext context, int count ) |
|
779 { |
|
780 TX_ENTRY |
|
781 mHandleMediaCommands = false; |
|
782 emit deleteStarted( context, count ); |
|
783 TX_EXIT |
|
784 } |
|
785 |
|
786 /*! |
|
787 Slot to be called when song deleting ends. |
|
788 */ |
|
789 void MpEngine::handleDeleteEnded( bool success ) |
|
790 { |
|
791 TX_ENTRY |
|
792 mHandleMediaCommands = true; |
|
793 emit songsDeleted( success ); |
|
794 TX_EXIT |
|
795 } |
|
796 |
|
797 /*! |
|
798 Slot to be called when song deleting ends. |
|
799 */ |
|
800 void MpEngine::cancelCollectionRequest() |
|
801 { |
|
802 TX_ENTRY |
|
803 mMpxCollectionWrapper->cancelRequest(); |
|
804 TX_EXIT |
|
805 } |
|
806 |
|
807 /*! |
|
808 Returns pointer to MpPlaybackData, which is the playback data. |
|
809 */ |
|
810 MpPlaybackData *MpEngine::playbackData() |
|
811 { |
|
812 return mMpxPlaybackWrapper->playbackData(); |
|
813 } |
|
814 |
|
815 /*! |
|
816 Requests playback of all songs with shuffle enabled |
|
817 */ |
|
818 void MpEngine::shuffleAll() |
|
819 { |
|
820 mMpxCollectionWrapper->openShuffleAllSongsPath(); |
|
821 } |
|
822 |
|
823 /*! |
|
824 Slot to be called to request embedded playback of item with Uri aFilename |
|
825 */ |
|
826 |
|
827 void MpEngine::playEmbedded( QString aFilename ) |
|
828 { |
|
829 mMpxPlaybackWrapper->play( aFilename ); |
|
830 } |
|
831 |
|
832 /*! |
|
833 Slot to be called to request embedded playback of item with file handle |
|
834 */ |
|
835 |
|
836 void MpEngine::playEmbedded(const XQSharableFile& file ) |
|
837 { |
|
838 mMpxPlaybackWrapper->play( file ); |
|
839 } |
|
840 |
|
841 /*! |
|
842 Slot to handle a play command |
|
843 */ |
|
844 |
|
845 void MpEngine::play() |
|
846 { |
|
847 if ( mHandleMediaCommands ) { |
|
848 mMpxPlaybackWrapper->play(); |
|
849 } |
|
850 } |
|
851 |
|
852 /*! |
|
853 Slot to handle a pause command. |
|
854 */ |
|
855 void MpEngine::pause() |
|
856 { |
|
857 if ( mHandleMediaCommands ) { |
|
858 mMpxPlaybackWrapper->pause(); |
|
859 } |
|
860 } |
|
861 |
|
862 /*! |
|
863 Slot to handle a play pause. |
|
864 */ |
|
865 void MpEngine::playPause() |
|
866 { |
|
867 if ( mHandleMediaCommands ) { |
|
868 mMpxPlaybackWrapper->playPause(); |
|
869 } |
|
870 } |
|
871 |
|
872 /*! |
|
873 Slot to handle a stop. |
|
874 */ |
|
875 void MpEngine::stop() |
|
876 { |
|
877 if ( mHandleMediaCommands ) { |
|
878 mMpxPlaybackWrapper->stop(); |
|
879 } |
|
880 } |
|
881 |
|
882 /*! |
|
883 Slot to handle a skip forward. |
|
884 */ |
|
885 void MpEngine::skipForward() |
|
886 { |
|
887 if ( mHandleMediaCommands ) { |
|
888 mMpxPlaybackWrapper->skipForward(); |
|
889 } |
|
890 } |
|
891 |
|
892 /*! |
|
893 Slot to handle seek forward. |
|
894 */ |
|
895 void MpEngine::startSeekForward() |
|
896 { |
|
897 if ( mHandleMediaCommands ) { |
|
898 mMpxPlaybackWrapper->startSeekForward(); |
|
899 } |
|
900 } |
|
901 |
|
902 /*! |
|
903 Slot to handle stop seeking. |
|
904 */ |
|
905 void MpEngine::stopSeeking() |
|
906 { |
|
907 if ( mHandleMediaCommands ) { |
|
908 mMpxPlaybackWrapper->stopSeeking(); |
|
909 } |
|
910 } |
|
911 |
|
912 /*! |
|
913 Slot to handle a skip backwards. |
|
914 */ |
|
915 void MpEngine::skipBackward() |
|
916 { |
|
917 if ( mHandleMediaCommands ) { |
|
918 mMpxPlaybackWrapper->skipBackward(); |
|
919 } |
|
920 } |
|
921 |
|
922 /*! |
|
923 Slot to handle seek backwards. |
|
924 */ |
|
925 void MpEngine::startSeekBackward() |
|
926 { |
|
927 if ( mHandleMediaCommands ) { |
|
928 mMpxPlaybackWrapper->startSeekBackward(); |
|
929 } |
|
930 } |
|
931 /*! |
|
932 Slot to handle a request to change \a position. |
|
933 */ |
|
934 void MpEngine::setPosition( int position ) |
|
935 { |
|
936 mMpxPlaybackWrapper->setPosition( position ); |
|
937 } |
|
938 |
|
939 /*! |
|
940 Slot to handle a request to change shuffle \a mode. |
|
941 */ |
|
942 void MpEngine::setShuffle( bool mode ) |
|
943 { |
|
944 mMpxPlaybackWrapper->setShuffle( mode ); |
|
945 } |
|
946 |
|
947 /*! |
|
948 Slot to handle a request to change repeat \a mode. |
|
949 */ |
|
950 void MpEngine::setRepeat( bool mode ) |
|
951 { |
|
952 mMpxPlaybackWrapper->setRepeat( mode ); |
|
953 } |
|
954 |
|
955 /*! |
|
956 Slot to handle a request to get the volume level Max. |
|
957 Response will be asynchronously sent through volumePropertyChanged() signal. |
|
958 */ |
|
959 void MpEngine::getMaxVolume( ) |
|
960 { |
|
961 mMpxPlaybackWrapper->getMaxVolume(); |
|
962 } |
|
963 |
|
964 /*! |
|
965 Slot to handle a request to get the current volume level. |
|
966 Response will be asynchronously sent through volumePropertyChanged() signal. |
|
967 */ |
|
968 void MpEngine::getVolume( ) |
|
969 { |
|
970 mMpxPlaybackWrapper->getVolume(); |
|
971 } |
|
972 |
|
973 /*! |
|
974 Slot to handle a request to increase volume. |
|
975 */ |
|
976 void MpEngine::increaseVolume() |
|
977 { |
|
978 if ( mHandleMediaCommands ) { |
|
979 mMpxPlaybackWrapper->increaseVolume(); |
|
980 } |
|
981 } |
|
982 |
|
983 /*! |
|
984 Slot to handle a request to decrease volume. |
|
985 */ |
|
986 void MpEngine::decreaseVolume() |
|
987 { |
|
988 if ( mHandleMediaCommands ) { |
|
989 mMpxPlaybackWrapper->decreaseVolume(); |
|
990 } |
|
991 } |
|
992 |
|
993 /*! |
|
994 Slot to handle a request to set the volume level. |
|
995 */ |
|
996 void MpEngine::setVolume( int value ) |
|
997 { |
|
998 if ( mHandleMediaCommands ) { |
|
999 mMpxPlaybackWrapper->setVolume( value ); |
|
1000 } |
|
1001 } |
|
1002 |
|
1003 /*! |
|
1004 Slot to handle a request to get the current mute state. |
|
1005 Response will be asynchronously sent through volumePropertyChanged() signal. |
|
1006 */ |
|
1007 void MpEngine::getMuteState( ) |
|
1008 { |
|
1009 mMpxPlaybackWrapper->getMuteState(); |
|
1010 } |
|
1011 |
|
1012 /*! |
|
1013 Slot to handle a request to mute. |
|
1014 */ |
|
1015 void MpEngine::mute() |
|
1016 { |
|
1017 if ( mHandleMediaCommands ) { |
|
1018 mMpxPlaybackWrapper->mute(); |
|
1019 } |
|
1020 } |
|
1021 |
|
1022 /*! |
|
1023 Slot to handle a request to unmute. |
|
1024 */ |
|
1025 void MpEngine::unmute() |
|
1026 { |
|
1027 if ( mHandleMediaCommands ) { |
|
1028 mMpxPlaybackWrapper->unmute(); |
|
1029 } |
|
1030 } |
|
1031 |
|
1032 /*! |
|
1033 Returns pointer to MpSongData, which is the song data for Details View. |
|
1034 */ |
|
1035 MpSongData *MpEngine::songData() |
|
1036 { |
|
1037 return mSongData; |
|
1038 } |
|
1039 |
|
1040 /*! |
|
1041 Retrieves song details for the specified \a index. |
|
1042 */ |
|
1043 void MpEngine::retrieveSongDetails( int index ) |
|
1044 { |
|
1045 TX_ENTRY |
|
1046 if ( index == -1 ) { |
|
1047 // Retrieve song details of currently playing song |
|
1048 mMpxPlaybackWrapper->retrieveSongDetails(); |
|
1049 } |
|
1050 else { |
|
1051 mMpxCollectionWrapper->retrieveSongDetails(index); |
|
1052 } |
|
1053 TX_EXIT |
|
1054 } |
|
1055 |
|
1056 /*! |
|
1057 Retrieve balance informatioin from audio effects |
|
1058 */ |
|
1059 int MpEngine::balance() |
|
1060 { |
|
1061 return mAudioEffectsWrapper->balance(); |
|
1062 } |
|
1063 |
|
1064 /*! |
|
1065 Retrieve loudness informatioin from audio effects |
|
1066 */ |
|
1067 bool MpEngine::loudness() |
|
1068 { |
|
1069 return mAudioEffectsWrapper->loudness(); |
|
1070 } |
|
1071 |
|
1072 /*! |
|
1073 Slot to handle a request to change \a balance in audio effects. |
|
1074 */ |
|
1075 void MpEngine::setBalance( int balance ) |
|
1076 { |
|
1077 TX_ENTRY |
|
1078 |
|
1079 if ( mAudioEffectsWrapper->balance() != balance ) { |
|
1080 mAudioEffectsWrapper->setBalance( balance ); |
|
1081 mMpxPlaybackWrapper->setBalance( balance ); |
|
1082 } |
|
1083 |
|
1084 TX_EXIT |
|
1085 } |
|
1086 |
|
1087 /*! |
|
1088 Slot to handle a request to change loudness \a mode in audio effects. |
|
1089 */ |
|
1090 void MpEngine::setLoudness( bool mode ) |
|
1091 { |
|
1092 TX_ENTRY |
|
1093 |
|
1094 if( mAudioEffectsWrapper->loudness() != mode ) { //do not set same value twice |
|
1095 mAudioEffectsWrapper->setLoudness( mode ); |
|
1096 mMpxPlaybackWrapper->applyAudioEffects(); |
|
1097 } |
|
1098 |
|
1099 TX_EXIT |
|
1100 } |
|
1101 |
|
1102 /*! |
|
1103 Apply the preset by giving \a presetIndex. The index is subtracted by 1 because |
|
1104 index 0 represent "Off" at UI level. |
|
1105 */ |
|
1106 void MpEngine::applyPreset( int presetIndex ) |
|
1107 { |
|
1108 TX_ENTRY_ARGS( "presetIndex=" << presetIndex ); |
|
1109 |
|
1110 TInt presetKey = mEqualizerWrapper->getPresetNameKey( presetIndex - 1 ); |
|
1111 |
|
1112 if ( presetKey != KEqualizerPresetNone ) { |
|
1113 TX_LOG_ARGS( "Preset key in engine =" << presetKey ); |
|
1114 // Store in CenRep file |
|
1115 MpSettingsManager::setPreset( presetKey ); |
|
1116 // Notify playback framework of the change. |
|
1117 mMpxPlaybackWrapper->applyEqualizer(); |
|
1118 mCurrentPresetIndex = presetIndex; |
|
1119 } |
|
1120 else { |
|
1121 TX_LOG_ARGS("getPresetNameKey Error = " << KEqualizerPresetNone); |
|
1122 } |
|
1123 |
|
1124 TX_EXIT |
|
1125 } |
|
1126 |
|
1127 /*! |
|
1128 Disabling equalizer by setting the preset to -1 and apply it to |
|
1129 disable current preset. |
|
1130 */ |
|
1131 void MpEngine::disableEqualizer() |
|
1132 { |
|
1133 TX_ENTRY |
|
1134 |
|
1135 mCurrentPresetIndex = 0; |
|
1136 // Store in CenRep file |
|
1137 MpSettingsManager::setPreset( KEqualizerPresetNone ); |
|
1138 // Notify playback framework of the change. |
|
1139 mMpxPlaybackWrapper->applyEqualizer(); |
|
1140 |
|
1141 TX_EXIT |
|
1142 } |
|
1143 |
|
1144 /*! |
|
1145 Return current preset index (UI) |
|
1146 */ |
|
1147 int MpEngine::activePreset() |
|
1148 { |
|
1149 TX_LOG_ARGS("mCurrentPresetIndex = " << mCurrentPresetIndex ); |
|
1150 |
|
1151 return mCurrentPresetIndex; |
|
1152 } |
|
1153 |
|
1154 /*! |
|
1155 Retrieve list of preset names from equalizer wrapper |
|
1156 */ |
|
1157 QStringList MpEngine::presetNames() |
|
1158 { |
|
1159 return mEqualizerWrapper->presetNames(); |
|
1160 } |
|
1161 |
|
1162 /*! |
|
1163 Save data needed to later restore state (activity) |
|
1164 */ |
|
1165 void MpEngine::saveActivityData( QByteArray &data ) |
|
1166 { |
|
1167 mMpxCollectionWrapper->savePath( data ); |
|
1168 } |
|
1169 |
|
1170 /*! |
|
1171 Restore state from activity data |
|
1172 */ |
|
1173 void MpEngine::loadActivityData( const QByteArray &data ) |
|
1174 { |
|
1175 mMpxCollectionWrapper->restorePath( data ); |
|
1176 } |
|
1177 |
|
1178 /*! |
|
1179 Slot to handle equalizer ready signal from equalizer wrapper. |
|
1180 */ |
|
1181 void MpEngine::handleEqualizerReady() |
|
1182 { |
|
1183 TX_ENTRY |
|
1184 |
|
1185 // Get preset id from cenrep |
|
1186 TInt presetKey( MpSettingsManager::preset() ); |
|
1187 |
|
1188 mCurrentPresetIndex = mEqualizerWrapper->getPresetIndex( presetKey ); |
|
1189 emit equalizerReady(); |
|
1190 |
|
1191 TX_EXIT |
|
1192 } |
|
1193 |