ipsservices/ipssosplugin/src/ipsplgimap4plugin.cpp
branchRCL_3
changeset 64 3533d4323edc
parent 63 d189ee25cf9d
equal deleted inserted replaced
63:d189ee25cf9d 64:3533d4323edc
    13 *
    13 *
    14 * Description: This file implements class CIpsPlgImap4Plugin.
    14 * Description: This file implements class CIpsPlgImap4Plugin.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
       
    18 
       
    19 
    18 #include "emailtrace.h"
    20 #include "emailtrace.h"
    19 #include "ipsplgheaders.h"
    21 #include "ipsplgheaders.h"
    20 
    22 #include <baseplugincommonutils.h>     // CleanupResetAndDestroyPushL
    21 // <qmail> priority const has been removed
    23 
       
    24 const TInt KConnectOpPriority = CActive::EPriorityStandard;
    22 
    25 
    23 // ---------------------------------------------------------------------------
    26 // ---------------------------------------------------------------------------
    24 // CIpsPlgImap4Plugin::CIpsPlgImap4Plugin()
    27 // CIpsPlgImap4Plugin::CIpsPlgImap4Plugin()
    25 // ---------------------------------------------------------------------------
    28 // ---------------------------------------------------------------------------
    26 //
    29 //
    29     {
    32     {
    30     FUNC_LOG;
    33     FUNC_LOG;
    31     // none
    34     // none
    32     }
    35     }
    33 
    36 
       
    37 
    34 // ---------------------------------------------------------------------------
    38 // ---------------------------------------------------------------------------
    35 // CIpsPlgImap4Plugin::ConstructL()
    39 // CIpsPlgImap4Plugin::ConstructL()
    36 // ---------------------------------------------------------------------------
    40 // ---------------------------------------------------------------------------
    37 //
    41 //
    38 void CIpsPlgImap4Plugin::ConstructL()
    42 void CIpsPlgImap4Plugin::ConstructL()
    39     {
    43     {
    40     FUNC_LOG;
    44     FUNC_LOG;
    41     BaseConstructL();
    45     BaseConstructL();
    42     }
    46     }
       
    47 
    43 
    48 
    44 // ---------------------------------------------------------------------------
    49 // ---------------------------------------------------------------------------
    45 // CIpsPlgImap4Plugin::NewL()
    50 // CIpsPlgImap4Plugin::NewL()
    46 // ---------------------------------------------------------------------------
    51 // ---------------------------------------------------------------------------
    47 //
    52 //
    50     FUNC_LOG;
    55     FUNC_LOG;
    51     CIpsPlgImap4Plugin* self = CIpsPlgImap4Plugin::NewLC();
    56     CIpsPlgImap4Plugin* self = CIpsPlgImap4Plugin::NewLC();
    52     CleanupStack::Pop( self );
    57     CleanupStack::Pop( self );
    53     return self;
    58     return self;
    54     }
    59     }
       
    60 
    55 
    61 
    56 // ---------------------------------------------------------------------------
    62 // ---------------------------------------------------------------------------
    57 // CIpsPlgImap4Plugin::NewLC()
    63 // CIpsPlgImap4Plugin::NewLC()
    58 // ---------------------------------------------------------------------------
    64 // ---------------------------------------------------------------------------
    59 //
    65 //
   139 // ---------------------------------------------------------------------------
   145 // ---------------------------------------------------------------------------
   140 //
   146 //
   141 void CIpsPlgImap4Plugin::RefreshNowL(
   147 void CIpsPlgImap4Plugin::RefreshNowL(
   142     const TFSMailMsgId& aMailBoxId,
   148     const TFSMailMsgId& aMailBoxId,
   143     MFSMailRequestObserver& aOperationObserver,
   149     MFSMailRequestObserver& aOperationObserver,
   144     TInt aRequestId,
   150     TInt aRequestId )
   145     const TBool /*aSilentConnection*/ )
       
   146     {
   151     {
   147     FUNC_LOG;
   152     FUNC_LOG;
   148     
   153     
   149     TMsvId service = aMailBoxId.Id();
   154     TMsvId service = aMailBoxId.Id();
   150     
   155     
   151     CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewL( *this );
   156     CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewL( *this );
   152     CleanupStack::PushL( watcher );
   157     CleanupStack::PushL( watcher );
   153     
   158     
   154     // <qmail> priority parameter has been removed
       
   155     CIpsPlgBaseOperation* op = CIpsPlgImap4ConnectOp::NewL(
   159     CIpsPlgBaseOperation* op = CIpsPlgImap4ConnectOp::NewL(
   156     		*iSession,
   160     		*iSession,
       
   161     		KConnectOpPriority, 
   157     		watcher->iStatus, 
   162     		watcher->iStatus, 
   158     		service,
   163     		service,
   159     		ActivityTimerL( aMailBoxId ),
   164     		ActivityTimerL( aMailBoxId ),
   160           	aMailBoxId, 
   165           	aMailBoxId, 
   161           	&aOperationObserver,
   166           	aOperationObserver,
   162           	aRequestId,
   167           	aRequestId,
   163           	iEventHandler );
   168           	iEventHandler );
   164     
   169     
   165     watcher->SetOperation( op );
   170     watcher->SetOperation( op );
   166     iOperations.AppendL( watcher );
   171     iOperations.AppendL( watcher );
   293     info.iTotalSizeLimit = KMaxTInt32;
   298     info.iTotalSizeLimit = KMaxTInt32;
   294     info.iBodyTextSizeLimit = KMaxTInt32;
   299     info.iBodyTextSizeLimit = KMaxTInt32;
   295     info.iAttachmentSizeLimit = 0;
   300     info.iAttachmentSizeLimit = 0;
   296     info.iDestinationFolder = aFolderId.Id();
   301     info.iDestinationFolder = aFolderId.Id();
   297     
   302     
   298     // <qmail> priority parameter has been removed
       
   299     CIpsPlgBaseOperation* op = CIpsPlgImap4PopulateOp::NewL( 
   303     CIpsPlgBaseOperation* op = CIpsPlgImap4PopulateOp::NewL( 
   300         *iSession, 
   304         *iSession, 
   301         watcher->iStatus,
   305         watcher->iStatus,
       
   306         CActive::EPriorityStandard,
   302         aMailBoxId.Id(),
   307         aMailBoxId.Id(),
   303         ActivityTimerL( aMailBoxId ),
   308         ActivityTimerL( aMailBoxId ),
   304         info,
   309         info,
   305         *sel,
   310         *sel,
   306         aMailBoxId, 
   311         aMailBoxId, 
   307         &aObserver,
   312         aObserver,
   308         aRequestId,
   313         aRequestId,
   309         iEventHandler, 
   314         iEventHandler, 
   310         EFalse ); // do not filter mail selection
   315         EFalse ); // do not filter mail selection
   311     
   316     
   312     watcher->SetOperation( op );
   317     watcher->SetOperation( op );
   349         TInt msgIdCount( aMessageIds.Count() );
   354         TInt msgIdCount( aMessageIds.Count() );
   350         for ( TInt i(0); i< msgIdCount; i++ )
   355         for ( TInt i(0); i< msgIdCount; i++ )
   351             {
   356             {
   352             sel->AppendL( aMessageIds[i].Id() );
   357             sel->AppendL( aMessageIds[i].Id() );
   353             }
   358             }
   354     	
   359 
   355 		// <qmail> TImImap4GetMailInfo options not needed
   360         TPckgBuf<TImImap4GetMailInfo> optionsBuf;
       
   361         TImImap4GetMailInfo& options = optionsBuf();
       
   362         options.iMaxEmailSize = KMaxTInt32;
       
   363         options.iGetMailBodyParts = EGetImap4EmailHeaders;
       
   364         options.iDestinationFolder = aDestinationFolderId.Id();
   356 
   365 
   357         CIpsPlgImap4MoveRemoteOpObserver* observer =
   366         CIpsPlgImap4MoveRemoteOpObserver* observer =
   358             CIpsPlgImap4MoveRemoteOpObserver::NewL( *iSession, *iEventHandler,
   367             CIpsPlgImap4MoveRemoteOpObserver::NewL( *iSession, *iEventHandler,
   359                 aSourceFolderId, aMessageIds );
   368                 aSourceFolderId, aMessageIds );
   360         watcher->SetRequestObserver( observer );
   369         watcher->SetRequestObserver( observer );
   361 
   370 
   362         // Synchronous operation
   371         // Synchronous operation
   363         // <qmail> following constructor's parameters have changed
   372         CIpsPlgBaseOperation* op = CIpsPlgImap4MoveRemoteOp::NewL(
   364     	CIpsPlgBaseOperation* op = CIpsPlgImap4MoveRemoteOp::NewL(
       
   365             *iSession, 
   373             *iSession, 
   366             watcher->iStatus,
   374             watcher->iStatus,
       
   375             KIMAP4MTMMoveMailSelectionWhenAlreadyConnected,
   367             service,
   376             service,
   368             ActivityTimerL( aMailBoxId ),
   377             ActivityTimerL( aMailBoxId ),
   369             aDestinationFolderId.Id(),
   378             options,
   370             *sel,
   379             *sel,
   371             aMailBoxId,
   380             aMailBoxId,
   372             NULL, // no observer, async not supported
   381             *observer, // async not supported
   373             0 ); // async not supported
   382             0 ); // async not supported
   374 
   383 
   375         watcher->SetOperation( op );
   384         watcher->SetOperation( op );
   376         CleanupStack::PopAndDestroy( sel );
   385         CleanupStack::PopAndDestroy( sel );
   377         iOperations.AppendL( watcher );
   386         iOperations.AppendL( watcher );
   431         TImImap4GetMailInfo& options = optionsBuf();
   440         TImImap4GetMailInfo& options = optionsBuf();
   432         options.iMaxEmailSize = KMaxTInt32;
   441         options.iMaxEmailSize = KMaxTInt32;
   433         options.iGetMailBodyParts = EGetImap4EmailBodyTextAndAttachments;
   442         options.iGetMailBodyParts = EGetImap4EmailBodyTextAndAttachments;
   434         options.iDestinationFolder = aDestinationFolderId.Id();
   443         options.iDestinationFolder = aDestinationFolderId.Id();
   435 
   444 
   436 		// <qmail> following constructor's parameters have changed
   445         CIpsPlgBaseOperation* op = CIpsPlgImap4MoveRemoteOp::NewL(
   437     	CIpsPlgBaseOperation* op = CIpsPlgImap4MoveRemoteOp::NewL(
       
   438             *iSession, 
   446             *iSession, 
   439             watcher->iStatus,
   447             watcher->iStatus,
       
   448             KIMAP4MTMMoveMailSelectionWhenAlreadyConnected,
   440             service,
   449             service,
   441             ActivityTimerL( aMailBoxId ),
   450             ActivityTimerL( aMailBoxId ),
   442             aDestinationFolderId.Id(),
   451             options,
   443             *sel,
   452             *sel,
   444             aMailBoxId,
   453             aMailBoxId,
   445             &aOperationObserver, // async not supported
   454             aOperationObserver,
   446             0 ); // async not supported
   455             aRequestId ); 
   447 
   456 
   448         watcher->SetOperation( op );
   457         watcher->SetOperation( op );
   449         CleanupStack::PopAndDestroy( sel );
   458         CleanupStack::PopAndDestroy( sel );
   450         iOperations.AppendL( watcher );
   459         iOperations.AppendL( watcher );
   451         CleanupStack::Pop( watcher );
   460         CleanupStack::Pop( watcher );
   522                         
   531                         
   523             return;
   532             return;
   524             }
   533             }
   525         
   534         
   526         }
   535         }
   527        
   536     
   528 	// <qmail> TImImap4GetMailInfo options removed
   537     TPckgBuf<TImImap4GetMailInfo> optionsBuf;
       
   538     TImImap4GetMailInfo& options = optionsBuf();
       
   539     options.iMaxEmailSize = KMaxTInt32;
       
   540     options.iGetMailBodyParts = EGetImap4EmailAttachments;
       
   541     options.iDestinationFolder = 0; // not used
       
   542     
   529     CIpsPlgBaseOperation* op = CIpsPlgImap4FetchAttachmentOp::NewL( 
   543     CIpsPlgBaseOperation* op = CIpsPlgImap4FetchAttachmentOp::NewL( 
   530         *iSession, 
   544         *iSession, watcher->iStatus, KIMAP4MTMPopulate, aMailBoxId.Id(),
   531         watcher->iStatus,
   545         ActivityTimerL( aMailBoxId ), options, *sel, aMailBoxId,
   532         aMailBoxId.Id(),
   546         aOperationObserver, aRequestId );
   533         ActivityTimerL( aMailBoxId ), 
       
   534         sel, // ownership is transferred
       
   535         aMailBoxId,
       
   536         &aOperationObserver,
       
   537         aRequestId );
       
   538     
   547     
   539     watcher->SetOperation( op );
   548     watcher->SetOperation( op );
       
   549     CleanupStack::PopAndDestroy( sel );
   540     iOperations.AppendL( watcher );
   550     iOperations.AppendL( watcher );
   541 // <qmail>
       
   542     CleanupStack::Pop( sel );
       
   543 // </qmail>
       
   544     CleanupStack::Pop( watcher );
   551     CleanupStack::Pop( watcher );
   545     }
   552     }
   546 
   553 
   547 // ----------------------------------------------------------------------------
   554 // ----------------------------------------------------------------------------
   548 // CIpsPlgImap4Plugin::PopulateNewMailL( )
   555 // CIpsPlgImap4Plugin::PopulateNewMailL( )
   576     CEmailAccounts* accounts = CEmailAccounts::NewLC();
   583     CEmailAccounts* accounts = CEmailAccounts::NewLC();
   577     TImapAccount imapAcc;
   584     TImapAccount imapAcc;
   578     accounts->GetImapAccountL( aMailboxId.Id(), imapAcc );
   585     accounts->GetImapAccountL( aMailboxId.Id(), imapAcc );
   579     accounts->LoadImapSettingsL( imapAcc, *settings );
   586     accounts->LoadImapSettingsL( imapAcc, *settings );
   580     TImImap4GetPartialMailInfo info;
   587     TImImap4GetPartialMailInfo info;
   581 // <qmail> Get TImImap4GetPartialMailInfo based on settings
   588     CIpsSetDataApi::ConstructImapPartialFetchInfo( info, *settings );
   582     CIpsPlgImap4ConnectOp::ConstructImapPartialFetchInfo( info, *settings );
       
   583     CleanupStack::PopAndDestroy( 2, settings );
   589     CleanupStack::PopAndDestroy( 2, settings );
   584 
   590     
   585     if ( info.iTotalSizeLimit == KIpsSetDataHeadersOnly )
   591     if ( info.iTotalSizeLimit == KIpsSetDataHeadersOnly )
   586         {
   592         {
   587         return;
   593         return;
   588         }
   594         }
   589 // </qmail>
       
   590     
   595     
   591     TPckgBuf<TImImap4GetPartialMailInfo> package(info);
   596     TPckgBuf<TImImap4GetPartialMailInfo> package(info);
   592     
   597     
   593     CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewL(*this);
   598     CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewL(*this);
   594     CleanupStack::PushL( watcher );
   599     CleanupStack::PushL( watcher );
   596     CMsvEntrySelection* sel = new(ELeave) CMsvEntrySelection;
   601     CMsvEntrySelection* sel = new(ELeave) CMsvEntrySelection;
   597     CleanupStack::PushL(sel);
   602     CleanupStack::PushL(sel);
   598     sel->AppendL( aMailboxId.Id() );
   603     sel->AppendL( aMailboxId.Id() );
   599     sel->AppendL( aNewId );
   604     sel->AppendL( aNewId );
   600     
   605     
   601     // <qmail> priority parameter has been removed
       
   602     CIpsPlgBaseOperation* op = CIpsPlgImap4PopulateOp::NewL( 
   606     CIpsPlgBaseOperation* op = CIpsPlgImap4PopulateOp::NewL( 
   603         *iSession, 
   607         *iSession, 
   604         watcher->iStatus,
   608         watcher->iStatus,
       
   609         KIMAP4MTMPopulateMailSelectionWhenAlreadyConnected,
   605         aMailboxId.Id(),
   610         aMailboxId.Id(),
   606         ActivityTimerL( aMailboxId ),
   611         ActivityTimerL( aMailboxId ),
   607         info,
   612         info,
   608         *sel,
   613         *sel,
   609         aMailboxId, 
   614         aMailboxId, 
   610         NULL, // no operation observer
   615         *this,
   611         0,    // no use for requestId
   616         KErrNotFound,
   612         iEventHandler,
   617         iEventHandler,
   613         EFalse ); // do not block entry changed and created events
   618         EFalse ); // do not block entry changed and created events
   614     
   619     
   615     watcher->SetOperation( op );
   620     watcher->SetOperation( op );
   616     CleanupStack::PopAndDestroy( sel );
   621     CleanupStack::PopAndDestroy( sel );