|
1 /* |
|
2 * Copyright (c) 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: Cleans Vpn settings |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <e32base.h> |
|
21 #include <swi/swispubsubdefs.h> |
|
22 |
|
23 #include <cmmanagerext.h> |
|
24 #include <cmdestinationext.h> |
|
25 #include <cmconnectionmethodext.h> |
|
26 #include <cmpluginvpndef.h> |
|
27 |
|
28 #include "log_vpncleaner.h" |
|
29 #include "vpncleaner.h" |
|
30 |
|
31 |
|
32 TVpnCleaner::TVpnCleaner() |
|
33 { |
|
34 } |
|
35 |
|
36 |
|
37 TVpnCleaner::~TVpnCleaner() |
|
38 { |
|
39 } |
|
40 |
|
41 |
|
42 void TVpnCleaner::Clean() |
|
43 { |
|
44 LOG( Log::Printf( _L( "-> TVpnCleaner::Clean()\n" ) ) ); |
|
45 |
|
46 TInt value; |
|
47 |
|
48 TInt ret = |
|
49 RProperty::Get( KUidSystemCategory, Swi::KUidSoftwareInstallKey, value ); |
|
50 |
|
51 if( KErrNone != ret ){ |
|
52 // No need for error handling |
|
53 return; |
|
54 } |
|
55 |
|
56 switch( value & Swi::KSwisOperationMask ){ |
|
57 case Swi::ESwisInstall: |
|
58 // SW update ongoing, no clean needed |
|
59 return; |
|
60 case Swi::ESwisUninstall: |
|
61 TRAPD( err, CleanAPsL() ); |
|
62 LOG( Log::Printf( _L( "TVpnCleaner::Clean(), err: %d\n" ), err) ); |
|
63 |
|
64 // Prevent compiler warning Re: unused variable |
|
65 if( KErrNone == err ){ |
|
66 } |
|
67 break; |
|
68 default: |
|
69 return; |
|
70 } |
|
71 } |
|
72 |
|
73 |
|
74 void TVpnCleaner::CleanAPsL() |
|
75 { |
|
76 using namespace CMManager; |
|
77 RCmManagerExt cmManager; |
|
78 cmManager.OpenL(); |
|
79 CleanupClosePushL( cmManager ); |
|
80 |
|
81 DelAPsL( cmManager ); |
|
82 |
|
83 CleanupStack::PopAndDestroy(); // cmManager |
|
84 } |
|
85 |
|
86 |
|
87 void TVpnCleaner::DelAPsL( RCmManagerExt& aCm ) |
|
88 { |
|
89 using namespace CMManager; |
|
90 |
|
91 RArray<TUint32> aps; |
|
92 |
|
93 TBool supportedBearersOnly = ETrue; |
|
94 TBool legacyCmsOnly = EFalse; |
|
95 |
|
96 aCm.ConnectionMethodL( aps, supportedBearersOnly, legacyCmsOnly ); |
|
97 CleanupClosePushL( aps ); |
|
98 |
|
99 for( TInt i = 0; i < aps.Count(); ++i ){ |
|
100 RCmConnectionMethodExt ap = aCm.ConnectionMethodL( aps[i] ); |
|
101 CleanupClosePushL( ap ); |
|
102 |
|
103 if( KPluginVPNBearerTypeUid == ap.GetIntAttributeL( ECmBearerType ) ){ |
|
104 ap.DeleteL(); |
|
105 } |
|
106 |
|
107 CleanupStack::PopAndDestroy(); // ap |
|
108 } |
|
109 |
|
110 CleanupStack::PopAndDestroy(); // aps |
|
111 } |
|
112 |
|
113 |
|
114 /***/ |