sipplugins/sippsipsettingsui/src/gssiptimer.cpp
changeset 15 8248b03a2669
parent 0 307788aac0a8
child 17 bfe1f539b721
equal deleted inserted replaced
0:307788aac0a8 15:8248b03a2669
     1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:  Timer for Hight light listbox item Container
       
    14 //
       
    15 //
       
    16 
       
    17 
       
    18 // INCLUDE FILES
       
    19 
       
    20 #include "gssiptimer.h"
       
    21 #include  "gssippluginlogger.h"
       
    22 
       
    23 // LOCAL CONSTANTS AND MACROS
       
    24 const TInt KTimerPeriod = 6;
       
    25 
       
    26 
       
    27 // -----------------------------------------------------------------------------
       
    28 // CGSSIPTimer::NewL()
       
    29 // -----------------------------------------------------------------------------
       
    30 //
       
    31 CGSSIPTimer* CGSSIPTimer::NewL( const CCoeControl& aContainer, 
       
    32                                 CListItemDrawer& aListItemDrawer )
       
    33     {
       
    34     __GSLOGSTRING("CGSSIPTimer::NewL" )
       
    35     CGSSIPTimer* self = new( ELeave ) CGSSIPTimer( aContainer, aListItemDrawer );
       
    36         
       
    37     CleanupStack::PushL( self );
       
    38     self->ConstructL();
       
    39     CleanupStack::Pop( self );
       
    40 
       
    41     return self;
       
    42     }
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CGSSIPTimer::CGSSIPTimer()
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 CGSSIPTimer::CGSSIPTimer( const CCoeControl& aContainer, 
       
    49                           CListItemDrawer& aListItemDrawer )
       
    50     : iTotal( 0 ),
       
    51       iContainer ( aContainer ),
       
    52       iListItemDrawer ( aListItemDrawer ),
       
    53       iIfStart ( EFalse )
       
    54     {
       
    55     __GSLOGSTRING("CGSSIPTimer::CGSSIPTimer" )
       
    56     }
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // CGSSIPTimer::~CGSSIPTimer()
       
    60 // DestructL.
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 CGSSIPTimer::~CGSSIPTimer()
       
    64     {
       
    65     __GSLOGSTRING("CGSSIPTimer::~CGSSIPTimer" )
       
    66     delete iHeart;
       
    67     iHeart = NULL;
       
    68     }
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // CGSSIPTimer::ConstructL()
       
    72 // ConstructL.
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 void CGSSIPTimer::ConstructL()
       
    76     {
       
    77     iHeart = CHeartbeat::NewL( CActive::EPriorityStandard );
       
    78     }
       
    79 
       
    80 // -----------------------------------------------------------------------------
       
    81 // CGSSIPTimer::StartTimer()
       
    82 // Start a Heart beat.
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 void CGSSIPTimer::StartTimer()
       
    86     {
       
    87     __GSLOGSTRING("CGSSIPTimer::StartTimer" )
       
    88     iTotal = 0;
       
    89     
       
    90     if ( !iIfStart )
       
    91         {
       
    92         iIfStart = ETrue;
       
    93         iHeart->Start( ETwelveOClock, this );
       
    94         }
       
    95     
       
    96     }
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // CGSSIPTimer::StopTimer()
       
   100 // Stop a Heart beat.
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 void CGSSIPTimer::StopTimer()
       
   104     {
       
   105     __GSLOGSTRING("CGSSIPTimer::StopTimer" )
       
   106     if (iIfStart )
       
   107         {
       
   108          iHeart->Cancel();
       
   109         iIfStart = EFalse;
       
   110         iTotal = 0;
       
   111         }
       
   112     else
       
   113         {
       
   114         iListItemDrawer.SetFlags( CTextListItemDrawer::EDisableHighlight );
       
   115         iContainer.DrawNow();
       
   116         }
       
   117     }
       
   118 
       
   119 // -----------------------------------------------------------------------------
       
   120 // CGSSIPTimer::Beat()
       
   121 // Count and stop stop.
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 void CGSSIPTimer::Beat()
       
   125     {
       
   126     iTotal++;
       
   127      if( iTotal >= KTimerPeriod )
       
   128          {
       
   129           StopTimer();
       
   130           iListItemDrawer.SetFlags( CTextListItemDrawer::EDisableHighlight );
       
   131           iContainer.DrawNow();
       
   132          }
       
   133     }
       
   134 
       
   135 // -----------------------------------------------------------------------------
       
   136 // CGSSIPTimer::Synchronize()
       
   137 // Synchronize.
       
   138 // -----------------------------------------------------------------------------
       
   139 //
       
   140 void CGSSIPTimer::Synchronize()
       
   141     {
       
   142     return;
       
   143     }
       
   144 
       
   145 // -----------------------------------------------------------------------------
       
   146 // CGSSIPTimer::IsStarted()
       
   147 // IsStarted.
       
   148 // -----------------------------------------------------------------------------
       
   149 //
       
   150 TBool CGSSIPTimer::IsStarted() const
       
   151     {
       
   152     return iIfStart;
       
   153     }
       
   154 
       
   155 //  End of File