/**
  Function : doTestStepL
  Description : Change the IMAP4 Subscribe and Synchronise settings of a test case through the .ini file
  @return : TVerdict - Test step result
*/		
TVerdict CT_MsgChangeImap4SubAndSyncSettings::doTestStepL()
	{
	INFO_PRINTF1(_L("Test Step : ChangeImap4SubAndSyncSettings"));
	if(ReadIni())
		{
		CEmailAccounts* accounts = CEmailAccounts::NewL();
		CleanupStack::PushL(accounts);
			
		CImImap4Settings *imapSettings = new (ELeave) CImImap4Settings;
		CleanupStack::PushL(imapSettings);
				
		TImapAccount imapAccountId;
		CT_MsgUtilsCentralRepository::GetImapAccountL((TDes&)iImapAccountName,imapAccountId);
				
		accounts->LoadImapSettingsL(imapAccountId,*imapSettings);
			
		TFolderSubscribeType setFolderSubscribeType = CT_MsgUtilsEnumConverter::ConvertDesToTFolderSubscribeType(iImapSubscribeMethod);
		imapSettings->SetSubscribe(setFolderSubscribeType);
		TFolderSyncType setFolderSyncType = CT_MsgUtilsEnumConverter::ConvertDesToTFolderSyncType(iImapSynchroniseMethod);
		imapSettings->SetSynchronise(setFolderSyncType);
				
		accounts->SaveImapSettingsL(imapAccountId,*imapSettings);
	
		CleanupStack::PopAndDestroy(2,accounts); // imapSettings,accounts
		}
	return TestStepResult();
	}
void CTestImapSyncManager::ChangeSyncLimitL(TInt limit)
	{
	CEmailAccounts* newaccount = CEmailAccounts::NewLC();
	iTestUtils->GoClientSideL();
	
	newaccount->GetImapAccountL(iServiceId, iImapAccount);
	newaccount->LoadImapSettingsL(iImapAccount, *iImapSettings1);
	
	iImapSettings1->SetInboxSynchronisationLimit(limit);
	iImapSettings1->SetMailboxSynchronisationLimit(limit);
	newaccount->SaveImapSettingsL(iImapAccount, *iImapSettings1);
	CleanupStack::PopAndDestroy(newaccount); 
	iTestUtils->GoServerSideL();
	
	iTestUtils->InstantiateImapServerMtmL();

	iImapServerMtm=(CImap4ServerMtm*)iTestUtils->iImapServerMtm;		

	iEntry = iTestUtils->iServerEntry;
	
	// load the new impsettings...
	iImapSettings = CImapSettings::NewL(*iEntry);
	iImapSettings->LoadSettingsL(iServiceId);
	delete iSel;
	iSel = new (ELeave) CMsvEntrySelection;
	}
