vtuis/videotelui/src/CVtUiNaviPane.cpp
changeset 0 ed9695c8bcbe
child 8 07d1685f0cd4
equal deleted inserted replaced
-1:000000000000 0:ed9695c8bcbe
       
     1 /*
       
     2 * Copyright (c) 2004-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 the CVtUiNaviPane class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    "CVtUiNaviPane.h"
       
    22 #include    "CVtUiNaviPaneControl.h"
       
    23 #include    "CVtUiMutedControl.h"
       
    24 #include    "CVtUiAppUi.h"
       
    25 
       
    26 #include    <cvtlogger.h>
       
    27 #include    <avkon.rsg>
       
    28 #include    <aknnavi.h>
       
    29 #include    <aknnavide.h>
       
    30 #include    <featmgr.h>
       
    31 #include	"tVtuifeaturevariation.h"
       
    32 #include    <stringloader.h>
       
    33 #include    <videotelui.rsg>
       
    34 
       
    35 // CONSTANTS
       
    36 
       
    37 // Timeout after which voice volume bar is switched back to indicators.
       
    38 const TInt KVtUiVoiceVolumeTimeout = 2000000;
       
    39 
       
    40 // LOCAL FUNCTION PROTOTYPES
       
    41 
       
    42 /**
       
    43 * Creates navigation decorator.
       
    44 * @param aNaviPane reference to navi pane.
       
    45 * @param aControl control to be decorated, ownership passed.
       
    46 * @return new navigation decorator instance.
       
    47 */
       
    48 CAknNavigationDecorator* CreateDecoratorL(
       
    49     CAknNavigationControlContainer& aNaviPane,
       
    50     CCoeControl* aControl );
       
    51 
       
    52 // ============================= LOCAL FUNCTIONS ===============================
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // CreateDecoratorL Creates navigation decorator.
       
    56 // Returns: new navigation decorator instance.
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 CAknNavigationDecorator* CreateDecoratorL(
       
    60         CAknNavigationControlContainer& aNaviPane,
       
    61         CCoeControl* aControl )
       
    62     {
       
    63     CAknNavigationDecorator* decoratedFolder =
       
    64         CAknNavigationDecorator::NewL(
       
    65             &aNaviPane,
       
    66             aControl,
       
    67             CAknNavigationDecorator::ENotSpecified );
       
    68 
       
    69     CleanupStack::PushL( decoratedFolder );
       
    70     decoratedFolder->SetContainerWindowL( aNaviPane );
       
    71     aControl->SetContainerWindowL( *decoratedFolder );
       
    72     CleanupStack::Pop( decoratedFolder );
       
    73 
       
    74     decoratedFolder->MakeScrollButtonVisible( EFalse );
       
    75 
       
    76     return decoratedFolder;
       
    77     }
       
    78 
       
    79 // ============================ MEMBER FUNCTIONS ===============================
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CVtUiNaviPane::CVtUiNaviPane
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 CVtUiNaviPane::CVtUiNaviPane(
       
    86         CAknNavigationControlContainer& aNaviPane,
       
    87         CVtUiAppUi& aAppUi )
       
    88     : CActive( CActive::EPriorityStandard ),
       
    89       iNaviPane( aNaviPane ),
       
    90       iAppUi ( aAppUi )
       
    91     {
       
    92     CActiveScheduler::Add( this );
       
    93     }
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // CVtUiNaviPane::ConstructL
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 void CVtUiNaviPane::ConstructL( )
       
   100     {
       
   101     // Create the navi pane indicator (call duration).
       
   102         {
       
   103         CVtUiNaviPaneControl* naviControl =
       
   104             new ( ELeave ) CVtUiNaviPaneControl( *this );
       
   105         CleanupStack::PushL( naviControl );
       
   106         naviControl->ConstructL();
       
   107         CleanupStack::Pop( naviControl );
       
   108 
       
   109         iMainIndicators =
       
   110             CreateDecoratorL( iNaviPane, naviControl );
       
   111 
       
   112         iNaviPaneControl = naviControl;
       
   113         }
       
   114 
       
   115     // Create muted indicator.
       
   116         {
       
   117         HBufC* mutedText = 
       
   118             StringLoader::LoadLC( R_VIDEOTELUI_QTN_INCAL_MUTED_PANE ); 
       
   119 
       
   120         iMutedIndicator = iNaviPane.CreateNavigationLabelL( *mutedText );
       
   121         
       
   122         CleanupStack::PopAndDestroy( mutedText );
       
   123         }
       
   124 
       
   125     User::LeaveIfError( iTimer.CreateLocal() );
       
   126 
       
   127     }
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // CVtUiNaviPane::NewL
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 CVtUiNaviPane* CVtUiNaviPane::NewL(
       
   134         CAknNavigationControlContainer& aNaviPane,
       
   135         CVtUiAppUi& aAppUi )
       
   136     {
       
   137     CVtUiNaviPane* self =
       
   138         new ( ELeave ) CVtUiNaviPane(
       
   139             aNaviPane, aAppUi );
       
   140     CleanupStack::PushL( self );
       
   141     self->ConstructL();
       
   142     CleanupStack::Pop( self );
       
   143     return self;
       
   144     }
       
   145 
       
   146 // -----------------------------------------------------------------------------
       
   147 // CVtUiNaviPane::~CVtUiNaviPane
       
   148 // -----------------------------------------------------------------------------
       
   149 //
       
   150 CVtUiNaviPane::~CVtUiNaviPane()
       
   151     {
       
   152     Cancel();
       
   153 
       
   154     delete iMainIndicators;
       
   155     delete iMutedIndicator;
       
   156 
       
   157     iTimer.Close();
       
   158     }
       
   159 
       
   160 // -----------------------------------------------------------------------------
       
   161 // CVtUiNaviPane::SetCurrentSpeaker
       
   162 // Parameter aLoudspeaker defines which speaker is used.
       
   163 // ETrue for loudspeaker, EFalse for handset.
       
   164 // -----------------------------------------------------------------------------
       
   165 //
       
   166 void CVtUiNaviPane::SetCurrentSpeaker( const TBool aLoudspeaker )
       
   167     {
       
   168     if( iLoudspeaker != aLoudspeaker )
       
   169         {
       
   170         Cancel();
       
   171         if( iCallDurationEnabled || iMicrophoneMuted )
       
   172             {
       
   173             iSliderType = ENone;
       
   174             }
       
   175         }
       
   176     iLoudspeaker = aLoudspeaker;
       
   177     }
       
   178 
       
   179 
       
   180 // -----------------------------------------------------------------------------
       
   181 // CVtUiNaviPane::SetMuted
       
   182 // -----------------------------------------------------------------------------
       
   183 //
       
   184 void CVtUiNaviPane::SetMuted(
       
   185         const TBool aStatus )
       
   186     {
       
   187     __VTPRINT2( DEBUG_GEN, "NaviPane.SetMuted.aStatus=%d", aStatus )
       
   188     if( iMicrophoneMuted != aStatus )
       
   189         {
       
   190         Cancel();
       
   191         // if volume indicator is shown when audio is umuted
       
   192         // volume indicator won't be dismissed and call duration
       
   193         // will not be shown
       
   194         if( iCallDurationEnabled || aStatus )
       
   195             {
       
   196             iSliderType = ENone;
       
   197             }
       
   198         }
       
   199     iMicrophoneMuted = aStatus;
       
   200     }
       
   201 
       
   202 // -----------------------------------------------------------------------------
       
   203 // CVtUiNaviPane::SetCallDuration
       
   204 // -----------------------------------------------------------------------------
       
   205 //
       
   206 void CVtUiNaviPane::SetCallDuration(
       
   207         const TTimeIntervalSeconds& aDuration,
       
   208         const TBool aEnabled )
       
   209     {
       
   210     iCallDurationEnabled = aEnabled;
       
   211     iNaviPaneControl->SetCallDuration( aDuration, aEnabled );
       
   212     }
       
   213 
       
   214 // -----------------------------------------------------------------------------
       
   215 // CVtUiNaviPane::CommitL
       
   216 //
       
   217 // Priority order of different navi pane elements is the following:
       
   218 // 1. Muted indicator
       
   219 // 2. Main indicators (call duration)
       
   220 //
       
   221 // -----------------------------------------------------------------------------
       
   222 //
       
   223 void CVtUiNaviPane::CommitL()
       
   224     {
       
   225     CAknNavigationDecorator* selected = DefaultIndicator();
       
   226 
       
   227     PushL( selected );
       
   228 
       
   229     // If current is main indicators, then update now.
       
   230     if ( iCurrent == iMainIndicators )
       
   231         {
       
   232         iNaviPaneControl->CommitL();
       
   233         }
       
   234     }
       
   235 
       
   236 // -----------------------------------------------------------------------------
       
   237 // CVtUiNaviPane::GetSpeakerVolume
       
   238 // -----------------------------------------------------------------------------
       
   239 //
       
   240 void CVtUiNaviPane::GetSpeakerVolume(
       
   241         const TBool ,
       
   242         TInt& aValue ) const
       
   243     {
       
   244     aValue = 0;
       
   245     }
       
   246 
       
   247 // -----------------------------------------------------------------------------
       
   248 // CVtUiNaviPane::HandleResourceChange
       
   249 // -----------------------------------------------------------------------------
       
   250 //
       
   251 void CVtUiNaviPane::HandleResourceChange(
       
   252         TInt aType )
       
   253     {
       
   254     // iCurrent will get event through navi pane.
       
   255     if ( iMainIndicators != iCurrent )
       
   256         {
       
   257         iMainIndicators->HandleResourceChange( aType );
       
   258         iNaviPaneControl->HandleResourceChange( aType );
       
   259         }
       
   260     if ( iMutedIndicator != iCurrent )
       
   261         {
       
   262         iMutedIndicator->HandleResourceChange( aType );
       
   263         }
       
   264     }
       
   265 
       
   266 // -----------------------------------------------------------------------------
       
   267 // CVtUiNaviPane::DoCancel
       
   268 // -----------------------------------------------------------------------------
       
   269 //
       
   270 void CVtUiNaviPane::DoCancel()
       
   271     {
       
   272     iTimer.Cancel();
       
   273     }
       
   274 
       
   275 // -----------------------------------------------------------------------------
       
   276 // CVtUiNaviPane::RunL
       
   277 // -----------------------------------------------------------------------------
       
   278 //
       
   279 void CVtUiNaviPane::RunL()
       
   280     {
       
   281     iSliderType = ENone;
       
   282     CAknNavigationDecorator* selected = DefaultIndicator();
       
   283     if ( selected )
       
   284         {
       
   285         PushL( selected );
       
   286         }
       
   287     }
       
   288 
       
   289 // -----------------------------------------------------------------------------
       
   290 // CVtUiNaviPane::PushAfterTimeout
       
   291 // -----------------------------------------------------------------------------
       
   292 //
       
   293 void CVtUiNaviPane::PushAfterTimeout()
       
   294     {
       
   295     Cancel();
       
   296     iTimer.After( iStatus, KVtUiVoiceVolumeTimeout );
       
   297     SetActive();
       
   298     }
       
   299 
       
   300 // -----------------------------------------------------------------------------
       
   301 // CVtUiNaviPane::PushL
       
   302 // -----------------------------------------------------------------------------
       
   303 //
       
   304 void CVtUiNaviPane::PushL( CAknNavigationDecorator* aNew )
       
   305     {
       
   306     if ( !aNew )
       
   307         {
       
   308         if ( iCurrent )
       
   309             {
       
   310             iNaviPane.Pop();
       
   311             iCurrent = NULL;
       
   312             }
       
   313         else
       
   314             {
       
   315             iNaviPane.PushDefaultL();
       
   316             }
       
   317         }
       
   318     else if ( iCurrent != aNew )
       
   319         {
       
   320         // If current not defined, then push to navi pane. This should be called
       
   321         // during construction.
       
   322         if ( !iCurrent )
       
   323             {
       
   324             iNaviPane.PushL( *aNew );
       
   325             iCurrent = aNew;
       
   326             }
       
   327         // Otherwise replace the old one.
       
   328         else
       
   329             {
       
   330             iNaviPane.ReplaceL( *iCurrent, *aNew );
       
   331             iCurrent = aNew;
       
   332             }
       
   333         }
       
   334     }
       
   335 
       
   336 // -----------------------------------------------------------------------------
       
   337 // CVtUiNaviPane::DefaultIndicator
       
   338 // Returns default indicator. Note that this does not include temporary
       
   339 // zoom indicator.
       
   340 // -----------------------------------------------------------------------------
       
   341 //
       
   342 CAknNavigationDecorator* CVtUiNaviPane::DefaultIndicator() const
       
   343     {
       
   344     CAknNavigationDecorator* selected = NULL;
       
   345 
       
   346     if ( IsActive() )
       
   347         {
       
   348         selected = iMainIndicators;
       
   349         }
       
   350     else if ( iMicrophoneMuted && iSliderType != EVolume && iSliderType != EZoom )
       
   351         {
       
   352         selected = iMutedIndicator;
       
   353         }
       
   354      else if ( iCallDurationEnabled && iSliderType != EVolume && iSliderType != EZoom )
       
   355         {
       
   356         selected = iMainIndicators;
       
   357         }
       
   358 
       
   359     return selected;
       
   360     }
       
   361 
       
   362 //  End of File