|
1 /* |
|
2 * Copyright (c) 2004 - 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: Handler for DTMF sending. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CVtEngDtmfHandler.h" |
|
21 #include "CVtEngMediaHandler.h" |
|
22 #include "VtEngPanic.h" |
|
23 #include "cvtlogger.h" |
|
24 |
|
25 // LOCAL MACROS |
|
26 #define DTMF_STATES_COUNT 3 |
|
27 const TInt KProtoDtmfCommandId = -1; |
|
28 |
|
29 // ============================ MEMBER FUNCTIONS =============================== |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CVtEngDtmfHandler::NewL |
|
33 // |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 CVtEngDtmfHandler* CVtEngDtmfHandler::NewL( MVtH324ConfigCommand& aH324Config ) |
|
37 { |
|
38 __VTPRINTENTER( "DTMF.New" ) |
|
39 CVtEngDtmfHandler* self = new ( ELeave ) CVtEngDtmfHandler( aH324Config ); |
|
40 CleanupStack::PushL( self ); |
|
41 self->ConstructL(); |
|
42 CleanupStack::Pop(); // self |
|
43 __VTPRINTEXIT( "DTMF.New" ) |
|
44 return self; |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CVtEngDtmfHandler::~CVtEngDtmfHandler |
|
49 // |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CVtEngDtmfHandler::~CVtEngDtmfHandler() |
|
53 { |
|
54 __VTPRINTENTER( "DTMF.~" ) |
|
55 if ( iDtmfStates ) |
|
56 { |
|
57 iDtmfStates->ResetAndDestroy(); |
|
58 } |
|
59 delete iDtmfStates; |
|
60 if( iProtoDtmf ) |
|
61 { |
|
62 VTProtocolFactory::DeleteUserInputIndication(iProtoDtmf); |
|
63 } |
|
64 iProtoDtmf = NULL; |
|
65 __VTPRINTEXIT( "DTMF.~" ) |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CVtEngDtmfHandler::HandleL |
|
70 // |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 void CVtEngDtmfHandler::HandleL( CVtEngOperation& aOp ) |
|
74 { |
|
75 __VTPRINTENTER( "DTMF.HandleL" ) |
|
76 |
|
77 const TVtEngCommandId cmdId( aOp.Command() ); |
|
78 switch ( cmdId ) |
|
79 { |
|
80 case KVtEngStartDtmfTone: |
|
81 { |
|
82 __VTPRINT( DEBUG_MEDIA , "DTMF. start tone" ) |
|
83 TChar tone; |
|
84 TVtEngOpParamUtil<TChar>::Set( tone, aOp ); |
|
85 CVtEngDtmfState* state = (*iDtmfStates)[iCurrentState]; |
|
86 if ( state ) |
|
87 { |
|
88 TVtEngDtmfTone dtmfTone( tone ); |
|
89 state->SendDtmfL( dtmfTone ); |
|
90 } |
|
91 } |
|
92 break; |
|
93 case KVtEngStopDtmfTone: |
|
94 __VTPRINT( DEBUG_MEDIA , "DTMF. stop tone (no op)" ) |
|
95 break; |
|
96 // Handling of different UIIs |
|
97 case KVtEngSetUIIDtmfSupport: |
|
98 SetUIISupport( EDTMFString ); |
|
99 __VTPRINT( DEBUG_MEDIA , "DTMF Support enabled" ) |
|
100 break; |
|
101 case KVtEngSetUIIBasicStringSupport: |
|
102 SetUIISupport( EBasicString ); |
|
103 __VTPRINT( DEBUG_MEDIA , "Basic string Support enabled" ) |
|
104 break; |
|
105 case KVtEngSetUIIIA5StringSupport: |
|
106 SetUIISupport( EIA5String ); |
|
107 __VTPRINT( DEBUG_MEDIA , "IA5 String Support enabled" ) |
|
108 break; |
|
109 case KVtEngSetUIIGeneralStringSupport: |
|
110 SetUIISupport( EGeneralString ); |
|
111 __VTPRINT( DEBUG_MEDIA , "General String Support enabled" ) |
|
112 break; |
|
113 default: |
|
114 __VTPRINT( DEBUG_MEDIA , "DTMF.Handle cmd not supported" ) |
|
115 User::Leave( KErrNotSupported ); |
|
116 } |
|
117 __VTPRINTEXIT( "DTMF.HandleL" ) |
|
118 } |
|
119 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // CVtEngDtmfHandler::ActivateState |
|
122 // |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 CVtEngDtmfState& CVtEngDtmfHandler::ActivateState( TVtEngDtmfState aNewState ) |
|
126 { |
|
127 __VTPRINTENTER( "DTMF.ActivateState" ) |
|
128 __VTPRINT2( DEBUG_MEDIA , " new state=%d", aNewState ) |
|
129 __ASSERT_ALWAYS( aNewState >= EVtDtmfStateIdle && |
|
130 aNewState <= EVtDtmfStateBuffered, |
|
131 Panic( EVtEngPanicInvalidDtmfState) ); |
|
132 iCurrentState = aNewState; |
|
133 __VTPRINTEXIT( "DTMF.ActivateState" ) |
|
134 return *(*iDtmfStates)[iCurrentState]; |
|
135 } |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CVtEngDtmfHandler::SendComplete |
|
139 // |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 void CVtEngDtmfHandler::SendComplete( TInt aError ) |
|
143 { |
|
144 __VTPRINTENTER( "DTMF.SendComplete" ) |
|
145 #ifdef VTDEBUG |
|
146 TRAPD( ignore, HandleSendCompleteL( aError ) ); |
|
147 __VTPRINT2( DEBUG_MEDIA , "DTMF.SendComplete err=%d", ignore ) |
|
148 #else |
|
149 TRAP_IGNORE( HandleSendCompleteL( aError ) ); |
|
150 #endif // VTDEBUG |
|
151 __VTPRINTEXIT( "DTMF.SendComplete" ) |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CVtEngDtmfHandler::ProtoDtmf |
|
156 // |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 MVTUserInput& CVtEngDtmfHandler::ReserveProtoDtmfL( |
|
160 const TVtEngDtmfTone& aTone ) |
|
161 { |
|
162 __VTPRINTENTER( "DTMF.ReserveProtoDtmfL" ) |
|
163 if ( iProtoDtmf != NULL ) |
|
164 { |
|
165 __VTPRINT( DEBUG_MEDIA , "DTMF.ReserveProtoDtmfL IN USE" ) |
|
166 User::Leave( KErrInUse ); |
|
167 } |
|
168 TUint8 val = (TUint8) aTone.iTone; |
|
169 |
|
170 #ifdef VTDEBUG |
|
171 if ( CVtLogger::Flags() & CVtLogger::ELogMedia ) |
|
172 { |
|
173 const TChar ch( val ); |
|
174 _LIT( KVtDtmfBufferTrace, "VT: DTMF. tone value=" ); |
|
175 TBuf<25> buffer( KVtDtmfBufferTrace() ); |
|
176 buffer.Append( ch ); |
|
177 RDebug::Print( buffer ); |
|
178 } |
|
179 #endif |
|
180 |
|
181 |
|
182 |
|
183 // NOTE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
184 // IT MUST BE CHECKED IS GIVEN LETTER SUPPORTED BY |
|
185 // USED ENCODING SCHEME. NOW WE PASS ONLY NUMBERS AND * AND # |
|
186 // AND THEY ARE SAFE TO USE BUT USING POWERFULL UIIs GIVE POSSIBILITY |
|
187 // TO SEND ALL DIGITS AND NUMBERS. IN THAT CASE SET OF CHARS MUST BE CHECKED |
|
188 // IN VTENGINE. (THAT IS THE REASON WHY THERE IS SEPARATE IF ELSEs) |
|
189 // NOTE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
190 |
|
191 __VTPRINT2( DEBUG_MEDIA , "DTMF. Proto USERINPUT %d", iUIISupport ) |
|
192 switch ( iUIISupport ) |
|
193 { |
|
194 case EBasicString: |
|
195 case EIA5String: |
|
196 case EGeneralString: |
|
197 __VTPRINT( DEBUG_MEDIA , "DTMF. Proto USERINPUT alphanumeric" ) |
|
198 iProtoDtmf = VTProtocolFactory::CreateUserInputIndication( EVtUiiDTFM, val ); |
|
199 break; |
|
200 case EDTMFString: |
|
201 __VTPRINT( DEBUG_MEDIA , "DTMF. Proto USERINPUT iDTMFString" ) |
|
202 iProtoDtmf = VTProtocolFactory::CreateUserInputIndication( EVtUiiAlphaNumeric, val); |
|
203 break; |
|
204 default: |
|
205 __VTPRINT( DEBUG_MEDIA , "DTMF. Proto USERINPUT unsupported" ) |
|
206 break; |
|
207 } |
|
208 __VTPRINTEXIT( "DTMF.ReserveProtoDtmfL" ) |
|
209 return *iProtoDtmf; |
|
210 } |
|
211 |
|
212 // ----------------------------------------------------------------------------- |
|
213 // CVtEngDtmfHandler::ReleaseProtoDtmf |
|
214 // |
|
215 // ----------------------------------------------------------------------------- |
|
216 // |
|
217 void CVtEngDtmfHandler::ReleaseProtoDtmf() |
|
218 { |
|
219 __VTPRINTENTER( "DTMF.ReleaseProtoDtmf" ) |
|
220 if( iProtoDtmf ) |
|
221 { |
|
222 VTProtocolFactory::DeleteUserInputIndication(iProtoDtmf); |
|
223 } |
|
224 iProtoDtmf = NULL; |
|
225 __VTPRINTEXIT( "DTMF.ReleaseProtoDtmf" ) |
|
226 } |
|
227 |
|
228 // ----------------------------------------------------------------------------- |
|
229 // CVtEngDtmfHandler::CVtEngDtmfHandler |
|
230 // |
|
231 // ----------------------------------------------------------------------------- |
|
232 // |
|
233 CVtEngDtmfHandler::CVtEngDtmfHandler( MVtH324ConfigCommand& aH324Config ) : |
|
234 iCurrentState( EVtDtmfStateIdle ), iH324Config( aH324Config ), |
|
235 iUIISupport( EIA5String ), iIssuedDtmfCommandId(KProtoDtmfCommandId) |
|
236 { |
|
237 } |
|
238 |
|
239 // ----------------------------------------------------------------------------- |
|
240 // CVtEngDtmfHandler::ConstructL |
|
241 // |
|
242 // ----------------------------------------------------------------------------- |
|
243 // |
|
244 void CVtEngDtmfHandler::ConstructL() |
|
245 { |
|
246 __VTPRINTENTER( "DTMF.ConstructL" ) |
|
247 iDtmfStates = new ( ELeave ) |
|
248 CArrayPtrFlat<CVtEngDtmfState>( DTMF_STATES_COUNT ); |
|
249 |
|
250 for ( TInt state = EVtDtmfStateIdle; |
|
251 state <= EVtDtmfStateBuffered; |
|
252 state++ ) |
|
253 { |
|
254 CreateStateL( state ); |
|
255 } |
|
256 __VTPRINTEXIT( "DTMF.ConstructL" ) |
|
257 } |
|
258 |
|
259 // ----------------------------------------------------------------------------- |
|
260 // CVtEngDtmfHandler::HandleSendCompleteL |
|
261 // |
|
262 // ----------------------------------------------------------------------------- |
|
263 // |
|
264 void CVtEngDtmfHandler::HandleSendCompleteL( TInt aError ) |
|
265 { |
|
266 __VTPRINTENTER( "DTMF.HandleSendCompleteL" ) |
|
267 |
|
268 __VTPRINT2( DEBUG_MEDIA , " HandleSendCompleteL err=%d", aError ) |
|
269 if ( iDtmfStates ) |
|
270 { |
|
271 CVtEngDtmfState* state = (*iDtmfStates)[iCurrentState]; |
|
272 if ( state ) |
|
273 { |
|
274 __VTPRINT2( DEBUG_MEDIA | DEBUG_DETAIL, |
|
275 "DTMF. complete on state %d", iCurrentState ) |
|
276 state->DtmfSendCompleteL( aError ); |
|
277 } |
|
278 } |
|
279 __VTPRINTEXIT( "DTMF.HandleSendCompleteL" ) |
|
280 } |
|
281 |
|
282 // ----------------------------------------------------------------------------- |
|
283 // CVtEngDtmfHandler::CreateState |
|
284 // |
|
285 // ----------------------------------------------------------------------------- |
|
286 // |
|
287 void CVtEngDtmfHandler::CreateStateL( TInt aState ) |
|
288 { |
|
289 __VTPRINTENTER( "DTMF.CreateStateL" ) |
|
290 CVtEngDtmfState* dtmfState = NULL; |
|
291 switch ( aState ) |
|
292 { |
|
293 case EVtDtmfStateIdle: |
|
294 dtmfState = CVtEngDtmfIdle::NewL( *this, iH324Config ); |
|
295 break; |
|
296 case EVtDtmfStateSending: |
|
297 dtmfState = CVtEngDtmfSending::NewL( *this, iH324Config ); |
|
298 break; |
|
299 case EVtDtmfStateBuffered: |
|
300 dtmfState = CVtEngDtmfBuffered::NewL( *this, iH324Config ); |
|
301 break; |
|
302 default: |
|
303 Panic( EVtEngPanicInvalidDtmfState ); |
|
304 break; |
|
305 } |
|
306 CleanupStack::PushL( dtmfState ); |
|
307 iDtmfStates->AppendL( dtmfState ); |
|
308 CleanupStack::Pop(); |
|
309 __VTPRINTEXIT( "DTMF.CreateStateL" ) |
|
310 } |
|
311 |
|
312 // ----------------------------------------------------------------------------- |
|
313 // CVtEngDtmfHandler::GetUIISupport |
|
314 // returns the current UII support |
|
315 // ----------------------------------------------------------------------------- |
|
316 // |
|
317 CVtEngDtmfHandler::TUIISupport CVtEngDtmfHandler::GetUIISupport() const |
|
318 { |
|
319 __VTPRINT2( DEBUG_MEDIA , "DTMF. GETUSERINPUT support=%d", iUIISupport ) |
|
320 return iUIISupport; |
|
321 } |
|
322 |
|
323 // ----------------------------------------------------------------------------- |
|
324 // CVtEngDtmfHandler::SetUIISupport |
|
325 // Sets the UII support mode |
|
326 // ----------------------------------------------------------------------------- |
|
327 // |
|
328 void CVtEngDtmfHandler::SetUIISupport( CVtEngDtmfHandler::TUIISupport aValue ) |
|
329 { |
|
330 __VTPRINT2( DEBUG_MEDIA , "DTMF. SETUSERINPUT support=%d", aValue ) |
|
331 iUIISupport = aValue; |
|
332 } |
|
333 |
|
334 // ----------------------------------------------------------------------------- |
|
335 // CVtEngDtmfHandler::CheckCommandId |
|
336 // Compares last issued DTMF command ID to parameter given command ID |
|
337 // ----------------------------------------------------------------------------- |
|
338 // |
|
339 TBool CVtEngDtmfHandler::CheckCommandId( TInt aCheckCommandId ) const |
|
340 { |
|
341 __VTPRINT3( DEBUG_MEDIA , "DTMF. CHKCMID aCheckCommandId=%d iIssuedDtmfCommandId=%d",\ |
|
342 aCheckCommandId, iIssuedDtmfCommandId ) |
|
343 |
|
344 if( iIssuedDtmfCommandId == aCheckCommandId ) |
|
345 { |
|
346 return ETrue; |
|
347 } |
|
348 |
|
349 return EFalse; |
|
350 } |
|
351 |
|
352 // ----------------------------------------------------------------------------- |
|
353 // CVtEngDtmfHandler::StoreCommandId |
|
354 // Stores given command ID |
|
355 // ----------------------------------------------------------------------------- |
|
356 // |
|
357 void CVtEngDtmfHandler::StoreCommandId( TInt aStoreCommandId ) |
|
358 { |
|
359 __VTPRINT2( DEBUG_MEDIA , "DTMF. STORECOMMANDID aStoreCommandId=%d", aStoreCommandId ) |
|
360 |
|
361 iIssuedDtmfCommandId = aStoreCommandId; |
|
362 } |
|
363 // End of File |