|
1 /* |
|
2 * Copyright (c) 2008 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: Sends and receives DTMF tones |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <cconvergedcallprovider.h> |
|
19 |
|
20 #include "cvccdtmfprovider.h" |
|
21 #include "cvccdirector.h" |
|
22 #include "rubydebug.h" |
|
23 |
|
24 // ======== MEMBER FUNCTIONS ======== |
|
25 |
|
26 // --------------------------------------------------------------------------- |
|
27 // Symbian constructor |
|
28 // --------------------------------------------------------------------------- |
|
29 // |
|
30 CVccDtmfProvider* CVccDtmfProvider::NewL( |
|
31 RPointerArray<CConvergedCallProvider>& /*aProviders*/, |
|
32 const MCCPDTMFObserver& aObserver, |
|
33 CVccDirector& aDirector ) |
|
34 { |
|
35 RUBY_DEBUG_BLOCK( "CVccDtmfProvider::NewL" ); |
|
36 CVccDtmfProvider* self; |
|
37 self = new( ELeave ) CVccDtmfProvider( aObserver, aDirector ); |
|
38 CleanupStack::PushL( self ); |
|
39 self->ConstructL(); |
|
40 CleanupStack::Pop( self ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // Destructor |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 CVccDtmfProvider::~CVccDtmfProvider() |
|
49 { |
|
50 iObservers.Close(); |
|
51 iProviders.Close(); |
|
52 } |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // CVccDtmfProvider::CVccDtmfProvider |
|
56 // C++ default constructor can NOT contain any code, that might leave. |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 CVccDtmfProvider::CVccDtmfProvider( const MCCPDTMFObserver& aObserver, |
|
60 CVccDirector& aDirector): |
|
61 iDirector( &aDirector ) |
|
62 { |
|
63 RUBY_DEBUG_BLOCK( "CVccDtmfProvider::CVccDtmfProvider" ); |
|
64 iObservers.InsertInAddressOrder( &aObserver ); |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // 2nd phase constructor |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 void CVccDtmfProvider::ConstructL() |
|
72 { |
|
73 RUBY_DEBUG_BLOCKL( "CVccDtmfProvider::ConstructL" ); |
|
74 } |
|
75 |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // @ see MCCPDTMFObserver::HandleDTMFEvent |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 void CVccDtmfProvider::HandleDTMFEvent( const MCCPDTMFObserver::TCCPDtmfEvent aEvent, |
|
82 const TInt aError, |
|
83 const TChar aTone ) const |
|
84 { |
|
85 RUBY_DEBUG_BLOCK( "CVccDtmfProvider::HandleDTMFEvent" ); |
|
86 RUBY_DEBUG1( "CVccDtmfProvider::HandleDTMFEvent -- obs count: %d", |
|
87 iObservers.Count() ); |
|
88 for ( TInt i = 0; i < iObservers.Count(); i++ ) |
|
89 { |
|
90 iObservers[i]->HandleDTMFEvent( aEvent, aError, aTone ); |
|
91 } |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------------------------- |
|
95 // @see MCCPDTMFProvider::CancelDtmfStringSending |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 TInt CVccDtmfProvider::CancelDtmfStringSending() |
|
99 { |
|
100 RUBY_DEBUG_BLOCK( "CVccDtmfProvider::CancelDtmfStringSending" ); |
|
101 RUBY_DEBUG1( "-- call type = %d (0 = cs, 4 = ps)", |
|
102 iDirector->CurrentCallTypeForDTMF() ); |
|
103 TInt err( KErrNotSupported ); |
|
104 |
|
105 CConvergedCallProvider* prov = iDirector->GetProvider(); |
|
106 if( prov ) |
|
107 { |
|
108 MCCPDTMFProvider* dtmf = NULL; |
|
109 TRAPD( err1, dtmf = prov->DTMFProviderL( *this ) ); |
|
110 if( err1 == KErrNone ) |
|
111 { |
|
112 err = dtmf->CancelDtmfStringSending(); |
|
113 } |
|
114 else |
|
115 { |
|
116 err = err1; |
|
117 } |
|
118 |
|
119 } |
|
120 |
|
121 RUBY_DEBUG1( "err = %d ", err ); |
|
122 |
|
123 return err; |
|
124 } |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // @see MCCPDTMFProvider::StartDtmfTone |
|
128 // --------------------------------------------------------------------------- |
|
129 // |
|
130 TInt CVccDtmfProvider::StartDtmfTone( const TChar aTone ) |
|
131 { |
|
132 RUBY_DEBUG_BLOCK( "CVccDtmfProvider::StartDtmfTone" ); |
|
133 RUBY_DEBUG1( "-- call type = %d (0 = cs, 4 = ps)", |
|
134 iDirector->CurrentCallTypeForDTMF() ); |
|
135 TInt err( KErrNotSupported ); |
|
136 |
|
137 CConvergedCallProvider* prov = iDirector->GetProvider(); |
|
138 if( prov ) |
|
139 { |
|
140 MCCPDTMFProvider* dtmf = NULL; |
|
141 TRAPD( err1, dtmf = prov->DTMFProviderL( *this ) ); |
|
142 if( err1 == KErrNone ) |
|
143 { |
|
144 err = dtmf->StartDtmfTone( aTone ); |
|
145 } |
|
146 else |
|
147 { |
|
148 err = err1; |
|
149 } |
|
150 } |
|
151 return err; |
|
152 } |
|
153 |
|
154 // --------------------------------------------------------------------------- |
|
155 // @see MCCPDTMFProvider::StopDtmfTone |
|
156 // --------------------------------------------------------------------------- |
|
157 // |
|
158 TInt CVccDtmfProvider::StopDtmfTone() |
|
159 { |
|
160 RUBY_DEBUG_BLOCK( "CVccDtmfProvider::StopDtmfTone" ); |
|
161 RUBY_DEBUG1( "-- call type = %d (0 = cs, 4 = ps)", |
|
162 iDirector->CurrentCallTypeForDTMF() ); |
|
163 TInt err( KErrNotSupported ); |
|
164 CConvergedCallProvider* prov = iDirector->GetProvider(); |
|
165 if( prov ) |
|
166 { |
|
167 MCCPDTMFProvider* dtmf = NULL; |
|
168 TRAPD( err1, dtmf = prov->DTMFProviderL( *this ) ); |
|
169 if( err1 == KErrNone ) |
|
170 { |
|
171 err = dtmf->StopDtmfTone(); |
|
172 } |
|
173 else |
|
174 { |
|
175 err = err1; |
|
176 } |
|
177 } |
|
178 return err; |
|
179 } |
|
180 |
|
181 // --------------------------------------------------------------------------- |
|
182 // @see MCCPDTMFProvider::SendDtmfToneString |
|
183 // --------------------------------------------------------------------------- |
|
184 // |
|
185 TInt CVccDtmfProvider::SendDtmfToneString( const TDesC& aString ) |
|
186 { |
|
187 RUBY_DEBUG_BLOCK( "CVccDtmfProvider::SendDtmfToneString" ); |
|
188 RUBY_DEBUG1( "-- call type = %d (0 = cs, 4 = ps)", |
|
189 iDirector->CurrentCallTypeForDTMF() ); |
|
190 TInt err( KErrNotSupported ); |
|
191 |
|
192 CConvergedCallProvider* prov = iDirector->GetProvider(); |
|
193 if( prov ) |
|
194 { |
|
195 MCCPDTMFProvider* dtmf = NULL; |
|
196 TRAPD( err1, dtmf = prov->DTMFProviderL( *this ) ); |
|
197 if( err1 == KErrNone ) |
|
198 { |
|
199 err = dtmf->SendDtmfToneString( aString ); |
|
200 } |
|
201 else |
|
202 { |
|
203 err = err1; |
|
204 } |
|
205 } |
|
206 RUBY_DEBUG1( "err = %d ", err ); |
|
207 |
|
208 return err; |
|
209 } |
|
210 |
|
211 // --------------------------------------------------------------------------- |
|
212 // @see MCCPDTMFProvider::ContinueDtmfStringSending |
|
213 // --------------------------------------------------------------------------- |
|
214 // |
|
215 TInt CVccDtmfProvider::ContinueDtmfStringSending( const TBool aContinue ) |
|
216 { |
|
217 RUBY_DEBUG_BLOCK( "CVccDtmfProvider::ContinueDtmfStringSending" ); |
|
218 RUBY_DEBUG1( "-- call type = %d (0 = cs, 4 = ps)", |
|
219 iDirector->CurrentCallTypeForDTMF() ); |
|
220 TInt err ( KErrNotSupported ); |
|
221 |
|
222 CConvergedCallProvider* prov = iDirector->GetProvider(); |
|
223 if( prov ) |
|
224 { |
|
225 MCCPDTMFProvider* dtmf = NULL; |
|
226 TRAPD( err1, dtmf = prov->DTMFProviderL( *this ) ); |
|
227 if( err1 == KErrNone ) |
|
228 { |
|
229 err = dtmf->ContinueDtmfStringSending( aContinue ); |
|
230 } |
|
231 else |
|
232 { |
|
233 err = err1; |
|
234 } |
|
235 } |
|
236 return err; |
|
237 } |
|
238 |
|
239 // --------------------------------------------------------------------------- |
|
240 // @see MCCPDTMFProvider::AddObserverL |
|
241 // --------------------------------------------------------------------------- |
|
242 // |
|
243 void CVccDtmfProvider::AddObserverL( const MCCPDTMFObserver& aObserver ) |
|
244 { |
|
245 RUBY_DEBUG_BLOCK( "CVccDtmfProvider::AddObserverL" ); |
|
246 iObservers.InsertInAddressOrderL( &aObserver ); |
|
247 } |
|
248 |
|
249 // --------------------------------------------------------------------------- |
|
250 // @see MCCPDTMFProvider::RemoveObserver |
|
251 // --------------------------------------------------------------------------- |
|
252 // |
|
253 TInt CVccDtmfProvider::RemoveObserver( const MCCPDTMFObserver& aObserver ) |
|
254 { |
|
255 RUBY_DEBUG_BLOCK( "CVccDtmfProvider::RemoveObserver" ); |
|
256 TInt res = iObservers.Find( &aObserver ); |
|
257 if ( res != KErrNotFound ) |
|
258 { |
|
259 iObservers.Remove( res ); |
|
260 res = KErrNone; |
|
261 } |
|
262 return res; |
|
263 } |