wlan_plat/wlan_dbif_api/inc/wdbifwlansettings.h
changeset 0 c40eb8fe8501
equal deleted inserted replaced
-1:000000000000 0:c40eb8fe8501
       
     1 /*
       
     2 * Copyright (c) 2002-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 "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:  Handles the custom WLANServiceTable in CommsDat
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19 * %version: 13 %
       
    20 */
       
    21 
       
    22 #ifndef WLANSETTINGS_H
       
    23 #define WLANSETTINGS_H
       
    24 
       
    25 #include <commsdattypesv1_1.h>
       
    26 #include <commsdat.h>
       
    27 
       
    28 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    29 #include <commsdat_partner.h>
       
    30 #endif
       
    31 
       
    32 
       
    33 using namespace CommsDat;
       
    34 
       
    35 // Should be same as KMaxWepKeyLength, but defined here to
       
    36 // avoid dependency to 802dot11.h
       
    37 const TUint32 KWLMMaxWEPKeyLength = 29;
       
    38 
       
    39 // The maximum WPA Pre-Shared Key length.
       
    40 const TUint KWLMMaxWpaPskLength = 64;
       
    41 
       
    42 // Maximum length of a SSID in BYTES
       
    43 const TUint8 KMaxSSIDLen = 32;
       
    44 
       
    45 // Size of Expanded EAP Type
       
    46 const TUint8 KExpandedEapTypeSize = 8; //8
       
    47 
       
    48 /**
       
    49 * Data structure for storing a WEP key.
       
    50 */
       
    51 struct TWep
       
    52     {
       
    53     /** Specifies which key to add or remove. Range: 0-3 */
       
    54     TUint32 KeyIndex;
       
    55     /** The length of KeyMaterial in bytes. Range: 0-29 */
       
    56     TUint32 KeyLength;
       
    57     /** Array that stores the WEP key. */
       
    58     TUint8 KeyMaterial[KWLMMaxWEPKeyLength];
       
    59     };
       
    60 
       
    61 /**
       
    62 * Data structure for storing a WPA Pre-Shared Key.
       
    63 */
       
    64 struct TWpaPsk
       
    65 	{
       
    66 	/** The length of KeyMaterial in bytes. Range: 8-64 */
       
    67 	TUint KeyLength;
       
    68 	/** Array of that stores the WPA Pre-Shared Key. */
       
    69 	TUint8 KeyMaterial[KWLMMaxWpaPskLength];
       
    70 	};
       
    71 
       
    72 const TInt KWlanWpaPskLength =     64;
       
    73 
       
    74 enum EWepAuthenticationMode
       
    75     {
       
    76     EWepAuthModeOpen = 0,
       
    77     EWepAuthModeShared = 1    
       
    78     };
       
    79 
       
    80 enum EConnectionMode
       
    81     {
       
    82     Adhoc =0,
       
    83     Infrastructure=1
       
    84     };
       
    85 
       
    86 enum EWlanSecurityMode
       
    87     {
       
    88     AllowUnsecure = 1,
       
    89     Wep = 2,
       
    90     Wlan8021x = 4,
       
    91     Wpa = 8,
       
    92     Wpa2Only = 16,
       
    93     Wapi = 32
       
    94     };
       
    95 
       
    96 /**
       
    97  * Format of the preshared key (hex/ASCII)
       
    98  */
       
    99 enum TWlanPresharedKeyFormat
       
   100     {
       
   101     EWlanPresharedKeyFormatAscii,
       
   102     EWlanPresharedKeyFormatHex
       
   103     };
       
   104 
       
   105 /**
       
   106 * struct for wlan settings data
       
   107 */
       
   108 struct SWLANSettings
       
   109     {
       
   110     TUint32                         Id;
       
   111     TBuf<KMaxMedTextLength>         Name;
       
   112     
       
   113     TUint32                         ServiceID;
       
   114     TUint32                         ConnectionMode;        // Infrastructure / adhoc
       
   115     TBuf<KMaxSSIDLen>            SSID;                // network name
       
   116     
       
   117     TBuf<KMaxSSIDLen>            UsedSSID;
       
   118     TBool                           ScanSSID;
       
   119     TUint32                         ChannelID;
       
   120 
       
   121     TUint32                         SecurityMode;         // SecurityMode (Allow insecure, wep, 802.1xs, wpa, wpa2only) enum EWlanSecurityMode
       
   122     
       
   123     TWep                            WepKey1; 
       
   124     TWep                            WepKey2;
       
   125     TWep                            WepKey3;
       
   126     TWep                            WepKey4;
       
   127     TUint32                         WepIndex;  
       
   128     TUint32                         AuthenticationMode; // open / Shared
       
   129     
       
   130     TBuf8<KWlanWpaPskLength>        WPAPreSharedKey;
       
   131     TUint32                         WPAKeyLength;
       
   132     TBool                           EnableWpaPsk;
       
   133     TUint32                         PresharedKeyFormat; // format of the preshared key
       
   134     
       
   135     // there is also WLAN_EAPS, but it is a long text field, handled separately
       
   136     
       
   137     };
       
   138 
       
   139 struct SWlanIAPId
       
   140     {
       
   141     TUint iWLANRecordId;
       
   142     TUint iIAPId;
       
   143     };
       
   144 
       
   145 /**
       
   146 * Struct for containing eap identifiers
       
   147 */
       
   148 typedef struct _TEap
       
   149     {
       
   150     TBool    Enabled;
       
   151     TBuf8<3>    UID; // Unique ID
       
   152     } TEap;
       
   153 
       
   154 typedef RPointerArray<TEap> TEapArray;
       
   155 /**
       
   156 * Struct for containing expanded eap identifiers
       
   157 */
       
   158 struct SEapExpandedType
       
   159     {
       
   160     TBuf8<KExpandedEapTypeSize>    EapExpandedType; // Unique ID
       
   161     };
       
   162 
       
   163 typedef RPointerArray<SEapExpandedType> RExpandedEapTypeArray;
       
   164 
       
   165 /**
       
   166 * Structure for storing information about a secondary SSID.
       
   167 */
       
   168 struct TWlanSecondarySsid
       
   169 	{
       
   170 	TUint32 id;
       
   171 	TBuf<KMaxSSIDLen> ssid;
       
   172 	TBuf<KMaxSSIDLen> usedSsid;
       
   173 	};
       
   174 
       
   175 //  CLASS DECLARATION
       
   176 
       
   177 /**
       
   178 * Class for handling wlan table in commsdat
       
   179 *
       
   180 * @lib wlandbif.lib
       
   181 */
       
   182 NONSHARABLE_CLASS( CWLanSettings ) : public CBase
       
   183     {
       
   184 public:  // Constructors and destructor
       
   185 
       
   186     /**
       
   187     * Constructor
       
   188     */
       
   189     IMPORT_C CWLanSettings();
       
   190     
       
   191     /**
       
   192     * Destructor
       
   193     * Handles disconnection if needed
       
   194     */
       
   195     IMPORT_C virtual ~CWLanSettings();
       
   196     
       
   197 public:  // New functions
       
   198 
       
   199     /**
       
   200     * Makes a connection to CommsDat
       
   201     * @param 
       
   202     * @return KErrNone or other symbian error code
       
   203     * @remarks
       
   204     * @see
       
   205     */
       
   206     IMPORT_C TInt Connect();
       
   207     
       
   208     /**
       
   209     * Disconnect function that disconnects the connection to commsdat
       
   210     * @param 
       
   211     * @return
       
   212     * @remarks
       
   213     * @see
       
   214     */
       
   215     IMPORT_C void Disconnect();
       
   216     
       
   217     /**
       
   218     * Gets WLAN settings with specified ID
       
   219     * @param aId is the id of wlan settings record that is fetched, aSettings contains the wlan settings
       
   220     * @return KErrNone or other symbian error code
       
   221     * @remarks
       
   222     * @see
       
   223     */
       
   224     IMPORT_C TInt GetWlanSettings(TUint32 aId,SWLANSettings &aSettings);
       
   225     
       
   226     /**
       
   227     * Gets all the wlan settings for specified LAN service
       
   228     * @param aId is the id of lan settings that uses wanted wlan settings. aSettings contains the wlan settings
       
   229     * @return KErrNone or other symbian error code
       
   230     * @remarks
       
   231     * @see
       
   232     */
       
   233     IMPORT_C TInt GetWlanSettingsForService(TUint32 aId,SWLANSettings &aSettings);
       
   234 
       
   235     /**
       
   236     * Gets WLAN settings with specified IAP ID
       
   237     * @param aId is the IAP id that is fetched, aSettings contains the wlan settings
       
   238     * @return KErrNone or other symbian error code
       
   239     * @remarks
       
   240     * @see
       
   241     */
       
   242     IMPORT_C TInt GetWlanSettingsForIap(TUint32 aId,SWLANSettings &aSettings);
       
   243 
       
   244     /**
       
   245     *
       
   246     * Not supported
       
   247     *
       
   248     */
       
   249     IMPORT_C TInt GetFirstSettings(SWLANSettings &aSettings);
       
   250 
       
   251     /**
       
   252     *
       
   253     * Not supported
       
   254     *
       
   255     */
       
   256     IMPORT_C TInt GetNextSettings(SWLANSettings &aSettings);
       
   257     
       
   258     /**
       
   259     * writes all the wlan settings to CommsDat, if settings.id is 0, new record is created
       
   260     * returns KErrNone on success, other error code if failed
       
   261     */
       
   262     IMPORT_C TInt WriteWlanSettings(SWLANSettings &aSettings);
       
   263 
       
   264     /**
       
   265     * Deletes wlan settings record with specified ID
       
   266     * returns KErrNone on success, other error code if failed
       
   267     */
       
   268     IMPORT_C TInt DeleteWlanSettings(TUint32 aId);
       
   269 
       
   270     /**
       
   271     * Deletes wlan settings record for specified LAN service
       
   272     * returns KErrNone on success, other error code if failed
       
   273     */
       
   274     IMPORT_C TInt DeleteWlanSettingsForService(TUint32 aId);
       
   275 
       
   276     /**
       
   277     *
       
   278     * Not supported
       
   279     *
       
   280     */
       
   281     IMPORT_C void AddWlanTableL();
       
   282 
       
   283     /**
       
   284     * Sets the EAP information to current wlan settings (first do a GetWlanSettings{ForService})
       
   285     * returns
       
   286     */
       
   287     IMPORT_C void SetEapDataL(const TEapArray &aEaps);
       
   288 
       
   289     /**
       
   290     * Gets the current wlan settings EAP information (first do a GetWlanSettings{ForService})
       
   291     * returns
       
   292     */
       
   293     IMPORT_C void GetEapDataL(TEapArray &aEaps);
       
   294 
       
   295     /**
       
   296     * Sets aEasyWlan to ETrue if the aServiceID service is an easy wlan
       
   297     * returns
       
   298     */
       
   299     IMPORT_C TInt IsEasyWlan(TUint aServiceId, TBool &aEasyWlan);
       
   300     
       
   301     /** 
       
   302     * Gets WLAN Service Id's which correspond to IAP's using WLAN 
       
   303     * returns found WLANServiceTable and IAP record ID's in aServices
       
   304     */
       
   305     IMPORT_C void GetIAPWlanServicesL( RArray<SWlanIAPId>& aServices);
       
   306     
       
   307     /**
       
   308     * Get all secondary SSIDs for the specified LAN service.
       
   309     * @since Series 60 3.0
       
   310     * @param aÍd ID of the LAN service.
       
   311     * @param aSsids Secondary SSIDs for the service.
       
   312     * @return KErrNone if successful, a Symbian error code otherwise.
       
   313     */
       
   314     IMPORT_C TInt GetSecondarySsidsForService(
       
   315     	TUint32 aId,
       
   316     	RArray<TWlanSecondarySsid>& aSsids );
       
   317     
       
   318     /**
       
   319     * Gets the current wlan settings EAP information (first do a GetWlanSettings{ForService})
       
   320     * returns
       
   321     */
       
   322 	IMPORT_C void GetEapDataL( RExpandedEapTypeArray &aEapsEnabled, RExpandedEapTypeArray &aEapsDisabled );
       
   323 	
       
   324     /**
       
   325     * Sets the EAP information to current wlan settings (first do a GetWlanSettings{ForService})
       
   326     * returns
       
   327     */
       
   328 	IMPORT_C void SetEapDataL( RExpandedEapTypeArray &aEapsEnabled, RExpandedEapTypeArray &aEapsDisabled );
       
   329 	
       
   330 private:
       
   331 
       
   332     enum TWlanRecIdType
       
   333          {
       
   334          EWlanRecordId,
       
   335          EWlanServiceId,
       
   336          EWlanIapId,
       
   337          };
       
   338          
       
   339     // prepare iWLANServiceRecord (leaves if oom)
       
   340     void CreateWLANServiceRecordL( TUint32 aId, TWlanRecIdType aType);
       
   341     
       
   342     /**
       
   343     * Gets current settings
       
   344     */
       
   345     void GetDataL(SWLANSettings& aSettings);
       
   346 
       
   347     /**
       
   348     * Writes aSettings to current record
       
   349     */
       
   350     void WriteDataL(SWLANSettings& aSettings);
       
   351     
       
   352     /**
       
   353     * Reads current Wep Keys
       
   354     */
       
   355     void ReadWepKeysL(SWLANSettings &aSettings);
       
   356 
       
   357     /**
       
   358     * If secmode is other than WEP, clear wep keys
       
   359     */
       
   360     void ClearWepKeys( SWLANSettings &aSettings);
       
   361 
       
   362     /**
       
   363     * Returns the hex value of aValue, which originally is the ascii value of a hex digit
       
   364     */
       
   365     void AsciiToHexValue( TUint8& aValue);
       
   366 
       
   367     /**
       
   368     * Writes Wep Keys to current settings
       
   369     */
       
   370     void WriteWepKeysL(SWLANSettings &aSettings);
       
   371 
       
   372     /**
       
   373     * Unpacks wep keys from CommsDat format to TWep struct
       
   374     */
       
   375     void UnPackWepKey( TDesC8& aPackedKey,TWep& aInputKey, TInt aKeyIndex);
       
   376 
       
   377     /**
       
   378     * Packs wep keys from TWep to CommsDat format
       
   379     */
       
   380     void PackWepKeyL(const TWep& aInputKey, CMDBField<TDesC8>* aPackedKey);
       
   381 
       
   382     void DoSetEapDataL( TDesC& aData);
       
   383 
       
   384 	void DoSetEapDataL( TDesC8& aEnabledData, TDesC8& aDisabledData );
       
   385     HBufC* DoGetEapDataLC();
       
   386     
       
   387     void DoGetEapDataLC( HBufC8*& enabledEapsData, HBufC8*& disabledEapsData );
       
   388     void DoConnectL();
       
   389 
       
   390 private:  // Data
       
   391 
       
   392     // the current "row"
       
   393     TInt iCurrentRecord;
       
   394 
       
   395     CMDBGenericRecord* iWLANRecord;
       
   396     CMDBSession* iDBSession;
       
   397     };
       
   398 
       
   399 #endif // WLANSETTINGS_H