ipsservices/ipssosplugin/src/ipsplgpop3connectop.cpp
changeset 43 99bcbff212ad
parent 23 2dc6caa42ec3
child 56 15bc1d5d6267
equal deleted inserted replaced
42:139d4b7b2938 43:99bcbff212ad
    28 
    28 
    29 // ----------------------------------------------------------------------------
    29 // ----------------------------------------------------------------------------
    30 // CIpsPlgPop3ConnectOp::NewL()
    30 // CIpsPlgPop3ConnectOp::NewL()
    31 // ----------------------------------------------------------------------------
    31 // ----------------------------------------------------------------------------
    32 // <qmail> MFSMailRequestObserver& changed to pointer
    32 // <qmail> MFSMailRequestObserver& changed to pointer
    33 // <qmail> aSignallingAllowed parameter removed
    33 // <qmail> aSignallingAllowed parameter added
       
    34 // <qmail> aFetchWillFollow parameter added
    34 CIpsPlgPop3ConnectOp* CIpsPlgPop3ConnectOp::NewL(
    35 CIpsPlgPop3ConnectOp* CIpsPlgPop3ConnectOp::NewL(
    35     CMsvSession& aMsvSession,                           
    36     CMsvSession& aMsvSession,                           
    36     TRequestStatus& aObserverRequestStatus,
    37     TRequestStatus& aObserverRequestStatus,
    37     TMsvId aService,
    38     TMsvId aService,
    38     TBool aForcePopulate,
    39     TBool aForcePopulate,
    39     CIpsPlgTimerOperation& aActivityTimer,
    40     CIpsPlgTimerOperation& aActivityTimer,
    40     TFSMailMsgId aFSMailBoxId,
    41     TFSMailMsgId aFSMailBoxId,
    41     MFSMailRequestObserver* aFSOperationObserver,
    42     MFSMailRequestObserver* aFSOperationObserver,
    42     TInt aFSRequestId,
    43     TInt aFSRequestId,
    43     CIpsPlgEventHandler* aEventHandler )
    44     CIpsPlgEventHandler* aEventHandler,
       
    45     TBool aSignallingAllowed,
       
    46     TBool aFetchWillFollow )
    44     {
    47     {
    45     FUNC_LOG;
    48     FUNC_LOG;
    46     CIpsPlgPop3ConnectOp* op = new(ELeave) CIpsPlgPop3ConnectOp(
    49     CIpsPlgPop3ConnectOp* op = new(ELeave) CIpsPlgPop3ConnectOp(
    47         aMsvSession,
    50         aMsvSession,
    48         aObserverRequestStatus,
    51         aObserverRequestStatus,
    50         aForcePopulate,
    53         aForcePopulate,
    51         aActivityTimer,
    54         aActivityTimer,
    52         aFSMailBoxId,
    55         aFSMailBoxId,
    53         aFSOperationObserver,
    56         aFSOperationObserver,
    54         aFSRequestId,
    57         aFSRequestId,
    55         aEventHandler );
    58         aEventHandler,
       
    59         aSignallingAllowed,
       
    60         aFetchWillFollow );
    56 
    61 
    57     CleanupStack::PushL( op );
    62     CleanupStack::PushL( op );
    58     op->ConstructL();
    63     op->ConstructL();
    59     CleanupStack::Pop( op );
    64     CleanupStack::Pop( op );
    60     return op;
    65     return op;
   110 // ----------------------------------------------------------------------------
   115 // ----------------------------------------------------------------------------
   111 //
   116 //
   112 void CIpsPlgPop3ConnectOp::DoRunL()
   117 void CIpsPlgPop3ConnectOp::DoRunL()
   113     {
   118     {
   114     FUNC_LOG;
   119     FUNC_LOG;
   115     // <qmail> move TInt err declaration later, and narrow the scope
   120     TInt err( KErrNone );
   116 
   121 
   117     // <qmail> remove EQueryingDetails state
   122     // <qmail> remove EQueryingDetails state
   118     if ( iState == EStartConnect )
   123     if ( iState == EStartConnect )
   119         {
   124         {
   120         if ( iSubOperation )
   125         if ( iSubOperation )
   131         iState = EConnected;
   136         iState = EConnected;
   132         }
   137         }
   133     else if ( iState == EConnected )
   138     else if ( iState == EConnected )
   134         {
   139         {
   135         // Connect completed
   140         // Connect completed
   136 // <qmail> Login details checking removed
   141         // <qmail> Login details checking removed
   137         User::LeaveIfError( iStatus.Int() );
   142         err = GetOperationErrorCodeL( );
       
   143         User::LeaveIfError( err );
       
   144 
   138         if ( iForcePopulate && Connected() )
   145         if ( iForcePopulate && Connected() )
   139             {
   146             {
   140             iState = EPopulate;
   147             iState = EPopulate;
   141             DoPopulateL();
   148             DoPopulateL();
   142             }
   149             }
       
   150         // <qmail>
       
   151         else if( iFetchWillFollow && Connected() )
       
   152             {
       
   153             // Leave connection open to make fetch
       
   154             // operation possible
       
   155             iState = EIdle;
       
   156             CompleteObserver( KErrNone );
       
   157             }
       
   158         // </qmail>
   143         else
   159         else
   144             {
   160             {
   145             // <qmail>
   161             // <qmail>
   146             // start disconnecting
   162             // start disconnecting
   147             iState = EDisconnecting;
   163             iState = EDisconnecting;
   148             DoDisconnect();
   164             DoDisconnectL();
   149             // </qmail>
   165             // </qmail>
   150             }
   166             }
   151         }
   167         }
   152     else if ( iState == EPopulate )
   168     else if ( iState == EPopulate )
   153         {
   169         {
   154         // <qmail> suboperation has completed, the result is in 'this->iStatus'
   170         err = GetOperationErrorCodeL( );
   155         if ( iEventHandler )
   171         if ( iEventHandler )
   156             {
   172             {
   157             iEventHandler->SetNewPropertyEvent( iService, KIpsSosEmailSyncCompleted, iStatus.Int() );
   173             iEventHandler->SetNewPropertyEvent( iService, KIpsSosEmailSyncCompleted, err );
   158             }
   174             }
   159         CIpsPlgSyncStateHandler::SaveSuccessfulSyncTimeL( iMsvSession, iService );
   175         CIpsPlgSyncStateHandler::SaveSuccessfulSyncTimeL( iMsvSession, iService );
   160 
   176 
   161         // <qmail>
   177         // <qmail>
   162         // start disconnecting
   178         // start disconnecting
   163         iState = EDisconnecting;
   179         iState = EDisconnecting;
   164         DoDisconnect();
   180         DoDisconnectL();
   165         // </qmail>
   181         // </qmail>
   166         }
   182         }
   167     // <qmail>
   183     // <qmail>
   168     else if ( iState == EDisconnecting )
   184     else if ( iState == EDisconnecting )
   169         {
   185         {
   238 // CIpsPlgPop3ConnectOp::CIpsPlgPop3ConnectOp
   254 // CIpsPlgPop3ConnectOp::CIpsPlgPop3ConnectOp
   239 // ----------------------------------------------------------------------------
   255 // ----------------------------------------------------------------------------
   240 //
   256 //
   241 // <qmail> priority parameter has been removed
   257 // <qmail> priority parameter has been removed
   242 // <qmail> MFSMailRequestObserver& changed to pointer
   258 // <qmail> MFSMailRequestObserver& changed to pointer
   243 // <qmail> aSignallingAllowed parameter removed
   259 // <qmail> aSignallingAllowed parameter added
       
   260 // <qmail> aFetchWillFollow parameter added
       
   261 // <qmail> iAlreadyConnected removed
   244 CIpsPlgPop3ConnectOp::CIpsPlgPop3ConnectOp(
   262 CIpsPlgPop3ConnectOp::CIpsPlgPop3ConnectOp(
   245     CMsvSession& aMsvSession,
   263     CMsvSession& aMsvSession,
   246     TRequestStatus& aObserverRequestStatus,
   264     TRequestStatus& aObserverRequestStatus,
   247     TMsvId aServiceId,
   265     TMsvId aServiceId,
   248     TBool aForcePopulate,
   266     TBool aForcePopulate,
   249     CIpsPlgTimerOperation& aActivityTimer,
   267     CIpsPlgTimerOperation& aActivityTimer,
   250     TFSMailMsgId aFSMailBoxId,
   268     TFSMailMsgId aFSMailBoxId,
   251     MFSMailRequestObserver* aFSOperationObserver,
   269     MFSMailRequestObserver* aFSOperationObserver,
   252     TInt aFSRequestId,
   270     TInt aFSRequestId,
   253     CIpsPlgEventHandler* aEventHandler )
   271     CIpsPlgEventHandler* aEventHandler,
       
   272     TBool aSignallingAllowed,
       
   273     TBool aFetchWillFollow )
   254     :
   274     :
   255     CIpsPlgOnlineOperation(
   275     CIpsPlgOnlineOperation(
   256         aMsvSession,
   276         aMsvSession,
   257         aObserverRequestStatus, 
   277         aObserverRequestStatus, 
   258         aActivityTimer, 
   278         aActivityTimer, 
   259         aFSMailBoxId,
   279         aFSMailBoxId,
   260         aFSOperationObserver, 
   280         aFSOperationObserver, 
   261         aFSRequestId ),
   281         aFSRequestId,
       
   282         aSignallingAllowed ),
   262     iState( EIdle ),
   283     iState( EIdle ),
   263     iForcePopulate( aForcePopulate ),
   284     iForcePopulate( aForcePopulate ),
   264     iEventHandler( aEventHandler ),
   285     iEventHandler( aEventHandler ),
   265     iAlreadyConnected( EFalse )
   286     iFetchWillFollow( aFetchWillFollow )
   266     {
   287     {
   267     iService = aServiceId; 
   288     iService = aServiceId; 
   268     }
   289     }
   269 
   290 
   270 // ----------------------------------------------------------------------------
   291 // ----------------------------------------------------------------------------
   295     // <qmail> it is read from settings when needed
   316     // <qmail> it is read from settings when needed
   296     
   317     
   297     if ( tentry.Connected() )
   318     if ( tentry.Connected() )
   298         {      
   319         {      
   299         iState = EConnected;
   320         iState = EConnected;
   300 		iAlreadyConnected = ETrue;
   321         // <qmail> iAlreadyConnected removed
   301         }
   322         }
   302     else
   323     else
   303         {
   324         {
   304         iState = EStartConnect;
   325         iState = EStartConnect;
   305         }
   326         }
   365     return EIpsOpTypePop3SyncOp;
   386     return EIpsOpTypePop3SyncOp;
   366     }
   387     }
   367 
   388 
   368 // <qmail> removed QueryUsrPassL() from here as unneeded
   389 // <qmail> removed QueryUsrPassL() from here as unneeded
   369 // <qmail> removed ValidateL() (did nothing)
   390 // <qmail> removed ValidateL() (did nothing)
   370 // <qmail> removed TInt CIpsPlgPop3ConnectOp::GetOperationErrorCodeL( )
   391 
       
   392 // ----------------------------------------------------------------------------
       
   393 // ----------------------------------------------------------------------------    
       
   394 // 
       
   395 TInt CIpsPlgPop3ConnectOp::GetOperationErrorCodeL( )
       
   396     {
       
   397     FUNC_LOG;
       
   398     if ( !iSubOperation )
       
   399         {
       
   400         return KErrNotFound;
       
   401         }
       
   402     if ( !iSubOperation->IsActive() && iSubOperation->iStatus.Int() != KErrNone )
       
   403         {
       
   404         return iSubOperation->iStatus.Int();
       
   405         }
       
   406     
       
   407     TPckgBuf<TPop3Progress> paramPack;
       
   408     paramPack.Copy( iSubOperation->ProgressL() );
       
   409     const TPop3Progress& progress = paramPack();
       
   410     
       
   411     return progress.iErrorCode;
       
   412     }
       
   413 
   371 // <qmail> removed CIpsPlgImap4ConnectOp::CredientialsSetL
   414 // <qmail> removed CIpsPlgImap4ConnectOp::CredientialsSetL
   372 
   415 
   373 //<qmail> new functions
   416 //<qmail> new functions
   374 // ----------------------------------------------------------------------------
   417 // ----------------------------------------------------------------------------
   375 // ----------------------------------------------------------------------------
   418 // ----------------------------------------------------------------------------
   376 void CIpsPlgPop3ConnectOp::DoDisconnect()
   419 void CIpsPlgPop3ConnectOp::DoDisconnectL()
   377     {
   420     {
   378     FUNC_LOG;
   421     FUNC_LOG;
   379     // <qmail> unnecessary: iStatus = KRequestPending;
   422     // <qmail> unnecessary: iStatus = KRequestPending;
   380     InvokeClientMtmAsyncFunctionL( KPOP3MTMDisconnect, iService ); // <qmail> 1 param removed
   423     InvokeClientMtmAsyncFunctionL( KPOP3MTMDisconnect, iService ); // <qmail> 1 param removed
   381     SetActive();
   424     SetActive();
   396     accounts->LoadPopSettingsL( popAccountId, *settings );
   439     accounts->LoadPopSettingsL( popAccountId, *settings );
   397     limit = settings->PopulationLimit();
   440     limit = settings->PopulationLimit();
   398     if ( limit > 0 )
   441     if ( limit > 0 )
   399         {
   442         {
   400         // basically doing a _very_rough_ conversion from kilobyte value to number-of-rows
   443         // basically doing a _very_rough_ conversion from kilobyte value to number-of-rows
   401     limit = ( limit * KPopulateAlgorithmBytesInKilo ) / KPopulateAlgorithmRowLength;
   444         limit = ( limit * KPopulateAlgorithmBytesInKilo ) / KPopulateAlgorithmRowLength;
   402         }
   445         }
   403     CleanupStack::PopAndDestroy( 2, settings );
   446     CleanupStack::PopAndDestroy( 2, settings );
   404     return limit;
   447     return limit;
   405     }
   448     }
   406 
   449