|
1 /* |
|
2 * Copyright (c) 2007-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: Controls the vpn policy import procedure. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef C_VPNPOLICYINSTALLER_H |
|
22 #define C_VPNPOLICYINSTALLER_H |
|
23 |
|
24 #include <e32base.h> |
|
25 #include "vpnnotifierdefs.h" |
|
26 |
|
27 #include "vpnapi.h" |
|
28 #include "vpnnotifierdefs.h" |
|
29 |
|
30 class CZipFileDecompressor; |
|
31 class CApaCommandLine; |
|
32 class CVpnPolicyInstaller; |
|
33 |
|
34 /** |
|
35 * Activeobject for wait note during policy import procedure |
|
36 * |
|
37 */ |
|
38 class CImportWaitNoteHandler : public CActive |
|
39 { |
|
40 public: |
|
41 static CImportWaitNoteHandler* NewL(CVpnPolicyInstaller* aCallBack); |
|
42 CImportWaitNoteHandler(CVpnPolicyInstaller* aCallBack); |
|
43 ~CImportWaitNoteHandler(); |
|
44 |
|
45 protected: |
|
46 void DoCancel(); |
|
47 void RunL(); |
|
48 TInt RunError(TInt aError); |
|
49 |
|
50 void ConstructL(); |
|
51 |
|
52 public: |
|
53 /** |
|
54 * Starts the wait note. The exact nature of note depends on aNoteId |
|
55 * parameter. |
|
56 * |
|
57 * @param aNoteId The note type to display. Possible values are |
|
58 * TVpnDialog::EPolicyInstallInProgress ("Importing"; default) |
|
59 * and TVpnDialog::EGenericProgress ("Processing" with no cancel) |
|
60 */ |
|
61 void StartWaitNote(TInt aNoteId = TVpnDialog::EPolicyInstallInProgress); |
|
62 |
|
63 protected: |
|
64 TPckgBuf<TVpnDialogInfo> iDialogInfoDes; |
|
65 TPckgBuf<TVpnDialogOutput> iDialogResponseDes; |
|
66 RNotifier iNotifier; |
|
67 TInt iStatem; |
|
68 |
|
69 // Callback used when cancel occurs |
|
70 CVpnPolicyInstaller* iCallBack; |
|
71 }; |
|
72 |
|
73 class CVpnPolicyInstaller : public CActive |
|
74 { |
|
75 public: |
|
76 static CVpnPolicyInstaller* NewL(); |
|
77 ~CVpnPolicyInstaller(); |
|
78 |
|
79 void InstallPolicy(); |
|
80 void DialogDismissedL(TInt /*aButtonId*/) |
|
81 { |
|
82 }; |
|
83 void UserCancelledWait(); |
|
84 void CancelWaitNote(); |
|
85 |
|
86 protected: // From CActive |
|
87 void DoCancel(); |
|
88 void RunL(); |
|
89 TInt RunError(TInt aError); |
|
90 |
|
91 private: |
|
92 CVpnPolicyInstaller(); |
|
93 void ConstructL(); |
|
94 |
|
95 /** |
|
96 * Starts the policy installation process |
|
97 */ |
|
98 void InstallPolicyL(); |
|
99 |
|
100 /** |
|
101 * Unzips the .VPN zipped file |
|
102 */ |
|
103 void DeflateZippedPolicyL(); |
|
104 |
|
105 /** |
|
106 * "Emtpies" the temp dir that was used for zip extraction |
|
107 */ |
|
108 void EmtpyTempDirL(); |
|
109 |
|
110 /** |
|
111 * Locate the command file from the extracted VPN file contents, |
|
112 * and parse it. Parsed variables are stored locally to CVpnPolicyInstaller |
|
113 * instance (at the moment, the variables are PKCS#12 password, |
|
114 * device lock policy level and device lock optionality information) |
|
115 */ |
|
116 void ExtractAndParseCmdFileL(); |
|
117 |
|
118 /** |
|
119 * Install a policy that is unpacked. Used after a VPN file has been |
|
120 * decompressed, as well. |
|
121 */ |
|
122 void InstallPinPolicyL(const TDesC& aFileDirectory); |
|
123 |
|
124 /** |
|
125 * Shows a generic "Installation failed" note |
|
126 */ |
|
127 void ShowImportErrorNote(const TInt aReason = KErrGeneral); |
|
128 |
|
129 /** |
|
130 * Shows the device lock related confirmation note |
|
131 * "Import VPN policy X? Note: devlock will be forced" |
|
132 * |
|
133 * @return ETrue iff the user gave positive confirmation |
|
134 */ |
|
135 TBool ShowDevLockConfirmNote(); |
|
136 |
|
137 /** |
|
138 * Shows the standard confirmation note |
|
139 * "Import VPN policy X?" |
|
140 * Used when a) no devlock used or b) devlock use is optional and |
|
141 * no device lock found / device lock not accessible by VPN. |
|
142 * |
|
143 * @return ETrue iff the user gave positive confirmation |
|
144 */ |
|
145 TBool ShowConfirmNote(); |
|
146 |
|
147 /** |
|
148 * Shows a wait note. Default wait note is "Importing policy" (can |
|
149 * be cancelled). For special purposes, a generic "Processing" wait |
|
150 * note (non-cancellable) can be used. |
|
151 * |
|
152 * @param aNoteId The type of the note to display. Valid values are |
|
153 * TVpnDialog::EPolicyInstallInProgress and |
|
154 * TVpnDialog::EGenericProgress |
|
155 */ |
|
156 void ShowWaitNoteL(TInt aNoteId = TVpnDialog::EPolicyInstallInProgress); |
|
157 |
|
158 /** |
|
159 * Continues policy install operation |
|
160 * |
|
161 */ |
|
162 void ContinueInstallPolicyL(); |
|
163 |
|
164 /** |
|
165 * After VPN zip has been decompressed, go through its contents, |
|
166 * locate the commanad / p12 files, check the device lock status, |
|
167 * parse command file, and extract p12 objects. |
|
168 * |
|
169 */ |
|
170 void ProcessBundleContentsL(); |
|
171 |
|
172 /** |
|
173 * Parse cmd file XML and extract the relevant parameters to local |
|
174 * instance variables |
|
175 * |
|
176 * @param aCmdData XML-formatted cmd file data, in 8bit descriptor |
|
177 * |
|
178 * @leave Leaves if oom, or if data is corrupted |
|
179 */ |
|
180 void ExtractCommandParametersL(const TDesC8& aCmdData); |
|
181 |
|
182 /** |
|
183 * Dump PKCS#12 objects into separate files |
|
184 * |
|
185 * @param aData Raw PKCS#12 data in binary format |
|
186 * @param aPwd The password used for descrambling PKCS#12 data. |
|
187 * If password is wrong, it will be prompted again (and again, |
|
188 * and again...) |
|
189 * |
|
190 * @leave Leaves if PKCS#12 is corrupt or OOM |
|
191 * |
|
192 */ |
|
193 void ExtractPKCS12ObjectsL(const TDesC8& aData, const TDesC& aPwd); |
|
194 |
|
195 /** |
|
196 * Checks whether device lock is available, and usable by VPN. |
|
197 * Returns false if it's not. Leaves in case of OOM. |
|
198 * |
|
199 * @return ETrue iff device lock is available and VPN-enabled |
|
200 */ |
|
201 TBool IsDeviceLockAvailable(); |
|
202 |
|
203 /** |
|
204 * Checks whether Device Lock is available / requested, and then |
|
205 * prompts the user about it with confirm note |
|
206 * |
|
207 * @return ETrue if user confirmed devicelock policy install |
|
208 */ |
|
209 TBool ConfirmDeviceLockUseL(); |
|
210 |
|
211 /** |
|
212 * Applies the device lock settings. This should be done only after |
|
213 * the policy has been successfully imported. |
|
214 * |
|
215 * @leave Leaves if OOM or if there are problems with device |
|
216 * lock access. |
|
217 * |
|
218 */ |
|
219 void ApplyDevLockSettingsL(); |
|
220 |
|
221 enum TTask |
|
222 { |
|
223 ETaskNone = 1, |
|
224 ETaskImportPinPolicies, |
|
225 ETaskImportZippedPolicies, |
|
226 ETaskShowImportErrorNote |
|
227 }; |
|
228 |
|
229 |
|
230 RNotifier iNotifier; |
|
231 RVpnApi iVpnServ; |
|
232 RFs iFileServer; |
|
233 |
|
234 |
|
235 CApaCommandLine* iCommandLine; |
|
236 HBufC* iDriveAndPath; |
|
237 HBufC* iFormat; |
|
238 HBufC8* iFileName; |
|
239 |
|
240 HBufC* iP12Password; |
|
241 TInt iDevLockPolicy; |
|
242 TBool iDevLockRequired; |
|
243 TBool iDevSupportsDevLock; |
|
244 |
|
245 TTask iOngoingTask; |
|
246 |
|
247 RLibrary iTCLib; |
|
248 |
|
249 CZipFileDecompressor* iDecompressor; |
|
250 |
|
251 TPckgBuf<TVpnDialogInfo> iDialogInfoDes; |
|
252 TPckgBuf<TVpnDialogOutput> iDialogResponseDes; |
|
253 |
|
254 CImportWaitNoteHandler* iWaitNoteHandler; |
|
255 }; |
|
256 |
|
257 #endif // C_VPNPOLICYINSTALLER_H |
|
258 |