epoc32/include/app/cntviewsortplugin.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@4
     1
// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@4
     2
// All rights reserved.
williamr@4
     3
// This component and the accompanying materials are made available
williamr@4
     4
// under the terms of "Eclipse Public License v1.0"
williamr@4
     5
// which accompanies this distribution, and is available
williamr@4
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@4
     7
//
williamr@4
     8
// Initial Contributors:
williamr@4
     9
// Nokia Corporation - initial contribution.
williamr@4
    10
//
williamr@4
    11
// Contributors:
williamr@4
    12
//
williamr@4
    13
// Description:
williamr@4
    14
//
williamr@4
    15
williamr@4
    16
#ifndef __CNTVIEWSORTPLUGIN_H__
williamr@4
    17
#define __CNTVIEWSORTPLUGIN_H__
williamr@4
    18
williamr@4
    19
#include <e32base.h>
williamr@4
    20
#include "ecom/ecom.h"		// For REComSession
williamr@4
    21
#include <cntviewbase.h>
williamr@4
    22
williamr@4
    23
williamr@4
    24
williamr@4
    25
/** The UID of the ECOM contact view sort interface. 
williamr@4
    26
@publishedAll
williamr@4
    27
@released
williamr@4
    28
*/
williamr@4
    29
const TUid KCntSortPluginInterfaceUid = {0x10200FBD};
williamr@4
    30
williamr@4
    31
/** The name of the default ECOM contact view sort plug-in. 
williamr@4
    32
@publishedAll
williamr@4
    33
@released
williamr@4
    34
*/
williamr@4
    35
_LIT8(KViewSortPluginDefaultName, "/default");
williamr@4
    36
williamr@4
    37
#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
williamr@4
    38
williamr@4
    39
//********************************************************************************************
williamr@4
    40
//
williamr@4
    41
// Parameter blocks passed to Sort Plug-in's NewL, where they should be copied.
williamr@4
    42
//
williamr@4
    43
williamr@4
    44
/** The UID for the sort plug-in parameters (TSortPluginParams and 
williamr@4
    45
TSortPluginViewParamsRev1) that are used to pass data to the ECOM plug-in DLL. 
williamr@4
    46
@publishedPartner
williamr@4
    47
@released
williamr@4
    48
*/
williamr@4
    49
const TUid KCntSortPluginViewParamsRev1Uid = {0x10201325};
williamr@4
    50
williamr@4
    51
/** Information block holding the sort plug-in's parameters.
williamr@4
    52
This is passed to the plug-in instance from the contact view via 
williamr@4
    53
TSortPluginParams::iViewSortParams.
williamr@4
    54
williamr@4
    55
It has an inline constructor to initialise the data members.
williamr@4
    56
williamr@4
    57
@publishedPartner
williamr@4
    58
@released */
williamr@4
    59
class TSortPluginViewParamsRev1
williamr@4
    60
	{
williamr@4
    61
public:	// constructors
williamr@4
    62
	/** Empty default constructor. */
williamr@4
    63
	TSortPluginViewParamsRev1()
williamr@4
    64
			{}
williamr@4
    65
	/** Inline constructor, initialises all data members. 
williamr@4
    66
	
williamr@4
    67
	@param aViewPreferences The view's view preferences.
williamr@4
    68
	@param aCompareViewContactsL A pointer to a default function that is used 
williamr@4
    69
	to compare two contact items. The plug-in may call this function from its 
williamr@4
    70
	implementation of SortCompareViewContactsL().
williamr@4
    71
	@param aIsSortable A pointer to a default function that is used to test 
williamr@4
    72
	whether a CViewContact is sortable. The plug-in may call this function 
williamr@4
    73
	from its implementation of ViewContactIsSortable(). */
williamr@4
    74
	TSortPluginViewParamsRev1(TContactViewPreferences aViewPreferences,
williamr@4
    75
		TInt(*aCompareViewContactsL)(const CViewContact& aFirst, const CViewContact& aSecond),
williamr@4
    76
		TBool(*aIsSortable)(const CViewContact& aViewContact)) :
williamr@4
    77
		iViewPreferences(aViewPreferences), iCompareViewContactsL(aCompareViewContactsL), iIsSortable(aIsSortable)
williamr@4
    78
			{}
williamr@4
    79
public:
williamr@4
    80
	// Fields in all versions
williamr@4
    81
	/** The view's view preferences.*/
williamr@4
    82
	TContactViewPreferences		iViewPreferences;		// preferences of view (at creation)
williamr@4
    83
williamr@4
    84
	// Default implementations of Compare and IsSortable methods
williamr@4
    85
	// that the sort Plugin can call.
williamr@4
    86
	// Must not be NULL !
williamr@4
    87
	/** A pointer to a default function that is used to compare two contact 
williamr@4
    88
	items. The plug-in may call this function from its implementation of 
williamr@4
    89
	SortCompareViewContactsL(). */
williamr@4
    90
	TInt (*iCompareViewContactsL)(const CViewContact& aFirst, const CViewContact& aSecond);
williamr@4
    91
	/** A pointer to a default function that is used to test whether a contact item 
williamr@4
    92
	is sortable. The plug-in may call this function from its implementation of 
williamr@4
    93
	ViewContactIsSortable(). */
williamr@4
    94
	TBool(*iIsSortable)(const CViewContact& aViewContact);
williamr@4
    95
	};
