1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/Recogniser/src/mmruf.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,131 @@
1.4 +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef MMRUF_H
1.20 +#define MMRUF_H
1.21 +
1.22 +#include <e32cons.h>
1.23 +#include <apmrec.h>
1.24 +#include <ecom/ecom.h>
1.25 +#include <ecom/implementationproxy.h>
1.26 +#include "constants.h"
1.27 +
1.28 +//
1.29 +// This class is used to store the results of a match.
1.30 +// iConfidence - the confidence of the match
1.31 +// iMime - the matched mime-type.
1.32 +//
1.33 +class TMatch
1.34 + {
1.35 +public:
1.36 + TMatch()
1.37 + : iConfidence(CApaDataRecognizerType::ENotRecognized),
1.38 + iMime(NULL)
1.39 + {
1.40 + }
1.41 +
1.42 + TMatch(TInt aConfidence, const TText8* aMime)
1.43 + : iConfidence(aConfidence),
1.44 + iMime(aMime)
1.45 + {
1.46 + }
1.47 +
1.48 + void Reset()
1.49 + {
1.50 + iConfidence = KConfNotRecognised;
1.51 + iMime = NULL;
1.52 + }
1.53 +
1.54 + TInt iConfidence;
1.55 + const TText8* iMime;
1.56 + };
1.57 +
1.58 +
1.59 +//
1.60 +// Function prototype for custom format recogniser functions.
1.61 +// Forward declaration of CReader required.
1.62 +//
1.63 +class CReader;
1.64 +typedef void (*TCustomProc)(const TDesC& aFileExt, CReader& aReader, TMatch& aMatch);
1.65 +
1.66 +
1.67 +//
1.68 +// These macros are used when creating the KSigs table.
1.69 +// CUSTOM_SIG - this is to be used when a format cannot be identified
1.70 +// from a known header pattern. It takes the MIME-type it
1.71 +// tries to identify and a pointer to a function that
1.72 +// does the identification.
1.73 +// HEADER_SIG - this is to be used when a format can be identified
1.74 +// from a known header pattern.
1.75 +//
1.76 +#define CUSTOM_SIG(mime, funcPtr) {NULL, (mime), (TAny*)(funcPtr), 0}
1.77 +#define HEADER_SIG(mime, ext, header) {(ext), (mime), (TAny*)_S8(header), sizeof(header) - 1}
1.78 +
1.79 +
1.80 +//
1.81 +// This structure tells the recogniser how to match a format.
1.82 +// iExt - the standard file extension for the format.
1.83 +// iMime - the defined MIME-type for the format.
1.84 +// iHeaderOrProc - a pointer to either a header signature pattern
1.85 +// (if iHeaderLen = 0) or a function that carries
1.86 +// out in-depth parsing of the file (if iHeaderLen > 0)
1.87 +// iHeaderLen - the length of the header signature in characters, or zero
1.88 +// if iHeaderOrProc is a pointer to a function.
1.89 +//
1.90 +typedef struct
1.91 + {
1.92 + const TText* iExt;
1.93 + const TText8* iMime;
1.94 + TAny* iHeaderOrProc;
1.95 + TInt iHeaderLen;
1.96 + }
1.97 +TSignature;
1.98 +
1.99 +
1.100 +// UIDs taken from Multimedia Allocation Table.
1.101 +static const TInt KRecogniserUID = 0x1027381A;
1.102 +static const TUid KMMRUFDLLUid = {0x102825F6};
1.103 +
1.104 +// The amount of file data wanted from the AppArc framework.
1.105 +static const TInt KPreferredBufSize = 256;
1.106 +
1.107 +// The recogniser priority.
1.108 +static const TInt KRecogniserPriority = CApaDataRecognizerType::ENormal;
1.109 +
1.110 +
1.111 +//
1.112 +// This class does the recognising.
1.113 +//
1.114 +class CMMRUF : public CApaDataRecognizerType
1.115 + {
1.116 +public:
1.117 + static CMMRUF* NewL();
1.118 + virtual ~CMMRUF();
1.119 + TDataType SupportedDataTypeL(TInt aIndex) const;
1.120 + TDataType SupportedDataTypeL(const TText8* aMime) const;
1.121 + TUint PreferredBufSize();
1.122 +
1.123 +protected:
1.124 + void DoRecognizeL(const TDesC& aName, const TDesC8& aBuffer);
1.125 + void SetDataTypeL(TInt aConfidence, const TText8* aMime);
1.126 + TUint8 MatchExtension(const TDesC& aFileName, const TText* aExt) const;
1.127 + TUint8 MatchHeader(const TDesC8& aBuffer, const TDesC8& aHeader) const;
1.128 +
1.129 +private:
1.130 + CMMRUF();
1.131 + };
1.132 +
1.133 +
1.134 +#endif