phoneapp/phoneuiview/src/cphonecallheadertextanimation.cpp
changeset 0 5f000ab63145
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     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: Implementation of CPhoneCallHeaderTextAnimation class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "cphonecallheadertextanimation.h"
       
    21 #include "phoneconstants.h"
       
    22 #include "phonelogger.h"
       
    23 #include "cphonetimer.h"
       
    24 
       
    25 // CONSTANTS
       
    26 const TUint16 KPhoneCallHeaderAnimationDot = 0x002E;
       
    27 const TInt KPhoneCallHeaderDotNum = 3;
       
    28 const TInt KOneSecond = 1000000;
       
    29 
       
    30 // ================= MEMBER FUNCTIONS =======================
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // CPhoneCallHeaderTextAnimation::CPhoneCallHeaderTextAnimation
       
    34 // C++ default constructor can NOT contain any code, that
       
    35 // might leave.
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 CPhoneCallHeaderTextAnimation::CPhoneCallHeaderTextAnimation() : 
       
    39     CCoeStatic( KUidCallHeaderTextAnimationSingleton ),
       
    40     iTimer( NULL ),
       
    41     iDotNum( 0 ),
       
    42     iBubbleManager( NULL ),
       
    43     iActiveBubble( 0 )
       
    44     {
       
    45     }
       
    46 
       
    47 // Destructor
       
    48 CPhoneCallHeaderTextAnimation::~CPhoneCallHeaderTextAnimation()
       
    49     { 
       
    50     delete iTimer;
       
    51     iTimer = NULL;  
       
    52     }
       
    53 
       
    54 // ---------------------------------------------------------
       
    55 // CPhoneCallHeaderTextAnimation::InstanceL
       
    56 // (other items were commented in a header).
       
    57 // ---------------------------------------------------------
       
    58 //
       
    59 CPhoneCallHeaderTextAnimation* CPhoneCallHeaderTextAnimation::InstanceL()
       
    60     {
       
    61     __LOGMETHODSTARTEND(EPhoneUIView, "CPhoneCallHeaderTextAnimation::InstanceL");
       
    62     CPhoneCallHeaderTextAnimation* instance = static_cast<CPhoneCallHeaderTextAnimation*>(
       
    63         CCoeEnv::Static( KUidCallHeaderTextAnimationSingleton ) );
       
    64     if ( !instance )
       
    65         {
       
    66         instance = new ( ELeave ) CPhoneCallHeaderTextAnimation;
       
    67         CleanupStack::PushL( instance );
       
    68         instance->ConstructL();
       
    69         CleanupStack::Pop( instance );
       
    70         }
       
    71     return instance;
       
    72     }
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // CPhoneCallHeaderTextAnimation::CPhoneCallHeaderTextAnimation
       
    76 // Symbian 2nd phase constructor can leave.
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 void CPhoneCallHeaderTextAnimation::ConstructL()
       
    80     {
       
    81     iTimer = CPhoneTimer::NewL();
       
    82     }
       
    83 
       
    84 // ---------------------------------------------------------
       
    85 // CPhoneCallHeaderTextAnimation::StartAnimatingVideoCallHeaderL
       
    86 // ---------------------------------------------------------
       
    87 //
       
    88 void CPhoneCallHeaderTextAnimation::StartAnimatingVideoCallHeaderL(
       
    89 	const CBubbleManager::TBubbleId aBubbleId,    
       
    90     const TDesC& aNormalText,
       
    91     const TDesC& aShortText,
       
    92     CBubbleManager& aBubbleManager )
       
    93 	{
       
    94     __LOGMETHODSTARTEND(EPhoneUIView, "CPhoneCallHeaderTextAnimation::StartAnimatingVideoCallHeaderL");
       
    95 	iActiveBubble = aBubbleId;
       
    96 	iBubbleManager = &aBubbleManager;
       
    97 
       
    98 	SetBubbleTexts( aNormalText, aShortText );
       
    99 	
       
   100 	// Update immediately when we start
       
   101 	HandleTimeOutL();		
       
   102 	}
       
   103 
       
   104 // ---------------------------------------------------------
       
   105 // CPhoneCallHeaderTextAnimation::RemoveAnimatingVideoCallHeader
       
   106 // ---------------------------------------------------------
       
   107 //
       
   108 void CPhoneCallHeaderTextAnimation::RemoveAnimatingVideoCallHeader()
       
   109     {
       
   110     __LOGMETHODSTARTEND(EPhoneUIView, "CPhoneCallHeaderTextAnimation::RemoveAnimatingVideoCallHeader");
       
   111     if( iTimer )
       
   112         {
       
   113         if( iTimer->IsActive() )
       
   114             {
       
   115             iTimer->CancelTimer();                
       
   116             }          
       
   117         }
       
   118     iDotNum = 0;
       
   119     }
       
   120 
       
   121 // ---------------------------------------------------------
       
   122 // CPhoneCallHeaderTextAnimation::HandleTimeOutL
       
   123 // ---------------------------------------------------------
       
   124 //
       
   125 void CPhoneCallHeaderTextAnimation::HandleTimeOutL()
       
   126     {
       
   127     __LOGMETHODSTARTEND(EPhoneUIView, "CPhoneCallHeaderTextAnimation::HandleTimeOutL");
       
   128 
       
   129     iBubbleManager->UpdateCallHeaderText( iActiveBubble, 
       
   130                 iNormalText, iShortText, CBubbleManager::ERight );    
       
   131 
       
   132     if ( iDotNum < KPhoneCallHeaderDotNum ) 
       
   133         {
       
   134         __PHONELOG( EBasic, EPhoneUIView, 
       
   135             "CPhoneCallHeaderTextAnimation::HandleTimeOutL()->iDotNum < KPhoneCallHeaderDotNum" );
       
   136         iNormalText.Append( &KPhoneCallHeaderAnimationDot, 1);
       
   137         iShortText.Append( &KPhoneCallHeaderAnimationDot, 1);
       
   138         iDotNum++;
       
   139         }
       
   140     else
       
   141         {
       
   142         __PHONELOG( EBasic, EPhoneUIView, 
       
   143             "CPhoneCallHeaderTextAnimation::HandleTimeOutL()->else..." );
       
   144         TInt normalLength = iNormalText.Length();
       
   145         iNormalText.Delete( normalLength - KPhoneCallHeaderDotNum, KPhoneCallHeaderDotNum);
       
   146 
       
   147         TInt shortLength = iShortText.Length();
       
   148         iShortText.Delete( shortLength - KPhoneCallHeaderDotNum, KPhoneCallHeaderDotNum);
       
   149         
       
   150         iDotNum = 0;
       
   151         }    	
       
   152 
       
   153     // Start timer to update headers periodically
       
   154     if ( !iTimer->IsActive() )
       
   155         {
       
   156         __PHONELOG( EBasic, EPhoneUIView, 
       
   157             "CPhoneCallHeaderTextAnimation::HandleTimeOutL()-> Start timer to update headers periodically" );
       
   158 		iTimer->After( KOneSecond, this );
       
   159         }
       
   160     }
       
   161 
       
   162 // ---------------------------------------------------------
       
   163 // CPhoneCallHeaderTextAnimation::SetBubbleTexts
       
   164 // ---------------------------------------------------------
       
   165 //
       
   166 void CPhoneCallHeaderTextAnimation::SetBubbleTexts( const TDesC& aNormalText, 
       
   167 	const TDesC& aShortText )
       
   168 	{
       
   169     __LOGMETHODSTARTEND(EPhoneUIView, "CPhoneCallHeaderTextAnimation::SetBubbleTexts");
       
   170     __PHONELOG1( 
       
   171         EBasic, 
       
   172         EPhoneUIView, 
       
   173         "CPhoneCallHeaderTextAnimation::SetBubbleTexts aNormalText = %S",
       
   174         &aNormalText );
       
   175         
       
   176     __PHONELOG1( 
       
   177         EBasic, 
       
   178         EPhoneUIView, 
       
   179         "CPhoneCallHeaderTextAnimation::SetBubbleTexts aShortText = %S",
       
   180         &aShortText );
       
   181         
       
   182 	if( aNormalText.Length() > KPhoneCallHeaderAnimationTextLength )
       
   183 		{
       
   184 		iNormalText = aNormalText.Left( KPhoneCallHeaderAnimationTextLength );	
       
   185 		}
       
   186 	else
       
   187 		{
       
   188 		iNormalText = aNormalText;			
       
   189 		}
       
   190 		
       
   191 	if( aShortText.Length() > KPhoneCallHeaderAnimationTextLength )
       
   192 		{
       
   193 		iShortText = aShortText.Left( KPhoneCallHeaderAnimationTextLength );		
       
   194 		}
       
   195 	else
       
   196 		{
       
   197 		iShortText = aShortText;			
       
   198 		}		
       
   199 	}
       
   200 
       
   201 // End of File