37
|
1 |
/*
|
|
2 |
* Copyright (c) 2004-2009 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: AT command request monitor
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
#include "cpeclientcommandhandlermonitor.h"
|
|
22 |
#include "cpemanualcallcontrolhandler.h"
|
|
23 |
#include "cpemessagehandler.h"
|
|
24 |
#include "mpecallhandling.h"
|
|
25 |
#include "mpephonemodelinternal.h"
|
|
26 |
#include <mpedatastore.h>
|
|
27 |
#include <rphcltserver.h>
|
|
28 |
#include <talogger.h>
|
|
29 |
#include <telephonyvariant.hrh>
|
|
30 |
|
|
31 |
|
|
32 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
33 |
|
|
34 |
// -----------------------------------------------------------------------------
|
|
35 |
// CPEClientCommandHandlerMonitor::CPEClientCommandHandlerMonitor
|
|
36 |
// Constructor can NOT contain any code, that
|
|
37 |
// might leave.
|
|
38 |
// -----------------------------------------------------------------------------
|
|
39 |
//
|
|
40 |
CPEClientCommandHandlerMonitor::CPEClientCommandHandlerMonitor(
|
|
41 |
MPECallHandling& aCallHandling,
|
|
42 |
CPEMessageHandler& aMessageHandler,
|
|
43 |
MPEPhoneModelInternal& aModel,
|
|
44 |
RPhCltServer& aServer,
|
|
45 |
CPEManualCallControlHandler& aManualCallControlHandler )
|
|
46 |
: iServer ( aServer ),
|
|
47 |
iCallHandling( aCallHandling ),
|
|
48 |
iMessageHandler ( aMessageHandler),
|
|
49 |
iModel ( aModel ),
|
|
50 |
iManualCallControlHandler( aManualCallControlHandler )
|
|
51 |
{
|
|
52 |
iWaitingForResponse = EFalse;
|
|
53 |
}
|
|
54 |
|
|
55 |
// -----------------------------------------------------------------------------
|
|
56 |
// CPEClientCommandHandlerMonitor::ConstructL
|
|
57 |
// Symbian 2nd phase constructor can leave.
|
|
58 |
// -----------------------------------------------------------------------------
|
|
59 |
//
|
|
60 |
void CPEClientCommandHandlerMonitor::ConstructL()
|
|
61 |
{
|
|
62 |
iNotify = CPhCltCallNotify::NewL();
|
|
63 |
// Open subsession
|
|
64 |
User::LeaveIfError( iNotify->Open( iServer ) );
|
|
65 |
}
|
|
66 |
|
|
67 |
// -----------------------------------------------------------------------------
|
|
68 |
// CPEClientCommandHandlerMonitor::NewL
|
|
69 |
// Two-phased constructor.
|
|
70 |
// -----------------------------------------------------------------------------
|
|
71 |
//
|
|
72 |
CPEClientCommandHandlerMonitor* CPEClientCommandHandlerMonitor::NewL(
|
|
73 |
MPECallHandling& aCallHandling,
|
|
74 |
CPEMessageHandler& aMessageHandler,
|
|
75 |
MPEPhoneModelInternal& aModel,
|
|
76 |
RPhCltServer& aPhoneServer,
|
|
77 |
CPEManualCallControlHandler& aManualCallControlHandler )
|
|
78 |
{
|
|
79 |
CPEClientCommandHandlerMonitor* self = new( ELeave ) CPEClientCommandHandlerMonitor(
|
|
80 |
aCallHandling, aMessageHandler, aModel, aPhoneServer, aManualCallControlHandler );
|
|
81 |
|
|
82 |
CleanupStack::PushL( self );
|
|
83 |
self->ConstructL();
|
|
84 |
CleanupStack::Pop( self );
|
|
85 |
|
|
86 |
return self;
|
|
87 |
}
|
|
88 |
|
|
89 |
|
|
90 |
// Destructor
|
|
91 |
CPEClientCommandHandlerMonitor::~CPEClientCommandHandlerMonitor()
|
|
92 |
{
|
|
93 |
Cancel();
|
|
94 |
|
|
95 |
if ( iNotify )
|
|
96 |
{
|
|
97 |
iNotify->Close();
|
|
98 |
delete iNotify;
|
|
99 |
}
|
|
100 |
iLibrary.Close();
|
|
101 |
}
|
|
102 |
|
|
103 |
|
|
104 |
// -----------------------------------------------------------------------------
|
|
105 |
// CPEClientCommandHandlerMonitor::Start
|
|
106 |
// Start listening for AT command requests.
|
|
107 |
// -----------------------------------------------------------------------------
|
|
108 |
//
|
|
109 |
void CPEClientCommandHandlerMonitor::Start()
|
|
110 |
{
|
|
111 |
TEFLOGSTRING( KTAOBJECT, "PE CPEClientCommandHandlerMonitor::Start()" );
|
|
112 |
iNotify->NotifyComHandCommand( this, iArgs );
|
|
113 |
}
|
|
114 |
|
|
115 |
// -----------------------------------------------------------------------------
|
|
116 |
// CPEClientCommandHandlerMonitor::Respond
|
|
117 |
// Sends response to AT command request
|
|
118 |
// -----------------------------------------------------------------------------
|
|
119 |
//
|
|
120 |
void CPEClientCommandHandlerMonitor::Respond( const TInt aErrorCode )
|
|
121 |
{
|
|
122 |
TEFLOGSTRING2( KTAINT,
|
|
123 |
"PE CPEClientCommandHandlerMonitor::Respond: error %d", aErrorCode );
|
|
124 |
|
|
125 |
SendResponse( aErrorCode );
|
|
126 |
Start();
|
|
127 |
}
|
|
128 |
|
|
129 |
|
|
130 |
// -----------------------------------------------------------------------------
|
|
131 |
// CPEClientCommandHandlerMonitor::SendResponse
|
|
132 |
// Sends response to server.
|
|
133 |
// -----------------------------------------------------------------------------
|
|
134 |
//
|
|
135 |
void CPEClientCommandHandlerMonitor::SendResponse( const TInt aResponse )
|
|
136 |
{
|
|
137 |
iNotify->RespondComHandClient( aResponse );
|
|
138 |
}
|
|
139 |
|
|
140 |
|
|
141 |
// -----------------------------------------------------------------------------
|
|
142 |
// CPEClientCommandHandlerMonitor::RunL
|
|
143 |
//
|
|
144 |
// -----------------------------------------------------------------------------
|
|
145 |
//
|
|
146 |
void CPEClientCommandHandlerMonitor::ComHandRequest()
|
|
147 |
{
|
|
148 |
TEFLOGSTRING( KTAREQEND, "PE CPEClientCommandHandlerMonitor::ComHandRequest");
|
|
149 |
TRAPD( err, HandleCommandRequestL( iArgs() ) );
|
|
150 |
if ( err != ECCPErrorNone )
|
|
151 |
{
|
|
152 |
Respond( err );
|
|
153 |
}
|
|
154 |
}
|
|
155 |
|
|
156 |
|
|
157 |
// -----------------------------------------------------------------------------
|
|
158 |
// CPEClientCommandHandlerMonitor::DoCancel
|
|
159 |
//
|
|
160 |
// -----------------------------------------------------------------------------
|
|
161 |
//
|
|
162 |
void CPEClientCommandHandlerMonitor::Cancel()
|
|
163 |
{
|
|
164 |
TEFLOGSTRING( KTAINT, "PE CPEClientCommandHandlerMonitor::Cancel" );
|
|
165 |
if ( iNotify )
|
|
166 |
{
|
|
167 |
iNotify->CancelNotifyComHandCommand();
|
|
168 |
}
|
|
169 |
}
|
|
170 |
|
|
171 |
|
|
172 |
// -----------------------------------------------------------------------------
|
|
173 |
// CPEClientCommandHandlerMonitor::HandleAtCommandRequestL
|
|
174 |
// Processing various supported BT AT commands
|
|
175 |
// -----------------------------------------------------------------------------
|
|
176 |
//
|
|
177 |
void CPEClientCommandHandlerMonitor::HandleCommandRequestL(
|
|
178 |
const TPhCltComHandCommandParameters& aArgs )
|
|
179 |
{
|
|
180 |
TEFLOGSTRING2( KTAINT,
|
|
181 |
"PE CPEClientCommandHandlerMonitor::HandleCommandRequestL: command %d"
|
|
182 |
, aArgs.iCommandHandlerCommand );
|
|
183 |
|
|
184 |
switch ( aArgs.iCommandHandlerCommand )
|
|
185 |
{
|
|
186 |
case EPhCltCommandAta:
|
|
187 |
HandleCmdAta();
|
|
188 |
break;
|
|
189 |
|
|
190 |
case EPhCltCommandChup:
|
|
191 |
HandleCmdChup();
|
|
192 |
break;
|
|
193 |
|
|
194 |
case EPhCltCommandVts:
|
|
195 |
HandleCmdVtsL( aArgs.iDtmfTone, aArgs.iDtmfAction );
|
|
196 |
break;
|
|
197 |
|
|
198 |
case EPhCltCommandAtd:
|
|
199 |
HandleCmdAtdL( aArgs.iTelNumber );
|
|
200 |
break;
|
|
201 |
|
|
202 |
case EPhCltCommandChld:
|
|
203 |
HandleCmdChldL( aArgs.iChldCommand, aArgs.iChldCallNumber );
|
|
204 |
break;
|
|
205 |
|
|
206 |
case EPhCltCommandMuteMic:
|
|
207 |
HandleCmdMuteMic( aArgs.iMute );
|
|
208 |
break;
|
|
209 |
|
|
210 |
case EPhCltCommandMuteRingingTone:
|
|
211 |
HandleCmdMuteRingingTone();
|
|
212 |
break;
|
|
213 |
|
|
214 |
default:
|
|
215 |
Respond( ECCPErrorNotSupported );
|
|
216 |
break;
|
|
217 |
}
|
|
218 |
}
|
|
219 |
|
|
220 |
// -----------------------------------------------------------------------------
|
|
221 |
// CPEClientCommandHandlerMonitor::HandleCmdAta
|
|
222 |
// Processing ATA command
|
|
223 |
// -----------------------------------------------------------------------------
|
|
224 |
//
|
|
225 |
void CPEClientCommandHandlerMonitor::HandleCmdAta()
|
|
226 |
{
|
|
227 |
TEFLOGSTRING( KTAINT, "PE CPEClientCommandHandlerMonitor::HandleCmdAta" );
|
|
228 |
// Checking for available ringing call is done in CallHandling,
|
|
229 |
// no need to do it here. If a ringing call was not found, the
|
|
230 |
// error code equals "ECCPErrorNotFound".
|
|
231 |
Respond( iMessageHandler.HandleAnswerCall( EFalse ));
|
|
232 |
}
|
|
233 |
|
|
234 |
// -----------------------------------------------------------------------------
|
|
235 |
// CPEClientCommandHandlerMonitor::HandleCmdChup
|
|
236 |
// Processing CHUP command
|
|
237 |
// -----------------------------------------------------------------------------
|
|
238 |
//
|
|
239 |
void CPEClientCommandHandlerMonitor::HandleCmdChup()
|
|
240 |
{
|
|
241 |
TEFLOGSTRING( KTAINT, "PE CPEClientCommandHandlerMonitor::HandleCmdChup" );
|
|
242 |
if ( iCallHandling.IsCallInState( EPEStateRinging ) &&
|
|
243 |
iCallHandling.GetNumberOfCalls() == 1 )
|
|
244 |
{
|
|
245 |
Respond( iCallHandling.RejectCall() );
|
|
246 |
}
|
|
247 |
else if( iCallHandling.GetNumberOfCalls() > 1 )
|
|
248 |
{
|
|
249 |
// Hang up the calls in the order specified by Multicall Handling UI spec.
|
|
250 |
// If the call has a hang up request pending already, hang up the next call.
|
|
251 |
TInt err = HangUp( EPEStateDisconnecting );
|
|
252 |
if ( ECCPErrorNone != err )
|
|
253 |
{
|
|
254 |
err = HangUp( EPEStateCreatingConference );
|
|
255 |
if ( ECCPErrorNone != err )
|
|
256 |
{
|
|
257 |
err = HangUp( EPEStateDialing );
|
|
258 |
if ( ECCPErrorNone != err )
|
|
259 |
{
|
|
260 |
err = HangUp( EPEStateConnecting );
|
|
261 |
if ( ECCPErrorNone != err )
|
|
262 |
{
|
|
263 |
err = HangUp( EPEStateConnectedConference );
|
|
264 |
if ( ECCPErrorNone != err )
|
|
265 |
{
|
|
266 |
err = HangUp( EPEStateConnected );
|
|
267 |
if ( ECCPErrorNone != err )
|
|
268 |
{
|
|
269 |
err = HangUp( EPEStateHeldConference );
|
|
270 |
if ( ECCPErrorNone != err )
|
|
271 |
{
|
|
272 |
err = HangUp( EPEStateHeld );
|
|
273 |
}
|
|
274 |
}
|
|
275 |
}
|
|
276 |
}
|
|
277 |
}
|
|
278 |
}
|
|
279 |
}
|
|
280 |
Respond( err ); // Responds KErrNone or any error code
|
|
281 |
}
|
|
282 |
else if( iCallHandling.GetNumberOfCalls() == 1 )
|
|
283 |
{
|
|
284 |
Respond( iCallHandling.ReleaseAll() );
|
|
285 |
}
|
|
286 |
else
|
|
287 |
{
|
|
288 |
Respond( ECCPErrorGeneral );
|
|
289 |
}
|
|
290 |
|
|
291 |
}
|
|
292 |
|
|
293 |
// -----------------------------------------------------------------------------
|
|
294 |
// CPEClientCommandHandlerMonitor::HandleCmdVtsL
|
|
295 |
// Processing VTS command
|
|
296 |
// -----------------------------------------------------------------------------
|
|
297 |
//
|
|
298 |
void CPEClientCommandHandlerMonitor::HandleCmdVtsL(
|
|
299 |
const TPhCltDtmfTone aDtmfTone,
|
|
300 |
const TPhCltDtmfAction aAction )
|
|
301 |
{
|
|
302 |
TEFLOGSTRING( KTAINT, "PE CPEClientCommandHandlerMonitor::HandleCmdVtsL" );
|
|
303 |
TInt errorCode;
|
|
304 |
|
|
305 |
switch ( aAction )
|
|
306 |
{
|
|
307 |
case EPhCltDtmfNotUsed:
|
|
308 |
iModel.DataStore()->SetKeyCode( aDtmfTone );
|
|
309 |
iMessageHandler.HandlePlayDTMFL();
|
|
310 |
errorCode = iMessageHandler.HandleEndDTMF();
|
|
311 |
break;
|
|
312 |
case EPhCltDtmfStart:
|
|
313 |
iModel.DataStore()->SetKeyCode( aDtmfTone );
|
|
314 |
iMessageHandler.HandlePlayDTMFL();
|
|
315 |
errorCode = ECCPErrorNone;
|
|
316 |
break;
|
|
317 |
case EPhCltDtmfStop:
|
|
318 |
errorCode = iMessageHandler.HandleEndDTMF();
|
|
319 |
break;
|
|
320 |
default:
|
|
321 |
errorCode = ECCPErrorNotSupported;
|
|
322 |
break;
|
|
323 |
}
|
|
324 |
Respond( errorCode );
|
|
325 |
|
|
326 |
}
|
|
327 |
|
|
328 |
// -----------------------------------------------------------------------------
|
|
329 |
// CPEClientCommandHandlerMonitor::HandleCmdAtdL
|
|
330 |
// Handle AT dial.
|
|
331 |
// -----------------------------------------------------------------------------
|
|
332 |
//
|
|
333 |
void CPEClientCommandHandlerMonitor::HandleCmdAtdL(
|
|
334 |
const TPhCltTelephoneNumber& aPhoneNumber )
|
|
335 |
{
|
|
336 |
TEFLOGSTRING( KTAINT, "PE CPEClientCommandHandlerMonitor::HandleCmdAtdL" );
|
|
337 |
iModel.DataStore()->SetPhoneNumber(
|
|
338 |
static_cast<TPEPhoneNumber>( aPhoneNumber ) );
|
|
339 |
iWaitingForResponse = ETrue;
|
|
340 |
iModel.SendMessage( MEngineMonitor::EPEMessageStartATDialing );
|
|
341 |
}
|
|
342 |
|
|
343 |
// -----------------------------------------------------------------------------
|
|
344 |
// CPEClientCommandHandlerMonitor::HandleCmdChldL
|
|
345 |
// Processing CHLD command
|
|
346 |
// -----------------------------------------------------------------------------
|
|
347 |
//
|
|
348 |
void CPEClientCommandHandlerMonitor::HandleCmdChldL(
|
|
349 |
const TPhCltChldCommand aChldCommand,
|
|
350 |
const TUint aCallNo ) // Only used in GSM.
|
|
351 |
{
|
|
352 |
TEFLOGSTRING( KTAINT, "PE CPEClientCommandHandlerMonitor::HandleCmdChldL" );
|
|
353 |
TInt errorCode = ECCPErrorNone;
|
|
354 |
|
|
355 |
// All commands are meant for incall situations.
|
|
356 |
if ( iCallHandling.GetNumberOfCalls() > 0 )
|
|
357 |
{
|
|
358 |
// Leaves on error code. The leave error is sent as a response
|
|
359 |
// to the client.
|
|
360 |
TRAP( errorCode, iManualCallControlHandler.HandleChldL( aChldCommand, aCallNo ));
|
|
361 |
}
|
|
362 |
else
|
|
363 |
{
|
|
364 |
errorCode = ECCPErrorGeneral;
|
|
365 |
}
|
|
366 |
|
|
367 |
Respond( errorCode );
|
|
368 |
}
|
|
369 |
|
|
370 |
// -----------------------------------------------------------------------------
|
|
371 |
// CPEClientCommandHandlerMonitor::DoCompleteCmdAtd
|
|
372 |
// Processing response from Phone UI (dialing started indication)
|
|
373 |
// -----------------------------------------------------------------------------
|
|
374 |
//
|
|
375 |
void CPEClientCommandHandlerMonitor::DoCompleteCmdAtd( TBool aFlag )
|
|
376 |
{
|
|
377 |
TEFLOGSTRING( KTAINT, "PE CPEClientCommandHandlerMonitor::DoCompleteCmdAtd" );
|
|
378 |
if ( iWaitingForResponse )
|
|
379 |
{
|
|
380 |
iWaitingForResponse = EFalse;
|
|
381 |
if ( aFlag )
|
|
382 |
{
|
|
383 |
Respond( ECCPErrorNone );
|
|
384 |
}
|
|
385 |
else
|
|
386 |
{
|
|
387 |
Respond( ECCPErrorGeneral );
|
|
388 |
}
|
|
389 |
}
|
|
390 |
}
|
|
391 |
|
|
392 |
// -----------------------------------------------------------------------------
|
|
393 |
// CPEClientCommandHandlerMonitor::HandleCmdMuteRingingTone
|
|
394 |
// -----------------------------------------------------------------------------
|
|
395 |
//
|
|
396 |
void CPEClientCommandHandlerMonitor::HandleCmdMuteRingingTone()
|
|
397 |
{
|
|
398 |
TEFLOGSTRING( KTAINT, "PE CPEClientCommandHandlerMonitor::HandleCmdMuteRingingTone" );
|
|
399 |
TInt errorCode( ECCPErrorNone );
|
|
400 |
|
|
401 |
// command is meant for incall situations.
|
|
402 |
if ( iCallHandling.GetNumberOfCalls() > 0 )
|
|
403 |
{
|
|
404 |
iModel.SendMessage( MEngineMonitor::EPEMessageMuteRingingTone );
|
|
405 |
}
|
|
406 |
else
|
|
407 |
{
|
|
408 |
errorCode = ECCPErrorGeneral;
|
|
409 |
}
|
|
410 |
|
|
411 |
Respond( errorCode );
|
|
412 |
}
|
|
413 |
|
|
414 |
// -----------------------------------------------------------------------------
|
|
415 |
// CPEClientCommandHandlerMonitor::HandleCmdMuteMic
|
|
416 |
// -----------------------------------------------------------------------------
|
|
417 |
//
|
|
418 |
void CPEClientCommandHandlerMonitor::HandleCmdMuteMic( TBool aMute )
|
|
419 |
{
|
|
420 |
TEFLOGSTRING( KTAINT, "PE CPEClientCommandHandlerMonitor::HandleCmdMuteMic" );
|
|
421 |
// command is meant for incall situations.
|
|
422 |
if ( iCallHandling.GetNumberOfCalls() > 0 )
|
|
423 |
{
|
|
424 |
iModel.DataStore()->SetAudioMuteCommand( aMute );
|
|
425 |
iMessageHandler.HandleSetAudioMute();
|
|
426 |
Respond( ECCPErrorNone );
|
|
427 |
}
|
|
428 |
else
|
|
429 |
{
|
|
430 |
Respond( ECCPErrorGeneral );
|
|
431 |
}
|
|
432 |
}
|
|
433 |
|
|
434 |
// -----------------------------------------------------------------------------
|
|
435 |
// CPEClientCommandHandlerMonitor::HangUp
|
|
436 |
// Finds a conference call or a single call (in that order) in specified
|
|
437 |
// state and tries to hang it up.
|
|
438 |
// -----------------------------------------------------------------------------
|
|
439 |
//
|
|
440 |
TInt CPEClientCommandHandlerMonitor::HangUp( TPEState aState )
|
|
441 |
{
|
|
442 |
TEFLOGSTRING2( KTAINT, "CPEClientCommandHandlerMonitor::HangUp aState=%d", aState);
|
|
443 |
TInt ret( ECCPErrorNotFound );
|
|
444 |
|
|
445 |
TPEState conferenceState = iCallHandling.GetCallState( KPEConferenceCallID );
|
|
446 |
if ( conferenceState == aState )
|
|
447 |
{
|
|
448 |
ret = iCallHandling.HangUp( KPEConferenceCallID, ETPEHangUpDefault );
|
|
449 |
}
|
|
450 |
else
|
|
451 |
{
|
|
452 |
TInt callId = iCallHandling.GetCallIdByState( aState );
|
|
453 |
if ( KPECallIdNotUsed != callId )
|
|
454 |
{
|
|
455 |
ret = iCallHandling.HangUp( callId, ETPEHangUpDefault );
|
|
456 |
}
|
|
457 |
}
|
|
458 |
|
|
459 |
TEFLOGSTRING2( KTAINT, "CPEClientCommandHandlerMonitor::HangUp ret=%d", ret );
|
|
460 |
return ret;
|
|
461 |
}
|
|
462 |
|
|
463 |
// End of File
|