2 * Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
27 #ifndef __CCTTOKENTYPE_H__
28 #define __CCTTOKENTYPE_H__
30 #include <ct/mcttokentype.h>
33 * Abstract base class for a handler object to be called when a CCTTokenType is
34 * deleted. The handler is called simply by being deleted. It is called from
35 * CCTTokenType's destructor.
37 * This allows for ecom-loaded tokens to be destroyed properly without
38 * forcing clients of ctframework.dll to link against ecom.
42 class CCTTokenTypeDeleteHandler : public CBase
45 IMPORT_C virtual ~CCTTokenTypeDeleteHandler();
51 * This abstract class is instantiated using the ECom plug-in architecture
52 * for a particular token type. This adds a delayed destruction behaviour
53 * to MCTTokenType, which defines the majority of the interface.
55 * This class uses protected inheritance from CBase so that clients cannot
56 * inadvertantly call delete on instances of it - they should call the Release()
63 class CCTTokenType : protected CBase, public MCTTokenType
66 /** Gets a file server session */
70 /** Increments the reference count.
72 * Must be called for every token created from this interface */
73 IMPORT_C void IncReferenceCount();
75 // From this point onwards, everything in this class is essentialy
76 // internal and of no interest to dereived classes.
79 /** Creates a CCTTokenType given its CCTTokenTypeInfo.
81 * Static constructor function that uses the ECom
82 * plug-in architecture to load the actual implementation.
84 * @param aInfo Information about the token type.
85 * @param aFs An open file server session.
86 * @return The new token type object. */
87 IMPORT_C static CCTTokenType* NewL(const CCTTokenTypeInfo& aInfo, RFs aFs);
89 /** Creates a CCTTokenType given the UID of the token type.
91 * Static constructor function that uses the ECom
92 * plug-in architecture to load the actual implementation.
94 * @param aUID The UID of the token type.
95 * @param aFs An open file server session.
96 * @return The new token type object. */
97 IMPORT_C static CCTTokenType* NewL(TUid aUID, RFs aFs);
99 /** Releases the token type object.
101 * To be called when you have finished with the object.
103 * The API does not allow the destructor to be directly called as this object
104 * could remain in existence for longer to hold onto the ECom handle on the DLL;
105 * for instance it may not be deleted until all tokens and interfaces have also
107 IMPORT_C virtual void Release();
109 /** Gets the UID of the token type.
111 * @return The UID of the token type. */
112 IMPORT_C virtual TUid Type() const;
114 /** Gets the label of the token type.
116 * @return The label of the token type. */
117 IMPORT_C virtual const TDesC& Label() const;
120 IMPORT_C CCTTokenType();
123 IMPORT_C virtual ~CCTTokenType();
126 * For 2 phase construction.
128 * This function must be called by derived NewL() functions if and only if the
129 * class is being constructed without using ECom.
131 IMPORT_C void ConstructL(TUid aUID, const TDesC& aLabel, RFs aFs);
134 static CCTTokenType* CreateTokenTypeLC(TUid aUid);
137 /// Delete handler, called on destruction
138 CCTTokenTypeDeleteHandler* iDeleteHandler;
140 /// A refedrence count
143 /// The UID of the token type.
146 /// The label of the token type
152 inline RFs& CCTTokenType::Fs()
153 /** Gets the file server session.
155 * @return The file server session. */
160 // These are defined here as they need to ahve both MCTTokenType and
161 // CCTTokenType defined before they can be.
162 inline MCTTokenType* MCTTokenType::NewL(const CCTTokenTypeInfo& aInfo, RFs aFs)
163 /** Creates a MCTTokenType object given it's CCTTokenTypeInfo.
165 * @param aInfo Information about the token type.
166 * @param aFs An open file server session.
167 * @return A new token type object. */
169 return CCTTokenType::NewL(aInfo, aFs);
172 inline MCTTokenType* MCTTokenType::NewL(TUid aUID, RFs aFs)
173 /** Creates a MCTTokenType object given the UID of the token type.
175 * @param aUID The UID of the token type.
176 * @param aFs An open file server session.
177 * @return A new token type object. */
179 return CCTTokenType::NewL(aUID, aFs);
182 #endif //__CCTTOKENTYPE_H__