email/imap4mtm/imapservermtm/src/cimapupsresponsewaiter.cpp
changeset 40 224522e33db9
parent 23 238255e8b033
child 76 60a8a215b0ec
--- a/email/imap4mtm/imapservermtm/src/cimapupsresponsewaiter.cpp	Tue Jun 29 23:42:47 2010 +0530
+++ b/email/imap4mtm/imapservermtm/src/cimapupsresponsewaiter.cpp	Tue Jul 06 22:50:16 2010 +0530
@@ -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
+    	
 	}