ipsservices/ipssosplugin/src/ipsplgmsgmapper.cpp
branchRCL_3
changeset 80 726fba06891a
parent 73 c8382f7b54ef
--- a/ipsservices/ipssosplugin/src/ipsplgmsgmapper.cpp	Wed Sep 15 11:52:37 2010 +0300
+++ b/ipsservices/ipssosplugin/src/ipsplgmsgmapper.cpp	Wed Oct 13 14:11:15 2010 +0300
@@ -86,11 +86,6 @@
 CIpsPlgMsgMapper::~CIpsPlgMsgMapper()
     {
     FUNC_LOG;
-    if( iMsgMapperHelper )
-        {
-        delete iMsgMapperHelper;
-        iMsgMapperHelper = NULL;
-        }
     }
 
 // ---------------------------------------------------------------------------
@@ -112,8 +107,6 @@
 void CIpsPlgMsgMapper::ConstructL()
     {
     FUNC_LOG;
-	
-    iMsgMapperHelper = CIpsPlgMsgMapperHelper::NewL( iSession );
     }
 
 // ---------------------------------------------------------------------------
@@ -366,11 +359,6 @@
     // EFSMsgFlag_Answered: supported only with IMAP4 (see below)
 
     // EFSMsgFlag_Forwarded: no counterpart in Symbian message in S60 3.1
-    if ( LogicalXor( aEmlEntry.Forwarded(), msgFlags & EFSMsgFlag_Forwarded ) )
-        {
-        aEmlEntry.SetForwarded( !aEmlEntry.Forwarded() );
-        modified = ETrue;
-        }
 
     // EFSMsgFlag_OnlyToMe: no counterpart in Symbian message
 
@@ -761,14 +749,7 @@
     aMsg.ResetFlag( EFSMsgFlag_Answered );
 
     // EFSMsgFlag_Forwarded: not supported in S60 3.1
-    if ( aEntry.Forwarded() )
-        {
-        aMsg.SetFlag( EFSMsgFlag_Forwarded );
-        }
-    else
-        {
-        aMsg.ResetFlag( EFSMsgFlag_Forwarded );
-        }
+    aMsg.ResetFlag( EFSMsgFlag_Forwarded );
 
     // EFSMsgFlag_OnlyToMe: like EFSMsgFlag_Multiple
 
@@ -1514,11 +1495,7 @@
         aMsg.SetFlag( EFSMsgFlag_Attachments );
         if ( !aEntry.Attachment() )
         	{
-            TBool success = iMsgMapperHelper->AppendMsvIdToArrayL( aEntry.Id() );
-            if( success )
-                {
-                iMsgMapperHelper->StartSetAttchmentFlag();
-                }
+        	SetAttachmentFlagL( aEntry, ETrue );
         	}
         }
 
@@ -1607,235 +1584,3 @@
     CleanupStack::PopAndDestroy( cEntry );
     }
 // </cmail>
