messagingfw/biomsgfw/IACPSRC/ISPP.CPP
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Internet Service Provider Settings
       
    15 // 
       
    16 //
       
    17 
       
    18 #include "BSP.H"
       
    19 #include "IACP.H"
       
    20 #include "ISPP.H"
       
    21 #include "IACPDEF.H"
       
    22 #include "IACPERR.H"
       
    23 
       
    24 _LIT(KIacpProxyProtocolName, "HTTP");
       
    25 _LIT(KCharOne,"1");
       
    26 //
       
    27 // Constructor
       
    28 //
       
    29 CIspParser::CIspParser(TInt aSmsType)
       
    30 :iSmsType(aSmsType)
       
    31 	{
       
    32 	__ASSERT_DEBUG((iSmsType==CIacSettingsParser::EBasicIAP ||iSmsType==CIacSettingsParser::EBasicMailIAP ||
       
    33 		iSmsType==CIacSettingsParser::EExtendedIAP),
       
    34 					User::Panic(KIACP, KIacpUnknownSmsType));
       
    35 	}
       
    36 
       
    37 //
       
    38 // Factory fns
       
    39 //
       
    40 CIspParser* CIspParser::NewLC(TInt aSmsType)
       
    41 	{
       
    42 	CIspParser* self=new (ELeave) CIspParser(aSmsType);
       
    43 	CleanupStack::PushL(self);
       
    44 	self->ConstructL();
       
    45 	return self;
       
    46 	}
       
    47 
       
    48 CIspParser* CIspParser::NewL(TInt aSmsType)
       
    49 	{
       
    50 	CIspParser* self=CIspParser::NewLC(aSmsType);
       
    51 	CleanupStack::Pop();
       
    52 	return self;
       
    53 	}
       
    54 
       
    55 //
       
    56 // 2nd stage of construction
       
    57 //
       
    58 void CIspParser::ConstructL()
       
    59 	{
       
    60 	iLoginPrompt=ETrue;		//Mandatory Data
       
    61 	iSecureProxy=EFalse;
       
    62 	iDbSession = CMDBSession::NewL(CMDBSession::LatestVersion());					
       
    63 
       
    64 	iAddr = CIpAddress::NewL();
       
    65 	iDNS1 = CIpAddress::NewL();
       
    66 	iDNS2 = CIpAddress::NewL();
       
    67 	iNetMask = CIpAddress::NewL();
       
    68 	iGateway = CIpAddress::NewL();
       
    69 
       
    70 	iProxyExeptions = CIpAddress::NewL();
       
    71 	iProxyServerName = CIpAddress::NewL();
       
    72 	iSecureProxySrv = CIpAddress::NewL();
       
    73 	}
       
    74 
       
    75 //
       
    76 // Destruction
       
    77 //
       
    78 CIspParser::~CIspParser()
       
    79 	{
       
    80 	delete iName;
       
    81 	delete iDefaultTelNum;
       
    82 	delete iLoginName;
       
    83 	delete iLoginPass;
       
    84 	delete iAddr;
       
    85 	delete iNetMask;
       
    86 	delete iGateway;
       
    87 	delete iDNS1;
       
    88 	delete iDNS2;
       
    89 	delete iModemInit;
       
    90 
       
    91 	//Extended IAP data (Proxies Table)
       
    92 	delete iProxyExeptions;
       
    93 	delete iProxyServerName;
       
    94 	delete iSecureProxySrv;
       
    95 	delete iLoginCustomisation;
       
    96 	
       
    97 	delete iDbSession;
       
    98 	}
       
    99 
       
   100 
       
   101 void CIspParser::CheckMandatoryFieldsL(CParsedFieldCollection& aIacpFields)
       
   102 	{
       
   103 	if (aIacpFields.GetFieldValue(SMS_ISP_I_NAME).Length()==0 )
       
   104 		User::Leave(KIacpMandatoryDataNotSet);
       
   105 	}
       
   106 
       
   107 
       
   108 //
       
   109 // 
       
   110 //
       
   111 void CIspParser::ParseL(CParsedFieldCollection& aIacpFields)
       
   112 	{
       
   113 	TPtrC aFieldValueBuf;
       
   114 
       
   115 	if (aIacpFields.GetFieldValueAndLength(SMS_ISP_I_NAME, aFieldValueBuf) != 0)
       
   116 		{
       
   117 		delete iName;
       
   118 		iName = NULL;
       
   119 		iName = aFieldValueBuf.AllocL();
       
   120 		}
       
   121 
       
   122 	if (aIacpFields.GetFieldValueAndLength(SMS_DEFAULT_TEL_NUM, aFieldValueBuf) != 0)
       
   123 		{
       
   124 		delete iDefaultTelNum;
       
   125 		iDefaultTelNum = NULL;
       
   126 		iDefaultTelNum= aFieldValueBuf.AllocL();
       
   127 		}
       
   128 
       
   129 	if (aIacpFields.GetFieldValueAndLength(SMS_LOGIN_NAME, aFieldValueBuf) != 0)
       
   130 		{
       
   131 		delete iLoginName;
       
   132 		iLoginName = NULL;
       
   133 		iLoginName= aFieldValueBuf.AllocL();
       
   134 		}
       
   135 
       
   136 	if (aIacpFields.FieldNameExists(SMS_LOGIN_PASS))
       
   137 		{
       
   138 		//should recheck for -	if (aIacpFields.GetFieldValueAndLength(SMS_LOGIN_PASS, aFieldValueBuf) != 0)
       
   139 		//to set it if it exists if it doesn't it needs resetting
       
   140 		if (aIacpFields.GetFieldValueAndLength(SMS_LOGIN_PASS, aFieldValueBuf))
       
   141 			{
       
   142 			delete iLoginPass;
       
   143 			iLoginPass = NULL;
       
   144 			iLoginPass= aFieldValueBuf.AllocL();		
       
   145 			}		
       
   146 		}
       
   147 
       
   148 	if (aIacpFields.GetFieldValueAndLength(SMS_PROMPT_FOR_LOGIN, aFieldValueBuf) != 0)
       
   149 		aIacpFields.GetTBoolL(aFieldValueBuf,iLoginPrompt);
       
   150 	else if((iLoginName) && (iLoginPass) ) 
       
   151 		iLoginPrompt=EFalse; // if both the login Name and password are specified then this should be set to EFalse
       
   152 
       
   153 	if (aIacpFields.GetFieldValueAndLength(SMS_IP_ADDR, aFieldValueBuf) != 0)
       
   154 		{
       
   155 		iAddr->SetAddrL(aFieldValueBuf);
       
   156 		}
       
   157 
       
   158 	if (aIacpFields.GetFieldValueAndLength(SMS_IP_NETMASK, aFieldValueBuf) != 0)
       
   159 		{
       
   160 		iNetMask->SetAddrL(aFieldValueBuf);
       
   161 		}
       
   162 
       
   163 	if (aIacpFields.GetFieldValueAndLength(SMS_IP_GATEWAY, aFieldValueBuf) != 0)
       
   164 		{
       
   165 		iGateway->SetAddrL(aFieldValueBuf);
       
   166 		}
       
   167 
       
   168 	if (aIacpFields.GetFieldValueAndLength(SMS_IP_NAME_SERVER1, aFieldValueBuf) != 0)
       
   169 		{
       
   170 		iDNS1->SetAddrL(aFieldValueBuf);
       
   171 		}
       
   172 
       
   173 	if (aIacpFields.GetFieldValueAndLength(SMS_IP_NAME_SERVER2, aFieldValueBuf) != 0)	
       
   174 		{
       
   175 		iDNS2->SetAddrL(aFieldValueBuf);
       
   176 		}
       
   177 
       
   178 	if (aIacpFields.GetFieldValueAndLength(SMS_INIT_STRING, aFieldValueBuf) != 0)
       
   179 		{
       
   180 		delete iModemInit;
       
   181 		iModemInit = NULL;
       
   182 		iModemInit = HBufC8::NewL(aFieldValueBuf.Length());
       
   183 		iModemInit->Des().Copy(aFieldValueBuf);
       
   184 		}
       
   185 
       
   186 	//Extended IAP
       
   187 	if (aIacpFields.GetFieldValueAndLength(SMS_PROXY_EXCEPTIONS, aFieldValueBuf) != 0)
       
   188 		{
       
   189 		iProxyExeptions->SetAddrL(aFieldValueBuf);
       
   190 		}
       
   191 
       
   192 	if (aIacpFields.GetFieldValueAndLength(SMS_PROXY_PORT_NUMBER, aFieldValueBuf) != 0)
       
   193 		aIacpFields.GetTUint32NumL(aFieldValueBuf,iProxyPortNum);
       
   194 
       
   195 	if (aIacpFields.GetFieldValueAndLength(SMS_PROXY_SERVER_NAME, aFieldValueBuf) != 0)
       
   196 		{
       
   197 		iProxyServerName->SetAddrL(aFieldValueBuf);
       
   198 		iSecureProxy=EFalse;
       
   199 		}
       
   200 
       
   201 	if (aIacpFields.GetFieldValueAndLength(SMS_LOGIN_CUSTOMISATION, aFieldValueBuf) != 0)
       
   202 		{
       
   203 		delete iLoginCustomisation;
       
   204 		iLoginCustomisation = NULL;
       
   205 		iLoginCustomisation= aFieldValueBuf.AllocL();
       
   206 		}
       
   207 
       
   208 	if (aIacpFields.GetFieldValueAndLength(SMS_ENABLE_SW_COMP, aFieldValueBuf) != 0)
       
   209 		aIacpFields.GetTBoolL(aFieldValueBuf, iSWCompressionEnabled);  //goes to ISP -Dial out Table fields
       
   210 
       
   211 	if (aIacpFields.GetFieldValueAndLength(SMS_SECURE_PROXY, aFieldValueBuf) != 0)
       
   212 		{
       
   213 		iSecureProxySrv->SetAddrL(aFieldValueBuf);
       
   214 		iSecureProxy=ETrue;
       
   215 		}
       
   216 
       
   217 	if (aIacpFields.GetFieldValueAndLength(SMS_SECURE_PORT, aFieldValueBuf) != 0)
       
   218 		aIacpFields.GetTUint32NumL(aFieldValueBuf,iSecurePortNum);
       
   219 	}
       
   220 //
       
   221 //
       
   222 //
       
   223 void CIspParser::ProcessL(CIacSettingsParser::TIacpConnectionPreferenceFlag& aConnectionPreference)
       
   224 	{
       
   225 	iNoExistingIpAddr = ETrue;
       
   226 	iNoExistingDNS	  = ETrue;
       
   227 	WriteToDialOutISPTableL();
       
   228 	SetIapIdsL();	
       
   229 	if(iSmsType== CIacSettingsParser::EExtendedIAP)
       
   230 		{
       
   231 		WriteToProxiesTableL();	
       
   232 		}
       
   233 	WriteToDialOutIAPTableL();
       
   234 	SetGlobalIapL(TPtrC(KCDTypeNameIAP), iRecordId);
       
   235 	iDialOutIap = iRecordId;
       
   236 	
       
   237 	if(aConnectionPreference == CIacSettingsParser::EIacpAttempCreateAsFirstRank ||
       
   238 		aConnectionPreference == CIacSettingsParser::EIacpAttempCreateAsSecondRank)
       
   239 		{
       
   240 		WriteToPreferencesTableL(ECommDbConnectionDirectionOutgoing,aConnectionPreference);
       
   241 		}			
       
   242 	}
       
   243 void CIspParser::SetGlobalIapL(const TDesC& aTable, TUint32 aIAP)
       
   244 	{
       
   245 	CCDConnectionPrefsRecord* connectionPrefsRecord = static_cast<CCDConnectionPrefsRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdConnectionPrefsRecord));	
       
   246 	CleanupStack::PushL(connectionPrefsRecord);
       
   247 	connectionPrefsRecord->iDirection = ECommDbConnectionDirectionOutgoing;
       
   248 	connectionPrefsRecord->iRanking = 1;	//rank 1 is like a default value
       
   249 	TBool recExists = connectionPrefsRecord->FindL(*iDbSession);
       
   250 	if (recExists)
       
   251 		{
       
   252 		TInt intValue = 	connectionPrefsRecord->iDefaultIAP;
       
   253 		if(aTable.CompareF(TPtrC(KCDTypeNameIAP)) && intValue != aIAP)
       
   254 			{
       
   255 			CCDIAPRecord* iapRecord = static_cast<CCDIAPRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdIAPRecord));
       
   256 			CleanupStack::PushL(iapRecord);
       
   257 			iapRecord->iRecordTag = intValue;
       
   258 			recExists = iapRecord->FindL(*iDbSession);			
       
   259 			CleanupStack::PopAndDestroy(iapRecord);		
       
   260 			}
       
   261 		// If there are no IAP record
       
   262 		if(!recExists)
       
   263 			{
       
   264 			connectionPrefsRecord->iDefaultIAP = aIAP;	
       
   265 			connectionPrefsRecord->ModifyL(*iDbSession);
       
   266 			}		
       
   267 		}
       
   268 	// If there are no ConnPref 
       
   269 	else
       
   270 		{
       
   271 		connectionPrefsRecord->iDefaultIAP = aIAP;	
       
   272 		connectionPrefsRecord->StoreL(*iDbSession);
       
   273 		}	
       
   274 	CleanupStack::PopAndDestroy(connectionPrefsRecord);
       
   275 
       
   276 	}
       
   277 
       
   278 //
       
   279 // Id of IAP record entry
       
   280 //
       
   281 TUint32	CIspParser::IapEntryId()
       
   282 	{
       
   283 	return iDialOutIap;
       
   284 	}
       
   285 //
       
   286 //
       
   287 //
       
   288 void CIspParser::SetIapIdsL()
       
   289 	{
       
   290 	TUint32 id=0;
       
   291 	GetIapIdL(TPtrC(KCDTypeNameDialOutISP), id);
       
   292 	iIapIsp=id;
       
   293 	iProxyIsp=id;
       
   294 	}
       
   295 
       
   296 //
       
   297 // Get COMMDB_ID from table that matches the COMMDB_NAME extracted from BioMsg
       
   298 //
       
   299 void CIspParser::GetIapIdL(const TDesC& aTableName, TUint32& aId)
       
   300 	{
       
   301   	const TPtrC KNameFieldToken(iName->Des());
       
   302 	if (aTableName.CompareF(TPtrC(KCDTypeNameDialOutISP)) == KErrNone)
       
   303 		{
       
   304 		CCDDialOutISPRecord* dialOutIspRecord = static_cast<CCDDialOutISPRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdDialOutISPRecord));
       
   305 		CleanupStack::PushL(dialOutIspRecord);
       
   306 		dialOutIspRecord->iRecordName.SetMaxLengthL(KNameFieldToken.Length());
       
   307 		dialOutIspRecord->iRecordName =  KNameFieldToken;
       
   308 		TBool err = dialOutIspRecord->FindL(*iDbSession);	
       
   309 		if (err)
       
   310 			{		
       
   311 			aId = dialOutIspRecord->iRecordTag.RecordId();
       
   312 			}
       
   313 		else
       
   314 			{
       
   315 			User::Leave(err);
       
   316 			}
       
   317 		CleanupStack::PopAndDestroy(dialOutIspRecord);		
       
   318 		}
       
   319 	}
       
   320 	
       
   321 
       
   322 void CIspParser::WriteToDialOutISPTableL()
       
   323 	{
       
   324 	CCDDialOutISPRecord* dialOutIspRecord = static_cast<CCDDialOutISPRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdDialOutISPRecord));
       
   325 	CleanupStack::PushL(dialOutIspRecord);
       
   326 	(dialOutIspRecord->iRecordName).SetMaxLengthL(iName->Length());	
       
   327 	dialOutIspRecord->iRecordName = *iName;
       
   328 	TBool recordExist = FALSE;
       
   329 	if(!(dialOutIspRecord->FindL(*iDbSession)))
       
   330 		{
       
   331 		dialOutIspRecord->SetRecordId(KCDNewRecordRequest);		
       
   332 		}
       
   333 	else
       
   334 		{
       
   335 		recordExist = TRUE;
       
   336 		}
       
   337 	dialOutIspRecord->iDialResolution = ETrue;
       
   338 	if(iDefaultTelNum)
       
   339 		{
       
   340 		(dialOutIspRecord->iDefaultTelNum).SetMaxLengthL(iDefaultTelNum->Length());
       
   341 		dialOutIspRecord->iDefaultTelNum = LimitStringSize(iDefaultTelNum->Des());
       
   342 		}
       
   343 	dialOutIspRecord->iPromptForLogin = iLoginPrompt;
       
   344 
       
   345 	TBool manualCustomisation = EFalse;
       
   346 	if(iLoginCustomisation)
       
   347 		{
       
   348 		// If Ilgn field is found in the BIO message check whether
       
   349 		// it is '1', in which case place TRUE into the CommsDat field.
       
   350 		// Currently it is not possible to handle a script name being
       
   351 		// specified in the Ilgn field of the BIO message because CommsDat
       
   352 		// will only accept a boolean value for ISP_USE_LOGIN_SCRIPT.
       
   353 		// This may need to be changed in the future depending on requirements.
       
   354 
       
   355 		manualCustomisation = (iLoginCustomisation->Compare(KCharOne) == 0);
       
   356 		}
       
   357 
       
   358 	dialOutIspRecord->iUseLoginScript = manualCustomisation;
       
   359 	if (iLoginName)
       
   360 		{
       
   361 		(dialOutIspRecord->iLoginName).SetMaxLengthL(iLoginName->Length());
       
   362 		dialOutIspRecord->iLoginName = LimitStringSize(iLoginName->Des());
       
   363 		(dialOutIspRecord->iIfAuthName).SetMaxLengthL(iLoginName->Length());
       
   364 		dialOutIspRecord->iIfAuthName = LimitStringSize(iLoginName->Des());	
       
   365 		}
       
   366 	if(iLoginPass)
       
   367 		{
       
   368 		(dialOutIspRecord->iLoginPass).SetMaxLengthL(iLoginPass->Length());
       
   369 		dialOutIspRecord->iLoginPass = LimitStringSize(iLoginPass->Des());
       
   370 		(dialOutIspRecord->iIfAuthPass).SetMaxLengthL(iLoginPass->Length());
       
   371 		dialOutIspRecord->iIfAuthPass = LimitStringSize(iLoginPass->Des());		
       
   372 		}
       
   373 		
       
   374 	dialOutIspRecord->iDisplayPct = EFalse;
       
   375 	dialOutIspRecord->iIfPromptForAuth = EFalse;
       
   376 	dialOutIspRecord->iIfCallbackEnabled = EFalse;
       
   377 	(dialOutIspRecord->iIpAddr).SetMaxLengthL(KCommsDbSvrMaxFieldLength);
       
   378 	dialOutIspRecord->iIpAddr = iAddr->Addr();
       
   379 	dialOutIspRecord->iIpAddrFromServer = EFalse;
       
   380 	dialOutIspRecord->iIpAddrFromServer = ETrue;
       
   381 	if(iNetMask)
       
   382 		{
       
   383 		(dialOutIspRecord->iIpNetMask).SetMaxLengthL(KCommsDbSvrMaxFieldLength);
       
   384 		dialOutIspRecord->iIpNetMask = LimitStringSize(iNetMask->Addr());
       
   385 		}
       
   386 	if(iGateway)
       
   387 		{
       
   388 		(dialOutIspRecord->iIpGateway).SetMaxLengthL(KCommsDbSvrMaxFieldLength);
       
   389 		dialOutIspRecord->iIpGateway = LimitStringSize(iGateway->Addr());
       
   390 		}
       
   391 	TBool dns1Specified = (iDNS1->Addr().Compare(KNullDesC) != 0);
       
   392 	TBool dns2Specified = (iDNS2->Addr().Compare(KNullDesC) != 0);
       
   393 	if(dns1Specified)
       
   394 		{
       
   395 		(dialOutIspRecord->iIpNameServer1).SetMaxLengthL(KCommsDbSvrMaxFieldLength);
       
   396 		dialOutIspRecord->iIpNameServer1 = iDNS1->Addr();
       
   397 		}
       
   398 	if(dns2Specified)
       
   399 		{
       
   400 		(dialOutIspRecord->iIpNameServer2).SetMaxLengthL(KCommsDbSvrMaxFieldLength);
       
   401 		dialOutIspRecord->iIpNameServer2 = LimitStringSize(iDNS2->Addr());	
       
   402 		}	
       
   403 	if(dns1Specified || dns2Specified || !iNoExistingDNS)
       
   404 		{
       
   405 		dialOutIspRecord->iIpDnsAddrFromServer = EFalse;	
       
   406 		}		
       
   407 	else
       
   408 		{
       
   409 		dialOutIspRecord->iIpDnsAddrFromServer = ETrue;	
       
   410 		}		
       
   411 	dialOutIspRecord->iEnableIpHeaderComp = EFalse;
       
   412 	dialOutIspRecord->iDisablePlainTextAuth = EFalse;
       
   413 	dialOutIspRecord->iEnableSwComp = iSWCompressionEnabled;
       
   414 	dialOutIspRecord->iIfNetworks = KIacpIfNetworks;
       
   415 	if(iModemInit)
       
   416 		{
       
   417 		(dialOutIspRecord->iInitString).SetMaxLengthL(KCommsDbSvrMaxFieldLength);
       
   418 		dialOutIspRecord->iInitString = iModemInit->Des();	
       
   419 		}
       
   420 	if(iIapChargeCard)
       
   421 		{
       
   422 		dialOutIspRecord->iChargecard = iIapChargeCard;	
       
   423 		}
       
   424 		
       
   425 	if (!recordExist)
       
   426 		{
       
   427 		dialOutIspRecord->StoreL(*iDbSession);
       
   428 		}
       
   429 	else 
       
   430 		{
       
   431 		dialOutIspRecord->ModifyL(*iDbSession);	
       
   432 		}
       
   433 	CleanupStack::PopAndDestroy(dialOutIspRecord);
       
   434 	}
       
   435 
       
   436 void CIspParser::WriteToDialOutIAPTableL()
       
   437 	{
       
   438 	CCDIAPRecord* iapRecord = static_cast<CCDIAPRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdIAPRecord));
       
   439 	CleanupStack::PushL(iapRecord);
       
   440 
       
   441 	(iapRecord->iRecordName).SetMaxLengthL(iName->Length());	
       
   442 	iapRecord->iRecordName = *iName;
       
   443 	TBool recordExist = FALSE;
       
   444 	if(!(iapRecord->FindL(*iDbSession)))
       
   445 		{
       
   446 		iapRecord->SetRecordId(KCDNewRecordRequest);		
       
   447 		}
       
   448 	else
       
   449 		{
       
   450 		recordExist = TRUE;
       
   451 		}
       
   452 	iapRecord->iServiceType.SetMaxLengthL(((TPtrC)KCDTypeNameDialOutISP).Length());
       
   453 	iapRecord->iServiceType = TPtrC(KCDTypeNameDialOutISP);
       
   454 	iapRecord->iService =  iIapIsp; 
       
   455 	iapRecord->iBearerType.SetMaxLengthL(((TPtrC)KCDTypeNameModemBearer).Length());
       
   456 	iapRecord->iBearerType = TPtrC(KCDTypeNameModemBearer);
       
   457 	//there are 7 fields in IAP table which cannot have null values, and so when creating an IAP record we were only filling in one of the fields which meant we were submitting a record with lots of null values which can't be handled.
       
   458 	iapRecord->iBearer = 2;
       
   459 	iapRecord->iNetwork = 1;
       
   460 	iapRecord->iNetworkWeighting = 0;
       
   461 	iapRecord->iLocation = 4;
       
   462 	if (!recordExist)
       
   463 		{
       
   464 		iapRecord->StoreL(*iDbSession);
       
   465 		}
       
   466 	else 
       
   467 		{
       
   468 		iapRecord->ModifyL(*iDbSession);	
       
   469 		}
       
   470 	iRecordId = iapRecord->iRecordTag.RecordId();	
       
   471 	CleanupStack::PopAndDestroy(iapRecord);
       
   472 	}
       
   473 void CIspParser::WriteToPreferencesTableL(TCommDbConnectionDirection aDirection,CIacSettingsParser::TIacpConnectionPreferenceFlag& aConnectionPreference)
       
   474 	{
       
   475 	// create a new connection prefs record
       
   476 	CCDConnectionPrefsRecord* connectionPrefsRecord = static_cast<CCDConnectionPrefsRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdConnectionPrefsRecord));
       
   477 	CleanupStack::PushL(connectionPrefsRecord);
       
   478 	connectionPrefsRecord->iRanking = aConnectionPreference;
       
   479 	connectionPrefsRecord->iDirection = aDirection;
       
   480 	connectionPrefsRecord->iDialogPref = ECommDbDialogPrefPrompt;
       
   481 	connectionPrefsRecord->iBearerSet  = ECommDbBearerWcdma;
       
   482 	connectionPrefsRecord->SetRecordId(KCDNewRecordRequest);
       
   483 	if(!(connectionPrefsRecord->FindL(*iDbSession)))
       
   484 		{
       
   485 		connectionPrefsRecord->StoreL(*iDbSession);		
       
   486 		}
       
   487 	else
       
   488 		{
       
   489 		aConnectionPreference = CIacSettingsParser::EIacpDoNotCreatePreference;
       
   490 		}
       
   491 	CleanupStack::PopAndDestroy(connectionPrefsRecord);	
       
   492 	}
       
   493 void CIspParser::WriteToProxiesTableL()
       
   494 	{
       
   495 	CCDProxiesRecord *proxiesRecord = static_cast<CCDProxiesRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdProxiesRecord));
       
   496 	CleanupStack::PushL(proxiesRecord);
       
   497 	proxiesRecord->iService = iProxyIsp;
       
   498 	TBool recordExist = FALSE;
       
   499 	if(!(proxiesRecord->FindL(*iDbSession)))
       
   500 		{
       
   501 		proxiesRecord->SetRecordId(KCDNewRecordRequest);		
       
   502 		}
       
   503 	else
       
   504 		{
       
   505 		recordExist = TRUE;
       
   506 		}
       
   507 	if(iSecureProxy)
       
   508 		{
       
   509 		if(iSecureProxySrv)
       
   510 			{
       
   511 			(proxiesRecord->iServerName).SetMaxLengthL(KCommsDbSvrMaxFieldLength);
       
   512 			proxiesRecord->iServerName = iSecureProxySrv->Addr();		
       
   513 			}
       
   514 		if(iSecurePortNum)
       
   515 			{
       
   516 			proxiesRecord->iPortNumber = iSecurePortNum;		
       
   517 			}
       
   518 		(proxiesRecord->iProtocolName).SetMaxLengthL(KCommsDbSvrMaxFieldLength);		
       
   519 		proxiesRecord->iProtocolName = KIacpProxyProtocolName;
       
   520 		
       
   521 		}
       
   522 	else
       
   523 		{
       
   524 		if(iProxyServerName)
       
   525 			{
       
   526 			(proxiesRecord->iServerName).SetMaxLengthL(KCommsDbSvrMaxFieldLength);
       
   527 			proxiesRecord->iServerName = iProxyServerName->Addr();		
       
   528 			}
       
   529 		proxiesRecord->iPortNumber = iProxyPortNum;
       
   530 		proxiesRecord->iProtocolName = KIacpProxyProtocolName;
       
   531 		}
       
   532 
       
   533 	if(iProxyExeptions)
       
   534 		{
       
   535 		(proxiesRecord->iExceptions).SetMaxLengthL(KCommsDbSvrMaxFieldLength);
       
   536 		proxiesRecord->iExceptions = iProxyExeptions->Addr();		
       
   537 		}		
       
   538 	proxiesRecord->iUseProxyServer = EFalse;
       
   539 
       
   540 	if (!recordExist)
       
   541 		{
       
   542 		proxiesRecord->StoreL(*iDbSession);
       
   543 		}
       
   544 	else
       
   545 		{
       
   546 		proxiesRecord->ModifyL(*iDbSession);	
       
   547 		}
       
   548 	CleanupStack::PopAndDestroy(proxiesRecord);	
       
   549 	}
       
   550 
       
   551 
       
   552 TPtrC CIspParser::LimitStringSize(const TDesC& aString)
       
   553 	{
       
   554 	if (aString.Length() < KCommsDbSvrMaxFieldLength)
       
   555 		return aString;
       
   556 	else
       
   557 		return aString.Left(KCommsDbSvrMaxFieldLength);
       
   558 	}
       
   559 
       
   560 TPtrC8 CIspParser::LimitStringSize(const TDesC8& aString)
       
   561 	{
       
   562 	if (aString.Length() < KCommsDbSvrMaxFieldLength)
       
   563 		return aString;
       
   564 	else
       
   565 		return aString.Left(KCommsDbSvrMaxFieldLength);
       
   566 	}