mpxplugins/viewplugins/views/metadataeditordialog/src/mpxmetadataeditordialog.cpp
branchRCL_3
changeset 66 1f1dad4af8f8
parent 53 3de6c4cf6b67
equal deleted inserted replaced
60:bdd9da0d70fe 66:1f1dad4af8f8
    67 #include <mpxconstants.h>
    67 #include <mpxconstants.h>
    68 #include <mpxcollectionhelperfactory.h>
    68 #include <mpxcollectionhelperfactory.h>
    69 #include <mpxcollectionplugin.hrh>
    69 #include <mpxcollectionplugin.hrh>
    70 #include <mpxinternalcrkeys.h>
    70 #include <mpxinternalcrkeys.h>
    71 #include <mpxuser.h>
    71 #include <mpxuser.h>
    72 #include <drmuihandling.h>
       
    73 #include <mpxplaybackutility.h>
       
    74 
       
    75 #include "mpxcommonuihelper.h"
    72 #include "mpxcommonuihelper.h"
    76 #include "mpxmetadataeditordialog.h"
    73 #include "mpxmetadataeditordialog.h"
    77 #include "mpxmetadataeditordialog.hrh"
    74 #include "mpxmetadataeditordialog.hrh"
    78 #include "mpxmetadataeditordialog.hlp.hrh"
    75 #include "mpxmetadataeditordialog.hlp.hrh"
    79 #include "mpxlog.h"
    76 #include "mpxlog.h"
    80 #include <mpxmessagegeneraldefs.h>
    77 #include <drmuihandling.h>
    81 #include <mpxplaybackmessage.h>
    78 #include <mpxplaybackutility.h>
    82 #include <caf/caferr.h>
       
    83 
    79 
    84 // CONSTANTS
    80 // CONSTANTS
    85 const TInt KMPXFileDetailsMaxTitleLen = 32;
    81 const TInt KMPXFileDetailsMaxTitleLen = 32;
    86 const TInt KMPXFileDetailsMaxBufferLen = 255;
    82 const TInt KMPXFileDetailsMaxBufferLen = 255;
    87 const TInt KMPXMinNumDateTrack = 0;
    83 const TInt KMPXMinNumDateTrack = 0;
   195     delete iParam;
   191     delete iParam;
   196     delete iIdle;
   192     delete iIdle;
   197     delete iDrmInfo;
   193     delete iDrmInfo;
   198     if ( iPlaybackUtility ) 
   194     if ( iPlaybackUtility ) 
   199         { 
   195         { 
   200         iPlaybackUtility->RemoveObserverL( *this ); 
       
   201         iPlaybackUtility->CancelRequest(); 
   196         iPlaybackUtility->CancelRequest(); 
   202         iPlaybackUtility->Close(); 
   197         iPlaybackUtility->Close(); 
   203         } 
   198         } 
   204     if ( iCollectionUtility )
   199     if ( iCollectionUtility )
   205         {
   200         {
   618 
   613 
   619             // Fetch the track number
   614             // Fetch the track number
   620             SetControlNumberL( EMPXMetadataEditorDlgCtrlIdTrackNumber,
   615             SetControlNumberL( EMPXMetadataEditorDlgCtrlIdTrackNumber,
   621                 iMedia->ValueText( KMPXMediaMusicAlbumTrack ),
   616                 iMedia->ValueText( KMPXMediaMusicAlbumTrack ),
   622                 KMPXSongDetailsTrackNumMin, KMPXSongDetailsTrackNumMax );
   617                 KMPXSongDetailsTrackNumMin, KMPXSongDetailsTrackNumMax );
   623 				
       
   624            // Fetch the genre
       
   625            SetControlTextL( EMPXMetadataEditorDlgCtrlIdGenre,
       
   626               iMedia->ValueText( KMPXMediaMusicGenre ), KNullDesC );  
       
   627 
   618 
   628             // Fetch the year
   619             // Fetch the year
   629             TInt64 year(0);
   620             TInt64 year(0);
   630             if ( iMedia->IsSupported (KMPXMediaMusicYear ) )
   621             if ( iMedia->IsSupported (KMPXMediaMusicYear ) )
   631                 {
   622                 {
   632                 year = iMedia->ValueTObjectL<TInt64>( KMPXMediaMusicYear );
   623                 year = iMedia->ValueTObjectL<TInt64>( KMPXMediaMusicYear );
   633                 }
   624                 }
   634             TTime yearTime( year);
   625             TTime yearTime( year);
   635             iYear = yearTime.DateTime().Year ( );
   626             iYear = yearTime.DateTime().Year ( );
   636             HBufC* yearBuf = HBufC::NewLC ( KMPXMaxTimeLength );
   627             HBufC* yearBuf = HBufC::NewLC ( KMPXMaxTimeLength );
   637             if ( iYear > 0)
   628             yearBuf->Des().AppendNum ( iYear );
   638                 {    
       
   639                 yearBuf->Des().AppendNum ( iYear );
       
   640                 }
       
   641             SetControlNumberL ( EMPXMetadataEditorDlgCtrlIdYear, *yearBuf,
   629             SetControlNumberL ( EMPXMetadataEditorDlgCtrlIdYear, *yearBuf,
   642                     KMPXSongDetailsYearMin, KMPXSongDetailsYearMax );
   630                     KMPXSongDetailsYearMin, KMPXSongDetailsYearMax );
   643             CleanupStack::PopAndDestroy ( yearBuf );
   631             CleanupStack::PopAndDestroy ( yearBuf );
   644 
   632 
   645            
   633             // Fetch genre
       
   634             FetchGenreL();
       
   635 
   646             // Fetch the comment
   636             // Fetch the comment
   647             SetControlTextL( EMPXMetadataEditorDlgCtrlIdComment,
   637             SetControlTextL( EMPXMetadataEditorDlgCtrlIdComment,
   648                 iMedia->ValueText( KMPXMediaGeneralComment ), KNullDesC );
   638                 iMedia->ValueText( KMPXMediaGeneralComment ), KNullDesC );
   649 
   639 
   650             // Fetch the song name
   640             // Fetch the song name
  2460         }
  2450         }
  2461     else // Dialog launched from NowPlayingView
  2451     else // Dialog launched from NowPlayingView
  2462         {
  2452         {
  2463         // Get the playback utility instance from engine.
  2453         // Get the playback utility instance from engine.
  2464         iPlaybackUtility = MMPXPlaybackUtility::UtilityL( KPbModeDefault );
  2454         iPlaybackUtility = MMPXPlaybackUtility::UtilityL( KPbModeDefault );
  2465         iPlaybackUtility->AddObserverL( *this );
       
  2466         MMPXSource* s = iPlaybackUtility->Source();
  2455         MMPXSource* s = iPlaybackUtility->Source();
  2467         if ( s )
  2456         if ( s )
  2468             {
  2457             {
  2469             RArray<TMPXAttribute> attrs;
  2458             RArray<TMPXAttribute> attrs;
  2470             CleanupClosePushL(attrs);
  2459             CleanupClosePushL(attrs);
  2480                 iCurrentMediaLOp = EMPXMetadataEditorGetSongInfo;
  2469                 iCurrentMediaLOp = EMPXMetadataEditorGetSongInfo;
  2481                 s->MediaL(attrs.Array(), *this);
  2470                 s->MediaL(attrs.Array(), *this);
  2482                 CleanupStack::PopAndDestroy( &attrs );
  2471                 CleanupStack::PopAndDestroy( &attrs );
  2483             }  
  2472             }  
  2484         }
  2473         }
       
  2474     
       
  2475 
       
  2476     // Podcasting is enabled
       
  2477     if ( !iDisablePodcasting )
       
  2478         {
       
  2479         iPopup = static_cast<CAknPopupField*>
       
  2480             ( ControlOrNull( EMPXMetadataEditorDlgCtrlIdLibrary ) );
       
  2481         iLibraryArr = new (ELeave) CDesCArrayFlat( 1 );
       
  2482         HBufC* custTxt = StringLoader::LoadLC( R_MPX_CUI_GENRE_SELECTION_MUSIC_TEXT );
       
  2483         iLibraryArr->AppendL( *custTxt );
       
  2484         CleanupStack::PopAndDestroy( custTxt );
       
  2485         custTxt = StringLoader::LoadLC( R_MPX_CUI_GENRE_SELECTION_PODCAST_TEXT );
       
  2486         iLibraryArr->AppendL( *custTxt );
       
  2487         CleanupStack::PopAndDestroy( custTxt );
       
  2488         iLibraryValueTextArray = CAknQueryValueTextArray::NewL();
       
  2489         iLibraryValueTextArray->SetArray( *iLibraryArr );
       
  2490         iLibraryTextValues = CAknQueryValueText::NewL();
       
  2491         iLibraryTextValues->SetArrayL( iLibraryValueTextArray );
       
  2492         iLibraryTextValues->SetCurrentValueIndex( iCurrentLibrary );
       
  2493         // Set values into popup fields
       
  2494         iPopup->SetQueryValueL( iLibraryTextValues ); // Moved up from below
       
  2495         }
  2485     }
  2496     }
  2486 
  2497 
  2487 // ----------------------------------------------------------------------------
  2498 // ----------------------------------------------------------------------------
  2488 // CMPXMetadataEditorDialog::PostLayoutDynInitL
  2499 // CMPXMetadataEditorDialog::PostLayoutDynInitL
  2489 // Set default field value to member data.
  2500 // Set default field value to member data.
  2492 void CMPXMetadataEditorDialog::PostLayoutDynInitL()
  2503 void CMPXMetadataEditorDialog::PostLayoutDynInitL()
  2493     {
  2504     {
  2494     MPX_FUNC( "CMPXMetadataEditorDialog::PostLayoutDynInitL" );
  2505     MPX_FUNC( "CMPXMetadataEditorDialog::PostLayoutDynInitL" );
  2495     CAknForm::PostLayoutDynInitL();
  2506     CAknForm::PostLayoutDynInitL();
  2496     SetEditableL( EFalse );
  2507     SetEditableL( EFalse );
  2497     }
       
  2498 
       
  2499 // -----------------------------------------------------------------------------
       
  2500 // CMPXMetadataEditorDialog::HandlePlaybackMessage
       
  2501 // Handle playback message.
       
  2502 // ---------------------------------------------------------------------------
       
  2503 //
       
  2504 void CMPXMetadataEditorDialog::HandlePlaybackMessage(
       
  2505     CMPXMessage* aMessage, TInt aError )
       
  2506     {
       
  2507     MPX_DEBUG2 ( "CMPXMetadataEditorDialog::HandlePlaybackMessage aError %d " ,aError );
       
  2508     if ( aError == KErrNone && aMessage )
       
  2509         {
       
  2510         TRAP_IGNORE( DoHandlePlaybackMessageL( *aMessage ) );
       
  2511         }
       
  2512     else if ( aError != KErrNone )
       
  2513         {
       
  2514         TryExitL( EAknSoftkeyExit );
       
  2515         }
       
  2516     }
       
  2517 
       
  2518 
       
  2519 // ---------------------------------------------------------------------------
       
  2520 // CMPXMetadataEditorDialog::HandlePlaybackMessage
       
  2521 // Handle playback message.
       
  2522 // ---------------------------------------------------------------------------
       
  2523 //
       
  2524 void CMPXMetadataEditorDialog::DoHandlePlaybackMessageL(
       
  2525     const CMPXMessage& aMessage )
       
  2526     {
       
  2527     MPX_FUNC( "CMPXMetadataEditorDialog::DoHandlePlaybackMessageL(CMPXMessage)" );
       
  2528 
       
  2529     TMPXMessageId id( aMessage.ValueTObjectL<TMPXMessageId>( KMPXMessageGeneralId ) );
       
  2530     TInt value = aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralEvent );
       
  2531     if ( KMPXMessageGeneral == id && 
       
  2532         ( ( value  == TMPXPlaybackMessage::EMediaChanged ) || ( value  == TMPXPlaybackMessage::ESkipping ) ) )
       
  2533         {
       
  2534         MPX_DEBUG1( "CMPXMetadataEditorDialog::DoHandlePlaybackMessageL Dismissing Details view - change in playing media" );
       
  2535         TryExitL( EAknSoftkeyExit );
       
  2536         }
       
  2537     }
  2508     }
  2538 
  2509 
  2539 // -----------------------------------------------------------------------------
  2510 // -----------------------------------------------------------------------------
  2540 // CMPXMetadataEditorDialog::SaveMediaPropertiesL
  2511 // CMPXMetadataEditorDialog::SaveMediaPropertiesL
  2541 // Saves media back to collection engine
  2512 // Saves media back to collection engine