uifw/AvKon/src/aknsignal.cpp
branchRCL_3
changeset 15 c52421ed5f07
parent 6 9f56a4e1b8ab
child 18 fcdfafb36fe7
--- a/uifw/AvKon/src/aknsignal.cpp	Wed Jun 09 09:58:37 2010 +0300
+++ b/uifw/AvKon/src/aknsignal.cpp	Mon Jun 21 15:57:43 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -303,8 +303,6 @@
     iSignalIconControl->SetContainerWindowL( *this );
     iSignalStrengthControl->SetContainerWindowL( *this );
 
-    iTicker = CPeriodic::NewL( CActive::EPriorityLow );
-
     // Set flags to default values
     iPrivateFlags = 0;
 
@@ -381,10 +379,7 @@
 //
 void CAknSignalPane::DisableAnimation()
     {
-    if ( iTicker && iTicker->IsActive() )
-        {
-        iTicker->Cancel();
-        }
+    StopTicker();
     }
 
 
@@ -404,19 +399,14 @@
 
         iSignalIconControl->SetDrawBlank( EFalse );
 
-        if ( aGprsIconState != EAknSignalGprsIndicatorEstablishingContext &&
-             iTicker )
+        if ( aGprsIconState != EAknSignalGprsIndicatorEstablishingContext )
             {
-            iTicker->Cancel();
+            StopTicker();
             }
         else if ( aGprsIconState == EAknSignalGprsIndicatorEstablishingContext )
             {
-            if ( iTicker && !iTicker->IsActive() )
-                {
-                iTicker->Start( KAknIndicatorAnimationDelay,
-                                KAknIndicatorAnimationInterval,
-                                TCallBack( TickerCallback, this ) );
-                }
+            TRAP_IGNORE( StartTickerL( KAknIndicatorAnimationDelay,
+                                       KAknIndicatorAnimationInterval ) );
             }
         }
     }
@@ -769,19 +759,14 @@
 
         iSignalIconControl->SetDrawBlank( EFalse );
 
-        if ( aCommonPacketDataIconState != EAknSignalCommonPacketDataIndicatorEstablishingContext &&
-             iTicker )
+        if ( aCommonPacketDataIconState != EAknSignalCommonPacketDataIndicatorEstablishingContext )
             {
-            iTicker->Cancel();
+            StopTicker();
             }
         else if ( aCommonPacketDataIconState == EAknSignalCommonPacketDataIndicatorEstablishingContext )
             {
-            if ( iTicker && !iTicker->IsActive() )
-                {
-                iTicker->Start( KAknIndicatorAnimationDelay,
-                                KAknIndicatorAnimationInterval,
-                                TCallBack( TickerCallback, this ) );
-                }
+            TRAP_IGNORE( StartTickerL( KAknIndicatorAnimationDelay,
+                                       KAknIndicatorAnimationInterval ) );
             }
         }
     }
@@ -803,19 +788,14 @@
 
         iSignalIconControl->SetDrawBlank( EFalse );
 
-        if ( aEdgeIconState != EAknSignalEdgeIndicatorEstablishingContext &&
-             iTicker )
+        if ( aEdgeIconState != EAknSignalEdgeIndicatorEstablishingContext )
             {
-            iTicker->Cancel();
+            StopTicker();
             }
         else if ( aEdgeIconState == EAknSignalEdgeIndicatorEstablishingContext )
             {
-            if ( iTicker && !iTicker->IsActive() )
-                {
-                iTicker->Start( KAknIndicatorAnimationDelay,
-                                KAknIndicatorAnimationInterval,
-                                TCallBack( TickerCallback, this ) );
-                }
+            TRAP_IGNORE( StartTickerL( KAknIndicatorAnimationDelay,
+                                       KAknIndicatorAnimationInterval ) );
             }
         }
     }
@@ -837,19 +817,14 @@
 
         iSignalIconControl->SetDrawBlank( EFalse );
 
