|
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 "hspfeaturemanager.h" |
|
20 #include "hspcalltermination.h" |
|
21 #include "hspincomingcallacceptance.h" |
|
22 #include "hspremoteaudiovolumecontrol.h" |
|
23 #include "hspcommand.h" |
|
24 #include "debug.h" |
|
25 |
|
26 CHsHSPFeatureManager* CHsHSPFeatureManager::NewL() |
|
27 { |
|
28 CHsHSPFeatureManager *self = CHsHSPFeatureManager::NewLC(); |
|
29 CleanupStack::Pop( self ); |
|
30 |
|
31 return self; |
|
32 } |
|
33 |
|
34 CHsHSPFeatureManager* CHsHSPFeatureManager::NewLC() |
|
35 { |
|
36 |
|
37 CHsHSPFeatureManager *self = new ( ELeave ) CHsHSPFeatureManager(); |
|
38 CleanupStack::PushL( self ); |
|
39 self->ConstructL(); |
|
40 return self; |
|
41 } |
|
42 |
|
43 CHsHSPFeatureManager::~CHsHSPFeatureManager() |
|
44 { |
|
45 TRACE_FUNC_ENTRY |
|
46 |
|
47 if ( iCallTermProc ) |
|
48 { |
|
49 delete iCallTermProc; |
|
50 } |
|
51 if ( iCallAcceptProc ) |
|
52 { |
|
53 delete iCallAcceptProc; |
|
54 } |
|
55 if ( iVolumeControl ) |
|
56 { |
|
57 delete iVolumeControl; |
|
58 } |
|
59 |
|
60 if ( iSettings ) |
|
61 { |
|
62 iSettings -> Release(); |
|
63 } |
|
64 |
|
65 TRACE_FUNC_EXIT |
|
66 } |
|
67 |
|
68 void CHsHSPFeatureManager::PerformDataProcessingL( |
|
69 const CHsHSPCommand* aATCommandIn, CHsHSPCommand& aATCommandOut ) |
|
70 { |
|
71 TRACE_FUNC_ENTRY |
|
72 switch ( aATCommandIn->Type() ) |
|
73 { |
|
74 case EHSPCmdOK: |
|
75 { |
|
76 HandleOKCommandL( aATCommandIn, aATCommandOut ); |
|
77 } |
|
78 break; |
|
79 case EHSPCmdERROR: |
|
80 { |
|
81 //No implementation needed |
|
82 } |
|
83 break; |
|
84 |
|
85 case EHSPCmdRING: |
|
86 { |
|
87 User::LeaveIfNull( iCallAcceptProc ); |
|
88 User::LeaveIfError( iCallAcceptProc->ProcessCommand( aATCommandIn, |
|
89 aATCommandOut ) ); |
|
90 iProcedureStarted = EHSPCallAccept; |
|
91 } |
|
92 break; |
|
93 |
|
94 case EHSPCmdVGS: |
|
95 { |
|
96 if ( !aATCommandIn ->FromAG() ) |
|
97 iProcedureStarted = EHSPVolumeControl; |
|
98 |
|
99 User::LeaveIfNull( iVolumeControl ); |
|
100 User::LeaveIfError( iVolumeControl->ProcessCommand( aATCommandIn, |
|
101 aATCommandOut ) ); |
|
102 } |
|
103 break; |
|
104 case EHSPCmdVGM: |
|
105 { |
|
106 if ( !aATCommandIn ->FromAG() ) |
|
107 iProcedureStarted = EHSPVolumeControl; |
|
108 |
|
109 User::LeaveIfNull( iVolumeControl ); |
|
110 User::LeaveIfError( iVolumeControl->ProcessCommand( aATCommandIn, |
|
111 aATCommandOut ) ); |
|
112 } |
|
113 break; |
|
114 case EHSPCmdCKPD: |
|
115 { |
|
116 HandleCKPDCommandL( aATCommandIn, aATCommandOut ); |
|
117 } |
|
118 break; |
|
119 default: |
|
120 User::Leave( KErrArgument ); |
|
121 } |
|
122 |
|
123 TRACE_FUNC_EXIT |
|
124 } |
|
125 |
|
126 void CHsHSPFeatureManager::HandleClientDisconnected( TInt aErr ) |
|
127 { |
|
128 TRACE_FUNC_ENTRY |
|
129 |
|
130 if ( iVolumeControl ) |
|
131 { |
|
132 iVolumeControl->Reset(); |
|
133 } |
|
134 |
|
135 iSettings ->UpdateCallStatus( EFalse ); |
|
136 |
|
137 TRACE_FUNC_EXIT |
|
138 } |
|
139 |
|
140 void CHsHSPFeatureManager::HandleClientConnected( TDes8& aCommandOut ) |
|
141 { |
|
142 TRACE_FUNC_ENTRY |
|
143 |
|
144 TRACE_FUNC_EXIT |
|
145 } |
|
146 |
|
147 void CHsHSPFeatureManager::HandleProcedureCompleted( TInt aErr, |
|
148 const THSPProcedure aProcedure ) |
|
149 { |
|
150 TRACE_FUNC_ENTRY |
|
151 |
|
152 if ( KErrNone == aErr ) |
|
153 { |
|
154 switch ( aProcedure ) |
|
155 { |
|
156 case EHSPCallTerminate: |
|
157 iSettings -> UpdateCallStatus( EFalse ); |
|
158 TRACE_INFO(_L("Completed: Call release")) |
|
159 iProcedureStarted = EHSPIdle; |
|
160 break; |
|
161 |
|
162 case EHSPCallAccept: |
|
163 iSettings -> UpdateCallStatus( ETrue ); |
|
164 TRACE_INFO(_L("Completed: Call accept")) |
|
165 iProcedureStarted = EHSPIdle; |
|
166 break; |
|
167 |
|
168 case EHSPVolumeControl: |
|
169 TRACE_INFO(_L("Completed: Volume control")) |
|
170 break; |
|
171 } |
|
172 |
|
173 } |
|
174 TRACE_FUNC_EXIT |
|
175 } |
|
176 |
|
177 CHsHSPFeatureManager::CHsHSPFeatureManager() |
|
178 { |
|
179 |
|
180 } |
|
181 |
|
182 void CHsHSPFeatureManager::ConstructL() |
|
183 { |
|
184 TRACE_FUNC_ENTRY |
|
185 iCallTermProc = CHsHSPCallTerminationProc::NewL( this ); |
|
186 iCallAcceptProc = CHsHSPIncomingCallAcceptance::NewL( this ); |
|
187 iVolumeControl = CHsHSPRemoteAudioVolumeControl::NewL( this ); |
|
188 iSettings = CHsHSPSettings::InstanceL(); |
|
189 iProcedureStarted = EHSPIdle; |
|
190 TRACE_FUNC_EXIT |
|
191 } |
|
192 |
|
193 void CHsHSPFeatureManager::HandleOKCommandL( const CHsHSPCommand* aATCommandIn, |
|
194 CHsHSPCommand& aATCommandOut ) |
|
195 { |
|
196 TRACE_FUNC_ENTRY |
|
197 |
|
198 if ( iProcedureStarted == EHSPCallTerminate ) |
|
199 { |
|
200 TRACE_INFO(_L("iProcedureStarted == EHSPCallTerminate")) |
|
201 User::LeaveIfNull( iCallTermProc ); |
|
202 User::LeaveIfError( iCallTermProc->ProcessCommand( aATCommandIn, |
|
203 aATCommandOut ) ); |
|
204 } |
|
205 else if ( iProcedureStarted == EHSPCallAccept ) |
|
206 { |
|
207 TRACE_INFO(_L("iProcedureStarted == EHSPCallAccept")) |
|
208 User::LeaveIfNull( iCallAcceptProc ); |
|
209 User::LeaveIfError( iCallAcceptProc->ProcessCommand( aATCommandIn, |
|
210 aATCommandOut ) ); |
|
211 } |
|
212 else if ( iProcedureStarted == EHSPVolumeControl ) |
|
213 { |
|
214 TRACE_INFO(_L("iProcedureStarted == EHSPVolumeControl")) |
|
215 User::LeaveIfNull( iVolumeControl ); |
|
216 User::LeaveIfError( iVolumeControl->ProcessCommand( aATCommandIn, |
|
217 aATCommandOut ) ); |
|
218 } |
|
219 |
|
220 else |
|
221 { |
|
222 User::Leave( KErrArgument ); |
|
223 } |
|
224 TRACE_FUNC_EXIT |
|
225 } |
|
226 |
|
227 void CHsHSPFeatureManager::HandleCKPDCommandL( |
|
228 const CHsHSPCommand* aATCommandIn, CHsHSPCommand& aATCommandOut ) |
|
229 { |
|
230 TRACE_FUNC_ENTRY |
|
231 |
|
232 if ( !iSettings -> CallOngoing() ) |
|
233 { |
|
234 iProcedureStarted = EHSPCallAccept; |
|
235 User::LeaveIfNull( iCallAcceptProc ); |
|
236 User::LeaveIfError( iCallAcceptProc->ProcessCommand( aATCommandIn, |
|
237 aATCommandOut ) ); |
|
238 } |
|
239 else |
|
240 { |
|
241 iProcedureStarted = EHSPCallTerminate; |
|
242 User::LeaveIfNull( iCallTermProc ); |
|
243 User::LeaveIfError( iCallTermProc->ProcessCommand( aATCommandIn, |
|
244 aATCommandOut ) ); |
|
245 } |
|
246 |
|
247 TRACE_FUNC_EXIT |
|
248 } |