williamr@4
    96
williamr@4
    97
williamr@4
    98
/** A data class used to pass initialization information to 
williamr@4
    99
CViewContactSortPlugin::NewL().
williamr@4
   100
williamr@4
   101
@publishedPartner
williamr@4
   102
@released */
williamr@4
   103
class TSortPluginParams
williamr@4
   104
	{
williamr@4
   105
public:	// constructors
williamr@4
   106
	/** Empty default constructor. */
williamr@4
   107
	TSortPluginParams() {}
williamr@4
   108
	
williamr@4
   109
	/** Inline constructor, initialises all data members.
williamr@4
   110
williamr@4
   111
	The parameter revision UID is initialised to KCntSortPluginViewParamsRev1Uid.
williamr@4
   112
	@param aInterfaceUid Interface UID as specified in the INTERFACE_INFO resource struct, 
williamr@4
   113
	required by ECOM.
williamr@4
   114
	@param aImplementationUid Implementation UID, as specified in the IMPLEMENTATION_INFO 
williamr@4
   115
	resource struct, required by ECOM.
williamr@4
   116
	@param aViewSortParams View sort parameters pointer. This object should match the 
williamr@4
   117
	parameter revision UID value. */
williamr@4
   118
	TSortPluginParams(TUid aInterfaceUid, TUid aImplementationUid, TSortPluginViewParamsRev1* aViewSortParams) : 
williamr@4
   119
		iParametersRevision(KCntSortPluginViewParamsRev1Uid), iInterfaceUid(aInterfaceUid), 
williamr@4
   120
		iImplementationUid(aImplementationUid), iViewSortParams(aViewSortParams)
williamr@4
   121
	{}
williamr@4
   122
public:
williamr@4
   123
	/** A UID that identifies the revision of the structure holding 
williamr@4
   124
	the view's sort parameters. A value of KCntSortPluginViewParamsRev1Uid 
williamr@4
   125
	indicates TSortPluginViewParamsRev1. */
williamr@4
   126
	TUid	iParametersRevision;	
williamr@4
   127
williamr@4
   128
	// Information for ECOM to load the correct plug-in
williamr@4
   129
	/** Interface UID as specified in the INTERFACE_INFO resource struct, 
williamr@4
   130
	required by ECOM.*/
williamr@4
   131
	TUid	iInterfaceUid;
williamr@4
   132
	/** Implementation UID, as specified in the IMPLEMENTATION_INFO 
williamr@4
   133
	resource struct, required by ECOM.*/
williamr@4
   134
	TUid	iImplementationUid;
williamr@4
   135
williamr@4
   136
	// information block from Contact View
williamr@4
   137
	/** View sort parameters pointer. This object should match the 
williamr@4
   138
	parameter revision UID value.*/
williamr@4
   139
	TAny*	iViewSortParams;
williamr@4
   140
	};
williamr@4
   141
williamr@4
   142
williamr@4
   143
williamr@4
   144
/** An interface class that enables implementers to configure the way in which 
williamr@4
   145
contacts are sorted in a contact view.
williamr@4
   146
williamr@4
   147
This is an abstract base class that will be derived from.
williamr@4
   148
williamr@4
   149
@publishedPartner
williamr@4
   150
@released */
williamr@4
   151
