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