emailservices/emailserver/cmailhandlerplugin/src/cmailcpshandler.cpp
branchRCL_3
changeset 35 e64954c2c8e2
parent 34 cd2816114bd1
child 26 67369d1b217f
equal deleted inserted replaced
34:cd2816114bd1 35:e64954c2c8e2
    25 #include <emailobserverinterface.hrh>
    25 #include <emailobserverinterface.hrh>
    26 #include <emailobserverplugin.h>
    26 #include <emailobserverplugin.h>
    27 #include <memaildata.h>
    27 #include <memaildata.h>
    28 #include <memailmailboxdata.h>
    28 #include <memailmailboxdata.h>
    29 
    29 
       
    30 #include <scs/cleanuputils.h> // CleanupResetAndDestroyPushL
       
    31 
    30 #include "emailtrace.h"
    32 #include "emailtrace.h"
    31 #include "cfsmailclient.h"
    33 #include "cfsmailclient.h"
    32 #include "cfsmailbox.h"
    34 #include "cfsmailbox.h"
    33 #include "cfsmailfolder.h"
    35 #include "cfsmailfolder.h"
    34 #include "cmailcpshandler.h"
    36 #include "cmailcpshandler.h"
   128 void CMailCpsHandler::InitializeL()
   130 void CMailCpsHandler::InitializeL()
   129     {
   131     {
   130     FUNC_LOG;
   132     FUNC_LOG;
   131     // Get current configuration from settings interface,
   133     // Get current configuration from settings interface,
   132     // and pass it on to actual publisher interface
   134     // and pass it on to actual publisher interface
       
   135         
   133     iLiwIf->SetConfiguration( iSettings->Configuration() );
   136     iLiwIf->SetConfiguration( iSettings->Configuration() );
   134 
       
   135     TInt iiMax( iSettings->Mailboxes().Count() );
   137     TInt iiMax( iSettings->Mailboxes().Count() );
       
   138     INFO_1("iSettings->Mailboxes().Count() = %d", iiMax );
   136     for ( TInt ii = 0; ii < iiMax; ii++ )
   139     for ( TInt ii = 0; ii < iiMax; ii++ )
   137         {
   140         {
   138         CFSMailBox* mailbox( NULL );
   141         CFSMailBox* mailbox( NULL );
   139         mailbox = MailClient().GetMailBoxByUidL( iSettings->Mailboxes()[ii] );
   142         mailbox = MailClient().GetMailBoxByUidL( iSettings->Mailboxes()[ii] );
   140 
   143 
   141         TInt mailboxId(0);
   144         TInt mailboxId(0);
   142         if (mailbox)
   145         if (mailbox)
   143             {
   146             {
       
   147             CleanupStack::PushL( mailbox );
   144             mailboxId = mailbox->GetId().Id();
   148             mailboxId = mailbox->GetId().Id();
   145             }
   149             if ( mailboxId )
   146         if ( mailboxId )
   150                 {
   147             {
   151                 CMailMailboxDetails* mailboxDetails = CreateMailboxDetailsL( *mailbox );
   148             CleanupStack::PushL( mailbox );
   152                 CleanupStack::PushL( mailboxDetails );
   149             CMailMailboxDetails* mailboxDetails = CreateMailboxDetailsL( *mailbox );
   153     
   150             CleanupStack::PushL( mailboxDetails );
   154                 TBuf<KMaxDescLen> cid;
   151 
   155                 TInt next(1);
   152             TBuf<KMaxDescLen> cid;
   156     
   153             TInt next(1);
   157                 // Check if same mailbox is already in iAccountsArray once or more
   154 
   158                 for ( TInt i = 0; i < iAccountsArray.Count(); i++ )
   155             // Check if same mailbox is already in iAccountsArray once or more
   159                     {
   156             for ( TInt i = 0; i < iAccountsArray.Count(); i++ )
   160                     TInt id = (TInt)iAccountsArray[i]->iMailboxId.Id();
   157                 {
   161                     if (id == mailboxId)
   158                 TInt id = (TInt)iAccountsArray[i]->iMailboxId.Id();
   162                         {
   159                 if (id == mailboxId)
   163                         next++;
   160                     {
   164                         }
   161                     next++;
   165                     }
   162                     }
   166                 iSettings->GetContentId(mailboxId, next, cid);
   163                 }
   167                 mailboxDetails->SetWidgetInstance(cid);
   164             iSettings->GetContentId(mailboxId, next, cid);
   168                 iAccountsArray.AppendL( mailboxDetails );
   165             mailboxDetails->SetWidgetInstance(cid);
   169                 CleanupStack::Pop( mailboxDetails );
   166             iAccountsArray.AppendL( mailboxDetails );
   170                 }
   167             CleanupStack::Pop( mailboxDetails );
       
   168             CleanupStack::PopAndDestroy( mailbox );
   171             CleanupStack::PopAndDestroy( mailbox );
   169             }
   172             }
   170         }
   173         }
       
   174      INFO_1("iAccountsArray.Count() = %d", iAccountsArray.Count() );
   171     }
   175     }
   172 
   176 
   173 // ---------------------------------------------------------
   177 // ---------------------------------------------------------
   174 // CMailCpsHandler::InitializeExternalAccountsL
   178 // CMailCpsHandler::InitializeExternalAccountsL
   175 // ---------------------------------------------------------
   179 // ---------------------------------------------------------
   177 void CMailCpsHandler::InitializeExternalAccountsL()
   181 void CMailCpsHandler::InitializeExternalAccountsL()
   178     {
   182     {
   179     FUNC_LOG;
   183     FUNC_LOG;
   180     // Read external account data from settings
   184     // Read external account data from settings
   181     RPointerArray<CMailExternalAccount> extAccounts;
   185     RPointerArray<CMailExternalAccount> extAccounts;
   182     CleanupClosePushL( extAccounts );
   186     CleanupResetAndDestroyPushL( extAccounts );  // owning - GetExtMailboxesL transfers ownership
   183     iSettings->GetExtMailboxesL( extAccounts );
   187     iSettings->GetExtMailboxesL( extAccounts );
   184 
   188 
   185     // Delete removed plugins
   189     // Delete removed plugins
   186     RemoveUnusedPluginsL( extAccounts );
   190     RemoveUnusedPluginsL( extAccounts );
   187 
   191 
   190 
   194 
   191     // Set accounts under correct pluginProxies
   195     // Set accounts under correct pluginProxies
   192     SelectAndUpdateExtAccountsL( extAccounts );
   196     SelectAndUpdateExtAccountsL( extAccounts );
   193 
   197 
   194     __ASSERT_DEBUG( extAccounts.Count() == 0, Panic( ECmailHandlerPluginPanicNoFailedState ) );
   198     __ASSERT_DEBUG( extAccounts.Count() == 0, Panic( ECmailHandlerPluginPanicNoFailedState ) );
   195     CleanupStack::PopAndDestroy();
   199     CleanupStack::PopAndDestroy( &extAccounts );
   196     }
   200     }
   197 
   201 
   198 // ---------------------------------------------------------
   202 // ---------------------------------------------------------
   199 // CMailCpsHandler::RemoveUnusedPluginsL
   203 // CMailCpsHandler::RemoveUnusedPluginsL
   200 // ---------------------------------------------------------
   204 // ---------------------------------------------------------
   307     Reset();
   311     Reset();
   308     // Trying to keep callback interface non-leaving
   312     // Trying to keep callback interface non-leaving
   309     TRAP_IGNORE( InitializeL() );
   313     TRAP_IGNORE( InitializeL() );
   310     TRAP_IGNORE( InitializeExternalAccountsL() );
   314     TRAP_IGNORE( InitializeExternalAccountsL() );
   311     // Update widget contents after settings change
   315     // Update widget contents after settings change
       
   316     TInt count = iLiwIf->GetWidgetInstanceCount();
       
   317     for (TInt i = 0; i < count; i++ )
       
   318         {
       
   319         iLiwIf->SetUpdateNeeded( i, ETrue );
       
   320         }
   312     TRAP_IGNORE( UpdateFullL() );
   321     TRAP_IGNORE( UpdateFullL() );
   313     CleanWaitingForNewMailbox();
   322     CleanWaitingForNewMailbox();
   314     }
   323     }
   315 
   324 
   316 // ---------------------------------------------------------
   325 // ---------------------------------------------------------
       
   326 // CMailCpsHandler::SetUpdateNeeded
       
   327 // ---------------------------------------------------------
       
   328 //
       
   329 void CMailCpsHandler::SetUpdateNeeded( const TFSMailMsgId aMailbox )
       
   330     {
       
   331     FUNC_LOG;
       
   332     TInt count = iSettings->WidgetCountByMailbox( aMailbox.Id() );
       
   333     for (TInt i = 0; i < count; i++ )
       
   334         {
       
   335         TBuf<KMaxDescLen> cid;
       
   336         iSettings->GetContentId( aMailbox.Id(), i + 1, cid );
       
   337         iLiwIf->SetUpdateNeeded( iLiwIf->GetWidgetInstanceId( cid ), ETrue );
       
   338         }
       
   339     }
       
   340 
       
   341 // ---------------------------------------------------------
   317 // CMailCpsHandler::UpdateFullL
   342 // CMailCpsHandler::UpdateFullL
   318 // ---------------------------------------------------------
   343 // ---------------------------------------------------------
   319 //
   344 //
   320 void CMailCpsHandler::UpdateFullL()
   345 void CMailCpsHandler::UpdateFullL()
   321     {
   346     {
   322     FUNC_LOG;
   347     FUNC_LOG;
   323     for (TInt instance = 0; instance < iLiwIf->GetWidgetInstanceCount(); instance++)
   348     for (TInt instance = 0; instance < iLiwIf->GetWidgetInstanceCount(); instance++)
   324         {
   349         {
   325         if ( iLiwIf->AllowedToPublish(instance) )
   350         if ( iLiwIf->AllowedToPublish(instance) )
   326             {
   351             {
   327             UpdateMailboxesL(instance, iLiwIf->iInstIdList[instance]->Des());
   352             UpdateMailboxesL(instance, iLiwIf->iInstIdList[instance].iCid);
   328             }
   353             }
   329         }
   354         }
   330     }
   355     }
   331 
   356 
   332 // ---------------------------------------------------------
   357 // ---------------------------------------------------------
   342         {
   367         {
   343         // Publish its data
   368         // Publish its data
   344         plugin->UpdateAccountL( aContentId );
   369         plugin->UpdateAccountL( aContentId );
   345         }
   370         }
   346     else // handle internal accounts
   371     else // handle internal accounts
   347         {   
   372         {
   348         TInt row(1); // start from first row
   373         if ( iLiwIf->UpdateNeeded( aInstance ) )
   349         TInt mailbox(0);
   374             {
   350         TBool found( EFalse );
   375             TInt row(1); // start from first row
   351         // try to find mailbox with matching contentId
   376             TInt mailbox(0);
   352         for ( mailbox = 0; mailbox < iAccountsArray.Count(); mailbox++ )
   377             TBool found( EFalse );
   353             {
   378             // try to find mailbox with matching contentId
   354             if ( !aContentId.Compare( *iAccountsArray[mailbox]->iWidgetInstance ) )
   379             for ( mailbox = 0; mailbox < iAccountsArray.Count(); mailbox++ )
   355                 {
   380                 {
   356                 INFO_1("iAccountsArray.Count() == %d", iAccountsArray.Count());
   381                 if ( !aContentId.Compare( *iAccountsArray[mailbox]->iWidgetInstance ) )
   357                 found = ETrue;
   382                     {
   358                 break;
   383                     INFO_1("iAccountsArray[mailbox] mailbox = %d", mailbox);
   359                 }
   384                     found = ETrue;
   360             }
   385                     break;
   361 
   386                     }
   362         // if contentId found from array, update the mailbox
   387                 }
   363         if ( found )
   388 
   364             {
   389             // if contentId found from array, update the mailbox
   365             // Update fields from left to right
   390             if ( found )
   366             UpdateMailBoxIconL( mailbox, aInstance, row );
   391                 {
   367             UpdateMailboxNameL( mailbox, aInstance, row );
   392                  INFO_1("found = TRUE iAccountsArray.Count() == %d", iAccountsArray.Count());
   368             UpdateIndicatorIconL( mailbox, aInstance, row );
   393                 // Update fields from left to right
   369             row++;
   394                 UpdateMailBoxIconL( mailbox, aInstance, row );
   370             UpdateMessagesL( mailbox, aInstance, 1, row);
   395                 UpdateMailboxNameL( mailbox, aInstance, row );
   371             row++;
   396                 UpdateIndicatorIconL( mailbox, aInstance, row );
   372             UpdateMessagesL( mailbox, aInstance, 2, row);
   397                 row++;
   373             }
   398                 UpdateMessagesL( mailbox, aInstance, 1, row);
   374         else
   399                 row++;
   375             {
   400                 UpdateMessagesL( mailbox, aInstance, 2, row);
   376             // Clean mailbox name
   401                 }
   377             iLiwIf->PublishActiveMailboxNameL( aInstance, 1, KNullDesC );
   402             else
   378             // Clean mailbox icon
   403                 {
   379             TFSMailMsgId mailBoxId; // id not essential here        
   404                 INFO_1("found = FALSE iAccountsArray.Count() == %d", iAccountsArray.Count());
   380             iLiwIf->PublishMailboxIconL( aInstance, 1, KNullIcon, mailBoxId);
   405                 // Clean mailbox name
   381             // Clean indicator icon
   406                 iLiwIf->PublishActiveMailboxNameL( aInstance, 1, KNullDesC );
   382             iLiwIf->PublishIndicatorIconL( aInstance, 1, KNullIcon);
   407                 // Clean mailbox icon
   383             // Clean message rows
   408                 TFSMailMsgId mailBoxId; // id not essential here        
   384             UpdateEmptyMessagesL( aInstance, 2 );
   409                 iLiwIf->PublishMailboxIconL( aInstance, 1, KNullIcon, mailBoxId);
   385             UpdateEmptyMessagesL( aInstance, 3 );
   410                 // Clean indicator icon
       
   411                 iLiwIf->PublishIndicatorIconL( aInstance, 1, KNullIcon);
       
   412                 // Clean message rows
       
   413                 UpdateEmptyMessagesL( aInstance, 2 );
       
   414                 UpdateEmptyMessagesL( aInstance, 3 );
       
   415                 }
       
   416             iLiwIf->SetUpdateNeeded( aInstance, EFalse );
   386             }
   417             }
   387         }
   418         }
   388     }
   419     }
   389 
   420 
   390 // ---------------------------------------------------------
   421 // ---------------------------------------------------------
   476         {
   507         {
   477         TFSMailMsgId mailBoxId;
   508         TFSMailMsgId mailBoxId;
   478         mailBoxId = iAccountsArray[aMailBoxNumber]->iMailboxId;
   509         mailBoxId = iAccountsArray[aMailBoxNumber]->iMailboxId;
   479 
   510 
   480         CFSMailBox* mailbox( NULL );
   511         CFSMailBox* mailbox( NULL );
   481         mailbox = MailClient().GetMailBoxByUidL( mailBoxId );
   512         mailbox = MailClient().GetMailBoxByUidL( mailBoxId ); // transferred ownership
   482         if(mailbox)
   513         if(mailbox)
   483             {
   514             {
   484             TFSMailMsgId parentFolder( mailbox->GetStandardFolderId( EFSInbox ) );
   515             TFSMailMsgId parentFolder( mailbox->GetStandardFolderId( EFSInbox ) );
       
   516             delete mailbox;
   485             // Check that folder is correct
   517             // Check that folder is correct
   486             CFSMailFolder* folder = MailClient().GetFolderByUidL( mailBoxId, parentFolder );
   518             CFSMailFolder* folder = MailClient().GetFolderByUidL( mailBoxId, parentFolder );
   487             if ( !folder )
   519             if ( !folder )
   488                 {
   520                 {
   489 				UpdateEmptyMessagesL( aWidgetInstance, aRow );
   521 				UpdateEmptyMessagesL( aWidgetInstance, aRow );
   502 
   534 
   503             folder->SetFolderType(EFSInbox);
   535             folder->SetFolderType(EFSInbox);
   504 
   536 
   505             // Update folder if provided, otherwise use current folder
   537             // Update folder if provided, otherwise use current folder
   506             RPointerArray<CFSMailMessage> folderMessages(1);
   538             RPointerArray<CFSMailMessage> folderMessages(1);
   507             CleanupClosePushL( folderMessages );
   539             CleanupResetAndDestroyPushL( folderMessages ); // owning array, from emailapiutils.h
   508 
   540 
   509             TFSMailDetails details( EFSMsgDataEnvelope );
   541             TFSMailDetails details( EFSMsgDataEnvelope );
   510             RArray<TFSMailSortCriteria> sorting;
   542             RArray<TFSMailSortCriteria> sorting;
   511             CleanupClosePushL( sorting );
   543             CleanupClosePushL( sorting );
   512 
   544 
   527 
   559 
   528                 CleanupStack::PopAndDestroy( iterator );
   560                 CleanupStack::PopAndDestroy( iterator );
   529                 CleanupStack::PopAndDestroy( &sorting );
   561                 CleanupStack::PopAndDestroy( &sorting );
   530                 CleanupStack::PopAndDestroy( &folderMessages );
   562                 CleanupStack::PopAndDestroy( &folderMessages );
   531                 CleanupStack::PopAndDestroy( folder );
   563                 CleanupStack::PopAndDestroy( folder );
   532 
       
   533                 return;
   564                 return;
   534                 }
   565                 }
   535             TFSMailMsgId msgId = folderMessages[aMessageNumber - 1]->GetMessageId();
   566             TFSMailMsgId msgId = folderMessages[aMessageNumber - 1]->GetMessageId();
   536 
   567 
   537             CFSMailMessage* msg( NULL );
   568             CFSMailMessage* msg( NULL );
   731     if ( aMailBoxNumber < iAccountsArray.Count() )
   762     if ( aMailBoxNumber < iAccountsArray.Count() )
   732         {
   763         {
   733         TFSMailMsgId mailBoxId;
   764         TFSMailMsgId mailBoxId;
   734         mailBoxId = iAccountsArray[aMailBoxNumber]->iMailboxId;
   765         mailBoxId = iAccountsArray[aMailBoxNumber]->iMailboxId;
   735 
   766 
   736         if ( iSettings->GetNewMailState( mailBoxId ) )
   767         if ( iSettings->GetNewMailStateL( mailBoxId, GetUnreadCountL(mailBoxId) ) )
   737             {
   768             {
   738             iLiwIf->PublishIndicatorIconL( aWidgetInstance,
   769             iLiwIf->PublishIndicatorIconL( aWidgetInstance,
   739                                            aRowNumber,
   770                                            aRowNumber,
   740                                            EMbmCmailhandlerpluginQgn_stat_message_mail_uni );
   771                                            EMbmCmailhandlerpluginQgn_stat_message_mail_uni );
   741             }
   772             }
   742 
       
   743         else if( !IsOutboxEmptyL(mailBoxId) )
   773         else if( !IsOutboxEmptyL(mailBoxId) )
   744             {
   774             {
   745             iLiwIf->PublishIndicatorIconL( aWidgetInstance,
   775             iLiwIf->PublishIndicatorIconL( aWidgetInstance,
   746                                            aRowNumber,
   776                                            aRowNumber,
   747                                            EMbmCmailhandlerpluginQgn_indi_cmail_outbox_msg);
   777                                            EMbmCmailhandlerpluginQgn_indi_cmail_outbox_msg);
   818             break;
   848             break;
   819             }
   849             }
   820         case TFSEventMailboxRenamed:
   850         case TFSEventMailboxRenamed:
   821             {
   851             {
   822             HandleMailboxRenamedEventL( aMailbox );
   852             HandleMailboxRenamedEventL( aMailbox );
       
   853             SetUpdateNeeded( aMailbox );
   823             UpdateFullL();
   854             UpdateFullL();
   824             break;
   855             break;
   825             }
   856             }
   826         case TFSEventMailboxDeleted:
   857         case TFSEventMailboxDeleted:
   827             {
   858             {
   828             HandleMailboxDeletedEventL( aMailbox );
   859             HandleMailboxDeletedEventL( aMailbox );
       
   860             SetUpdateNeeded( aMailbox );
   829             UpdateFullL();
   861             UpdateFullL();
   830             break;
   862             break;
   831             }
   863             }
   832         case TFSEventNewMail:
   864         case TFSEventNewMail:
   833             {
   865             {
   834             HandleNewMailEventL( aMailbox, aParam1, aParam2 );
   866             HandleNewMailEventL( aMailbox, aParam1, aParam2 );
       
   867             SetUpdateNeeded( aMailbox );
   835             UpdateFullL();
   868             UpdateFullL();
   836             break;
   869             break;
   837             }
   870             }
   838         case TFSEventMailDeleted:
   871         case TFSEventMailDeleted:
   839             {
   872             {
   840             HandleMailDeletedEventL( aMailbox, aParam1, aParam2 );
   873             HandleMailDeletedEventL( aMailbox, aParam1, aParam2 );
       
   874             SetUpdateNeeded( aMailbox );
   841             UpdateFullL();
   875             UpdateFullL();
   842             break;
   876             break;
   843             }
   877             }
       
   878         case TFSEventMailChanged:
       
   879             {
       
   880             SetUpdateNeeded( aMailbox );
       
   881             UpdateFullL();
       
   882             break;
       
   883             }            
   844         default:
   884         default:
   845             {
   885             {
   846             break;
   886             break;
   847             }
   887             }
   848         }
   888         }
  1081     TInt unread (0);
  1121     TInt unread (0);
  1082     mailbox = MailClient().GetMailBoxByUidL( aMailbox );
  1122     mailbox = MailClient().GetMailBoxByUidL( aMailbox );
  1083     if(mailbox)
  1123     if(mailbox)
  1084         {
  1124         {
  1085         TFSMailMsgId folderId( mailbox->GetStandardFolderId( EFSInbox ) );
  1125         TFSMailMsgId folderId( mailbox->GetStandardFolderId( EFSInbox ) );
       
  1126         delete mailbox; // transferred ownership
  1086         // Check that folder is correct
  1127         // Check that folder is correct
  1087         CFSMailFolder* folder = MailClient().GetFolderByUidL( aMailbox, folderId );
  1128         CFSMailFolder* folder = MailClient().GetFolderByUidL( aMailbox, folderId );
  1088         if ( !folder )
  1129         if ( !folder )
  1089             {
  1130             {
  1090             return KErrNotFound;
  1131             return KErrNotFound;
  1115     TInt unseen (0);
  1156     TInt unseen (0);
  1116     mailbox = MailClient().GetMailBoxByUidL( aMailbox );
  1157     mailbox = MailClient().GetMailBoxByUidL( aMailbox );
  1117     if(mailbox)
  1158     if(mailbox)
  1118         {
  1159         {
  1119         TFSMailMsgId folderId( mailbox->GetStandardFolderId( EFSInbox ) );
  1160         TFSMailMsgId folderId( mailbox->GetStandardFolderId( EFSInbox ) );
       
  1161         delete mailbox; // transferred ownership
  1120         // Check that folder is correct
  1162         // Check that folder is correct
  1121         CFSMailFolder* folder = MailClient().GetFolderByUidL( aMailbox, folderId );
  1163         CFSMailFolder* folder = MailClient().GetFolderByUidL( aMailbox, folderId );
  1122         if ( !folder )
  1164         if ( !folder )
  1123             {
  1165             {
  1124             return KErrNotFound;
  1166             return KErrNotFound;
  1150     TInt msgCount(0);
  1192     TInt msgCount(0);
  1151     mailbox = MailClient().GetMailBoxByUidL( aMailbox );
  1193     mailbox = MailClient().GetMailBoxByUidL( aMailbox );
  1152     if(mailbox)
  1194     if(mailbox)
  1153         {
  1195         {
  1154         TFSMailMsgId folderId( mailbox->GetStandardFolderId( EFSOutbox ) );
  1196         TFSMailMsgId folderId( mailbox->GetStandardFolderId( EFSOutbox ) );
       
  1197         delete mailbox; // ownership was transferred
  1155         // Check that folder is correct
  1198         // Check that folder is correct
  1156         CFSMailFolder* folder = MailClient().GetFolderByUidL( aMailbox, folderId );
  1199         CFSMailFolder* folder = MailClient().GetFolderByUidL( aMailbox, folderId );
  1157         if ( !folder )
  1200         if ( !folder )
  1158             {
  1201             {
  1159             return KErrNotFound;
  1202             return KErrNotFound;
  1179         MFSMailIterator* iterator = folder->ListMessagesL( details, sorting );
  1222         MFSMailIterator* iterator = folder->ListMessagesL( details, sorting );
  1180         CleanupStack::PopAndDestroy( &sorting );
  1223         CleanupStack::PopAndDestroy( &sorting );
  1181         CleanupDeletePushL( iterator );
  1224         CleanupDeletePushL( iterator );
  1182 
  1225 
  1183         RPointerArray<CFSMailMessage> messages;
  1226         RPointerArray<CFSMailMessage> messages;
  1184         CleanupClosePushL( messages );
  1227         CleanupResetAndDestroyPushL( messages ); // owning array
  1185         iterator->NextL( TFSMailMsgId(), msgCount, messages );
  1228         iterator->NextL( TFSMailMsgId(), msgCount, messages );
  1186 
  1229 
  1187         TInt arrayCount(messages.Count());
  1230         TInt arrayCount(messages.Count());
  1188         for (TInt i = 0; i < arrayCount; i++)
  1231         for (TInt i = 0; i < arrayCount; i++)
  1189             {
  1232             {
  1772     {
  1815     {
  1773     FUNC_LOG;
  1816     FUNC_LOG;
  1774     TInt totalMailboxCount( 0 );
  1817     TInt totalMailboxCount( 0 );
  1775     TUid interfaceUid = TUid::Uid( KEmailObserverInterfaceUid );
  1818     TUid interfaceUid = TUid::Uid( KEmailObserverInterfaceUid );
  1776     RImplInfoPtrArray plugins;
  1819     RImplInfoPtrArray plugins;
  1777     CleanupClosePushL( plugins );
  1820     CleanupResetAndDestroyPushL(plugins); // CleanupClosePushL does not call ptr destructors
  1778     REComSession::ListImplementationsL( interfaceUid, plugins);
  1821     REComSession::ListImplementationsL( interfaceUid, plugins);
  1779 
  1822 
  1780     for ( TInt i = 0; i < plugins.Count(); i++ )
  1823     for ( TInt i = 0; i < plugins.Count(); i++ )
  1781         {
  1824         {
  1782         TUid implUid = plugins[i]->ImplementationUid();
  1825         TUid implUid = plugins[i]->ImplementationUid();
  1785             EmailInterface::CEmailObserverPlugin::NewL( implUid, this );
  1828             EmailInterface::CEmailObserverPlugin::NewL( implUid, this );
  1786         MEmailData& data( plugin->EmailDataL() );
  1829         MEmailData& data( plugin->EmailDataL() );
  1787         totalMailboxCount += data.MailboxesL().Count();
  1830         totalMailboxCount += data.MailboxesL().Count();
  1788         }
  1831         }
  1789 
  1832 
  1790     CleanupStack::PopAndDestroy(); // plugins
  1833     CleanupStack::PopAndDestroy( &plugins ); // plugins
  1791     return totalMailboxCount;
  1834     return totalMailboxCount;
  1792     }
  1835     }
  1793 
  1836 
  1794 // ---------------------------------------------------------------------------
  1837 // ---------------------------------------------------------------------------
  1795 // CMailCpsHandler::EmailObserverEvent
  1838 // CMailCpsHandler::EmailObserverEvent