ipsservices/ipssosplugin/src/ipsplgsosbaseplugin.cpp
branchRCL_3
changeset 8 e1b6206813b4
parent 0 8466d47a6819
child 13 0396474f30f5
equal deleted inserted replaced
4:e7aa27f58ae1 8:e1b6206813b4
    13 *
    13 *
    14 * Description: This file implements classes CIpsPlgSosBasePlugin, Plugin.
    14 * Description: This file implements classes CIpsPlgSosBasePlugin, Plugin.
    15  *
    15  *
    16 */
    16 */
    17 
    17 
    18 
       
    19 
       
    20 #include "emailtrace.h"
    18 #include "emailtrace.h"
    21 #include "ipsplgheaders.h"
    19 #include "ipsplgheaders.h"
       
    20 #include "FreestyleEmailUiConstants.h"
    22 
    21 
    23 #define FREESTYLE_EMAIL_UI_SID 0x2001E277
    22 #define FREESTYLE_EMAIL_UI_SID 0x2001E277
    24 
    23 
    25 const TInt KOpGranularity = 2;
    24 const TInt KOpGranularity = 2;
    26 
    25 
   818 // ----------------------------------------------------------------------------
   817 // ----------------------------------------------------------------------------
   819 // ----------------------------------------------------------------------------
   818 // ----------------------------------------------------------------------------
   820 CFSMailMessage* CIpsPlgSosBasePlugin::CreateForwardMessageL(
   819 CFSMailMessage* CIpsPlgSosBasePlugin::CreateForwardMessageL(
   821     const TFSMailMsgId& aMailBoxId,
   820     const TFSMailMsgId& aMailBoxId,
   822     const TFSMailMsgId& aOriginalMessageId,
   821     const TFSMailMsgId& aOriginalMessageId,
   823     const TDesC& /* aHeaderDescriptor */)
   822     const TDesC& aHeaderDescriptor )
   824     {
   823     {
   825     FUNC_LOG;
   824     FUNC_LOG;
   826     CFSMailMessage* msg = iSmtpService->CreateForwardSmtpMessageL(
   825     CFSMailMessage* msg = iSmtpService->CreateForwardSmtpMessageL(
   827         aMailBoxId, aOriginalMessageId );
   826         aMailBoxId, aOriginalMessageId );
       
   827     
       
   828     if ( aHeaderDescriptor != KNullDesC )
       
   829         {
       
   830         // Ignoring trap as it is better to provide something in case of the
       
   831         // below fix method fails than nothing.
       
   832         TRAP_IGNORE( FixReplyForwardHeaderL( 
       
   833                         msg, 
       
   834                         aMailBoxId, 
       
   835                         aOriginalMessageId, 
       
   836                         aHeaderDescriptor ) );
       
   837         }
       
   838   
   828     return msg;
   839     return msg;
   829     }
   840     }
   830 
   841 
   831 // ----------------------------------------------------------------------------
   842 // ----------------------------------------------------------------------------
   832 // ----------------------------------------------------------------------------
   843 // ----------------------------------------------------------------------------
   833 CFSMailMessage* CIpsPlgSosBasePlugin::CreateReplyMessageL(
   844 CFSMailMessage* CIpsPlgSosBasePlugin::CreateReplyMessageL(
   834     const TFSMailMsgId& aMailBoxId,
   845     const TFSMailMsgId& aMailBoxId,
   835     const TFSMailMsgId& aOriginalMessageId,
   846     const TFSMailMsgId& aOriginalMessageId,
   836     const TBool aReplyToAll,
   847     const TBool aReplyToAll,
   837     const TDesC& /* aHeaderDescriptor */ )
   848     const TDesC& aHeaderDescriptor )
   838     {
   849     {
   839     FUNC_LOG;
   850     FUNC_LOG;
   840     CFSMailMessage* msg = iSmtpService->CreateReplySmtpMessageL(
   851     CFSMailMessage* msg = iSmtpService->CreateReplySmtpMessageL(
   841         aMailBoxId, aOriginalMessageId, aReplyToAll );
   852         aMailBoxId, aOriginalMessageId, aReplyToAll );
       
   853 
       
   854     if ( aHeaderDescriptor != KNullDesC )
       
   855         {
       
   856         // Ignoring trap as it is better to provide something in case of the
       
   857         // below fix method fails than nothing.
       
   858         TRAP_IGNORE( FixReplyForwardHeaderL( 
       
   859                                 msg, 
       
   860                                 aMailBoxId, 
       
   861                                 aOriginalMessageId, 
       
   862                                 aHeaderDescriptor ) );
       
   863         }
       
   864 
   842     return msg;
   865     return msg;
   843     }
   866     }
   844 
   867 
   845 // ----------------------------------------------------------------------------
   868 // ----------------------------------------------------------------------------
   846 // ----------------------------------------------------------------------------
   869 // ----------------------------------------------------------------------------
  1559     FUNC_LOG;
  1582     FUNC_LOG;
  1560  	CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewL(*this);
  1583  	CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewL(*this);
  1561  	CleanupStack::PushL(watcher);
  1584  	CleanupStack::PushL(watcher);
  1562     CIpsPlgSmtpOperation* op = CIpsPlgSmtpOperation::NewLC(
  1585     CIpsPlgSmtpOperation* op = CIpsPlgSmtpOperation::NewLC(
  1563         *iSession, CActive::EPriorityStandard, watcher->iStatus, ETrue );
  1586         *iSession, CActive::EPriorityStandard, watcher->iStatus, ETrue );
       
  1587     op->SetEventHandler(iEventHandler);
  1564     watcher->SetOperation(op);
  1588     watcher->SetOperation(op);
  1565     CleanupStack::Pop( op ); // op added as member of watcher
  1589     CleanupStack::Pop( op ); // op added as member of watcher
  1566     op->StartSendL( aMessageId.Id() );
  1590     op->StartSendL( aMessageId.Id() );
  1567     iOperations.AppendL(watcher);
  1591     iOperations.AppendL(watcher);
  1568     CleanupStack::Pop( watcher );
  1592     CleanupStack::Pop( watcher );
  1829         CleanupStack::PushL( api );
  1853         CleanupStack::PushL( api );
  1830 
  1854 
  1831         CMsvEntry* cEntry = iSession->GetEntryL( aMailBoxId.Id() );
  1855         CMsvEntry* cEntry = iSession->GetEntryL( aMailBoxId.Id() );
  1832         CleanupStack::PushL( cEntry );
  1856         CleanupStack::PushL( cEntry );
  1833 
  1857 
  1834         api->SetNewPasswordL( *cEntry, aPassword );
  1858         RProcess process;
       
  1859         // only email server can set outgoing password
       
  1860         if ( process.SecureId() == FREESTYLE_FSSERVER_SID )
       
  1861             {
       
  1862             if ( !iEventHandler->IncomingPass() )
       
  1863                 {
       
  1864                 CMsvEntry* cTmp = iSession->GetEntryL( cEntry->Entry().iRelatedId );
       
  1865                 CleanupStack::PopAndDestroy( 1, cEntry );
       
  1866                 CleanupStack::PushL( cTmp );
       
  1867                 cEntry = cTmp;
       
  1868                 }
       
  1869             }
       
  1870 
       
  1871 		api->SetNewPasswordL( *cEntry, aPassword );
  1835 
  1872 
  1836         CleanupStack::PopAndDestroy( 2, api );//cEntry, api
  1873         CleanupStack::PopAndDestroy( 2, api );//cEntry, api
  1837 
  1874 
  1838         //now signal through eventhandler that credientials have been set
  1875         //now signal through eventhandler that credientials have been set
  1839 	    }
  1876 	    }
  2010         }
  2047         }
  2011     }
  2048     }
  2012 
  2049 
  2013 // ---------------------------------------------------------------------------
  2050 // ---------------------------------------------------------------------------
  2014 // ---------------------------------------------------------------------------
  2051 // ---------------------------------------------------------------------------
       
  2052 void CIpsPlgSosBasePlugin::FixReplyForwardHeaderL(
       
  2053         CFSMailMessage* aMessage,
       
  2054         const TFSMailMsgId& aMailBoxId,
       
  2055         const TFSMailMsgId& aOriginalMessageId,
       
  2056         const TDesC& aHeaderDescriptor )
       
  2057     {
       
  2058     FUNC_LOG;
       
  2059     CFSMailMessagePart* textBodyPart = aMessage->PlainTextBodyPartL();
       
  2060     if ( textBodyPart )
       
  2061         {
       
  2062         CleanupStack::PushL( textBodyPart );
       
  2063         CFSMailMessage* origMsg = GetMessageByUidL( 
       
  2064                                         aMailBoxId, 
       
  2065                                         TFSMailMsgId(), 
       
  2066                                         aOriginalMessageId, 
       
  2067                                         EFSMsgDataStructure );
       
  2068         if ( origMsg )
       
  2069             {
       
  2070             CleanupStack::PushL( origMsg );
       
  2071             CFSMailMessagePart* origMsgTextBodyPart = 
       
  2072                 origMsg->PlainTextBodyPartL();
       
  2073                 if ( origMsgTextBodyPart )
       
  2074                     {
       
  2075                     CleanupStack::PushL( origMsgTextBodyPart );
       
  2076                     // Use the content provided in aHeaderDescriptor
       
  2077                     // instead of what is provided by 
       
  2078                     // CreateForwardSmtpMessage..
       
  2079                     TPckgBuf<TReplyForwardParams> pckg;
       
  2080                     pckg.Copy( aHeaderDescriptor );
       
  2081                     TPtr hPtr( pckg().iHeader->Des() );
       
  2082                     HBufC* body = HBufC::NewLC( 
       
  2083                             textBodyPart->FetchedContentSize() );
       
  2084                     TPtr bPtr( body->Des() );
       
  2085                     origMsgTextBodyPart->GetContentToBufferL( bPtr, 0 );
       
  2086                     HBufC* content = HBufC::NewLC(
       
  2087                             hPtr.Length() + bPtr.Length() );
       
  2088                     TPtr cPtr( content->Des() );                        
       
  2089                     cPtr.Append( hPtr );
       
  2090                     cPtr.Append( bPtr );
       
  2091                     textBodyPart->SetContent( cPtr );
       
  2092                     textBodyPart->SaveL();
       
  2093                     CleanupStack::PopAndDestroy( content );
       
  2094                     CleanupStack::PopAndDestroy( body );
       
  2095                     CleanupStack::PopAndDestroy( origMsgTextBodyPart );
       
  2096                     }
       
  2097             CleanupStack::PopAndDestroy( origMsg );
       
  2098             }
       
  2099         CleanupStack::PopAndDestroy( textBodyPart );
       
  2100         }
       
  2101     }
       
  2102 
       
  2103 // ---------------------------------------------------------------------------
       
  2104 // ---------------------------------------------------------------------------
  2015 void CIpsPlgSosBasePlugin::DisconnectL(
  2105 void CIpsPlgSosBasePlugin::DisconnectL(
  2016     const TFSMailMsgId& aMailBoxId,
  2106     const TFSMailMsgId& aMailBoxId,
  2017     MFSMailRequestObserver& aObserver,
  2107     MFSMailRequestObserver& aObserver,
  2018     const TInt aRequestId,
  2108     const TInt aRequestId,
  2019     TBool aRemoveAccountAlso )
  2109     TBool aRemoveAccountAlso )
  2080     FUNC_LOG;
  2170     FUNC_LOG;
  2081     CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewL(*this);
  2171     CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewL(*this);
  2082  	CleanupStack::PushL(watcher);
  2172  	CleanupStack::PushL(watcher);
  2083     CIpsPlgSmtpOperation* op = CIpsPlgSmtpOperation::NewLC(
  2173     CIpsPlgSmtpOperation* op = CIpsPlgSmtpOperation::NewLC(
  2084         *iSession, CActive::EPriorityStandard, watcher->iStatus, ETrue );
  2174         *iSession, CActive::EPriorityStandard, watcher->iStatus, ETrue );
       
  2175     op->SetEventHandler(iEventHandler);
  2085     watcher->SetOperation(op);
  2176     watcher->SetOperation(op);
  2086     op->EmptyOutboxFromPendingMessagesL( aMailBoxId.Id() );
  2177     op->EmptyOutboxFromPendingMessagesL( aMailBoxId.Id() );
  2087     iOperations.AppendL(watcher);
  2178     iOperations.AppendL(watcher);
  2088     CleanupStack::Pop( 2, watcher );
  2179     CleanupStack::Pop( 2, watcher );
  2089     }
  2180     }