messagingfw/biomsgfw/IACPSRC/IACP.CPP
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     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 // IACP.CPP
       
    15 //
       
    16     
       
    17 #include <msvids.h>
       
    18 #include <mentact.h>
       
    19 #include <msvapi.h>
       
    20 #include "BSP.H"
       
    21 #include "IACP.H"
       
    22 #include "ISPP.H"
       
    23 #include "ISSP.H"
       
    24 #include "IMP.H"
       
    25 #include "SMSP.H"
       
    26 #include "TVMP.H"
       
    27 #include "gprsp.h"
       
    28 #include "wwwp.h"
       
    29 #include "IACPDEF.H"
       
    30 #include "IACPERR.H"
       
    31 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS 
       
    32 #include "tmsvbioinfo.h"
       
    33 #endif
       
    34 
       
    35 const TInt SMS_SCRIPT_DATA_LEN = 5;
       
    36 const TInt SMS_SCRIPT_ADD_LEN  = 4;
       
    37 
       
    38 const TInt KParsedFieldsGranularity=16;
       
    39 
       
    40 #define KUidMsvBIOInternetAccessPointMessageType  0x1000552F 
       
    41 
       
    42 #define KCharSlash			'/'
       
    43 _LIT(KIacpLowerY, "y");
       
    44 _LIT(KIacpLowerT, "t");
       
    45 _LIT(KIacpLowerN, "n");
       
    46 _LIT(KIacpLowerF, "f");
       
    47 
       
    48 //
       
    49 // Constructor
       
    50 //
       
    51 CIacSettingsParser::CIacSettingsParser(CRegisteredParserDll& aRegisteredParserDll, CMsvEntry& aEntry, RFs& aFs)
       
    52 :CBaseScriptParser2(aRegisteredParserDll, aEntry, aFs)
       
    53 	{
       
    54 	}
       
    55 
       
    56 //
       
    57 // Factory fns
       
    58 //
       
    59 EXPORT_C CIacSettingsParser* CIacSettingsParser::NewL(CRegisteredParserDll& aRegisteredParserDll, CMsvEntry& aEntry, RFs& aFs)
       
    60 	{
       
    61 	CIacSettingsParser* self= new(ELeave) CIacSettingsParser(aRegisteredParserDll,aEntry,aFs);
       
    62 	CleanupStack::PushL(self);
       
    63 	self->ConstructL();
       
    64 	CleanupStack::Pop();
       
    65 	return self;
       
    66 	}
       
    67 
       
    68 //
       
    69 // 2nd stage of construction
       
    70 //
       
    71 void CIacSettingsParser::ConstructL()
       
    72 	{
       
    73 	iParsedFieldArray = new(ELeave) CArrayPtrSeg<CParsedField>(KParsedFieldsGranularity);	
       
    74 	iSmsParsed=EFalse;
       
    75 	iParsedFieldCollections = new(ELeave)CArrayPtrSeg<CParsedFieldCollection>(4);
       
    76 	CActiveScheduler::Add(this);
       
    77 	}
       
    78 
       
    79 //
       
    80 // Destruction
       
    81 //
       
    82 CIacSettingsParser::~CIacSettingsParser()
       
    83 	{
       
    84 	Cancel();
       
    85 
       
    86 	
       
    87 	if(iParsedFieldCollections)
       
    88 		{
       
    89 		iParsedFieldCollections->ResetAndDestroy();
       
    90 		delete iParsedFieldCollections;
       
    91 		}
       
    92 
       
    93 	if(iParsedFieldArray)
       
    94 		{
       
    95 		iParsedFieldArray->ResetAndDestroy();
       
    96 		delete iParsedFieldArray;
       
    97 		}
       
    98 	delete iSmsBuf;
       
    99 	delete iMailParser;
       
   100 	delete iIspParser;
       
   101 	delete iScriptParser;
       
   102 	delete iSmsParser;
       
   103 	delete iTelVoiceMailboxParser;
       
   104 	delete iGprsParser;
       
   105 	delete iWWWHotlistParser;
       
   106 	}
       
   107 
       
   108 //
       
   109 // 
       
   110 //
       
   111 void CIacSettingsParser::RestoreParsedDataL()
       
   112 	{
       
   113 	//	We are assuming the server context is set to the Bio Msg entry	
       
   114 	iEntry.SetEntryL(iEntryId);
       
   115 
       
   116 	if(iEntry.Entry().MtmData3() != KBIO_MSG_ENTRY_PARSED && iEntry.Entry().MtmData3() != KBIO_MSG_ENTRY_PROCESSED)
       
   117 		{
       
   118 		iSmsParsed=EFalse; //sms not parsed yet
       
   119 		User::Leave(KIacpErrSmsDataNotRestored);
       
   120 		}
       
   121 
       
   122 	if(!iEntry.HasStoreL())
       
   123 		{
       
   124 		iSmsParsed=EFalse; //sms not parsed yet
       
   125 		User::Leave(KIacpErrSmsDataNotRestored);
       
   126 		}
       
   127 			
       
   128 	CMsvStore* store=iEntry.EditStoreL();
       
   129 	CleanupStack::PushL(store);
       
   130 	RestoreL(*store);
       
   131 	CleanupStack::PopAndDestroy();//store
       
   132 
       
   133 	// work out what type it is
       
   134 	PopulateFieldCollectionsL();
       
   135 	}
       
   136 
       
   137 void CIacSettingsParser::ParseL(TRequestStatus& aStatus,const TDesC& aSms)
       
   138 	{
       
   139 	__ASSERT_DEBUG (aSms.Length() > 0 ,User::Panic(KIACP, EIacpEmptyBuffer));
       
   140 	//make a local copy of sms
       
   141 	if(iSmsBuf)
       
   142 		{
       
   143 		delete iSmsBuf;
       
   144 		iSmsBuf=NULL;
       
   145 		}
       
   146 
       
   147 	iSmsBuf = aSms.AllocL();
       
   148 	iSms = iSmsBuf->Des(); //initialise Tlex
       
   149 
       
   150 	ChangeStateL(EParseSms); //Set to initial request
       
   151 	aStatus = KRequestPending;
       
   152 	iReport = &aStatus;
       
   153 	}
       
   154 //
       
   155 // Create service or database entries
       
   156 //
       
   157 void CIacSettingsParser::ProcessL(TRequestStatus& aStatus)
       
   158 	{
       
   159 	iState = EProcessSms;
       
   160 	iEntryId= iEntry.Entry().Id(); //store id of Bio Msg entry 
       
   161 
       
   162 	__ASSERT_DEBUG(iEntry.Entry().iMtm==KUidSmartMessageMtm, User::Panic(KIACP,EIacpInvalidEntry));
       
   163 	__ASSERT_DEBUG(iEntry.Entry().iBioType==KUidMsvBIOInternetAccessPointMessageType, User::Panic(KIACP,EIacpInvalidEntry));
       
   164 	__ASSERT_DEBUG(iEntry.Entry().Failed()== 0 , User::Panic(KIACP,EIacpInvalidEntry));
       
   165 
       
   166 	ChangeStateL(ESetParsersData); //Set to initial state
       
   167 	aStatus = KRequestPending;
       
   168 	iReport = &aStatus;
       
   169 	}
       
   170 
       
   171 
       
   172 void CIacSettingsParser::ChangeStateL(TParseSession aState)
       
   173 	{
       
   174 	iState = aState;
       
   175 	switch (iState)
       
   176 		{
       
   177 		case EParseSms:
       
   178 			ParseSmsL();
       
   179 			break;
       
   180 
       
   181 		case ECheckData:
       
   182 			iCurrentSettingsCtr = 0;
       
   183 			CheckMandatoryDataL();
       
   184 			break;
       
   185 
       
   186 		case ESetParsersData:
       
   187 			iCurrentSettingsCtr = 0;
       
   188 			SetDataL();
       
   189 			break;
       
   190 
       
   191 		case EProcessSms:
       
   192 			// Commit parsed data
       
   193 			DoProcessL();
       
   194 			break;
       
   195 
       
   196 		default:
       
   197 			break;
       
   198 		}
       
   199 
       
   200 		RequestComplete(iStatus,KErrNone);
       
   201 		SetActive();
       
   202 	}
       
   203 
       
   204 void CIacSettingsParser::CheckMandatoryDataL()
       
   205 	{
       
   206 	CParsedFieldCollection& currentFieldCollection = *(*iParsedFieldCollections)[iCurrentSettingsCtr];
       
   207 	TSmsType currentType = currentFieldCollection.MessageType();
       
   208 	switch(currentType)
       
   209 		{
       
   210 	case EBasicMail:
       
   211 		delete iMailParser;
       
   212 		iMailParser = NULL;
       
   213 		iMailParser = CMailParser::NewL();
       
   214 		iMailParser->CheckMandatoryFieldsL(currentFieldCollection);
       
   215 		break;
       
   216 	case EBasicIAP:
       
   217 	case EExtendedIAP:
       
   218 		delete iIspParser;
       
   219 		iIspParser = NULL;
       
   220 		iIspParser = CIspParser::NewL(currentType);
       
   221 		iIspParser->CheckMandatoryFieldsL(currentFieldCollection);
       
   222 		break;
       
   223 	case EExtScriptSettings:
       
   224 	case EExtSmsSettings:
       
   225 	case EExtTelephoneSettings:
       
   226 	case EExtendedMail:
       
   227 	case EExtWWWHostListItem:
       
   228 	case EExtTelnetSettings:
       
   229 	case EExtTerminalSettings:
       
   230 	case EExtWWWSettings:	
       
   231 	case EExtTTMLSettings:
       
   232 	case EExtFTPSettings:
       
   233 	case EExtInternetSettings:
       
   234 	case EExtWWWAutofetchSettings:
       
   235 	case ESmsTypeUndefined:
       
   236 	case EBasicMailIAP:
       
   237 	case EExtGprsIAP:	
       
   238 	case EExtGprsMail:
       
   239 	case EExtGprsIAPMail:
       
   240 	case ESmsMixedContent:
       
   241 		break;
       
   242 	case EExtGprsSettings:
       
   243 		delete iGprsParser;
       
   244 		iGprsParser = NULL;
       
   245 		iGprsParser = CGprsParser::NewL();
       
   246 		iGprsParser->CheckMandatoryFieldsL(currentFieldCollection);
       
   247 		break;
       
   248 		}
       
   249 	}
       
   250 
       
   251 void CIacSettingsParser::SetDataL()
       
   252 	{
       
   253 	if(!iSmsParsed)
       
   254 		{
       
   255 		RestoreParsedDataL();
       
   256 		}
       
   257 	SetParsersDataL();
       
   258 	}
       
   259 
       
   260 void CIacSettingsParser::DoProcessL()
       
   261 	{
       
   262 	switch((*iParsedFieldCollections)[iCurrentSettingsCtr]->MessageType())
       
   263 		{
       
   264 		case EBasicMail:
       
   265 			iMailParser->ProcessL(iEntry);
       
   266 			break;
       
   267 		case EBasicIAP:
       
   268 			iIspParser->ProcessL(iConnectionPreference);
       
   269 			break;
       
   270 		case EExtendedIAP:
       
   271 			iIspParser->ProcessL(iConnectionPreference);
       
   272 			break;
       
   273 		case EExtScriptSettings:
       
   274 			iScriptParser->ProcessL(iEntry);
       
   275 			break;
       
   276 		case EExtSmsSettings:
       
   277 			iSmsParser->ProcessL(iEntry);
       
   278 			break;
       
   279 		case EExtTelephoneSettings:
       
   280 			iTelVoiceMailboxParser->ProcessL(iEntry);
       
   281 			break;
       
   282 		case EExtGprsSettings:
       
   283 			iGprsParser->ProcessL(iConnectionPreference);
       
   284 			break;
       
   285 		case EExtWWWHostListItem:
       
   286 			iWWWHotlistParser->ProcessL(iEntry);
       
   287 			break;
       
   288 		default:
       
   289 			User::Leave(KIacpUnknownSmsType);
       
   290 		}
       
   291 	}
       
   292 //
       
   293 //
       
   294 //
       
   295 void CIacSettingsParser::DoCancel()
       
   296 	{
       
   297 	User::RequestComplete(iReport,KErrCancel);
       
   298 	}
       
   299 
       
   300 //
       
   301 //  
       
   302 //
       
   303 TInt CIacSettingsParser::RunError(TInt aError)
       
   304 	{
       
   305 	User::RequestComplete(iReport, aError);
       
   306 	return KErrNone;
       
   307 	}
       
   308 
       
   309 //
       
   310 //  
       
   311 //
       
   312 void CIacSettingsParser::RunL()
       
   313 	{
       
   314 	TInt eCode = iStatus.Int();
       
   315 
       
   316 	if(eCode==KErrNone)
       
   317 		{
       
   318 		switch(iState)
       
   319 			{
       
   320 			case EParseSms:
       
   321 				ChangeStateL(ECheckData);
       
   322 				return;
       
   323 
       
   324 			case ECheckData:
       
   325 				if(++iCurrentSettingsCtr < iParsedFieldCollections->Count())
       
   326 					{
       
   327 					CheckMandatoryDataL();
       
   328 					SetActive();
       
   329 					RequestComplete(iStatus, KErrNone);
       
   330 					return;
       
   331 					}
       
   332 				else
       
   333 					{
       
   334 					// Storing parsed data array as a new stream within the CMsvStore
       
   335 					// associated with the Msg Entry
       
   336 					StoreParsedDataL();
       
   337 					iSmsParsed=ETrue;
       
   338 					}
       
   339 				break;
       
   340 
       
   341 			case ESetParsersData:
       
   342 				ChangeStateL(EProcessSms);
       
   343 				return;
       
   344 				
       
   345 			case EProcessSms:
       
   346 				if(eCode == KErrNone)
       
   347 					{
       
   348 					if(++iCurrentSettingsCtr < iParsedFieldCollections->Count())
       
   349 						{
       
   350 						// set connections preferences flag
       
   351 						TSmsType currentType = (*iParsedFieldCollections)[iCurrentSettingsCtr-1]->MessageType();
       
   352 						if(currentType==EBasicIAP || currentType== EExtGprsSettings || currentType== EExtendedIAP)
       
   353 							{
       
   354 							if(iConnectionPreference==EIacpAttempCreateAsFirstRank)
       
   355 								iConnectionPreference =  EIacpAttempCreateAsSecondRank;
       
   356 							else
       
   357 								iConnectionPreference = EIacpDoNotCreatePreference;
       
   358 							}
       
   359 						// If IAP settings are found, store a ref to them
       
   360 						if(currentType== EBasicIAP || currentType== EExtendedIAP)
       
   361 							{
       
   362 							iDefaultIAP = iIspParser->IapEntryId();
       
   363 							// If Mail settings have been found previously, associate mail with IAP
       
   364 							if(iDefaultMail)
       
   365 								{
       
   366 								iMailParser->AssociateIAPWithMailL(iEntry,iDefaultIAP);
       
   367 								}
       
   368 							}
       
   369 						// If Mail settings are found, set a flag
       
   370 						if(currentType== EBasicMail || currentType== EExtendedMail)
       
   371 							{
       
   372 							iDefaultMail = 1;
       
   373 							// If IAP settings have ben found previously, associate mail with IAP
       
   374 							if(iDefaultIAP)
       
   375 								{
       
   376 								iMailParser->AssociateIAPWithMailL(iEntry,iDefaultIAP);
       
   377 								}
       
   378 							}
       
   379 						
       
   380 						
       
   381 						SetParsersDataL();
       
   382 						iState = ESetParsersData;
       
   383 						SetActive();
       
   384 						RequestComplete(iStatus,KErrNone);
       
   385 						return;
       
   386 						}
       
   387 					else
       
   388 						eCode = CompleteMessage();
       
   389 					}
       
   390 					TSmsType currentType = (*iParsedFieldCollections)[iCurrentSettingsCtr-1]->MessageType();
       
   391 					// If IAP settings are found, store a ref to them
       
   392 					if(currentType== EBasicIAP || currentType== EExtendedIAP)
       
   393 						{
       
   394 						iDefaultIAP = iIspParser->IapEntryId();
       
   395 						// If Mail settings have been found previously, associate mail with IAP
       
   396 						if(iDefaultMail)
       
   397 							{
       
   398 							iMailParser->AssociateIAPWithMailL(iEntry,iDefaultIAP);
       
   399 							}
       
   400 						}
       
   401 					// If Mail settings are found, set a flag
       
   402 					if(currentType== EBasicMail || currentType== EExtendedMail)
       
   403 						{
       
   404 						iDefaultMail = 1;
       
   405 						// If IAP settings have ben found previously, associate mail with IAP
       
   406 						if(iDefaultIAP)
       
   407 							{
       
   408 							iMailParser->AssociateIAPWithMailL(iEntry,iDefaultIAP);
       
   409 							}
       
   410 						}
       
   411 				break;
       
   412 			}
       
   413 		}
       
   414 
       
   415 	User::RequestComplete(iReport,eCode);
       
   416 	}
       
   417 
       
   418 //
       
   419 //
       
   420 //
       
   421 TInt CIacSettingsParser::CompleteMessage()
       
   422 	{
       
   423 	TMsvEntry entry = iEntry.Entry();
       
   424 	entry.SetMtmData3(KBIO_MSG_ENTRY_PROCESSED);
       
   425 	TRAPD(error, iEntry.ChangeL(entry));
       
   426 	return error;
       
   427 	}
       
   428 //
       
   429 // Untility function which sends completion signal to client active object
       
   430 //
       
   431 void CIacSettingsParser::RequestComplete(TRequestStatus& aStatus,TInt aCompletion)
       
   432 	{
       
   433 	TRequestStatus* statusPtr=&aStatus;
       
   434 	User::RequestComplete(statusPtr,aCompletion);
       
   435 	}
       
   436 //
       
   437 //
       
   438 //Data structure "LeftToken:RightToken<LF>"
       
   439 //
       
   440 void CIacSettingsParser::ParseSmsL()
       
   441 	{
       
   442 	iEntryId= iEntry.Entry().Id(); //store id of Bio Msg entry if changed 
       
   443 	__ASSERT_DEBUG(iEntry.Entry().iMtm==KUidSmartMessageMtm, User::Panic(KIACP,EIacpInvalidEntry));
       
   444 	__ASSERT_DEBUG(iEntry.Entry().iBioType==KUidMsvBIOInternetAccessPointMessageType, User::Panic(KIACP,EIacpInvalidEntry));
       
   445 	__ASSERT_DEBUG(iEntry.Entry().Failed()== 0 , User::Panic(KIACP,EIacpInvalidEntry));
       
   446 
       
   447 	iParsedFieldArray->ResetAndDestroy();
       
   448 	//if SMS allready parsed no need to parse again, restore the parsed data
       
   449 	iEntry.Entry().MtmData3() == KBIO_MSG_ENTRY_PARSED ? iSmsParsed = ETrue : iSmsParsed = EFalse;
       
   450 	if(iSmsParsed)
       
   451 		{
       
   452 		RestoreParsedDataL();
       
   453 		return;
       
   454 		}
       
   455 
       
   456 	// default to create 1st ranking Connection preference ntry in CommDb if required
       
   457 	iConnectionPreference = EIacpAttempCreateAsFirstRank;
       
   458 	
       
   459 	DoParseL();
       
   460 	}
       
   461 //
       
   462 // append sms data field/value to array,
       
   463 // set iSmsType to EBasicMail orEBasicIAP
       
   464 //
       
   465 void CIacSettingsParser::DoParseL()
       
   466 	{
       
   467 	TBuf<256> tempBuf;
       
   468 	// Set extraction mark at first character
       
   469     iSms.SkipSpaceAndMark();
       
   470 	// might or might not have header?
       
   471 	if(iSms.Peek() == KCharSlash)
       
   472 		{
       
   473 		// Check first line is <header>
       
   474 		iSms.SkipCharacters();
       
   475 		if (iSms.MarkedToken() != KSmsHeader)
       
   476 			{
       
   477 			User::Leave(KBspInvalidMessage);
       
   478 			}
       
   479        
       
   480 		tempBuf=iSms.MarkedToken(); //save a copy of header field
       
   481 		//appending header field to array
       
   482 		CParsedField* headerField= new (ELeave) CParsedField;
       
   483 		CleanupStack::PushL(headerField);
       
   484 		SetDataFieldsL(*headerField, SMS_HEADER,tempBuf,ETrue);
       
   485 		iParsedFieldArray->AppendL(headerField);
       
   486 		iSms.Inc();
       
   487 		CleanupStack::Pop();//headerField (No need to delete the CParsedField object, since it's now owned by the array)
       
   488 		}
       
   489 
       
   490 	// might or might not have password?
       
   491 	// if line does not contain ':' then we consider it as password
       
   492 	// if line contains ':' then we check the left token for any valid field names,
       
   493 	// a line with valid field name is not considered as password.
       
   494     TBool PwdWithColumn=EFalse;
       
   495 	iSms.SkipSpaceAndMark();
       
   496 	while ( iSms.Peek()!= '\n'  && !iSms.Eos())
       
   497 		iSms.Inc();
       
   498 	
       
   499 	TLex lex(iSms.MarkedToken());
       
   500 	while (lex.Peek() != ':' && lex.Peek() != '\n' && !lex.Eos())
       
   501 		lex.Inc();
       
   502 	
       
   503 	if(lex.Peek() == ':')
       
   504 		{
       
   505 		TPtrC LeftToken = lex.MarkedToken(); // extract left token
       
   506 		if(!IsValidToken(LeftToken))
       
   507 			PwdWithColumn=ETrue;//we consider it as password containing ':'
       
   508 		else
       
   509 			iSms.Inc(-iSms.MarkedToken().Length());	//reset pos. (password is not included in SMS message)
       
   510 		}
       
   511 
       
   512 
       
   513 	if(lex.Peek() != ':' || PwdWithColumn )
       
   514 		{
       
   515 		if (iSms.TokenLength() >255)
       
   516 			User::Leave(KErrOverflow); //leave if there is a ridiculously long password even though Nokia Smart Messaging Spec 3 allows password of length 0-infinity
       
   517 		tempBuf = iSms.MarkedToken(); //save a copy of password field 
       
   518 		//appending password field to array
       
   519 		CParsedField* passwordField = new (ELeave) CParsedField();
       
   520 		CleanupStack::PushL(passwordField);
       
   521 		SetDataFieldsL(*passwordField, SMS_PASSWORD,tempBuf,ETrue);
       
   522 		iParsedFieldArray->AppendL(passwordField);
       
   523 		CleanupStack::Pop();//passwordField
       
   524 		}
       
   525 
       
   526 	//start parsing body of message
       
   527 	while (!iSms.Eos())
       
   528 		{
       
   529 		iSms.SkipSpaceAndMark();
       
   530 		while (iSms.Peek() != '\n'  && !iSms.Eos())
       
   531 			iSms.Inc();
       
   532 		
       
   533 		TLex lex(iSms.MarkedToken());
       
   534 		// extract Line i.e "LeftToken:RightToken<LF>", then asign to TLex object
       
   535 		while (lex.Peek() != ':' && lex.Peek() != '\n' && !lex.Eos())
       
   536 			lex.Inc();
       
   537 		
       
   538 		//we are only interested in lines containing a colon delimeter ':'
       
   539 		// other text lines are ignored i.e "Welcome !<LF>"
       
   540 		if(lex.Peek() == ':')
       
   541 			{
       
   542 			if (lex.TokenLength() > 0 ) // if valid potential token
       
   543 				{
       
   544 				TPtrC LeftToken = lex.MarkedToken() ;        // extract left token
       
   545 				if(IsValidToken(LeftToken))
       
   546 					{					 
       
   547 					tempBuf= LeftToken; //save of copy of left token
       
   548 					// get the right token
       
   549 					lex.Inc();  // go past the ':'
       
   550 					
       
   551 					//Check if we have a case of script message, then deal with it.
       
   552 					//--start script data parsing...
       
   553 					TInt TokenLength=0; 
       
   554 					TInt pos=0;
       
   555 					TBool FoundScriptData=EFalse;
       
   556 					
       
   557 					if(LeftToken.CompareF(SMS_SCRIPT_DATA) ==0)
       
   558 						{
       
   559 						TokenLength= SMS_SCRIPT_DATA_LEN;
       
   560 						
       
   561 						if(KErrNotFound ==(pos=iSmsBuf->Find(SMS_SCRIPT_DATA)))
       
   562 							User::Leave(KIacpMandatoryDataNotSet);
       
   563 						
       
   564 						FoundScriptData=ETrue;
       
   565 						}
       
   566 					else if(LeftToken.CompareF(SMS_SCRIPT_ADD) ==0)
       
   567 						{
       
   568 						TokenLength= SMS_SCRIPT_ADD_LEN;
       
   569 						
       
   570 						if(KErrNotFound ==(pos=iSmsBuf->Find(SMS_SCRIPT_ADD)))
       
   571 							User::Leave(KIacpMandatoryDataNotSet);
       
   572 
       
   573 						FoundScriptData=ETrue;
       
   574 						}
       
   575 
       
   576 					//if found script data extract and append the data to the array then exit the while loop
       
   577 					if(FoundScriptData)
       
   578 						{
       
   579 						TPtrC PtrScript= iSmsBuf->Right(iSmsBuf->Length()-(pos+TokenLength+1));//add 1 for ':'
       
   580 
       
   581 						CParsedField* parsedField = new (ELeave) CParsedField();						
       
   582 						CleanupStack::PushL(parsedField);
       
   583 						SetDataFieldsL(*parsedField, tempBuf, PtrScript,isMandatoryData(tempBuf));
       
   584 						iParsedFieldArray->AppendL(parsedField);
       
   585 						CleanupStack::Pop();//parsedField
       
   586 						break;
       
   587 						}
       
   588 					//--...end script data parsing
       
   589 
       
   590 					lex.SkipSpaceAndMark();
       
   591 					while (lex.Peek() != '\n' && !lex.Eos())
       
   592 						lex.Inc();
       
   593 					
       
   594 					//appending parsedField to array
       
   595 					CParsedField* parsedField = new (ELeave) CParsedField();
       
   596 					CleanupStack::PushL(parsedField);
       
   597 					SetDataFieldsL(*parsedField, tempBuf, lex.MarkedToken(),isMandatoryData(tempBuf));
       
   598 					iParsedFieldArray->AppendL(parsedField);
       
   599 					CleanupStack::Pop();//parsedField
       
   600 					}
       
   601 				}
       
   602 			}
       
   603 
       
   604 		iSms.Inc();
       
   605 		}
       
   606 	PopulateFieldCollectionsL();
       
   607 	}
       
   608 
       
   609 //
       
   610 // Divide parsed field array into individual groups of settings
       
   611 //
       
   612 void CIacSettingsParser::PopulateFieldCollectionsL()
       
   613 	{
       
   614 	TSmsType currentSmsType;
       
   615 	iSmsType = ESmsTypeUndefined;
       
   616 	iParsedFieldCollections->ResetAndDestroy();
       
   617 	CParsedFieldCollection* currentParsedFieldCollection=NULL;
       
   618 
       
   619 	TInt count = iParsedFieldArray->Count();
       
   620 	for(TInt loop = 0; loop < count; loop++)
       
   621 		{
       
   622 		CParsedField& field = *(*iParsedFieldArray)[loop];
       
   623 		if(SetBioMsgTypeL(field.FieldName(),currentSmsType))
       
   624 			{
       
   625 			// append previous if it exists
       
   626 			if(currentParsedFieldCollection)
       
   627 				{
       
   628 				iParsedFieldCollections->AppendL(currentParsedFieldCollection);
       
   629 				CleanupStack::Pop();	// currentParsedFieldCollection
       
   630 				}
       
   631 
       
   632 			currentParsedFieldCollection = new(ELeave)CParsedFieldCollection(currentSmsType);
       
   633 			CleanupStack::PushL(currentParsedFieldCollection);
       
   634 			}
       
   635 
       
   636 		if(currentParsedFieldCollection)
       
   637 			currentParsedFieldCollection->AppendL(&field);
       
   638 		}
       
   639 	// add last collection
       
   640 	if(currentParsedFieldCollection)
       
   641 		{
       
   642 		iParsedFieldCollections->AppendL(currentParsedFieldCollection);
       
   643 		CleanupStack::Pop();	// currentParsedFieldCollection
       
   644 		}
       
   645 	else
       
   646 		User::Leave(KIacpMandatoryDataNotSet);
       
   647 	}
       
   648 
       
   649 //
       
   650 //
       
   651 //
       
   652 void CIacSettingsParser::GetPtrToScriptDataL(HBufC*& aPtrScriptData)
       
   653 	{
       
   654 	HBufC* PtrScript= iSmsBuf;
       
   655 	TInt loc = iSmsBuf->Find(SMS_SCRIPT_DATA);
       
   656 	PtrScript+=loc;
       
   657 	aPtrScriptData =PtrScript;
       
   658 	}
       
   659 
       
   660 //
       
   661 //
       
   662 //
       
   663 TBool CIacSettingsParser::SetBioMsgTypeL(const TDesC& aLeftToken, TSmsType& aType)
       
   664 	{
       
   665 	// basic internet
       
   666 	if(aLeftToken.CompareF(KINTERNET) == 0 )
       
   667 		{
       
   668 		aType = IsSmsExtendedIAP() ? EExtendedIAP : EBasicIAP;
       
   669 
       
   670 		if(iSmsType == ESmsTypeUndefined)
       
   671 			iSmsType = aType;
       
   672 		else if(iSmsType == EExtGprsSettings)
       
   673 			iSmsType = EExtGprsIAP;
       
   674 		else if(iSmsType == EBasicMail)
       
   675 			iSmsType = EBasicMailIAP;
       
   676 		else if(iSmsType == EBasicMailIAP)
       
   677 			iSmsType = EBasicMailIAP;
       
   678 		else
       
   679 			iSmsType = ESmsMixedContent;
       
   680 		}
       
   681 	// gprs
       
   682 	else if(aLeftToken.CompareF(KGPRS) == 0 )
       
   683 		{
       
   684 		if(iSmsType == ESmsTypeUndefined)
       
   685 			iSmsType = EExtGprsSettings;
       
   686 		else if(iSmsType == EBasicMail)
       
   687 			iSmsType = EExtGprsMail;
       
   688 		else if(iSmsType == EBasicIAP)
       
   689 			iSmsType = EExtGprsIAP;
       
   690 		else if(iSmsType == EBasicMailIAP)
       
   691 			iSmsType = EExtGprsIAPMail;
       
   692 		else
       
   693 			iSmsType = ESmsMixedContent;
       
   694 
       
   695 		aType = EExtGprsSettings;
       
   696 		}
       
   697 	// basic email
       
   698 	else if(aLeftToken.CompareF(KMAIL) == 0 )
       
   699 		{
       
   700 		if(iSmsType == ESmsTypeUndefined)
       
   701 			iSmsType = EBasicMail;
       
   702 		else if(iSmsType == EExtGprsSettings)
       
   703 			iSmsType = EExtGprsMail;
       
   704 		else if(iSmsType == EBasicIAP)
       
   705 			iSmsType = EBasicMailIAP;
       
   706 		else if(iSmsType == EExtGprsIAP)
       
   707 			iSmsType = EExtGprsIAPMail;
       
   708 		else if(iSmsType == EBasicMailIAP)
       
   709 			iSmsType = EBasicMailIAP;
       
   710 		else
       
   711 			iSmsType = ESmsMixedContent;
       
   712 
       
   713 		aType = EBasicMail;
       
   714 		}
       
   715 	// script settings
       
   716 	else if(aLeftToken.CompareF(KSCRIPT) == 0 ) //Script Settings
       
   717 		{
       
   718 		if(iSmsType == ESmsTypeUndefined)
       
   719 			aType = iSmsType = EExtScriptSettings;
       
   720 		else
       
   721 			iSmsType = ESmsMixedContent;
       
   722 		}
       
   723 	// SMS settings
       
   724 	else if(aLeftToken.CompareF(KSMS) == 0 ) //SMS Settings
       
   725 		{
       
   726 		if(iSmsType == ESmsTypeUndefined)
       
   727 			aType = iSmsType = EExtSmsSettings;
       
   728 		else
       
   729 			iSmsType = ESmsMixedContent;
       
   730 		}
       
   731 	// voice telephone settings
       
   732 	else if(aLeftToken.CompareF(KTELEPHONE) == 0 ) //Telephone Settings (voice mailbox number)
       
   733 		{
       
   734 		if(iSmsType == ESmsTypeUndefined)
       
   735 			aType = iSmsType = EExtTelephoneSettings;
       
   736 		else
       
   737 			iSmsType = ESmsMixedContent;
       
   738 		}
       
   739 	// WWW Hotlist items
       
   740 	else if(aLeftToken.CompareF(KWWWHotlist) == 0 ) 
       
   741 		{
       
   742 		if(iSmsType == ESmsTypeUndefined)
       
   743 			aType = iSmsType = EExtWWWHostListItem;
       
   744 		else if(iSmsType == EExtWWWHostListItem)
       
   745 			return EFalse;
       
   746 		else
       
   747 			iSmsType = ESmsMixedContent;
       
   748 		}
       
   749 	else 
       
   750 		return EFalse;
       
   751 
       
   752 	return ETrue;
       
   753 	}
       
   754 //
       
   755 //
       
   756 //
       
   757 TBool CIacSettingsParser::IsSmsExtendedIAP()
       
   758 	{
       
   759 	TInt count = iParsedFieldArray->Count();
       
   760 	for(TInt loop = 0; loop < count; loop++)
       
   761 		{
       
   762 		TPtrC fieldName = (*iParsedFieldArray)[loop]->FieldName();
       
   763 		if(fieldName.Length()==4)
       
   764 			{
       
   765 			if(fieldName.CompareF(SMS_PROXY_EXCEPTIONS)   == 0 || fieldName.CompareF(SMS_PROXY_PORT_NUMBER)   == 0 ||
       
   766 				fieldName.CompareF(SMS_PROXY_SERVER_NAME) == 0 || fieldName.CompareF(SMS_LOGIN_CUSTOMISATION) == 0 ||
       
   767 				fieldName.CompareF(SMS_ENABLE_SW_COMP)       == 0 || fieldName.CompareF(SMS_SECURE_PROXY)        == 0 ||
       
   768 				fieldName.CompareF(SMS_SECURE_PORT) == 0 )
       
   769 					{
       
   770 					return ETrue;
       
   771 					}
       
   772 			}
       
   773 		}
       
   774 	return EFalse;
       
   775 	}
       
   776 //
       
   777 //
       
   778 //
       
   779 TBool CIacSettingsParser::isMandatoryData(const TDesC& aFieldName)
       
   780 	{
       
   781 	__ASSERT_DEBUG(aFieldName.Length() > 0 ,User::Panic(KIACP,EIacpEmptyBuffer));
       
   782 
       
   783 	if(aFieldName.Length() == 5)
       
   784 		{
       
   785 		if(aFieldName.CompareF(SMS_ISP_M_NAME)   == 0 || aFieldName.CompareF(SMS_ISP_I_NAME) ==0 ||
       
   786 		  (aFieldName.CompareF(GPRSS_PDP_TYPE))  )
       
   787 			return ETrue;
       
   788 		}
       
   789 	else if(aFieldName.Length() == 4)
       
   790 		{	
       
   791 		if(aFieldName.CompareF(SMS_MAILBOX_NAME)   == 0 || aFieldName.CompareF(SMS_MAILBOX_PASS) == 0 ||
       
   792 		   aFieldName.CompareF(SMS_RECEIVING_HOST) == 0 || aFieldName.CompareF(SMS_SENDING_HOST) == 0 ||
       
   793 		   aFieldName.CompareF(SMS_USER_EMAIL_ADDR)== 0 || aFieldName.CompareF(SMS_MAIL_PROTOCOL)== 0 ||
       
   794 		   aFieldName.CompareF(GPRSS_APN)          == 0 || aFieldName.CompareF(GPRSS_PDP_ADDRESS) == 0)
       
   795 			return ETrue;
       
   796 		}
       
   797 
       
   798 	return EFalse;
       
   799 	}
       
   800 
       
   801 TBool CIacSettingsParser::IsValidToken(const TDesC& aToken)
       
   802 	{
       
   803 	__ASSERT_DEBUG(aToken.Length() > 0 ,User::Panic(KIACP,EIacpEmptyBuffer));
       
   804 
       
   805 	// case EBasicMail
       
   806 	if(aToken.Length() == 5)
       
   807 		{
       
   808 		if (aToken.CompareF(SMS_ISP_M_NAME)    ==0 ||aToken.CompareF(SMS_HOTLIST_ITEM_NAME) == 0)
       
   809 			return ETrue;
       
   810 		}
       
   811 	else if(aToken.Length() == 4)
       
   812 		{
       
   813 		if (aToken.CompareF(SMS_MAILBOX_NAME)    ==0 || aToken.CompareF(SMS_MAILBOX_PASS)   ==0 ||
       
   814 			aToken.CompareF(SMS_USER_EMAIL_ADDR) ==0 || aToken.CompareF(SMS_RECEIVING_HOST) ==0 ||
       
   815 			aToken.CompareF(SMS_SENDING_HOST)    ==0 || aToken.CompareF(SMS_MAIL_PROTOCOL)  ==0 ||
       
   816 			aToken.CompareF(SMS_FOLDER_PATH)==0 ||
       
   817 			aToken.CompareF(SMS_HOTLIST_ITEM_URL)  ==0
       
   818 			|| aToken.CompareF(SMS_HOTLIST_AUTOSELECT_IAP)  ==0 || aToken.CompareF(SMS_HOTLIST_ACCESS_POINT)  ==0
       
   819 			|| aToken.CompareF(SMS_HOTLIST_FOLDER)  ==0)
       
   820 			return ETrue;
       
   821 		}
       
   822 
       
   823 	//case EBasicIAP	
       
   824 	if(aToken.Length() == 5)
       
   825 		{
       
   826 		if (aToken.CompareF(SMS_ISP_I_NAME)		         ==0 || aToken.CompareF(SMS_IP_NAME_SERVER1) ==0 ||
       
   827 			aToken.CompareF(SMS_IP_NAME_SERVER2)==0) 
       
   828 			return ETrue;
       
   829 		}
       
   830 	else if(aToken.Length() == 4)
       
   831 		{
       
   832 		if (aToken.CompareF(SMS_INIT_STRING)		 ==0 ||
       
   833 			aToken.CompareF(SMS_DEFAULT_TEL_NUM)  ==0 || aToken.CompareF(SMS_LOGIN_NAME) ==0 ||
       
   834 			aToken.CompareF(SMS_PROMPT_FOR_LOGIN) ==0 || aToken.CompareF(SMS_LOGIN_PASS) ==0 ||
       
   835 			aToken.CompareF(SMS_IP_NETMASK) ==0 || aToken.CompareF(SMS_IP_GATEWAY) ==0)
       
   836 			return ETrue;
       
   837 		}
       
   838 	else if(aToken.Length() == 3)
       
   839 		{
       
   840 		if(aToken.CompareF(SMS_IP_ADDR) ==0)
       
   841 			return ETrue;
       
   842 		}
       
   843 
       
   844 	//caes EExtendedIAP
       
   845 	if(aToken.Length() == 4)
       
   846 		{
       
   847 		if (aToken.CompareF(SMS_PROXY_EXCEPTIONS) ==0 || aToken.CompareF(SMS_PROXY_PORT_NUMBER)  ==0 ||
       
   848 			aToken.CompareF(SMS_PROXY_SERVER_NAME)==0 || aToken.CompareF(SMS_LOGIN_CUSTOMISATION)==0 ||
       
   849 			aToken.CompareF(SMS_ENABLE_SW_COMP)	  ==0 || aToken.CompareF(SMS_SECURE_PROXY)		 ==0 ||
       
   850 			aToken.CompareF(SMS_SECURE_PORT)==0)
       
   851 			return ETrue;
       
   852 		}
       
   853 
       
   854 	// GPRS settings
       
   855 	if(aToken.Length() == 4)
       
   856 		{
       
   857 		if  (aToken.CompareF(GPRSS_APN)==0              || aToken.CompareF(GPRSS_PDP_ADDRESS)==0 ||
       
   858 			 aToken.CompareF(GPRSS_IF_NAME)==0          || aToken.CompareF(GPRSS_LOGIN_NAME)==0  ||
       
   859 			 aToken.CompareF(GPRSS_PROMPT_FOR_LOGIN)==0 || aToken.CompareF(GPRSS_LOGIN_PASS)==0  ||
       
   860 			 aToken.CompareF(GPRSS_IP_ADDR)==0          || aToken.CompareF(GPRSS_DNS_FROM_SERVER)==0  ||		 
       
   861 			 aToken.CompareF(GPRSS_IP_NETMASK)==0       
       
   862 			 )
       
   863 			 return ETrue;
       
   864 		}
       
   865 	else if (aToken.Length() == 5)
       
   866 		{
       
   867 		if  (aToken.CompareF(GPRSS_PDP_TYPE)==0                || aToken.CompareF(GPRSS_DNS_FROM_SERVER)==0  ||
       
   868 			 aToken.CompareF(GPRSS_IP_NAME_SERVER1)==0         || aToken.CompareF(GPRSS_IP_NAME_SERVER2)==0  ||
       
   869 			 aToken.CompareF(GPRSS_NAME)==0 
       
   870 			)
       
   871 			return ETrue;
       
   872 		}
       
   873 	else if(aToken.Length() == 3)
       
   874 		{
       
   875 		if  (aToken.CompareF(GPRSS_IP_ADDR)==0)
       
   876 			return ETrue;
       
   877 		}
       
   878 
       
   879 	//case EExtScriptSettings
       
   880 	if(aToken.Length() == 5)
       
   881 		{
       
   882 		if(aToken.CompareF(SMS_SCRIPT_NAME) ==0 || aToken.CompareF(SMS_SCRIPT_TYPE) ==0 ||
       
   883 		   aToken.CompareF(SMS_SCRIPT_DATA) ==0 )
       
   884 			return ETrue;
       
   885 		}
       
   886 	else if(aToken.Length() == 4)
       
   887 		{
       
   888 		if(aToken.CompareF(SMS_SCRIPT_ADD) ==0)
       
   889 			return ETrue;
       
   890 		}
       
   891 
       
   892 
       
   893 	//case EExtSmsSettings
       
   894 	if(aToken.Length() == 5)
       
   895 		{
       
   896 		if(aToken.CompareF(SMS_SERVICE_CENTER_NAME) ==0 )
       
   897 			return ETrue;
       
   898 		}
       
   899 	else if(aToken.Length() == 4)
       
   900 		{
       
   901 		if(aToken.CompareF(SMS_SERVICE_CENTER_ADDRESS) ==0)
       
   902 			return ETrue;
       
   903 		}
       
   904 
       
   905 
       
   906 	//case EExtTelephoneSettings
       
   907 	if(aToken.Length() == 4)
       
   908 		{
       
   909 		if(aToken.CompareF(SMS_TEL_VOICE_MAILBOX_NUM) ==0)
       
   910 			return ETrue;
       
   911 		}
       
   912 
       
   913 
       
   914 	return EFalse; //Token not valid
       
   915 	}
       
   916 //
       
   917 //
       
   918 //
       
   919 void CIacSettingsParser::SetParsersDataL()
       
   920 	{	
       
   921 	CParsedFieldCollection& parsedFields = *(*iParsedFieldCollections)[iCurrentSettingsCtr];
       
   922 	TSmsType dataType = parsedFields.MessageType();
       
   923 	switch(dataType)
       
   924 		{
       
   925 		case EBasicMail:
       
   926 			if (iMailParser)
       
   927 				{
       
   928 				delete iMailParser;
       
   929 				iMailParser =NULL;
       
   930 				}
       
   931 			iMailParser = CMailParser::NewL();
       
   932 			iMailParser->ParseL(parsedFields);
       
   933 			break;
       
   934 		case EBasicIAP:
       
   935 			if (iIspParser)
       
   936 				{
       
   937 				delete iIspParser;
       
   938 				iIspParser =NULL;
       
   939 				}
       
   940 			iIspParser = CIspParser::NewL(EBasicIAP);
       
   941 			iIspParser->ParseL(parsedFields);
       
   942 			break;
       
   943 
       
   944 		case EExtendedIAP:
       
   945 			if (iIspParser)
       
   946 				{
       
   947 				delete iIspParser;
       
   948 				iIspParser =NULL;
       
   949 				}
       
   950 			iIspParser = CIspParser::NewL(EExtendedIAP);
       
   951 			iIspParser->ParseL(parsedFields);
       
   952 			break;
       
   953 
       
   954 		case EExtScriptSettings:
       
   955 			if (iScriptParser)
       
   956 				{
       
   957 				delete iScriptParser;
       
   958 				iScriptParser =NULL;
       
   959 				}
       
   960 			iScriptParser = CScriptParser::NewL();
       
   961 			iScriptParser->ParseL(parsedFields);
       
   962 			break;
       
   963 		case EExtSmsSettings:
       
   964 			if (iSmsParser)
       
   965 				{
       
   966 				delete iSmsParser;
       
   967 				iSmsParser =NULL;
       
   968 				}
       
   969 			iSmsParser = CSmsParser::NewL();
       
   970 			iSmsParser->ParseL(parsedFields);
       
   971 
       
   972 			break;
       
   973 		case EExtTelephoneSettings:
       
   974 			if (iTelVoiceMailboxParser)
       
   975 				{
       
   976 				delete iTelVoiceMailboxParser;
       
   977 				iTelVoiceMailboxParser =NULL;
       
   978 				}
       
   979 			iTelVoiceMailboxParser = new(ELeave)CTelVoiceMailboxParser();
       
   980 			iTelVoiceMailboxParser->ParseL(parsedFields);
       
   981 			break;
       
   982 		case EExtGprsSettings:
       
   983 			if(iGprsParser)
       
   984 				{
       
   985 				delete iGprsParser;
       
   986 				iGprsParser = NULL;
       
   987 				}
       
   988 			iGprsParser = CGprsParser::NewL();
       
   989 			iGprsParser->ParseL(parsedFields);
       
   990 			break;
       
   991 		case EExtWWWHostListItem:
       
   992 			if (iWWWHotlistParser)
       
   993 				{
       
   994 				delete iWWWHotlistParser;
       
   995 				iWWWHotlistParser =NULL;
       
   996 				}
       
   997 			iWWWHotlistParser = CWWWHotlistParser::NewL(iFs);
       
   998 			iWWWHotlistParser->ParseL(parsedFields);
       
   999 			break;
       
  1000 		default:
       
  1001 			break;
       
  1002 		}
       
  1003 	}
       
  1004 
       
  1005 //
       
  1006 //
       
  1007 //
       
  1008 void CIacSettingsParser::SetDataFieldsL(CParsedField& aParsedField, const TDesC& aName, const TDesC& aValue, TBool aBool)
       
  1009 	{
       
  1010 	aParsedField.SetFieldNameL(aName);
       
  1011 	aParsedField.SetFieldValueL(aValue);
       
  1012 	aParsedField.SetMandatoryField(aBool);
       
  1013 	}
       
  1014 //
       
  1015 //
       
  1016 //
       
  1017 CArrayPtrSeg<CParsedField>& CIacSettingsParser::ParsedFieldArray() const
       
  1018 	{
       
  1019 	return *iParsedFieldArray;
       
  1020 	}
       
  1021 
       
  1022 //
       
  1023 //
       
  1024 //
       
  1025 void CIacSettingsParser::SetFieldValueL(const TDesC& aFieldName, const TDesC& aFieldValue)
       
  1026 	{
       
  1027 	TInt count = iParsedFieldArray->Count();
       
  1028 	for ( TInt i=0; i < count; i++ )
       
  1029 		{
       
  1030 		if(iParsedFieldArray->At(i)->FieldName().CompareF(aFieldName)==0)
       
  1031 			{
       
  1032 			iParsedFieldArray->At(i)->SetFieldValueL(aFieldValue);
       
  1033 			return;
       
  1034 			}
       
  1035 		}
       
  1036 	}
       
  1037 //
       
  1038 //
       
  1039 //
       
  1040 TBool CIacSettingsParser::GetMandatoryField(const TDesC& aFieldName) const
       
  1041 	{
       
  1042 	TInt count = iParsedFieldArray->Count();
       
  1043 	for ( TInt i=0; i < count; i++ )
       
  1044 		{
       
  1045 		if(iParsedFieldArray->At(i)->FieldName().CompareF(aFieldName)==0)
       
  1046 			return iParsedFieldArray->At(i)->MandatoryField();
       
  1047 		}
       
  1048 
       
  1049 	return EFalse;
       
  1050 	}
       
  1051 //
       
  1052 // store parsed data array as a stream store of SMS entry
       
  1053 //
       
  1054 void CIacSettingsParser::StoreParsedDataL()
       
  1055 	{
       
  1056 	iEntry.SetEntryL(iEntryId);
       
  1057 	CMsvStore* store=iEntry.EditStoreL();
       
  1058 	CleanupStack::PushL(store);
       
  1059 	StoreL(*store);
       
  1060 	CleanupStack::PopAndDestroy();//store
       
  1061 
       
  1062 	// indicate that Bio Msg has been parsed OK and Store has been created.
       
  1063 	iEntry.SetEntryL(iEntryId);
       
  1064 	TMsvEntry entry= iEntry.Entry();
       
  1065 	entry.SetMtmData3(KBIO_MSG_ENTRY_PARSED);
       
  1066 	// store iSmsType
       
  1067 	entry.SetMtmData1(iSmsType);
       
  1068 	//set SMS subject and Sender
       
  1069 	iEntry.ChangeL(entry);
       
  1070 	}
       
  1071 
       
  1072 
       
  1073 //
       
  1074 //
       
  1075 //
       
  1076 CParsedFieldCollection::CParsedFieldCollection(CIacSettingsParser::TSmsType aSmsType)
       
  1077 : CArrayPtrSeg<CParsedField>(8), iSmsType(aSmsType)
       
  1078 	{
       
  1079 	iCanCommit = ETrue;
       
  1080 	}
       
  1081 
       
  1082 TPtrC CParsedFieldCollection::GetFieldValue(const TDesC& aFieldName) const
       
  1083 	{
       
  1084 	const TInt count = Count();
       
  1085 
       
  1086 	for ( TInt i=0; i < count; i++ )
       
  1087 		{
       
  1088 		if(At(i)->FieldName().CompareF(aFieldName)==0)
       
  1089 			return At(i)->FieldValue();
       
  1090 		}
       
  1091 	return TPtrC();
       
  1092 	}
       
  1093 
       
  1094 TInt CParsedFieldCollection::GetFieldValueAndLength(const TDesC& aFieldName, TPtrC& aValue) const
       
  1095 	{
       
  1096 	aValue.Set(GetFieldValue(aFieldName));
       
  1097 	return aValue.Length();
       
  1098 	}
       
  1099 
       
  1100 void CParsedFieldCollection::GetTBoolL(const TDesC& aDes, TBool& aBool) const
       
  1101 	{
       
  1102 	__ASSERT_DEBUG(aDes.Length() > 0 ,User::Panic(KIACP,EIacpEmptyBuffer));
       
  1103 
       
  1104  	if ((aDes.Left(1).CompareF(KIacpLowerT)==0) || (aDes.Left(1).CompareF(KIacpLowerY)==0))
       
  1105 		aBool= ETrue;
       
  1106 	else if ((aDes.Left(1).CompareF(KIacpLowerF)==0) || (aDes.Left(1).CompareF(KIacpLowerN)==0))
       
  1107 		aBool= EFalse;
       
  1108 	else
       
  1109 		User::Leave(KIacpErrRightToken);
       
  1110 	}
       
  1111 
       
  1112 //
       
  1113 //
       
  1114 //
       
  1115 void CParsedFieldCollection::GetTUint32NumL(const TDesC& aDes, TUint32& aTUint32Value) const
       
  1116 	{
       
  1117 	__ASSERT_DEBUG(aDes.Length() > 0 ,User::Panic(KIACP,EIacpEmptyBuffer));
       
  1118 	
       
  1119 	TLex lex(aDes);
       
  1120     if (lex.Val(aTUint32Value,EDecimal) != KErrNone)
       
  1121 		User::Leave(KIacpErrRightToken);
       
  1122 	}
       
  1123 
       
  1124 TBool CParsedFieldCollection::FieldNameExists(const TDesC& aFieldName) const
       
  1125 	{
       
  1126 	const TInt count = Count();
       
  1127 
       
  1128 	for ( TInt i=0; i < count; i++ )
       
  1129 		{
       
  1130 		if(At(i)->FieldName().CompareF(aFieldName)==0)
       
  1131 			{
       
  1132 			return ETrue;
       
  1133 			}
       
  1134 		}
       
  1135 	return EFalse;
       
  1136 	}