phoneuis/easydialing/edcontactor/src/edphonecall.cpp
branchRCL_3
changeset 3 8871b09be73b
equal deleted inserted replaced
2:c84cf270c54f 3:8871b09be73b
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Launching Call.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "edcontactorheaders.h"
       
    21 
       
    22 _LIT8( KAiwContentTypeAll, "*" );
       
    23 
       
    24 /// Unnamed namespace for local definitions
       
    25 namespace
       
    26 	{
       
    27 
       
    28 #ifdef _DEBUG
       
    29 	enum TPanicCode
       
    30 		{
       
    31 		EPanicPreCond_ExecuteL = 1,
       
    32 		EPanicPreCond_ExecuteL2
       
    33 		};
       
    34 
       
    35 	void Panic(TPanicCode aReason)
       
    36 		{
       
    37 		_LIT(KPanicText, "CCmsPhoneCall");
       
    38 		User::Panic (KPanicText, aReason);
       
    39 		}
       
    40 #endif // _DEBUG
       
    41 
       
    42 
       
    43 	} /// namespace
       
    44 
       
    45 // ============================ MEMBER FUNCTIONS ===============================
       
    46 
       
    47 // ---------------------------------------------------------
       
    48 // CEDPhoneCall::ExecuteL
       
    49 // ---------------------------------------------------------
       
    50 void CEDPhoneCall::ExecuteL( const TDesC& aPhoneNumber, TEDPhoneCallType aCallType,
       
    51         TBool aForcedCallType, TUint32 aServiceId )
       
    52 	{   
       
    53     __ASSERT_DEBUG( NULL != &aPhoneNumber && 0 < aPhoneNumber.Size(), Panic(EPanicPreCond_ExecuteL) );
       
    54 
       
    55 #ifdef _DEBUG
       
    56 	HBufC8* buf = HBufC8::NewLC( aPhoneNumber.Length() );
       
    57 	buf->Des().Copy( aPhoneNumber );
       
    58 	TPtrC8 numberDesc( buf->Des() );
       
    59 	CleanupStack::PopAndDestroy( buf );
       
    60 #endif
       
    61 
       
    62 	//aPhoneNumber will be an xsp id of format "ServiceName:UserId"
       
    63 	//here we need to truncate the servicename and pass only the UserId
       
    64 	
       
    65     //Find if aPhoneNumber of type "ServiceName:UserId"
       
    66 	//if true, then remove the service part
       
    67     TPtrC phoneNum( aPhoneNumber );
       
    68     TInt phoneNumberStart = phoneNum.Locate(':');
       
    69     
       
    70     if ( KErrNotFound != phoneNumberStart )
       
    71         {
       
    72         phoneNumberStart++; //To get rid of ':'
       
    73         phoneNum.Set( phoneNum.Mid( phoneNumberStart ) );
       
    74         }
       
    75     
       
    76     HBufC* numBuf = phoneNum.AllocLC();
       
    77     TPtr numDesc( numBuf->Des() );
       
    78 	CommonPhoneParser::ParsePhoneNumber( numDesc,
       
    79 			CommonPhoneParser::EPhoneClientNumber ); 
       
    80 
       
    81 	CAiwDialDataExt* dialDataExt = CAiwDialDataExt::NewLC();
       
    82 	dialDataExt->SetPhoneNumberL( *numBuf );
       
    83 	switch (aCallType)
       
    84 	    {
       
    85 	    case ECCACallTypeVoice:
       
    86 	        if ( aForcedCallType )
       
    87 	            {
       
    88 	            // Use this with Action menu's Voice call icon
       
    89 	            dialDataExt->SetCallType( CAiwDialData::EAIWForcedCS );
       
    90 	            }
       
    91 	        else
       
    92 	            {
       
    93 	            // To be on the safe side, use this with Send key and big Call icon
       
    94 	            dialDataExt->SetCallType( CAiwDialData::EAIWVoice );
       
    95 	            }
       
    96 	        break;
       
    97 	    case ECCACallTypeVoIP:
       
    98 	        dialDataExt->SetServiceId( aServiceId );
       
    99 	        dialDataExt->SetCallType( CAiwDialData::EAIWVoiP );
       
   100 	        break;
       
   101 	    case ECCACallTypeVideo:
       
   102 	        dialDataExt->SetCallType( CAiwDialData::EAIWForcedVideo );
       
   103 	        break;
       
   104 	    default:
       
   105 	        dialDataExt->SetCallType( CAiwDialData::EAIWForcedCS );
       
   106 	        break;
       
   107 	    }
       
   108 
       
   109 	dialDataExt->SetWindowGroup( CCoeEnv::Static()->RootWin().Identifier() );
       
   110 
       
   111 	DoAIWCallL( *dialDataExt );
       
   112 
       
   113 	CleanupStack::PopAndDestroy( dialDataExt );
       
   114 	CleanupStack::PopAndDestroy( numBuf );
       
   115 	}
       
   116 
       
   117 // ---------------------------------------------------------
       
   118 // CEDPhoneCall::DoAIWCallL
       
   119 // ---------------------------------------------------------
       
   120 void CEDPhoneCall::DoAIWCallL( CAiwDialDataExt& aDialData )
       
   121 	{
       
   122 	RCriteriaArray interest;
       
   123 	CleanupClosePushL( interest );
       
   124 	CAiwCriteriaItem* criteria = CAiwCriteriaItem::NewLC( KAiwCmdCall,
       
   125 			KAiwCmdCall, KAiwContentTypeAll );
       
   126 	criteria->SetServiceClass( TUid::Uid(KAiwClassBase) );
       
   127 	User::LeaveIfError( interest.Append( criteria ) );
       
   128 
       
   129 	CAiwServiceHandler* serviceHandler = CAiwServiceHandler::NewLC();
       
   130 	serviceHandler->AttachL( interest );
       
   131 
       
   132 	CAiwGenericParamList& paramList = serviceHandler->InParamListL();
       
   133 	aDialData.FillInParamListL( paramList );
       
   134 
       
   135 	serviceHandler->ExecuteServiceCmdL( KAiwCmdCall, paramList,
       
   136 			serviceHandler->OutParamListL(), 0, NULL );
       
   137 	serviceHandler->DetachL( interest );
       
   138 
       
   139 	CleanupStack::PopAndDestroy( serviceHandler );
       
   140 	CleanupStack::PopAndDestroy( criteria );
       
   141 	CleanupStack::PopAndDestroy( &interest );
       
   142 	}
       
   143 
       
   144 //  End of File