williamr@2
|
1 |
// Copyright (c) 2001-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 |
#ifndef __CNTVIEWBASE_H__
|
williamr@2
|
17 |
#define __CNTVIEWBASE_H__
|
williamr@2
|
18 |
|
williamr@2
|
19 |
// System includes
|
williamr@2
|
20 |
#include <e32std.h>
|
williamr@2
|
21 |
#include <s32mem.h>
|
williamr@2
|
22 |
|
williamr@2
|
23 |
#include <cntdb.h>
|
williamr@2
|
24 |
|
williamr@2
|
25 |
// Classes referenced
|
williamr@2
|
26 |
class CViewContactExtension;
|
williamr@2
|
27 |
class CContactViewBase;
|
williamr@2
|
28 |
class CContactRemoteViewNotifier;
|
williamr@2
|
29 |
class CIdleContactSorter;
|
williamr@2
|
30 |
class CContactViewFindConfigInterface;
|
williamr@2
|
31 |
class CViewContactSortPlugin;
|
williamr@2
|
32 |
class TSortPluginViewParams;
|
williamr@2
|
33 |
|
williamr@2
|
34 |
/** View preferences for sorted contact views.
|
williamr@2
|
35 |
|
williamr@2
|
36 |
This is used to specify the types of contact item that should be sorted and
|
williamr@2
|
37 |
included in the view and the behaviour for items that cannot be sorted because
|
williamr@2
|
38 |
they do not have content in any of the fields specified in the view's sort
|
williamr@2
|
39 |
order.
|
williamr@2
|
40 |
|
williamr@2
|
41 |
The default behaviour is to include contact cards only and to sort contact
|
williamr@2
|
42 |
cards without content in any of the sort order fields using the first available
|
williamr@2
|
43 |
field containing any text.
|
williamr@2
|
44 |
|
williamr@2
|
45 |
The view preferences for all concrete contact view classes can be retrieved
|
williamr@2
|
46 |
using their implementation of CContactViewBase::ContactViewPreferences().
|
williamr@2
|
47 |
The view preferences are set during construction of a CContactLocalView.
|
williamr@2
|
48 |
|
williamr@2
|
49 |
@publishedAll
|
williamr@2
|
50 |
@released
|
williamr@2
|
51 |
*/
|
williamr@2
|
52 |
enum TContactViewPreferences
|
williamr@2
|
53 |
{
|
williamr@2
|
54 |
/** Only contact cards (of type KUidContactCard or KUidContactOwnCard) are included
|
williamr@2
|
55 |
in the view. This is the default. */
|
williamr@2
|
56 |
EContactsOnly =0x00000000,
|
williamr@2
|
57 |
/** Only contact groups (of type KUidContactGroup) are included in the view. */
|
williamr@2
|
58 |
EGroupsOnly =0x00000001,
|
williamr@2
|
59 |
/** Contact groups and contact cards (of type KUidContactGroup, KUidContactCard
|
williamr@2
|
60 |
or KUidContactOwnCard) are included in the view. */
|
williamr@2
|
61 |
EContactAndGroups =0x00000002,
|
williamr@2
|
62 |
/** Excludes contact items from the view which don't have content in any of the
|
williamr@2
|
63 |
fields specified in the sort order. */
|
williamr@2
|
64 |
EIgnoreUnSorted =0x00000004,
|
williamr@2
|
65 |
/** Includes contacts in the view which don't have content in any of the fields
|
williamr@2
|
66 |
specified in the sort order. These contacts are placed in an unsorted contact
|
williamr@2
|
67 |
list which is located before the sorted list. */
|
williamr@2
|
68 |
EUnSortedAtBeginning =0x00000008,
|
williamr@2
|
69 |
/** Includes contacts in the view which don't have content in any of the fields
|
williamr@2
|
70 |
specified in the sort order. These contacts are placed in an unsorted contact
|
williamr@2
|
71 |
list which is located after the sorted list. */
|
williamr@2
|
72 |
EUnSortedAtEnd =0x00000010,
|
williamr@2
|
73 |
/** Fields containing a single white space only are treated as empty, and therefore
|
williamr@2
|
74 |
unsortable. */
|
williamr@2
|
75 |
ESingleWhiteSpaceIsEmptyField =0x00000020,
|
williamr@2
|
76 |
/** Only ICC entries (of type KUidContactICCEntry) are included in the view. */
|
williamr@2
|
77 |
EICCEntriesOnly =0x00000040,
|
williamr@2
|
78 |
/** Only contact cards and ICC entries (of type KUidContactCard, KUidContactOwnCard
|
williamr@2
|
79 |
or KUidContactICCEntry) are included in the view. */
|
williamr@2
|
80 |
EICCEntriesAndContacts =0x00000080
|
williamr@2
|
81 |
};
|
williamr@2
|
82 |
|
williamr@2
|
83 |
|
williamr@2
|
84 |
class TContactViewEvent
|
williamr@2
|
85 |
/** Identifies a contact view event.
|
williamr@2
|
86 |
|
williamr@2
|
87 |
Sent by contact views when notifying their observers of an event.
|
williamr@2
|
88 |
|
williamr@2
|
89 |
@see MContactViewObserver::HandleContactViewEvent()
|
williamr@2
|
90 |
@publishedAll
|
williamr@2
|
91 |
@released
|
williamr@2
|
92 |
*/
|
williamr@2
|
93 |
{
|
williamr@2
|
94 |
public:
|
williamr@2
|
95 |
/** Identifies the event's type. */
|
williamr@2
|
96 |
enum TEventType
|
williamr@2
|
97 |
{
|
williamr@2
|
98 |
/** The observed view's state has changed from EReady to either ENotReady or EInitializing,
|
williamr@2
|
99 |
so is not available for use. */
|
williamr@2
|
100 |
EUnavailable,
|
williamr@2
|
101 |
/** The observed view's state has changed from ENotReady or EInitializing to EReady
|
williamr@2
|
102 |
so is available for use. */
|
williamr@2
|
103 |
EReady,
|
williamr@2
|
104 |
/** The observed view's sort order has changed, so observer views need to update
|
williamr@2
|
105 |
themselves. */
|
williamr@2
|
106 |
ESortOrderChanged,
|
williamr@2
|
107 |
/** An error occurred when sorting the observed view or when appending an observer
|
williamr@2
|
108 |
to its observer array.
|
williamr@2
|
109 |
|
williamr@2
|
110 |
The error code is provided in iInt. */
|
williamr@2
|
111 |
ESortError,
|
williamr@2
|
112 |
/** An error occurred in the contacts server.
|
williamr@2
|
113 |
|
williamr@2
|
114 |
The error code is provided in iInt. */
|
williamr@2
|
115 |
EServerError,
|
williamr@2
|
116 |
/** An error occurred when setting the range for a CContactSubView.
|
williamr@2
|
117 |
|
williamr@2
|
118 |
The error code is provided in iInt. */
|
williamr@2
|
119 |
EIndexingError,
|
williamr@2
|
120 |
/** An item has been added to the observed view.
|
williamr@2
|
121 |
|
williamr@2
|
122 |
The ID of the added item is provided in iContactId and the index into the
|
williamr@2
|
123 |
observed view of the added item is provided in iInt.
|
williamr@2
|
124 |
Exception from this are the first version of CContactFindView, CContactSubView and
|
williamr@2
|
125 |
CContactGroupView classes.
|
williamr@2
|
126 |
For these classes, iInt has KErrNone value */
|
williamr@2
|
127 |
|
williamr@2
|
128 |
EItemAdded,
|
williamr@2
|
129 |
/** An item has been removed from the observed view.
|
williamr@2
|
130 |
|
williamr@2
|
131 |
The ID of the removed item is provided in iContactId and the index into the
|
williamr@2
|
132 |
observed view of the item is provided in iInt.
|
williamr@2
|
133 |
Exception from this are the first version of CContactFindView and CContactSubView classes.
|
williamr@2
|
134 |
For these classes, iInt has KErrNone value */
|
williamr@2
|
135 |
|
williamr@2
|
136 |
EItemRemoved,
|
williamr@2
|
137 |
/** A change has occurred in a contact group, for instance a contact item has been
|
williamr@2
|
138 |
moved into or out of the group.
|
williamr@2
|
139 |
|
williamr@2
|
140 |
The ID of the group affected is provided in iContactId. */
|
williamr@2
|
141 |
EGroupChanged
|
williamr@2
|
142 |
};
|
williamr@2
|
143 |
public:
|
williamr@2
|
144 |
inline TContactViewEvent();
|
williamr@2
|
145 |
inline TContactViewEvent(TEventType aEventType,TInt aInt = KErrUnknown,TContactItemId aContactId = KErrUnknown);
|
williamr@2
|
146 |
public:
|
williamr@2
|
147 |
/** The type of event. */
|
williamr@2
|
148 |
TEventType iEventType;
|
williamr@2
|
149 |
/** The error code (where relevant) or the index of the contact item added to/removed
|
williamr@2
|
150 |
from the underlying view. */
|
williamr@2
|
151 |
TInt iInt;
|
williamr@2
|
152 |
/** The ID of the contact item that has been added or removed or the group ID, where
|
williamr@2
|
153 |
relevant. */
|
williamr@2
|
154 |
TContactItemId iContactId;//ContactId that has been added / removed if relevant.
|
williamr@2
|
155 |
};
|
williamr@2
|
156 |
|
williamr@2
|
157 |
|
williamr@2
|
158 |
struct TContactIdWithMapping
|
williamr@2
|
159 |
/** A struct used internally by filtered and group views to pair a contact item
|
williamr@2
|
160 |
ID and its index into the underlying view.
|
williamr@2
|
161 |
@publishedAll
|
williamr@2
|
162 |
@released
|
williamr@2
|
163 |
*/
|
williamr@2
|
164 |
{
|
williamr@2
|
165 |
/** The contact item's ID. */
|
williamr@2
|
166 |
TContactItemId iId;
|
williamr@2
|
167 |
/** The index of the item into the view's underlying view. */
|
williamr@2
|
168 |
TInt iMapping;
|
williamr@2
|
169 |
};
|
williamr@2
|
170 |
|
williamr@2
|
171 |
|
williamr@2
|
172 |
class MContactViewObserver
|
williamr@2
|
173 |
/** The interface for a contact view observer.
|
williamr@2
|
174 |
|
williamr@2
|
175 |
Objects that need to observe a contact view should implement this interface.
|
williamr@2
|
176 |
The view observer should be passed to the observed view's OpenL() or Open()
|
williamr@2
|
177 |
function. This adds the observer to the view's observer array: a view can
|
williamr@2
|
178 |
have more than one observer. The observers receive notifications when the
|
williamr@2
|
179 |
observed view becomes ready for use and when changes occur in it.
|
williamr@2
|
180 |
|
williamr@2
|
181 |
Many contact view classes implement this interface to observe an underlying
|
williamr@2
|
182 |
view. They in turn send notification to any objects observing them.
|
williamr@2
|
183 |
|
williamr@2
|
184 |
@see CContactViewBase::NotifyObservers()
|
williamr@2
|
185 |
@see CContactViewBase::NotifyObserverAsync()
|
williamr@2
|
186 |
@publishedAll
|
williamr@2
|
187 |
@released
|
williamr@2
|
188 |
*/
|
williamr@2
|
189 |
{
|
williamr@2
|
190 |
public:
|
williamr@2
|
191 |
/** Handles an event in an observed contact view.
|
williamr@2
|
192 |
|
williamr@2
|
193 |
@param aView The contact view causing the notification.
|
williamr@2
|
194 |
@param aEvent The event. */
|
williamr@2
|
195 |
virtual void HandleContactViewEvent(const CContactViewBase& aView,const TContactViewEvent& aEvent)=0;
|
williamr@2
|
196 |
};
|
williamr@2
|
197 |
|
williamr@2
|
198 |
|
williamr@2
|
199 |
class RContactViewSortOrder
|
williamr@2
|
200 |
/** Specifies the sort order for a contact view.
|
williamr@2
|
201 |
|
williamr@2
|
202 |
It is implemented as an array of TFieldType UIDs, which define the fields
|
williamr@2
|
203 |
whose contents are used to sort on, and their order.
|
williamr@2
|
204 |
|
williamr@2
|
205 |
The sort order for all concrete contact view classes can be retrieved using
|
williamr@2
|
206 |
their implementation of CContactViewBase::SortOrderL(). The sort order is
|
williamr@2
|
207 |
set during construction of local and remote views.
|
williamr@2
|
208 |
@publishedAll
|
williamr@2
|
209 |
@released
|
williamr@2
|
210 |
*/
|
williamr@2
|
211 |
{
|
williamr@2
|
212 |
public:
|
williamr@2
|
213 |
IMPORT_C RContactViewSortOrder();
|
williamr@2
|
214 |
IMPORT_C void Close();
|
williamr@2
|
215 |
IMPORT_C void CopyL(const RContactViewSortOrder& aSortOrder);
|
williamr@2
|
216 |
IMPORT_C void InternalizeL(RReadStream& aStream);
|
williamr@2
|
217 |
IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
|
williamr@2
|
218 |
IMPORT_C TInt ExternalizedSize() const;
|
williamr@2
|
219 |
IMPORT_C TBool operator==(const RContactViewSortOrder& aSortOrder) const;
|
williamr@2
|
220 |
inline void AppendL(TFieldType aField);
|
williamr@2
|
221 |
inline TFieldType operator[](TInt aIndex) const;
|
williamr@2
|
222 |
inline TInt Count() const;
|
williamr@2
|
223 |
private:
|
williamr@2
|
224 |
RArray<TFieldType> iFields;
|
williamr@2
|
225 |
TInt iSpare;
|
williamr@2
|
226 |
TInt32 iSpare2;
|
williamr@2
|
227 |
TInt32 iSpare3;
|
williamr@2
|
228 |
};
|
williamr@2
|
229 |
|
williamr@2
|
230 |
|
williamr@2
|
231 |
/**
|
williamr@2
|
232 |
Wrapper around RArray, to container TTextFieldMinimal buffers.
|
williamr@2
|
233 |
|
williamr@2
|
234 |
Features: minimum size 1, easy resize of array, persistent last counted total.
|
williamr@2
|
235 |
|
williamr@2
|
236 |
@internalComponent
|
williamr@2
|
237 |
@released
|
williamr@2
|
238 |
*/
|
williamr@2
|
239 |
class RFieldBufferArray : public RArray<CContactDatabase::TTextFieldMinimal>
|
williamr@2
|
240 |
{
|
williamr@2
|
241 |
public:
|
williamr@2
|
242 |
explicit RFieldBufferArray();
|
williamr@2
|
243 |
|
williamr@2
|
244 |
void ResizeL(TInt aNewSize);
|
williamr@2
|
245 |
void ZeroAll();
|
williamr@2
|
246 |
TInt NewTotal();
|
williamr@2
|
247 |
TInt LastTotal() const;
|
williamr@2
|
248 |
|
williamr@2
|
249 |
private:
|
williamr@2
|
250 |
TInt iTotalLength;
|
williamr@2
|
251 |
};
|
williamr@2
|
252 |
|
williamr@2
|
253 |
|
williamr@2
|
254 |
|
williamr@2
|
255 |
class CViewContact : public CBase
|
williamr@2
|
256 |
/** The representation of a contact item used in contact views.
|
williamr@2
|
257 |
|
williamr@2
|
258 |
It stores the contact item ID and other information. This includes a buffer
|
williamr@2
|
259 |
holding the contents of all the item's fields, an array of indexes into the
|
williamr@2
|
260 |
buffer indicating the start position of each field and a hint bit field (a
|
williamr@2
|
261 |
combination of CContactDatabase::TContactViewFilter values) which is used
|
williamr@2
|
262 |
in filtered views.
|
williamr@2
|
263 |
|
williamr@2
|
264 |
The fields are defined by the view's sort order (RContactViewSortOrder).
|
williamr@2
|
265 |
@publishedAll
|
williamr@2
|
266 |
@released
|
williamr@2
|
267 |
*/
|
williamr@2
|
268 |
{
|
williamr@2
|
269 |
public:
|
williamr@2
|
270 |
/** Defines whether the contact view item is a contact group. */
|
williamr@2
|
271 |
enum TViewContactType
|
williamr@2
|
272 |
{
|
williamr@2
|
273 |
/** The contact view item is not a contact group. */
|
williamr@2
|
274 |
EContactItem,
|
williamr@2
|
275 |
/** The contact view item is a contact group (CContactGroup). */
|
williamr@2
|
276 |
EGroup
|
williamr@2
|
277 |
};
|
williamr@2
|
278 |
IMPORT_C CViewContact(TContactItemId aId);
|
williamr@2
|
279 |
IMPORT_C static CViewContact* NewL(const CViewContact& aContact);
|
williamr@2
|
280 |
IMPORT_C static CViewContact* NewLC(TContactItemId aId);
|
williamr@2
|
281 |
IMPORT_C static CViewContact* NewL(TContactItemId aId, TInt aLength);
|
williamr@2
|
282 |
static CViewContact* NewLC(RReadStream& aStream);
|
williamr@2
|
283 |
|
williamr@2
|
284 |
IMPORT_C ~CViewContact();
|
williamr@2
|
285 |
IMPORT_C void InternalizeL(RReadStream& aStream);
|
williamr@2
|
286 |
IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
|
williamr@2
|
287 |
IMPORT_C TInt ExternalizedSize() const;
|
williamr@2
|
288 |
IMPORT_C TInt FieldCount() const;
|
williamr@2
|
289 |
IMPORT_C TPtrC Field(TInt aPosition) const;
|
williamr@2
|
290 |
IMPORT_C TBool ContactMatchesFilter(TInt aFilter) const;
|
williamr@2
|
291 |
IMPORT_C void AddFieldL(const TDesC& aField);
|
williamr@2
|
292 |
IMPORT_C TBool IsSortable() const;
|
williamr@2
|
293 |
IMPORT_C void SetFirstFieldForBlankContactL(const TDesC& aFirstField);
|
williamr@2
|
294 |
IMPORT_C void Reset();
|
williamr@2
|
295 |
IMPORT_C TInt ContactHint() const;
|
williamr@2
|
296 |
IMPORT_C void SetContactHint(TInt aHint);
|
williamr@2
|
297 |
IMPORT_C TUid ContactTypeUid() const;
|
williamr@2
|
298 |
IMPORT_C void SetContactTypeUid(TUid aUid);
|
williamr@2
|
299 |
|
williamr@2
|
300 |
inline TContactItemId Id() const;
|
williamr@2
|
301 |
inline TViewContactType ContactType() const;
|
williamr@2
|
302 |
public:
|
williamr@2
|
303 |
inline void SetId(TContactItemId aId);
|
williamr@2
|
304 |
inline void SetContactType(CViewContact::TViewContactType aContactType);
|
williamr@2
|
305 |
static TBool HintFieldMatchesFilter(TInt aHintField, TInt aFilter);
|
williamr@2
|
306 |
TPtrC FindFirstPopulatedField(TInt aOffset, TInt& aFoundPosition) const;
|
williamr@2
|
307 |
|
williamr@2
|
308 |
#ifdef __SYMBIAN_CNTMODEL_USE_SQLITE__
|
williamr@2
|
309 |
IMPORT_C void ChangeToLightweightObject();
|
williamr@2
|
310 |
TBool IsLightweightObject() const;
|
williamr@2
|
311 |
void CopyL(const CViewContact& aContact);
|
williamr@2
|
312 |
#endif //__SYMBIAN_CNTMODEL_USE_SQLITE__
|
williamr@2
|
313 |
|
williamr@2
|
314 |
private:
|
williamr@2
|
315 |
void ConstructL(TInt aLength = 0);
|
williamr@2
|
316 |
void ConstructL(const CViewContact& aContact);
|
williamr@2
|
317 |
friend class CContactViewBase;
|
williamr@2
|
318 |
private:
|
williamr@2
|
319 |
TContactItemId iId;
|
williamr@2
|
320 |
TViewContactType iContactType;
|
williamr@2
|
321 |
CViewContactExtension* iExtension;
|
williamr@2
|
322 |
RArray<TInt> iTextIndexes;
|
williamr@2
|
323 |
};
|
williamr@2
|
324 |
|
williamr@2
|
325 |
|
williamr@2
|
326 |
/*
|
williamr@2
|
327 |
* A view can be named or un-named. An un-named view has a fixed sort order - the
|
williamr@2
|
328 |
* only way to change this is by closing the object and creating a new one with a
|
williamr@2
|
329 |
* different order. Named views may have their sort order changed. When this is
|
williamr@2
|
330 |
* done, first all observers will be informed that the view is 'unavailable'. This
|
williamr@2
|
331 |
* notification will be followed by 'sort order changed' and 'ready'. Only once
|
williamr@2
|
332 |
* the 'ready' notification has been received may the view be used again.
|
williamr@2
|
333 |
*/
|
williamr@2
|
334 |
class CContactViewBase : public CBase
|
williamr@2
|
335 |
/** The abstract base class for all contact view classes.
|
williamr@2
|
336 |
|
williamr@2
|
337 |
All contact views operate asynchronously, so users of the view must observe
|
williamr@2
|
338 |
it, by implementing the MContactViewObserver interface. Immediately after
|
williamr@2
|
339 |
construction, views are not in a usable state (the underlying data may be
|
williamr@2
|
340 |
being sorted, for instance). Only after the user has received a TContactViewEvent::EReady
|
williamr@2
|
341 |
event may the view be used.
|
williamr@2
|
342 |
|
williamr@2
|
343 |
View observers are also notified when changes occur, for instance when the
|
williamr@2
|
344 |
view's state changes (see TState), when an error occurs, or when an item is
|
williamr@2
|
345 |
added or removed.
|
williamr@2
|
346 |
@publishedAll
|
williamr@2
|
347 |
@released
|
williamr@2
|
348 |
*/
|
williamr@2
|
349 |
{
|
williamr@2
|
350 |
public:
|
williamr@2
|
351 |
class CContactViewBaseExtension : public CBase
|
williamr@2
|
352 |
/** An extension class that holds member data added in v7.0s.
|
williamr@2
|
353 |
|
williamr@2
|
354 |
It was created for binary compatibility purposes.
|
williamr@2
|
355 |
@internalComponent
|
williamr@2
|
356 |
@released */
|
williamr@2
|
357 |
{
|
williamr@2
|
358 |
public:
|
williamr@2
|
359 |
static CContactViewBaseExtension* NewL();
|
williamr@2
|
360 |
~CContactViewBaseExtension();
|
williamr@2
|
361 |
|
williamr@2
|
362 |
private:
|
williamr@2
|
363 |
CContactViewBaseExtension();
|
williamr@2
|
364 |
void ConstructL();
|
williamr@2
|
365 |
|
williamr@2
|
366 |
public:
|
williamr@2
|
367 |
/** A standard error code that is passed to view observers by NotifyObservers()
|
williamr@2
|
368 |
(unless its value is KErrNone). */
|
williamr@2
|
369 |
TInt iError;
|
williamr@2
|
370 |
/** The UID of the view's find configuration plug-in.
|
williamr@2
|
371 |
|
williamr@2
|
372 |
On construction, this is initialised to KNullUid.
|
williamr@2
|
373 |
|
williamr@2
|
374 |
The plug-in is loaded when ContactsMatchingCriteriaL(), ContactsMatchingPrefixL()
|
williamr@2
|
375 |
or MatchesCriteriaL() is called. */
|
williamr@2
|
376 |
TUid iFindPluginUid;
|
williamr@2
|
377 |
/** The UID of the view's sort plug-in. */
|
williamr@2
|
378 |
TUid iSortPluginUid;
|
williamr@2
|
379 |
private:
|
williamr@2
|
380 |
CContactViewFindConfigInterface* iFindPluginImpl;
|
williamr@2
|
381 |
CViewContactSortPlugin* iSortPluginImpl;
|
williamr@2
|
382 |
TCollationMethod iCollationMethod;
|
williamr@2
|
383 |
friend class CContactViewBase;
|
williamr@2
|
384 |
};
|
williamr@2
|
385 |
class TVirtualFunction1Params
|
williamr@2
|
386 |
/** Holds the two parameters passed to the helper method GetContactIdsL() from
|
williamr@2
|
387 |
the reserved function CContactViewBase_Reserved_1(). It has an inline constructor
|
williamr@2
|
388 |
to initialise the data members.
|
williamr@2
|
389 |
@publishedAll
|
williamr@2
|
390 |
@released */
|
williamr@2
|
391 |
{
|
williamr@2
|
392 |
public:
|
williamr@2
|
393 |
/** Inline constructor to initialize member data
|
williamr@2
|
394 |
@param aIndexes Pointer to an array of indexes in a view
|
williamr@2
|
395 |
@param aIdArray Pointer to array of contact IDs */
|
williamr@2
|
396 |
inline TVirtualFunction1Params(const CArrayFix<TInt>* aIndexes, CContactIdArray* aIdArray) :iIndexes(aIndexes), iIdArray(aIdArray){};
|
williamr@2
|
397 |
/** Pointer to an array of indexes in a view */
|
williamr@2
|
398 |
const CArrayFix<TInt>* iIndexes;
|
williamr@2
|
399 |
/** Pointer to array of contact IDs */
|
williamr@2
|
400 |
CContactIdArray* iIdArray;
|
williamr@2
|
401 |
};
|
williamr@2
|
402 |
class TVirtualFunction2Params
|
williamr@2
|
403 |
/** Holds the two parameters passed to the method GetContactsMatchingFilterL()
|
williamr@2
|
404 |
from the reserved function CContactViewBase_Reserved_1(). It has an inline
|
williamr@2
|
405 |
constructor to initialise the data members.
|
williamr@2
|
406 |
*/
|
williamr@2
|
407 |
{
|
williamr@2
|
408 |
public:
|
williamr@2
|
409 |
/** Inline constructor to initialize member data.
|
williamr@2
|
410 |
@param aFilter Filter for the contacts
|
williamr@2
|
411 |
@param aMatchingContacts Contacts matching a particular criterion */
|
williamr@2
|
412 |
inline TVirtualFunction2Params(TInt aFilter, RArray<TContactIdWithMapping>& aMatchingContacts) : iFilter(aFilter), iMatchingContacts(aMatchingContacts){};
|
williamr@2
|
413 |
public:
|
williamr@2
|
414 |
/** Filter for the contacts. */
|
williamr@2
|
415 |
TInt iFilter;
|
williamr@2
|
416 |
/** List of contacts matching the criteria. */
|
williamr@2
|
417 |
RArray<TContactIdWithMapping>& iMatchingContacts;
|
williamr@2
|
418 |
};
|
williamr@2
|
419 |
class TVirtualFunction3Params
|
williamr@2
|
420 |
/** Holds the two parameters passed to the method InsertContactInView() from the
|
williamr@2
|
421 |
reserved function CContactViewBase_Reserved_1(). It has an inline
|
williamr@2
|
422 |
constructor to initialise the data members.
|
williamr@2
|
423 |
|
williamr@2
|
424 |
@internalAll */
|
williamr@2
|
425 |
{
|
williamr@2
|
426 |
public:
|
williamr@2
|
427 |
inline TVirtualFunction3Params(RPointerArray<CViewContact>& aContacts, const CViewContact* aNewContact) :iContacts(aContacts), iNewContact(aNewContact){};
|
williamr@2
|
428 |
RPointerArray<CViewContact>& iContacts;
|
williamr@2
|
429 |
const CViewContact* iNewContact;
|
williamr@2
|
430 |
};
|
williamr@2
|
431 |
/** Search type.
|
williamr@2
|
432 |
|
williamr@2
|
433 |
This controls whether a search term can occur anywhere in a contact item field,
|
williamr@2
|
434 |
or just at the beginning of the field. */
|
williamr@2
|
435 |
enum TSearchType
|
williamr@2
|
436 |
{
|
williamr@2
|
437 |
/** The search uses full wildcard matching so that the search string can occur anywhere
|
williamr@2
|
438 |
in the item's fields. */
|
williamr@2
|
439 |
EFullSearch,
|
williamr@2
|
440 |
/** The search uses partial wildcard matching so that the search string can only
|
williamr@2
|
441 |
occur at the beginning of the item's fields. */
|
williamr@2
|
442 |
EPrefixSearch
|
williamr@2
|
443 |
};
|
williamr@2
|
444 |
/** Identifies the functions that have been added to CContactViewBase, or that
|
williamr@2
|
445 |
may be added in the future. This identifier is passed to the reserved virtual
|
williamr@2
|
446 |
function CContactViewBase_Reserved_1() and enables the addition of new virtual
|
williamr@2
|
447 |
methods without breaking binary compatibility. */
|
williamr@2
|
448 |
enum TFunction
|
williamr@2
|
449 |
{
|
williamr@2
|
450 |
/** Identifies the function CContactViewBase::GetContactIdsL(). */
|
williamr@2
|
451 |
ECContactViewBaseVirtualFunction1,
|
williamr@2
|
452 |
/** Identifies the function CContactViewBase::GetContactsMatchingFilterL(). */
|
williamr@2
|
453 |
ECContactViewBaseVirtualFunction2,
|
williamr@2
|
454 |
// communication with Sort Plug-in
|
williamr@2
|
455 |
/** Identifies the function CContactViewBase::InsertContactInView(). */
|
williamr@2
|
456 |
ECContactViewBaseVirtualFunction3,
|
williamr@2
|
457 |
};
|
williamr@2
|
458 |
protected:
|
williamr@2
|
459 |
/** Defines the contact view states. */
|
williamr@2
|
460 |
enum TState
|
williamr@2
|
461 |
{
|
williamr@2
|
462 |
/** The view is initialising.
|
williamr@2
|
463 |
|
williamr@2
|
464 |
This is the view's state immediately after construction or after a significant change
|
williamr@2
|
465 |
(e.g CurrentDatabaseChanged or UnknownChanges), indicating that it can't be used yet. */
|
williamr@2
|
466 |
EInitializing,
|
williamr@2
|
467 |
/** The view is ready to be used. */
|
williamr@2
|
468 |
EReady,
|
williamr@2
|
469 |
/** The view is not ready to be used, for instance immediately after the sort order
|
williamr@2
|
470 |
has changed, or after an error has occurred. */
|
williamr@2
|
471 |
ENotReady
|
williamr@2
|
472 |
};
|
williamr@2
|
473 |
public:
|
williamr@2
|
474 |
IMPORT_C void OpenL(MContactViewObserver& aObserver);
|
williamr@2
|
475 |
IMPORT_C TInt Open(MContactViewObserver& aObserver);
|
williamr@2
|
476 |
IMPORT_C TBool Close(const MContactViewObserver& aObserver);
|
williamr@2
|
477 |
/** Returns the contact item ID at the specified index into the view.
|
williamr@2
|
478 |
|
williamr@2
|
479 |
@capability ReadUserData
|
williamr@2
|
480 |
@param aIndex Index of the contact item ID into the view.
|
williamr@2
|
481 |
@return The contact item ID. */
|
williamr@2
|
482 |
virtual TContactItemId AtL(TInt aIndex) const=0;
|
williamr@2
|
483 |
/** Returns the contact item at the specified index into the view.
|
williamr@2
|
484 |
|
williamr@2
|
485 |
@capability ReadUserData
|
williamr@2
|
486 |
@param aIndex Index of the contact item into the view.
|
williamr@2
|
487 |
@return The contact item. */
|
williamr@2
|
488 |
virtual const CViewContact& ContactAtL(TInt aIndex) const =0;
|
williamr@2
|
489 |
/** Returns the number of contact items in the view.
|
williamr@2
|
490 |
|
williamr@2
|
491 |
@capability ReadUserData
|
williamr@2
|
492 |
@return The number of contact items in the view. */
|
williamr@2
|
493 |
virtual TInt CountL() const=0;
|
williamr@2
|
494 |
/** Returns the index into the view of the specified contact item.
|
williamr@2
|
495 |
|
williamr@2
|
496 |
@capability ReadUserData
|
williamr@2
|
497 |
@param aId The contact item ID to search for.
|
williamr@2
|
498 |
@return The index into the view of the contact item ID, or KErrNotFound if
|
williamr@2
|
499 |
no matching ID can be found. */
|
williamr@2
|
500 |
virtual TInt FindL(TContactItemId aId) const=0;
|
williamr@2
|
501 |
/** Returns a descriptor containing the contents of all fields for an item in the view.
|
williamr@2
|
502 |
|
williamr@2
|
503 |
The field separator is used to separate the contents of each field. It is
|
williamr@2
|
504 |
not appended to the last field.
|
williamr@2
|
505 |
|
williamr@2
|
506 |
@capability ReadUserData
|
williamr@2
|
507 |
@param aIndex The index of the contact item into the view.
|
williamr@2
|
508 |
@param aSeparator The string to use to separate the fields.
|
williamr@2
|
509 |
@return Pointer to the contact item descriptor. */
|
williamr@2
|
510 |
virtual HBufC* AllFieldsLC(TInt aIndex,const TDesC& aSeparator) const=0;
|
williamr@2
|
511 |
IMPORT_C virtual void ContactsMatchingCriteriaL(const MDesCArray& aFindWords,RPointerArray<CViewContact>& aMatchedContacts);
|
williamr@2
|
512 |
/** Gets the view preferences.
|
williamr@2
|
513 |
|
williamr@2
|
514 |
@capability ReadUserData
|
williamr@2
|
515 |
@return The view preferences. */
|
williamr@2
|
516 |
virtual TContactViewPreferences ContactViewPreferences()=0;
|
williamr@2
|
517 |
/** Gets the view's sort order.
|
williamr@2
|
518 |
|
williamr@2
|
519 |
@capability ReadUserData
|
williamr@2
|
520 |
@return The sort order. */
|
williamr@2
|
521 |
virtual const RContactViewSortOrder& SortOrderL() const = 0;
|
williamr@2
|
522 |
IMPORT_C virtual void ContactsMatchingPrefixL(const MDesCArray& aFindWords, RPointerArray<CViewContact>& aMatchedContacts);
|
williamr@2
|
523 |
//This is a reserved virtual exported function that is used for BC proofing against present
|
williamr@2
|
524 |
//and future additions of new exported virtual functions. Existing exported virtual methods
|
williamr@2
|
525 |
//that broke BC are now non-virtual exported helper functions called from this method.
|
williamr@2
|
526 |
//All derived classes of CContactViewBase that are public must mandatorily
|
williamr@2
|
527 |
//implement this reserved exported virtual method.
|
williamr@2
|
528 |
IMPORT_C virtual TAny* CContactViewBase_Reserved_1(TFunction aFunction,TAny* aParams);
|
williamr@2
|
529 |
//New exported method to set the ECOM plug-in to be used
|
williamr@2
|
530 |
IMPORT_C void SetViewFindConfigPlugin(TUid aUid);
|
williamr@2
|
531 |
IMPORT_C TUid GetViewFindConfigPlugin();
|
williamr@2
|
532 |
IMPORT_C virtual void GetContactIdsL(const CArrayFix<TInt>& aIndexes, CContactIdArray& aContactIds);
|
williamr@2
|
533 |
IMPORT_C TInt Error() const;
|
williamr@2
|
534 |
IMPORT_C TUid GetViewSortPluginImplUid() const;
|
williamr@2
|
535 |
|
williamr@2
|
536 |
protected:
|
williamr@2
|
537 |
IMPORT_C ~CContactViewBase();
|
williamr@2
|
538 |
IMPORT_C void ConstructL();
|
williamr@2
|
539 |
|
williamr@2
|
540 |
IMPORT_C CContactViewBase(const CContactDatabase& aDb);
|
williamr@2
|
541 |
IMPORT_C void NotifyObservers(const TContactViewEvent& aEvent);
|
williamr@2
|
542 |
IMPORT_C TInt NotifyObserverAsync(MContactViewObserver& aObserver,const TContactViewEvent& aEvent);
|
williamr@2
|
543 |
IMPORT_C static TBool IdsMatch(const CViewContact& aFirst,const CViewContact& aSecond);
|
williamr@2
|
544 |
IMPORT_C HBufC* FieldsWithSeparatorLC(const RPointerArray<CViewContact>& aContacts,TInt aIndex,const TDesC& aSeparator) const;
|
williamr@2
|
545 |
//Find helper functions
|
williamr@2
|
546 |
IMPORT_C virtual TBool MatchesCriteriaL(const CViewContact& aContact,const MDesCArray& aFindWords);
|
williamr@2
|
547 |
IMPORT_C static TBool MatchesCriteriaL(const CViewContact& aContact,const MDesCArray& aFindWords, TSearchType aSearchType);
|
williamr@2
|
548 |
IMPORT_C static TBool MatchesCriteriaL(const CViewContact& aContact,const MDesCArray& aFindWords, TSearchType aSearchType,CContactViewBase::CContactViewBaseExtension* aExtension);
|
williamr@2
|
549 |
IMPORT_C static TBool IdsEqual(const TContactIdWithMapping& aFirst,const TContactIdWithMapping& aSecond);
|
williamr@2
|
550 |
IMPORT_C static TBool IndexesEqual(const TContactIdWithMapping& aFirst,const TContactIdWithMapping& aSecond);
|
williamr@2
|
551 |
IMPORT_C static TInt CompareFieldsL(const CViewContact& aFirst, const CViewContact& aSecond);
|
williamr@2
|
552 |
// View Sort Plugin changes
|
williamr@2
|
553 |
IMPORT_C static TInt CompareContactIds(const CViewContact& aFirst, const CViewContact& aSecond);
|
williamr@2
|
554 |
IMPORT_C static TBool ContactIsSortable(const CViewContact& aContact);
|
williamr@2
|
555 |
IMPORT_C TInt CompareContactsAndIdsL(const CViewContact& aFirst, const CViewContact& aSecond) const;
|
williamr@2
|
556 |
protected: // these are needed by CContactLocalView only
|
williamr@2
|
557 |
TInt InsertContactInView(RPointerArray<CViewContact>& aContacts, const CViewContact* aNewContact, TBool aSortByIdOnly, TInt* aIndex) const;
|
williamr@2
|
558 |
TBool IsContactSortable(const CViewContact& aContact, TContactViewPreferences& aViewPreferences) const;
|
williamr@2
|
559 |
CViewContactSortPlugin* SortPluginImpl() const;
|
williamr@2
|
560 |
TUid FindSortPluginImplL (const TDesC8& aSortPluginName,TBool aWildCard=EFalse) const;
|
williamr@2
|
561 |
TUid FindDefaultViewSortPluginImplL () const;
|
williamr@2
|
562 |
void LoadViewSortPluginL (TUid aSortPluginUid,TContactViewPreferences& aViewPreferences);
|
williamr@2
|
563 |
|
williamr@2
|
564 |
private:
|
williamr@2
|
565 |
static TInt AsyncNotifyCallBack(TAny* aSelf);
|
williamr@2
|
566 |
static CDesCArrayFlat* CreateFindWordArrayLC(const MDesCArray& aFindWords, TSearchType aSearchType);
|
williamr@2
|
567 |
static TBool ContactMatchesCriteriaL(const CViewContact& aContact,const MDesCArray& aFindWords,CContactViewBase::CContactViewBaseExtension* aExtension);
|
williamr@2
|
568 |
void MatchContactsL(const MDesCArray& aFindWords,RPointerArray<CViewContact>& aMatchedContacts, TSearchType aSearchType);
|
williamr@2
|
569 |
static TInt CompareFieldsWithCollationLevel(const CViewContact& aFirst, const CViewContact& aSecond,
|
williamr@2
|
570 |
TInt aCollationLevel, TCollationMethod* aCollateMethod);
|
williamr@2
|
571 |
TInt GetErrorValueFromExtensionClass();
|
williamr@2
|
572 |
void GetContactsMatchingFilterL(TInt aFilter, RArray<TContactIdWithMapping>& aMatchingContacts);
|
williamr@2
|
573 |
TInt TextCompareFieldsL(const CViewContact& aFirst, const CViewContact& aSecond) const;
|
williamr@2
|
574 |
|
williamr@2
|
575 |
|
williamr@2
|
576 |
private:
|
williamr@2
|
577 |
struct TObserverAndEvent
|
williamr@2
|
578 |
{
|
williamr@2
|
579 |
TContactViewEvent iAsyncEvent;
|
williamr@2
|
580 |
MContactViewObserver* iObserverToNotify;
|
williamr@2
|
581 |
};
|
williamr@2
|
582 |
protected:
|
williamr@2
|
583 |
// Reference to CContactDatabase class.
|
williamr@2
|
584 |
const CContactDatabase& iDb;
|
williamr@2
|
585 |
// Different Contacts view states.
|
williamr@2
|
586 |
TState iState;
|
williamr@2
|
587 |
// The pointer to the ContactViewBase BC extension class.
|
williamr@2
|
588 |
CContactViewBaseExtension* iExtension;
|
williamr@2
|
589 |
private:
|
williamr@2
|
590 |
RPointerArray<MContactViewObserver> iObserverArray;
|
williamr@2
|
591 |
CIdle* iAsyncNotifier;
|
williamr@2
|
592 |
RArray<TObserverAndEvent> iOutstandingNotifications;
|
williamr@2
|
593 |
};
|
williamr@2
|
594 |
|
williamr@2
|
595 |
inline TInt CContactViewBase::GetErrorValueFromExtensionClass()
|
williamr@2
|
596 |
{
|
williamr@2
|
597 |
return iExtension->iError;
|
williamr@2
|
598 |
}
|
williamr@2
|
599 |
|
williamr@2
|
600 |
class MLplPersistenceLayerFactory;
|
williamr@2
|
601 |
|
williamr@2
|
602 |
#ifdef __SYMBIAN_CNTMODEL_USE_SQLITE__
|
williamr@2
|
603 |
|
williamr@2
|
604 |
class CViewContactManager;
|
williamr@2
|
605 |
|
williamr@2
|
606 |
#else //__SYMBIAN_CNTMODEL_USE_SQLITE__
|
williamr@2
|
607 |
|
williamr@2
|
608 |
class CViewIterator;
|
williamr@2
|
609 |
|
williamr@2
|
610 |
#endif //__SYMBIAN_CNTMODEL_USE_SQLITE__
|
williamr@2
|
611 |
|
williamr@2
|
612 |
class CContactLocalView : public CContactViewBase, public MContactDbObserver
|
williamr@2
|
613 |
/** An instantiable base class for contact views.
|
williamr@2
|
614 |
|
williamr@2
|
615 |
The data associated with a local view is allocated within the client's memory
|
williamr@2
|
616 |
space; CContactRemoteView should be used in preference if the view is likely
|
williamr@2
|
617 |
to be shared between multiple clients. It is kept up to date by receiving
|
williamr@2
|
618 |
change events from the underlying CContactDatabase object which it observes.
|
williamr@2
|
619 |
The view preferences and sort order are specified on construction.
|
williamr@2
|
620 |
@publishedAll
|
williamr@2
|
621 |
@released
|
williamr@2
|
622 |
*/
|
williamr@2
|
623 |
{
|
williamr@2
|
624 |
public:
|
williamr@2
|
625 |
IMPORT_C static CContactLocalView* NewL(MContactViewObserver& aObserver,const CContactDatabase& aDb,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes);
|
williamr@2
|
626 |
IMPORT_C static CContactLocalView* NewL(MContactViewObserver& aObserver,const CContactDatabase& aDb,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes,
|
williamr@2
|
627 |
const TDesC8& aSortPluginName);
|
williamr@2
|
628 |
IMPORT_C static CContactLocalView* NewL(MContactViewObserver& aObserver,const CContactDatabase& aDb,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes,
|
williamr@2
|
629 |
MLplPersistenceLayerFactory* aFactory,const TDesC8& aSortPluginName);
|
williamr@2
|
630 |
|
williamr@2
|
631 |
IMPORT_C const RContactViewSortOrder& SortOrder() const;
|
williamr@2
|
632 |
public: // From CContactViewBase.
|
williamr@2
|
633 |
TContactItemId AtL(TInt aIndex) const;
|
williamr@2
|
634 |
TInt CountL() const;
|
williamr@2
|
635 |
TInt FindL(TContactItemId aId) const;
|
williamr@2
|
636 |
HBufC* AllFieldsLC(TInt aIndex,const TDesC& aSeparator) const;
|
williamr@2
|
637 |
const CViewContact& ContactAtL(TInt aIndex) const;
|
williamr@2
|
638 |
TContactViewPreferences ContactViewPreferences();
|
williamr@2
|
639 |
const RContactViewSortOrder& SortOrderL() const;
|
williamr@2
|
640 |
void NotifySortError(TInt aError);
|
williamr@2
|
641 |
//All derived classes of CContactViewBase that are public should mandatorily
|
williamr@2
|
642 |
//implement this reserved exported virtual method.
|
williamr@2
|
643 |
IMPORT_C TAny* CContactViewBase_Reserved_1(TFunction aFunction,TAny* aParams);
|
williamr@2
|
644 |
protected:
|
williamr@2
|
645 |
IMPORT_C ~CContactLocalView();
|
williamr@2
|
646 |
IMPORT_C CContactLocalView(const CContactDatabase& aDb,TContactViewPreferences aContactTypes);
|
williamr@2
|
647 |
CContactLocalView(const CContactDatabase& aDb,TContactViewPreferences aContactTypes,MLplPersistenceLayerFactory* aIterFactory);
|
williamr@2
|
648 |
IMPORT_C void ConstructL(MContactViewObserver& aObserver,const RContactViewSortOrder& aSortOrder);
|
williamr@2
|
649 |
void ConstructL(MContactViewObserver& aObserver,const RContactViewSortOrder& aSortOrder, const TBool aUseNamedPlugin, const TDesC8& aSortPluginName);
|
williamr@2
|
650 |
IMPORT_C virtual void SortL(const RContactViewSortOrder& aSortOrder);
|
williamr@2
|
651 |
IMPORT_C virtual TInt InsertL(TContactItemId aId);
|
williamr@2
|
652 |
IMPORT_C virtual TInt RemoveL(TContactItemId aId);
|
williamr@2
|
653 |
protected:
|
williamr@2
|
654 |
void SetState(TState aState);
|
williamr@2
|
655 |
private: // From MContactDbObserver.
|
williamr@2
|
656 |
virtual void HandleDatabaseEventL(TContactDbObserverEvent aEvent);
|
williamr@2
|
657 |
|
williamr@2
|
658 |
private:
|
williamr@2
|
659 |
|
williamr@2
|
660 |
#ifdef __SYMBIAN_CNTMODEL_USE_SQLITE__
|
williamr@2
|
661 |
void SortComplete(TInt aSortErr);
|
williamr@2
|
662 |
void SetSortOrderL(const RContactViewSortOrder& aSortOrder);
|
williamr@2
|
663 |
void SortL();
|
williamr@2
|
664 |
void SafeResort();
|
williamr@2
|
665 |
friend class CViewContactManager;
|
williamr@2
|
666 |
#else //__SYMBIAN_CNTMODEL_USE_SQLITE__
|
williamr@2
|
667 |
TInt SortCallBack();
|
williamr@2
|
668 |
TInt DoReadIncrementL();
|
williamr@2
|
669 |
void ResetSortL();
|
williamr@2
|
670 |
void InitialiseSortL(const RContactViewSortOrder& aSortOrder, TBool aChangingSortOrder);
|
williamr@2
|
671 |
void SortL();
|
williamr@2
|
672 |
void SafeResort();
|
williamr@2
|
673 |
void ContactsArraySortL();
|
williamr@2
|
674 |
TBool ContactCorrectType(TUid aType,TContactViewPreferences aTypeToInclude);
|
williamr@2
|
675 |
#endif //__SYMBIAN_CNTMODEL_USE_SQLITE__
|
williamr@2
|
676 |
|
williamr@2
|
677 |
private: // Metheds for event handling
|
williamr@2
|
678 |
void HandleOutstandingEvents();
|
williamr@2
|
679 |
void HandleOutstandingEventL();
|
williamr@2
|
680 |
friend class CIdleContactSorter;
|
williamr@2
|
681 |
protected:
|
williamr@2
|
682 |
/** The sort order.
|
williamr@2
|
683 |
This is set during construction or when SortL() is called. */
|
williamr@2
|
684 |
RContactViewSortOrder iSortOrder ;
|
williamr@2
|
685 |
private:
|
williamr@2
|
686 |
IMPORT_C virtual void CContactLocalView_Reserved_1();
|
williamr@2
|
687 |
IMPORT_C virtual void CContactLocalView_Reserved_2();
|
williamr@2
|
688 |
|
williamr@2
|
689 |
private:
|
williamr@2
|
690 |
MLplPersistenceLayerFactory* iFactory;
|
williamr@2
|
691 |
RPointerArray<CViewContact> iContacts;
|
williamr@2
|
692 |
RPointerArray<CViewContact> iUnSortedContacts;
|
williamr@2
|
693 |
RArray<TContactDbObserverEvent> iOutstandingEvents;
|
williamr@2
|
694 |
CIdleContactSorter* iAsyncSorter;
|
williamr@2
|
695 |
|
williamr@2
|
696 |
#ifdef __SYMBIAN_CNTMODEL_USE_SQLITE__
|
williamr@2
|
697 |
CViewContactManager* iViewCntMgr;
|
williamr@2
|
698 |
#else //__SYMBIAN_CNTMODEL_USE_SQLITE__
|
williamr@2
|
699 |
CViewIterator* iViewIterator;
|
williamr@2
|
700 |
#endif //__SYMBIAN_CNTMODEL_USE_SQLITE__
|
williamr@2
|
701 |
|
williamr@2
|
702 |
CContactTextDef* iTextDef;
|
williamr@2
|
703 |
TContactViewPreferences iViewPreferences;
|
williamr@2
|
704 |
TBool iSpare0;
|
williamr@2
|
705 |
TInt iSpare;
|
williamr@2
|
706 |
};
|
williamr@2
|
707 |
|
williamr@2
|
708 |
class RContactRemoteView : public RSubSessionBase
|
williamr@2
|
709 |
/** This class is used internally by remote contact views as the handle to the
|
williamr@2
|
710 |
server side view object.
|
williamr@2
|
711 |
|
williamr@2
|
712 |
@see CContactRemoteViewBase
|
williamr@2
|
713 |
@internalComponent
|
williamr@2
|
714 |
@released
|
williamr@2
|
715 |
*/
|
williamr@2
|
716 |
{
|
williamr@2
|
717 |
public:
|
williamr@2
|
718 |
void OpenL(const CContactDatabase& aDb,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes,const TUid& aSortPluginImplUid,const TDesC8& aSortPluginName);
|
williamr@2
|
719 |
void OpenL(const CContactDatabase& aDb,const TDesC& aName,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes,const TUid& aSortPluginImplUid,const TDesC8& aSortPluginName);
|
williamr@2
|
720 |
void Close();
|
williamr@2
|
721 |
public: // From CContactViewBase
|
williamr@2
|
722 |
TContactItemId AtL(TInt aIndex) const;
|
williamr@2
|
723 |
CViewContact* ContactAtL(TInt aIndex);
|
williamr@2
|
724 |
TInt CountL() const;
|
williamr@2
|
725 |
TInt FindL(TContactItemId aId) const;
|
williamr@2
|
726 |
HBufC* AllFieldsLC(TInt aIndex,const TDesC& aSeparator) const;
|
williamr@2
|
727 |
const RContactViewSortOrder& SortOrderL();
|
williamr@2
|
728 |
public:
|
williamr@2
|
729 |
void ContactsMatchingCriteriaL(const MDesCArray& aFindWords,RPointerArray<CViewContact>& aMatchedContacts, TBool aPrefixSearch,TUid aUid);
|
williamr@2
|
730 |
void ChangeSortOrderL(const RContactViewSortOrder& aSortOrder);
|
williamr@2
|
731 |
void GetSortOrderL(RContactViewSortOrder& aSortOrder);
|
williamr@2
|
732 |
TContactViewPreferences ContactViewPreferencesL();
|
williamr@2
|
733 |
|
williamr@2
|
734 |
void RequestViewEvent(TPckgBuf<TContactViewEvent>& aEvent,TRequestStatus& aStatus);
|
williamr@2
|
735 |
TInt CancelRequestViewEvent();
|
williamr@2
|
736 |
void GetContactIdsL(const CArrayFix<TInt>& aIndexes, CContactIdArray& aContactIds);
|
williamr@2
|
737 |
void GetContactsMatchingFilterL(TInt aFilter, RArray<TContactIdWithMapping>& aMatchingContacts);
|
williamr@2
|
738 |
TUid GetViewSortPluginImplUidL() const;
|
williamr@2
|
739 |
private:
|
williamr@2
|
740 |
HBufC8* PackageSortOrderLC(const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes) const;
|
williamr@2
|
741 |
HBufC8* PackageSortOrderAndPluginDetailsLC(const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes,const TUid& aSortPluginImplUid,const TDesC8& aSortPluginName) const;
|
williamr@2
|
742 |
private:
|
williamr@2
|
743 |
CViewContact* iContact;
|
williamr@2
|
744 |
RContactViewSortOrder iSortOrder ;
|
williamr@2
|
745 |
};
|
williamr@2
|
746 |
|
williamr@2
|
747 |
|
williamr@2
|
748 |
NONSHARABLE_CLASS(CContactRemoteViewBase) : public CContactViewBase
|
williamr@2
|
749 |
/** Base class for all remote contact view classes.
|
williamr@2
|
750 |
|
williamr@2
|
751 |
It implements all the pure virtual functions in CContactViewBase and additionally
|
williamr@2
|
752 |
it handles remote view notifications. The data associated with remote views
|
williamr@2
|
753 |
is allocated within the memory space of the contacts server. This means that
|
williamr@2
|
754 |
multiple clients can share the same server side view object, thereby reducing
|
williamr@2
|
755 |
the overhead associated with initial sorting of the view data and keeping
|
williamr@2
|
756 |
it in sync with the underlying data. Remote views should therefore be used
|
williamr@2
|
757 |
when the same view is likely to be needed by more than one client.
|
williamr@2
|
758 |
@internalComponent
|
williamr@2
|
759 |
@released
|
williamr@2
|
760 |
*/
|
williamr@2
|
761 |
{
|
williamr@2
|
762 |
public: // From CContactViewBase.
|
williamr@2
|
763 |
TContactItemId AtL(TInt aIndex) const;
|
williamr@2
|
764 |
TInt CountL() const;
|
williamr@2
|
765 |
TInt FindL(TContactItemId aId) const;
|
williamr@2
|
766 |
HBufC* AllFieldsLC(TInt aIndex,const TDesC& aSeparator) const;
|
williamr@2
|
767 |
const CViewContact& ContactAtL(TInt aIndex) const;
|
williamr@2
|
768 |
TContactViewPreferences ContactViewPreferences();
|
williamr@2
|
769 |
void ContactsMatchingCriteriaL(const MDesCArray& aFindWords,RPointerArray<CViewContact>& aMatchedContacts);
|
williamr@2
|
770 |
void ContactsMatchingPrefixL(const MDesCArray& aFindWords, RPointerArray<CViewContact>& aMatchedContacts);
|
williamr@2
|
771 |
const RContactViewSortOrder& SortOrderL() const;
|
williamr@2
|
772 |
//All derived classes of CContactViewBase that are public should mandatorily
|
williamr@2
|
773 |
//implement this reserved exported virtual method.
|
williamr@2
|
774 |
TAny* CContactViewBase_Reserved_1(TFunction aFunction,TAny* aParams);
|
williamr@2
|
775 |
//This function was virtual in a previous release, if you still need to use it
|
williamr@2
|
776 |
//in a virtual way then you can call it via the Reserved function.
|
williamr@2
|
777 |
//The functionality of this function ,however,remains the same.
|
williamr@2
|
778 |
void GetContactIdsL(const CArrayFix<TInt>& aIndexes, CContactIdArray& aContactIds);
|
williamr@2
|
779 |
void GetContactsMatchingFilterL(TInt aFilter, RArray<TContactIdWithMapping>& aMatchingContacts);
|
williamr@2
|
780 |
protected:
|
williamr@2
|
781 |
~CContactRemoteViewBase();
|
williamr@2
|
782 |
CContactRemoteViewBase(const CContactDatabase& aDb);
|
williamr@2
|
783 |
void ConstructL(MContactViewObserver& aObserver);
|
williamr@2
|
784 |
private:
|
williamr@2
|
785 |
static TInt NotifierCallBack(TAny* aSelf);
|
williamr@2
|
786 |
void HandleContactViewEvent(const TContactViewEvent& aEvent);
|
williamr@2
|
787 |
protected:
|
williamr@2
|
788 |
/** A handle to the server side view. */
|
williamr@2
|
789 |
RContactRemoteView iView;
|
williamr@2
|
790 |
private:
|
williamr@2
|
791 |
CContactRemoteViewNotifier* iNotifier;
|
williamr@2
|
792 |
/** Cached copy of the count of the local view in the contacts server.
|
williamr@2
|
793 |
If this is KCachedItemCountInvalid then next time CountL is called
|
williamr@2
|
794 |
the current count is retrieved from the contacts server. */
|
williamr@2
|
795 |
mutable TInt iCount;
|
williamr@2
|
796 |
};
|
williamr@2
|
797 |
|
williamr@2
|
798 |
|
williamr@2
|
799 |
class CContactRemoteView : public CContactRemoteViewBase
|
williamr@2
|
800 |
/** An instantiable remote contact view class.
|
williamr@2
|
801 |
|
williamr@2
|
802 |
Remote views are associated with a CContactLocalView object held in the contacts
|
williamr@2
|
803 |
server. They provide an efficient means for multiple clients to share the
|
williamr@2
|
804 |
same underlying view.
|
williamr@2
|
805 |
|
williamr@2
|
806 |
The view preferences and sort order are specified on construction.
|
williamr@2
|
807 |
@publishedAll
|
williamr@2
|
808 |
@released
|
williamr@2
|
809 |
*/
|
williamr@2
|
810 |
{
|
williamr@2
|
811 |
public:
|
williamr@2
|
812 |
IMPORT_C static CContactRemoteView* NewL(MContactViewObserver& aObserver,const CContactDatabase& aDb,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes);
|
williamr@2
|
813 |
IMPORT_C static CContactRemoteView* NewL(MContactViewObserver& aObserver,const CContactDatabase& aDb,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes,
|
williamr@2
|
814 |
const TDesC8& aSortPluginName);
|
williamr@2
|
815 |
IMPORT_C void GetSortOrderL(RContactViewSortOrder& aSortOrder);
|
williamr@2
|
816 |
//All derived classes of CContactViewBase that are public should mandatorily
|
williamr@2
|
817 |
//implement this reserved exported virtual method.
|
williamr@2
|
818 |
TAny* CContactViewBase_Reserved_1(TFunction aFunction,TAny* aParams);
|
williamr@2
|
819 |
protected:
|
williamr@2
|
820 |
~CContactRemoteView();
|
williamr@2
|
821 |
CContactRemoteView(const CContactDatabase& aDb);
|
williamr@2
|
822 |
private:
|
williamr@2
|
823 |
void ConstructL(MContactViewObserver& aObserver,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes);
|
williamr@2
|
824 |
void ConstructL(MContactViewObserver& aObserver,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypesconst, const TDesC8& aSortPluginName);
|
williamr@2
|
825 |
};
|
williamr@2
|
826 |
|
williamr@2
|
827 |
|
williamr@2
|
828 |
class CContactNamedRemoteView : public CContactRemoteView
|
williamr@2
|
829 |
/** A named remote contact view.
|
williamr@2
|
830 |
|
williamr@2
|
831 |
This class enables multiple clients to share a named server side view. It
|
williamr@2
|
832 |
also provides a function to change the sort order. If the sort order is changed,
|
williamr@2
|
833 |
a notification is sent to all users of the named view.
|
williamr@2
|
834 |
@publishedAll
|
williamr@2
|
835 |
@released
|
williamr@2
|
836 |
*/
|
williamr@2
|
837 |
{
|
williamr@2
|
838 |
public:
|
williamr@2
|
839 |
IMPORT_C static CContactNamedRemoteView* NewL(MContactViewObserver& aObserver,const TDesC& aName,const CContactDatabase& aDb,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes);
|
williamr@2
|
840 |
IMPORT_C static CContactNamedRemoteView* NewL(MContactViewObserver& aObserver,const TDesC& aName,const CContactDatabase& aDb,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes,
|
williamr@2
|
841 |
const TDesC8& aSortPluginName);
|
williamr@2
|
842 |
IMPORT_C void ChangeSortOrderL(const RContactViewSortOrder& aSortOrder);
|
williamr@2
|
843 |
//All derived classes of CContactViewBase that are public should mandatorily
|
williamr@2
|
844 |
//implement this reserved exported virtual method.
|
williamr@2
|
845 |
TAny* CContactViewBase_Reserved_1(TFunction aFunction,TAny* aParams);
|
williamr@2
|
846 |
private:
|
williamr@2
|
847 |
~CContactNamedRemoteView();
|
williamr@2
|
848 |
CContactNamedRemoteView(const CContactDatabase& aDb);
|
williamr@2
|
849 |
void ConstructL(MContactViewObserver& aObserver,const TDesC& aName,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes);
|
williamr@2
|
850 |
void ConstructL(MContactViewObserver& aObserver,const TDesC& aName,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes, const TDesC8& aSortPluginName);
|
williamr@2
|
851 |
};
|
williamr@2
|
852 |
|
williamr@2
|
853 |
inline TContactViewEvent::TContactViewEvent()
|
williamr@2
|
854 |
/** Empty default constructor. */
|
williamr@2
|
855 |
{};
|
williamr@2
|
856 |
|
williamr@2
|
857 |
inline TContactViewEvent::TContactViewEvent(TEventType aEventType,TInt aInt,TContactItemId aContactId) : iEventType(aEventType),iInt(aInt),iContactId(aContactId)
|
williamr@2
|
858 |
/** Constructor with an event type and an optional error code and contact item ID.
|
williamr@2
|
859 |
|
williamr@2
|
860 |
@param aEventType The event type.
|
williamr@2
|
861 |
@param aInt Optional standard error code.
|
williamr@2
|
862 |
@param aContactId Optional contact item ID. */
|
williamr@2
|
863 |
{};
|
williamr@2
|
864 |
|
williamr@2
|
865 |
inline void RContactViewSortOrder::AppendL(TFieldType aField)
|
williamr@2
|
866 |
/** Appends a field type to the sort order object.
|
williamr@2
|
867 |
|
williamr@2
|
868 |
@param aField The field type to append. */
|
williamr@2
|
869 |
{ User::LeaveIfError(iFields.Append(aField)); }
|
williamr@2
|
870 |
|
williamr@2
|
871 |
inline TFieldType RContactViewSortOrder::operator[](TInt aIndex) const
|
williamr@2
|
872 |
/** Gets an indexed field type.
|
williamr@2
|
873 |
|
williamr@2
|
874 |
@param aIndex Index of the required field type. A panic occurs if this is
|
williamr@2
|
875 |
invalid.
|
williamr@2
|
876 |
@return The field type located at the indexed position in the array. */
|
williamr@2
|
877 |
{ return iFields[aIndex]; }
|
williamr@2
|
878 |
|
williamr@2
|
879 |
inline TInt RContactViewSortOrder::Count() const
|
williamr@2
|
880 |
/** Gets the number of field types in the sort order array.
|
williamr@2
|
881 |
|
williamr@2
|
882 |
@return The number of field types in the array. */
|
williamr@2
|
883 |
{ return iFields.Count(); }
|
williamr@2
|
884 |
|
williamr@2
|
885 |
inline TContactItemId CViewContact::Id() const
|
williamr@2
|
886 |
/** Gets the view item's ID.
|
williamr@2
|
887 |
|
williamr@2
|
888 |
@return The view item's ID. */
|
williamr@2
|
889 |
{return iId;}
|
williamr@2
|
890 |
|
williamr@2
|
891 |
inline CViewContact::TViewContactType CViewContact::ContactType() const
|
williamr@2
|
892 |
/** Gets the view item's type.
|
williamr@2
|
893 |
|
williamr@2
|
894 |
@return The view item's type. */
|
williamr@2
|
895 |
{return iContactType;}
|
williamr@2
|
896 |
|
williamr@2
|
897 |
inline void CViewContact::SetId(TContactItemId aId)
|
williamr@2
|
898 |
/** Sets the view item's ID.
|
williamr@2
|
899 |
|
williamr@2
|
900 |
@param aId The contact item ID. */
|
williamr@2
|
901 |
{iId=aId;}
|
williamr@2
|
902 |
|
williamr@2
|
903 |
inline void CViewContact::SetContactType(CViewContact::TViewContactType aContactType)
|
williamr@2
|
904 |
/** Sets the view item's type.
|
williamr@2
|
905 |
|
williamr@2
|
906 |
@param aContactType The view item's type. */
|
williamr@2
|
907 |
{iContactType=aContactType;}
|
williamr@2
|
908 |
#endif
|