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