diff -r 0396474f30f5 -r 4ce476e64c59 meetingrequest/mrentry/src/cesmrfsmailboxutils.cpp --- a/meetingrequest/mrentry/src/cesmrfsmailboxutils.cpp Mon Mar 15 12:39:10 2010 +0200 +++ b/meetingrequest/mrentry/src/cesmrfsmailboxutils.cpp Wed Mar 31 21:08:33 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -22,9 +22,12 @@ #include "esmrinternaluid.h" #include -#include "cfsmailclient.h" -#include "cfsmailbox.h" +// +#include "CFSMailClient.h" +#include "CFSMailBox.h" +// #include +#include // Unnamed namespace for local definitions namespace { @@ -32,20 +35,6 @@ // Definition for email address comparison const TInt KEqualEmailAddress( 0 ); -// --------------------------------------------------------------------------- -// Cleanup operation for RPointerArray. -// @param aArray Pointer to RPointerArray. -// --------------------------------------------------------------------------- -// -void MailboxPointerArrayCleanup( TAny* aArray ) - { - RPointerArray* entryArray = - static_cast*>( aArray ); - - entryArray->ResetAndDestroy(); - entryArray->Close(); - } - /** * Listes all FS mailboxes. On return aMailboxes contains FS mailboxes * @param aMailClient FS mail client @@ -79,7 +68,7 @@ // CESMRFsMailboxUtils::~CESMRFsMailboxUtils // --------------------------------------------------------------------------- // -CESMRFsMailboxUtils::~CESMRFsMailboxUtils() +EXPORT_C CESMRFsMailboxUtils::~CESMRFsMailboxUtils() { FUNC_LOG; if ( iMailClient ) @@ -92,7 +81,7 @@ // CESMRFsMailboxUtils::NewL // --------------------------------------------------------------------------- // -CESMRFsMailboxUtils* CESMRFsMailboxUtils::NewL( +EXPORT_C CESMRFsMailboxUtils* CESMRFsMailboxUtils::NewL( CMRMailboxUtils& aMailboxUtils ) { FUNC_LOG; @@ -118,7 +107,7 @@ // CESMRFsMailboxUtils::SetPhoneOwnerL // --------------------------------------------------------------------------- // -TInt CESMRFsMailboxUtils::SetPhoneOwnerL( +EXPORT_C TInt CESMRFsMailboxUtils::SetPhoneOwnerL( CCalEntry& aCalEntry, TMsvId aPrimaryBox ) { @@ -130,11 +119,8 @@ { // Check if phone owner can be set using FS mailboxes // Loop throug all mailboxes in this plug-in - RPointerArray mailboxes; - CleanupStack::PushL( - TCleanupItem( - MailboxPointerArrayCleanup, - &mailboxes ) ); + RCPointerArray mailboxes; + CleanupClosePushL( mailboxes ); ListMailBoxesL( MailClientL(), @@ -148,6 +134,7 @@ aCalEntry.SetPhoneOwnerL( phoneOwner ); err = KErrNone; } + CleanupStack::PopAndDestroy( &mailboxes ); } return err; @@ -157,14 +144,14 @@ // CESMRFsMailboxUtils::SetPhoneOwnerL // ---------------------------------------------------------------------------- // -TInt CESMRFsMailboxUtils::SetPhoneOwnerL( +EXPORT_C TInt CESMRFsMailboxUtils::SetPhoneOwnerL( CCalEntry& aCalEntry, CFSMailClient& aMailClient, CFSMailMessage& aMailMessage ) { FUNC_LOG; TInt err( KErrNotFound ); - + TFSMailMsgId mailboxId( aMailMessage.GetMailBoxId() ); CFSMailBox* mailbox = aMailClient.GetMailBoxByUidL( mailboxId ); @@ -172,16 +159,16 @@ { return KErrNotFound; } - + CleanupStack::PushL( mailbox ); TPtrC mailboxOwnerAddName( mailbox->OwnMailAddress().GetEmailAddress() ); - + CCalUser* po = NULL; CCalUser* organizer = aCalEntry.OrganizerL(); - if ( organizer && + if ( organizer && KEqualEmailAddress == organizer->Address().CompareF(mailboxOwnerAddName) ) { po = organizer; @@ -200,16 +187,16 @@ po = attendee; } } - } - + } + if ( po ) { aCalEntry.SetPhoneOwnerL( po ); err = KErrNone; } - + CleanupStack::PopAndDestroy( mailbox ); - + return err; } @@ -217,39 +204,36 @@ // CESMRFsMailboxUtils::FSEmailPluginForEntryL // ---------------------------------------------------------------------------- // -TESMRMailPlugin CESMRFsMailboxUtils::FSEmailPluginForEntryL( +EXPORT_C TESMRMailPlugin CESMRFsMailboxUtils::FSEmailPluginForEntryL( const CCalEntry& aEntry ) { FUNC_LOG; - RPointerArray mailboxes; - CleanupStack::PushL( - TCleanupItem( - MailboxPointerArrayCleanup, - &mailboxes ) ); + RCPointerArray mailboxes; + CleanupClosePushL( mailboxes ); ListMailBoxesL( MailClientL(), - mailboxes ); - + mailboxes ); + CCalUser* phoneOwner = aEntry.PhoneOwnerL(); TPtrC poMailAddress( phoneOwner->Address() ); - + CFSMailBox* fsEmailMailbox = NULL; TInt mailboxCount( mailboxes.Count() ); for (TInt j(0); j < mailboxCount && !fsEmailMailbox; ++j ) - { + { TPtrC mailboxOwnerAddName( mailboxes[j]->OwnMailAddress().GetEmailAddress() ); - + if ( KEqualEmailAddress == mailboxOwnerAddName.CompareF(poMailAddress) ) { // Correct mailbox is found fsEmailMailbox = mailboxes[j]; } - } - + } + TESMRMailPlugin plugin( EESMRUnknownPlugin ); - + if ( fsEmailMailbox ) { // Mailbox was found --> We need to resolve mailboxes plug-in @@ -268,54 +252,41 @@ TUid::Uid( KFSEmailImap4 ) == pluginId ) { plugin = EESMRImapPop; - } + } } - - CleanupStack::PopAndDestroy( &mailboxes ); + + CleanupStack::PopAndDestroy( &mailboxes ); return plugin; } // ---------------------------------------------------------------------------- -// CESMRFsMailboxUtils::FSEmailMailBoxForEntryL +// CESMRFsMailboxUtils::DefaultMailboxSupportCapabilityL // ---------------------------------------------------------------------------- // -TFSMailMsgId CESMRFsMailboxUtils::FSEmailMailBoxForEntryL( - const CCalEntry& aEntry ) +EXPORT_C TBool CESMRFsMailboxUtils::DefaultMailboxSupportCapabilityL( + CESMRFsMailboxUtils::TMRMailboxCapability aCapability ) { FUNC_LOG; - RPointerArray mailboxes; - CleanupStack::PushL( - TCleanupItem( MailboxPointerArrayCleanup, &mailboxes ) ); - - ListMailBoxesL( MailClientL(), mailboxes ); - CCalUser* phoneOwner = aEntry.PhoneOwnerL(); - TPtrC poMailAddress( phoneOwner->Address() ); + TBool retValue( EFalse ); + + CFSMailBox* defaultMailbox = DefaultMailboxL(); + CleanupStack::PushL( defaultMailbox ); + ASSERT( defaultMailbox ); - CFSMailBox* fsEmailMailbox = NULL; - TInt mailboxCount( mailboxes.Count() ); - for (TInt j(0); j < mailboxCount && !fsEmailMailbox; ++j ) - { - TPtrC mailboxOwnerAddName( - mailboxes[j]->OwnMailAddress().GetEmailAddress() ); - - if ( KEqualEmailAddress == - mailboxOwnerAddName.CompareF( poMailAddress ) ) + switch ( aCapability ) + { + case CESMRFsMailboxUtils::EMRCapabilityAttachment: { - // Correct mailbox is found - fsEmailMailbox = mailboxes[j]; + retValue = defaultMailbox->HasCapability( + EFSMboxCapaSupportsAttahmentsInMR ); } + break; } - TFSMailMsgId retVal; // default ctor constructs a null id. + CleanupStack::PopAndDestroy( defaultMailbox ); - if ( fsEmailMailbox ) - { - retVal = fsEmailMailbox->GetId(); - } - - CleanupStack::PopAndDestroy( &mailboxes ); - return retVal; + return retValue; } // ---------------------------------------------------------------------------- @@ -398,5 +369,46 @@ return *iMailClient; } +// ---------------------------------------------------------------------------- +// CESMRFsMailboxUtils::DefaultMailboxL +// ---------------------------------------------------------------------------- +// +CFSMailBox* CESMRFsMailboxUtils::DefaultMailboxL() + { + FUNC_LOG; + + CFSMailBox* defaultMailbox( NULL ); + + CMRMailboxUtils::TMailboxInfo mailboxInfo; + TInt err = iMRMailboxUtils.GetDefaultMRMailBoxL( mailboxInfo ); + + if ( KErrNone == err ) + { + RCPointerArray mailboxes; + CleanupClosePushL( mailboxes ); + + ListMailBoxesL( MailClientL(), mailboxes ); + + TInt mailboxCount( mailboxes.Count() ); + for (TInt j(0); j < mailboxCount && !defaultMailbox; ++j ) + { + TPtrC mailboxOwnerAddName( + mailboxes[j]->OwnMailAddress().GetEmailAddress() ); + + if ( KEqualEmailAddress == + mailboxOwnerAddName.CompareF( mailboxInfo.iEmailAddress) ) + { + // Default mailbox is found + defaultMailbox = mailboxes[j]; + mailboxes.Remove( j ); + } + } + + CleanupStack::PopAndDestroy( &mailboxes ); + } + + return defaultMailbox; + } + // EOF