80 TUint32& aIapId, |
80 TUint32& aIapId, |
81 const TDesC& aUid ) |
81 const TDesC& aUid ) |
82 { |
82 { |
83 DEBUG("CHssIapSettingsHandler::CreateClientIapL"); |
83 DEBUG("CHssIapSettingsHandler::CreateClientIapL"); |
84 |
84 |
85 RCmManager cmManager; |
85 RCmManagerExt cmManager; |
86 cmManager.OpenL(); |
86 cmManager.OpenL(); |
87 CleanupClosePushL( cmManager ); |
87 CleanupClosePushL( cmManager ); |
88 |
88 |
89 // Read all destination(SNAP) settings into an array |
89 // Read all destination(SNAP) settings into an array |
90 RArray<TUint32> destinations; |
90 RArray<TUint32> destinations; |
91 CleanupClosePushL( destinations ); |
91 CleanupClosePushL( destinations ); |
92 |
92 |
93 cmManager.AllDestinationsL( destinations ); |
93 cmManager.AllDestinationsL( destinations ); |
94 RCmDestination destination; |
94 RCmDestinationExt destination; |
95 // Loop through each destination |
95 // Loop through each destination |
96 for( TInt i = 0; i < destinations.Count(); i++ ) |
96 for( TInt i = 0; i < destinations.Count(); i++ ) |
97 { |
97 { |
98 destination = cmManager.DestinationL(destinations[i]); |
98 destination = cmManager.DestinationL(destinations[i]); |
99 CleanupClosePushL(destination); |
99 CleanupClosePushL(destination); |
100 // Internet destination will always exist in the system. |
100 // Internet destination will always exist in the system. |
101 // Internet destination will have ESnapPurposeInternet set in its metadata. |
101 // Internet destination will have ESnapPurposeInternet set in its metadata. |
102 if (destination.MetadataL(CMManager::ESnapMetadataPurpose) == CMManager::ESnapPurposeInternet) |
102 if ( destination.MetadataL( CMManager::ESnapMetadataPurpose ) == |
|
103 CMManager::ESnapPurposeInternet ) |
103 { |
104 { |
104 RCmConnectionMethod plugin = cmManager.CreateConnectionMethodL( KUidWlanBearerType ); |
105 RCmConnectionMethodExt plugin = cmManager.CreateConnectionMethodL( KUidWlanBearerType ); |
105 CleanupClosePushL( plugin ); |
106 CleanupClosePushL( plugin ); |
106 |
107 |
107 plugin.SetStringAttributeL( ECmName, aIapName ); |
108 plugin.SetStringAttributeL( ECmName, aIapName ); |
108 plugin.SetStringAttributeL( EWlanSSID, aIapName ); |
109 plugin.SetStringAttributeL( EWlanSSID, aIapName ); |
109 plugin.SetStringAttributeL( EWlanServiceExtensionTableName, aUid ); |
110 plugin.SetStringAttributeL( EWlanServiceExtensionTableName, aUid ); |
123 |
124 |
124 DEBUG("CHssIapSettingsHandler::CreateClientIapL Done"); |
125 DEBUG("CHssIapSettingsHandler::CreateClientIapL Done"); |
125 } |
126 } |
126 |
127 |
127 // ----------------------------------------------------------------------------- |
128 // ----------------------------------------------------------------------------- |
128 // DeleteIapL |
129 // CreateIapL |
129 // ----------------------------------------------------------------------------- |
130 // ----------------------------------------------------------------------------- |
130 // |
131 // |
131 void CHssIapSettingsHandler::DeleteIapL( const TUint aIapId ) |
132 TInt CHssIapSettingsHandler::CreateIapL( TBool aHotspot ) |
132 { |
133 { |
133 DEBUG1("CHssIapSettingsHandler:::DeleteIapL aIapId=%d ", aIapId); |
134 DEBUG("CHssIapSettingsHandler::CreateIapL"); |
134 |
135 TInt ret ( KErrNone ); |
135 RCmManager cmManager; |
136 RCmManagerExt cmManager; |
136 cmManager.OpenL(); |
137 cmManager.OpenL(); |
137 CleanupClosePushL( cmManager ); |
138 CleanupClosePushL( cmManager ); |
138 |
139 |
139 RCmConnectionMethod plugin = cmManager.ConnectionMethodL( aIapId ); |
140 // Read all destination(SNAP) settings into an array |
|
141 RArray<TUint32> destinations; |
|
142 CleanupClosePushL( destinations ); |
|
143 |
|
144 cmManager.AllDestinationsL( destinations ); |
|
145 RCmDestinationExt destination; |
|
146 // Loop through each destination |
|
147 for( TInt i = 0; i < destinations.Count(); i++ ) |
|
148 { |
|
149 destination = cmManager.DestinationL( destinations[i] ); |
|
150 CleanupClosePushL( destination ); |
|
151 // Internet destination will always exist in the system. |
|
152 // Internet destination will have ESnapPurposeInternet |
|
153 // set in its metadata. |
|
154 if ( destination.MetadataL( CMManager::ESnapMetadataPurpose ) == |
|
155 CMManager::ESnapPurposeInternet ) |
|
156 { |
|
157 CWlanMgmtClient* wlanMgmtClient = CWlanMgmtClient::NewL(); |
|
158 CleanupStack::PushL( wlanMgmtClient ); |
|
159 |
|
160 TWlanConnectionMode connMode; |
|
161 User::LeaveIfError( |
|
162 wlanMgmtClient->GetConnectionMode( connMode ) ); |
|
163 |
|
164 TWlanConnectionSecurityMode secMode; |
|
165 User::LeaveIfError( |
|
166 wlanMgmtClient->GetConnectionSecurityMode( secMode ) ); |
|
167 |
|
168 HBufC* ssid( NULL ); |
|
169 TWlanSsid ssidConn; |
|
170 |
|
171 User::LeaveIfError( |
|
172 wlanMgmtClient->GetConnectionSsid( ssidConn ) ); |
|
173 ssid = HBufC::NewLC( ssidConn.Length() ); |
|
174 ssid->Des().Copy( ssidConn ); |
|
175 |
|
176 TUint32 serviceId(0); |
|
177 TUint32 easyWlanIapId(0); |
|
178 easyWlanIapId = cmManager.EasyWlanIdL(); |
|
179 |
|
180 RCmConnectionMethodExt easyWlanPlugin; |
|
181 easyWlanPlugin = cmManager.ConnectionMethodL( easyWlanIapId ); |
|
182 CleanupClosePushL( easyWlanPlugin ); |
|
183 TBool scanSsid = easyWlanPlugin.GetBoolAttributeL( EWlanScanSSID ); |
|
184 TUint32 easyWlanServiceId = |
|
185 easyWlanPlugin.GetIntAttributeL( EWlanServiceId ); |
|
186 CleanupStack::PopAndDestroy(); // easyWlanPlugin; |
|
187 |
|
188 RCmConnectionMethodExt plugin = |
|
189 cmManager.CreateConnectionMethodL( KUidWlanBearerType ); |
|
190 CleanupClosePushL( plugin ); |
|
191 plugin.SetStringAttributeL( ECmName, *ssid ); |
|
192 plugin.SetStringAttributeL( EWlanSSID, *ssid ); |
|
193 plugin.SetIntAttributeL( CMManager::EWlanSecurityMode, |
|
194 ConvertConnectionSecurityModeToSecModeL( secMode )); |
|
195 plugin.SetIntAttributeL( EWlanConnectionMode, |
|
196 ConvertConnectionModeToNetModeL( connMode ) ); |
|
197 plugin.SetBoolAttributeL( EWlanScanSSID, scanSsid ); |
|
198 |
|
199 if ( aHotspot ) |
|
200 { |
|
201 // A hotspot IAP. Mark it so it can be deleted after the use. |
|
202 plugin.SetStringAttributeL( ECmConfigDaemonManagerName, |
|
203 KHotSpotPlugin ); |
|
204 } |
|
205 |
|
206 destination.AddConnectionMethodL( plugin ); |
|
207 destination.UpdateL(); |
|
208 serviceId = plugin.GetIntAttributeL( EWlanServiceId ); |
|
209 ret = plugin.GetIntAttributeL( ECmIapId ); |
|
210 CleanupStack::PopAndDestroy( &plugin ); |
|
211 if ( secMode == EWlanConnectionSecurityWep ) |
|
212 { |
|
213 SaveWEPKeyL( easyWlanServiceId, serviceId ); |
|
214 } |
|
215 |
|
216 if ( secMode == EWlanConnectionSecurityWpaPsk ) |
|
217 { |
|
218 SaveWPAKeyL( easyWlanServiceId, serviceId ); |
|
219 } |
|
220 |
|
221 CleanupStack::PopAndDestroy( ssid ); |
|
222 CleanupStack::PopAndDestroy( wlanMgmtClient ); |
|
223 } |
|
224 CleanupStack::PopAndDestroy( &destination ); |
|
225 } |
|
226 CleanupStack::PopAndDestroy( &destinations ); |
|
227 CleanupStack::PopAndDestroy( &cmManager ); |
|
228 |
|
229 DEBUG1("CHssIapSettingsHandler::CreateIapL Done iapId: %d", ret); |
|
230 return ret; |
|
231 } |
|
232 |
|
233 // ----------------------------------------------------------------------------- |
|
234 // DeleteIapL |
|
235 // ----------------------------------------------------------------------------- |
|
236 // |
|
237 void CHssIapSettingsHandler::DeleteIapL( const TUint aIapId ) |
|
238 { |
|
239 DEBUG1("CHssIapSettingsHandler:::DeleteIapL aIapId=%d ", aIapId); |
|
240 |
|
241 RCmManagerExt cmManager; |
|
242 cmManager.OpenL(); |
|
243 CleanupClosePushL( cmManager ); |
|
244 |
|
245 RCmConnectionMethodExt plugin = cmManager.ConnectionMethodL( aIapId ); |
140 CleanupClosePushL( plugin ); |
246 CleanupClosePushL( plugin ); |
141 |
247 |
142 cmManager.RemoveAllReferencesL( plugin ); |
248 cmManager.RemoveAllReferencesL( plugin ); |
143 TBool result = plugin.DeleteL(); |
249 TBool result = plugin.DeleteL(); |
144 |
250 |
145 DEBUG1("CHssIapSettingsHandler:::DeleteIapL result = %d ", result); |
251 DEBUG1("CHssIapSettingsHandler:::DeleteIapL result = %d ", result); |
146 CleanupStack::PopAndDestroy( &plugin ); |
252 CleanupStack::PopAndDestroy( &plugin ); |
147 CleanupStack::PopAndDestroy( &cmManager ); |
253 CleanupStack::PopAndDestroy( &cmManager ); |
|
254 } |
|
255 |
|
256 // --------------------------------------------------------- |
|
257 // MoveIapL() |
|
258 // --------------------------------------------------------- |
|
259 // |
|
260 void CHssIapSettingsHandler::MoveIapL( const TUint aIapId ) |
|
261 { |
|
262 DEBUG1("CHssIapSettingsHandler::MoveIapL aIapId=%d ", aIapId); |
|
263 // Now move to Internet SNAP |
|
264 RCmManagerExt cmManager; |
|
265 cmManager.OpenL(); |
|
266 CleanupClosePushL( cmManager ); |
|
267 |
|
268 // Read all destination(SNAP) settings into an array |
|
269 RArray<TUint32> destinations; |
|
270 CleanupClosePushL( destinations ); |
|
271 |
|
272 cmManager.AllDestinationsL( destinations ); |
|
273 RCmDestinationExt destination; |
|
274 // Loop through each destination |
|
275 for( TInt i = 0; i < destinations.Count(); i++ ) |
|
276 { |
|
277 destination = cmManager.DestinationL( destinations[i] ); |
|
278 CleanupClosePushL( destination ); |
|
279 // Internet destination will always exist in the system. |
|
280 // Internet destination will have ESnapPurposeInternet |
|
281 // set in its metadata. |
|
282 if ( destination.MetadataL( CMManager::ESnapMetadataPurpose ) == |
|
283 CMManager::ESnapPurposeInternet ) |
|
284 { |
|
285 RCmConnectionMethodExt iap = cmManager.ConnectionMethodL( aIapId ); |
|
286 CleanupClosePushL( iap ); |
|
287 iap.SetStringAttributeL( ECmConfigDaemonManagerName, KHotSpotPlugin ); |
|
288 destination.AddConnectionMethodL( iap ); |
|
289 CleanupStack::PopAndDestroy( &iap ); |
|
290 destination.UpdateL(); |
|
291 } |
|
292 CleanupStack::PopAndDestroy( &destination ); |
|
293 } |
|
294 CleanupStack::PopAndDestroy( &destinations ); |
|
295 CleanupStack::PopAndDestroy( &cmManager ); |
|
296 |
|
297 DEBUG( "CHssIapSettingsHandler::MoveIapL Done" ); |
148 } |
298 } |
149 |
299 |
150 // --------------------------------------------------------- |
300 // --------------------------------------------------------- |
151 // SaveWEPKeyL() |
301 // SaveWEPKeyL() |
152 // --------------------------------------------------------- |
302 // --------------------------------------------------------- |