messagingfw/biomsgfw/IACPSRC/IMP.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 Mail Settings Parser
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <msvids.h>   // KMsvRootIndexEntryId
       
    19 #include <msventry.h>
       
    20 #include <msvruids.h>
       
    21 #include <smtpset.h>
       
    22 #include <pop3set.h>
       
    23 #include <imapset.h>
       
    24 #include <cemailaccounts.h>
       
    25 //
       
    26 #include "BSP.H"
       
    27 #include "IACP.H"
       
    28 #include "IMP.H"
       
    29 #include "IACPDEF.H"
       
    30 #include "IACPERR.H"
       
    31 #include <iapprefs.h>
       
    32 
       
    33 _LIT(KIacpOldImapName, "-Old-IMAP");
       
    34 _LIT(KIacpOldPop3Name, "-Old-POP");
       
    35 
       
    36 #include <commdb.h>
       
    37 #include <ipaddr.h>
       
    38 
       
    39 //
       
    40 // Constructor
       
    41 //
       
    42 CMailParser::CMailParser()
       
    43 	{
       
    44 	}
       
    45 
       
    46 //
       
    47 // Factory fns
       
    48 //
       
    49 CMailParser* CMailParser::NewLC()
       
    50 	{
       
    51 	CMailParser* self=new (ELeave) CMailParser();
       
    52 	CleanupStack::PushL(self);
       
    53 	self->ConstructL();
       
    54 	return self;
       
    55 	}
       
    56 
       
    57 CMailParser* CMailParser::NewL()
       
    58 	{
       
    59 	CMailParser* self=CMailParser::NewLC();
       
    60 	CleanupStack::Pop();
       
    61 	return self;
       
    62 	}
       
    63 
       
    64 //
       
    65 // 2nd stage of construction
       
    66 //
       
    67 void CMailParser::ConstructL()
       
    68 	{
       
    69 	// --- Create the blank settings objects ---
       
    70 	iSmtpSettings=new(ELeave) CImSmtpSettings();
       
    71 	iPop3Settings=new(ELeave) CImPop3Settings();
       
    72 	iImap4Settings=new(ELeave) CImImap4Settings();
       
    73 	
       
    74 	// email account creator
       
    75 	iEmailAccounts = CEmailAccounts::NewL();
       
    76 	
       
    77 	// IAP preferences
       
    78 	iEmailPreferences = CImIAPPreferences::NewLC();
       
    79 	CleanupStack::Pop(iEmailPreferences);
       
    80 	iSmtpPreferences = CImIAPPreferences::NewLC();
       
    81 	CleanupStack::Pop(iSmtpPreferences);
       
    82 
       
    83 	// set defaults	
       
    84 	iEmailAccounts->PopulateDefaultPopSettingsL(*iPop3Settings, *iEmailPreferences);
       
    85 	iEmailAccounts->PopulateDefaultSmtpSettingsL(*iSmtpSettings, *iSmtpPreferences); 											
       
    86 	iEmailAccounts->PopulateDefaultImapSettingsL(*iImap4Settings, *iEmailPreferences);
       
    87 	}
       
    88 
       
    89 //
       
    90 // Destruction
       
    91 //
       
    92 CMailParser::~CMailParser()
       
    93 	{
       
    94 	delete iSmtpSettings;
       
    95 	delete iPop3Settings;
       
    96 	delete iImap4Settings;
       
    97 	delete iEmailAccounts;
       
    98 	delete iEmailPreferences;
       
    99 	delete iSmtpPreferences;
       
   100 	}
       
   101 
       
   102 void CMailParser::CheckMandatoryFieldsL(CParsedFieldCollection& aIacpFields)
       
   103 	{
       
   104 	//Defect fix for Def021855- IACP - Not all fields should be mandatory 
       
   105 	
       
   106 	//according to the Smart Messaging Spec v3.0.0 (18/12/00) the only mandatory field is the mail-iap-name
       
   107 	//all other parameters are optional and so this function will leave only if the mail-iap-name is empty.
       
   108 	//However this may change and so the spec needs to be watched just in case.
       
   109 	if(aIacpFields.GetFieldValue(SMS_ISP_M_NAME).Length()==0)		
       
   110 			User::Leave(KIacpMandatoryDataNotSet);
       
   111 	}
       
   112 
       
   113 //
       
   114 // Parse/Set data members of CImSmtpSettings, CImPop3Settings, CImImap4Settings
       
   115 //
       
   116 void CMailParser::ParseL(CParsedFieldCollection& aIacpFields)
       
   117 	{
       
   118 	TPtrC aFieldValueBuf;
       
   119 	TBuf8<KMaxSettingStringLength>	tempBuf; //LoginName, Password, FolderPath
       
   120 
       
   121 	SetMailProtocolL(aIacpFields);
       
   122 
       
   123 	//set service name
       
   124 	if (aIacpFields.GetFieldValueAndLength(SMS_ISP_M_NAME, aFieldValueBuf) != 0)
       
   125 		iIspName= aFieldValueBuf;
       
   126 
       
   127 	//smtp settings
       
   128 	if (aIacpFields.GetFieldValueAndLength(SMS_SENDING_HOST, aFieldValueBuf) != 0)
       
   129 		iSmtpSettings->SetServerAddressL(aFieldValueBuf);
       
   130 	
       
   131 	if (aIacpFields.GetFieldValueAndLength(SMS_USER_EMAIL_ADDR, aFieldValueBuf) != 0)
       
   132 		iSmtpSettings->SetEmailAddressL(aFieldValueBuf);
       
   133 	
       
   134 	if(iProtocolName == EPop3)
       
   135 		{
       
   136 		//pop3 settings
       
   137 		if (aIacpFields.GetFieldValueAndLength(SMS_MAILBOX_NAME, aFieldValueBuf) != 0)
       
   138 			{
       
   139 			tempBuf.Copy(aFieldValueBuf); //copy from 16 to 8 bit buffer
       
   140 			iPop3Settings->SetLoginNameL(tempBuf);
       
   141 			}
       
   142 
       
   143 		if (aIacpFields.GetFieldValueAndLength(SMS_MAILBOX_PASS, aFieldValueBuf) != 0)
       
   144 			{
       
   145 			tempBuf.Copy(aFieldValueBuf); //copy from 16 to 8 bit buffer
       
   146 			iPop3Settings->SetPasswordL(tempBuf);
       
   147 			}
       
   148 			
       
   149 
       
   150 		if (aIacpFields.GetFieldValueAndLength(SMS_RECEIVING_HOST, aFieldValueBuf) != 0)
       
   151 			iPop3Settings->SetServerAddressL(aFieldValueBuf);
       
   152 
       
   153 		// Set DisconnectedUserMode flag so that messages are not made invisible
       
   154 		iPop3Settings->SetDisconnectedUserMode(ETrue);	
       
   155 		}
       
   156 	else if(iProtocolName == EImap4)
       
   157 		{
       
   158 		//imap4 settings
       
   159 		if (aIacpFields.GetFieldValueAndLength(SMS_MAILBOX_NAME, aFieldValueBuf) != 0)
       
   160 			{
       
   161 			tempBuf.Copy(aFieldValueBuf); //copy from 16 to 8 bit buffer
       
   162 			iImap4Settings->SetLoginNameL(tempBuf);
       
   163 			}
       
   164 
       
   165 		if (aIacpFields.GetFieldValueAndLength(SMS_MAILBOX_PASS, aFieldValueBuf) != 0)
       
   166 			{
       
   167 			tempBuf.Copy(aFieldValueBuf); //copy from 16 to 8 bit buffer
       
   168 			iImap4Settings->SetPasswordL(tempBuf);
       
   169 			}
       
   170 		
       
   171 		
       
   172 		if (aIacpFields.GetFieldValueAndLength(SMS_RECEIVING_HOST, aFieldValueBuf) != 0)
       
   173 			iImap4Settings->SetServerAddressL(aFieldValueBuf);
       
   174 
       
   175 		if (aIacpFields.GetFieldValueAndLength(SMS_FOLDER_PATH, aFieldValueBuf) != 0)
       
   176 			{
       
   177 			tempBuf.Copy(aFieldValueBuf); //copy from 16 to 8 bit buffer
       
   178 			iImap4Settings->SetFolderPathL(tempBuf);
       
   179 			}
       
   180 
       
   181 		// Set DisconnectedUserMode flag so that messages are not made invisible
       
   182 		iImap4Settings->SetDisconnectedUserMode(ETrue);
       
   183 		}
       
   184 	}
       
   185 
       
   186 //
       
   187 // Create smtp, pop3, imap4 services
       
   188 //
       
   189 void CMailParser::ProcessL(CMSVENTRY& aEntry)
       
   190 	{
       
   191 	
       
   192 	// check for existing services with the same name
       
   193 	GetServiceIdsL(iPop3AccountId, iImap4AccountId);
       
   194 
       
   195 	// check if this account has switched from IMAP to POP or vise-versa
       
   196 	TBool protChanged = EFalse;
       
   197 	TBuf<KMaxSettingStringLength> oldIspName;
       
   198 	oldIspName.Copy(iIspName);
       
   199 	if (iProtocolName == EPop3 && iImap4AccountId.iImapAccountId != KErrNotFound && 
       
   200 								  iPop3AccountId.iPopAccountId == KErrNotFound)
       
   201 		{
       
   202 		protChanged = ETrue;
       
   203 		oldIspName.Append(KIacpOldImapName);
       
   204 		}
       
   205 	else if (iProtocolName == EImap4 && iPop3AccountId.iPopAccountId != KErrNotFound && 
       
   206 										iImap4AccountId.iImapAccountId == KErrNotFound)
       
   207 		{
       
   208 		protChanged = ETrue;
       
   209 		oldIspName.Append(KIacpOldPop3Name);
       
   210 		}
       
   211 
       
   212 	// create a new account if there is no existing account or the account has been
       
   213 	// switched from POP to IMAP or IMAP to POP
       
   214 	if (protChanged || iPop3AccountId.iPopAccountId == KErrNotFound && 
       
   215 					   iImap4AccountId.iImapAccountId == KErrNotFound)
       
   216 		{
       
   217 		// if service swapped rename old service
       
   218 		if (protChanged)
       
   219 			{
       
   220 			CImSmtpSettings* smtpSettings = new(ELeave) CImSmtpSettings;
       
   221 			CleanupStack::PushL(smtpSettings);
       
   222 			
       
   223 			if (iProtocolName == EPop3)
       
   224 				{
       
   225 				CImPop3Settings* popSettings = new(ELeave) CImPop3Settings;
       
   226 				CleanupStack::PushL(popSettings);
       
   227 				
       
   228 				// load settings
       
   229 				iEmailAccounts->LoadPopSettingsL(iPop3AccountId, *popSettings);
       
   230 				TSmtpAccount smtpAccountId;
       
   231 				iEmailAccounts->GetSmtpAccountL(iPop3AccountId.iSmtpService, smtpAccountId);
       
   232 				iEmailAccounts->LoadSmtpSettingsL(smtpAccountId, *smtpSettings);
       
   233 				
       
   234 				// rename old service
       
   235 				iPop3AccountId.iPopAccountName = oldIspName;
       
   236 				
       
   237 				// save settings
       
   238 				iEmailAccounts->SavePopSettingsL(iPop3AccountId, *popSettings); 
       
   239 				iEmailAccounts->SaveSmtpSettingsL(smtpAccountId, *smtpSettings);
       
   240 				CleanupStack::PopAndDestroy(popSettings);
       
   241 				}
       
   242 			else if (iProtocolName == EImap4)
       
   243 				{
       
   244 				CImImap4Settings* imapSettings = new(ELeave) CImImap4Settings;
       
   245 				CleanupStack::PushL(imapSettings);
       
   246 				
       
   247 				// load settings
       
   248 				iEmailAccounts->LoadImapSettingsL(iImap4AccountId, *imapSettings);
       
   249 				TSmtpAccount smtpAccountId;
       
   250 				iEmailAccounts->GetSmtpAccountL(iImap4AccountId.iSmtpService, smtpAccountId);				
       
   251 				iEmailAccounts->LoadSmtpSettingsL(smtpAccountId, *smtpSettings);
       
   252 
       
   253 				// rename old service
       
   254 				iImap4AccountId.iImapAccountName = oldIspName;
       
   255 				
       
   256 				// save settings
       
   257 				iEmailAccounts->SaveImapSettingsL(iImap4AccountId, *imapSettings);
       
   258 				iEmailAccounts->SaveSmtpSettingsL(smtpAccountId, *smtpSettings);
       
   259 				CleanupStack::PopAndDestroy(imapSettings);
       
   260 				}
       
   261 			CleanupStack::PopAndDestroy(smtpSettings);
       
   262 			}
       
   263 
       
   264 		// create new services
       
   265 		if (iProtocolName == EPop3)
       
   266 			{
       
   267 			iPop3AccountId = iEmailAccounts->CreatePopAccountL(iIspName, *iPop3Settings, *iEmailPreferences, EFalse);
       
   268 			TSmtpAccount smtpAccountId = iEmailAccounts->CreateSmtpAccountL(iPop3AccountId, *iSmtpSettings, *iSmtpPreferences, EFalse);
       
   269 
       
   270 			aEntry.SetEntryL(iPop3AccountId.iPopService);
       
   271 			iEmailAccounts->SetDefaultSmtpAccountL(smtpAccountId);
       
   272 			iImap4AccountId.iImapAccountId = KErrNotFound;
       
   273 			}
       
   274 		else if (iProtocolName == EImap4)
       
   275 			{
       
   276 			iImap4AccountId = iEmailAccounts->CreateImapAccountL(iIspName, *iImap4Settings, *iEmailPreferences, EFalse);
       
   277 			TSmtpAccount smtpAccountId = iEmailAccounts->CreateSmtpAccountL(iImap4AccountId, *iSmtpSettings, *iSmtpPreferences, EFalse);
       
   278 			
       
   279 			aEntry.SetEntryL(iImap4AccountId.iImapService);
       
   280 			iEmailAccounts->SetDefaultSmtpAccountL(smtpAccountId);
       
   281 			iPop3AccountId.iPopAccountId = KErrNotFound;
       
   282 			}
       
   283 		}
       
   284 	else
       
   285 		{
       
   286 		// overwrite existing account settings
       
   287 		if (iProtocolName == EPop3)
       
   288 			{
       
   289 			iEmailAccounts->SavePopSettingsL(iPop3AccountId, *iPop3Settings);
       
   290 			iEmailAccounts->SavePopIapSettingsL(iPop3AccountId, *iEmailPreferences);
       
   291 			TSmtpAccount smtpAccountId;
       
   292 			iEmailAccounts->GetSmtpAccountL(iPop3AccountId.iSmtpService, smtpAccountId);							
       
   293 			iEmailAccounts->SaveSmtpSettingsL(smtpAccountId, *iSmtpSettings);
       
   294 			iEmailAccounts->SaveSmtpIapSettingsL(smtpAccountId, *iSmtpPreferences);
       
   295 
       
   296 			aEntry.SetEntryL(iPop3AccountId.iPopService);
       
   297 			iEmailAccounts->SetDefaultSmtpAccountL(smtpAccountId);
       
   298 			}
       
   299 		else if (iProtocolName == EImap4)
       
   300 			{
       
   301 			iEmailAccounts->SaveImapSettingsL(iImap4AccountId, *iImap4Settings);
       
   302 			iEmailAccounts->SaveImapIapSettingsL(iImap4AccountId, *iEmailPreferences);
       
   303 			TSmtpAccount smtpAccountId;
       
   304 			iEmailAccounts->GetSmtpAccountL(iImap4AccountId.iSmtpService, smtpAccountId);			
       
   305 			iEmailAccounts->SaveSmtpSettingsL(smtpAccountId, *iSmtpSettings);
       
   306 			iEmailAccounts->SaveSmtpIapSettingsL(smtpAccountId, *iSmtpPreferences);
       
   307 
       
   308 			aEntry.SetEntryL(iImap4AccountId.iImapService);
       
   309 			iEmailAccounts->SetDefaultSmtpAccountL(smtpAccountId);
       
   310 			}
       
   311 		}
       
   312 	}
       
   313 	
       
   314 //
       
   315 // Get the email account ids for any matching POP/IMAP accounts
       
   316 //
       
   317 void CMailParser::GetServiceIdsL(TPopAccount& aPop3AccountId, TImapAccount& aImap4AccountId)
       
   318 	{
       
   319 	aPop3AccountId.iPopAccountId = KErrNotFound;
       
   320 	aImap4AccountId.iImapAccountId = KErrNotFound;
       
   321 	
       
   322 	// get list of pop3 accounts
       
   323 	RArray<TPopAccount> pop3Accounts;
       
   324 	CleanupClosePushL(pop3Accounts);
       
   325 	iEmailAccounts->GetPopAccountsL(pop3Accounts);
       
   326 	for (TInt i=0; i<pop3Accounts.Count(); ++i)
       
   327 		{
       
   328 		if (pop3Accounts[i].iPopAccountName.Length() == iIspName.Length())
       
   329 			{
       
   330 			if (pop3Accounts[i].iPopAccountName.CompareF(iIspName) == 0)
       
   331 				{
       
   332 				aPop3AccountId = pop3Accounts[i];
       
   333 				break;
       
   334 				}
       
   335 			}
       
   336 		}
       
   337 
       
   338 	// get list of imap4 accounts	
       
   339 	RArray<TImapAccount> imap4Accounts;
       
   340 	CleanupClosePushL(imap4Accounts);
       
   341 	iEmailAccounts->GetImapAccountsL(imap4Accounts);
       
   342 	for (TInt j=0; j<imap4Accounts.Count(); ++j)
       
   343 		{
       
   344 		if (imap4Accounts[j].iImapAccountName.Length() == iIspName.Length())
       
   345 			{
       
   346 			if (imap4Accounts[j].iImapAccountName.CompareF(iIspName) == 0)
       
   347 				{
       
   348 				aImap4AccountId = imap4Accounts[j];
       
   349 				break;
       
   350 				}
       
   351 			}
       
   352 		}
       
   353 
       
   354 	CleanupStack::PopAndDestroy(2, &pop3Accounts); // imap4Accounts, pop3Accounts
       
   355 	}
       
   356 
       
   357 	
       
   358 	
       
   359 //
       
   360 // Gets Types of folder list sync
       
   361 //
       
   362 void CMailParser::GetFolderSyncTypeL(const TDesC& aDes,TFolderSyncType& aFolderSyncType) const
       
   363 	{
       
   364 	__ASSERT_DEBUG(aDes.Length() > 0 ,User::Panic(KIACP,EIacpEmptyBuffer));
       
   365 	TInt8 extractInt=0;
       
   366 
       
   367 	TLex lex(aDes);
       
   368     if (lex.Val(extractInt) == KErrNone)
       
   369 		{
       
   370 		if(extractInt==0)
       
   371 			aFolderSyncType = EUseCombination;
       
   372 		else if(extractInt==1)
       
   373 			aFolderSyncType = EUseLocal;
       
   374 		else if(extractInt==2)
       
   375 			aFolderSyncType = EUseRemote;
       
   376 		else
       
   377 			User::Leave(KIacpErrRightToken);
       
   378 		}
       
   379 	else
       
   380 		User::Leave(KIacpErrRightToken);
       
   381 
       
   382 	}
       
   383 //
       
   384 //  Subscription data
       
   385 //
       
   386 void CMailParser::GetFolderSubscribeTypeL(const TDesC& aDes,TFolderSubscribeType& aFolderSubscribeType) const
       
   387 	{
       
   388 	__ASSERT_DEBUG(aDes.Length() > 0 ,User::Panic(KIACP,EIacpEmptyBuffer));
       
   389 	TInt8 extractInt=0;
       
   390 
       
   391 	TLex lex(aDes);
       
   392     if (lex.Val(extractInt) == KErrNone)
       
   393 		{
       
   394 		if(extractInt==0)
       
   395 			aFolderSubscribeType = EUpdateNeither;
       
   396 		else if(extractInt==1)
       
   397 			aFolderSubscribeType = EUpdateLocal;
       
   398 		else if(extractInt==2)
       
   399 			aFolderSubscribeType = EUpdateRemote;
       
   400 		else if(extractInt==3)
       
   401 			aFolderSubscribeType = EUpdateBoth;
       
   402 		else
       
   403 			User::Leave(KIacpErrRightToken);
       
   404 		}
       
   405 	else
       
   406 		User::Leave(KIacpErrRightToken);
       
   407 	}
       
   408 
       
   409 //
       
   410 // set iMailProtocolName to Pop3 or Imap4
       
   411 //
       
   412 void CMailParser::SetMailProtocolL(CParsedFieldCollection& aIacpFields)
       
   413 	{
       
   414 	iProtocolName =0;
       
   415 	TInt count = aIacpFields.Count();
       
   416 
       
   417 	for ( TInt i=0; i < count; i++ )
       
   418 		{
       
   419 		CParsedField& field = *(aIacpFields[i]);
       
   420 		if(field.FieldName().CompareF(SMS_MAIL_PROTOCOL)==0)
       
   421 			{	
       
   422 			if(field.FieldValue().CompareF(SMS_POP)==0)
       
   423 				{
       
   424 				iProtocolName = EPop3;
       
   425 				return;
       
   426 				}
       
   427 			else if (field.FieldValue().CompareF(SMS_IMAP)==0)
       
   428 				{
       
   429 				iProtocolName = EImap4;
       
   430 				return;
       
   431 				}
       
   432 			}
       
   433 		}
       
   434 	User::Leave(KIacpUnknownMailProtocol);
       
   435 	}
       
   436 
       
   437 void CMailParser::AssociateIAPWithMailL(CMSVENTRY& /*aEntry*/, TUint32 aId)
       
   438 	{
       
   439 	// load settings
       
   440 	TSmtpAccount smtpAccountId;
       
   441 	if (iPop3AccountId.iPopAccountId != KErrNotFound)
       
   442 		{
       
   443 		iEmailAccounts->LoadPopSettingsL(iPop3AccountId, *iPop3Settings);
       
   444 		iEmailAccounts->LoadPopIapSettingsL(iPop3AccountId, *iEmailPreferences);
       
   445 
       
   446 		iEmailAccounts->GetSmtpAccountL(iPop3AccountId.iSmtpService, smtpAccountId);
       
   447 		iEmailAccounts->LoadSmtpSettingsL(smtpAccountId, *iSmtpSettings);
       
   448 		iEmailAccounts->LoadSmtpIapSettingsL(smtpAccountId, *iSmtpPreferences);
       
   449 		}
       
   450 	else if (iImap4AccountId.iImapAccountId != KErrNotFound)
       
   451 		{
       
   452 		iEmailAccounts->LoadImapSettingsL(iImap4AccountId, *iImap4Settings);
       
   453 		iEmailAccounts->LoadImapIapSettingsL(iImap4AccountId, *iEmailPreferences);
       
   454 
       
   455 		iEmailAccounts->GetSmtpAccountL(iImap4AccountId.iSmtpService, smtpAccountId);			
       
   456 		iEmailAccounts->LoadSmtpSettingsL(smtpAccountId, *iSmtpSettings);
       
   457 		iEmailAccounts->LoadSmtpIapSettingsL(smtpAccountId, *iSmtpPreferences);
       
   458 		}
       
   459 
       
   460 	// update IAP preferences
       
   461 	TBool updated(EFalse);
       
   462 	TImIAPChoice iap;
       
   463 	iap.iIAP = aId;
       
   464 	iap.iDialogPref = ECommDbDialogPrefDoNotPrompt;
       
   465 	TInt location;
       
   466 	if (iEmailPreferences->FindIAPL(iap.iIAP, location) == KErrNotFound)
       
   467 		{
       
   468 		iEmailPreferences->AddIAPL(iap);
       
   469 		updated = ETrue;
       
   470 		}
       
   471 	if (iSmtpPreferences->FindIAPL(iap.iIAP, location) == KErrNotFound)
       
   472 		{
       
   473 		iSmtpPreferences->AddIAPL(iap);
       
   474 		updated = ETrue;
       
   475 		}
       
   476 
       
   477 	// save settings
       
   478 	if (updated && iPop3AccountId.iPopAccountId != KErrNotFound)
       
   479 		{
       
   480 		iEmailAccounts->SavePopIapSettingsL(iPop3AccountId, *iEmailPreferences);
       
   481 		iEmailAccounts->SaveSmtpIapSettingsL(smtpAccountId, *iSmtpPreferences);
       
   482 		}
       
   483 	else if (updated && iImap4AccountId.iImapAccountId != KErrNotFound)
       
   484 		{
       
   485 		iEmailAccounts->SaveImapIapSettingsL(iImap4AccountId, *iEmailPreferences);
       
   486 		iEmailAccounts->SaveSmtpIapSettingsL(smtpAccountId, *iSmtpPreferences);
       
   487 		}
       
   488 	}
       
   489