williamr@2: /* williamr@2: * Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@2: * under the terms of the License "Eclipse Public License v1.0" williamr@2: * which accompanies this distribution, and is available williamr@2: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: williamr@2: * CTTokenType Codes williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @file williamr@2: @internalTechnology williamr@2: */ williamr@2: williamr@2: #ifndef __CCTTOKENTYPE_H__ williamr@2: #define __CCTTOKENTYPE_H__ williamr@2: williamr@2: #include williamr@2: williamr@2: /** williamr@2: * Abstract base class for a handler object to be called when a CCTTokenType is williamr@2: * deleted. The handler is called simply by being deleted. It is called from williamr@2: * CCTTokenType's destructor. williamr@2: * williamr@2: * This allows for ecom-loaded tokens to be destroyed properly without williamr@2: * forcing clients of ctframework.dll to link against ecom. williamr@2: * williamr@2: * @internalTechnology williamr@2: */ williamr@2: class CCTTokenTypeDeleteHandler : public CBase williamr@2: { williamr@2: public: williamr@2: IMPORT_C virtual ~CCTTokenTypeDeleteHandler(); williamr@2: }; williamr@2: williamr@2: /** williamr@2: * A token type. williamr@2: * williamr@2: * This abstract class is instantiated using the ECom plug-in architecture williamr@2: * for a particular token type. This adds a delayed destruction behaviour williamr@2: * to MCTTokenType, which defines the majority of the interface. williamr@2: * williamr@2: * This class uses protected inheritance from CBase so that clients cannot williamr@2: * inadvertantly call delete on instances of it - they should call the Release() williamr@2: * method instead. williamr@2: * williamr@2: * @publishedPartner williamr@2: * @released williamr@2: * @since v7.0 williamr@2: */ williamr@2: class CCTTokenType : protected CBase, public MCTTokenType williamr@2: { williamr@2: public: williamr@2: /** Gets a file server session */ williamr@2: inline RFs& Fs(); williamr@2: williamr@2: protected: williamr@2: /** Increments the reference count. williamr@2: * williamr@2: * Must be called for every token created from this interface */ williamr@2: IMPORT_C void IncReferenceCount(); williamr@2: williamr@2: // From this point onwards, everything in this class is essentialy williamr@2: // internal and of no interest to dereived classes. williamr@2: public: williamr@2: williamr@2: /** Creates a CCTTokenType given its CCTTokenTypeInfo. williamr@2: * williamr@2: * Static constructor function that uses the ECom williamr@2: * plug-in architecture to load the actual implementation. williamr@2: * williamr@2: * @param aInfo Information about the token type. williamr@2: * @param aFs An open file server session. williamr@2: * @return The new token type object. */ williamr@2: IMPORT_C static CCTTokenType* NewL(const CCTTokenTypeInfo& aInfo, RFs aFs); williamr@2: williamr@2: /** Creates a CCTTokenType given the UID of the token type. williamr@2: * williamr@2: * Static constructor function that uses the ECom williamr@2: * plug-in architecture to load the actual implementation. williamr@2: * williamr@2: * @param aUID The UID of the token type. williamr@2: * @param aFs An open file server session. williamr@2: * @return The new token type object. */ williamr@2: IMPORT_C static CCTTokenType* NewL(TUid aUID, RFs aFs); williamr@2: williamr@2: /** Releases the token type object. williamr@2: * williamr@2: * To be called when you have finished with the object. williamr@2: * williamr@2: * The API does not allow the destructor to be directly called as this object williamr@2: * could remain in existence for longer to hold onto the ECom handle on the DLL; williamr@2: * for instance it may not be deleted until all tokens and interfaces have also williamr@2: * been released. */ williamr@2: IMPORT_C virtual void Release(); williamr@2: williamr@2: /** Gets the UID of the token type. williamr@2: * williamr@2: * @return The UID of the token type. */ williamr@2: IMPORT_C virtual TUid Type() const; williamr@2: williamr@2: /** Gets the label of the token type. williamr@2: * williamr@2: * @return The label of the token type. */ williamr@2: IMPORT_C virtual const TDesC& Label() const; williamr@2: williamr@2: protected: williamr@2: IMPORT_C CCTTokenType(); williamr@2: williamr@2: /** Destructor */ williamr@2: IMPORT_C virtual ~CCTTokenType(); williamr@2: williamr@2: /** williamr@2: * For 2 phase construction. williamr@2: * williamr@2: * This function must be called by derived NewL() functions if and only if the williamr@2: * class is being constructed without using ECom. williamr@2: */ williamr@2: IMPORT_C void ConstructL(TUid aUID, const TDesC& aLabel, RFs aFs); williamr@2: williamr@2: private: williamr@2: static CCTTokenType* CreateTokenTypeLC(TUid aUid); williamr@2: williamr@2: private: williamr@2: /// Delete handler, called on destruction williamr@2: CCTTokenTypeDeleteHandler* iDeleteHandler; williamr@2: williamr@2: /// A refedrence count williamr@2: TInt iCount; williamr@2: williamr@2: /// The UID of the token type. williamr@2: TUid iUID; williamr@2: williamr@2: /// The label of the token type williamr@2: HBufC* iLabel; williamr@2: williamr@2: RFs iFs; williamr@2: }; williamr@2: williamr@2: inline RFs& CCTTokenType::Fs() williamr@2: /** Gets the file server session. williamr@2: * williamr@2: * @return The file server session. */ williamr@2: { williamr@2: return iFs; williamr@2: } williamr@2: williamr@2: // These are defined here as they need to ahve both MCTTokenType and williamr@2: // CCTTokenType defined before they can be. williamr@2: inline MCTTokenType* MCTTokenType::NewL(const CCTTokenTypeInfo& aInfo, RFs aFs) williamr@2: /** Creates a MCTTokenType object given it's CCTTokenTypeInfo. williamr@2: * williamr@2: * @param aInfo Information about the token type. williamr@2: * @param aFs An open file server session. williamr@2: * @return A new token type object. */ williamr@2: { williamr@2: return CCTTokenType::NewL(aInfo, aFs); williamr@2: } williamr@2: williamr@2: inline MCTTokenType* MCTTokenType::NewL(TUid aUID, RFs aFs) williamr@2: /** Creates a MCTTokenType object given the UID of the token type. williamr@2: * williamr@2: * @param aUID The UID of the token type. williamr@2: * @param aFs An open file server session. williamr@2: * @return A new token type object. */ williamr@2: { williamr@2: return CCTTokenType::NewL(aUID, aFs); williamr@2: } williamr@2: williamr@2: #endif //__CCTTOKENTYPE_H__