63 |
63 |
64 |
64 |
65 if ( internetDestinationId != 0) |
65 if ( internetDestinationId != 0) |
66 { |
66 { |
67 //Generate name for the connection method |
67 //Generate name for the connection method |
68 HBufC* name = CreateConnectionMethodNameLC(cmManagerExt, |
68 HBufC* name = CreateConnectionMethodNameLC(aVpnPolicyInfo.iName); |
69 aVpnPolicyInfo.iName); |
|
70 |
69 |
71 //Create VPN connection method |
70 //Create VPN connection method |
72 RCmConnectionMethodExt vpnConnectionMethod = |
71 RCmConnectionMethodExt vpnConnectionMethod = |
73 CreateNewConnectionMethodToIntranetL(cmManagerExt, |
72 CreateNewConnectionMethodToIntranetL(cmManagerExt, |
74 *name, |
73 *name, |
109 aConnectionMethod.SetIntAttributeL( ECmNextLayerSNAPId, aInternetDestinationId ); |
108 aConnectionMethod.SetIntAttributeL( ECmNextLayerSNAPId, aInternetDestinationId ); |
110 |
109 |
111 LOG_("CmManagerUtils::SetVpnConnectionMethodAttributesL - end \n"); |
110 LOG_("CmManagerUtils::SetVpnConnectionMethodAttributesL - end \n"); |
112 } |
111 } |
113 |
112 |
114 HBufC* CmManagerUtils::CreateConnectionMethodNameLC(RCmManagerExt& aCmManagerExt, |
113 HBufC* CmManagerUtils::CreateConnectionMethodNameLC(const TDesC& aPolicyName) |
115 const TDesC& aPolicyName) |
114 { |
116 { |
115 |
117 using namespace CMManager; |
|
118 |
|
119 LOG_("CmManagerUtils::CreateConnectionMethodNameLC \n"); |
116 LOG_("CmManagerUtils::CreateConnectionMethodNameLC \n"); |
120 |
117 |
121 HBufC* name = HBufC::NewLC(KMaxDestinationNameLength); |
118 HBufC* name = HBufC::NewLC(KMaxDestinationNameLength); |
122 TPtr namePtr = name->Des(); |
119 TPtr namePtr = name->Des(); |
123 |
120 |
124 RArray<TUint32> connections; |
121 namePtr.Copy(aPolicyName.Left(KMaxDestinationNameLength)); |
125 CleanupClosePushL( connections ); |
122 |
126 aCmManagerExt.ConnectionMethodL( connections, EFalse, EFalse, EFalse ); |
|
127 |
|
128 TInt connectionMethodCount = connections.Count(); |
|
129 TBool matchFound = EFalse; |
|
130 TInt counter = 1; |
|
131 do |
|
132 { |
|
133 matchFound = EFalse; |
|
134 |
|
135 namePtr.Copy(aPolicyName.Left(KMaxDestinationNameLength)); |
|
136 if (counter > 1) |
|
137 { |
|
138 TBuf<10> numberValue; |
|
139 numberValue.Format(_L("(%d)"), counter); |
|
140 if (namePtr.MaxLength() < numberValue.Length() + namePtr.Length()) |
|
141 { |
|
142 namePtr.SetLength(namePtr.MaxLength() - numberValue.Length()); |
|
143 |
|
144 } |
|
145 namePtr.Append(numberValue); |
|
146 } |
|
147 |
|
148 for (TInt i = 0; i < connectionMethodCount; i++) |
|
149 { |
|
150 RCmConnectionMethodExt connectionMethod = aCmManagerExt.ConnectionMethodL( connections[i] ); |
|
151 CleanupClosePushL(connectionMethod); |
|
152 HBufC* existingName = connectionMethod.GetStringAttributeL( ECmName ); |
|
153 CleanupStack::PopAndDestroy(); //connectionMethod |
|
154 |
|
155 if (name->Compare(*existingName) == 0) |
|
156 { |
|
157 delete existingName; |
|
158 matchFound = ETrue; |
|
159 break; |
|
160 } |
|
161 delete existingName; |
|
162 } |
|
163 counter++; |
|
164 }while(matchFound); |
|
165 |
|
166 CleanupStack::PopAndDestroy(); // connections |
|
167 LOG_("CmManagerUtils::CreateConnectionMethodNameLC - end \n"); |
123 LOG_("CmManagerUtils::CreateConnectionMethodNameLC - end \n"); |
168 return name; |
124 return name; |
169 } |
125 } |
170 |
126 |
171 |
127 |