telephonyserverplugins/ctsydispatchlayer/test/dispatchertests/dispatchsrc/isvao.cpp
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
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 #include "isvao.h"
       
    17 #include "testconstants.h"
       
    18 
       
    19 CIsvAO::CIsvAO() :
       
    20 	CActive(EPriorityStandard), iLineStatusPckg(iLineStatus), 
       
    21 	iCurrentOperation(EIsvNoOperation)
       
    22 	{
       
    23 	} // CIsvAO::CIsvAO
       
    24 
       
    25 CIsvAO* CIsvAO::NewLC()
       
    26 	{
       
    27 	CIsvAO* self = new ( ELeave ) CIsvAO();
       
    28 	CleanupStack::PushL(self);
       
    29 	self->ConstructL();
       
    30 	return self;
       
    31 	} // CIsvAO::NewLC
       
    32 
       
    33 CIsvAO* CIsvAO::NewL()
       
    34 	{
       
    35 	CIsvAO* self = CIsvAO::NewLC();
       
    36 	CleanupStack::Pop(self);
       
    37 	return self;
       
    38 	} // CIsvAO::NewL
       
    39 
       
    40 void CIsvAO::ConstructL()
       
    41 	{
       
    42 	iScheduler = new (ELeave) CActiveScheduler();
       
    43 	CActiveScheduler::Install(iScheduler);
       
    44 	CActiveScheduler::Add(this); 
       
    45 
       
    46 	iTelephony = CTelephony::NewL();
       
    47 	} // CIsvAO::ConstructL
       
    48 
       
    49 CIsvAO::~CIsvAO()
       
    50 	{
       
    51 	Cancel();
       
    52 	
       
    53 	if (iTelephony)
       
    54 		{
       
    55 		delete iTelephony;
       
    56 		iTelephony = NULL;
       
    57 		}
       
    58 	
       
    59 	if (iScheduler)
       
    60 		{
       
    61 		delete iScheduler;
       
    62 		iScheduler = NULL;
       
    63 		}
       
    64 	
       
    65 	} // CIsvAO::~CIsvAO
       
    66 
       
    67 void CIsvAO::DoCancel()
       
    68 	{
       
    69 	switch (iCurrentOperation)
       
    70 		{
       
    71 		case EIsvDial:
       
    72 			iTelephony->CancelAsync(CTelephony::EDialNewCallCancel);
       
    73 			break;
       
    74 		case EIsvHangUp:
       
    75 			iTelephony->CancelAsync(CTelephony::EHangupCancel);
       
    76 			break;
       
    77 		case EIsvAnswer:
       
    78 			iTelephony->CancelAsync(CTelephony::EAnswerIncomingCallCancel);
       
    79 			break;
       
    80 		case EIsvNotifyIncomingCall:
       
    81 			iTelephony->CancelAsync(CTelephony::EVoiceLineStatusChangeCancel);
       
    82 			break;
       
    83 		default:
       
    84 			break;
       
    85 		}
       
    86 	
       
    87 	iCurrentOperation = EIsvNoOperation;
       
    88 	} // CIsvAO::DoCancel
       
    89 
       
    90 void CIsvAO::DoOperation(TIsvOperation aOperation)
       
    91 	{
       
    92 	Cancel(); 
       
    93 	
       
    94 	iCurrentOperation = aOperation;
       
    95 	
       
    96 	switch (aOperation)
       
    97 		{
       
    98 		case EIsvDial:
       
    99 			{
       
   100 			
       
   101 			CTelephony::TTelNumber telNumber(KPhoneNumber);
       
   102 			CTelephony::TCallParamsV1 callParams;
       
   103 			callParams.iIdRestrict = CTelephony::ESendMyId;
       
   104 			CTelephony::TCallParamsV1Pckg callParamsPckg(callParams);
       
   105 		
       
   106 			iTelephony->DialNewCall(iStatus, callParamsPckg, telNumber, iCallId);
       
   107 			}
       
   108 			break;
       
   109 		case EIsvHangUp:
       
   110 			{
       
   111 			iTelephony->Hangup(iStatus, iCallId);
       
   112 			}
       
   113 			break;
       
   114 		case EIsvAnswer:
       
   115 			{
       
   116 			iTelephony->AnswerIncomingCall(iStatus, iCallId);
       
   117 			}
       
   118 			break;
       
   119 		case EIsvNotifyIncomingCall:
       
   120 			{
       
   121 			iTelephony->NotifyChange(iStatus,
       
   122 									CTelephony::EVoiceLineStatusChange,
       
   123 									iLineStatusPckg);
       
   124 			}
       
   125 			break;
       
   126 		default:
       
   127 			break;
       
   128 		}
       
   129 
       
   130 	SetActive();
       
   131 	CActiveScheduler::Start();
       
   132 	} // CIsvAO::Dial
       
   133 
       
   134 void CIsvAO::RunL()
       
   135 	{
       
   136 	iCurrentOperation = EIsvNoOperation;
       
   137 	CActiveScheduler::Stop();
       
   138 	} // CIsvAO::RunL
       
   139 
       
   140 TInt CIsvAO::RunError(TInt aError)
       
   141 	{
       
   142 	return aError;
       
   143 	} // CIsvAO::RunError
       
   144