ipsservices/ipssosplugin/src/ipsplgimap4moveremoteop.cpp
branchRCL_3
changeset 64 3533d4323edc
parent 63 d189ee25cf9d
equal deleted inserted replaced
63:d189ee25cf9d 64:3533d4323edc
    14 * Description: 
    14 * Description: 
    15 *       Move a selection of messages that may or may not be complete
    15 *       Move a selection of messages that may or may not be complete
    16 *
    16 *
    17 */
    17 */
    18 
    18 
       
    19 
    19 #include "emailtrace.h"
    20 #include "emailtrace.h"
    20 #include "ipsplgheaders.h"
    21 #include "ipsplgheaders.h"
    21 
    22 
    22 // <qmail> priority parameter has been removed
    23 const TInt KMoveRemoteOpPriority = CActive::EPriorityStandard;
    23 
    24 
    24 // ----------------------------------------------------------------------------
    25 // ----------------------------------------------------------------------------
    25 // ----------------------------------------------------------------------------
    26 // ----------------------------------------------------------------------------
    26 // <qmail> TImImap4GetMailInfo& -> TMsvId&, aFunctionId removed
       
    27 // <qmail> MFSMailRequestObserver& changed to pointer
       
    28 CIpsPlgImap4MoveRemoteOp* CIpsPlgImap4MoveRemoteOp::NewL(
    27 CIpsPlgImap4MoveRemoteOp* CIpsPlgImap4MoveRemoteOp::NewL(
    29     CMsvSession& aMsvSession,
    28     CMsvSession& aMsvSession,
    30     TRequestStatus& aObserverRequestStatus,
    29     TRequestStatus& aObserverRequestStatus,
       
    30     TInt aFunctionId,
    31     TMsvId aService,
    31     TMsvId aService,
    32     CIpsPlgTimerOperation& aActivityTimer,
    32     CIpsPlgTimerOperation& aActivityTimer,
    33     const TMsvId& aDestinationFolderId,
    33     const TImImap4GetMailInfo& aGetMailInfo,
    34     const CMsvEntrySelection& aSelection,    
    34     const CMsvEntrySelection& aSel,
    35     TFSMailMsgId aFSMailBoxId,
    35     TFSMailMsgId aFSMailBoxId,
    36     MFSMailRequestObserver* aFSOperationObserver,
    36     MFSMailRequestObserver& aFSOperationObserver,
    37     TInt aFSRequestId )
    37     TInt aFSRequestId )
    38     {
    38     {
    39     FUNC_LOG;
    39     FUNC_LOG;
    40     CIpsPlgImap4MoveRemoteOp* op = new (ELeave) CIpsPlgImap4MoveRemoteOp(
    40     CIpsPlgImap4MoveRemoteOp* op = new (ELeave) CIpsPlgImap4MoveRemoteOp(
    41         aMsvSession,
    41         aMsvSession,
    42         aObserverRequestStatus,
    42         aObserverRequestStatus,
       
    43         aFunctionId,
    43         aService,
    44         aService,
    44         aActivityTimer,
    45         aActivityTimer,
    45         aDestinationFolderId,
    46         aGetMailInfo,
    46         aFSMailBoxId,
    47         aFSMailBoxId,
    47         aFSOperationObserver,
    48         aFSOperationObserver,
    48         aFSRequestId );
    49         aFSRequestId );
    49         
    50         
    50     CleanupStack::PushL( op );
    51     CleanupStack::PushL( op );
    51     op->ConstructL( aSelection );
    52     op->ConstructL( aSel );
    52     CleanupStack::Pop( op );
    53     CleanupStack::Pop( op );
    53     return op;
    54     return op;
    54     }
    55     }
    55 
    56 
    56 // ----------------------------------------------------------------------------
    57 // ----------------------------------------------------------------------------
    57 // ----------------------------------------------------------------------------
    58 // ----------------------------------------------------------------------------
    58 // <qmail> TImImap4GetMailInfo& -> TMsvId&, aFunctionId removed, priority param removed
       
    59 // <qmail> MFSMailRequestObserver& changed to pointer
       
    60 CIpsPlgImap4MoveRemoteOp::CIpsPlgImap4MoveRemoteOp(
    59 CIpsPlgImap4MoveRemoteOp::CIpsPlgImap4MoveRemoteOp(
    61     CMsvSession& aMsvSession,
    60     CMsvSession& aMsvSession,
    62     TRequestStatus& aObserverRequestStatus,
    61     TRequestStatus& aObserverRequestStatus,
       
    62     TInt aFunctionId,
    63     TMsvId aService,
    63     TMsvId aService,
    64     CIpsPlgTimerOperation& aActivityTimer,
    64     CIpsPlgTimerOperation& aActivityTimer,
    65     const TMsvId& aDestinationFolderId,
    65     const TImImap4GetMailInfo& aGetMailInfo,
    66     TFSMailMsgId aFSMailBoxId,
    66     TFSMailMsgId aFSMailBoxId,
    67     MFSMailRequestObserver* aFSOperationObserver,
    67     MFSMailRequestObserver& aFSOperationObserver,
    68     TInt aFSRequestId )
    68     TInt aFSRequestId )
    69     :
    69     :
    70     CIpsPlgOnlineOperation(
    70     CIpsPlgOnlineOperation(
    71         aMsvSession,
    71     aMsvSession,
    72         aObserverRequestStatus,
    72     KMoveRemoteOpPriority,
    73         aActivityTimer,
    73     aObserverRequestStatus,
    74         aFSMailBoxId,
    74     aActivityTimer,
    75         aFSOperationObserver,
    75     aFSMailBoxId,
    76         aFSRequestId ),
    76     aFSOperationObserver,
    77 // <qmail>
    77     aFSRequestId ),
    78     iState( EIdle ),
    78     iFunctionId(aFunctionId),
    79     iDestinationFolderId( aDestinationFolderId )
    79     iGetMailInfo(aGetMailInfo)
    80 // </qmail>
       
    81     {
    80     {
    82     FUNC_LOG;
    81     FUNC_LOG;
    83     iService = aService;
    82     iService = aService;
    84     }
    83     }
    85 
    84 
    87 // ----------------------------------------------------------------------------    
    86 // ----------------------------------------------------------------------------    
    88 CIpsPlgImap4MoveRemoteOp::~CIpsPlgImap4MoveRemoteOp()
    87 CIpsPlgImap4MoveRemoteOp::~CIpsPlgImap4MoveRemoteOp()
    89     {
    88     {
    90     FUNC_LOG;
    89     FUNC_LOG;
    91     delete iRemoteSel;
    90     delete iRemoteSel;
    92 // <qmail>
       
    93     delete iMoveErrorProgress;
       
    94 // </qmail>
       
    95     }
    91     }
    96 
    92 
    97 // ----------------------------------------------------------------------------
    93 // ----------------------------------------------------------------------------
    98 // ----------------------------------------------------------------------------
    94 // ----------------------------------------------------------------------------
    99 void CIpsPlgImap4MoveRemoteOp::ConstructL( const CMsvEntrySelection& aSel )
    95 void CIpsPlgImap4MoveRemoteOp::ConstructL( const CMsvEntrySelection& aSel )
   110     {
   106     {
   111     FUNC_LOG;
   107     FUNC_LOG;
   112     iState = EConnecting;
   108     iState = EConnecting;
   113     iStatus = KRequestPending;
   109     iStatus = KRequestPending;
   114 
   110 
   115     // <qmail> priority parameter has been removed
       
   116     CIpsPlgImap4ConnectOp* connOp = CIpsPlgImap4ConnectOp::NewL(
   111     CIpsPlgImap4ConnectOp* connOp = CIpsPlgImap4ConnectOp::NewL(
   117         iMsvSession,
   112         iMsvSession,
       
   113         KMoveRemoteOpPriority,
   118         iStatus, 
   114         iStatus, 
   119         iService,
   115         iService,
   120         *iActivityTimer,
   116         *iActivityTimer,
   121         iFSMailboxId,
   117         iFSMailboxId,
   122         NULL, // no operationobserver for suboperation
   118         iFSOperationObserver,
   123         0,    // no requestId needed
   119         iFSRequestId,
   124         NULL, // event handler not needed whin plain connect
   120         NULL, // event handler not needed whin plain connect
   125         ETrue ); // do only connect
   121         ETrue,
       
   122         EFalse );
   126         
   123         
   127     delete iSubOperation;
   124     delete iOperation;
   128     iSubOperation = connOp;
   125     iOperation = connOp;
   129 
   126 
   130     SetActive();
   127     SetActive();
   131     }
   128     }
   132 
   129 
   133 // ----------------------------------------------------------------------------
   130 // ----------------------------------------------------------------------------
   204     TInt err = iStatus.Int();
   201     TInt err = iStatus.Int();
   205     switch(iState)
   202     switch(iState)
   206         {
   203         {
   207         case EConnecting:
   204         case EConnecting:
   208             {
   205             {
   209             // <qmail> Connected() usage
   206             TBool connected = STATIC_CAST(CIpsPlgImap4ConnectOp*, iOperation)->Connected();
   210             if ( !Connected() )
   207             if( !connected )
   211                 {
   208                 {
   212                 CompleteObserver( KErrCouldNotConnect );
   209                 CompleteObserver( KErrCouldNotConnect );
   213                 return;
   210                 return;
   214                 }
   211                 }
   215             DoMoveRemoteL();
   212             DoMoveRemoteL();
   228                 DoMoveRemoteL();
   225                 DoMoveRemoteL();
   229                 }
   226                 }
   230             break;
   227             break;
   231         case ERemoteMsgs:
   228         case ERemoteMsgs:
   232             // Remote move complete.
   229             // Remote move complete.
   233             if( err != KErrNone && iSubOperation )
   230             if( err != KErrNone && iOperation )
   234                 {
   231                 {
   235                 iMoveErrorProgress = iSubOperation->ProgressL().AllocL();
   232                 iMoveErrorProgress = iOperation->ProgressL().AllocL();
   236                 }
   233                 }
   237             iState = EIdle;
   234             iState = EIdle;
   238             // to be considered
   235             // to be considered
   239             // if this fails, should we move the messages back to local 
   236             // if this fails, should we move the messages back to local 
   240             // directory
   237             // directory
   267         {
   264         {
   268         id = aSel[count];
   265         id = aSel[count];
   269         err = iMsvSession.GetEntry( id, service, tEntry );
   266         err = iMsvSession.GetEntry( id, service, tEntry );
   270         if( KErrNone == err )
   267         if( KErrNone == err )
   271             {
   268             {
   272             iRemoteSel->AppendL( id );
   269                 iRemoteSel->AppendL( id );
       
   270                 }
   273             }
   271             }
   274         }
   272         }
   275     }
       
   276 
   273 
   277 // ----------------------------------------------------------------------------
   274 // ----------------------------------------------------------------------------
   278 // ----------------------------------------------------------------------------
   275 // ----------------------------------------------------------------------------
   279 void CIpsPlgImap4MoveRemoteOp::Complete()
   276 void CIpsPlgImap4MoveRemoteOp::Complete()
   280     {
   277     {
   292     iStatus = KRequestPending;
   289     iStatus = KRequestPending;
   293     // first element of the CMsvEntrySelection is the service which is then
   290     // first element of the CMsvEntrySelection is the service which is then
   294     // followed by any messages
   291     // followed by any messages
   295     if( iRemoteSel->Count() > 1 )
   292     if( iRemoteSel->Count() > 1 )
   296         {
   293         {
   297         // <qmail> deletion of iSubOperation is done inside InvokeClientMtmAsyncFunctionL </qmail>
   294         // Switch operations.
       
   295         delete iOperation;
       
   296         iOperation = NULL;
   298     
   297     
   299         // Filters are not used when performing 'move' operation, use normal 
   298         // Filters are not used when performing 'move' operation, use normal 
   300         // getmail info instead
   299         // getmail info instead
   301 		// <qmail>
   300         TPckg<TImImap4GetMailInfo> param( iGetMailInfo );
   302         TPckgBuf<TImImap4GetMailInfo> paramBuf;
   301         InvokeClientMtmAsyncFunctionL( iFunctionId, *iRemoteSel, iService, param );
   303         TImImap4GetMailInfo& mailInfo = paramBuf();
       
   304         mailInfo.iMaxEmailSize = KMaxTInt32;
       
   305         mailInfo.iGetMailBodyParts = EGetImap4EmailBodyTextAndAttachments;
       
   306         mailInfo.iDestinationFolder = iDestinationFolderId;
       
   307 
       
   308 // <qmail> Parameters changed
       
   309         InvokeClientMtmAsyncFunctionL( KIMAP4MTMMoveMailSelectionWhenAlreadyConnected, *iRemoteSel, paramBuf );
       
   310 // </qmail>
       
   311         SetActive();
   302         SetActive();
   312         }
   303         }
   313     else
   304     else
   314         {
   305         {
   315         // <qmail> SetActive(); moved inside CompleteThis();
   306         SetActive();
   316         CompleteThis();        
   307         CompleteThis();
   317         }    
   308         }
   318     }
   309     }
   319     
   310     
   320 // <qmail> removed CIpsPlgImap4MoveRemoteOp::GetEngineProgress( const TDesC8& aProgress )
       
   321 
       
   322 // <qmail> new func to this op
       
   323 // ----------------------------------------------------------------------------
   311 // ----------------------------------------------------------------------------
   324 // ----------------------------------------------------------------------------    
   312 // ----------------------------------------------------------------------------    
   325 TIpsOpType CIpsPlgImap4MoveRemoteOp::IpsOpType() const
   313 TInt CIpsPlgImap4MoveRemoteOp::GetEngineProgress( const TDesC8& aProgress )
   326     {
   314     {
   327     FUNC_LOG;
   315     FUNC_LOG;
   328     return EIpsOpTypeMoveRemoteOp;
   316     if( !aProgress.Length() )
   329     }
   317         {
   330 // </qmail>	
   318         return KErrNone;
       
   319         }
       
   320     else
       
   321         {
       
   322         TPckgBuf<TImap4CompoundProgress> paramPack;
       
   323         paramPack.Copy( aProgress );
       
   324         const TImap4GenericProgress& progress = paramPack().iGenericProgress;
       
   325 
       
   326         return progress.iErrorCode;
       
   327         }
       
   328     }
   331 
   329 
   332 // class CIpsPlgImap4MoveRemoteOpObserver
   330 // class CIpsPlgImap4MoveRemoteOpObserver
   333 //
   331 //
   334 
   332 
   335 // ----------------------------------------------------------------------------
   333 // ----------------------------------------------------------------------------