class CViewContactSortPlugin : public CBase
williamr@4
   152
	{
williamr@4
   153
public:
williamr@4
   154
	/** Identifies the type of sort operation to SortStart(). 
williamr@4
   155
	
williamr@4
   156
	@publishedPartner
williamr@4
   157
	@released */
williamr@4
   158
	enum TSortStartTypes {
williamr@4
   159
		/** No sort is in progress. */
williamr@4
   160
		ESortNull = 0,
williamr@4
   161
		/** A full sort or re-sort. */
williamr@4
   162
		ESortStartFull,	
williamr@4
   163
		/** A single contact has been inserted or changed. */
williamr@4
   164
		ESortStartInsertOne,
williamr@4
   165
		/** Multiple contacts have been added. For example, ICC contacts arrived in a 
williamr@4
   166
		mixed view (one that also includes contacts from the phone's memory). */
williamr@4
   167
		ESortStartInsertMultiple,
williamr@4
   168
		// other values are reserved
williamr@4
   169
		};
williamr@4
   170
	
williamr@4
   171
	/* aImplementationUid is used by ECOM to select plugin.
williamr@4
   172
	Contacts model can use REComSession::ListImplementationsL() to determine
williamr@4
   173
	DLLs that match the interface UID for this class. */
williamr@4
   174
	static CViewContactSortPlugin* NewL(TSortPluginParams* aParams);
williamr@4
   175
williamr@4
   176
	/* Class must free all memory, implementation should include:
williamr@4
   177
	iViewSortOrder.Close();	*/
williamr@4
   178
	inline virtual ~CViewContactSortPlugin();
williamr@4
   179
williamr@4
   180
williamr@4
   181
	//pure virtual methods to be implemented by the plugin.
williamr@4
   182
williamr@4
   183
	/** Called by a contact view to pass the sort plug-in the required sort order.
williamr@4
   184
	Any processing of the order information is done here.
williamr@4
   185
williamr@4
   186
    This function is called when the view is created and when a different sort order 
williamr@4
   187
	is requested. 
williamr@4
   188
williamr@4
   189
	@param aViewSortOrder The requested sort order. */
williamr@4
   190
	virtual void SetSortOrderL(const RContactViewSortOrder& aViewSortOrder) = 0;
williamr@4
   191
williamr@4
   192
	/** Called by a contact view to notify the sort plug-in that sorting is about to start.
williamr@4
   193
williamr@4
   194
	@param aSortStartType Indicates the type of sort operation required.
williamr@4
   195
	@param aCount The approximate number of contacts to be processed.
williamr@4
   196
	@return KErrNone if successful, otherwise another of the system-wide error codes. */
williamr@4
   197
	virtual TInt SortStart(TSortStartTypes aSortStartType, TInt aCount) = 0;
williamr@4
   198
williamr@4
   199
	/** Called by a contact view to notify the sort plug-in that sorting is complete. */
williamr@4
   200
	virtual void SortCompleted() = 0;
williamr@4
   201
williamr@4
   202
	/** Called by a contact view to compare two CViewContact items for sorting in the 
williamr@4
   203
	view.
williamr@4
   204
williamr@4
   205
	If TDesC::CompareC() is used to implement this function, the return value from 
williamr@4
   206
	TDesC::CompareC() can be used directly.
williamr@4
   207
williamr@4
   208
	@param aLhs The first item to compare.
williamr@4
   209
	@param aRhs The second item to compare.
williamr@4
   210
	@return Zero means that aLhs and aRhs have an equal sorting order.
williamr@4
   211
	An arbitrary negative value means that aLhs is to be sorted before aRhs. 
williamr@4
   212
	An arbitrary positive value means that aRhs is to be sorted before aLhs. */
williamr@4
   213
	virtual TInt SortCompareViewContactsL(const CViewContact& aLhs, const CViewContact& aRhs) = 0;
williamr@4
   214
williamr@4
   215
	/** Tests whether a CViewContact is sortable. 
williamr@4
   216
	
williamr@4
   217
	For instance, a contact may be unsortable if none of the fields used to sort on 
williamr@4
   218
	contain any data. 
williamr@4
   219
	@param aViewContact The view contact to test.
williamr@4
   220
	@return ETrue if the view contact is sortable, EFalse if not. */
williamr@4
   221
	virtual TBool ViewContactIsSortable(const CViewContact& aViewContact) = 0;
williamr@4
   222
williamr@4
   223
private:
williamr@4
   224
	// The uid is stored here, so that it can be used during destruction of the instance.
williamr@4
   225
	TUid iDtor_ID_Key;
williamr@4
   226
	};
williamr@4
   227
williamr@4
   228
williamr@4
   229
//********************************************************************************************
williamr@4
   230
//
williamr@4
   231
// NewL() & destructor inline functions, placed in .h file for simplicity
williamr@4
   232
//
williamr@4
   233
williamr@4
   234
// -----------------------CViewContactSortPlugin --------------------------------
williamr@4
   235
williamr@4
   236
/** Allocates and constructs a sort plug-in instance.
williamr@4
   237
williamr@4
   238
@param aParams The sort plug-in's parameters.
williamr@4
   239
@return Pointer to the newly created sort plug-in implementation. */
williamr@4
   240
inline CViewContactSortPlugin* CViewContactSortPlugin::NewL(TSortPluginParams* aParams)
williamr@4
   241
	{
williamr@4
   242
	TAny* ptr = REComSession::CreateImplementationL(aParams->iImplementationUid,
williamr@4
   243
				_FOFF(CViewContactSortPlugin, iDtor_ID_Key),
williamr@4
   244
				aParams);
williamr@4
   245
	return reinterpret_cast<CViewContactSortPlugin*>(ptr);
williamr@4
   246
	}
williamr@4
   247
williamr@4
   248
/** Virtual destructor. */
williamr@4
   249
inline CViewContactSortPlugin::~CViewContactSortPlugin()
williamr@4
   250
	{
williamr@4
   251
	REComSession::DestroyedImplementation(iDtor_ID_Key);
williamr@4
   252
	}
williamr@4
   253
#endif //SYMBIAN_ENABLE_SPLIT_HEADERS
williamr@4
   254
williamr@4
   255
#endif