/**
  Function 		: MoveAsyncImap4CommandL
  Description 	: This function retrieves the download limits set
  @param 		: aCommand			The Imap command to be executed.
			 	  aImapServiceId	The Imap service Id
				  aMailSelection	The selection object
				  aDownloadLimits	The download limts set.		
  @return 		: none
*/
void CT_MsgImapMoveAsyncFunction::MoveAsyncImap4CommandL( TImap4Cmds aCommand,
										    CMsvEntrySelection& aMailSelection, TMsvId aImapServiceId , TBool aDownloadLimits, TMsvId afolderId)
	{
	
	// Loads the Imap account settings and saves the download limits
	CEmailAccounts* emailAccounts = CEmailAccounts::NewLC();	
	CImImap4Settings* imapSettings =  new(ELeave) CImImap4Settings();
	CleanupStack::PushL(imapSettings);

	TImapAccount imapAccount;
	emailAccounts->GetImapAccountL(aImapServiceId, imapAccount);
	emailAccounts->LoadImapSettingsL(imapAccount, *imapSettings);


	// If full download limts are set load it onto the the account
	CT_MsgActive&	active=Active();
	if(aDownloadLimits)
		{
		TImImap4GetMailInfo imapFullinfo;
		imapFullinfo.iDestinationFolder = afolderId;
		imapFullinfo.iGetMailBodyParts = imapSettings->GetMailOptions();
		imapFullinfo.iMaxEmailSize = imapSettings->MaxEmailSize();
	
		// Package of the download limits
		TPckgBuf<TImImap4GetMailInfo> fullPack(imapFullinfo);

		iSharedDataIMAP.iMtm->SwitchCurrentEntryL(aImapServiceId);
		// Moves asynchronous IMAP4-specific operation 
		iOperation = iSharedDataIMAP.iMtm->InvokeAsyncFunctionL(aCommand,aMailSelection, fullPack, active.iStatus);	
		}
	// If partial download limts are set load it onto the the account 
	else 
		{
		TImImap4GetPartialMailInfo imapPartialinfo;
		imapPartialinfo.iAttachmentSizeLimit = imapSettings->AttachmentSizeLimit();
		imapPartialinfo.iBodyTextSizeLimit = imapSettings->BodyTextSizeLimit();
		imapPartialinfo.iDestinationFolder = afolderId;
		imapPartialinfo.iPartialMailOptions = imapSettings->PartialMailOptions();
		imapPartialinfo.iTotalSizeLimit = imapSettings->MaxEmailSize();
	
		// Package of the download limits 
		TPckgBuf<TImImap4GetPartialMailInfo> partialPack(imapPartialinfo);
		
		// Switches the cuurent context on to the IMAP service ID 
		iSharedDataIMAP.iMtm->SwitchCurrentEntryL(aImapServiceId);
		
		// Moves asynchronous IMAP4-specific operation
		iOperation = iSharedDataIMAP.iMtm->InvokeAsyncFunctionL(aCommand,aMailSelection, partialPack, active.iStatus);
		}

	active.Activate();
	CActiveScheduler::Start();
	User::LeaveIfError(active.Result());

	CleanupStack::PopAndDestroy(2,emailAccounts); // imapSettings,emailAccounts
	}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
CImImap4Settings* CIpsPlgImap4ConnectOp::GetImapSettingsLC()
    {
    FUNC_LOG;
    CImImap4Settings* settings = new ( ELeave ) CImImap4Settings();
    CleanupStack::PushL( settings );
    CEmailAccounts* accounts = CEmailAccounts::NewLC();
    TImapAccount imapAcc;
    accounts->GetImapAccountL(iService, imapAcc );
    accounts->LoadImapSettingsL( imapAcc, *settings );
    CleanupStack::PopAndDestroy( accounts );
    return settings;
    }
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
void CIpsSosAOImapAgent::LoadSettingsL( )
    {
    FUNC_LOG;
    delete iImapSettings;
    iImapSettings = NULL;
    iImapSettings = new ( ELeave ) CImImap4Settings();
    CEmailAccounts* accounts = CEmailAccounts::NewLC();
    TImapAccount imapAcc;
    accounts->GetImapAccountL(iServiceId, imapAcc );
    accounts->LoadImapSettingsL( imapAcc, *iImapSettings );
    CleanupStack::PopAndDestroy( accounts );
    }
