wlansecuritysettings/wepsecuritysettingsui/inc/WEPSecuritySettingsImpl.h
branchRCL_3
changeset 46 c74b3d9f6b9e
equal deleted inserted replaced
45:bad0cc58d154 46:c74b3d9f6b9e
       
     1 /*
       
     2 * Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: Declaration of class CWEPSecuritySettingsImpl.  
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19 * %version: tr1cfwln#19 %
       
    20 */
       
    21 
       
    22 #ifndef WEPSECURITYSETTINGSIMPL_H
       
    23 #define WEPSECURITYSETTINGSIMPL_H
       
    24 
       
    25 // INCLUDES
       
    26 #include <e32base.h>
       
    27 
       
    28 #include <WEPSecuritySettingsUI.h>
       
    29 #include "WepSecuritySettingsDefs.h"
       
    30 
       
    31 #include <metadatabase.h>
       
    32 using namespace CommsDat;
       
    33 
       
    34 // FORWARD DECLARATIONS
       
    35 
       
    36 class CCommsDatabase;
       
    37 
       
    38 
       
    39 // CLASS DECLARATION
       
    40 
       
    41 /**
       
    42 * WEP Security Settings.
       
    43 * Implementation behind proxy class CWEPSecuritySettings.
       
    44 */
       
    45 NONSHARABLE_CLASS( CWEPSecuritySettingsImpl ) : public CBase
       
    46     {
       
    47 
       
    48     public:     // Constructors and destructor
       
    49 
       
    50         /**
       
    51         * Two-phased constructor. Leaves on failure.
       
    52         * @return The constructed CWEPSecuritySettings object.
       
    53         */
       
    54         static CWEPSecuritySettingsImpl* NewL();
       
    55 
       
    56         /**
       
    57         * Destructor.
       
    58         */
       
    59         virtual ~CWEPSecuritySettingsImpl();
       
    60 
       
    61     protected:  // Constructors
       
    62 
       
    63         /**
       
    64         * Constructor.
       
    65         * @param aEikEnv Eikon environment.
       
    66         */
       
    67         CWEPSecuritySettingsImpl();
       
    68 
       
    69         /**
       
    70         * Second-phase constructor.
       
    71         */
       
    72         void ConstructL();
       
    73 
       
    74     public:     // New methods
       
    75 
       
    76         /**
       
    77         * Load from database.
       
    78         * @param aIapId Wlan Service Table Id of the IAP to be loaded
       
    79         * @param aCommsDb Comms database.
       
    80         */
       
    81         void LoadL( TUint32 aIapId, CCommsDatabase& aCommsDb );
       
    82 
       
    83         /**
       
    84         * Save to database.
       
    85         * @param aIapId Wlan Service Table Id of the IAP to be saved
       
    86         * @param aCommsDb Comms database.
       
    87         */
       
    88         void SaveL( TUint32 aIapId, CCommsDatabase& aCommsDb ) const;
       
    89 
       
    90         /**
       
    91         * Tells if the settings are valid and can be saved
       
    92         * @return ETrue if all the compulsory settings have been entered
       
    93         */
       
    94         TBool IsValid();
       
    95 
       
    96 
       
    97         /**
       
    98         * Sets the new data of the key
       
    99         * @param aElement   Index of the element whose data has to be set.
       
   100         * @param aKeyData   The new value for data of the key.
       
   101         * @param aHex       ETrue if data is in Ascii format
       
   102         */
       
   103         TInt SetKeyDataL( const TInt aElement, const TDesC& aKeyData, 
       
   104                           const TBool aHex );
       
   105 
       
   106 
       
   107         /**
       
   108         * Calculates expected length of hex string of keyData on the base of
       
   109         * the selected key length.
       
   110         * @param aKeyLength Chosen key length
       
   111         * @return   Expected length
       
   112         */
       
   113         TInt ExpectedLengthOfKeyData( CWEPSecuritySettings::TWEPKeyLength 
       
   114                                                                   aKeyLength );
       
   115 
       
   116 
       
   117         /**
       
   118         * Gets Key currently in use
       
   119         * @return The key in use.
       
   120         */
       
   121         inline CWEPSecuritySettings::TWEPKeyInUse KeyInUse () const;
       
   122 
       
   123         /**
       
   124         * Sets Key currently in use
       
   125         * @param aKeyInUse  The new value for key in use.
       
   126         */
       
   127         inline void SetKeyInUse ( const CWEPSecuritySettings::TWEPKeyInUse 
       
   128                                                                    aKeyInUse );
       
   129 
       
   130 
       
   131         /**
       
   132         * Gets type of Authentication
       
   133         * @return The type of Authentication.
       
   134         */
       
   135         inline CWEPSecuritySettings::TWEPAuthentication Authentication () const;
       
   136 
       
   137         /**
       
   138         * Sets type of Authentication
       
   139         * @param aAuthentication    The new value for type of Authentication.
       
   140         */
       
   141         inline void SetAuthentication( 
       
   142               const CWEPSecuritySettings::TWEPAuthentication aAuthentication );
       
   143 
       
   144 
       
   145         /**
       
   146         * Gets the length of the key
       
   147         * @param aElement   Index of the element whose length has to be 
       
   148         *                   retrieved.
       
   149         * @return The length of the key
       
   150         */
       
   151         inline CWEPSecuritySettings::TWEPKeyLength KeyLength ( 
       
   152                                                    const TInt aElement ) const;
       
   153 
       
   154         /**
       
   155         * Sets the length of the key
       
   156         * @param aElement   Index of the element whose length has to be set.
       
   157         * @param aKeyLength The new value for length of the key.
       
   158         */
       
   159         inline void SetKeyLength( const TInt aElement, 
       
   160                         const CWEPSecuritySettings::TWEPKeyLength aKeyLength );
       
   161 
       
   162 
       
   163         /**
       
   164         * Gets the format of the key
       
   165         * @param aElement   Index of the element whose format has to be 
       
   166         *                   retrieved.
       
   167         * @return The format of the key
       
   168         */
       
   169         inline CWEPSecuritySettings::TWEPKeyFormat KeyFormat( 
       
   170                                                    const TInt aElement ) const;
       
   171 
       
   172         /**
       
   173         * Sets the format of the key
       
   174         * @param aElement   Index of the element whose format has to be set.
       
   175         * @param aKeyLength The new value for format of the key.
       
   176         */
       
   177         inline void SetKeyFormat( const TInt aElement, 
       
   178                         const CWEPSecuritySettings::TWEPKeyFormat aKeyFormat );
       
   179 
       
   180 
       
   181         /**
       
   182         * Gets the key data
       
   183         * @param aElement   Index of the element whose keyData has to be 
       
   184         *                   retrieved.
       
   185         * @return The data of the key
       
   186         */
       
   187         inline TDes8* KeyData( const TInt aElement );
       
   188 
       
   189         /**
       
   190         * Sets the new data of the key
       
   191         * @param aElement   Index of the element whose data has to be set.
       
   192         * @param aKeyLength The new value for data of the key.
       
   193         */
       
   194         inline void SetKeyData( const TInt aElement, const TDesC8& aKeyData );
       
   195 
       
   196         /**
       
   197         * Tells if the Wep256 feature is enabled or not
       
   198         * @return ETrue if the flag is enabled
       
   199         */
       
   200         inline TBool WEP256Enabled() const;
       
   201 
       
   202         /**
       
   203         * Verify if the entered keyData is valid
       
   204         * @param aTextToTest        The text to be verified
       
   205         * @param aLengthOfKeyData   The expected length of the keyData
       
   206         * @param aWEPKeyFormat      The format chosen to enter the keyData
       
   207         * @return   KErrNone if the text is valid, or error code if not.
       
   208         */
       
   209         TInt VerifyKeyData( const TDesC8& aTextToTest, TInt aLengthOfKeyData,
       
   210                             CWEPSecuritySettings::TWEPKeyFormat aWEPKeyFormat );
       
   211 
       
   212         /**
       
   213         * Converts keyData enetered in Ascii format to hex format
       
   214         * @param aSource    Source string
       
   215         * @param aDest      destination string
       
   216         */
       
   217         void ConvertAsciiToHex( const TDesC8& aSource, HBufC8*& aDest );
       
   218         
       
   219         /**
       
   220         * Load from database.
       
   221         * @param aIapId Wlan Service Table Id of the IAP to be loaded
       
   222         * @param aSession CommsDat session.
       
   223         */
       
   224         void LoadL( TUint32 aIapId, CMDBSession& aSession );
       
   225         
       
   226         /**
       
   227         * Save to database.
       
   228         * @param aIapId Wlan Service Table Id of the IAP to be saved
       
   229         * @param aSession CommsDat session.
       
   230         */
       
   231         void SaveL( TUint32 aIapId, CMDBSession& aSession ) const;
       
   232 
       
   233 
       
   234     private:
       
   235 
       
   236         /**
       
   237         * Sets keyLength parsing data contained in iKeyData
       
   238         * @param aIndex Index of the element whose length has to be calculated.
       
   239         */
       
   240         void SetLenKeyDataFromText( const TInt aIndex );
       
   241 
       
   242 
       
   243     private:    // Data 
       
   244 
       
   245         // Index of the key currently in use (EKeyNumber1, EKeyNumber2, 
       
   246         // EKeyNumber3, EKeyNumber4
       
   247         CWEPSecuritySettings::TWEPKeyInUse iKeyInUse;
       
   248 
       
   249         // Type of authentication (EAuthOpen, EAuthShared)
       
   250         CWEPSecuritySettings::TWEPAuthentication iAuthentication;
       
   251 
       
   252         // Length of the key (E40Bits, E104Bits, E232Bits)
       
   253         CWEPSecuritySettings::TWEPKeyLength iKeyLength[KMaxNumberofKeys];
       
   254 
       
   255         // Format of the key (EAscii, EHexadecimal)
       
   256         CWEPSecuritySettings::TWEPKeyFormat iKeyFormat[KMaxNumberofKeys];
       
   257 
       
   258         // Data of the key
       
   259         TBuf8<KMaxLengthOfKeyData> iKeyData[KMaxNumberofKeys];
       
   260 
       
   261         // Tells if the Wep256 feature is enabled
       
   262         TBool iIsWEP256Enabled;
       
   263     };
       
   264 
       
   265 // Include inline functions
       
   266 #include "WEPSecuritySettingsImpl.inl"
       
   267 
       
   268 
       
   269 #endif