email/pop3andsmtpmtm/clientmtms/src/cemailaccounts.cpp
branchRCL_3
changeset 77 da6ac9d688df
parent 60 7fdbb852d323
equal deleted inserted replaced
71:17302fa075e1 77:da6ac9d688df
  2305 void CEmailAccounts::DoLoadPopSettingsL(TUint32 aAccountId, CImPop3Settings& aPopSettings)
  2305 void CEmailAccounts::DoLoadPopSettingsL(TUint32 aAccountId, CImPop3Settings& aPopSettings)
  2306 	{
  2306 	{
  2307 	aPopSettings.Reset();	
  2307 	aPopSettings.Reset();	
  2308 	CRepository& popRepository = PopRepositoryL();
  2308 	CRepository& popRepository = PopRepositoryL();
  2309 
  2309 
  2310 	TInt temp = 0;
  2310 	TInt temp = 0;			
  2311 	TBuf<KMaxSettingStringLength> tempDesc;			
  2311 	HBufC* heapBuf = HBufC::NewLC( KMaxSettingStringLength );
       
  2312 	TPtr tempDesc(heapBuf->Des());
  2312 	TInt error = popRepository.Get(aAccountId + EPOPServerAddressId, tempDesc);
  2313 	TInt error = popRepository.Get(aAccountId + EPOPServerAddressId, tempDesc);
  2313 	if (error == KErrNone)
  2314 	if (error == KErrNone)
  2314 		{		
  2315 		{		
  2315 		aPopSettings.SetServerAddressL(tempDesc);
  2316 		aPopSettings.SetServerAddressL(tempDesc);
  2316 		}
  2317 		}
  2320 		}
  2321 		}
  2321 	else
  2322 	else
  2322 		{
  2323 		{
  2323 		User::Leave(error);
  2324 		User::Leave(error);
  2324 		}
  2325 		}
       
  2326 	
       
  2327 	CleanupStack::PopAndDestroy( heapBuf );
  2325 
  2328 
  2326 	error = popRepository.Get(aAccountId + EPOPPortNumberId, temp);	
  2329 	error = popRepository.Get(aAccountId + EPOPPortNumberId, temp);	
  2327 	if (error == KErrNone)
  2330 	if (error == KErrNone)
  2328 		{		
  2331 		{		
  2329 		aPopSettings.SetPort(static_cast<TUint>(temp));
  2332 		aPopSettings.SetPort(static_cast<TUint>(temp));
  2338 		}
  2341 		}
  2339 
  2342 
  2340 	User::LeaveIfError(popRepository.Get(aAccountId + EPOPFlagsId, temp));	
  2343 	User::LeaveIfError(popRepository.Get(aAccountId + EPOPFlagsId, temp));	
  2341 	aPopSettings.SetSettingsFlags(static_cast<TUint32>(temp));
  2344 	aPopSettings.SetSettingsFlags(static_cast<TUint32>(temp));
  2342 		
  2345 		
  2343 	TBuf8<KMaxSettingStringLength> tempDesc8;			
  2346 	HBufC8* heapBuf8 = HBufC8::NewLC( KMaxSettingStringLength );
       
  2347 	TPtr8 tempDesc8(heapBuf8->Des());
       
  2348 	
  2344 	error = popRepository.Get(aAccountId + EPOPLoginNameId, tempDesc8);	
  2349 	error = popRepository.Get(aAccountId + EPOPLoginNameId, tempDesc8);	
  2345 	if (error == KErrNone)
  2350 	if (error == KErrNone)
  2346 		{		
  2351 		{		
  2347 		aPopSettings.SetLoginNameL(tempDesc8);
  2352 		aPopSettings.SetLoginNameL(tempDesc8);
  2348 		}
  2353 		}
  2390 			{
  2395 			{
  2391 			User::LeaveIfError(popRepository.Get(aAccountId + EPOPTlsSslDomainId, tempDesc8));
  2396 			User::LeaveIfError(popRepository.Get(aAccountId + EPOPTlsSslDomainId, tempDesc8));
  2392 			aPopSettings.SetTlsSslDomainL(tempDesc8);
  2397 			aPopSettings.SetTlsSslDomainL(tempDesc8);
  2393 			}
  2398 			}
  2394 		}
  2399 		}
       
  2400 	CleanupStack::PopAndDestroy( heapBuf8 );
       
  2401 	
  2395 	}
  2402 	}
  2396 
  2403 
  2397 void CEmailAccounts::DoLoadSmtpSettingsL(TUint32 aAccountId, CImSmtpSettings& aSmtpSettings)
  2404 void CEmailAccounts::DoLoadSmtpSettingsL(TUint32 aAccountId, CImSmtpSettings& aSmtpSettings)
  2398 	{
  2405 	{
  2399 	aSmtpSettings.Reset();
  2406 	aSmtpSettings.Reset();
  2400 	CRepository& smtpRepository = SmtpRepositoryL();
  2407 	CRepository& smtpRepository = SmtpRepositoryL();
  2401 
  2408 
  2402 	TInt temp = 0;
  2409 	TInt temp = 0;
  2403 	TBuf<KMaxSettingStringLength> tempDesc;			
  2410 	HBufC* heapBuf = HBufC::NewLC( KMaxSettingStringLength );
       
  2411 	TPtr tempDesc( heapBuf->Des() );
       
  2412 	
  2404 	TInt error = smtpRepository.Get(aAccountId + ESMTPServerAddressId, tempDesc);	
  2413 	TInt error = smtpRepository.Get(aAccountId + ESMTPServerAddressId, tempDesc);	
  2405 	if (error == KErrNone)
  2414 	if (error == KErrNone)
  2406 		{		
  2415 		{		
  2407 		aSmtpSettings.SetServerAddressL(tempDesc);
  2416 		aSmtpSettings.SetServerAddressL(tempDesc);
  2408 		}
  2417 		}
  2486 	else
  2495 	else
  2487 		{
  2496 		{
  2488 		User::Leave(error);
  2497 		User::Leave(error);
  2489 		}
  2498 		}
  2490 
  2499 
       
  2500 	CleanupStack::PopAndDestroy( heapBuf );
       
  2501 	
  2491 	User::LeaveIfError(smtpRepository.Get(aAccountId + ESMTPBodyEncodingId, temp));	
  2502 	User::LeaveIfError(smtpRepository.Get(aAccountId + ESMTPBodyEncodingId, temp));	
  2492 	aSmtpSettings.SetBodyEncoding(static_cast<TMsgOutboxBodyEncoding>(temp));
  2503 	aSmtpSettings.SetBodyEncoding(static_cast<TMsgOutboxBodyEncoding>(temp));
  2493 
  2504 
  2494 	User::LeaveIfError(smtpRepository.Get(aAccountId + ESMTPDefaultMsgCharSetId, temp));	
  2505 	User::LeaveIfError(smtpRepository.Get(aAccountId + ESMTPDefaultMsgCharSetId, temp));	
  2495 	aSmtpSettings.SetDefaultMsgCharSet(TUid::Uid(temp));
  2506 	aSmtpSettings.SetDefaultMsgCharSet(TUid::Uid(temp));
  2497 	User::LeaveIfError(smtpRepository.Get(aAccountId + ESMTPSendCopyToSelfId, temp));	
  2508 	User::LeaveIfError(smtpRepository.Get(aAccountId + ESMTPSendCopyToSelfId, temp));	
  2498 	aSmtpSettings.SetSendCopyToSelf(static_cast<TImSMTPSendCopyToSelf>(temp));
  2509 	aSmtpSettings.SetSendCopyToSelf(static_cast<TImSMTPSendCopyToSelf>(temp));
  2499 
  2510 
  2500 	User::LeaveIfError(smtpRepository.Get(aAccountId + ESMTPSendMessageOptionId, temp));	
  2511 	User::LeaveIfError(smtpRepository.Get(aAccountId + ESMTPSendMessageOptionId, temp));	
  2501 	aSmtpSettings.SetSendMessageOption(static_cast<TImSMTPSendMessageOption>(temp));
  2512 	aSmtpSettings.SetSendMessageOption(static_cast<TImSMTPSendMessageOption>(temp));
  2502 
  2513 	HBufC8* heapBuf8 = HBufC8::NewLC(KMaxSettingStringLength);
  2503 	TBuf8<KMaxSettingStringLength> tempDesc8;			
  2514 	TPtr8 tempDesc8( heapBuf8->Des() );
       
  2515 	
  2504 	error = smtpRepository.Get(aAccountId + ESMTPLoginNameId, tempDesc8);	
  2516 	error = smtpRepository.Get(aAccountId + ESMTPLoginNameId, tempDesc8);	
  2505 	if (error == KErrNone)
  2517 	if (error == KErrNone)
  2506 		{		
  2518 		{		
  2507 		aSmtpSettings.SetLoginNameL(tempDesc8);
  2519 		aSmtpSettings.SetLoginNameL(tempDesc8);
  2508 		}
  2520 		}
  2555 			{
  2567 			{
  2556 			User::LeaveIfError(smtpRepository.Get(aAccountId + ESMTPTlsSslDomainId, tempDesc8));
  2568 			User::LeaveIfError(smtpRepository.Get(aAccountId + ESMTPTlsSslDomainId, tempDesc8));
  2557 			aSmtpSettings.SetTlsSslDomainL(tempDesc8);
  2569 			aSmtpSettings.SetTlsSslDomainL(tempDesc8);
  2558 			}
  2570 			}
  2559 		}	
  2571 		}	
       
  2572 	
       
  2573 	CleanupStack::PopAndDestroy( heapBuf8 );
       
  2574 	
  2560 	}
  2575 	}
  2561 
  2576 
  2562 void CEmailAccounts::DoLoadImapSettingsL(TUint32 aAccountId, CImImap4Settings& aImapSettings)
  2577 void CEmailAccounts::DoLoadImapSettingsL(TUint32 aAccountId, CImImap4Settings& aImapSettings)
  2563 	{
  2578 	{
  2564 	aImapSettings.Reset();
  2579 	aImapSettings.Reset();
  2565 	CRepository& imapRepository = ImapRepositoryL();
  2580 	CRepository& imapRepository = ImapRepositoryL();
  2566 
  2581 
  2567 	TInt temp = 0;
  2582 	TInt temp = 0;
  2568 	TBuf<KMaxSettingStringLength> tempDesc;			
  2583 	HBufC* heapBuf = HBufC::NewLC( KMaxSettingStringLength );
       
  2584 	TPtr tempDesc(heapBuf->Des());
       
  2585 	
  2569 	TInt error = imapRepository.Get(aAccountId + EIMAPServerAddressId, tempDesc);	
  2586 	TInt error = imapRepository.Get(aAccountId + EIMAPServerAddressId, tempDesc);	
  2570 	if (error == KErrNone)
  2587 	if (error == KErrNone)
  2571 		{		
  2588 		{		
  2572 		aImapSettings.SetServerAddressL(tempDesc);
  2589 		aImapSettings.SetServerAddressL(tempDesc);
  2573 		}
  2590 		}
  2578 	else
  2595 	else
  2579 		{
  2596 		{
  2580 		User::Leave(error);
  2597 		User::Leave(error);
  2581 		}
  2598 		}
  2582 
  2599 
       
  2600 	CleanupStack::PopAndDestroy( heapBuf );
       
  2601 	
  2583 	error = imapRepository.Get(aAccountId + EIMAPPortNumberId, temp);	
  2602 	error = imapRepository.Get(aAccountId + EIMAPPortNumberId, temp);	
  2584 	if (error == KErrNone)
  2603 	if (error == KErrNone)
  2585 		{		
  2604 		{		
  2586 		aImapSettings.SetPort(static_cast<TUint>(temp));
  2605 		aImapSettings.SetPort(static_cast<TUint>(temp));
  2587 		}
  2606 		}
  2595 		}
  2614 		}
  2596 
  2615 
  2597 	User::LeaveIfError(imapRepository.Get(aAccountId + EIMAPFlagsId, temp));	
  2616 	User::LeaveIfError(imapRepository.Get(aAccountId + EIMAPFlagsId, temp));	
  2598 	aImapSettings.SetSettingsFlags(static_cast<TUint32>(temp));
  2617 	aImapSettings.SetSettingsFlags(static_cast<TUint32>(temp));
  2599 		
  2618 		
  2600 	TBuf8<KMaxSettingStringLength> tempDesc8;			
  2619 	HBufC8* heapBuf8 = HBufC8::NewLC( KMaxSettingStringLength );
       
  2620 	TPtr8 tempDesc8( heapBuf8->Des() );
       
  2621 	
  2601 	error = imapRepository.Get(aAccountId + EIMAPLoginNameId, tempDesc8);	
  2622 	error = imapRepository.Get(aAccountId + EIMAPLoginNameId, tempDesc8);	
  2602 	if (error == KErrNone)
  2623 	if (error == KErrNone)
  2603 		{		
  2624 		{		
  2604 		aImapSettings.SetLoginNameL(tempDesc8);
  2625 		aImapSettings.SetLoginNameL(tempDesc8);
  2605 		}
  2626 		}
  2680 			{
  2701 			{
  2681 			User::LeaveIfError(imapRepository.Get(aAccountId + EIMAPTlsSslDomainId, tempDesc8));
  2702 			User::LeaveIfError(imapRepository.Get(aAccountId + EIMAPTlsSslDomainId, tempDesc8));
  2682 			aImapSettings.SetTlsSslDomainL(tempDesc8);
  2703 			aImapSettings.SetTlsSslDomainL(tempDesc8);
  2683 			}
  2704 			}
  2684 		}
  2705 		}
       
  2706 	
       
  2707 	CleanupStack::PopAndDestroy( heapBuf8 );
       
  2708 	
  2685 	}
  2709 	}
  2686 
  2710 
  2687 void CEmailAccounts::LoadIAPPrefSettingsL(TUint32 aAccountId, CImIAPPreferences& aIAP, CRepository& aRepository)
  2711 void CEmailAccounts::LoadIAPPrefSettingsL(TUint32 aAccountId, CImIAPPreferences& aIAP, CRepository& aRepository)
  2688 	{
  2712 	{
  2689 	// Remove existing settings.
  2713 	// Remove existing settings.