os/mm/mmlibs/mmfw/Recogniser/src/others.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2006-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 #include "parsers.h"
    17 
    18 //
    19 // This file format is treated differently from all the others in that if the
    20 // file extension is not recognised then the file is not recognised.
    21 // Only once the extension is recognised does it try to match any header data.
    22 //
    23 void TRAMParser::DoRecognise(const TDesC& aFileExt, CReader& aReader, TMatch& aMatch)
    24 	{
    25 	TBool extMatch = (aFileExt.MatchF(TPtrC(KExtRAM)) != KErrNotFound);
    26 	if (extMatch)
    27 		{
    28 		aMatch.iMime = KMimeRAM;
    29 		TPtrC8 header = MAKE_TPtrC8(KSigRAM);
    30 		
    31 		if (aReader.Match(header))
    32 			{
    33 			aMatch.iConfidence = KConfProbable;
    34 			}
    35 		else
    36 			{
    37 			aMatch.iConfidence = KConfPossible;
    38 			}
    39 		}
    40 	}
    41 
    42 
    43 //
    44 // SDP and XPS have almost identical header signatures, so when it comes to
    45 // recognise an SDP file with a bad extension, it can be incorrectly identified
    46 // as an XPS file.
    47 //
    48 void TSDPParser::DoRecognise(const TDesC& aFileExt, CReader& aReader, TMatch& aMatch)
    49 	{
    50 	TBool extMatch = (aFileExt.MatchF(TPtrC(KExtSDP)) != KErrNotFound);
    51 	if (extMatch)
    52 		{
    53 		aMatch.iMime = KMimeSDP;
    54 		TPtrC8 header = MAKE_TPtrC8(KSigSDP);
    55 		
    56 		if (aReader.Match(header))
    57 			{
    58 			aMatch.iConfidence = KConfProbable;
    59 			}
    60 		else
    61 			{
    62 			aMatch.iConfidence = KConfPossible;
    63 			}
    64 		}
    65 	}
    66 
    67 
    68 //
    69 // See TSDPParser::DoRecognise comment.
    70 //
    71 void TXPSParser::DoRecognise(const TDesC& aFileExt, CReader& aReader, TMatch& aMatch)
    72 	{
    73 	TBool extMatch = (aFileExt.MatchF(TPtrC(KExtXPS)) != KErrNotFound);
    74 	if (extMatch)
    75 		{
    76 		aMatch.iMime = KMimeXPS;
    77 		TPtrC8 header = MAKE_TPtrC8(KSigXPS);
    78 		
    79 		if (aReader.Match(header))
    80 			{
    81 			aMatch.iConfidence = KConfProbable;
    82 			}
    83 		else
    84 			{
    85 			aMatch.iConfidence = KConfPossible;
    86 			}
    87 		}
    88 	}
    89