/**
  ExecuteActionL
  Sets the values for TImImap4GetMailInfo memeber variables and then store it
  as an output parameter of the Test Action.
  @internalTechnology 
  @pre    None
  @post   None
  @leave  System wide errors
*/
void CMtfTestActionSetImap4FullDownloadLimits::ExecuteActionL()
	{	
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSetImap4FullDownloadLimits);
	// Obtain Test Action input parameters
	TInt  paramTotalSizeLimit	  = ObtainValueParameterL<TInt>(TestCase(),
										ActionParameters().Parameter(0),KMaxTInt);

	TImap4GetMailOptions  paramMailOptions	 = ObtainValueParameterL<TImap4GetMailOptions>
												(TestCase(),ActionParameters().Parameter(1),
												EGetImap4EmailHeaders);

 	TMsvId	paramDestinationFolder  = ObtainValueParameterL<TMsvId>
										(TestCase(),ActionParameters().Parameter(2));
										
	TMsvId paramServiceId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(3));

	// Store the full donwload limits values 
	TImImap4GetMailInfo  imap4GetMailInfo;
		
	imap4GetMailInfo.iMaxEmailSize      = paramTotalSizeLimit;
	imap4GetMailInfo.iGetMailBodyParts  = paramMailOptions;
	imap4GetMailInfo.iDestinationFolder = paramDestinationFolder;
	
	// Load the Imap account settings and save the download limits
	CEmailAccounts* emailAccounts = CEmailAccounts::NewLC();	
	CImImap4Settings* imapSettings =  new(ELeave) CImImap4Settings();
	CleanupStack::PushL(imapSettings);

	TImapAccount imapAccount;
	emailAccounts->GetImapAccountL(paramServiceId, imapAccount);
	emailAccounts->LoadImapSettingsL(imapAccount, *imapSettings);
		
	imapSettings->SetMaxEmailSize( imap4GetMailInfo.iMaxEmailSize );
	imapSettings->SetGetMailOptions( imap4GetMailInfo.iGetMailBodyParts );
	
	emailAccounts->SaveImapSettingsL(imapAccount, *imapSettings);
	CleanupStack::PopAndDestroy( 2, emailAccounts ); // imapSettings, emailSettings
	

	// Store the full download limits as the ouput parameter of the Test Action		
	StoreParameterL<TImImap4GetMailInfo>(TestCase(),imap4GetMailInfo,
											ActionParameters().Parameter(4));

	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSetImap4FullDownloadLimits );
	TestCase().ActionCompletedL(*this);
	}
