contenthandling/webrecognisers/waprecogniser/recwap.cpp
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 // header
       
    17 #include "recwap.h"
       
    18 
       
    19 // other includes
       
    20 #include <wapmime.h> // constants
       
    21 #include <f32file.h> // TParse
       
    22 
       
    23 #ifdef __UI_FRAMEWORKS_V2__
       
    24 #include <ecom/implementationproxy.h>
       
    25 #endif //__UI_FRAMEWORKS_V2__
       
    26 
       
    27 
       
    28 //
       
    29 // CApaWapRecognizer
       
    30 //
       
    31 CApaWapRecognizer::CApaWapRecognizer()
       
    32 :CApaDataRecognizerType(KUidMimeWapRecognizer,CApaDataRecognizerType::ENormal)
       
    33 	{
       
    34 	// All these mime types have reasonable recognition
       
    35 	iCountDataTypes=KWapNumMimeTypes;
       
    36 	}
       
    37 
       
    38 TUint CApaWapRecognizer::PreferredBufSize()
       
    39 	{
       
    40 	// no buffer recognition yet
       
    41 	return 0;
       
    42 	}
       
    43 
       
    44 TDataType CApaWapRecognizer::SupportedDataTypeL(TInt aIndex) const
       
    45 	{
       
    46 	__ASSERT_DEBUG(aIndex>=0 && aIndex<KWapNumMimeTypes,User::Invariant());
       
    47 	switch (aIndex)
       
    48 		{
       
    49 	case 0:
       
    50 		return TDataType(KWMLMimeType);
       
    51 	case 1:
       
    52 		return TDataType(KWMLCMimeType);
       
    53 	case 2:
       
    54 		return TDataType(KWMLDTDMimeType);
       
    55 	case 3:
       
    56 		return TDataType(KWBXMLMimeType);
       
    57 	case 4:
       
    58 	default:
       
    59 		return TDataType(KWMLSCMimeType);
       
    60 		}
       
    61 	}
       
    62 
       
    63 void CApaWapRecognizer::DoRecognizeL(const TDesC& aName, const TDesC8& /*aBuffer*/)
       
    64 	{
       
    65 	if (aName.Length()<3)
       
    66 		return;
       
    67 
       
    68 	TInt dotPos = aName.LocateReverse('.');
       
    69 	if (dotPos == KErrNotFound)
       
    70 		return;
       
    71 	TInt extLength = aName.Length() - dotPos;
       
    72 
       
    73 	HBufC* ext = aName.Right(extLength).AllocL();
       
    74 	CleanupStack::PushL(ext);
       
    75 
       
    76 	if (ext->CompareF(KDotWML)==0)
       
    77 		{
       
    78 		iDataType=TDataType(KWMLMimeType);
       
    79 		iConfidence=EProbable;
       
    80 		}
       
    81 	else if (ext->CompareF(KDotWMLC)==0)
       
    82 		{
       
    83 		iDataType=TDataType(KWMLCMimeType);
       
    84 		iConfidence=EProbable;
       
    85 		}
       
    86 	else if (ext->CompareF(KDotWMLSC)==0)
       
    87 		{
       
    88 		iDataType=TDataType(KWMLSCMimeType);
       
    89 		iConfidence=EProbable;
       
    90 		}
       
    91 	else if (ext->CompareF(KDotWMLS)==0)
       
    92 		{
       
    93 		iDataType=TDataType(KWMLSMimeType);
       
    94 		iConfidence=EProbable;
       
    95 		}
       
    96 	else if (ext->CompareF(KDotWBXML)==0)
       
    97 		{
       
    98 		iDataType=TDataType(KWBXMLMimeType);
       
    99 		iConfidence=EProbable;
       
   100 		}
       
   101 	else if (ext->CompareF(KDotWDTD)==0)
       
   102 		{
       
   103 		iDataType=TDataType(KWMLDTDMimeType);
       
   104 		iConfidence=EProbable;
       
   105 		}
       
   106 	CleanupStack::PopAndDestroy();	// ext
       
   107 	}
       
   108 
       
   109 #ifdef __UI_FRAMEWORKS_V2__
       
   110 
       
   111 const TImplementationProxy ImplementationTable[]=
       
   112 	{
       
   113 	IMPLEMENTATION_PROXY_ENTRY(0x1000515E,CApaWapRecognizer::NewL)
       
   114 	};
       
   115 
       
   116 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
       
   117     {
       
   118     aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
       
   119     return ImplementationTable;
       
   120     }
       
   121 
       
   122 CApaDataRecognizerType* CApaWapRecognizer::NewL()
       
   123 	{
       
   124     return new (ELeave) CApaWapRecognizer();
       
   125     }
       
   126 
       
   127 #else
       
   128 
       
   129 EXPORT_C CApaDataRecognizerType* CreateRecognizer()
       
   130 //
       
   131 // The gate function - ordinal 1
       
   132 //
       
   133 	{
       
   134 	CApaDataRecognizerType* thing=new CApaWapRecognizer();
       
   135 	return thing; // NULL if new failed
       
   136 	}
       
   137 
       
   138 #endif //__UI_FRAMEWORKS_V2__
       
   139 
       
   140 #ifndef EKA2
       
   141 GLDEF_C TInt E32Dll(TDllReason /*aReason*/)
       
   142 //
       
   143 // DLL entry point
       
   144 //
       
   145 	{
       
   146 	return KErrNone;
       
   147 	}
       
   148 #endif