37
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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: Manual call control handler
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include "cpemanualcallcontrolhandler.h"
|
|
21 |
#include "cpemessagehandler.h"
|
|
22 |
#include <ccpdefs.h>
|
|
23 |
#include <mpecallhandling.h>
|
|
24 |
#include <mpedatastore.h>
|
|
25 |
#include <pepanic.pan>
|
|
26 |
#include <pevirtualengine.h>
|
|
27 |
#include <talogger.h>
|
|
28 |
|
|
29 |
|
|
30 |
// EXTERNAL DATA STRUCTURES
|
|
31 |
// None.
|
|
32 |
|
|
33 |
// EXTERNAL FUNCTION PROTOTYPES
|
|
34 |
// None.
|
|
35 |
|
|
36 |
// CONSTANTS
|
|
37 |
// None.
|
|
38 |
|
|
39 |
|
|
40 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
41 |
|
|
42 |
// -----------------------------------------------------------------------------
|
|
43 |
// cpemanualcallcontrolhandler::CPEManualCallControlHandler
|
|
44 |
// C++ default constructor can NOT contain any code, that
|
|
45 |
// might leave.
|
|
46 |
// -----------------------------------------------------------------------------
|
|
47 |
//
|
|
48 |
CPEManualCallControlHandler::CPEManualCallControlHandler(
|
|
49 |
MPECallHandling& aCallHandling,
|
|
50 |
CPEMessageHandler& aMessageHandler,
|
|
51 |
MPEDataStore& aDataStore )
|
|
52 |
: iCallHandling( aCallHandling ),
|
|
53 |
iMessageHandler( aMessageHandler ),
|
|
54 |
iDataStore( aDataStore )
|
|
55 |
{
|
|
56 |
}
|
|
57 |
|
|
58 |
// Destructor
|
|
59 |
CPEManualCallControlHandler::~CPEManualCallControlHandler()
|
|
60 |
{
|
|
61 |
}
|
|
62 |
|
|
63 |
// -----------------------------------------------------------------------------
|
|
64 |
// CPEManualCallControlHandler::NewL
|
|
65 |
// Two-phased constructor.
|
|
66 |
// -----------------------------------------------------------------------------
|
|
67 |
//
|
|
68 |
CPEManualCallControlHandler* CPEManualCallControlHandler::NewL
|
|
69 |
(
|
|
70 |
MPECallHandling& aCallHandling,
|
|
71 |
CPEMessageHandler& aMessageHandler,
|
|
72 |
MPEDataStore& aDataStore )
|
|
73 |
{
|
|
74 |
CPEManualCallControlHandler* handler = new ( ELeave ) CPEManualCallControlHandler(
|
|
75 |
aCallHandling,
|
|
76 |
aMessageHandler,
|
|
77 |
aDataStore);
|
|
78 |
|
|
79 |
return handler;
|
|
80 |
}
|
|
81 |
// -----------------------------------------------------------------------------
|
|
82 |
// CPEManualCallControlHandler::HandleChldL
|
|
83 |
// Handles common Chld (swap, answer waiting call, ... )
|
|
84 |
// -----------------------------------------------------------------------------
|
|
85 |
//
|
|
86 |
void CPEManualCallControlHandler::HandleChldL(
|
|
87 |
const TPhCltChldCommand aChldCommand,
|
|
88 |
const TUint aCallNo )
|
|
89 |
{
|
|
90 |
TEFLOGSTRING3( KTAMESINT,
|
|
91 |
"PE CPEManualCallControlHandler::HandleChldL, aChldCommand: %d, aCallNo: %d"
|
|
92 |
, aChldCommand
|
|
93 |
, aCallNo );
|
|
94 |
TInt error( KErrNotFound );
|
|
95 |
|
|
96 |
switch ( aChldCommand )
|
|
97 |
{
|
|
98 |
case EPhCltChldZero:
|
|
99 |
// Release held calls or set UDUB for a waiting call.
|
|
100 |
error = HandleChldZero();
|
|
101 |
break;
|
|
102 |
|
|
103 |
case EPhCltChldOne:
|
|
104 |
// Release all active calls and accept other (held or waiting) call.
|
|
105 |
{
|
|
106 |
if( aCallNo )
|
|
107 |
{
|
|
108 |
HandleChldOneXL( aCallNo );
|
|
109 |
error = ECCPErrorNone;
|
|
110 |
}
|
|
111 |
else
|
|
112 |
{
|
|
113 |
error = HandleChldOne();
|
|
114 |
}
|
|
115 |
}
|
|
116 |
break;
|
|
117 |
|
|
118 |
case EPhCltChldTwo:
|
|
119 |
// Place all active calls on hold and accept the other (held or waiting) call.
|
|
120 |
{
|
|
121 |
if( aCallNo )
|
|
122 |
{
|
|
123 |
HandleChldTwoXL( aCallNo );
|
|
124 |
error = ECCPErrorNone;
|
|
125 |
}
|
|
126 |
else
|
|
127 |
{
|
|
128 |
error = HandleChldTwo();
|
|
129 |
}
|
|
130 |
}
|
|
131 |
break;
|
|
132 |
|
|
133 |
case EPhCltChldThree:
|
|
134 |
// Add a held call to the conversation.
|
|
135 |
error = HandleChldThree();
|
|
136 |
break;
|
|
137 |
|
|
138 |
case EPhCltChldFour:
|
|
139 |
// Connect the two calls and disconnect the subscriber from
|
|
140 |
// both calls (Explicit call transfer).
|
|
141 |
error = HandleChldFour();
|
|
142 |
break;
|
|
143 |
|
|
144 |
default:
|
|
145 |
{
|
|
146 |
TEFLOGSTRING2( KTAERROR,
|
|
147 |
"PE CPEManualCallControlHandler::HandleChldL, aChldCommand; %d"
|
|
148 |
,aChldCommand );
|
|
149 |
__ASSERT_DEBUG( EFalse, Panic( EPEPanicIllegalCommand ) );
|
|
150 |
break;
|
|
151 |
}
|
|
152 |
}
|
|
153 |
User::LeaveIfError( error );
|
|
154 |
}
|
|
155 |
|
|
156 |
// -----------------------------------------------------------------------------
|
|
157 |
// CPEManualCallControlHandler::HandleChldZero
|
|
158 |
// -----------------------------------------------------------------------------
|
|
159 |
//
|
|
160 |
TInt CPEManualCallControlHandler::HandleChldZero()
|
|
161 |
{
|
|
162 |
TEFLOGSTRING( KTAINT, "PE CPEManualCallControlHandler::HandleChldZero" );
|
|
163 |
TInt error( ECCPErrorNotAllowed );
|
|
164 |
|
|
165 |
if ( iCallHandling.IsCallInState( EPEStateRinging ) )
|
|
166 |
{
|
|
167 |
error = iCallHandling.RejectCall();
|
|
168 |
}
|
|
169 |
else if( iDataStore.ConferenceCallState( ) == EPEStateHeldConference )
|
|
170 |
{
|
|
171 |
iDataStore.SetCallId( KPEConferenceCallID );
|
|
172 |
error = iMessageHandler.HandleReleaseCall();
|
|
173 |
}
|
|
174 |
else if ( iCallHandling.IsCallInState( EPEStateHeld ) )
|
|
175 |
{
|
|
176 |
TInt callId = iCallHandling.GetCallIdByState( EPEStateHeld );
|
|
177 |
if ( callId != KPECallIdNotUsed )
|
|
178 |
{
|
|
179 |
iDataStore.SetCallId( callId );
|
|
180 |
error = iMessageHandler.HandleReleaseCall();
|
|
181 |
}
|
|
182 |
}
|
|
183 |
|
|
184 |
TEFLOGSTRING2( KTAINT,
|
|
185 |
"PE CPEManualCallControlHandler::HandleChldZero, error: %d", error );
|
|
186 |
return error;
|
|
187 |
}
|
|
188 |
|
|
189 |
// -----------------------------------------------------------------------------
|
|
190 |
// CPEManualCallControlHandler::HandleChldOne
|
|
191 |
// -----------------------------------------------------------------------------
|
|
192 |
//
|
|
193 |
TInt CPEManualCallControlHandler::HandleChldOne()
|
|
194 |
{
|
|
195 |
TEFLOGSTRING( KTAINT,
|
|
196 |
"PE CPEManualCallControlHandler::HandleChldOne" );
|
|
197 |
|
|
198 |
TInt error( ECCPErrorNotAllowed );
|
|
199 |
// Find active call
|
|
200 |
TInt callId( KPECallIdNotUsed );
|
|
201 |
|
|
202 |
if ( ( iDataStore.ConferenceCallState( ) == EPEStateConnectedConference ) )
|
|
203 |
{
|
|
204 |
callId = KPEConferenceCallID;
|
|
205 |
}
|
|
206 |
else if ( iCallHandling.IsCallInState( EPEStateConnected ) )
|
|
207 |
{
|
|
208 |
callId = iCallHandling.GetCallIdByState( EPEStateConnected );
|
|
209 |
}
|
|
210 |
else if ( iCallHandling.IsCallInState( EPEStateConnecting ) )
|
|
211 |
{
|
|
212 |
callId = iCallHandling.GetCallIdByState( EPEStateConnecting );
|
|
213 |
}
|
|
214 |
else if ( iCallHandling.IsCallInState( EPEStateDialing ) )
|
|
215 |
{
|
|
216 |
callId = iCallHandling.GetCallIdByState( EPEStateDialing );
|
|
217 |
}
|
|
218 |
else if ( iCallHandling.IsCallInState( EPEStateAnswering ) )
|
|
219 |
{
|
|
220 |
callId = iCallHandling.GetCallIdByState( EPEStateAnswering );
|
|
221 |
}
|
|
222 |
|
|
223 |
// Replace
|
|
224 |
if ( iCallHandling.IsCallInState( EPEStateConnected ) &&
|
|
225 |
iCallHandling.IsCallInState( EPEStateRinging ) )
|
|
226 |
{
|
|
227 |
TInt callIdConn = iCallHandling.GetCallIdByState( EPEStateConnected );
|
|
228 |
TInt callIdRing = iCallHandling.GetCallIdByState( EPEStateRinging );
|
|
229 |
if ( iDataStore.CallType( callIdConn ) == iDataStore.CallType( callIdRing ) )
|
|
230 |
{
|
|
231 |
// Replace allowed for same call types
|
|
232 |
error = iCallHandling.ReplaceActive();
|
|
233 |
}
|
|
234 |
}
|
|
235 |
else
|
|
236 |
{
|
|
237 |
// Relese active call
|
|
238 |
if ( callId != KPECallIdNotUsed )
|
|
239 |
{
|
|
240 |
iDataStore.SetCallId( callId );
|
|
241 |
error = iMessageHandler.HandleReleaseCall( ETPEHangUpResumeHeldCall );
|
|
242 |
}
|
|
243 |
// accept held or waiting call
|
|
244 |
if ( iCallHandling.IsCallInState( EPEStateRinging ) )
|
|
245 |
{
|
|
246 |
error = iCallHandling.AnswerCall();
|
|
247 |
}
|
|
248 |
else if ( iCallHandling.IsCallInState( EPEStateHeld ) )
|
|
249 |
{
|
|
250 |
error = iCallHandling.ResumeCall();
|
|
251 |
}
|
|
252 |
}
|
|
253 |
|
|
254 |
|
|
255 |
TEFLOGSTRING2( KTAINT,
|
|
256 |
"PE CPEManualCallControlHandler::HandleChldOne, error: %d", error );
|
|
257 |
return error;
|
|
258 |
}
|
|
259 |
|
|
260 |
// -----------------------------------------------------------------------------
|
|
261 |
// CPEManualCallControlHandler::HandleChldOneXL
|
|
262 |
// -----------------------------------------------------------------------------
|
|
263 |
//
|
|
264 |
void CPEManualCallControlHandler::HandleChldOneXL( TInt aCallNo )
|
|
265 |
{
|
|
266 |
TEFLOGSTRING2( KTAINT,
|
|
267 |
"PE CPEManualCallControlHandler::HandleChldOneXL, aCallNo %d",
|
|
268 |
aCallNo );
|
|
269 |
|
|
270 |
TInt error( ECCPErrorNotAllowed );
|
|
271 |
TPEState callState;
|
|
272 |
|
|
273 |
if ( ( KPEMaximumNumberOfVoiceCalls > aCallNo ) && ( aCallNo > 0 ) )
|
|
274 |
{
|
|
275 |
callState = iDataStore.CallState( CallIdByIndexL( aCallNo ) );
|
|
276 |
TEFLOGSTRING2( KTAINT,
|
|
277 |
"PE CPEManualCallControlHandler::HandleChldOneXL, callState %d",
|
|
278 |
callState );
|
|
279 |
if ( callState == EPEStateRinging &&
|
|
280 |
!( iCallHandling.IsCallInState( EPEStateDialing ) || iCallHandling.IsCallInState( EPEStateConnecting ) ) )
|
|
281 |
{
|
|
282 |
error = iMessageHandler.HandleAnswerCall( EFalse );
|
|
283 |
TEFLOGSTRING2( KTAINT,
|
|
284 |
"PE CPEManualCallControlHandler::HandleChldOneXL > HandleAnswerCall, Error code %d",
|
|
285 |
error );
|
|
286 |
}
|
|
287 |
else if ( callState == EPEStateConnected )
|
|
288 |
{
|
|
289 |
iDataStore.SetCallId( CallIdByIndexL( aCallNo ) );
|
|
290 |
error = iMessageHandler.HandleReleaseCall( ETPEHangUpNotResumeHeldCall );
|
|
291 |
TEFLOGSTRING2( KTAINT,
|
|
292 |
"PE CPEManualCallControlHandler::HandleChldOneXL > HandleReleaseCall, Error code %d",
|
|
293 |
error );
|
|
294 |
}
|
|
295 |
}
|
|
296 |
|
|
297 |
TEFLOGSTRING2( KTAINT,
|
|
298 |
"PE CPEManualCallControlHandler::HandleChldOneXL, error: %d", error );
|
|
299 |
User::LeaveIfError( error );
|
|
300 |
}
|
|
301 |
|
|
302 |
// -----------------------------------------------------------------------------
|
|
303 |
// CPEManualCallControlHandler::HandleChldTwo
|
|
304 |
// -----------------------------------------------------------------------------
|
|
305 |
//
|
|
306 |
TInt CPEManualCallControlHandler::HandleChldTwo()
|
|
307 |
{
|
|
308 |
TEFLOGSTRING( KTAINT, "PE CPEManualCallControlHandler::HandleChldTwo");
|
|
309 |
|
|
310 |
TInt error( ECCPErrorNotAllowed );
|
|
311 |
|
|
312 |
if ( iCallHandling.IsCallInState( EPEStateDialing ) ||
|
|
313 |
iCallHandling.IsCallInState( EPEStateConnecting ) )
|
|
314 |
{
|
|
315 |
TEFLOGSTRING(
|
|
316 |
KTAERROR,
|
|
317 |
"PE CPEManualCallControlHandler::HandleChldTwo: Call found in EPEStateDialing or EPEStateConnecting,state > swap NOT ALLOWED" );
|
|
318 |
}
|
|
319 |
else
|
|
320 |
{
|
|
321 |
if ( iCallHandling.IsCallInState( EPEStateConnected ) &&
|
|
322 |
iCallHandling.IsCallInState( EPEStateHeld ) )
|
|
323 |
{
|
|
324 |
error = iCallHandling.SwapCalls();
|
|
325 |
}
|
|
326 |
else if ( iCallHandling.IsCallInState( EPEStateConnected ) &&
|
|
327 |
!iCallHandling.IsCallInState( EPEStateRinging ) )
|
|
328 |
{
|
|
329 |
error = iCallHandling.HoldCall();
|
|
330 |
}
|
|
331 |
else if ( iCallHandling.IsCallInState( EPEStateHeld ) &&
|
|
332 |
!( iCallHandling.IsCallInState( EPEStateRinging ) ) )
|
|
333 |
{
|
|
334 |
error = iCallHandling.ResumeCall();
|
|
335 |
}
|
|
336 |
else if ( iCallHandling.IsCallInState( EPEStateRinging ) )
|
|
337 |
{
|
|
338 |
error = iCallHandling.AnswerCall();
|
|
339 |
}
|
|
340 |
}
|
|
341 |
|
|
342 |
TEFLOGSTRING2( KTAINT,
|
|
343 |
"PE CPEManualCallControlHandler::HandleChldtwo, error: %d", error );
|
|
344 |
return error;
|
|
345 |
}
|
|
346 |
|
|
347 |
// -----------------------------------------------------------------------------
|
|
348 |
// CPEManualCallControlHandler::HandleChldTwoXL
|
|
349 |
// -----------------------------------------------------------------------------
|
|
350 |
//
|
|
351 |
void CPEManualCallControlHandler::HandleChldTwoXL( TInt aCallNo )
|
|
352 |
{
|
|
353 |
TEFLOGSTRING( KTAINT,
|
|
354 |
"PE CPEManualCallControlHandler::HandleChldTwoXL" );
|
|
355 |
|
|
356 |
TInt error( ECCPErrorNotAllowed );
|
|
357 |
|
|
358 |
if ( ( KPEMaximumNumberOfVoiceCalls > aCallNo ) && ( aCallNo > 0 ) )
|
|
359 |
{
|
|
360 |
if ( ( iDataStore.CallState( CallIdByIndexL( aCallNo ) ) == EPEStateConnected )
|
|
361 |
&& ( iDataStore.ConferenceCallState( ) == EPEStateConnectedConference ) )
|
|
362 |
{
|
|
363 |
iDataStore.SetCallId( CallIdByIndexL( aCallNo ) );
|
|
364 |
error = iMessageHandler.HandleGoOneToOne();
|
|
365 |
}
|
|
366 |
}
|
|
367 |
|
|
368 |
TEFLOGSTRING2( KTAINT,
|
|
369 |
"PE CPEManualCallControlHandler::HandleChldTwoXL, error: %d", error );
|
|
370 |
User::LeaveIfError( error );
|
|
371 |
}
|
|
372 |
// -----------------------------------------------------------------------------
|
|
373 |
// CPEManualCallControlHandler::HandleChldThree
|
|
374 |
// -----------------------------------------------------------------------------
|
|
375 |
//
|
|
376 |
TInt CPEManualCallControlHandler::HandleChldThree()
|
|
377 |
{
|
|
378 |
TEFLOGSTRING( KTAINT, "PE CPEManualCallControlHandler::HandleChldThree");
|
|
379 |
|
|
380 |
TInt error( ECCPErrorNotAllowed );
|
|
381 |
|
|
382 |
if( iDataStore.ConferenceCallState( ) == EPEStateConferenceIdle )
|
|
383 |
{
|
|
384 |
TEFLOGSTRING( KTAINT, "PE CPEManualCallControlHandler::HandleChldThree: HandleBuildConferenceCall" );
|
|
385 |
error = iMessageHandler.HandleBuildConferenceCall();
|
|
386 |
}
|
|
387 |
else if ( iDataStore.ConferenceCallState( ) == EPEStateConnectedConference )
|
|
388 |
{
|
|
389 |
TEFLOGSTRING( KTAINT, "PE CPEManualCallControlHandler::HandleChldThree: EPEStateConnectedConference" );
|
|
390 |
if ( iCallHandling.IsCallInState( EPEStateHeld ) )
|
|
391 |
{
|
|
392 |
TEFLOGSTRING( KTAINT, "PE CPEManualCallControlHandler::HandleChldThree: AddConferenceMember" );
|
|
393 |
error = iCallHandling.AddConferenceMember();
|
|
394 |
}
|
|
395 |
}
|
|
396 |
else if( iDataStore.ConferenceCallState( ) == EPEStateHeldConference )
|
|
397 |
{
|
|
398 |
TEFLOGSTRING( KTAINT, "PE CPEManualCallControlHandler::HandleChldThree: EPEStateHeldConference" );
|
|
399 |
if ( iCallHandling.IsCallInState( EPEStateConnected ) )
|
|
400 |
{
|
|
401 |
TEFLOGSTRING( KTAINT, "PE CPEManualCallControlHandler::HandleChldThree: AddConferenceMember" );
|
|
402 |
error = iCallHandling.AddConferenceMember();
|
|
403 |
}
|
|
404 |
}
|
|
405 |
|
|
406 |
TEFLOGSTRING2( KTAINT,
|
|
407 |
"PE CPEManualCallControlHandler::HandleChldTree, error: %d", error );
|
|
408 |
return error;
|
|
409 |
}
|
|
410 |
|
|
411 |
// -----------------------------------------------------------------------------
|
|
412 |
// CPEManualCallControlHandler::HandleChldFour
|
|
413 |
// -----------------------------------------------------------------------------
|
|
414 |
//
|
|
415 |
TInt CPEManualCallControlHandler::HandleChldFour()
|
|
416 |
{
|
|
417 |
TEFLOGSTRING( KTAINT, "PE CPEManualCallControlHandler::HandleChldFour" );
|
|
418 |
|
|
419 |
TInt error( ECCPErrorNotAllowed );
|
|
420 |
|
|
421 |
if ( ( iCallHandling.IsCallInState( EPEStateConnected ) || iCallHandling.IsCallInState( EPEStateConnecting ) ) &&
|
|
422 |
iCallHandling.IsCallInState( EPEStateHeld ) )
|
|
423 |
{
|
|
424 |
TEFLOGSTRING( KTAINT, "PE CPEManualCallControlHandler::HandleChldFour > TransferCalls" );
|
|
425 |
error = iCallHandling.TransferCalls();
|
|
426 |
}
|
|
427 |
|
|
428 |
TEFLOGSTRING2( KTAINT,
|
|
429 |
"PE CPEManualCallControlHandler::HandleChldFour, error: %d", error );
|
|
430 |
return error;
|
|
431 |
}
|
|
432 |
|
|
433 |
// -----------------------------------------------------------------------------
|
|
434 |
// CPEManualCallControlHandler::CallIdByIndexL
|
|
435 |
// -----------------------------------------------------------------------------
|
|
436 |
//
|
|
437 |
TInt CPEManualCallControlHandler::CallIdByIndexL( const TInt& aCallIndex )
|
|
438 |
{
|
|
439 |
TInt i, errorCode( ECCPErrorNotAllowed );
|
|
440 |
for( i = 0; i < KPEMaximumNumberOfCalls; i++ )
|
|
441 |
{
|
|
442 |
if( iDataStore.CallIndex( i ) == aCallIndex )
|
|
443 |
{
|
|
444 |
errorCode = ECCPErrorNone;
|
|
445 |
break;
|
|
446 |
}
|
|
447 |
}
|
|
448 |
User::LeaveIfError( errorCode );
|
|
449 |
return i;
|
|
450 |
}
|
|
451 |
|
|
452 |
// End of File
|