|
1 /* |
|
2 * Copyright (c) 2007-2009 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: Implementation of CVmSPSHandler class. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <spsettings.h> |
|
20 #include <spentry.h> |
|
21 #include <spproperty.h> |
|
22 #include <spnotifychange.h> |
|
23 #include <featmgr.h> |
|
24 #include "vmspshandler.h" |
|
25 #include "voicemailboxdefsinternal.h" |
|
26 |
|
27 #include "vmbxlogger.h" |
|
28 |
|
29 |
|
30 // CONSTANTS |
|
31 /** Maximum length of descriptor data */ |
|
32 const TInt KVmbxMaxDesLength = 512; |
|
33 |
|
34 |
|
35 // ============================ MEMBER FUNCTIONS ============================= |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // CVmSPSHandler::CVmSPSHandler |
|
39 // C++ default constructor can NOT contain any code, that might leave. |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 CVmSPSHandler::CVmSPSHandler() |
|
43 { |
|
44 } |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // CVmSPSHandler::ConstructL |
|
48 // Symbian 2nd phase constructor can leave. |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 void CVmSPSHandler::ConstructL() |
|
52 { |
|
53 VMBLOGSTRING( "VMBX: CVmSPSHandler::ConstructL =>" ); |
|
54 iSettings = CSPSettings::NewL(); |
|
55 iSpsSettingsVoipUtils = CSPSettingsVoIPUtils::NewL(); |
|
56 |
|
57 iNotifier = CSPNotifyChange::NewL( *this ); |
|
58 |
|
59 // Subscribe to service change notifies |
|
60 // Empty array so that new services will be notified also |
|
61 RIdArray array; |
|
62 CleanupClosePushL( array ); |
|
63 // Commented out because voip is not supported yet. |
|
64 //iNotifier->NotifyChangeL( iServiceIds ); |
|
65 iNotifier->NotifyChangeL( array ); |
|
66 CleanupStack::PopAndDestroy( &array ); |
|
67 VMBLOGSTRING( "VMBX: CVmSPSHandler::ConstructL <=" ); |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // CVmSPSHandler::NewL |
|
72 // Two-phased constructor. |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 CVmSPSHandler* CVmSPSHandler::NewL( ) |
|
76 { |
|
77 VMBLOGSTRING( "VMBX: CVmSPSHandler::NewL =>" ); |
|
78 CVmSPSHandler* self = CVmSPSHandler::NewLC(); |
|
79 CleanupStack::Pop( self ); |
|
80 VMBLOGSTRING( "VMBX: CVmSPSHandler::NewL <=" ); |
|
81 return self; |
|
82 } |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 // CVmSPSHandler::NewLC |
|
86 // Two-phased constructor. |
|
87 // --------------------------------------------------------------------------- |
|
88 // |
|
89 CVmSPSHandler* CVmSPSHandler::NewLC() |
|
90 { |
|
91 VMBLOGSTRING( "VMBX: CVmSPSHandler::NewLC =>" ); |
|
92 CVmSPSHandler* self = new (ELeave) CVmSPSHandler(); |
|
93 CleanupStack::PushL( self ); |
|
94 self->ConstructL(); |
|
95 VMBLOGSTRING( "VMBX: CVmSPSHandler::NewLC <=" ); |
|
96 return self; |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // CVmSPSHandler::~CVmSPSHandler |
|
101 // Destructor |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 CVmSPSHandler::~CVmSPSHandler() |
|
105 { |
|
106 VMBLOGSTRING( "VMBX: CVmSPSHandler::~CVmSPSHandler =>" ); |
|
107 iObserver = NULL; |
|
108 |
|
109 if ( iNotifier ) |
|
110 { |
|
111 iNotifier->Cancel(); |
|
112 delete iNotifier; |
|
113 } |
|
114 |
|
115 delete iSettings; |
|
116 |
|
117 delete iSpsSettingsVoipUtils; |
|
118 VMBLOGSTRING( "VMBX: CVmSPSHandler::~CVmSPSHandler <=" ); |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 // CVmSPSHandler::GetServiceIdsL |
|
123 // (other items were commented in a header). |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 void CVmSPSHandler::GetServiceIdsL( RArray<TUint>& aServiceIds ) const |
|
127 { |
|
128 VMBLOGSTRING( "VMBX: CVmSPSHandler::GetServiceIdsL =>" ); |
|
129 RArray<TUint> serviceIds; |
|
130 CleanupClosePushL( serviceIds ); |
|
131 // Get all service Ids and.. |
|
132 iSettings->FindServiceIdsL( serviceIds ); |
|
133 // ..remove service if VMBX is not defined or if VMBX address is empty |
|
134 for ( TInt i( 0 ); i < serviceIds.Count(); i++ ) |
|
135 { |
|
136 if ( IsVbmxSupportedL( serviceIds[ i ] ) ) |
|
137 { |
|
138 aServiceIds.Append( serviceIds[ i ] ); |
|
139 } |
|
140 } |
|
141 |
|
142 VMBLOGSTRING2( "VMBX: CVmSPSHandler::GetServiceIdsL: found %d \ |
|
143 Voip mailbox services", serviceIds.Count() ); |
|
144 |
|
145 CleanupStack::PopAndDestroy( &serviceIds ); |
|
146 VMBLOGSTRING( "VMBX: CVmSPSHandler::GetServiceIdsL <=" ); |
|
147 } |
|
148 |
|
149 // --------------------------------------------------------------------------- |
|
150 // CVmSPSHandler::IsVbmxSupportedL |
|
151 // (other items were commented in a header). |
|
152 // --------------------------------------------------------------------------- |
|
153 // |
|
154 TBool CVmSPSHandler::IsVbmxSupportedL( TUint32 aServiceId ) const |
|
155 { |
|
156 VMBLOGSTRING( "VMBX: CVmSPSHandler::IsVbmxSupportedL =>" ); |
|
157 TBool supported( EFalse ); |
|
158 // Get entry |
|
159 CSPEntry* entry = CSPEntry::NewLC(); |
|
160 iSettings->FindEntryL( aServiceId, *entry ); |
|
161 |
|
162 // Get all service properties a.k.a subservices |
|
163 RPropertyArray properties; |
|
164 properties = entry->GetAllProperties(); |
|
165 |
|
166 TServicePropertyName propertyName; |
|
167 |
|
168 for ( TInt i( 0 ); i < properties.Count() && !supported; i++ ) |
|
169 { |
|
170 propertyName = properties[ i ]->GetName(); |
|
171 |
|
172 supported = propertyName == EPropertyVMBXSubServicePluginId; |
|
173 |
|
174 if ( supported ) |
|
175 { |
|
176 TVmbxServiceInfo serviceInfo; |
|
177 TRAPD( found, GetVmAddressL( aServiceId, serviceInfo.iAddress ) ); |
|
178 |
|
179 supported = KErrNotFound != found; |
|
180 } |
|
181 } |
|
182 |
|
183 CleanupStack::PopAndDestroy( entry ); |
|
184 VMBLOGSTRING2( "VMBX: CVmSPSHandler::IsVbmxSupportedL: %d<=", supported ); |
|
185 return supported; |
|
186 } |
|
187 |
|
188 // --------------------------------------------------------------------------- |
|
189 // CVmSPSHandler::GetServiceInfo |
|
190 // (other items were commented in a header). |
|
191 // --------------------------------------------------------------------------- |
|
192 TInt CVmSPSHandler::GetServiceInfo( TVmbxServiceInfo& aServiceInfo ) const |
|
193 { |
|
194 VMBLOGSTRING( "VMBX: CVmSPSHandler::GetServiceInfo =>" ); |
|
195 TInt ret( KErrNone ); |
|
196 TRAP( ret, |
|
197 { |
|
198 GetServiceNameL( aServiceInfo.iServiceId, aServiceInfo.iName ); |
|
199 |
|
200 GetVmAddressL( aServiceInfo.iServiceId, aServiceInfo.iAddress ); |
|
201 |
|
202 TInt snap( 0 ); |
|
203 GetSNAPIdL( aServiceInfo.iServiceId, snap ); |
|
204 aServiceInfo.iSnapId = static_cast<TUint32> ( snap ); |
|
205 } ); |
|
206 |
|
207 VMBLOGSTRING( "VMBX: CVmSPSHandler::GetServiceInfo <=" ); |
|
208 return ret; |
|
209 } |
|
210 |
|
211 // --------------------------------------------------------------------------- |
|
212 // CVmSPSHandler::GetVmAddressL |
|
213 // (other items were commented in a header). |
|
214 // --------------------------------------------------------------------------- |
|
215 // |
|
216 void CVmSPSHandler::GetVmAddressL( const TUint32 aServiceId, |
|
217 TDes& aAddress ) const |
|
218 { |
|
219 VMBLOGSTRING( "VMBX: CVmSPSHandler::GetVmAddressL =>" ); |
|
220 RBuf buffer; |
|
221 CleanupClosePushL( buffer ); |
|
222 buffer.ReAllocL( KVmbxMaxDesLength ); |
|
223 |
|
224 CSPEntry* entry = CSPEntry::NewLC(); |
|
225 const CSPProperty* property = NULL; |
|
226 |
|
227 iSettings->FindEntryL( aServiceId, *entry ); |
|
228 |
|
229 // Find correct subservice |
|
230 TInt err = entry->GetProperty( property, ESubPropertyVMBXListenAddress ); |
|
231 VMBLOGSTRING2( "VMBX: CVmSPSHandler::GetVmAddressL: err%d", err ); |
|
232 User::LeaveIfError( err ); |
|
233 |
|
234 property->GetValue( buffer ); |
|
235 buffer.Length() > aAddress.MaxLength() ? |
|
236 User::Leave( KErrOverflow ) : aAddress.Copy( buffer ); |
|
237 |
|
238 CleanupStack::PopAndDestroy( entry ); |
|
239 CleanupStack::PopAndDestroy( &buffer ); |
|
240 |
|
241 VMBLOGSTRING( "VMBX: CVmSPSHandler::GetVmAddressL <=" ); |
|
242 } |
|
243 |
|
244 // --------------------------------------------------------------------------- |
|
245 // CVmSPSHandler::GetServiceNameL |
|
246 // (other items were commented in a header). |
|
247 // --------------------------------------------------------------------------- |
|
248 // |
|
249 void CVmSPSHandler::GetServiceNameL( const TUint32 aServiceId, |
|
250 TDes& aName ) const |
|
251 { |
|
252 VMBLOGSTRING( "VMBX: CVmSPSHandler::GetServiceNameL: =>" ); |
|
253 RBuf buffer; |
|
254 CleanupClosePushL( buffer ); |
|
255 buffer.ReAllocL( KVmbxMaxDesLength ); |
|
256 |
|
257 // Get entry |
|
258 CSPEntry* entry = CSPEntry::NewLC(); |
|
259 |
|
260 iSettings->FindEntryL( aServiceId, *entry ); |
|
261 VMBLOGSTRING( "VMBX: CVmSPSHandler::GetServiceNameL: 1" ); |
|
262 // Read service id and service name |
|
263 buffer.Copy( entry->GetServiceName() ); |
|
264 VMBLOGSTRING( "VMBX: CVmSPSHandler::GetServiceNameL: 2" ); |
|
265 buffer.Length() > aName.MaxLength() ? |
|
266 User::Leave( KErrOverflow ) : aName.Copy( buffer ); |
|
267 |
|
268 CleanupStack::PopAndDestroy( entry ); |
|
269 CleanupStack::PopAndDestroy( &buffer ); |
|
270 |
|
271 VMBLOGSTRING( "VMBX: CVmSPSHandler::GetServiceNameL: <=" ); |
|
272 } |
|
273 |
|
274 // --------------------------------------------------------------------------- |
|
275 // CVmSPSHandler::GetSNAPIdL |
|
276 // (other items were commented in a header). |
|
277 // --------------------------------------------------------------------------- |
|
278 // |
|
279 void CVmSPSHandler::GetSNAPIdL( TUint32 aServiceId, TInt& aSNAPId ) const |
|
280 { |
|
281 VMBLOGSTRING( "VMBX: CVmSPSHandler::GetSNAPIdL: =>" ); |
|
282 CSPEntry* entry = CSPEntry::NewLC(); |
|
283 const CSPProperty* property = NULL; |
|
284 iSettings->FindEntryL( aServiceId, *entry ); |
|
285 // Find correct subservice |
|
286 TInt error( |
|
287 entry->GetProperty( property, ESubPropertyVMBXPreferredSNAPId ) ); |
|
288 VMBLOGSTRING2( "VMBX: CVmSPSHandler::GetSNAPIdL: error%d", error ); |
|
289 |
|
290 if ( KErrNotFound != error ) |
|
291 { |
|
292 property->GetValue( aSNAPId ); |
|
293 } |
|
294 |
|
295 CleanupStack::PopAndDestroy( entry ); |
|
296 VMBLOGSTRING( "VMBX: CVmSPSHandler::GetSNAPIdL: <=" ); |
|
297 } |
|
298 |
|
299 // --------------------------------------------------------------------------- |
|
300 // CVmSPSHandler::BrandIdL |
|
301 // (other items were commented in a header). |
|
302 // --------------------------------------------------------------------------- |
|
303 // |
|
304 void CVmSPSHandler::BrandIdL( TInt aServiceId, TDes8& aBrandId ) |
|
305 { |
|
306 VMBLOGSTRING( "VMBX: CVmSPSHandler::BrandIdL: =>" ); |
|
307 CSPEntry* entry = CSPEntry::NewLC(); |
|
308 const CSPProperty* property = NULL;; |
|
309 TBuf<KSPMaxDesLength> brandId( KNullDesC ); |
|
310 |
|
311 TInt err = iSettings->FindEntryL( aServiceId, *entry ); |
|
312 VMBLOGSTRING2( "VMBX: CVmSPSHandler::BrandIdL: err%d", err ); |
|
313 User::LeaveIfError( err ); |
|
314 |
|
315 err = entry->GetProperty( property, EPropertyBrandId ); |
|
316 VMBLOGSTRING2( "VMBX: CVmSPSHandler::BrandIdL: err%d", err ); |
|
317 User::LeaveIfError( err ); |
|
318 |
|
319 if ( property ) |
|
320 { |
|
321 property->GetValue( brandId ); |
|
322 } |
|
323 |
|
324 if ( brandId.Length() ) |
|
325 { |
|
326 aBrandId.Copy( brandId ); |
|
327 } |
|
328 CleanupStack::PopAndDestroy( entry ); |
|
329 VMBLOGSTRING( "VMBX: CVmSPSHandler::BrandIdL: <=" ); |
|
330 } |
|
331 |
|
332 // --------------------------------------------------------------------------- |
|
333 // CVmSPSHandler::IsActivatedL |
|
334 // (other items were commented in a header). |
|
335 // --------------------------------------------------------------------------- |
|
336 // |
|
337 TBool CVmSPSHandler::IsActivatedL( TInt aServiceId ) |
|
338 { |
|
339 VMBLOGSTRING( "VMBX: CVmSPSHandler::IsActivatedL: =>" ); |
|
340 TBool enabled( EFalse ); |
|
341 CSPEntry* entry = CSPEntry::NewLC(); |
|
342 const CSPProperty* property = NULL; |
|
343 |
|
344 iSettings->FindEntryL( aServiceId, *entry ); |
|
345 |
|
346 // Find correct subservice |
|
347 TInt error( |
|
348 entry->GetProperty( property, ESubPropertyVMBXEnabled ) ); |
|
349 |
|
350 if ( KErrNotFound != error ) |
|
351 { |
|
352 TOnOff onOff( EOONotSet ); |
|
353 property->GetValue( onOff ); |
|
354 enabled = onOff == EOn; |
|
355 } |
|
356 |
|
357 CleanupStack::PopAndDestroy( entry ); |
|
358 |
|
359 VMBLOGSTRING2( "VMBX: CVmSPSHandler::IsActivatedL: %d", enabled ); |
|
360 VMBLOGSTRING( "VMBX: CVmSPSHandler::IsActivatedL: <=" ); |
|
361 return enabled; |
|
362 } |
|
363 |
|
364 // ---------------------------------------------------------------------------- |
|
365 // CVmSPSHandler::NotifyServiceChange |
|
366 // (other items were commented in a header). |
|
367 // ---------------------------------------------------------------------------- |
|
368 // |
|
369 void CVmSPSHandler::NotifyServiceChange( MServiceNotifyHandler* aHandler ) |
|
370 { |
|
371 VMBLOGSTRING( "VMBX: CVmSPSHandler::NotifyServiceChange: =>" ); |
|
372 iObserver = aHandler; |
|
373 VMBLOGSTRING( "VMBX: CVmSPSHandler::NotifyServiceChange: <=" ); |
|
374 } |
|
375 |
|
376 // ---------------------------------------------------------------------------- |
|
377 // CVmSPSHandler::NotifyServiceChangeCancel |
|
378 // (other items were commented in a header). |
|
379 // ---------------------------------------------------------------------------- |
|
380 // |
|
381 void CVmSPSHandler::NotifyServiceChangeCancel() |
|
382 { |
|
383 VMBLOGSTRING( "VMBX: CVmSPSHandler::NotifyServiceChangeCancel: =>" ); |
|
384 iObserver = NULL; |
|
385 VMBLOGSTRING( "VMBX: CVmSPSHandler::NotifyServiceChangeCancel: <=" ); |
|
386 } |
|
387 |
|
388 // --------------------------------------------------------------------------- |
|
389 // CVmSPSHandler::HandleNotifyChange |
|
390 // (other items were commented in a header). |
|
391 // --------------------------------------------------------------------------- |
|
392 // |
|
393 void CVmSPSHandler::HandleNotifyChange( TServiceId /*ServiceId*/ ) |
|
394 { |
|
395 VMBLOGSTRING( "VMBX: CVmSPSHandler::HandleNotifyChange: =>" ); |
|
396 if ( iObserver ) |
|
397 { |
|
398 TRAP_IGNORE( iObserver->HandleServiceNotifyL() ); |
|
399 } |
|
400 VMBLOGSTRING( "VMBX: CVmSPSHandler::HandleNotifyChange: <=" ); |
|
401 } |
|
402 |
|
403 // --------------------------------------------------------------------------- |
|
404 // CVmSPSHandler::HandleError |
|
405 // (other items were commented in a header). |
|
406 // --------------------------------------------------------------------------- |
|
407 // |
|
408 void CVmSPSHandler::HandleError( TInt aError ) |
|
409 { |
|
410 VMBLOGSTRING2( "VMBX: CVmSPSHandler::HandleError: aError %d", aError ); |
|
411 } |
|
412 |
|
413 // --------------------------------------------------------------------------- |
|
414 // CVmSPSHandler::IsVoIPProfilesFound |
|
415 // |
|
416 // --------------------------------------------------------------------------- |
|
417 // |
|
418 TBool CVmSPSHandler::IsVoIPProfilesFound() |
|
419 { |
|
420 VMBLOGSTRING( "VMBX: CVmSPSHandler::IsVoIPProfilesFound" ); |
|
421 TBool ret( EFalse ); |
|
422 if ( FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) ) |
|
423 { |
|
424 TRAP_IGNORE( ret = iSpsSettingsVoipUtils->VoIPProfilesExistL() ); |
|
425 } |
|
426 VMBLOGSTRING2( "VMBX: CVmSPSHandler::IsVoIPProfilesFound: return %I", ret ); |
|
427 return ret; |
|
428 } |
|
429 |
|
430 // End of File |