mpxplugins/viewplugins/views/upnpplaybackview/src/mpxupnpplaybackviewimp.cpp
changeset 0 ff3acec5bc43
child 2 b70d77332e66
equal deleted inserted replaced
-1:000000000000 0:ff3acec5bc43
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Implementation of Upnp Playback view
       
    15 *  Version     : %version: da1mmcf#35.1.3.1.4 % << Don't touch! Updated by Synergy at check-out.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <aknViewAppUi.h>
       
    23 #include <eikmenub.h>
       
    24 #include <StringLoader.h>
       
    25 #include <eikapp.h>
       
    26 #include <AknUtils.h>
       
    27 #include <akntitle.h>
       
    28 #include <akntoolbar.h>
       
    29 #include <bautils.h>
       
    30 #include <data_caging_path_literals.hrh>
       
    31 #include <aknnotewrappers.h> // CAknErrorNote
       
    32 #include <ctsydomainpskeys.h> // KTelephonyCallState
       
    33 #include <e32property.h>  // RProperty
       
    34 #include <featmgr.h>
       
    35 
       
    36 #include <mpxplaybackmessage.h>
       
    37 #include <mpxplaybackutility.h>
       
    38 #include <mpxviewutility.h>
       
    39 #include <mpxviewpluginmanager.h>
       
    40 #include <mpxviewplugin.h>
       
    41 #include <mpxmusicplayerviewplugin.hrh>
       
    42 #include <mpxmessagegeneraldefs.h>
       
    43 #include <mpxcollectionplaylist.h>
       
    44 #include <mpxcollectionpath.h>
       
    45 #include <mpxcollectionutility.h>
       
    46 #include <mpxmediamusicdefs.h>
       
    47 #include <mpxcommonplaybackview.rsg>
       
    48 #include <mpxupnpplaybackview.rsg>
       
    49 #include <mpxuser.h>
       
    50 #include "mpxcommonplaybackview.hrh"
       
    51 #include "mpxcommonuihelper.h"
       
    52 #include "mpxupnpplaybackview.hrh"
       
    53 #include "mpxupnpplaybackviewimp.h"
       
    54 #include "mpxupnpplaybackviewcontainer.h"
       
    55 #include "mpxupnpplaybackviewlayout.h"
       
    56 #include "mpxlog.h"
       
    57 #include "mpxconstants.h"
       
    58 
       
    59 
       
    60 // CONSTANTS
       
    61 _LIT( KMPXUpnpPlaybackRscPath, "mpxupnpplaybackview.rsc" );
       
    62 const TUid KMPXUpnpNPVImpmentationUid = { 0x101FFC99 };
       
    63 
       
    64 
       
    65 // ======== MEMBER FUNCTIONS ========
       
    66 
       
    67 // ---------------------------------------------------------------------------
       
    68 // C++ default constructor can NOT contain any code, that
       
    69 // might leave.
       
    70 // ---------------------------------------------------------------------------
       
    71 //
       
    72 CMPXUPnPPlaybackViewImp::CMPXUPnPPlaybackViewImp()
       
    73     {
       
    74     // Do nothing
       
    75     }
       
    76 
       
    77 // ---------------------------------------------------------------------------
       
    78 // Symbian 2nd phase constructor can leave.
       
    79 // ---------------------------------------------------------------------------
       
    80 //
       
    81 void CMPXUPnPPlaybackViewImp::ConstructL()
       
    82     {
       
    83     MPX_FUNC( "CMPXUPnPPlaybackViewImp::ConstructL" );
       
    84 
       
    85     CMPXCommonPlaybackViewImp::ConstructL();
       
    86 
       
    87     // Override base class setting to allow
       
    88     // upnp playback to properly fetch media properties.
       
    89     iLastPBViewActivated = ETrue;
       
    90 
       
    91     CCoeEnv* coeEnv = iEikonEnv;
       
    92     TParse parse;
       
    93     parse.Set( KMPXUpnpPlaybackRscPath, &KDC_APP_RESOURCE_DIR, NULL );
       
    94     TFileName resourceFile = parse.FullName();
       
    95     User::LeaveIfError( MPXUser::CompleteWithDllPath( resourceFile ) );
       
    96     BaflUtils::NearestLanguageFile( coeEnv->FsSession(), resourceFile );
       
    97     iUpnpResourceOffset = coeEnv->AddResourceFileL( resourceFile );
       
    98 
       
    99     iPodcastPlayback = EFalse;
       
   100 
       
   101     BaseConstructL( R_MPX_UPNP_PLAYBACK_VIEW );
       
   102 	if ( AknLayoutUtils::PenEnabled() )
       
   103         {
       
   104         CAknView::ShowToolbarOnViewActivation(ETrue);
       
   105         if ( Toolbar() )
       
   106             {
       
   107             iToolbar = Toolbar();
       
   108             iToolbar->SetToolbarObserver( this );
       
   109             }
       
   110         }
       
   111     }
       
   112 
       
   113 // ---------------------------------------------------------------------------
       
   114 // Two-phased constructor.
       
   115 // ---------------------------------------------------------------------------
       
   116 //
       
   117 CMPXUPnPPlaybackViewImp* CMPXUPnPPlaybackViewImp::NewL()
       
   118     {
       
   119     CMPXUPnPPlaybackViewImp* self = CMPXUPnPPlaybackViewImp::NewLC();
       
   120     CleanupStack::Pop( self );
       
   121     return self;
       
   122     }
       
   123 
       
   124 // ---------------------------------------------------------------------------
       
   125 // Two-phased constructor.
       
   126 // ---------------------------------------------------------------------------
       
   127 //
       
   128 CMPXUPnPPlaybackViewImp* CMPXUPnPPlaybackViewImp::NewLC()
       
   129     {
       
   130     CMPXUPnPPlaybackViewImp* self = new ( ELeave ) CMPXUPnPPlaybackViewImp();
       
   131     CleanupStack::PushL( self );
       
   132     self->ConstructL();
       
   133     return self;
       
   134     }
       
   135 
       
   136 // ---------------------------------------------------------------------------
       
   137 // Destructor
       
   138 // ---------------------------------------------------------------------------
       
   139 //
       
   140 CMPXUPnPPlaybackViewImp::~CMPXUPnPPlaybackViewImp()
       
   141     {
       
   142     MPX_DEBUG1( "CMPXUPnPPlaybackViewImp::~CMPXUPnPPlaybackViewImp entering" );
       
   143 
       
   144     delete iPlaybackViewLayout;
       
   145 
       
   146     if ( iUpnpResourceOffset )
       
   147         {
       
   148         iEikonEnv->DeleteResourceFile( iUpnpResourceOffset );
       
   149         }
       
   150 
       
   151     if ( iLoadingWaitNote )
       
   152         {
       
   153         iLoadingWaitNote->Cancel();
       
   154         delete iLoadingWaitNote;
       
   155         }
       
   156     MPX_DEBUG1( "CMPXUPnPPlaybackViewImp::~CMPXUPnPPlaybackViewImp exiting" );
       
   157     }
       
   158 
       
   159 
       
   160 // ---------------------------------------------------------------------------
       
   161 // Handle playback message.
       
   162 // ---------------------------------------------------------------------------
       
   163 //
       
   164 void CMPXUPnPPlaybackViewImp::DoHandlePlaybackMessageL(
       
   165     const CMPXMessage& aMessage )
       
   166     {
       
   167     MPX_FUNC( "CMPXUPnPPlaybackViewImp::DoHandlePlaybackMessageL" );
       
   168 
       
   169     TMPXMessageId id( aMessage.ValueTObjectL<TMPXMessageId>( KMPXMessageGeneralId ) );
       
   170     if ( KMPXMessageGeneral == id )
       
   171         {
       
   172         TInt type( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralType ) );
       
   173         TInt data( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralData ) );
       
   174         switch ( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralEvent ) )
       
   175             {
       
   176             case TMPXPlaybackMessage::EError:
       
   177                 {
       
   178                 TInt error( data );
       
   179                 if ( KErrNone != error )
       
   180                     {
       
   181                     UpdateTitlePaneL();
       
   182                     DismissWaitNoteL();
       
   183                     }
       
   184                 break;
       
   185                 }
       
   186             case TMPXPlaybackMessage::ESubPlayersChanged:
       
   187             case TMPXPlaybackMessage::EPlayerChanged:
       
   188                 {
       
   189                 MPX_DEBUG2( "HandlePlaybackMessageL - ESubPlayersChanged(%d)", type );
       
   190                 UpdateTitlePaneL();
       
   191                 break;
       
   192                 }
       
   193             case TMPXPlaybackMessage::EPlayerUnavailable:
       
   194                 {
       
   195                 MPX_DEBUG2( "HandlePlaybackMessageL - EPlayerUnavailable(%d)", type );
       
   196                 TUid activeView = iViewUtility->ActiveViewType();
       
   197                 if ( activeView == TUid::Uid( KMPXPluginTypePlaybackUid ) )
       
   198                     {
       
   199                     if ( data == KErrNotFound )
       
   200                         {
       
   201                         if ( iSubPlayerName )
       
   202                             {
       
   203                             HBufC* dialogText = StringLoader::LoadLC(
       
   204                                                 R_MPX_NOTE_REMOTE_CONNECTION_FAILED,
       
   205                                                 *iSubPlayerName );
       
   206                             CAknErrorNote* errNote = new(ELeave) CAknErrorNote(ETrue);
       
   207                             errNote->SetTimeout(CAknNoteDialog::ELongTimeout);
       
   208                             errNote->ExecuteLD( *dialogText );
       
   209                             CleanupStack::PopAndDestroy( dialogText );
       
   210                             }
       
   211                         }
       
   212 
       
   213                     // Remove from view utility's stack so that activating the
       
   214                     // previous view will not activate this one.
       
   215                     // have to use plugin implementation UID
       
   216                     CMPXViewPlugin* p = iViewUtility->ViewPluginManager().PluginL( KMPXUpnpNPVImpmentationUid );
       
   217                     p->DeactivateView();
       
   218                     }
       
   219                 break;
       
   220                 }
       
   221             case TMPXPlaybackMessage::EInitializeComplete:
       
   222                 {
       
   223                 DismissWaitNoteL();
       
   224                 break;
       
   225                 }
       
   226             case TMPXPlaybackMessage::EAccessoryChanged:
       
   227                 {
       
   228                 MPX_DEBUG2( "HandlePlaybackMessageL - EAccessoryChanged(%d)", type );
       
   229 
       
   230                 // Get call status and type.
       
   231                 TInt callState( EPSCTsyCallStateUninitialized );
       
   232 
       
   233                 // Ignore error
       
   234                 RProperty::Get( KPSUidCtsyCallInformation,
       
   235                                 KCTsyCallState,
       
   236                                 callState );
       
   237                 MPX_DEBUG2("CMPXUPnPPlaybackViewImp EAccessoryChanged call state: %d", callState );
       
   238 
       
   239                 if ( callState != EPSCTsyCallStateConnected )
       
   240                     {
       
   241                     TMPXPlaybackAccessoryMode mode( static_cast<TMPXPlaybackAccessoryMode>( type ));
       
   242                     TBool resetToLocal( EFalse );
       
   243 #ifdef __ACCESSORY_FW
       
   244                     resetToLocal = ( EPbAccessoryWiredHeadset == mode ||
       
   245                                      EPbAccessoryWirelessHeadset == mode ||
       
   246                                      EPbAccessoryMusicStand == mode ||
       
   247                                      EPbAccessoryTVOut == mode ||
       
   248                                      EPbAccessoryHeadphones == mode );
       
   249 #else
       
   250                     resetToLocal = ( EPbAccessoryHeadset == mode ||
       
   251                                      EPbAccessoryLoopset == mode );
       
   252 #endif
       
   253                     if ( resetToLocal )
       
   254                         {
       
   255                         SelectNewPlayerL( EMPXPbvCmdUpnpPlayViaLocal );
       
   256                         GetCurrentPlayerDetails();
       
   257                         }
       
   258                     }
       
   259                 break;
       
   260                 }
       
   261             case TMPXPlaybackMessage::EStateChanged:
       
   262                 {
       
   263 		        MPX_DEBUG1( "HandlePlaybackMessageL - EStateChanged" );
       
   264                 UpdateMiddleSoftKeyDisplayL();
       
   265                 UpdateToolbar();
       
   266                 break;
       
   267                 }
       
   268             default:
       
   269                 {
       
   270                 break;
       
   271                 }
       
   272             }
       
   273         }
       
   274 
       
   275     CMPXCommonPlaybackViewImp::DoHandlePlaybackMessageL( aMessage );
       
   276     }
       
   277 
       
   278 // ---------------------------------------------------------------------------
       
   279 // Handle playback state changed.
       
   280 // ---------------------------------------------------------------------------
       
   281 //
       
   282 void CMPXUPnPPlaybackViewImp::DoHandleStateChangedL(
       
   283     TMPXPlaybackState aState,
       
   284     TInt aData )
       
   285     {
       
   286     MPX_FUNC( "CMPXUPnPPlaybackViewImp::DoHandleStateChangedL" );
       
   287     MPX_DEBUG2( "CMPXUPnPPlaybackViewImp::DoHandleStateChangedL %d", aState );
       
   288 
       
   289     if ( ( aState == EPbStatePaused ) &&
       
   290          ( aData == KErrDisconnected ) )
       
   291         {
       
   292         TUid activeView = iViewUtility->ActiveViewType();
       
   293         if ( activeView == TUid::Uid( KMPXPluginTypePlaybackUid ) )
       
   294             {
       
   295             if ( iSubPlayerName )
       
   296                 {
       
   297                 HBufC* dialogText = StringLoader::LoadLC(
       
   298                                     R_MPX_NOTE_REMOTE_CONNECTION_FAILED,
       
   299                                     *iSubPlayerName );
       
   300                 CAknErrorNote* errNote = new(ELeave) CAknErrorNote(ETrue);
       
   301                 errNote->SetTimeout(CAknNoteDialog::ELongTimeout);
       
   302                 errNote->ExecuteLD( *dialogText );
       
   303                 CleanupStack::PopAndDestroy( dialogText );
       
   304                 }
       
   305 
       
   306             // UPnP connection failed, reset playback to Local
       
   307             SelectNewPlayerL( EMPXPbvCmdUpnpPlayViaLocal );
       
   308             GetCurrentPlayerDetails();
       
   309             }
       
   310         }
       
   311     else
       
   312         {
       
   313         CMPXCommonPlaybackViewImp::DoHandleStateChangedL( aState, aData );
       
   314         }
       
   315 
       
   316     switch ( aState )
       
   317         {
       
   318         case EPbStateStopped:
       
   319         case EPbStatePlaying:
       
   320         case EPbStatePaused:
       
   321             {
       
   322             DismissWaitNoteL();
       
   323             break;
       
   324             }
       
   325         }
       
   326     }
       
   327 
       
   328 // -----------------------------------------------------------------------------
       
   329 // CMPXUPnPPlaybackViewImp::UpdateTitlePaneL
       
   330 // Retrieves the current player name and updates the Label
       
   331 // -----------------------------------------------------------------------------
       
   332 //
       
   333 void CMPXUPnPPlaybackViewImp::UpdateTitlePaneL()
       
   334     {
       
   335     TUid activeView = iViewUtility->ActiveViewType();
       
   336     if ( activeView == TUid::Uid( KMPXPluginTypePlaybackUid ) )
       
   337         {
       
   338         CAknTitlePane* title( NULL );
       
   339 
       
   340         TRAP_IGNORE(
       
   341             {
       
   342             title = static_cast<CAknTitlePane*>
       
   343                 ( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   344             } );
       
   345 
       
   346         GetCurrentPlayerDetails();
       
   347 
       
   348         if ( title )
       
   349             {
       
   350             if ( iCurrentPlayerType != EPbLocal)
       
   351                 {
       
   352                 if ( iSubPlayerName )
       
   353                     {
       
   354                     title->SetTextL( *iSubPlayerName );
       
   355                     }
       
   356                 }
       
   357             else
       
   358                 {
       
   359                 CMPXCommonPlaybackViewImp::UpdateTitlePaneL();
       
   360                 }
       
   361             }
       
   362         }
       
   363     }
       
   364 
       
   365 // ---------------------------------------------------------------------------
       
   366 // Updates track info field.
       
   367 // ---------------------------------------------------------------------------
       
   368 //
       
   369 void CMPXUPnPPlaybackViewImp::UpdateTrackInfoL(
       
   370     const CMPXMedia* aMedia )
       
   371     {
       
   372     MPX_FUNC( "CMPXUPnPPlaybackViewImp::UpdateTrackInfo" );
       
   373 
       
   374     CMPXCommonPlaybackViewImp::UpdateTrackInfoL( aMedia );
       
   375 
       
   376     if ( iPodcastPlayback &&
       
   377          iContainer &&
       
   378          !iSwitchingView )
       
   379         {
       
   380         if ( aMedia )
       
   381             {
       
   382             // Set ETextArtist field as Podcast Title
       
   383             if ( aMedia->IsSupported(KMPXMediaMusicAlbum))
       
   384                 {
       
   385                 HBufC* titleText = aMedia->ValueText(KMPXMediaMusicAlbum).AllocL();
       
   386                 CleanupStack::PushL(titleText);
       
   387                 if ( titleText->Length() > 0)
       
   388                     {
       
   389                     iContainer->UpdateLabelL( ETextArtist, *titleText );
       
   390                     }
       
   391                 else
       
   392                     {
       
   393                     HBufC* unknownText =
       
   394                         StringLoader::LoadLC( R_MPX_QTN_NMP_UNKNOWN_TITLE );
       
   395                     iContainer->UpdateLabelL(
       
   396                         ETextArtist, *unknownText );
       
   397                     CleanupStack::PopAndDestroy( unknownText );
       
   398                     }
       
   399                 CleanupStack::PopAndDestroy( titleText );
       
   400                 }
       
   401             else
       
   402                 {
       
   403                 HBufC* unknownText =
       
   404                         StringLoader::LoadLC( R_MPX_QTN_NMP_UNKNOWN_TITLE );
       
   405                 iContainer->UpdateLabelL(
       
   406                     ETextArtist, *unknownText );
       
   407                 CleanupStack::PopAndDestroy( unknownText );
       
   408                 }
       
   409             }
       
   410         }
       
   411     }
       
   412 
       
   413 // ---------------------------------------------------------------------------
       
   414 // From MEikMenuObserver
       
   415 // Dynamically initialises a menu pane.
       
   416 // ---------------------------------------------------------------------------
       
   417 //
       
   418 void CMPXUPnPPlaybackViewImp::DynInitMenuPaneL(
       
   419     TInt aResourceId,
       
   420     CEikMenuPane* aMenuPane )
       
   421     {
       
   422     // Call base clase to handle most cases
       
   423     CMPXCommonPlaybackViewImp::DynInitMenuPaneL( aResourceId, aMenuPane );
       
   424 
       
   425     switch ( aResourceId )
       
   426         {
       
   427         case R_MPX_UPNP_PODCAST_PLAYBACK_VIEW_MENU1:
       
   428             {
       
   429             if ( !iPodcastPlayback )
       
   430                 {
       
   431                 aMenuPane->SetItemDimmed(
       
   432                         EMPXPbvCmdGoToPodcastMenu,
       
   433                         ETrue );
       
   434                 }
       
   435             break;
       
   436             }
       
   437         case R_MPX_PLAYBACK_VIEW_MENU:
       
   438             {
       
   439             aMenuPane->SetItemDimmed(
       
   440                     EMPXPbvCmdOpenMusicSettings,
       
   441                     ETrue );
       
   442 
       
   443             aMenuPane->SetItemDimmed(
       
   444                     EMPXPbvCmdEqualizer,
       
   445                     ETrue );
       
   446 
       
   447 
       
   448 
       
   449 			// Check if FM Transmitter is supported
       
   450 			if ( !FeatureManager::FeatureSupported( KFeatureIdFmtx ) )
       
   451 				{
       
   452 				aMenuPane->SetItemDimmed(
       
   453 						EMPXPbvCmdFMTransmitter,
       
   454 						ETrue );
       
   455 				}
       
   456 
       
   457             if ( iPodcastPlayback )
       
   458                 {
       
   459                 // dim the options that aren't applicable
       
   460                 // to podcast collection
       
   461                 aMenuPane->SetItemDimmed(
       
   462                         EMPXPbvCmdGotoMusicMenu,
       
   463                         ETrue );
       
   464                 aMenuPane->SetItemDimmed(
       
   465                         EMPXPbvCmdAddToPlaylist,
       
   466                         ETrue );
       
   467             aMenuPane->SetItemDimmed(
       
   468                 EMPXPbvCmdUseAsCascade,
       
   469                 ETrue );
       
   470                 aMenuPane->SetItemDimmed(
       
   471                         EMPXPbvCmdRepeat,
       
   472                         ETrue );
       
   473                 aMenuPane->SetItemDimmed(
       
   474                         EMPXPbvCmdRandom,
       
   475                         ETrue );
       
   476                 }
       
   477             break;
       
   478             }
       
   479         default:
       
   480             {
       
   481             // Do nothing
       
   482             break;
       
   483             }
       
   484         }
       
   485     }
       
   486 
       
   487 // ---------------------------------------------------------------------------
       
   488 // From CAknView
       
   489 // Returns views id.
       
   490 // ---------------------------------------------------------------------------
       
   491 //
       
   492 TUid CMPXUPnPPlaybackViewImp::Id() const
       
   493     {
       
   494     return TUid::Uid( KMPXUPnPPlaybackViewId );
       
   495     }
       
   496 
       
   497 // ---------------------------------------------------------------------------
       
   498 // From CAknView
       
   499 // Command handling function.
       
   500 // ---------------------------------------------------------------------------
       
   501 //
       
   502 void CMPXUPnPPlaybackViewImp::HandleCommandL( TInt aCommand )
       
   503     {
       
   504     MPX_DEBUG2( "CMPXUPnPPlaybackViewImp::HandleCommandL(%d)", aCommand );
       
   505 
       
   506     switch( aCommand )
       
   507         {
       
   508         case EMPXPbvCmdGoToPodcastMenu:
       
   509             {
       
   510             // Handle Go to main podcast menu
       
   511             CMPXCollectionPath* cpath = iCollectionUiHelper->PodCastMenuPathL();
       
   512             CleanupStack::PushL( cpath );
       
   513             MPX_DEBUG_PATH (*cpath);
       
   514             iCollectionUtility->Collection().OpenL( *cpath );
       
   515             CleanupStack::PopAndDestroy( cpath );
       
   516 
       
   517             // Restore status pane
       
   518             if ( StatusPane()->CurrentLayoutResId() !=
       
   519                  R_AVKON_STATUS_PANE_LAYOUT_USUAL)
       
   520                 {
       
   521                 StatusPane()->SwitchLayoutL(R_AVKON_STATUS_PANE_LAYOUT_USUAL);
       
   522                 }
       
   523             break;
       
   524             }
       
   525         default:
       
   526             {
       
   527             CMPXCommonPlaybackViewImp::HandleCommandL( aCommand );
       
   528             break;
       
   529             }
       
   530         }
       
   531     }
       
   532 
       
   533 // ---------------------------------------------------------------------------
       
   534 // From CAknView
       
   535 // Processes user commands.
       
   536 // ---------------------------------------------------------------------------
       
   537 //
       
   538 void CMPXUPnPPlaybackViewImp::ProcessCommandL( TInt aCommand )
       
   539     {
       
   540     MPX_DEBUG2("--->CMPXUPnPPlaybackViewImp::ProcessCommandL(%d)", aCommand);
       
   541     if ( aCommand == EAknCmdExit )
       
   542         {
       
   543         if ( MenuBar() )
       
   544             {
       
   545             MenuBar()->StopDisplayingMenuBar();
       
   546             }
       
   547         }
       
   548     CAknView::ProcessCommandL( aCommand );
       
   549     MPX_DEBUG1("<---CMPXUPnPPlaybackViewImp::ProcessCommandL(): exiting");
       
   550     }
       
   551 
       
   552 // ---------------------------------------------------------------------------
       
   553 // From CAknView
       
   554 // Handles a view activation.
       
   555 // ---------------------------------------------------------------------------
       
   556 //
       
   557 void CMPXUPnPPlaybackViewImp::DoActivateL(
       
   558     const TVwsViewId& aPrevViewId,
       
   559     TUid aCustomMessageId,
       
   560     const TDesC8& aCustomMessage )
       
   561     {
       
   562     MPX_FUNC( "CMPXUPnPPlaybackViewImp::DoActivateL()" );
       
   563 
       
   564     if ( !iContainer )
       
   565         {
       
   566         if ( !iPlaybackViewLayout )
       
   567             {
       
   568             iPlaybackViewLayout = CMPXUPnPPlaybackViewLayout::NewL();
       
   569             }
       
   570 
       
   571         iPodcastPlayback = EFalse;
       
   572         MMPXSource* source( iPlaybackUtility->Source() );
       
   573         if ( source )
       
   574             {
       
   575             CMPXCollectionPlaylist* pl( source->PlaylistL() );
       
   576             if ( pl )
       
   577                 {
       
   578                 if ( TUid::Uid((TInt)pl->Path().Id(0)) == KMPXUidPodcastDBPlugin )
       
   579                     {
       
   580                     iPodcastPlayback = ETrue;
       
   581                     }
       
   582                 delete pl;
       
   583                 }
       
   584             }
       
   585 
       
   586         iPlaybackViewLayout->SetAlbumArtLayout( iPodcastPlayback );
       
   587 
       
   588         iContainer = new ( ELeave ) CMPXUPnPPlaybackViewContainer(
       
   589             this,
       
   590             this,
       
   591             iPlaybackViewLayout );
       
   592         iContainer->SetMopParent( this );
       
   593         iContainer->ConstructL( ClientRect() );
       
   594         AppUi()->AddToStackL( *this, iContainer );
       
   595 
       
   596         iUPnPLoadingWaitNoteDisplayed =EFalse;
       
   597 
       
   598         if ( iPlaybackUtility->StateL() == EPbStateInitialising )
       
   599             {
       
   600             if ( !iLoadingWaitNote )
       
   601                 {
       
   602                 iLoadingWaitNote = CIdle::NewL(CActive::EPriorityStandard);
       
   603                 }
       
   604             iLoadingWaitNote->Cancel();
       
   605             TCallBack callBack( CMPXUPnPPlaybackViewImp::LoadingSong,
       
   606                                 this );
       
   607 
       
   608             // timer is needed because notes are dismissed by avkon during view
       
   609             // activation/deactivation process, so we need to do it later
       
   610             iLoadingWaitNote->Start(callBack);
       
   611             }
       
   612         }
       
   613 
       
   614     CMPXCommonPlaybackViewImp::DoActivateL( aPrevViewId , aCustomMessageId, aCustomMessage );
       
   615     }
       
   616 
       
   617 // -----------------------------------------------------------------------------
       
   618 // Displays  when callback from CIdle
       
   619 // -----------------------------------------------------------------------------
       
   620 //
       
   621 TInt CMPXUPnPPlaybackViewImp::LoadingSong( TAny* aPtr )
       
   622     {
       
   623     MPX_FUNC( "CMPXUPnPPlaybackViewImp::LoadingSong()");
       
   624 
       
   625     CMPXUPnPPlaybackViewImp* upnpPlaybackview =
       
   626     static_cast<CMPXUPnPPlaybackViewImp*>(aPtr);
       
   627 
       
   628     TRAP_IGNORE( upnpPlaybackview->LoadingSongL() );
       
   629     return EFalse;
       
   630     }
       
   631 
       
   632 // -----------------------------------------------------------------------------
       
   633 // Displays  when callback from CIdle
       
   634 // -----------------------------------------------------------------------------
       
   635 //
       
   636 void CMPXUPnPPlaybackViewImp::LoadingSongL()
       
   637     {
       
   638     MPX_FUNC( "CMPXUPnPPlaybackViewImp::LoadingSongL()");
       
   639 
       
   640     HBufC* string = StringLoader::LoadLC(
       
   641         R_MPX_WAIT_UPNP_LOADING_SONG );
       
   642 
       
   643     iUPnPLoadingWaitNoteDisplayed = ETrue;
       
   644 
       
   645     // display waiting note
       
   646     iCommonUiHelper->ShowWaitNoteL(
       
   647         *string,
       
   648         R_AVKON_SOFTKEYS_CANCEL,
       
   649         EFalse, this );
       
   650     CleanupStack::PopAndDestroy( string );
       
   651     }
       
   652 
       
   653 // ---------------------------------------------------------------------------
       
   654 // Dismisses the loading song error note
       
   655 // ---------------------------------------------------------------------------
       
   656 //
       
   657 void CMPXUPnPPlaybackViewImp::DismissWaitNoteL()
       
   658     {
       
   659     MPX_FUNC( "CMPXUPnPPlaybackViewImp::DismissWaitNoteL()" );
       
   660     if ( iUPnPLoadingWaitNoteDisplayed )
       
   661         {
       
   662         if ( iLoadingWaitNote )
       
   663             {
       
   664             iLoadingWaitNote->Cancel();
       
   665             }
       
   666 
       
   667         if ( iCommonUiHelper )
       
   668             {
       
   669             iCommonUiHelper->DismissWaitNoteL();
       
   670             }
       
   671         iUPnPLoadingWaitNoteDisplayed = EFalse;
       
   672         }
       
   673     }
       
   674 
       
   675 // ---------------------------------------------------------------------------
       
   676 // Displays error notes.
       
   677 // ---------------------------------------------------------------------------
       
   678 //
       
   679 void CMPXUPnPPlaybackViewImp::HandleErrorL( TInt aError )
       
   680     {
       
   681     MPX_DEBUG2( "--->CMPXUPnPPlaybackViewImp::HandleErrorL(%d)", aError );
       
   682     if ( aError )
       
   683         {
       
   684         DismissWaitNoteL();
       
   685         }
       
   686 
       
   687     if ( aError == KErrDisconnected )
       
   688         {
       
   689         MPX_DEBUG1( "CMPXUPnPPlaybackViewImp::HandleErrorL - KErrDisconnected");
       
   690         TUid activeView = iViewUtility->ActiveViewType();
       
   691         if ( activeView == TUid::Uid( KMPXPluginTypePlaybackUid ) )
       
   692             {
       
   693             if ( iSubPlayerName )
       
   694                 {
       
   695                 HBufC* dialogText = StringLoader::LoadLC(
       
   696                                     R_MPX_NOTE_REMOTE_CONNECTION_FAILED,
       
   697                                     *iSubPlayerName );
       
   698                 CAknErrorNote* errNote = new(ELeave) CAknErrorNote(ETrue);
       
   699                 errNote->SetTimeout(CAknNoteDialog::ELongTimeout);
       
   700                 errNote->ExecuteLD( *dialogText );
       
   701                 CleanupStack::PopAndDestroy( dialogText );
       
   702                 }
       
   703 
       
   704             // UPnP connection failed, reset playback to Local
       
   705             SelectNewPlayerL( EMPXPbvCmdUpnpPlayViaLocal );
       
   706             GetCurrentPlayerDetails();
       
   707             }
       
   708         }
       
   709     else if ( aError == KErrNotSupported )
       
   710         {
       
   711         MPX_DEBUG1( "CMPXUPnPPlaybackViewImp::HandleErrorL - KErrNotSupported" );
       
   712         TUid activeView = iViewUtility->ActiveViewType();
       
   713         if ( activeView == TUid::Uid( KMPXPluginTypePlaybackUid ) )
       
   714             {
       
   715             HBufC* dialogText = StringLoader::LoadLC( 
       
   716                                                 R_MPX_INVALID_GROUP_TEXT );
       
   717 
       
   718             CAknErrorNote* errNote = new ( ELeave ) CAknErrorNote( ETrue );
       
   719             errNote->SetTimeout( CAknNoteDialog::ELongTimeout );
       
   720             errNote->ExecuteLD( *dialogText );
       
   721             CleanupStack::PopAndDestroy( dialogText );
       
   722             }
       
   723         CMPXCommonPlaybackViewImp::HandleErrorL( aError );
       
   724         }
       
   725     else
       
   726         {
       
   727         CMPXCommonPlaybackViewImp::HandleErrorL( aError );
       
   728         }
       
   729     MPX_DEBUG1( "<---CMPXUPnPPlaybackViewImp::HandleErrorL");
       
   730     }
       
   731 
       
   732 // ---------------------------------------------------------------------------
       
   733 // From MProgressDialogCallback
       
   734 // Callback method. Get's called when a dialog is dismissed
       
   735 // ---------------------------------------------------------------------------
       
   736 //
       
   737 void CMPXUPnPPlaybackViewImp::DialogDismissedL( TInt aButtonId )
       
   738     {
       
   739     MPX_DEBUG2("--->CMPXUPnPPlaybackViewImp::DialogDismissedL(%d)", aButtonId);
       
   740     switch (aButtonId)
       
   741         {
       
   742         case EAknSoftkeyCancel:
       
   743             {
       
   744             if ( iPlaybackUtility->StateL() == EPbStateInitialising &&
       
   745                  iUPnPLoadingWaitNoteDisplayed )
       
   746                 {
       
   747                 iPlaybackUtility->CommandL(EPbCmdCancelInit);
       
   748                 HandleCommandL(EAknSoftkeyBack);
       
   749                 }
       
   750             break;
       
   751             }
       
   752         case EAknSoftkeyDone:
       
   753             {
       
   754             break;
       
   755             }
       
   756         default:
       
   757             {
       
   758             break;
       
   759             }
       
   760         }
       
   761     MPX_DEBUG1("<---CMPXUPnPPlaybackViewImp::DialogDismissedL()");
       
   762     }
       
   763 
       
   764 // -----------------------------------------------------------------------------
       
   765 // From MAknToolbarObserver
       
   766 // Used to change toolbar settings before toolbar becomes visible
       
   767 // -----------------------------------------------------------------------------
       
   768 //
       
   769 
       
   770 void CMPXUPnPPlaybackViewImp::DynInitToolbarL(TInt aResourceId, CAknToolbar* aToolbar)
       
   771     {
       
   772     MPX_FUNC( "CMPXUPnPPlaybackViewImp::DynInitToolbarL" );
       
   773     if ( aResourceId == R_MPX_PBV_TOUCH_TOOLBAR )
       
   774         {
       
   775         // Put initializations here to take effect before toolbar is shown
       
   776         UpdateToolbar();
       
   777         aToolbar->UpdateBackground();
       
   778         }
       
   779     }
       
   780 
       
   781 // -----------------------------------------------------------------------------
       
   782 // From MAknToolbarObserver
       
   783 // Handles toolbar events
       
   784 // -----------------------------------------------------------------------------
       
   785 //
       
   786 
       
   787 void CMPXUPnPPlaybackViewImp::OfferToolbarEventL( TInt aCommandId )
       
   788     {
       
   789     MPX_FUNC( "CMPXUPnPPlaybackViewImp::OfferToolbarEventL" );
       
   790     TInt commandId = aCommandId;
       
   791     TInt eventModifiers = iToolbar->EventModifiers();
       
   792     if ( eventModifiers == CAknToolbar::ELongPress )
       
   793         {
       
   794         if ( aCommandId == EMPXPbvCmdNextListItem )
       
   795             {
       
   796             commandId = EMPXPbvCmdSeekForward;
       
   797             }
       
   798         else if ( aCommandId == EMPXPbvCmdPreviousListItem )
       
   799             {
       
   800             commandId = EMPXPbvCmdSeekBackward;
       
   801             }
       
   802         }
       
   803     else if ( eventModifiers == CAknToolbar::ELongPressEnded )
       
   804         {
       
   805         if ( aCommandId == EMPXPbvCmdNextListItem || aCommandId == EMPXPbvCmdPreviousListItem )
       
   806             {
       
   807             commandId = EMPXPbvCmdEndSeek;
       
   808             }
       
   809         }
       
   810 
       
   811     CAknView::ProcessCommandL( commandId );
       
   812     }
       
   813 //  End of File