|
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: Contains service settings handling logic |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "cccespsettingshandler.h" |
|
19 #include "cccepluginmanager.h" |
|
20 #include "mccespsobserver.h" |
|
21 #include "cccelogger.h" |
|
22 #include "cccecallcontainer.h" |
|
23 |
|
24 #include <spsettingsvoiputils.h> |
|
25 #include <spsettings.h> |
|
26 #include <spentry.h> |
|
27 #include <spproperty.h> |
|
28 #include <spnotifychange.h> |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CCCESPSettingsHandler |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 CCCESPSettingsHandler::CCCESPSettingsHandler( MCCESPSObserver& aObserver ) : |
|
35 iObserver( aObserver ) |
|
36 { |
|
37 } |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // ~CCCESPSettingsHandler |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 CCCESPSettingsHandler::~CCCESPSettingsHandler() |
|
44 { |
|
45 delete iSettings; |
|
46 delete iNotifier; |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // NewL |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 CCCESPSettingsHandler* CCCESPSettingsHandler::NewL( MCCESPSObserver& aObserver ) |
|
54 { |
|
55 CCCESPSettingsHandler* self = new (ELeave) CCCESPSettingsHandler( aObserver ); |
|
56 CleanupStack::PushL( self ); |
|
57 self->ConstructL(); |
|
58 CleanupStack::Pop( self ); |
|
59 return self; |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // ConstructL |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 void CCCESPSettingsHandler::ConstructL() |
|
67 { |
|
68 iNotifier = CSPNotifyChange::NewL( *this ); |
|
69 iSettings = CSPSettings::NewL(); |
|
70 StartListeningChangesL(); |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // IsPluginSupportedL |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 void CCCESPSettingsHandler::IsPluginSupportedL( TUid aImplementationUid ) |
|
78 { |
|
79 if( aImplementationUid != KCSProviderUid ) |
|
80 { |
|
81 CSPSettingsVoIPUtils *utils = CSPSettingsVoIPUtils::NewLC(); |
|
82 if( !utils->IsVoIPSupported() ) |
|
83 { |
|
84 CCELOGSTRING( "CCCESPSettingsHandler::IsPluginSupportedL : False" ); |
|
85 User::Leave( KErrNotSupported ); |
|
86 } |
|
87 |
|
88 CleanupStack::PopAndDestroy( utils ); |
|
89 } |
|
90 |
|
91 CCELOGSTRING( "CCCESPSettingsHandler::IsPluginSupportedL : True" ); |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // GetServicesL |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 void CCCESPSettingsHandler::GetServicesL( RIdArray& aServices ) |
|
99 { |
|
100 iSettings->FindServiceIdsL( aServices ); |
|
101 } |
|
102 |
|
103 // ----------------------------------------------------------------------------- |
|
104 // ImplementationUidL |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 TUid CCCESPSettingsHandler::ImplementationUidL( TInt aServiceId ) |
|
108 { |
|
109 CSPProperty* property = CSPProperty::NewLC(); |
|
110 |
|
111 iSettings->FindPropertyL( aServiceId, |
|
112 EPropertyCallProviderPluginId, *property ); |
|
113 |
|
114 TInt pluginId; |
|
115 property->GetValue( pluginId ); |
|
116 |
|
117 TUid id(KNullUid); |
|
118 id.iUid = pluginId; |
|
119 |
|
120 CleanupStack::PopAndDestroy( property ); |
|
121 |
|
122 return id; |
|
123 } |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // CapablitiesL |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 TPropertyServiceAttributes CCCESPSettingsHandler::CapabilitiesL( TInt aServiceId ) |
|
130 { |
|
131 CSPProperty* property = CSPProperty::NewLC(); |
|
132 |
|
133 iSettings->FindPropertyL( aServiceId, |
|
134 EPropertyServiceAttributeMask, *property ); |
|
135 |
|
136 TInt mask( 0 ); |
|
137 property->GetValue( mask ); |
|
138 |
|
139 CleanupStack::PopAndDestroy( property ); |
|
140 |
|
141 return (TPropertyServiceAttributes)mask; |
|
142 } |
|
143 |
|
144 // ----------------------------------------------------------------------------- |
|
145 // IsEnabledL |
|
146 // ----------------------------------------------------------------------------- |
|
147 // |
|
148 TBool CCCESPSettingsHandler::IsEnabledL( TInt aServiceId ) |
|
149 { |
|
150 CSPProperty* property = CSPProperty::NewLC(); |
|
151 |
|
152 iSettings->FindPropertyL( aServiceId, |
|
153 ESubPropertyVoIPEnabled, *property ); |
|
154 |
|
155 TBool enabled( 0 ); |
|
156 property->GetValue( enabled ); |
|
157 |
|
158 CleanupStack::PopAndDestroy( property ); |
|
159 |
|
160 return enabled; |
|
161 } |
|
162 |
|
163 // ----------------------------------------------------------------------------- |
|
164 // HandleNotifyChange |
|
165 // ----------------------------------------------------------------------------- |
|
166 // |
|
167 void CCCESPSettingsHandler::HandleNotifyChange( TServiceId aServiceId ) |
|
168 { |
|
169 CCELOGSTRING( "CCCESPSettingsHandler::HandleNotifyChange" ); |
|
170 #ifdef _DEBUG |
|
171 TInt err = KErrNone; |
|
172 TRAP( err, HandleServiceChangeL( aServiceId ) ) |
|
173 CCELOGSTRING2( "CCCESPSettingsHandler::HandleNotifyChange err=%i", err ); |
|
174 #else |
|
175 TRAP_IGNORE( HandleServiceChangeL( aServiceId ) ); |
|
176 #endif |
|
177 } |
|
178 |
|
179 // ----------------------------------------------------------------------------- |
|
180 // HandleError |
|
181 // ----------------------------------------------------------------------------- |
|
182 // |
|
183 void CCCESPSettingsHandler::HandleError( TInt /*aError*/ ) |
|
184 { |
|
185 |
|
186 } |
|
187 |
|
188 // ----------------------------------------------------------------------------- |
|
189 // HandleServiceChangeL |
|
190 // ----------------------------------------------------------------------------- |
|
191 // |
|
192 void CCCESPSettingsHandler::HandleServiceChangeL( TInt aServiceId ) |
|
193 { |
|
194 TUid uid = ImplementationUidL( aServiceId ); |
|
195 |
|
196 if ( IsPluginOnStandbyL( uid ) ) |
|
197 { |
|
198 CCELOGSTRING2( |
|
199 "CCCESPSettingsHandler:: Load call provider plugin uid: 0x%X", |
|
200 uid.iUid ); |
|
201 iObserver.ServiceEnabledL( uid ); |
|
202 } |
|
203 else |
|
204 { |
|
205 CCELOGSTRING2( |
|
206 "CCCESPSettingsHandler:: Unload call provider plugin uid: 0x%X", |
|
207 uid.iUid ); |
|
208 iObserver.ServiceDisabledL( uid ); |
|
209 } |
|
210 } |
|
211 |
|
212 // ----------------------------------------------------------------------------- |
|
213 // StartListeningChangesL |
|
214 // ----------------------------------------------------------------------------- |
|
215 // |
|
216 void CCCESPSettingsHandler::StartListeningChangesL() |
|
217 { |
|
218 RIdArray array; |
|
219 CleanupClosePushL( array ); |
|
220 // Array is empty because, also new added services are needed to be notified |
|
221 iNotifier->NotifyChangeL( array ); |
|
222 CleanupStack::PopAndDestroy( &array ); |
|
223 } |
|
224 |
|
225 // ----------------------------------------------------------------------------- |
|
226 // IsPluginOnStandbyL |
|
227 // ----------------------------------------------------------------------------- |
|
228 // |
|
229 TBool CCCESPSettingsHandler::IsPluginOnStandbyL( TUid aImplementationUid ) |
|
230 { |
|
231 CCELOGSTRING( "CCCESPSettingsHandler:: IsPluginOnStandbyL." ); |
|
232 TBool ret( EFalse ); |
|
233 |
|
234 RIdArray idArray; |
|
235 CleanupClosePushL( idArray ); |
|
236 |
|
237 // Create property array |
|
238 RPropertyArray* propertyArray = new (ELeave) RPropertyArray( 1 ); |
|
239 TCleanupItem cleanup( CCCESPSettingsHandler::CleanupPointerArray, propertyArray ); |
|
240 CleanupStack::PushL( cleanup ); |
|
241 |
|
242 // call provider property |
|
243 CSPProperty* callProviderPluginId = CSPProperty::NewLC(); |
|
244 callProviderPluginId->SetName( EPropertyCallProviderPluginId ); |
|
245 callProviderPluginId->SetValue( aImplementationUid.iUid ); |
|
246 propertyArray->AppendL( callProviderPluginId ); |
|
247 CleanupStack::Pop( callProviderPluginId ); |
|
248 |
|
249 // Get service's |
|
250 User::LeaveIfError( iSettings-> |
|
251 FindServiceIdsFromPropertiesL( *propertyArray, idArray ) ); |
|
252 |
|
253 |
|
254 TInt count = idArray.Count(); |
|
255 for ( TInt index( 0 ); index < count && !ret; index++ ) |
|
256 { |
|
257 TInt tmpServiceId = idArray[ index ]; |
|
258 // ETrue if VoIP atribute is enabled or Bootstrap is enabled |
|
259 ret = ( IsEnabledL( tmpServiceId ) || |
|
260 ( CapabilitiesL( tmpServiceId ) & EBootstrapCallProvider ) ); |
|
261 } |
|
262 CleanupStack::PopAndDestroy( propertyArray ); |
|
263 CleanupStack::PopAndDestroy( &idArray ); |
|
264 CCELOGSTRING2( "CCCESPSettingsHandler:: ret %i ", ret ); |
|
265 //note: Lint doesn't understand the use of PopAndDestroy and thinks |
|
266 //that there is a memory leak for propertyArray, we disable that warning with |
|
267 //the following command |
|
268 //lint -e429 |
|
269 |
|
270 return ret; |
|
271 } |
|
272 //lint +e429 |
|
273 |
|
274 // ----------------------------------------------------------------------------- |
|
275 // CleanupPointerArray |
|
276 // ----------------------------------------------------------------------------- |
|
277 // |
|
278 void CCCESPSettingsHandler::CleanupPointerArray( TAny* aPointer ) |
|
279 { |
|
280 CCELOGSTRING( "CCCESPSettingsHandler:: CleanupPointerArray." ); |
|
281 RPropertyArray* array = static_cast< RPropertyArray* >( aPointer ); |
|
282 array->ResetAndDestroy(); |
|
283 array->Close(); |
|
284 delete array; |
|
285 } |
|
286 |
|
287 // end of file |