os/security/cryptomgmtlibs/cryptotokenfw/inc/ct/mcttokenobject.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/cryptomgmtlibs/cryptotokenfw/inc/ct/mcttokenobject.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,128 @@
     1.4 +/*
     1.5 +* Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +/**
    1.23 + @file
    1.24 + @publishedAll
    1.25 + @released    
    1.26 +*/
    1.27 +
    1.28 +
    1.29 +#ifndef __MCTTOKENOBJECT_H__
    1.30 +#define __MCTTOKENOBJECT_H__
    1.31 +
    1.32 +class MCTToken;
    1.33 +
    1.34 +/** 
    1.35 + * The base class for all token objects.
    1.36 + *
    1.37 + * Any object representing something managed via a particular token interface 
    1.38 + * should be derived from this class. It provides certain common attributes that 
    1.39 + * all objects must have (e.g. Label, Type, Token, Handle) and code to interact 
    1.40 + * with the token's reference counting code. Token objects themselves are not 
    1.41 + * reference counted, but the token will not be closed while token objects from 
    1.42 + * it remain in existence. (Token objects can implement their own reference counting 
    1.43 + * framework if required.) 
    1.44 + *
    1.45 + * @since v7.0 
    1.46 + */
    1.47 +class MCTTokenObject 
    1.48 +	{
    1.49 +public:
    1.50 +	/** 
    1.51 +	 * Releases the MCTTokenObject object.
    1.52 +	 *
    1.53 +	 * To be called when you have finished with the object. 
    1.54 +	 */
    1.55 +	IMPORT_C void Release();
    1.56 +
    1.57 +	/** 
    1.58 +	 * Gets the object's human-readable label.	
    1.59 +	 *
    1.60 +	 * @return	A human-readable label of the object. 
    1.61 +	 */
    1.62 +	virtual const TDesC& Label() const = 0;
    1.63 +	
    1.64 +	/** 
    1.65 +	 * Gets a reference to the associated token.
    1.66 +	 *
    1.67 +	 * @return	The associated token. 
    1.68 +	 */
    1.69 +	virtual MCTToken& Token() const = 0;
    1.70 +
    1.71 +	/** 
    1.72 +	 * Gets the UID representing the type of the token object.
    1.73 +	 *
    1.74 +	 * The meanings of possible UIDs should be documented in the documentation for 
    1.75 +	 * the interface that returns them.
    1.76 +	 *
    1.77 +	 * @return	The UID representing the type of the token object. 
    1.78 +	 */
    1.79 +	virtual TUid Type() const = 0;
    1.80 +
    1.81 +	/** 
    1.82 +	 * Gets a handle for the object.
    1.83 +	 *
    1.84 +	 * The primary purpose of the handle is to allow token objects to be 'passed' 
    1.85 +	 * between processes. 
    1.86 +	 *
    1.87 +	 * @see TCTTokenObjectHandle for more details. 
    1.88 +	 * @return	The handle of the Token Object. 
    1.89 +	 */
    1.90 +	virtual TCTTokenObjectHandle Handle() const = 0;
    1.91 + protected:
    1.92 +	/** 
    1.93 +	 * Releases the object once the base-class framework work has been done.
    1.94 +	 * 
    1.95 +	 * The default implementation simply does a 'delete this', but derived classes 
    1.96 +	 * can substitute their own behaviour; for instance, to implement reference counting 
    1.97 +	 * of the token objects themselves. 
    1.98 +	 */
    1.99 +	IMPORT_C virtual void DoRelease();
   1.100 +
   1.101 +	/**
   1.102 +	 * Constructor. This needs a token in order to increment the
   1.103 +	 * token's reference count. 
   1.104 +	 * 
   1.105 +	 * @param aToken	The associated token.
   1.106 +	 */
   1.107 +	IMPORT_C MCTTokenObject(MCTToken& aToken);
   1.108 +
   1.109 +	/** This destructor is protected as clients should use Release() instead. 
   1.110 +	*/
   1.111 +	inline virtual ~MCTTokenObject() = 0;
   1.112 +
   1.113 +	/** 
   1.114 +	 * Increments the token's reference count by one.  
   1.115 +	 * 
   1.116 +	 * This is neccessary to allow derived classes to implement their own 
   1.117 +	 * reference counting, as Release() automatically call Release() on the token. 
   1.118 +	 */
   1.119 +	IMPORT_C void AddTokenRef();
   1.120 +	};
   1.121 +
   1.122 +/** 
   1.123 + * Destructor.
   1.124 + *
   1.125 + * Frees all resources owned by the object, prior to its destruction. 
   1.126 + */
   1.127 +inline MCTTokenObject::~MCTTokenObject()
   1.128 +	{
   1.129 +	}
   1.130 +
   1.131 +#endif