epoc32/include/mw/mtudcbas.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 epoc32/include/mtudcbas.h@2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
williamr@2
     1
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     2
// All rights reserved.
williamr@2
     3
// This component and the accompanying materials are made available
williamr@2
     4
// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
williamr@2
     5
// which accompanies this distribution, and is available
williamr@2
     6
// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2
     7
//
williamr@2
     8
// Initial Contributors:
williamr@2
     9
// Nokia Corporation - initial contribution.
williamr@2
    10
//
williamr@2
    11
// Contributors:
williamr@2
    12
//
williamr@2
    13
// Description:
williamr@2
    14
//
williamr@2
    15
williamr@2
    16
#if !defined(__MTUDBAS_H__)
williamr@2
    17
#define __MTUDBAS_H__
williamr@2
    18
williamr@2
    19
#if !defined(__MSVSTD_H__)
williamr@2
    20
#include <msvstd.h>
williamr@2
    21
#endif
williamr@2
    22
williamr@2
    23
#if !defined(__MSVREG_H__)
williamr@2
    24
#include <msvreg.h>
williamr@2
    25
#endif
williamr@2
    26
williamr@2
    27
#if !defined(__MTCLREG_H__)
williamr@2
    28
#include <mtclreg.h>
williamr@2
    29
#endif
williamr@2
    30
williamr@2
    31
#if !defined(__BARSREAD_H__)
williamr@2
    32
#include <barsread.h>
williamr@2
    33
#endif
williamr@2
    34
williamr@2
    35
// Forward references
williamr@2
    36
class CFbsBitmap;
williamr@2
    37
class CCoeEnv;
williamr@2
    38
williamr@2
    39
///////////////////////////////////////////////////
williamr@2
    40
// CBaseMtmUiData - MTM Ui data layer base API   //
williamr@2
    41
///////////////////////////////////////////////////
williamr@2
    42
class CBaseMtmUiData : public CBase
williamr@2
    43
