creator/engine/src/creator_connectionmethodelement.cpp
branchRCL_3
changeset 22 fad26422216a
parent 21 b3cee849fa46
child 23 f8280f3bfeb7
equal deleted inserted replaced
21:b3cee849fa46 22:fad26422216a
     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_connectionmethodelement.h"
       
    22 #include "creator_traces.h"
       
    23 //#include "creator_accesspoint.h"
       
    24 
       
    25 
       
    26 using namespace creatorconnectionmethod;
       
    27 
       
    28 // connection name needs extra space for possible renaming
       
    29 const TInt KExtraSpace = 10;
       
    30 
       
    31 /*
       
    32  * 
       
    33  */
       
    34 CCreatorConnectionMethodElement* CCreatorConnectionMethodElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext )
       
    35     {
       
    36     CCreatorConnectionMethodElement* self = new (ELeave) CCreatorConnectionMethodElement(aEngine);
       
    37     CleanupStack::PushL(self);
       
    38     self->ConstructL(aName, aContext);
       
    39     CleanupStack::Pop(self);
       
    40     return self;
       
    41     }
       
    42 /*
       
    43  * 
       
    44  */
       
    45 CCreatorConnectionMethodElement::CCreatorConnectionMethodElement(CCreatorEngine* aEngine) 
       
    46 : 
       
    47 CCreatorScriptElement(aEngine)
       
    48     {
       
    49     iIsCommandElement = ETrue;
       
    50     }
       
    51 
       
    52 void CCreatorConnectionMethodElement::ExecuteCommandL()
       
    53 	{
       
    54 	const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount);
       
    55 	TInt cmAmount = 1;    
       
    56 	if( amountAttr )
       
    57 		{
       
    58 		cmAmount = ConvertStrToIntL(amountAttr->Value());
       
    59 		}
       
    60 	// Get 'fields' element 
       
    61 	CCreatorScriptElement* fieldsElement = FindSubElement(KFields);
       
    62 	if( fieldsElement )
       
    63 		{
       
    64 		// Get sub-elements
       
    65 		const RPointerArray<CCreatorScriptElement>& fields = fieldsElement->SubElements();        
       
    66 		// Create connection method entries, the amount of entries is defined by cmAmount:
       
    67 		for( TInt cI = 0; cI < cmAmount; ++cI )
       
    68 			{            
       
    69 			CAccessPointsParameters* param = new (ELeave) CAccessPointsParameters;
       
    70 			CleanupStack::PushL(param);
       
    71 
       
    72 			for( TInt i = 0; i < fields.Count(); ++i )
       
    73 				{
       
    74 				CCreatorScriptElement* field = fields[i];
       
    75 				TPtrC elemName = field->Name();
       
    76 				TPtrC elemContent = field->Content();
       
    77 				const CCreatorScriptAttribute* randomAttr = fields[i]->FindAttributeByName(KRandomLength);
       
    78 				TBool useRandom = EFalse;
       
    79 				if( randomAttr || elemContent.Length() == 0 )
       
    80 					{
       
    81 					useRandom = ETrue;
       
    82 					}
       
    83 
       
    84 				if( elemName == Kconnectionname )
       
    85 					{
       
    86 					if( useRandom )
       
    87 						{
       
    88 						param->SetRandomCMNameL(*iEngine);
       
    89 						}
       
    90 					else
       
    91 						{
       
    92 						SetContentToTextParamL(param->iConnectionName, elemContent);
       
    93                         // reserve extra space for possible renaming
       
    94                         TInt newLen = param->iConnectionName->Length() + KExtraSpace;
       
    95                         param->iConnectionName = param->iConnectionName->ReAllocL(newLen);
       
    96 
       
    97                         SetContentToTextParamL(param->iGprsAcessPointName, elemContent);
       
    98 						}
       
    99 					}
       
   100 				else if( elemName == Kstartpage )
       
   101 					{
       
   102 					if( useRandom )
       
   103 						{
       
   104 						param->SetRandomStartPageL(*iEngine);
       
   105 						}
       
   106 					else
       
   107 						{
       
   108 						SetContentToTextParamL(param->iWapStartPage, elemContent);
       
   109 						}
       
   110 					}
       
   111 				else if( elemName == Kwapwspoption )
       
   112 					{
       
   113 					if( useRandom )
       
   114 						{
       
   115 						param->SetRandomWapWspOptionL(*iEngine);
       
   116 						}
       
   117 					else
       
   118 						{
       
   119 						if( CompareIgnoreCase(elemContent, Kconnectionless) == 0 )
       
   120 							{
       
   121 							param->iWapWspOption = EWapWspOptionConnectionless;
       
   122 							}
       
   123 						else if( CompareIgnoreCase(elemContent, Kconnectionoriented) == 0 )
       
   124 							{
       
   125 							param->iWapWspOption = EWapWspOptionConnectionOriented;
       
   126 							}
       
   127 						}
       
   128 					}
       
   129 				else if( elemName == Kloginname )
       
   130 					{
       
   131 					if( useRandom )
       
   132 						{
       
   133 						param->SetRandomLoginNameL(*iEngine);                		
       
   134 						}
       
   135 					else
       
   136 						{
       
   137 						SetContentToTextParamL(param->iIspLoginName, elemContent);
       
   138 						}
       
   139 					}
       
   140 				else if( elemName == Ksecureauthentication )
       
   141 					{
       
   142 					if( useRandom )
       
   143 						{
       
   144 						param->SetRandomSecureAuthenticationL(*iEngine);
       
   145 						}
       
   146 					else
       
   147 						{
       
   148 						param->iSecureAuthentication = ConvertStrToBooleanL(elemContent);
       
   149 						}
       
   150 					}
       
   151 				else if( elemName == Kloginpass )
       
   152 					{
       
   153 					if( useRandom )
       
   154 						{
       
   155 						param->SetRandomLoginPassL(*iEngine);
       
   156 						}
       
   157 					else
       
   158 						{
       
   159 						SetContentToTextParamL(param->iIspLoginPass, elemContent);
       
   160 						}
       
   161 					}
       
   162 				else if( elemName == Kpromptpassword )
       
   163 					{
       
   164 					if( useRandom )
       
   165 						{
       
   166 						param->SetRandomPromptPasswordL(*iEngine);
       
   167 						}
       
   168 					else
       
   169 						{
       
   170 						param->iPromptPassword = ConvertStrToBooleanL(elemContent);
       
   171 						}
       
   172 					}
       
   173 				else if( elemName == Kgatewayaddress )
       
   174 					{
       
   175 					if( useRandom )
       
   176 						{
       
   177 						param->SetRandomGatewayAddressL(*iEngine);
       
   178 						}
       
   179 					else
       
   180 						{
       
   181 						SetContentToTextParamL(param->iWapGatewayAddress, elemContent);
       
   182 						}
       
   183 					}
       
   184 				else if( elemName == Kdeviceipaddr )
       
   185 					{
       
   186 					if( useRandom )
       
   187 						{
       
   188 						param->SetRandomIPAddressL(*iEngine);
       
   189 						}
       
   190 					else
       
   191 						{
       
   192 						SetContentToTextParamL(param->iIspIPAddr, elemContent);
       
   193 						}
       
   194 					}
       
   195 				else if( elemName == Kip4nameserver1 )
       
   196 					{
       
   197 					if( useRandom )
       
   198 						{
       
   199 						param->SetRandomIP4NameServer1L(*iEngine);
       
   200 						}
       
   201 					else
       
   202 						{
       
   203 						SetContentToTextParamL(param->iIspIPNameServer1, elemContent);
       
   204 						}
       
   205 					}
       
   206 				else if( elemName == Kip4nameserver2 )
       
   207 					{
       
   208 					if( useRandom )
       
   209 						{
       
   210 						param->SetRandomIP4NameServer2L(*iEngine);
       
   211 						}
       
   212 					else
       
   213 						{
       
   214 						SetContentToTextParamL(param->iIspIPNameServer2, elemContent);
       
   215 						}
       
   216 					}
       
   217 				else if( elemName == Kdatacalltelnumber )
       
   218 					{
       
   219 					if( useRandom )
       
   220 						{
       
   221 						param->SetRandomTelephoneNumberL(*iEngine);
       
   222 						}
       
   223 					else
       
   224 						{
       
   225 						SetContentToTextParamL(param->iIspDefaultTelNumber, elemContent);
       
   226 						}
       
   227 					}
       
   228 				else if( elemName == Kdatacalltypeisdn )
       
   229 					{
       
   230 					if( useRandom )
       
   231 						{
       
   232 						param->SetRandomBearerTypeIsdnL(*iEngine);
       
   233 						}
       
   234 					else
       
   235 						{
       
   236 						if( CompareIgnoreCase(elemContent, Kanalogue) == 0 )
       
   237 							param->iIspBearerCallTypeIsdn = ECallTypeAnalogue;
       
   238 						else if( CompareIgnoreCase( elemContent, Kisdnv110) == 0 )
       
   239 							param->iIspBearerCallTypeIsdn = ECallTypeISDNv110;
       
   240 						else if( CompareIgnoreCase( elemContent, Kisdnv120) == 0 )
       
   241 							param->iIspBearerCallTypeIsdn = ECallTypeISDNv120;
       
   242 						}
       
   243 					}
       
   244 				else if( elemName == Kbearertype )
       
   245 					{
       
   246 					if( useRandom )
       
   247 						{
       
   248 						param->iBearerType = EApBearerTypeGPRS;
       
   249 						}
       
   250 					else
       
   251 						{
       
   252 						if( CompareIgnoreCase(elemContent, Kwlan) == 0 )
       
   253 							{
       
   254 							param->iBearerType = EApBearerTypeWLAN;
       
   255 							}
       
   256 						else if( CompareIgnoreCase(elemContent, Kgprs) == 0 )
       
   257 							{
       
   258 							param->iBearerType = EApBearerTypeGPRS;
       
   259 							}
       
   260 						else if( CompareIgnoreCase(elemContent, Kdatacall) == 0 )
       
   261 							{
       
   262 							param->iBearerType = EApBearerTypeCSD;
       
   263 							}
       
   264 						else if( CompareIgnoreCase(elemContent, Khsgsm) == 0 )
       
   265 							{
       
   266 							param->iBearerType = EApBearerTypeHSCSD;
       
   267 							}
       
   268 						else if( CompareIgnoreCase(elemContent, Klan) == 0 )
       
   269 							{
       
   270 							param->iBearerType = EApBearerTypeLAN;
       
   271 							}
       
   272 						}
       
   273 					}
       
   274 				else if( elemName == Kdatacalllinespeed )
       
   275 					{
       
   276 					if( useRandom )
       
   277 						{
       
   278 						param->SetRandomBearerSpeedL(*iEngine);
       
   279 						}
       
   280 					else
       
   281 						{
       
   282 						if( CompareIgnoreCase(elemContent, Kautomatic) == 0 )
       
   283 							{                			 
       
   284 							param->iIspBearerSpeed = KSpeedAutobaud;
       
   285 							}
       
   286 						else
       
   287 							{
       
   288 							TUint lineSpeed = ConvertStrToUintL(elemContent);
       
   289 							if( lineSpeed == 9600 )
       
   290 								param->iIspBearerSpeed = KSpeed9600;
       
   291 							else if( lineSpeed == 14400 )
       
   292 								param->iIspBearerSpeed = KSpeed14400;
       
   293 							else if( lineSpeed == 19200 )
       
   294 								param->iIspBearerSpeed = KSpeed19200;
       
   295 							else if( lineSpeed == 28800 )
       
   296 								param->iIspBearerSpeed = KSpeed28800;
       
   297 							else if( lineSpeed == 38400 )
       
   298 								param->iIspBearerSpeed = KSpeed38400;
       
   299 							else if( lineSpeed == 43200 )
       
   300 								param->iIspBearerSpeed = KSpeed43200;
       
   301 							else if( lineSpeed == 56000 )
       
   302 								param->iIspBearerSpeed = KSpeed56000;
       
   303 							}                			
       
   304 						}
       
   305 					}
       
   306 				else if( elemName == Kproxyserveraddress )
       
   307 					{
       
   308 					if( useRandom )
       
   309 						{
       
   310 						param->SetRandomProxyAddressL(*iEngine);
       
   311 						}
       
   312 					else
       
   313 						{
       
   314 						SetContentToTextParamL(param->iProxyServerAddress, elemContent);                		
       
   315 						}
       
   316 					}
       
   317 				else if( elemName == Kproxyportnumber )
       
   318 					{
       
   319 					if( useRandom )
       
   320 						{
       
   321 						param->SetRandomProxyPortL(*iEngine);
       
   322 						}
       
   323 					else
       
   324 						{
       
   325 						param->iProxyPortNumber = ConvertStrToUintL(elemContent);                		
       
   326 						}
       
   327 					}
       
   328 				}
       
   329 			iEngine->AppendToCommandArrayL(ECmdCreateMiscEntryAccessPoints, param);
       
   330 			CleanupStack::Pop(); // param
       
   331 			}
       
   332 		}
       
   333 	}