|
1 /* |
|
2 * Copyright (c) 2002-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: |
|
15 * This class implements a timer used when waiting for information from WAP GW |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include "mmsoperationtimer.h" |
|
23 #include "mmsconst.h" |
|
24 #include "mmstransportobserver.h" |
|
25 #include "mmsservercommon.h" |
|
26 #include "MmsServerDebugLogging.h" |
|
27 |
|
28 // EXTERNAL DATA STRUCTURES |
|
29 // EXTERNAL FUNCTION PROTOTYPES |
|
30 // CONSTANTS |
|
31 // MACROS |
|
32 // LOCAL CONSTANTS AND MACROS |
|
33 #ifndef _NO_MMSS_LOGGING_ |
|
34 const TInt KMmsSecondsToMilliseconds = 1000000; |
|
35 #endif |
|
36 // MODULE DATA STRUCTURES |
|
37 // LOCAL FUNCTION PROTOTYPES |
|
38 // ==================== LOCAL FUNCTIONS ==================== |
|
39 // ================= MEMBER FUNCTIONS ======================= |
|
40 |
|
41 // --------------------------------------------------------- |
|
42 // CMmsOperationTimer |
|
43 // --------------------------------------------------------- |
|
44 // |
|
45 CMmsOperationTimer::CMmsOperationTimer() |
|
46 :CTimer ( EPriorityStandard ) |
|
47 { |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------- |
|
51 // ConstructL |
|
52 // --------------------------------------------------------- |
|
53 // |
|
54 void CMmsOperationTimer::ConstructL() |
|
55 { |
|
56 CTimer::ConstructL(); |
|
57 CActiveScheduler::Add( this ); |
|
58 } |
|
59 |
|
60 // --------------------------------------------------------- |
|
61 // NewL |
|
62 // --------------------------------------------------------- |
|
63 // |
|
64 CMmsOperationTimer* CMmsOperationTimer::NewL() |
|
65 { |
|
66 CMmsOperationTimer* self = new ( ELeave ) CMmsOperationTimer; |
|
67 CleanupStack::PushL( self ); |
|
68 self->ConstructL(); |
|
69 CleanupStack::Pop( self ); |
|
70 return self; |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------- |
|
74 // ~CMmsOperationTimer |
|
75 // --------------------------------------------------------- |
|
76 // |
|
77 CMmsOperationTimer::~CMmsOperationTimer() |
|
78 { |
|
79 Cancel(); |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------- |
|
83 // Start |
|
84 // --------------------------------------------------------- |
|
85 // |
|
86 void CMmsOperationTimer::Start( |
|
87 MMmsTransportObserver* aRequester, |
|
88 const TInt aTimerValue ) |
|
89 { |
|
90 LOG2( _L("CMmsOperationTimer::Start (%d seconds)"), aTimerValue/KMmsSecondsToMilliseconds ); |
|
91 |
|
92 // no problem with prototype coercion - LINT |
|
93 iOriginalTimerValue = aTimerValue; |
|
94 |
|
95 iRequester = (MMmsTransportObserver*) aRequester; |
|
96 |
|
97 // time now |
|
98 iStartTime.HomeTime(); |
|
99 |
|
100 // endtime |
|
101 iEndTime = iStartTime + iOriginalTimerValue; |
|
102 |
|
103 At( iEndTime ); // At() calls SetActive() |
|
104 } |
|
105 |
|
106 // --------------------------------------------------------- |
|
107 // Pause |
|
108 // --------------------------------------------------------- |
|
109 // |
|
110 void CMmsOperationTimer::Pause() |
|
111 { |
|
112 LOG( _L("CMmsOperationTimer::Pause") ); |
|
113 // The status of timer is still pending |
|
114 Cancel(); // cancel the request |
|
115 // Calculate how much was left |
|
116 iCurrentTime.HomeTime(); |
|
117 iTimeLeft = iEndTime.MicroSecondsFrom( iCurrentTime ); |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------- |
|
121 // Continue |
|
122 // --------------------------------------------------------- |
|
123 // |
|
124 void CMmsOperationTimer::Continue() |
|
125 { |
|
126 LOG( _L("CMmsOperationTime::Continue") ); |
|
127 // If timer active, Continue() will do nothing |
|
128 if ( !IsActive() ) |
|
129 { |
|
130 // just make sure |
|
131 Cancel(); |
|
132 |
|
133 // New expiration time will be time now + how much was left before pausing... |
|
134 iCurrentTime.HomeTime(); |
|
135 iEndTime = iCurrentTime + iTimeLeft; |
|
136 |
|
137 At( iEndTime ); |
|
138 } |
|
139 } |
|
140 |
|
141 // --------------------------------------------------------- |
|
142 // RunL() |
|
143 // --------------------------------------------------------- |
|
144 // |
|
145 void CMmsOperationTimer::RunL() |
|
146 { |
|
147 // |
|
148 // timer completes and control is returned to caller |
|
149 // |
|
150 LOG2( _L("CMmsOperationTimer::RunL status %d"), iStatus.Int() ); |
|
151 if ( iStatus.Int() == KErrAbort ) |
|
152 { |
|
153 LOG( _L("- CMmsOperationTimer aborted abnormally - continuing.") ); |
|
154 iCurrentTime.HomeTime(); |
|
155 iTimeLeft = iEndTime.MicroSecondsFrom( iCurrentTime ); |
|
156 Continue(); |
|
157 return; |
|
158 } |
|
159 |
|
160 iTimeLeft = iOriginalTimerValue; |
|
161 iRequester->TimerExpired(); |
|
162 } |
|
163 |
|
164 // --------------------------------------------------------- |
|
165 // DoCancel() |
|
166 // --------------------------------------------------------- |
|
167 // |
|
168 void CMmsOperationTimer::DoCancel() |
|
169 { |
|
170 LOG( _L("CMmsOperationTimer::DoCancel") ); |
|
171 CTimer::DoCancel(); |
|
172 } |
|
173 |
|
174 // ================= OTHER EXPORTED FUNCTIONS ============== |
|
175 |
|
176 // End of File |
|
177 |