|
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: Voip handler. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32property.h> |
|
20 #include <NetworkHandlingDomainPSKeys.h> |
|
21 #include <spdefinitions.h> |
|
22 #include "scpvoiphandler.h" |
|
23 #include "scpprofilehandler.h" |
|
24 #include "scplogger.h" |
|
25 #include "scpsubservice.h" |
|
26 #include "scpservicestorage.h" |
|
27 #include "scpsettinghandler.h" |
|
28 #include "scpsipconnection.h" |
|
29 #include "scputility.h" |
|
30 #include "scppropertynotifier.h" |
|
31 #include "csipclientresolverutils.h" |
|
32 |
|
33 // : These need to be in some common header |
|
34 const TUid KResolver = { 0x10283140 }; |
|
35 |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CScpVoipHandler::CCScpVoipHandler |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CScpVoipHandler::CScpVoipHandler( CScpSubService& aSubService ) : |
|
42 CScpServiceHandlerBase( aSubService ) |
|
43 { |
|
44 SCPLOGSTRING2( "CScpVoipHandler[0x%x]::CScpVoipHandler", this ); |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CScpVoipHandler::ConstructL |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 void CScpVoipHandler::ConstructL() |
|
52 { |
|
53 SCPLOGSTRING2( "CScpVoipHandler[0x%x]::ConstructL", this ); |
|
54 |
|
55 BaseConstructL(); |
|
56 iNetworkMode = CScpPropertyNotifier::NewL( KPSUidNetworkInfo, |
|
57 KNWTelephonyNetworkMode, *this ) ; |
|
58 iSipClientResolver = CSipClientResolverUtils::NewL(); |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CScpVoipHandler::NewL |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 CScpVoipHandler* CScpVoipHandler::NewL( CScpSubService& aSubService ) |
|
66 { |
|
67 SCPLOGSTRING( "CScpVoipHandler::NewL" ); |
|
68 |
|
69 CScpVoipHandler* self = new(ELeave) CScpVoipHandler( aSubService ); |
|
70 CleanupStack::PushL( self ); |
|
71 self->ConstructL(); |
|
72 CleanupStack::Pop( self ); |
|
73 |
|
74 return self; |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CScpVoipHandler::~CScpVoipHandler |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 CScpVoipHandler::~CScpVoipHandler() |
|
82 { |
|
83 SCPLOGSTRING2( "CScpVoipHandler[0x%x]::~CScpVoipHandler", this ); |
|
84 delete iSipClientResolver; |
|
85 delete iNetworkMode; |
|
86 } |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // CScpVoipHandler::HandlePropertyChanged |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 void CScpVoipHandler::HandlePropertyChanged( TInt /* aPropertyValue */) |
|
93 { |
|
94 CScpSipConnection::TConnectionState sipState = CScpSipConnection::EUnknown; |
|
95 TInt sipError = KErrNotFound; |
|
96 CScpSipConnection* sipConnection = |
|
97 iSubService.ProfileHandler().GetSipConnection( |
|
98 iSubService.SipProfileId() ); |
|
99 if ( sipConnection ) |
|
100 { |
|
101 sipConnection->GetState( sipState, sipError ); |
|
102 } |
|
103 if ( ECCHEnabled == iSubService.State() && |
|
104 KErrNone == sipError && CScpSipConnection::ERegistered == sipState ) |
|
105 { |
|
106 HandleSipConnectionEvent( iSubService.SipProfileId(), EScpRegistered ); |
|
107 } |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // CScpVoipHandler::EnableSubServiceL |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 void CScpVoipHandler::EnableSubServiceL() |
|
115 { |
|
116 SCPLOGSTRING4( "CScpVoipHandler[0x%x]::EnableSubServiceL: 0x%x type: %i", |
|
117 this, &iSubService, iSubService.SubServiceType() ); |
|
118 __ASSERT_DEBUG( iSubService.SubServiceType() == ECCHVoIPSub, |
|
119 User::Panic( KNullDesC, KErrGeneral ) ); |
|
120 |
|
121 CScpServiceHandlerBase::RegisterProfileL(); |
|
122 } |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // CScpVoipHandler::DisableSubService |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 TInt CScpVoipHandler::DisableSubService() |
|
129 { |
|
130 SCPLOGSTRING4( "CScpVoipHandler[0x%x]::DisableSubService: 0x%x type: %i", |
|
131 this, &iSubService, iSubService.SubServiceType() ); |
|
132 __ASSERT_DEBUG( iSubService.SubServiceType() == ECCHVoIPSub, |
|
133 User::Panic( KNullDesC, KErrGeneral ) ); |
|
134 |
|
135 TInt result = KErrNone; |
|
136 |
|
137 TCCHSubserviceState subServiceState = iSubService.State(); |
|
138 |
|
139 if( subServiceState != ECCHDisabled ) |
|
140 { |
|
141 TRAP( result, DeregisterContactHeaderL() ) |
|
142 |
|
143 DeregisterProfile(); |
|
144 } |
|
145 else |
|
146 { |
|
147 result = KErrNotSupported; |
|
148 } |
|
149 |
|
150 return result; |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CScpVoipHandler::DeregisterContactHeaderL |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 void CScpVoipHandler::DeregisterContactHeaderL() |
|
158 { |
|
159 SCPLOGSTRING2( "CScpVoipHandler[0x%x]::DeregisterContactHeaderL", this ); |
|
160 |
|
161 RBuf8 contactHeaderUser; |
|
162 contactHeaderUser.CleanupClosePushL(); |
|
163 |
|
164 GetSipProfileContactHeaderUserL( contactHeaderUser ); |
|
165 |
|
166 iSipClientResolver->UnRegisterClientWithUserL( |
|
167 GetCallProviderImplementationUidL(), contactHeaderUser ); |
|
168 |
|
169 CleanupStack::PopAndDestroy( &contactHeaderUser ); |
|
170 } |
|
171 |
|
172 // ----------------------------------------------------------------------------- |
|
173 // CScpVoipHandler::SubServiceType |
|
174 // ----------------------------------------------------------------------------- |
|
175 // |
|
176 TCCHSubserviceType CScpVoipHandler::SubServiceType() const |
|
177 { |
|
178 SCPLOGSTRING2( "CScpVoipHandler[0x%x]::SubServiceType", this ); |
|
179 |
|
180 return ECCHVoIPSub; |
|
181 } |
|
182 |
|
183 |
|
184 // ----------------------------------------------------------------------------- |
|
185 // CScpVoipHandler::HandleSipConnectionEvent |
|
186 // ----------------------------------------------------------------------------- |
|
187 // |
|
188 void CScpVoipHandler::HandleSipConnectionEvent( TUint32 aProfileId, |
|
189 TScpConnectionEvent aEvent ) |
|
190 { |
|
191 TRAP_IGNORE( HandleSipConnectionEventL( aProfileId,aEvent )); |
|
192 } |
|
193 // ----------------------------------------------------------------------------- |
|
194 // CScpVoipHandler::HandleSipConnectionEvent |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 void CScpVoipHandler::HandleSipConnectionEventL( TUint32 aProfileId, |
|
198 TScpConnectionEvent aEvent ) |
|
199 { |
|
200 SCPLOGSTRING4( "CScpVoipHandler[0x%x]::HandleSipConnectionEvent id: %d event: %d", |
|
201 this, aProfileId, aEvent ); |
|
202 |
|
203 if( iSubService.SipProfileId() == aProfileId && |
|
204 iSubService.EnableRequestedState() != CScpSubService::EScpNoRequest ) |
|
205 { |
|
206 // When in 2G mode with GPRS iap we are enabled but can't |
|
207 // create or receive any VoIP calls |
|
208 if( aEvent == EScpRegistered && |
|
209 iSubService.EnableRequestedState() == CScpSubService::EScpEnabled ) |
|
210 { |
|
211 RBuf8 contactHeaderUser; |
|
212 contactHeaderUser.CleanupClosePushL(); |
|
213 GetSipProfileContactHeaderUserL( contactHeaderUser ); |
|
214 |
|
215 HBufC* string = HBufC::NewLC(contactHeaderUser.Length()); |
|
216 string->Des().Copy(contactHeaderUser); |
|
217 |
|
218 SCPLOGSTRING2( "CScpVoipHandler::HandleSipConnectionEventL(), contactHeaderUser %S", string ); |
|
219 |
|
220 CleanupStack::PopAndDestroy(string); |
|
221 |
|
222 TInt networkMode = KErrNotFound; |
|
223 TInt result = iNetworkMode->GetValue( networkMode ); |
|
224 |
|
225 if( result == KErrNone && |
|
226 networkMode == ENWNetworkModeGsm && |
|
227 iSubService.GetIapType() == EScpGprs ) |
|
228 { |
|
229 aEvent = EScpBandwidthLimited; |
|
230 iSipClientResolver->UnRegisterClientWithUserL( |
|
231 GetCallProviderImplementationUidL(), contactHeaderUser ); |
|
232 } |
|
233 else if ( KErrNone == result && |
|
234 EScpGprs == iSubService.GetIapType() && |
|
235 !iSubService.ServiceStorage().SettingsHandler().IsVoIPOverWcdmaAllowedL( iSubService.SubServiceId() ) ) |
|
236 { |
|
237 aEvent = EScpBearerNotSupported; |
|
238 SCPLOGSTRING( "CScpVoipHandler::HandleSipConnectionEventL(), VoIP over 3G not allowed" ); |
|
239 iSipClientResolver->UnRegisterClientWithUserL( |
|
240 GetCallProviderImplementationUidL(), contactHeaderUser ); |
|
241 } |
|
242 else |
|
243 { |
|
244 iSipClientResolver->RegisterClientWithUserL( |
|
245 GetCallProviderImplementationUidL(), contactHeaderUser, KResolver ); |
|
246 SCPLOGSTRING( "CScpVoipHandler::HandleSipConnectionEventL(), client resolver" ); |
|
247 } |
|
248 |
|
249 CleanupStack::PopAndDestroy( &contactHeaderUser ); |
|
250 } |
|
251 |
|
252 iSubService.HandleConnectionEvent( aEvent ); |
|
253 } |
|
254 } |
|
255 |
|
256 // ----------------------------------------------------------------------------- |
|
257 // CScpVoipHandler::GetSipProfileContactHeaderL |
|
258 // ----------------------------------------------------------------------------- |
|
259 // |
|
260 void CScpVoipHandler::GetSipProfileContactHeaderUserL( |
|
261 RBuf8& aContactHeaderUser ) const |
|
262 { |
|
263 SCPLOGSTRING2( "CScpVoipHandler[0x%x]::GetSipProfileContactHeaderL", this ); |
|
264 |
|
265 TUint32 sipProfileId = iSubService.SipProfileId(); |
|
266 |
|
267 CScpProfileHandler& profileHandler = iSubService.ProfileHandler(); |
|
268 CScpSipConnection* sipConnection = |
|
269 profileHandler.CreateSipConnectionL( sipProfileId ); |
|
270 CleanupStack::PushL( sipConnection ); |
|
271 |
|
272 if( sipConnection ) |
|
273 { |
|
274 User::LeaveIfError( sipConnection->GetContactHeaderUser( aContactHeaderUser ) ); |
|
275 __ASSERT_DEBUG( aContactHeaderUser.Length() > 0, |
|
276 User::Panic( KNullDesC, KErrGeneral ) ); |
|
277 } |
|
278 else |
|
279 { |
|
280 User::Leave( KErrNotFound ); |
|
281 } |
|
282 |
|
283 CleanupStack::PopAndDestroy( sipConnection ); |
|
284 } |
|
285 |
|
286 // ----------------------------------------------------------------------------- |
|
287 // CScpVoipHandler::CallProviderImplementationUid |
|
288 // ----------------------------------------------------------------------------- |
|
289 // |
|
290 TUid CScpVoipHandler::GetCallProviderImplementationUidL() |
|
291 { |
|
292 SCPLOGSTRING2( "CScpVoipHandler[0x%x]::GetCallProviderImplementationUidL", this ); |
|
293 |
|
294 CScpServiceStorage& serviceStorage = iSubService.ServiceStorage(); |
|
295 CScpSettingHandler& settingHandler = serviceStorage.SettingsHandler(); |
|
296 |
|
297 TInt impUid = 0; |
|
298 settingHandler.GetSPSettingsIntPropertyL( iSubService.SubServiceId(), |
|
299 EPropertyCallProviderPluginId, |
|
300 impUid ); |
|
301 |
|
302 TUid implementationUid; |
|
303 implementationUid.iUid = impUid; |
|
304 |
|
305 return implementationUid; |
|
306 } |
|
307 |
|
308 // End of File |