ipsservices/ipssosaoplugin/src/IpsSosAOImapAgent.cpp
changeset 59 16ed8d08d0b1
parent 54 997a02608b3a
child 75 47d84de1c893
equal deleted inserted replaced
54:997a02608b3a 59:16ed8d08d0b1
    14 * Description: 
    14 * Description: 
    15 *     Contains imap specified sync logic
    15 *     Contains imap specified sync logic
    16 *
    16 *
    17 */
    17 */
    18 
    18 
    19 
    19 #include "ipssosaopluginheaders.h"
    20 #include "emailtrace.h"
       
    21 #include <cemailaccounts.h>
       
    22 #include <imapcmds.h>
       
    23 #include <miutset.h>
       
    24 #include <impcmtm.h>
       
    25 #include <msvapi.h>
       
    26 #include <AlwaysOnlineManagerCommon.h>
       
    27 #include "CFSMailCommon.h"
       
    28 
       
    29 #include "IpsSosAOImapAgent.h"
       
    30 #include "IpsSosAOImapPopLogic.h"
       
    31 
       
    32 
       
    33 //<QMail>
       
    34 #include "IpsSosAOSettingsHandler.h"
       
    35 
       
    36 //<qmail> removed
       
    37 //</QMail>
       
    38 
       
    39 // from ipsplugin
       
    40 #include "ipsplgimap4populateop.h"
       
    41 #include "ipsplgcommon.h"
       
    42 
    20 
    43 // ----------------------------------------------------------------------------
    21 // ----------------------------------------------------------------------------
    44 // ----------------------------------------------------------------------------
    22 // ----------------------------------------------------------------------------
    45 CIpsSosAOImapAgent::CIpsSosAOImapAgent(             
    23 CIpsSosAOImapAgent::CIpsSosAOImapAgent(             
    46     CMsvSession& aSession,
    24     CMsvSession& aSession,
   205          case EStateFetchOngoing:
   183          case EStateFetchOngoing:
   206              break;
   184              break;
   207          case EStateFetchOnHold:
   185          case EStateFetchOnHold:
   208              break;
   186              break;
   209          case EStateDisconnect:
   187          case EStateDisconnect:
       
   188              NM_COMMENT("CIpsSosAOImapAgent: disconnecting");
   210              if ( !iDoNotDisconnect )
   189              if ( !iDoNotDisconnect )
   211                  {
   190                  {
   212                  CancelAllAndDisconnectL();
   191                  CancelAllAndDisconnectL();
   213                  }
   192                  }
   214              else
   193              else
   216                  iState = EStateCompleted;
   195                  iState = EStateCompleted;
   217                  SetActiveAndCompleteThis();
   196                  SetActiveAndCompleteThis();
   218                  }
   197                  }
   219              break;
   198              break;
   220          case EStateCompleted:
   199          case EStateCompleted:
       
   200              NM_COMMENT("CIpsSosAOImapAgent: completed");
   221              TRAP_IGNORE( iOpResponse.OperationCompletedL( iError ) );
   201              TRAP_IGNORE( iOpResponse.OperationCompletedL( iError ) );
   222              SignalSyncCompleted( iServiceId, iError );
   202              SignalSyncCompleted( iServiceId, iError );
   223              iError = KErrNone;
   203              iError = KErrNone;
   224              ClearSignaledFlags();
   204              ClearSignaledFlags();
   225              iState = EStateIdle;
   205              iState = EStateIdle;
   328         User::Leave( KErrNotReady );
   308         User::Leave( KErrNotReady );
   329         }
   309         }
   330     LoadSettingsL( );
   310     LoadSettingsL( );
   331     if ( !IsConnected() )
   311     if ( !IsConnected() )
   332         {
   312         {
       
   313         NM_COMMENT("CIpsSosAOImapAgent: starting sync");
   333         TPckg<MMsvImapConnectionObserver*> parameter(this);
   314         TPckg<MMsvImapConnectionObserver*> parameter(this);
   334         // connect and synchronise starts background sync or idle
   315         // connect and synchronise starts background sync or idle
   335         CMsvEntrySelection* sel = new ( ELeave ) CMsvEntrySelection();
   316         CMsvEntrySelection* sel = new ( ELeave ) CMsvEntrySelection();
   336         CleanupStack::PushL( sel );
   317         CleanupStack::PushL( sel );
   337         sel->AppendL( iServiceId );
   318         sel->AppendL( iServiceId );
   343         SetActive();
   324         SetActive();
   344         iState = EStateConnectAndSync;
   325         iState = EStateConnectAndSync;
   345         }
   326         }
   346     else
   327     else
   347         {
   328         {
       
   329         NM_COMMENT("CIpsSosAOImapAgent: already connected do not sync");
   348         // do not do anything if we are connected, especially do never
   330         // do not do anything if we are connected, especially do never
   349         // try to sync if sync is is already started (ex. from ips plugin)
   331         // try to sync if sync is is already started (ex. from ips plugin)
   350         // that cause problems with imap flags etc.
   332         // that cause problems with imap flags etc.
   351         iError = KErrNone;
   333         iError = KErrCancel;
   352         iState = EStateCompleted;
   334         iState = EStateCompleted;
   353         SetActiveAndCompleteThis();
   335         SetActiveAndCompleteThis();
   354         }
   336         }
   355     }
   337     }
   356 
   338