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