uifw/AvKon/src/aknindicatordataobserver.cpp
changeset 0 2f259fa3e83a
child 25 941195f2d488
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2006-2008 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:  This class updates the status indicator container control
       
    15 *                in status pane.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // SYSTEM INCLUDE FILES
       
    21 #include <AknIndicatorContainer.h>
       
    22 #include <AknIndicator.h>
       
    23 #include "aknstatuspanedatasubscriber.h"
       
    24 #include <eikspane.h>
       
    25 #include <avkon.hrh>
       
    26 #include <AknDef.h>
       
    27 
       
    28 // USER INCLUDE FILES
       
    29 #include "aknindicatordataobserver.h"
       
    30 #include "aknstatuspanedata.h"
       
    31 #include "AknIncallStatusBubble.h"
       
    32 
       
    33 /** Value used to specify that an indicator is not shown. */
       
    34 const TInt KEmpty = 0xFFFFFFFF;
       
    35 
       
    36 // ============================ MEMBER FUNCTIONS =============================
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // CAknIndicatorDataObserver::CAknIndicatorDataObserver
       
    40 // C++ default constructor can NOT contain any code, that
       
    41 // might leave.
       
    42 // ---------------------------------------------------------------------------
       
    43 //
       
    44 CAknIndicatorDataObserver::CAknIndicatorDataObserver(
       
    45     CAknIndicatorContainer* aIndicatorPane )
       
    46 	{
       
    47 	iIndicatorPane = aIndicatorPane;
       
    48 	iIndicatorPane->MopGetObject( iDataSubscriber );
       
    49 	if ( iDataSubscriber )
       
    50 		{
       
    51 		iDataSubscriber->AddObserver( this );
       
    52 		}
       
    53 
       
    54 	iFirstUpdate = ETrue;
       
    55   	}
       
    56 
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // Destructor
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 CAknIndicatorDataObserver::~CAknIndicatorDataObserver()
       
    63 	{
       
    64 	if ( iDataSubscriber )
       
    65 		{
       
    66 		iDataSubscriber->RemoveObserver( this );
       
    67 		}
       
    68 
       
    69     }
       
    70 
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // CAknIndicatorDataObserver::HandleUpdateL
       
    74 // Update state to UI control.
       
    75 // ---------------------------------------------------------------------------
       
    76 //
       
    77 void CAknIndicatorDataObserver::HandleUpdateL(
       
    78     const TAknStatusPaneStateData& aData )
       
    79 	{
       
    80 	if ( !iDataSubscriber )
       
    81 	    {
       
    82 		return;
       
    83 	    }
       
    84 
       
    85 	TAknIndicatorState state = aData.iIndicatorState;
       
    86 
       
    87 	TBool indicatorPaneIsInCurrentLayout = ETrue;
       
    88 
       
    89 	// If this pane is not in current layout, no update.
       
    90 	// Update happens when status pane layout is changed.
       
    91     CEikStatusPaneBase* statusPane = CEikStatusPaneBase::Current();
       
    92    	if ( !statusPane ||
       
    93    		 !statusPane->PaneCapabilities(
       
    94    		    TUid::Uid( EEikStatusPaneUidIndic ) ).IsInCurrentLayout() )
       
    95    		{
       
    96 		indicatorPaneIsInCurrentLayout = EFalse;
       
    97    		}
       
    98 
       
    99     TBool updateAnimation =
       
   100     	( !iDataSubscriber->IsBackground() ||
       
   101     	  iDataSubscriber->RefreshLevel() > CAknStatusPaneDataSubscriber::ERefreshLevelMedium );
       
   102 
       
   103 	// Incall bubble is shown when in foreground and in
       
   104 	// the very first update (to avoid flicker).
       
   105     TBool showIncallBubble = !iDataSubscriber->IsBackground() || iFirstUpdate;
       
   106 
       
   107 	TBool anyIndicatorChanged = EFalse;
       
   108 
       
   109 	if ( indicatorPaneIsInCurrentLayout )
       
   110 		{
       
   111 		// If indicator does not yet exist, set its state
       
   112 		// initially to "off" -> indicator gets created.
       
   113 		for ( TInt j = 0; j < TAknIndicatorState::EMaxVisibleIndicators; j++ )
       
   114 		    {
       
   115 		    if ( state.visibleIndicators[j] != KEmpty &&
       
   116 		    	 !iIndicatorPane->IndicatorExists(
       
   117 		    	    TUid::Uid( state.visibleIndicators[j] ) ) )
       
   118 		    	{
       
   119 		    	iIndicatorPane->SetIndicatorState(
       
   120 		    	    TUid::Uid( state.visibleIndicators[j] ),
       
   121 		    	    MAknIndicator::EIndicatorOff,
       
   122 		    	    EFalse );
       
   123 		    	}
       
   124 		    }
       
   125 
       
   126 		TInt count = iIndicatorPane->iIndicators->Count();
       
   127 
       
   128 		for ( TInt ii = 0; ii < count; ii++ )
       
   129 		    {
       
   130 		    CAknIndicator* indicator = iIndicatorPane->iIndicators->At( ii );
       
   131 		    TInt indicState = indicator->IndicatorState();
       
   132 		    TInt indicUid   = indicator->Uid().iUid;
       
   133 
       
   134 		    TBool shownInCurrentLayoutMode = ( indicator->Priority() != -1 );
       
   135 
       
   136 		    TBool found = EFalse;
       
   137 
       
   138 		    for ( TInt jj = 0; jj < TAknIndicatorState::EMaxVisibleIndicators; jj++ )
       
   139 		    	{
       
   140 		    	if ( state.visibleIndicators[jj] == KEmpty )
       
   141 		    		{
       
   142 		    		break;
       
   143 		    		}
       
   144 			    else if ( state.visibleIndicators[jj] == indicUid )
       
   145 		    		{
       
   146 		    		found = ETrue;
       
   147 			    	if ( state.visibleIndicatorStates[jj] != indicState &&
       
   148 			    	     shownInCurrentLayoutMode )
       
   149 			    		{
       
   150 		           	    anyIndicatorChanged = ETrue;
       
   151 						if ( state.visibleIndicatorStates[jj] == MAknIndicator::EIndicatorAnimate )
       
   152 							{
       
   153 							if ( updateAnimation )
       
   154 								{
       
   155 								// Update animations only in foreground (unless forced)
       
   156 								indicator->SetIndicatorState( state.visibleIndicatorStates[jj] );
       
   157 		        	        	indicator->SetAnimateState( iIndicatorPane->iSynchronizingValue );
       
   158 								}
       
   159 							else
       
   160 								{
       
   161 								// In background just set it on
       
   162 							   	indicator->SetIndicatorState( MAknIndicator::EIndicatorOn );
       
   163 								}
       
   164 
       
   165 							}
       
   166 						else
       
   167 							{
       
   168 							indicator->SetIndicatorState( state.visibleIndicatorStates[jj] );
       
   169 							}
       
   170 			    		}
       
   171 		    		}
       
   172 		    	}
       
   173 
       
   174 			// If indicators was not in the list we assume its state to be OFF.
       
   175 		    if ( !found )
       
   176 		    	{
       
   177 				if ( indicState != MAknIndicator::EIndicatorOff )
       
   178 					{
       
   179 					anyIndicatorChanged = ETrue;
       
   180 					indicator->SetIndicatorState( MAknIndicator::EIndicatorOff );
       
   181 					}
       
   182 		    	}
       
   183 		    }
       
   184 		}
       
   185 
       
   186     if ( anyIndicatorChanged )
       
   187     	{
       
   188     	iIndicatorPane->PrioritizeIndicatorsL();
       
   189     	iIndicatorPane->SizeChanged();
       
   190 		}
       
   191 
       
   192 
       
   193 	// Incall bubble
       
   194 	TInt modifiedFlags = state.iIncallBubbleFlags;
       
   195 
       
   196 	if ( !showIncallBubble )
       
   197 	    {
       
   198 		modifiedFlags &= ~CIncallStatusBubble::ESBVisible; // Clear visible bit
       
   199 	    }
       
   200 
       
   201 	iIndicatorPane->SetIncallBubbleAllowedInIdle( state.iIncallBubbleAllowedInIdle );
       
   202 	iIndicatorPane->SetIncallBubbleAllowedInUsual( state.iIncallBubbleAllowedInUsual );
       
   203 	iIndicatorPane->SetIncallBubbleDisabled( state.iIncallBubbleDisabled );
       
   204 
       
   205 	iIndicatorPane->SetIncallBubbleFlags( modifiedFlags );
       
   206 
       
   207     if ( anyIndicatorChanged || showIncallBubble )
       
   208     	{
       
   209     	iIndicatorPane->DrawDeferred();
       
   210 		}
       
   211 
       
   212 	iFirstUpdate = EFalse;
       
   213 	}
       
   214 
       
   215 
       
   216 //  End of File