1 /* |
1 /* |
2 * Copyright (c) 2000-2007 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2000-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
13 * |
13 * |
14 * Description: Policy store |
14 * Description: Policy store |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
|
19 |
|
20 #include <e32math.h> |
18 #include <e32math.h> |
21 #include <cmconnectionmethod.h> |
19 #include <cmconnectionmethod.h> |
22 #include <cmpluginvpndef.h> // vpn plugin |
20 #include <cmpluginvpndef.h> // vpn plugin |
|
21 #include <centralrepository.h> |
|
22 #include <browseruisdkcrkeys.h> |
23 #include "policystore.h" |
23 #include "policystore.h" |
24 #include "pinparser.h" |
24 #include "pinparser.h" |
25 #include "ikepolparser.h" |
25 #include "ikepolparser.h" |
26 #include "pkiserviceapi.h" |
26 #include "pkiserviceapi.h" |
27 #include "policyimporter.h" |
27 #include "policyimporter.h" |
186 if (iFileUtil.FileExists(*polFile)) |
186 if (iFileUtil.FileExists(*polFile)) |
187 { |
187 { |
188 iFileUtil.DeleteFileL(*polFile); |
188 iFileUtil.DeleteFileL(*polFile); |
189 } |
189 } |
190 CleanupStack::PopAndDestroy(2); // polFile, pinFile |
190 CleanupStack::PopAndDestroy(2); // polFile, pinFile |
|
191 |
|
192 // Policy was deleted successfully. |
|
193 TUint policyCount = PolicyCount(); |
|
194 |
|
195 if ( policyCount == 0 ) |
|
196 { |
|
197 CRepository* repository = CRepository::NewLC( KCRUidBrowser ); |
|
198 TInt tempMode; |
|
199 TBrowserCenRepApSelectionModeValues mode; |
|
200 |
|
201 TUint err = repository->Get( KBrowserOccAccessPointSelectionMode, tempMode ); |
|
202 mode = static_cast<TBrowserCenRepApSelectionModeValues> ( tempMode ); |
|
203 |
|
204 // This was the last policy. Now restore old value, if appropriate. |
|
205 if (mode != EBrowserCenRepApSelModeAlwaysAsk) |
|
206 { |
|
207 // Nothing to change because user has edited the setting in meanwhile and this code will not |
|
208 // mess up user's choice. |
|
209 LOG(Log::Printf(_L("Browser user has changed mode from EBrowserCenRepApSelModeAlwaysAsk - no change"))); |
|
210 } |
|
211 else |
|
212 { |
|
213 // Reset to original value |
|
214 TInt err = repository->Reset( KBrowserOccAccessPointSelectionMode ); |
|
215 LOG(Log::Printf(_L("Set KBrowserOccAccessPointSelectionMode -> Original value"))); |
|
216 } |
|
217 CleanupStack::PopAndDestroy( repository ); |
|
218 } |
|
219 else |
|
220 { |
|
221 LOG(Log::Printf(_L("Browser settings not changed because policy count > 0"))); |
|
222 } |
|
223 |
191 LOG(Log::Printf(_L("<- CPolicyStore::DeletePolicyL()"))); |
224 LOG(Log::Printf(_L("<- CPolicyStore::DeletePolicyL()"))); |
192 return KErrNone; |
225 return KErrNone; |
193 } |
226 } |
194 |
227 |
195 TInt CPolicyStore::PolicyCount() |
228 TInt CPolicyStore::PolicyCount() |
296 { |
329 { |
297 iPolicyListVisible->AppendL(*policyInfo); |
330 iPolicyListVisible->AppendL(*policyInfo); |
298 } |
331 } |
299 |
332 |
300 CleanupStack::PopAndDestroy(policyInfo); |
333 CleanupStack::PopAndDestroy(policyInfo); |
|
334 |
|
335 // Policy was installed successfully. |
|
336 // Now change Browser's settings so that it must ask always for SNAP/IAP. |
|
337 // This is done because otherwise the VPN usage is seen difficult for Browser users. |
|
338 TUint policyCount = PolicyCount(); |
|
339 |
|
340 if ( policyCount == 1 ) |
|
341 { |
|
342 CRepository* repository = CRepository::NewLC( KCRUidBrowser ); |
|
343 TInt tempMode; |
|
344 TBrowserCenRepApSelectionModeValues mode; |
|
345 |
|
346 TInt err = repository->Get( KBrowserOccAccessPointSelectionMode, tempMode ); |
|
347 mode = static_cast<TBrowserCenRepApSelectionModeValues> ( tempMode ); |
|
348 |
|
349 // This is the first policy. Now do the changes and save old value. |
|
350 if (mode == EBrowserCenRepApSelModeAlwaysAsk) |
|
351 { |
|
352 // Nothing to change |
|
353 LOG(Log::Printf(_L("Browser already uses mode EBrowserCenRepApSelModeAlwaysAsk"))); |
|
354 } |
|
355 else |
|
356 { |
|
357 TInt err = repository->Set( KBrowserOccAccessPointSelectionMode, EBrowserCenRepApSelModeAlwaysAsk ); |
|
358 LOG_1("Set KBrowserOccAccessPointSelectionMode -> EBrowserCenRepApSelModeAlwaysAsk, error code: %d", err); |
|
359 } |
|
360 |
|
361 CleanupStack::PopAndDestroy( repository ); |
|
362 } |
|
363 else |
|
364 { |
|
365 LOG(Log::Printf(_L("Browser settings not changed because policy count > 1"))); |
|
366 } |
|
367 |
301 LOG(Log::Printf(_L("<- CPolicyStore::AddPolicyL"))); |
368 LOG(Log::Printf(_L("<- CPolicyStore::AddPolicyL"))); |
302 } |
369 } |
303 |
370 |
304 TVpnPolicyId CPolicyStore::NewPolicyIdL() |
371 TVpnPolicyId CPolicyStore::NewPolicyIdL() |
305 { |
372 { |