|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "engine.h" |
|
20 #include "enginewrapper.h" |
|
21 #include "creator_connectionmethod.h" |
|
22 #include "creator_traces.h" |
|
23 |
|
24 |
|
25 |
|
26 using namespace CMManager; |
|
27 //#define KUidLanBearerType 0x1020737A |
|
28 #include <cmpluginpacketdatadef.h> |
|
29 #include <cmplugincsddef.h> |
|
30 #include <cmpluginhscsddef.h> |
|
31 #include <cmmanagerext.h> |
|
32 #include <cmdestinationext.h> |
|
33 #include <cmpluginembdestinationdef.h> |
|
34 #include <cmpluginvpndef.h> |
|
35 #include <cmpluginlandef.h> |
|
36 #include <cmdefconnvalues.h> |
|
37 #include <cmconnectionmethoddef.h> |
|
38 |
|
39 |
|
40 #include <wlanmgmtinterface.h> |
|
41 #include <wlanmgmtclient.h> |
|
42 #include <wlanmgmtclient.inl> |
|
43 #include <wlanmgmtcommon.h> |
|
44 #include <wlanscaninfo.h> |
|
45 #include <wlanscaninfo.inl> |
|
46 #include <wlanscaninfointerface.h> |
|
47 |
|
48 //#include <WEPSecuritySettingsUI.h>//For WEP setting |
|
49 //#include <dbcreatorcommon.h> |
|
50 |
|
51 static const TInt KConnectionSettingssFieldLength = 128; |
|
52 |
|
53 _LIT(KCreatorConnectionSettingssPrefixName, "CR_"); |
|
54 |
|
55 //---------------------------------------------------------------------------- |
|
56 |
|
57 CConnectionSettingsParameters::CConnectionSettingsParameters() |
|
58 { |
|
59 LOGSTRING("Creator: CConnectionSettingsParameters::CConnectionSettingsParameters"); |
|
60 |
|
61 iConnectionName = HBufC::New(KConnectionSettingssFieldLength); |
|
62 iStartPage = HBufC::New(KConnectionSettingssFieldLength); |
|
63 iLoginName = HBufC::New(KConnectionSettingssFieldLength); |
|
64 iLoginPass = HBufC::New(KConnectionSettingssFieldLength); |
|
65 iIPAddr = HBufC::New(KConnectionSettingssFieldLength); |
|
66 iIP4NameServer1 = HBufC::New(KConnectionSettingssFieldLength); |
|
67 iIP4NameServer2 = HBufC::New(KConnectionSettingssFieldLength); |
|
68 iDefaultTelNumber = HBufC::New(KConnectionSettingssFieldLength); |
|
69 iProxyServerAddress = HBufC::New(KConnectionSettingssFieldLength); |
|
70 iSubnetMask = HBufC::New(KConnectionSettingssFieldLength); |
|
71 iGatewayAddress = HBufC::New(KConnectionSettingssFieldLength); |
|
72 iWLANName = HBufC::New(KConnectionSettingssFieldLength); |
|
73 iWlanIpAddr = HBufC::New(KConnectionSettingssFieldLength); |
|
74 iIP6NameServer1 = HBufC::New(KConnectionSettingssFieldLength); |
|
75 iIP6NameServer2 = HBufC::New(KConnectionSettingssFieldLength); |
|
76 } |
|
77 |
|
78 CConnectionSettingsParameters::~CConnectionSettingsParameters() |
|
79 { |
|
80 LOGSTRING("Creator: CConnectionSettingssParameters::~CConnectionSettingssParameters"); |
|
81 |
|
82 delete iProxyServerAddress; |
|
83 delete iDefaultTelNumber; |
|
84 delete iIP4NameServer2; |
|
85 delete iIP4NameServer1; |
|
86 delete iIPAddr; |
|
87 delete iLoginPass; |
|
88 delete iLoginName; |
|
89 delete iStartPage; |
|
90 delete iConnectionName; |
|
91 delete iSubnetMask; |
|
92 delete iGatewayAddress; |
|
93 delete iWLANName; |
|
94 delete iWlanIpAddr; |
|
95 delete iIP6NameServer1; |
|
96 delete iIP6NameServer2; |
|
97 } |
|
98 |
|
99 //---------------------------------------------------------------------------- |
|
100 |
|
101 CCreatorConnectionSettings* CCreatorConnectionSettings::NewL(CCreatorEngine* aEngine) |
|
102 { |
|
103 CCreatorConnectionSettings* self = CCreatorConnectionSettings::NewLC(aEngine); |
|
104 CleanupStack::Pop(self); |
|
105 return self; |
|
106 } |
|
107 |
|
108 CCreatorConnectionSettings* CCreatorConnectionSettings::NewLC(CCreatorEngine* aEngine) |
|
109 { |
|
110 CCreatorConnectionSettings* self = new (ELeave) CCreatorConnectionSettings; |
|
111 CleanupStack::PushL(self); |
|
112 self->ConstructL(aEngine); |
|
113 return self; |
|
114 } |
|
115 |
|
116 CCreatorConnectionSettings::CCreatorConnectionSettings() |
|
117 { |
|
118 } |
|
119 |
|
120 void CCreatorConnectionSettings::ConstructL(CCreatorEngine* aEngine) |
|
121 { |
|
122 LOGSTRING("Creator: CCreatorConnectionSettings::ConstructL"); |
|
123 |
|
124 iEngine = aEngine; |
|
125 |
|
126 iCmManagerExt.CreateTablesAndOpenL(); |
|
127 } |
|
128 |
|
129 CCreatorConnectionSettings::~CCreatorConnectionSettings() |
|
130 { |
|
131 LOGSTRING("Creator: CCreatorConnectionSettings::~CCreatorConnectionSettings"); |
|
132 |
|
133 if ( iEngine && iEntryIds.Count() ) |
|
134 { |
|
135 TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iEntryIds, KUidDictionaryUidIAP ) ); |
|
136 } |
|
137 iEntryIds.Reset(); |
|
138 iEntryIds.Close(); |
|
139 |
|
140 if (iParameters) |
|
141 { |
|
142 delete iParameters; |
|
143 } |
|
144 |
|
145 iCmManagerExt.Close(); |
|
146 } |
|
147 |
|
148 |
|
149 //---------------------------------------------------------------------------- |
|
150 |
|
151 TBool CCreatorConnectionSettings::AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries) |
|
152 { |
|
153 LOGSTRING("Creator: CCreatorConnectionSettings::AskDataFromUserL"); |
|
154 |
|
155 if( aCommand == ECmdDeleteIAPs ) |
|
156 { |
|
157 return iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Delete all Connection Methods?") ); |
|
158 } |
|
159 else if( aCommand == ECmdDeleteCreatorIAPs ) |
|
160 { |
|
161 return iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Delete all Connection Methods created with Creator?") ); |
|
162 } |
|
163 else |
|
164 { |
|
165 return iEngine->GetEngineWrapper()->EntriesQueryDialog(aNumberOfEntries, _L("How many entries to create?")); |
|
166 } |
|
167 } |
|
168 |
|
169 |
|
170 //---------------------------------------------------------------------------- |
|
171 |
|
172 TInt CCreatorConnectionSettings::CreateConnectionSettingsEntryL(CCreatorModuleBaseParameters *aParameters) |
|
173 { |
|
174 LOGSTRING("Creator: CCreatorConnectionSettings::CreateConnectionSettingsEntryL"); |
|
175 |
|
176 CConnectionSettingsParameters* parameters = (CConnectionSettingsParameters*) aParameters; |
|
177 |
|
178 // clear any existing parameter definations |
|
179 delete iParameters; |
|
180 iParameters = NULL; |
|
181 |
|
182 // random data needed if no predefined data available |
|
183 if (!parameters) |
|
184 { |
|
185 iParameters = new (ELeave) CConnectionSettingsParameters(); |
|
186 parameters = iParameters; |
|
187 SetRandomParametersL(*parameters); |
|
188 } |
|
189 |
|
190 if( parameters->iBearerType == KRandomBearerType ) |
|
191 { |
|
192 SetRandomBearerTypeL(*parameters); |
|
193 } |
|
194 |
|
195 TInt err = KErrNone; |
|
196 |
|
197 // create unique name for each network destination |
|
198 RCmDestinationExt dest; |
|
199 TInt destinationError = KErrNone; |
|
200 TInt count = 0; |
|
201 TBuf<KConnectionSettingssFieldLength> name; |
|
202 name.Copy(parameters->iConnectionName->Des()); |
|
203 do |
|
204 { |
|
205 TRAP(destinationError, dest = iCmManagerExt.CreateDestinationL(name)); |
|
206 if (destinationError == KErrAlreadyExists) |
|
207 { |
|
208 name.Copy(parameters->iConnectionName->Des()); |
|
209 count++; |
|
210 name.AppendFormat(_L(" (%d)"), count); |
|
211 } |
|
212 else if (destinationError != KErrNone) |
|
213 { |
|
214 User::Leave(destinationError); |
|
215 } |
|
216 } |
|
217 while (destinationError == KErrAlreadyExists); |
|
218 parameters->iConnectionName->Des().Copy(name); |
|
219 |
|
220 CleanupClosePushL(dest); |
|
221 dest.UpdateL(); |
|
222 |
|
223 RCmConnectionMethodExt conMethod = dest.CreateConnectionMethodL( parameters->iBearerType);//KUidPacketDataBearerType |
|
224 CleanupClosePushL( conMethod ); |
|
225 |
|
226 if(parameters->iBearerType == KUidWlanBearerType) |
|
227 { |
|
228 //IP net mask of interface |
|
229 conMethod.SetStringAttributeL( EWlanIpNetMask, parameters->iSubnetMask->Des() ); |
|
230 |
|
231 //IP address of EPOC. |
|
232 conMethod.SetStringAttributeL( EWlanIpAddr, parameters->iWlanIpAddr->Des() ); |
|
233 // |
|
234 //following gateway ID:s is not workin, |
|
235 //logically ID would be EWlanIpGateway because EWlanIpNetMask |
|
236 //is going to net mask, which is just before gateway in ui |
|
237 //---> |
|
238 conMethod.SetStringAttributeL( EWlanIpGateway, parameters->iGatewayAddress->Des() ); |
|
239 //conMethod.SetStringAttributeL( EApIspIPGateway, parameters->iGatewayAddress->Des() ); |
|
240 conMethod.SetStringAttributeL( ECmWapIPGatewayAddress, parameters->iGatewayAddress->Des() ); |
|
241 conMethod.SetStringAttributeL( ECmIPGateway, parameters->iGatewayAddress->Des() ); |
|
242 //<--- |
|
243 |
|
244 //IP Address of primary and secondary name server (IP v4). |
|
245 conMethod.SetStringAttributeL( EWlanIpNameServer1, parameters->iIP4NameServer1->Des() ); |
|
246 conMethod.SetStringAttributeL( EWlanIpNameServer2, parameters->iIP4NameServer2->Des() ); |
|
247 //The SSID of this WLAN connection. |
|
248 conMethod.SetStringAttributeL( EWlanSSID, parameters->iWLANName->Des() ); |
|
249 |
|
250 //IP6 address of primary and secondary name servers |
|
251 conMethod.SetStringAttributeL( EWlanIp6NameServer1, parameters->iIP6NameServer1->Des() ); |
|
252 conMethod.SetStringAttributeL( EWlanIp6NameServer2, parameters->iIP6NameServer2->Des() ); |
|
253 |
|
254 // |
|
255 //Setting secure mode settings |
|
256 // |
|
257 |
|
258 //Network status (default: EWlanSecModeOpen) // EWlanAuthenticationMode use instead? |
|
259 conMethod.SetIntAttributeL( EWlanSecurityMode, parameters->iWLanSecMode ); |
|
260 //WLAN Network mode |
|
261 conMethod.SetIntAttributeL( EWlanConnectionMode, parameters->iWlanNetMode ); |
|
262 |
|
263 |
|
264 if(parameters->iWLanSecMode == EWlanSecModeOpen) |
|
265 {}//Nothing to set when mode is open |
|
266 else if(parameters->iWLanSecMode == EWlanSecModeWep) |
|
267 { |
|
268 //See WEPSecuritySettingsUI.h |
|
269 |
|
270 |
|
271 ///CWEPSecuritySettings |
|
272 // conMethod.SetIntAttributeL( EWlanSecurityMode, parameters->iWLanSecMode ); |
|
273 } |
|
274 else if(parameters->iWLanSecMode == EWlanSecMode802_1x) |
|
275 { |
|
276 } |
|
277 else if(parameters->iWLanSecMode == EWlanSecModeWpa) |
|
278 { |
|
279 } |
|
280 else if(parameters->iWLanSecMode == EWlanSecModeWpa2) |
|
281 { |
|
282 } |
|
283 |
|
284 //WLAN security setting |
|
285 //conMethod.SetStringAttributeL( EWlanAuthenticationMode, parameters->iIP6NameServer2->Des() ); |
|
286 //Utilise this method |
|
287 //conMethod.SetStringAttributeL( EWlanSecurityMode, parameters->iWLanSecMode ); |
|
288 } |
|
289 //Not known special attributes for packet data |
|
290 else if(parameters->iBearerType == KUidPacketDataBearerType) |
|
291 { |
|
292 |
|
293 //Access point name. |
|
294 conMethod.SetStringAttributeL( EPacketDataAPName, parameters->iConnectionName->Des() );//crash |
|
295 |
|
296 //Authentication user name |
|
297 conMethod.SetStringAttributeL( EPacketDataIFAuthName, parameters->iLoginName->Des() ); |
|
298 ///TProtocolType a; |
|
299 //EPdpTypeIPv4 or EPdpTypeIPv6 |
|
300 conMethod.SetIntAttributeL( EPacketDataPDPType, parameters->iProtocolType ); |
|
301 |
|
302 //IP6 address of primary and secondary name servers |
|
303 conMethod.SetStringAttributeL( EPacketDataIPIP6NameServer1, parameters->iIP6NameServer1->Des() ); |
|
304 conMethod.SetStringAttributeL( EPacketDataIPIP6NameServer2, parameters->iIP6NameServer2->Des() ); |
|
305 //IP address of primary name server |
|
306 conMethod.SetStringAttributeL( EPacketDataIPNameServer1, parameters->iIP4NameServer1->Des() ); |
|
307 //IP address of secondary name server |
|
308 conMethod.SetStringAttributeL( EPacketDataIPNameServer2, parameters->iIP4NameServer2->Des() ); |
|
309 |
|
310 //Also existing but UI not showing them: EPacketDataHeaderCompression, EPacketDataDisablePlainTextAuth |
|
311 //EPacketDataIFAuthPass, EDialIFAuthPass, EPacketDataIFPromptForAuth, EPacketDataIPAddr |
|
312 } |
|
313 else if(parameters->iBearerType == KUidCSDBearerType || parameters->iBearerType == KUidHSCSDBearerType) |
|
314 { |
|
315 //Authentication user name |
|
316 conMethod.SetStringAttributeL( EDialIFAuthName, parameters->iLoginName->Des() ); |
|
317 //Dial-up number |
|
318 conMethod.SetStringAttributeL( EDialDefaultTelNum, parameters->iDefaultTelNumber->Des() ); |
|
319 //Call type |
|
320 conMethod.SetIntAttributeL( EDialCallType , parameters->iBearerCallTypeIsdn ); |
|
321 //Maximum speed |
|
322 conMethod.SetIntAttributeL( EDialMaxConnSpeed, parameters->iBearerSpeed ); |
|
323 //Prompt user for username and password? (Only for dial out) |
|
324 conMethod.SetBoolAttributeL( EDialPromptForLogin, parameters->iPromptPassword ); |
|
325 //IP6 address of primary and secondary name servers |
|
326 conMethod.SetStringAttributeL( EDialIP6NameServer1, parameters->iIP6NameServer1->Des() ); |
|
327 conMethod.SetStringAttributeL( EDialIP6NameServer2, parameters->iIP6NameServer2->Des() ); |
|
328 //Disable plaintext authentication |
|
329 conMethod.SetBoolAttributeL( EDialDisablePlainTextAuth, parameters->iDisableTextAuth ); |
|
330 //IP address of primary name server |
|
331 conMethod.SetStringAttributeL( EDialIPNameServer1, parameters->iIP4NameServer1->Des() ); |
|
332 //IP address of secondary name server |
|
333 conMethod.SetStringAttributeL( EDialIPNameServer2, parameters->iIP4NameServer2->Des() ); |
|
334 |
|
335 //Also existing EDialEnableIPHeaderComp; EDialIFPromptForAuth;EDialIPAddress parameters |
|
336 |
|
337 } |
|
338 else if(parameters->iBearerType == KUidLanBearerType) |
|
339 { |
|
340 |
|
341 conMethod.SetStringAttributeL( ELanIpNetMask, parameters->iSubnetMask->Des() ); |
|
342 conMethod.SetStringAttributeL( ELanIpGateway, parameters->iGatewayAddress->Des()); |
|
343 conMethod.SetStringAttributeL( ELanIpAddr, parameters->iIPAddr->Des() ); |
|
344 conMethod.SetStringAttributeL( ELanIpNameServer1, parameters->iIP4NameServer1->Des() ); |
|
345 conMethod.SetStringAttributeL( ELanIpNameServer2, parameters->iIP4NameServer2->Des() ); |
|
346 conMethod.SetStringAttributeL( ELanIp6NameServer1,parameters->iIP6NameServer1->Des() ); |
|
347 conMethod.SetStringAttributeL( ELanIp6NameServer2,parameters->iIP6NameServer2->Des() ); |
|
348 |
|
349 } |
|
350 else //KUidEmbeddedDestination and KPluginVPNBearerTypeUid |
|
351 { |
|
352 //NOTE: NOT Tested, because no supporting Emulator for them |
|
353 |
|
354 //Authentication user name |
|
355 conMethod.SetStringAttributeL( ECmIFAuthName, parameters->iLoginName->Des() ); |
|
356 //IP6 address of primary and secondary name servers |
|
357 conMethod.SetStringAttributeL( ECmIP6NameServer1, parameters->iIP6NameServer1->Des() ); |
|
358 conMethod.SetStringAttributeL( ECmIP6NameServer2, parameters->iIP6NameServer2->Des() ); |
|
359 //Disable plaintext authentication |
|
360 conMethod.SetBoolAttributeL( ECmDisablePlainTextAuth, parameters->iDisableTextAuth ); |
|
361 //Prompt user for authentication |
|
362 conMethod.SetBoolAttributeL( ECmIFPromptForAuth, parameters->iPromptPassword ); |
|
363 //Authentication password |
|
364 conMethod.SetStringAttributeL( ECmIFAuthPass, parameters->iLoginPass->Des() ); |
|
365 } |
|
366 |
|
367 // |
|
368 //Adding common attributes, all not neccessary used with all bearer types, but should not cause any problems eather |
|
369 // |
|
370 |
|
371 //CM Name (Connection Method, formelly known as Access Point) |
|
372 conMethod.SetStringAttributeL( ECmName, parameters->iConnectionName->Des() ); |
|
373 // Start page of CM |
|
374 conMethod.SetStringAttributeL( ECmStartPage, parameters->iStartPage->Des() ); |
|
375 // Enable Proxy |
|
376 conMethod.SetBoolAttributeL( ECmProxyUsageEnabled, parameters->iUseProxy ); |
|
377 // Server Name |
|
378 conMethod.SetStringAttributeL( ECmProxyServerName, parameters->iProxyServerAddress->Des() ); |
|
379 // Port Number |
|
380 conMethod.SetIntAttributeL( ECmProxyPortNumber, parameters->iProxyPortNumber ); |
|
381 //Proxy login name |
|
382 conMethod.SetStringAttributeL( ECmWapIPProxyLoginName, parameters->iLoginName->Des() ); |
|
383 //Proxy login password |
|
384 conMethod.SetStringAttributeL( ECmWapIPProxyLoginPass, parameters->iLoginPass->Des() ); |
|
385 //IP address of gateway |
|
386 conMethod.SetStringAttributeL( ECmIPGateway, parameters->iGatewayAddress->Des() ); |
|
387 //connection-oriented or connectionless API should be used |
|
388 //ECmWapIPWSPOption option TWapWSPOption: ECmWapWspOptionConnectionless or ECmWapWspOptionConnectionOriented |
|
389 conMethod.SetIntAttributeL( ECmWapIPWSPOption, parameters->iWapWspOption ); |
|
390 //NOT WORKING????? Attempt secure WTLS connection to the gateway |
|
391 conMethod.SetBoolAttributeL( ECmWapIPSecurity, parameters->iSecureAuthentication ); |
|
392 |
|
393 // |
|
394 //Adding advanced settings (Network type, Phone IP addr, DNS addr, proxy srv name, proxy port nbr |
|
395 // |
|
396 |
|
397 //IP address of interface |
|
398 conMethod.SetStringAttributeL( ECmIPAddress, parameters->iIPAddr->Des() ); |
|
399 //IP address of primary name server |
|
400 conMethod.SetStringAttributeL( ECmIPNameServer1, parameters->iIP4NameServer1->Des() ); |
|
401 //IP address of secondary name server |
|
402 conMethod.SetStringAttributeL( ECmIPNameServer2, parameters->iIP4NameServer2->Des() ); |
|
403 |
|
404 |
|
405 conMethod.UpdateL(); |
|
406 |
|
407 //If no defaults set, set the created CM as a default |
|
408 SetDefaultCML( conMethod ); |
|
409 |
|
410 // id has been generated, store it for being able to delete |
|
411 // only entries created with Creator |
|
412 iEntryIds.Append( dest.Id() ); |
|
413 |
|
414 conMethod.Close(); |
|
415 CleanupStack::Pop( );//conMethod |
|
416 |
|
417 dest.UpdateL(); |
|
418 dest.Close(); |
|
419 CleanupStack::Pop(); // dest |
|
420 |
|
421 return err; |
|
422 } |
|
423 |
|
424 //---------------------------------------------------------------------------- |
|
425 void CConnectionSettingsParameters::SetRandomCMNameL(CCreatorEngine& aEngine) |
|
426 { |
|
427 LOGSTRING("Creator: CConnectionSettingsParameters::SetRandomCMNameL"); |
|
428 |
|
429 TInt num = aEngine.RandomNumber(1, 3); |
|
430 TBuf<10> apType; |
|
431 |
|
432 if (num==1) |
|
433 { |
|
434 apType = _L("mms"); |
|
435 } |
|
436 else if (num==2) |
|
437 { |
|
438 apType = _L("wap"); |
|
439 } |
|
440 else |
|
441 { |
|
442 apType = _L("internet"); |
|
443 } |
|
444 TBuf<160> company = aEngine.RandomString(CCreatorEngine::ECompany); |
|
445 iConnectionName->Des() = KCreatorConnectionSettingssPrefixName; |
|
446 iConnectionName->Des().Append( company ); |
|
447 iConnectionName->Des().Append(_L(" ")); |
|
448 iConnectionName->Des().Append(apType); |
|
449 } |
|
450 |
|
451 void CConnectionSettingsParameters::SetRandomWLANNameL(CCreatorEngine& aEngine) |
|
452 { |
|
453 LOGSTRING("Creator: CConnectionSettingsParameters::SetRandomWLANNameL"); |
|
454 |
|
455 TBuf<160> company = aEngine.RandomString(CCreatorEngine::ECompany); |
|
456 iWLANName->Des() = KCreatorConnectionSettingssPrefixName; |
|
457 iWLANName->Des().Append( company ); |
|
458 iWLANName->Des().Append( _L(" WLAN") ); |
|
459 } |
|
460 |
|
461 void CConnectionSettingsParameters::SetRandomWLANNetModeL(CCreatorEngine& aEngine) |
|
462 { |
|
463 LOGSTRING("Creator: CConnectionSettingsParameters::SetRandomWLANNetModeL"); |
|
464 |
|
465 TInt wlanNetModeRand = aEngine.RandomNumber(1, 2); |
|
466 if(wlanNetModeRand == 1) |
|
467 { |
|
468 iWlanNetMode = EAdhoc;//Ad-Hoc mode |
|
469 } |
|
470 else |
|
471 { |
|
472 iWlanNetMode = CMManager::EInfra;//Infrastructure mode |
|
473 } |
|
474 } |
|
475 |
|
476 void CConnectionSettingsParameters::SetRandomWLANSecurityModeL(CCreatorEngine& aEngine) |
|
477 { |
|
478 LOGSTRING("Creator: CConnectionSettingsParameters::SetRandomWLANSecurityModeL"); |
|
479 |
|
480 TInt wlanSecModeRand = aEngine.RandomNumber(1, 5); |
|
481 if(wlanSecModeRand == 1) |
|
482 { |
|
483 iWLanSecMode = EWlanSecModeOpen;///< Open security mode |
|
484 } |
|
485 else if(wlanSecModeRand == 2) |
|
486 { |
|
487 iWLanSecMode = EWlanSecModeWep;///< WEP security mode |
|
488 //See WEPSecuritySettingsUI.h |
|
489 |
|
490 ///CWEPSecuritySettings |
|
491 |
|
492 //WEP key in us |
|
493 |
|
494 //Authentication type |
|
495 |
|
496 //WEP Key settings (key len, key format, key data) |
|
497 } |
|
498 else if(wlanSecModeRand == 3) |
|
499 { |
|
500 iWLanSecMode = EWlanSecMode802_1x; ///< 802.1x security mode |
|
501 } |
|
502 else if(wlanSecModeRand == 4) |
|
503 { |
|
504 iWLanSecMode = EWlanSecModeWpa;///< WPA security mode |
|
505 } |
|
506 else if(wlanSecModeRand == 5) |
|
507 { |
|
508 iWLanSecMode = EWlanSecModeWpa2;///< WPA@ security mode |
|
509 } |
|
510 } |
|
511 |
|
512 void CConnectionSettingsParameters::SetRandomLoginNameL(CCreatorEngine& aEngine) |
|
513 { |
|
514 iLoginName->Des() = aEngine.RandomString(CCreatorEngine::EFirstName); |
|
515 iLoginName->Des().LowerCase(); |
|
516 } |
|
517 |
|
518 void CConnectionSettingsParameters::SetRandomLoginPassL(CCreatorEngine& aEngine) |
|
519 { |
|
520 iLoginPass->Des() = aEngine.RandomString(CCreatorEngine::ESurname); |
|
521 iLoginPass->Des().LowerCase(); |
|
522 } |
|
523 |
|
524 void CConnectionSettingsParameters::SetRandomSecureAuthenticationL(CCreatorEngine& /*aEngine*/) |
|
525 { |
|
526 iSecureAuthentication = EFalse; |
|
527 } |
|
528 |
|
529 void CConnectionSettingsParameters::SetRandomPromptPasswordL(CCreatorEngine& /*aEngine*/) |
|
530 { |
|
531 iPromptPassword = ETrue; |
|
532 } |
|
533 |
|
534 void CConnectionSettingsParameters::SetRandomUseProxyL(CCreatorEngine& /*aEngine*/) |
|
535 { |
|
536 iUseProxy = ETrue; |
|
537 } |
|
538 |
|
539 void CConnectionSettingsParameters::SetRandomProxyAddressL(CCreatorEngine& /*aEngine*/) |
|
540 { |
|
541 iProxyServerAddress->Des() = _L("127.0.0.1"); |
|
542 } |
|
543 |
|
544 void CConnectionSettingsParameters::SetRandomProxyPortL(CCreatorEngine& /*aEngine*/) |
|
545 { |
|
546 iProxyPortNumber = 80; |
|
547 } |
|
548 |
|
549 void CConnectionSettingsParameters::SetRandomStartPageL(CCreatorEngine& aEngine) |
|
550 { |
|
551 LOGSTRING("Creator: CConnectionSettingsParameters::SetRandomStartPageL"); |
|
552 |
|
553 TInt num = aEngine.RandomNumber(1, 3); |
|
554 TBuf<10> apType; |
|
555 |
|
556 if (num==1) |
|
557 { |
|
558 apType = _L("mms"); |
|
559 } |
|
560 else if (num==2) |
|
561 { |
|
562 apType = _L("wap"); |
|
563 } |
|
564 else |
|
565 { |
|
566 apType = _L("internet"); |
|
567 } |
|
568 TBuf<160> company = aEngine.RandomString(CCreatorEngine::ECompany); |
|
569 iStartPage->Des() = _L("http://"); |
|
570 iStartPage->Des().Append(apType); |
|
571 iStartPage->Des().Append(_L(".")); |
|
572 iStartPage->Des().Append(company); |
|
573 iStartPage->Des().Append(_L(".com")); |
|
574 iStartPage->Des().LowerCase(); |
|
575 } |
|
576 |
|
577 void CConnectionSettingsParameters::SetRandomIPAddressL(CCreatorEngine& /*aEngine*/) |
|
578 { |
|
579 iIPAddr->Des() = _L("10.10.10.10"); |
|
580 } |
|
581 |
|
582 void CConnectionSettingsParameters::SetRandomIP4NameServer1L(CCreatorEngine& /*aEngine*/) |
|
583 { |
|
584 iIP4NameServer1->Des() = _L("10.1.1.1"); |
|
585 } |
|
586 void CConnectionSettingsParameters::SetRandomIP4NameServer2L(CCreatorEngine& /*aEngine*/) |
|
587 { |
|
588 iIP4NameServer2->Des() = _L("10.2.2.2"); |
|
589 } |
|
590 |
|
591 void CConnectionSettingsParameters::SetRandomProtocolTypeL(CCreatorEngine& aEngine) |
|
592 { |
|
593 LOGSTRING("Creator: CConnectionSettingsParameters::SetRandomProtocolTypeL"); |
|
594 |
|
595 TInt protocolTypeRand = aEngine.RandomNumber(1, 2); |
|
596 if(protocolTypeRand == 1) |
|
597 { |
|
598 iProtocolType = RPacketContext::EPdpTypeIPv4; |
|
599 } |
|
600 else |
|
601 { |
|
602 iProtocolType = RPacketContext::EPdpTypeIPv6; |
|
603 } |
|
604 } |
|
605 |
|
606 void CConnectionSettingsParameters::SetRandomTelephoneNumberL(CCreatorEngine& aEngine) |
|
607 { |
|
608 iDefaultTelNumber->Des() = aEngine.RandomString(CCreatorEngine::EPhoneNumber); |
|
609 } |
|
610 |
|
611 void CConnectionSettingsParameters::SetRandomBearerTypeIsdnL(CCreatorEngine& /*aEngine*/) |
|
612 { |
|
613 iBearerCallTypeIsdn = ECmCallTypeISDNv110; |
|
614 } |
|
615 |
|
616 void CConnectionSettingsParameters::SetRandomBearerSpeedL(CCreatorEngine& /*aEngine*/) |
|
617 { |
|
618 iBearerSpeed = ECmSpeed14400; |
|
619 } |
|
620 |
|
621 void CConnectionSettingsParameters::SetRandomWapWspOptionL(CCreatorEngine& /*aEngine*/) |
|
622 { |
|
623 iWapWspOption = ECmWapWspOptionConnectionless; |
|
624 } |
|
625 |
|
626 void CConnectionSettingsParameters::SetRandomSubnetMaskL(CCreatorEngine& /*aEngine*/) |
|
627 { |
|
628 iSubnetMask->Des() = _L("255.255.255.0"); |
|
629 } |
|
630 |
|
631 void CConnectionSettingsParameters::SetRandomGatewayAddressL(CCreatorEngine& /*aEngine*/) |
|
632 { |
|
633 iGatewayAddress->Des() = _L("10.0.0.1"); |
|
634 } |
|
635 |
|
636 void CConnectionSettingsParameters::SetRandomWlanIpAddrL(CCreatorEngine& /*aEngine*/) |
|
637 { |
|
638 iWlanIpAddr->Des() = _L("10.0.0.99"); |
|
639 } |
|
640 |
|
641 void CConnectionSettingsParameters::SetRandomIPv6NameServer1L(CCreatorEngine& /*aEngine*/) |
|
642 { |
|
643 iIP6NameServer1->Des() = _L("2007:abcd:1000:2000:3000:4000:5000:6001"); |
|
644 } |
|
645 |
|
646 void CConnectionSettingsParameters::SetRandomIPv6NameServer2L(CCreatorEngine& /*aEngine*/) |
|
647 { |
|
648 iIP6NameServer2->Des() = _L("2007:abcd:1000:2000:3000:4000:5000:6002"); |
|
649 } |
|
650 |
|
651 void CConnectionSettingsParameters::SetRandomDisableTextAuthL(CCreatorEngine& /*aEngine*/) |
|
652 { |
|
653 iDisableTextAuth = EFalse; |
|
654 } |
|
655 |
|
656 void CCreatorConnectionSettings::SetRandomBearerTypeL(CConnectionSettingsParameters& parameters) |
|
657 { |
|
658 LOGSTRING("Creator: CCreatorConnectionSettings::SetRandomBearerTypeL"); |
|
659 |
|
660 RArray<TUint32> supportedBearers = RArray<TUint32>( 10 ); |
|
661 iCmManagerExt.SupportedBearersL(supportedBearers); |
|
662 CleanupClosePushL( supportedBearers ); |
|
663 |
|
664 //In random mode, skipping KUidLanBearerType |
|
665 //Because of Emulator migh show it as supported, when it's really not |
|
666 //and that causes weird situation in UI when there is an item, but it can't be opened |
|
667 TInt lanID = supportedBearers.Find(KUidLanBearerType); |
|
668 if( lanID != KErrNotFound ) |
|
669 { |
|
670 supportedBearers.Remove(lanID); |
|
671 } |
|
672 |
|
673 // in emulator remove WLAN |
|
674 #ifdef __WINSCW__ |
|
675 TInt wlanID = supportedBearers.Find(KUidWlanBearerType); |
|
676 if( wlanID != KErrNotFound ) |
|
677 { |
|
678 supportedBearers.Remove(wlanID); |
|
679 } |
|
680 #endif |
|
681 |
|
682 /* |
|
683 for(TInt i = 0; i<supportedCount; i++) |
|
684 { |
|
685 TUint bearer = supportedBearers[i]; |
|
686 if(bearer == KUidLanBearerType) |
|
687 { |
|
688 supportedBearers.Remove(i); |
|
689 } |
|
690 } |
|
691 */ |
|
692 |
|
693 //Select random bearer type. |
|
694 //Also possible to use SupportedBearersL() -method to find supported methods |
|
695 //but using that will cause problems when setting attributes. |
|
696 TInt supportedCount = supportedBearers.Count(); |
|
697 TInt bearerTypeID = iEngine->RandomNumber(0, supportedCount-1); |
|
698 |
|
699 TUint bearerType = supportedBearers[bearerTypeID]; |
|
700 |
|
701 //Bearer types KUidEmbeddedDestination and KPluginVPNBearerTypeUid is not supported |
|
702 if(bearerType == KUidWlanBearerType)//Wireless LAN |
|
703 { |
|
704 parameters.iBearerType = KUidWlanBearerType; |
|
705 } |
|
706 else if(bearerType == KUidPacketDataBearerType)//Packet data (GPRS) |
|
707 { |
|
708 parameters.iBearerType = KUidPacketDataBearerType; |
|
709 } |
|
710 else if(bearerType == KUidCSDBearerType)//Data Call |
|
711 { |
|
712 parameters.iBearerType = KUidCSDBearerType; |
|
713 } |
|
714 else if(bearerType == KUidHSCSDBearerType) //High speed GSM |
|
715 { |
|
716 parameters.iBearerType = KUidHSCSDBearerType; |
|
717 } |
|
718 else if(bearerType == KUidEmbeddedDestination) |
|
719 { |
|
720 parameters.iBearerType = KUidEmbeddedDestination; |
|
721 } |
|
722 else// if(bearerType == KPluginVPNBearerTypeUid) |
|
723 { |
|
724 parameters.iBearerType = KPluginVPNBearerTypeUid; |
|
725 } |
|
726 /* In random mode skipping LAN type |
|
727 else// if(bearerType == KUidLanBearerType) |
|
728 { |
|
729 iBearerType = KUidLanBearerType; |
|
730 }*/ |
|
731 |
|
732 CleanupStack::PopAndDestroy(); // supportedBearers |
|
733 } |
|
734 |
|
735 void CCreatorConnectionSettings::SetRandomParametersL(CConnectionSettingsParameters& parameters) |
|
736 { |
|
737 LOGSTRING("Creator: CCreatorConnectionSettings::SetRandomParametersL"); |
|
738 |
|
739 // Connection method name: |
|
740 parameters.SetRandomCMNameL(*iEngine); |
|
741 |
|
742 SetRandomBearerTypeL(parameters); |
|
743 |
|
744 if(parameters.iBearerType == KUidWlanBearerType)//Wireless LAN |
|
745 { |
|
746 // WLAN name: |
|
747 parameters.SetRandomWLANNameL(*iEngine); |
|
748 |
|
749 //WLAN network mode |
|
750 parameters.SetRandomWLANNetModeL(*iEngine); |
|
751 |
|
752 //WLAN security mode: |
|
753 parameters.SetRandomWLANSecurityModeL(*iEngine); |
|
754 } |
|
755 |
|
756 // Login name: |
|
757 parameters.SetRandomLoginNameL(*iEngine); |
|
758 |
|
759 // Login password: |
|
760 parameters.SetRandomLoginPassL(*iEngine); |
|
761 |
|
762 // Secure authentication: |
|
763 parameters.SetRandomSecureAuthenticationL(*iEngine); |
|
764 |
|
765 // Prompt password: |
|
766 parameters.SetRandomPromptPasswordL(*iEngine); |
|
767 |
|
768 // Use proxy: |
|
769 parameters.SetRandomUseProxyL(*iEngine); |
|
770 |
|
771 // Proxy address |
|
772 parameters.SetRandomProxyAddressL(*iEngine); |
|
773 |
|
774 // Proxy port number: |
|
775 parameters.SetRandomProxyPortL(*iEngine); |
|
776 |
|
777 // Start page: |
|
778 parameters.SetRandomStartPageL(*iEngine); |
|
779 |
|
780 // IP address: |
|
781 parameters.SetRandomIPAddressL(*iEngine); |
|
782 |
|
783 // IPv4 name servers: |
|
784 parameters.SetRandomIP4NameServer1L(*iEngine); |
|
785 parameters.SetRandomIP4NameServer2L(*iEngine); |
|
786 |
|
787 // Protocol type: |
|
788 parameters.SetRandomProtocolTypeL(*iEngine); |
|
789 |
|
790 // Default telephone number: |
|
791 parameters.SetRandomTelephoneNumberL(*iEngine); |
|
792 |
|
793 // Bearer isdn |
|
794 parameters.SetRandomBearerTypeIsdnL(*iEngine); |
|
795 |
|
796 // Bearer speed: |
|
797 parameters.SetRandomBearerSpeedL(*iEngine); |
|
798 |
|
799 // WAP wsp option: |
|
800 parameters.SetRandomWapWspOptionL(*iEngine); |
|
801 |
|
802 // Subnet mask: |
|
803 parameters.SetRandomSubnetMaskL(*iEngine); |
|
804 |
|
805 // Gateway address: |
|
806 parameters.SetRandomGatewayAddressL(*iEngine); |
|
807 |
|
808 // WLAN ip address: |
|
809 parameters.SetRandomWlanIpAddrL(*iEngine); |
|
810 |
|
811 // IPv6 name servers: |
|
812 parameters.SetRandomIPv6NameServer1L(*iEngine); |
|
813 parameters.SetRandomIPv6NameServer2L(*iEngine); |
|
814 |
|
815 // Disable text authorization: |
|
816 parameters.SetRandomDisableTextAuthL(*iEngine); |
|
817 } |
|
818 |
|
819 //---------------------------------------------------------------------------- |
|
820 |
|
821 void CCreatorConnectionSettings::SetDefaultCML(RCmConnectionMethodExt conMethod) |
|
822 { |
|
823 LOGSTRING("Creator: CCreatorConnectionSettings::SetDefaultCM"); |
|
824 |
|
825 TCmDefConnValue defConnValue; |
|
826 |
|
827 //Returns the default connection method/SNAP. |
|
828 TRAPD( err, iCmManagerExt.ReadDefConnL( defConnValue ) ); |
|
829 if( err == KErrNotSupported ) |
|
830 { |
|
831 return; //If Default Connection NOT supported, just returning |
|
832 } |
|
833 else if ( err != KErrNone ) |
|
834 { |
|
835 User::Leave( err ); //If something else happend |
|
836 } |
|
837 else if ( defConnValue.iId == 0 ) // default not set |
|
838 { |
|
839 TCmDefConnValue newDefaultCM; |
|
840 HBufC* cmName = conMethod.GetStringAttributeL( ECmName ); |
|
841 CleanupStack::PushL( cmName ); |
|
842 newDefaultCM.iId = AccessPointNameToIdL( cmName->Des() ); |
|
843 newDefaultCM.iType = ECmDefConnDestination; |
|
844 //Stores the default connection method/SNAP. |
|
845 iCmManagerExt.WriteDefConnL( newDefaultCM ); |
|
846 CleanupStack::PopAndDestroy( cmName ); |
|
847 } |
|
848 } |
|
849 |
|
850 //---------------------------------------------------------------------------- |
|
851 |
|
852 TUint32 CCreatorConnectionSettings::AccessPointNameToIdL(const TDesC& aAPName, |
|
853 TBool aAnyIfNotFound ) |
|
854 { |
|
855 LOGSTRING("Creator: CCreatorConnectionSettings::AccessPointNameToIdL"); |
|
856 |
|
857 //RCmDestination destination |
|
858 |
|
859 RArray<TUint32> destIdArray = RArray<TUint32>( 10 ); |
|
860 |
|
861 iCmManagerExt.AllDestinationsL( destIdArray ); |
|
862 |
|
863 CleanupClosePushL( destIdArray ); |
|
864 TUint32 id = 0 ; |
|
865 TBool found = EFalse; |
|
866 |
|
867 for( TInt i = 0; i < destIdArray.Count(); i++ ) |
|
868 { |
|
869 RCmDestinationExt dest = iCmManagerExt.DestinationL( destIdArray[i] ); |
|
870 CleanupClosePushL( dest ); |
|
871 |
|
872 HBufC* destName = dest.NameLC(); |
|
873 |
|
874 if (destName->CompareF(aAPName) == 0){ |
|
875 id = dest.Id(); |
|
876 found = ETrue; |
|
877 } |
|
878 if ( !found && id == 0 && aAnyIfNotFound ) |
|
879 { |
|
880 id = dest.Id(); |
|
881 } |
|
882 CleanupStack::PopAndDestroy( 2 ); // destName , dest |
|
883 if(found) |
|
884 { |
|
885 break; |
|
886 } |
|
887 } |
|
888 |
|
889 CleanupStack::PopAndDestroy(); // destIdArray |
|
890 return id; |
|
891 } |
|
892 |
|
893 //---------------------------------------------------------------------------- |
|
894 |
|
895 void CCreatorConnectionSettings::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) // from MMsvSessionObserver |
|
896 { |
|
897 LOGSTRING("Creator: CCreatorConnectionSettings::HandleSessionEventL"); |
|
898 } |
|
899 |
|
900 //---------------------------------------------------------------------------- |
|
901 void CCreatorConnectionSettings::DeleteAllL() |
|
902 { |
|
903 LOGSTRING("Creator: CCreatorConnectionSettings::DeleteAllL"); |
|
904 DeleteAllDestinationsL( EFalse ); |
|
905 } |
|
906 |
|
907 //---------------------------------------------------------------------------- |
|
908 void CCreatorConnectionSettings::DeleteAllCreatedByCreatorL() |
|
909 { |
|
910 LOGSTRING("Creator: CCreatorConnectionSettings::DeleteAllCreatedByCreatorL"); |
|
911 iEntryIds.Reset(); |
|
912 |
|
913 // fetch ids of entries created by Creator |
|
914 iEngine->ReadEntryIdsFromStoreL( iEntryIds, KUidDictionaryUidIAP ); |
|
915 |
|
916 // delete entries |
|
917 DeleteAllDestinationsL( ETrue ); |
|
918 } |
|
919 |
|
920 //---------------------------------------------------------------------------- |
|
921 |
|
922 void CCreatorConnectionSettings::DeleteAllDestinationsL( TBool aOnlyCreatedWithCreator ) |
|
923 { |
|
924 LOGSTRING("Creator: CCreatorConnectionSettings::DeleteAllDestinationsL"); |
|
925 RArray<TUint32> destIdArray(5); |
|
926 CleanupClosePushL( destIdArray ); |
|
927 iCmManagerExt.AllDestinationsL( destIdArray ); |
|
928 |
|
929 for( TInt i = 0; i < destIdArray.Count(); i++ ) |
|
930 { |
|
931 TRAP_IGNORE |
|
932 ( |
|
933 RCmDestinationExt dest = iCmManagerExt.DestinationL( destIdArray[i] ); |
|
934 CleanupClosePushL( dest ); |
|
935 |
|
936 if ( !aOnlyCreatedWithCreator || iEntryIds.Find( destIdArray[i]) != KErrNotFound ) |
|
937 { |
|
938 dest.DeleteLD(); |
|
939 } |
|
940 CleanupStack::PopAndDestroy(); // dest |
|
941 ); |
|
942 } |
|
943 |
|
944 CleanupStack::PopAndDestroy(); // destIdArray |
|
945 |
|
946 // reset must be done here, because iEntryIds is stored in destructor |
|
947 iEntryIds.Reset(); |
|
948 |
|
949 // all entries deleted, remove the IMPS related registry |
|
950 iEngine->RemoveStoreL( KUidDictionaryUidIAP ); |
|
951 } |
|
952 //---------------------------------------------------------------------------- |