installationservices/refswinstallationplugin/source/sifrefpkgrec.cpp
branchRCL_3
changeset 25 7333d7932ef7
equal deleted inserted replaced
24:5cc91383ab1e 25:7333d7932ef7
       
     1 /*
       
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 * This file implements a package file recognizer for the Reference Installer.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include <apmrec.h>
       
    21 #include <apmstd.h>
       
    22 #include <ecom/ecom.h>
       
    23 #include <ecom/implementationproxy.h>
       
    24 #include "sifrefpkgrec.h"
       
    25 
       
    26 const TUid KUidSifRefRecognizer = {0x10286351};
       
    27 const TInt KSifRefNumMimeTypes = 1;
       
    28 const TInt KMaxBufferLength = 0xf;
       
    29 
       
    30 /**
       
    31 A file extension and MIME type for reference package files.
       
    32 */
       
    33 _LIT(KSifRefBinPkgFileExt, ".sifrefbinpkg");
       
    34 _LIT8(KDataTestMimeType, "binary/sif-refpkg");
       
    35 
       
    36 CSifRefPkgRecognizer::CSifRefPkgRecognizer()
       
    37 	: CApaDataRecognizerType(KUidSifRefRecognizer, CApaDataRecognizerType::EHigh)
       
    38 	{
       
    39 	iCountDataTypes = KSifRefNumMimeTypes;
       
    40 	}
       
    41 
       
    42 TUint CSifRefPkgRecognizer::PreferredBufSize()
       
    43 	{
       
    44 	return KMaxBufferLength;
       
    45 	}
       
    46 
       
    47 TDataType CSifRefPkgRecognizer::SupportedDataTypeL(TInt /*aIndex*/) const
       
    48 	{
       
    49 	return TDataType(KDataTestMimeType);
       
    50 	}
       
    51 
       
    52 void CSifRefPkgRecognizer::DoRecognizeL(const TDesC& aName, const TDesC8& /*aBuffer*/)
       
    53 	{
       
    54 	// This recognition is based only on the file extension
       
    55 	const TInt dotPos = aName.LocateReverse('.');
       
    56 	if (dotPos == KErrNotFound)
       
    57 		{
       
    58 		iConfidence = ENotRecognized;
       
    59 		return;
       
    60 		}
       
    61 	TInt extLen = aName.Length() - dotPos;
       
    62 	if (aName.Right(extLen).CompareF(KSifRefBinPkgFileExt) == 0)
       
    63 		{
       
    64 		iDataType = TDataType(KDataTestMimeType);
       
    65 		iConfidence = ECertain;
       
    66 		}
       
    67 	}
       
    68 
       
    69 CApaDataRecognizerType* CSifRefPkgRecognizer::CreateRecognizerL()
       
    70 	{
       
    71 	return new (ELeave) CSifRefPkgRecognizer();
       
    72 	}
       
    73 
       
    74 const TImplementationProxy ImplementationTable[] = 
       
    75 	{
       
    76 		IMPLEMENTATION_PROXY_ENTRY(0x10286352, CSifRefPkgRecognizer::CreateRecognizerL)
       
    77 	};
       
    78 
       
    79 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
       
    80 	{
       
    81 	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
       
    82 	return ImplementationTable;
       
    83 	}