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