telephonyserverplugins/simtsy/src/CSimDtmf.cpp
branchRCL_3
changeset 65 630d2f34d719
parent 0 3553901f7fa8
child 66 07a122eea281
equal deleted inserted replaced
61:17af172ffa5f 65:630d2f34d719
     1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2001-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    17 
    17 
    18 /**
    18 /**
    19  @file
    19  @file
    20 */
    20 */
    21 
    21 
       
    22 
       
    23 
       
    24 #include "OstTraceDefinitions.h"
       
    25 #ifdef OST_TRACE_COMPILER_IN_USE
       
    26 #include "CSimDtmfTraces.h"
       
    27 #endif
       
    28 
    22 #include <testconfigfileparser.h>
    29 #include <testconfigfileparser.h>
    23 #include "CSimDtmf.h"
    30 #include "CSimDtmf.h"
    24 #include "CSimPhone.h"
    31 #include "CSimPhone.h"
    25 #include "CSimVoiceCall.h"
    32 #include "CSimVoiceCall.h"
    26 #include "Simlog.h"
       
    27 
    33 
    28 const TInt KPauseDuration=2;		//< The duration of a "pause" DTMF character.
    34 const TInt KPauseDuration=2;		//< The duration of a "pause" DTMF character.
    29 const TInt KDtmfToneDuration=3;		//< The duration of a standard DTMF character (tone or "pause").
    35 const TInt KDtmfToneDuration=3;		//< The duration of a standard DTMF character (tone or "pause").
    30 
    36 
    31 CSimDtmf* CSimDtmf::NewL(CSimPhone* aPhone)
    37 CSimDtmf* CSimDtmf::NewL(CSimPhone* aPhone)
   288 		return ret;
   294 		return ret;
   289 
   295 
   290 	case EEventTimer:
   296 	case EEventTimer:
   291 		__ASSERT_ALWAYS(iState==ETxTone,SimPanic(EIllegalDtmfEvent));
   297 		__ASSERT_ALWAYS(iState==ETxTone,SimPanic(EIllegalDtmfEvent));
   292 		__ASSERT_ALWAYS(iDtmfString,SimPanic(EIllegalDtmfEvent));
   298 		__ASSERT_ALWAYS(iDtmfString,SimPanic(EIllegalDtmfEvent));
   293 		LOGMISC1("Completed sending DTMF Tone");
   299 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMDTMF_ACTIONEVENT1_1, "Completed sending DTMF Tone");
   294 		iDtmfStringIndex++;
   300 		iDtmfStringIndex++;
   295 		if(iDtmfStringIndex<iDtmfData->Length())
   301 		if(iDtmfStringIndex<iDtmfData->Length())
   296 			ret = ProcessTone((*iDtmfData)[iDtmfStringIndex],ETrue);
   302 			ret = ProcessTone((*iDtmfData)[iDtmfStringIndex],ETrue);
   297 		else
   303 		else
   298 			{
   304 			{
   304 	case EEventStopDtmfTone:
   310 	case EEventStopDtmfTone:
   305 		if(iDtmfString)
   311 		if(iDtmfString)
   306 			return KErrInUse;
   312 			return KErrInUse;
   307 		if(iState!=ETxTone)			// If there's been no StartDtmfTone, then return an error.
   313 		if(iState!=ETxTone)			// If there's been no StartDtmfTone, then return an error.
   308 			return KErrUnknown;
   314 			return KErrUnknown;
   309 		LOGMISC1("Stopping DTMF Tone");
   315 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMDTMF_ACTIONEVENT1_2, "Stopping DTMF Tone");
   310 		iState=EIdle;
   316 		iState=EIdle;
   311 		return KErrNone;
   317 		return KErrNone;
   312 
   318 
   313 	case EEventContinueDtmf:
   319 	case EEventContinueDtmf:
   314 		if(iState!=EStopped)
   320 		if(iState!=EStopped)
   315 			return KErrUnknown;
   321 			return KErrUnknown;
   316 		__ASSERT_ALWAYS(iDtmfString,SimPanic(EIllegalDtmfEvent));
   322 		__ASSERT_ALWAYS(iDtmfString,SimPanic(EIllegalDtmfEvent));
   317 		LOGMISC1("Continuing Transmitting a DTMF string after a wait");
   323 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMDTMF_ACTIONEVENT1_3, "Continuing Transmitting a DTMF string after a wait");
   318 		iDtmfStringIndex++;
   324 		iDtmfStringIndex++;
   319 		if(iDtmfStringIndex<iDtmfData->Length())
   325 		if(iDtmfStringIndex<iDtmfData->Length())
   320 			ret = ProcessTone((*iDtmfData)[iDtmfStringIndex],ETrue);
   326 			ret = ProcessTone((*iDtmfData)[iDtmfStringIndex],ETrue);
   321 		else
   327 		else
   322 			{
   328 			{
   362 	const TChar wait('w');
   368 	const TChar wait('w');
   363 	const TChar pause('p');
   369 	const TChar pause('p');
   364 
   370 
   365 	if(aTone==wait)
   371 	if(aTone==wait)
   366 		{
   372 		{
   367 		LOGMISC1("Starting to perform a DTMF wait; character w");
   373 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMDTMF_PROCESSTONE_1, "Starting to perform a DTMF wait; character w");
   368 		iState=EStopped;
   374 		iState=EStopped;
   369 		CheckNotification();
   375 		CheckNotification();
   370 		return KErrNone;
   376 		return KErrNone;
   371 		}
   377 		}
   372 	else if(aTone.IsDigit()||(aTone>='A')&&(aTone<='D'))
   378 	else if(aTone.IsDigit()||(aTone>='A')&&(aTone<='D'))
   373 		{
   379 		{
   374 		LOGMISC2("Starting to send DTMF Tone %c", TUint(aTone));
   380 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMDTMF_PROCESSTONE_2, "Starting to send DTMF Tone %u", TUint(aTone));
   375 		iState=ETxTone;
   381 		iState=ETxTone;
   376 		if(aStartTimer)
   382 		if(aStartTimer)
   377 			{
   383 			{
   378 			iTimer->Start(KDtmfToneDuration,this);
   384 			iTimer->Start(KDtmfToneDuration,this);
   379 			}
   385 			}
   383 		{
   389 		{
   384 		if(!aStartTimer)
   390 		if(!aStartTimer)
   385 			{
   391 			{
   386 			return KErrArgument;  // can't tx a single "pause" character
   392 			return KErrArgument;  // can't tx a single "pause" character
   387 			}
   393 			}
   388 		LOGMISC1("Starting to perform a DTMF pause; character p");
   394 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMDTMF_PROCESSTONE_3, "Starting to perform a DTMF pause; character p");
   389 		iState=ETxTone;
   395 		iState=ETxTone;
   390 		iTimer->Start(KPauseDuration,this);
   396 		iTimer->Start(KPauseDuration,this);
   391 		return KErrNone;
   397 		return KErrNone;
   392 		}
   398 		}
   393 	return KErrArgument;			// Illegal DTMF character.
   399 	return KErrArgument;			// Illegal DTMF character.