-
-
-// ---------------------------------------------------------------------------
-// CIpsPlgMsgMapperHelper::OpCompleted
-// ---------------------------------------------------------------------------
-//
-void CIpsPlgMsgMapperHelper::OpCompleted(
-    CIpsPlgSingleOpWatcher& aOpWatcher,
-    TInt aCompletionCode )
-    {
-    FUNC_LOG;
-    
-    TInt opId = aOpWatcher.Operation().Id();
-    TMsvId completedMsvId = aOpWatcher.Operation().Service();
-    
-    if( iCurrentOperationWatcher )
-        {
-        CMsvOperation& oper = iCurrentOperationWatcher->Operation();
-        
-        //delete the iOngoingOperation when it has completed
-        if( oper.Id() == opId )
-            {
-            delete iCurrentOperationWatcher;
-            iCurrentOperationWatcher = NULL;
-            }
-        }
-    
-    //remove the completed MsvId from the iNeedSetAttachFlagArray
-    for( TInt j = 0; j < iNeedSetAttachFlagArray.Count(); ++j )
-        {
-        if( completedMsvId == iNeedSetAttachFlagArray[j] )
-            {
-            iNeedSetAttachFlagArray.Remove( j );
-            break;
-            }
-        }
-    //start next async process
-    iTimer.After( iStatus, 0 );
-    SetActive();
-    }
-
-
-// ---------------------------------------------------------------------------
-// CIpsPlgMsgMapperHelper::NewL
-// ---------------------------------------------------------------------------
-//
-CIpsPlgMsgMapperHelper* CIpsPlgMsgMapperHelper::NewL( CMsvSession& aSession )
-    {
-    FUNC_LOG;
-    
-    CIpsPlgMsgMapperHelper* self = new (ELeave) CIpsPlgMsgMapperHelper( aSession );
-    CleanupStack::PushL(self);
-    self->ConstructL();
-    CleanupStack::Pop();
-    return self;
-    }
-
-// ---------------------------------------------------------------------------
-// CIpsPlgMsgMapperHelper::~CIpsPlgMsgMapperHelper
-// ---------------------------------------------------------------------------
-//
-CIpsPlgMsgMapperHelper::~CIpsPlgMsgMapperHelper()
-    {
-    FUNC_LOG;
-    
-    Cancel();
-    //should delete the iOngoingOperation if it not completed 
-    if( iCurrentOperationWatcher )
-        {
-        delete iCurrentOperationWatcher;
-        iCurrentOperationWatcher = NULL;
-        }
-    iNeedSetAttachFlagArray.Reset();
-    iNeedSetAttachFlagArray.Close();
-    
-    Deque();
-    iTimer.Close();
-    }
-
-// ---------------------------------------------------------------------------
-// CIpsPlgMsgMapperHelper::CIpsPlgMsgMapperHelper
-// ---------------------------------------------------------------------------
-//
-CIpsPlgMsgMapperHelper::CIpsPlgMsgMapperHelper( CMsvSession& aSession )
-:CActive( EPriorityStandard ), iSession( aSession ), iPending( EFalse ),
-iCurrentOperationWatcher( NULL )
-    {
-    FUNC_LOG;
-    }
-
-// ---------------------------------------------------------------------------
-// CIpsPlgMsgMapperHelper::ConstructL
-// ---------------------------------------------------------------------------
-//
-void CIpsPlgMsgMapperHelper::ConstructL()
-    {
-    FUNC_LOG;
-    
-    User::LeaveIfError( iTimer.CreateLocal() );
-    CActiveScheduler::Add(this);
-    }
-
-// inherited from CActive
-// ---------------------------------------------------------------------------
-// CIpsPlgMsgMapperHelper::RunL
-// ---------------------------------------------------------------------------
-//
-void CIpsPlgMsgMapperHelper::RunL()
-    {
-    FUNC_LOG;
-
-    User::LeaveIfError( iStatus.Int() );
-    // always start the async process from the index 0 of iNeedSetAttachFlagArray
-    TInt currentIndex = 0;
-    
-    if( iNeedSetAttachFlagArray.Count() > 0 )
-        {
-        TMsvId entry = iNeedSetAttachFlagArray[currentIndex];
-        TMsvId serviceId;
-        TMsvEmailEntry entryToBeChanged;
-        //get enty by msvid
-        TBool result = iSession.GetEntry( entry, serviceId, entryToBeChanged);
-        
-        if( entryToBeChanged.Attachment() )
-            {
-            // ignore this operation and delete when it has set the attach flag
-            iNeedSetAttachFlagArray.Remove( currentIndex );
-            iTimer.After( iStatus, 0 );
-            SetActive();
-            return;
-            }
-        
-        CIpsPlgSingleOpWatcher* opW = CIpsPlgSingleOpWatcher::NewLC( *this );
-        
-        CMsvEntry* cEntry = iSession.GetEntryL( entry );
-        CleanupStack::PushL( cEntry );
-        
-        entryToBeChanged.SetAttachment( ETrue );
-        CMsvOperation* ops = cEntry->ChangeL( entryToBeChanged, opW->iStatus );
-        CleanupStack::PopAndDestroy( cEntry );
-        
-        if( ops )
-            {
-            opW->SetOperation( ops );
-            if( iCurrentOperationWatcher )
-                {
-                delete iCurrentOperationWatcher;
-                iCurrentOperationWatcher = NULL;
-                }
-            iCurrentOperationWatcher = opW;
-            CleanupStack::Pop( opW );
-            }
-        else
-            {
-            CleanupStack::PopAndDestroy( opW ); 
-            }
-        }
-    else
-        {
-        //all these operation have processed
-        iPending = EFalse;
-        }
-    }
-
-// ---------------------------------------------------------------------------
-// CIpsPlgMsgMapperHelper::RunError
-// ---------------------------------------------------------------------------
-//
-TInt CIpsPlgMsgMapperHelper::RunError( TInt aError )
-    {
-    FUNC_LOG;
-
-    if ( KErrNone != aError )
-        {
-        Cancel();
-        }
-    return KErrNone;
-    }
-
-void CIpsPlgMsgMapperHelper::DoCancel()
-    {
-    FUNC_LOG;
-    if( iCurrentOperationWatcher )
-        {
-        iCurrentOperationWatcher->Cancel();
-        delete iCurrentOperationWatcher;
-        iCurrentOperationWatcher = NULL;
-        }
-    iTimer.Cancel();
-    }
-
-// ---------------------------------------------------------------------------
-// CIpsPlgMsgMapperHelper::StartSetAttchmentFlag
-// ---------------------------------------------------------------------------
-//
-void CIpsPlgMsgMapperHelper::StartSetAttchmentFlag()
-    {    
-    FUNC_LOG;
-    //should start the ao when not in pending status
-    if( !IsActive() && !iPending )
-        {
-        iTimer.After( iStatus, 0 );
-        SetActive();
-        iPending = ETrue;
-        }
-    }
-
-// ---------------------------------------------------------------------------
-// CIpsPlgMsgMapperHelper::AppendToArrayL
-// ---------------------------------------------------------------------------
-//
-TBool CIpsPlgMsgMapperHelper::AppendMsvIdToArrayL( TMsvId aId )
-    {
-    FUNC_LOG;
-
-    TInt count = iNeedSetAttachFlagArray.Count();
-    //check the MsvId if already exist in iNeedSetAttachFlagArray
-    for( TInt i = 0; i < count; ++i )
-        {
-        TMsvId id = iNeedSetAttachFlagArray[i];
-        if( id == aId )
-            {
-            return EFalse;
-            }
-        }
-    
-    iNeedSetAttachFlagArray.AppendL( aId );
-    return ETrue;
-    }
-
-
-