-        if ( aWcdmaIconState != EAknSignalWcdmaIndicatorEstablishingContext &&
-             iTicker )
+        if ( aWcdmaIconState != EAknSignalWcdmaIndicatorEstablishingContext )
             {
-            iTicker->Cancel();
+            StopTicker();
             }
         else if ( aWcdmaIconState == EAknSignalWcdmaIndicatorEstablishingContext )
             {
-            if ( iTicker && !iTicker->IsActive() )
-                {
-                iTicker->Start( KAknIndicatorAnimationDelay,
-                                KAknIndicatorAnimationInterval,
-                                TCallBack( TickerCallback, this ) );
-                }
+            TRAP_IGNORE( StartTickerL( KAknIndicatorAnimationDelay,
+                                       KAknIndicatorAnimationInterval ) );
             }
         }
     }
@@ -871,19 +846,14 @@
 
         iSignalIconControl->SetDrawBlank( EFalse );
 
-        if ( aHsdpaIconState != EAknSignalHsdpaIndicatorEstablishingContext &&
-             iTicker )
+        if ( aHsdpaIconState != EAknSignalHsdpaIndicatorEstablishingContext )
             {
-            iTicker->Cancel();
+            StopTicker();
             }
         else if ( aHsdpaIconState == EAknSignalHsdpaIndicatorEstablishingContext )
             {
-            if ( iTicker && !iTicker->IsActive() )
-                {
-                iTicker->Start( KAknIndicatorAnimationDelay,
-                                KAknIndicatorAnimationInterval,
-                                TCallBack( TickerCallback, this ) );
-                }
+            TRAP_IGNORE( StartTickerL( KAknIndicatorAnimationDelay,
+                                       KAknIndicatorAnimationInterval ) );
             }
         }
     }
@@ -909,25 +879,26 @@
 
         // Tick timer is only used when animating.
         if ( aCdmaIconState != EAknSignalCdmaIndicatorSending &&
-             aCdmaIconState != EAknSignalCdmaIndicatorReceiving &&
-             iTicker )
+             aCdmaIconState != EAknSignalCdmaIndicatorReceiving )
             {
-            iTicker->Cancel();
+            StopTicker();
             }
 
         switch ( aCdmaIconState )
             {
             case EAknSignalCdmaIndicatorSending:
             case EAknSignalCdmaIndicatorReceiving:
+                {
                 if ( iTicker && !iTicker->IsActive() )
                     {
                     // restart animation
                     iExtension->iCdmaAnimationIndex = 0;
-                    iTicker->Start( KAknIndicatorShortAnimationInterval,
-                                    KAknIndicatorShortAnimationInterval,
-                                    TCallBack( TickerCallback, this ) );
+                    TRAP_IGNORE(
+                        StartTickerL( KAknIndicatorShortAnimationInterval,
+                                      KAknIndicatorShortAnimationInterval ) );
                     }
                 break;
+                }
             default:
                 break;
             }
@@ -1084,4 +1055,42 @@
     iSignalState = aIconState;
     }
 
+
+// ---------------------------------------------------------------------------
+// CAknSignalPane::StartTickerL
+// Starts the animation timer.
+// ---------------------------------------------------------------------------
+//
+void CAknSignalPane::StartTickerL( TTimeIntervalMicroSeconds32 aDelay,
+                                   TTimeIntervalMicroSeconds32 aInterval )
+    {
+    if ( !iTicker )
+        {
+        iTicker = CPeriodic::NewL( CActive::EPriorityLow );
+        }
+
+    if ( iTicker && !iTicker->IsActive() )
+        {
+        iTicker->Start( aDelay,
+                        aInterval,
+                        TCallBack( TickerCallback, this ) );
+        }
+    }
+
+
+// ---------------------------------------------------------------------------
+// CAknSignalPane::StopTicker
+// Stops the animation timer.
+// ---------------------------------------------------------------------------
+//
+void CAknSignalPane::StopTicker()
+    {
+    if ( iTicker )
+        {
+        iTicker->Cancel();
+        delete iTicker;
+        iTicker = NULL;
+        }
+    }
+
 //  End of File