ccservices/cmsservices/cmsengine/Server/src/cmsserversession.cpp
branchRCL_3
changeset 6 e8e3147d53eb
parent 5 81f8547efd4f
child 7 b3431bff8c19
equal deleted inserted replaced
5:81f8547efd4f 6:e8e3147d53eb
    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
   808             IsTopContactL( aMessage );
   822             IsTopContactL( aMessage );
   809             break;
   823             break;
   810             }
   824             }
   811 		case ECmsSetVoiceCallDefault:
   825 		case ECmsSetVoiceCallDefault:
   812         	{
   826         	{
   813         	iCmsServer->PhonebookProxyHandle().SetVoiceCallDefaultL();
   827         	iServerContact->SetVoiceCallDefaultL();
   814         	aMessage.Complete( KErrNone );
   828         	aMessage.Complete( KErrNone );
   815         	break;
   829         	break;
   816         	}
   830         	}
   817         default:
   831         default:
   818             {
   832             {