ipsservices/ipssosplugin/src/ipsplgimap4fetchattachmentop.cpp
changeset 20 ecc8def7944a
parent 18 578830873419
child 23 2dc6caa42ec3
--- a/ipsservices/ipssosplugin/src/ipsplgimap4fetchattachmentop.cpp	Fri Apr 16 14:51:52 2010 +0300
+++ b/ipsservices/ipssosplugin/src/ipsplgimap4fetchattachmentop.cpp	Mon May 03 12:23:15 2010 +0300
@@ -20,9 +20,8 @@
 #include "emailtrace.h"
 #include "ipsplgheaders.h"
 
-// Constants and defines
-const TInt KFetchOpPriority = CActive::EPriorityStandard;
-const TInt KIpsAttaFetchProgressReportInterval = 1000000; // 1 sec
+// <qmail> priority const has been removed
+const TInt KIpsAttaFetchProgressReportInterval = 200000; // 0.2 sec
 
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
@@ -97,17 +96,16 @@
     }
 
 // ----------------------------------------------------------------------------
+// CIpsPlgImap4FetchAttachmentOp
 // ----------------------------------------------------------------------------
 CIpsPlgImap4FetchAttachmentOp* CIpsPlgImap4FetchAttachmentOp::NewL(
     CMsvSession& aMsvSession,
     TRequestStatus& aObserverRequestStatus,
-    TInt aFunctionId,
     TMsvId aService,
     CIpsPlgTimerOperation& aActivityTimer,
-    const TImImap4GetMailInfo& aGetMailInfo,
-    const CMsvEntrySelection& aSel,
+    const CMsvEntrySelection* aSelection,
     TFSMailMsgId aFSMailBoxId,
-    MFSMailRequestObserver& aFSOperationObserver,
+    MFSMailRequestObserver* aFSOperationObserver,
     TInt aFSRequestId )
     {
     FUNC_LOG;
@@ -115,44 +113,40 @@
         ELeave) CIpsPlgImap4FetchAttachmentOp(
         aMsvSession,
         aObserverRequestStatus,
-        aFunctionId,
         aService,
         aActivityTimer,
-        aGetMailInfo,
+        aSelection,
         aFSMailBoxId,
         aFSOperationObserver,
         aFSRequestId );
         
     CleanupStack::PushL( op );
-    op->ConstructL( aSel );
+    op->ConstructL();
     CleanupStack::Pop( op );
     return op;
     }
 
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
+// <qmail> priority parameter has been removed
 CIpsPlgImap4FetchAttachmentOp::CIpsPlgImap4FetchAttachmentOp(
     CMsvSession& aMsvSession,
     TRequestStatus& aObserverRequestStatus,
-    TInt aFunctionId,
     TMsvId aService,
     CIpsPlgTimerOperation& aActivityTimer,
-    const TImImap4GetMailInfo& aGetMailInfo,
+    const CMsvEntrySelection* aSelection,
     TFSMailMsgId aFSMailBoxId,
-    MFSMailRequestObserver& aFSOperationObserver,
+    MFSMailRequestObserver* aFSOperationObserver,
     TInt aFSRequestId )
     :
     CIpsPlgOnlineOperation(
-    aMsvSession,
-    KFetchOpPriority,
-    aObserverRequestStatus,
-    aActivityTimer,
-    aFSMailBoxId,
-    aFSOperationObserver,
-    aFSRequestId),
-    iSelection( NULL ),
-    iGetMailInfo(aGetMailInfo),
-    iFunctionId(aFunctionId)
+        aMsvSession,
+        aObserverRequestStatus,
+        aActivityTimer,
+        aFSMailBoxId,
+        aFSOperationObserver,
+        aFSRequestId ),
+    iSelection( aSelection )
     {
     FUNC_LOG;
     iService = aService;
@@ -165,15 +159,15 @@
     FUNC_LOG;
     delete iSelection;
     delete iProgReport;
+    delete iFetchErrorProgress;
     }
 
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
-void CIpsPlgImap4FetchAttachmentOp::ConstructL( const CMsvEntrySelection& aSel )
+void CIpsPlgImap4FetchAttachmentOp::ConstructL()
     {
     FUNC_LOG;
     BaseConstructL( KUidMsgTypeIMAP4 );
-    iSelection = aSel.CopyL();
     DoConnectL();
     }
 
@@ -185,21 +179,20 @@
     iState = EStateConnecting;
     iStatus = KRequestPending;
 
