diff -r 000000000000 -r 71ca22bcf22a mmfenh/advancedaudiocontroller/audiotonecontrollerplugin/ringtonerecognizer/src/recrt.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mmfenh/advancedaudiocontroller/audiotonecontrollerplugin/ringtonerecognizer/src/recrt.cpp Tue Feb 02 01:08:46 2010 +0200 @@ -0,0 +1,128 @@ +/* +* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of RingToneRecognizer +* +*/ + + +// INCLUDE FILES +#include +#include +#include + +#include "recrt.h" + +// CONSTANTS +const TUid KUidRingingToneRecognizer={0x100059EA}; +const TInt KMinBufferLength=3; // minimum amount of file needed to determine a ringing tone IF it's not called .rng +const TInt KMaxBufferLength=4; // maximum amount of buffer space we will ever use +const TInt KRecRtCommandByte=2; // 00000010 = +const TInt KRecRtUnicodeCommandByte=3; // 00000011 = if unicode +const TInt KRecRtProgrammingByte=74; // 01001010 = + 0 +const TInt KRecRtSoundByte=58; // 00111010 = + 0 +const TInt KRecRtUnicodeByte=68; // 01000100 = + 0 +const TInt KRecRtFileExtensionsMightBeValid=4; // If the file name length > 4, the file extension might be valid + +_LIT(KRingToneExtension1, ".rng"); +_LIT(KRingToneExtension2, ".nrt"); +_LIT(KRingToneExtension3, ".ota"); +_LIT8(KDataTypeRingingTone,"application/vnd.nokia.ringing-tone"); + + + +CApaRingingToneRecognizer::CApaRingingToneRecognizer() + : CApaDataRecognizerType(KUidRingingToneRecognizer, CApaDataRecognizerType::ENormal) + { + iCountDataTypes=1; + } + +CApaRingingToneRecognizer::~CApaRingingToneRecognizer() + { + // Do nothing + } + +TUint CApaRingingToneRecognizer::PreferredBufSize() + { + return KMaxBufferLength; + } + +TDataType CApaRingingToneRecognizer::SupportedDataTypeL(TInt /*aIndex*/) const + { +// __ASSERT_DEBUG(aIndex==0,User::Invariant()); + return TDataType(KDataTypeRingingTone); + } + +void CApaRingingToneRecognizer::DoRecognizeL(const TDesC& aName, const TDesC8& aBuffer) +{ + TBool nameRecognized=EFalse; + if (aName.Length()>KRecRtFileExtensionsMightBeValid) + { + if ((aName.Right(KRecRtFileExtensionsMightBeValid).CompareF(KRingToneExtension1)==0) || + (aName.Right(KRecRtFileExtensionsMightBeValid).CompareF(KRingToneExtension2)==0) || + (aName.Right(KRecRtFileExtensionsMightBeValid).CompareF(KRingToneExtension3)==0)) + nameRecognized=ETrue; + } + + TInt length=aBuffer.Length(); + if (length