wlan_bearer/wlandbif_cd/src/wdbifwlansettings.cpp
branchRCL_3
changeset 9 191c8407e577
parent 0 c40eb8fe8501
child 16 5fb7af913dfd
equal deleted inserted replaced
8:4e2a442f3e66 9:191c8407e577
    14 * Description:  Handles the custom WLANServiceTable  in CommsDat
    14 * Description:  Handles the custom WLANServiceTable  in CommsDat
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: 12 %
    19 * %version: 12.1.1 %
    20 */
    20 */
    21 
    21 
    22 //  INCLUDE FILES
    22 //  INCLUDE FILES
    23 
    23 
    24 #include <e32svr.h>
    24 #include <e32svr.h>
   108     TraceDump(WARNING_LEVEL,(_L("CWlanSettings::GetDataL start")));
   108     TraceDump(WARNING_LEVEL,(_L("CWlanSettings::GetDataL start")));
   109     
   109     
   110     ClearWepKeys( aSettings);
   110     ClearWepKeys( aSettings);
   111     
   111     
   112     aSettings.Id = iWLANRecord->RecordId();
   112     aSettings.Id = iWLANRecord->RecordId();
       
   113     TraceDump(WARNING_LEVEL,(_L("CWlanSettings::GetDataL() - aSettings.Id: %d"),
       
   114         aSettings.Id));
   113 
   115 
   114     aSettings.Name = *((CMDBField<TDesC>*)iWLANRecord->GetFieldByIdL(KCDTIdRecordName));
   116     aSettings.Name = *((CMDBField<TDesC>*)iWLANRecord->GetFieldByIdL(KCDTIdRecordName));
       
   117     TraceDump(WARNING_LEVEL,(_L("CWlanSettings::GetDataL() - aSettings.Name: %S [%d]"),
       
   118         &aSettings.Name, aSettings.Name.Length()));
   115 
   119 
   116     aSettings.ServiceID = *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanServiceId));
   120     aSettings.ServiceID = *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanServiceId));
       
   121     TraceDump(WARNING_LEVEL,(_L("CWlanSettings::GetDataL() - aSettings.ServiceID: %d"),
       
   122         aSettings.ServiceID));
   117     
   123     
   118     aSettings.ConnectionMode = *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanConnMode));
   124     aSettings.ConnectionMode = *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanConnMode));
       
   125     TraceDump(WARNING_LEVEL,(_L("CWlanSettings::GetDataL() - aSettings.ConnectionMode: %d"),
       
   126         aSettings.ConnectionMode));
   119     
   127     
   120     aSettings.SSID = *((CMDBField<TDesC>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanSSID));
   128     aSettings.SSID = *((CMDBField<TDesC>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanSSID));
       
   129     TraceDump(WARNING_LEVEL,(_L("CWlanSettings::GetDataL() - aSettings.SSID: %S [%d]"),
       
   130         &aSettings.SSID, aSettings.SSID.Length()));
   121     
   131     
   122     // new
   132     // new
   123     aSettings.UsedSSID = *((CMDBField<TDesC>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanUsedSSID));
   133     aSettings.UsedSSID = *((CMDBField<TDesC>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanUsedSSID));
       
   134     TraceDump(WARNING_LEVEL,(_L("CWlanSettings::GetDataL() - aSettings.UsedSSID: %S [%d]"),
       
   135         &aSettings.UsedSSID, aSettings.UsedSSID.Length()));
   124     
   136     
   125     aSettings.ScanSSID = *((CMDBField<TBool>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanScanSSID));
   137     aSettings.ScanSSID = *((CMDBField<TBool>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanScanSSID));
   126     TraceDump(WARNING_LEVEL,(_L("CWlanSettings::GetDataL ScanSSID = %d"),aSettings.ScanSSID));
   138     TraceDump(WARNING_LEVEL,(_L("CWlanSettings::GetDataL() - aSettings.ScanSSID: %d"),
       
   139         aSettings.ScanSSID));
   127     
   140     
   128     aSettings.ChannelID = *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanChannelID));
   141     aSettings.ChannelID = *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanChannelID));
       
   142     TraceDump(WARNING_LEVEL,(_L("CWlanSettings::GetDataL() - aSettings.ChannelID: %d"),
       
   143         aSettings.ChannelID));
       
   144 
   129     // end new
   145     // end new
   130 
   146 
   131     aSettings.AuthenticationMode = EWepAuthModeOpen; // defaults to open (in case of wep, the value will be read from db later)
   147     aSettings.AuthenticationMode = EWepAuthModeOpen; // defaults to open (in case of wep, the value will be read from db later)
   132     aSettings.EnableWpaPsk = EFalse;
   148     aSettings.EnableWpaPsk = EFalse;
   133     aSettings.WPAKeyLength = 0;
   149     aSettings.WPAKeyLength = 0;
       
   150     aSettings.WPAPreSharedKey.Zero();
       
   151     aSettings.PresharedKeyFormat = EWlanPresharedKeyFormatAscii;
   134 
   152 
   135     aSettings.SecurityMode = *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanSecMode));
   153     aSettings.SecurityMode = *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanSecMode));
   136     
   154     TraceDump(WARNING_LEVEL,(_L("CWlanSettings::GetDataL() - aSettings.SecurityMode: %d"),
   137     TraceDump(WARNING_LEVEL,(_L("CWlanSettings::GetDataL, SecurityMode = %d"),aSettings.SecurityMode));
   155         aSettings.SecurityMode));
   138 
   156     
   139     if( aSettings.SecurityMode == Wep)
   157     if( aSettings.SecurityMode == Wep)
   140         {    
   158         {    
   141         // authentication mode can be != open only when WEP in use
   159         // authentication mode can be != open only when WEP in use
   142         aSettings.AuthenticationMode = *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanAuthMode));
   160         aSettings.AuthenticationMode = *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanAuthMode));
       
   161         TraceDump(WARNING_LEVEL,(_L("CWlanSettings::GetDataL() - aSettings.AuthenticationMode: %d"),
       
   162             aSettings.AuthenticationMode));
   143 
   163 
   144         aSettings.WepIndex = *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanWepIndex));
   164         aSettings.WepIndex = *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanWepIndex));
   145         ReadWepKeysL(aSettings);
   165         TraceDump(WARNING_LEVEL,(_L("CWlanSettings::GetDataL() - aSettings.WepIndex: %d"),
       
   166             aSettings.WepIndex));
       
   167         ReadWepKeysL(aSettings);           
   146         TraceDump(WARNING_LEVEL,(_L("CWlanSettings::GetDataL, Wep keys succesfully read")));
   168         TraceDump(WARNING_LEVEL,(_L("CWlanSettings::GetDataL, Wep keys succesfully read")));
   147         }
   169         }
   148     else if( aSettings.SecurityMode > Wep)
   170     else if( aSettings.SecurityMode > Wep)
   149         {
   171         {
   150         aSettings.WPAKeyLength = *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanWpaKeyLength));
   172         aSettings.WPAKeyLength = *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanWpaKeyLength));
       
   173         TraceDump(WARNING_LEVEL,(_L("CWlanSettings::GetDataL() - aSettings.WPAKeyLength: %d"),
       
   174             aSettings.WPAKeyLength));       
   151         aSettings.EnableWpaPsk = *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanEnableWpaPsk));
   175         aSettings.EnableWpaPsk = *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanEnableWpaPsk));
   152         aSettings.PresharedKeyFormat = EWlanPresharedKeyFormatAscii;
   176         TraceDump(WARNING_LEVEL,(_L("CWlanSettings::GetDataL() - aSettings.EnableWpaPsk: %d"),
   153         aSettings.WPAPreSharedKey.Zero();
   177             aSettings.EnableWpaPsk));       
   154         CMDBField<TDesC8>* wpaKey = static_cast<CMDBField<TDesC8>*>(iWLANRecord->GetFieldByIdL(KCDTIdWlanWpaPreSharedKey));
   178         CMDBField<TDesC8>* wpaKey = static_cast<CMDBField<TDesC8>*>(iWLANRecord->GetFieldByIdL(KCDTIdWlanWpaPreSharedKey));        
   155          
       
   156         aSettings.WPAPreSharedKey.Append( *wpaKey);
   179         aSettings.WPAPreSharedKey.Append( *wpaKey);
   157         
   180         
   158         // In WPA-PSK case the preshared key can be either 8 - 63 characters in ASCII
   181         // In WPA-PSK case the preshared key can be either 8 - 63 characters in ASCII
   159         // or 64 characters in hex.
   182         // or 64 characters in hex.
   160         //
   183         //
   169             else if( aSettings.WPAKeyLength == KWLMMaxWpaPskLength )
   192             else if( aSettings.WPAKeyLength == KWLMMaxWpaPskLength )
   170                 {
   193                 {
   171                 aSettings.PresharedKeyFormat = EWlanPresharedKeyFormatHex;
   194                 aSettings.PresharedKeyFormat = EWlanPresharedKeyFormatHex;
   172                 }
   195                 }
   173             }            
   196             }            
       
   197         
       
   198         TraceDump(WARNING_LEVEL,(_L("CWlanSettings::GetDataL() - aSettings.PresharedKeyFormat: %d"),
       
   199             aSettings.PresharedKeyFormat));       
   174         }
   200         }
   175     
   201     
   176     TraceDump(WARNING_LEVEL,(_L("CWlanSettings::GetDataL end")));
   202     TraceDump(WARNING_LEVEL,(_L("CWlanSettings::GetDataL end")));
   177     }
   203     }
   178     
   204     
  1083 //
  1109 //
  1084 
  1110 
  1085 EXPORT_C void CWLanSettings::GetIAPWlanServicesL( RArray<SWlanIAPId>& aServices)
  1111 EXPORT_C void CWLanSettings::GetIAPWlanServicesL( RArray<SWlanIAPId>& aServices)
  1086     {
  1112     {
  1087     TraceDump(WARNING_LEVEL,(_L("CWlanSettings::GetIAPWlanServicesL start")));
  1113     TraceDump(WARNING_LEVEL,(_L("CWlanSettings::GetIAPWlanServicesL start")));
       
  1114     CleanupClosePushL( aServices );
  1088     
  1115     
  1089     CMDBRecordSet<CCDIAPRecord>* iapRecSet = new (ELeave) CMDBRecordSet<CCDIAPRecord>(KCDTIdIAPRecord);
  1116     CMDBRecordSet<CCDIAPRecord>* iapRecSet = new (ELeave) CMDBRecordSet<CCDIAPRecord>(KCDTIdIAPRecord);
  1090     CleanupStack::PushL( iapRecSet);
  1117     CleanupStack::PushL( iapRecSet);
  1091     
  1118     
  1092     CCDIAPRecord* iapPrimer = static_cast<CCDIAPRecord*>
  1119     CCDIAPRecord* iapPrimer = static_cast<CCDIAPRecord*>
  1096     // prime record set for service type "LANService"
  1123     // prime record set for service type "LANService"
  1097     TPtrC servType( KCDTypeNameLANService);
  1124     TPtrC servType( KCDTypeNameLANService);
  1098     iapPrimer->iServiceType.SetL( servType);
  1125     iapPrimer->iServiceType.SetL( servType);
  1099     iapRecSet->iRecords.AppendL( iapPrimer);
  1126     iapRecSet->iRecords.AppendL( iapPrimer);
  1100     
  1127     
  1101     CleanupStack::Pop( ); // iapPrimer
  1128     CleanupStack::Pop( iapPrimer );
  1102     iapPrimer = 0;
  1129     iapPrimer = 0;
  1103     
  1130     
  1104     TBool found( EFalse);
  1131     TBool found( EFalse);
  1105 
  1132 
  1106     // get all iap records with service type "LANService"    
  1133     // get all iap records with service type "LANService"    
  1121                 id.iIAPId = (*iapRecSet)[i]->RecordId();    // IAP record id
  1148                 id.iIAPId = (*iapRecSet)[i]->RecordId();    // IAP record id
  1122                 User::LeaveIfError( aServices.Append( id)); 
  1149                 User::LeaveIfError( aServices.Append( id)); 
  1123                 }
  1150                 }
  1124             }
  1151             }
  1125         }
  1152         }
  1126     CleanupStack::PopAndDestroy( ); // iapRecSet
  1153     CleanupStack::PopAndDestroy( iapRecSet );
       
  1154     CleanupStack::Pop( &aServices );
  1127     TraceDump(WARNING_LEVEL,(_L("CWlanSettings::GetIAPWlanServicesL end")));
  1155     TraceDump(WARNING_LEVEL,(_L("CWlanSettings::GetIAPWlanServicesL end")));
  1128     }
  1156     }
  1129 
  1157 
  1130 // -----------------------------------------------------------------------------
  1158 // -----------------------------------------------------------------------------
  1131 // CWLanSettings::GetSecondarySsidsForService
  1159 // CWLanSettings::GetSecondarySsidsForService