ipsservices/ipssosplugin/src/ipsplgsmtpservice.cpp
changeset 20 ecc8def7944a
parent 18 578830873419
child 23 2dc6caa42ec3
equal deleted inserted replaced
18:578830873419 20:ecc8def7944a
    46 //    
    46 //    
    47 CIpsPlgSmtpService::~CIpsPlgSmtpService() 
    47 CIpsPlgSmtpService::~CIpsPlgSmtpService() 
    48     {
    48     {
    49     FUNC_LOG;
    49     FUNC_LOG;
    50     delete iMsgMapper;
    50     delete iMsgMapper;
    51 // <qmail>
       
    52     iOperations.ResetAndDestroy();
       
    53 // </qmail>
       
    54     }    
    51     }    
    55 
    52 
    56 // ---------------------------------------------------------------------------
    53 // ---------------------------------------------------------------------------
    57 // CIpsPlgSmtpService::NewL
    54 // CIpsPlgSmtpService::NewL
    58 // ---------------------------------------------------------------------------
    55 // ---------------------------------------------------------------------------
    91 void CIpsPlgSmtpService::ConstructL()
    88 void CIpsPlgSmtpService::ConstructL()
    92     {
    89     {
    93     FUNC_LOG;
    90     FUNC_LOG;
    94     iMsgMapper = CIpsPlgMsgMapper::NewL( iSession, iPlugin );
    91     iMsgMapper = CIpsPlgMsgMapper::NewL( iSession, iPlugin );
    95     }
    92     }
    96 
       
    97 // <qmail>
       
    98 // ----------------------------------------------------------------------------
       
    99 // CIpsPlgSmtpService::OpCompleted
       
   100 // ----------------------------------------------------------------------------
       
   101 void CIpsPlgSmtpService::OpCompleted(
       
   102     CIpsPlgSingleOpWatcher& aOpWatcher,
       
   103     TInt /*aCompletionCode*/ )
       
   104     {
       
   105     FUNC_LOG;
       
   106     // Get valid operation count in each, some operations could have been
       
   107     // deleted in array
       
   108     TInt opId = aOpWatcher.Operation().Id();
       
   109 	
       
   110 	TInt count = iOperations.Count();
       
   111 	
       
   112     for ( TInt i = count - 1; i >= 0; i-- )
       
   113         {
       
   114         CMsvOperation& oper = iOperations[i]->Operation();
       
   115 
       
   116         if ( oper.Id() == opId )
       
   117             {
       
   118             DeleteAndRemoveOperation( i );
       
   119             }
       
   120         }
       
   121     }
       
   122 
       
   123 // ---------------------------------------------------------------------------
       
   124 // CIpsPlgSmtpService::DeleteAndRemoveOperation
       
   125 // ---------------------------------------------------------------------------
       
   126 void CIpsPlgSmtpService::DeleteAndRemoveOperation( const TInt aOpArrayIndex )
       
   127     {
       
   128     FUNC_LOG;
       
   129     CIpsPlgSingleOpWatcher* opWatcher = iOperations[aOpArrayIndex];
       
   130 
       
   131     iOperations.Remove( aOpArrayIndex );
       
   132     delete opWatcher;
       
   133     opWatcher = NULL;
       
   134     }
       
   135 // </qmail>
       
   136 
    93 
   137 // ---------------------------------------------------------------------------
    94 // ---------------------------------------------------------------------------
   138 // CIpsPlgSmtpService::CreateDisplayStringLC
    95 // CIpsPlgSmtpService::CreateDisplayStringLC
   139 // ---------------------------------------------------------------------------
    96 // ---------------------------------------------------------------------------
   140 //
    97 //
   297     
   254     
   298     return CreateFSMessageAndSetFlagsL( 
   255     return CreateFSMessageAndSetFlagsL( 
   299             msgId, KErrNotFound, aMailBoxId.Id() );
   256             msgId, KErrNotFound, aMailBoxId.Id() );
   300     }
   257     }
   301 
   258 
   302 // <qmail>
       
   303 // ---------------------------------------------------------------------------
       
   304 // CIpsPlgSmtpService::CreateNewSmtpMessageL
       
   305 // ---------------------------------------------------------------------------
       
   306 //
       
   307 void CIpsPlgSmtpService::CreateNewSmtpMessageL(
       
   308     const TFSMailMsgId& aMailBoxId,
       
   309     MFSMailRequestObserver& aOperationObserver,
       
   310     const TInt aRequestId )
       
   311     {
       
   312     TMsvPartList partList( KMsvMessagePartBody );
       
   313     
       
   314     CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewLC(*this);
       
   315     
       
   316     TMsvEntry mboxEntry;
       
   317     TMsvId service;
       
   318     User::LeaveIfError(
       
   319 	    iSession.GetEntry( aMailBoxId.Id(), service, mboxEntry ) );
       
   320 
       
   321     CIpsPlgCreateMessageOperation* op = CIpsPlgCreateMessageOperation::NewL( this, 
       
   322         iSession,
       
   323         watcher->iStatus,
       
   324         mboxEntry.iRelatedId, 
       
   325         partList, 
       
   326         aMailBoxId.Id(), 
       
   327         aOperationObserver, 
       
   328         aRequestId );
       
   329     watcher->SetOperation( op );
       
   330 
       
   331     iOperations.AppendL( watcher ); 
       
   332     CleanupStack::Pop( watcher );
       
   333     }
       
   334 // </qmail>
       
   335 
       
   336 // ---------------------------------------------------------------------------
   259 // ---------------------------------------------------------------------------
   337 // CIpsPlgSmtpService::CreateForwardSmtpMessageL
   260 // CIpsPlgSmtpService::CreateForwardSmtpMessageL
   338 // ---------------------------------------------------------------------------
   261 // ---------------------------------------------------------------------------
   339 //
   262 //
   340 CFSMailMessage* CIpsPlgSmtpService::CreateForwardSmtpMessageL( 
   263 CFSMailMessage* CIpsPlgSmtpService::CreateForwardSmtpMessageL( 
   379     
   302     
   380     CleanupStack::PopAndDestroy( 2, wait );
   303     CleanupStack::PopAndDestroy( 2, wait );
   381     
   304     
   382     return CreateFSMessageAndSetFlagsL( msgId, orgMsg.Id(), aMailBoxId.Id() );
   305     return CreateFSMessageAndSetFlagsL( msgId, orgMsg.Id(), aMailBoxId.Id() );
   383     }
   306     }
   384 
       
   385 // <qmail>
       
   386 // ---------------------------------------------------------------------------
       
   387 // CIpsPlgSmtpService::CreateNewSmtpMessageL
       
   388 // ---------------------------------------------------------------------------
       
   389 //
       
   390 void CIpsPlgSmtpService::CreateForwardSmtpMessageL(
       
   391     const TFSMailMsgId& aMailBoxId,
       
   392     const TFSMailMsgId& aOriginalMessageId,
       
   393     MFSMailRequestObserver& aOperationObserver,
       
   394     const TInt aRequestId )
       
   395     {
       
   396     FUNC_LOG;
       
   397     // 1. part of function checs that body text and all
       
   398     // attachments are fetched
       
   399     TMsvEntry orgMsg;
       
   400     TMsvId service;
       
   401     User::LeaveIfError( iSession.GetEntry( 
       
   402             aOriginalMessageId.Id(), service, orgMsg ) );
       
   403     
       
   404     if ( orgMsg.Id() ==  KMsvNullIndexEntryIdValue )
       
   405         {
       
   406         User::Leave(KErrNotFound);
       
   407         }
       
   408     
       
   409     if ( ( orgMsg.Parent() == KMsvSentEntryIdValue ) && 
       
   410          ( orgMsg.iMtm == KSenduiMtmSmtpUid ) )
       
   411         {
       
   412         ChangeServiceIdL( orgMsg );
       
   413         }
       
   414     
       
   415     TMsvPartList partList( KMsvMessagePartBody | KMsvMessagePartAttachments );
       
   416     
       
   417     CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewLC(*this);
       
   418     
       
   419     CIpsPlgCreateForwardMessageOperation* op = CIpsPlgCreateForwardMessageOperation::NewL( 
       
   420         this, 
       
   421         iSession,
       
   422         watcher->iStatus,
       
   423         partList, 
       
   424         aMailBoxId.Id(), 
       
   425         orgMsg.Id(), 
       
   426         aOperationObserver, 
       
   427         aRequestId );
       
   428     watcher->SetOperation( op );
       
   429 
       
   430     iOperations.AppendL( watcher ); 
       
   431     CleanupStack::Pop( watcher );
       
   432     }
       
   433 // </qmail>
       
   434 
   307 
   435 // ---------------------------------------------------------------------------
   308 // ---------------------------------------------------------------------------
   436 // CIpsPlgSmtpService::CreateReplySmtpMessageL
   309 // CIpsPlgSmtpService::CreateReplySmtpMessageL
   437 // ---------------------------------------------------------------------------
   310 // ---------------------------------------------------------------------------
   438 //
   311 //
   536     CleanupStack::PopAndDestroy( 3, cEntry ); // header, store, cEntry
   409     CleanupStack::PopAndDestroy( 3, cEntry ); // header, store, cEntry
   537     CleanupStack::Pop( fsMsg ); // fsMsg is given to client
   410     CleanupStack::Pop( fsMsg ); // fsMsg is given to client
   538     return fsMsg;
   411     return fsMsg;
   539     }
   412     }
   540 
   413 
   541 // <qmail>
       
   542 // ---------------------------------------------------------------------------
       
   543 // CIpsPlgSmtpService::CreateReplySmtpMessageL
       
   544 // ---------------------------------------------------------------------------
       
   545 //
       
   546 void CIpsPlgSmtpService::CreateReplySmtpMessageL( 
       
   547     const TFSMailMsgId& aMailBoxId,
       
   548     const TFSMailMsgId& aOriginalMessageId,
       
   549     TBool aReplyToAll,
       
   550     MFSMailRequestObserver& aOperationObserver,
       
   551     const TInt aRequestId )
       
   552     {
       
   553     FUNC_LOG;
       
   554     // find orginal message header and check that body is fetched
       
   555     TMsvEntry orgMsg;
       
   556     TMsvId service;
       
   557     User::LeaveIfError( 
       
   558         iSession.GetEntry( aOriginalMessageId.Id(), service, orgMsg ) );
       
   559     
       
   560     if ( orgMsg.Id() ==  KMsvNullIndexEntryIdValue )
       
   561         {
       
   562         User::Leave(KErrNotFound);
       
   563         }
       
   564     
       
   565     if ( ( orgMsg.Parent() == KMsvSentEntryIdValue ) && 
       
   566          ( orgMsg.iMtm == KSenduiMtmSmtpUid ) )
       
   567         {
       
   568         ChangeServiceIdL( orgMsg );
       
   569         }
       
   570     
       
   571     // partList flags control e.g. what kind of recipient set is created
       
   572     TMsvPartList partList = KMsvMessagePartBody | KMsvMessagePartDescription
       
   573     | KMsvMessagePartOriginator;        
       
   574     if( aReplyToAll )
       
   575         {
       
   576         partList |= KMsvMessagePartRecipient;
       
   577         }
       
   578     
       
   579     CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewLC(*this);
       
   580     
       
   581     CIpsPlgCreateReplyMessageOperation* op = CIpsPlgCreateReplyMessageOperation::NewL( 
       
   582         this, 
       
   583         iSession,
       
   584         watcher->iStatus,
       
   585         partList, 
       
   586         aMailBoxId.Id(), 
       
   587         orgMsg.Id(), 
       
   588         aOperationObserver, 
       
   589         aRequestId );
       
   590     watcher->SetOperation( op );
       
   591 
       
   592     iOperations.AppendL( watcher ); 
       
   593     CleanupStack::Pop( watcher );
       
   594     }
       
   595 // </qmail>
       
   596 
       
   597 // ---------------------------------------------------------------------------
   414 // ---------------------------------------------------------------------------
   598 // CIpsPlgSmtpService::ChangeServiceIdL
   415 // CIpsPlgSmtpService::ChangeServiceIdL
   599 // ---------------------------------------------------------------------------
   416 // ---------------------------------------------------------------------------
   600 //
   417 //
   601 void CIpsPlgSmtpService::ChangeServiceIdL( TMsvEntry& aEntry )
   418 void CIpsPlgSmtpService::ChangeServiceIdL( TMsvEntry& aEntry )