cmmanager/cmmgr/cmmplugins/cmpluginwlan/src/cmpluginwlan.cpp
changeset 30 8dde790cab74
parent 28 860702281757
child 40 c5b848e6c7d1
--- a/cmmanager/cmmgr/cmmplugins/cmpluginwlan/src/cmpluginwlan.cpp	Thu May 13 23:17:48 2010 +0300
+++ b/cmmanager/cmmgr/cmmplugins/cmpluginwlan/src/cmpluginwlan.cpp	Fri May 14 10:52:16 2010 +0300
@@ -25,6 +25,7 @@
 #include <cmcommonconstants.h>
 #include <featmgr.h>
 
+#include "datamobilitycommsdattypes.h"
 #include "cmpluginwlan.h"
 #include "cmwlancoveragecheck.h"
 #include "cmmanagerdef.h"
@@ -52,13 +53,11 @@
 
 const TInt KWlanServiceRecordIndex = 0;
 
-const TUint32 KDefaultPriorityWLan = 0;
-
 const TInt KWlanLastSocketActivityTimeout = -1;
 const TInt KWlanLastSessionClosedTimeout = 1;
 const TInt KWlanLastSocketClosedTimeout = -1;
 
-/// Modem bearer names for WLAN connection methods
+/// Modem bearer names for WLAN connection methods.
 _LIT( KModemBearerWLAN, "WLANBearer" );
 
 _LIT( KWlanBearerName, "WLANBearer" );
@@ -154,6 +153,16 @@
 
     CCmPluginBaseEng::ConstructL();
 
+    // Get bearer priority table ID.
+    TRAP_IGNORE( iBearerPriorityTableId =
+            CCDGlobalBearerTypePriorizationRecord::TableIdL( iSession ) );
+
+    if ( !iBearerPriorityTableId )
+        {
+        iBearerPriorityTableId =
+                CCDGlobalBearerTypePriorizationRecord::CreateTableL( iSession );
+        }
+
     // get WLAN table id
     TRAP_IGNORE( iWlanTableId = CCDWlanServiceRecord::TableIdL( iSession ) );
 
@@ -312,12 +321,12 @@
             break;
         case ECmDefaultUiPriority:
             {
-            retVal = KDefaultPriorityWLan;
+            retVal = GetDefPriorityL( aAttribute );
             }
             break;
         case ECmDefaultPriority:
             {
-            retVal = KDefaultPriorityWLan;
+            retVal = GetDefPriorityL( aAttribute );
             }
             break;
         case EWlanServiceId:
@@ -453,7 +462,7 @@
             break;
         case EWlan802_1xAllowUnencrypted:
             {
-            retVal = static_cast<TBool>( wlanServiceRecord->iWlanWpaKeyLength );
+            retVal = static_cast<TBool>( wlanServiceRecord->iWlanWpaKeyLength );//TODO, change typecast to if-else structure?
             }
             break;
         default:
@@ -1232,8 +1241,8 @@
 
     TBool retVal( EFalse );
 
-    CCDIAPRecord *iapRecord = static_cast<CCDIAPRecord *>
-                        ( CCDRecordBase::RecordFactoryL(KCDTIdIAPRecord) );
+    CCDIAPRecord *iapRecord = static_cast<CCDIAPRecord *>(
+            CCDRecordBase::RecordFactoryL(KCDTIdIAPRecord) );
 
     CleanupStack::PushL( iapRecord );
     iapRecord->SetRecordId( aIapId );
