musichomescreen_multiview/mcpmusicplayer/src/mcpmusicplayer.cpp
branchRCL_3
changeset 14 943ff5625028
parent 2 b70d77332e66
child 17 c8156a91d13c
--- a/musichomescreen_multiview/mcpmusicplayer/src/mcpmusicplayer.cpp	Fri Feb 19 22:48:30 2010 +0200
+++ b/musichomescreen_multiview/mcpmusicplayer/src/mcpmusicplayer.cpp	Fri Mar 12 15:42:25 2010 +0200
@@ -677,6 +677,7 @@
             case EMPlayerStatePlaying:
                 {
                 MPX_DEBUG1("CMCPMusicPlayer::DoUpdatePlayerStateL EMPlayerStatePlaying");
+                iMusicPlayerOpeningTimer->Cancel();
                 UpdateToolBarL(TBK::KSkeep_L|TBK::KPause|TBK::KSkeep_R);
                 break;
                 }
@@ -697,7 +698,7 @@
             case EMPlayerStateStopped:
                 {
                 MPX_DEBUG1("CMCPMusicPlayer::DoUpdatePlayerStateL EMPlayerStateStopped");
-                if ( iUSBOnGoing )
+                if ( iBlockingOperationOngoing )
                     {
                     UpdateToolBarL( TBK::KSkeep_L_dimmed |
                             TBK::KPlay_dimmed |
@@ -1209,11 +1210,15 @@
     TInt type = aMsg.ValueTObjectL<TInt> ( KMPXMessageGeneralType );
     MPX_DEBUG3("--->CMCPMusicPlayer::DoHandleGeneralMessageL(), event = %d, type = %d", event, type);
 
+    
     if ( event == TMPXCollectionMessage::EBroadcastEvent
-        && ( type == EMcMsgUSBMassStorageStart || type == EMcMsgUSBMTPStart ))
+        && ( type == EMcMsgUSBMassStorageStart || 
+             type == EMcMsgUSBMTPStart ||
+             type == EMcMsgRefreshStart ))
         {
-        iUSBOnGoing = ETrue;
-        MPX_DEBUG2("CMCPMusicPlayer::DoHandleGeneralMessageL(), iUSBOnGoing changed to: %d", iUSBOnGoing );
+        iBlockingOperationOngoing = ETrue;
+        MPX_DEBUG2("CMCPMusicPlayer::DoHandleGeneralMessageL(), iBlockingOperationOngoing changed to: %d", 
+                  iBlockingOperationOngoing );
         UpdateToolBarL( TBK::KSkeep_L_dimmed |
                 TBK::KPlay_dimmed |
                 TBK::KSkeep_R_dimmed );
@@ -1223,10 +1228,13 @@
             }
         }
     else if ( event == TMPXCollectionMessage::EBroadcastEvent
-            && ( type == EMcMsgUSBMassStorageEnd || type == EMcMsgUSBMTPEnd ))
+            && ( type == EMcMsgUSBMassStorageEnd || 
+                 type == EMcMsgUSBMTPEnd ||
+                 type == EMcMsgRefreshEnd ))
         {
-        iUSBOnGoing = EFalse;
-        MPX_DEBUG2("CMCPMusicPlayer::DoHandleGeneralMessageL(), iUSBOnGoing changed to: %d", iUSBOnGoing );
+        iBlockingOperationOngoing = EFalse;
+        MPX_DEBUG2("CMCPMusicPlayer::DoHandleGeneralMessageL(), iBlockingOperationOngoing changed to: %d", 
+                   iBlockingOperationOngoing );
         DoUpdatePlayerStateL( iEngine->PlayerState() );
         if ( IsOKToPublishData() )
             {
@@ -1297,31 +1305,12 @@
 //
 TInt CMCPMusicPlayer::MusicPlayerOpeningTimerCallback( TAny* aPtr )
     {
-    MPX_DEBUG1("CMCPMusicPlayer::MusicPlayerOpeningTimerCallback <---");
-    RWsSession wsSession;
-    TInt error = wsSession.Connect();
-    if ( error != KErrNone )
-        {
-        return error;
-        }
-    
-    TBool taskExists( EFalse );
-    CAknTaskList* taskList( NULL );
-    TRAPD( err, taskList = CAknTaskList::NewL( wsSession ) );
-    if ( err == KErrNone )
+    MPX_DEBUG1("CMCPMusicPlayer::MusicPlayerOpeningTimerCallback <---");     
+    if ( EMPlayerStatePlaying != static_cast<CMCPMusicPlayer*>(aPtr)->iEngine->PlayerState() )
         {
-        MPX_DEBUG2("CMCPMusicPlayer::MusicPlayerOpeningTimerCallback "
-                "error = %d occur when creating CAknTaskList", err);
-        TApaTask task = taskList->FindRootApp( TUid::Uid( KMusicPlayerAppUidAsTInt ) );
-        delete taskList;
-        taskExists = task.Exists();
-        }
-    wsSession.Close();
-    
-    if ( !taskExists )
-        {
-        MPX_DEBUG1("CMCPMusicPlayer::MusicPlayerOpeningTimerCallback Music Player not opened");
-        //Reset the widget and menu, music player is not running
+        MPX_DEBUG1("CMCPMusicPlayer::MusicPlayerOpeningTimerCallback Music Player not Playing");
+        //Reset the widget and menu, music player is not running and playing.
+        static_cast<CMCPMusicPlayer*>(aPtr)->iActive = EFalse;
         TRAP_IGNORE( static_cast<CMCPMusicPlayer*>(aPtr)->ResetL() );
         }
     static_cast<CMCPMusicPlayer*>(aPtr)->iMusicPlayerOpeningTimer->Cancel();