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