emailservices/emailclientapi/src/emailmailbox.cpp
branchRCL_3
changeset 63 d189ee25cf9d
parent 26 67369d1b217f
child 64 3533d4323edc
equal deleted inserted replaced
61:dcf0eedfc1a3 63:d189ee25cf9d
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2010 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".
    29 #include "emailapiutils.h"
    29 #include "emailapiutils.h"
    30 #include "emailaddress.h"
    30 #include "emailaddress.h"
    31 #include "emailfolder.h"
    31 #include "emailfolder.h"
    32 #include "emailmessage.h"
    32 #include "emailmessage.h"
    33 #include "emailmessagesearch.h"
    33 #include "emailmessagesearch.h"
    34 #include "cfsmailclient.h"
    34 #include "CFSMailClient.h"
    35 #include "emailclientapiimpl.h"
    35 #include "emailclientapiimpl.h"
    36 #include "cfsmailplugin.h"
    36 #include "CFSMailPlugin.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 
       
    41 #include <xqservicerequest.h>
       
    42 #include "email_services_api.h"
    41 
    43 
    42 // Constants
    44 // Constants
       
    45 
       
    46 #include <QStringList>
       
    47 
       
    48 _LIT( KNewLine, "\n" );
    43 
    49 
    44 // -----------------------------------------------------------------------------
    50 // -----------------------------------------------------------------------------
    45 //
    51 //
    46 // -----------------------------------------------------------------------------
    52 // -----------------------------------------------------------------------------
    47 CEmailMailbox* CEmailMailbox::NewL(
    53 CEmailMailbox* CEmailMailbox::NewL(
    49     const TMailboxId& aMailboxId )
    55     const TMailboxId& aMailboxId )
    50     {
    56     {
    51     CEmailMailbox* self = new ( ELeave ) CEmailMailbox( aPluginData, aMailboxId );
    57     CEmailMailbox* self = new ( ELeave ) CEmailMailbox( aPluginData, aMailboxId );
    52     CleanupStack::PushL( self );
    58     CleanupStack::PushL( self );
    53     self->ConstructL();
    59     self->ConstructL();
    54     CleanupStack::Pop();
    60     CleanupStack::Pop( self );
    55     return self;
    61     return self;
    56     }
    62     }
    57 
    63 
    58 // -----------------------------------------------------------------------------
    64 // -----------------------------------------------------------------------------
    59 //
    65 //
    73     {
    79     {
    74     iPlugin = iPluginData.ClaimInstanceL();
    80     iPlugin = iPluginData.ClaimInstanceL();
    75     iEventMapper = new ( ELeave ) TObserverEventMapper(
    81     iEventMapper = new ( ELeave ) TObserverEventMapper(
    76         iPlugin, iPluginData.Uid(), iMailboxId );
    82         iPlugin, iPluginData.Uid(), iMailboxId );
    77     iFsMailbox = iPlugin->GetMailBoxByUidL( FsMailboxId() );
    83     iFsMailbox = iPlugin->GetMailBoxByUidL( FsMailboxId() );
    78     iSyncObserver = new (ELeave) CEmailMailbox::CEmailRequestObserver();
    84     iSyncObserver = new ( ELeave ) CEmailMailbox::CEmailRequestObserver();
    79     }
    85     }
    80 
    86 
    81 // -----------------------------------------------------------------------------
    87 // -----------------------------------------------------------------------------
    82 //
    88 //
    83 // -----------------------------------------------------------------------------
    89 // -----------------------------------------------------------------------------
   160         const CFSMailFolder* fsfolder = folders[i];
   166         const CFSMailFolder* fsfolder = folders[i];
   161         const TEntryId id = fsfolder->GetFolderId().Id();
   167         const TEntryId id = fsfolder->GetFolderId().Id();
   162         const TFolderId folderId( id, iMailboxId );
   168         const TFolderId folderId( id, iMailboxId );
   163         CEmailFolder* folder = CEmailFolder::NewLC( iPluginData, folderId, folders[i] );
   169         CEmailFolder* folder = CEmailFolder::NewLC( iPluginData, folderId, folders[i] );
   164         aFolders.AppendL( folder );
   170         aFolders.AppendL( folder );
   165         CleanupStack::Pop();    // folder
   171         CleanupStack::Pop( folder );
   166         }
   172         }
   167     CleanupStack::Pop();    // folders
   173     CleanupStack::Pop( &folders );
   168     folders.Close(); // close but don't delete folders because they are
   174     folders.Close(); // close but don't delete folders because they are
   169                      // owned by CEmailFolder
   175                      // owned by CEmailFolder
   170     return res;
   176     return res;
   171     }
   177     }
   172 
   178 
   179             FsMsgId( iPluginData, iMailboxId ),
   185             FsMsgId( iPluginData, iMailboxId ),
   180             FsMsgId( iPluginData, aFolderId ) );
   186             FsMsgId( iPluginData, aFolderId ) );
   181     CleanupStack::PushL( fsFolder );
   187     CleanupStack::PushL( fsFolder );
   182 
   188 
   183     CEmailFolder* folder = CEmailFolder::NewL( iPluginData,
   189     CEmailFolder* folder = CEmailFolder::NewL( iPluginData,
   184                 aFolderId, fsFolder);
   190                 aFolderId, fsFolder );
   185     CleanupStack::Pop();    // folder
   191     CleanupStack::Pop( fsFolder );
   186 
   192 
   187     return folder;
   193     return folder;
   188     }
   194     }
   189 
   195 
   190 // -----------------------------------------------------------------------------
   196 // -----------------------------------------------------------------------------
   211             break;
   217             break;
   212         case ESent:
   218         case ESent:
   213             fsFolderId = iPlugin->GetStandardFolderIdL( FsMailboxId(), EFSSentFolder );
   219             fsFolderId = iPlugin->GetStandardFolderIdL( FsMailboxId(), EFSSentFolder );
   214             break;
   220             break;
   215         case EOther:
   221         case EOther:
   216             break;
       
   217         default:
   222         default:
   218             User::Leave( KErrNotFound );
   223             User::Leave( KErrNotFound );
   219             break;
   224             break;
   220         }
   225         }
   221 
   226 
   228 
   233 
   229     CEmailFolder* folder = CEmailFolder::NewL( iPluginData,
   234     CEmailFolder* folder = CEmailFolder::NewL( iPluginData,
   230             folderId,
   235             folderId,
   231             fsFolder );
   236             fsFolder );
   232 
   237 
   233     CleanupStack::Pop();
   238     CleanupStack::Pop( fsFolder );
   234 
   239 
   235     return folder;
   240     return folder;
   236     }
   241     }
   237 
   242 
   238 // -----------------------------------------------------------------------------
   243 // -----------------------------------------------------------------------------
   242     {
   247     {
   243     CFSMailMessage *fsMessage = iPlugin->GetMessageByUidL(
   248     CFSMailMessage *fsMessage = iPlugin->GetMessageByUidL(
   244             FsMsgId( iPluginData, aMessageId.iFolderId.iMailboxId ),
   249             FsMsgId( iPluginData, aMessageId.iFolderId.iMailboxId ),
   245             FsMsgId( iPluginData, aMessageId.iFolderId ),
   250             FsMsgId( iPluginData, aMessageId.iFolderId ),
   246             FsMsgId( iPluginData, aMessageId ),
   251             FsMsgId( iPluginData, aMessageId ),
   247             EFSMsgDataEnvelope);
   252             EFSMsgDataEnvelope );
   248 
   253 
   249     CleanupStack::PushL( fsMessage );
   254     CleanupStack::PushL( fsMessage );
   250     
   255     CEmailMessage* message = CEmailMessage::NewL( iPluginData, fsMessage, EClientOwns );
   251     CEmailMessage* message = NULL;
   256     CleanupStack::Pop( fsMessage );
   252     
       
   253     if ( fsMessage )
       
   254         message = CEmailMessage::NewL( iPluginData, fsMessage, EClientOwns );
       
   255     CleanupStack::Pop();  // fsMessage
       
   256 
   257 
   257     return message;
   258     return message;
   258     }
   259     }
   259 
   260 
   260 // -----------------------------------------------------------------------------
   261 // -----------------------------------------------------------------------------
   264     {
   265     {
   265     CFSMailMessage* fsMessage = iFsMailbox->CreateMessageToSend();
   266     CFSMailMessage* fsMessage = iFsMailbox->CreateMessageToSend();
   266     User::LeaveIfNull( fsMessage );
   267     User::LeaveIfNull( fsMessage );
   267     CleanupStack::PushL( fsMessage );
   268     CleanupStack::PushL( fsMessage );
   268     MEmailMessage* message = CEmailMessage::NewL( iPluginData, fsMessage, EClientOwns );
   269     MEmailMessage* message = CEmailMessage::NewL( iPluginData, fsMessage, EClientOwns );
   269     CleanupStack::Pop();  // fsMessage
   270     CleanupStack::Pop( fsMessage );
   270 
   271 
   271     return message;
   272     return message;
   272     }
   273     }
   273 
   274 
   274 // -----------------------------------------------------------------------------
   275 // -----------------------------------------------------------------------------
   275 //
   276 //
   276 // -----------------------------------------------------------------------------
   277 // -----------------------------------------------------------------------------
   277 MEmailMessage* CEmailMailbox::CreateReplyMessageL( const TMessageId& aMessageId, const TBool aReplyToAll ) const
   278 MEmailMessage* CEmailMailbox::CreateReplyMessageL( 
   278     {
   279         const TMessageId& aMessageId, const TBool aReplyToAll ) const
   279     CFSMailMessage* fsMessage = iFsMailbox->CreateReplyMessage( FsMsgId( iPluginData, aMessageId ), aReplyToAll );
   280     {
       
   281     CFSMailMessage* fsMessage = iFsMailbox->CreateReplyMessage( 
       
   282         FsMsgId( iPluginData, aMessageId ), aReplyToAll );
   280     User::LeaveIfNull( fsMessage );
   283     User::LeaveIfNull( fsMessage );
   281     CleanupStack::PushL( fsMessage );
   284     CleanupStack::PushL( fsMessage );
   282     MEmailMessage* message = CEmailMessage::NewL( iPluginData, fsMessage, EClientOwns );
   285     MEmailMessage* message = CEmailMessage::NewL( iPluginData, fsMessage, EClientOwns );
   283     CleanupStack::Pop();  // fsMessage
   286     CleanupStack::Pop( fsMessage );
   284 
   287 
   285     return message;
   288     return message;
   286     }
   289     }
   287 
   290 
   288 // -----------------------------------------------------------------------------
   291 // -----------------------------------------------------------------------------
   289 //
   292 //
   290 // -----------------------------------------------------------------------------
   293 // -----------------------------------------------------------------------------
   291 MEmailMessage* CEmailMailbox::CreateForwardMessageL( const TMessageId& aMessageId ) const
   294 MEmailMessage* CEmailMailbox::CreateForwardMessageL( const TMessageId& aMessageId ) const
   292     {
   295     {
   293     // create temp header descriptor
       
   294     TReplyForwardParams params;
       
   295     params.iHeader = HBufC::NewLC(1);
       
   296     params.iHeader->Des().Copy(KNullDesC());    
       
   297     params.iSmartTag = HBufC::NewLC(1);
       
   298     params.iSmartTag->Des().Copy(KNullDesC());        
       
   299     TPckgBuf<TReplyForwardParams> buf( params );
       
   300     HBufC* temp = HBufC::NewLC( buf.Length() );
       
   301     temp->Des().Copy( buf );
       
   302     
       
   303     CFSMailMessage* fsMessage = iFsMailbox->CreateForwardMessage(
   296     CFSMailMessage* fsMessage = iFsMailbox->CreateForwardMessage(
   304         FsMsgId( iPluginData, aMessageId ), *temp );
   297         FsMsgId( iPluginData, aMessageId ), KNewLine() );
   305     User::LeaveIfNull( fsMessage );
   298     User::LeaveIfNull( fsMessage );
   306     CleanupStack::PushL( fsMessage );
   299     CleanupStack::PushL( fsMessage );
   307     MEmailMessage* message = CEmailMessage::NewL( iPluginData, fsMessage, EClientOwns );
   300     MEmailMessage* message = CEmailMessage::NewL( iPluginData, fsMessage, EClientOwns );
   308     CleanupStack::Pop();  // fsMessage
   301     CleanupStack::Pop( fsMessage );
   309     
   302 
   310     CleanupStack::PopAndDestroy( temp );
       
   311     CleanupStack::PopAndDestroy( params.iSmartTag );
       
   312     CleanupStack::PopAndDestroy( params.iHeader );
       
   313     
       
   314     return message;
   303     return message;
   315     }
   304     }
   316 
   305 
   317 // -----------------------------------------------------------------------------
   306 // -----------------------------------------------------------------------------
   318 //
   307 //
   350 // -----------------------------------------------------------------------------
   339 // -----------------------------------------------------------------------------
   351 //
   340 //
   352 // -----------------------------------------------------------------------------
   341 // -----------------------------------------------------------------------------
   353 MEmailMessageSearchAsync* CEmailMailbox::MessageSearchL()
   342 MEmailMessageSearchAsync* CEmailMailbox::MessageSearchL()
   354     {
   343     {
   355     MEmailMessageSearchAsync* searchAPI = CEmailMessageSearchAsync::NewL( iPluginData, iMailboxId );
   344     MEmailMessageSearchAsync* searchAPI = 
       
   345         CEmailMessageSearchAsync::NewL( iPluginData, iMailboxId );
   356     return searchAPI;
   346     return searchAPI;
   357     }
   347     }
   358 
   348 
       
   349 // -----------------------------------------------------------------------------
       
   350 //
       
   351 // -----------------------------------------------------------------------------
   359 void CEmailMailbox::ShowInboxL()
   352 void CEmailMailbox::ShowInboxL()
   360     {
   353     {
   361     TMailListActivationData mailListData;
   354     User::Leave( KErrNotSupported );
   362 
   355     }
   363     mailListData.iMailBoxId = FsMsgId(iPluginData, iMailboxId);
   356 
   364 
   357 // -----------------------------------------------------------------------------
   365     TPckgBuf<TMailListActivationData> pkgOut( mailListData );
   358 //
   366     CVwsSessionWrapper* viewSrvSession = CVwsSessionWrapper::NewLC();
   359 // -----------------------------------------------------------------------------
   367     viewSrvSession->ActivateView(TVwsViewId(KFSEmailUiUid, MailListId), KStartListWithFolderId, pkgOut);
       
   368     CleanupStack::PopAndDestroy();
       
   369     }
       
   370 
       
   371 void CEmailMailbox::EditNewMessageL()
   360 void CEmailMailbox::EditNewMessageL()
   372     {
   361     {
   373     TEditorLaunchParams editorLaunchData;
   362     bool syncronous;
   374     editorLaunchData.iExtra = NULL;
   363 
   375     editorLaunchData.iMailboxId = FsMsgId(iPluginData, iMailboxId);
   364     XQServiceRequest request( emailInterfaceNameSend,
   376     editorLaunchData.iActivatedExternally = ETrue;
   365                              emailOperationSendMail,
   377 
   366                              syncronous );
   378     TPckgBuf<TEditorLaunchParams> pckgData( editorLaunchData );
   367 
   379     CVwsSessionWrapper* viewSrvSession = CVwsSessionWrapper::NewLC();
   368     QVariant returnValue;
   380     TUid command = TUid::Uid(KEditorCmdCreateNew);
   369     if ( !request.send( returnValue ) )
   381     viewSrvSession->ActivateView(TVwsViewId(KFSEmailUiUid, MailEditorId), command, pckgData);
   370         User::Leave( KErrGeneral );
   382     CleanupStack::PopAndDestroy( viewSrvSession );
   371     }
   383     }
   372 
   384 /*
       
   385 void CEmailMailbox::GetLatestMail()
       
   386     {
       
   387     CFSMailFolder* fsFolder = NULL;
       
   388     TFSMailMsgId fsFolderId = iPlugin->GetStandardFolderIdL( FsMailboxId(), EFSInbox );
       
   389 
       
   390     }
       
   391 */
       
   392 // -----------------------------------------------------------------------------
   373 // -----------------------------------------------------------------------------
   393 //
   374 //
   394 // -----------------------------------------------------------------------------
   375 // -----------------------------------------------------------------------------
   395 CEmailMailbox::TObserverEventMapper::TObserverEventMapper(
   376 CEmailMailbox::TObserverEventMapper::TObserverEventMapper(
   396     CFSMailPlugin* aPlugin,
   377     CFSMailPlugin* aPlugin,
   410 
   391 
   411 // -----------------------------------------------------------------------------
   392 // -----------------------------------------------------------------------------
   412 // Adds mailbox observer and subscribes to plugin mailbox events if there
   393 // Adds mailbox observer and subscribes to plugin mailbox events if there
   413 // were no previous observers.
   394 // were no previous observers.
   414 // -----------------------------------------------------------------------------
   395 // -----------------------------------------------------------------------------
   415 void CEmailMailbox::TObserverEventMapper::AddObserverL( MMailboxContentObserver& aObserver )
   396 void CEmailMailbox::TObserverEventMapper::AddObserverL( 
   416     {
   397         MMailboxContentObserver& aObserver )
   417     TIdentityRelation<MMailboxContentObserver> relation( &CEmailMailbox::TObserverEventMapper::Equals );
   398     {
       
   399     TIdentityRelation<MMailboxContentObserver> relation( 
       
   400         &CEmailMailbox::TObserverEventMapper::Equals );
   418     if ( iClientObservers.Find( &aObserver, relation ) == KErrNotFound )
   401     if ( iClientObservers.Find( &aObserver, relation ) == KErrNotFound )
   419         {
   402         {
   420         const TInt count( iClientObservers.Count() );
   403         const TInt count( iClientObservers.Count() );
   421         if  ( !count )
   404         if  ( !count )
   422             {
   405             {
   428 
   411 
   429 // -----------------------------------------------------------------------------
   412 // -----------------------------------------------------------------------------
   430 // Removes an observer and removes event subscription if the observer was
   413 // Removes an observer and removes event subscription if the observer was
   431 // last in observer array.
   414 // last in observer array.
   432 // -----------------------------------------------------------------------------
   415 // -----------------------------------------------------------------------------
   433 void CEmailMailbox::TObserverEventMapper::RemoveObserver( MMailboxContentObserver& aObserver )
   416 void CEmailMailbox::TObserverEventMapper::RemoveObserver( 
   434     {
   417         MMailboxContentObserver& aObserver )
   435     TIdentityRelation<MMailboxContentObserver> relation( &CEmailMailbox::TObserverEventMapper::Equals );
   418     {
       
   419     TIdentityRelation<MMailboxContentObserver> relation( 
       
   420         &CEmailMailbox::TObserverEventMapper::Equals );
   436     const TInt index( iClientObservers.Find( &aObserver, relation ) );
   421     const TInt index( iClientObservers.Find( &aObserver, relation ) );
   437     if ( index != KErrNotFound )
   422     if ( index != KErrNotFound )
   438         {
   423         {
   439         iClientObservers.Remove( index );
   424         iClientObservers.Remove( index );
   440         const TInt count( iClientObservers.Count() );
   425         const TInt count( iClientObservers.Count() );
   488         TEventMapFunc method = KMailboxEventHandlers[ index ];
   473         TEventMapFunc method = KMailboxEventHandlers[ index ];
   489         (this->*method)(id, aParam1,aParam2,aParam3 );
   474         (this->*method)(id, aParam1,aParam2,aParam3 );
   490         }
   475         }
   491     }
   476     }
   492 
   477 
   493 void CEmailMailbox::TObserverEventMapper::ConvertParamsL( TMailboxId aMailbox, TAny* aParam1, 
   478 // -----------------------------------------------------------------------------
   494                                             TAny* aParam2, REmailMessageIdArray& aMessageIds, TFolderId& aFolderId )
   479 //
   495     {  
   480 // -----------------------------------------------------------------------------
       
   481 void CEmailMailbox::TObserverEventMapper::ConvertParamsL( 
       
   482         TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, 
       
   483         REmailMessageIdArray& aMessageIds, TFolderId& aFolderId )
       
   484     {
   496     RArray<TFSMailMsgId>* newEntries( static_cast< RArray<TFSMailMsgId>* >( aParam1 ) );
   485     RArray<TFSMailMsgId>* newEntries( static_cast< RArray<TFSMailMsgId>* >( aParam1 ) );
   497     CleanupClosePushL( *newEntries );
   486     CleanupClosePushL( *newEntries );
   498     TFSMailMsgId* parentFolder = static_cast<TFSMailMsgId*>( aParam2 );
   487     TFSMailMsgId* parentFolder = static_cast<TFSMailMsgId*>( aParam2 );
   499     aFolderId = TFolderId( parentFolder->Id(), aMailbox );
   488     aFolderId = TFolderId( parentFolder->Id(), aMailbox );
   500     
   489 
   501     for (TInt j = 0; j < newEntries->Count(); j++ ) 
   490     for ( TInt j = 0; j < newEntries->Count(); j++ ) 
   502         {
   491         {
   503         TFSMailMsgId fsId(( *newEntries )[j]);
   492         TFSMailMsgId fsId(( *newEntries )[j] );
   504         TMessageId messageId( fsId.Id(), aFolderId.iId, aMailbox);
   493         TMessageId messageId( fsId.Id(), aFolderId.iId, aMailbox );
   505         aMessageIds.Append(messageId);
   494         aMessageIds.Append( messageId );
   506         }
   495         }
   507     
   496 
   508     CleanupStack::PopAndDestroy( newEntries );
   497     CleanupStack::PopAndDestroy( newEntries );
   509     }
   498     }
   510 
   499 
       
   500 // -----------------------------------------------------------------------------
       
   501 //
       
   502 // -----------------------------------------------------------------------------
   511 void CEmailMailbox::TObserverEventMapper::IgnoreEventL(
   503 void CEmailMailbox::TObserverEventMapper::IgnoreEventL(
   512     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   504     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   513     {
   505     {
   514     }
   506     }
   515 
   507 
       
   508 // -----------------------------------------------------------------------------
       
   509 //
       
   510 // -----------------------------------------------------------------------------
   516 void CEmailMailbox::TObserverEventMapper::NewMessageL(
   511 void CEmailMailbox::TObserverEventMapper::NewMessageL(
   517     TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* /*aParam3*/ )
   512     TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* /*aParam3*/ )
   518     {  
   513     {
       
   514     REmailMessageIdArray messageIds;
       
   515     TFolderId folderId;
       
   516     ConvertParamsL( aMailbox, aParam1, aParam2, messageIds, folderId );
       
   517     CleanupClosePushL( messageIds );
       
   518 
       
   519     for ( TInt i = 0; i < iClientObservers.Count(); i++ )
       
   520         {
       
   521         MMailboxContentObserver* observer = iClientObservers[i];
       
   522         if (observer)
       
   523             observer->NewMessageEventL( aMailbox, messageIds, folderId );
       
   524         }
       
   525     
       
   526     CleanupStack::PopAndDestroy( &messageIds );
       
   527     }
       
   528 
       
   529 // -----------------------------------------------------------------------------
       
   530 //
       
   531 // -----------------------------------------------------------------------------
       
   532 void CEmailMailbox::TObserverEventMapper::MessageChangedL(
       
   533     TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* /*aParam3*/ )
       
   534     {
       
   535     REmailMessageIdArray messageIds;
       
   536     TFolderId folderId;
       
   537     ConvertParamsL( aMailbox, aParam1, aParam2, messageIds, folderId );
       
   538     CleanupClosePushL( messageIds );
       
   539 
       
   540     for ( TInt i = 0; i < iClientObservers.Count(); i++ )
       
   541         {
       
   542         MMailboxContentObserver* observer = iClientObservers[i];
       
   543         if (observer)
       
   544             observer->MessageChangedEventL( aMailbox, messageIds, folderId );
       
   545         }
       
   546     CleanupStack::PopAndDestroy( &messageIds );
       
   547     }
       
   548 
       
   549 // -----------------------------------------------------------------------------
       
   550 //
       
   551 // -----------------------------------------------------------------------------
       
   552 void CEmailMailbox::TObserverEventMapper::MessageDeletedL(
       
   553     TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* /*aParam3*/ )
       
   554     {
   519     REmailMessageIdArray messageIds;    
   555     REmailMessageIdArray messageIds;    
   520     TFolderId folderId;
   556     TFolderId folderId;
   521     ConvertParamsL( aMailbox, aParam1, aParam2, messageIds, folderId );
   557     ConvertParamsL( aMailbox, aParam1, aParam2, messageIds, folderId );
   522     for ( TInt i = 0; i < iClientObservers.Count(); i++ ) 
   558     CleanupClosePushL( messageIds );
       
   559 
       
   560     for ( TInt i = 0; i < iClientObservers.Count(); i++ )
   523         {
   561         {
   524         MMailboxContentObserver* observer = iClientObservers[i];
   562         MMailboxContentObserver* observer = iClientObservers[i];
   525         observer->NewMessageEventL( aMailbox, messageIds, folderId );
   563         if (observer)
   526         }
   564             observer->MessageDeletedEventL( aMailbox, messageIds, folderId );
   527     }
   565         }
   528 
       
   529 void CEmailMailbox::TObserverEventMapper::MessageChangedL(
       
   530     TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* /*aParam3*/ )
       
   531     {
       
   532     REmailMessageIdArray messageIds;    
       
   533     TFolderId folderId;
       
   534     ConvertParamsL( aMailbox, aParam1, aParam2, messageIds, folderId );
       
   535     
   566     
   536     for ( TInt i = 0; i < iClientObservers.Count(); i++ ) 
   567     CleanupStack::PopAndDestroy( &messageIds );
   537         {
   568     }
   538         MMailboxContentObserver* observer = iClientObservers[i];
   569 
   539         observer->MessageChangedEventL( aMailbox, messageIds, folderId );
   570 // -----------------------------------------------------------------------------
   540         }
   571 //
   541     }
   572 // -----------------------------------------------------------------------------
   542 
       
   543 void CEmailMailbox::TObserverEventMapper::MessageDeletedL(
       
   544     TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* /*aParam3*/ )
       
   545     {
       
   546     REmailMessageIdArray messageIds;    
       
   547     TFolderId folderId;
       
   548     ConvertParamsL( aMailbox, aParam1, aParam2, messageIds, folderId );
       
   549         
       
   550     for ( TInt i = 0; i < iClientObservers.Count(); i++ ) 
       
   551         {
       
   552         MMailboxContentObserver* observer = iClientObservers[i];
       
   553         observer->MessageDeletedEventL( aMailbox, messageIds, folderId );
       
   554         }
       
   555     }
       
   556 
       
   557 void CEmailMailbox::TObserverEventMapper::MessageMoved(
   573 void CEmailMailbox::TObserverEventMapper::MessageMoved(
   558     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   574     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   559     {
   575     {
   560     }
   576     }
   561 
   577 
       
   578 // -----------------------------------------------------------------------------
       
   579 //
       
   580 // -----------------------------------------------------------------------------
   562 void CEmailMailbox::TObserverEventMapper::MessageCopiedL(
   581 void CEmailMailbox::TObserverEventMapper::MessageCopiedL(
   563     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   582     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   564     {
   583     {
   565     }
   584     }
   566 
   585 
       
   586 // -----------------------------------------------------------------------------
       
   587 //
       
   588 // -----------------------------------------------------------------------------
   567 void CEmailMailbox::TObserverEventMapper::NewFolderL(
   589 void CEmailMailbox::TObserverEventMapper::NewFolderL(
   568     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   590     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   569     {
   591     {
   570     }
   592     }
   571 
   593 
       
   594 // -----------------------------------------------------------------------------
       
   595 //
       
   596 // -----------------------------------------------------------------------------
   572 void CEmailMailbox::TObserverEventMapper::FolderChangeL(
   597 void CEmailMailbox::TObserverEventMapper::FolderChangeL(
   573     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   598     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   574     {
   599     {
   575     }
   600     }
   576 
   601 
       
   602 // -----------------------------------------------------------------------------
       
   603 //
       
   604 // -----------------------------------------------------------------------------
   577 void CEmailMailbox::TObserverEventMapper::FoldersDeletedL(
   605 void CEmailMailbox::TObserverEventMapper::FoldersDeletedL(
   578     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   606     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   579     {
   607     {
   580     }
   608     }
   581 
   609 
       
   610 // -----------------------------------------------------------------------------
       
   611 //
       
   612 // -----------------------------------------------------------------------------
   582 void CEmailMailbox::TObserverEventMapper::FoldersMovedL(
   613 void CEmailMailbox::TObserverEventMapper::FoldersMovedL(
   583     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   614     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   584     {
   615     {
   585     }
   616     }
   586 
   617 
       
   618 // -----------------------------------------------------------------------------
       
   619 //
       
   620 // -----------------------------------------------------------------------------
   587 void CEmailMailbox::TObserverEventMapper::ExceptionL(
   621 void CEmailMailbox::TObserverEventMapper::ExceptionL(
   588     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   622     TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
   589     {
   623     {
   590     }
   624     }
   591 
   625 
   592 
   626 // -----------------------------------------------------------------------------
   593 // -----------------------------------------------------------------------------
   627 //
   594 //
   628 // -----------------------------------------------------------------------------
   595 // -----------------------------------------------------------------------------
   629 TBool CEmailMailbox::TObserverEventMapper::Equals( 
   596 TBool CEmailMailbox::TObserverEventMapper::Equals( const MMailboxContentObserver& a1, const MMailboxContentObserver& a2 )
   630         const MMailboxContentObserver& a1, const MMailboxContentObserver& a2 )
   597     {
   631     {
   598     return ( &a1 == &a2 );
   632     return ( &a1 == &a2 );
   599     }
   633     }
   600 
   634 // -----------------------------------------------------------------------------
   601 
   635 //
       
   636 // -----------------------------------------------------------------------------
   602 CEmailMailbox::CEmailRequestObserver::CEmailRequestObserver() : iObserver( NULL )
   637 CEmailMailbox::CEmailRequestObserver::CEmailRequestObserver() : iObserver( NULL )
   603     {
   638     {
   604     }
   639     }
   605 
   640 
   606 
   641 // -----------------------------------------------------------------------------
   607 void CEmailMailbox::CEmailRequestObserver::RequestResponseL( TFSProgress aEvent, TInt /* aRequestId */ )
   642 //
   608 {
   643 // -----------------------------------------------------------------------------
   609     if (aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestComplete)
   644 void CEmailMailbox::CEmailRequestObserver::RequestResponseL( 
       
   645         TFSProgress aEvent, TInt /* aRequestId */ )
       
   646     {
       
   647     if ( iObserver && aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestComplete )
   610         {
   648         {
   611         iObserver->MailboxSynchronisedL(aEvent.iError);
   649         iObserver->MailboxSynchronisedL(aEvent.iError);
   612         }
   650         }
   613 }
   651     }
   614 
   652 
       
   653 // -----------------------------------------------------------------------------
       
   654 //
       
   655 // -----------------------------------------------------------------------------
   615 void CEmailMailbox::CEmailRequestObserver::SetObserverL( MMailboxSyncObserver* aObserver )
   656 void CEmailMailbox::CEmailRequestObserver::SetObserverL( MMailboxSyncObserver* aObserver )
   616 {
   657     {
   617     iObserver = aObserver;
   658     iObserver = aObserver;
   618 }
   659     }
   619 
   660 
   620 // End of file.
   661 // End of file
   621 
   662