vpnengine/vpnmanager/src/cmmanagerutils.cpp
branchRCL_3
changeset 41 e06095241a65
parent 40 473321461bba
child 49 5960d2d03390
--- a/vpnengine/vpnmanager/src/cmmanagerutils.cpp	Tue Aug 31 16:14:16 2010 +0300
+++ b/vpnengine/vpnmanager/src/cmmanagerutils.cpp	Wed Sep 01 12:23:21 2010 +0100
@@ -29,11 +29,13 @@
 static const TUint KMaxDestinationNameLength = 32;
 
 
-void CmManagerUtils::CreateVPNConnectionMethodToIntranetL(const TVpnPolicyInfo& aVpnPolicyInfo,
+TUint32 CmManagerUtils::CreateVPNConnectionMethodToIntranetL(const TVpnPolicyInfo& aVpnPolicyInfo,
                                                           CEventLogger& aEventLogger)
     {
     LOG_("CmManagerUtils::CreateVPNConnectionMethodToIntranetL \n");
     
+    TUint32 connectionMethodId(0);
+    
     using namespace CMManager;
     
     RCmManagerExt cmManagerExt;
@@ -75,7 +77,7 @@
                                                  internetDestinationId);                        
             
         CleanupClosePushL( vpnConnectionMethod );
-        TUint32 connectionMethodId = vpnConnectionMethod.GetIntAttributeL( ECmId );
+        connectionMethodId = vpnConnectionMethod.GetIntAttributeL( ECmId );
         aEventLogger.LogEvent(R_VPN_MSG_CREATED_VPN_ACCESS_POINT_WITH_SNAP,
                               &(aVpnPolicyInfo.iId), NULL,
                               connectionMethodId, internetDestinationId);
@@ -91,6 +93,8 @@
     CleanupStack::PopAndDestroy(); //cmManagerExt
     
     LOG_("CmManagerUtils::CreateVPNConnectionMethodToIntranetL - end \n");
+    return connectionMethodId;
+    
     }
 
 void CmManagerUtils::SetVpnConnectionMethodAttributesL(RCmConnectionMethodExt& aConnectionMethod,
@@ -102,7 +106,7 @@
     
     LOG_("CmManagerUtils::SetVpnConnectionMethodAttributesL \n");                                                   
     
-    aConnectionMethod.SetIntAttributeL( ECmNamingMethod, ENamingNothing );
+    aConnectionMethod.SetIntAttributeL( ECmNamingMethod, ENamingUnique );
     aConnectionMethod.SetStringAttributeL( ECmName, aConnectionMethodName );
     aConnectionMethod.SetStringAttributeL( EVpnServicePolicy, aPolicyId );      
     aConnectionMethod.SetIntAttributeL( ECmNextLayerSNAPId, aInternetDestinationId );
@@ -112,7 +116,7 @@
 
 HBufC* CmManagerUtils::CreateConnectionMethodNameLC(const TDesC& aPolicyName)
     {
-        
+       
     LOG_("CmManagerUtils::CreateConnectionMethodNameLC \n");
     
     HBufC* name = HBufC::NewLC(KMaxDestinationNameLength);
@@ -259,3 +263,42 @@
     LOG_("CmManagerUtils::CreateNewConnectionMethodToIntranetL - end \n");
     return vpnConnectionMethod;
     }
+
+TBool CmManagerUtils::ProvisionIAPNameExistL(TUint32 aAgileProvisionAPId)
+    {
+    TBool apExist=EFalse;
+    using namespace CMManager;
+    RCmManagerExt cmManagerExt;
+    cmManagerExt.OpenL();        
+    CleanupClosePushL( cmManagerExt ); 
+    
+    RArray<TUint32> aps;
+
+    TBool supportedBearersOnly = ETrue;
+    TBool legacyCmsOnly        = EFalse;
+
+    cmManagerExt.ConnectionMethodL( aps, supportedBearersOnly, legacyCmsOnly );
+    CleanupClosePushL( aps );
+
+    for( TInt i = 0; i < aps.Count(); ++i )
+        {
+        RCmConnectionMethodExt ap = cmManagerExt.ConnectionMethodL( aps[i] );
+        CleanupClosePushL( ap );
+        
+        if( KPluginVPNBearerTypeUid == ap.GetIntAttributeL( ECmBearerType ) )
+           if ( ap.GetIntAttributeL(ECmId) == aAgileProvisionAPId )
+              {
+              apExist=ETrue;
+              }
+        CleanupStack::PopAndDestroy();  // ap
+      }    
+      
+      CleanupStack::PopAndDestroy();  // aps
+    
+    
+    CleanupStack::PopAndDestroy(); //cmManagerExt
+       
+    return apExist;
+    }
+
+