ipsservices/ipssosplugin/src/ipsplgimap4fetchattachmentop.cpp
changeset 20 ecc8def7944a
parent 18 578830873419
child 23 2dc6caa42ec3
equal deleted inserted replaced
18:578830873419 20:ecc8def7944a
    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
    24 const TInt KFetchOpPriority = CActive::EPriorityStandard;
    24 const TInt KIpsAttaFetchProgressReportInterval = 200000; // 0.2 sec
    25 const TInt KIpsAttaFetchProgressReportInterval = 1000000; // 1 sec
       
    26 
    25 
    27 // ----------------------------------------------------------------------------
    26 // ----------------------------------------------------------------------------
    28 // ----------------------------------------------------------------------------
    27 // ----------------------------------------------------------------------------
    29 CIpsFetchProgReport* CIpsFetchProgReport::NewL( 
    28 CIpsFetchProgReport* CIpsFetchProgReport::NewL( 
    30     CIpsPlgImap4FetchAttachmentOp& aAttaOp )
    29     CIpsPlgImap4FetchAttachmentOp& aAttaOp )
    95     iAttaOp.ReportProgressL();
    94     iAttaOp.ReportProgressL();
    96     AdjustTimer();
    95     AdjustTimer();
    97     }
    96     }
    98 
    97 
    99 // ----------------------------------------------------------------------------
    98 // ----------------------------------------------------------------------------
       
    99 // CIpsPlgImap4FetchAttachmentOp
   100 // ----------------------------------------------------------------------------
   100 // ----------------------------------------------------------------------------
   101 CIpsPlgImap4FetchAttachmentOp* CIpsPlgImap4FetchAttachmentOp::NewL(
   101 CIpsPlgImap4FetchAttachmentOp* CIpsPlgImap4FetchAttachmentOp::NewL(
   102     CMsvSession& aMsvSession,
   102     CMsvSession& aMsvSession,
   103     TRequestStatus& aObserverRequestStatus,
   103     TRequestStatus& aObserverRequestStatus,
   104     TInt aFunctionId,
       
   105     TMsvId aService,
   104     TMsvId aService,
   106     CIpsPlgTimerOperation& aActivityTimer,
   105     CIpsPlgTimerOperation& aActivityTimer,
   107     const TImImap4GetMailInfo& aGetMailInfo,
   106     const CMsvEntrySelection* aSelection,
   108     const CMsvEntrySelection& aSel,
       
   109     TFSMailMsgId aFSMailBoxId,
   107     TFSMailMsgId aFSMailBoxId,
   110     MFSMailRequestObserver& aFSOperationObserver,
   108     MFSMailRequestObserver* aFSOperationObserver,
   111     TInt aFSRequestId )
   109     TInt aFSRequestId )
   112     {
   110     {
   113     FUNC_LOG;
   111     FUNC_LOG;
   114     CIpsPlgImap4FetchAttachmentOp* op = new (
   112     CIpsPlgImap4FetchAttachmentOp* op = new (
   115         ELeave) CIpsPlgImap4FetchAttachmentOp(
   113         ELeave) CIpsPlgImap4FetchAttachmentOp(
   116         aMsvSession,
   114         aMsvSession,
   117         aObserverRequestStatus,
   115         aObserverRequestStatus,
   118         aFunctionId,
       
   119         aService,
   116         aService,
   120         aActivityTimer,
   117         aActivityTimer,
   121         aGetMailInfo,
   118         aSelection,
   122         aFSMailBoxId,
   119         aFSMailBoxId,
   123         aFSOperationObserver,
   120         aFSOperationObserver,
   124         aFSRequestId );
   121         aFSRequestId );
   125         
   122         
   126     CleanupStack::PushL( op );
   123     CleanupStack::PushL( op );
   127     op->ConstructL( aSel );
   124     op->ConstructL();
   128     CleanupStack::Pop( op );
   125     CleanupStack::Pop( op );
   129     return op;
   126     return op;
   130     }
   127     }
   131 
   128 
   132 // ----------------------------------------------------------------------------
   129 // ----------------------------------------------------------------------------
   133 // ----------------------------------------------------------------------------
   130 // ----------------------------------------------------------------------------
       
   131 // <qmail> priority parameter has been removed
   134 CIpsPlgImap4FetchAttachmentOp::CIpsPlgImap4FetchAttachmentOp(
   132 CIpsPlgImap4FetchAttachmentOp::CIpsPlgImap4FetchAttachmentOp(
   135     CMsvSession& aMsvSession,
   133     CMsvSession& aMsvSession,
   136     TRequestStatus& aObserverRequestStatus,
   134     TRequestStatus& aObserverRequestStatus,
   137     TInt aFunctionId,
       
   138     TMsvId aService,
   135     TMsvId aService,
   139     CIpsPlgTimerOperation& aActivityTimer,
   136     CIpsPlgTimerOperation& aActivityTimer,
   140     const TImImap4GetMailInfo& aGetMailInfo,
   137     const CMsvEntrySelection* aSelection,
   141     TFSMailMsgId aFSMailBoxId,
   138     TFSMailMsgId aFSMailBoxId,
   142     MFSMailRequestObserver& aFSOperationObserver,
   139     MFSMailRequestObserver* aFSOperationObserver,
   143     TInt aFSRequestId )
   140     TInt aFSRequestId )
   144     :
   141     :
   145     CIpsPlgOnlineOperation(
   142     CIpsPlgOnlineOperation(
   146     aMsvSession,
   143         aMsvSession,
   147     KFetchOpPriority,
   144         aObserverRequestStatus,
   148     aObserverRequestStatus,
   145         aActivityTimer,
   149     aActivityTimer,
   146         aFSMailBoxId,
   150     aFSMailBoxId,
   147         aFSOperationObserver,
   151     aFSOperationObserver,
   148         aFSRequestId ),
   152     aFSRequestId),
   149     iSelection( aSelection )
   153     iSelection( NULL ),
       
   154     iGetMailInfo(aGetMailInfo),
       
   155     iFunctionId(aFunctionId)
       
   156     {
   150     {
   157     FUNC_LOG;
   151     FUNC_LOG;
   158     iService = aService;
   152     iService = aService;
   159     }
   153     }
   160 
   154 
   163 CIpsPlgImap4FetchAttachmentOp::~CIpsPlgImap4FetchAttachmentOp()
   157 CIpsPlgImap4FetchAttachmentOp::~CIpsPlgImap4FetchAttachmentOp()
   164     {
   158     {
   165     FUNC_LOG;
   159     FUNC_LOG;
   166     delete iSelection;
   160     delete iSelection;
   167     delete iProgReport;
   161     delete iProgReport;
   168     }
   162     delete iFetchErrorProgress;
   169 
   163     }
   170 // ----------------------------------------------------------------------------
   164 
   171 // ----------------------------------------------------------------------------
   165 // ----------------------------------------------------------------------------
   172 void CIpsPlgImap4FetchAttachmentOp::ConstructL( const CMsvEntrySelection& aSel )
   166 // ----------------------------------------------------------------------------
       
   167 void CIpsPlgImap4FetchAttachmentOp::ConstructL()
   173     {
   168     {
   174     FUNC_LOG;
   169     FUNC_LOG;
   175     BaseConstructL( KUidMsgTypeIMAP4 );
   170     BaseConstructL( KUidMsgTypeIMAP4 );
   176     iSelection = aSel.CopyL();
       
   177     DoConnectL();
   171     DoConnectL();
   178     }
   172     }
   179 
   173 
   180 // ----------------------------------------------------------------------------
   174 // ----------------------------------------------------------------------------
   181 // ----------------------------------------------------------------------------
   175 // ----------------------------------------------------------------------------
   183     {
   177     {
   184     FUNC_LOG;
   178     FUNC_LOG;
   185     iState = EStateConnecting;
   179     iState = EStateConnecting;
   186     iStatus = KRequestPending;
   180     iStatus = KRequestPending;
   187 
   181 
       
   182     // <qmail> priority parameter has been removed
   188     CIpsPlgImap4ConnectOp* connOp = CIpsPlgImap4ConnectOp::NewL(
   183     CIpsPlgImap4ConnectOp* connOp = CIpsPlgImap4ConnectOp::NewL(
   189         iMsvSession,
   184         iMsvSession,
   190         KFetchOpPriority,
       
   191         iStatus, 
   185         iStatus, 
   192         iService,
   186         iService,
   193         iActivityTimer,
   187         iActivityTimer,
   194         iFSMailboxId,
   188         iFSMailboxId,
   195         iFSOperationObserver,
   189         NULL, // no observer for subopertaion
   196         iFSRequestId,
   190         0,    // no requestId needed
   197         NULL, // event handler not needed whin plain connect
   191         NULL, // event handler not needed whin plain connect
   198         ETrue,
   192         ETrue );
   199         EFalse );
       
   200         
   193         
   201     delete iOperation;
   194     delete iSubOperation;
   202     iOperation = connOp;
   195     iSubOperation = connOp;
   203 
   196 
   204     SetActive();
   197     SetActive();
   205     }
   198     }
   206     
   199     
   207 // ----------------------------------------------------------------------------
   200 // ----------------------------------------------------------------------------
   238         case EStateFetching:         
   231         case EStateFetching:         
   239             {
   232             {
   240             delete iProgReport;
   233             delete iProgReport;
   241             iProgReport = NULL;
   234             iProgReport = NULL;
   242             
   235             
   243             TInt err = iStatus.Int();
   236             TInt err( iStatus.Int() );
   244 
   237             if( err != KErrNone && iSubOperation )
   245             if( err != KErrNone && iOperation )
       
   246                 {
   238                 {
   247                 iFetchErrorProgress = iOperation->ProgressL().AllocL();
   239                 iFetchErrorProgress = iSubOperation->ProgressL().AllocL();
   248                 }
   240                 }
   249             
   241             
   250             iState = EStateIdle;
   242             iState = EStateIdle;
   251             CompleteObserver( err );
   243             CompleteObserver( err );
   252             break;
   244             break;
   265         {
   257         {
   266         // Completed, but with an error during fetch.
   258         // Completed, but with an error during fetch.
   267         return *iFetchErrorProgress;
   259         return *iFetchErrorProgress;
   268         }
   260         }
   269     
   261     
   270     if ( iOperation )
   262     if ( iSubOperation )
   271         {
   263         {
   272         iProgress.Copy( iOperation->ProgressL() );
   264         iProgress.Copy( iSubOperation->ProgressL() );
   273         }
   265         }
   274     else
   266     else
   275         {
   267         {
   276         TImap4CompoundProgress progg;
   268         TImap4CompoundProgress progg;
   277         progg.iGenericProgress.iErrorCode = KErrNone;
   269         progg.iGenericProgress.iErrorCode = KErrNone;
   285 // ----------------------------------------------------------------------------
   277 // ----------------------------------------------------------------------------
   286 // ----------------------------------------------------------------------------
   278 // ----------------------------------------------------------------------------
   287 void CIpsPlgImap4FetchAttachmentOp::ReportProgressL()
   279 void CIpsPlgImap4FetchAttachmentOp::ReportProgressL()
   288     {
   280     {
   289     FUNC_LOG;
   281     FUNC_LOG;
   290     TInt error = KErrNone;
   282     TInt error( KErrNone );
   291     TFSProgress fsProgress = { TFSProgress::EFSStatus_Waiting, 0, 0, KErrNone };
   283     TFSProgress fsProgress = { TFSProgress::EFSStatus_Waiting, 0, 0, KErrNone };
   292     if ( iOperation && iState == EStateFetching )
   284     if ( iSubOperation && iState == EStateFetching )
   293         {
   285         {
   294         TRAP(error, iProgress.Copy( iOperation->ProgressL() ) );
   286         TRAP(error, iProgress.Copy( iSubOperation->ProgressL() ) );
   295         }
   287         }
   296     
   288     
   297     if ( error == KErrNone )
   289     if ( error == KErrNone )
   298         {
   290         {
   299         const TImap4GenericProgress& progg = iProgress().iGenericProgress;
   291         const TImap4GenericProgress& progg = iProgress().iGenericProgress;
   314     else
   306     else
   315         {
   307         {
   316         User::Leave( error );
   308         User::Leave( error );
   317         }
   309         }
   318     
   310     
   319     iFSOperationObserver.RequestResponseL( fsProgress, iFSRequestId );
   311     // signal observer if it exists
       
   312     if ( iFSOperationObserver )
       
   313         {
       
   314         iFSOperationObserver->RequestResponseL( fsProgress, iFSRequestId );
       
   315         }
   320     }
   316     }
   321 
   317 
   322 // ----------------------------------------------------------------------------
   318 // ----------------------------------------------------------------------------
   323 // ----------------------------------------------------------------------------
   319 // ----------------------------------------------------------------------------
   324 const TDesC8& CIpsPlgImap4FetchAttachmentOp::GetErrorProgressL(TInt /*aError*/ )
   320 const TDesC8& CIpsPlgImap4FetchAttachmentOp::GetErrorProgressL(TInt /*aError*/ )
   370     {
   366     {
   371     FUNC_LOG;
   367     FUNC_LOG;
   372     iState = EStateFetching;
   368     iState = EStateFetching;
   373 
   369 
   374     // Switch operations.
   370     // Switch operations.
   375     delete iOperation;
   371     delete iSubOperation;
   376     iOperation = NULL;
   372     iSubOperation = NULL;
   377     iStatus = KRequestPending;
       
   378 
   373 
   379     iProgReport = CIpsFetchProgReport::NewL( *this );
   374     iProgReport = CIpsFetchProgReport::NewL( *this );
   380 
   375 
   381     // Filters are not used when performing 'fetch' operation, 
   376     // Filters are not used when performing 'fetch' operation, 
   382     // use normal getmail info instead
   377     // use normal getmail info instead
   383     TPckg<TImImap4GetMailInfo> param(iGetMailInfo);
   378     TPckgBuf<TImImap4GetMailInfo> param;
   384     InvokeClientMtmAsyncFunctionL( iFunctionId, *iSelection, iService, param );
   379     TImImap4GetMailInfo& options = param();
       
   380     options.iMaxEmailSize = KMaxTInt32;
       
   381     options.iGetMailBodyParts = EGetImap4EmailAttachments;
       
   382     options.iDestinationFolder = 0; // not used
       
   383 
       
   384     InvokeClientMtmAsyncFunctionL( KIMAP4MTMPopulate, *iSelection, param ); // <qmail> 1 param removed
   385     SetActive();
   385     SetActive();
   386     }
   386     }
   387     
   387     
       
   388 // <qmail> new func to this op
   388 // ----------------------------------------------------------------------------
   389 // ----------------------------------------------------------------------------
   389 // ----------------------------------------------------------------------------    
   390 // ----------------------------------------------------------------------------    
   390 TInt CIpsPlgImap4FetchAttachmentOp::GetEngineProgress( const TDesC8& aProgress )
   391 TIpsOpType CIpsPlgImap4FetchAttachmentOp::IpsOpType() const
   391     {
   392     {
   392     FUNC_LOG;
   393     FUNC_LOG;
   393     if( !aProgress.Length() )
   394     return EIpsOpTypeFetchAttachmentOp;
   394         {
   395     }
   395         return KErrNone;
       
   396         }
       
   397     else
       
   398         {
       
   399         TPckgBuf<TImap4CompoundProgress> paramPack;
       
   400         paramPack.Copy( aProgress );
       
   401         const TImap4GenericProgress& progress = paramPack().iGenericProgress;
       
   402 
       
   403         return progress.iErrorCode;
       
   404         }    
       
   405     }        
       
   406 
       
   407 
       
   408 // End of File
       
   409