@@ -1307,8 +1316,8 @@
 
     if ( TPtrC( KCDTypeNameLANService ) == iIapRecord->iServiceType )
         {
-        iServiceRecord = static_cast<CCDLANServiceRecord *>
-                    ( CCDRecordBase::RecordFactoryL( KCDTIdLANServiceRecord ) );
+        iServiceRecord = static_cast<CCDLANServiceRecord*>(
+                CCDRecordBase::RecordFactoryL( KCDTIdLANServiceRecord ) );
 
         ServiceRecord().SetRecordId( iIapRecord->iService );
         ServiceRecord().LoadL( iSession );
@@ -1362,11 +1371,10 @@
     delete iServiceRecord;
     iServiceRecord = NULL;
 
-    iServiceRecord = static_cast<CCDLANServiceRecord*>
-                (CCDRecordBase::RecordFactoryL( KCDTIdLANServiceRecord ) );
+    iServiceRecord = static_cast<CCDLANServiceRecord*>(
+            CCDRecordBase::RecordFactoryL( KCDTIdLANServiceRecord ) );
 
-    CCDLANServiceRecord* lanServiceRecord = static_cast<CCDLANServiceRecord *>( iServiceRecord );
-
+    CCDLANServiceRecord* lanServiceRecord = static_cast<CCDLANServiceRecord*>( iServiceRecord );
 
     if ( FeatureManager::FeatureSupported( KFeatureIdIPv6 ) )
         {
@@ -1401,7 +1409,7 @@
         lanServiceRecord->iConfigDaemonName.SetL( KEmpty );
         }
 
-    // create WLAN service record
+    // Create WLAN service record.
     CreateWlanServiceRecordL();
 
     OstTraceFunctionExit0( CCMPLUGINWLAN_CREATESERVICERECORDL_EXIT );
@@ -1422,9 +1430,11 @@
     iWlanServiceRecord = new( ELeave ) CCDWlanServiceRecord ( iWlanTableId );
     iWlanServiceRecord->SetRecordId( KCDNewRecordRequest );
 
+    // Some attributes need to have default values set.
     iWlanServiceRecord->iRecordName.SetL( iIapRecord->iRecordName );
     iWlanServiceRecord->iWlanConnMode.SetL( CMManager::EInfra );
     iWlanServiceRecord->iWlanSecMode.SetL( CMManager::EWlanSecModeOpen );
+    iWlanServiceRecord->iWlanAuthMode.SetL( CMManager::EWlanAuthModeOpen );
     iWlanServiceRecord->iWlanScanSSID.SetL( EFalse );
 
     OstTraceFunctionExit0( CCMPLUGINWLAN_CREATEWLANSERVICERECORDL_EXIT );
@@ -2226,9 +2236,13 @@
             }
             break;
         case ECmDefaultUiPriority:
+            {
+            retVal = GetDefPriorityL( aAttribute );
+            }
+            break;
         case ECmDefaultPriority:
             {
-            retVal = KDefaultPriorityWLan;
+            retVal = GetDefPriorityL( aAttribute );
             }
             break;
         case ECmExtensionLevel:
@@ -2614,4 +2628,44 @@
     return result;
     }
 
+// ---------------------------------------------------------------------------
+// CCmPluginWlan::GetDefPriorityL
+// ---------------------------------------------------------------------------
+//
+TUint32 CCmPluginWlan::GetDefPriorityL( const TUint32 aAttribute ) const//TODO, OST
+    {
+
+    TUint32 retVal( KDataMobilitySelectionPolicyPriorityWildCard );
+
+    CCDGlobalBearerTypePriorizationRecord* priorityRecord =
+            new( ELeave ) CCDGlobalBearerTypePriorizationRecord( iBearerPriorityTableId );
+    CleanupStack::PushL( priorityRecord );
+
+    priorityRecord->iServiceType.SetL( TPtrC( KCDTypeNameLANService ) );
+
+    if ( priorityRecord->FindL( iSession ) )
+        {
+        priorityRecord->LoadL( iSession );
+
+        switch ( aAttribute )
+            {
+            case ECmDefaultPriority:
+                {
+                retVal = priorityRecord->iPriority;
+                }
+                break;
+            case ECmDefaultUiPriority:
+                {
+                retVal = priorityRecord->iUIPriority;
+                }
+                break;
+            default:
+                break;
+            }
+        }
+    CleanupStack::PopAndDestroy( priorityRecord );
+
+    return retVal;
+    }
+
 // End of File