os/mm/mmlibs/mmfw/Recogniser/src/others.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include "parsers.h"
sl@0
    17
sl@0
    18
//
sl@0
    19
// This file format is treated differently from all the others in that if the
sl@0
    20
// file extension is not recognised then the file is not recognised.
sl@0
    21
// Only once the extension is recognised does it try to match any header data.
sl@0
    22
//
sl@0
    23
void TRAMParser::DoRecognise(const TDesC& aFileExt, CReader& aReader, TMatch& aMatch)
sl@0
    24
	{
sl@0
    25
	TBool extMatch = (aFileExt.MatchF(TPtrC(KExtRAM)) != KErrNotFound);
sl@0
    26
	if (extMatch)
sl@0
    27
		{
sl@0
    28
		aMatch.iMime = KMimeRAM;
sl@0
    29
		TPtrC8 header = MAKE_TPtrC8(KSigRAM);
sl@0
    30
		
sl@0
    31
		if (aReader.Match(header))
sl@0
    32
			{
sl@0
    33
			aMatch.iConfidence = KConfProbable;
sl@0
    34
			}
sl@0
    35
		else
sl@0
    36
			{
sl@0
    37
			aMatch.iConfidence = KConfPossible;
sl@0
    38
			}
sl@0
    39
		}
sl@0
    40
	}
sl@0
    41
sl@0
    42
sl@0
    43
//
sl@0
    44
// SDP and XPS have almost identical header signatures, so when it comes to
sl@0
    45
// recognise an SDP file with a bad extension, it can be incorrectly identified
sl@0
    46
// as an XPS file.
sl@0
    47
//
sl@0
    48
void TSDPParser::DoRecognise(const TDesC& aFileExt, CReader& aReader, TMatch& aMatch)
sl@0
    49
	{
sl@0
    50
	TBool extMatch = (aFileExt.MatchF(TPtrC(KExtSDP)) != KErrNotFound);
sl@0
    51
	if (extMatch)
sl@0
    52
		{
sl@0
    53
		aMatch.iMime = KMimeSDP;
sl@0
    54
		TPtrC8 header = MAKE_TPtrC8(KSigSDP);
sl@0
    55
		
sl@0
    56
		if (aReader.Match(header))
sl@0
    57
			{
sl@0
    58
			aMatch.iConfidence = KConfProbable;
sl@0
    59
			}
sl@0
    60
		else
sl@0
    61
			{
sl@0
    62
			aMatch.iConfidence = KConfPossible;
sl@0
    63
			}
sl@0
    64
		}
sl@0
    65
	}
sl@0
    66
sl@0
    67
sl@0
    68
//
sl@0
    69
// See TSDPParser::DoRecognise comment.
sl@0
    70
//
sl@0
    71
void TXPSParser::DoRecognise(const TDesC& aFileExt, CReader& aReader, TMatch& aMatch)
sl@0
    72
	{
sl@0
    73
	TBool extMatch = (aFileExt.MatchF(TPtrC(KExtXPS)) != KErrNotFound);
sl@0
    74
	if (extMatch)
sl@0
    75
		{
sl@0
    76
		aMatch.iMime = KMimeXPS;
sl@0
    77
		TPtrC8 header = MAKE_TPtrC8(KSigXPS);
sl@0
    78
		
sl@0
    79
		if (aReader.Match(header))
sl@0
    80
			{
sl@0
    81
			aMatch.iConfidence = KConfProbable;
sl@0
    82
			}
sl@0
    83
		else
sl@0
    84
			{
sl@0
    85
			aMatch.iConfidence = KConfPossible;
sl@0
    86
			}
sl@0
    87
		}
sl@0
    88
	}
sl@0
    89