emailservices/emailcommon/src/CFSMailBox.cpp
changeset 20 ecc8def7944a
parent 18 578830873419
child 30 759dc5235cdb
equal deleted inserted replaced
18:578830873419 20:ecc8def7944a
     1 /*
     1 /*
     2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). 
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    13 *
    13 *
    14 * Description:  common mailbox object
    14 * Description:  common mailbox object
    15 *
    15 *
    16 */
    16 */
    17 
    17 
       
    18 // <qmail>
    18 #include <nmcommonheaders.h>
    19 #include <nmcommonheaders.h>
       
    20 // <//qmail>
    19 
    21 
    20 #include "emailtrace.h"
    22 #include "emailtrace.h"
       
    23 #include <bamdesca.h>
    21 #include "CFSMailPlugin.h"
    24 #include "CFSMailPlugin.h"
       
    25 #include "cmrcalendarinfoimpl.h"
    22 #include "CFSMailBox.h"
    26 #include "CFSMailBox.h"
    23 #include "CFSMailRequestObserver.h"
    27 #include "CFSMailRequestObserver.h"
       
    28 #include "cmailboxstateext.h"
    24 // <qmail>
    29 // <qmail>
    25 #include "CFSMailFolder.h"
    30 #include "CFSMailFolder.h"
    26 #include "CFSMailAddress.h"
    31 #include "CFSMailAddress.h"
    27 // </qmail>
    32 // </qmail>
    28 
    33 
    30 
    35 
    31 // ================= MEMBER FUNCTIONS ==========================================
    36 // ================= MEMBER FUNCTIONS ==========================================
    32 // -----------------------------------------------------------------------------
    37 // -----------------------------------------------------------------------------
    33 // CFSMailBox::NewLC
    38 // CFSMailBox::NewLC
    34 // -----------------------------------------------------------------------------
    39 // -----------------------------------------------------------------------------
    35 EXPORT_C CFSMailBox* CFSMailBox::NewLC( TFSMailMsgId aMailBoxId )
    40 EXPORT_C CFSMailBox* CFSMailBox::NewLC(TFSMailMsgId aMailBoxId)
    36 {
    41 {
    37     FUNC_LOG;
    42     FUNC_LOG;
    38     CFSMailBox* api = new (ELeave) CFSMailBox();
    43   CFSMailBox* api = new (ELeave) CFSMailBox();
    39     CleanupStack:: PushL(api);
    44   CleanupStack:: PushL(api);
    40     api->ConstructL(aMailBoxId);
    45   api->ConstructL(aMailBoxId);
    41     return api;
    46   return api;
    42 } 
    47 } 
    43 
    48 
    44 // -----------------------------------------------------------------------------
    49 // -----------------------------------------------------------------------------
    45 // CFSMailBox::NewL
    50 // CFSMailBox::NewL
    46 // -----------------------------------------------------------------------------
    51 // -----------------------------------------------------------------------------
    47 EXPORT_C CFSMailBox* CFSMailBox::NewL( TFSMailMsgId aMailBoxId )
    52 EXPORT_C CFSMailBox* CFSMailBox::NewL(TFSMailMsgId aMailBoxId)
    48 {
    53 {
    49     FUNC_LOG;
    54     FUNC_LOG;
    50     CFSMailBox* api =  CFSMailBox::NewLC(aMailBoxId);
    55   CFSMailBox* api =  CFSMailBox::NewLC(aMailBoxId);
    51     CleanupStack:: Pop(api);
    56   CleanupStack:: Pop(api);
    52     return api;
    57   return api;
    53 }
    58 }
    54 
    59 
    55 // -----------------------------------------------------------------------------
    60 // -----------------------------------------------------------------------------
    56 // CFSMailBox::CFSMailBox
    61 // CFSMailBox::CFSMailBox
    57 // -----------------------------------------------------------------------------
    62 // -----------------------------------------------------------------------------
    72 }
    77 }
    73 
    78 
    74 // -----------------------------------------------------------------------------
    79 // -----------------------------------------------------------------------------
    75 // CFSMailBox::ConstructL
    80 // CFSMailBox::ConstructL
    76 // -----------------------------------------------------------------------------
    81 // -----------------------------------------------------------------------------
    77 void CFSMailBox::ConstructL( TFSMailMsgId aMailBoxId )
    82 void CFSMailBox::ConstructL(TFSMailMsgId aMailBoxId)
    78 {
    83 {
    79     FUNC_LOG;
    84     FUNC_LOG;
       
    85 // <qmail>
    80     CFSMailBoxBase::ConstructL(aMailBoxId);
    86     CFSMailBoxBase::ConstructL(aMailBoxId);
       
    87 // </qmail>
    81 }
    88 }
    82 
    89 
    83 // -----------------------------------------------------------------------------
    90 // -----------------------------------------------------------------------------
    84 // CFSMailBox::GoOnlineL
    91 // CFSMailBox::GoOnlineL
    85 // -----------------------------------------------------------------------------
    92 // -----------------------------------------------------------------------------
    86 EXPORT_C void CFSMailBox::GoOnlineL()
    93 EXPORT_C void CFSMailBox::GoOnlineL()
    87 {
    94     {
    88     FUNC_LOG;  
    95     FUNC_LOG;
       
    96     
    89     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
    97     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
    90         {
    98         {
    91         plugin->GoOnlineL( GetId() );
    99         plugin->GoOnlineL( GetId() );
    92         }
   100         }
    93 }
   101     }
    94 
   102 
    95 // -----------------------------------------------------------------------------
   103 // -----------------------------------------------------------------------------
    96 // CFSMailBox::GoOfflineL
   104 // CFSMailBox::GoOfflineL
    97 // -----------------------------------------------------------------------------
   105 // -----------------------------------------------------------------------------
    98 EXPORT_C void CFSMailBox::GoOfflineL()
   106 EXPORT_C void CFSMailBox::GoOfflineL()
    99 {
   107     {
   100     FUNC_LOG;    
   108     FUNC_LOG;
       
   109     
   101     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   110     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   102         {
   111         {
   103         plugin->GoOfflineL( GetId() );
   112         plugin->GoOfflineL( GetId() );
   104         }
   113         }
   105 }
   114         
       
   115     }
   106 
   116 
   107 // -----------------------------------------------------------------------------
   117 // -----------------------------------------------------------------------------
   108 // CFSMailBox::CancelSyncL
   118 // CFSMailBox::CancelSyncL
   109 // -----------------------------------------------------------------------------
   119 // -----------------------------------------------------------------------------
   110 EXPORT_C void CFSMailBox::CancelSyncL()
   120 EXPORT_C void CFSMailBox::CancelSyncL()
   111 {
   121     {
   112     FUNC_LOG;  
   122     FUNC_LOG;
       
   123     
   113     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   124     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   114         {
   125         {
   115         plugin->CancelSyncL( GetId() );
   126         plugin->CancelSyncL( GetId() );
   116         }
   127         }
   117 }
   128     }
   118 
   129 
   119 // -----------------------------------------------------------------------------
   130 // -----------------------------------------------------------------------------
   120 // CFSMailBox::GetLastSyncStatusL
   131 // CFSMailBox::GetLastSyncStatusL
   121 // -----------------------------------------------------------------------------
   132 // -----------------------------------------------------------------------------
   122 EXPORT_C TFSProgress CFSMailBox::GetLastSyncStatusL()
   133 EXPORT_C TFSProgress CFSMailBox::GetLastSyncStatusL()
   123 {
   134     {
   124     FUNC_LOG;
   135     FUNC_LOG;
   125     TFSProgress progress;
   136     TFSProgress progress;
   126     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   137     progress.iError = EFalse;
   127         {
   138     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   128         progress = plugin->GetLastSyncStatusL( GetId() );   
   139         {
       
   140         progress = plugin->GetLastSyncStatusL( GetId() );       
   129         }
   141         }
   130     return progress;
   142     return progress;
   131 }
   143     }
   132 
   144 
   133 // -----------------------------------------------------------------------------
   145 // -----------------------------------------------------------------------------
   134 // CFSMailBox::RefreshNowL
   146 // CFSMailBox::RefreshNowL
   135 // -----------------------------------------------------------------------------
   147 // -----------------------------------------------------------------------------
   136 EXPORT_C TInt CFSMailBox::RefreshNowL(
   148 EXPORT_C TInt CFSMailBox::RefreshNowL(
   137     MFSMailRequestObserver& aOperationObserver )
   149     MFSMailRequestObserver& aOperationObserver )
   138 {
   150     {
   139     FUNC_LOG;
   151     FUNC_LOG;
   140 
   152 
   141     TFSPendingRequest request;
   153     TFSPendingRequest request;
       
   154     request.iRequestId = 0;
   142     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   155     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   143         {
   156         {
   144         // init asynchronous request
   157         // init asynchronous request
   145         request = iRequestHandler->InitAsyncRequestL( GetId().PluginId(),
   158         request = iRequestHandler->InitAsyncRequestL( GetId().PluginId(),
   146                               aOperationObserver );
   159                                                         aOperationObserver );
   147         MFSMailRequestObserver* observer = request.iObserver;
   160         MFSMailRequestObserver* observer = request.iObserver;
   148         TRAPD(err,plugin->RefreshNowL( GetId(), *observer, request.iRequestId));
   161         TRAPD(err,plugin->RefreshNowL( GetId(), *observer, request.iRequestId));
   149         if(err != KErrNone)
   162         if(err != KErrNone)
   150             {
   163             {
   151             iRequestHandler->CompleteRequest(request.iRequestId);
   164             iRequestHandler->CompleteRequest(request.iRequestId);
   152             User::Leave(err);
   165             User::Leave(err);
   153             }
   166             }
   154         }
   167         }
   155     return request.iRequestId;
   168     return request.iRequestId;
   156 }
   169 
       
   170    }
   157 
   171 
   158 // -----------------------------------------------------------------------------
   172 // -----------------------------------------------------------------------------
   159 // CFSMailBox::RefreshNowL
   173 // CFSMailBox::RefreshNowL
   160 // -----------------------------------------------------------------------------
   174 // -----------------------------------------------------------------------------
   161 EXPORT_C TInt CFSMailBox::RefreshNowL()
   175 EXPORT_C TInt CFSMailBox::RefreshNowL( )
   162 {
   176     {
   163     FUNC_LOG;
   177     FUNC_LOG;
   164 
   178 
   165     TFSPendingRequest request;
   179     TFSPendingRequest request;
       
   180     request.iRequestId = 0;
   166     MFSMailRequestObserver* observer = NULL;
   181     MFSMailRequestObserver* observer = NULL;
   167     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   182     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   168         {
   183         {
   169         // init asynchronous request
   184         // init asynchronous request
   170         request = iRequestHandler->InitAsyncRequestL( GetId().PluginId(), *observer );
   185         request = iRequestHandler->InitAsyncRequestL( GetId().PluginId(), *observer );
   171       
   186         
   172         observer = request.iObserver;
   187         observer = request.iObserver;
   173         TRAPD(err,plugin->RefreshNowL( GetId(), *observer, request.iRequestId));
   188         TRAPD(err,plugin->RefreshNowL( GetId(), *observer, request.iRequestId));
   174         if(err != KErrNone)
   189         if(err != KErrNone)
   175         {
   190             {
   176             iRequestHandler->CompleteRequest(request.iRequestId);
   191             iRequestHandler->CompleteRequest(request.iRequestId);
   177             User::Leave(err);
   192             User::Leave(err);
   178         }
   193             }
   179     }
   194         }
   180     return request.iRequestId;
   195     return request.iRequestId;
   181 }
   196 
       
   197    }
   182 
   198 
   183 // -----------------------------------------------------------------------------
   199 // -----------------------------------------------------------------------------
   184 // CFSMailBox::CreateMessageToSend
   200 // CFSMailBox::CreateMessageToSend
   185 // -----------------------------------------------------------------------------
   201 // -----------------------------------------------------------------------------
   186 EXPORT_C CFSMailMessage* CFSMailBox::CreateMessageToSend()
   202 EXPORT_C CFSMailMessage* CFSMailBox::CreateMessageToSend( )
   187 {
   203 {
   188     FUNC_LOG;
   204     FUNC_LOG;
   189 
   205 
   190     CFSMailMessage* message = NULL;
   206     CFSMailMessage* message = NULL;
   191     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   207     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   277 //</qmail>
   293 //</qmail>
   278 
   294 
   279 // -----------------------------------------------------------------------------
   295 // -----------------------------------------------------------------------------
   280 // CFSMailBox::CreateForwardMessage
   296 // CFSMailBox::CreateForwardMessage
   281 // -----------------------------------------------------------------------------
   297 // -----------------------------------------------------------------------------
   282 EXPORT_C CFSMailMessage* CFSMailBox::CreateForwardMessage( TFSMailMsgId aOriginalMessageId,
   298 EXPORT_C CFSMailMessage* CFSMailBox::CreateForwardMessage(  TFSMailMsgId aOriginalMessageId,
   283                               const TDesC& aHeaderDescriptor )
   299                                                             const TDesC& aHeaderDescriptor )
   284 {
   300 {
   285     FUNC_LOG;
   301     FUNC_LOG;
   286     CFSMailMessage* message = NULL;
   302     CFSMailMessage* message = NULL;
   287     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   303     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   288         {
   304         {
   289         TRAPD(err,message = plugin->CreateForwardMessageL( GetId(), 
   305         TRAPD(err,message = plugin->CreateForwardMessageL( GetId(), 
   290                                 aOriginalMessageId,
   306                                                                 aOriginalMessageId,
   291                                 aHeaderDescriptor ));
   307                                                                 aHeaderDescriptor ));
   292         if(err != KErrNone)
   308         if(err != KErrNone)
   293             {
   309             {
   294             message = NULL;
   310             message = NULL;
   295             }
   311             }
   296         }
   312         }
   337 
   353 
   338 // -----------------------------------------------------------------------------
   354 // -----------------------------------------------------------------------------
   339 // CFSMailBox::CreateReplyMessage
   355 // CFSMailBox::CreateReplyMessage
   340 // -----------------------------------------------------------------------------
   356 // -----------------------------------------------------------------------------
   341 EXPORT_C CFSMailMessage* CFSMailBox::CreateReplyMessage( TFSMailMsgId aOriginalMessageId,
   357 EXPORT_C CFSMailMessage* CFSMailBox::CreateReplyMessage( TFSMailMsgId aOriginalMessageId,
   342                              TBool aReplyToAll,
   358                                                          TBool aReplyToAll,
   343                              const TDesC& aHeaderDescriptor )
   359                                                          const TDesC& aHeaderDescriptor )
   344 {
   360 {
   345     FUNC_LOG;
   361     FUNC_LOG;
   346     CFSMailMessage* message = NULL;
   362     CFSMailMessage* message = NULL;
   347     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   363     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   348         {
   364         {
   349         TRAPD(err,message = plugin->CreateReplyMessageL( GetId(),
   365         TRAPD(err,message = plugin->CreateReplyMessageL( GetId(),
   350                               aOriginalMessageId,
   366                                                             aOriginalMessageId,
   351                               aReplyToAll,
   367                                                             aReplyToAll,
   352                               aHeaderDescriptor ));
   368                                                             aHeaderDescriptor ));
   353         if(err != KErrNone)
   369         if(err != KErrNone)
   354             {
   370             {
   355             message = NULL;
   371             message = NULL;
   356             }
   372             }
   357     }
   373         }
   358     return message;
   374     return message;
   359 }
   375 }
   360 
   376 
   361 // <qmail>
   377 // <qmail>
   362 // -----------------------------------------------------------------------------
   378 // -----------------------------------------------------------------------------
   398 // </qmail>
   414 // </qmail>
   399 
   415 
   400 // -----------------------------------------------------------------------------
   416 // -----------------------------------------------------------------------------
   401 // CFSMailBox::GetStandardFolderId
   417 // CFSMailBox::GetStandardFolderId
   402 // -----------------------------------------------------------------------------
   418 // -----------------------------------------------------------------------------
   403 EXPORT_C TFSMailMsgId CFSMailBox::GetStandardFolderId( TFSFolderType aFolderType )
   419 EXPORT_C TFSMailMsgId CFSMailBox::GetStandardFolderId(TFSFolderType aFolderType)
   404 {
   420 {
   405     FUNC_LOG;
   421     FUNC_LOG;
   406 
   422 
   407     TFSMailMsgId folderId;
   423     TFSMailMsgId folderId;
   408     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   424     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   418 
   434 
   419 // -----------------------------------------------------------------------------
   435 // -----------------------------------------------------------------------------
   420 // CFSMailBox::SendMessageL
   436 // CFSMailBox::SendMessageL
   421 // -----------------------------------------------------------------------------
   437 // -----------------------------------------------------------------------------
   422 EXPORT_C void CFSMailBox::SendMessageL( CFSMailMessage& aMessage )
   438 EXPORT_C void CFSMailBox::SendMessageL( CFSMailMessage& aMessage )
   423 {
   439     {
   424     FUNC_LOG;
   440     FUNC_LOG;
   425     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   441     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   426         {
   442         {
   427         // <qmail> Not activated yet.
   443         // <qmail> Not activated yet.
   428         //UpdateMrusL( aMessage.GetToRecipients(),
   444         //UpdateMrusL( aMessage.GetToRecipients(),
   429         //         aMessage.GetCCRecipients(),
   445         //         aMessage.GetCCRecipients(),
   430         //       aMessage.GetBCCRecipients() );
   446         //       aMessage.GetBCCRecipients() );
   431         // </qmail>
   447         // </qmail>
   432         plugin->SendMessageL( aMessage );
   448         plugin->SendMessageL( aMessage );
   433         }
   449         }
   434 }
   450 	}
   435 
   451 
   436 // <qmail>
   452 // <qmail>
   437 // -----------------------------------------------------------------------------
   453 // -----------------------------------------------------------------------------
   438 // CFSMailBox::SendMessageL
   454 // CFSMailBox::SendMessageL
   439 // -----------------------------------------------------------------------------
   455 // -----------------------------------------------------------------------------
   481 
   497 
   482 // -----------------------------------------------------------------------------
   498 // -----------------------------------------------------------------------------
   483 // CFSMailBox::ListFolders
   499 // CFSMailBox::ListFolders
   484 // -----------------------------------------------------------------------------
   500 // -----------------------------------------------------------------------------
   485 EXPORT_C void CFSMailBox::ListFolders(  TFSMailMsgId aFolder,
   501 EXPORT_C void CFSMailBox::ListFolders(  TFSMailMsgId aFolder,
   486                     RPointerArray<CFSMailFolder>& aFolderList )
   502                                         RPointerArray<CFSMailFolder>& aFolderList)
   487 {
   503 {
   488     FUNC_LOG;
   504     FUNC_LOG;
   489 
   505 
   490     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   506     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   491         {
   507     {
   492         TRAPD(err, plugin->ListFoldersL(GetId(),aFolder,aFolderList));
   508         TRAPD(err, plugin->ListFoldersL(GetId(),aFolder,aFolderList));
   493         if(err != KErrNone)
   509         if(err != KErrNone)
   494             {
   510             {
   495             aFolderList.ResetAndDestroy();
   511             aFolderList.ResetAndDestroy();
   496             }
   512             }
   497         }
   513     }
   498 }
   514 }
   499 
   515 
   500 // -----------------------------------------------------------------------------
   516 // -----------------------------------------------------------------------------
   501 // CFSMailBox::ListFolders
   517 // CFSMailBox::ListFolders
   502 // -----------------------------------------------------------------------------
   518 // -----------------------------------------------------------------------------
   503 EXPORT_C RPointerArray<CFSMailFolder>& CFSMailBox::ListFolders()
   519 EXPORT_C RPointerArray<CFSMailFolder>& CFSMailBox::ListFolders( )
   504 { 
   520 {   
   505     iFolders.ResetAndDestroy();
   521     iFolders.ResetAndDestroy();
   506     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   522     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   507         {
   523     {
   508         TRAPD(err,plugin->ListFoldersL(GetId(),iFolders));
   524         TRAPD(err,plugin->ListFoldersL(GetId(),iFolders));
   509         if(err != KErrNone)
   525         if(err != KErrNone)
   510             {
   526             {
   511             iFolders.ResetAndDestroy();
   527             iFolders.ResetAndDestroy();
   512             }
   528             }
   513         }
   529     }
       
   530 
   514     return iFolders;
   531     return iFolders;
   515 }
   532 }
   516 
   533 
   517 // -----------------------------------------------------------------------------
   534 // -----------------------------------------------------------------------------
   518 // CFSMailBox::GetBrandingIdL
   535 // CFSMailBox::GetBrandingIdL
   519 // -----------------------------------------------------------------------------
   536 // -----------------------------------------------------------------------------
   520 EXPORT_C TDesC& CFSMailBox::GetBrandingIdL()
   537 EXPORT_C TDesC& CFSMailBox::GetBrandingIdL( )
   521 {
   538 {
   522     FUNC_LOG;
   539     FUNC_LOG;
   523     return BrandingId();
   540     return BrandingId();
   524 }
   541 }
   525 
   542 
   526 // -----------------------------------------------------------------------------
   543 // -----------------------------------------------------------------------------
   527 // CFSMailBox::MoveMessagesL
   544 // CFSMailBox::MoveMessagesL
   528 // -----------------------------------------------------------------------------
   545 // -----------------------------------------------------------------------------
   529 EXPORT_C void CFSMailBox::MoveMessagesL( const RArray<TFSMailMsgId>& aMessageIds, 
   546 EXPORT_C void CFSMailBox::MoveMessagesL( const RArray<TFSMailMsgId>& aMessageIds, 
   530                                    const TFSMailMsgId aSourceFolderId, 
   547                                          const TFSMailMsgId aSourceFolderId, 
   531                                    const TFSMailMsgId aDestinationFolderId )
   548                                          const TFSMailMsgId aDestinationFolderId )
   532 {
   549 {
   533     FUNC_LOG;
   550     FUNC_LOG;
   534     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   551     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   535         {
   552         {
   536         plugin->MoveMessagesL(GetId(), aMessageIds, aSourceFolderId, aDestinationFolderId);
   553         plugin->MoveMessagesL(GetId(), aMessageIds, aSourceFolderId, aDestinationFolderId);
   537         }
   554         }
   538 }
   555 }
   539 
   556 
   540 // -----------------------------------------------------------------------------
   557 // -----------------------------------------------------------------------------
       
   558 // CFSMailBox::MoveMessagesL
       
   559 // -----------------------------------------------------------------------------
       
   560 EXPORT_C TInt CFSMailBox::MoveMessagesL( MFSMailRequestObserver& aOperationObserver,
       
   561                                          const RArray<TFSMailMsgId>& aMessageIds, 
       
   562                                          const TFSMailMsgId aSourceFolderId, 
       
   563                                          const TFSMailMsgId aDestinationFolderId )
       
   564 {
       
   565     FUNC_LOG;
       
   566     TFSPendingRequest request;
       
   567     if( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() ) )
       
   568         {
       
   569         // init asynchronous request
       
   570         request = iRequestHandler->InitAsyncRequestL( GetId().PluginId(),
       
   571                                                         aOperationObserver );
       
   572         plugin->MoveMessagesL(
       
   573             GetId(), 
       
   574             aMessageIds, 
       
   575             aSourceFolderId, 
       
   576             aDestinationFolderId, 
       
   577             aOperationObserver, 
       
   578             request.iRequestId );
       
   579         }
       
   580     return request.iRequestId;
       
   581 }
       
   582 
       
   583 // -----------------------------------------------------------------------------
   541 // CFSMailBox::CopyMessagesL
   584 // CFSMailBox::CopyMessagesL
   542 // -----------------------------------------------------------------------------
   585 // -----------------------------------------------------------------------------
   543 EXPORT_C void CFSMailBox::CopyMessagesL( const RArray<TFSMailMsgId>& aMessageIds, 
   586 EXPORT_C void CFSMailBox::CopyMessagesL( const RArray<TFSMailMsgId>& aMessageIds, 
   544                                        RArray<TFSMailMsgId>& aNewMessages, 
   587                                          RArray<TFSMailMsgId>& aNewMessages, 
   545                                        const TFSMailMsgId aSourceFolderId, 
   588                                          const TFSMailMsgId aSourceFolderId, 
   546                                        const TFSMailMsgId aDestinationFolderId )
   589                                          const TFSMailMsgId aDestinationFolderId )
   547 {
   590 {
   548     FUNC_LOG;
   591     FUNC_LOG;
   549     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   592     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   550         {
   593         {
   551         plugin->CopyMessagesL(GetId(), aMessageIds, aNewMessages,
   594         plugin->CopyMessagesL(GetId(), aMessageIds, aNewMessages,
   552                 aSourceFolderId, aDestinationFolderId );  
   595                                 aSourceFolderId, aDestinationFolderId );    
   553         }
   596         }
   554 }
   597 }
   555 
   598 
   556 // -----------------------------------------------------------------------------
   599 // -----------------------------------------------------------------------------
   557 // CFSMailBox::SearchL
   600 // CFSMailBox::SearchL
   558 // -----------------------------------------------------------------------------
   601 // -----------------------------------------------------------------------------
   559 EXPORT_C void CFSMailBox::SearchL( const RPointerArray<TDesC>& /*aSearchStrings*/,
   602 EXPORT_C void CFSMailBox::SearchL( const RPointerArray<TDesC>& /*aSearchStrings*/,
   560                    const TFSMailSortCriteria&  /*aSortCriteria*/,
   603                                    const TFSMailSortCriteria&  /*aSortCriteria*/,
   561                    MFSMailBoxSearchObserver&   /*aSearchObserver*/,
   604                                    MFSMailBoxSearchObserver&   /*aSearchObserver*/,
   562                    const RArray<TFSMailMsgId>  /*aFolderIds */ )
   605                                    const RArray<TFSMailMsgId>  /*aFolderIds */ )
   563 {
   606     {
   564     FUNC_LOG;
   607     FUNC_LOG;
   565 }
   608 
   566   
   609     }
       
   610     
   567 // -----------------------------------------------------------------------------
   611 // -----------------------------------------------------------------------------
   568 // CFSMailBox::SearchL
   612 // CFSMailBox::SearchL
   569 // -----------------------------------------------------------------------------
   613 // -----------------------------------------------------------------------------
   570 EXPORT_C void CFSMailBox::SearchL( const RPointerArray<TDesC>& aSearchStrings,
   614 EXPORT_C void CFSMailBox::SearchL( const RPointerArray<TDesC>& aSearchStrings,
   571                    const TFSMailSortCriteria& aSortCriteria,
   615                                    const TFSMailSortCriteria& aSortCriteria,
   572                    MFSMailBoxSearchObserver& aSearchObserver )
   616                                    MFSMailBoxSearchObserver& aSearchObserver )
   573 {
   617     {
   574     FUNC_LOG;
   618     FUNC_LOG;
   575     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   619     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   576         {
   620         {
       
   621 
   577         // get mailbox folder list
   622         // get mailbox folder list
   578         iFolders.ResetAndDestroy();
   623         iFolders.ResetAndDestroy();
   579         plugin->ListFoldersL(GetId(),iFolders);
   624         plugin->ListFoldersL(GetId(),iFolders);
   580     
   625 
   581         TFSMailMsgId draftsFolderId = GetStandardFolderId( EFSDraftsFolder );
   626         TFSMailMsgId draftsFolderId = GetStandardFolderId( EFSDraftsFolder );
   582         TFSMailMsgId outboxId = GetStandardFolderId( EFSOutbox );
   627         TFSMailMsgId outboxId = GetStandardFolderId( EFSOutbox );
   583         
   628         
   584         // remove outbox, drafts folder from folder list
   629         // remove outbox, drafts folder from folder list
   585         RArray<TFSMailMsgId> folderIds;
   630         RArray<TFSMailMsgId> folderIds;
   586         folderIds.Reset();
   631         folderIds.Reset();
   587         for(TInt i=0;i<iFolders.Count();i++)
   632         for(TInt i=0;i<iFolders.Count();i++)
   588             {
   633         {
   589             TFSMailMsgId id = iFolders[i]->GetFolderId();
   634             TFSMailMsgId id = iFolders[i]->GetFolderId();
   590             if( id != draftsFolderId && id != outboxId )
   635             if( id != draftsFolderId && id != outboxId )
   591                 {
   636             {
   592                 folderIds.Append(id);
   637                 folderIds.Append(id);
   593                 }
   638             }
   594             }
   639         }
   595     
   640         
   596         // start search
   641         // start search
   597         plugin->SearchL( GetId(), folderIds, aSearchStrings, aSortCriteria, aSearchObserver );
   642         plugin->SearchL( GetId(), folderIds, aSearchStrings, aSortCriteria, aSearchObserver );
   598         folderIds.Reset();
   643         folderIds.Reset();
   599         }
   644         }
   600 }
   645     }
   601 
   646 
   602 // -----------------------------------------------------------------------------
   647 // -----------------------------------------------------------------------------
   603 // CFSMailBox::CancelSearch
   648 // CFSMailBox::CancelSearch
   604 // -----------------------------------------------------------------------------
   649 // -----------------------------------------------------------------------------
   605 EXPORT_C void CFSMailBox::CancelSearch()
   650 EXPORT_C void CFSMailBox::CancelSearch()
   606 {
   651     {
   607     FUNC_LOG;
   652     FUNC_LOG;
   608     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   653     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   609         {
   654         {
   610         plugin->CancelSearch( GetId() );
   655         plugin->CancelSearch( GetId() );
   611         }
   656         }
   612 }
   657     }
   613 
   658 
   614 // -----------------------------------------------------------------------------
   659 // -----------------------------------------------------------------------------
   615 // CFSMailBox::ClearSearchResultCache
   660 // CFSMailBox::ClearSearchResultCache
   616 // -----------------------------------------------------------------------------
   661 // -----------------------------------------------------------------------------
   617 EXPORT_C void CFSMailBox::ClearSearchResultCache()
   662 EXPORT_C void CFSMailBox::ClearSearchResultCache()
   618 {
   663     {
   619     FUNC_LOG;
   664     FUNC_LOG;
   620     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   665     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   621         {
   666         {
   622         plugin->ClearSearchResultCache( GetId() );
   667         plugin->ClearSearchResultCache( GetId() );
   623         }
   668         }
   624 }
   669     }
   625 
   670 
   626 // -----------------------------------------------------------------------------
   671 // -----------------------------------------------------------------------------
   627 // CFSMailBox::ListMrusL
   672 // CFSMailBox::ListMrusL
   628 // -----------------------------------------------------------------------------
   673 // -----------------------------------------------------------------------------
   629 EXPORT_C MDesCArray* CFSMailBox::ListMrusL() const
   674 EXPORT_C MDesCArray* CFSMailBox::ListMrusL() const
   630 {
   675     {
   631     FUNC_LOG;
   676     FUNC_LOG;
   632     MDesCArray* mruList(0);
   677     MDesCArray* mruList(0);
   633     if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId() ) )
   678     if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId() ) )
   634         {
   679         {
   635         mruList = plugin->GetMrusL( GetId() );
   680         mruList = plugin->GetMrusL( GetId() );
   636         }
   681         }
   637     return mruList;
   682     return mruList;
   638 }
   683     }
   639 
   684 
   640 
   685 
   641 // -----------------------------------------------------------------------------
   686 // -----------------------------------------------------------------------------
   642 // CFSMailBox::CurrentSyncState
   687 // CFSMailBox::CurrentSyncState
   643 // -----------------------------------------------------------------------------
   688 // -----------------------------------------------------------------------------
   644 EXPORT_C TSSMailSyncState CFSMailBox::CurrentSyncState() const
   689 EXPORT_C TSSMailSyncState CFSMailBox::CurrentSyncState() const
   645 {
   690     {
   646     FUNC_LOG;
   691     FUNC_LOG;
   647     TSSMailSyncState syncState(Idle);
   692     TSSMailSyncState syncState(Idle);
   648     if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() ) )
   693     if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() ) )
   649         {
   694         {
   650         syncState = plugin->CurrentSyncState( GetId() );
   695         syncState = plugin->CurrentSyncState( GetId() );
   651         }
   696         }
   652     return syncState;
   697     return syncState;
   653 }
   698     }
   654 
   699 
   655 // -----------------------------------------------------------------------------
   700 // -----------------------------------------------------------------------------
   656 // CFSMailBox::HasCapability
   701 // CFSMailBox::HasCapability
   657 // -----------------------------------------------------------------------------
   702 // -----------------------------------------------------------------------------
   658 EXPORT_C TBool CFSMailBox::HasCapability( const TFSMailBoxCapabilities aCapability ) const
   703 EXPORT_C TBool CFSMailBox::HasCapability( const TFSMailBoxCapabilities aCapability ) const
   664         TRAPD( err,capability = plugin->MailboxHasCapabilityL( aCapability,GetId() )) ;
   709         TRAPD( err,capability = plugin->MailboxHasCapabilityL( aCapability,GetId() )) ;
   665         if ( err != KErrNone )
   710         if ( err != KErrNone )
   666             {
   711             {
   667             capability = EFalse;
   712             capability = EFalse;
   668             }
   713             }
   669     }
   714         }
   670     return capability;
   715     return capability;
   671 }
   716 }
   672 
   717 
   673 // -----------------------------------------------------------------------------
   718 // -----------------------------------------------------------------------------
   674 // CFSMailBox::GetMailBoxStatus
   719 // CFSMailBox::GetMailBoxStatus
   676 EXPORT_C TFSMailBoxStatus CFSMailBox::GetMailBoxStatus()
   721 EXPORT_C TFSMailBoxStatus CFSMailBox::GetMailBoxStatus()
   677 {
   722 {
   678     FUNC_LOG;
   723     FUNC_LOG;
   679     TFSMailBoxStatus status(EFSMailBoxOffline);
   724     TFSMailBoxStatus status(EFSMailBoxOffline);
   680     if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId() ) )
   725     if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId() ) )
   681         {
   726     {
   682         status = plugin->GetMailBoxStatus( GetId() );
   727         status = plugin->GetMailBoxStatus( GetId() );
   683         }
   728     }
   684     return status;
   729     return status;
   685 }
   730 }
   686 
   731 
   687 // -----------------------------------------------------------------------------
   732 // -----------------------------------------------------------------------------
   688 // CFSMailBox::SetCredentialsL
   733 // CFSMailBox::SetCredentialsL
   689 // -----------------------------------------------------------------------------
   734 // -----------------------------------------------------------------------------
   690 EXPORT_C void CFSMailBox::SetCredentialsL( const TDesC& aUsername, const TDesC& aPassword )
   735 EXPORT_C void CFSMailBox::SetCredentialsL( const TDesC& aUsername, const TDesC& aPassword )
   691 {
   736     {
   692     FUNC_LOG;
   737     FUNC_LOG;
   693     if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId() ) )
   738     if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId() ) )
   694         {
   739         {
   695         plugin->SetCredentialsL( GetId(), aUsername, aPassword );
   740         plugin->SetCredentialsL( GetId(), aUsername, aPassword );
   696         }
   741         }
   697 }
   742     }
   698 
   743 
   699 // -----------------------------------------------------------------------------
   744 // -----------------------------------------------------------------------------
   700 // CFSMailBox::RemoveDownLoadedAttachmentsL
   745 // CFSMailBox::RemoveDownLoadedAttachmentsL
   701 // -----------------------------------------------------------------------------
   746 // -----------------------------------------------------------------------------
   702 EXPORT_C void CFSMailBox::RemoveDownLoadedAttachmentsL()
   747 EXPORT_C void CFSMailBox::RemoveDownLoadedAttachmentsL()
   703 {
   748     {
   704     FUNC_LOG;
   749     FUNC_LOG;
   705     
   750     
   706     CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() );
   751     CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() );
   707     if ( plugin )
   752     if ( plugin )
   708         {
   753         {
   713             {
   758             {
   714             folder->RemoveDownLoadedAttachmentsL();
   759             folder->RemoveDownLoadedAttachmentsL();
   715             delete folder;
   760             delete folder;
   716             }
   761             }
   717         }
   762         }
   718 }
   763     }
   719 
   764 
   720 // -----------------------------------------------------------------------------
   765 // -----------------------------------------------------------------------------
   721 // CFSMailBox::GetConnectionId
   766 // CFSMailBox::GetConnectionId
   722 // -----------------------------------------------------------------------------
   767 // -----------------------------------------------------------------------------
   723 EXPORT_C TInt CFSMailBox::GetConnectionId( TUint32& aConnectionId )
   768 EXPORT_C TInt CFSMailBox::GetConnectionId( TUint32& aConnectionId )
   724 {
   769     {
   725     FUNC_LOG;
   770     FUNC_LOG;
   726     TInt rcode = KErrNotSupported;
   771     TInt rcode = KErrNotSupported;
   727     if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() ) )
   772     if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() ) )
   728         {
   773         {
   729         rcode = plugin->GetConnectionId( GetId(), aConnectionId );
   774         rcode = plugin->GetConnectionId( GetId(), aConnectionId );
   730         }
   775         }
   731     return rcode;
   776     return rcode;
   732 }
   777     }
   733 
   778 
   734 // -----------------------------------------------------------------------------
   779 // -----------------------------------------------------------------------------
   735 // CFSMailBox::IsConnectionAllowedWhenRoaming
   780 // CFSMailBox::IsConnectionAllowedWhenRoaming
   736 // -----------------------------------------------------------------------------
   781 // -----------------------------------------------------------------------------
   737 EXPORT_C TInt CFSMailBox::IsConnectionAllowedWhenRoaming( TBool& aConnectionAllowed )
   782 EXPORT_C TInt CFSMailBox::IsConnectionAllowedWhenRoaming( TBool& aConnectionAllowed )
   738 {
   783     {
   739     FUNC_LOG;
   784     FUNC_LOG;
   740     TInt rcode = KErrNotSupported;
   785     TInt rcode = KErrNotSupported;
   741     if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() ) )
   786     if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() ) )
   742         {
   787         {
   743         rcode = plugin->IsConnectionAllowedWhenRoaming( GetId(), aConnectionAllowed );
   788         rcode = plugin->IsConnectionAllowedWhenRoaming( GetId(), aConnectionAllowed );
   744         }
   789         }
   745     return rcode;
   790     return rcode;
       
   791     }
       
   792 
       
   793 // -----------------------------------------------------------------------------
       
   794 // CFSMailBox::CreateMessageFromFileL
       
   795 // -----------------------------------------------------------------------------
       
   796 EXPORT_C CFSMailMessage* CFSMailBox::CreateMessageFromFileL( const RFile& aFile )
       
   797 {
       
   798     FUNC_LOG;
       
   799     CFSMailMessage* message = NULL;
       
   800     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
       
   801     {
       
   802 		message = plugin->CreateMessageFromFileL( GetId(), aFile );
       
   803     }
       
   804     return message;
   746 }
   805 }
   747 
   806 
   748 // -----------------------------------------------------------------------------
   807 // -----------------------------------------------------------------------------
   749 // CFSMailBox::UpdateMrusL
   808 // CFSMailBox::UpdateMrusL
   750 // -----------------------------------------------------------------------------
   809 // -----------------------------------------------------------------------------
   751 void CFSMailBox::UpdateMrusL(
   810 void CFSMailBox::UpdateMrusL(
   752     const RPointerArray<CFSMailAddress>& aRecipients,
   811     const RPointerArray<CFSMailAddress>& aRecipients,
   753     const RPointerArray<CFSMailAddress>& aCCRecipients,
   812     const RPointerArray<CFSMailAddress>& aCCRecipients,
   754     const RPointerArray<CFSMailAddress>& aBCCRecipients ) const
   813     const RPointerArray<CFSMailAddress>& aBCCRecipients ) const
   755 {
   814     {
   756     FUNC_LOG;
   815     FUNC_LOG;
   757     
   816     
   758     // First lets make a copy of the current mru list
   817     // First lets make a copy of the current mru list
   759     // whose content we can later alter as we wish
   818     // whose content we can later alter as we wish
   760     MDesCArray* currentMruList( NULL );
   819     MDesCArray* currentMruList( NULL );
   799     
   858     
   800     // Finally update the new mru list to the plugin
   859     // Finally update the new mru list to the plugin
   801     plugin->SetMrusL( GetId(), newMruList );
   860     plugin->SetMrusL( GetId(), newMruList );
   802     
   861     
   803     CleanupStack::PopAndDestroy( newMruList );
   862     CleanupStack::PopAndDestroy( newMruList );
   804 }
   863     }
   805 
   864 
   806 // -----------------------------------------------------------------------------
   865 // -----------------------------------------------------------------------------
   807 // CFSMailBox::CopyArrayL
   866 // CFSMailBox::CopyArrayL
   808 // -----------------------------------------------------------------------------    
   867 // -----------------------------------------------------------------------------    
   809 CDesCArraySeg* CFSMailBox::CopyArrayL( MDesCArray& aArrayToBeCopied ) const
   868 CDesCArraySeg* CFSMailBox::CopyArrayL( MDesCArray& aArrayToBeCopied ) const
   810 {
   869     {
   811     FUNC_LOG;
   870     FUNC_LOG;
   812     CDesCArraySeg* newArray = new (ELeave) CDesCArraySeg( 10 );
   871     CDesCArraySeg* newArray = new (ELeave) CDesCArraySeg( 10 );
   813     CleanupStack::PushL( newArray );
   872     CleanupStack::PushL( newArray );
   814     
   873     
   815     TInt itemCount( aArrayToBeCopied.MdcaCount() );
   874     TInt itemCount( aArrayToBeCopied.MdcaCount() );
   820         ++index;
   879         ++index;
   821         }
   880         }
   822     
   881     
   823     CleanupStack::Pop( newArray );
   882     CleanupStack::Pop( newArray );
   824     return newArray;
   883     return newArray;
   825 }
   884     }
   826 
   885 
   827 // -----------------------------------------------------------------------------
   886 // -----------------------------------------------------------------------------
   828 // CFSMailBox::UpdateMruListL
   887 // CFSMailBox::UpdateMruListL
   829 // -----------------------------------------------------------------------------
   888 // -----------------------------------------------------------------------------
   830 void CFSMailBox::UpdateMruListL(
   889 void CFSMailBox::UpdateMruListL(
   831     CDesCArraySeg& aMruList,
   890     CDesCArraySeg& aMruList,
   832     const RPointerArray<CFSMailAddress>& aNewRecentlyUsedOnes ) const
   891     const RPointerArray<CFSMailAddress>& aNewRecentlyUsedOnes ) const
   833 {
   892     {
   834     FUNC_LOG;
   893     FUNC_LOG;
   835     TUint newCount( aNewRecentlyUsedOnes.Count() );
   894     TUint newCount( aNewRecentlyUsedOnes.Count() );
   836     TUint newIndexer( 0 );
   895     TUint newIndexer( 0 );
   837     
   896     
   838     while ( newIndexer < newCount )
   897     while ( newIndexer < newCount )
   861                 }
   920                 }
   862             }        
   921             }        
   863         
   922         
   864         ++newIndexer;
   923         ++newIndexer;
   865         }
   924         }
   866 }
   925     }
   867 
   926 
   868 // -----------------------------------------------------------------------------
   927 // -----------------------------------------------------------------------------
   869 // CFSMailBox::FindAddressFromMruList
   928 // CFSMailBox::FindAddressFromMruList
   870 // -----------------------------------------------------------------------------
   929 // -----------------------------------------------------------------------------
   871 TInt CFSMailBox::FindAddressFromMruList( CDesCArraySeg& aMruList,
   930 TInt CFSMailBox::FindAddressFromMruList( CDesCArraySeg& aMruList,
   872                                          TDesC& searchedAddress,
   931                                          TDesC& searchedAddress,
   873                                          TInt& aPos ) const
   932                                          TInt& aPos ) const
   874 {
   933     {
   875     FUNC_LOG;
   934     FUNC_LOG;
   876     // CDesCArray::Find() is not used here because there is
   935     // CDesCArray::Find() is not used here because there is
   877     // possibility that we have to go through the whole array
   936     // possibility that we have to go through the whole array
   878     // and return the index for one specific match. Find() returns
   937     // and return the index for one specific match. Find() returns
   879     // only the index of the first match and searching for the rest
   938     // only the index of the first match and searching for the rest
   901     
   960     
   902     aPos = aMruList.Count();
   961     aPos = aMruList.Count();
   903     return 1;
   962     return 1;
   904     }
   963     }
   905 
   964 
       
   965 
       
   966 
       
   967 
   906 // -----------------------------------------------------------------------------
   968 // -----------------------------------------------------------------------------
   907 // CFSMailBox::AddAndRemoveExcessMruL
   969 // CFSMailBox::AddAndRemoveExcessMruL
   908 // -----------------------------------------------------------------------------
   970 // -----------------------------------------------------------------------------
   909 void CFSMailBox::AddAndRemoveExcessMruL( CDesCArraySeg& aMruList,
   971 void CFSMailBox::AddAndRemoveExcessMruL( CDesCArraySeg& aMruList,
   910                                          CFSMailAddress& aToBeAdded ) const
   972                                          CFSMailAddress& aToBeAdded ) const
   911 {
   973     {
   912     FUNC_LOG;
   974     FUNC_LOG;
   913     if ( aMruList.Count() == KMaxMruEntries )
   975     if ( aMruList.Count() == KMaxMruEntries )
   914         {
   976         {
   915         // Remove the oldest entry pair from the beginning
   977         // Remove the oldest entry pair from the beginning
   916         aMruList.Delete( 0, 2 );
   978         aMruList.Delete( 0, 2 );
   917         }
   979         }
   918     // Latest address is always found from the end.
   980     // Latest address is always found from the end.
   919     AppendMruItemL( aMruList, aToBeAdded );
   981     AppendMruItemL( aMruList, aToBeAdded );
   920 }
   982     }
   921 
   983 
   922 // -----------------------------------------------------------------------------
   984 // -----------------------------------------------------------------------------
   923 // CFSMailBox::SetAsMostRecentMruL
   985 // CFSMailBox::SetAsMostRecentMruL
   924 // -----------------------------------------------------------------------------
   986 // -----------------------------------------------------------------------------
   925 void CFSMailBox::SetAsMostRecentMruL( CDesCArraySeg& aMruList,
   987 void CFSMailBox::SetAsMostRecentMruL( CDesCArraySeg& aMruList,
   926                                       TInt aPosition,
   988                                       TInt aPosition,
   927                                       CFSMailAddress& aMostRecent ) const
   989                                       CFSMailAddress& aMostRecent ) const
   928 {
   990     {
   929     FUNC_LOG;
   991     FUNC_LOG;
   930     // Position of the address is given so the possible display name is
   992     // Position of the address is given so the possible display name is
   931     // in the previous slot. Delete both.
   993     // in the previous slot. Delete both.
   932     aMruList.Delete( aPosition - 1, 2 );
   994     aMruList.Delete( aPosition - 1, 2 );
   933     // Latest address is always found from the end.
   995     // Latest address is always found from the end.
   934     AppendMruItemL( aMruList, aMostRecent );
   996     AppendMruItemL( aMruList, aMostRecent );
   935 }
   997     }
   936 
   998 
   937 // -----------------------------------------------------------------------------
   999 // -----------------------------------------------------------------------------
   938 // CFSMailBox::AppendMruItemL
  1000 // CFSMailBox::AppendMruItemL
   939 // -----------------------------------------------------------------------------
  1001 // -----------------------------------------------------------------------------
   940 void CFSMailBox::AppendMruItemL( CDesCArraySeg& aMruList,
  1002 void CFSMailBox::AppendMruItemL( CDesCArraySeg& aMruList,
   941                                  CFSMailAddress& aToBeAppended ) const
  1003                                  CFSMailAddress& aToBeAppended ) const
   942 {
  1004     {
   943     FUNC_LOG;
  1005     FUNC_LOG;
   944     // In the array, display name is always the first and then comes
  1006     // In the array, display name is always the first and then comes
   945     // the actual address.
  1007     // the actual address.
   946     
  1008     
   947     // <cmail> avoid setting email address as display name so it won't 
  1009     // <cmail> avoid setting email address as display name so it won't 
   948     // be displayed twice in the list
  1010     // be displayed twice in the list
   949     TDesC* displayName  = &aToBeAppended.GetDisplayName();    
  1011     TDesC* displayName  = &aToBeAppended.GetDisplayName();    
   950     TDesC* emailAddress = &aToBeAppended.GetEmailAddress();
  1012     TDesC* emailAddress = &aToBeAppended.GetEmailAddress();
   951 
  1013 
   952     if( displayName->Length() > 0 && displayName->Compare(*emailAddress) == 0 )
  1014     if( displayName->Length() > 0 && displayName->Compare(*emailAddress) == 0 )
   953         {
  1015     {
   954         aMruList.AppendL( KNullDesC );
  1016         aMruList.AppendL( KNullDesC );
   955         }
  1017     }
   956     else
  1018     else
   957         {
  1019     {
   958         aMruList.AppendL( *displayName );                
  1020         aMruList.AppendL( *displayName );                
   959         }
  1021     }
   960     
  1022     
   961     aMruList.AppendL( *emailAddress );    
  1023     aMruList.AppendL( *emailAddress );    
   962     // </cmail>
  1024     }
   963 }
  1025 
   964 
  1026 // -----------------------------------------------------------------------------
       
  1027 // CFSMailBox::ReleaseExtension
       
  1028 // -----------------------------------------------------------------------------
       
  1029 EXPORT_C void CFSMailBox::ReleaseExtension( CEmailExtension* aExtension )
       
  1030     {
       
  1031     FUNC_LOG;
       
  1032     // no specialized behaviour, call base class
       
  1033     CExtendableEmail::ReleaseExtension( aExtension );
       
  1034     }
       
  1035     
       
  1036 // -----------------------------------------------------------------------------
       
  1037 // CFSMailBox::ExtensionL
       
  1038 // -----------------------------------------------------------------------------
       
  1039 EXPORT_C CEmailExtension* CFSMailBox::ExtensionL( const TUid& aInterfaceUid )
       
  1040     {
       
  1041     FUNC_LOG;
       
  1042     CEmailExtension* extension = NULL;
       
  1043     if ( aInterfaceUid == KMailboxExtMrCalInfo )
       
  1044         {
       
  1045         extension = CExtendableEmail::ExtensionL( aInterfaceUid );
       
  1046         if ( extension == NULL )
       
  1047             {
       
  1048             extension = new ( ELeave ) CMRCalendarInfoImpl();
       
  1049             CleanupStack::PushL( extension );
       
  1050             iExtensions.AddL( extension );
       
  1051             CleanupStack::Pop(); // calInfo
       
  1052             }
       
  1053         }    
       
  1054     else if ( aInterfaceUid == KEmailMailboxStateExtensionUid )
       
  1055         {
       
  1056         if ( !extension )
       
  1057             {
       
  1058             // check that plugin supports requested extension.
       
  1059             if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() ) )
       
  1060                 {
       
  1061                 // request extension from plugin, leaves if not supported
       
  1062                 extension = plugin->ExtensionL( aInterfaceUid );
       
  1063                 }
       
  1064     
       
  1065             }
       
  1066         }
       
  1067     else
       
  1068         {
       
  1069         User::Leave( KErrNotSupported );
       
  1070         }
       
  1071     return extension;
       
  1072     }
       
  1073