ipsservices/ipssosplugin/src/ipsplgimap4moveremoteop.cpp
changeset 1 12c456ceeff2
parent 0 8466d47a6819
child 13 0396474f30f5
child 18 578830873419
equal deleted inserted replaced
0:8466d47a6819 1:12c456ceeff2
    85 // ----------------------------------------------------------------------------
    85 // ----------------------------------------------------------------------------
    86 // ----------------------------------------------------------------------------    
    86 // ----------------------------------------------------------------------------    
    87 CIpsPlgImap4MoveRemoteOp::~CIpsPlgImap4MoveRemoteOp()
    87 CIpsPlgImap4MoveRemoteOp::~CIpsPlgImap4MoveRemoteOp()
    88     {
    88     {
    89     FUNC_LOG;
    89     FUNC_LOG;
    90     delete iLocalSel;
       
    91     delete iRemoteSel;
    90     delete iRemoteSel;
    92     }
    91     }
    93 
    92 
    94 // ----------------------------------------------------------------------------
    93 // ----------------------------------------------------------------------------
    95 // ----------------------------------------------------------------------------
    94 // ----------------------------------------------------------------------------
   207             if( !connected )
   206             if( !connected )
   208                 {
   207                 {
   209                 CompleteObserver( KErrCouldNotConnect );
   208                 CompleteObserver( KErrCouldNotConnect );
   210                 return;
   209                 return;
   211                 }
   210                 }
   212             DoMoveLocalL();
   211             DoMoveRemoteL();
   213             }
   212             }
   214             break;
   213             break;
   215         case ELocalMsgs:
   214         case ELocalMsgs:
   216             // Local move complete
   215             // Local move complete
   217             if( err != KErrNone )
   216             if( err != KErrNone )
   251     if ( aSel.Count() == 0 )
   250     if ( aSel.Count() == 0 )
   252         {
   251         {
   253         User::Leave( KErrNotSupported );
   252         User::Leave( KErrNotSupported );
   254         }
   253         }
   255     // Sort messages into complete and incomplete selections.
   254     // Sort messages into complete and incomplete selections.
   256     iLocalSel = new(ELeave) CMsvEntrySelection;
       
   257     iRemoteSel = new(ELeave) CMsvEntrySelection;
   255     iRemoteSel = new(ELeave) CMsvEntrySelection;
   258 
   256 
   259     TInt err;
   257     TInt err;
   260     TMsvId id;
   258     TMsvId id;
   261     TMsvId service;
   259     TMsvId service;
   265         {
   263         {
   266         id = aSel[count];
   264         id = aSel[count];
   267         err = iMsvSession.GetEntry( id, service, tEntry );
   265         err = iMsvSession.GetEntry( id, service, tEntry );
   268         if( KErrNone == err )
   266         if( KErrNone == err )
   269             {
   267             {
   270             // local move is not needed, if the message is not fetched
       
   271             if( tEntry.Complete() )
       
   272                 {
       
   273                 if ( 0 < count )
       
   274                     {
       
   275                     // service id is not added to local, 
       
   276                     // service is already
       
   277                     // added in MoveMessagesL
       
   278                     iLocalSel->AppendL( id );
       
   279                     }
       
   280                 }
       
   281                 iRemoteSel->AppendL( id );
   268                 iRemoteSel->AppendL( id );
   282                 }
   269                 }
   283             }
   270             }
   284         }
   271         }
   285 
   272 
   288 void CIpsPlgImap4MoveRemoteOp::Complete()
   275 void CIpsPlgImap4MoveRemoteOp::Complete()
   289     {
   276     {
   290     FUNC_LOG;
   277     FUNC_LOG;
   291     TRequestStatus* observer = &iObserverRequestStatus;
   278     TRequestStatus* observer = &iObserverRequestStatus;
   292     User::RequestComplete( observer, KErrNone );
   279     User::RequestComplete( observer, KErrNone );
   293     }
       
   294     
       
   295 // ----------------------------------------------------------------------------
       
   296 // ----------------------------------------------------------------------------
       
   297 void CIpsPlgImap4MoveRemoteOp::DoMoveLocalL()
       
   298     {
       
   299     FUNC_LOG;
       
   300     iState = ELocalMsgs;
       
   301     iStatus = KRequestPending;
       
   302     if( iLocalSel->Count() )
       
   303         {
       
   304         // this gets the first msg to be moved
       
   305         CMsvEntry* cEntry = iMsvSession.GetEntryL( (*iLocalSel)[0] );
       
   306         CleanupStack::PushL( cEntry );
       
   307         // find the parent of the moved message...
       
   308         TMsvId parent = cEntry->Entry().Parent();
       
   309         // and use it as a context
       
   310         cEntry->SetEntryL( parent );
       
   311 
       
   312         delete iOperation;
       
   313         iOperation = NULL;
       
   314         iOperation = cEntry->MoveL( *iLocalSel, 
       
   315                                     iGetMailInfo.iDestinationFolder, 
       
   316                                     iStatus );
       
   317         CleanupStack::PopAndDestroy( cEntry ); 
       
   318         SetActive();
       
   319         }
       
   320     else
       
   321         {
       
   322         SetActive();
       
   323         CompleteThis();
       
   324         }
       
   325     }
   280     }
   326 
   281 
   327 // ----------------------------------------------------------------------------
   282 // ----------------------------------------------------------------------------
   328 // ----------------------------------------------------------------------------
   283 // ----------------------------------------------------------------------------
   329 void CIpsPlgImap4MoveRemoteOp::DoMoveRemoteL()
   284 void CIpsPlgImap4MoveRemoteOp::DoMoveRemoteL()