emailservices/emailcommon/src/CFSMailBox.cpp
changeset 68 83cc6bae1de8
parent 66 084b5b1f02a7
child 74 6c59112cfd31
equal deleted inserted replaced
67:459da34cdb45 68:83cc6bae1de8
    29 #include "cmailboxstateext.h"
    29 #include "cmailboxstateext.h"
    30 // <qmail>
    30 // <qmail>
    31 #include "CFSMailFolder.h"
    31 #include "CFSMailFolder.h"
    32 #include "CFSMailAddress.h"
    32 #include "CFSMailAddress.h"
    33 // </qmail>
    33 // </qmail>
       
    34 #include <emailmru.h>
    34 
    35 
    35 
    36 
    36 // ================= MEMBER FUNCTIONS ==========================================
    37 // ================= MEMBER FUNCTIONS ==========================================
    37 // -----------------------------------------------------------------------------
    38 // -----------------------------------------------------------------------------
    38 // CFSMailBox::NewLC
    39 // CFSMailBox::NewLC
    66 {
    67 {
    67     NM_FUNCTION;
    68     NM_FUNCTION;
    68 
    69 
    69     // get requesthandler pointer
    70     // get requesthandler pointer
    70     iRequestHandler = static_cast<CFSMailRequestHandler*>(Dll::Tls());
    71     iRequestHandler = static_cast<CFSMailRequestHandler*>(Dll::Tls());
       
    72     QT_TRYCATCH_LEAVING({
       
    73     iMru = new EmailMRU();
       
    74     });
    71 }
    75 }
    72 
    76 
    73 // -----------------------------------------------------------------------------
    77 // -----------------------------------------------------------------------------
    74 // CFSMailBox::~CFSMailBox
    78 // CFSMailBox::~CFSMailBox
    75 // -----------------------------------------------------------------------------
    79 // -----------------------------------------------------------------------------
    76 EXPORT_C CFSMailBox::~CFSMailBox()
    80 EXPORT_C CFSMailBox::~CFSMailBox()
    77 {
    81 {
    78     NM_FUNCTION;
    82     NM_FUNCTION;
    79     // <qmail> Not using KMailboxExtMrCalInfo </qmail>
    83     // <qmail> Not using KMailboxExtMrCalInfo </qmail>
    80     iFolders.ResetAndDestroy();
    84     iFolders.ResetAndDestroy();
       
    85     QT_TRYCATCH_LEAVING({
       
    86     delete iMru;
       
    87     });
    81 }
    88 }
    82 
    89 
    83 // -----------------------------------------------------------------------------
    90 // -----------------------------------------------------------------------------
    84 // CFSMailBox::ConstructL
    91 // CFSMailBox::ConstructL
    85 // -----------------------------------------------------------------------------
    92 // -----------------------------------------------------------------------------
   422     {
   429     {
   423     NM_FUNCTION;
   430     NM_FUNCTION;
   424 
   431 
   425     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   432     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   426         {
   433         {
   427         // <qmail> Removed UpdateMrusL. </qmail>
   434         UpdateMrusL( aMessage.GetToRecipients(),
       
   435                      aMessage.GetCCRecipients(),
       
   436                      aMessage.GetBCCRecipients() );
   428         plugin->SendMessageL( aMessage );
   437         plugin->SendMessageL( aMessage );
   429         }
   438         }
   430 	}
   439 	}
   431 
   440 
   432 // <qmail>
   441 // <qmail>
   443 
   452 
   444     CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() );
   453     CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() );
   445 
   454 
   446     if ( plugin )
   455     if ( plugin )
   447         {
   456         {
   448         // <qmail> Removed UpdateMrusL. </qmail>
   457         UpdateMrusL( aMessage.GetToRecipients(),
       
   458                      aMessage.GetCCRecipients(),
       
   459                      aMessage.GetBCCRecipients() );
       
   460 
   449 
   461 
   450         // init asynchronous request
   462         // init asynchronous request
   451         request = iRequestHandler->InitAsyncRequestL( GetId().PluginId(),
   463         request = iRequestHandler->InitAsyncRequestL( GetId().PluginId(),
   452                                                       aOperationObserver );
   464                                                       aOperationObserver );
   453 
   465 
   661     }
   673     }
   662     return status;
   674     return status;
   663 }
   675 }
   664 
   676 
   665 // -----------------------------------------------------------------------------
   677 // -----------------------------------------------------------------------------
       
   678 // CFSMailBox::HasCapability
       
   679 // -----------------------------------------------------------------------------
       
   680 EXPORT_C TBool CFSMailBox::HasCapability( const TFSMailBoxCapabilities aCapability ) const
       
   681 {
       
   682     NM_FUNCTION;
       
   683     
       
   684     TBool capability = EFalse;
       
   685     if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() ) )
       
   686         {
       
   687         TRAPD( err,capability = plugin->MailboxHasCapabilityL( aCapability,GetId() )) ;
       
   688         if ( err != KErrNone )
       
   689             {
       
   690             capability = EFalse;
       
   691             }
       
   692         }
       
   693     return capability;
       
   694 }
       
   695 
       
   696 // -----------------------------------------------------------------------------
       
   697 
       
   698 // -----------------------------------------------------------------------------
       
   699 // -----------------------------------------------------------------------------
       
   700 // CFSMailBox::UpdateMrusL
       
   701 // -----------------------------------------------------------------------------
       
   702 void CFSMailBox::UpdateMrusL(
       
   703     const RPointerArray<CFSMailAddress>& aRecipients,
       
   704     const RPointerArray<CFSMailAddress>& aCCRecipients,
       
   705     const RPointerArray<CFSMailAddress>& aBCCRecipients ) const
       
   706     {
       
   707     NM_FUNCTION;
       
   708 
       
   709     QT_TRYCATCH_LEAVING({
       
   710         TUint count( aRecipients.Count() );
       
   711         TUint indexer( 0 );
       
   712         while ( indexer < count )
       
   713             {
       
   714             TDesC& address(aRecipients[indexer]->GetEmailAddress() );
       
   715             TDesC& name(aRecipients[indexer]->GetDisplayName() );
       
   716             QString qaddress = QString::fromUtf16(address.Ptr(), address.Length());
       
   717             QString qname = QString::fromUtf16(name.Ptr(), name.Length());
       
   718             iMru->updateMRU(qname, qaddress);
       
   719             indexer++;
       
   720             }
       
   721 
       
   722         count = aCCRecipients.Count();
       
   723         indexer = 0 ;
       
   724         while ( indexer < count )
       
   725             {
       
   726             TDesC& address(aCCRecipients[indexer]->GetEmailAddress() );
       
   727             TDesC& name(aCCRecipients[indexer]->GetDisplayName() );
       
   728             QString qaddress = QString::fromUtf16(address.Ptr(), address.Length());
       
   729             QString qname = QString::fromUtf16(name.Ptr(), name.Length());
       
   730             iMru->updateMRU(qname, qaddress);
       
   731             indexer++;
       
   732             }
       
   733 
       
   734         count = aBCCRecipients.Count();
       
   735         indexer = 0 ;
       
   736         while ( indexer < count )
       
   737             {
       
   738             TDesC& address(aBCCRecipients[indexer]->GetEmailAddress() );
       
   739             TDesC& name(aBCCRecipients[indexer]->GetDisplayName() );
       
   740             QString qaddress = QString::fromUtf16(address.Ptr(), address.Length());
       
   741             QString qname = QString::fromUtf16(name.Ptr(), name.Length());
       
   742             iMru->updateMRU(qname, qaddress);
       
   743             indexer++;
       
   744             }
       
   745 
       
   746     });
       
   747 
       
   748     }
       
   749 
       
   750 // -----------------------------------------------------------------------------
   666 // CFSMailBox::ReleaseExtension
   751 // CFSMailBox::ReleaseExtension
   667 // -----------------------------------------------------------------------------
   752 // -----------------------------------------------------------------------------
   668 EXPORT_C void CFSMailBox::ReleaseExtension( CEmailExtension* aExtension )
   753 EXPORT_C void CFSMailBox::ReleaseExtension( CEmailExtension* aExtension )
   669     {
   754     {
   670     NM_FUNCTION;
   755     NM_FUNCTION;
   714         {
   799         {
   715         User::Leave( KErrNotSupported );
   800         User::Leave( KErrNotSupported );
   716         }
   801         }
   717     return extension;
   802     return extension;
   718     }
   803     }
   719 
   804     
       
   805