1 /* |
|
2 * Copyright (c) 2007-2010 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: For timer handling. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "cscengtimer.h" |
|
20 #include "cscenglogger.h" |
|
21 #include "mcscengtimerobserver.h" |
|
22 |
|
23 const TInt KWaitConnectionToClose = 5000000; // 5 seconds |
|
24 const TInt KWaitNoteDelayTime = 20000; // 20 ms |
|
25 |
|
26 // ======== MEMBER FUNCTIONS ======== |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // --------------------------------------------------------------------------- |
|
30 // |
|
31 CCSCEngTimer::CCSCEngTimer( MCSCEngTimerObserver& aObserver ) |
|
32 : CTimer( EPriorityStandard ), iObserver( aObserver ) |
|
33 { |
|
34 } |
|
35 |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 void CCSCEngTimer::ConstructL() |
|
41 { |
|
42 CSCENGDEBUG( "CCSCEngTimer::ConstructL - begin" ); |
|
43 |
|
44 CActiveScheduler::Add( this ); |
|
45 CTimer::ConstructL(); |
|
46 |
|
47 CSCENGDEBUG( "CCSCEngTimer::ConstructL - end" ); |
|
48 } |
|
49 |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 EXPORT_C CCSCEngTimer* CCSCEngTimer::NewL( MCSCEngTimerObserver& aObserver ) |
|
55 { |
|
56 CCSCEngTimer* self = new ( ELeave ) CCSCEngTimer( aObserver ); |
|
57 CleanupStack::PushL( self ); |
|
58 self->ConstructL(); |
|
59 CleanupStack::Pop( self ); |
|
60 return self; |
|
61 } |
|
62 |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 CCSCEngTimer::~CCSCEngTimer() |
|
68 { |
|
69 CSCENGDEBUG( "CCSCEngTimer::~CCSCEngTimer - begin" ); |
|
70 |
|
71 CTimer::Cancel(); |
|
72 |
|
73 CSCENGDEBUG( "CCSCEngTimer::~CCSCEngTimer - end" ); |
|
74 } |
|
75 |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // Start timer. |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 EXPORT_C TInt CCSCEngTimer::StartTimer( TTimerType aTimerType ) |
|
82 { |
|
83 CSCENGDEBUG( "CCSCEngTimer::StartTimer" ); |
|
84 |
|
85 TInt error ( KErrNone ); |
|
86 |
|
87 if ( CTimer::IsActive() ) |
|
88 { |
|
89 CTimer::Cancel(); |
|
90 } |
|
91 |
|
92 if ( EConnectionMonitoringTimer == aTimerType ) |
|
93 { |
|
94 CTimer::After( KWaitConnectionToClose ); |
|
95 } |
|
96 else if ( ENoteDelayTimer == aTimerType ) |
|
97 { |
|
98 CTimer::After( KWaitNoteDelayTime ); |
|
99 } |
|
100 else |
|
101 { |
|
102 error = KErrArgument; |
|
103 } |
|
104 |
|
105 return error; |
|
106 } |
|
107 |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // Stop timer. |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 EXPORT_C void CCSCEngTimer::StopTimer() |
|
114 { |
|
115 CSCENGDEBUG( "CCSCEngTimer::StopTimer - begin" ); |
|
116 |
|
117 if ( CTimer::IsActive() ) |
|
118 { |
|
119 CTimer::Cancel(); |
|
120 } |
|
121 |
|
122 CSCENGDEBUG( "CCSCEngTimer::StopTimer - end" ); |
|
123 } |
|
124 |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // CCSCEngTimer::RunL |
|
128 // --------------------------------------------------------------------------- |
|
129 // |
|
130 void CCSCEngTimer::RunL() |
|
131 { |
|
132 iObserver.TimerExpired(); |
|
133 } |
|