ipsservices/ipssosplugin/src/ipsplgdisconnectop.cpp
branchRCL_3
changeset 64 3533d4323edc
parent 63 d189ee25cf9d
equal deleted inserted replaced
63:d189ee25cf9d 64:3533d4323edc
    13 *
    13 *
    14 * Description:  IMAP4 connect operation
    14 * Description:  IMAP4 connect operation
    15 *
    15 *
    16 */
    16 */
    17 
    17 
       
    18 
       
    19 
    18 #include "emailtrace.h"
    20 #include "emailtrace.h"
    19 #include "ipsplgheaders.h"
    21 #include "ipsplgheaders.h"
    20 
    22 
    21 // <qmail> remove priority const
    23 // Constants and defines
       
    24 const TInt KConnectOpPriority = CActive::EPriorityStandard;
    22 
    25 
    23 // ----------------------------------------------------------------------------
    26 // ----------------------------------------------------------------------------
    24 // CIpsPlgDisconnectOp::NewL()
    27 // CIpsPlgDisconnectOp::NewL()
    25 // ----------------------------------------------------------------------------
    28 // ----------------------------------------------------------------------------
    26 // <qmail> aDoRemoveAfterDisconnect parameter removed
    29 //
    27 // <qmail> MFSMailRequestObserver& changed to pointer
       
    28 CIpsPlgDisconnectOp* CIpsPlgDisconnectOp::NewL(
    30 CIpsPlgDisconnectOp* CIpsPlgDisconnectOp::NewL(
    29     CMsvSession& aMsvSession,
    31     CMsvSession& aMsvSession,
    30     TRequestStatus& aObserverRequestStatus,
    32                                            TRequestStatus& aObserverRequestStatus,
    31     TMsvId aService,
    33                                            TMsvId aService,
    32     CIpsPlgTimerOperation& aActivityTimer,
    34                                            CIpsPlgTimerOperation& aActivityTimer,
    33     TFSMailMsgId aFSMailBoxId,
    35                                            TFSMailMsgId aFSMailBoxId,
    34     MFSMailRequestObserver* aFSOperationObserver,
    36                                            MFSMailRequestObserver& aFSOperationObserver,
    35     TInt aFSRequestId )
    37                                            TInt aFSRequestId,
    36     {
    38                                            TBool aDoRemoveAfterDisconnect )
    37     FUNC_LOG;
    39     {
    38 // <qmail> aDoRemoveAfterDisconnect removed
    40     FUNC_LOG;
    39     CIpsPlgDisconnectOp* op = new(ELeave) CIpsPlgDisconnectOp(
    41     CIpsPlgDisconnectOp* op = new(ELeave) CIpsPlgDisconnectOp(aMsvSession,
    40         aMsvSession,
       
    41         aObserverRequestStatus,
    42         aObserverRequestStatus,
    42         aService,
    43         aService,
    43         aActivityTimer,
    44         aActivityTimer,
    44         aFSMailBoxId,
    45         aFSMailBoxId,
    45         aFSOperationObserver,
    46         aFSOperationObserver,
    46         aFSRequestId );
    47         aFSRequestId,
       
    48         aDoRemoveAfterDisconnect );
    47         
    49         
    48     CleanupStack::PushL(op);
    50     CleanupStack::PushL(op);
    49     op->ConstructL();
    51     op->ConstructL();
    50     CleanupStack::Pop( op );
    52     CleanupStack::Pop( op );
    51     return op;
    53     return op;
    83 //
    85 //
    84 const TDesC8& CIpsPlgDisconnectOp::GetErrorProgressL(TInt aError)
    86 const TDesC8& CIpsPlgDisconnectOp::GetErrorProgressL(TInt aError)
    85     {
    87     {
    86     FUNC_LOG;
    88     FUNC_LOG;
    87     iError = aError;
    89     iError = aError;
    88     if ( iSubOperation && iError == KErrNone )
    90     if ( iOperation && iError == KErrNone )
    89         {
    91         {
    90         return iSubOperation->ProgressL();
    92         return iOperation->ProgressL();
    91         }
    93         }
    92     
    94     
    93     if ( iTEntry.iMtm == KUidMsgTypePOP3 )
    95     if ( iTEntry.iMtm == KUidMsgTypePOP3 )
    94         {
    96         {
    95         return iPopProgress;
    97         return iPopProgress;
   119         result.iError = iStatus.Int();
   121         result.iError = iStatus.Int();
   120         }
   122         }
   121     return result;
   123     return result;
   122     }
   124     }
   123 
   125 
   124 // <qmail> Connected() moved to base class
   126 // ----------------------------------------------------------------------------
   125 
   127 // CIpsPlgDisconnectOp::Connected()
   126 // ----------------------------------------------------------------------------
   128 // ----------------------------------------------------------------------------
   127 
   129 //
       
   130 TBool CIpsPlgDisconnectOp::Connected() const
       
   131     {
       
   132     FUNC_LOG;
       
   133     return iTEntry.Connected();
       
   134     }
       
   135 
       
   136 // ----------------------------------------------------------------------------
   128 // CIpsPlgDisconnectOp::DoRunL()
   137 // CIpsPlgDisconnectOp::DoRunL()
   129 // ----------------------------------------------------------------------------
   138 // ----------------------------------------------------------------------------
   130 //
   139 //
   131 void CIpsPlgDisconnectOp::DoRunL()
   140 void CIpsPlgDisconnectOp::DoRunL()
   132     {
   141     {
   133     FUNC_LOG;
   142     FUNC_LOG;
   134 // <qmail>
   143     if( !iDisconnected )
   135     if( Connected() )
       
   136         {        
   144         {        
   137         DoDisconnectL();
   145         DoDisconnectL();
   138 // </qmail>
   146         iDisconnected = ETrue;
   139         }
   147         }
   140     else
   148     else
   141         {                
   149         {                
   142         // <qmail> iDoRemoveAfterDisconnect feature from this op has been removed
   150         if ( iDoRemoveAfterDisconnect )
       
   151             {
       
   152             CIpsSetDataApi* settings = CIpsSetDataApi::NewL( iMsvSession );
       
   153             CleanupStack::PushL( settings );
       
   154             settings->RemoveAccountL( iTEntry, iMsvSession );
       
   155             CleanupStack::PopAndDestroy( settings );
       
   156 
       
   157             // delete the activitytimer here and set it to null so we don't try 
       
   158             // to use it in CompleteObserver. This is a special case that 
       
   159             // relates to deleting a connected mailbox.
       
   160             delete iActivityTimer;
       
   161             iActivityTimer = NULL;
       
   162             }
       
   163 
   143         CompleteObserver( KErrNone );
   164         CompleteObserver( KErrNone );
   144         }
   165         }
   145     }
   166     }
   146 
   167 
   147 // ----------------------------------------------------------------------------
   168 // ----------------------------------------------------------------------------
   148 // CIpsPlgDisconnectOp::CIpsPlgDisconnectOp()
   169 // CIpsPlgDisconnectOp::CIpsPlgDisconnectOp()
   149 // ----------------------------------------------------------------------------
   170 // ----------------------------------------------------------------------------
   150 // <qmail> aDoRemoveAfterDisconnect removed
   171 //
   151 // <qmail> MFSMailRequestObserver& changed to pointer
       
   152 CIpsPlgDisconnectOp::CIpsPlgDisconnectOp(
   172 CIpsPlgDisconnectOp::CIpsPlgDisconnectOp(
   153     CMsvSession& aMsvSession,
   173     CMsvSession& aMsvSession,
   154     TRequestStatus& aObserverRequestStatus,
   174     TRequestStatus& aObserverRequestStatus,
   155     TMsvId aServiceId,
   175     TMsvId aServiceId,
   156     CIpsPlgTimerOperation& aActivityTimer,
   176     CIpsPlgTimerOperation& aActivityTimer,
   157     TFSMailMsgId aFSMailBoxId,
   177     TFSMailMsgId aFSMailBoxId,
   158     MFSMailRequestObserver* aFSOperationObserver,
   178     MFSMailRequestObserver& aFSOperationObserver,
   159     TInt aFSRequestId )
   179     TInt aFSRequestId,
       
   180     TBool aDoRemoveAfterDisconnect )
   160     :
   181     :
   161     CIpsPlgOnlineOperation(
   182     CIpsPlgOnlineOperation(
   162         aMsvSession,
   183     aMsvSession,
   163         aObserverRequestStatus,
   184     KConnectOpPriority,
   164         aActivityTimer,
   185     aObserverRequestStatus,
   165         aFSMailBoxId,
   186     aActivityTimer,
   166         aFSOperationObserver, 
   187     aFSMailBoxId,
   167         aFSRequestId )
   188     aFSOperationObserver, 
       
   189     aFSRequestId),
       
   190     iDoRemoveAfterDisconnect( aDoRemoveAfterDisconnect )
   168     {
   191     {
   169     iService = aServiceId;
   192     iService = aServiceId;
   170     }
   193     }
   171 
   194 
   172 // ----------------------------------------------------------------------------
   195 // ----------------------------------------------------------------------------
   174 // ----------------------------------------------------------------------------
   197 // ----------------------------------------------------------------------------
   175 //
   198 //
   176 void CIpsPlgDisconnectOp::ConstructL()
   199 void CIpsPlgDisconnectOp::ConstructL()
   177     {    
   200     {    
   178     FUNC_LOG;
   201     FUNC_LOG;
   179 // <qmail> iDisconnected removed
   202     iDisconnected = EFalse;
   180     TMsvId service;
   203     TMsvId service;
   181     
   204     
   182     iMsvSession.GetEntry( iService, service, iTEntry );
   205     iMsvSession.GetEntry( iService, service, iTEntry );
   183     
   206     
   184     if ( iTEntry.iType.iUid == KUidMsvServiceEntryValue )
   207     if ( iTEntry.iType.iUid == KUidMsvServiceEntryValue )
   189         {
   212         {
   190         //should we panic with own codes?
   213         //should we panic with own codes?
   191         User::Leave( KErrNotSupported );
   214         User::Leave( KErrNotSupported );
   192         }
   215         }
   193     
   216     
   194     // <qmail> SetActive(); moved inside CompleteThis();
   217     SetActive();
   195     CompleteThis();
   218     CompleteThis();
   196     }
   219     }
   197     
   220     
   198 // ----------------------------------------------------------------------------
   221 // ----------------------------------------------------------------------------
   199 // CIpsPlgDisconnectOp::DoDisconnectL()
   222 // CIpsPlgDisconnectOp::DoDisconnectL()
   201 //
   224 //
   202 void CIpsPlgDisconnectOp::DoDisconnectL()
   225 void CIpsPlgDisconnectOp::DoDisconnectL()
   203     {
   226     {
   204     FUNC_LOG;
   227     FUNC_LOG;
   205     iStatus = KRequestPending;
   228     iStatus = KRequestPending;
   206     NM_COMMENT("CIpsPlgDisconnectOp: doing disconnect");
   229     
   207     TInt cmd = (iTEntry.iMtm == KUidMsgTypePOP3) ? KPOP3MTMDisconnect : KIMAP4MTMDisconnect;
   230     TInt cmd = (iTEntry.iMtm == KUidMsgTypePOP3) ? KPOP3MTMDisconnect : KIMAP4MTMDisconnect;
   208     InvokeClientMtmAsyncFunctionL( cmd, iService ); // <qmail> 1 param removed
   231     
       
   232     InvokeClientMtmAsyncFunctionL(cmd, iService, iService);
   209     SetActive();
   233     SetActive();
   210     }
   234     }
   211 
   235 
   212 // <qmail> adding this func
       
   213 // ----------------------------------------------------------------------------
       
   214 // ----------------------------------------------------------------------------
       
   215 //
       
   216 TIpsOpType CIpsPlgDisconnectOp::IpsOpType() const
       
   217     {
       
   218     FUNC_LOG;
       
   219     if ( iTEntry.iMtm == KUidMsgTypePOP3 )
       
   220         {
       
   221         return EIpsOpTypePop3Disconnect;
       
   222         }
       
   223     else
       
   224         {
       
   225         return EIpsOpTypeImap4Disconnect;
       
   226         }
       
   227     }
       
   228 // </qmail>
       
   229