|
1 /* |
|
2 * Copyright (c) 2002-2007 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: This module contains the implementation of CPEGsmAudioData class |
|
15 * member functions |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "cpeaudiodtmftoneplayer.h" |
|
22 #include "cpeaudiofactory.h" |
|
23 #include "cpeaudioinbandtoneplayer.h" |
|
24 #include "cpegsmaudiodata.h" |
|
25 #include <ccpdefs.h> |
|
26 #include <mpeclientinformation.h> |
|
27 #include <mpedatastore.h> |
|
28 #include <mpephonemodelinternal.h> |
|
29 #include <talogger.h> |
|
30 |
|
31 // EXTERNAL DATA STRUCTURES |
|
32 // None. |
|
33 |
|
34 // EXTERNAL FUNCTION PROTOTYPES |
|
35 // None. |
|
36 |
|
37 // CONSTANTS |
|
38 // None. |
|
39 |
|
40 // MACROS |
|
41 // None. |
|
42 |
|
43 // LOCAL CONSTANTS AND MACROS |
|
44 // None. |
|
45 |
|
46 // MODULE DATA STRUCTURES |
|
47 // None. |
|
48 |
|
49 // LOCAL FUNCTION PROTOTYPES |
|
50 // None. |
|
51 |
|
52 // FORWARD DECLARATIONS |
|
53 // None. |
|
54 |
|
55 // ==================== LOCAL FUNCTIONS ==================== |
|
56 // None. |
|
57 |
|
58 // ================= MEMBER FUNCTIONS ======================= |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CPEGsmAudioData::CPEGsmAudioData |
|
62 // C++ default constructor can NOT contain any code, that |
|
63 // might leave. |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 CPEGsmAudioData::CPEGsmAudioData |
|
67 ( |
|
68 MPEPhoneModelInternal& aPhoneModel, |
|
69 RFs& aFsSession |
|
70 ) : CPEAudioData( aPhoneModel ), |
|
71 iFsSession( aFsSession ) |
|
72 { |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CPEGsmAudioData::ConstructL |
|
77 // Symbian 2nd phase constructor can leave. |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 void CPEGsmAudioData::ConstructL( CPEAudioFactory& aAudioFactory ) |
|
81 { |
|
82 CPEAudioData::ConstructL( aAudioFactory ); |
|
83 |
|
84 iInbandTonePlayer = |
|
85 CPEAudioInbandTonePlayer::NewL( *this, iFsSession, aAudioFactory ); |
|
86 iDtmfTonePlayer = CPEAudioDtmfTonePlayer::NewL(); |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // CPEGsmAudioData::NewL |
|
91 // Two-phased constructor. |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 EXPORT_C CPEGsmAudioData* CPEGsmAudioData::NewL |
|
95 ( |
|
96 MPEPhoneModelInternal& aPhoneModel, |
|
97 RFs& aFsSession |
|
98 ) |
|
99 { |
|
100 CPEGsmAudioData* self = new ( ELeave ) |
|
101 CPEGsmAudioData ( aPhoneModel, aFsSession ); |
|
102 CleanupStack::PushL( self ); |
|
103 |
|
104 CPEAudioFactory* factory = CPEAudioFactory::NewLC(); |
|
105 self->ConstructL(*factory); |
|
106 CleanupStack::PopAndDestroy( factory ); |
|
107 |
|
108 CleanupStack::Pop( self ); |
|
109 return self; |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CPEGsmAudioData::NewL |
|
114 // Two-phased constructor for testing purposes. |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 EXPORT_C CPEGsmAudioData* CPEGsmAudioData::NewL |
|
118 ( |
|
119 MPEPhoneModelInternal& aPhoneModel, |
|
120 RFs& aFsSession, |
|
121 CPEAudioFactory& aAudioFactory |
|
122 ) |
|
123 { |
|
124 CPEGsmAudioData* self = new ( ELeave ) |
|
125 CPEGsmAudioData ( aPhoneModel, aFsSession ); |
|
126 CleanupStack::PushL( self ); |
|
127 |
|
128 self->ConstructL(aAudioFactory); |
|
129 CleanupStack::Pop( self ); |
|
130 return self; |
|
131 } |
|
132 |
|
133 // Destructor |
|
134 EXPORT_C CPEGsmAudioData::~CPEGsmAudioData |
|
135 ( |
|
136 // None. |
|
137 ) |
|
138 { |
|
139 delete iDtmfTonePlayer; |
|
140 delete iInbandTonePlayer; |
|
141 } |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // CPEGsmAudioData::PlayDtmfTone |
|
145 // Starts to play the given tone from dtmf player. |
|
146 // (other items were commented in a header). |
|
147 // ----------------------------------------------------------------------------- |
|
148 // |
|
149 EXPORT_C void CPEGsmAudioData::PlayDtmfTone |
|
150 ( |
|
151 const TChar& aTone //DTMF tone to play |
|
152 ) const |
|
153 { |
|
154 TInt volume; //DTMF tone volume |
|
155 volume = iPhoneModel.DataStore()->KeypadVolume(); |
|
156 |
|
157 TEFLOGSTRING3( KTAREQIN, |
|
158 "AUD CPEGsmAudioData::PlayDtmfTone, aTone = %s, volume = %d", |
|
159 &aTone, |
|
160 volume ); |
|
161 |
|
162 iDtmfTonePlayer->SetVolume( volume ); |
|
163 iDtmfTonePlayer->PlayDtmfTone( aTone ); |
|
164 } |
|
165 |
|
166 // ----------------------------------------------------------------------------- |
|
167 // CPEGsmAudioData::StopDtmfTonePlay |
|
168 // Stops the playing of dtmf tone. |
|
169 // (other items were commented in a header). |
|
170 // ----------------------------------------------------------------------------- |
|
171 // |
|
172 EXPORT_C void CPEGsmAudioData::StopDtmfTonePlay |
|
173 ( |
|
174 ) |
|
175 { |
|
176 TEFLOGSTRING( KTAREQIN, "AUD CPEGsmAudioData::StopDtmfTonePlay" ); |
|
177 iDtmfTonePlayer->Cancel(); |
|
178 } |
|
179 |
|
180 // ----------------------------------------------------------------------------- |
|
181 // CPEGsmAudioData::StopInbandTonePlay |
|
182 // Stops the playing of inband tone. |
|
183 // (other items were commented in a header). |
|
184 // ----------------------------------------------------------------------------- |
|
185 // |
|
186 EXPORT_C void CPEGsmAudioData::StopInbandTonePlay |
|
187 ( |
|
188 ) |
|
189 { |
|
190 TEFLOGSTRING( KTAREQIN, "AUD CPEGsmAudioData::StopInbandTonePlay" ); |
|
191 iInbandTonePlayer->Cancel(); |
|
192 } |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // CPEGsmAudioData::PlayInbandTone |
|
196 // Starts to play the given tone from inband player. |
|
197 // ----------------------------------------------------------------------------- |
|
198 // |
|
199 |
|
200 EXPORT_C void CPEGsmAudioData::PlayInbandTone() |
|
201 { |
|
202 TCCPTone tone = iPhoneModel.DataStore()->InbandTone(); |
|
203 |
|
204 TEFLOGSTRING2( KTAREQIN, |
|
205 "AUD CPEGsmAudioData::PlayInbandTone, tone = %d", |
|
206 tone ); |
|
207 iInbandTonePlayer->PlayInbandTone( tone ); |
|
208 } |
|
209 |
|
210 // ----------------------------------------------------------------------------- |
|
211 // CPEGsmAudioData::HandleDtmfEvent |
|
212 // From MCCEDtmfObserver. |
|
213 // All the occurred DTMF events are notified through this interface. |
|
214 // ----------------------------------------------------------------------------- |
|
215 // |
|
216 EXPORT_C void CPEGsmAudioData::HandleDTMFEvent( const MCCEDtmfObserver::TCCEDtmfEvent aEvent, |
|
217 const TInt aError, |
|
218 const TChar aTone ) |
|
219 { |
|
220 TEFLOGSTRING3( |
|
221 KTAMESIN, |
|
222 "AUD CPEGsmAudioData::HandleDtmfEvent: aEvent %d, aError %d", |
|
223 aEvent, |
|
224 aError ); |
|
225 |
|
226 if( aError == KErrNone ) |
|
227 { |
|
228 switch( aEvent ) |
|
229 { |
|
230 case ECCEDtmfManualStart: |
|
231 case ECCEDtmfSequenceStart: |
|
232 if ( DtmfLocalPlayAllowed() ) |
|
233 { |
|
234 TEFLOGSTRING( KTAINT, "AUD CPEGsmAudioData::HandleDTMFEvent: PlayDtmfTone" ); |
|
235 PlayDtmfTone( aTone ); |
|
236 } |
|
237 else |
|
238 { |
|
239 TEFLOGSTRING( KTAERROR, "AUD CPEGSMAUDIODATA::HANDLEDTMFEVENT ! LOCAL PLAY NOT ALLOWED" ); |
|
240 } |
|
241 |
|
242 break; |
|
243 |
|
244 case ECCEDtmfManualStop: |
|
245 case ECCEDtmfSequenceStop: |
|
246 case ECCEDtmfManualAbort: |
|
247 case ECCEDtmfSequenceAbort: |
|
248 case ECCEDtmfStopInDtmfString: |
|
249 case ECCEDtmfStringSendingCompleted: |
|
250 default: |
|
251 TEFLOGSTRING( KTAINT, "AUD CPEGsmAudioData::HandleDTMFEvent: StopDtmfTonePlay" ); |
|
252 //Stop tone playing |
|
253 StopDtmfTonePlay(); |
|
254 break; |
|
255 } |
|
256 } |
|
257 else |
|
258 { |
|
259 TEFLOGSTRING( KTAINT, "AUD CPEGsmAudioData::HandleDTMFEvent: Error case" ); |
|
260 //Stop tone playing |
|
261 StopDtmfTonePlay(); |
|
262 } |
|
263 } |
|
264 |
|
265 // ----------------------------------------------------------------------------- |
|
266 // CPEGsmAudioData::DtmfLocalPlayAllowed |
|
267 // Checks if a DTMF tone may be played locally |
|
268 // ----------------------------------------------------------------------------- |
|
269 // |
|
270 TBool CPEGsmAudioData::DtmfLocalPlayAllowed() const |
|
271 { |
|
272 TBool localPlayAllowed( ETrue ); |
|
273 |
|
274 // Check if dtmf string sending was requested by user |
|
275 if ( iPhoneModel.DataStore()->DtmfString() == KNullDesC ) |
|
276 { |
|
277 // No dtmf string was defined - assuming dtmf string sending was initiated |
|
278 // by third party. Proceed to check if a connected SAT originated call exists |
|
279 for( TInt callId = 0; callId < KPEMaximumNumberOfVoiceCalls; callId++ ) |
|
280 { |
|
281 if( iPhoneModel.DataStore()->CallOrigin( callId ) == EPECallOriginSAT |
|
282 && iPhoneModel.DataStore()->CallState( callId ) == EPEStateConnected ) |
|
283 { |
|
284 // SAT call is in connected state - prevent dtmf local play |
|
285 localPlayAllowed = EFalse; |
|
286 break; |
|
287 } |
|
288 } |
|
289 } |
|
290 |
|
291 return localPlayAllowed; |
|
292 } |
|
293 |
|
294 // ----------------------------------------------------------------------------- |
|
295 // CPEGsmAudioData::DoHandleVolumeChange |
|
296 // ----------------------------------------------------------------------------- |
|
297 // |
|
298 void CPEGsmAudioData::DoHandleVolumeChange( TInt aVolume ) |
|
299 |
|
300 { |
|
301 iInbandTonePlayer->SetVolume( aVolume ); |
|
302 } |
|
303 |
|
304 // ================= OTHER EXPORTED FUNCTIONS =============================== |
|
305 // None |
|
306 |
|
307 // End of File |