|
1 /* |
|
2 * |
|
3 * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies). |
|
4 * All rights reserved. |
|
5 * This component and the accompanying materials are made available |
|
6 * under the terms of the License "Eclipse Public License v1.0" |
|
7 * which accompanies this distribution, and is available |
|
8 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
9 * |
|
10 * Original Contributors: |
|
11 * Comarch S.A. - original contribution. |
|
12 * |
|
13 * Contributors: |
|
14 * |
|
15 * Description: |
|
16 * |
|
17 */ |
|
18 |
|
19 #include "hspincomingcallacceptance.h" |
|
20 #include "hspcommand.h" |
|
21 #include "hspsettings.h" |
|
22 #include "debug.h" |
|
23 |
|
24 CHsHSPIncomingCallAcceptance* CHsHSPIncomingCallAcceptance::NewL( |
|
25 MHsHSPFeatureProviderObserver* aObserver ) |
|
26 { |
|
27 CHsHSPIncomingCallAcceptance* self = CHsHSPIncomingCallAcceptance::NewLC( |
|
28 aObserver ); |
|
29 CleanupStack::Pop( self ); |
|
30 return self; |
|
31 } |
|
32 CHsHSPIncomingCallAcceptance* CHsHSPIncomingCallAcceptance::NewLC( |
|
33 MHsHSPFeatureProviderObserver* aObserver ) |
|
34 { |
|
35 CHsHSPIncomingCallAcceptance* self = |
|
36 new ( ELeave ) CHsHSPIncomingCallAcceptance( aObserver ); |
|
37 CleanupStack::PushL( self ); |
|
38 self->ConstructL(); |
|
39 return self; |
|
40 } |
|
41 |
|
42 CHsHSPIncomingCallAcceptance::~CHsHSPIncomingCallAcceptance() |
|
43 { |
|
44 } |
|
45 |
|
46 TInt CHsHSPIncomingCallAcceptance::ProcessCommand( |
|
47 const CHsHSPCommand *aInputCmd, CHsHSPCommand &aOutputCmd ) |
|
48 { |
|
49 TRACE_FUNC_ENTRY |
|
50 |
|
51 TInt res = KErrNone; |
|
52 if ( aInputCmd -> FromAG() ) |
|
53 { |
|
54 if ( aInputCmd -> Type() == EHSPCmdRING ) |
|
55 { |
|
56 iWaitingForCKPD200 = ETrue; |
|
57 } |
|
58 else if ( iWaitingForOK && aInputCmd -> Type() == EHSPCmdOK ) |
|
59 { |
|
60 iWaitingForOK = EFalse; |
|
61 iObserver->HandleProcedureCompleted( KErrNone, EHSPCallAccept ); |
|
62 } |
|
63 else |
|
64 { |
|
65 res = KErrArgument; |
|
66 } |
|
67 } |
|
68 else |
|
69 { |
|
70 if ( iWaitingForCKPD200 && IsCKPD200( aInputCmd ) ) |
|
71 { |
|
72 iWaitingForCKPD200 = EFalse; |
|
73 iWaitingForOK = ETrue; |
|
74 TRAP(res,CHsHSPCommand::CopyL( aInputCmd, aOutputCmd )); |
|
75 } |
|
76 /** Incoming call not indicated by RING command */ |
|
77 else if ( !iWaitingForCKPD200 && IsCKPD200( aInputCmd ) ) |
|
78 { |
|
79 iWaitingForCKPD200 = EFalse; |
|
80 iWaitingForOK = ETrue; |
|
81 TRAP(res,CHsHSPCommand::CopyL( aInputCmd, aOutputCmd )); |
|
82 } |
|
83 else |
|
84 { |
|
85 res = KErrArgument; |
|
86 } |
|
87 } |
|
88 |
|
89 TRACE_FUNC_EXIT |
|
90 return res; |
|
91 } |
|
92 |
|
93 CHsHSPIncomingCallAcceptance::CHsHSPIncomingCallAcceptance( |
|
94 MHsHSPFeatureProviderObserver* aObserver ) : |
|
95 iObserver( aObserver ) |
|
96 { |
|
97 } |
|
98 |
|
99 void CHsHSPIncomingCallAcceptance::ConstructL() |
|
100 { |
|
101 } |
|
102 |
|
103 TBool CHsHSPIncomingCallAcceptance::IsCKPD200( const CHsHSPCommand* aCommand ) |
|
104 { |
|
105 TBool res = EFalse; |
|
106 |
|
107 if ( ( EHSPCmdCKPD == aCommand -> Type() ) |
|
108 && ( aCommand -> Params().Count() == 1 ) |
|
109 && ( ( aCommand -> Params()[0].Des().Compare( _L8("200") ) ) == 0 ) ) |
|
110 { |
|
111 res = ETrue; |
|
112 } |
|
113 |
|
114 return res; |
|
115 } |
|
116 |
|
117 void CHsHSPIncomingCallAcceptance::InformObserver( TInt aErr ) |
|
118 { |
|
119 __ASSERT_ALWAYS(iObserver, User::Panic(_L("Observer missing"),KErrGeneral)); |
|
120 iObserver ->HandleProcedureCompleted( aErr, iHSPProc ); |
|
121 } |