--- a/bearermanagement/mpm/src/mpmwlanquerydialog.cpp Fri Apr 16 15:21:37 2010 +0300
+++ b/bearermanagement/mpm/src/mpmwlanquerydialog.cpp Mon May 03 12:53:07 2010 +0300
@@ -27,42 +27,21 @@
#include "mpmconnmonevents.h"
#include "mpmlogger.h"
-// valid Wep key lengths, to check wep key format
-// (wep key format depends on key length)
-const TInt KConnUiUtilsWepLengthASCII5 = 5;
-const TInt KConnUiUtilsWepLengthASCII13 = 13;
-const TInt KConnUiUtilsWepLengthASCII29 = 29;
-const TInt KConnUiUtilsWepLengthHEX10 = 10;
-const TInt KConnUiUtilsWepLengthHEX26 = 26;
-const TInt KConnUiUtilsWepLengthHEX58 = 58;
-
-// Retry count and delay for storing Easy WLAN data
-const TInt KStoreRetryCount = 10;
-const TInt KStoreRetryDelay = 100000;
-
// ======== MEMBER FUNCTIONS ========
// ---------------------------------------------------------------------------
// CMPMWlanQueryDialog::CMPMWlanQueryDialog
// ---------------------------------------------------------------------------
//
-CMPMWlanQueryDialog::CMPMWlanQueryDialog( CMPMIapSelection& aSession,
+CMPMWlanQueryDialog::CMPMWlanQueryDialog( CMPMIapSelection& aIapSelection,
TUint32 aWlanIapId )
: CActive( CActive::EPriorityStandard ),
- iIapSelection( aSession ),
- iNetworkPrefs(),
- iNotifWep(),
- iWlanQueryState( EWlanNetwork ),
+ iIapSelection( aIapSelection ),
+ iWlanQueryState( EOffline ),
iWlanIapId( aWlanIapId ),
- iEasyWlanSelected( EFalse ),
- iOverrideStatus( KErrNone ),
- iConnUiUtils( NULL ),
- iWps( NULL ),
- iWpsReturn( WiFiProt::EWiFiOK ),
- iWpsCompleted( EFalse ),
- iRetryCount( 0 )
+ iOverrideStatus( KErrNone )
{
-
+ CActiveScheduler::Add( this );
}
// ---------------------------------------------------------------------------
@@ -72,9 +51,6 @@
void CMPMWlanQueryDialog::ConstructL()
{
User::LeaveIfError(iNotifier.Connect());
- CActiveScheduler::Add( this );
- iConnUiUtils = CConnectionUiUtilities::NewL();
- User::LeaveIfError( iTimer.CreateLocal() );
}
// ---------------------------------------------------------------------------
@@ -100,14 +76,14 @@
CMPMWlanQueryDialog::~CMPMWlanQueryDialog()
{
MPMLOGSTRING( "CMPMWlanQueryDialog::~CMPMWlanQueryDialog enters" )
+
// Check if this dialog instance was not started but only added to the queue
if ( iIapSelection.Session()->MyServer().FirstInWlanQueryQueue() != this )
{
MPMLOGSTRING( "CMPMWlanQueryDialog::~CMPMWlanQueryDialog, not a active delete" )
- // Close notifier and timer
+ // Close notifier
iNotifier.Close();
- iTimer.Close();
// We're not first in the queue, thus we can just delete.
// But remember the pointer in the array.
@@ -119,24 +95,18 @@
// Cancel previous dialogs if any.
Cancel();
- // Close notifier and timer
+ // Close notifier
iNotifier.Close();
- iTimer.Close();
- delete iConnUiUtils;
-
- delete iWps;
// Remove self from the queue
iIapSelection.Session()->MyServer().RemoveFromWlanQueryQueue( this );
-
+
// Start the next query
CMPMWlanQueryDialog* dlg = iIapSelection.Session()->MyServer().FirstInWlanQueryQueue();
if ( dlg )
{
MPMLOGSTRING( "CMPMWlanQueryDialog::~CMPMWlanQueryDialog starts new dialog" )
- dlg->OfferInformation( iWlanIapId,
- iIapSelection.OfflineNoteResponse(),
- iStatus.Int() );
+ dlg->OfferInformation( iStatus.Int() );
// In destructor we cannot let the query leave
TRAPD( err, dlg->StartWlanQueryL(); )
if ( err != KErrNone )
@@ -160,26 +130,6 @@
{
iNotifier.CancelNotifier( KUidCOfflineWlanNoteDlg );
}
- else if ( iWlanQueryState == EWlanNetwork )
- {
- iConnUiUtils->CancelSearchWLANNetwork();
- }
- else if ( iWlanQueryState == EWepSettings )
- {
- iNotifier.CancelNotifier( KUidEasyWepDlg );
- }
- else if( iWlanQueryState == EWPS )
- {
- iWps->CancelWiFiProt();
- }
- else if ( iWlanQueryState == EWpaSettings )
- {
- iNotifier.CancelNotifier( KUidEasyWpaDlg );
- }
- else // ERetrySettingsStorage
- {
- iTimer.Cancel();
- }
}
// ---------------------------------------------------------------------------
@@ -191,21 +141,18 @@
MPMLOGSTRING3( "CMPMWlanQueryDialog::RunL status %d state %d",
iStatus.Int(),
iWlanQueryState )
+
if( iWlanQueryState == EOffline )
{
if( iStatus.Int() == KErrNone )
{
- iIapSelection.SetOfflineNoteResponse( EOfflineResponseYes );
- if( iIapSelection.Session()->MyServer().CommsDatAccess()->CheckEasyWLanL( iWlanIapId ) )
- {
- MPMLOGSTRING( "CMPMWlanQueryDialog::RunL starting wlan network query" )
- GetNetworkPrefs();
- return;
- }
+ iIapSelection.Session()->MyServer().SetOfflineWlanQueryResponse(
+ EOfflineResponseYes );
}
else if ( iStatus.Int() == KErrCancel )
{
- iIapSelection.SetOfflineNoteResponse( EOfflineResponseNo );
+ iIapSelection.Session()->MyServer().SetOfflineWlanQueryResponse(
+ EOfflineResponseNo );
MPMLOGSTRING2( "CMPMWlanQueryDialog::RunL offline query returned %d",
iStatus.Int() )
}
@@ -215,163 +162,12 @@
iStatus.Int() )
}
}
- else if( iWlanQueryState == EWlanNetwork )
+ // if an error was given through OfferInformation() -call we abort the execution.
+ //
+ else if ( iOverrideStatus != KErrNone )
{
- if( iStatus.Int() == KErrNone )
- {
-
- TUint secMode( 0 );
- TWlanNetMode connMode( EInfra );
- TInt err = ConnSecModeToCommsDatSecMode( iNetworkPrefs().iSecMode,
- secMode );
- if( err != KErrNone )
- {
- MPMLOGSTRING( "CMPMWlanQueryDialog::RunL, Unknown security mode" )
- iWlanIapId = 0;
- iWlanQueryState = EWlanNetwork;
- iIapSelection.UserWlanSelectionDoneL( KErrCouldNotConnect, iWlanIapId );
- return;
- }
-
- TUint32 configuredIap = iIapSelection.Session()->MyServer().
- CommsDatAccess()->CheckWLANIapWithSsidL( iNetworkPrefs().iSsId,
- secMode,
- connMode );
- // If previously unknown IAP, query wep/wpa parameters
- //
- if( !configuredIap )
- {
- iEasyWlanSelected = ETrue;
- if ( iNetworkPrefs().iProtectedSetupSupported &&
- iNetworkPrefs().iNetworkMode != EWlanConnectionModeAdhoc )
- {
- StartWpsDlgL();
- return;
- }
- // WEP
- //
- if( iNetworkPrefs().iSecMode == EWlanConnectionSecurityWep )
- {
- MPMLOGSTRING( "CMPMWlanQueryDialog::RunL unknown wep network" )
- iWlanQueryState = EWepSettings;
- iNotifier.StartNotifierAndGetResponse( iStatus,
- KUidEasyWepDlg,
- iNotifWep,
- iNotifWep );
- SetActive();
- return;
- }
- // WPA
- //
- else if ( iNetworkPrefs().iSecMode == EWlanConnectionSecurityWpaPsk )
- {
- MPMLOGSTRING( "CMPMWlanQueryDialog::RunL unknown wpa network" )
- iWlanQueryState = EWpaSettings;
- iNotifier.StartNotifierAndGetResponse( iStatus,
- KUidEasyWpaDlg,
- iNotifWpaKey,
- iNotifWpaKey );
- SetActive();
- return;
-
- }
- else
- {
- MPMLOGSTRING2( "CMPMWlanQueryDialog::RunL security mode %d",
- iNetworkPrefs().iSecMode )
- }
- }
-
- else
- {
- iWlanIapId = configuredIap;
- MPMLOGSTRING2( "CMPMWlanQueryDialog::RunL found configured iap matching ssid, id %d",
- iWlanIapId )
-
- }
- }
- else if( iStatus.Int() == KErrCancel )
- {
- iEasyWlanSelected = EFalse;
- MPMLOGSTRING( "CMPMWlanQueryDialog::RunL easy wlan dialog cancelled, \
-setting easy wlan as not selected" )
- }
- else
- {
- MPMLOGSTRING2( "CMPMWlanQueryDialog::RunL EWlanNetwork error %d",
- iStatus.Int() )
- }
-
- }
- else if( iWlanQueryState == EWepSettings || iWlanQueryState == EWpaSettings )
- {
- if( iStatus.Int() == KErrCancel )
- {
- MPMLOGSTRING( "CMPMWlanQueryDialog::Key dialog cancelled,back to easy wlan" )
- iNetworkPrefs().iSsId.FillZ();
- iNetworkPrefs().iNetworkMode = EWlanConnectionModeNotConnected;
- iNetworkPrefs().iSecMode = EWlanConnectionSecurityOpen;
- GetNetworkPrefs();
- return;
- }
- }
- else if( iWlanQueryState == EWPS )
- {
- MPMLOGSTRING2( "CMPMWlanQueryDialog::RunL WPS, status %d", iStatus.Int() )
- if( iStatus.Int() == KErrNone )
- {
- if( iWpsReturn == WiFiProt::EWiFiOK)
- {
- MPMLOGSTRING( "CMPMWlanQueryDialog::RunL WPS ok" )
- iWpsCompleted = ETrue;
- }
- else if ( iWpsReturn == WiFiProt::EWiFiCancel )
- {
- MPMLOGSTRING( "CMPMWlanQueryDialog::RunL WPS cancelled" )
- iStatus = KErrCancel;
- }
- else // WiFiProt::EWiFiNoAuto
- {
- if( iNetworkPrefs().iSecMode == EWlanConnectionSecurityWep )
- {
- MPMLOGSTRING( "CMPMWlanQueryDialog::RunL: No WPS, starting WEP key query" );
- iWlanQueryState = EWepSettings;
- iNotifier.StartNotifierAndGetResponse( iStatus,
- KUidEasyWepDlg,
- iNotifWep,
- iNotifWep );
- SetActive();
- return;
- }
- else if ( iNetworkPrefs().iSecMode == EWlanConnectionSecurityWpaPsk )
- {
- MPMLOGSTRING( "CMPMWlanQueryDialog::RunL: No WPS, starting WPA key query" );
- iWlanQueryState = EWpaSettings;
- iNotifier.StartNotifierAndGetResponse( iStatus,
- KUidEasyWpaDlg,
- iNotifWpaKey,
- iNotifWpaKey );
- SetActive();
- return;
- }
- else if ( iNetworkPrefs().iSecMode == EWlanConnectionSecurityOpen )
- {
- MPMLOGSTRING( "CMPMWlanQueryDialog::RunL: No WPS, sec mode open" );
- iStatus = KErrNone;
- }
- else
- {
- MPMLOGSTRING2( "CMPMWlanQueryDialog::RunL: No WPS, unsupported sec mode %d",
- iNetworkPrefs().iSecMode );
- iStatus = KErrNotSupported;
- }
- }
- }
- }
- else if ( iWlanQueryState == ERetrySettingsStorage )
- {
- // Retry settings storage
- MPMLOGSTRING( "CMPMWlanQueryDialog::RunL Retry settings storage" )
+ MPMLOGSTRING2( "CMPMWlanQueryDialog::StartWlanQuery inherited error %d", iOverrideStatus )
+ iIapSelection.UserWlanSelectionDoneL( iOverrideStatus, iWlanIapId );
}
else
{
@@ -379,29 +175,9 @@
User::Leave( KErrCancel );
}
- TRAPD( leaveCode, iIapSelection.UserWlanSelectionDoneL( iStatus.Int(), iWlanIapId ) );
- if( leaveCode != KErrNone )
- {
- // Something caused method to leave, if CommsDat was locked we should retry
- if ( iStatus.Int() == KErrNone &&
- leaveCode == KErrLocked &&
- iRetryCount > 0 )
- {
- MPMLOGSTRING2( "CMPMWlanQueryDialog::RunL Start retry timer, retry count %d", iRetryCount )
- iWlanQueryState = ERetrySettingsStorage;
- iRetryCount--;
- iTimer.After( iStatus, KStoreRetryDelay );
- SetActive();
- return;
- }
- else
- {
- User::Leave( leaveCode );
- }
- }
+ iIapSelection.UserWlanSelectionDoneL( iStatus.Int(), iWlanIapId );
iWlanIapId = 0;
- iWlanQueryState = EWlanNetwork;
}
// ---------------------------------------------------------------------------
@@ -411,7 +187,6 @@
TInt CMPMWlanQueryDialog::RunError( TInt aError )
{
MPMLOGSTRING2( "CMPMWlanQueryDialog::RunError failed with %d", aError )
- iEasyWlanSelected = EFalse;
iIapSelection.ChooseIapComplete( aError, NULL );
return KErrNone;
}
@@ -423,26 +198,6 @@
void CMPMWlanQueryDialog::StartWlanQueryL()
{
MPMLOGSTRING( "CMPMWlanQueryDialog::StartWlanQuery" )
-
- iRetryCount = KStoreRetryCount;
-
- // if first dialog user, add it to the array and continue.
- //
- if ( iIapSelection.Session()->MyServer().WlanQueryQueue()->Count() == 0 )
- {
- MPMLOGSTRING( "CMPMWlanQueryDialog::StartWlanQuery First one, start immediately" )
- iIapSelection.Session()->MyServer().AppendWlanQueryQueueL( this );
- }
- // if another dialog should be processed before this, just add and return.
- //
- else if ( iIapSelection.Session()->MyServer().FirstInWlanQueryQueue() != this )
- {
- MPMLOGSTRING( "CMPMWlanQueryDialog::StartWlanQuery Latter, process later" )
- iIapSelection.Session()->MyServer().AppendWlanQueryQueueL( this );
- return;
- }
- // else Continue to process the first dialog.(this one)
- // FirstInWlanQueryQueue() == this && Count() > 0
TUint32 activeWlanIap = iIapSelection.Session()->MyServer().IsWlanConnectionStartedL(
iIapSelection.Session()->MyServer().CommsDatAccess() );
@@ -462,19 +217,12 @@
MPMLOGSTRING2( "CMPMWlanQueryDialog::StartWlanQuery noteBehaviour = %d", noteBehaviour )
if( !emergencyCallEstablished &&
- iIapSelection.Session()->IsPhoneOfflineL() &&
+ iIapSelection.Session()->MyServer().IsPhoneOffline() &&
!activeWlanIap &&
- iIapSelection.OfflineNoteResponse() != EOfflineResponseYes &&
+ iIapSelection.Session()->MyServer().OfflineWlanQueryResponse() != EOfflineResponseYes &&
iOverrideStatus == KErrNone )
{
- // if user has already refused offline note complete immediately
- //
- if ( iIapSelection.OfflineNoteResponse() == EOfflineResponseNo )
- {
- MPMLOGSTRING( "CMPMWlanQueryDialog::StartWlanQuery user has already refused offline" )
- iIapSelection.UserWlanSelectionDoneL( KErrCancel, iWlanIapId );
- }
- else if ( noteBehaviour & TExtendedConnPref::ENoteBehaviourConnDisableQueries )
+ if ( noteBehaviour & TExtendedConnPref::ENoteBehaviourConnDisableQueries )
{
MPMLOGSTRING( "CMPMWlanQueryDialog::StartWlanQuery offline note query not shown due to disabled queries" )
iIapSelection.UserWlanSelectionDoneL( KErrPermissionDenied, iWlanIapId );
@@ -490,32 +238,6 @@
SetActive();
}
}
- // if easy wlan iap and some wlan iap started, use existing connection
- //
- else if( iIapSelection.Session()->MyServer().CommsDatAccess()->CheckEasyWLanL( iWlanIapId ) &&
- activeWlanIap )
- {
- MPMLOGSTRING2( "CMPMWlanQueryDialog::StartWlanQuery using active WLAN IAP %d",
- activeWlanIap )
- iIapSelection.UserWlanSelectionDoneL( KErrNone, activeWlanIap );
- }
- // if easy wlan iap and easy wlan is not already started
- //
- else if( iIapSelection.Session()->MyServer().CommsDatAccess()->CheckEasyWLanL( iWlanIapId ) &&
- !iIapSelection.Session()->MyServer().CheckIfStarted( iWlanIapId ) &&
- iNetworkPrefs().iSsId.Length() == 0 &&
- iOverrideStatus == KErrNone )
- {
- MPMLOGSTRING( "CMPMWlanQueryDialog::StartWlanQuery starting network query" )
- GetNetworkPrefs();
- }
- // if an error was given through OfferInformation() -call we abort the execution.
- //
- else if ( iOverrideStatus != KErrNone )
- {
- MPMLOGSTRING2( "CMPMWlanQueryDialog::StartWlanQuery inherited error %d", iOverrideStatus )
- iIapSelection.UserWlanSelectionDoneL( iOverrideStatus, iWlanIapId );
- }
else
{
MPMLOGSTRING( "CMPMWlanQueryDialog::StartWlanQuery no wlan dialog to show" )
@@ -523,40 +245,19 @@
}
}
-
// -----------------------------------------------------------------------------
// CMPMWlanQueryDialog::OfferInformation
// -----------------------------------------------------------------------------
//
-void CMPMWlanQueryDialog::OfferInformation(
- TUint32 aWlanIapId,
- TOfflineNoteResponse aOfflineStatus,
- TInt aDialogStatus )
+void CMPMWlanQueryDialog::OfferInformation( TInt aDialogStatus )
{
- TBool isEasyWlan( EFalse );
- // Take information from earlier note into use
- // if the selected IAP is EasyWLAN or Offline note response was No.
- //
- TRAP_IGNORE( isEasyWlan =
- iIapSelection.Session()->MyServer().CommsDatAccess()->CheckEasyWLanL( iWlanIapId ); )
- if ( isEasyWlan )
- {
- // iEasyWlanSelected is not passed as only the first connection
- // should write the easy wlan settings to commsdat if easy wlan is used.
- //
- MPMLOGSTRING3( "CMPMWlanQueryDialog<0x%x>::OfferInformation: EasyWLAN, iap %d",
- iIapSelection.Session()->ConnectionId(),
- aWlanIapId )
-
- iWlanIapId = aWlanIapId;
- iOverrideStatus = aDialogStatus;
- }
- if ( aOfflineStatus != EOfflineResponseUndefined )
+ TOfflineWlanQueryResponse offlineResponse =
+ iIapSelection.Session()->MyServer().OfflineWlanQueryResponse();
+ if ( offlineResponse != EOfflineResponseUndefined )
{
MPMLOGSTRING3( "CMPMWlanQueryDialog<0x%x>::OfferInformation: offline response %d",
iIapSelection.Session()->ConnectionId(),
- aOfflineStatus )
- iIapSelection.SetOfflineNoteResponse( aOfflineStatus );
+ offlineResponse )
iOverrideStatus = aDialogStatus;
}
@@ -568,313 +269,3 @@
#endif
}
-
-// -----------------------------------------------------------------------------
-// CMPMWlanQueryDialog::StoreEasyWlanSelectionL
-// -----------------------------------------------------------------------------
-//
-void CMPMWlanQueryDialog::StoreEasyWlanSelectionL()
- {
- if( iEasyWlanSelected )
- {
- TWlanSsid ssid;
- TWepKeyData wepData;
- TUint wpaPskEnabled( 0 );
- TUint wpaPskLen( 0 );
- TBuf8<KWLMMaxWpaPskLength> wpa;
- TUint secMode( 0 );
- TWlanNetMode connMode( EInfra );
-
- if( iWpsCompleted )
- {
- GetEasyWlanDataForWpsL( ssid,
- secMode,
- connMode,
- wepData,
- wpaPskEnabled,
- wpa,
- wpaPskLen );
- MPMLOGSTRING3( "CMPMWlanQueryDialog::StoreEasyWlanSelection: \
-wps used, connection iap %d, ssid %S", iWlanIapId, &iWpsAttribute.iSsid )
- iIapSelection.Session()->MyServer().Events()->
- SetConnInfoIapSsid( iWlanIapId,
- iWpsAttribute.iSsid );
- iIapSelection.Session()->MyServer().CommsDatAccess()->SetEasyWlanDataL( ssid,
- secMode,
- connMode,
- wepData,
- wpaPskEnabled,
- wpa,
- wpaPskLen );
- return;
- }
-
- MPMLOGSTRING( "CMPMWlanQueryDialog::StoreEasyWlanSelection: setting easy wlan data" )
- GetEasyWlanDataL( ssid,
- secMode,
- connMode,
- wepData,
- wpaPskEnabled,
- wpa,
- wpaPskLen );
-
- MPMLOGSTRING3( "CMPMWlanQueryDialog::StoreEasyWlanSelection: \
-setting easy wlan iap %d ssid %S in connmon events", iWlanIapId, &iNetworkPrefs().iSsId )
- iIapSelection.Session()->MyServer().Events()->SetConnInfoIapSsid( iWlanIapId,
- iNetworkPrefs().iSsId );
- iIapSelection.Session()->MyServer().CommsDatAccess()->SetEasyWlanDataL( ssid,
- secMode,
- connMode,
- wepData,
- wpaPskEnabled,
- wpa,
- wpaPskLen );
-
- }
- else
- {
- MPMLOGSTRING( "CMPMWlanQueryDialog::StoreEasyWlanSelection: no easy wlan selected by user" )
- }
- }
-
-
-// -----------------------------------------------------------------------------
-// CMPMWlanQueryDialog::GetEasyWlanDataL
-// -----------------------------------------------------------------------------
-//
-void CMPMWlanQueryDialog::GetEasyWlanDataL( TWlanSsid& aSsid,
- TUint& aSecMode,
- TWlanNetMode& aConnMode,
- TWepKeyData& aWepData,
- TUint& aEnableWpaPsk,
- TDes8& aWpaPsk,
- TUint& aWpaKeyLen )
- {
- aSsid.Copy( iNetworkPrefs().iSsId );
- if ( iNetworkPrefs().iNetworkMode == EWlanConnectionModeAdhoc )
- {
- aConnMode = EAdhoc;
- }
-
- // Set security mode
- TInt err = ConnSecModeToCommsDatSecMode( iNetworkPrefs().iSecMode,
- aSecMode );
-
- if( err != KErrNone )
- {
- MPMLOGSTRING2( "CMPMWlanQueryDialog::StoreEasyWlanSelection: \
-unsupported sec mode %d. leaving", iNetworkPrefs().iSecMode )
- User::Leave( KErrNotSupported );
- }
-
- if( iNetworkPrefs().iSecMode == EWlanConnectionSecurityWep )
- {
- CnvUtfConverter::ConvertFromUnicodeToUtf8( aWepData.iWep1, iNotifWep().iKey );
- //MPMLOG8STRING2( "CMPMWlanQueryDialog::StoreEasyWlanSelection:wep-key8:%S ", &aWepData.iWep1 )
- if( iNotifWep().iHex )
- {
- aWepData.iWepFormat1 = 1;
- MPMLOGSTRING( "CMPMWlanQueryDialog::StoreEasyWlanSelection: wep format is 1 (hex)")
- }
- aWepData.iDefaultWep = EWlanDefaultWepKey1;
- }
- else if( iNetworkPrefs().iSecMode == EWlanConnectionSecurityWpaPsk )
- {
- CnvUtfConverter::ConvertFromUnicodeToUtf8( aWpaPsk, iNotifWpaKey() );
- aEnableWpaPsk = 1;
- aWpaKeyLen = aWpaPsk.Length();
- MPMLOGSTRING3( "CMPMWlanQueryDialog::StoreEasyWlanSelection:wpapsk-key:%s, len:%d",
- &iNotifWpaKey(),
- aWpaKeyLen )
- }
- else
- {
- MPMLOGSTRING2( "CMPMWlanQueryDialog::StoreEasyWlanSelection: \
-no key handling needed for sec mode %d", iNetworkPrefs().iSecMode )
- }
- }
-
-// ---------------------------------------------------------------------------
-// CMPMWlanQueryDialog::ConnSecModeToCommsDatSecMode
-// ---------------------------------------------------------------------------
-//
-TInt CMPMWlanQueryDialog::ConnSecModeToCommsDatSecMode( TWlanConnectionSecurityMode aConnSecmode,
- TUint& aCommsdatSecMode ) const
- {
-
- if ( aConnSecmode == EWlanConnectionSecurityOpen )
- {
- aCommsdatSecMode = EWlanSecModeOpen;
- }
- else if ( aConnSecmode == EWlanConnectionSecurityWep )
- {
- aCommsdatSecMode = EWlanSecModeWep;
- }
- else if ( aConnSecmode == EWlanConnectionSecurityWpaPsk )
- {
- aCommsdatSecMode = EWlanSecModeWpa2;
- }
- else if ( aConnSecmode == EWlanConnectionSecurityWpa )
- {
- aCommsdatSecMode = EWlanSecModeWpa;
- }
- else
- {
- MPMLOGSTRING( "CMPMWlanQueryDialog::RunL, Unknown security mode" )
- return KErrCouldNotConnect;
- }
- return KErrNone;
- }
-
-
-// ---------------------------------------------------------------------------
-// CMPMWlanQueryDialog::IapSecModeToCommsDatSecMode
-// ---------------------------------------------------------------------------
-//
-TInt CMPMWlanQueryDialog::IapSecModeToCommsDatSecMode( TWlanIapSecurityMode aIapSecmode,
- TUint& aCommsdatSecMode ) const
- {
- switch( aIapSecmode )
- {
- case EWlanIapSecurityModeAllowUnsecure:
- aCommsdatSecMode |= EWlanSecModeOpen;
- break;
- case EWlanIapSecurityModeWep:
- aCommsdatSecMode |= EWlanSecModeWep;
- break;
- case EWlanIapSecurityModeWpa:
- aCommsdatSecMode |= EWlanSecModeWpa;
- break;
- case EWlanIapSecurityModeWpa2Only:
- aCommsdatSecMode |= EWlanSecModeWpa2;
- break;
- default:
- MPMLOGSTRING2( "CMPMWlanQueryDialog::IapSecModeToCommsDatSecMode: \
-unsupported sec mode %d ", aIapSecmode )
- return KErrNotSupported;
- }
- return KErrNone;
- }
-
-// -----------------------------------------------------------------------------
-// CMPMWlanQueryDialog::GetEasyWlanDataForWpsL
-// -----------------------------------------------------------------------------
-//
-void CMPMWlanQueryDialog::GetEasyWlanDataForWpsL( TWlanSsid& aSsid,
- TUint& aSecMode,
- TWlanNetMode& aConnMode,
- TWepKeyData& aWepKeyData,
- TUint& aEnableWpaPsk,
- TDes8& aWpaPsk,
- TUint& aWpaKeyLen )
- {
- aSsid.Copy( iWpsAttribute.iSsid );
- if ( iWpsAttribute.iOperatingMode == EWlanOperatingModeAdhoc )
- {
- aConnMode = EAdhoc;
- }
- TInt err = IapSecModeToCommsDatSecMode( iWpsAttribute.iSecurityMode,
- aSecMode );
- if( err != KErrNone )
- {
- MPMLOGSTRING( "CMPMWlanQueryDialog::GetEasyWlanDataForWpsL: \
-unsupported wps sec mode leaving" )
- User::Leave( KErrNotSupported );
- }
-
- if( iWpsAttribute.iSecurityMode == EWlanIapSecurityModeWep )
- {
- if( iWpsAttribute.iWepKey1.Length() &&
- IsWepFormatHexL( iWpsAttribute.iWepKey1.Length() ) )
- {
- aWepKeyData.iWepFormat1 = 1;
- }
- if( iWpsAttribute.iWepKey2.Length() &&
- IsWepFormatHexL( iWpsAttribute.iWepKey2.Length() ) )
- {
- aWepKeyData.iWepFormat2 = 1;
- }
- if( iWpsAttribute.iWepKey3.Length() &&
- IsWepFormatHexL( iWpsAttribute.iWepKey3.Length() ) )
- {
- aWepKeyData.iWepFormat3 = 1;
- }
- if( iWpsAttribute.iWepKey4.Length() &&
- IsWepFormatHexL( iWpsAttribute.iWepKey4.Length() ) )
- {
- aWepKeyData.iWepFormat4 = 1;
- }
- aWepKeyData.iWep1.Copy( iWpsAttribute.iWepKey1 );
- aWepKeyData.iWep2.Copy( iWpsAttribute.iWepKey2 );
- aWepKeyData.iWep3.Copy( iWpsAttribute.iWepKey3 );
- aWepKeyData.iWep4.Copy( iWpsAttribute.iWepKey4 );
- aWepKeyData.iDefaultWep = iWpsAttribute.iWepDefaultKey;
- }
- if( iWpsAttribute.iWpaPreSharedKey.Length() )
- {
- aEnableWpaPsk = 1;
- aWpaPsk.Copy( iWpsAttribute.iWpaPreSharedKey );
- aWpaKeyLen = aWpaPsk.Length();
- }
-
- }
-
-// ---------------------------------------------------------------------------
-// CMPMWlanQueryDialog::StartWpsDlgL
-// ---------------------------------------------------------------------------
-//
-void CMPMWlanQueryDialog::StartWpsDlgL()
- {
- MPMLOGSTRING( "CMPMWlanQueryDialog::StartWpsDlgL, Starting WPS" )
- iWlanQueryState = EWPS;
- iWps = CWiFiProtUiClient::NewL();
- iWps->StartWiFiProtConnL( iNetworkPrefs().iSsId, // TWlanSsid&,
- iWpsAttribute,
- iWpsReturn,
- iStatus );
- SetActive();
- }
-
-// ---------------------------------------------------------------------------
-// CMPMWlanQueryDialog::IsWepFormatHexL
-// ---------------------------------------------------------------------------
-//
-TBool CMPMWlanQueryDialog::IsWepFormatHexL( TInt aLength ) const
- {
- MPMLOGSTRING2( "CMPMWlanQueryDialog::IsWepFormatHexL length %d", aLength )
-
- if ( ( aLength == KConnUiUtilsWepLengthASCII5 ) ||
- ( aLength == KConnUiUtilsWepLengthASCII13 ) ||
- ( aLength == KConnUiUtilsWepLengthASCII29 ) )
- {
- return EFalse;
- }
- else if ( ( aLength == KConnUiUtilsWepLengthHEX10 ) ||
- ( aLength == KConnUiUtilsWepLengthHEX26 ) ||
- ( aLength == KConnUiUtilsWepLengthHEX58 ) )
- {
- return ETrue;
- }
- else
- {
- User::Leave( KErrNotSupported );
- }
- return EFalse;
- }
-
-// ---------------------------------------------------------------------------
-// CMPMWlanQueryDialog::GetNetworkPrefs
-// ---------------------------------------------------------------------------
-//
-void CMPMWlanQueryDialog::GetNetworkPrefs()
- {
- iWlanQueryState = EWlanNetwork;
- iConnUiUtils->SearchWLANNetworkAsync( iStatus,
- iNetworkPrefs().iSsId,
- iNetworkPrefs().iNetworkMode,
- iNetworkPrefs().iSecMode,
- iNetworkPrefs().iProtectedSetupSupported
- );
- SetActive();
- }
-