ipsservices/ipssosplugin/src/ipsplgimap4fetchattachmentop.cpp
branchRCL_3
changeset 24 d189ee25cf9d
parent 17 67369d1b217f
child 25 3533d4323edc
equal deleted inserted replaced
23:dcf0eedfc1a3 24:d189ee25cf9d
    18 
    18 
    19 
    19 
    20 #include "emailtrace.h"
    20 #include "emailtrace.h"
    21 #include "ipsplgheaders.h"
    21 #include "ipsplgheaders.h"
    22 
    22 
    23 // Constants and defines
    23 // <qmail> priority const has been removed, interval changed to 0.2 sec
    24 const TInt KFetchOpPriority = CActive::EPriorityStandard;
    24 const TInt KIpsAttaFetchProgressReportInterval = 200000; // 0.2 sec
    25 const TInt KIpsAttaFetchProgressReportInterval = 1000000; // 1 sec
       
    26 const TInt KIpsAttaFetchRetryInterval = 1000000; // 1 sec
    25 const TInt KIpsAttaFetchRetryInterval = 1000000; // 1 sec
    27 const TInt KIpsAttaFetchRetryCount = 30;
    26 const TInt KIpsAttaFetchRetryCount = 30;
    28 
    27 
    29 // ----------------------------------------------------------------------------
    28 // ----------------------------------------------------------------------------
    30 // ----------------------------------------------------------------------------
    29 // ----------------------------------------------------------------------------
    97     iAttaOp.ReportProgressL();
    96     iAttaOp.ReportProgressL();
    98     AdjustTimer();
    97     AdjustTimer();
    99     }
    98     }
   100 
    99 
   101 // ----------------------------------------------------------------------------
   100 // ----------------------------------------------------------------------------
   102 // ----------------------------------------------------------------------------
   101 // CIpsPlgImap4FetchAttachmentOp
       
   102 // ----------------------------------------------------------------------------
       
   103 // <qmail> aFunctionId removed, CMsvEntrySelection& changed to pointer
       
   104 // <qmail> MFSMailRequestObserver& changed to pointer
   103 CIpsPlgImap4FetchAttachmentOp* CIpsPlgImap4FetchAttachmentOp::NewL(
   105 CIpsPlgImap4FetchAttachmentOp* CIpsPlgImap4FetchAttachmentOp::NewL(
   104     CMsvSession& aMsvSession,
   106     CMsvSession& aMsvSession,
   105     TRequestStatus& aObserverRequestStatus,
   107     TRequestStatus& aObserverRequestStatus,
   106     TInt aFunctionId,
       
   107     TMsvId aService,
   108     TMsvId aService,
   108     CIpsPlgTimerOperation& aActivityTimer,
   109     CIpsPlgTimerOperation& aActivityTimer,
   109     const TImImap4GetMailInfo& aGetMailInfo,
   110     const CMsvEntrySelection* aSelection,
   110     const CMsvEntrySelection& aSel,
       
   111     TFSMailMsgId aFSMailBoxId,
   111     TFSMailMsgId aFSMailBoxId,
   112     MFSMailRequestObserver& aFSOperationObserver,
   112     MFSMailRequestObserver* aFSOperationObserver,
   113     TInt aFSRequestId )
   113     TInt aFSRequestId )
   114     {
   114     {
   115     FUNC_LOG;
   115     FUNC_LOG;
   116     CIpsPlgImap4FetchAttachmentOp* op = new (
   116     CIpsPlgImap4FetchAttachmentOp* op = new (
   117         ELeave) CIpsPlgImap4FetchAttachmentOp(
   117         ELeave) CIpsPlgImap4FetchAttachmentOp(
   118         aMsvSession,
   118         aMsvSession,
   119         aObserverRequestStatus,
   119         aObserverRequestStatus,
   120         aFunctionId,
       
   121         aService,
   120         aService,
   122         aActivityTimer,
   121         aActivityTimer,
   123         aGetMailInfo,
   122         aSelection,
   124         aFSMailBoxId,
   123         aFSMailBoxId,
   125         aFSOperationObserver,
   124         aFSOperationObserver,
   126         aFSRequestId );
   125         aFSRequestId );
   127         
   126         
   128     CleanupStack::PushL( op );
   127     CleanupStack::PushL( op );
   129     op->ConstructL( aSel );
   128     op->ConstructL();
   130     CleanupStack::Pop( op );
   129     CleanupStack::Pop( op );
   131     return op;
   130     return op;
   132     }
   131     }
   133 
   132 
   134 // ----------------------------------------------------------------------------
   133 // ----------------------------------------------------------------------------
   135 // ----------------------------------------------------------------------------
   134 // ----------------------------------------------------------------------------
       
   135 // <qmail> priority parameter has been removed
       
   136 // <qmail> MFSMailRequestObserver& changed to pointer
   136 CIpsPlgImap4FetchAttachmentOp::CIpsPlgImap4FetchAttachmentOp(
   137 CIpsPlgImap4FetchAttachmentOp::CIpsPlgImap4FetchAttachmentOp(
   137     CMsvSession& aMsvSession,
   138     CMsvSession& aMsvSession,
   138     TRequestStatus& aObserverRequestStatus,
   139     TRequestStatus& aObserverRequestStatus,
   139     TInt aFunctionId,
       
   140     TMsvId aService,
   140     TMsvId aService,
   141     CIpsPlgTimerOperation& aActivityTimer,
   141     CIpsPlgTimerOperation& aActivityTimer,
   142     const TImImap4GetMailInfo& aGetMailInfo,
   142     const CMsvEntrySelection* aSelection,
   143     TFSMailMsgId aFSMailBoxId,
   143     TFSMailMsgId aFSMailBoxId,
   144     MFSMailRequestObserver& aFSOperationObserver,
   144     MFSMailRequestObserver* aFSOperationObserver,
   145     TInt aFSRequestId )
   145     TInt aFSRequestId )
   146     :
   146     :
   147     CIpsPlgOnlineOperation(
   147     CIpsPlgOnlineOperation(
   148     aMsvSession,
   148         aMsvSession,
   149     KFetchOpPriority,
   149         aObserverRequestStatus,
   150     aObserverRequestStatus,
   150         aActivityTimer,
   151     aActivityTimer,
   151         aFSMailBoxId,
   152     aFSMailBoxId,
   152         aFSOperationObserver,
   153     aFSOperationObserver,
   153         aFSRequestId ),
   154     aFSRequestId),
   154     	iSelection( aSelection ),
   155     iSelection( NULL ),
   155     	iRetryCount( 0 )
   156     iGetMailInfo(aGetMailInfo),
       
   157     iFunctionId(aFunctionId),
       
   158     iRetryCount( 0 )
       
   159     {
   156     {
   160     FUNC_LOG;
   157     FUNC_LOG;
   161     iService = aService;
   158     iService = aService;
   162     iRetryTimer.CreateLocal();
   159     iRetryTimer.CreateLocal();
   163     }
   160     }
   168     {
   165     {
   169     FUNC_LOG;
   166     FUNC_LOG;
   170     iRetryTimer.Close();
   167     iRetryTimer.Close();
   171     delete iSelection;
   168     delete iSelection;
   172     delete iProgReport;
   169     delete iProgReport;
   173     }
   170     delete iFetchErrorProgress;
   174 
   171     }
   175 // ----------------------------------------------------------------------------
   172 
   176 // ----------------------------------------------------------------------------
   173 // ----------------------------------------------------------------------------
   177 void CIpsPlgImap4FetchAttachmentOp::ConstructL( const CMsvEntrySelection& aSel )
   174 // ----------------------------------------------------------------------------
       
   175 void CIpsPlgImap4FetchAttachmentOp::ConstructL()
   178     {
   176     {
   179     FUNC_LOG;
   177     FUNC_LOG;
   180     BaseConstructL( KUidMsgTypeIMAP4 );
   178     BaseConstructL( KUidMsgTypeIMAP4 );
   181     iSelection = aSel.CopyL();
       
   182     DoConnectL();
   179     DoConnectL();
   183     }
   180     }
   184 
   181 
   185 // ----------------------------------------------------------------------------
   182 // ----------------------------------------------------------------------------
   186 // ----------------------------------------------------------------------------
   183 // ----------------------------------------------------------------------------
   188     {
   185     {
   189     FUNC_LOG;
   186     FUNC_LOG;
   190     iState = EStateConnecting;
   187     iState = EStateConnecting;
   191     iStatus = KRequestPending;
   188     iStatus = KRequestPending;
   192 
   189 
       
   190     // <qmail> priority parameter has been removed
   193     CIpsPlgImap4ConnectOp* connOp = CIpsPlgImap4ConnectOp::NewL(
   191     CIpsPlgImap4ConnectOp* connOp = CIpsPlgImap4ConnectOp::NewL(
   194         iMsvSession,
   192         iMsvSession,
   195         KFetchOpPriority,
       
   196         iStatus, 
   193         iStatus, 
   197         iService,
   194         iService,
   198         *iActivityTimer,
   195         *iActivityTimer,
   199         iFSMailboxId,
   196         iFSMailboxId,
   200         iFSOperationObserver,
   197         NULL, // no observer for subopertaion
   201         iFSRequestId,
   198         0,    // no requestId needed
   202         NULL, // event handler not needed whin plain connect
   199         NULL, // event handler not needed whin plain connect
   203         ETrue,
   200         ETrue );
   204         EFalse );
       
   205         
   201         
   206     delete iOperation;
   202     delete iSubOperation;
   207     iOperation = connOp;
   203     iSubOperation = connOp;
   208 
   204 
   209     SetActive();
   205     SetActive();
   210     }
   206     }
   211     
   207     
   212 // ----------------------------------------------------------------------------
   208 // ----------------------------------------------------------------------------
   229     FUNC_LOG;
   225     FUNC_LOG;
   230     switch( iState )
   226     switch( iState )
   231         {
   227         {
   232         case EStateConnecting:
   228         case EStateConnecting:
   233             {
   229             {
   234             // get result of connect operation
   230             // <qmail> Connected() usage
   235             TInt err = iStatus.Int();
   231             if ( !Connected() )
   236 
       
   237             if( err != KErrNone )
       
   238                 {
   232                 {
   239                 CompleteObserver( err == KErrCancel ? err : KErrCouldNotConnect );
   233                 CompleteObserver( KErrCouldNotConnect );
   240                 return;
   234                 return;
   241                 }
   235                 }
   242             iRetryCount = 0;
   236             iRetryCount = 0;
   243             DoFetchAttachmentL();
   237             DoFetchAttachmentL();
   244             break;
   238             break;
   266                 iRetryTimer.After( iStatus, KIpsAttaFetchRetryInterval );
   260                 iRetryTimer.After( iStatus, KIpsAttaFetchRetryInterval );
   267                 SetActive();
   261                 SetActive();
   268                 }
   262                 }
   269             else
   263             else
   270                 {
   264                 {
   271                 if( err != KErrNone && iOperation )
   265                 if( err != KErrNone && iSubOperation )
   272                     {
   266                     {
   273                     iFetchErrorProgress = iOperation->ProgressL().AllocL();
   267                     iFetchErrorProgress = iSubOperation->ProgressL().AllocL();
   274                     }
   268                     }
   275                 
   269                 
   276                 iState = EStateIdle;
   270                 iState = EStateIdle;
   277                 CompleteObserver( err );
   271                 CompleteObserver( err );
   278                 }
   272                 }
   292         {
   286         {
   293         // Completed, but with an error during fetch.
   287         // Completed, but with an error during fetch.
   294         return *iFetchErrorProgress;
   288         return *iFetchErrorProgress;
   295         }
   289         }
   296     
   290     
   297     if ( iOperation )
   291     if ( iSubOperation )
   298         {
   292         {
   299         iProgress.Copy( iOperation->ProgressL() );
   293         iProgress.Copy( iSubOperation->ProgressL() );
   300         }
   294         }
   301     else
   295     else
   302         {
   296         {
   303         TImap4CompoundProgress progg;
   297         TImap4CompoundProgress progg;
   304         progg.iGenericProgress.iErrorCode = KErrNone;
   298         progg.iGenericProgress.iErrorCode = KErrNone;
   314 void CIpsPlgImap4FetchAttachmentOp::ReportProgressL()
   308 void CIpsPlgImap4FetchAttachmentOp::ReportProgressL()
   315     {
   309     {
   316     FUNC_LOG;
   310     FUNC_LOG;
   317     TInt error = KErrNone;
   311     TInt error = KErrNone;
   318     TFSProgress fsProgress = { TFSProgress::EFSStatus_Waiting, 0, 0, KErrNone };
   312     TFSProgress fsProgress = { TFSProgress::EFSStatus_Waiting, 0, 0, KErrNone };
   319     if ( iOperation && iState == EStateFetching )
   313     if ( iSubOperation && iState == EStateFetching )
   320         {
   314         {
   321         TRAP(error, iProgress.Copy( iOperation->ProgressL() ) );
   315         TRAP(error, iProgress.Copy( iSubOperation->ProgressL() ) );
   322         }
   316         }
   323     
   317     
   324     if ( error == KErrNone )
   318     if ( error == KErrNone )
   325         {
   319         {
   326         const TImap4GenericProgress& progg = iProgress().iGenericProgress;
   320         const TImap4GenericProgress& progg = iProgress().iGenericProgress;
   340         }
   334         }
   341     else
   335     else
   342         {
   336         {
   343         User::Leave( error );
   337         User::Leave( error );
   344         }
   338         }
   345     
   339 
   346     iFSOperationObserver.RequestResponseL( fsProgress, iFSRequestId );
   340 // <qmail>
       
   341     // signal observer if it exists
       
   342     if ( iFSOperationObserver )
       
   343         {
       
   344         iFSOperationObserver->RequestResponseL( fsProgress, iFSRequestId );
       
   345         }
       
   346 // </qmail>
   347     }
   347     }
   348 
   348 
   349 // ----------------------------------------------------------------------------
   349 // ----------------------------------------------------------------------------
   350 // ----------------------------------------------------------------------------
   350 // ----------------------------------------------------------------------------
   351 const TDesC8& CIpsPlgImap4FetchAttachmentOp::GetErrorProgressL(TInt /*aError*/ )
   351 const TDesC8& CIpsPlgImap4FetchAttachmentOp::GetErrorProgressL(TInt /*aError*/ )
   397     {
   397     {
   398     FUNC_LOG;
   398     FUNC_LOG;
   399     iState = EStateFetching;
   399     iState = EStateFetching;
   400 
   400 
   401     // Switch operations.
   401     // Switch operations.
   402     delete iOperation;
   402     delete iSubOperation;
   403     iOperation = NULL;
   403     iSubOperation = NULL;
   404     iStatus = KRequestPending;
   404     iStatus = KRequestPending;
   405 
   405 
   406     iProgReport = CIpsFetchProgReport::NewL( *this );
   406     iProgReport = CIpsFetchProgReport::NewL( *this );
   407 
   407 
   408     // Filters are not used when performing 'fetch' operation, 
   408     // Filters are not used when performing 'fetch' operation, 
   409     // use normal getmail info instead
   409     // use normal getmail info instead
   410     TPckg<TImImap4GetMailInfo> param(iGetMailInfo);
   410 // <qmail>
   411     InvokeClientMtmAsyncFunctionL( iFunctionId, *iSelection, iService, param );
   411     TPckgBuf<TImImap4GetMailInfo> param;
       
   412     TImImap4GetMailInfo& options = param();
       
   413     options.iMaxEmailSize = KMaxTInt32;
       
   414     options.iGetMailBodyParts = EGetImap4EmailAttachments;
       
   415     options.iDestinationFolder = 0; // not used
       
   416 
       
   417     InvokeClientMtmAsyncFunctionL( KIMAP4MTMPopulate, *iSelection, param ); // <qmail> 1 param removed
       
   418 // </qmail>
   412     SetActive();
   419     SetActive();
   413     }
   420     }
   414     
   421     
       
   422 // <qmail> GetEngineProgress function removed
       
   423 
       
   424 // <qmail> new func to this op
   415 // ----------------------------------------------------------------------------
   425 // ----------------------------------------------------------------------------
   416 // ----------------------------------------------------------------------------    
   426 // ----------------------------------------------------------------------------    
   417 TInt CIpsPlgImap4FetchAttachmentOp::GetEngineProgress( const TDesC8& aProgress )
   427 TIpsOpType CIpsPlgImap4FetchAttachmentOp::IpsOpType() const
   418     {
   428     {
   419     FUNC_LOG;
   429     FUNC_LOG;
   420     if( !aProgress.Length() )
   430     return EIpsOpTypeFetchAttachmentOp;
   421         {
   431     }
   422         return KErrNone;
   432 // </qmail>
   423         }
       
   424     else
       
   425         {
       
   426         TPckgBuf<TImap4CompoundProgress> paramPack;
       
   427         paramPack.Copy( aProgress );
       
   428         const TImap4GenericProgress& progress = paramPack().iGenericProgress;
       
   429 
       
   430         return progress.iErrorCode;
       
   431         }    
       
   432     }        
       
   433 
   433 
   434 
   434 
   435 // End of File
   435 // End of File
   436 
   436