1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
/*
* Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
* Contact: http://www.qt-project.org/legal
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/
#include <cntviewsortplugin.h>
#include <ecom/implementationproxy.h>
#include "cntsimplesortplugin.hrh"
#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
#include <cntviewsortpluginbase.h>
#endif
// For simplicity Class definition and declaration in the same file.
/**
@class CViewSortPluginExample
Intended usage: This class implements the functionality promised by
the CSortUtilInterface defintion class. It does little apart from
implementing a simple sort,as a demonstration of using ECOM to load a test plugin.
*/
class CViewSortPluginExample : public CViewContactSortPlugin
{
public:
/** Factory function
*/
static CViewSortPluginExample* NewL(TSortPluginParams* aParams);
// Implementation of CView
void SetSortOrderL(const RContactViewSortOrder& aViewSortOrder);
TInt SortStart(TSortStartTypes aSortStartType, TInt aToCount);
void SortCompleted();
TInt SortCompareViewContactsL(const CViewContact& aLhs, const CViewContact& aRhs);
TBool ViewContactIsSortable(const CViewContact& aViewContact);
// functions not in VTable:
public:
CViewSortPluginExample();
void ConstructL(TSortPluginParams* aParams);
private:
~CViewSortPluginExample();
protected:
RContactViewSortOrder iViewSortOrder;
TSortStartTypes iCurrentSort;
TInt iToCount;
// Parameter block given to NewL
TSortPluginParams iPluginParams;
// Parameters from View
TSortPluginViewParamsRev1 iPluginViewParams;
};
// __________________________________________________________________________
// Implementation
CViewSortPluginExample::CViewSortPluginExample() : CViewContactSortPlugin()
{
}
CViewSortPluginExample* CViewSortPluginExample::NewL(TSortPluginParams* aParams)
{
CViewSortPluginExample* self = new (ELeave) CViewSortPluginExample(); // calls c'tor
CleanupStack::PushL(self);
self->ConstructL(aParams);
CleanupStack::Pop(); // self
return(self);
}
void CViewSortPluginExample::ConstructL(TSortPluginParams* aParams)
{
// parameters
__ASSERT_DEBUG(aParams, User::Invariant());
// Check parameters UID
if (!aParams || (aParams->iParametersRevision != KCntSortPluginViewParamsRev1Uid))
User::Leave(KErrArgument);
// Parameters are valid, copy
iPluginParams = *aParams;
// View Parameters pointer must not be NULL
__ASSERT_DEBUG(aParams->iViewSortParams, User::Invariant());
// COPY View parameters
iPluginViewParams = *(reinterpret_cast<TSortPluginViewParamsRev1*> (aParams->iViewSortParams));
// Function pointers must not be NULL
__ASSERT_DEBUG(iPluginViewParams.iCompareViewContactsL, User::Invariant());
__ASSERT_DEBUG(iPluginViewParams.iIsSortable, User::Invariant());
RDebug::Print(_L("-->Instantiated example sort plugin\n"));
}
CViewSortPluginExample::~CViewSortPluginExample()
{
// Class must free all memory
iViewSortOrder.Close();
RDebug::Print(_L("-->Deleted example sort plugin\n"));
}
/** Used by the Contacts View to tell the plugin the required sort order.
Any processing of the order information is done here. */
void CViewSortPluginExample::SetSortOrderL(const RContactViewSortOrder& aViewSortOrder)
{
iViewSortOrder.CopyL(aViewSortOrder);
}
/* Notify Start of sort;
indicating type of operation and approx number of contacts to be processed
*/
TInt CViewSortPluginExample::SortStart(TSortStartTypes aSortStartType, TInt aToCount)
{
// Sort should have NOT have started
__ASSERT_DEBUG( iCurrentSort == ESortNull, User::Invariant());
// sort is starting
iCurrentSort = aSortStartType;
iToCount = aToCount;
// Can allocate buffers here if required ...
return KErrNone;
}
// Notify completion of sort
void CViewSortPluginExample::SortCompleted()
{
// Sort should have started previously
__ASSERT_DEBUG( iCurrentSort != ESortNull, User::Invariant());
// sort has finished
iCurrentSort = ESortNull;
// release buffers here
// ...
}
/** Compare 2 contacts for Contacts View Sort, Insert or Update
*/
TInt CViewSortPluginExample::SortCompareViewContactsL(const CViewContact& aFirst, const CViewContact& aSecond)
{
// must be notified before a sort starts
__ASSERT_DEBUG( iCurrentSort != ESortNull, User::Invariant());
// must have a Sort Order
__ASSERT_DEBUG( iViewSortOrder.Count() > 0, User::Invariant());
// result of comparison: Zero = fields are identical
// pass to default compare function
TInt comparison = iPluginViewParams.iCompareViewContactsL(aFirst, aSecond);
// REVERSE normal sort order
return -comparison;
}
TBool CViewSortPluginExample::ViewContactIsSortable(const CViewContact& aContact)
{
// pass to default Sortable Contact test
return iPluginViewParams.iIsSortable(aContact);
};
//***********************************************************************************
//
// DLL Information for ECOM
/** Exported proxy for instantiation method resolution
Define the interface UIDs */
const TImplementationProxy ImplementationTable[] =
{
// old style: {{KCntSortPluginImplement1Uid}, CViewSortPluginExample::NewL},
// Required for EABI compiler:
IMPLEMENTATION_PROXY_ENTRY(KCntSortPluginImplement1UidInt, CViewSortPluginExample::NewL),
};
EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
{
aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
return ImplementationTable;
}
|