mpxplugins/viewplugins/views/metadataeditordialog/src/mpxmetadataeditordialog.cpp
branchRCL_3
changeset 50 26a1709b9fec
parent 31 a12246c97fcc
equal deleted inserted replaced
49:455f89b7fcc5 50:26a1709b9fec
    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 
    72 #include "mpxcommonuihelper.h"
    75 #include "mpxcommonuihelper.h"
    73 #include "mpxmetadataeditordialog.h"
    76 #include "mpxmetadataeditordialog.h"
    74 #include "mpxmetadataeditordialog.hrh"
    77 #include "mpxmetadataeditordialog.hrh"
    75 #include "mpxmetadataeditordialog.hlp.hrh"
    78 #include "mpxmetadataeditordialog.hlp.hrh"
    76 #include "mpxlog.h"
    79 #include "mpxlog.h"
    77 #include <drmuihandling.h>
    80 #include <mpxmessagegeneraldefs.h>
    78 #include <mpxplaybackutility.h>
    81 #include <mpxplaybackmessage.h>
       
    82 #include <caf/caferr.h>
    79 
    83 
    80 // CONSTANTS
    84 // CONSTANTS
    81 const TInt KMPXFileDetailsMaxTitleLen = 32;
    85 const TInt KMPXFileDetailsMaxTitleLen = 32;
    82 const TInt KMPXFileDetailsMaxBufferLen = 255;
    86 const TInt KMPXFileDetailsMaxBufferLen = 255;
    83 const TInt KMPXMinNumDateTrack = 0;
    87 const TInt KMPXMinNumDateTrack = 0;
   191     delete iParam;
   195     delete iParam;
   192     delete iIdle;
   196     delete iIdle;
   193     delete iDrmInfo;
   197     delete iDrmInfo;
   194     if ( iPlaybackUtility ) 
   198     if ( iPlaybackUtility ) 
   195         { 
   199         { 
       
   200         iPlaybackUtility->RemoveObserverL( *this ); 
   196         iPlaybackUtility->CancelRequest(); 
   201         iPlaybackUtility->CancelRequest(); 
   197         iPlaybackUtility->Close(); 
   202         iPlaybackUtility->Close(); 
   198         } 
   203         } 
   199     if ( iCollectionUtility )
   204     if ( iCollectionUtility )
   200         {
   205         {
   613 
   618 
   614             // Fetch the track number
   619             // Fetch the track number
   615             SetControlNumberL( EMPXMetadataEditorDlgCtrlIdTrackNumber,
   620             SetControlNumberL( EMPXMetadataEditorDlgCtrlIdTrackNumber,
   616                 iMedia->ValueText( KMPXMediaMusicAlbumTrack ),
   621                 iMedia->ValueText( KMPXMediaMusicAlbumTrack ),
   617                 KMPXSongDetailsTrackNumMin, KMPXSongDetailsTrackNumMax );
   622                 KMPXSongDetailsTrackNumMin, KMPXSongDetailsTrackNumMax );
       
   623 				
       
   624            // Fetch the genre
       
   625            SetControlTextL( EMPXMetadataEditorDlgCtrlIdGenre,
       
   626               iMedia->ValueText( KMPXMediaMusicGenre ), KNullDesC );  
   618 
   627 
   619             // Fetch the year
   628             // Fetch the year
   620             TInt64 year(0);
   629             TInt64 year(0);
   621             if ( iMedia->IsSupported (KMPXMediaMusicYear ) )
   630             if ( iMedia->IsSupported (KMPXMediaMusicYear ) )
   622                 {
   631                 {
   623                 year = iMedia->ValueTObjectL<TInt64>( KMPXMediaMusicYear );
   632                 year = iMedia->ValueTObjectL<TInt64>( KMPXMediaMusicYear );
   624                 }
   633                 }
   625             TTime yearTime( year);
   634             TTime yearTime( year);
   626             iYear = yearTime.DateTime().Year ( );
   635             iYear = yearTime.DateTime().Year ( );
   627             HBufC* yearBuf = HBufC::NewLC ( KMPXMaxTimeLength );
   636             HBufC* yearBuf = HBufC::NewLC ( KMPXMaxTimeLength );
   628             yearBuf->Des().AppendNum ( iYear );
   637             if ( iYear > 0)
       
   638                 {    
       
   639                 yearBuf->Des().AppendNum ( iYear );
       
   640                 }
   629             SetControlNumberL ( EMPXMetadataEditorDlgCtrlIdYear, *yearBuf,
   641             SetControlNumberL ( EMPXMetadataEditorDlgCtrlIdYear, *yearBuf,
   630                     KMPXSongDetailsYearMin, KMPXSongDetailsYearMax );
   642                     KMPXSongDetailsYearMin, KMPXSongDetailsYearMax );
   631             CleanupStack::PopAndDestroy ( yearBuf );
   643             CleanupStack::PopAndDestroy ( yearBuf );
   632 
   644 
   633             // Fetch genre
   645            
   634             FetchGenreL();
       
   635 
       
   636             // Fetch the comment
   646             // Fetch the comment
   637             SetControlTextL( EMPXMetadataEditorDlgCtrlIdComment,
   647             SetControlTextL( EMPXMetadataEditorDlgCtrlIdComment,
   638                 iMedia->ValueText( KMPXMediaGeneralComment ), KNullDesC );
   648                 iMedia->ValueText( KMPXMediaGeneralComment ), KNullDesC );
   639 
   649 
   640             // Fetch the song name
   650             // Fetch the song name
  2450         }
  2460         }
  2451     else // Dialog launched from NowPlayingView
  2461     else // Dialog launched from NowPlayingView
  2452         {
  2462         {
  2453         // Get the playback utility instance from engine.
  2463         // Get the playback utility instance from engine.
  2454         iPlaybackUtility = MMPXPlaybackUtility::UtilityL( KPbModeDefault );
  2464         iPlaybackUtility = MMPXPlaybackUtility::UtilityL( KPbModeDefault );
       
  2465         iPlaybackUtility->AddObserverL( *this );
  2455         MMPXSource* s = iPlaybackUtility->Source();
  2466         MMPXSource* s = iPlaybackUtility->Source();
  2456         if ( s )
  2467         if ( s )
  2457             {
  2468             {
  2458             RArray<TMPXAttribute> attrs;
  2469             RArray<TMPXAttribute> attrs;
  2459             CleanupClosePushL(attrs);
  2470             CleanupClosePushL(attrs);
  2469                 iCurrentMediaLOp = EMPXMetadataEditorGetSongInfo;
  2480                 iCurrentMediaLOp = EMPXMetadataEditorGetSongInfo;
  2470                 s->MediaL(attrs.Array(), *this);
  2481                 s->MediaL(attrs.Array(), *this);
  2471                 CleanupStack::PopAndDestroy( &attrs );
  2482                 CleanupStack::PopAndDestroy( &attrs );
  2472             }  
  2483             }  
  2473         }
  2484         }
  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         }
       
  2496     }
  2485     }
  2497 
  2486 
  2498 // ----------------------------------------------------------------------------
  2487 // ----------------------------------------------------------------------------
  2499 // CMPXMetadataEditorDialog::PostLayoutDynInitL
  2488 // CMPXMetadataEditorDialog::PostLayoutDynInitL
  2500 // Set default field value to member data.
  2489 // Set default field value to member data.
  2503 void CMPXMetadataEditorDialog::PostLayoutDynInitL()
  2492 void CMPXMetadataEditorDialog::PostLayoutDynInitL()
  2504     {
  2493     {
  2505     MPX_FUNC( "CMPXMetadataEditorDialog::PostLayoutDynInitL" );
  2494     MPX_FUNC( "CMPXMetadataEditorDialog::PostLayoutDynInitL" );
  2506     CAknForm::PostLayoutDynInitL();
  2495     CAknForm::PostLayoutDynInitL();
  2507     SetEditableL( EFalse );
  2496     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         }
  2508     }
  2537     }
  2509 
  2538 
  2510 // -----------------------------------------------------------------------------
  2539 // -----------------------------------------------------------------------------
  2511 // CMPXMetadataEditorDialog::SaveMediaPropertiesL
  2540 // CMPXMetadataEditorDialog::SaveMediaPropertiesL
  2512 // Saves media back to collection engine
  2541 // Saves media back to collection engine