diff -r 000000000000 -r dd21522fd290 codhandler/ddrecog/src/DdRecog.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/codhandler/ddrecog/src/DdRecog.cpp Mon Mar 30 12:54:55 2009 +0300 @@ -0,0 +1,163 @@ +/* +* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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 class CDdRecog. +* +* +*/ + + +// INCLUDE FILES + +#include +#include +#include +#include +#include +#include +#include +#include "DdRecog.h" +#include "DdRecogLogger.h" + +// ================= CONSTANTS ======================= + +/// UID of DD Viewer Application. +LOCAL_D const TUid KDdUidDdViewerApp = { DD_VIEWER_UID }; +/// Preferred recognition buffer size. +const TInt KPreferedBufferSize = 1024; +/// DD MIME type string. +_LIT8( KDdMimeType, DD_MIME_TYPE ); +/// DD file extension. +_LIT( KDdExt,".dd" ); +/// DD content recognition pattern (8 bit). +_LIT8( KDd8,"= len && !aName.Right( len ).CompareF( KDdExt ) ) + { + CLOG_WRITE( "DoRecognize: extension is '.dd'" ); + // Named ".dd" + iDataType = TDataType( KDdMimeType ); + iConfidence = ECertain; + } + else + { + CLOG_WRITE( "DoRecognize: pattern search" ); + // Not named ".dd". Recognition by pattern-matching. + // Prepare pointers to buffer (both 8 and 16 bits). + TPtrC8 buf8( aBuffer ); + if ( aBuffer.Length() > KPreferedBufferSize ) + { + buf8.Set( aBuffer.Left( KPreferedBufferSize ) ); + } + TPtrC buf16( (TText*)buf8.Ptr(), buf8.Length() / 2 ); + // Find DD-specific pattern in buffer (both 8 and 16 bits). + if ( buf8.FindF( KDd8 ) >= 0 || buf16.FindF( KDd16 ) >= 0 ) + { + iDataType = TDataType( KDdMimeType ); + iConfidence = ECertain; + } + } + CLOG_WRITE_FORMAT( "DoRecognize: confidence: %d", iConfidence ); + CLOG_LEAVEFN( "CDdRecog::DoRecognizeL" ); + } + +/** +* Implementation group proxy. +* @param aTableCount Table count is returned here. +* @return Implementation table is returned here. +*/ +EXPORT_C const TImplementationProxy* ImplementationGroupProxy +( TInt& aTableCount ) + { + aTableCount = + sizeof( ImplementationTable ) / sizeof( TImplementationProxy ); + return ImplementationTable; + }