36 #include "cmsdebug.h" |
36 #include "cmsdebug.h" |
37 |
37 |
38 #include <MVPbkContactFieldTextData.h> |
38 #include <MVPbkContactFieldTextData.h> |
39 #include <MVPbkContactFieldUriData.h> |
39 #include <MVPbkContactFieldUriData.h> |
40 #include <MVPbkContactFieldData.h> |
40 #include <MVPbkContactFieldData.h> |
41 #include <cemailaccounts.h> // For finding out available email account counts |
|
42 #include <e32base.h> |
41 #include <e32base.h> |
|
42 |
|
43 // For finding mailbox accounts |
|
44 #include <EmailInterfaceFactory.h> |
|
45 #include <MEmailMailbox.h> |
|
46 |
|
47 |
43 namespace { |
48 namespace { |
44 |
49 |
45 TBool IsFieldTypeVoipCapable( TInt aFieldTypeResId, TInt aVoipFlag ) |
50 TBool IsFieldTypeVoipCapable( TInt aFieldTypeResId, TInt aVoipFlag ) |
46 { |
51 { |
47 TBool ret( EFalse ); |
52 TBool ret( EFalse ); |
480 availability = iServerContact->ParseVoIPAvailabilityL(); |
485 availability = iServerContact->ParseVoIPAvailabilityL(); |
481 break; |
486 break; |
482 } |
487 } |
483 case VPbkFieldTypeSelectorFactory::EEmailEditorSelector: |
488 case VPbkFieldTypeSelectorFactory::EEmailEditorSelector: |
484 { |
489 { |
485 CEmailAccounts* emailAccounts = CEmailAccounts::NewLC(); |
490 using namespace EmailInterface; |
486 RArray<TPopAccount> popAccounts; |
491 |
487 RArray<TImapAccount> imapAccounts; |
492 CEmailInterfaceFactory* factory = CEmailInterfaceFactory::NewL(); |
488 RArray<TSmtpAccount> smtpAccounts; |
493 CleanupStack::PushL( factory ); |
|
494 MEmailInterface* ifPtr = factory->InterfaceL( KEmailClientApiInterface ); |
|
495 MEmailClientApi* clientApi = static_cast<MEmailClientApi*>( ifPtr ); |
|
496 CleanupReleasePushL( *clientApi ); |
489 |
497 |
490 emailAccounts->GetPopAccountsL(popAccounts); |
498 RMailboxPtrArray mailboxes; |
491 emailAccounts->GetImapAccountsL(imapAccounts); |
499 TRAPD( error, clientApi->GetMailboxesL( mailboxes );); |
492 emailAccounts->GetSmtpAccountsL(smtpAccounts); |
500 TInt count = mailboxes.Count(); |
493 CleanupStack::PopAndDestroy(emailAccounts); |
|
494 |
501 |
495 // If no mailbox exists, set availability to false |
502 // Release mailboxs before releasing clientapi |
496 if( ( popAccounts.Count() + imapAccounts.Count() + smtpAccounts.Count() ) == 0 ) |
503 for ( TInt i=0; i<count; i++ ) |
497 { |
504 { |
498 availability = EFalse; |
505 MEmailMailbox* mailbox = mailboxes[i]; |
|
506 mailbox->Release(); |
499 } |
507 } |
500 |
508 |
501 popAccounts.Reset(); |
509 mailboxes.Close(); |
502 imapAccounts.Reset(); |
510 |
503 smtpAccounts.Reset(); |
511 CleanupStack::PopAndDestroy( 2 ); // clientApi and factory |
|
512 |
|
513 if( count == 0 ) |
|
514 { |
|
515 availability = EFalse; |
|
516 } |
|
517 |
504 break; |
518 break; |
505 } |
519 } |
506 default: |
520 default: |
507 { |
521 { |
508 //In case the type is unknown, just break here and return true |
522 //In case the type is unknown, just break here and return true |