ipsservices/ipssosplugin/src/ipsplgimap4connectop.cpp
changeset 20 ecc8def7944a
parent 18 578830873419
child 23 2dc6caa42ec3
equal deleted inserted replaced
18:578830873419 20:ecc8def7944a
    14 * Description:  IMAP4 connect operation
    14 * Description:  IMAP4 connect operation
    15 *
    15 *
    16 *
    16 *
    17 */
    17 */
    18 
    18 
    19 
       
    20 #include "emailtrace.h"
    19 #include "emailtrace.h"
    21 #include "ipsplgheaders.h"
    20 #include "ipsplgheaders.h"
    22 
    21 
    23 // <qmail>
    22 // <qmail>
    24 const TInt KIpsSetDataHeadersOnly           = -2;
    23 const TInt KIpsSetDataHeadersOnly           = -2;
    25 const TInt KIpsSetDataFullBodyAndAttas      = -1;
    24 const TInt KIpsSetDataFullBodyAndAttas      = -1;
    26 const TInt KIpsSetDataFullBodyOnly          = -3;
    25 const TInt KIpsSetDataFullBodyOnly          = -3;
    27 // </qmail>
    26 // </qmail>
    28 
    27 
    29 _LIT( KIpsPlgIpsConnPanic, "IpsConn" ); 
    28 // ----------------------------------------------------------------------------
    30 
    29 // CIpsPlgImap4ConnOp::NewL()
    31 // ----------------------------------------------------------------------------
    30 // ----------------------------------------------------------------------------
    32 // CIpsPlgImap4ConnectOp::NewL()
    31 // <qmail> priority parameter has been removed
    33 // ----------------------------------------------------------------------------
       
    34 // 
       
    35 CIpsPlgImap4ConnectOp* CIpsPlgImap4ConnectOp::NewL(
    32 CIpsPlgImap4ConnectOp* CIpsPlgImap4ConnectOp::NewL(
    36     CMsvSession& aMsvSession,
    33     CMsvSession& aMsvSession,
    37 	TInt aPriority,
       
    38     TRequestStatus& aObserverRequestStatus,
    34     TRequestStatus& aObserverRequestStatus,
    39     TMsvId aService,
    35     TMsvId aService,
    40     CIpsPlgTimerOperation& aActivityTimer,
    36     CIpsPlgTimerOperation& aActivityTimer,
    41     TFSMailMsgId aFSMailBoxId,
    37     TFSMailMsgId aFSMailBoxId,
    42     MFSMailRequestObserver& aFSOperationObserver,
    38     MFSMailRequestObserver* aFSOperationObserver,
    43     TInt aFSRequestId,
    39     TInt aFSRequestId,
    44     CIpsPlgEventHandler* aEventHandler,
    40     CIpsPlgEventHandler* aEventHandler,
    45     TBool aDoPlainConnect,
    41     TBool aDoPlainConnect )
    46     TBool aSignallingAllowed )
       
    47     {
    42     {
    48     FUNC_LOG;
    43     FUNC_LOG;
    49     CIpsPlgImap4ConnectOp* self = new (ELeave) CIpsPlgImap4ConnectOp(
    44     CIpsPlgImap4ConnectOp* self = new (ELeave) CIpsPlgImap4ConnectOp(
    50         aMsvSession, 
    45         aMsvSession, 
    51         aPriority, 
       
    52         aObserverRequestStatus,
    46         aObserverRequestStatus,
    53         aService, 
    47         aService, 
    54         aActivityTimer,
    48         aActivityTimer,
    55         aFSMailBoxId, 
    49         aFSMailBoxId, 
    56         aFSOperationObserver,
    50         aFSOperationObserver,
    57         aFSRequestId,
    51         aFSRequestId,
    58         aDoPlainConnect,
    52         aDoPlainConnect,
    59         aSignallingAllowed,
       
    60         aEventHandler );
    53         aEventHandler );
    61         
    54         
    62     CleanupStack::PushL( self );
    55     CleanupStack::PushL( self );
    63     self->ConstructL();
    56     self->ConstructL();
    64     CleanupStack::Pop( self );
    57     CleanupStack::Pop( self );
    66     }
    59     }
    67 
    60 
    68 // ----------------------------------------------------------------------------
    61 // ----------------------------------------------------------------------------
    69 // CIpsPlgImap4ConnectOp::CIpsPlgImap4ConnectOp()
    62 // CIpsPlgImap4ConnectOp::CIpsPlgImap4ConnectOp()
    70 // ----------------------------------------------------------------------------
    63 // ----------------------------------------------------------------------------
    71 // 
    64 // <qmail> priority parameter has been removed
    72 CIpsPlgImap4ConnectOp::CIpsPlgImap4ConnectOp(
    65 CIpsPlgImap4ConnectOp::CIpsPlgImap4ConnectOp(
    73     CMsvSession& aMsvSession,
    66     CMsvSession& aMsvSession,
    74 	TInt aPriority,
       
    75     TRequestStatus& aObserverRequestStatus,
    67     TRequestStatus& aObserverRequestStatus,
    76     TMsvId aService,
    68     TMsvId aService,
    77     CIpsPlgTimerOperation& aActivityTimer,
    69     CIpsPlgTimerOperation& aActivityTimer,
    78     TFSMailMsgId aFSMailBoxId,
    70     TFSMailMsgId aFSMailBoxId,
    79     MFSMailRequestObserver& aFSOperationObserver,
    71     MFSMailRequestObserver* aFSOperationObserver,
    80     TInt aFSRequestId,
    72     TInt aFSRequestId,
    81     TBool aDoPlainConnect,
    73     TBool aDoPlainConnect,
    82     TBool aSignallingAllowed,
       
    83     CIpsPlgEventHandler* aEventHandler)
    74     CIpsPlgEventHandler* aEventHandler)
    84     :
    75     :
    85     CIpsPlgOnlineOperation(
    76     CIpsPlgOnlineOperation(
    86 	    aMsvSession,
    77 	    aMsvSession,
    87 	    aPriority,
       
    88 	    aObserverRequestStatus,
    78 	    aObserverRequestStatus,
    89 	    aActivityTimer,
    79 	    aActivityTimer,
    90 	    aFSMailBoxId,
    80 	    aFSMailBoxId,
    91 	    aFSOperationObserver,
    81 	    aFSOperationObserver,
    92 	    aFSRequestId,
    82 	    aFSRequestId ),
    93     	aSignallingAllowed ),
    83     iState( EStateIdle ),
       
    84     iSelection( NULL ),
    94     iDoPlainConnect( aDoPlainConnect ),
    85     iDoPlainConnect( aDoPlainConnect ),
    95     iEventHandler( aEventHandler ),
    86     iEventHandler( aEventHandler ),
    96     iIsSyncStartedSignaled( EFalse )
    87     iIsSyncStartedSignaled( EFalse )
    97     {
    88     {
    98     FUNC_LOG;
    89     FUNC_LOG;
   106 CIpsPlgImap4ConnectOp::~CIpsPlgImap4ConnectOp()
    97 CIpsPlgImap4ConnectOp::~CIpsPlgImap4ConnectOp()
   107     {
    98     {
   108     FUNC_LOG;
    99     FUNC_LOG;
   109     Cancel();
   100     Cancel();
   110     delete iSelection;
   101     delete iSelection;
   111     iState = EStateIdle;
   102     // <qmail> setting state in destructor makes no sense
   112     }
   103     }
   113 
   104 
   114 // ----------------------------------------------------------------------------
   105 // ----------------------------------------------------------------------------
   115 // CIpsPlgImap4ConnectOp::ConstructL()
   106 // CIpsPlgImap4ConnectOp::ConstructL()
   116 // ----------------------------------------------------------------------------
   107 // ----------------------------------------------------------------------------
   128     if ( tentry.iType.iUid != KUidMsvServiceEntryValue )
   119     if ( tentry.iType.iUid != KUidMsvServiceEntryValue )
   129         {
   120         {
   130         User::Panic( KIpsPlgIpsConnPanic, KErrNotSupported );
   121         User::Panic( KIpsPlgIpsConnPanic, KErrNotSupported );
   131         }
   122         }
   132     
   123     
   133 	iState = EStateStartConnect;
   124     // <qmail> moved here from StartL which was removed
       
   125     if ( Connected() && iDoPlainConnect )
       
   126         {
       
   127         // trivial case: connect requested, but already connected
       
   128         // (sync is done automatically on background)
       
   129         iState = EStateIdle;
       
   130         }
       
   131     else
       
   132         {
       
   133         iState = EStateStartConnect;
       
   134         }
   134     iStatus = KRequestPending;    
   135     iStatus = KRequestPending;    
   135     SetActive();
   136     // <qmail> SetActive(); moved inside CompleteThis();
   136     CompleteThis();
   137     CompleteThis();
   137     }
   138     }
   138 
   139 
   139 // ----------------------------------------------------------------------------
   140 // ----------------------------------------------------------------------------
   140 // CIpsPlgImap4ConnectOp::ProgressL()
   141 // CIpsPlgImap4ConnectOp::ProgressL()
   145     FUNC_LOG;
   146     FUNC_LOG;
   146     if( iError != KErrNone )
   147     if( iError != KErrNone )
   147         {
   148         {
   148         return GetErrorProgressL( iError );
   149         return GetErrorProgressL( iError );
   149         }
   150         }
   150     else if(iOperation)
   151     else if( iSubOperation )
   151         {
   152         {
   152         return iOperation->ProgressL();
   153         return iSubOperation->ProgressL();
   153         }
   154         }
   154         
   155         
   155     TImap4CompoundProgress& prog = iProgressBuf();
   156     TImap4CompoundProgress& prog = iProgressBuf();
   156     prog.iGenericProgress.iErrorCode = KErrNone;
   157     prog.iGenericProgress.iErrorCode = KErrNone;
   157     return iProgressBuf;
   158     return iProgressBuf;
   179     // might not never called, but gives something reasonable if called
   180     // might not never called, but gives something reasonable if called
   180     TFSProgress result = { TFSProgress::EFSStatus_Waiting, 0, 0, KErrNone };
   181     TFSProgress result = { TFSProgress::EFSStatus_Waiting, 0, 0, KErrNone };
   181     result.iError = KErrNone;
   182     result.iError = KErrNone;
   182     switch( iState )
   183     switch( iState )
   183         {
   184         {
   184         case EStateQueryingDetails:
   185         // <qmail> case EStateQueryingDetails removed
   185             result.iProgressStatus = TFSProgress::EFSStatus_Authenticating;
       
   186             break;
       
   187         case EStateStartConnect:
   186         case EStateStartConnect:
   188             result.iProgressStatus = TFSProgress::EFSStatus_Started;
   187             result.iProgressStatus = TFSProgress::EFSStatus_Started;
   189             break;
   188             break;
   190         case EStateConnectAndSync:
   189         case EStateConnectAndSync:
   191             result.iProgressStatus = TFSProgress::EFSStatus_Connecting;
   190             result.iProgressStatus = TFSProgress::EFSStatus_Connecting;
   204     }
   203     }
   205 
   204 
   206 // ----------------------------------------------------------------------------
   205 // ----------------------------------------------------------------------------
   207 // CIpsPlgImap4ConnectOp::IpsOpType()
   206 // CIpsPlgImap4ConnectOp::IpsOpType()
   208 // ----------------------------------------------------------------------------
   207 // ----------------------------------------------------------------------------
   209 // 
   208 // <qmail> return type
   210 TInt CIpsPlgImap4ConnectOp::IpsOpType() const
   209 TIpsOpType CIpsPlgImap4ConnectOp::IpsOpType() const
   211     {
   210     {
   212     FUNC_LOG;
   211     FUNC_LOG;
   213     return EIpsOpTypeImap4SyncOp;
   212     return EIpsOpTypeImap4SyncOp;
   214     }
   213     }
   215 
   214 
   219 // ----------------------------------------------------------------------------
   218 // ----------------------------------------------------------------------------
   220 // 
   219 // 
   221 void CIpsPlgImap4ConnectOp::DoCancel()
   220 void CIpsPlgImap4ConnectOp::DoCancel()
   222     {
   221     {
   223     FUNC_LOG;
   222     FUNC_LOG;
   224     if( iOperation )
   223     if( iSubOperation )
   225         {
   224         {
   226         iOperation->Cancel();
   225         iSubOperation->Cancel();
   227         }
   226         }
   228     SignalSyncCompleted( KErrCancel );
   227     SignalSyncCompleted( KErrCancel );
   229     CompleteObserver( KErrCancel );
   228     CompleteObserver( KErrCancel );
   230     }
   229     }
   231 
   230 
   234 // ----------------------------------------------------------------------------    
   233 // ----------------------------------------------------------------------------    
   235 //  
   234 //  
   236 void CIpsPlgImap4ConnectOp::DoRunL()
   235 void CIpsPlgImap4ConnectOp::DoRunL()
   237     {
   236     {
   238     FUNC_LOG;
   237     FUNC_LOG;
   239     TInt err = KErrNone;
   238     TInt err( KErrNone );
   240     __ASSERT_DEBUG( !(iOperation && iOperation->IsActive()), 
   239     __ASSERT_DEBUG( !(iSubOperation && iSubOperation->IsActive()),
   241             User::Panic( KIpsPlgPanicCategory, KErrGeneral ) );
   240         User::Panic( KIpsPlgPanicCategory, KErrGeneral ) );
   242     if ( iOperation )
   241     if ( iSubOperation )
   243         {
   242         {
   244         err = iOperation->iStatus.Int();
   243         err = iSubOperation->iStatus.Int();
   245         delete iOperation;
   244         delete iSubOperation;
   246         iOperation = NULL;
   245         iSubOperation = NULL;
   247         }
   246         }
   248     
   247     
   249     switch( iState )
   248     switch( iState )
   250         {
   249         {
   251         case EStateQueryingDetails:
   250         // <qmail> removing case EStateQueryingDetails
   252             
       
   253             if ( KErrNone != err )
       
   254                 {
       
   255                 // user might be cancelled query
       
   256                 // or it IS EMPTY
       
   257                 iError = err;
       
   258                 iState = EStateIdle;
       
   259                 }
       
   260             else
       
   261                 {
       
   262                 // Retry connect.
       
   263                 DoConnectOpL();
       
   264                 }
       
   265             break;
       
   266         case EStateStartConnect:
   251         case EStateStartConnect:
   267         	StartL();
   252             // <qmail> remove StartL() func and replace it directly with DoConnectOpL
   268         	break;
   253             DoConnectOpL();
       
   254             break;
   269         case EStateConnectAndSync:
   255         case EStateConnectAndSync:
   270             // Connection completed
   256             // Connection completed
   271                 
   257                 
   272             if( err == KErrImapBadLogon )
   258             // <qmail> all errors should fail the op
       
   259             if( err )
   273                 {
   260                 {
   274                 // Login details are wrong.
   261                 iState = EStateIdle;
   275                 QueryUserPwdL();
   262                 // <qmail> SetActive(); moved inside CompleteThis();
   276                 iState = EStateQueryingDetails;
   263                 CompleteThis();
   277                 
       
   278                 err = KErrNone;
       
   279                 }
   264                 }
   280             else if ( err == KErrNone )
   265             else
   281                 {
   266                 {
   282                 // no errors in connection
   267                 // no errors in connection
   283                 if( !iDoPlainConnect )
   268                 if( !iDoPlainConnect )
   284                     {
   269                     {
   285                     DoPopulateAllL();
   270                     DoPopulateAllL();
   286                     }
   271                     }
   287                 else
   272                 else
   288                     {
   273                     {
   289                     // Get on with others using this class for connection only
   274                     // Get on with others using this class for connection only
   290                     iState = EStateIdle;
   275                     iState = EStateIdle;
   291                     SetActive();
   276                     // <qmail> SetActive(); moved inside CompleteThis();
   292                     CompleteThis();
   277                     CompleteThis();
   293                     }
   278                     }
   294                 }
   279                 }
   295             break;
   280             break;
   296         case EStatePopulateAllCompleted:
   281         case EStatePopulateAllCompleted:
   297             CIpsPlgSyncStateHandler::SaveSuccessfulSyncTimeL(
   282             CIpsPlgSyncStateHandler::SaveSuccessfulSyncTimeL( iMsvSession, iService );
   298                     iMsvSession, iService );
       
   299             // break command is intentially left out
   283             // break command is intentially left out
   300         case EStateCompleted:
   284         case EStateCompleted:
   301             if ( err == KErrNone )
   285             if ( err == KErrNone )
   302                 {
   286                 {
   303                 iState = EStateIdle;
   287                 iState = EStateIdle;
   304                 SetActive();
   288                 // <qmail> SetActive(); moved inside CompleteThis();
   305                 CompleteThis();
   289                 CompleteThis();
   306                 }
   290                 }
   307             break;
   291             break;
   308         case EStateIdle:
   292         case EStateIdle:
   309         default:
   293         default:
   310             if ( iOperation )
   294             if ( iSubOperation )
   311                 {
   295                 {
   312                 delete iOperation;
   296                 delete iSubOperation;
   313                 iOperation = NULL;
   297                 iSubOperation = NULL;
   314                 }
   298                 }
   315             CompleteObserver();
   299             CompleteObserver();
   316             break;
   300             break;
   317         }
   301         }
   318    
   302    
   322         {
   306         {
   323         SignalSyncCompleted( err );
   307         SignalSyncCompleted( err );
   324         }
   308         }
   325     }
   309     }
   326 
   310 
   327 // ----------------------------------------------------------------------------
   311 // <qmail> CIpsPlgImap4ConnectOp::HandleImapConnectionEvent() removed
   328 // CIpsPlgImap4ConnectOp::HandleImapConnectionEvent()
       
   329 // ----------------------------------------------------------------------------
       
   330 // 
       
   331 void CIpsPlgImap4ConnectOp::HandleImapConnectionEvent(
       
   332     TImapConnectionEvent /*aConnectionEvent*/ )
       
   333     {
       
   334     //not used at the moment
       
   335     }
       
   336 
   312 
   337 // ----------------------------------------------------------------------------
   313 // ----------------------------------------------------------------------------
   338 // CIpsPlgImap4ConnectOp::RequestResponseL()
   314 // CIpsPlgImap4ConnectOp::RequestResponseL()
   339 // ----------------------------------------------------------------------------    
   315 // ----------------------------------------------------------------------------    
   340 //   
   316 //   
   353     FUNC_LOG;
   329     FUNC_LOG;
   354     iBaseMtm->SwitchCurrentEntryL( iService );
   330     iBaseMtm->SwitchCurrentEntryL( iService );
   355 
   331 
   356     iSelection->ResizeL(0);
   332     iSelection->ResizeL(0);
   357     iSelection->AppendL(iService);
   333     iSelection->AppendL(iService);
   358     
   334 
       
   335     // <qmail>
       
   336     iStatus = KRequestPending;
   359     if ( iDoPlainConnect && !Connected() )
   337     if ( iDoPlainConnect && !Connected() )
   360         {
   338         {
   361         TBuf8<1> parameter;
   339         TBuf8<1> parameter;
   362         iStatus = KRequestPending;
       
   363         // connect and synchronise starts background sync or idle
   340         // connect and synchronise starts background sync or idle
   364         iOperation = iBaseMtm->InvokeAsyncFunctionL(
   341         iSubOperation = iBaseMtm->InvokeAsyncFunctionL(
   365                 KIMAP4MTMConnect, *iSelection, parameter, iStatus);
   342             KIMAP4MTMConnect, *iSelection, parameter, iStatus);
   366         // also set sync started
       
   367         SignalSyncStarted();
       
   368         iState = EStateConnectAndSync;
       
   369         SetActive();
       
   370         }
   343         }
   371     else if ( Connected() )
   344     else if ( Connected() )
   372         {
   345         {
   373         // in this point cant use "connect and do something" commands,
   346         // in this point cant use "connect and do something" commands,
   374         // use regular sync, when new mails is populated elsewhere.
   347         // use regular sync, when new mails is populated elsewhere.
   375         TBuf8<1> parameter;
   348         TBuf8<1> parameter;
   376         iStatus = KRequestPending;
   349         iSubOperation = iBaseMtm->InvokeAsyncFunctionL(
   377         iOperation = iBaseMtm->InvokeAsyncFunctionL(
   350             KIMAP4MTMFullSync, *iSelection, parameter, iStatus);
   378                 KIMAP4MTMFullSync, *iSelection, parameter, iStatus);
       
   379         // also set sync started
       
   380         SignalSyncStarted();
       
   381         iState = EStateConnectAndSync;
       
   382         SetActive();
       
   383         }
   351         }
   384     else
   352     else
   385         {
   353         {
   386         TPckg<MMsvImapConnectionObserver*> parameter(this);
   354         // the used command requires an observer to be given even though we're not using it
   387         // connect and synchronise starts background sync or idle
   355         TPckg<MMsvImapConnectionObserver*> parameter( NULL );
   388         iStatus = KRequestPending;
   356         iSubOperation = iBaseMtm->InvokeAsyncFunctionL(
   389         iOperation = iBaseMtm->InvokeAsyncFunctionL(
   357             KIMAP4MTMConnectAndSyncCompleteAfterFullSync, 
   390                 KIMAP4MTMConnectAndSyncCompleteAfterFullSync, 
   358             *iSelection, parameter, iStatus );
   391                 *iSelection, parameter, iStatus);
   359         }
   392         SignalSyncStarted();
   360     SignalSyncStarted();
   393         iState = EStateConnectAndSync;
   361     iState = EStateConnectAndSync;
   394         SetActive();
   362     SetActive();
   395         }
   363     // </qmail>
   396 	}
   364 	}
   397 
   365 
   398 // ----------------------------------------------------------------------------
   366 // ----------------------------------------------------------------------------
   399 // CIpsPlgImap4ConnectOp::DoPopulateAll()
   367 // CIpsPlgImap4ConnectOp::DoPopulateAll()
   400 // ---------------------------------------------------------------------------- 
   368 // ---------------------------------------------------------------------------- 
   401 void CIpsPlgImap4ConnectOp::DoPopulateAllL()
   369 void CIpsPlgImap4ConnectOp::DoPopulateAllL()
   402     {
   370     {
   403     FUNC_LOG;
   371     FUNC_LOG;
   404     
   372     
   405     // construct partial fetch info according to imap settings
   373     // construct partial fetch info according to imap settings
   406     CImImap4Settings* settings = new ( ELeave ) CImImap4Settings();
   374     // <qmail> new function to wrap settings loading
   407     CleanupStack::PushL( settings );
   375     CImImap4Settings* settings = GetImapSettingsLC();
   408     CEmailAccounts* accounts = CEmailAccounts::NewLC();
       
   409     TImapAccount imapAcc;
       
   410     accounts->GetImapAccountL(iService, imapAcc );
       
   411     accounts->LoadImapSettingsL( imapAcc, *settings );
       
   412     TImImap4GetPartialMailInfo info;
   376     TImImap4GetPartialMailInfo info;
   413     ConstructImapPartialFetchInfo( info, *settings );
   377     ConstructImapPartialFetchInfo( info, *settings );
   414     TPckgBuf<TImImap4GetPartialMailInfo> package(info);
   378     TPckgBuf<TImImap4GetPartialMailInfo> package(info);
   415     CleanupStack::PopAndDestroy( 2, settings );
   379     CleanupStack::PopAndDestroy( settings );
   416     
   380     settings = NULL;
       
   381     
       
   382     // do populate operation unless only headers should be fetched
   417     if ( info.iTotalSizeLimit != KIpsSetDataHeadersOnly )
   383     if ( info.iTotalSizeLimit != KIpsSetDataHeadersOnly )
   418         {
   384         {
   419         SignalSyncStarted();
   385         // Update iSelection (which will be given to populate op)
   420         CMsvEntry* cEntry = iMsvSession.GetEntryL( iService );
   386         // <qmail> new function to wrap iSelection populating
   421         CleanupStack::PushL( cEntry );
   387         CreateInboxMessagesSelectionL();
   422         CMsvEntrySelection* childrenSelection = cEntry->ChildrenL();
   388         
   423         CleanupStack::PushL( childrenSelection );
       
   424         if ( childrenSelection->Count() )
       
   425             {
       
   426             // only inbox is set, do we have to populate other folders also
       
   427             TMsvId id = (*childrenSelection)[0];
       
   428             CMsvEntry* cEntry2 = iMsvSession.GetEntryL( id );
       
   429             CleanupStack::PushL( cEntry2 );
       
   430             delete iSelection;
       
   431             iSelection = NULL;
       
   432             iSelection = cEntry2->ChildrenWithTypeL( KUidMsvMessageEntry );
       
   433             CleanupStack::PopAndDestroy( cEntry2 );
       
   434             
       
   435             }
       
   436         CleanupStack::PopAndDestroy( childrenSelection );
       
   437     
       
   438         iStatus = KRequestPending;
   389         iStatus = KRequestPending;
   439         CIpsPlgTimerOperation* dummy = NULL;
       
   440         iBaseMtm->SwitchCurrentEntryL( iService );
   390         iBaseMtm->SwitchCurrentEntryL( iService );
   441         iOperation = CIpsPlgImap4PopulateOp::NewL(
   391         // <qmail> priority parameter has been removed
   442                 iMsvSession,
   392         iSubOperation = CIpsPlgImap4PopulateOp::NewL(
   443                 this->iStatus,
   393             iMsvSession,
   444                 CActive::EPriorityLow,
   394             iStatus,
   445                 iService,
   395             iService,
   446                 *dummy,
   396             // <qmail> passing in activity timer; only place where NULL "reference" was used
   447                 info,
   397             // <qmail> -> can get rid of checking existence of a reference memeber...
   448                 *iSelection,
   398             iActivityTimer,
   449                 iFSMailboxId,
   399             info,
   450                 *this,
   400             *iSelection,
   451                 0,
   401             iFSMailboxId,
   452                 iEventHandler );
   402             NULL, // no observer for suboperation
       
   403             0, // requestId can be 0
       
   404             iEventHandler );
   453         
   405         
   454         SetActive();
   406         SetActive();
   455         CleanupStack::PopAndDestroy( cEntry );
   407         // <qmail> SignalSyncStarted signal moved to happen later in case something goes wrong
       
   408         SignalSyncStarted();
   456         }
   409         }
   457     else
   410     else
   458         {
   411         {
   459         SetActive();
   412         // <qmail> SetActive(); moved inside CompleteThis();
   460         CompleteThis();
   413         CompleteThis();
   461         }
   414         }
   462     iState = EStatePopulateAllCompleted;
   415     iState = EStatePopulateAllCompleted;
   463     }
   416     }
   464 
   417 
   465 // ----------------------------------------------------------------------------
   418 // <qmail> remove CIpsPlgImap4ConnectOp::StartL()
   466 // CIpsPlgImap4ConnectOp::StartL()
   419 // <qmail> remove CIpsPlgImap4ConnectOp::QueryUserPwdL()
   467 // ----------------------------------------------------------------------------    
   420 // <qmail> remove CIpsPlgImap4ConnectOp::GetOperationErrorCodeL()
   468 // 
       
   469 void CIpsPlgImap4ConnectOp::StartL()
       
   470     {
       
   471     FUNC_LOG;
       
   472     if ( Connected() && iDoPlainConnect )
       
   473         {
       
   474         // sync is done background, no explicit supported
       
   475         iState = EStateIdle;
       
   476         SetActive();
       
   477         CompleteThis();
       
   478         }
       
   479     else 
       
   480         {
       
   481         DoConnectOpL();
       
   482         }
       
   483     }    
       
   484 
       
   485 // ----------------------------------------------------------------------------
       
   486 // CIpsPlgImap4ConnectOp::QueryUserPwdL()
       
   487 // ----------------------------------------------------------------------------
       
   488 // 
       
   489 void CIpsPlgImap4ConnectOp::QueryUserPwdL()
       
   490     {
       
   491     iEventHandler->QueryUsrPassL( iService, this );
       
   492     }
       
   493 
       
   494     
       
   495 // ----------------------------------------------------------------------------
       
   496 // CIpsPlgImap4ConnectOp::GetOperationErrorCodeL()
       
   497 // ----------------------------------------------------------------------------    
       
   498 //     
       
   499 /*TInt CIpsPlgImap4ConnectOp::GetOperationErrorCodeL( )
       
   500     {
       
   501     if ( !iOperation )
       
   502         {
       
   503         return KErrNotFound;
       
   504         }
       
   505     if ( !iOperation->IsActive() && iOperation->iStatus.Int() != KErrNone )
       
   506         {
       
   507         return iOperation->iStatus.Int();
       
   508         }
       
   509      
       
   510     TPckgBuf<TImap4CompoundProgress> paramPack;
       
   511     paramPack.Copy( iOperation->ProgressL() );
       
   512     const TImap4CompoundProgress& comProgg = paramPack();
       
   513 
       
   514     return comProgg.iGenericProgress.iErrorCode;
       
   515     }*/
       
   516 
   421 
   517 // ----------------------------------------------------------------------------
   422 // ----------------------------------------------------------------------------
   518 // ----------------------------------------------------------------------------       
   423 // ----------------------------------------------------------------------------       
   519 void CIpsPlgImap4ConnectOp::SignalSyncStarted()
   424 void CIpsPlgImap4ConnectOp::SignalSyncStarted()
   520     {
   425     {
   522     if ( iEventHandler && !iIsSyncStartedSignaled )
   427     if ( iEventHandler && !iIsSyncStartedSignaled )
   523         {
   428         {
   524         // mark that sync is signaled to prevent 
   429         // mark that sync is signaled to prevent 
   525         // sending necessary event
   430         // sending necessary event
   526         iIsSyncStartedSignaled = ETrue;
   431         iIsSyncStartedSignaled = ETrue;
   527         iEventHandler->SetNewPropertyEvent( 
   432         iEventHandler->SetNewPropertyEvent( iService, KIpsSosEmailSyncStarted, KErrNone );
   528                 iService, KIpsSosEmailSyncStarted, KErrNone );
       
   529         }
   433         }
   530     }
   434     }
   531 
   435 
   532 // ----------------------------------------------------------------------------
   436 // ----------------------------------------------------------------------------
   533 // ----------------------------------------------------------------------------       
   437 // ----------------------------------------------------------------------------       
   534 void CIpsPlgImap4ConnectOp::SignalSyncCompleted( TInt aError )
   438 void CIpsPlgImap4ConnectOp::SignalSyncCompleted( TInt aError )
   535     {
   439     {
   536     FUNC_LOG;
   440     FUNC_LOG;
   537     if ( iEventHandler && aError == KErrImapBadLogon )
   441     // <qmail> don't test for aError code; all situations should complete op
   538         {
   442     if ( iEventHandler )
   539         iEventHandler->SetNewPropertyEvent( 
   443         {
   540                 iService, KIpsSosEmailSyncCompleted, aError );
   444         iEventHandler->SetNewPropertyEvent( iService, KIpsSosEmailSyncCompleted, aError );
   541         iIsSyncStartedSignaled = EFalse;
   445         iIsSyncStartedSignaled = EFalse;
   542         }
   446         }
   543     }
   447     }
   544 
   448 
   545 
   449 // <qmail> Removing CIpsPlgImap4ConnectOp::CredientialsSetL 
   546 // ----------------------------------------------------------------------------
       
   547 // ----------------------------------------------------------------------------
       
   548 void CIpsPlgImap4ConnectOp::CredientialsSetL( TInt aEvent )
       
   549     {
       
   550     FUNC_LOG;
       
   551     if ( aEvent == EIPSSosCredientialsCancelled )
       
   552         {
       
   553         CompleteObserver( KErrCancel );
       
   554         }
       
   555     //password has been set, continue with operation
       
   556     
       
   557     SetActive();
       
   558     CompleteThis();
       
   559     }
       
   560 
   450 
   561 // <qmail>
   451 // <qmail>
   562 // ----------------------------------------------------------------------------
   452 // ----------------------------------------------------------------------------
   563 // ----------------------------------------------------------------------------
   453 // ----------------------------------------------------------------------------
   564 void CIpsPlgImap4ConnectOp::ConstructImapPartialFetchInfo( 
   454 void CIpsPlgImap4ConnectOp::ConstructImapPartialFetchInfo( 
   565         TImImap4GetPartialMailInfo& aInfo, CImImap4Settings& aImap4Settings )
   455     TImImap4GetPartialMailInfo& aInfo, 
   566 
   456     const CImImap4Settings& aImap4Settings )
   567     {
   457     {
   568     FUNC_LOG;
   458     FUNC_LOG;
   569     TInt sizeLimit = aImap4Settings.BodyTextSizeLimit();
   459     TInt sizeLimit = aImap4Settings.BodyTextSizeLimit();
   570     
   460     
   571     if ( sizeLimit == KIpsSetDataHeadersOnly )
   461     if ( sizeLimit == KIpsSetDataHeadersOnly )
   591         aInfo.iGetMailBodyParts = EGetImap4EmailBodyAlternativeText;
   481         aInfo.iGetMailBodyParts = EGetImap4EmailBodyAlternativeText;
   592         }
   482         }
   593     else
   483     else
   594         {
   484         {
   595         aInfo.iTotalSizeLimit = sizeLimit*1024; 
   485         aInfo.iTotalSizeLimit = sizeLimit*1024; 
   596         // set zero when it not documentated does total size overrides these 
       
   597         aInfo.iAttachmentSizeLimit = 0;
   486         aInfo.iAttachmentSizeLimit = 0;
   598         aInfo.iMaxEmailSize = sizeLimit*1024;
   487         aInfo.iMaxEmailSize = sizeLimit*1024;
   599         aInfo.iBodyTextSizeLimit = sizeLimit*1024;
   488         aInfo.iBodyTextSizeLimit = sizeLimit*1024;
   600         aInfo.iPartialMailOptions = EBodyAlternativeText;
   489         aInfo.iPartialMailOptions = EBodyAlternativeText;
   601         aInfo.iGetMailBodyParts = EGetImap4EmailBodyAlternativeText;
   490         aInfo.iGetMailBodyParts = EGetImap4EmailBodyAlternativeText;
   602         }
   491         }
   603     }
   492     }
       
   493 
       
   494 // ----------------------------------------------------------------------------
       
   495 // ----------------------------------------------------------------------------
       
   496 CImImap4Settings* CIpsPlgImap4ConnectOp::GetImapSettingsLC()
       
   497     {
       
   498     FUNC_LOG;
       
   499     CImImap4Settings* settings = new ( ELeave ) CImImap4Settings();
       
   500     CleanupStack::PushL( settings );
       
   501     CEmailAccounts* accounts = CEmailAccounts::NewLC();
       
   502     TImapAccount imapAcc;
       
   503     accounts->GetImapAccountL(iService, imapAcc );
       
   504     accounts->LoadImapSettingsL( imapAcc, *settings );
       
   505     CleanupStack::PopAndDestroy( accounts );
       
   506     return settings;
       
   507     }
       
   508 
       
   509 // ----------------------------------------------------------------------------
       
   510 // ----------------------------------------------------------------------------
       
   511 void CIpsPlgImap4ConnectOp::CreateInboxMessagesSelectionL()
       
   512     {
       
   513     FUNC_LOG;
       
   514     // get children of service entry 
       
   515     CMsvEntry* cEntry = iMsvSession.GetEntryL( iService );
       
   516     CleanupStack::PushL( cEntry );
       
   517     CMsvEntrySelection* childrenSelection = cEntry->ChildrenL();
       
   518     CleanupStack::PopAndDestroy( cEntry );
       
   519     cEntry = NULL;
       
   520     CleanupStack::PushL( childrenSelection );
       
   521 
       
   522     if ( childrenSelection->Count() )
       
   523         {
       
   524         TMsvId id = (*childrenSelection)[0]; // index 0 == inbox
       
   525         cEntry = iMsvSession.GetEntryL( id ); // reusing cEntry pointer for Inbox entry
       
   526         CleanupStack::PushL( cEntry );
       
   527         delete iSelection;
       
   528         iSelection = NULL;
       
   529         // get message-type children of inbox
       
   530         iSelection = cEntry->ChildrenWithTypeL( KUidMsvMessageEntry );
       
   531         CleanupStack::PopAndDestroy( cEntry );
       
   532         }
       
   533     CleanupStack::PopAndDestroy( childrenSelection );
       
   534     }
       
   535 
   604 // </qmail>
   536 // </qmail>
   605 // End of File
       
   606