email/imap4mtm/imapservermtm/src/cimapupsresponsewaiter.cpp
changeset 52 12db4185673b
parent 31 ebfee66fde93
--- a/email/imap4mtm/imapservermtm/src/cimapupsresponsewaiter.cpp	Tue Jul 06 14:12:40 2010 +0300
+++ b/email/imap4mtm/imapservermtm/src/cimapupsresponsewaiter.cpp	Wed Aug 18 09:45:25 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -37,7 +37,8 @@
 CImapUpsResponseWaiter::CImapUpsResponseWaiter(CMsvServerEntry& aServerEntry, CImapProtocolController& aImapProtocolController)
 	:CMsgActive(EPriorityStandard), iServerEntry(aServerEntry), iImapProtocolController(aImapProtocolController)
 	{
-	CActiveScheduler::Add(this);
+    iImapSettings = CImapSettings::NewL(iServerEntry);
+    CActiveScheduler::Add(this);
 	}
 
 /**
@@ -46,6 +47,7 @@
 CImapUpsResponseWaiter::~CImapUpsResponseWaiter()
 	{
 	Cancel();
+	delete iImapSettings;
 	iUpsSubsession.Close();
 	iUpsSession.Close(); 
 	}
@@ -73,28 +75,32 @@
 		{
 		iState = EIMAP4MTMConnectAndSynchronise;
 		}
-	iEntrySelection = &aEntrySelection;
+	
+    iEntrySelection = &aEntrySelection;
 	
 	iDecision = EUpsDecNo;
 	
-	CImapSettings* imapSettings = CImapSettings::NewL(iServerEntry);
-	CleanupStack::PushL(imapSettings);
-	imapSettings->LoadSettingsL(iServerEntry.Entry().Id());
+	if( iImapSettings->SettingsLoaded() == EFalse)
+	    {
+	    iImapSettings->LoadSettingsL(iServerEntry.Entry().Id());
+	    }
 
 	// Connect to UPS service.....
 	User::LeaveIfError(iUpsSession.Connect());
+
 	RThread clientThread;
  	User::LeaveIfError(clientThread.Open(aClientThreadId));
 	CleanupClosePushL(clientThread);
- 	User::LeaveIfError(iUpsSubsession.Initialise(iUpsSession, clientThread));
+
+    User::LeaveIfError(iUpsSubsession.Initialise(iUpsSession, clientThread));
 	CleanupStack::PopAndDestroy(&clientThread);
 	
-	
 	iStatus=KRequestPending;
-	iUpsSubsession.Authorise(aHasCapability, KUidIMAPService, imapSettings->ServerAddress(), iDecision, iStatus);
+	iUpsSubsession.Authorise(aHasCapability, KUidIMAPService, iImapSettings->ServerAddress(), iDecision, iStatus);
+
 	Queue(aStatus);
 	SetActive();
-	CleanupStack::PopAndDestroy();// imapSettings
+    	
 	}