+    // <qmail> priority parameter has been removed
     CIpsPlgImap4ConnectOp* connOp = CIpsPlgImap4ConnectOp::NewL(
         iMsvSession,
-        KFetchOpPriority,
         iStatus, 
         iService,
         iActivityTimer,
         iFSMailboxId,
-        iFSOperationObserver,
-        iFSRequestId,
+        NULL, // no observer for subopertaion
+        0,    // no requestId needed
         NULL, // event handler not needed whin plain connect
-        ETrue,
-        EFalse );
+        ETrue );
         
-    delete iOperation;
-    iOperation = connOp;
+    delete iSubOperation;
+    iSubOperation = connOp;
 
     SetActive();
     }
@@ -240,11 +233,10 @@
             delete iProgReport;
             iProgReport = NULL;
             
-            TInt err = iStatus.Int();
-
-            if( err != KErrNone && iOperation )
+            TInt err( iStatus.Int() );
+            if( err != KErrNone && iSubOperation )
                 {
-                iFetchErrorProgress = iOperation->ProgressL().AllocL();
+                iFetchErrorProgress = iSubOperation->ProgressL().AllocL();
                 }
             
             iState = EStateIdle;
@@ -267,9 +259,9 @@
         return *iFetchErrorProgress;
         }
     
-    if ( iOperation )
+    if ( iSubOperation )
         {
-        iProgress.Copy( iOperation->ProgressL() );
+        iProgress.Copy( iSubOperation->ProgressL() );
         }
     else
         {
@@ -287,11 +279,11 @@
 void CIpsPlgImap4FetchAttachmentOp::ReportProgressL()
     {
     FUNC_LOG;
-    TInt error = KErrNone;
+    TInt error( KErrNone );
     TFSProgress fsProgress = { TFSProgress::EFSStatus_Waiting, 0, 0, KErrNone };
-    if ( iOperation && iState == EStateFetching )
+    if ( iSubOperation && iState == EStateFetching )
         {
-        TRAP(error, iProgress.Copy( iOperation->ProgressL() ) );
+        TRAP(error, iProgress.Copy( iSubOperation->ProgressL() ) );
         }
     
     if ( error == KErrNone )
@@ -316,7 +308,11 @@
         User::Leave( error );
         }
     
-    iFSOperationObserver.RequestResponseL( fsProgress, iFSRequestId );
+    // signal observer if it exists
+    if ( iFSOperationObserver )
+        {
+        iFSOperationObserver->RequestResponseL( fsProgress, iFSRequestId );
+        }
     }
 
 // ----------------------------------------------------------------------------
@@ -372,38 +368,28 @@
     iState = EStateFetching;
 
     // Switch operations.
-    delete iOperation;
-    iOperation = NULL;
-    iStatus = KRequestPending;
+    delete iSubOperation;
+    iSubOperation = NULL;
 
     iProgReport = CIpsFetchProgReport::NewL( *this );
 
     // Filters are not used when performing 'fetch' operation, 
     // use normal getmail info instead
-    TPckg<TImImap4GetMailInfo> param(iGetMailInfo);
-    InvokeClientMtmAsyncFunctionL( iFunctionId, *iSelection, iService, param );
+    TPckgBuf<TImImap4GetMailInfo> param;
+    TImImap4GetMailInfo& options = param();
+    options.iMaxEmailSize = KMaxTInt32;
+    options.iGetMailBodyParts = EGetImap4EmailAttachments;
+    options.iDestinationFolder = 0; // not used
+
+    InvokeClientMtmAsyncFunctionL( KIMAP4MTMPopulate, *iSelection, param ); // <qmail> 1 param removed
     SetActive();
     }
     
+// <qmail> new func to this op
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------    
-TInt CIpsPlgImap4FetchAttachmentOp::GetEngineProgress( const TDesC8& aProgress )
+TIpsOpType CIpsPlgImap4FetchAttachmentOp::IpsOpType() const
     {
     FUNC_LOG;
-    if( !aProgress.Length() )
-        {
-        return KErrNone;
-        }
-    else
-        {
-        TPckgBuf<TImap4CompoundProgress> paramPack;
-        paramPack.Copy( aProgress );
-        const TImap4GenericProgress& progress = paramPack().iGenericProgress;
-
-        return progress.iErrorCode;
-        }    
-    }        
-
-
-// End of File
-
+    return EIpsOpTypeFetchAttachmentOp;
+    }