emailservices/emailclientapi/src/emailmailbox.cpp
branchRCL_3
changeset 12 f5907b1a1053
parent 8 e1b6206813b4
child 13 0396474f30f5
equal deleted inserted replaced
8:e1b6206813b4 12:f5907b1a1053
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 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: This file implements class CEmailMailbox.
    14 * Description: This file implements class CEmailMailbox.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include <e32cmn.h> 
    18 #include <e32cmn.h>
    19 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    19 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    20 #include <viewclipartner.h>
    20 #include <viewclipartner.h>
    21 #include <vwsdefpartner.h>
    21 #include <vwsdefpartner.h>
    22 #else
    22 #else
    23 #include <viewcli.h>
    23 #include <viewcli.h>
    37 #include "cfsmailbox.h"
    37 #include "cfsmailbox.h"
    38 #include "cfsmailfolder.h"
    38 #include "cfsmailfolder.h"
    39 #include "emailclientapi.hrh"
    39 #include "emailclientapi.hrh"
    40 #include "FreestyleEmailUiConstants.h"
    40 #include "FreestyleEmailUiConstants.h"
    41 
    41 
    42 // -----------------------------------------------------------------------------
    42 // Constants
    43 // 
    43 
    44 // -----------------------------------------------------------------------------
    44 _LIT( KNewLine, "\n" );
    45 CEmailMailbox* CEmailMailbox::NewL( 
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 // -----------------------------------------------------------------------------
       
    49 CEmailMailbox* CEmailMailbox::NewL(
    46     CPluginData& aPluginData,
    50     CPluginData& aPluginData,
    47     const TMailboxId& aMailboxId )
    51     const TMailboxId& aMailboxId )
    48     {
    52     {
    49     CEmailMailbox* self = new ( ELeave ) CEmailMailbox( aPluginData, aMailboxId );
    53     CEmailMailbox* self = new ( ELeave ) CEmailMailbox( aPluginData, aMailboxId );
    50     CleanupStack::PushL( self );
    54     CleanupStack::PushL( self );
    52     CleanupStack::Pop();
    56     CleanupStack::Pop();
    53     return self;
    57     return self;
    54     }
    58     }
    55 
    59 
    56 // -----------------------------------------------------------------------------
    60 // -----------------------------------------------------------------------------
    57 // 
    61 //
    58 // -----------------------------------------------------------------------------
    62 // -----------------------------------------------------------------------------
    59 CEmailMailbox::CEmailMailbox( 
    63 CEmailMailbox::CEmailMailbox(
    60     CPluginData& aPluginData,
    64     CPluginData& aPluginData,
    61     const TMailboxId& aMailboxId )
    65     const TMailboxId& aMailboxId )
    62     : iPluginData( aPluginData ),
    66     : iPluginData( aPluginData ),
    63     iMailboxId( aMailboxId.iId )
    67     iMailboxId( aMailboxId.iId )
    64     {        
    68     {
    65     }
    69     }
    66 
    70 
    67 // -----------------------------------------------------------------------------
    71 // -----------------------------------------------------------------------------
    68 // 
    72 //
    69 // -----------------------------------------------------------------------------
    73 // -----------------------------------------------------------------------------
    70 void CEmailMailbox::ConstructL()
    74 void CEmailMailbox::ConstructL()
    71     {
    75     {
    72     iPlugin = iPluginData.ClaimInstanceL();
    76     iPlugin = iPluginData.ClaimInstanceL();
    73     iEventMapper = new ( ELeave ) TObserverEventMapper( 
    77     iEventMapper = new ( ELeave ) TObserverEventMapper(
    74         iPlugin, iPluginData.Uid(), iMailboxId );
    78         iPlugin, iPluginData.Uid(), iMailboxId );
    75     iFsMailbox = iPlugin->GetMailBoxByUidL( FsMailboxId() );
    79     iFsMailbox = iPlugin->GetMailBoxByUidL( FsMailboxId() );
    76     iSyncObserver = new (ELeave) CEmailMailbox::CEmailRequestObserver();    
    80     iSyncObserver = new (ELeave) CEmailMailbox::CEmailRequestObserver();
    77     }
    81     }
    78 
    82 
    79 // -----------------------------------------------------------------------------
    83 // -----------------------------------------------------------------------------
    80 // 
    84 //
    81 // -----------------------------------------------------------------------------
    85 // -----------------------------------------------------------------------------
    82 CEmailMailbox::~CEmailMailbox()
    86 CEmailMailbox::~CEmailMailbox()
    83     {
    87     {
    84     delete iFsMailbox;
    88     delete iFsMailbox;
    85     delete iEventMapper;
    89     delete iEventMapper;
    87     iPluginData.ReleaseInstance();
    91     iPluginData.ReleaseInstance();
    88     delete iSyncObserver;
    92     delete iSyncObserver;
    89     }
    93     }
    90 
    94 
    91 // -----------------------------------------------------------------------------
    95 // -----------------------------------------------------------------------------
    92 // 
    96 //
    93 // -----------------------------------------------------------------------------
    97 // -----------------------------------------------------------------------------
    94 TEmailTypeId CEmailMailbox::InterfaceId() const
    98 TEmailTypeId CEmailMailbox::InterfaceId() const
    95     {
    99     {
    96     return KEmailIFUidMailbox;
   100     return KEmailIFUidMailbox;
    97     }
   101     }
    98 
   102 
    99 // -----------------------------------------------------------------------------
   103 // -----------------------------------------------------------------------------
   100 // 
   104 //
   101 // -----------------------------------------------------------------------------
   105 // -----------------------------------------------------------------------------
   102 void CEmailMailbox::Release()
   106 void CEmailMailbox::Release()
   103     {
   107     {
   104     delete this;
   108     delete this;
   105     }
   109     }
   106 
   110 
   107 // -----------------------------------------------------------------------------
   111 // -----------------------------------------------------------------------------
   108 // 
   112 //
   109 // -----------------------------------------------------------------------------
   113 // -----------------------------------------------------------------------------
   110 TMailboxId CEmailMailbox::MailboxId() const
   114 TMailboxId CEmailMailbox::MailboxId() const
   111     {
   115     {
   112     return iMailboxId;
   116     return iMailboxId;
   113     }
   117     }
   114    
   118 
   115 // -----------------------------------------------------------------------------
   119 // -----------------------------------------------------------------------------
   116 // 
   120 //
   117 // -----------------------------------------------------------------------------
   121 // -----------------------------------------------------------------------------
   118 MEmailAddress* CEmailMailbox::AddressL() const
   122 MEmailAddress* CEmailMailbox::AddressL() const
   119     {
   123     {
   120     if ( !iAddress )
   124     if ( !iAddress )
   121         {        
   125         {
   122         iAddress = CEmailAddress::NewL(
   126         iAddress = CEmailAddress::NewL(
   123             MEmailAddress::ESender, EAPIOwns );
   127             MEmailAddress::ESender, EAPIOwns );
   124         iAddress->SetDisplayNameL( iFsMailbox->GetName() );
   128         iAddress->SetDisplayNameL( iFsMailbox->GetName() );
   125         iAddress->SetAddressL( iFsMailbox->OwnMailAddress().GetEmailAddress() );
   129         iAddress->SetAddressL( iFsMailbox->OwnMailAddress().GetEmailAddress() );
   126         }
   130         }
   127     return iAddress;
   131     return iAddress;
   128     }
   132     }
   129 
   133 
   130 // -----------------------------------------------------------------------------
   134 // -----------------------------------------------------------------------------
   131 // 
   135 //
   132 // -----------------------------------------------------------------------------
   136 // -----------------------------------------------------------------------------
   133 TPtrC CEmailMailbox::MailboxName() const
   137 TPtrC CEmailMailbox::MailboxName() const
   134     {
   138     {
   135     return iFsMailbox->GetName();
   139     return iFsMailbox->GetName();
   136     }
   140     }
   139 // Constructs and returns type mailbox id of internal data type TFSMailMsgId
   143 // Constructs and returns type mailbox id of internal data type TFSMailMsgId
   140 // -----------------------------------------------------------------------------
   144 // -----------------------------------------------------------------------------
   141 TFSMailMsgId CEmailMailbox::FsMailboxId() const
   145 TFSMailMsgId CEmailMailbox::FsMailboxId() const
   142     {
   146     {
   143     return FsMsgId( iPluginData, iMailboxId );
   147     return FsMsgId( iPluginData, iMailboxId );
   144     }    
   148     }
   145 
   149 
   146 // -----------------------------------------------------------------------------
   150 // -----------------------------------------------------------------------------
   147 // 
   151 //
   148 // -----------------------------------------------------------------------------
   152 // -----------------------------------------------------------------------------
   149 TInt CEmailMailbox::GetFoldersL( RFolderArray& aFolders ) const
   153 TInt CEmailMailbox::GetFoldersL( RFolderArray& aFolders ) const
   150     {
   154     {
   151     TFSMailMsgId rootId = TFSMailMsgId();
   155     TFSMailMsgId rootId = TFSMailMsgId();
   152     RPointerArray<CFSMailFolder> folders;
   156     RPointerArray<CFSMailFolder> folders;
   153     CleanupResetAndDestroyPushL( folders );    
   157     CleanupResetAndDestroyPushL( folders );
   154     iPlugin->ListFoldersL( FsMailboxId(), rootId, folders );    
   158     iPlugin->ListFoldersL( FsMailboxId(), rootId, folders );
   155     TInt res( folders.Count() );
   159     TInt res( folders.Count() );
   156     for ( TInt i = 0; i < res; i++ )
   160     for ( TInt i = 0; i < res; i++ )
   157         {
   161         {
   158         const CFSMailFolder* fsfolder = folders[i]; 
   162         const CFSMailFolder* fsfolder = folders[i];
   159         const TEntryId id = fsfolder->GetFolderId().Id();
   163         const TEntryId id = fsfolder->GetFolderId().Id();
   160         const TFolderId folderId( id, iMailboxId );
   164         const TFolderId folderId( id, iMailboxId );
   161         CEmailFolder* folder = CEmailFolder::NewLC( iPluginData, folderId, folders[i] );        
   165         CEmailFolder* folder = CEmailFolder::NewLC( iPluginData, folderId, folders[i] );
   162         aFolders.AppendL( folder );
   166         aFolders.AppendL( folder );
   163         CleanupStack::Pop();    // folder
   167         CleanupStack::Pop();    // folder
   164         }
   168         }
   165     CleanupStack::Pop();    // folders
   169     CleanupStack::Pop();    // folders
   166     folders.Close(); // close but don't delete folders because they are
   170     folders.Close(); // close but don't delete folders because they are
   167                      // owned by CEmailFolder
   171                      // owned by CEmailFolder
   168     return res;
   172     return res;
   169     }
   173     }
   170 
   174 
   171 // -----------------------------------------------------------------------------
   175 // -----------------------------------------------------------------------------
   172 // 
   176 //
   173 // -----------------------------------------------------------------------------
   177 // -----------------------------------------------------------------------------
   174 MEmailFolder* CEmailMailbox::FolderL( const TFolderId& aFolderId ) const
   178 MEmailFolder* CEmailMailbox::FolderL( const TFolderId& aFolderId ) const
   175     {
   179     {
   176     CFSMailFolder* fsFolder = iPlugin->GetFolderByUidL(
   180     CFSMailFolder* fsFolder = iPlugin->GetFolderByUidL(
   177             FsMsgId( iPluginData, iMailboxId ),
   181             FsMsgId( iPluginData, iMailboxId ),
   178             FsMsgId( iPluginData, aFolderId ) );
   182             FsMsgId( iPluginData, aFolderId ) );
   179     CleanupStack::PushL( fsFolder );
   183     CleanupStack::PushL( fsFolder );
   180     
   184 
   181     CEmailFolder* folder = CEmailFolder::NewL( iPluginData, 
   185     CEmailFolder* folder = CEmailFolder::NewL( iPluginData,
   182                 aFolderId, fsFolder);   
   186                 aFolderId, fsFolder);
   183     CleanupStack::Pop();    // folder
   187     CleanupStack::Pop();    // folder
   184     
   188 
   185     return folder;             
   189     return folder;
   186     }
   190     }
   187  
   191 
   188 // -----------------------------------------------------------------------------
   192 // -----------------------------------------------------------------------------
   189 // 
   193 //
   190 // -----------------------------------------------------------------------------
   194 // -----------------------------------------------------------------------------
   191 MEmailFolder* CEmailMailbox::FolderByTypeL( 
   195 MEmailFolder* CEmailMailbox::FolderByTypeL(
   192     const TFolderType aFolderType ) const
   196     const TFolderType aFolderType ) const
   193     {   
   197     {
   194     TFSMailMsgId fsFolderId;
   198     TFSMailMsgId fsFolderId;
   195     
   199 
   196     switch ( aFolderType )
   200     switch ( aFolderType )
   197         {                   
   201         {
   198         case EInbox:
   202         case EInbox:
   199             fsFolderId = iPlugin->GetStandardFolderIdL( FsMailboxId(), EFSInbox ); 
   203             fsFolderId = iPlugin->GetStandardFolderIdL( FsMailboxId(), EFSInbox );
   200         case EOutbox:
   204         case EOutbox:
   201             fsFolderId = iPlugin->GetStandardFolderIdL( FsMailboxId(), EFSOutbox ); 
   205             fsFolderId = iPlugin->GetStandardFolderIdL( FsMailboxId(), EFSOutbox );
   202         case EDrafts:
   206         case EDrafts:
   203             fsFolderId = iPlugin->GetStandardFolderIdL( FsMailboxId(), EFSDraftsFolder ); 
   207             fsFolderId = iPlugin->GetStandardFolderIdL( FsMailboxId(), EFSDraftsFolder );
   204         case EDeleted:
   208         case EDeleted:
   205             fsFolderId = iPlugin->GetStandardFolderIdL( FsMailboxId(), EFSDeleted ); 
   209             fsFolderId = iPlugin->GetStandardFolderIdL( FsMailboxId(), EFSDeleted );
   206         case ESent:
   210         case ESent:
   207             fsFolderId = iPlugin->GetStandardFolderIdL( FsMailboxId(), EFSSentFolder ); 
   211             fsFolderId = iPlugin->GetStandardFolderIdL( FsMailboxId(), EFSSentFolder );
   208         case EOther:
   212         case EOther:
   209         default:
   213         default:
   210             User::Leave( KErrNotFound );
   214             User::Leave( KErrNotFound );
   211             break;
   215             break;
   212         }
   216         }
   213     
   217 
   214     const TFolderId folderId( fsFolderId.Id(), iMailboxId );
   218     const TFolderId folderId( fsFolderId.Id(), iMailboxId );
   215     
   219 
   216     CFSMailFolder* fsFolder = iPlugin->GetFolderByUidL(
   220     CFSMailFolder* fsFolder = iPlugin->GetFolderByUidL(
   217             FsMsgId( iPluginData, iMailboxId ),
   221             FsMsgId( iPluginData, iMailboxId ),
   218             fsFolderId );
   222             fsFolderId );
   219     CleanupStack::PushL( fsFolder );
   223     CleanupStack::PushL( fsFolder );
   220     
   224 
   221     CEmailFolder* folder = CEmailFolder::NewL( iPluginData,
   225     CEmailFolder* folder = CEmailFolder::NewL( iPluginData,
   222             folderId, 
   226             folderId,
   223             fsFolder );
   227             fsFolder );
   224     
   228 
   225     CleanupStack::Pop();
   229     CleanupStack::Pop();
   226     
   230 
   227     return folder;    
   231     return folder;
   228     }
   232     }
   229 
   233 
   230 // -----------------------------------------------------------------------------
   234 // -----------------------------------------------------------------------------
   231 // 
   235 //
   232 // -----------------------------------------------------------------------------
   236 // -----------------------------------------------------------------------------
   233 MEmailMessage* CEmailMailbox::MessageL( const TMessageId& aMessageId )
   237 MEmailMessage* CEmailMailbox::MessageL( const TMessageId& aMessageId )
   234     {    
   238     {
   235     CFSMailMessage *fsMessage = iPlugin->GetMessageByUidL( 
   239     CFSMailMessage *fsMessage = iPlugin->GetMessageByUidL(
   236             FsMsgId( iPluginData, aMessageId.iFolderId.iMailboxId ), 
   240             FsMsgId( iPluginData, aMessageId.iFolderId.iMailboxId ),
   237             FsMsgId( iPluginData, aMessageId.iFolderId ), 
   241             FsMsgId( iPluginData, aMessageId.iFolderId ),
   238             FsMsgId( iPluginData, aMessageId ), 
   242             FsMsgId( iPluginData, aMessageId ),
   239             EFSMsgDataEnvelope);
   243             EFSMsgDataEnvelope);
   240 
   244 
   241     CleanupStack::PushL( fsMessage );    
   245     CleanupStack::PushL( fsMessage );
   242     CEmailMessage* message = CEmailMessage::NewL( iPluginData, fsMessage, EClientOwns );
   246     CEmailMessage* message = CEmailMessage::NewL( iPluginData, fsMessage, EClientOwns );
   243     CleanupStack::Pop();  // fsMessage
   247     CleanupStack::Pop();  // fsMessage
   244     
   248 
   245     return message;
   249     return message;
   246     }
   250     }
   247 
   251 
   248 // -----------------------------------------------------------------------------
   252 // -----------------------------------------------------------------------------
   249 // 
   253 //
   250 // -----------------------------------------------------------------------------
   254 // -----------------------------------------------------------------------------
   251 MEmailMessage* CEmailMailbox::CreateDraftMessageL() const
   255 MEmailMessage* CEmailMailbox::CreateDraftMessageL() const
   252     {
   256     {
   253     CFSMailMessage* fsMessage = iFsMailbox->CreateMessageToSend();
   257     CFSMailMessage* fsMessage = iFsMailbox->CreateMessageToSend();
   254     CleanupStack::PushL( fsMessage );    
   258     User::LeaveIfNull( fsMessage );
       
   259     CleanupStack::PushL( fsMessage );
   255     MEmailMessage* message = CEmailMessage::NewL( iPluginData, fsMessage, EClientOwns );
   260     MEmailMessage* message = CEmailMessage::NewL( iPluginData, fsMessage, EClientOwns );
   256     CleanupStack::Pop();  // fsMessage
   261     CleanupStack::Pop();  // fsMessage
   257     
   262 
   258     return message;
   263     return message;
   259     }
   264     }
   260     
   265 
   261 // -----------------------------------------------------------------------------
   266 // -----------------------------------------------------------------------------
   262 // 
   267 //
   263 // -----------------------------------------------------------------------------
   268 // -----------------------------------------------------------------------------
   264 MEmailMessage* CEmailMailbox::CreateReplyMessageL( const TMessageId& aMessageId, const TBool aReplyToAll ) const
   269 MEmailMessage* CEmailMailbox::CreateReplyMessageL( const TMessageId& aMessageId, const TBool aReplyToAll ) const
   265     {
   270     {
   266     CFSMailMessage* fsMessage = iFsMailbox->CreateReplyMessage( FsMsgId( iPluginData, aMessageId ), aReplyToAll );   
   271     CFSMailMessage* fsMessage = iFsMailbox->CreateReplyMessage( FsMsgId( iPluginData, aMessageId ), aReplyToAll );
   267     CleanupStack::PushL( fsMessage );    
   272     User::LeaveIfNull( fsMessage );
       
   273     CleanupStack::PushL( fsMessage );
   268     MEmailMessage* message = CEmailMessage::NewL( iPluginData, fsMessage, EClientOwns );
   274     MEmailMessage* message = CEmailMessage::NewL( iPluginData, fsMessage, EClientOwns );
   269     CleanupStack::Pop();  // fsMessage
   275     CleanupStack::Pop();  // fsMessage
   270 
   276 
   271     return message;
   277     return message;
   272     }
   278     }
   273 
   279 
   274 // -----------------------------------------------------------------------------
   280 // -----------------------------------------------------------------------------
   275 // 
   281 //
   276 // -----------------------------------------------------------------------------
   282 // -----------------------------------------------------------------------------
   277 MEmailMessage* CEmailMailbox::CreateForwardMessageL( const TMessageId& aMessageId ) const
   283 MEmailMessage* CEmailMailbox::CreateForwardMessageL( const TMessageId& aMessageId ) const
   278     {            
   284     {
   279     CFSMailMessage* fsMessage = iFsMailbox->CreateForwardMessage( FsMsgId( iPluginData, aMessageId ) );
   285     CFSMailMessage* fsMessage = iFsMailbox->CreateForwardMessage(
   280     CleanupStack::PushL( fsMessage );    
   286         FsMsgId( iPluginData, aMessageId ), KNewLine() );
       
   287     User::LeaveIfNull( fsMessage );
       
   288     CleanupStack::PushL( fsMessage );
   281     MEmailMessage* message = CEmailMessage::NewL( iPluginData, fsMessage, EClientOwns );
   289     MEmailMessage* message = CEmailMessage::NewL( iPluginData, fsMessage, EClientOwns );
   282     CleanupStack::Pop();  // fsMessage
   290     CleanupStack::Pop();  // fsMessage
   283 
   291 
   284     return message;
   292     return message;
   285     }
   293     }
   286 
   294 
   287 // -----------------------------------------------------------------------------
   295 // -----------------------------------------------------------------------------
   288 // 
   296 //
   289 // -----------------------------------------------------------------------------
   297 // -----------------------------------------------------------------------------
   290 void CEmailMailbox::SynchroniseL( MMailboxSyncObserver& aObserver )
   298 void CEmailMailbox::SynchroniseL( MMailboxSyncObserver& aObserver )
   291     {
   299     {
   292     iSyncObserver->SetObserverL( &aObserver );
   300     iSyncObserver->SetObserverL( &aObserver );
   293     iRequestId = iFsMailbox->RefreshNowL( *iSyncObserver );    
   301     iRequestId = iFsMailbox->RefreshNowL( *iSyncObserver );
   294     }
   302     }
   295     
   303 
   296 // -----------------------------------------------------------------------------
   304 // -----------------------------------------------------------------------------
   297 // 
   305 //
   298 // -----------------------------------------------------------------------------
   306 // -----------------------------------------------------------------------------
   299 void CEmailMailbox::CancelSynchronise()
   307 void CEmailMailbox::CancelSynchronise()
   300     {
   308     {
   301     iFsMailbox->CancelSearch();
   309     iFsMailbox->CancelSearch();
   302     }
   310     }
   303 
   311 
   304 // -----------------------------------------------------------------------------
   312 // -----------------------------------------------------------------------------
   305 // 
   313 //
   306 // -----------------------------------------------------------------------------
   314 // -----------------------------------------------------------------------------
   307 void CEmailMailbox::RegisterObserverL( MMailboxContentObserver& aObserver )
   315 void CEmailMailbox::RegisterObserverL( MMailboxContentObserver& aObserver )
   308     {
   316     {
   309     iEventMapper->AddObserverL( aObserver );
   317     iEventMapper->AddObserverL( aObserver );
   310     }
   318     }
   311         
   319 
   312 // -----------------------------------------------------------------------------
   320 // -----------------------------------------------------------------------------
   313 // 
   321 //
   314 // -----------------------------------------------------------------------------
   322 // -----------------------------------------------------------------------------
   315 void CEmailMailbox::UnregisterObserver( MMailboxContentObserver& aObserver )
   323 void CEmailMailbox::UnregisterObserver( MMailboxContentObserver& aObserver )
   316     {
   324     {
   317     iEventMapper->RemoveObserver( aObserver );
   325     iEventMapper->RemoveObserver( aObserver );
   318     }
   326     }
   319 
   327 
   320 // -----------------------------------------------------------------------------
   328 // -----------------------------------------------------------------------------
   321 // 
   329 //
   322 // -----------------------------------------------------------------------------
   330 // -----------------------------------------------------------------------------
   323 MEmailMessageSearchAsync* CEmailMailbox::MessageSearchL()
   331 MEmailMessageSearchAsync* CEmailMailbox::MessageSearchL()
   324     {
   332     {
   325     MEmailMessageSearchAsync* searchAPI = CEmailMessageSearchAsync::NewL( iPluginData, iMailboxId );
   333     MEmailMessageSearchAsync* searchAPI = CEmailMessageSearchAsync::NewL( iPluginData, iMailboxId );
   326     return searchAPI;
   334     return searchAPI;
   327     }
   335     }
   328     
   336 
   329 void CEmailMailbox::ShowInboxL()
   337 void CEmailMailbox::ShowInboxL()
   330     {
   338     {
   331     TMailListActivationData mailListData;
   339     TMailListActivationData mailListData;
   332              
   340 
   333     mailListData.iMailBoxId = FsMsgId(iPluginData, iMailboxId);
   341     mailListData.iMailBoxId = FsMsgId(iPluginData, iMailboxId);
   334              
   342 
   335     TPckgBuf<TMailListActivationData> pkgOut( mailListData );
   343     TPckgBuf<TMailListActivationData> pkgOut( mailListData );
   336     CVwsSessionWrapper* viewSrvSession = CVwsSessionWrapper::NewLC();
   344     CVwsSessionWrapper* viewSrvSession = CVwsSessionWrapper::NewLC();
   337     viewSrvSession->ActivateView(TVwsViewId(KFSEmailUiUid, MailListId), KStartListWithFolderId, pkgOut);
   345     viewSrvSession->ActivateView(TVwsViewId(KFSEmailUiUid, MailListId), KStartListWithFolderId, pkgOut);
   338     CleanupStack::PopAndDestroy();    
   346     CleanupStack::PopAndDestroy();
   339     }
   347     }
   340 
   348 
   341 void CEmailMailbox::EditNewMessageL()
   349 void CEmailMailbox::EditNewMessageL()
   342     {
   350     {
   343     TEditorLaunchParams editorLaunchData;
   351     TEditorLaunchParams editorLaunchData;
   344     editorLaunchData.iMailboxId = FsMsgId(iPluginData, iMailboxId);
   352     editorLaunchData.iMailboxId = FsMsgId(iPluginData, iMailboxId);
   345     editorLaunchData.iActivatedExternally = ETrue; 
   353     editorLaunchData.iActivatedExternally = ETrue;
   346     
   354 
   347     TPckgBuf<TEditorLaunchParams> pckgData( editorLaunchData );
   355     TPckgBuf<TEditorLaunchParams> pckgData( editorLaunchData );
   348     CVwsSessionWrapper* viewSrvSession = CVwsSessionWrapper::NewLC();
   356     CVwsSessionWrapper* viewSrvSession = CVwsSessionWrapper::NewLC();
   349     TUid command = TUid::Uid(KEditorCmdCreateNew);
   357     TUid command = TUid::Uid(KEditorCmdCreateNew);
   350     viewSrvSession->ActivateView(TVwsViewId(KFSEmailUiUid, MailEditorId), command, pckgData);
   358     viewSrvSession->ActivateView(TVwsViewId(KFSEmailUiUid, MailEditorId), command, pckgData);
   351     CleanupStack::PopAndDestroy( viewSrvSession );
   359     CleanupStack::PopAndDestroy( viewSrvSession );
   353 /*
   361 /*
   354 void CEmailMailbox::GetLatestMail()
   362 void CEmailMailbox::GetLatestMail()
   355     {
   363     {
   356     CFSMailFolder* fsFolder = NULL;
   364     CFSMailFolder* fsFolder = NULL;
   357     TFSMailMsgId fsFolderId = iPlugin->GetStandardFolderIdL( FsMailboxId(), EFSInbox );
   365     TFSMailMsgId fsFolderId = iPlugin->GetStandardFolderIdL( FsMailboxId(), EFSInbox );
   358     
   366 
   359     }
   367     }
   360 */
   368 */
   361 // -----------------------------------------------------------------------------
   369 // -----------------------------------------------------------------------------
   362 // 
   370 //
   363 // -----------------------------------------------------------------------------
   371 // -----------------------------------------------------------------------------
   364 CEmailMailbox::TObserverEventMapper::TObserverEventMapper( 
   372 CEmailMailbox::TObserverEventMapper::TObserverEventMapper(
   365     CFSMailPlugin* aPlugin, 
   373     CFSMailPlugin* aPlugin,
   366     TUid aPluginUid, const TMailboxId& aMailboxId )
   374     TUid aPluginUid, const TMailboxId& aMailboxId )
   367      : iPlugin( aPlugin ), 
   375      : iPlugin( aPlugin ),
   368        iFsMailboxId( aPluginUid.iUid, aMailboxId.iId )
   376        iFsMailboxId( aPluginUid.iUid, aMailboxId.iId )
   369     {
   377     {
   370     }
   378     }
   371 
   379 
   372 // -----------------------------------------------------------------------------
   380 // -----------------------------------------------------------------------------
   373 // 
   381 //
   374 // -----------------------------------------------------------------------------
   382 // -----------------------------------------------------------------------------
   375 CEmailMailbox::TObserverEventMapper::~TObserverEventMapper()
   383 CEmailMailbox::TObserverEventMapper::~TObserverEventMapper()
   376     {
   384     {
   377     iClientObservers.Close();
   385     iClientObservers.Close();
   378     }
   386     }
   416 
   424 
   417 // -----------------------------------------------------------------------------
   425 // -----------------------------------------------------------------------------
   418 // Maps protocol a plugin event to client event
   426 // Maps protocol a plugin event to client event
   419 // -----------------------------------------------------------------------------
   427 // -----------------------------------------------------------------------------
   420 void CEmailMailbox::TObserverEventMapper::EventL(
   428 void CEmailMailbox::TObserverEventMapper::EventL(
   421     TFSMailEvent aEvent, 
   429     TFSMailEvent aEvent,
   422     TFSMailMsgId aMailbox, 
   430     TFSMailMsgId aMailbox,
   423     TAny* aParam1, 
   431     TAny* aParam1,
   424     TAny* aParam2, 
   432     TAny* aParam2,
   425     TAny* aParam3 )
   433     TAny* aParam3 )
   426     {
   434     {
   427     const TEventMapFunc KMailboxEventHandlers[] = {
   435     const TEventMapFunc KMailboxEventHandlers[] = {
   428     CEmailMailbox::TObserverEventMapper::IgnoreEventL,
   436     CEmailMailbox::TObserverEventMapper::IgnoreEventL,
   429     CEmailMailbox::TObserverEventMapper::IgnoreEventL, 
   437     CEmailMailbox::TObserverEventMapper::IgnoreEventL,
   430     CEmailMailbox::TObserverEventMapper::IgnoreEventL, 
   438     CEmailMailbox::TObserverEventMapper::IgnoreEventL,
   431     CEmailMailbox::TObserverEventMapper::IgnoreEventL,
   439     CEmailMailbox::TObserverEventMapper::IgnoreEventL,
   432     CEmailMailbox::TObserverEventMapper::IgnoreEventL,
   440     CEmailMailbox::TObserverEventMapper::IgnoreEventL,
   433     CEmailMailbox::TObserverEventMapper::IgnoreEventL,
   441     CEmailMailbox::TObserverEventMapper::IgnoreEventL,
   434     CEmailMailbox::TObserverEventMapper::IgnoreEventL,
   442     CEmailMailbox::TObserverEventMapper::IgnoreEventL,
   435     CEmailMailbox::TObserverEventMapper::IgnoreEventL,
   443     CEmailMailbox::TObserverEventMapper::IgnoreEventL,
   436     CEmailMailbox::TObserverEventMapper::IgnoreEventL,
   444     CEmailMailbox::TObserverEventMapper::IgnoreEventL,
   437     CEmailMailbox::TObserverEventMapper::IgnoreEventL,
   445     CEmailMailbox::TObserverEventMapper::IgnoreEventL,
   438     CEmailMailbox::TObserverEventMapper::NewMessageL, 
   446     CEmailMailbox::TObserverEventMapper::NewMessageL,
   439     CEmailMailbox::TObserverEventMapper::MessageChangedL,
   447     CEmailMailbox::TObserverEventMapper::MessageChangedL,
   440     CEmailMailbox::TObserverEventMapper::MessageDeletedL,
   448     CEmailMailbox::TObserverEventMapper::MessageDeletedL,
   441     CEmailMailbox::TObserverEventMapper::MessageMoved,
   449     CEmailMailbox::TObserverEventMapper::MessageMoved,
   442     CEmailMailbox::TObserverEventMapper::MessageCopiedL,
   450     CEmailMailbox::TObserverEventMapper::MessageCopiedL,
   443     CEmailMailbox::TObserverEventMapper::NewFolderL, 
   451     CEmailMailbox::TObserverEventMapper::NewFolderL,
   444     CEmailMailbox::TObserverEventMapper::FolderChangeL,
   452     CEmailMailbox::TObserverEventMapper::FolderChangeL,
   445     CEmailMailbox::TObserverEventMapper::FoldersDeletedL,
   453     CEmailMailbox::TObserverEventMapper::FoldersDeletedL,
   446     CEmailMailbox::TObserverEventMapper::FoldersMovedL,
   454     CEmailMailbox::TObserverEventMapper::FoldersMovedL,
   447     CEmailMailbox::TObserverEventMapper::ExceptionL
   455     CEmailMailbox::TObserverEventMapper::ExceptionL
   448     };
   456     };
   451     // boundary check
   459     // boundary check
   452     const TInt index( aEvent );
   460     const TInt index( aEvent );
   453     if ( index < sizeof( KMailboxEventHandlers ) / sizeof( KMailboxEventHandlers[ index ] ) )
   461     if ( index < sizeof( KMailboxEventHandlers ) / sizeof( KMailboxEventHandlers[ index ] ) )
   454         {
   462         {
   455         // call event handler function
   463         // call event handler function
   456         TEventMapFunc method = KMailboxEventHandlers[ index ];        
   464         TEventMapFunc method = KMailboxEventHandlers[ index ];
   457         (this->*method)(id, aParam1,aParam2,aParam3 );
   465         (this->*method)(id, aParam1,aParam2,aParam3 );
   458         }
   466         }
   459     }
   467     }
   460 
   468 
   461 void CEmailMailbox::TObserverEventMapper::IgnoreEventL( 
   469 void CEmailMailbox::TObserverEventMapper::IgnoreEventL(
   462     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   470     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   463     {
   471     {
   464     }
   472     }
   465     
   473 
   466 void CEmailMailbox::TObserverEventMapper::NewMessageL( 
   474 void CEmailMailbox::TObserverEventMapper::NewMessageL(
   467     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   475     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   468     {
   476     {
   469     }
   477     }
   470     
   478 
   471 void CEmailMailbox::TObserverEventMapper::MessageChangedL( 
   479 void CEmailMailbox::TObserverEventMapper::MessageChangedL(
   472     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   480     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   473     {
   481     {
   474     }
   482     }
   475     
   483 
   476 void CEmailMailbox::TObserverEventMapper::MessageDeletedL( 
   484 void CEmailMailbox::TObserverEventMapper::MessageDeletedL(
   477     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   485     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   478     {
   486     {
   479     }
   487     }
   480     
   488 
   481 void CEmailMailbox::TObserverEventMapper::MessageMoved( 
   489 void CEmailMailbox::TObserverEventMapper::MessageMoved(
   482     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   490     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   483     {
   491     {
   484     }
   492     }
   485     
   493 
   486 void CEmailMailbox::TObserverEventMapper::MessageCopiedL( 
   494 void CEmailMailbox::TObserverEventMapper::MessageCopiedL(
   487     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   495     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   488     {
   496     {
   489     }
   497     }
   490     
   498 
   491 void CEmailMailbox::TObserverEventMapper::NewFolderL( 
   499 void CEmailMailbox::TObserverEventMapper::NewFolderL(
   492     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   500     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   493     {
   501     {
   494     }
   502     }
   495     
   503 
   496 void CEmailMailbox::TObserverEventMapper::FolderChangeL( 
   504 void CEmailMailbox::TObserverEventMapper::FolderChangeL(
   497     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   505     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   498     {
   506     {
   499     }
   507     }
   500     
   508 
   501 void CEmailMailbox::TObserverEventMapper::FoldersDeletedL( 
   509 void CEmailMailbox::TObserverEventMapper::FoldersDeletedL(
   502     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   510     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   503     {
   511     {
   504     }
   512     }
   505     
   513 
   506 void CEmailMailbox::TObserverEventMapper::FoldersMovedL( 
   514 void CEmailMailbox::TObserverEventMapper::FoldersMovedL(
   507     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   515     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   508     {
   516     {
   509     }
   517     }
   510     
   518 
   511 void CEmailMailbox::TObserverEventMapper::ExceptionL( 
   519 void CEmailMailbox::TObserverEventMapper::ExceptionL(
   512     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   520     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   513     {
   521     {
   514     }
   522     }
   515     
   523 
   516 
   524 
   517 // -----------------------------------------------------------------------------
   525 // -----------------------------------------------------------------------------
   518 // 
   526 //
   519 // -----------------------------------------------------------------------------
   527 // -----------------------------------------------------------------------------
   520 TBool CEmailMailbox::TObserverEventMapper::Equals( const MMailboxContentObserver& a1, const MMailboxContentObserver& a2 )
   528 TBool CEmailMailbox::TObserverEventMapper::Equals( const MMailboxContentObserver& a1, const MMailboxContentObserver& a2 )
   521     {
   529     {
   522     return ( &a1 == &a2 );
   530     return ( &a1 == &a2 );
   523     }
   531     }
   524 
   532 
   525 
   533 
   526 CEmailMailbox::CEmailRequestObserver::CEmailRequestObserver() : iObserver( NULL )
   534 CEmailMailbox::CEmailRequestObserver::CEmailRequestObserver() : iObserver( NULL )
   527     {    
   535     {
   528     }
   536     }
   529 
   537 
   530 
   538 
   531 void CEmailMailbox::CEmailRequestObserver::RequestResponseL( TFSProgress aEvent, TInt /* aRequestId */ )
   539 void CEmailMailbox::CEmailRequestObserver::RequestResponseL( TFSProgress aEvent, TInt /* aRequestId */ )
   532 {
   540 {
   533     if (aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestComplete)
   541     if (aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestComplete)
   534         {
   542         {
   535         iObserver->MailboxSynchronisedL(aEvent.iError);       
   543         iObserver->MailboxSynchronisedL(aEvent.iError);
   536         }
   544         }
   537 }
   545 }
   538 
   546 
   539 void CEmailMailbox::CEmailRequestObserver::SetObserverL( MMailboxSyncObserver* aObserver )
   547 void CEmailMailbox::CEmailRequestObserver::SetObserverL( MMailboxSyncObserver* aObserver )
   540 {
   548 {