ipsservices/ipssosplugin/src/ipsplgsosbaseplugin.cpp
changeset 72 64e38f08e49c
parent 65 478bc57ad291
child 68 83cc6bae1de8
equal deleted inserted replaced
65:478bc57ad291 72:64e38f08e49c
    22 
    22 
    23 // <qmail>
    23 // <qmail>
    24 #include "ipsplgsosbaseplugin.hrh"
    24 #include "ipsplgsosbaseplugin.hrh"
    25 #include "ipsplgmailstoreroperation.h"
    25 #include "ipsplgmailstoreroperation.h"
    26 #include "ipsplgmessagepartstoreroperation.h"
    26 #include "ipsplgmessagepartstoreroperation.h"
    27 #include "BasePlugin.h" 
    27 #include "BasePlugin.h"
    28 //<Qmail>
    28 //<Qmail>
    29 #include "ipssosextendedsettingsmanager.h"
    29 #include "ipssosextendedsettingsmanager.h"
    30 #include "ipssettingkeys.h"
    30 #include "ipssettingkeys.h"
    31 //</Qmail>
    31 //</Qmail>
    32 //</qmail>
    32 //</qmail>
    58     {
    58     {
    59     if(aInterfaceUid != KEmailMailboxStateExtensionUid)
    59     if(aInterfaceUid != KEmailMailboxStateExtensionUid)
    60         {
    60         {
    61         User::Leave(KErrNotSupported);
    61         User::Leave(KErrNotSupported);
    62         }
    62         }
    63     
    63 
    64     return iStateExtension;
    64     return iStateExtension;
    65     }
    65     }
    66 //</Qmail>
    66 //</Qmail>
    67 // ----------------------------------------------------------------------------
    67 // ----------------------------------------------------------------------------
    68 // ----------------------------------------------------------------------------
    68 // ----------------------------------------------------------------------------
    87     }
    87     }
    88 
    88 
    89 // ----------------------------------------------------------------------------
    89 // ----------------------------------------------------------------------------
    90 // ----------------------------------------------------------------------------
    90 // ----------------------------------------------------------------------------
    91 // <qmail> iSettingsApi, iWait removed
    91 // <qmail> iSettingsApi, iWait removed
    92 CIpsPlgSosBasePlugin::~CIpsPlgSosBasePlugin()
    92 EXPORT_C CIpsPlgSosBasePlugin::~CIpsPlgSosBasePlugin()
    93     {
    93     {
    94     FUNC_LOG;
    94     FUNC_LOG;
    95     iOperations.ResetAndDestroy();
    95     iOperations.ResetAndDestroy();
    96     iActivitytimers.ResetAndDestroy();
    96     iActivitytimers.ResetAndDestroy();
    97     iOperations.Close();
    97     iOperations.Close();
   149         TRAP( err, aosession.RelayCommandL(
   149         TRAP( err, aosession.RelayCommandL(
   150                 EServerAPIEmailDisableAOEmailPlugin,
   150                 EServerAPIEmailDisableAOEmailPlugin,
   151                 dummyBuf ) );
   151                 dummyBuf ) );
   152         }
   152         }
   153     aosession.Close();
   153     aosession.Close();
   154 #endif    
   154 #endif
   155     }
   155     }
   156 
   156 
   157 // ----------------------------------------------------------------------------
   157 // ----------------------------------------------------------------------------
   158 // ----------------------------------------------------------------------------
   158 // ----------------------------------------------------------------------------
   159 void CIpsPlgSosBasePlugin::CompleteConstructL()
   159 void CIpsPlgSosBasePlugin::CompleteConstructL()
   319         CleanupStack::PushL( smtpSet );
   319         CleanupStack::PushL( smtpSet );
   320         acc->LoadSmtpSettingsL( smtpAcc, *smtpSet );
   320         acc->LoadSmtpSettingsL( smtpAcc, *smtpSet );
   321         address = smtpSet->EmailAddress().AllocL();
   321         address = smtpSet->EmailAddress().AllocL();
   322         CleanupStack::PopAndDestroy( 2, acc );
   322         CleanupStack::PopAndDestroy( 2, acc );
   323 // </qmail>
   323 // </qmail>
   324         
   324 
   325         CleanupStack::PushL( address ); // << address
   325         CleanupStack::PushL( address ); // << address
   326         CFSMailAddress* fsAddress = CFSMailAddress::NewLC();    // << fsAddress
   326         CFSMailAddress* fsAddress = CFSMailAddress::NewLC();    // << fsAddress
   327         fsAddress->SetEmailAddress( *address );
   327         fsAddress->SetEmailAddress( *address );
   328         result->SetOwnMailAddressL( fsAddress );
   328         result->SetOwnMailAddressL( fsAddress );
   329         CleanupStack::Pop( fsAddress ); // >> fsAddress
   329         CleanupStack::Pop( fsAddress ); // >> fsAddress
   346     TMsvId service;
   346     TMsvId service;
   347     if( !iSessionOk )
   347     if( !iSessionOk )
   348         {
   348         {
   349         User::Leave( KErrNotReady );
   349         User::Leave( KErrNotReady );
   350         }
   350         }
   351     
   351 
   352 // <qmail> RAlwaysOnlineClientSession - related code removed
   352 // <qmail> RAlwaysOnlineClientSession - related code removed
   353     // Prepare the parameters to be forwarded to AO-server
   353     // Prepare the parameters to be forwarded to AO-server
   354     TPckg<TMsvId> param = aMailBoxId.Id();
   354     TPckg<TMsvId> param = aMailBoxId.Id();
   355 
   355 
   356     // delete MRU list from cen rep
   356     // delete MRU list from cen rep
   452             aSourceFolderId,
   452             aSourceFolderId,
   453             aDestinationFolderId );
   453             aDestinationFolderId );
   454         ret = KErrNone;
   454         ret = KErrNone;
   455         }
   455         }
   456     ret = KErrNotSupported;
   456     ret = KErrNotSupported;
   457     TFSProgress progress = { 
   457     TFSProgress progress = {
   458             TFSProgress::EFSStatus_RequestComplete, 0, 0, ret };
   458             TFSProgress::EFSStatus_RequestComplete, 0, 0, ret };
   459     aOperationObserver.RequestResponseL(
   459     aOperationObserver.RequestResponseL(
   460             progress, aRequestId );
   460             progress, aRequestId );
   461     return ret;
   461     return ret;
   462     }
   462     }
   549     RArray<TFSMailMsgId>& /*aNewMessages*/,
   549     RArray<TFSMailMsgId>& /*aNewMessages*/,
   550     const TFSMailMsgId& /*aSourceFolderId*/,
   550     const TFSMailMsgId& /*aSourceFolderId*/,
   551     const TFSMailMsgId& /*aDestinationFolderId*/ )
   551     const TFSMailMsgId& /*aDestinationFolderId*/ )
   552 	{
   552 	{
   553 	}
   553 	}
   554 
       
   555 // ----------------------------------------------------------------------------
       
   556 // ----------------------------------------------------------------------------
       
   557 MDesCArray* CIpsPlgSosBasePlugin::GetMrusL(
       
   558                 const TFSMailMsgId& aMailBoxId)
       
   559     {
       
   560     return iMruList->GetMruListL( aMailBoxId );
       
   561     }
       
   562 
       
   563 // ----------------------------------------------------------------------------
       
   564 // ----------------------------------------------------------------------------
       
   565 void CIpsPlgSosBasePlugin::SetMrusL(
       
   566     const TFSMailMsgId& aMailBoxId,
       
   567     MDesCArray*  aNewMruList )
       
   568     {
       
   569     iMruList->SetMruListL( aMailBoxId, aNewMruList );
       
   570     }
       
   571 
   554 
   572 // ---------------------------------------------------------------------------
   555 // ---------------------------------------------------------------------------
   573 // ---------------------------------------------------------------------------
   556 // ---------------------------------------------------------------------------
   574 void CIpsPlgSosBasePlugin::GoOnlineL( const TFSMailMsgId& aMailBoxId )
   557 void CIpsPlgSosBasePlugin::GoOnlineL( const TFSMailMsgId& aMailBoxId )
   575     {
   558     {
   646                 || baseOp->IpsOpType() == EIpsOpTypeImap4PopulateOp ) )
   629                 || baseOp->IpsOpType() == EIpsOpTypeImap4PopulateOp ) )
   647             {
   630             {
   648             DeleteAndRemoveOperation( i, KErrCancel );
   631             DeleteAndRemoveOperation( i, KErrCancel );
   649             }
   632             }
   650         }
   633         }
   651     
   634 
   652 #ifndef RD_101_EMAIL    
   635 #ifndef RD_101_EMAIL
   653     RAlwaysOnlineClientSession aosession;
   636     RAlwaysOnlineClientSession aosession;
   654     err = aosession.Connect();
   637     err = aosession.Connect();
   655     if ( err == KErrNone )
   638     if ( err == KErrNone )
   656         {
   639         {
   657         TPckgBuf<TMsvId> buf(aMailBoxId.Id());
   640         TPckgBuf<TMsvId> buf(aMailBoxId.Id());
   658         TRAP( err, aosession.RelayCommandL( 
   641         TRAP( err, aosession.RelayCommandL(
   659                 EServerAPIEmailCancelAllAndDoNotDisconnect, buf ) );
   642                 EServerAPIEmailCancelAllAndDoNotDisconnect, buf ) );
   660         }
   643         }
   661     aosession.Close();
   644     aosession.Close();
   662 #endif    
   645 #endif
   663 
   646 
   664     return err;
   647     return err;
   665     }
   648     }
   666 
   649 
   667 // ----------------------------------------------------------------------------
   650 // ----------------------------------------------------------------------------
   840                                     const TInt aRequestId )
   823                                     const TInt aRequestId )
   841     {
   824     {
   842     FUNC_LOG;
   825     FUNC_LOG;
   843     // asynchronous message creation is started here to enable canceling of the operation
   826     // asynchronous message creation is started here to enable canceling of the operation
   844     TMsvPartList partList( KMsvMessagePartBody );
   827     TMsvPartList partList( KMsvMessagePartBody );
   845     
   828 
   846     CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewLC(*this);
   829     CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewLC(*this);
   847 
   830 
   848     //<qmail> removed mboxEntry from parameters + changed iSmtpService to pointer 
   831     //<qmail> removed mboxEntry from parameters + changed iSmtpService to pointer
   849     
   832 
   850     CIpsPlgCreateMessageOperation* op = CIpsPlgCreateMessageOperation::NewL( 
   833     CIpsPlgCreateMessageOperation* op = CIpsPlgCreateMessageOperation::NewL(
   851         *iSmtpService, 
   834         *iSmtpService,
   852         *iSession,
   835         *iSession,
   853         watcher->iStatus,
   836         watcher->iStatus,
   854         partList, 
   837         partList,
   855         aMailBoxId, 
   838         aMailBoxId,
   856         aOperationObserver, 
   839         aOperationObserver,
   857         aRequestId );
   840         aRequestId );
   858     //</qmail>
   841     //</qmail>
   859     watcher->SetOperation( op );
   842     watcher->SetOperation( op );
   860 
   843 
   861     iOperations.AppendL( watcher ); 
   844     iOperations.AppendL( watcher );
   862     CleanupStack::Pop( watcher );    
   845     CleanupStack::Pop( watcher );
   863     }
   846     }
   864 // </qmail> 
   847 // </qmail>
   865  
   848 
   866 // ----------------------------------------------------------------------------
   849 // ----------------------------------------------------------------------------
   867 // ----------------------------------------------------------------------------
   850 // ----------------------------------------------------------------------------
   868 CFSMailMessage* CIpsPlgSosBasePlugin::CreateForwardMessageL(
   851 CFSMailMessage* CIpsPlgSosBasePlugin::CreateForwardMessageL(
   869     const TFSMailMsgId& /*aMailBoxId*/,
   852     const TFSMailMsgId& /*aMailBoxId*/,
   870     const TFSMailMsgId& /*aOriginalMessageId*/,
   853     const TFSMailMsgId& /*aOriginalMessageId*/,
   876     }
   859     }
   877 
   860 
   878 // <qmail>
   861 // <qmail>
   879 // ----------------------------------------------------------------------------
   862 // ----------------------------------------------------------------------------
   880 // ----------------------------------------------------------------------------
   863 // ----------------------------------------------------------------------------
   881 void CIpsPlgSosBasePlugin::CreateForwardMessageL( 
   864 void CIpsPlgSosBasePlugin::CreateForwardMessageL(
   882     const TFSMailMsgId& aMailBoxId,
   865     const TFSMailMsgId& aMailBoxId,
   883     const TFSMailMsgId& aOriginalMessageId,
   866     const TFSMailMsgId& aOriginalMessageId,
   884     MFSMailRequestObserver& aOperationObserver,
   867     MFSMailRequestObserver& aOperationObserver,
   885     const TInt aRequestId,
   868     const TInt aRequestId,
   886     const TDesC& /*aHeaderDescriptor*/ )
   869     const TDesC& /*aHeaderDescriptor*/ )
   887     {
   870     {
   888     FUNC_LOG;
   871     FUNC_LOG;
   889     // asynchronous message creation is started here to enable canceling of the operation
   872     // asynchronous message creation is started here to enable canceling of the operation
   890     
   873 
   891     // 1. part of function checs that body text and all
   874     // 1. part of function checs that body text and all
   892     // attachments are fetched
   875     // attachments are fetched
   893     TMsvEntry orgMsg;
   876     TMsvEntry orgMsg;
   894     TMsvId service;
   877     TMsvId service;
   895     User::LeaveIfError( iSession->GetEntry( 
   878     User::LeaveIfError( iSession->GetEntry(
   896             aOriginalMessageId.Id(), service, orgMsg ) );
   879             aOriginalMessageId.Id(), service, orgMsg ) );
   897     
   880 
   898     if ( orgMsg.Id() ==  KMsvNullIndexEntryIdValue )
   881     if ( orgMsg.Id() ==  KMsvNullIndexEntryIdValue )
   899         {
   882         {
   900         User::Leave(KErrNotFound);
   883         User::Leave(KErrNotFound);
   901         }
   884         }
   902     
   885 
   903     if ( ( orgMsg.Parent() == KMsvSentEntryIdValue ) && 
   886     if ( ( orgMsg.Parent() == KMsvSentEntryIdValue ) &&
   904          ( orgMsg.iMtm == KSenduiMtmSmtpUid ) )
   887          ( orgMsg.iMtm == KSenduiMtmSmtpUid ) )
   905         {
   888         {
   906         iSmtpService->ChangeServiceIdL( orgMsg );
   889         iSmtpService->ChangeServiceIdL( orgMsg );
   907         }
   890         }
   908     
   891 
   909     TMsvPartList partList( KMsvMessagePartBody | KMsvMessagePartAttachments );
   892     TMsvPartList partList( KMsvMessagePartBody | KMsvMessagePartAttachments );
   910     
   893 
   911     CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewLC(*this);
   894     CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewLC(*this);
   912     
   895 
   913     //<qmail> changed iSmtpService to pointer
   896     //<qmail> changed iSmtpService to pointer
   914     CIpsPlgCreateForwardMessageOperation* op = CIpsPlgCreateForwardMessageOperation::NewL( 
   897     CIpsPlgCreateForwardMessageOperation* op = CIpsPlgCreateForwardMessageOperation::NewL(
   915         *iSmtpService, 
   898         *iSmtpService,
   916         *iSession,
   899         *iSession,
   917         watcher->iStatus,
   900         watcher->iStatus,
   918         partList, 
   901         partList,
   919         aMailBoxId, 
   902         aMailBoxId,
   920         orgMsg.Id(), 
   903         orgMsg.Id(),
   921         aOperationObserver, 
   904         aOperationObserver,
   922         aRequestId );
   905         aRequestId );
   923     //</qmail>
   906     //</qmail>
   924     watcher->SetOperation( op );
   907     watcher->SetOperation( op );
   925 
   908 
   926     iOperations.AppendL( watcher ); 
   909     iOperations.AppendL( watcher );
   927     CleanupStack::Pop( watcher );
   910     CleanupStack::Pop( watcher );
   928     }
   911     }
   929 // </qmail> 
   912 // </qmail>
   930 
   913 
   931 // ----------------------------------------------------------------------------
   914 // ----------------------------------------------------------------------------
   932 // ---------------------------------------------------------------------------- 	
   915 // ----------------------------------------------------------------------------
   933 CFSMailMessage* CIpsPlgSosBasePlugin::CreateReplyMessageL( 
   916 CFSMailMessage* CIpsPlgSosBasePlugin::CreateReplyMessageL(
   934     const TFSMailMsgId& /*aMailBoxId*/,
   917     const TFSMailMsgId& /*aMailBoxId*/,
   935     const TFSMailMsgId& /*aOriginalMessageId*/,
   918     const TFSMailMsgId& /*aOriginalMessageId*/,
   936     const TBool /*aReplyToAll*/,
   919     const TBool /*aReplyToAll*/,
   937     const TDesC& /*aHeaderDescriptor*/ )
   920     const TDesC& /*aHeaderDescriptor*/ )
   938     {
   921     {
   941     return NULL; // prevents compiler warning
   924     return NULL; // prevents compiler warning
   942     }
   925     }
   943 
   926 
   944 // <qmail>
   927 // <qmail>
   945 // ----------------------------------------------------------------------------
   928 // ----------------------------------------------------------------------------
   946 // ---------------------------------------------------------------------------- 	
   929 // ----------------------------------------------------------------------------
   947 void CIpsPlgSosBasePlugin::CreateReplyMessageL( 
   930 void CIpsPlgSosBasePlugin::CreateReplyMessageL(
   948     const TFSMailMsgId& aMailBoxId,
   931     const TFSMailMsgId& aMailBoxId,
   949     const TFSMailMsgId& aOriginalMessageId,
   932     const TFSMailMsgId& aOriginalMessageId,
   950     const TBool aReplyToAll,
   933     const TBool aReplyToAll,
   951     MFSMailRequestObserver& aOperationObserver,
   934     MFSMailRequestObserver& aOperationObserver,
   952     const TInt aRequestId,
   935     const TInt aRequestId,
   953     const TDesC& /* aHeaderDescriptor */ )
   936     const TDesC& /* aHeaderDescriptor */ )
   954     {
   937     {
   955     FUNC_LOG;
   938     FUNC_LOG;
   956     // asynchronous message creation is started here to enable canceling of the operation
   939     // asynchronous message creation is started here to enable canceling of the operation
   957     
   940 
   958     // find orginal message header and check that body is fetched
   941     // find orginal message header and check that body is fetched
   959     TMsvEntry orgMsg;
   942     TMsvEntry orgMsg;
   960     TMsvId service;
   943     TMsvId service;
   961     User::LeaveIfError( 
   944     User::LeaveIfError(
   962         iSession->GetEntry( aOriginalMessageId.Id(), service, orgMsg ) );
   945         iSession->GetEntry( aOriginalMessageId.Id(), service, orgMsg ) );
   963     
   946 
   964     if ( orgMsg.Id() ==  KMsvNullIndexEntryIdValue )
   947     if ( orgMsg.Id() ==  KMsvNullIndexEntryIdValue )
   965         {
   948         {
   966         User::Leave(KErrNotFound);
   949         User::Leave(KErrNotFound);
   967         }
   950         }
   968     
   951 
   969     if ( ( orgMsg.Parent() == KMsvSentEntryIdValue ) && 
   952     if ( ( orgMsg.Parent() == KMsvSentEntryIdValue ) &&
   970          ( orgMsg.iMtm == KSenduiMtmSmtpUid ) )
   953          ( orgMsg.iMtm == KSenduiMtmSmtpUid ) )
   971         {
   954         {
   972         iSmtpService->ChangeServiceIdL( orgMsg );
   955         iSmtpService->ChangeServiceIdL( orgMsg );
   973         }
   956         }
   974     
   957 
   975     // partList flags control e.g. what kind of recipient set is created
   958     // partList flags control e.g. what kind of recipient set is created
   976     TMsvPartList partList = KMsvMessagePartBody | KMsvMessagePartDescription
   959     TMsvPartList partList = KMsvMessagePartBody | KMsvMessagePartDescription
   977     | KMsvMessagePartOriginator;        
   960     | KMsvMessagePartOriginator;
   978     if( aReplyToAll )
   961     if( aReplyToAll )
   979         {
   962         {
   980         partList |= KMsvMessagePartRecipient;
   963         partList |= KMsvMessagePartRecipient;
   981         }
   964         }
   982     
   965 
   983     CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewLC(*this);
   966     CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewLC(*this);
   984     
   967 
   985     //<qmail> changed iSmtpService to pointer
   968     //<qmail> changed iSmtpService to pointer
   986     CIpsPlgCreateReplyMessageOperation* op = CIpsPlgCreateReplyMessageOperation::NewL( 
   969     CIpsPlgCreateReplyMessageOperation* op = CIpsPlgCreateReplyMessageOperation::NewL(
   987         *iSmtpService, 
   970         *iSmtpService,
   988         *iSession,
   971         *iSession,
   989         watcher->iStatus,
   972         watcher->iStatus,
   990         partList, 
   973         partList,
   991         aMailBoxId, 
   974         aMailBoxId,
   992         orgMsg.Id(), 
   975         orgMsg.Id(),
   993         aOperationObserver, 
   976         aOperationObserver,
   994         aRequestId );
   977         aRequestId );
   995     //</qmail>
   978     //</qmail>
   996     watcher->SetOperation( op );
   979     watcher->SetOperation( op );
   997 
   980 
   998     iOperations.AppendL( watcher ); 
   981     iOperations.AppendL( watcher );
   999     CleanupStack::Pop( watcher );
   982     CleanupStack::Pop( watcher );
  1000     }
   983     }
  1001 // </qmail>
   984 // </qmail>
  1002 
   985 
  1003 // ----------------------------------------------------------------------------
   986 // ----------------------------------------------------------------------------
  1004 // ---------------------------------------------------------------------------- 	
   987 // ----------------------------------------------------------------------------
  1005 //	
   988 //
  1006 void CIpsPlgSosBasePlugin::StoreMessageL( 
   989 void CIpsPlgSosBasePlugin::StoreMessageL(
  1007     const TFSMailMsgId& aMailBoxId,
   990     const TFSMailMsgId& aMailBoxId,
  1008     CFSMailMessage& aMessage )
   991     CFSMailMessage& aMessage )
  1009  	{
   992  	{
  1010     FUNC_LOG;
   993     FUNC_LOG;
  1011     TInt status( KErrNone);
   994     TInt status( KErrNone);
  1029     if ( incoming )
  1012     if ( incoming )
  1030         {
  1013         {
  1031 		// <qmail> Cmail change to synchronous call (UpdateMessageFlagsL) ignored,
  1014 		// <qmail> Cmail change to synchronous call (UpdateMessageFlagsL) ignored,
  1032         // <qmail> because it causes emulator & HW to freeze on 10.1
  1015         // <qmail> because it causes emulator & HW to freeze on 10.1
  1033         CIpsPlgSingleOpWatcher* opW = CIpsPlgSingleOpWatcher::NewLC( *this );
  1016         CIpsPlgSingleOpWatcher* opW = CIpsPlgSingleOpWatcher::NewLC( *this );
  1034         CMsvOperation* op = iMsgMapper->UpdateMessageFlagsAsyncL( 
  1017         CMsvOperation* op = iMsgMapper->UpdateMessageFlagsAsyncL(
  1035                 msgId.Id(), aMessage, opW->iStatus );
  1018                 msgId.Id(), aMessage, opW->iStatus );
  1036         
  1019 
  1037         if ( op )
  1020         if ( op )
  1038             {
  1021             {
  1039             opW->SetOperation( op );
  1022             opW->SetOperation( op );
  1040             iOperations.AppendL( opW );
  1023             iOperations.AppendL( opW );
  1041             CleanupStack::Pop( opW );
  1024             CleanupStack::Pop( opW );
  1061 void CIpsPlgSosBasePlugin::StoreMessagesL(
  1044 void CIpsPlgSosBasePlugin::StoreMessagesL(
  1062     const TFSMailMsgId& /*aMailBox*/,
  1045     const TFSMailMsgId& /*aMailBox*/,
  1063     RPointerArray<CFSMailMessage> &messages,
  1046     RPointerArray<CFSMailMessage> &messages,
  1064     MFSMailRequestObserver& aOperationObserver,
  1047     MFSMailRequestObserver& aOperationObserver,
  1065     const TInt aRequestId )
  1048     const TInt aRequestId )
  1066     
  1049 
  1067     {
  1050     {
  1068     CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewL(*this);
  1051     CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewL(*this);
  1069     CleanupStack::PushL(watcher);
  1052     CleanupStack::PushL(watcher);
  1070     CIpsPlgMailStorerOperation* op = 
  1053     CIpsPlgMailStorerOperation* op =
  1071             CIpsPlgMailStorerOperation::NewLC(
  1054             CIpsPlgMailStorerOperation::NewLC(
  1072                     *iSession,
  1055                     *iSession,
  1073                     watcher->iStatus,
  1056                     watcher->iStatus,
  1074                     *this, 
  1057                     *this,
  1075                     messages, 
  1058                     messages,
  1076                     aOperationObserver, 
  1059                     aOperationObserver,
  1077                     aRequestId );
  1060                     aRequestId );
  1078     
  1061 
  1079     watcher->SetOperation(op);
  1062     watcher->SetOperation(op);
  1080     iOperations.AppendL(watcher);
  1063     iOperations.AppendL(watcher);
  1081     CleanupStack::Pop( 2, watcher );
  1064     CleanupStack::Pop( 2, watcher );
  1082     }
  1065     }
  1083 // </qmail>
  1066 // </qmail>
  1152     return NULL; // prevents compiler warning
  1135     return NULL; // prevents compiler warning
  1153     }
  1136     }
  1154 
  1137 
  1155 // <qmail>
  1138 // <qmail>
  1156 // ----------------------------------------------------------------------------
  1139 // ----------------------------------------------------------------------------
  1157 // ----------------------------------------------------------------------------  
  1140 // ----------------------------------------------------------------------------
  1158 void CIpsPlgSosBasePlugin::NewChildPartFromFileL(
  1141 void CIpsPlgSosBasePlugin::NewChildPartFromFileL(
  1159     const TFSMailMsgId& aMailBoxId,
  1142     const TFSMailMsgId& aMailBoxId,
  1160     const TFSMailMsgId& /* aParentFolderId */,
  1143     const TFSMailMsgId& /* aParentFolderId */,
  1161     const TFSMailMsgId& aMessageId,
  1144     const TFSMailMsgId& aMessageId,
  1162     const TFSMailMsgId& /* aParentPartId */,
  1145     const TFSMailMsgId& /* aParentPartId */,
  1165     MFSMailRequestObserver& aOperationObserver,
  1148     MFSMailRequestObserver& aOperationObserver,
  1166     const TInt aRequestId )
  1149     const TInt aRequestId )
  1167     {
  1150     {
  1168     FUNC_LOG;
  1151     FUNC_LOG;
  1169     CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewLC(*this);
  1152     CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewLC(*this);
  1170     
  1153 
  1171     CIpsPlgNewChildPartFromFileOperation* op = CIpsPlgNewChildPartFromFileOperation::NewL(
  1154     CIpsPlgNewChildPartFromFileOperation* op = CIpsPlgNewChildPartFromFileOperation::NewL(
  1172         *iSession, 
  1155         *iSession,
  1173         watcher->iStatus,
  1156         watcher->iStatus,
  1174         aMailBoxId,
  1157         aMailBoxId,
  1175         aMessageId,
  1158         aMessageId,
  1176         aContentType,
  1159         aContentType,
  1177         aFilePath,
  1160         aFilePath,
  1178         aOperationObserver, 
  1161         aOperationObserver,
  1179         aRequestId,
  1162         aRequestId,
  1180         iMsgMapper);
  1163         iMsgMapper);
  1181     watcher->SetOperation( op );
  1164     watcher->SetOperation( op );
  1182 
  1165 
  1183     iOperations.AppendL( watcher ); 
  1166     iOperations.AppendL( watcher );
  1184     CleanupStack::Pop( watcher );
  1167     CleanupStack::Pop( watcher );
  1185     }
  1168     }
  1186 // </qmail> 
  1169 // </qmail>
  1187 
  1170 
  1188 // ----------------------------------------------------------------------------
  1171 // ----------------------------------------------------------------------------
  1189 // ----------------------------------------------------------------------------  
  1172 // ----------------------------------------------------------------------------
  1190 CFSMailMessagePart* CIpsPlgSosBasePlugin::NewChildPartFromFileL(
  1173 CFSMailMessagePart* CIpsPlgSosBasePlugin::NewChildPartFromFileL(
  1191     const TFSMailMsgId& /*aMailBoxId*/,
  1174     const TFSMailMsgId& /*aMailBoxId*/,
  1192     const TFSMailMsgId& /*aParentFolderId*/,
  1175     const TFSMailMsgId& /*aParentFolderId*/,
  1193     const TFSMailMsgId& /*aMessageId*/,
  1176     const TFSMailMsgId& /*aMessageId*/,
  1194     const TFSMailMsgId& /*aParentPartId*/,
  1177     const TFSMailMsgId& /*aParentPartId*/,
  1229     User::Leave(KErrFSMailPluginNotSupported);
  1212     User::Leave(KErrFSMailPluginNotSupported);
  1230 	}
  1213 	}
  1231 
  1214 
  1232 // <qmail>
  1215 // <qmail>
  1233 // ----------------------------------------------------------------------------
  1216 // ----------------------------------------------------------------------------
  1234 // Supports currently deletion of attachments and multipart structures 
  1217 // Supports currently deletion of attachments and multipart structures
  1235 // which are represented as folders in Symbian store)
  1218 // which are represented as folders in Symbian store)
  1236 // ----------------------------------------------------------------------------  
  1219 // ----------------------------------------------------------------------------
  1237 //
  1220 //
  1238 void CIpsPlgSosBasePlugin::RemoveChildPartL(
  1221 void CIpsPlgSosBasePlugin::RemoveChildPartL(
  1239     const TFSMailMsgId& /* aMailBoxId */,
  1222     const TFSMailMsgId& /* aMailBoxId */,
  1240     const TFSMailMsgId& /* aParentFolderId */,
  1223     const TFSMailMsgId& /* aParentFolderId */,
  1241     const TFSMailMsgId& aMessageId,
  1224     const TFSMailMsgId& aMessageId,
  1244     MFSMailRequestObserver& aOperationObserver,
  1227     MFSMailRequestObserver& aOperationObserver,
  1245     const TInt aRequestId )
  1228     const TInt aRequestId )
  1246     {
  1229     {
  1247     FUNC_LOG;
  1230     FUNC_LOG;
  1248     CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewLC(*this);
  1231     CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewLC(*this);
  1249     
  1232 
  1250     CIpsPlgRemoveChildPartOperation* op = CIpsPlgRemoveChildPartOperation::NewL(
  1233     CIpsPlgRemoveChildPartOperation* op = CIpsPlgRemoveChildPartOperation::NewL(
  1251         *iSession, 
  1234         *iSession,
  1252         watcher->iStatus,
  1235         watcher->iStatus,
  1253         aMessageId,
  1236         aMessageId,
  1254         aPartId,
  1237         aPartId,
  1255         aOperationObserver, 
  1238         aOperationObserver,
  1256         aRequestId);
  1239         aRequestId);
  1257     watcher->SetOperation( op );
  1240     watcher->SetOperation( op );
  1258 
  1241 
  1259     iOperations.AppendL( watcher ); 
  1242     iOperations.AppendL( watcher );
  1260     CleanupStack::Pop( watcher );
  1243     CleanupStack::Pop( watcher );
  1261 
  1244 
  1262     }
  1245     }
  1263 // </qmail>
  1246 // </qmail>
  1264 
  1247 
  1282 // ----------------------------------------------------------------------------
  1265 // ----------------------------------------------------------------------------
  1283 // The implementation bypass CImEmailMessage and its email's attachment
  1266 // The implementation bypass CImEmailMessage and its email's attachment
  1284 // manager. Instead, it calls Symbian framework classes directly by
  1267 // manager. Instead, it calls Symbian framework classes directly by
  1285 // accessing the attachment entry.
  1268 // accessing the attachment entry.
  1286 // Qmail change: returns file handle for read/write
  1269 // Qmail change: returns file handle for read/write
  1287 // ----------------------------------------------------------------------------  
  1270 // ----------------------------------------------------------------------------
  1288 TInt CIpsPlgSosBasePlugin::GetMessagePartFileL(  
  1271 TInt CIpsPlgSosBasePlugin::GetMessagePartFileL(
  1289     const TFSMailMsgId& /* aMailBoxId */,
  1272     const TFSMailMsgId& /* aMailBoxId */,
  1290     const TFSMailMsgId& /* aParentFolderId */,
  1273     const TFSMailMsgId& /* aParentFolderId */,
  1291     const TFSMailMsgId& /* aMessageId */,
  1274     const TFSMailMsgId& /* aMessageId */,
  1292     const TFSMailMsgId& aMessagePartId,
  1275     const TFSMailMsgId& aMessagePartId,
  1293     RFile& aFileHandle)
  1276     RFile& aFileHandle)
  1439     const TFSMailMsgId& /* aParentFolderId */,
  1422     const TFSMailMsgId& /* aParentFolderId */,
  1440     const TFSMailMsgId& /* aMessageId */,
  1423     const TFSMailMsgId& /* aMessageId */,
  1441     const TFSMailMsgId& aMessagePartId )
  1424     const TFSMailMsgId& aMessagePartId )
  1442 	{
  1425 	{
  1443     FUNC_LOG;
  1426     FUNC_LOG;
  1444     
  1427 
  1445 //<qmail> Rewritten in Qmail: CIpsPlgOperationWait is no longer used 
  1428 //<qmail> Rewritten in Qmail: CIpsPlgOperationWait is no longer used
  1446     // Notice that SetContentL sets only the content of text/plain message part:
  1429     // Notice that SetContentL sets only the content of text/plain message part:
  1447     // text/html part can be modified directly using GetMessagePartFileL
  1430     // text/html part can be modified directly using GetMessagePartFileL
  1448 	CMsvEntry* cEntry( NULL );
  1431 	CMsvEntry* cEntry( NULL );
  1449     CMsvStore* store = NULL;
  1432     CMsvStore* store = NULL;
  1450     
  1433 
  1451     // following code should fill text/plain content
  1434     // following code should fill text/plain content
  1452     cEntry = iSession->GetEntryL( aMessagePartId.Id() );
  1435     cEntry = iSession->GetEntryL( aMessagePartId.Id() );
  1453     CleanupStack::PushL( cEntry );
  1436     CleanupStack::PushL( cEntry );
  1454     TBool hasStore = cEntry->HasStoreL();
  1437     TBool hasStore = cEntry->HasStoreL();
  1455     if ( hasStore ) {
  1438     if ( hasStore ) {
  1505     {
  1488     {
  1506     }
  1489     }
  1507 
  1490 
  1508 //<qmail>
  1491 //<qmail>
  1509 // ----------------------------------------------------------------------------
  1492 // ----------------------------------------------------------------------------
  1510 // ----------------------------------------------------------------------------     
  1493 // ----------------------------------------------------------------------------
  1511 void CIpsPlgSosBasePlugin::StoreMessagePartsL(
  1494 void CIpsPlgSosBasePlugin::StoreMessagePartsL(
  1512     RPointerArray<CFSMailMessagePart>&  aMessageParts,
  1495     RPointerArray<CFSMailMessagePart>&  aMessageParts,
  1513     MFSMailRequestObserver& aOperationObserver,
  1496     MFSMailRequestObserver& aOperationObserver,
  1514     const TInt aRequestId )
  1497     const TInt aRequestId )
  1515     {
  1498     {
  1517     CleanupStack::PushL(watcher);
  1500     CleanupStack::PushL(watcher);
  1518     CIpsPlgMessagePartStorerOperation* op =
  1501     CIpsPlgMessagePartStorerOperation* op =
  1519             CIpsPlgMessagePartStorerOperation::NewLC(*iSession,
  1502             CIpsPlgMessagePartStorerOperation::NewLC(*iSession,
  1520                     watcher->iStatus, *this, aMessageParts,
  1503                     watcher->iStatus, *this, aMessageParts,
  1521                     aOperationObserver, aRequestId);
  1504                     aOperationObserver, aRequestId);
  1522     
  1505 
  1523     watcher->SetOperation(op);
  1506     watcher->SetOperation(op);
  1524     iOperations.AppendL(watcher);
  1507     iOperations.AppendL(watcher);
  1525     CleanupStack::Pop( 2, watcher );    
  1508     CleanupStack::Pop( 2, watcher );
  1526     }
  1509     }
  1527 //<//qmail>
  1510 //<//qmail>
  1528 
  1511 
  1529 // ----------------------------------------------------------------------------
  1512 // ----------------------------------------------------------------------------
  1530 // ---------------------------------------------------------------------------- 	
  1513 // ----------------------------------------------------------------------------
  1531 void CIpsPlgSosBasePlugin::UnregisterRequestObserver( TInt /* aRequestId */)
  1514 void CIpsPlgSosBasePlugin::UnregisterRequestObserver( TInt /* aRequestId */)
  1532     {
  1515     {
  1533     }
  1516     }
  1534 
  1517 
  1535 // ----------------------------------------------------------------------------
  1518 // ----------------------------------------------------------------------------
  1549     op->StartSendL( aMessageId.Id() );
  1532     op->StartSendL( aMessageId.Id() );
  1550     iOperations.AppendL(watcher);
  1533     iOperations.AppendL(watcher);
  1551     CleanupStack::Pop( watcher );
  1534     CleanupStack::Pop( watcher );
  1552  	}
  1535  	}
  1553 
  1536 
  1554    
  1537 
  1555 // ----------------------------------------------------------------------------
  1538 // ----------------------------------------------------------------------------
  1556 // ---------------------------------------------------------------------------- 	
  1539 // ----------------------------------------------------------------------------
  1557 void CIpsPlgSosBasePlugin::SendMessageL( CFSMailMessage& /*aMessage*/ )
  1540 void CIpsPlgSosBasePlugin::SendMessageL( CFSMailMessage& /*aMessage*/ )
  1558     {
  1541     {
  1559     FUNC_LOG;
  1542     FUNC_LOG;
  1560     // <qmail>
  1543     // <qmail>
  1561     User::Leave( KErrFSMailPluginNotSupported );
  1544     User::Leave( KErrFSMailPluginNotSupported );
  1700     CleanupStack::PushL(sel);
  1683     CleanupStack::PushL(sel);
  1701 
  1684 
  1702     TInt count = aMessages.Count();
  1685     TInt count = aMessages.Count();
  1703     TMsvEntry tEntry;
  1686     TMsvEntry tEntry;
  1704     TMsvId service;
  1687     TMsvId service;
  1705     
  1688 
  1706     for(TInt i=0; i<count; i++)
  1689     for(TInt i=0; i<count; i++)
  1707         {
  1690         {
  1708         iSession->GetEntry( aMessages[i].Id(), service, tEntry );
  1691         iSession->GetEntry( aMessages[i].Id(), service, tEntry );
  1709         //make sure that only messages get deleted.
  1692         //make sure that only messages get deleted.
  1710         if( tEntry.iType == KUidMsvMessageEntry )
  1693         if( tEntry.iType == KUidMsvMessageEntry )
  1711             {            
  1694             {
  1712 			// <qmail>    
  1695 			// <qmail>
  1713             sel->AppendL( tEntry.Id() );
  1696             sel->AppendL( tEntry.Id() );
  1714 			// </qmail>    
  1697 			// </qmail>
  1715             }
  1698             }
  1716         }
  1699         }
  1717         
  1700 
  1718     CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewL( *this );
  1701     CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewL( *this );
  1719     CleanupStack::PushL( watcher );
  1702     CleanupStack::PushL( watcher );
  1720     //<qmail>
  1703     //<qmail>
  1721     CMsvOperation* op = CIpsPlgDeleteOperation::NewL( *iSession,
  1704     CMsvOperation* op = CIpsPlgDeleteOperation::NewL( *iSession,
  1722         watcher->iStatus, sel );
  1705         watcher->iStatus, sel );
  1744     CleanupStack::PushL(sel);
  1727     CleanupStack::PushL(sel);
  1745 
  1728 
  1746     TInt count = aMessages.Count();
  1729     TInt count = aMessages.Count();
  1747     TMsvEntry tEntry;
  1730     TMsvEntry tEntry;
  1748     TMsvId service;
  1731     TMsvId service;
  1749     
  1732 
  1750     for(TInt i=0; i<count; i++)
  1733     for(TInt i=0; i<count; i++)
  1751         {
  1734         {
  1752         iSession->GetEntry( aMessages[i].Id(), service, tEntry );
  1735         iSession->GetEntry( aMessages[i].Id(), service, tEntry );
  1753         //make sure that only messages get deleted.
  1736         //make sure that only messages get deleted.
  1754         if( tEntry.iType == KUidMsvMessageEntry )
  1737         if( tEntry.iType == KUidMsvMessageEntry )
  1755             {            
  1738             {
  1756             sel->AppendL( tEntry.Id() );
  1739             sel->AppendL( tEntry.Id() );
  1757             }
  1740             }
  1758         }
  1741         }
  1759         
  1742 
  1760     CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewL( *this );
  1743     CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewL( *this );
  1761     CleanupStack::PushL( watcher );
  1744     CleanupStack::PushL( watcher );
  1762     CMsvOperation* op = CIpsPlgDeleteOperation::NewL( *iSession,
  1745     CMsvOperation* op = CIpsPlgDeleteOperation::NewL( *iSession,
  1763         watcher->iStatus, sel, aOperationObserver, aRequestId );
  1746         watcher->iStatus, sel, aOperationObserver, aRequestId );
  1764     watcher->SetOperation( op );
  1747     watcher->SetOperation( op );
  1854 	const TDesC& /*aUsername*/, const TDesC& /*aPassword*/ )
  1837 	const TDesC& /*aUsername*/, const TDesC& /*aPassword*/ )
  1855 	{
  1838 	{
  1856 // <qmail> not used; should be removed
  1839 // <qmail> not used; should be removed
  1857 //    FUNC_LOG;
  1840 //    FUNC_LOG;
  1858 //	TBool cancelled = EFalse;
  1841 //	TBool cancelled = EFalse;
  1859 //	
  1842 //
  1860 //	if ( aPassword.Length() > 0 )
  1843 //	if ( aPassword.Length() > 0 )
  1861 //	    {
  1844 //	    {
  1862 //    	//Set new password and signal (possible) ongoing connect operation
  1845 //    	//Set new password and signal (possible) ongoing connect operation
  1863 //    	//CIpsSetDataApi* api = CIpsSetDataApi::NewL( *iSession );
  1846 //    	//CIpsSetDataApi* api = CIpsSetDataApi::NewL( *iSession );
  1864 //        //CleanupStack::PushL( api );
  1847 //        //CleanupStack::PushL( api );
  1865 //        
  1848 //
  1866 //        //CMsvEntry* cEntry = iSession->GetEntryL( aMailBoxId.Id() );
  1849 //        //CMsvEntry* cEntry = iSession->GetEntryL( aMailBoxId.Id() );
  1867 //        //CleanupStack::PushL( cEntry );
  1850 //        //CleanupStack::PushL( cEntry );
  1868 //        
  1851 //
  1869 //        //api->SetNewPasswordL( *cEntry, aPassword );
  1852 //        //api->SetNewPasswordL( *cEntry, aPassword );
  1870 //        
  1853 //
  1871 //        //CleanupStack::PopAndDestroy( 2, api );//cEntry, api
  1854 //        //CleanupStack::PopAndDestroy( 2, api );//cEntry, api
  1872 //        
  1855 //
  1873 //        //now signal through eventhandler that credientials have been set       
  1856 //        //now signal through eventhandler that credientials have been set
  1874 //	    }
  1857 //	    }
  1875 //	else
  1858 //	else
  1876 //	    {
  1859 //	    {
  1877 //	    cancelled = ETrue;
  1860 //	    cancelled = ETrue;
  1878 //	    }
  1861 //	    }
  1904         }
  1887         }
  1905     aMessageEntry = iCachedEntry;
  1888     aMessageEntry = iCachedEntry;
  1906     aImEmailMessage = iCachedEmailMessage;
  1889     aImEmailMessage = iCachedEmailMessage;
  1907     }
  1890     }
  1908 
  1891 
  1909     
  1892 
  1910 // ----------------------------------------------------------------------------
  1893 // ----------------------------------------------------------------------------
  1911 // CIpsPlgSosBasePlugin::TakeMessageEntryL( )
  1894 // CIpsPlgSosBasePlugin::TakeMessageEntryL( )
  1912 // Takes ownership of the cached objects or creates new ones
  1895 // Takes ownership of the cached objects or creates new ones
  1913 // ----------------------------------------------------------------------------
  1896 // ----------------------------------------------------------------------------
  1914 
  1897 
  1922             iCachedEmailMessage->IsActive() )
  1905             iCachedEmailMessage->IsActive() )
  1923         {
  1906         {
  1924         // Can't use the ones that are in cache, create new ones and don't replace the ones in cache
  1907         // Can't use the ones that are in cache, create new ones and don't replace the ones in cache
  1925         aMessageEntry = iSession->GetEntryL( aId );
  1908         aMessageEntry = iSession->GetEntryL( aId );
  1926         aImEmailMessage = 0;
  1909         aImEmailMessage = 0;
  1927         
  1910 
  1928         if ( aMessageEntry->Entry().iType == KUidMsvMessageEntry )
  1911         if ( aMessageEntry->Entry().iType == KUidMsvMessageEntry )
  1929             {
  1912             {
  1930             CleanupStack::PushL( aMessageEntry );
  1913             CleanupStack::PushL( aMessageEntry );
  1931             aImEmailMessage = CImEmailMessage::NewL( *aMessageEntry );
  1914             aImEmailMessage = CImEmailMessage::NewL( *aMessageEntry );
  1932             CleanupStack::Pop();
  1915             CleanupStack::Pop();
  1938     	aMessageEntry = iCachedEntry;
  1921     	aMessageEntry = iCachedEntry;
  1939     	aImEmailMessage = iCachedEmailMessage;
  1922     	aImEmailMessage = iCachedEmailMessage;
  1940     	iCachedEntry = 0;
  1923     	iCachedEntry = 0;
  1941     	iCachedEmailMessage = 0;
  1924     	iCachedEmailMessage = 0;
  1942     	}
  1925     	}
  1943     	
  1926 
  1944     // Ownership is transferred to the caller
  1927     // Ownership is transferred to the caller
  1945     CleanupStack::PushL( aMessageEntry );
  1928     CleanupStack::PushL( aMessageEntry );
  1946     CleanupStack::PushL( aImEmailMessage );
  1929     CleanupStack::PushL( aImEmailMessage );
  1947     }
  1930     }
  1948 
  1931 
  1952         CMsvEntry* aMessageEntry,
  1935         CMsvEntry* aMessageEntry,
  1953         CImEmailMessage* aImEmailMessage )
  1936         CImEmailMessage* aImEmailMessage )
  1954 	{
  1937 	{
  1955 	// Clean old ones from the cache
  1938 	// Clean old ones from the cache
  1956 	CleanCachedMessageEntries();
  1939 	CleanCachedMessageEntries();
  1957 	
  1940 
  1958 	// Always save the latest ones in the cache
  1941 	// Always save the latest ones in the cache
  1959 	iCachedEntry = aMessageEntry;
  1942 	iCachedEntry = aMessageEntry;
  1960 	iCachedEmailMessage = aImEmailMessage;
  1943 	iCachedEmailMessage = aImEmailMessage;
  1961     }
  1944     }
  1962    
  1945 
  1963 // ----------------------------------------------------------------------------
  1946 // ----------------------------------------------------------------------------
  1964 // ----------------------------------------------------------------------------
  1947 // ----------------------------------------------------------------------------
  1965 //
  1948 //
  1966 void CIpsPlgSosBasePlugin::CleanCachedMessageEntries()
  1949 void CIpsPlgSosBasePlugin::CleanCachedMessageEntries()
  1967     {
  1950     {
  2071 void CIpsPlgSosBasePlugin::DeleteAndRemoveOperation(
  2054 void CIpsPlgSosBasePlugin::DeleteAndRemoveOperation(
  2072         const TInt aOpArrayIndex, TInt aCompleteCode )
  2055         const TInt aOpArrayIndex, TInt aCompleteCode )
  2073     {
  2056     {
  2074     FUNC_LOG;
  2057     FUNC_LOG;
  2075     CIpsPlgSingleOpWatcher* opWatcher = iOperations[aOpArrayIndex];
  2058     CIpsPlgSingleOpWatcher* opWatcher = iOperations[aOpArrayIndex];
  2076     
  2059 
  2077 // <qmail> removed; does nothing
  2060 // <qmail> removed; does nothing
  2078     // The operations matches, handle it in protocol plugin...if needed.
  2061     // The operations matches, handle it in protocol plugin...if needed.
  2079     //TRAP_IGNORE( HandleOpCompletedL( *opWatcher, aCompleteCode ) );
  2062     //TRAP_IGNORE( HandleOpCompletedL( *opWatcher, aCompleteCode ) );
  2080 // </qmail>
  2063 // </qmail>
  2081     const CIpsPlgBaseOperation* op = opWatcher->BaseOperation();
  2064     const CIpsPlgBaseOperation* op = opWatcher->BaseOperation();
  2112     FUNC_LOG;
  2095     FUNC_LOG;
  2113     CFSMailMessagePart* textBodyPart = aMessage->PlainTextBodyPartL();
  2096     CFSMailMessagePart* textBodyPart = aMessage->PlainTextBodyPartL();
  2114     if ( textBodyPart )
  2097     if ( textBodyPart )
  2115         {
  2098         {
  2116         CleanupStack::PushL( textBodyPart );
  2099         CleanupStack::PushL( textBodyPart );
  2117         CFSMailMessage* origMsg = GetMessageByUidL( 
  2100         CFSMailMessage* origMsg = GetMessageByUidL(
  2118                                         aMailBoxId, 
  2101                                         aMailBoxId,
  2119                                         TFSMailMsgId(), 
  2102                                         TFSMailMsgId(),
  2120                                         aOriginalMessageId, 
  2103                                         aOriginalMessageId,
  2121                                         EFSMsgDataStructure );
  2104                                         EFSMsgDataStructure );
  2122         if ( origMsg )
  2105         if ( origMsg )
  2123             {
  2106             {
  2124             CleanupStack::PushL( origMsg );
  2107             CleanupStack::PushL( origMsg );
  2125             CFSMailMessagePart* origMsgTextBodyPart = 
  2108             CFSMailMessagePart* origMsgTextBodyPart =
  2126                 origMsg->PlainTextBodyPartL();
  2109                 origMsg->PlainTextBodyPartL();
  2127                 if ( origMsgTextBodyPart )
  2110                 if ( origMsgTextBodyPart )
  2128                     {
  2111                     {
  2129                     CleanupStack::PushL( origMsgTextBodyPart );
  2112                     CleanupStack::PushL( origMsgTextBodyPart );
  2130                     // Use the content provided in aHeaderDescriptor
  2113                     // Use the content provided in aHeaderDescriptor
  2131                     // instead of what is provided by 
  2114                     // instead of what is provided by
  2132                     // CreateForwardSmtpMessage..
  2115                     // CreateForwardSmtpMessage..
  2133                     TPckgBuf<TReplyForwardParams> pckg;
  2116                     TPckgBuf<TReplyForwardParams> pckg;
  2134                     pckg.Copy( aHeaderDescriptor );
  2117                     pckg.Copy( aHeaderDescriptor );
  2135                     TPtr hPtr( pckg().iHeader->Des() );
  2118                     TPtr hPtr( pckg().iHeader->Des() );
  2136                     HBufC* body = HBufC::NewLC( 
  2119                     HBufC* body = HBufC::NewLC(
  2137                             textBodyPart->FetchedContentSize() );
  2120                             textBodyPart->FetchedContentSize() );
  2138                     TPtr bPtr( body->Des() );
  2121                     TPtr bPtr( body->Des() );
  2139                     origMsgTextBodyPart->GetContentToBufferL( bPtr, 0 );
  2122                     origMsgTextBodyPart->GetContentToBufferL( bPtr, 0 );
  2140                     HBufC* content = HBufC::NewLC(
  2123                     HBufC* content = HBufC::NewLC(
  2141                             hPtr.Length() + bPtr.Length() );
  2124                             hPtr.Length() + bPtr.Length() );
  2142                     TPtr cPtr( content->Des() );                        
  2125                     TPtr cPtr( content->Des() );
  2143                     cPtr.Append( hPtr );
  2126                     cPtr.Append( hPtr );
  2144                     cPtr.Append( bPtr );
  2127                     cPtr.Append( bPtr );
  2145                     textBodyPart->SetContent( cPtr );
  2128                     textBodyPart->SetContent( cPtr );
  2146                     textBodyPart->SaveL();
  2129                     textBodyPart->SaveL();
  2147                     CleanupStack::PopAndDestroy( content );
  2130                     CleanupStack::PopAndDestroy( content );
  2180 
  2163 
  2181         sel->AppendL( service );
  2164         sel->AppendL( service );
  2182 
  2165 
  2183         CIpsPlgBaseOperation* op = CIpsPlgDisconnectOp::NewL(
  2166         CIpsPlgBaseOperation* op = CIpsPlgDisconnectOp::NewL(
  2184             *iSession,
  2167             *iSession,
  2185             watcher->iStatus, 
  2168             watcher->iStatus,
  2186             service, 
  2169             service,
  2187             ActivityTimerL( aMailBoxId ),
  2170             ActivityTimerL( aMailBoxId ),
  2188             aMailBoxId, 
  2171             aMailBoxId,
  2189             &aObserver, 
  2172             &aObserver,
  2190             aRequestId );
  2173             aRequestId );
  2191 
  2174 
  2192         watcher->SetOperation( op );
  2175         watcher->SetOperation( op );
  2193         CleanupStack::PopAndDestroy( sel );
  2176         CleanupStack::PopAndDestroy( sel );
  2194         iOperations.AppendL( watcher );
  2177         iOperations.AppendL( watcher );
  2414     return iSyncStateHandler->ConnOpRunning( aMailBoxId );
  2397     return iSyncStateHandler->ConnOpRunning( aMailBoxId );
  2415     }
  2398     }
  2416 
  2399 
  2417 // ---------------------------------------------------------------------------
  2400 // ---------------------------------------------------------------------------
  2418 // ---------------------------------------------------------------------------
  2401 // ---------------------------------------------------------------------------
  2419 void CIpsPlgSosBasePlugin::SetMailboxName( 
  2402 void CIpsPlgSosBasePlugin::SetMailboxName(
  2420         const TFSMailMsgId& aMailboxId, 
  2403         const TFSMailMsgId& aMailboxId,
  2421         const TDesC& /*aMailboxName*/ )
  2404         const TDesC& /*aMailboxName*/ )
  2422     {
  2405     {
  2423     FUNC_LOG;
  2406     FUNC_LOG;
  2424     TMsvEntry tEntry;
  2407     TMsvEntry tEntry;
  2425     TMsvId service;
  2408     TMsvId service;
  2473     {
  2456     {
  2474     FUNC_LOG;
  2457     FUNC_LOG;
  2475     TBool ret( EFalse );
  2458     TBool ret( EFalse );
  2476     for ( TInt i = 0; i < iOperations.Count(); i++ )
  2459     for ( TInt i = 0; i < iOperations.Count(); i++ )
  2477         {
  2460         {
  2478         if( iOperations[i]->BaseOperation() && 
  2461         if( iOperations[i]->BaseOperation() &&
  2479             iOperations[i]->BaseOperation()->FSMailboxId() == aMailboxId )
  2462             iOperations[i]->BaseOperation()->FSMailboxId() == aMailboxId )
  2480             {
  2463             {
  2481             ret = ETrue;
  2464             ret = ETrue;
  2482             }
  2465             }
  2483         }
  2466         }
  2494         const TFSMailMsgId& aActiveFolderId)
  2477         const TFSMailMsgId& aActiveFolderId)
  2495     {
  2478     {
  2496     TMsvId service;
  2479     TMsvId service;
  2497     TMsvEntry folder;
  2480     TMsvEntry folder;
  2498     iSession->GetEntry( aActiveFolderId.Id(), service, folder );
  2481     iSession->GetEntry( aActiveFolderId.Id(), service, folder );
  2499     
  2482 
  2500     
  2483 
  2501     //currently, no actions unless this is inbox
  2484     //currently, no actions unless this is inbox
  2502     //also, if id is '0', it means inbox before first sync...it doesn't really exist yet
  2485     //also, if id is '0', it means inbox before first sync...it doesn't really exist yet
  2503     if( folder.iDetails.CompareF( KIpsPlgInbox ) == 0 || folder.Id() == 0 || 
  2486     if( folder.iDetails.CompareF( KIpsPlgInbox ) == 0 || folder.Id() == 0 ||
  2504             ( folder.iMtm == KSenduiMtmPop3Uid ) &&
  2487             ( folder.iMtm == KSenduiMtmPop3Uid ) &&
  2505             ( folder.iType == KUidMsvServiceEntry ) &&
  2488             ( folder.iType == KUidMsvServiceEntry ) &&
  2506             ( folder.iServiceId == aActiveFolderId.Id() ) )
  2489             ( folder.iServiceId == aActiveFolderId.Id() ) )
  2507         {
  2490         {
  2508         //folder is inbox
  2491         //folder is inbox
  2510                     == KIpsSosEmailSyncStarted )
  2493                     == KIpsSosEmailSyncStarted )
  2511             {
  2494             {
  2512             //we won't do anything if sync is already started
  2495             //we won't do anything if sync is already started
  2513             return;
  2496             return;
  2514             }
  2497             }
  2515         
  2498 
  2516         //check are we in polling mode
  2499         //check are we in polling mode
  2517         NmIpsSosExtendedSettingsManager* eMgr= 
  2500         NmIpsSosExtendedSettingsManager* eMgr=
  2518                 new NmIpsSosExtendedSettingsManager(aActiveMailboxId.Id());
  2501                 new NmIpsSosExtendedSettingsManager(aActiveMailboxId.Id());
  2519         
  2502 
  2520         QVariant value;
  2503         QVariant value;
  2521         bool ok = eMgr->readSetting(IpsServices::ReceptionActiveProfile, value);
  2504         bool ok = eMgr->readSetting(IpsServices::ReceptionActiveProfile, value);
  2522         delete eMgr;
  2505         delete eMgr;
  2523         
  2506 
  2524         if ( ok )
  2507         if ( ok )
  2525             {
  2508             {
  2526             TInt profile = value.toInt();
  2509             TInt profile = value.toInt();
  2527             if ( profile != IpsServices::EmailSyncProfileManualFetch )
  2510             if ( profile != IpsServices::EmailSyncProfileManualFetch )
  2528                 {
  2511                 {
  2529                 // let's sync
  2512                 // let's sync
  2530                 GoOnlineL(aActiveMailboxId);
  2513                 GoOnlineL(aActiveMailboxId);
  2531                 }
  2514                 }
  2532             }        
  2515             }
  2533         }        
  2516         }
  2534     }
  2517     }
  2535 // </qmail>
  2518 // </qmail>