|
1 /* |
|
2 * Copyright (c) 2001-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 the License "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: Declaration of class CWPASecuritySettingsImpl. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef WPASECURITYSETTINGSIMPL_H |
|
20 #define WPASECURITYSETTINGSIMPL_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <WlanCdbCols.h> |
|
25 |
|
26 #include <WPASecuritySettingsUI.h> |
|
27 |
|
28 #include <metadatabase.h> |
|
29 using namespace CommsDat; |
|
30 |
|
31 |
|
32 |
|
33 // CONST DECLARATIONS |
|
34 #define KWLANEAPLISTLENGTH 1024 // Max length of the EAP Plugin list |
|
35 |
|
36 |
|
37 // FORWARD DECLARATIONS |
|
38 class CCommsDatabase; |
|
39 class CEAPPluginConfigurationIf; |
|
40 |
|
41 // CLASS DECLARATION |
|
42 |
|
43 /** |
|
44 * WPA Security Settings. |
|
45 * Implementation behind proxy class CWPASecuritySettings. |
|
46 */ |
|
47 NONSHARABLE_CLASS( CWPASecuritySettingsImpl ) : public CBase |
|
48 { |
|
49 |
|
50 public: // Constructors and destructor |
|
51 |
|
52 /** |
|
53 * Two-phased constructor. Leaves on failure. |
|
54 * @param aSecurityMode The chosen security mode. It can be |
|
55 * ESecurityMode8021x or ESecurityModeWpa |
|
56 * @return The constructed CWPASecuritySettings object. |
|
57 */ |
|
58 static CWPASecuritySettingsImpl* NewL( TSecurityMode aSecurityMode ); |
|
59 |
|
60 /** |
|
61 * Destructor. |
|
62 */ |
|
63 virtual ~CWPASecuritySettingsImpl(); |
|
64 |
|
65 |
|
66 protected: // Constructors |
|
67 |
|
68 /** |
|
69 * Constructor. |
|
70 * @param aSecurityMode The chosen security mode. It can be |
|
71 * ESecurityMode8021x or ESecurityModeWpa |
|
72 */ |
|
73 CWPASecuritySettingsImpl( TSecurityMode aSecurityMode ); |
|
74 |
|
75 /** |
|
76 * Second-phase constructor. |
|
77 */ |
|
78 void ConstructL(); |
|
79 |
|
80 |
|
81 public: // New methods |
|
82 |
|
83 /** |
|
84 * Load from database. |
|
85 * @param aIapId Wlan Service Table Id of the IAP to be loaded |
|
86 * @param aCommsDb Comms database. |
|
87 */ |
|
88 void LoadL( TUint32 aIapId, CCommsDatabase& aCommsDb ); |
|
89 |
|
90 |
|
91 /** |
|
92 * Save to database. |
|
93 * @param aIapId Wlan Service Table Id of the IAP to be saved |
|
94 * @param aCommsDb Comms database. |
|
95 * @param aTypeOfSaving Tells what kind of AP we are going to save: it |
|
96 * can be ESavingEditedAP, ESavingBrandNewAP, or |
|
97 * ESavingNewAPAsACopy |
|
98 * @param aOldIapId The old Id of the IAP; it is used to save the EAP |
|
99 * configuration, only when aIsNewAP is ETrue |
|
100 */ |
|
101 void SaveL( TUint32 aIapId, CCommsDatabase& aCommsDb, |
|
102 TTypeOfSaving aTypeOfSaving, TUint32 aOldIapId ); |
|
103 |
|
104 |
|
105 /** |
|
106 * Delete from database. It actually just removes EAP Configuration. |
|
107 * @param aIapId Id of the IAP to be saved |
|
108 */ |
|
109 void DeleteL( TUint32 aIapId ); |
|
110 |
|
111 |
|
112 /** |
|
113 * Tells if the settings are valid and can be saved |
|
114 * @return ETrue if all the compulsory settings have been entered |
|
115 */ |
|
116 TBool IsValid(); |
|
117 |
|
118 |
|
119 /** |
|
120 * Sets the Pre-shared key |
|
121 * @param aPreSharedKey The key to be set |
|
122 * @return KErrNone if successful, or an error code |
|
123 */ |
|
124 TInt SetWPAPreSharedKey( const TDesC& aPreSharedKey ); |
|
125 |
|
126 /** |
|
127 * Gets the type of Security set. |
|
128 * @return The security mode in use. It can be ESecurityMode8021x or |
|
129 * ESecurityModeWpa |
|
130 */ |
|
131 inline TSecurityMode SecurityMode() const; |
|
132 |
|
133 |
|
134 /** |
|
135 * Tells if Pre-shared key is in use or not |
|
136 * @return ETrue if Pre-shared key is in use |
|
137 */ |
|
138 inline TBool WPAMode() const; |
|
139 |
|
140 |
|
141 /** |
|
142 * Sets the use of Pre-shared key. |
|
143 * @param aWPAMode ETrue if pre-shared key is in use |
|
144 */ |
|
145 inline void SetWPAMode( const TBool aWPAMode ); |
|
146 |
|
147 |
|
148 /** |
|
149 * Tells if it is WPA2 Only mode |
|
150 * @return ETrue if it is WPA2 Only mode |
|
151 */ |
|
152 inline TBool Wpa2Only() const; |
|
153 |
|
154 |
|
155 /** |
|
156 * Sets the WPA2 Only mode enabling variable |
|
157 * @param aAllowed ETrue if WPA2 Only mode is enabled |
|
158 */ |
|
159 inline void SetWpa2Only( const TBool aAllowed ); |
|
160 |
|
161 |
|
162 /** |
|
163 * Returns the Pre-shared key |
|
164 * @return The pre-shared key |
|
165 */ |
|
166 inline TDes8* WPAPreSharedKey(); |
|
167 |
|
168 |
|
169 /** |
|
170 * Sets the Pre-shared key |
|
171 * @param aPreSharedKey The key to be set |
|
172 */ |
|
173 inline void SetWPAPreSharedKey( const TDesC8& aPreSharedKey ); |
|
174 |
|
175 |
|
176 /** |
|
177 * Returns the content of the WlanEapList column of WLANServiceTable |
|
178 * @return The content string |
|
179 */ |
|
180 inline TDes* WPAEAPPlugin(); |
|
181 |
|
182 /** |
|
183 * Returns the content of the WlanEnabledEapList column of |
|
184 * WLANServiceTable |
|
185 * @return The content string. Ownership not passed! |
|
186 */ |
|
187 inline HBufC8* WPAEnabledEAPPlugin(); |
|
188 |
|
189 /** |
|
190 * Returns the content of the WlanDisabledEapList column of |
|
191 * WLANServiceTable |
|
192 * @return The content string. Ownership not passed! |
|
193 */ |
|
194 inline HBufC8* WPADisabledEAPPlugin(); |
|
195 |
|
196 /** |
|
197 * Sets the content of the WlanEapList column of WLANServiceTable |
|
198 * @param aPluginList The content string to be set |
|
199 */ |
|
200 inline void SetWPAEAPPlugin( const TDes& aPluginList ); |
|
201 |
|
202 /** |
|
203 * Sets the content of the WlanEnabledEapList column of WLANServiceTable |
|
204 * (for expanded EAP types) |
|
205 * @param aEnabledPluginList Enumeration of enabled plugins |
|
206 * @return KErrNone if successful, or an error code |
|
207 */ |
|
208 TInt SetWPAEnabledEAPPlugin( const TDesC8& aEnabledPluginList ); |
|
209 |
|
210 /** |
|
211 * Sets the content of the WlanDisabledEapList column of WLANServiceTable |
|
212 * (for expanded EAP types) |
|
213 * @param aDisabledPluginList Enumeration of disabled plugins |
|
214 * @return KErrNone if successful, or an error code |
|
215 */ |
|
216 TInt SetWPADisabledEAPPlugin( const TDesC8& aDisabledPluginList ); |
|
217 |
|
218 /** |
|
219 * Sets the Id of the AP |
|
220 * @param aIapId The Id to be set |
|
221 */ |
|
222 inline void SetIapId( const TUint32 aIapId ); |
|
223 |
|
224 /** |
|
225 * Returns the Id of the AP |
|
226 * @return The Id |
|
227 */ |
|
228 inline const TUint32 IapId(); |
|
229 |
|
230 /** |
|
231 * Returns the pointer to the EAP Configuration plugin |
|
232 * @return The EAP Configuration plugin |
|
233 */ |
|
234 inline CEAPPluginConfigurationIf* Plugin(); |
|
235 |
|
236 /** |
|
237 * Load from database. |
|
238 * @param aIapId Wlan Service Table Id of the IAP to be loaded |
|
239 * @param aSession CommsDat session. |
|
240 */ |
|
241 void LoadL( TUint32 aIapId, CMDBSession& aSession ); |
|
242 |
|
243 |
|
244 /** |
|
245 * Save to database. |
|
246 * @param aIapId Wlan Service Table Id of the IAP to be saved |
|
247 * @param aSession CommsDat session. |
|
248 * @param aTypeOfSaving Tells what kind of AP we are going to save: it |
|
249 * can be ESavingEditedAP, ESavingBrandNewAP, or |
|
250 * ESavingNewAPAsACopy |
|
251 * @param aOldIapId The old Id of the IAP; it is used to save the EAP |
|
252 * configuration, only when aIsNewAP is ETrue |
|
253 */ |
|
254 void SaveL( TUint32 aIapId, CMDBSession& aSession, |
|
255 TTypeOfSaving aTypeOfSaving, TUint32 aOldIapId ); |
|
256 |
|
257 private: |
|
258 /** |
|
259 * Checks whether the given string is a valid PSK |
|
260 * @since S60 5.0 |
|
261 * @param aPsk The string to be checked |
|
262 * @return ETrue if the string is a valid PSK, EFalse otherwise. |
|
263 */ |
|
264 TBool IsValidPsk( const TDesC8& aPsk ); |
|
265 |
|
266 private: // Data |
|
267 |
|
268 // Security mode in use |
|
269 TSecurityMode iSecurityMode; |
|
270 |
|
271 // Pre-shared key in use or not |
|
272 TBool iWPAMode; |
|
273 |
|
274 // The content of the WlanEapList column of WLANServiceTable |
|
275 TBuf<KWLANEAPLISTLENGTH> iWPAEAPPlugin; |
|
276 |
|
277 // The pre-shared key |
|
278 TBuf8<KWlanWpaPskLength> iWPAPreSharedKey; |
|
279 |
|
280 // The content of the WlanEnabledEapList column of WLANServiceTable. |
|
281 // Owned. |
|
282 HBufC8 *iWPAEnabledEAPPlugin; |
|
283 |
|
284 // The content of the WlanDisabledEapList column of WLANServiceTable. |
|
285 // Owned. |
|
286 HBufC8 *iWPADisabledEAPPlugin; |
|
287 |
|
288 // WPA2 Only mode enabled or not |
|
289 TBool iWpa2Only; |
|
290 |
|
291 // The Id of the AP. |
|
292 TUint32 iIapId; |
|
293 |
|
294 // The EAP Configuration plugin. Owned. |
|
295 CEAPPluginConfigurationIf* iPlugin; |
|
296 }; |
|
297 |
|
298 // Include inline functions |
|
299 #include "WPASecuritySettingsImpl.inl" |
|
300 |
|
301 |
|
302 #endif |