telephonyserverplugins/common_tsy/commontsy/src/mmgsmwcdma/cmmcallgsmwcdmaextwithdispatcher.cpp
changeset 0 3553901f7fa8
child 14 7ef16719d8cb
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifdef USING_CTSY_DISPATCHER
       
    17 
       
    18 /**
       
    19  * This file contains additional function definitions for the CMmCallGsmWcdmaExt class
       
    20  * in CTSY for use when the CTSY is used with the CTSY Dispatcher. 
       
    21  */
       
    22 
       
    23 #include "cmmcallgsmwcdmaext.h"
       
    24 #include "cmmphonetsy.h"
       
    25 #include "cmmcalltsy.h"
       
    26 #include "cmmcalllist.h"
       
    27 
       
    28 // ---------------------------------------------------------------------------
       
    29 // CMmCallGsmWcdmaExt::SwapL
       
    30 // This method can be used to swap between active and held calls.
       
    31 // (other items were commented in a header).
       
    32 // ---------------------------------------------------------------------------
       
    33 //
       
    34 TInt CMmCallGsmWcdmaExt::SwapL(TInt aCallId)
       
    35 	{
       
    36     TInt ret = KErrNone;
       
    37 
       
    38     // CTSY supports RMobileCall::Swap where there are two calls (one held, one active)
       
    39     // and their states are swapped. Where Swap() is called on a single call, this is
       
    40     // not supported.
       
    41     CMmPhoneTsy& mmPhone = *iMmCallTsy->Phone();
       
    42     CMmCallList& callList = *mmPhone.CallList();
       
    43     CMmCallTsy* call = callList.GetMmCallById(aCallId);
       
    44     
       
    45     if (!call)
       
    46     	{
       
    47     	ret = KErrGeneral;
       
    48     	}
       
    49     else
       
    50     	{
       
    51     	const RMobileCall::TMobileCallStatus callStatus = call->MobileCallStatus();
       
    52     	
       
    53     	switch(callStatus)
       
    54     		{
       
    55     		case RMobileCall::EStatusHold:
       
    56     			{
       
    57     			// Pack the following to the dispatcher:
       
    58     			// Call status of held call in iCallId in CCallDataPackage
       
    59     		    CCallDataPackage package;
       
    60         		package.SetCallIdAndMode(aCallId, iSymbianCallMode);
       
    61         		// Get connected call and pack its call ID
       
    62         		CMmCallTsy* connectedCall = callList.GetMmCallByStatus(RMobileCall::EStatusConnected);
       
    63         		if (connectedCall)
       
    64         			{
       
    65         			TInt connectedCallId = connectedCall->CallId();
       
    66         			package.PackData(&connectedCallId);
       
    67         			ret = iMessageManager->HandleRequestL(EMobileCallSwap, &package);
       
    68         			}
       
    69         		else
       
    70         			{
       
    71         			ret = KErrNotSupported;
       
    72         			}
       
    73         		
       
    74     			break;
       
    75     			}
       
    76     			
       
    77     		case RMobileCall::EStatusConnected:
       
    78     			{
       
    79     		    // Pack the following to the dispatcher:
       
    80     		    // Call status of connected call in additional parameter slot in CCallDataPackage
       
    81     		    CCallDataPackage package;
       
    82     			package.PackData(&aCallId);
       
    83         		// Get held call and pack its call ID
       
    84         		CMmCallTsy* heldCall = callList.GetMmCallByStatus(RMobileCall::EStatusHold);
       
    85         		if (heldCall)
       
    86         			{
       
    87         			package.SetCallIdAndMode(heldCall->CallId(), heldCall->CallMode());
       
    88         			ret = iMessageManager->HandleRequestL(EMobileCallSwap, &package);
       
    89         			}
       
    90         		else
       
    91         			{
       
    92         			ret = KErrNotSupported;
       
    93         			}
       
    94     			break;
       
    95     			}
       
    96     		
       
    97     		default:
       
    98     			{
       
    99     	 		ret = KErrNotReady; // Call is neither held nor in EStatusConnected state.
       
   100     								// Cannot swap it.
       
   101     			break;
       
   102     			}
       
   103     		}
       
   104     	}
       
   105 
       
   106     return ret;
       
   107     }
       
   108 
       
   109 
       
   110 // ---------------------------------------------------------------------------
       
   111 // CMmCallGsmWcdmaExt::TransferL
       
   112 // This method transfers call to another destination.
       
   113 // (other items were commented in a header).
       
   114 // ---------------------------------------------------------------------------
       
   115 //
       
   116 TInt CMmCallGsmWcdmaExt::TransferL()
       
   117     {
       
   118     TInt ret( KErrNone );
       
   119 
       
   120     // Retrieve possible held call
       
   121     CMmCallTsy* mmCall = iMmCallTsy->Phone()->CallList()->GetMmCallByStatus( 
       
   122         RMobileCall::EStatusHold );
       
   123 
       
   124     if ( mmCall )
       
   125         {
       
   126         // Held call Id
       
   127 TFLOGSTRING2("TSY: CMmCallGsmWcdmaExt::Transfer, CallId: %d", \
       
   128             mmCall->CallId() );
       
   129 
       
   130 		// With the CTSY dispatcher, there are two call IDs sent from the CTSY
       
   131 		// The first (packed in iCallId of the data package is the call ID
       
   132 		// of the held call, the second is the call ID of the ringing or
       
   133 		// connected call.
       
   134 		CMmCallTsy* mmCall2 = iMmCallTsy->Phone()->CallList()->GetMmCallByStatus(
       
   135 		                RMobileCall::EStatusConnected );
       
   136 		if (!mmCall2)
       
   137 			{
       
   138 			// Can't find a connected call, find a ringing call
       
   139 			mmCall2 = iMmCallTsy->Phone()->CallList()->GetMmCallByStatus(
       
   140 					                RMobileCall::EStatusRinging );
       
   141 			}
       
   142 
       
   143 		if (mmCall2)
       
   144 			{
       
   145 			CCallDataPackage package;
       
   146 			// Set call id (of held call) and call mode (call mode not used but
       
   147 			// something needs to be packed there).
       
   148 			package.SetCallIdAndMode( mmCall->CallId(), iSymbianCallMode );
       
   149 			TInt callId2 = mmCall2->CallId();
       
   150 			package.PackData(&callId2);
       
   151 			ret = iMessageManager->HandleRequestL(EMobileCallTransfer, &package);
       
   152 			}
       
   153 		else
       
   154 			{
       
   155 			ret = KErrNotReady;
       
   156 			}
       
   157         }
       
   158     else
       
   159         {
       
   160         ret = KErrNotReady;
       
   161         }
       
   162 
       
   163     return ret;
       
   164     }
       
   165 
       
   166 #endif //USING_CTSY_DISPATCHER
       
   167