idlefw/src/idleint/aiuiidleintegration.cpp
branchRCL_3
changeset 18 bd874ee5e5e2
parent 9 d0529222e3f0
child 51 15e4dd19031c
equal deleted inserted replaced
9:d0529222e3f0 18:bd874ee5e5e2
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  Window server plug-in manager.
    14 * Description:  Idle integration
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
       
    19 // System includes
       
    20 #include <coeaui.h>
       
    21 #include <eikenv.h>
       
    22 #include <AknIncallBubbleNotify.h>
       
    23 #include <aknsoundsystem.h>
       
    24 #include <AknDef.h>
       
    25 #include <ctsydomainpskeys.h>
       
    26 
       
    27 // User includes
       
    28 #include <aisystemuids.hrh>
       
    29 #include <aiutility.h>
       
    30 #include <aipspropertyobserver.h>
       
    31 #include "activeidle2domainpskeys.h"
    19 #include "aiuiidleintegrationimpl.h"
    32 #include "aiuiidleintegrationimpl.h"
    20 #include "aifweventhandler.h"
    33 #include "aifweventhandler.h"
    21 
       
    22 #include <coemain.h>
       
    23 #include <coeaui.h>
       
    24 #include <eikenv.h>
       
    25 #include <apgtask.h>
       
    26 #include <AknIncallBubbleNotify.h>
       
    27 #include <aknsoundsystem.h>
       
    28 #include <apgwgnam.h> 
       
    29 #include <AknDef.h>
       
    30 #include <AknCapServerDefs.h> 
       
    31 #include <startupdomainpskeys.h>
       
    32 #include <aiutility.h>
       
    33 #include <aipspropertyobserver.h>
       
    34 #include <aisystemuids.hrh>
       
    35 
       
    36 #include "aistate.h"
    34 #include "aistate.h"
    37 #include "aifwpanic.h"
    35 #include "aifwpanic.h"
    38 #include "activeidle2domainpskeys.h"
    36 #include "debug.h"
    39 
    37 
    40 #include <ctsydomainpskeys.h>
       
    41 
       
    42 #include <AknSgcc.h>
       
    43 
    38 
    44 // ======== MEMBER FUNCTIONS ========
    39 // ======== MEMBER FUNCTIONS ========
    45 
    40 
    46 // ----------------------------------------------------------------------------
    41 // ----------------------------------------------------------------------------
    47 // CAiUiIdleIntegrationImpl::NewL()
    42 // CAiUiIdleIntegrationImpl::NewL()
    68     {
    63     {
    69     delete iActiveIdleState;
    64     delete iActiveIdleState;
    70     
    65     
    71     delete iIncallBubble;
    66     delete iIncallBubble;
    72     
    67     
    73     Release( iSystemStateObserver );
       
    74     
       
    75     Release( iUiStartupStateObserver );
       
    76     
       
    77     Release( iCallStatusObserver );
    68     Release( iCallStatusObserver );
    78     }
    69     }
    79 
    70 
    80 // ----------------------------------------------------------------------------
    71 // ----------------------------------------------------------------------------
    81 // CAiUiIdleIntegrationImpl::CAiUiIdleIntegrationImpl()
    72 // CAiUiIdleIntegrationImpl::CAiUiIdleIntegrationImpl()
    93 // ----------------------------------------------------------------------------
    84 // ----------------------------------------------------------------------------
    94 //
    85 //
    95 void CAiUiIdleIntegrationImpl::ConstructL(
    86 void CAiUiIdleIntegrationImpl::ConstructL(
    96     const TAiIdleKeySoundConfig& aKeySoundConfig )       
    87     const TAiIdleKeySoundConfig& aKeySoundConfig )       
    97     {   
    88     {   
       
    89     __PRINTS( "*** CAiUiIdleIntegrationImpl::ConstructL" );
       
    90     __TIME_MARK( time );
       
    91     
    98 	iIncallBubble = CAknIncallBubble::NewL();
    92 	iIncallBubble = CAknIncallBubble::NewL();
    99 	
    93 	
   100     iActiveIdleState = CActiveIdleState::NewL();
    94     iActiveIdleState = CActiveIdleState::NewL();
   101            
    95            
   102     // Set up keysounds
    96     // Set up keysounds
   103     if( aKeySoundConfig.iKeySounds )
    97     if( aKeySoundConfig.iKeySounds )
   104         {
    98         {
   105         aKeySoundConfig.iKeySounds
    99         aKeySoundConfig.iKeySounds->PushContextL( 
   106             ->PushContextL( aKeySoundConfig.iContextResId );            
   100             aKeySoundConfig.iContextResId );                       
   107         }
   101         }
   108     
   102     
   109     iEikEnv.SetSystem( ETrue );
   103     iEikEnv.SetSystem( ETrue );
   110                  
   104              
   111     // Eikon server window group
   105     TInt wgId( iEikEnv.RootWin().Identifier() );
   112     iThisApplicationWgId = iEikEnv.RootWin().Identifier();
   106     TInt focusWgId( iEikEnv.WsSession().GetFocusWindowGroup() );
   113     
   107     
   114     CApaWindowGroupName::FindByAppUid( KAknCapServerUid, 
   108     if ( focusWgId == wgId )
   115                                        iEikEnv.WsSession(), 
   109         {
   116                                        iEikonServerWgId );
   110         __PRINTS( "*** CAiUiIdleIntegrationImpl::ConstructL - iForeground: 1" );
   117 	           
   111     
   118     iActiveIdleState->SetIsIdleForeground( iThisApplicationForeground );
   112         iForeground = ETrue;
       
   113         }
       
   114     
       
   115     iActiveIdleState->SetIsIdleForeground( iForeground );
   119       
   116       
   120     iSystemStateObserver = AiUtility::CreatePSPropertyObserverL(                      
       
   121                             TCallBack( HandleSystemStateChange, this ),            
       
   122                                        KPSUidStartup, 
       
   123                                        KPSGlobalSystemState );
       
   124               
       
   125     iUiStartupStateObserver = AiUtility::CreatePSPropertyObserverL(                           
       
   126                                 TCallBack( HandleUiStartupStateChange, this ),            
       
   127                                            KPSUidStartup, 
       
   128                                            KPSStartupUiPhase );        
       
   129                  
       
   130     iCallStatusObserver = AiUtility::CreatePSPropertyObserverL(          
   117     iCallStatusObserver = AiUtility::CreatePSPropertyObserverL(          
   131                             TCallBack( HandleCallEvent, this ),  
   118                             TCallBack( HandleCallEvent, this ),  
   132                                        KPSUidCtsyCallInformation, 
   119                                        KPSUidCtsyCallInformation, 
   133                                        KCTsyCallState );  
   120                                        KCTsyCallState );  
   134     
   121     
   135     // Update state flags.    
   122     ActivateUI();
   136     CAiUiIdleIntegrationImpl::HandleSystemStateChange( this );
   123            
   137     CAiUiIdleIntegrationImpl::HandleUiStartupStateChange( this );
   124     __TIME_ENDMARK( "CAiUiIdleIntegrationImpl::ConstructL, done", time );
   138     }
   125     }
   139 
   126 
   140 // ----------------------------------------------------------------------------
   127 // ----------------------------------------------------------------------------
   141 // CAiUiIdleIntegrationImpl::ActivateUI()
   128 // CAiUiIdleIntegrationImpl::ActivateUI()
   142 // ----------------------------------------------------------------------------
   129 // ----------------------------------------------------------------------------
   143 //
   130 //
   144 void CAiUiIdleIntegrationImpl::ActivateUI()
   131 void CAiUiIdleIntegrationImpl::ActivateUI()
   145     {       
   132     {   
   146     if( iUiStartupPhaseOk && iSystemStateOk )
   133     __TICK( "CAiUiIdleIntegrationImpl::ActivateUI - HandleActivateUI" );
   147         {      
   134     
   148         RWsSession& wsSession( iEikEnv.WsSession() );
   135     iAiFwEventHandler->HandleActivateUI();
   149         
   136     
   150         TInt focusWgId( wsSession.GetFocusWindowGroup() );
   137     __PRINTS( "CAiUiIdleIntegrationImpl::ActivateUI - HandleActivateUI done" );    
   151         
       
   152         if( iThisApplicationWgId != focusWgId )
       
   153             {                       
       
   154             TApaTaskList taskList( wsSession );
       
   155             
       
   156             TApaTask task( taskList.FindApp( TUid::Uid( AI_UID3_AIFW_EXE ) ) );
       
   157             
       
   158             task.SendSystemEvent( EApaSystemEventBroughtToForeground );            
       
   159             }
       
   160 
       
   161         iAiFwEventHandler->HandleActivateUI();
       
   162         }    
       
   163     }
   138     }
   164 
   139 
   165 // ----------------------------------------------------------------------------
   140 // ----------------------------------------------------------------------------
   166 // CAiUiIdleIntegrationImpl::HandleWsEventL()
   141 // CAiUiIdleIntegrationImpl::HandleWsEventL()
   167 // ----------------------------------------------------------------------------
   142 // ----------------------------------------------------------------------------
   168 //
   143 //
   169 void CAiUiIdleIntegrationImpl::HandleWsEventL( const TWsEvent& aEvent, 
   144 void CAiUiIdleIntegrationImpl::HandleWsEventL( const TWsEvent& aEvent, 
   170     CCoeControl* /*aDestination*/ )
   145     CCoeControl* /*aDestination*/ )
   171     {
   146     {
   172     if( !iSystemStateOk || !iUiStartupPhaseOk )
   147     TInt type( aEvent.Type() );
   173         {                
   148     
   174         return;
   149     if ( type == KAknFullOrPartialForegroundGained )
   175         }
   150         {
   176       
   151         if ( !iForeground )
   177     switch ( aEvent.Type() )
   152             {
   178     	{
   153             iForeground = ETrue;
   179     	case KAknFullOrPartialForegroundGained:	
   154             iActiveIdleState->SetIsIdleForeground( ETrue );
   180         	{
   155             SetCallBubbleIfNeededL();
   181             if ( !iThisApplicationForeground )
   156             }    
   182             	{
   157         }
   183                 iThisApplicationForeground = ETrue;
   158     else if ( type == KAknFullOrPartialForegroundLost )
   184                 iActiveIdleState->SetIsIdleForeground( ETrue );
   159         {
   185                	SetCallBubbleIfNeededL();
   160         if ( iForeground )
       
   161             {
       
   162             iForeground = EFalse;
       
   163             iActiveIdleState->SetIsIdleForeground( EFalse );
       
   164             ClearCallBubbleL();
       
   165             }    
       
   166         }
       
   167     else if ( type == EEventKeyDown )
       
   168         {
       
   169         if( aEvent.Key()->iScanCode == EStdKeyDevice0 )
       
   170             {
       
   171             TBool isDialog( iEikEnv.AppUi()->IsDisplayingMenuOrDialog() );
       
   172             
       
   173             if( isDialog || iAiFwEventHandler->QueryIsMenuOpen() )
       
   174                 {
       
   175                 RProperty::Set(
       
   176                     KPSUidAiInformation, 
       
   177                     KActiveIdlePopupState, 
       
   178                     EPSAiDisplayingMenuOrDialog );
   186                 }
   179                 }
   187           	break;
   180             else
   188         	}
   181                 {
   189                 
   182                 RProperty::Set(
   190         case KAknFullOrPartialForegroundLost:
   183                     KPSUidAiInformation, 
   191         	{
   184                     KActiveIdlePopupState, 
   192         	if ( iThisApplicationForeground )
   185                     EPSAiNotDisplayingMenuOrDialog );
   193             	{
   186                 }    
   194             	iThisApplicationForeground = EFalse;
   187             }
   195                 iActiveIdleState->SetIsIdleForeground( EFalse );
   188         }        
   196                 ClearCallBubbleL();
       
   197                 }
       
   198         	break;
       
   199         	}
       
   200         
       
   201     	case EEventKeyDown:
       
   202     	    {
       
   203             if( aEvent.Key()->iScanCode == EStdKeyDevice0 )
       
   204             	{
       
   205             	TBool isDialog( iEikEnv.AppUi()->IsDisplayingMenuOrDialog() );
       
   206             	
       
   207             	if( isDialog || iAiFwEventHandler->QueryIsMenuOpen() )
       
   208             	    {
       
   209                     RProperty::Set(
       
   210                         KPSUidAiInformation, 
       
   211                         KActiveIdlePopupState, 
       
   212                         EPSAiDisplayingMenuOrDialog );
       
   213             	    }
       
   214             	else
       
   215             	    {
       
   216                     RProperty::Set(
       
   217                         KPSUidAiInformation, 
       
   218                         KActiveIdlePopupState, 
       
   219                         EPSAiNotDisplayingMenuOrDialog );
       
   220             	    }
       
   221             	} 
       
   222     	    break;
       
   223     	    }
       
   224                 
       
   225     	default:
       
   226     	    {
       
   227     		break;
       
   228     	    }
       
   229     	}
       
   230     }
   189     }
   231 
   190 
   232 // ----------------------------------------------------------------------------
   191 // ----------------------------------------------------------------------------
   233 // CAiUiIdleIntegrationImpl::SetCallBubbleIfNeededL()
   192 // CAiUiIdleIntegrationImpl::SetCallBubbleIfNeededL()
   234 // ----------------------------------------------------------------------------
   193 // ----------------------------------------------------------------------------
   276     return CAiUiIdleIntegrationImpl::NewL( aEikEnv, aKeySoundConfig,                                             
   235     return CAiUiIdleIntegrationImpl::NewL( aEikEnv, aKeySoundConfig,                                             
   277                                            aAiFwEventHandler );
   236                                            aAiFwEventHandler );
   278     }
   237     }
   279 
   238 
   280 // ----------------------------------------------------------------------------
   239 // ----------------------------------------------------------------------------
   281 // CAiUiIdleIntegrationImpl::HandleSystemStateChange()
       
   282 // ----------------------------------------------------------------------------
       
   283 //
       
   284 TInt CAiUiIdleIntegrationImpl::HandleSystemStateChange( TAny* aPtr )
       
   285     {
       
   286     __ASSERT_DEBUG( aPtr, 
       
   287             AiFwPanic::Panic( AiFwPanic::EAiFwPanic_NullPointerReference ) );
       
   288     
       
   289     CAiUiIdleIntegrationImpl* self = 
       
   290         static_cast<CAiUiIdleIntegrationImpl*>( aPtr );
       
   291            
       
   292     if( !self->iSystemStateOk )
       
   293         {
       
   294         TInt state( 0 );
       
   295         
       
   296         self->iSystemStateObserver->Get( state );               
       
   297 
       
   298         if ( state == ESwStateCriticalPhaseOK ||
       
   299              state == ESwStateNormalRfOn || 
       
   300              state == ESwStateNormalRfOff ||
       
   301              state == ESwStateNormalBTSap )        
       
   302             {
       
   303             self->iSystemStateOk = ETrue;            
       
   304             self->ActivateUI();
       
   305             }        
       
   306         }
       
   307               
       
   308     return KErrNone;
       
   309     }
       
   310 
       
   311 // ----------------------------------------------------------------------------
       
   312 // CAiUiIdleIntegrationImpl::HandleUiStartupStateChange()
       
   313 // ----------------------------------------------------------------------------
       
   314 //
       
   315 TInt CAiUiIdleIntegrationImpl::HandleUiStartupStateChange( TAny *aPtr )
       
   316     {
       
   317     __ASSERT_DEBUG( aPtr, 
       
   318             AiFwPanic::Panic( AiFwPanic::EAiFwPanic_NullPointerReference ) );
       
   319     
       
   320     CAiUiIdleIntegrationImpl* self = 
       
   321         static_cast<CAiUiIdleIntegrationImpl*>( aPtr );
       
   322 
       
   323     if( !self->iUiStartupPhaseOk )
       
   324         {
       
   325         TInt state( 0 );
       
   326         
       
   327         self->iUiStartupStateObserver->Get( state );
       
   328         
       
   329         if( state == EStartupUiPhaseAllDone )
       
   330             {
       
   331             self->iUiStartupPhaseOk = ETrue;
       
   332             
       
   333             self->ActivateUI();
       
   334             }
       
   335         }
       
   336     
       
   337     return KErrNone;
       
   338     }
       
   339 
       
   340 // ----------------------------------------------------------------------------
       
   341 // CAiUiIdleIntegrationImpl::HandleCallEvent()
   240 // CAiUiIdleIntegrationImpl::HandleCallEvent()
   342 // ----------------------------------------------------------------------------
   241 // ----------------------------------------------------------------------------
   343 //
   242 //
   344 TInt CAiUiIdleIntegrationImpl::HandleCallEvent( TAny* aPtr )
   243 TInt CAiUiIdleIntegrationImpl::HandleCallEvent( TAny* aPtr )
   345 	{
   244 	{
   357 		{
   256 		{
   358 		// Call ongoing => show bubble if not showing already
   257 		// Call ongoing => show bubble if not showing already
   359 		TBool allowed = EFalse;
   258 		TBool allowed = EFalse;
   360 		
   259 		
   361 		if( !self->iIncallBubbleAllowed &&
   260 		if( !self->iIncallBubbleAllowed &&
   362 		     self->iThisApplicationForeground &&
   261 		     self->iForeground &&
   363 		    ( callStatus > EPSCTsyCallStateNone ) )
   262 		    ( callStatus > EPSCTsyCallStateNone ) )
   364 			{
   263 			{
   365 			allowed = ETrue;
   264 			allowed = ETrue;
   366     		
   265     		
   367 			TRAP( err, 
   266 			TRAP( err,