/** Base class for UI Data MTM components. 
williamr@2
    44
williamr@2
    45
CBaseMtmUiData-derived classes allow message client applications to customise 
williamr@2
    46
dynamically their user interfaces for a particular message type. For example, 
williamr@2
    47
if a message client application currently had a fax entry selected, then it 
williamr@2
    48
could use the fax MTM's concrete class to get information on the menus and 
williamr@2
    49
icons that it should display. 
williamr@2
    50
williamr@2
    51
Specifically, functionality falls into the following three areas:
williamr@2
    52
williamr@2
    53
1. supplying MTM-specific icons for Message Server entries
williamr@2
    54
williamr@2
    55
2. supplying user interface text, e.g. for menus, for MTM-specific operations
williamr@2
    56
williamr@2
    57
3. providing checks that MTM functions are suitable for use on an entry. It is 
williamr@2
    58
intended that client applications will use these functions to select dynamically 
williamr@2
    59
the user interface features available dependent on the entry currently selected 
williamr@2
    60
within the application. For example, menu items that do not apply to particular 
williamr@2
    61
entries could be greyed out. Note that OperationSupportedL() performs a similar 
williamr@2
    62
function for MTM-specific functions. Implementations should determine if the 
williamr@2
    63
operation is supported by checking the properties of the entry, such as its 
williamr@2
    64
type. If the operation is not appropriate on the entry, then the aReasonResourceId 
williamr@2
    65
argument is set to the ID of a string in the UI Data MTM's resource file 
williamr@2
    66
that explains why not. Otherwise, aReasonResourceId is 0.
williamr@2
    67
williamr@2
    68
Message client applications use the class to access such functionality polymorphically. 
williamr@2
    69
MTM implementers implement this class to provide such functionality for their 
williamr@2
    70
message protocol. 
williamr@2
    71
@publishedAll
williamr@2
    72
@released
williamr@2
    73
*/
williamr@2
    74
	{
williamr@2
    75
public:
williamr@2
    76
	// --- Types ---
williamr@2
    77
	/** Defines an array of icon bitmaps for the UI Data MTM. 
williamr@2
    78
	
williamr@2
    79
	It is used in the definition of CBaseMtmUiData::iIconArrays. */
williamr@2
    80
	typedef CArrayPtr<CFbsBitmap> CBitmapArray;
williamr@2
    81
	//
williamr@2
    82
	// --- Inline class ---
williamr@2
    83
	class TMtmUiFunction
williamr@2
    84
	/** Provides the interface for clients to access MTM-specific functions, and present 
williamr@2
    85
	these functions to the user. A message client application can use this information to customise the UI.
williamr@2
    86
williamr@2
    87
	The class encapsulates information relating to an MTM-specific operation:
williamr@2
    88
williamr@2
    89
	1. human-readable name: for display on the UI
williamr@2
    90
williamr@2
    91
	2. ID: used to invoke the operation through the CBaseMtmUi::InvokeSyncFunctionL()/InvokeAsyncFunctionL() functions on the associated User Interface MTM 
williamr@2
    92
williamr@2
    93
	3. a suggested hot-key that the UI should support for the operation
williamr@2
    94
williamr@2
    95
	4. flags that describe further operation characteristics. 
williamr@2
    96
@publishedAll
williamr@2
    97
@released
williamr@2
    98
*/
williamr@2
    99
		{
williamr@2
   100
		friend class CBaseMtmUiData;// For access to constructor
williamr@2
   101
	public:
williamr@2
   102
		// --- Constants ---
williamr@2
   103
		/** Enum to define UI Data base class constants. */
williamr@2
   104
		enum 
williamr@2
   105
			{
williamr@2
   106
			/** Maximum length for operation caption. Used in defining iCaption. */
williamr@2
   107
			ECaptionMaxLen=40
williamr@2
   108
			};
williamr@2
   109
williamr@2
   110
	public:
williamr@2
   111
		// --- Construction ---
williamr@2
   112
		IMPORT_C TMtmUiFunction(TResourceReader& aResourceReader);		
williamr@2
   113
		IMPORT_C TMtmUiFunction(const TMtmUiFunction& aFunc);		
williamr@2
   114
williamr@2
   115
	private:
williamr@2
   116
		// --- Private functions ---
williamr@2
   117
		void SetModifiersFromResourceDefinition(TInt aResourceFileModifiers);		
williamr@2
   118
williamr@2
   119
	public:
williamr@2
   120
		// --- Data ---
williamr@2
   121
		/** String, suitable for a menu, describing the operation. */
williamr@2
   122
		TBuf<ECaptionMaxLen>		iCaption;
williamr@2
   123
		/** Character code for a suggested hotkey for the operation. */
williamr@2
   124
		TInt						iPreferredHotKeyKeyCode;
williamr@2
   125
		/** Suggested key modifiers for the hotkey.  */
williamr@2
   126
		TInt						iPreferredHotKeyModifiers;
williamr@2
   127
		/** The ID that can be used to invoke the operation. */
williamr@2
   128
		TInt						iFunctionId;
williamr@2
   129
		/** Flags setting location characteristics of the operation. */
williamr@2
   130
		TUint8						iFunctionType;	// see MTUD.HRH
williamr@2
   131
		/** Flags setting characteristics of the operation. */
williamr@2
   132
		TInt						iFlags;			// see MTUD.HRH
williamr@2
   133
		};
williamr@2
   134
	//
williamr@2
   135
	// --- Destruction ---
williamr@2
   136
	IMPORT_C virtual ~CBaseMtmUiData();
williamr@2
   137
	//
williamr@2
   138
	// --- Accessor functions ---
williamr@2
   139
	IMPORT_C TUid Type() const;
williamr@2
   140
	//
williamr@2
   141
	// --- Context icons ---
williamr@2
   142
	/** Gets an array of bitmaps relevant to the passed context entry. 
williamr@2
   143
	
williamr@2
   144
	The bitmaps within the array should be representations of the same bitmap at various sizes. 
williamr@2
   145
	
williamr@2
   146
	The aStateFlags argument indicates the user interface state, for example, 
williamr@2
   147
	"open", of the entry. 
williamr@2
   148
	
williamr@2
   149
	Requirements:
williamr@2
   150
	
williamr@2
   151
	Implementations should check the type of the context, using TMsvEntry::iType::iUid, 
williamr@2
   152
	and the passed state, and return an appropriate bitmap array.
williamr@2
   153
	
williamr@2
   154
	@param aContext Context entry to return the icons for. 
williamr@2
   155
	@param aStateFlags Flasgs indicating the user interface state of the entry. 
williamr@2
   156
	@return Bitmap array for the given context.. */
williamr@2
   157
	virtual const CBitmapArray& ContextIcon(const TMsvEntry& aContext, TInt aStateFlags) const = 0;
williamr@2
   158
	//
williamr@2
   159
	// --- MTM-Specific function information (e.g. for dynamically-added menu items) ---
williamr@2
   160
	IMPORT_C const CArrayFix<TMtmUiFunction>& MtmSpecificFunctions() const;
williamr@2
   161
	IMPORT_C TBool FunctionRecognised(TInt aFunctionId) const;
williamr@2
   162
	//
williamr@2
   163
	// --- Provide context-specific function information ---
williamr@2
   164
	/** Tests if an entry can be created as a child.
williamr@2
   165
	
williamr@2
   166
	@param aParent The entry under which aNewEntry should be created. 
williamr@2
   167
	@param aNewEntry The entry to which the operation applies. 
williamr@2
   168
	@param aReasonResourceId On return, a resource string ID or 0. 
williamr@2
   169
	@return ETrue, if the operation is appropriate on the entry; 
williamr@2
   170
	EFalse, if the operation is NOT appropriate on the entry. */
williamr@2
   171
	virtual TBool CanCreateEntryL(const TMsvEntry& aParent, TMsvEntry& aNewEntry, TInt& aReasonResourceId) const = 0;
williamr@2
   172
	/** Tests if a delete operation is supported.
williamr@2
   173
	
williamr@2
   174
	@param aContext The entry to which the operation applies. 
williamr@2
   175
	@param aReasonResourceId On return, a resource string ID or 0. 
williamr@2
   176
	@return ETrue, if the operation is appropriate on the entry; 
williamr@2
   177
	EFalse, if the operation is NOT appropriate on the entry. */
williamr@2
   178
	virtual TBool CanDeleteFromEntryL(const TMsvEntry& aContext, TInt& aReasonResourceId) const = 0;
williamr@2
   179
	/** Tests if the entry can be undeleted.
williamr@2
   180
	
williamr@2
   181
	@param aContext The entry to which the operation applies. 
williamr@2
   182
	@param aReasonResourceId On return, a resource string ID or 0. 
williamr@2
   183
	@return ETrue, if the operation is appropriate on the entry; 
williamr@2
   184
	EFalse, if the operation is NOT appropriate on the entry. */
williamr@2
   185
	IMPORT_C virtual TBool CanUnDeleteFromEntryL(const TMsvEntry& aContext, TInt& aReasonResourceId) const;
williamr@2
   186
	/** Tests if the service entry can be deleted.
williamr@2
   187
	
williamr@2
   188
	@param aService The service entry to which the operation applies. 
williamr@2
   189
	@param aReasonResourceId On return, a resource string ID or 0. 
williamr@2
   190
	@return ETrue, if the operation is appropriate on the entry; 
williamr@2
   191
	EFalse, if the operation is NOT appropriate on the entry. */
williamr@2
   192
	virtual TBool CanDeleteServiceL(const TMsvEntry& aService, TInt& aReasonResourceId) const = 0;
williamr@2
   193
	/** Tests if an entry can be replied to.
williamr@2
   194
	
williamr@2
   195
	@param aContext The entry to which the operation applies. 
williamr@2
   196
	@param aReasonResourceId On return, a resource string ID or 0. 
williamr@2
   197
	@return ETrue, if the operation is appropriate on the entry; 
williamr@2
   198
	EFalse, if the operation is NOT appropriate on the entry. */
williamr@2
   199
	virtual TBool CanReplyToEntryL(const TMsvEntry& aContext, TInt& aReasonResourceId) const = 0;
williamr@2
   200
	/** Tests if an entry can be forwarded.
williamr@2
   201
	
williamr@2
   202
	@param aContext The entry to which the operation applies. 
williamr@2
   203
	@param aReasonResourceId On return, a resource string ID or 0. 
williamr@2
   204
	@return ETrue, if the operation is appropriate on the entry; 
williamr@2
   205
	EFalse, if the operation is NOT appropriate on the entry. */
williamr@2
   206
	virtual TBool CanForwardEntryL(const TMsvEntry& aContext, TInt& aReasonResourceId) const = 0;
williamr@2
   207
	/** Tests if the entry can be edited.
williamr@2
   208
	
williamr@2
   209
	@param aContext The entry to which the operation applies. 
williamr@2
   210
	@param aReasonResourceId On return, a resource string ID or 0. 
williamr@2
   211
	@return ETrue, if the operation is appropriate on the entry; 
williamr@2
   212
	EFalse, if the operation is NOT appropriate on the entry. */
williamr@2
   213
	virtual TBool CanEditEntryL(const TMsvEntry& aContext, TInt& aReasonResourceId) const = 0;
williamr@2
   214
	/** Tests if an entry can be viewed.
williamr@2
   215
	
williamr@2
   216
	@param aContext The entry to which the operation applies. 
williamr@2
   217
	@param aReasonResourceId On return, a resource string ID or 0. 
williamr@2
   218
	@return ETrue, if the operation is appropriate on the entry; 
williamr@2
   219
	EFalse, if the operation is NOT appropriate on the entry. */
williamr@2
   220
	virtual TBool CanViewEntryL(const TMsvEntry& aContext, TInt& aReasonResourceId) const = 0;
williamr@2
   221
	/** Tests if an entry can be opened.
williamr@2
   222
	
williamr@2
   223
	@param aContext The entry to which the operation applies. 
williamr@2
   224
	@param aReasonResourceId On return, a resource string ID or 0. 
williamr@2
   225
	@return ETrue, if the operation is appropriate on the entry; 
williamr@2
   226
	EFalse, if the operation is NOT appropriate on the entry. */
williamr@2
   227
	virtual TBool CanOpenEntryL(const TMsvEntry& aContext, TInt& aReasonResourceId) const = 0;
williamr@2
   228
	/** Tests if a close operation is supported.
williamr@2
   229
	
williamr@2
   230
	@param aContext The entry to which the operation applies. 
williamr@2
   231
	@param aReasonResourceId On return, a resource string ID, or 0 if operation 
williamr@2
   232
	is supported. 
williamr@2
   233
	@return ETrue, if the operation is appropriate on the entry; 
williamr@2
   234
	EFalse, if the operation is NOT appropriate on the entry. */
williamr@2
   235
	virtual TBool CanCloseEntryL(const TMsvEntry& aContext, TInt& aReasonResourceId) const = 0;
williamr@2
   236
	/** Tests if a copy from or move to operation is supported.
williamr@2
   237
	
williamr@2
   238
	@param aContext The entry to which the operation applies. 
williamr@2
   239
	@param aReasonResourceId On return, a resource string ID or 0. 
williamr@2
   240
	@return ETrue, if the operation is appropriate on the entry; 
williamr@2
   241
	EFalse, if the operation is NOT appropriate on the entry. */
williamr@2
   242
	virtual TBool CanCopyMoveToEntryL(const TMsvEntry& aContext, TInt& aReasonResourceId) const = 0;
williamr@2
   243
	/** Tests whether a copy from or move from operation is supported.
williamr@2
   244
	
williamr@2
   245
	@param aContext The entry to which the operation applies. 
williamr@2
   246
	@param aReasonResourceId On return, a resource string ID or 0. 
williamr@2
   247
	@return ETrue, if the operation is appropriate on the entry; 
williamr@2
   248
	EFalse, if the operation is NOT appropriate on the entry. */
williamr@2
   249
	virtual TBool CanCopyMoveFromEntryL(const TMsvEntry& aContext, TInt& aReasonResourceId) const = 0;
williamr@2
   250
	/** Tests if the current operation on the entry can be cancelled.
williamr@2
   251
	
williamr@2
   252
	@param aContext The entry to which the operation applies. 
williamr@2
   253
	@param aReasonResourceId On return, a resource string ID, or 0 if operation 
williamr@2
   254
	is supported. 
williamr@2
   255
	@return ETrue, if the operation is appropriate on the entry; 
williamr@2
   256
	EFalse, if the operation is NOT appropriate on the entry. */
williamr@2
   257
	virtual TBool CanCancelL(const TMsvEntry& aContext, TInt& aReasonResourceId) const = 0;
williamr@2
   258
	//
williamr@2
   259
	// --- RTTI ---
williamr@2
   260
	/** Tests if an MTM-specific operation is appropriate to the specified entry. The 
williamr@2
   261
	operation specified must have been obtained from a call to MtmSpecificFunctions(). 
williamr@2
   262
		
williamr@2
   263
	It is intended that client applications will use this function to select dynamically 
williamr@2
   264
	the MTM-specific user interface features available dependent on the entry 
williamr@2
   265
	currently selected within the application.
williamr@2
   266
	
williamr@2
   267
	Requirements:
williamr@2
   268
	
williamr@2
   269
	Implementations should check the type of the context, using TMsvEntry::iType::iUid, 
williamr@2
   270
	and use any other information required available from the context, to determine 
williamr@2
   271
	if the operation is supported.
williamr@2
   272
	
williamr@2
   273
	@param aOperationId ID of operation to query. 
williamr@2
   274
	@param aContext The entry to which the operation applies. 
williamr@2
   275
	@return KErrNone: operation is appropriate to User Interface MTM and entry. 
williamr@2
   276
	Other: if the operation is not appropriate on the entry, then this is the 
williamr@2
   277
	ID of a string in the UI Data MTM's resource file that explains why not. */
williamr@2
   278
	virtual TInt OperationSupportedL(TInt aOperationId, const TMsvEntry& aContext) const = 0; // returns 0 if operation *IS* supported, otherwise a resource ID for the reason text
williamr@2
   279
	/** Queries if the MTM supports a particular capability, specified by a UID. 
williamr@2
   280
	
williamr@2
   281
	Requirements:
williamr@2
   282
	
williamr@2
   283
	Implementations should check aCapability for the standard capability values 
williamr@2
   284
	and return a suitable response in aResponse. If aFunctionId is unknown, return 
williamr@2
   285
	KErrNotSupported.
williamr@2
   286
	
williamr@2
   287
	@param aFunctionId UID of capability to be queried 
williamr@2
   288
	@param aResponse Response value. The format of the response varies according 
williamr@2
   289
	to the capability. 
williamr@2
   290
	@return KErrNone: aFunctionId is a recognised value and a response is returned 
williamr@2
   291
	KErrNotSupported: aFunctionId is not a recognised value */
williamr@2
   292
	virtual TInt QueryCapability(TUid aFunctionId, TInt& aResponse) const = 0;
williamr@2
   293
	/** Provides status text for the sending state of the entry.
williamr@2
   294
	
williamr@2
   295
	@param aContext Entry to query
williamr@2
   296
	@return Descriptor containing status text. */
williamr@2
   297
	virtual HBufC* StatusTextL(const TMsvEntry& aContext) const = 0;
williamr@2
   298
williamr@2
   299
protected:
williamr@2
   300
	// --- Construction ---
williamr@2
   301
	IMPORT_C CBaseMtmUiData(CRegisteredMtmDll& aRegisteredMtmDll);
williamr@2
   302
	IMPORT_C void ConstructL();
williamr@2
   303
	/** Initialises bitmaps and function information. 
williamr@2
   304
	
williamr@2
   305
	Client applications do not use this function. It is relevant only to implementers of derived classes.
williamr@2
   306
	
williamr@2
   307
	Requirements:
williamr@2
   308
	
williamr@2
   309
	This function is called by the base class ConstructL() function. Implementations 
williamr@2
   310
	should provide this function to:
williamr@2
   311
	
williamr@2
   312
	1. insert MTM-specific icon bitmap arrays into the iIconArrays array data member 
williamr@2
   313
	
williamr@2
   314
	2. insert MTM-specific operation information into the iMtmSpecificFunctions array 
williamr@2
   315
	data member */
williamr@2
   316
	virtual void PopulateArraysL() = 0; // Should populate iCapabilities, iMtmSpecificFunctions and iIconArrays
williamr@2
   317
	/** Gets the resource file name. 
williamr@2
   318
	
williamr@2
   319
	Client applications do not use this function. It is relevant only to implementers of derived classes.
williamr@2
   320
	
williamr@2
   321
	Requirements:
williamr@2
   322
	
williamr@2
   323
	Each UI Data MTM can have a resource file associated with it. Implementations 
williamr@2
   324
	should set aFilename to the full path and name of this resource file. The 
williamr@2
   325
	function is called by CBaseMtmUiData::ConstructL(), which then loads the resource 
williamr@2
   326
	file.
williamr@2
   327
	
williamr@2
   328
	@param aFileName Filename buffer to be filled with the resource file path 
williamr@2
   329
	and name */
williamr@2
   330
	virtual void GetResourceFileName(TFileName& aFileName) const = 0;
williamr@2
   331
	//
williamr@2
   332
	// --- Utility ---
williamr@2
   333
	IMPORT_C void ReadFunctionsFromResourceFileL(TInt aResourceId);// Up to clients to call this if necessary
williamr@2
   334
	IMPORT_C void CreateBitmapsL(TInt aNumZoomStates, const TDesC& aBitmapFile, TInt aStartBitmap, TInt aEndBitmap);
williamr@2
   335
	CFbsBitmap* CreateBitmapL(const TDesC& aFileName, TInt aId) const;
williamr@2
   336
williamr@2
   337
	// Method used for extension: called by non virtual methods that need 
williamr@2
   338
	// to have a polymorphic behaviour.
williamr@2
   339
	IMPORT_C virtual TAny* GetInterface(TUid aUid);
williamr@2
   340
williamr@2
   341
protected:
williamr@2
   342
	// --- Data ---
williamr@2
   343
	/** Control environment object. It is set by the constructor. */
williamr@2
   344
	CCoeEnv*									iCoeEnv;
williamr@2
   345
	/** The array that stores the arrays of icon bitmaps for the UI Data MTM. Items 
williamr@2
   346
	are added to the array by PopulateArraysL(). */
williamr@2
   347
	CArrayPtr<CBitmapArray>*					iIconArrays;
williamr@2
   348
	/** The array that stores MTM-specific function information for the UI Data MTM. 
williamr@2
   349
	Items are added to the array by ReadFunctionsFromResourceFileL(). */
williamr@2
   350
	CArrayFix<TMtmUiFunction>*					iMtmSpecificFunctions;
williamr@2
   351
williamr@2
   352
private:
williamr@2
   353
	// --- Data ---
williamr@2
   354
	TInt										iResourceFileOffset;
williamr@2
   355
	CRegisteredMtmDll&							iRegisteredMtmDll;  // Required in order to call ReleaseLibrary()
williamr@2
   356
williamr@2
   357
	// Extra data member to allow for future extensions
williamr@2
   358
	TAny* iExtensionData;
williamr@2
   359
	};
williamr@2
   360
williamr@2
   361
williamr@2
   362
#endif // __MTUDBAS_H__