authorisation/userpromptservice/policies/source/fingerprint.cpp
changeset 8 35751d3474b7
equal deleted inserted replaced
2:675a964f4eb5 8:35751d3474b7
       
     1 /*
       
     2 * Copyright (c) 2007-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 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <ups/fingerprint.h>
       
    20 #include <ups/upsconst.h>
       
    21 #include <ups/upserr.h>
       
    22 
       
    23 using namespace UserPromptService;
       
    24 
       
    25 
       
    26 EXPORT_C CFingerprint* CFingerprint::NewL(const TDesC8& aFingerprint, const TDesC& aDescription)
       
    27 /**
       
    28 Creates a new fingerprint object.
       
    29 @param	aFingerprint	  An 8-bit descriptor containing the raw fingerprint data.
       
    30 @param	aDescription	  A human readable description of the fingerprint.
       
    31 @return	A pointer to the new fingerprint object.
       
    32 @leave	KErrUpsBadFingerprintLength if the fingerprint is empty or exceeds 
       
    33 		KUpsMaxFingerprintLength bytes in length.
       
    34 */
       
    35 	{
       
    36 	CFingerprint* self = CFingerprint::NewLC(aFingerprint, aDescription);
       
    37 	CleanupStack::Pop(self);
       
    38 	return self;
       
    39 	}
       
    40 
       
    41 EXPORT_C CFingerprint* CFingerprint::NewLC(const TDesC8& aFingerprint, const TDesC& aDescription)
       
    42 /**
       
    43 Creates a new fingerprint object.
       
    44 @param	aFingerprint	  An 8-bit descriptor containing the raw fingerprint data.
       
    45 @param	aDescription	  A human readable description of the fingerprint.
       
    46 @return A pointer to the new fingerprint object.
       
    47 @leave	KErrUpsBadFingerprintLength if the fingerprint is empty or exceeds 
       
    48 		KUpsMaxFingerprintLength bytes in length.
       
    49 */
       
    50 	{
       
    51 	CFingerprint* self = new(ELeave) CFingerprint();
       
    52 	CleanupStack::PushL(self);
       
    53 	self->ConstructL(aFingerprint, aDescription);
       
    54 	return self;
       
    55 	}
       
    56 
       
    57 void CFingerprint::ConstructL(const TDesC8& aFingerprint, const TDesC& aDescription)
       
    58 /**
       
    59 Second phase constructor
       
    60 @param	aFingerprint The raw fingerprint data.
       
    61 @param	aDescription A description of the fingerprint data.
       
    62 @leave	KErrUpsBadFingerprintLength if the fingerprint exceeds 
       
    63 		KUpsMaxFingerprintLength bytes in length.
       
    64 */
       
    65 	{
       
    66 	if (aFingerprint.Length() > KUpsMaxFingerprintLength)
       
    67 		{
       
    68 		User::Leave(KErrUpsBadFingerprintLength);
       
    69 		}
       
    70 	iFingerprint = aFingerprint.AllocL();
       
    71 	iDescription = aDescription.AllocL();
       
    72 	}
       
    73 	
       
    74 EXPORT_C const TDesC8& CFingerprint::Fingerprint() const
       
    75 /**
       
    76 Gets the raw fingerprint data.
       
    77 @return An 8-bit descriptor containing the raw fingerprint data.
       
    78 */
       
    79 	{
       
    80 	return *iFingerprint;
       
    81 	}
       
    82 	
       
    83 EXPORT_C const TDesC& CFingerprint::Description() const
       
    84 /**
       
    85 Gets the description of the fingerprint.
       
    86 @return A 16-bit description containing the description of the fingerprint.
       
    87 */
       
    88 	{
       
    89 	return *iDescription;
       
    90 	}
       
    91 
       
    92 CFingerprint::CFingerprint() 
       
    93 /**
       
    94 Constructor
       
    95 */
       
    96 	{	
       
    97 	}
       
    98 
       
    99 CFingerprint::~CFingerprint() 
       
   100 /**
       
   101 Destructor
       
   102 */
       
   103 	{
       
   104 	delete iFingerprint;
       
   105 	delete iDescription;
       
   106 	}