mmsharing/mmshui/src/musuiappui.cpp
changeset 15 ccd8e69b5392
parent 2 b31261fd4e04
child 20 e8be2c2e049d
child 22 496ad160a278
equal deleted inserted replaced
2:b31261fd4e04 15:ccd8e69b5392
     1 /*
       
     2 * Copyright (c) 2005 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:  Application's UI class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "musuiappui.h"
       
    21 #include "musuilivesharingview.h"
       
    22 #include "musuiclipsharingview.h"
       
    23 #include "musuireceiveview.h"
       
    24 #include "musuistatuspanehandler.h"
       
    25 #include "musuistartcontroller.h"
       
    26 #include "musuiactivequerydialog.h"
       
    27 #include "musuidefinitions.h"
       
    28 #include "mussettings.h"
       
    29 #include "mussettingskeys.h"
       
    30 #include "musmanagercommon.h"
       
    31 #include "musui.hrh"
       
    32 #include "musuid.hrh"
       
    33 #include "muslogger.h" // debug logging
       
    34 #include <musui.rsg>
       
    35 #include <musui.mbg>
       
    36 
       
    37 #include <csxhelp/msh.hlp.hrh>
       
    38 #include <avkon.hrh>
       
    39 #include <AknsUtils.h>
       
    40 #include <remconcoreapitarget.h>
       
    41 #include <remconinterfaceselector.h>
       
    42 #include <akntoolbar.h>
       
    43 #include <AknVolumePopup.h>
       
    44 
       
    45 using namespace MusSettingsKeys;
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 // Symbian second-phase constructor.
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 void CMusUiAppUi::ConstructL()
       
    52     {
       
    53     MUS_LOG( "mus: [MUSUI ]  -> CMusUiAppUi::ConstructL" );
       
    54     BaseConstructL( EAknEnableSkin | EAppOrientationAutomatic | EAknEnableMSK );
       
    55 
       
    56     iForeground = ETrue;
       
    57     
       
    58     // View for Live Sharing:
       
    59     CMusUiLiveSharingView* liveSharingView =
       
    60                             new ( ELeave ) CMusUiLiveSharingView;
       
    61     CleanupStack::PushL( liveSharingView );
       
    62     liveSharingView->ConstructL();
       
    63     AddViewL( liveSharingView );      // transfer ownership to CAknViewAppUi
       
    64     CleanupStack::Pop( liveSharingView );
       
    65 
       
    66     // View for Clip Sharing:
       
    67     CMusUiClipSharingView* clipSharingView =
       
    68                             new ( ELeave ) CMusUiClipSharingView;
       
    69     CleanupStack::PushL( clipSharingView );
       
    70     clipSharingView->ConstructL();
       
    71     AddViewL( clipSharingView );      // transfer ownership to CAknViewAppUi
       
    72     CleanupStack::Pop( clipSharingView );
       
    73 
       
    74     // View for Receiving:
       
    75     CMusUiReceiveView* receiveView =  new ( ELeave ) CMusUiReceiveView;
       
    76     CleanupStack::PushL( receiveView );
       
    77     receiveView->ConstructL();
       
    78     AddViewL( receiveView );      // transfer ownership to CAknViewAppUi
       
    79     CleanupStack::Pop( receiveView );
       
    80 
       
    81     FindWindowGroupIdentifiersL();
       
    82     
       
    83     iStatusPaneHandler = CMusUiStatusPaneHandler::NewL( *iEikonEnv );
       
    84     // The application icon:
       
    85     iStatusPaneHandler->SetStatusPaneIconsL(
       
    86                             EMbmMusuiQgn_menu_mus_app_cxt,
       
    87                             EMbmMusuiQgn_menu_mus_app_cxt_mask );
       
    88 
       
    89     AknsUtils::InitSkinSupportL();
       
    90     AknsUtils::SetAvkonSkinEnabledL( ETrue );
       
    91 
       
    92     // Check use case and set default view
       
    93     switch ( MusUiStartController::ReadUseCaseL() )
       
    94         {
       
    95         case MultimediaSharing::EMusLiveVideo:
       
    96             ActivateLocalViewL( liveSharingView->Id() );
       
    97             break;
       
    98         case MultimediaSharing::EMusClipVideo:
       
    99             ActivateLocalViewL( clipSharingView->Id() );
       
   100             break;
       
   101         case MultimediaSharing::EMusReceive:
       
   102             ActivateLocalViewL( receiveView->Id() );
       
   103             break;
       
   104         default:
       
   105             User::Leave( KErrNotSupported );
       
   106             break;
       
   107         }
       
   108 
       
   109     iInterfaceSelector = CRemConInterfaceSelector::NewL();
       
   110     iCoreTarget = CRemConCoreApiTarget::NewL(*iInterfaceSelector, *this);
       
   111     iInterfaceSelector->OpenTargetL();
       
   112     
       
   113     // check if operator specific functionality is needed  
       
   114     iOperatorSpecificFunctionality = 
       
   115         ( MultimediaSharingSettings::OperatorVariantSettingL() == 
       
   116                                                     EOperatorSpecific );
       
   117 
       
   118     MUS_LOG( "mus: [MUSUI ]  <- CMusUiAppUi::ConstructL" );
       
   119     }
       
   120 
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 // Destructor.
       
   124 // -----------------------------------------------------------------------------
       
   125 //
       
   126 CMusUiAppUi::~CMusUiAppUi()
       
   127     {
       
   128     MUS_LOG( "mus: [MUSUI ]  -> CMusUiAppUi::~CMusUiAppUi" );
       
   129     delete iConfirmationQuery;
       
   130     delete iStatusPaneHandler;
       
   131     delete iInterfaceSelector;
       
   132     MUS_LOG( "mus: [MUSUI ]  <- CMusUiAppUi::~CMusUiAppUi" );
       
   133     }
       
   134 
       
   135 
       
   136 // -----------------------------------------------------------------------------
       
   137 // Fetches a handle to status pane handler
       
   138 // -----------------------------------------------------------------------------
       
   139 //
       
   140 CMusUiStatusPaneHandler* CMusUiAppUi::MusStatusPane()
       
   141     {
       
   142     return iStatusPaneHandler;
       
   143     }
       
   144 
       
   145 
       
   146 // -----------------------------------------------------------------------------
       
   147 //
       
   148 // -----------------------------------------------------------------------------
       
   149 //
       
   150 TBool CMusUiAppUi::ExitValue()
       
   151     {
       
   152     return iExit;
       
   153     }
       
   154 
       
   155 
       
   156 // -----------------------------------------------------------------------------
       
   157 //
       
   158 // -----------------------------------------------------------------------------
       
   159 //
       
   160 void CMusUiAppUi::HandleWsEventL( const TWsEvent& aEvent, CCoeControl* aDestination )
       
   161     {
       
   162     MUS_LOG( "mus: [MUSUI ]  -> CMusUiAppUi::HandleWsEventL" );
       
   163 
       
   164     const TInt type = aEvent.Type();
       
   165 
       
   166     // Avoiding unknown failures
       
   167     if( !iView )
       
   168         {
       
   169         MUS_LOG( "mus: [MUSUI ]  <- CMusUiAppUi::HandleWsEventL, view is NULL" );
       
   170         return;
       
   171         }
       
   172     
       
   173     if ( type == EEventPointer &&
       
   174          iStatusPaneHandler->GetVolumePopup()->IsVisible() )
       
   175         {
       
   176         MUS_LOG( "mus: [MUSUI ]  EMusuiCmdViewVolumeChanged" );
       
   177         CMusUiGeneralView* activatedView = 
       
   178                                    static_cast<CMusUiGeneralView*>( iView );
       
   179         activatedView->HandleCommandL( EMusuiCmdViewVolumeChanged );
       
   180         }
       
   181    
       
   182     if( type == EEventKeyUp )
       
   183         {
       
   184         static_cast<CMusUiGeneralView*>
       
   185                 ( iView )->HandleKeyUpEvent( iLastKeyCode );
       
   186         }
       
   187 
       
   188     if ( ( type == EEventKey ) && iView->Toolbar()->IsShown() && !MUS_NO_TOOLBAR )
       
   189         {
       
   190         const TKeyEvent* keyEvent = aEvent.Key();
       
   191         
       
   192         iLastKeyCode = keyEvent->iCode;        
       
   193         
       
   194         MUS_LOG1( "mus: [MUSUI ]     CMusUiAppUi::HandleWsEventL iCode: %d", 
       
   195                                 keyEvent->iCode );
       
   196         CMusUiGeneralView* activatedView = 
       
   197                                     static_cast<CMusUiGeneralView*>( iView );
       
   198         activatedView->HandleToolbarCommandL( keyEvent->iCode );
       
   199         }
       
   200     
       
   201     if ( type == KAknFullOrPartialForegroundLost ||
       
   202          type == EEventFocusLost ||
       
   203          type == KAknFullOrPartialForegroundGained ||
       
   204          type == EEventFocusGained )
       
   205         {
       
   206         DoHandleForegroundEventL( type );
       
   207         }
       
   208          
       
   209     // All events are sent to base class.
       
   210     CAknAppUi::HandleWsEventL( aEvent, aDestination );
       
   211 
       
   212     MUS_LOG( "mus: [MUSUI ]  <- CMusUiAppUi::HandleWsEventL" );
       
   213     }
       
   214 
       
   215 // -----------------------------------------------------------------------------
       
   216 //
       
   217 // -----------------------------------------------------------------------------
       
   218 //
       
   219 void CMusUiAppUi::HandleForegroundEventL( TBool aForeground )
       
   220     {
       
   221     MUS_LOG( "mus: [MUSUI ]  -> CMusUiAppUi::HandleForegroundEventL" );
       
   222     
       
   223     CAknViewAppUi::HandleForegroundEventL( aForeground );
       
   224     
       
   225     MUS_LOG( "mus: [MUSUI ]  <- CMusUiAppUi::HandleForegroundEventL" );
       
   226     }
       
   227     
       
   228 // -----------------------------------------------------------------------------
       
   229 //
       
   230 // -----------------------------------------------------------------------------
       
   231 //
       
   232 void CMusUiAppUi::MrccatoCommand( TRemConCoreApiOperationId aOperationId, 
       
   233                                   TRemConCoreApiButtonAction aButtonAct )
       
   234     {
       
   235     MUS_LOG2( "mus: [MUSUI ]  -> CMusUiAppUi::MrccatoCommand: %d, %d", 
       
   236               aOperationId,
       
   237               aButtonAct );
       
   238               
       
   239     switch ( aOperationId )
       
   240         {
       
   241         case ERemConCoreApiVolumeUp:  //  Volume Up
       
   242             {
       
   243             switch ( aButtonAct )
       
   244                 {
       
   245                 case ERemConCoreApiButtonClick:
       
   246                     {
       
   247                     // volume up clicked
       
   248                     CMusUiGeneralView* activatedView = 
       
   249                                     static_cast<CMusUiGeneralView*>( iView );
       
   250                                     if( MUS_NO_TOOLBAR )
       
   251                                         {
       
   252                                         TRAP_IGNORE( activatedView->HandleCommandL( 
       
   253                                                 EMusuiCmdViewVolumeUp ) )                                        
       
   254                                         }
       
   255                                     else
       
   256                                         {
       
   257                                         TRAP_IGNORE( activatedView->HandleToolbarCommandL( 
       
   258                                                 EMusuiCmdViewVolumeUp ) )
       
   259                                         }
       
   260                     break;
       
   261                     }
       
   262                 default:
       
   263                     // Never hits this
       
   264                     break;
       
   265                 }
       
   266                 break;
       
   267             }
       
   268         case ERemConCoreApiVolumeDown:  //  Volume Down
       
   269             {
       
   270             switch ( aButtonAct )
       
   271                 {
       
   272                 case ERemConCoreApiButtonClick:
       
   273                     {
       
   274                     // volume down clicked
       
   275                     CMusUiGeneralView* activatedView = 
       
   276                                     static_cast<CMusUiGeneralView*>( iView );
       
   277                                     if( MUS_NO_TOOLBAR )
       
   278                                         {
       
   279                                         TRAP_IGNORE( activatedView->HandleCommandL( 
       
   280                                                     EMusuiCmdViewVolumeDown ) )
       
   281                                         }
       
   282                                     else
       
   283                                         {
       
   284                                         TRAP_IGNORE( activatedView->HandleToolbarCommandL( 
       
   285                                                     EMusuiCmdViewVolumeDown ) )                                        
       
   286                                         }
       
   287                     break;
       
   288                     }
       
   289                 default:
       
   290                     // Never hits this
       
   291                     break;
       
   292                 }
       
   293                 break;
       
   294             }
       
   295         }
       
   296         
       
   297     MUS_LOG( "mus: [MUSUI ]  <- CMusUiAppUi::MrccatoCommand" );
       
   298     }
       
   299 
       
   300 
       
   301 // -----------------------------------------------------------------------------
       
   302 //
       
   303 // -----------------------------------------------------------------------------
       
   304 //
       
   305 void CMusUiAppUi::QueryAcceptedL( TBool aAccepted )
       
   306     {
       
   307     MUS_LOG( "mus: [MUSUI ]  -> CMusUiAppUi::QueryAccepted" );
       
   308     CMusUiGeneralView* activatedView = static_cast<CMusUiGeneralView*>( iView );
       
   309     // TODO: If next call leaves, it causes error handling to be done with
       
   310     // previously deleted query object. This leads to crash.
       
   311     activatedView->AsyncQueryDialogAcceptedL( aAccepted );
       
   312     MUS_LOG( "mus: [MUSUI ]  <- CMusUiAppUi::QueryAccepted" );
       
   313     }
       
   314 
       
   315 
       
   316 // -----------------------------------------------------------------------------
       
   317 // 
       
   318 // -----------------------------------------------------------------------------
       
   319 //
       
   320 TInt CMusUiAppUi::HandleQueryError( TInt aError )
       
   321     {
       
   322     HandleError( aError ); // Forward to general error handler
       
   323     return KErrNone;
       
   324     }
       
   325     
       
   326 
       
   327 // -----------------------------------------------------------------------------
       
   328 //
       
   329 // -----------------------------------------------------------------------------
       
   330 //
       
   331 void CMusUiAppUi::ActivateLocalMusViewL( TUid aViewId )
       
   332     {
       
   333     MUS_LOG( "mus: [MUSUI ]  -> CMusUiAppUi::ActivateLocalMusViewL" );
       
   334     ActivateLocalViewL( aViewId );
       
   335     MUS_LOG( "mus: [MUSUI ]  <- CMusUiAppUi::ActivateLocalMusViewL" );
       
   336     }
       
   337 
       
   338 
       
   339 // -----------------------------------------------------------------------------
       
   340 //
       
   341 // -----------------------------------------------------------------------------
       
   342 //
       
   343 void CMusUiAppUi::ActivateLocalMusViewL( TUid aViewId,
       
   344                                          TUid aCustomMessageId,
       
   345                                          const TDesC8& aCustomMessage )
       
   346     {
       
   347     MUS_LOG( "mus: [MUSUI ]  -> CMusUiAppUi::ActivateLocalMusViewL" );
       
   348     ActivateLocalViewL( aViewId, aCustomMessageId, aCustomMessage );
       
   349     MUS_LOG( "mus: [MUSUI ]  <- CMusUiAppUi::ActivateLocalMusViewL" );
       
   350     }
       
   351 
       
   352 
       
   353 // -----------------------------------------------------------------------------
       
   354 //
       
   355 // -----------------------------------------------------------------------------
       
   356 //
       
   357 void CMusUiAppUi::ShowAsyncConfirmationQueryDialogL( const TDesC& aPrompt )
       
   358     {
       
   359     MUS_LOG( "mus: [MUSUI ]  -> CMusUiAppUi::ShowAsyncConfirmationQueryDialogL" );
       
   360     if ( !iConfirmationQuery )
       
   361         {
       
   362         iConfirmationQuery = CMusUiActiveQueryDialog::NewL( *this );
       
   363         }
       
   364     iConfirmationQuery->ShowL( aPrompt );
       
   365     MUS_LOG( "mus: [MUSUI ]  <- CMusUiAppUi::ShowAsyncConfirmationQueryDialogL" );
       
   366     }
       
   367 
       
   368 
       
   369 // -----------------------------------------------------------------------------
       
   370 //
       
   371 // -----------------------------------------------------------------------------
       
   372 //
       
   373 void CMusUiAppUi::SetToolbarVisibility( TBool aVisible )
       
   374     {
       
   375     CMusUiGeneralView* activatedView = static_cast<CMusUiGeneralView*>( iView );
       
   376     if ( activatedView )
       
   377         {
       
   378         activatedView->SetToolbarVisibility( aVisible );
       
   379         }
       
   380     }
       
   381 
       
   382 
       
   383 // -----------------------------------------------------------------------------
       
   384 //
       
   385 // -----------------------------------------------------------------------------
       
   386 //
       
   387 void CMusUiAppUi::ShowNaviPaneIconL( TMusUiNaviMediaDecorator aIcon )
       
   388     {
       
   389     MusStatusPane()->ShowNaviPaneIconL( aIcon );
       
   390     }
       
   391    
       
   392 
       
   393 // -----------------------------------------------------------------------------
       
   394 //
       
   395 // -----------------------------------------------------------------------------
       
   396 //
       
   397 CEikonEnv* CMusUiAppUi::EikonEnv( ) const
       
   398     {
       
   399     return iEikonEnv;
       
   400     }
       
   401     
       
   402     
       
   403 // -----------------------------------------------------------------------------
       
   404 //
       
   405 // -----------------------------------------------------------------------------
       
   406 //
       
   407 void CMusUiAppUi::TerminateCall()
       
   408     {
       
   409     // TODO: Remove hard-coded values!
       
   410     MUS_LOG( "mus: [MUSUI ]  -> CMusUiAppUi::TerminateCall" );
       
   411     RWsSession sess = iEikonEnv->WsSession();
       
   412     
       
   413     TApaTaskList taskList(sess);
       
   414     
       
   415     TApaTask phoneTask = taskList.FindApp(TUid::Uid(0x100058B3));
       
   416     MUS_LOG( "mus: [MUSUI ]     phoneTask" );
       
   417     TInt id = 0;
       
   418     if (phoneTask.Exists())
       
   419         id = phoneTask.WgId();
       
   420     MUS_LOG1( "PhoneTask ID: %d",id );    
       
   421     TWsEvent event;
       
   422 
       
   423     MUS_LOG( "mus: [MUSUI ]     CMusUiAppUi::TerminateCall: 1" );
       
   424     MUS_LOG( "mus: [MUSUI ]     CMusUiAppUi::EEventKeyDown" );
       
   425     event.SetType( EEventKeyDown );
       
   426     event.SetTimeNow();
       
   427     event.Key()->iCode = 0;
       
   428     event.Key()->iModifiers = EModifierNumLock;
       
   429     event.Key()->iRepeats = 0;
       
   430     event.Key()->iScanCode = EStdKeyNo;
       
   431     sess.SendEventToWindowGroup( id, event ); 
       
   432 
       
   433     MUS_LOG( "mus: [MUSUI ]     CMusUiAppUi::TerminateCall: 2" );
       
   434     MUS_LOG( "mus: [MUSUI ]     CMusUiAppUi::EEventKey" );
       
   435     event.SetType( EEventKey );
       
   436     event.SetTimeNow();
       
   437     event.Key()->iCode = EKeyNo;
       
   438     event.Key()->iModifiers = 32769;
       
   439     event.Key()->iRepeats = 0;
       
   440     event.Key()->iScanCode = EStdKeyNo;
       
   441     sess.SendEventToWindowGroup( id, event ); 
       
   442 
       
   443    	MUS_LOG( "mus: [MUSUI ]     CMusUiAppUi::TerminateCall: 3" );
       
   444     MUS_LOG( "mus: [MUSUI ]     CMusUiAppUi::EEventKeyUp" );
       
   445     event.SetType( EEventKeyUp );
       
   446     event.SetTimeNow();
       
   447     event.Key()->iCode = 0;
       
   448     event.Key()->iModifiers = 32769;
       
   449     event.Key()->iRepeats = 0;
       
   450     event.Key()->iScanCode = EStdKeyNo;
       
   451     sess.SendEventToWindowGroup( id, event );
       
   452     
       
   453     MUS_LOG( "mus: [MUSUI ]  <- CMusUiAppUi::TerminateCall" );
       
   454     }
       
   455 
       
   456 
       
   457 // -----------------------------------------------------------------------------
       
   458 // Return current app orientation.
       
   459 // -----------------------------------------------------------------------------
       
   460 //
       
   461 CAknAppUiBase::TAppUiOrientation CMusUiAppUi::AppOrientation() const
       
   462     {
       
   463     return ( ApplicationRect().Width() > ApplicationRect().Height() ) ?
       
   464             CAknAppUiBase::EAppUiOrientationLandscape :
       
   465             CAknAppUiBase::EAppUiOrientationPortrait;
       
   466     }
       
   467 
       
   468 
       
   469 // -----------------------------------------------------------------------------
       
   470 // Switch the active view's orientation, if it's in the foreground.
       
   471 // -----------------------------------------------------------------------------
       
   472 //
       
   473 void CMusUiAppUi::SwitchOrientationL( TAppUiOrientation aAppOrientation )
       
   474     {
       
   475     MUS_LOG( "mus: [MUSUI ]  -> CMusUiAppUi::SwitchOrientationL" );
       
   476     SetOrientationL( aAppOrientation );
       
   477     MUS_LOG( "mus: [MUSUI ]  <- CMusUiAppUi::SwitchOrientationL" );
       
   478     }
       
   479         
       
   480 
       
   481 // -----------------------------------------------------------------------------
       
   482 //
       
   483 // -----------------------------------------------------------------------------
       
   484 //
       
   485 void CMusUiAppUi::HandleError( const TInt aReason )
       
   486     {
       
   487     MUS_LOG( "mus: [MUSUI ]  -> CMusUiAppUi::HandleError" );
       
   488     if ( aReason != KErrNone )
       
   489         {
       
   490         HandleExit();
       
   491         }
       
   492     MUS_LOG( "mus: [MUSUI ]  <- CMusUiAppUi::HandleError" );
       
   493     }
       
   494 
       
   495 
       
   496 // -----------------------------------------------------------------------------
       
   497 //
       
   498 // -----------------------------------------------------------------------------
       
   499 //
       
   500 void CMusUiAppUi::HandleExit()
       
   501     {
       
   502     MUS_LOG( "mus: [MUSUI ]  -> CMusUiAppUi::HandleExit" );
       
   503     if ( !iExit )
       
   504         {
       
   505         iExit = ETrue;
       
   506         PrepareToExit();
       
   507 
       
   508         RemoveView( KMusUidLiveSharingView );
       
   509         RemoveView( KMusUidClipSharingView );
       
   510         RemoveView( KMusUidReceivingView );
       
   511 
       
   512         User::Exit( KErrNone );
       
   513         }
       
   514     MUS_LOG( "mus: [MUSUI ]  <- CMusUiAppUi::HandleExit" );
       
   515     }
       
   516 
       
   517 
       
   518 // -----------------------------------------------------------------------------
       
   519 //
       
   520 // -----------------------------------------------------------------------------
       
   521 //
       
   522 TBool CMusUiAppUi::OrientationCanBeChanged() const
       
   523     {
       
   524     return CAknAppUiBase::OrientationCanBeChanged();
       
   525     }
       
   526 
       
   527 
       
   528 // -----------------------------------------------------------------------------
       
   529 // From base class CEikAppUi.  Handles a change to the application's
       
   530 // resources which are shared across the environment.
       
   531 // -----------------------------------------------------------------------------
       
   532 //
       
   533 void CMusUiAppUi::HandleResourceChangeL( TInt aResourceChangeType )
       
   534     {
       
   535     MUS_LOG( "mus: [MUSUI ]  -> CMusUiAppUi::HandleResourceChangeL" );
       
   536     CAknAppUi::HandleResourceChangeL( aResourceChangeType );
       
   537 
       
   538     if ( aResourceChangeType == KEikDynamicLayoutVariantSwitch )
       
   539         {
       
   540         MUS_LOG( "mus: [MUSUI ]  CMusUiAppUi::HandleResourceChangeL:\
       
   541                  aResourceChangeType == KEikDynamicLayoutVariantSwitch" );
       
   542 
       
   543         CMusUiGeneralView* activatedView =
       
   544                                 static_cast<CMusUiGeneralView*>( iView );
       
   545         if ( !IsForeground() )
       
   546             {
       
   547             MUS_LOG( "mus: [MUSUI ]  <- CMusUiAppUi::HandleResourceChangeL" );
       
   548             return;
       
   549             }
       
   550         
       
   551         if ( activatedView )
       
   552             {
       
   553             activatedView->RefreshView();
       
   554             }
       
   555         }
       
   556 
       
   557     MUS_LOG( "mus: [MUSUI ]  <- CMusUiAppUi::HandleResourceChangeL" );
       
   558     }
       
   559 
       
   560 
       
   561 // -----------------------------------------------------------------------------
       
   562 // takes care of key event handling
       
   563 // -----------------------------------------------------------------------------
       
   564 //
       
   565 TKeyResponse CMusUiAppUi::HandleKeyEventL( const TKeyEvent& aKeyEvent,
       
   566                                            TEventCode /*aType*/ )
       
   567     {
       
   568     MUS_LOG1( "mus: [MUSUI ]  -> CMusUiAppUi::HandleKeyEventL: %d", 
       
   569                             aKeyEvent.iScanCode );
       
   570     MUS_LOG1( "mus: [MUSUI ]  -> CMusUiAppUi::HandleKeyEventL: %d", 
       
   571                             aKeyEvent.iCode );
       
   572 
       
   573     if ( aKeyEvent.iScanCode == EStdKeyDevice1 /*165*/ )   // Cancel in Options
       
   574         {
       
   575         SetToolbarVisibility( ETrue );
       
   576         }
       
   577     MUS_LOG( "mus: [MUSUI ]  <- CMusUiAppUi::HandleKeyEventL" );
       
   578     return EKeyWasNotConsumed;
       
   579     }
       
   580 
       
   581 
       
   582 // -----------------------------------------------------------------------------
       
   583 // takes care of command handling
       
   584 // -----------------------------------------------------------------------------
       
   585 //
       
   586 void CMusUiAppUi::HandleCommandL( TInt aCommand )
       
   587     {
       
   588     MUS_LOG1( "mus: [MUSUI ]     -> CMusUiAppUi::HandleCommandL [%d]", 
       
   589                             aCommand );
       
   590     switch ( aCommand )
       
   591         {
       
   592         case EMusuiGenCmdExit:
       
   593         case EAknSoftkeyExit:
       
   594         case EEikCmdExit:
       
   595             {
       
   596             SetToolbarVisibility( EFalse );
       
   597             HandleExit();
       
   598             break;
       
   599             }
       
   600         default:
       
   601             break;
       
   602         }
       
   603     MUS_LOG( "mus: [MUSUI ]  <-> CMusUiAppUi::HandleCommandL" );
       
   604     }
       
   605 
       
   606 // -----------------------------------------------------------------------------
       
   607 // CMusUiAppUi::GetVolumeFromUi()
       
   608 // -----------------------------------------------------------------------------
       
   609 //
       
   610 TInt CMusUiAppUi::GetUiVolumeValue()
       
   611     {
       
   612     return iStatusPaneHandler->GetVolumeControlValue();
       
   613     }
       
   614 
       
   615 
       
   616 // -----------------------------------------------------------------------------
       
   617 // CMusUiAppUi::AppHelpContextL()
       
   618 // -----------------------------------------------------------------------------
       
   619 //
       
   620 CArrayFix<TCoeHelpContext>* CMusUiAppUi::HelpContextL() const
       
   621     {
       
   622     MUS_LOG( "mus: [MUSUI ]  -> CMusUiAppUi::HelpContextL" );
       
   623     CArrayFix<TCoeHelpContext>* contexts = 
       
   624             new (ELeave) CArrayFixFlat<TCoeHelpContext>(1);    
       
   625     CleanupStack::PushL(contexts);
       
   626     
       
   627     TCoeHelpContext help; 
       
   628     help.iMajor.iUid = KMusUiUid;
       
   629     
       
   630     if ( iView->Id() == KMusUidLiveSharingView )
       
   631         {
       
   632         help.iContext = KMSH_HLP_LIVE;
       
   633         }
       
   634     else if ( iView->Id() == KMusUidClipSharingView )
       
   635         {
       
   636         help.iContext = KMSH_HLP_CLIP;
       
   637         }
       
   638     else if ( iView->Id() == KMusUidReceivingView )
       
   639         {
       
   640         help.iContext = KMSH_HLP_RECEIVE;
       
   641         }
       
   642 
       
   643     contexts->AppendL(help);    
       
   644     CleanupStack::Pop(); // contexts
       
   645 
       
   646     MUS_LOG( "mus: [MUSUI ]  <- CMusUiAppUi::HelpContextL" );
       
   647     return contexts;
       
   648     }
       
   649 
       
   650 
       
   651 // -----------------------------------------------------------------------------
       
   652 // We might get PartialFocusLost also for some notes and
       
   653 // overally items that are somehow overlapping screen instead of
       
   654 // FocusLost. In those cases we should not put app to background.
       
   655 // -----------------------------------------------------------------------------
       
   656 //
       
   657 void CMusUiAppUi::DoHandleForegroundEventL( TInt aEventType )
       
   658     {
       
   659     MUS_LOG1( "mus: [MUSUI ]  -> CMusUiAppUi::DoHandleForegroundEventL, event:%d", 
       
   660               aEventType );
       
   661     
       
   662     __ASSERT_ALWAYS( aEventType == KAknFullOrPartialForegroundGained ||
       
   663                      aEventType == KAknFullOrPartialForegroundLost ||
       
   664                      aEventType == EEventFocusLost ||
       
   665                      aEventType == EEventFocusGained, User::Leave( KErrArgument ) );
       
   666     
       
   667     TBool handleEvent( EFalse );
       
   668     TBool foreground( 
       
   669             aEventType == KAknFullOrPartialForegroundGained ||
       
   670             aEventType == EEventFocusGained );
       
   671 
       
   672     const TInt windowGroupId =
       
   673         iCoeEnv->WsSession().GetFocusWindowGroup();
       
   674 
       
   675     MUS_LOG1( "mus: [MUSUI ]    focus wgid:%d", windowGroupId );
       
   676     
       
   677     if ( foreground )
       
   678         {
       
   679         iCoeEnv->RootWin().EnableFocusChangeEvents();
       
   680         handleEvent = ETrue;
       
   681         }
       
   682     else if ( ( windowGroupId != iThisApplicationWgId ) &&
       
   683               ( windowGroupId != iEikonServerWgId ) &&
       
   684               ( windowGroupId != iAknCapServerWgId ) &&
       
   685               ( windowGroupId != iAknNfyServerWgId ) )
       
   686         {
       
   687         iCoeEnv->RootWin().DisableFocusChangeEvents();
       
   688         handleEvent = ETrue;
       
   689         }
       
   690     else
       
   691         {
       
   692         // NOP
       
   693         }
       
   694           
       
   695     if ( handleEvent && iView && foreground != iForeground )
       
   696         {
       
   697         iForeground = foreground;
       
   698         
       
   699         CMusUiGeneralView* activatedView = 
       
   700             static_cast<CMusUiGeneralView*>( iView );
       
   701             
       
   702         activatedView->DoHandleForegroundEventL( foreground );
       
   703         }
       
   704     
       
   705     MUS_LOG( "mus: [MUSUI ]  <- CMusUiAppUi::DoHandlerForegroundEventL" );
       
   706     }
       
   707 
       
   708 // -----------------------------------------------------------------------------
       
   709 // 
       
   710 // -----------------------------------------------------------------------------
       
   711 //
       
   712 void CMusUiAppUi::FindWindowGroupIdentifiersL()
       
   713     {
       
   714     MUS_LOG( "mus: [MUSUI ]  -> CMusUiAppUi::FindWindowGroupIdentifiersL" );
       
   715     
       
   716     // Name of the EIKON server window group.
       
   717     _LIT( KMusUiEikonServer, "EikonServer" );
       
   718 
       
   719     // Name of the AknCapServer window group.
       
   720     _LIT( KMusUiAknCapServer, "*akncapserver*" );
       
   721 
       
   722     // Name of the AknNotifierServer window group.
       
   723     _LIT( KMusUiAknNotifierServer, "*aknnfysrv*" );
       
   724     
       
   725     CEikonEnv& eikEnv = *( iEikonEnv );
       
   726     eikEnv.SetSystem( ETrue );
       
   727     eikEnv.WsSession().ComputeMode( RWsSession::EPriorityControlDisabled );
       
   728 
       
   729     iThisApplicationWgId = eikEnv.RootWin().Identifier();
       
   730     MUS_LOG1( "mus: [MUSUI ]    own wgid:%d", iThisApplicationWgId );
       
   731     iEikonServerWgId =
       
   732         eikEnv.WsSession().FindWindowGroupIdentifier( 0, KMusUiEikonServer );
       
   733     MUS_LOG1( "mus: [MUSUI ]    eikonserv wgid:%d", iEikonServerWgId );
       
   734     iAknCapServerWgId =
       
   735         eikEnv.WsSession().FindWindowGroupIdentifier( 0, KMusUiAknCapServer );
       
   736     MUS_LOG1( "mus: [MUSUI ]    akncapserv wgid:%d", iAknCapServerWgId );
       
   737     iAknNfyServerWgId =
       
   738         eikEnv.WsSession().FindWindowGroupIdentifier( 0,
       
   739             KMusUiAknNotifierServer );
       
   740     MUS_LOG1( "mus: [MUSUI ]    aknnotifserv wgid:%d", iAknNfyServerWgId );
       
   741     
       
   742     eikEnv.RootWin().EnableFocusChangeEvents();
       
   743     
       
   744     MUS_LOG( "mus: [MUSUI ]  <- CMusUiAppUi::FindWindowGroupIdentifiersL" );
       
   745     }
       
   746 
       
   747 // end of file