47
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2006 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: Wlan Adapter DB handler
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
|
|
19 |
#include <commsdat_partner.h>
|
|
20 |
#endif
|
|
21 |
#include <WlanCdbCols.h>
|
|
22 |
#include "NSmlWlanSettings.h"
|
|
23 |
#include "NSmlWLanAdapter.h"
|
|
24 |
#include "nsmldebug.h"
|
|
25 |
#include <comms-infras/commdb/protection/protectdb.h>
|
|
26 |
#include <SettingEnforcementInfo.h> // vsettingenforcementinfo
|
|
27 |
#include <featmgr.h>
|
|
28 |
#include <EapExpandedType.h>
|
|
29 |
#include <EapGeneralSettings.h>
|
|
30 |
|
|
31 |
#ifndef __WINS__
|
|
32 |
// This lowers the unnecessary compiler warning (armv5) to remark.
|
|
33 |
// "Warning: #174-D: expression has no effect..." is caused by
|
|
34 |
// DBG_ARGS8 macro in no-debug builds.
|
|
35 |
#pragma diag_remark 174
|
|
36 |
#endif
|
|
37 |
|
|
38 |
const TUint KEAPListBufferSize = 128;
|
|
39 |
const TUint KLengthOfOldStyleEAPListEntry = 5; // "+xxx,"
|
|
40 |
|
|
41 |
const TInt KBeginTransRetryDelay = 1000000; // Delay for comms db begintransaction retry (microseconds)
|
|
42 |
const TInt KBeginTransRetryCount = 7; // Maximum number of retries
|
|
43 |
//-----------------------------------------------------------------------------
|
|
44 |
// CWlanAdapter::CWlanSettings( CCommsDatabase& aDatabase )
|
|
45 |
//-----------------------------------------------------------------------------
|
|
46 |
CWlanSettings::CWlanSettings(CCommsDatabase& aDatabase) :
|
|
47 |
iDatabase(aDatabase), iExpandedEAPTypeFieldsUsed(ETrue)
|
|
48 |
{
|
|
49 |
_DBG_FILE("CWlanSettings::CWlanSettings(): begin");
|
|
50 |
|
|
51 |
iTableView = 0;
|
|
52 |
iEapType = NULL;
|
|
53 |
iSecondaryView = NULL;
|
|
54 |
|
|
55 |
_DBG_FILE("CWlanSettings::CWlanSettings(): end");
|
|
56 |
}
|
|
57 |
|
|
58 |
//-----------------------------------------------------------------------------
|
|
59 |
// CWlanAdapter::~CWlanSettings( )
|
|
60 |
//-----------------------------------------------------------------------------
|
|
61 |
CWlanSettings::~CWlanSettings()
|
|
62 |
{
|
|
63 |
|
|
64 |
delete iEapType;
|
|
65 |
delete iSecondaryView;
|
|
66 |
delete iTableView;
|
|
67 |
}
|
|
68 |
|
|
69 |
//-----------------------------------------------------------------------------
|
|
70 |
// CWlanSettings* CWlanSettings::NewL( CCommsDatabase& aDatabase )
|
|
71 |
//-----------------------------------------------------------------------------
|
|
72 |
CWlanSettings* CWlanSettings::NewL(CCommsDatabase& aDatabase)
|
|
73 |
{
|
|
74 |
_DBG_FILE("CWlanSettings::NewL(): begin");
|
|
75 |
|
|
76 |
CWlanSettings* self = new (ELeave) CWlanSettings(aDatabase);
|
|
77 |
|
|
78 |
CleanupStack::PushL(self);
|
|
79 |
self->ConstructL();
|
|
80 |
CleanupStack::Pop(self);
|
|
81 |
|
|
82 |
_DBG_FILE("CWlanSettings::NewL(): end");
|
|
83 |
return self;
|
|
84 |
}
|
|
85 |
|
|
86 |
//-----------------------------------------------------------------------------
|
|
87 |
// void CWlanSettings::ConstructL( )
|
|
88 |
//-----------------------------------------------------------------------------
|
|
89 |
void CWlanSettings::ConstructL()
|
|
90 |
{
|
|
91 |
_DBG_FILE("CWlanSettings::ConstructL(): begin");
|
|
92 |
_DBG_FILE("CWlanSettings::ConstructL(): end");
|
|
93 |
}
|
|
94 |
|
|
95 |
//-----------------------------------------------------------------------------
|
|
96 |
// TInt CWlanSettings::GetWlanSettings( TUint32 aLuid, TWlanSettings& aWlanSettings )
|
|
97 |
//-----------------------------------------------------------------------------
|
|
98 |
TInt CWlanSettings::GetWlanSettings(TUint32 aLuid,
|
|
99 |
TWlanSettings& aWlanSettings)
|
|
100 |
{
|
|
101 |
_DBG_FILE("CWlanSettings::GetWlanSettings(): begin");
|
|
102 |
|
|
103 |
TRAPD(err, ConnectToDatabaseL());
|
|
104 |
if (err == KErrNone)
|
|
105 |
{
|
|
106 |
err = GoToRecord(aLuid);
|
|
107 |
|
|
108 |
if (err == KErrNone)
|
|
109 |
{
|
|
110 |
TRAP(err, GetDataFromRecordL(&aWlanSettings));
|
|
111 |
}
|
|
112 |
}
|
|
113 |
|
|
114 |
_DBG_FILE("CWlanSettings::GetWlanSettings(): end");
|
|
115 |
return err;
|
|
116 |
}
|
|
117 |
|
|
118 |
//-----------------------------------------------------------------------------
|
|
119 |
// TInt CWlanSettings::GetEapSettings( TInt aId, TWlanSettings& aWlanSettings )
|
|
120 |
//-----------------------------------------------------------------------------
|
|
121 |
TInt CWlanSettings::GetEAPSettings(const TInt aId,
|
|
122 |
TEapExpandedType& aExpandedId, TEapExpandedType& aEncapsId,
|
|
123 |
EAPSettings& aEapSettings)
|
|
124 |
{
|
|
125 |
_DBG_FILE("CWlanSettings::GetEapSettings(): begin");
|
|
126 |
|
|
127 |
TRAPD(err, GetEAPInterfaceL(aId, aEncapsId, aExpandedId));
|
|
128 |
DBG_ARGS(_S16("GetEAPInterfaceL leaved with %d"), err);
|
|
129 |
if (err == KErrNone)
|
|
130 |
{
|
|
131 |
TRAP(err, iEapType->GetConfigurationL(aEapSettings));
|
|
132 |
DBG_ARGS(_S16("iEapType->GetConfigurationL leaved with %d"), err);
|
|
133 |
}
|
|
134 |
|
|
135 |
_DBG_FILE("CWlanSettings::GetEAPSettings(): end");
|
|
136 |
return err;
|
|
137 |
}
|
|
138 |
|
|
139 |
//-----------------------------------------------------------------------------
|
|
140 |
// TInt CWlanSettings::DeleteWlanSettings( TUint32 aLuid )
|
|
141 |
//-----------------------------------------------------------------------------
|
|
142 |
TInt CWlanSettings::DeleteWlanSettings(TUint32 aLuid)
|
|
143 |
{
|
|
144 |
_DBG_FILE("CWlanSettings::DeleteWlanSettings(): begin");
|
|
145 |
TBool wlanEnforce = EFalse;
|
|
146 |
TInt tableLockError = KErrNone;
|
|
147 |
|
|
148 |
if (FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement))
|
|
149 |
{
|
|
150 |
TInt enError = KErrNone;
|
|
151 |
TRAP(enError, wlanEnforce = CheckEnforcementL());
|
|
152 |
DBG_ARGS(
|
|
153 |
_S16(
|
|
154 |
"CWlanSettings::DeleteWLANSettings, check enforcement failed. error: <%D>"),
|
|
155 |
enError);
|
|
156 |
if (wlanEnforce)
|
|
157 |
{
|
|
158 |
_DBG_FILE(
|
|
159 |
"CWlanSettings::WriteWlanSettings(): wlan enforce is ON ");
|
|
160 |
TRAPD(lockError, tableLockError = PerformLockWLANTablesL(EFalse));
|
|
161 |
if (lockError == KErrNone && tableLockError == KErrNone)
|
|
162 |
{
|
|
163 |
_DBG_FILE(
|
|
164 |
"CWlanSettings::WriteWlanSettings(): Table unlcoked successfully ");
|
|
165 |
iWLANRelock = ETrue;
|
|
166 |
}
|
|
167 |
}
|
|
168 |
}
|
|
169 |
|
|
170 |
TRAPD(err, ConnectToDatabaseL());
|
|
171 |
if (err == KErrNone)
|
|
172 |
{
|
|
173 |
err = GoToRecord(aLuid);
|
|
174 |
if (err == KErrNone)
|
|
175 |
{
|
|
176 |
|
|
177 |
if (FeatureManager::FeatureSupported(
|
|
178 |
KFeatureIdSapPolicyManagement))
|
|
179 |
{
|
|
180 |
if (wlanEnforce)
|
|
181 |
{
|
|
182 |
((CCommsDbProtectTableView*) iTableView)->UnprotectRecord();
|
|
183 |
}
|
|
184 |
}
|
|
185 |
|
|
186 |
TInt err = iTableView->UpdateRecord();
|
|
187 |
if (err == KErrLocked)
|
|
188 |
{
|
|
189 |
_DBG_FILE("DeleteWlanSettings: UpdateRecord was locked.");
|
|
190 |
TInt retry = KBeginTransRetryCount;
|
|
191 |
while (retry > 0 && err == KErrLocked)
|
|
192 |
{
|
|
193 |
User::After(KBeginTransRetryDelay);
|
|
194 |
_DBG_FILE("DeleteWlanSettings: Slept 1 second. Try again");
|
|
195 |
err = iTableView->UpdateRecord();
|
|
196 |
retry--;
|
|
197 |
}
|
|
198 |
if (err != KErrNone)
|
|
199 |
{
|
|
200 |
_DBG_FILE(
|
|
201 |
"DeleteWlanSettings: UpdateRecord was unsuccessful");
|
|
202 |
}
|
|
203 |
else
|
|
204 |
{
|
|
205 |
_DBG_FILE(
|
|
206 |
"DeleteWlanSettings: UpdateRecord was successful");
|
|
207 |
}
|
|
208 |
}
|
|
209 |
|
|
210 |
if (err == KErrNone)
|
|
211 |
{
|
|
212 |
TRAP(err, iTableView->WriteUintL(TPtrC(WLAN_SERVICE_ID), 0));
|
|
213 |
if (err != KErrNone)
|
|
214 |
{
|
|
215 |
if (FeatureManager::FeatureSupported(
|
|
216 |
KFeatureIdSapPolicyManagement))
|
|
217 |
{
|
|
218 |
TInt tableLockError = KErrNone;
|
|
219 |
if (iWLANRelock)
|
|
220 |
{
|
|
221 |
TInt lockError = KErrNone;
|
|
222 |
TRAP(lockError, tableLockError
|
|
223 |
= PerformLockWLANTablesL(ETrue));
|
|
224 |
((CCommsDbProtectTableView*) iTableView)->ProtectRecord();
|
|
225 |
DBG_ARGS(
|
|
226 |
_S16(
|
|
227 |
"CWlanSettings::DeleteWLANSettings, WLAN table Lock error. error: <%D>, <%D> "),
|
|
228 |
lockError, tableLockError);
|
|
229 |
iWLANRelock = EFalse;
|
|
230 |
}
|
|
231 |
if (tableLockError != KErrNone) // to remove warnings
|
|
232 |
{
|
|
233 |
tableLockError = KErrNone;
|
|
234 |
}
|
|
235 |
}
|
|
236 |
return err;
|
|
237 |
}
|
|
238 |
}
|
|
239 |
err = iTableView->PutRecordChanges();
|
|
240 |
if (err == KErrLocked)
|
|
241 |
{
|
|
242 |
_DBG_FILE("DeleteWlanSettings: PutRecordChanges was locked.");
|
|
243 |
TInt retry = KBeginTransRetryCount;
|
|
244 |
while (retry > 0 && err == KErrLocked)
|
|
245 |
{
|
|
246 |
User::After(KBeginTransRetryDelay);
|
|
247 |
_DBG_FILE("DeleteWlanSettings: Slept 1 second. Try again");
|
|
248 |
err = iTableView->PutRecordChanges();
|
|
249 |
retry--;
|
|
250 |
}
|
|
251 |
if (err != KErrNone)
|
|
252 |
{
|
|
253 |
_DBG_FILE(
|
|
254 |
"DeleteWlanSettings: PutRecordChanges was unsuccessful");
|
|
255 |
}
|
|
256 |
else
|
|
257 |
{
|
|
258 |
_DBG_FILE(
|
|
259 |
"DeleteWlanSettings: PutRecordChanges was successful");
|
|
260 |
}
|
|
261 |
}
|
|
262 |
|
|
263 |
if (FeatureManager::FeatureSupported(
|
|
264 |
KFeatureIdSapPolicyManagement))
|
|
265 |
{
|
|
266 |
TInt tableLockError = KErrNone;
|
|
267 |
if (iWLANRelock)
|
|
268 |
{
|
|
269 |
TInt lockError = KErrNone;
|
|
270 |
TRAP(lockError, tableLockError = PerformLockWLANTablesL(
|
|
271 |
ETrue));
|
|
272 |
DBG_ARGS(
|
|
273 |
_S16(
|
|
274 |
"CWlanSettings::DeleteWLANSettings, WLAN table Lock error. error: <%D>, <%D> "),
|
|
275 |
lockError, tableLockError);
|
|
276 |
((CCommsDbProtectTableView*) iTableView)->ProtectRecord();
|
|
277 |
iWLANRelock = EFalse;
|
|
278 |
}
|
|
279 |
if (tableLockError != KErrNone) // to remove warnings
|
|
280 |
{
|
|
281 |
tableLockError = KErrNone;
|
|
282 |
}
|
|
283 |
}
|
|
284 |
|
|
285 |
if (err == KErrNone)
|
|
286 |
{
|
|
287 |
// Ignore err on purpose
|
|
288 |
TRAP(err, DeleteSecondarySSIDsL(aLuid));
|
|
289 |
|
|
290 |
TRAP(err, DeleteWlanEapSettingsL(aLuid));
|
|
291 |
}
|
|
292 |
}
|
|
293 |
}
|
|
294 |
|
|
295 |
_DBG_FILE("CWlanSettings::DeleteWlanSettings(): end");
|
|
296 |
if (FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement))
|
|
297 |
{
|
|
298 |
if (iWLANRelock)
|
|
299 |
{
|
|
300 |
TInt lockError = KErrNone;
|
|
301 |
TRAP(lockError, tableLockError = PerformLockWLANTablesL(ETrue));
|
|
302 |
DBG_ARGS(
|
|
303 |
_S16(
|
|
304 |
"CWlanSettings::DeleteWLANSettings, WLAN table Lock error. error: <%D>, <%D> "),
|
|
305 |
lockError, tableLockError);
|
|
306 |
((CCommsDbProtectTableView*) iTableView)->ProtectRecord();
|
|
307 |
iWLANRelock = EFalse;
|
|
308 |
}
|
|
309 |
}
|
|
310 |
|
|
311 |
if (wlanEnforce)
|
|
312 |
wlanEnforce = EFalse; // to get rid of warnings
|
|
313 |
return err;
|
|
314 |
}
|
|
315 |
|
|
316 |
TInt CWlanSettings::DeleteOneSecondarySSIDL(TUint32 aWLANId, TUint32 asecId)
|
|
317 |
{
|
|
318 |
|
|
319 |
TInt retval = KErrNone;
|
|
320 |
SetSecondaryViewToRecordL(aWLANId);
|
|
321 |
retval = iSecondaryView->GotoFirstRecord();
|
|
322 |
|
|
323 |
while (retval == KErrNone)
|
|
324 |
{
|
|
325 |
TSecondarySSID ssid;
|
|
326 |
TRAP(retval, iSecondaryView->ReadUintL(TPtrC(WLAN_SEC_SSID_ID),
|
|
327 |
ssid.Id));
|
|
328 |
if (ssid.Id == asecId)
|
|
329 |
{
|
|
330 |
//retval = iSecondaryView->UpdateRecord();
|
|
331 |
//if( retval==KErrNone )
|
|
332 |
// {
|
|
333 |
if (FeatureManager::FeatureSupported(
|
|
334 |
KFeatureIdSapPolicyManagement))
|
|
335 |
{
|
|
336 |
TBool wlanEnforce = EFalse;
|
|
337 |
TInt enError = KErrNone;
|
|
338 |
TRAP(enError, wlanEnforce = CheckEnforcementL());
|
|
339 |
DBG_ARGS(
|
|
340 |
_S16(
|
|
341 |
"CWlanSettings::DeleteWLANSettings, check enforcement failed. error: <%D>"),
|
|
342 |
enError);
|
|
343 |
if (wlanEnforce)
|
|
344 |
{
|
|
345 |
((CCommsDbProtectTableView*) iSecondaryView)->UnprotectRecord();
|
|
346 |
}
|
|
347 |
}
|
|
348 |
|
|
349 |
retval = iSecondaryView->DeleteRecord();
|
|
350 |
if (retval == KErrLocked)
|
|
351 |
{
|
|
352 |
_DBG_FILE("DeleteOneSecondarySSIDL: DeleteRecord was locked.");
|
|
353 |
TInt retry = KBeginTransRetryCount;
|
|
354 |
while (retry > 0 && retval == KErrLocked)
|
|
355 |
{
|
|
356 |
User::After(KBeginTransRetryDelay);
|
|
357 |
_DBG_FILE(
|
|
358 |
"DeleteOneSecondarySSIDL: Slept 1 second. Try again");
|
|
359 |
retval = iSecondaryView->DeleteRecord();
|
|
360 |
retry--;
|
|
361 |
}
|
|
362 |
if (retval != KErrNone)
|
|
363 |
{
|
|
364 |
_DBG_FILE(
|
|
365 |
"DeleteOneSecondarySSIDL: DeleteRecord was unsuccessful");
|
|
366 |
}
|
|
367 |
else
|
|
368 |
{
|
|
369 |
_DBG_FILE(
|
|
370 |
"DeleteOneSecondarySSIDL: DeleteRecord was successful");
|
|
371 |
}
|
|
372 |
}
|
|
373 |
DBG_ARGS(
|
|
374 |
_S16(
|
|
375 |
"CWlanSettings::DeleteOneSecondarySSIDL, Secondaryssid delete error: <%D> "),
|
|
376 |
retval);
|
|
377 |
|
|
378 |
// iTableView->PutRecordChanges( );
|
|
379 |
//}
|
|
380 |
|
|
381 |
break;
|
|
382 |
}
|
|
383 |
|
|
384 |
retval = iSecondaryView->GotoNextRecord();
|
|
385 |
}
|
|
386 |
|
|
387 |
return retval;
|
|
388 |
}
|
|
389 |
|
|
390 |
TInt CWlanSettings::DeleteSecondarySSIDsL(TUint32 aWLANId)
|
|
391 |
{
|
|
392 |
TInt retVal(KErrNone);
|
|
393 |
if (iSecondaryView == NULL)
|
|
394 |
{
|
|
395 |
SetSecondaryViewToRecordL(aWLANId);
|
|
396 |
}
|
|
397 |
else
|
|
398 |
{
|
|
399 |
retVal = iSecondaryView->GotoFirstRecord();
|
|
400 |
TUint32 secId = 0;
|
|
401 |
if (retVal == KErrNone)
|
|
402 |
{
|
|
403 |
iSecondaryView->ReadUintL(TPtrC(WLAN_SEC_SSID_SERVICE_ID), secId);
|
|
404 |
}
|
|
405 |
if (secId != aWLANId)
|
|
406 |
{
|
|
407 |
SetSecondaryViewToRecordL(aWLANId);
|
|
408 |
}
|
|
409 |
}
|
|
410 |
|
|
411 |
TInt err = iSecondaryView->GotoFirstRecord();
|
|
412 |
while (err == KErrNone)
|
|
413 |
{
|
|
414 |
if (FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement))
|
|
415 |
{
|
|
416 |
TBool wlanEnforce = EFalse;
|
|
417 |
TInt enError = KErrNone;
|
|
418 |
TRAP(enError, wlanEnforce = CheckEnforcementL());
|
|
419 |
DBG_ARGS(
|
|
420 |
_S16(
|
|
421 |
"CWlanSettings::DeleteSecondarySSIDsL, check enforcement failed. error: <%D>"),
|
|
422 |
enError);
|
|
423 |
if (wlanEnforce)
|
|
424 |
{
|
|
425 |
((CCommsDbProtectTableView*) iSecondaryView)->UnprotectRecord();
|
|
426 |
}
|
|
427 |
}
|
|
428 |
retVal = iSecondaryView->DeleteRecord();
|
|
429 |
if (retVal == KErrLocked)
|
|
430 |
{
|
|
431 |
_DBG_FILE("DeleteSecondarySSIDsL: DeleteRecord was locked.");
|
|
432 |
TInt retry = KBeginTransRetryCount;
|
|
433 |
while (retry > 0 && retVal == KErrLocked)
|
|
434 |
{
|
|
435 |
User::After(KBeginTransRetryDelay);
|
|
436 |
_DBG_FILE("DeleteSecondarySSIDsL: Slept 1 second. Try again");
|
|
437 |
retVal = iSecondaryView->DeleteRecord();
|
|
438 |
retry--;
|
|
439 |
}
|
|
440 |
if (retVal != KErrNone)
|
|
441 |
{
|
|
442 |
_DBG_FILE(
|
|
443 |
"DeleteSecondarySSIDsL: DeleteRecord was unsuccessful");
|
|
444 |
}
|
|
445 |
else
|
|
446 |
{
|
|
447 |
_DBG_FILE(
|
|
448 |
"DeleteSecondarySSIDsL: DeleteRecord was successful");
|
|
449 |
}
|
|
450 |
}
|
|
451 |
DBG_ARGS(
|
|
452 |
_S16(
|
|
453 |
"CWlanSettings::DeleteSecondarySSIDsL, Secondaryssid delete error: <%D> "),
|
|
454 |
retVal);
|
|
455 |
|
|
456 |
err = iSecondaryView->GotoNextRecord();
|
|
457 |
}
|
|
458 |
|
|
459 |
return retVal;
|
|
460 |
}
|
|
461 |
//-----------------------------------------------------------------------------
|
|
462 |
// TInt CWlanSettings::DeleteEapSettings( TInt aWlanId )
|
|
463 |
//-----------------------------------------------------------------------------
|
|
464 |
TInt CWlanSettings::DeleteEAPSettings(TInt aWlanId)
|
|
465 |
{
|
|
466 |
_DBG_FILE("CWlanSettings::DeleteEAPSettings(): begin");
|
|
467 |
|
|
468 |
TInt err(KErrNone);
|
|
469 |
|
|
470 |
TRAP(err, iEapType->DeleteConfigurationL());
|
|
471 |
if (err != KErrNone)
|
|
472 |
{
|
|
473 |
DBG_ARGS(
|
|
474 |
_S16(
|
|
475 |
"CWlanSettings::DeleteEAPSettings, delete failed, error: <%D> "),
|
|
476 |
err);
|
|
477 |
return err;
|
|
478 |
}
|
|
479 |
|
|
480 |
_DBG_FILE("CWlanSettings::DeleteEAPSettings(): end");
|
|
481 |
return err;
|
|
482 |
}
|
|
483 |
|
|
484 |
//-----------------------------------------------------------------------------
|
|
485 |
// TInt CWlanSettings::DeleteWlanEapSettings( TInt aWlanId )
|
|
486 |
// Deletes all EAPs from a Wlan
|
|
487 |
//-----------------------------------------------------------------------------
|
|
488 |
void CWlanSettings::DeleteWlanEapSettingsL(TInt aWlanId)
|
|
489 |
{
|
|
490 |
_DBG_FILE("CWlanSettings::DeleteWlanEapSettings(): begin");
|
|
491 |
TInt err(KErrNone);
|
|
492 |
err = DeleteEAPSettings(aWlanId);
|
|
493 |
User::LeaveIfError(err);
|
|
494 |
|
|
495 |
_DBG_FILE("CWlanSettings::DeleteWlanEapSettings(): end");
|
|
496 |
}
|
|
497 |
|
|
498 |
//-----------------------------------------------------------------------------
|
|
499 |
// TInt CWlanSettings::WriteWlanSettings( TWlanSettings& aWlanSettings )
|
|
500 |
//-----------------------------------------------------------------------------
|
|
501 |
TInt CWlanSettings::WriteWlanSettings(TWlanSettings& aWlanSettings)
|
|
502 |
{
|
|
503 |
_DBG_FILE("CWlanSettings::WriteWlanSettings(): begin");
|
|
504 |
|
|
505 |
TInt err = 0;
|
|
506 |
TInt enError = KErrNone;
|
|
507 |
iServiceID = aWlanSettings.ServiceID;
|
|
508 |
TBool wlanEnforce = EFalse;
|
|
509 |
|
|
510 |
if (FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement))
|
|
511 |
{
|
|
512 |
TRAP(enError, wlanEnforce = CheckEnforcementL());
|
|
513 |
DBG_ARGS(
|
|
514 |
_S16(
|
|
515 |
"CWlanSettings::WriteWlanSettings, check enforcement . error: <%D>"),
|
|
516 |
enError);
|
|
517 |
if (wlanEnforce)
|
|
518 |
{
|
|
519 |
TRAPD(lockError, enError = PerformLockWLANTablesL(EFalse));
|
|
520 |
if (lockError == KErrNone && enError == KErrNone)
|
|
521 |
{
|
|
522 |
iWLANRelock = ETrue;
|
|
523 |
}
|
|
524 |
}
|
|
525 |
}
|
|
526 |
|
|
527 |
if (RecordExists(aWlanSettings.ServiceID) <= 0)
|
|
528 |
{
|
|
529 |
err = iTableView->InsertRecord(aWlanSettings.Id);
|
|
530 |
if (err == KErrLocked)
|
|
531 |
{
|
|
532 |
_DBG_FILE("WriteWlanSettings InsertRecord: CommsDat was locked.");
|
|
533 |
TInt retry = KBeginTransRetryCount;
|
|
534 |
while (retry > 0 && err == KErrLocked)
|
|
535 |
{
|
|
536 |
User::After(KBeginTransRetryDelay);
|
|
537 |
_DBG_FILE("WriteWlanSettings: Slept 1 second. Try again");
|
|
538 |
err = iTableView->InsertRecord(aWlanSettings.Id);
|
|
539 |
retry--;
|
|
540 |
}
|
|
541 |
}
|
|
542 |
|
|
543 |
if (err != KErrNone)
|
|
544 |
{
|
|
545 |
DBG_ARGS(
|
|
546 |
_S16(
|
|
547 |
"CWlanSettings::WriteWlanSettings(): - InsertRecord failed. error: <%D>"),
|
|
548 |
err);
|
|
549 |
|
|
550 |
if (FeatureManager::FeatureSupported(
|
|
551 |
KFeatureIdSapPolicyManagement))
|
|
552 |
{
|
|
553 |
TInt tableLockError = KErrNone;
|
|
554 |
if (iWLANRelock)
|
|
555 |
{
|
|
556 |
TInt lockError = KErrNone;
|
|
557 |
TRAP(lockError, tableLockError = PerformLockWLANTablesL(
|
|
558 |
ETrue));
|
|
559 |
DBG_ARGS(
|
|
560 |
_S16(
|
|
561 |
"CWlanSettings::WriteWlanSettings, WLAN table Lock error. error: <%D>, <%D> "),
|
|
562 |
lockError, tableLockError);
|
|
563 |
iWLANRelock = EFalse;
|
|
564 |
}
|
|
565 |
if (tableLockError != KErrNone) // to remove warnings
|
|
566 |
{
|
|
567 |
tableLockError = KErrNone;
|
|
568 |
}
|
|
569 |
}
|
|
570 |
return err;
|
|
571 |
}
|
|
572 |
TRAP(err, InitialiseRecordL());
|
|
573 |
if (err != KErrNone)
|
|
574 |
{
|
|
575 |
DBG_ARGS(
|
|
576 |
_S16(
|
|
577 |
"CWlanSettings::WriteWlanSettings(): - InitialiseRecord failed. error: <%D>"),
|
|
578 |
err);
|
|
579 |
|
|
580 |
if (FeatureManager::FeatureSupported(
|
|
581 |
KFeatureIdSapPolicyManagement))
|
|
582 |
{
|
|
583 |
TInt tableLockError = KErrNone;
|
|
584 |
if (iWLANRelock)
|
|
585 |
{
|
|
586 |
TInt lockError = KErrNone;
|
|
587 |
TRAP(lockError, tableLockError = PerformLockWLANTablesL(
|
|
588 |
ETrue));
|
|
589 |
DBG_ARGS(
|
|
590 |
_S16(
|
|
591 |
"CWlanSettings::WriteWlanSettings, WLAN table Lock error. error: <%D>, <%D> "),
|
|
592 |
lockError, tableLockError);
|
|
593 |
iWLANRelock = EFalse;
|
|
594 |
}
|
|
595 |
if (tableLockError != KErrNone) // to remove warnings
|
|
596 |
{
|
|
597 |
tableLockError = KErrNone;
|
|
598 |
}
|
|
599 |
}
|
|
600 |
return err;
|
|
601 |
}
|
|
602 |
}
|
|
603 |
else
|
|
604 |
{
|
|
605 |
err = GoToRecord(aWlanSettings.ServiceID);
|
|
606 |
if (err == KErrNone)
|
|
607 |
{
|
|
608 |
|
|
609 |
if (FeatureManager::FeatureSupported(
|
|
610 |
KFeatureIdSapPolicyManagement))
|
|
611 |
{
|
|
612 |
if (wlanEnforce)
|
|
613 |
{
|
|
614 |
_DBG_FILE(
|
|
615 |
"CWlanSettings::WriteWlanSettings(): unprotect wlan");
|
|
616 |
((CCommsDbProtectTableView*) iTableView)->UnprotectRecord();
|
|
617 |
}
|
|
618 |
}
|
|
619 |
|
|
620 |
err = iTableView->UpdateRecord();
|
|
621 |
if (err == KErrLocked)
|
|
622 |
{
|
|
623 |
_DBG_FILE("WriteWlanSettings: UpdateRecord was locked.");
|
|
624 |
TInt retry = KBeginTransRetryCount;
|
|
625 |
while (retry > 0 && err == KErrLocked)
|
|
626 |
{
|
|
627 |
User::After(KBeginTransRetryDelay);
|
|
628 |
_DBG_FILE("WriteWlanSettings: Slept 1 second. Try again");
|
|
629 |
err = iTableView->UpdateRecord();
|
|
630 |
retry--;
|
|
631 |
}
|
|
632 |
if (err != KErrNone)
|
|
633 |
{
|
|
634 |
_DBG_FILE(
|
|
635 |
"WriteWlanSettings: UpdateRecord was unsuccessful");
|
|
636 |
}
|
|
637 |
else
|
|
638 |
{
|
|
639 |
_DBG_FILE(
|
|
640 |
"WriteWlanSettings: UpdateRecord was successful");
|
|
641 |
}
|
|
642 |
}
|
|
643 |
|
|
644 |
if (err != KErrNone)
|
|
645 |
{
|
|
646 |
DBG_ARGS(
|
|
647 |
_S16(
|
|
648 |
"CWlanSettings::WriteWlanSettings(): - UpdateRecord failed. error: <%D>"),
|
|
649 |
err);
|
|
650 |
|
|
651 |
if (FeatureManager::FeatureSupported(
|
|
652 |
KFeatureIdSapPolicyManagement))
|
|
653 |
{
|
|
654 |
TInt tableLockError = KErrNone;
|
|
655 |
if (iWLANRelock)
|
|
656 |
{
|
|
657 |
TInt lockError = KErrNone;
|
|
658 |
TRAP(lockError, tableLockError
|
|
659 |
= PerformLockWLANTablesL(ETrue));
|
|
660 |
DBG_ARGS(
|
|
661 |
_S16(
|
|
662 |
"CWlanSettings::WriteWlanSettings, WLAN table Lock error. error: <%D>, <%D> "),
|
|
663 |
lockError, tableLockError);
|
|
664 |
((CCommsDbProtectTableView*) iTableView)->ProtectRecord();
|
|
665 |
iWLANRelock = EFalse;
|
|
666 |
}
|
|
667 |
if (tableLockError != KErrNone) // to remove warnings
|
|
668 |
{
|
|
669 |
tableLockError = KErrNone;
|
|
670 |
}
|
|
671 |
}
|
|
672 |
return err;
|
|
673 |
}
|
|
674 |
}
|
|
675 |
}
|
|
676 |
|
|
677 |
TRAP(err, WriteDataToRecordL(&aWlanSettings));
|
|
678 |
|
|
679 |
if (err == KErrNone)
|
|
680 |
{
|
|
681 |
_DBG_FILE("CWlanSettings::WriteWlanSettings(): PutRecordChanges");
|
|
682 |
err = iTableView->PutRecordChanges();
|
|
683 |
if (err == KErrLocked)
|
|
684 |
{
|
|
685 |
_DBG_FILE("WriteWlanSettings: PutRecordChanges was locked.");
|
|
686 |
TInt retry = KBeginTransRetryCount;
|
|
687 |
while (retry > 0 && err == KErrLocked)
|
|
688 |
{
|
|
689 |
User::After(KBeginTransRetryDelay);
|
|
690 |
_DBG_FILE("WriteWlanSettings: Slept 1 second. Try again");
|
|
691 |
err = iTableView->PutRecordChanges();
|
|
692 |
retry--;
|
|
693 |
}
|
|
694 |
}
|
|
695 |
if (err != KErrNone)
|
|
696 |
{
|
|
697 |
_DBG_FILE("WriteWlanSettings: PutRecordChanges was unsuccessful");
|
|
698 |
}
|
|
699 |
else
|
|
700 |
{
|
|
701 |
_DBG_FILE("WriteWlanSettings: PutRecordChanges was successful");
|
|
702 |
}
|
|
703 |
}
|
|
704 |
if (FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement))
|
|
705 |
{
|
|
706 |
if (iWLANRelock)
|
|
707 |
{
|
|
708 |
TInt lockError = KErrNone;
|
|
709 |
TRAP(lockError, enError = PerformLockWLANTablesL(ETrue));
|
|
710 |
DBG_ARGS(
|
|
711 |
_S16(
|
|
712 |
"CWlanSettings::WriteWlanSettings, WLAN table Lock error. error: <%D>, <%D> "),
|
|
713 |
lockError, enError);
|
|
714 |
iWLANRelock = EFalse;
|
|
715 |
}
|
|
716 |
}
|
|
717 |
DBG_ARGS(_S16("CWlanSettings::WriteWlanSettings(): end. err: <%D>"), err);
|
|
718 |
return err;
|
|
719 |
}
|
|
720 |
|
|
721 |
//-----------------------------------------------------------------------------
|
|
722 |
// TInt CWlanSettings::WriteWlanSettings( TWlanSettings& aWlanSettings )
|
|
723 |
//-----------------------------------------------------------------------------
|
|
724 |
TInt CWlanSettings::WriteSecondarySSIDL(TUint32 aWlanID,
|
|
725 |
TSecondarySSID& aSettings, TBool aNew)
|
|
726 |
{
|
|
727 |
|
|
728 |
_DBG_FILE("CWlanSettings::WriteSecondarySSIDL(): begin");
|
|
729 |
|
|
730 |
TUint32 id = 0;
|
|
731 |
delete iSecondaryView;
|
|
732 |
iSecondaryView = NULL;
|
|
733 |
|
|
734 |
TInt retval = KErrNone;
|
|
735 |
TInt reLock = EFalse;
|
|
736 |
TBool apEnforce = EFalse;
|
|
737 |
|
|
738 |
if (FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement))
|
|
739 |
{
|
|
740 |
TRAPD(eError,apEnforce=CheckEnforcementL())
|
|
741 |
DBG_ARGS8(_S8("CNSmlInternetAdapter::WriteSecondarySSIDL(): EError %d , APEnforcement is %d"),eError,apEnforce);
|
|
742 |
if (eError == KErrNone && apEnforce)
|
|
743 |
{
|
|
744 |
_DBG_FILE("CWlanSettings::WriteSecondarySSIDL(): set db protect");
|
|
745 |
TInt enError = KErrNone;
|
|
746 |
TInt lockError = KErrNone;
|
|
747 |
TRAP(lockError, enError = PerformLockWLANTablesL(EFalse));
|
|
748 |
reLock = ETrue;
|
|
749 |
if (enError != KErrNone) // to remove warnings
|
|
750 |
{
|
|
751 |
enError = KErrNone;
|
|
752 |
}
|
|
753 |
}
|
|
754 |
}
|
|
755 |
|
|
756 |
if (aNew)
|
|
757 |
{
|
|
758 |
_DBG_FILE("CWlanSettings::WriteSecondarySSIDL(): new table inserted");
|
|
759 |
iSecondaryView = iDatabase.OpenTableLC(TPtrC(WLAN_SECONDARY_SSID));
|
|
760 |
CleanupStack::Pop(iSecondaryView); // iSecondaryView
|
|
761 |
retval = iSecondaryView->InsertRecord(id);
|
|
762 |
|
|
763 |
if (retval == KErrLocked)
|
|
764 |
{
|
|
765 |
_DBG_FILE("WriteSecondarySSIDL: InsertRecord was locked.");
|
|
766 |
TInt retry = KBeginTransRetryCount;
|
|
767 |
while (retry > 0 && retval == KErrLocked)
|
|
768 |
{
|
|
769 |
User::After(KBeginTransRetryDelay);
|
|
770 |
_DBG_FILE("WriteSecondarySSIDL: Slept 1 second. Try again");
|
|
771 |
retval = iSecondaryView->InsertRecord(id);
|
|
772 |
retry--;
|
|
773 |
}
|
|
774 |
}
|
|
775 |
if (retval != KErrNone)
|
|
776 |
{
|
|
777 |
_DBG_FILE("WriteSecondarySSIDL: InsertRecord was unsuccessful");
|
|
778 |
}
|
|
779 |
else
|
|
780 |
{
|
|
781 |
_DBG_FILE("WriteSecondarySSIDL: InsertRecord was successful");
|
|
782 |
}
|
|
783 |
|
|
784 |
DBG_ARGS8(
|
|
785 |
_S8(
|
|
786 |
"CNSmlInternetAdapter::WriteSecondarySSIDL(): Add record, error %d"),
|
|
787 |
retval);
|
|
788 |
if (retval == KErrNone)
|
|
789 |
{
|
|
790 |
_DBG_FILE(
|
|
791 |
"CWlanSettings::WriteSecondarySSIDL(): table insertion went ok");
|
|
792 |
iSecondaryView->WriteUintL(TPtrC(WLAN_SEC_SSID_SERVICE_ID),
|
|
793 |
aWlanID);
|
|
794 |
iSecondaryView->WriteUintL(TPtrC(WLAN_SEC_SSID_ID), id);
|
|
795 |
}
|
|
796 |
}
|
|
797 |
else
|
|
798 |
{
|
|
799 |
_DBG_FILE(
|
|
800 |
"CWlanSettings::WriteSecondarySSIDL(): table exists, find it");
|
|
801 |
iSecondaryView = iDatabase.OpenViewMatchingUintLC(TPtrC(
|
|
802 |
WLAN_SECONDARY_SSID), TPtrC(WLAN_SEC_SSID_ID), aSettings.Id);
|
|
803 |
CleanupStack::Pop(iSecondaryView); // iSecondaryView
|
|
804 |
TInt err = iSecondaryView->GotoFirstRecord();
|
|
805 |
if (err != KErrNone)
|
|
806 |
{
|
|
807 |
_DBG_FILE(
|
|
808 |
"CWlanSettings::WriteSecondarySSIDL(): go to first record failed");
|
|
809 |
// most likely KErrNotFound, something wrong with the URI parsing probably
|
|
810 |
return err;
|
|
811 |
}
|
|
812 |
if (FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement))
|
|
813 |
{
|
|
814 |
if (apEnforce)
|
|
815 |
{
|
|
816 |
((CCommsDbProtectTableView*) iSecondaryView)->UnprotectRecord();
|
|
817 |
}
|
|
818 |
}
|
|
819 |
retval = iSecondaryView->UpdateRecord();
|
|
820 |
if (retval == KErrLocked)
|
|
821 |
{
|
|
822 |
_DBG_FILE("WriteSecondarySSIDL: UpdateRecord was locked.");
|
|
823 |
TInt retry = KBeginTransRetryCount;
|
|
824 |
while (retry > 0 && retval == KErrLocked)
|
|
825 |
{
|
|
826 |
User::After(KBeginTransRetryDelay);
|
|
827 |
_DBG_FILE("WriteSecondarySSIDL: Slept 1 second. Try again");
|
|
828 |
retval = iSecondaryView->UpdateRecord();
|
|
829 |
retry--;
|
|
830 |
}
|
|
831 |
}
|
|
832 |
if (retval != KErrNone)
|
|
833 |
{
|
|
834 |
_DBG_FILE("WriteSecondarySSIDL: UpdateRecord was unsuccessful");
|
|
835 |
}
|
|
836 |
else
|
|
837 |
{
|
|
838 |
_DBG_FILE("WriteSecondarySSIDL: UpdateRecord was successful");
|
|
839 |
}
|
|
840 |
}
|
|
841 |
if (retval == KErrNone)
|
|
842 |
{
|
|
843 |
DBG_ARGS8(
|
|
844 |
_S8(
|
|
845 |
"CWlanSettings::writesecondaryssids - WLAN_SEC_SSID_SCANNED_SSID uri: <%S> ad WLAN_SEC_SSID_USED_SSID : <%S>"),
|
|
846 |
&aSettings.ScannedId, &aSettings.UsedId);
|
|
847 |
iSecondaryView->WriteTextL(TPtrC(WLAN_SEC_SSID_SCANNED_SSID),
|
|
848 |
aSettings.ScannedId);
|
|
849 |
iSecondaryView->WriteTextL(TPtrC(WLAN_SEC_SSID_USED_SSID),
|
|
850 |
aSettings.UsedId);
|
|
851 |
|
|
852 |
retval = iSecondaryView->PutRecordChanges();
|
|
853 |
if (retval == KErrLocked)
|
|
854 |
{
|
|
855 |
_DBG_FILE("WriteSecondarySSIDL: PutRecordChanges was locked.");
|
|
856 |
TInt retry = KBeginTransRetryCount;
|
|
857 |
while (retry > 0 && retval == KErrLocked)
|
|
858 |
{
|
|
859 |
User::After(KBeginTransRetryDelay);
|
|
860 |
_DBG_FILE("WriteSecondarySSIDL: Slept 1 second. Try again");
|
|
861 |
retval = iSecondaryView->PutRecordChanges();
|
|
862 |
retry--;
|
|
863 |
}
|
|
864 |
}
|
|
865 |
if (retval != KErrNone)
|
|
866 |
{
|
|
867 |
_DBG_FILE(
|
|
868 |
"WriteSecondarySSIDL: PutRecordChanges was unsuccessful");
|
|
869 |
}
|
|
870 |
else
|
|
871 |
{
|
|
872 |
_DBG_FILE("WriteSecondarySSIDL: PutRecordChanges was successful");
|
|
873 |
}
|
|
874 |
}
|
|
875 |
|
|
876 |
if (FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement))
|
|
877 |
{
|
|
878 |
if (reLock)
|
|
879 |
{
|
|
880 |
TInt enError = KErrNone;
|
|
881 |
TInt lockError = KErrNone;
|
|
882 |
TRAP(lockError, enError = PerformLockWLANTablesL(ETrue));
|
67
|
883 |
if (apEnforce)
|
47
|
884 |
{
|
|
885 |
((CCommsDbProtectTableView*) iSecondaryView)->ProtectRecord();
|
|
886 |
}
|
|
887 |
if (enError != KErrNone) // to remove warnings
|
|
888 |
{
|
|
889 |
enError = KErrNone;
|
|
890 |
}
|
|
891 |
}
|
|
892 |
}
|
|
893 |
|
|
894 |
// This makes sure that there will be no calling to GotoFirstRecord()
|
|
895 |
// before secondaryview is reinitialized, (causes a panic if that would happen)
|
|
896 |
delete iSecondaryView;
|
|
897 |
iSecondaryView = NULL;
|
|
898 |
|
|
899 |
if (reLock && apEnforce)
|
|
900 |
{
|
|
901 |
reLock = EFalse; // to get rid of warnings
|
|
902 |
apEnforce = EFalse;
|
|
903 |
}
|
|
904 |
|
|
905 |
return retval;
|
|
906 |
|
|
907 |
}
|
|
908 |
|
|
909 |
TInt CWlanSettings::WriteEAPSettings(EAPSettings& aEapSettings)
|
|
910 |
{
|
|
911 |
TRAPD(err, iEapType->SetConfigurationL(aEapSettings));
|
|
912 |
return err;
|
|
913 |
}
|
|
914 |
|
|
915 |
//-----------------------------------------------------------------------------
|
|
916 |
// void CWlanSettings::ConnectToDatabaseL( )
|
|
917 |
//-----------------------------------------------------------------------------
|
|
918 |
void CWlanSettings::ConnectToDatabaseL()
|
|
919 |
{
|
|
920 |
_DBG_FILE("CWlanSettings::ConnectToDatabaseL(): begin");
|
|
921 |
|
|
922 |
if (!iTableView)
|
|
923 |
{
|
|
924 |
iTableView = iDatabase.OpenTableLC(TPtrC(WLAN_SERVICE));
|
|
925 |
|
|
926 |
if (iTableView == NULL)
|
|
927 |
{
|
|
928 |
_DBG_FILE(
|
|
929 |
"CWlanSettings::ConnectToDatabaseL(): could not open table");
|
|
930 |
User::Leave(KErrCouldNotConnect);
|
|
931 |
}
|
|
932 |
|
|
933 |
CleanupStack::Pop(iTableView); //iTableView
|
|
934 |
}
|
|
935 |
|
|
936 |
_DBG_FILE("CWlanSettings::ConnectToDatabaseL(): end");
|
|
937 |
}
|
|
938 |
|
|
939 |
void CWlanSettings::GetEAPInterfaceL(const TInt aId,
|
|
940 |
TEapExpandedType& aEncapsId, TEapExpandedType& aExpandedId)
|
|
941 |
{
|
|
942 |
if (aId < 0)
|
|
943 |
{
|
|
944 |
// Illegal input
|
|
945 |
User::Leave(KErrArgument);
|
|
946 |
}
|
|
947 |
|
|
948 |
if (iEapType)
|
|
949 |
{
|
|
950 |
delete iEapType;
|
|
951 |
iEapType = NULL;
|
|
952 |
}
|
|
953 |
TInt err = KErrNone;
|
|
954 |
TRAP(err, iEapType = CEapType::NewL(ELan, aId, aExpandedId));
|
|
955 |
|
|
956 |
if (err == KErrNone)
|
|
957 |
{
|
|
958 |
if (aEncapsId != (*EapExpandedTypeNone.GetType()))
|
|
959 |
{
|
|
960 |
iEapType->SetTunnelingType(aEncapsId);
|
|
961 |
}
|
|
962 |
}
|
|
963 |
}
|
|
964 |
|
|
965 |
//-----------------------------------------------------------------------------
|
|
966 |
// TInt CWlanSettings::GoToRecord( TUint32 aId )
|
|
967 |
// Moves iTableView to point record whose id-number equals to aId
|
|
968 |
//-----------------------------------------------------------------------------
|
|
969 |
TInt CWlanSettings::GoToRecord(TUint32 aId)
|
|
970 |
{
|
|
971 |
_DBG_FILE("CWlanSettings::GoToRecord(): begin");
|
|
972 |
DBG_ARGS(
|
|
973 |
_S16("CWlanSettings::GoToRecord(): begin Search record id: <%D>"),
|
|
974 |
aId);
|
|
975 |
|
|
976 |
TInt err = iTableView->GotoFirstRecord();
|
|
977 |
if (err != KErrNone)
|
|
978 |
{
|
|
979 |
DBG_ARGS(
|
|
980 |
_S16(
|
|
981 |
"CWlanSettings::GoToRecord(): end, GotoFirstRecord. err: <%D>"),
|
|
982 |
err);
|
|
983 |
return err;
|
|
984 |
}
|
|
985 |
|
|
986 |
TUint32 id = 0;
|
|
987 |
TRAP(err, iTableView->ReadUintL(TPtrC(WLAN_SERVICE_ID), id));
|
|
988 |
if (err != KErrNone)
|
|
989 |
{
|
|
990 |
DBG_ARGS(_S16(
|
|
991 |
"CWlanSettings::GoToRecord(): end, ReadUintL. err: <%D>"),
|
|
992 |
err);
|
|
993 |
return err;
|
|
994 |
}
|
|
995 |
|
|
996 |
while (aId != id)
|
|
997 |
{
|
|
998 |
err = iTableView->GotoNextRecord();
|
|
999 |
if (err != KErrNone)
|
|
1000 |
{
|
|
1001 |
DBG_ARGS(
|
|
1002 |
_S16(
|
|
1003 |
"CWlanSettings::GoToRecord(): end, GotoNextRecord. err: <%D>"),
|
|
1004 |
err);
|
|
1005 |
return err;
|
|
1006 |
}
|
|
1007 |
|
|
1008 |
TRAP(err, iTableView->ReadUintL(TPtrC(WLAN_SERVICE_ID), id));
|
|
1009 |
|
|
1010 |
if (err == KErrNone)
|
|
1011 |
{
|
|
1012 |
DBG_ARGS(_S16(
|
|
1013 |
"CWlanSettings::GoToRecord(): Found service id: <%D>"),
|
|
1014 |
id);
|
|
1015 |
}
|
|
1016 |
else
|
|
1017 |
{
|
|
1018 |
DBG_ARGS(
|
|
1019 |
_S16(
|
|
1020 |
"CWlanSettings::GoToRecord(): end, ReadUintL next. err: <%D>"),
|
|
1021 |
err);
|
|
1022 |
return err;
|
|
1023 |
}
|
|
1024 |
}
|
|
1025 |
|
|
1026 |
TRAP(err, SetSecondaryViewToRecordL(aId));
|
|
1027 |
|
|
1028 |
DBG_ARGS(_S16("CWlanSettings::GoToRecord(): end. Final record id: <%D>"),
|
|
1029 |
id);
|
|
1030 |
|
|
1031 |
return err;
|
|
1032 |
}
|
|
1033 |
|
|
1034 |
void CWlanSettings::SetSecondaryViewToRecordL(TUint32 aId)
|
|
1035 |
{
|
|
1036 |
// optional secondarySSID
|
|
1037 |
if (iSecondaryView)
|
|
1038 |
{
|
|
1039 |
delete iSecondaryView;
|
|
1040 |
iSecondaryView = NULL;
|
|
1041 |
}
|
|
1042 |
|
|
1043 |
// first open a view to secondary ssid table, with all the rows with service id
|
|
1044 |
// matching the wlan service id (count can be zero)
|
|
1045 |
iSecondaryView = iDatabase.OpenViewMatchingUintLC(TPtrC(
|
|
1046 |
WLAN_SECONDARY_SSID), TPtrC(WLAN_SEC_SSID_SERVICE_ID), aId);
|
|
1047 |
if (iSecondaryView == NULL)
|
|
1048 |
{
|
|
1049 |
// this should not happen in a normal situation
|
|
1050 |
User::Leave(KErrCouldNotConnect);
|
|
1051 |
}
|
|
1052 |
CleanupStack::Pop(iSecondaryView);
|
|
1053 |
}
|
|
1054 |
|
|
1055 |
//-----------------------------------------------------------------------------
|
|
1056 |
// void CWlanSettings::GetDataFromRecordL( TWlanSettings* aWlanSettings )
|
|
1057 |
// Read settings from database to aWlanSettings structure
|
|
1058 |
//-----------------------------------------------------------------------------
|
|
1059 |
void CWlanSettings::GetDataFromRecordL(TWlanSettings* aWlanSettings)
|
|
1060 |
{
|
|
1061 |
_DBG_FILE("CWlanSettings::GetDataFromRecordL(): begin");
|
|
1062 |
|
|
1063 |
TInt leavecode = 0;
|
|
1064 |
|
|
1065 |
aWlanSettings->ServiceID = 0;
|
|
1066 |
aWlanSettings->ConnectionMode = 0;
|
|
1067 |
aWlanSettings->SSID = _L("");
|
|
1068 |
aWlanSettings->UsedSSID = _L("");
|
|
1069 |
aWlanSettings->ScanSSID = 0;
|
|
1070 |
aWlanSettings->WepKey1 = _L8("");
|
|
1071 |
aWlanSettings->WepKey2 = _L8("");
|
|
1072 |
aWlanSettings->WepKey3 = _L8("");
|
|
1073 |
aWlanSettings->WepKey4 = _L8("");
|
|
1074 |
aWlanSettings->WepIndex = 0;
|
|
1075 |
aWlanSettings->SecurityMode = EAllowUnsecure;
|
|
1076 |
aWlanSettings->WPAPreSharedKey = _L8("");
|
|
1077 |
aWlanSettings->UseWPAPSK = 0;
|
|
1078 |
aWlanSettings->EapList = _L("");
|
|
1079 |
aWlanSettings->AuthMode = 0;
|
|
1080 |
|
|
1081 |
TRAP(leavecode, iTableView->ReadUintL(TPtrC(WLAN_SERVICE_ID),
|
|
1082 |
aWlanSettings->ServiceID));
|
|
1083 |
if (leavecode != KErrNone)
|
|
1084 |
{
|
|
1085 |
DBG_ARGS(
|
|
1086 |
_S16(
|
|
1087 |
"CWlanSettings::GetDataFromRecordL(): WLAN_SERVICE_ID read error: <%D>"),
|
|
1088 |
leavecode);
|
|
1089 |
}
|
|
1090 |
|
|
1091 |
TRAP(leavecode, iTableView->ReadUintL(TPtrC(WLAN_CONNECTION_MODE),
|
|
1092 |
aWlanSettings->ConnectionMode));
|
|
1093 |
if (leavecode != KErrNone)
|
|
1094 |
{
|
|
1095 |
DBG_ARGS(
|
|
1096 |
_S16(
|
|
1097 |
"CWlanSettings::GetDataFromRecordL(): WLAN_CONNECTION_MODE read error: <%D>"),
|
|
1098 |
leavecode);
|
|
1099 |
}
|
|
1100 |
|
|
1101 |
TRAP(leavecode, iTableView->ReadUintL(TPtrC(NU_WLAN_AUTHENTICATION_MODE),
|
|
1102 |
aWlanSettings->AuthMode));
|
|
1103 |
if (leavecode != KErrNone)
|
|
1104 |
{
|
|
1105 |
DBG_ARGS(
|
|
1106 |
_S16(
|
|
1107 |
"CWlanSettings::GetDataFromRecordL(): NU_WLAN_AUTHENTICATION_MODE read error: <%D>"),
|
|
1108 |
leavecode);
|
|
1109 |
}
|
|
1110 |
|
|
1111 |
TRAP(leavecode, iTableView->ReadUintL(TPtrC(WLAN_WEP_INDEX),
|
|
1112 |
aWlanSettings->WepIndex));
|
|
1113 |
if (leavecode != KErrNone)
|
|
1114 |
{
|
|
1115 |
DBG_ARGS(
|
|
1116 |
_S16(
|
|
1117 |
"CWlanSettings::GetDataFromRecordL(): WLAN_WEP_INDEX read error: <%D>"),
|
|
1118 |
leavecode);
|
|
1119 |
}
|
|
1120 |
|
|
1121 |
TRAP(leavecode, iTableView->ReadUintL(TPtrC(WLAN_SECURITY_MODE),
|
|
1122 |
aWlanSettings->SecurityMode));
|
|
1123 |
if (leavecode != KErrNone)
|
|
1124 |
{
|
|
1125 |
DBG_ARGS(
|
|
1126 |
_S16(
|
|
1127 |
"CWlanSettings::GetDataFromRecordL(): WLAN_SECURITY_MODE read error: <%D>"),
|
|
1128 |
leavecode);
|
|
1129 |
}
|
|
1130 |
|
|
1131 |
TRAP(leavecode, iTableView->ReadUintL(TPtrC(WLAN_ENABLE_WPA_PSK),
|
|
1132 |
aWlanSettings->UseWPAPSK));
|
|
1133 |
if (leavecode != KErrNone)
|
|
1134 |
{
|
|
1135 |
DBG_ARGS(
|
|
1136 |
_S16(
|
|
1137 |
"CWlanSettings::GetDataFromRecordL(): WLAN_ENABLE_WPA_PSK read error: <%D>"),
|
|
1138 |
leavecode);
|
|
1139 |
}
|
|
1140 |
|
|
1141 |
TBuf8<KCommsDbSvrMaxFieldLength> columnValue8;
|
|
1142 |
TRAP(leavecode, iTableView->ReadTextL(TPtrC(NU_WLAN_WEP_KEY1),
|
|
1143 |
columnValue8));
|
|
1144 |
if ((leavecode == KErrNone) && (columnValue8.Length() > 0))
|
|
1145 |
{
|
|
1146 |
aWlanSettings->WepKey1 = columnValue8;
|
|
1147 |
}
|
|
1148 |
else
|
|
1149 |
{
|
|
1150 |
DBG_ARGS(
|
|
1151 |
_S16(
|
|
1152 |
"CWlanSettings::GetDataFromRecordL(): NU_WLAN_WEP_KEY1 read error: <%D>"),
|
|
1153 |
leavecode);
|
|
1154 |
}
|
|
1155 |
|
|
1156 |
TRAP(leavecode, iTableView->ReadTextL(TPtrC(NU_WLAN_WEP_KEY2),
|
|
1157 |
columnValue8));
|
|
1158 |
if ((leavecode == KErrNone) && (columnValue8.Length() > 0))
|
|
1159 |
{
|
|
1160 |
aWlanSettings->WepKey2 = columnValue8;
|
|
1161 |
}
|
|
1162 |
else
|
|
1163 |
{
|
|
1164 |
DBG_ARGS(
|
|
1165 |
_S16(
|
|
1166 |
"CWlanSettings::GetDataFromRecordL(): NU_WLAN_WEP_KEY2 read error: <%D>"),
|
|
1167 |
leavecode);
|
|
1168 |
}
|
|
1169 |
|
|
1170 |
TRAP(leavecode, iTableView->ReadTextL(TPtrC(NU_WLAN_WEP_KEY3),
|
|
1171 |
columnValue8));
|
|
1172 |
if ((leavecode == KErrNone) && (columnValue8.Length() > 0))
|
|
1173 |
{
|
|
1174 |
aWlanSettings->WepKey3 = columnValue8;
|
|
1175 |
}
|
|
1176 |
else
|
|
1177 |
{
|
|
1178 |
DBG_ARGS(
|
|
1179 |
_S16(
|
|
1180 |
"CWlanSettings::GetDataFromRecordL(): NU_WLAN_WEP_KEY3 read error: <%D>"),
|
|
1181 |
leavecode);
|
|
1182 |
}
|
|
1183 |
|
|
1184 |
TRAP(leavecode, iTableView->ReadTextL(TPtrC(NU_WLAN_WEP_KEY4),
|
|
1185 |
columnValue8));
|
|
1186 |
if ((leavecode == KErrNone) && (columnValue8.Length() > 0))
|
|
1187 |
{
|
|
1188 |
aWlanSettings->WepKey4 = columnValue8;
|
|
1189 |
}
|
|
1190 |
else
|
|
1191 |
{
|
|
1192 |
DBG_ARGS(
|
|
1193 |
_S16(
|
|
1194 |
"CWlanSettings::GetDataFromRecordL(): NU_WLAN_WEP_KEY4 read error: <%D>"),
|
|
1195 |
leavecode);
|
|
1196 |
}
|
|
1197 |
|
|
1198 |
TBuf8<KMaxPSKLength> precolumnValue8;
|
|
1199 |
TBuf<KCommsDbSvrMaxFieldLength> columnValue;
|
|
1200 |
|
|
1201 |
_DBG_FILE(
|
|
1202 |
"CWlanSettings::GetDataFromRecordL(): Before getting WLAN_WPA_PRE_SHARED_KEY ");
|
|
1203 |
TRAP(leavecode, iTableView->ReadTextL(TPtrC(WLAN_WPA_PRE_SHARED_KEY),
|
|
1204 |
precolumnValue8));
|
|
1205 |
DBG_ARGS(
|
|
1206 |
_S16(
|
|
1207 |
"CWlanSettings::ReadTextL( TPtrC(WLAN_WPA_PRE_SHARED_KEY ),length of key: <%D>"),
|
|
1208 |
precolumnValue8.Length());
|
|
1209 |
if ((leavecode == KErrNone) && (precolumnValue8.Length() > 0))
|
|
1210 |
{
|
|
1211 |
aWlanSettings->WPAPreSharedKey = precolumnValue8;
|
|
1212 |
}
|
|
1213 |
else
|
|
1214 |
{
|
|
1215 |
DBG_ARGS(
|
|
1216 |
_S16(
|
|
1217 |
"CWlanSettings::GetDataFromRecordL(): WLAN_WPA_PRE_SHARED_KEY read error: <%D>"),
|
|
1218 |
leavecode);
|
|
1219 |
}
|
|
1220 |
|
|
1221 |
TRAP(leavecode, iTableView->ReadTextL(TPtrC(NU_WLAN_SSID), columnValue));
|
|
1222 |
if ((leavecode == KErrNone) && (columnValue.Length() > 0))
|
|
1223 |
{
|
|
1224 |
aWlanSettings->SSID = columnValue;
|
|
1225 |
}
|
|
1226 |
else
|
|
1227 |
{
|
|
1228 |
DBG_ARGS(
|
|
1229 |
_S16(
|
|
1230 |
"CWlanSettings::GetDataFromRecordL(): NU_WLAN_SSID read error: <%D>"),
|
|
1231 |
leavecode);
|
|
1232 |
}
|
|
1233 |
|
|
1234 |
TRAP(leavecode, iTableView->ReadTextL(TPtrC(WLAN_USED_SSID), columnValue));
|
|
1235 |
if ((leavecode == KErrNone) && (columnValue.Length() > 0))
|
|
1236 |
{
|
|
1237 |
aWlanSettings->UsedSSID = columnValue;
|
|
1238 |
_DBG_FILE(
|
|
1239 |
"CWlanSettings::GetDataFromRecordL(): WLAN_USED_SSID reading ok");
|
|
1240 |
}
|
|
1241 |
else
|
|
1242 |
{
|
|
1243 |
DBG_ARGS(
|
|
1244 |
_S16(
|
|
1245 |
"CWlanSettings::GetDataFromRecordL(): WLAN_USED_SSID read error: <%D>"),
|
|
1246 |
leavecode);
|
|
1247 |
}
|
|
1248 |
|
|
1249 |
iTableView->ReadTextL(TPtrC(WLAN_USED_SSID), aWlanSettings->UsedSSID);
|
|
1250 |
_DBG_FILE("CWlanSettings::GetDataFromRecordL(): WLAN_USED_SSID");
|
|
1251 |
|
|
1252 |
TRAP(leavecode, iTableView->ReadUintL(TPtrC(WLAN_SCAN_SSID),
|
|
1253 |
aWlanSettings->ScanSSID));
|
|
1254 |
if (leavecode != KErrNone)
|
|
1255 |
{
|
|
1256 |
DBG_ARGS(
|
|
1257 |
_S16(
|
|
1258 |
"CWlanSettings::GetDataFromRecordL(): WLAN_SCAN_SSID read error: <%D>"),
|
|
1259 |
leavecode);
|
|
1260 |
}
|
|
1261 |
|
|
1262 |
TInt retval = iSecondaryView->GotoFirstRecord();
|
|
1263 |
if (retval == KErrNone)
|
|
1264 |
{
|
|
1265 |
aWlanSettings->SecondarySSIDsExisting = ETrue;
|
|
1266 |
}
|
|
1267 |
else
|
|
1268 |
{
|
|
1269 |
aWlanSettings->SecondarySSIDsExisting = EFalse;
|
|
1270 |
}
|
|
1271 |
|
|
1272 |
_DBG_FILE("CWlanSettings::GetDataFromRecordL(): WLAN_EAPS");
|
|
1273 |
|
|
1274 |
_DBG_FILE("CWlanSettings::GetDataFromRecordL(): end");
|
|
1275 |
}
|
|
1276 |
|
|
1277 |
//-----------------------------------------------------------------------------
|
|
1278 |
// void CWlanSettings::GetSecondarySSIDListL(TUint32 aId, RArray<TSecondarySSID>& aSecondarySSIDs)
|
|
1279 |
// Fills the array with secondarySSIDs, which are associated with given WLANID
|
|
1280 |
//-----------------------------------------------------------------------------
|
|
1281 |
void CWlanSettings::GetSecondarySSIDListL(TUint32 aWlanId, RArray<
|
|
1282 |
TSecondarySSID>& aSecondarySSIDs)
|
|
1283 |
{
|
|
1284 |
if (iSecondaryView == NULL)
|
|
1285 |
{
|
|
1286 |
// views haven't been initialized, in case of incorrect usage
|
|
1287 |
User::Leave(KErrNotReady);
|
|
1288 |
}
|
|
1289 |
|
|
1290 |
// set the view pointer into the first record
|
|
1291 |
TInt retval = iSecondaryView->GotoFirstRecord();
|
|
1292 |
if (retval != KErrNone)
|
|
1293 |
{
|
|
1294 |
return;
|
|
1295 |
}
|
|
1296 |
|
|
1297 |
// check that given id matches the current rowset. If not, then reinitialize
|
|
1298 |
TUint32 id;
|
|
1299 |
TInt err(KErrNone);
|
|
1300 |
TRAP(err, iSecondaryView->ReadUintL(TPtrC(WLAN_SEC_SSID_SERVICE_ID), id));
|
|
1301 |
if (id != aWlanId)
|
|
1302 |
{
|
|
1303 |
SetSecondaryViewToRecordL(aWlanId);
|
|
1304 |
retval = iSecondaryView->GotoFirstRecord();
|
|
1305 |
}
|
|
1306 |
|
|
1307 |
TBuf<KMaxTextLength> columnValue;
|
|
1308 |
|
|
1309 |
while (retval == KErrNone)
|
|
1310 |
{
|
|
1311 |
TSecondarySSID ssid;
|
|
1312 |
TRAP(retval, iSecondaryView->ReadUintL(TPtrC(WLAN_SEC_SSID_ID),
|
|
1313 |
ssid.Id));
|
|
1314 |
TRAP(retval, iSecondaryView->ReadTextL(TPtrC(
|
|
1315 |
WLAN_SEC_SSID_SCANNED_SSID), ssid.ScannedId));
|
|
1316 |
TRAP(retval, iSecondaryView->ReadTextL(
|
|
1317 |
TPtrC(WLAN_SEC_SSID_USED_SSID), ssid.UsedId));
|
|
1318 |
aSecondarySSIDs.Append(ssid);
|
|
1319 |
retval = iSecondaryView->GotoNextRecord();
|
|
1320 |
}
|
|
1321 |
}
|
|
1322 |
|
|
1323 |
//-----------------------------------------------------------------------------
|
|
1324 |
// void CWlanSettings::WriteDataToRecordL( TWlanSettings* aWlanSettings )
|
|
1325 |
// Writes settings to database from aWlanSettings structure
|
|
1326 |
//-----------------------------------------------------------------------------
|
|
1327 |
void CWlanSettings::WriteDataToRecordL(TWlanSettings* aWlanSettings)
|
|
1328 |
{
|
|
1329 |
_DBG_FILE("CWlanSettings::WriteDataToRecordL(): begin");
|
|
1330 |
|
|
1331 |
iTableView->WriteUintL(TPtrC(WLAN_SERVICE_ID), aWlanSettings->ServiceID);
|
|
1332 |
iTableView->WriteUintL(TPtrC(WLAN_CONNECTION_MODE),
|
|
1333 |
aWlanSettings->ConnectionMode);
|
|
1334 |
iTableView->WriteUintL(TPtrC(WLAN_WEP_INDEX), aWlanSettings->WepIndex);
|
|
1335 |
iTableView->WriteUintL(TPtrC(WLAN_SECURITY_MODE),
|
|
1336 |
aWlanSettings->SecurityMode);
|
|
1337 |
iTableView->WriteUintL(TPtrC(WLAN_ENABLE_WPA_PSK),
|
|
1338 |
aWlanSettings->UseWPAPSK);
|
|
1339 |
iTableView->WriteUintL(TPtrC(NU_WLAN_AUTHENTICATION_MODE),
|
|
1340 |
aWlanSettings->AuthMode);
|
|
1341 |
iTableView->WriteTextL(TPtrC(NU_WLAN_SSID), aWlanSettings->SSID);
|
|
1342 |
iTableView->WriteTextL(TPtrC(WLAN_USED_SSID), aWlanSettings->UsedSSID);
|
|
1343 |
iTableView->WriteUintL(TPtrC(WLAN_SCAN_SSID), aWlanSettings->ScanSSID);
|
|
1344 |
|
|
1345 |
iTableView->WriteTextL(TPtrC(NU_WLAN_WEP_KEY1), aWlanSettings->WepKey1);
|
|
1346 |
iTableView->WriteTextL(TPtrC(NU_WLAN_WEP_KEY2), aWlanSettings->WepKey2);
|
|
1347 |
iTableView->WriteTextL(TPtrC(NU_WLAN_WEP_KEY3), aWlanSettings->WepKey3);
|
|
1348 |
iTableView->WriteTextL(TPtrC(NU_WLAN_WEP_KEY4), aWlanSettings->WepKey4);
|
|
1349 |
iTableView->WriteUintL(TPtrC(WLAN_WEP_KEY1_FORMAT), 1); // 0 = Eascii, 1 = EHexadecimal
|
|
1350 |
iTableView->WriteUintL(TPtrC(WLAN_WEP_KEY2_FORMAT), 1);
|
|
1351 |
iTableView->WriteUintL(TPtrC(WLAN_WEP_KEY3_FORMAT), 1);
|
|
1352 |
iTableView->WriteUintL(TPtrC(WLAN_WEP_KEY4_FORMAT), 1);
|
|
1353 |
|
|
1354 |
iTableView->WriteTextL(TPtrC(WLAN_WPA_PRE_SHARED_KEY),
|
|
1355 |
aWlanSettings->WPAPreSharedKey);
|
|
1356 |
iTableView->WriteUintL(TPtrC(WLAN_WPA_KEY_LENGTH),
|
|
1357 |
aWlanSettings->WPAPreSharedKey.Length());
|
|
1358 |
|
|
1359 |
_DBG_FILE("CWlanSettings::WriteDataToRecordL(): end");
|
|
1360 |
}
|
|
1361 |
|
|
1362 |
//-----------------------------------------------------------------------------
|
|
1363 |
// TInt CWlanSettings::RecordExists( TUint32 aLuid )
|
|
1364 |
// Returns ETrue if record exists in database
|
|
1365 |
//-----------------------------------------------------------------------------
|
|
1366 |
TInt CWlanSettings::RecordExists(TUint32 aLuid)
|
|
1367 |
{
|
|
1368 |
_DBG_FILE("CWlanSettings::RecordExists(): begin");
|
|
1369 |
|
|
1370 |
TInt err = KErrNone;
|
|
1371 |
TRAP(err, ConnectToDatabaseL());
|
|
1372 |
|
|
1373 |
// If the connection went ok, then we can go to the record
|
|
1374 |
if (err == KErrNone)
|
|
1375 |
{
|
|
1376 |
err = GoToRecord(aLuid);
|
|
1377 |
}
|
|
1378 |
|
|
1379 |
if (err == KErrNone)
|
|
1380 |
{
|
|
1381 |
DBG_ARGS(
|
|
1382 |
_S16(
|
|
1383 |
"CWlanSettings::RecordExists(): end. GoToRecord OK err: <%D>"),
|
|
1384 |
err);
|
|
1385 |
return ETrue;
|
|
1386 |
}
|
|
1387 |
else
|
|
1388 |
{
|
|
1389 |
DBG_ARGS(
|
|
1390 |
_S16(
|
|
1391 |
"CWlanSettings::RecordExists(): end. GoToRecord error err: <%D>"),
|
|
1392 |
err);
|
|
1393 |
return err;
|
|
1394 |
}
|
|
1395 |
}
|
|
1396 |
|
|
1397 |
//-----------------------------------------------------------------------------
|
|
1398 |
// void CWlanSettings::InitialiseRecordL( )
|
|
1399 |
// Inserts mandatory values for commsdb
|
|
1400 |
//-----------------------------------------------------------------------------
|
|
1401 |
void CWlanSettings::InitialiseRecordL()
|
|
1402 |
{
|
|
1403 |
_DBG_FILE("CWlanSettings::InitialiseRecordL(): begin");
|
|
1404 |
|
|
1405 |
iTableView->WriteUintL(TPtrC(WLAN_WPA_KEY_LENGTH), 0);
|
|
1406 |
iTableView->WriteUintL(TPtrC(NU_WLAN_AUTHENTICATION_MODE), 0);
|
|
1407 |
|
|
1408 |
_DBG_FILE("CWlanSettings::InitialiseRecordL(): end");
|
|
1409 |
}
|
|
1410 |
|
|
1411 |
TInt CWlanSettings::InstalledEAPsL(CBufBase& aEAPList)
|
|
1412 |
{
|
|
1413 |
_DBG_FILE("CWlanSettings::InstalledEAPsL(): begin");
|
|
1414 |
|
|
1415 |
RImplInfoPtrArray ecomInfoArray;
|
|
1416 |
REComSession::ListImplementationsL(KEapTypeInterfaceUid, ecomInfoArray);
|
|
1417 |
|
|
1418 |
TUint eapId(0);
|
|
1419 |
|
|
1420 |
// First sort the EAPIds
|
|
1421 |
for (TInt i = 0; i < ecomInfoArray.Count(); i++)
|
|
1422 |
{
|
|
1423 |
if (ecomInfoArray[i]->DataType().Length() == KExpandedEAPIdLength)
|
|
1424 |
{
|
|
1425 |
// The EAP ID is in expanded type format
|
|
1426 |
// Only handle the vendor type of 0
|
|
1427 |
if ((ecomInfoArray[i]->DataType()[1] != 0
|
|
1428 |
|| ecomInfoArray[i]->DataType()[2] != 0
|
|
1429 |
|| ecomInfoArray[i]->DataType()[3] != 0)
|
|
1430 |
&& ((ecomInfoArray[i]->DataType()[7]
|
|
1431 |
!= KMschapv2TypeId[7])
|
|
1432 |
&& (ecomInfoArray[i]->DataType()[7]
|
|
1433 |
!= KTtlspapTypeId[7])))
|
|
1434 |
{
|
|
1435 |
// This is some other vendor type than IETF
|
|
1436 |
continue;
|
|
1437 |
}
|
|
1438 |
eapId = ecomInfoArray[i]->DataType()[7];
|
|
1439 |
_DBG_FILE(
|
|
1440 |
"CWlanSettings::InstalledEAPsL(): Expanded EAP id found.");
|
|
1441 |
}
|
|
1442 |
else
|
|
1443 |
{
|
|
1444 |
// The EAP ID is in old 8-bit format (as string)
|
|
1445 |
TLex8 lex(ecomInfoArray[i]->DataType());
|
|
1446 |
if (lex.Val(eapId) != KErrNone)
|
|
1447 |
{
|
|
1448 |
// Unsupported format. Ignore this.
|
|
1449 |
_DBG_FILE(
|
|
1450 |
"CWlanSettings::InstalledEAPsL(): Unsupported EAP id found.");
|
|
1451 |
continue;
|
|
1452 |
}
|
|
1453 |
_DBG_FILE(
|
|
1454 |
"CWlanSettings::InstalledEAPsL(): Old style EAP id found.");
|
|
1455 |
}
|
|
1456 |
|
|
1457 |
if (!IsDisallowedOutsidePEAP(*ecomInfoArray[i]))
|
|
1458 |
{
|
|
1459 |
aEAPList.InsertL(aEAPList.Size(), KNSmlWLanEapId); // EAPId
|
|
1460 |
TBuf8<3> cue; // Max EAPId == 255
|
|
1461 |
cue.AppendNumFixedWidth(eapId, EDecimal, 3);
|
|
1462 |
aEAPList.InsertL(aEAPList.Size(), cue);
|
|
1463 |
aEAPList.InsertL(aEAPList.Size(), KSlash);
|
|
1464 |
}
|
|
1465 |
|
|
1466 |
// Check if the method is allowed inside PEAP
|
|
1467 |
if (!IsDisallowedInsidePEAP(*ecomInfoArray[i]))
|
|
1468 |
{
|
|
1469 |
aEAPList.InsertL(aEAPList.Size(), KNSmlWLanEapId); // EAPId
|
|
1470 |
TBuf8<3> cue; // Max EAPId == 255
|
|
1471 |
cue.AppendNumFixedWidth(eapId, EDecimal, 3);
|
|
1472 |
aEAPList.InsertL(aEAPList.Size(), cue);
|
|
1473 |
aEAPList.InsertL(aEAPList.Size(), KDash);
|
|
1474 |
cue.Zero();
|
|
1475 |
cue.AppendNumFixedWidth(KEapPeapTypeId[7], EDecimal, 3);
|
|
1476 |
aEAPList.InsertL(aEAPList.Size(), cue);
|
|
1477 |
aEAPList.InsertL(aEAPList.Size(), KSlash);
|
|
1478 |
|
|
1479 |
#ifdef FF_WLAN_EXTENSIONS
|
|
1480 |
// same additions for EAP-FAST
|
|
1481 |
aEAPList.InsertL(aEAPList.Size(), KNSmlWLanEapId); // EAPId
|
|
1482 |
cue.Zero(); // Max EAPId == 255
|
|
1483 |
cue.AppendNumFixedWidth( eapId, EDecimal, 3 );
|
|
1484 |
aEAPList.InsertL(aEAPList.Size(), cue);
|
|
1485 |
aEAPList.InsertL(aEAPList.Size(), KDash);
|
|
1486 |
cue.Zero();
|
|
1487 |
cue.AppendNumFixedWidth( KEapFastTypeId[7], EDecimal, 3 );
|
|
1488 |
aEAPList.InsertL(aEAPList.Size(), cue);
|
|
1489 |
aEAPList.InsertL(aEAPList.Size(), KSlash);
|
|
1490 |
#endif
|
|
1491 |
}
|
|
1492 |
// Check if the method is allowed inside TTLS
|
|
1493 |
if (!IsDisallowedInsideTTLS(*ecomInfoArray[i]))
|
|
1494 |
{
|
|
1495 |
aEAPList.InsertL(aEAPList.Size(), KNSmlWLanEapId); // EAPId
|
|
1496 |
TBuf8<3> cue; // Max EAPId == 255
|
|
1497 |
cue.AppendNumFixedWidth(eapId, EDecimal, 3);
|
|
1498 |
aEAPList.InsertL(aEAPList.Size(), cue);
|
|
1499 |
aEAPList.InsertL(aEAPList.Size(), KDash);
|
|
1500 |
cue.Zero();
|
|
1501 |
cue.AppendNumFixedWidth(KEapTtlsTypeId[7], EDecimal, 3);
|
|
1502 |
aEAPList.InsertL(aEAPList.Size(), cue);
|
|
1503 |
aEAPList.InsertL(aEAPList.Size(), KSlash);
|
|
1504 |
}
|
|
1505 |
}
|
|
1506 |
// ECOM array is no longer needed.
|
|
1507 |
ecomInfoArray.ResetAndDestroy();
|
|
1508 |
|
|
1509 |
// Cut the last slash
|
|
1510 |
aEAPList.ResizeL(aEAPList.Size() - 1);
|
|
1511 |
|
|
1512 |
_DBG_FILE("CWlanSettings::InstalledEAPsL(): end");
|
|
1513 |
return KErrNone;
|
|
1514 |
}
|
|
1515 |
|
|
1516 |
//-----------------------------------------------------------------------------
|
|
1517 |
// TBool CWlanSettings::CheckEnforcementL( )
|
|
1518 |
// Checks if wlan enforcement is On or Off
|
|
1519 |
//-----------------------------------------------------------------------------
|
|
1520 |
TBool CWlanSettings::CheckEnforcementL()
|
|
1521 |
{
|
|
1522 |
CSettingEnforcementInfo* info = CSettingEnforcementInfo::NewL();
|
|
1523 |
CleanupStack::PushL(info);
|
|
1524 |
TBool enforceWLANActive(EFalse);
|
|
1525 |
User::LeaveIfError(info->EnforcementActive(EWLANEnforcement,
|
|
1526 |
enforceWLANActive));
|
|
1527 |
CleanupStack::PopAndDestroy(info);
|
|
1528 |
return (enforceWLANActive);
|
|
1529 |
}
|
|
1530 |
|
|
1531 |
//-----------------------------------------------------------------------------
|
|
1532 |
// TBool CWlanSettings::CheckAPEnforcementL( )
|
|
1533 |
// Checks if AP enforcement is On or Off
|
|
1534 |
//-----------------------------------------------------------------------------
|
|
1535 |
|
|
1536 |
TBool CWlanSettings::CheckAPEnforcementL()
|
|
1537 |
{
|
|
1538 |
CSettingEnforcementInfo* info = CSettingEnforcementInfo::NewL();
|
|
1539 |
CleanupStack::PushL(info);
|
|
1540 |
TBool enforceAPActive(EFalse);
|
|
1541 |
User::LeaveIfError(info->EnforcementActive(EAPEnforcement,
|
|
1542 |
enforceAPActive));
|
|
1543 |
CleanupStack::PopAndDestroy(info);
|
|
1544 |
return (enforceAPActive);
|
|
1545 |
}
|
|
1546 |
//-----------------------------------------------------------------------------
|
|
1547 |
// TInt CWlanSettings::PerformLockWLANTablesL( )
|
|
1548 |
// Locks or unlocks the wlan tables depending on the
|
|
1549 |
// aProtect value
|
|
1550 |
//-----------------------------------------------------------------------------
|
|
1551 |
TInt CWlanSettings::PerformLockWLANTablesL(TBool aProtect)
|
|
1552 |
{
|
|
1553 |
|
|
1554 |
_DBG_FILE("CWlanSettings::PerformLockWLANTablesL(): BEGIN ");
|
|
1555 |
CCommsDatabaseProtect* dbprotect = CCommsDatabaseProtect::NewL();
|
|
1556 |
CleanupStack::PushL(dbprotect);
|
|
1557 |
RArray<TPtrC> wlanTableList;
|
|
1558 |
CleanupClosePushL(wlanTableList);
|
|
1559 |
TBuf<KCommsDbSvrMaxFieldLength> serviceType;
|
|
1560 |
TBool apEnforce = EFalse;
|
|
1561 |
TInt err = KErrNone;
|
|
1562 |
|
|
1563 |
TRAP_IGNORE(apEnforce = CheckAPEnforcementL());
|
|
1564 |
if (apEnforce)
|
|
1565 |
{
|
|
1566 |
_DBG_FILE(
|
|
1567 |
"CWlanSettings::PerformLockWLANTablesL(): AP enforcement is TRUE");
|
|
1568 |
wlanTableList.AppendL(TPtrC(WAP_ACCESS_POINT));
|
|
1569 |
wlanTableList.AppendL(TPtrC(WAP_IP_BEARER));
|
|
1570 |
wlanTableList.AppendL(TPtrC(IAP));
|
|
1571 |
//condition when only ap is enforced and not wlan then its not
|
|
1572 |
//necessary to add wlanservice table
|
|
1573 |
RDbRowSet::TAccess checkAccessType;
|
|
1574 |
checkAccessType = dbprotect->GetTableAccessL(TPtrC(
|
|
1575 |
WLAN_DEVICE_SETTINGS));
|
|
1576 |
switch (checkAccessType)
|
|
1577 |
{
|
|
1578 |
case RDbRowSet::EReadOnly:
|
|
1579 |
{
|
|
1580 |
wlanTableList.AppendL(TPtrC(WLAN_SERVICE));
|
|
1581 |
wlanTableList.AppendL(TPtrC(WLAN_SECONDARY_SSID));
|
|
1582 |
}
|
|
1583 |
default:
|
|
1584 |
{
|
|
1585 |
break;
|
|
1586 |
}
|
|
1587 |
}
|
|
1588 |
|
|
1589 |
}
|
|
1590 |
else
|
|
1591 |
{
|
|
1592 |
_DBG_FILE(
|
|
1593 |
"CWlanSettings::PerformLockWLANTablesL() Only wlan enforcement is ON");
|
|
1594 |
wlanTableList.AppendL(TPtrC(WLAN_SERVICE));
|
|
1595 |
wlanTableList.AppendL(TPtrC(WLAN_SECONDARY_SSID));
|
|
1596 |
}
|
|
1597 |
|
|
1598 |
iDatabase.CommitTransaction();
|
|
1599 |
|
|
1600 |
for (TInt i(0); i < wlanTableList.Count(); i++)
|
|
1601 |
{
|
|
1602 |
if (!aProtect)
|
|
1603 |
{
|
|
1604 |
err = dbprotect->UnProtectTable(wlanTableList[i]);
|
|
1605 |
DBG_ARGS(
|
|
1606 |
_S16(
|
|
1607 |
"CWlanSettings::PerformLockWLANTablesL(): Unprotect error %D"),
|
|
1608 |
err);
|
|
1609 |
//Check if current AP is locked , if yes , unprotect
|
|
1610 |
// lock = EFalse;
|
|
1611 |
}
|
|
1612 |
else
|
|
1613 |
{
|
|
1614 |
err = dbprotect->ProtectTable(wlanTableList[i]);
|
|
1615 |
//Check if current ServiceID is not locked , if yes , protect
|
|
1616 |
// lock = ETrue;
|
|
1617 |
}
|
|
1618 |
} //for loop
|
|
1619 |
|
|
1620 |
CleanupStack::PopAndDestroy(&wlanTableList);
|
|
1621 |
CleanupStack::PopAndDestroy(dbprotect);
|
|
1622 |
CCommsDatabase* commsDataBase = CCommsDatabase::NewL();
|
|
1623 |
CleanupStack::PushL(commsDataBase);
|
|
1624 |
|
|
1625 |
// Open the IAP from IAP Table and protect
|
|
1626 |
|
|
1627 |
TUint32 apIAPID = 0;
|
|
1628 |
CCommsDbTableView* iapViews = commsDataBase->OpenViewMatchingUintLC(
|
|
1629 |
TPtrC(IAP), TPtrC(IAP_SERVICE), iServiceID);
|
|
1630 |
err = iapViews->GotoFirstRecord();
|
|
1631 |
// Service ID can be same for GPRS or WLAN, hence check service type and get the iAPID
|
|
1632 |
while (err == KErrNone)
|
|
1633 |
{
|
|
1634 |
iapViews->ReadTextL(TPtrC(IAP_SERVICE_TYPE), serviceType);
|
|
1635 |
if (serviceType == TPtrC(LAN_SERVICE))
|
|
1636 |
{
|
|
1637 |
iapViews->ReadUintL(TPtrC(COMMDB_ID), apIAPID);
|
|
1638 |
DBG_ARGS(_S16(
|
|
1639 |
"CWlanSettings::PerformLockWLANTablesL(): IAPId %D"),
|
|
1640 |
apIAPID);
|
|
1641 |
break;
|
|
1642 |
}
|
|
1643 |
err = iapViews->GotoNextRecord();
|
|
1644 |
}
|
|
1645 |
|
|
1646 |
//iapViews->ReadUintL(TPtrC(COMMDB_ID), apIAPID);
|
|
1647 |
DBG_ARGS(
|
|
1648 |
_S16(
|
|
1649 |
"CWlanSettings::PerformLockWLANTablesL(): end. IAP ID being locked %d "),
|
|
1650 |
apIAPID);
|
|
1651 |
if (err == KErrNone)
|
|
1652 |
{
|
|
1653 |
CCommsDbTableView* iapUpdate = commsDataBase->OpenViewMatchingUintLC(
|
|
1654 |
TPtrC(IAP), TPtrC(COMMDB_ID), apIAPID);
|
|
1655 |
TInt iapExists = iapUpdate->GotoFirstRecord();
|
|
1656 |
|
|
1657 |
if (!aProtect)
|
|
1658 |
{
|
|
1659 |
((CCommsDbProtectTableView*) iapViews)->UnprotectRecord();
|
|
1660 |
if (iapExists)
|
|
1661 |
{
|
|
1662 |
((CCommsDbProtectTableView*) iapUpdate)->UnprotectRecord();
|
|
1663 |
}
|
|
1664 |
}
|
|
1665 |
else
|
|
1666 |
{
|
|
1667 |
((CCommsDbProtectTableView*) iapViews)->ProtectRecord();
|
|
1668 |
if (iapExists)
|
|
1669 |
{
|
|
1670 |
((CCommsDbProtectTableView*) iapUpdate)->ProtectRecord();
|
|
1671 |
}
|
|
1672 |
}
|
|
1673 |
CleanupStack::PopAndDestroy(); // iapUpdate
|
|
1674 |
}
|
|
1675 |
|
|
1676 |
CleanupStack::PopAndDestroy(iapViews);
|
|
1677 |
CleanupStack::PopAndDestroy(commsDataBase);
|
|
1678 |
|
56
|
1679 |
err = iDatabase.BeginTransaction();
|
47
|
1680 |
return err;
|
|
1681 |
}
|
|
1682 |
|
|
1683 |
TBool CWlanSettings::IsDisallowedOutsidePEAP(
|
|
1684 |
const CImplementationInformation& aImplInfo)
|
|
1685 |
{
|
|
1686 |
|
|
1687 |
const TUint8 pluginOpaqueData = *(aImplInfo.OpaqueData().Ptr());
|
|
1688 |
|
|
1689 |
if (pluginOpaqueData & KNotOutsidePEAP)
|
|
1690 |
{
|
|
1691 |
return ETrue;
|
|
1692 |
}
|
|
1693 |
return EFalse;
|
|
1694 |
|
|
1695 |
}
|
|
1696 |
|
|
1697 |
TBool CWlanSettings::IsDisallowedInsidePEAP(
|
|
1698 |
const CImplementationInformation& aImplInfo)
|
|
1699 |
{
|
|
1700 |
const TUint8 pluginOpaqueData = *(aImplInfo.OpaqueData().Ptr());
|
|
1701 |
|
|
1702 |
if (pluginOpaqueData & KNotInsidePEAP)
|
|
1703 |
{
|
|
1704 |
return ETrue;
|
|
1705 |
}
|
|
1706 |
return EFalse;
|
|
1707 |
|
|
1708 |
}
|
|
1709 |
|
|
1710 |
TBool CWlanSettings::IsDisallowedInsideTTLS(
|
|
1711 |
const CImplementationInformation& aImplInfo)
|
|
1712 |
{
|
|
1713 |
const TUint8 pluginOpaqueData = *(aImplInfo.OpaqueData().Ptr());
|
|
1714 |
|
|
1715 |
if (pluginOpaqueData & KNotInsideTTLS)
|
|
1716 |
{
|
|
1717 |
return ETrue;
|
|
1718 |
}
|
|
1719 |
return EFalse;
|
|
1720 |
}
|
|
1721 |
|