/**
  Function : doTestStepL
  Description : Fetches the srvice ID using the IMAP account name and sets
  				the full download limit fields of the setting object corresponding to it. 
  @return : TVerdict - Test step result
  @leave  :	KMsvNullIndexEntryId	If valid IMAP account name is not specified or
									If valid remote folder name is not specified
*/
TVerdict CT_MsgSetImap4FullDownloadLimits::doTestStepL()
	{
	INFO_PRINTF1(KInfoTestStepName);
	TPtrC imapAccountName;
	
	/* Reads IMAP Account Name from ini file */
	if(!GetStringFromConfig(ConfigSection(), KImapAccountName, imapAccountName))
		{
		ERR_PRINTF1(KAcntNameNtSpecified);
		SetTestStepResult(EFail);
		}		
	else
		{
		TPtrC destFolderName;

		/* Reads the destination Folder Name */
		if(!GetStringFromConfig(ConfigSection(), KFolderName, destFolderName))
			{
			ERR_PRINTF1(KDestFolderNtSpecified);
			SetTestStepResult(EFail);
			}	
		else
			{
			TInt maxEmailSize = KMaxTInt;
			/* Reads the size of the Email to be set,where default is KMaxTInt */
			GetIntFromConfig(ConfigSection(), KMaxEmailSize, maxEmailSize);
			
			TPtrC mailOption;
			/* Reads the mail option to be set from the ini file */
			if(!GetStringFromConfig(ConfigSection(), KImapMailOption, mailOption))
				{
				ERR_PRINTF1(KGetMailOptNtSpecified);
				SetTestStepResult(EFail);
				}
			else
				{
				TMsvId destFolderId = -1;
				/* Retrieves the IMAP service Id based on the IMAP account name*/
				TMsvId imapServiceId = CT_MsgUtilsCentralRepository::GetImapServiceIdL((TDes&) imapAccountName);
				if(imapServiceId == KMsvNullIndexEntryId)
					{
					ERR_PRINTF2(KAcntNtExist, &imapAccountName);
					SetTestStepResult(EFail);
					}
				else
					{
					/* 
					 * Retrieves the mail options and the remote destination folder Id
					 * based on the IMAP account name and the remote folder name given
					 */
					TImap4GetMailOptions imapMailOption = CT_MsgUtilsEnumConverter::ConvertDesToTImap4GetMailOptions(mailOption);
		
					destFolderId = CT_MsgUtils::GetRemoteFolderIdByNameL(iSharedDataIMAP.iSession,
												imapAccountName,destFolderName);
			
					if(destFolderId == KMsvNullIndexEntryId)
						{
						ERR_PRINTF1(_L("Invalid remote folder name specified"));
						SetTestStepResult(EFail);
						}
					else
						{																						
						INFO_PRINTF2(KFolderId,destFolderId);		
						
						/* Stores the fulll donwload limit values */
						TImImap4GetMailInfo  imap4GetMailInfo;
						imap4GetMailInfo.iMaxEmailSize      = maxEmailSize;	
						imap4GetMailInfo.iGetMailBodyParts  = imapMailOption;
						imap4GetMailInfo.iDestinationFolder = destFolderId;
						
						/* Loads the Imap account settings and save the download limits */
						CEmailAccounts* emailAccounts = CEmailAccounts::NewLC();
						CImImap4Settings* imapSettings =  new(ELeave) CImImap4Settings();
						CleanupStack::PushL(imapSettings);

						TImapAccount imapAccount;
						emailAccounts->GetImapAccountL(imapServiceId, imapAccount);
						emailAccounts->LoadImapSettingsL(imapAccount, *imapSettings);
						
						
						TBool deleteFlag;
						if(GetBoolFromConfig(ConfigSection(),KDeleteFlag,deleteFlag))	
							{
							imapSettings->SetDeleteEmailsWhenDisconnecting(deleteFlag);
							}
						TBool updateFlag;
						if(GetBoolFromConfig(ConfigSection(),KUpdateFlag,updateFlag))	
							{
							imapSettings->SetUpdatingSeenFlags(updateFlag);
							}
							
						TInt fetchSizeLimit = 20480;
						if(GetIntFromConfig(ConfigSection(),KFetchSizeLimit,fetchSizeLimit))
							{
							imapSettings->SetFetchSizeL(fetchSizeLimit);		
							}
							
						TInt inboxSyncLimit;
						if(GetIntFromConfig(ConfigSection(),KInboxSyncLimit,inboxSyncLimit))
							{
							imapSettings->SetInboxSynchronisationLimit(inboxSyncLimit);
							}
						
						TInt mailboxSyncLimit;
						if(GetIntFromConfig(ConfigSection(),KMailboxSyncLimit,mailboxSyncLimit))
							{
							imapSettings->SetMailboxSynchronisationLimit(mailboxSyncLimit);
							}
						
						TPtrC searchString;
						if(GetStringFromConfig(ConfigSection(),KSearchString,searchString))
							{
							HBufC8* string = HBufC8::NewLC(searchString.Length());
							string->Des().Copy(searchString);
							imapSettings->SetSearchStringL(string->Des());
							CleanupStack::PopAndDestroy(string);
							}
						
						TPtrC folderSubTypeName;
						if(GetStringFromConfig(ConfigSection(),KFolderSubType,folderSubTypeName))
							{
							TFolderSubscribeType folderSubType =  CT_MsgUtilsEnumConverter::ConvertDesToTFolderSubscribeType
												((TDesC&)folderSubTypeName);
							imapSettings->SetSubscribe(folderSubType);
							}
							
						TPtrC folderSyncTypeName;
						if(GetStringFromConfig(ConfigSection(),KFolderSyncType,folderSyncTypeName))
							{
							TFolderSyncType  folderSyncType = CT_MsgUtilsEnumConverter::ConvertDesToTFolderSyncType
												((TDesC&)folderSyncTypeName);
							imapSettings->SetSynchronise(folderSyncType);
							}
										
						/* Sets the download limts in the settings object created */
						imapSettings->SetMaxEmailSize( imap4GetMailInfo.iMaxEmailSize );
						imapSettings->SetGetMailOptions( imap4GetMailInfo.iGetMailBodyParts );
						
						/* Saves the settings */
						emailAccounts->SaveImapSettingsL(imapAccount, *imapSettings);
						
						CleanupStack::PopAndDestroy(2,emailAccounts);/* imapSettings, emailAccounts */
						
						INFO_PRINTF2(KInfoCompletionStatus, &KSetImap4FullDownloadLimits);
						}
					}
				}
			}
		}
	return TestStepResult();
	}
Пример #8
0
//
// 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);
	}