ipsservices/ipssosaoplugin/src/IpsSosAOImapAgent.cpp
branchRCL_3
changeset 63 d189ee25cf9d
parent 8 e1b6206813b4
child 64 3533d4323edc
--- a/ipsservices/ipssosaoplugin/src/IpsSosAOImapAgent.cpp	Thu Aug 19 09:38:05 2010 +0300
+++ b/ipsservices/ipssosaoplugin/src/IpsSosAOImapAgent.cpp	Tue Aug 31 15:04:17 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2009 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"
@@ -16,30 +16,7 @@
 *
 */
 
-
-#include "emailtrace.h"
-#include <cemailaccounts.h>
-#include <imapcmds.h>
-#include <miutset.h>
-#include <impcmtm.h>
-#include <msvapi.h>
-#include <AlwaysOnlineManagerCommon.h>
-//<cmail>
-#include "cfsmailcommon.h"
-//</cmail>
-
-
-#include "IpsSosAOImapAgent.h"
-#include "IpsSosAOImapPopLogic.h"
-
-
-// from settings
-#include "ipssetdataapi.h"
-#include "ipssetutilsconsts.h"
-
-// from ipsplugin
-#include "ipsplgimap4populateop.h"
-#include "ipsplgcommon.h"
+#include "ipssosaopluginheaders.h"
 
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
@@ -67,7 +44,9 @@
     delete iOngoingOp;
     delete iImapClientMtm;
     delete iMtmReg;
-    delete iDataApi;
+	//<QMail>
+
+	//</QMail>
     iFoldersArray.Close();
 
     }
@@ -98,7 +77,9 @@
     iMtmReg = CClientMtmRegistry::NewL( iSession );
     CBaseMtm* bmtm = iMtmReg->NewMtmL( KUidMsgTypeIMAP4 );
     iImapClientMtm = static_cast<CImap4ClientMtm*>(bmtm);
-    iDataApi = CIpsSetDataApi::NewL( iSession );
+	//<QMail>
+    
+	//</QMail>
     iState = EStateIdle; 
     }
  
@@ -181,7 +162,15 @@
              StartSyncL();
              break;
          case EStateRefreshFolderArray:
-             iDataApi->GetSubscribedImapFoldersL( iServiceId , iFoldersArray );
+			 //<QMail>
+             {
+             CIpsSosAOSettingsHandler* settings = 
+                     CIpsSosAOSettingsHandler::NewL(iSession, iServiceId);
+             CleanupStack::PushL(settings);
+             settings->GetSubscribedImapFoldersL( iServiceId , iFoldersArray );
+             CleanupStack::PopAndDestroy(settings);
+             }             
+			 //</QMail>
              iState = EStatePopulateAll;
              SetActiveAndCompleteThis();
              break;
@@ -196,6 +185,7 @@
          case EStateFetchOnHold:
              break;
          case EStateDisconnect:
+             NM_COMMENT("CIpsSosAOImapAgent: disconnecting");
              if ( !iDoNotDisconnect )
                  {
                  CancelAllAndDisconnectL();
@@ -207,6 +197,7 @@
                  }
              break;
          case EStateCompleted:
+             NM_COMMENT("CIpsSosAOImapAgent: completed");
              TRAP_IGNORE( iOpResponse.OperationCompletedL( iError ) );
              SignalSyncCompleted( iServiceId, iError );
              iError = KErrNone;
@@ -319,6 +310,7 @@
     LoadSettingsL( );
     if ( !IsConnected() )
         {
+        NM_COMMENT("CIpsSosAOImapAgent: starting sync");
         TPckg<MMsvImapConnectionObserver*> parameter(this);
         // connect and synchronise starts background sync or idle
         CMsvEntrySelection* sel = new ( ELeave ) CMsvEntrySelection();
@@ -334,10 +326,11 @@
         }
     else
         {
+        NM_COMMENT("CIpsSosAOImapAgent: already connected do not sync");
         // do not do anything if we are connected, especially do never
         // try to sync if sync is is already started (ex. from ips plugin)
         // that cause problems with imap flags etc.
-        iError = KErrNone;
+        iError = KErrCancel;
         iState = EStateCompleted;
         SetActiveAndCompleteThis();
         }
@@ -357,10 +350,16 @@
 void CIpsSosAOImapAgent::CancelAllAndDisconnectL()
     {
     FUNC_LOG;
+    // if we are already idle state, do nothing,
+    // completing in idle state might cause unvanted events to ui
+    if (iState == EStateIdle) 
+        {
+        return;
+        }
+    
     iDoNotDisconnect = EFalse;
     iState = EStateCompleted;
     iFoldersArray.Reset();
-
     if ( IsActive() )
         {
         Cancel();
@@ -468,15 +467,23 @@
     {
     FUNC_LOG;
     TImImap4GetPartialMailInfo info;
-    CIpsSetDataApi::ConstructImapPartialFetchInfo( info, *iImapSettings );
+    //<QMail>
+    CIpsSosAOSettingsHandler* settings = 
+             CIpsSosAOSettingsHandler::NewL(iSession, iServiceId);
+     CleanupStack::PushL(settings);
+     settings->ConstructImapPartialFetchInfo( info, *iImapSettings );
+     CleanupStack::PopAndDestroy(settings);	
+	//</QMail>
     
     if ( !IsConnected() )
         {
         SignalSyncCompleted( iServiceId, iError );
         CancelAllAndDisconnectL();
         }
+	//<QMail>
     else if ( iFoldersArray.Count() > 0 && info.iTotalSizeLimit 
             != KIpsSetDataHeadersOnly )
+	//</QMail>
          {
 
          // only inbox is set, do we have to populate other folders also
@@ -493,19 +500,19 @@
          iImapClientMtm->SwitchCurrentEntryL( iServiceId );
          TFSMailMsgId mbox( KIpsPlgImap4PluginUidValue, iServiceId );
          iStatus = KRequestPending;
+		 //<Qmail>
          iOngoingOp = CIpsPlgImap4PopulateOp::NewL(
                  iSession,
                  this->iStatus,
-                 CActive::EPriorityLow,
                  iServiceId,
                  *dummy,
                  info,
                  *sel,
                  mbox,
-                 *this,
+                 this,
                  0,
                  NULL );
-         
+         //</Qmail>
          iFoldersArray.Remove( 0 );
          SetActive();
          iState = EStatePopulateAll;