コード例 #1
0
ファイル: ENP.CPP プロジェクト: cdaffara/symbiandump-mw2
//
// Get all email services
//
void CEmailNotificationParser::GetEmailServicesL()
	{

	CCnvCharacterSetConverter* charconv = CCnvCharacterSetConverter::NewL();
	CleanupStack::PushL(charconv);
	CArrayFix<CCnvCharacterSetConverter::SCharacterSet> *charsetsAvailable = charconv->CreateArrayOfCharacterSetsAvailableL(iFs);
	CleanupStack::PushL(charsetsAvailable);

	charconv->PrepareToConvertToOrFromL(KUidCharsetISO88591,*charsetsAvailable,iFs);
	
	const TMsvId current = iEntry.Entry().Id();
	iEntry.SetEntryL(KMsvRootIndexEntryId);
	// Get all POP3 and Imap services
	CMsvEntrySelection* rootChildren = iEntry.ChildrenL();
	CleanupStack::PushL(rootChildren);

	TMsvEntry entry;

	CEmailAccounts* accounts = CEmailAccounts::NewLC();

	const TInt count = rootChildren->Count(); 
	TInt j =0;
	while(j < count && iFoundServer ==EFalse)
		{
		// set context to service entry
		iEntry.SetEntryL((*rootChildren)[j]);
		entry = iEntry.Entry(); 
		if (entry.iType == KUidMsvServiceEntry && (entry.iMtm == KUidMsgTypePOP3 || entry.iMtm == KUidMsgTypeIMAP4))
			{
			TBuf8<8> port;

			if(entry.iMtm == KUidMsgTypePOP3)
				{
				// calculate hash value
				CImPop3Settings* settings = new(ELeave)CImPop3Settings;
				CleanupStack::PushL(settings);
 
 				TPopAccount id;
				accounts->GetPopAccountL(entry.Id(), id);
				accounts->LoadPopSettingsL(id, *settings);

				port.Num((TUint)KPOP3DefaultPortNumber);
				iFoundServer = CalcHashValueL( *charconv, settings->LoginName(), settings->ServerAddress(), port);
				}
			else // entry.iMtm == KUidMsgTypeIMAP4
				{
				CImImap4Settings* settings = new(ELeave)CImImap4Settings;
				CleanupStack::PushL(settings);
				
 				TImapAccount id;
				accounts->GetImapAccountL(entry.Id(), id);
				accounts->LoadImapSettingsL(id, *settings);

				port.Num((TUint)KIMAPDefaultPortNumber);
				iFoundServer = CalcHashValueL( *charconv, settings->LoginName(), settings->ServerAddress(), port);
				}
			CleanupStack::PopAndDestroy(); // settings
			}
		j++;
		}

	if(	iFoundServer )
		iServiceMsvId = entry.Id();

	CleanupStack::PopAndDestroy(4, charconv); // charconv, charsetsAvailable, rootChildren, accounts
	
	iEntry.SetEntryL(current);
	}