mpxplugins/viewplugins/views/metadataeditordialog/src/mpxmetadataeditordialog.cpp
branchRCL_3
changeset 50 26a1709b9fec
parent 31 a12246c97fcc
--- a/mpxplugins/viewplugins/views/metadataeditordialog/src/mpxmetadataeditordialog.cpp	Thu Jul 15 18:35:42 2010 +0300
+++ b/mpxplugins/viewplugins/views/metadataeditordialog/src/mpxmetadataeditordialog.cpp	Thu Aug 19 09:52:08 2010 +0300
@@ -69,13 +69,17 @@
 #include <mpxcollectionplugin.hrh>
 #include <mpxinternalcrkeys.h>
 #include <mpxuser.h>
+#include <drmuihandling.h>
+#include <mpxplaybackutility.h>
+
 #include "mpxcommonuihelper.h"
 #include "mpxmetadataeditordialog.h"
 #include "mpxmetadataeditordialog.hrh"
 #include "mpxmetadataeditordialog.hlp.hrh"
 #include "mpxlog.h"
-#include <drmuihandling.h>
-#include <mpxplaybackutility.h>
+#include <mpxmessagegeneraldefs.h>
+#include <mpxplaybackmessage.h>
+#include <caf/caferr.h>
 
 // CONSTANTS
 const TInt KMPXFileDetailsMaxTitleLen = 32;
@@ -193,6 +197,7 @@
     delete iDrmInfo;
     if ( iPlaybackUtility ) 
         { 
+        iPlaybackUtility->RemoveObserverL( *this ); 
         iPlaybackUtility->CancelRequest(); 
         iPlaybackUtility->Close(); 
         } 
@@ -615,6 +620,10 @@
             SetControlNumberL( EMPXMetadataEditorDlgCtrlIdTrackNumber,
                 iMedia->ValueText( KMPXMediaMusicAlbumTrack ),
                 KMPXSongDetailsTrackNumMin, KMPXSongDetailsTrackNumMax );
+				
+           // Fetch the genre
+           SetControlTextL( EMPXMetadataEditorDlgCtrlIdGenre,
+              iMedia->ValueText( KMPXMediaMusicGenre ), KNullDesC );  
 
             // Fetch the year
             TInt64 year(0);
@@ -625,14 +634,15 @@
             TTime yearTime( year);
             iYear = yearTime.DateTime().Year ( );
             HBufC* yearBuf = HBufC::NewLC ( KMPXMaxTimeLength );
-            yearBuf->Des().AppendNum ( iYear );
+            if ( iYear > 0)
+                {    
+                yearBuf->Des().AppendNum ( iYear );
+                }
             SetControlNumberL ( EMPXMetadataEditorDlgCtrlIdYear, *yearBuf,
                     KMPXSongDetailsYearMin, KMPXSongDetailsYearMax );
             CleanupStack::PopAndDestroy ( yearBuf );
 
-            // Fetch genre
-            FetchGenreL();
-
+           
             // Fetch the comment
             SetControlTextL( EMPXMetadataEditorDlgCtrlIdComment,
                 iMedia->ValueText( KMPXMediaGeneralComment ), KNullDesC );
@@ -2452,6 +2462,7 @@
         {
         // Get the playback utility instance from engine.
         iPlaybackUtility = MMPXPlaybackUtility::UtilityL( KPbModeDefault );
+        iPlaybackUtility->AddObserverL( *this );
         MMPXSource* s = iPlaybackUtility->Source();
         if ( s )
             {
@@ -2471,28 +2482,6 @@
                 CleanupStack::PopAndDestroy( &attrs );
             }  
         }
-    
-
-    // Podcasting is enabled
-    if ( !iDisablePodcasting )
-        {
-        iPopup = static_cast<CAknPopupField*>
-            ( ControlOrNull( EMPXMetadataEditorDlgCtrlIdLibrary ) );
-        iLibraryArr = new (ELeave) CDesCArrayFlat( 1 );
-        HBufC* custTxt = StringLoader::LoadLC( R_MPX_CUI_GENRE_SELECTION_MUSIC_TEXT );
-        iLibraryArr->AppendL( *custTxt );
-        CleanupStack::PopAndDestroy( custTxt );
-        custTxt = StringLoader::LoadLC( R_MPX_CUI_GENRE_SELECTION_PODCAST_TEXT );
-        iLibraryArr->AppendL( *custTxt );
-        CleanupStack::PopAndDestroy( custTxt );
-        iLibraryValueTextArray = CAknQueryValueTextArray::NewL();
-        iLibraryValueTextArray->SetArray( *iLibraryArr );
-        iLibraryTextValues = CAknQueryValueText::NewL();
-        iLibraryTextValues->SetArrayL( iLibraryValueTextArray );
-        iLibraryTextValues->SetCurrentValueIndex( iCurrentLibrary );
-        // Set values into popup fields
-        iPopup->SetQueryValueL( iLibraryTextValues ); // Moved up from below
-        }
     }
 
 // ----------------------------------------------------------------------------
@@ -2508,6 +2497,46 @@
     }
 
 // -----------------------------------------------------------------------------
+// CMPXMetadataEditorDialog::HandlePlaybackMessage
+// Handle playback message.
+// ---------------------------------------------------------------------------
+//
+void CMPXMetadataEditorDialog::HandlePlaybackMessage(
+    CMPXMessage* aMessage, TInt aError )
+    {
+    MPX_DEBUG2 ( "CMPXMetadataEditorDialog::HandlePlaybackMessage aError %d " ,aError );
+    if ( aError == KErrNone && aMessage )
+        {
+        TRAP_IGNORE( DoHandlePlaybackMessageL( *aMessage ) );
+        }
+    else if ( aError != KErrNone )
+        {
+        TryExitL( EAknSoftkeyExit );
+        }
+    }
+
+
+// ---------------------------------------------------------------------------
+// CMPXMetadataEditorDialog::HandlePlaybackMessage
+// Handle playback message.
+// ---------------------------------------------------------------------------
+//
+void CMPXMetadataEditorDialog::DoHandlePlaybackMessageL(
+    const CMPXMessage& aMessage )
+    {
+    MPX_FUNC( "CMPXMetadataEditorDialog::DoHandlePlaybackMessageL(CMPXMessage)" );
+
+    TMPXMessageId id( aMessage.ValueTObjectL<TMPXMessageId>( KMPXMessageGeneralId ) );
+    TInt value = aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralEvent );
+    if ( KMPXMessageGeneral == id && 
+        ( ( value  == TMPXPlaybackMessage::EMediaChanged ) || ( value  == TMPXPlaybackMessage::ESkipping ) ) )
+        {
+        MPX_DEBUG1( "CMPXMetadataEditorDialog::DoHandlePlaybackMessageL Dismissing Details view - change in playing media" );
+        TryExitL( EAknSoftkeyExit );
+        }
+    }
+
+// -----------------------------------------------------------------------------
 // CMPXMetadataEditorDialog::SaveMediaPropertiesL
 // Saves media back to collection engine
 // -----------------------------------------------------------------------------