|
1 /* |
|
2 * Copyright (c) 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: Asynchronises cce call observer calls |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include "cccecallobserverasynchroniser.h" |
|
22 #include "cccelogger.h" |
|
23 |
|
24 // ======== MEMBER FUNCTIONS ======== |
|
25 |
|
26 // ----------------------------------------------------------------------------- |
|
27 // NewL() |
|
28 // Two-phased constructor |
|
29 // ----------------------------------------------------------------------------- |
|
30 |
|
31 CCCECallObserverAsynchroniser* CCCECallObserverAsynchroniser::NewL() |
|
32 { |
|
33 CCCECallObserverAsynchroniser* self = CCCECallObserverAsynchroniser::NewLC(); |
|
34 CleanupStack::Pop( self ); |
|
35 return self; |
|
36 } |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // NewLC() |
|
40 // Two-phased constructor |
|
41 // Leaves pointer in cleanup stack |
|
42 // ----------------------------------------------------------------------------- |
|
43 |
|
44 CCCECallObserverAsynchroniser* CCCECallObserverAsynchroniser::NewLC() |
|
45 { |
|
46 CCCECallObserverAsynchroniser* self = new( ELeave ) CCCECallObserverAsynchroniser(); |
|
47 CleanupStack::PushL( self ); |
|
48 self->ConstructL(); |
|
49 return self; |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // Destructor |
|
54 // ----------------------------------------------------------------------------- |
|
55 CCCECallObserverAsynchroniser::~CCCECallObserverAsynchroniser() |
|
56 { |
|
57 Cancel(); |
|
58 iEvents.Close(); |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // Set call observer |
|
63 // ----------------------------------------------------------------------------- |
|
64 void CCCECallObserverAsynchroniser::SetMCCECallObserver( MCCECallObserver* aObserver ) |
|
65 { |
|
66 CCELOGSTRING( "CCCECallObserverAsynchroniser::SetMCCECallObserver()" ); |
|
67 iCCECallObserver = aObserver; |
|
68 if ( iIsRuning && aObserver ) |
|
69 { |
|
70 if( !IsActive() ) |
|
71 { |
|
72 SetActive(); |
|
73 TRequestStatus* status = &iStatus; |
|
74 User::RequestComplete( status, KErrNone ); |
|
75 } |
|
76 } |
|
77 else |
|
78 { |
|
79 Cancel(); |
|
80 iEvents.Reset(); |
|
81 } |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // get call observer |
|
86 // ----------------------------------------------------------------------------- |
|
87 MCCECallObserver* CCCECallObserverAsynchroniser::GetMCCECallObserver() |
|
88 { |
|
89 return iCCECallObserver; |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // CActive RunL |
|
94 // ----------------------------------------------------------------------------- |
|
95 void CCCECallObserverAsynchroniser::RunL() |
|
96 { |
|
97 CCELOGSTRING2( "CCCECallObserverAsynchroniser::RunL() events: %d", iEvents.Count() ); |
|
98 |
|
99 if ( !iCCECallObserver ) |
|
100 { |
|
101 CCELOGSTRING( "CCCECallObserverAsynchroniser::RunL() No observer!"); |
|
102 return; |
|
103 } |
|
104 |
|
105 while (iEvents.Count() > 0) |
|
106 { |
|
107 switch ( iEvents[0].iEventType ) |
|
108 { |
|
109 case EErrorOccurred: |
|
110 { |
|
111 CCELOGSTRING( "CCCECallObserverAsynchroniser::RunL() Event: EErrorOccurred"); |
|
112 iCCECallObserver->ErrorOccurred( |
|
113 (TCCPError)iEvents[0].iInt1 ); |
|
114 break; |
|
115 } |
|
116 |
|
117 case ECallStateChanged: |
|
118 { |
|
119 CCELOGSTRING( "CCCECallObserverAsynchroniser::RunL() Event: ECallStateChanged"); |
|
120 iCCECallObserver->CallStateChanged( |
|
121 (CCPCall::TCallState)iEvents[0].iInt1 ); |
|
122 break; |
|
123 } |
|
124 |
|
125 case ECallStateChangedWithInband: |
|
126 { |
|
127 CCELOGSTRING( "CCCECallObserverAsynchroniser::RunL() Event: ECallStateChangedWithInband"); |
|
128 iCCECallObserver->CallStateChangedWithInband( |
|
129 (CCPCall::TCallState)iEvents[0].iInt1 ); |
|
130 break; |
|
131 } |
|
132 |
|
133 case ECallEventOccurred: |
|
134 { |
|
135 CCELOGSTRING( "CCCECallObserverAsynchroniser::RunL() Event: ECallEventOccurredanged"); |
|
136 iCCECallObserver->CallEventOccurred( |
|
137 (MCCECallObserver::TCCECallEvent)iEvents[0].iInt1 ); |
|
138 break; |
|
139 } |
|
140 |
|
141 case ECallDurationChanged: |
|
142 { |
|
143 CCELOGSTRING( "CCCECallObserverAsynchroniser::RunL() Event: ECallDurationChanged"); |
|
144 iCCECallObserver->CallDurationChanged(iEvents[0].iDuration ); |
|
145 break; |
|
146 } |
|
147 |
|
148 case ECallCapsChanged: |
|
149 { |
|
150 CCELOGSTRING( "CCCECallObserverAsynchroniser::RunL() Event: ECallCapsChanged"); |
|
151 iCCECallObserver->CallCapsChanged( |
|
152 (MCCECallObserver::TCCECallControlCaps)iEvents[0].iInt1 ); |
|
153 break; |
|
154 } |
|
155 |
|
156 case EHandleTransfer: |
|
157 { |
|
158 CCELOGSTRING( "CCCECallObserverAsynchroniser::RunL() Event: EHandleTransfer"); |
|
159 iCCECallObserver->HandleTransfer(iEvents[0].iBoolean, *iEvents[0].iDescriptor ); |
|
160 break; |
|
161 } |
|
162 } |
|
163 |
|
164 if( iEvents.Count() ) |
|
165 { |
|
166 iEvents.Remove( 0 ); |
|
167 iEvents.Compress(); |
|
168 } |
|
169 } |
|
170 |
|
171 iIsRuning = EFalse; |
|
172 } |
|
173 |
|
174 // ----------------------------------------------------------------------------- |
|
175 // CActive RunError |
|
176 // ----------------------------------------------------------------------------- |
|
177 TInt CCCECallObserverAsynchroniser::RunError(TInt aError) |
|
178 { |
|
179 return aError; |
|
180 } |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // CActive DoCancel |
|
184 // ----------------------------------------------------------------------------- |
|
185 void CCCECallObserverAsynchroniser::DoCancel() |
|
186 { |
|
187 iEvents.Reset(); |
|
188 iIsRuning = EFalse; |
|
189 } |
|
190 |
|
191 // ----------------------------------------------------------------------------- |
|
192 // MCCECallObserver ErrorOccurred |
|
193 // ----------------------------------------------------------------------------- |
|
194 void CCCECallObserverAsynchroniser::ErrorOccurred( const TCCPError aError ) |
|
195 { |
|
196 CCELOGSTRING( "CCCECallObserverAsynchroniser::ErrorOccurred"); |
|
197 TEventStorage event; |
|
198 event.iEventType = EErrorOccurred; |
|
199 event.iInt1 = aError; |
|
200 AddEvent(event); |
|
201 |
|
202 } |
|
203 |
|
204 // ----------------------------------------------------------------------------- |
|
205 // MCCECallObserver CallStateChanged |
|
206 // ----------------------------------------------------------------------------- |
|
207 void CCCECallObserverAsynchroniser::CallStateChanged( |
|
208 const CCPCall::TCallState aState ) |
|
209 { |
|
210 CCELOGSTRING( "CCCECallObserverAsynchroniser::CallStateChanged"); |
|
211 TEventStorage event; |
|
212 event.iEventType = ECallStateChanged; |
|
213 event.iInt1 = aState; |
|
214 AddEvent(event); |
|
215 |
|
216 } |
|
217 |
|
218 // ----------------------------------------------------------------------------- |
|
219 // MCCECallObserver CallStateChangedWithInband |
|
220 // ----------------------------------------------------------------------------- |
|
221 void CCCECallObserverAsynchroniser::CallStateChangedWithInband( |
|
222 const CCPCall::TCallState aState ) |
|
223 { |
|
224 CCELOGSTRING( "CCCECallObserverAsynchroniser::CallStateChangedWithInband"); |
|
225 TEventStorage event; |
|
226 event.iEventType = ECallStateChangedWithInband; |
|
227 event.iInt1 = aState; |
|
228 AddEvent(event); |
|
229 |
|
230 } |
|
231 |
|
232 // ----------------------------------------------------------------------------- |
|
233 // MCCECallObserver CallEventOccurred |
|
234 // ----------------------------------------------------------------------------- |
|
235 void CCCECallObserverAsynchroniser::CallEventOccurred( |
|
236 const MCCECallObserver::TCCECallEvent aEvent ) |
|
237 { |
|
238 CCELOGSTRING( "CCCECallObserverAsynchroniser::CallEventOccurred"); |
|
239 TEventStorage event; |
|
240 event.iEventType = ECallEventOccurred; |
|
241 event.iInt1 = aEvent; |
|
242 AddEvent(event); |
|
243 |
|
244 } |
|
245 |
|
246 // ----------------------------------------------------------------------------- |
|
247 // MCCECallObserver CallDurationChanged |
|
248 // ----------------------------------------------------------------------------- |
|
249 void CCCECallObserverAsynchroniser::CallDurationChanged( |
|
250 const TTimeIntervalSeconds aDuration ) |
|
251 { |
|
252 CCELOGSTRING( "CCCECallObserverAsynchroniser::CallDurationChanged"); |
|
253 TEventStorage event; |
|
254 event.iEventType = ECallDurationChanged; |
|
255 event.iDuration = aDuration; |
|
256 AddEvent(event); |
|
257 } |
|
258 |
|
259 // ----------------------------------------------------------------------------- |
|
260 // MCCECallObserver CallCapsChanged |
|
261 // ----------------------------------------------------------------------------- |
|
262 void CCCECallObserverAsynchroniser::CallCapsChanged( |
|
263 const MCCECallObserver::TCCECallControlCaps aCaps ) |
|
264 { |
|
265 CCELOGSTRING( "CCCECallObserverAsynchroniser::CallCapsChanged"); |
|
266 TEventStorage event; |
|
267 event.iEventType = ECallCapsChanged; |
|
268 event.iInt1 = aCaps; |
|
269 AddEvent(event); |
|
270 } |
|
271 |
|
272 // ----------------------------------------------------------------------------- |
|
273 // MCCECallObserver HandleTransfer |
|
274 // ----------------------------------------------------------------------------- |
|
275 void CCCECallObserverAsynchroniser::HandleTransfer( const TBool aAttended, |
|
276 const TDesC& aDestination ) |
|
277 { |
|
278 CCELOGSTRING( "CCCECallObserverAsynchroniser::HandleTransfer"); |
|
279 TEventStorage event; |
|
280 event.iEventType = EHandleTransfer; |
|
281 event.iBoolean = aAttended; |
|
282 event.iDescriptor = &aDestination; |
|
283 AddEvent(event); |
|
284 } |
|
285 |
|
286 // ----------------------------------------------------------------------------- |
|
287 // Constructor |
|
288 // ----------------------------------------------------------------------------- |
|
289 CCCECallObserverAsynchroniser::CCCECallObserverAsynchroniser() |
|
290 :CActive( EPriorityStandard ), iIsRuning( EFalse ) |
|
291 { |
|
292 } |
|
293 |
|
294 |
|
295 // ----------------------------------------------------------------------------- |
|
296 // Leaving stuff in constructor |
|
297 // ----------------------------------------------------------------------------- |
|
298 void CCCECallObserverAsynchroniser::ConstructL() |
|
299 { |
|
300 CActiveScheduler::Add( this ); |
|
301 } |
|
302 |
|
303 // ----------------------------------------------------------------------------- |
|
304 // Adding event to queue |
|
305 // ----------------------------------------------------------------------------- |
|
306 void CCCECallObserverAsynchroniser::AddEvent( TEventStorage aEvent ) |
|
307 { |
|
308 iEvents.Append(aEvent); |
|
309 CCELOGSTRING( "CCCECallObserverAsynchroniser::AddEvent"); |
|
310 if (!iIsRuning) |
|
311 { |
|
312 CCELOGSTRING( "CCCECallObserverAsynchroniser::AddEvent Activating..."); |
|
313 iIsRuning = ETrue; |
|
314 if (iCCECallObserver) |
|
315 { |
|
316 SetActive(); |
|
317 TRequestStatus* status = &iStatus; |
|
318 User::RequestComplete(status, KErrNone); |
|
319 } |
|
320 } |
|
321 } |
|
322 // end of file |