mpxplugins/viewplugins/views/upnpbrowsedialog/src/mpxupnpbrowsedialog.cpp
changeset 4 beaa16f65879
parent 0 ff3acec5bc43
equal deleted inserted replaced
3:3f752ecfeea4 4:beaa16f65879
   205                                   ( aPlayerUid == iCurrentlyUsedPlayer.iUid) );
   205                                   ( aPlayerUid == iCurrentlyUsedPlayer.iUid) );
   206                             }
   206                             }
   207                         MPX_DEBUG2( "CMPXUPnPBrowseDialog::ExecuteLD() selecDifferentSubPlayer %d", selecDifferentSubPlayer);
   207                         MPX_DEBUG2( "CMPXUPnPBrowseDialog::ExecuteLD() selecDifferentSubPlayer %d", selecDifferentSubPlayer);
   208                         }
   208                         }
   209 
   209 
   210                     MMPXSource* source = iPlaybackUtility->Source();
   210                     if(iPlaybackUtility)
   211                     CMPXCollectionPlaylist* playlist = NULL;
       
   212                     if ( source )
       
   213                         {
   211                         {
   214                         playlist = source->PlaylistL();
   212                         MMPXSource* source = iPlaybackUtility->Source();
       
   213                         CMPXCollectionPlaylist* playlist = NULL;
       
   214                         if ( source )
       
   215                             {
       
   216                             playlist = source->PlaylistL();
       
   217                             if ( playlist )
       
   218                                 {
       
   219                                 CleanupStack::PushL( playlist );
       
   220                                 }
       
   221                             }
       
   222 
       
   223                         MMPXPlayerManager& manager = iPlaybackUtility->PlayerManager();
       
   224                         // user selects a different remote player
       
   225                         if ( iCurrentlySelectedSubPlayerName &&
       
   226                                 selecDifferentSubPlayer )
       
   227                             {
       
   228                             // need to clean up the current plugin
       
   229                             TRAP_IGNORE( manager.ClearSelectPlayersL() );
       
   230                             }
       
   231 
       
   232                         MPX_DEBUG3( "CMPXUPnPBrowseDialog::ExecuteLD() before call to manager.SelectSubPlayerL(%d, %d)", iPlayerUid, currentItemIndex );
       
   233                         MPX_TRAP( errorSelectSubPlayer,
       
   234                                 manager.SelectSubPlayerL( TUid::Uid(iPlayerUid),
       
   235                                         currentItemIndex ) );
       
   236 
       
   237                         MPX_DEBUG2( "CMPXUPnPBrowseDialog::ExecuteLD() after manager.SelectSubPlayerL()", errorSelectSubPlayer );
       
   238                         if ( errorSelectSubPlayer == KErrNone )
       
   239                             {
       
   240                             okToExit = ETrue;
       
   241 
       
   242                             if ( selecDifferentSubPlayer )
       
   243                                 {
       
   244                                 selectedSubplayerIndex = currentItemIndex;
       
   245                                 }
       
   246                             else // subplayer selected is the same as the current one
       
   247                                 {
       
   248                                 selectedSubplayerIndex = KErrInUse;
       
   249                                 }
       
   250                             }
       
   251                         else
       
   252                             {
       
   253                             TRAP_IGNORE( manager.ClearSelectPlayersL() );
       
   254                             if ( playlist )
       
   255                                 {
       
   256                                 iPlaybackUtility->InitL( *playlist, EFalse );
       
   257                                 }
       
   258 
       
   259                             DisplayErrorNoteL( R_UPNP_ERROR_PLAYER_UNAVAILABLE );
       
   260                             }
       
   261 
   215                         if ( playlist )
   262                         if ( playlist )
   216                             {
   263                             {
   217                             CleanupStack::PushL( playlist );
   264                             CleanupStack::PopAndDestroy( playlist );
   218                             }
       
   219                         }
       
   220 
       
   221                     MMPXPlayerManager& manager = iPlaybackUtility->PlayerManager();
       
   222                     // user selects a different remote player
       
   223                     if ( iCurrentlySelectedSubPlayerName &&
       
   224                          selecDifferentSubPlayer )
       
   225                         {
       
   226                         // need to clean up the current plugin
       
   227                         TRAP_IGNORE( manager.ClearSelectPlayersL() );
       
   228                         }
       
   229 
       
   230                     MPX_DEBUG3( "CMPXUPnPBrowseDialog::ExecuteLD() before call to manager.SelectSubPlayerL(%d, %d)", iPlayerUid, currentItemIndex );
       
   231                     MPX_TRAP( errorSelectSubPlayer,
       
   232                           manager.SelectSubPlayerL( TUid::Uid(iPlayerUid),
       
   233                                                     currentItemIndex ) );
       
   234 
       
   235                     MPX_DEBUG2( "CMPXUPnPBrowseDialog::ExecuteLD() after manager.SelectSubPlayerL()", errorSelectSubPlayer );
       
   236                     if ( errorSelectSubPlayer == KErrNone )
       
   237                         {
       
   238                         okToExit = ETrue;
       
   239 
       
   240                         if ( selecDifferentSubPlayer )
       
   241                             {
       
   242                             selectedSubplayerIndex = currentItemIndex;
       
   243                             }
       
   244                         else // subplayer selected is the same as the current one
       
   245                             {
       
   246                             selectedSubplayerIndex = KErrInUse;
       
   247                             }
   265                             }
   248                         }
   266                         }
   249                     else
   267                     else
   250                         {
   268                         {
   251                         TRAP_IGNORE( manager.ClearSelectPlayersL() );
   269                         // Should not reach here  
   252                         if ( playlist )
   270                         MPX_DEBUG1( "CMPXUPnPBrowseDialog::ExecuteLD()playbackutility is NULL" );
   253                             {
   271                         }     
   254                             iPlaybackUtility->InitL( *playlist, EFalse );
       
   255                             }
       
   256 
       
   257                         DisplayErrorNoteL( R_UPNP_ERROR_PLAYER_UNAVAILABLE );
       
   258                         }
       
   259 
       
   260                     if ( playlist )
       
   261                         {
       
   262                         CleanupStack::PopAndDestroy( playlist );
       
   263                         }
       
   264                     } // if ( isSelectedItemASubplayerName )
   272                     } // if ( isSelectedItemASubplayerName )
   265                 } // check for boundaries
   273                 } // check for boundaries
   266             else
   274             else
   267                 {
   275                 {
   268                 okToExit = ETrue;
   276                 okToExit = ETrue;
   283                 cmd->SetTObjectValueL<TInt>(KMPXCommandGeneralId, KMPXCommandIdPlaybackGeneral);
   291                 cmd->SetTObjectValueL<TInt>(KMPXCommandGeneralId, KMPXCommandIdPlaybackGeneral);
   284                 // All of current commands are sync
   292                 // All of current commands are sync
   285                 cmd->SetTObjectValueL<TBool>(KMPXCommandGeneralDoSync, ETrue);
   293                 cmd->SetTObjectValueL<TBool>(KMPXCommandGeneralDoSync, ETrue);
   286                 cmd->SetTObjectValueL<TInt>(KMPXCommandPlaybackGeneralType, EPbCmdUnloadNonActivePlugin);
   294                 cmd->SetTObjectValueL<TInt>(KMPXCommandPlaybackGeneralType, EPbCmdUnloadNonActivePlugin);
   287                 cmd->SetTObjectValueL<TInt>(KMPXCommandPlaybackGeneralData, aPlayerUid);
   295                 cmd->SetTObjectValueL<TInt>(KMPXCommandPlaybackGeneralData, aPlayerUid);
   288                 iPlaybackUtility->CommandL(*cmd, NULL);
   296                 if(iPlaybackUtility)
       
   297                  {
       
   298                   iPlaybackUtility->CommandL(*cmd, NULL);
       
   299                  } 
   289                 CleanupStack::PopAndDestroy(cmd);
   300                 CleanupStack::PopAndDestroy(cmd);
   290 
   301 
   291                 okToExit = ETrue;
   302                 okToExit = ETrue;
   292                 selectedSubplayerIndex = KErrCancel;
   303                 selectedSubplayerIndex = KErrCancel;
   293                 }
   304                 }
   633     if ( iCurrentlySelectedSubPlayerName )
   644     if ( iCurrentlySelectedSubPlayerName )
   634         {
   645         {
   635         delete iCurrentlySelectedSubPlayerName;
   646         delete iCurrentlySelectedSubPlayerName;
   636         iCurrentlySelectedSubPlayerName = NULL;
   647         iCurrentlySelectedSubPlayerName = NULL;
   637         }
   648         }
   638 
   649     if(  iPlaybackUtility)
   639     MMPXPlayerManager& manager = iPlaybackUtility->PlayerManager();
   650         {
   640     TMPXPlaybackPlayerType playerType;
   651         MMPXPlayerManager& manager = iPlaybackUtility->PlayerManager();
   641     TInt currentlyUsedSubPlayer;
   652         TMPXPlaybackPlayerType playerType;
   642     MPX_DEBUG1( "CMPXUPnPBrowseDialog::RetrieveCurrentlySelectSubplayerName() before call to manager.GetSelectionL()" );
   653         TInt currentlyUsedSubPlayer;
   643     MPX_TRAPD( errorSelectSubPlayer, manager.GetSelectionL( playerType,
   654         MPX_DEBUG1( "CMPXUPnPBrowseDialog::RetrieveCurrentlySelectSubplayerName() before call to manager.GetSelectionL()" );
   644                                                         iCurrentlyUsedPlayer,
   655         MPX_TRAPD( errorSelectSubPlayer, manager.GetSelectionL( playerType,
   645                                                         currentlyUsedSubPlayer,
   656                 iCurrentlyUsedPlayer,
   646                                                         iCurrentlySelectedSubPlayerName));
   657                 currentlyUsedSubPlayer,
   647     MPX_DEBUG4( "CMPXUPnPBrowseDialog::RetrieveCurrentlySelectSubplayerName() after call to manager.GetSelectionL(%d, %d, %d)",
   658                 iCurrentlySelectedSubPlayerName));
   648                                                         playerType,
   659         MPX_DEBUG4( "CMPXUPnPBrowseDialog::RetrieveCurrentlySelectSubplayerName() after call to manager.GetSelectionL(%d, %d, %d)",
   649                                                         iCurrentlyUsedPlayer.iUid,
   660                 playerType,
   650                                                         currentlyUsedSubPlayer );
   661                 iCurrentlyUsedPlayer.iUid,
   651     if (iCurrentlySelectedSubPlayerName)
   662                 currentlyUsedSubPlayer );
   652         {
   663         if (iCurrentlySelectedSubPlayerName)
   653         MPX_DEBUG2( "CMPXUPnPBrowseDialog::RetrieveCurrentlySelectSubplayerName() after call to manager.GetSelectionL(%S)",
   664             {
   654                                                         iCurrentlySelectedSubPlayerName );
   665             MPX_DEBUG2( "CMPXUPnPBrowseDialog::RetrieveCurrentlySelectSubplayerName() after call to manager.GetSelectionL(%S)",
   655         }
   666                     iCurrentlySelectedSubPlayerName );
   656     if ( errorSelectSubPlayer != KErrNone  && iCurrentlySelectedSubPlayerName )
   667             }
   657         {
   668         if ( errorSelectSubPlayer != KErrNone  && iCurrentlySelectedSubPlayerName )
   658         MPX_DEBUG2( "CMPXUPnPBrowseDialog::RetrieveCurrentlySelectSubplayerName() after call to manager.GetSelectionL() error %d",
   669             {
   659                                                         errorSelectSubPlayer );
   670             MPX_DEBUG2( "CMPXUPnPBrowseDialog::RetrieveCurrentlySelectSubplayerName() after call to manager.GetSelectionL() error %d",
   660         delete iCurrentlySelectedSubPlayerName;
   671                     errorSelectSubPlayer );
   661         iCurrentlySelectedSubPlayerName = NULL;
   672             delete iCurrentlySelectedSubPlayerName;
   662         }
   673             iCurrentlySelectedSubPlayerName = NULL;
       
   674             }
       
   675         }
       
   676     else
       
   677         {
       
   678         //Should not reach here
       
   679         MPX_DEBUG1( "CMPXUPnPBrowseDialog::RetrieveCurrentlySelectSubplayerName() iPlaybackUtility is NULL" );	
       
   680         } 
   663     }
   681     }
   664 
   682 
   665 // ---------------------------------------------------------------------------
   683 // ---------------------------------------------------------------------------
   666 // CMPXUPnPBrowseDialog::DisplayErrorNoteL
   684 // CMPXUPnPBrowseDialog::DisplayErrorNoteL
   667 // Retrieves the name and other info of the currently used subplayer
   685 // Retrieves the name and other info of the currently used subplayer