emailservices/emailcommon/src/CFSMailBox.cpp
changeset 74 6c59112cfd31
parent 68 83cc6bae1de8
child 76 38bf5461e270
equal deleted inserted replaced
69:4e54af54a4a1 74:6c59112cfd31
    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 #include "emailmru.h"
    35 
    35 
    36 
    36 
    37 // ================= MEMBER FUNCTIONS ==========================================
    37 // ================= MEMBER FUNCTIONS ==========================================
    38 // -----------------------------------------------------------------------------
    38 // -----------------------------------------------------------------------------
    39 // CFSMailBox::NewLC
    39 // CFSMailBox::NewLC
    67 {
    67 {
    68     NM_FUNCTION;
    68     NM_FUNCTION;
    69 
    69 
    70     // get requesthandler pointer
    70     // get requesthandler pointer
    71     iRequestHandler = static_cast<CFSMailRequestHandler*>(Dll::Tls());
    71     iRequestHandler = static_cast<CFSMailRequestHandler*>(Dll::Tls());
       
    72 }
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // CFSMailBox::~CFSMailBox
       
    76 // -----------------------------------------------------------------------------
       
    77 EXPORT_C CFSMailBox::~CFSMailBox()
       
    78 {
       
    79     NM_FUNCTION;
       
    80     // <qmail> Not using KMailboxExtMrCalInfo </qmail>
       
    81     iFolders.ResetAndDestroy();
       
    82     delete iMru;
       
    83 }
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // CFSMailBox::ConstructL
       
    87 // -----------------------------------------------------------------------------
       
    88 void CFSMailBox::ConstructL(TFSMailMsgId aMailBoxId)
       
    89 {
       
    90     NM_FUNCTION;
       
    91 
    72     QT_TRYCATCH_LEAVING({
    92     QT_TRYCATCH_LEAVING({
    73     iMru = new EmailMRU();
    93     iMru = new EmailMRU();
    74     });
    94     });
    75 }
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CFSMailBox::~CFSMailBox
       
    79 // -----------------------------------------------------------------------------
       
    80 EXPORT_C CFSMailBox::~CFSMailBox()
       
    81 {
       
    82     NM_FUNCTION;
       
    83     // <qmail> Not using KMailboxExtMrCalInfo </qmail>
       
    84     iFolders.ResetAndDestroy();
       
    85     QT_TRYCATCH_LEAVING({
       
    86     delete iMru;
       
    87     });
       
    88 }
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CFSMailBox::ConstructL
       
    92 // -----------------------------------------------------------------------------
       
    93 void CFSMailBox::ConstructL(TFSMailMsgId aMailBoxId)
       
    94 {
       
    95     NM_FUNCTION;
       
    96 
    95 
    97 // <qmail>
    96 // <qmail>
    98     CFSMailBoxBase::ConstructL(aMailBoxId);
    97     CFSMailBoxBase::ConstructL(aMailBoxId);
    99 // </qmail>
    98 // </qmail>
   100 }
    99 }
   429     {
   428     {
   430     NM_FUNCTION;
   429     NM_FUNCTION;
   431 
   430 
   432     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   431     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   433         {
   432         {
   434         UpdateMrusL( aMessage.GetToRecipients(),
   433         UpdateMrus( aMessage.GetToRecipients() );
   435                      aMessage.GetCCRecipients(),
   434         UpdateMrus( aMessage.GetCCRecipients() );
   436                      aMessage.GetBCCRecipients() );
   435         UpdateMrus( aMessage.GetBCCRecipients() );
   437         plugin->SendMessageL( aMessage );
   436         plugin->SendMessageL( aMessage );
   438         }
   437         }
   439 	}
   438 	}
   440 
   439 
   441 // <qmail>
   440 // <qmail>
   452 
   451 
   453     CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() );
   452     CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() );
   454 
   453 
   455     if ( plugin )
   454     if ( plugin )
   456         {
   455         {
   457         UpdateMrusL( aMessage.GetToRecipients(),
   456         UpdateMrus( aMessage.GetToRecipients() );
   458                      aMessage.GetCCRecipients(),
   457         UpdateMrus( aMessage.GetCCRecipients() );
   459                      aMessage.GetBCCRecipients() );
   458         UpdateMrus( aMessage.GetBCCRecipients() );
   460 
       
   461 
   459 
   462         // init asynchronous request
   460         // init asynchronous request
   463         request = iRequestHandler->InitAsyncRequestL( GetId().PluginId(),
   461         request = iRequestHandler->InitAsyncRequestL( GetId().PluginId(),
   464                                                       aOperationObserver );
   462                                                       aOperationObserver );
   465 
   463 
   695 
   693 
   696 // -----------------------------------------------------------------------------
   694 // -----------------------------------------------------------------------------
   697 
   695 
   698 // -----------------------------------------------------------------------------
   696 // -----------------------------------------------------------------------------
   699 // -----------------------------------------------------------------------------
   697 // -----------------------------------------------------------------------------
   700 // CFSMailBox::UpdateMrusL
   698 // CFSMailBox::UpdateMrus
   701 // -----------------------------------------------------------------------------
   699 // -----------------------------------------------------------------------------
   702 void CFSMailBox::UpdateMrusL(
   700 void CFSMailBox::UpdateMrus(
   703     const RPointerArray<CFSMailAddress>& aRecipients,
   701     const RPointerArray<CFSMailAddress>& aRecipients ) const
   704     const RPointerArray<CFSMailAddress>& aCCRecipients,
       
   705     const RPointerArray<CFSMailAddress>& aBCCRecipients ) const
       
   706     {
   702     {
   707     NM_FUNCTION;
   703     NM_FUNCTION;
   708 
   704 
   709     QT_TRYCATCH_LEAVING({
   705     QT_TRYCATCH_LEAVING({
   710         TUint count( aRecipients.Count() );
   706 
       
   707     TUint count( aRecipients.Count() );
   711         TUint indexer( 0 );
   708         TUint indexer( 0 );
   712         while ( indexer < count )
   709         while ( indexer < count )
   713             {
   710             {
   714             TDesC& address(aRecipients[indexer]->GetEmailAddress() );
   711             TDesC& address(aRecipients[indexer]->GetEmailAddress() );
   715             TDesC& name(aRecipients[indexer]->GetDisplayName() );
   712             TDesC& name(aRecipients[indexer]->GetDisplayName() );
   716             QString qaddress = QString::fromUtf16(address.Ptr(), address.Length());
   713             QString qaddress = QString::fromUtf16(address.Ptr(), address.Length());
   717             QString qname = QString::fromUtf16(name.Ptr(), name.Length());
   714             QString qname = QString::fromUtf16(name.Ptr(), name.Length());
   718             iMru->updateMRU(qname, qaddress);
   715             iMru->updateMRU(qname, qaddress);
   719             indexer++;
   716             indexer++;
   720             }
   717             }
   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     });
   718     });
   747 
   719 
   748     }
   720     }
   749 
   721 
   750 // -----------------------------------------------------------------------------
   722 // -----------------------------------------------------------------------------