contenthandling/webrecognisers/waprecogniser/recwap.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 19 Aug 2010 10:05:08 +0300
branchRCL_3
changeset 18 0818dd463d41
parent 0 2e3d3ce01487
permissions -rw-r--r--
Revision: 201031 Kit: 201033

// Copyright (c) 2002-2009 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:
//

// header
#include "recwap.h"

// other includes
#include <wapmime.h> // constants
#include <f32file.h> // TParse

#ifdef __UI_FRAMEWORKS_V2__
#include <ecom/implementationproxy.h>
#endif //__UI_FRAMEWORKS_V2__


//
// CApaWapRecognizer
//
CApaWapRecognizer::CApaWapRecognizer()
:CApaDataRecognizerType(KUidMimeWapRecognizer,CApaDataRecognizerType::ENormal)
	{
	// All these mime types have reasonable recognition
	iCountDataTypes=KWapNumMimeTypes;
	}

TUint CApaWapRecognizer::PreferredBufSize()
	{
	// no buffer recognition yet
	return 0;
	}

TDataType CApaWapRecognizer::SupportedDataTypeL(TInt aIndex) const
	{
	__ASSERT_DEBUG(aIndex>=0 && aIndex<KWapNumMimeTypes,User::Invariant());
	switch (aIndex)
		{
	case 0:
		return TDataType(KWMLMimeType);
	case 1:
		return TDataType(KWMLCMimeType);
	case 2:
		return TDataType(KWMLDTDMimeType);
	case 3:
		return TDataType(KWBXMLMimeType);
	case 4:
	default:
		return TDataType(KWMLSCMimeType);
		}
	}

void CApaWapRecognizer::DoRecognizeL(const TDesC& aName, const TDesC8& /*aBuffer*/)
	{
	if (aName.Length()<3)
		return;

	TInt dotPos = aName.LocateReverse('.');
	if (dotPos == KErrNotFound)
		return;
	TInt extLength = aName.Length() - dotPos;

	HBufC* ext = aName.Right(extLength).AllocL();
	CleanupStack::PushL(ext);

	if (ext->CompareF(KDotWML)==0)
		{
		iDataType=TDataType(KWMLMimeType);
		iConfidence=EProbable;
		}
	else if (ext->CompareF(KDotWMLC)==0)
		{
		iDataType=TDataType(KWMLCMimeType);
		iConfidence=EProbable;
		}
	else if (ext->CompareF(KDotWMLSC)==0)
		{
		iDataType=TDataType(KWMLSCMimeType);
		iConfidence=EProbable;
		}
	else if (ext->CompareF(KDotWMLS)==0)
		{
		iDataType=TDataType(KWMLSMimeType);
		iConfidence=EProbable;
		}
	else if (ext->CompareF(KDotWBXML)==0)
		{
		iDataType=TDataType(KWBXMLMimeType);
		iConfidence=EProbable;
		}
	else if (ext->CompareF(KDotWDTD)==0)
		{
		iDataType=TDataType(KWMLDTDMimeType);
		iConfidence=EProbable;
		}
	CleanupStack::PopAndDestroy();	// ext
	}

#ifdef __UI_FRAMEWORKS_V2__

const TImplementationProxy ImplementationTable[]=
	{
	IMPLEMENTATION_PROXY_ENTRY(0x1000515E,CApaWapRecognizer::NewL)
	};

EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
    {
    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
    return ImplementationTable;
    }

CApaDataRecognizerType* CApaWapRecognizer::NewL()
	{
    return new (ELeave) CApaWapRecognizer();
    }

#else

EXPORT_C CApaDataRecognizerType* CreateRecognizer()
//
// The gate function - ordinal 1
//
	{
	CApaDataRecognizerType* thing=new CApaWapRecognizer();
	return thing; // NULL if new failed
	}

#endif //__UI_FRAMEWORKS_V2__

#ifndef EKA2
GLDEF_C TInt E32Dll(TDllReason /*aReason*/)
//
// DLL entry point
//
	{
	return KErrNone;
	}
#endif