|
1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <cntviewbase.h> |
|
17 #include "cntviewprivate.h" |
|
18 #include <cntviewsortplugin.h> |
|
19 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
20 #include <cntviewsortpluginbase.h> |
|
21 #endif |
|
22 |
|
23 #include "CCntServer.h" //for KSlot1 and KSlot2 |
|
24 #include "rcntmodel.h" |
|
25 |
|
26 // uncomment define in header to select debug prints for API profiling |
|
27 #include "CntApiProfile.h" |
|
28 |
|
29 |
|
30 // |
|
31 // RContactRemoteView. |
|
32 // |
|
33 |
|
34 const TInt KCachedItemCountInvalid = -1; |
|
35 |
|
36 /** |
|
37 @capability ReadUserData |
|
38 */ |
|
39 void RContactRemoteView::OpenL(const CContactDatabase& aDb,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes,const TUid& aSortPluginImplUid,const TDesC8& aSortPluginName) |
|
40 { |
|
41 HBufC8* pckgBuf = PackageSortOrderAndPluginDetailsLC(aSortOrder,aContactTypes,aSortPluginImplUid,aSortPluginName); |
|
42 TIpcArgs args(pckgBuf->Length()); |
|
43 args.Set(KSlot1,pckgBuf); |
|
44 TInt err = CreateSubSession(*aDb.iCntSvr, ECntCreateView, args ); |
|
45 |
|
46 CleanupStack::PopAndDestroy(pckgBuf); |
|
47 User::LeaveIfError(err); |
|
48 } |
|
49 |
|
50 /** |
|
51 @capability ReadUserData |
|
52 */ |
|
53 void RContactRemoteView::OpenL(const CContactDatabase& aDb,const TDesC& aName,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes,const TUid& aSortPluginImplUid,const TDesC8& aSortPluginName) |
|
54 { |
|
55 HBufC8* pckgBuf = PackageSortOrderAndPluginDetailsLC(aSortOrder,aContactTypes,aSortPluginImplUid,aSortPluginName); |
|
56 TIpcArgs args(pckgBuf->Length()); |
|
57 args.Set(KSlot1,pckgBuf); |
|
58 args.Set(KSlot2,&aName); |
|
59 TInt err = CreateSubSession(*aDb.iCntSvr, ECntCreateNamedView, args ); |
|
60 |
|
61 CleanupStack::PopAndDestroy(pckgBuf); |
|
62 User::LeaveIfError(err); |
|
63 } |
|
64 |
|
65 /** |
|
66 @capability None |
|
67 */ |
|
68 void RContactRemoteView::Close() |
|
69 { |
|
70 CloseSubSession(ECntCloseView); |
|
71 if(iContact!=NULL) |
|
72 { |
|
73 delete iContact; |
|
74 } |
|
75 iSortOrder.Close(); |
|
76 } |
|
77 |
|
78 /** |
|
79 Returns the contact item at the specified index into the view. |
|
80 @capability ReadUserData |
|
81 @param aIndex Index |
|
82 */ |
|
83 CViewContact* RContactRemoteView::ContactAtL(TInt aIndex) |
|
84 { |
|
85 const TContactItemId KUnknownContactId = -1; |
|
86 |
|
87 // 4 context switches |
|
88 TPckgBuf<TInt>pckg; |
|
89 TIpcArgs args(aIndex,&pckg); |
|
90 User::LeaveIfError(SendReceive(ECntViewContactAtLength,args)); |
|
91 // |
|
92 CViewContact* contact = CViewContact::NewLC(KUnknownContactId); |
|
93 delete iContact; |
|
94 iContact = contact; |
|
95 CleanupStack::Pop(contact); |
|
96 // |
|
97 TInt contactLength=pckg(); |
|
98 HBufC8* buf=HBufC8::NewLC(contactLength); |
|
99 TPtr8 bufPtr(buf->Des()); |
|
100 TIpcArgs args2(&bufPtr); |
|
101 User::LeaveIfError(SendReceive(ECntViewContactAt,args2)); |
|
102 RDesReadStream readStream(bufPtr); |
|
103 CleanupClosePushL(readStream); |
|
104 readStream >> *iContact; |
|
105 CleanupStack::PopAndDestroy(2); // readStream , buf. |
|
106 return iContact; |
|
107 } |
|
108 |
|
109 /** |
|
110 Searches all contact items in the view for fields that contain the search |
|
111 strings specified. |
|
112 |
|
113 @capability ReadUserData |
|
114 @param aFindWords A descriptor array containing one or more search strings |
|
115 @param aMatchedContacts On return, an array of matching contact items |
|
116 @param find behaviour configuration uid to be passed to the server. |
|
117 */ |
|
118 void RContactRemoteView::ContactsMatchingCriteriaL(const MDesCArray& aFindWords, RPointerArray<CViewContact>& aMatchedContacts, TBool aPrefixSearch,TUid aUid) |
|
119 { |
|
120 if(aUid != KNullUid) |
|
121 { |
|
122 TIpcArgs args(aUid.iUid); |
|
123 User::LeaveIfError(SendReceive(ECntSendPluginUidToServer,args)); |
|
124 } |
|
125 CBufBase* buffer = CBufFlat::NewL(32); |
|
126 CleanupStack::PushL(buffer); |
|
127 RBufWriteStream writeStream(*buffer); |
|
128 CleanupClosePushL(writeStream); |
|
129 |
|
130 writeStream.WriteUint32L(aPrefixSearch); |
|
131 const TInt count = aFindWords.MdcaCount(); |
|
132 writeStream.WriteUint32L(count); |
|
133 for (TInt i=0; i<count; ++i) |
|
134 { |
|
135 TPtrC ptr = aFindWords.MdcaPoint(i); |
|
136 writeStream.WriteUint32L(ptr.Length()); |
|
137 writeStream << ptr; |
|
138 } |
|
139 |
|
140 writeStream.CommitL(); |
|
141 CleanupStack::PopAndDestroy(&writeStream); //writeStream.Close() |
|
142 |
|
143 TPtr8 ptr(buffer->Ptr(0)); |
|
144 const TInt bufferSize = buffer->Size(); |
|
145 TPckg<TInt> size(bufferSize); |
|
146 |
|
147 TPckgBuf<TInt> pckg; |
|
148 TIpcArgs args(&pckg,&size,&ptr); |
|
149 User::LeaveIfError(SendReceive(ECntContactMatchingCriteriaExternalizedSize,args)); |
|
150 CleanupStack::PopAndDestroy(buffer); |
|
151 |
|
152 //Internalize Contacts |
|
153 HBufC8* buf=HBufC8::NewLC(pckg()); |
|
154 TPtr8 contactsbufPtr(buf->Des()); |
|
155 TIpcArgs args2(&contactsbufPtr); |
|
156 User::LeaveIfError(SendReceive(ECntGetContactMatchingCriteria,args2)); |
|
157 |
|
158 RDesReadStream readStream(contactsbufPtr); |
|
159 CleanupClosePushL(readStream); |
|
160 const TInt findCount = readStream.ReadUint32L(); |
|
161 for (TInt zz=0;zz<findCount;++zz) |
|
162 { |
|
163 CViewContact* thisContact = CViewContact::NewLC(KNullContactId); |
|
164 readStream >> *thisContact; |
|
165 aMatchedContacts.AppendL(thisContact); |
|
166 CleanupStack::Pop(thisContact); |
|
167 } |
|
168 CleanupStack::PopAndDestroy(2, buf); |
|
169 } |
|
170 |
|
171 /** |
|
172 @capability ReadUserData |
|
173 */ |
|
174 TContactItemId RContactRemoteView::AtL(TInt aIndex) const |
|
175 { |
|
176 TPckgBuf<TContactItemId> pckg; |
|
177 TIpcArgs args(aIndex,&pckg); |
|
178 User::LeaveIfError(SendReceive(ECntViewAt,args)); |
|
179 return pckg(); |
|
180 } |
|
181 |
|
182 /** |
|
183 @capability ReadUserData |
|
184 */ |
|
185 TInt RContactRemoteView::CountL() const |
|
186 { |
|
187 TPckgBuf<TInt> pckg; |
|
188 TIpcArgs args(&pckg); |
|
189 User::LeaveIfError(SendReceive(ECntViewCount,args)); |
|
190 return pckg(); |
|
191 } |
|
192 |
|
193 /** |
|
194 @capability ReadUserData |
|
195 */ |
|
196 TInt RContactRemoteView::FindL(TContactItemId aId) const |
|
197 { |
|
198 TPckgBuf<TInt> pckg; |
|
199 TIpcArgs args(aId, &pckg); |
|
200 User::LeaveIfError(SendReceive(ECntViewFind,args)); |
|
201 return pckg(); |
|
202 } |
|
203 |
|
204 /** |
|
205 @capability ReadUserData |
|
206 */ |
|
207 HBufC* RContactRemoteView::AllFieldsLC(TInt aIndex,const TDesC& aSeparator) const |
|
208 { |
|
209 // 4 context switches |
|
210 TPckgBuf<TInt>pckg; |
|
211 TIpcArgs args(aIndex,&aSeparator,&pckg); |
|
212 User::LeaveIfError(SendReceive(ECntAllFieldsLength,args)); |
|
213 TInt fieldLength = pckg(); |
|
214 HBufC* buf=HBufC::NewLC(fieldLength); |
|
215 TPtr8 narrowBufPtr((TUint8*)buf->Ptr(),buf->Des().MaxLength()*2); // Note, must call MaxLength because the cell allocated may be larger than aLength. |
|
216 TIpcArgs args2(&narrowBufPtr); |
|
217 User::LeaveIfError(SendReceive(ECntAllFieldsText,args2)); |
|
218 TPtr bufPtr(buf->Des()); |
|
219 bufPtr.SetLength(narrowBufPtr.Length()/2); |
|
220 return buf; |
|
221 } |
|
222 |
|
223 /** |
|
224 @capability ReadUserData |
|
225 */ |
|
226 void RContactRemoteView::ChangeSortOrderL(const RContactViewSortOrder& aSortOrder) |
|
227 { |
|
228 TInt size = aSortOrder.ExternalizedSize(); |
|
229 size +=sizeof(TInt32);//TContactViewPreferences |
|
230 TIpcArgs args(size); |
|
231 args.Set(KSlot1,PackageSortOrderLC(aSortOrder,ContactViewPreferencesL())); |
|
232 User::LeaveIfError(SendReceive(ECntChangeViewSortOrder,args)); |
|
233 CleanupStack::PopAndDestroy(); // buf. |
|
234 } |
|
235 |
|
236 /** |
|
237 @capability ReadUserData |
|
238 */ |
|
239 void RContactRemoteView::GetSortOrderL(RContactViewSortOrder& aSortOrder) |
|
240 { |
|
241 TPckgBuf<TInt> pckg; |
|
242 TIpcArgs args(&pckg); |
|
243 User::LeaveIfError(SendReceive(ECntViewSortOrderExternalizedSize,args)); |
|
244 HBufC8* buf=HBufC8::NewLC(pckg()); |
|
245 TPtr8 bufPtr(buf->Des()); |
|
246 TIpcArgs args2(&bufPtr); |
|
247 User::LeaveIfError(SendReceive(ECntGetViewSortOrder,args2)); |
|
248 RDesReadStream readStream(bufPtr); |
|
249 CleanupClosePushL(readStream); |
|
250 readStream >> aSortOrder; |
|
251 CleanupStack::PopAndDestroy(2); //readStream // buf. |
|
252 } |
|
253 |
|
254 /** |
|
255 @capability ReadUserData |
|
256 */ |
|
257 void RContactRemoteView::RequestViewEvent(TPckgBuf<TContactViewEvent>& aEvent,TRequestStatus& aStatus) |
|
258 { |
|
259 TIpcArgs args(&aEvent); |
|
260 SendReceive(ECntRequestViewEvent,args,aStatus); |
|
261 } |
|
262 |
|
263 /** |
|
264 @capability None |
|
265 */ |
|
266 TInt RContactRemoteView::CancelRequestViewEvent() |
|
267 { |
|
268 TIpcArgs args; |
|
269 return SendReceive(ECntCancelRequestViewEvent,args); |
|
270 } |
|
271 |
|
272 HBufC8* RContactRemoteView::PackageSortOrderLC(const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes) const |
|
273 { |
|
274 TInt bufLength=aSortOrder.ExternalizedSize(); |
|
275 bufLength+=sizeof(TContactViewPreferences);// |
|
276 HBufC8* buf=HBufC8::NewLC(bufLength); |
|
277 TPtr8 bufPtr(buf->Des()); |
|
278 RDesWriteStream writeStream(bufPtr); |
|
279 writeStream << (TInt32&)aContactTypes; |
|
280 writeStream << aSortOrder; |
|
281 bufPtr.SetLength(bufLength); |
|
282 return buf; |
|
283 } |
|
284 |
|
285 HBufC8* RContactRemoteView::PackageSortOrderAndPluginDetailsLC(const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes,const TUid& aSortPluginImplUid,const TDesC8& aSortPluginName) const |
|
286 { |
|
287 // Make a packe that includes the sort plugin name |
|
288 TInt bufLength = aSortOrder.ExternalizedSize(); |
|
289 bufLength += sizeof(TContactViewPreferences); |
|
290 bufLength +=sizeof(TInt32);//length of UID |
|
291 bufLength +=sizeof(TInt32);//length of aSortPluginName |
|
292 bufLength +=aSortPluginName.Length(); |
|
293 |
|
294 HBufC8* buf=HBufC8::NewLC(bufLength); |
|
295 TPtr8 bufPtr(buf->Des()); |
|
296 RDesWriteStream writeStream(bufPtr); |
|
297 writeStream << (TInt32&)aContactTypes; |
|
298 writeStream << aSortOrder; |
|
299 writeStream.WriteInt32L(aSortPluginImplUid.iUid); |
|
300 writeStream.WriteInt32L(aSortPluginName.Length()); |
|
301 writeStream.WriteL(aSortPluginName); |
|
302 bufPtr.SetLength(bufLength); |
|
303 return buf; |
|
304 } |
|
305 /** |
|
306 @capability ReadUserData |
|
307 */ |
|
308 const RContactViewSortOrder& RContactRemoteView::SortOrderL() |
|
309 { |
|
310 iSortOrder.Close(); |
|
311 GetSortOrderL(iSortOrder); |
|
312 return iSortOrder; |
|
313 } |
|
314 |
|
315 /** |
|
316 @capability ReadUserData |
|
317 */ |
|
318 TContactViewPreferences RContactRemoteView::ContactViewPreferencesL() |
|
319 { |
|
320 TPckgBuf<TContactViewPreferences> pckg; |
|
321 TIpcArgs args(&pckg); |
|
322 User::LeaveIfError(SendReceive(ECntGetIncludedTypes,args)); |
|
323 return pckg(); |
|
324 } |
|
325 |
|
326 /** |
|
327 Convert between view indexes and contact ids. |
|
328 This method makes the request to the server. |
|
329 @capability ReadUserData |
|
330 */ |
|
331 void RContactRemoteView::GetContactIdsL(const CArrayFix<TInt>& aIndexes, CContactIdArray& aContactIds) |
|
332 { |
|
333 CBufBase* buffer = CBufFlat::NewL(32); |
|
334 CleanupStack::PushL(buffer); |
|
335 RBufWriteStream writeStream(*buffer); |
|
336 CleanupClosePushL(writeStream); |
|
337 |
|
338 const TInt count = aIndexes.Count(); |
|
339 writeStream.WriteUint32L(count); |
|
340 for (TInt i=0; i<count; ++i) |
|
341 { |
|
342 writeStream.WriteUint32L(aIndexes[i]); |
|
343 } |
|
344 writeStream.CommitL(); |
|
345 CleanupStack::PopAndDestroy(&writeStream); //writeStream.Close() |
|
346 |
|
347 |
|
348 TPtr8 indexes(buffer->Ptr(0)); |
|
349 const TInt bufferSize = buffer->Size(); |
|
350 TPckg<TInt> size(bufferSize); |
|
351 |
|
352 HBufC8* buf=HBufC8::NewLC(bufferSize); |
|
353 TPtr8 ids(buf->Des()); |
|
354 |
|
355 TIpcArgs args(&size, &indexes, &ids); |
|
356 User::LeaveIfError(SendReceive(ECntGetContactIds,args)); |
|
357 |
|
358 |
|
359 RDesReadStream readStream(ids); |
|
360 CleanupClosePushL(readStream); |
|
361 CContactIdArray* array = CContactIdArray::NewLC(); |
|
362 readStream >> *array; |
|
363 |
|
364 const TInt arrayCount = array->Count(); |
|
365 for(TInt loop=0;loop<arrayCount;loop++) |
|
366 aContactIds.AddL((*array)[loop]); |
|
367 |
|
368 CleanupStack::PopAndDestroy(4,buffer); //array, &readStream, buf, buffer |
|
369 } |
|
370 |
|
371 /** |
|
372 Requests an array of contact IDs from the server-side view which |
|
373 match the filter provided by the client. |
|
374 |
|
375 @capability ReadUserData |
|
376 @param aFilter Filter supplied by client |
|
377 @param aMatchingContacts Array of contacts which match the filter |
|
378 */ |
|
379 void RContactRemoteView::GetContactsMatchingFilterL(TInt aFilter, RArray<TContactIdWithMapping>& aMatchingContacts) |
|
380 { |
|
381 // Create a large enough buffer to hold whole view and ask server which contacts match |
|
382 const TInt viewCount(CountL()); |
|
383 const TInt maxBufferSize = (1+(viewCount*2))*sizeof(TInt); |
|
384 HBufC8* buf=HBufC8::NewLC(maxBufferSize); |
|
385 TPtr8 ids(buf->Des()); |
|
386 TIpcArgs args(aFilter,&ids); |
|
387 User::LeaveIfError(SendReceive(ECntGetContactsMatchingFilter,args)); |
|
388 |
|
389 // Read results from buffer externalized by server |
|
390 RDesReadStream readStream(ids); |
|
391 CleanupClosePushL(readStream); |
|
392 const TInt count = readStream.ReadUint32L(); |
|
393 TContactIdWithMapping idMap; |
|
394 for(TInt i=0;i<count;++i) |
|
395 { |
|
396 idMap.iId=readStream.ReadInt32L(); |
|
397 idMap.iMapping=readStream.ReadInt32L(); |
|
398 aMatchingContacts.AppendL(idMap); |
|
399 } |
|
400 CleanupStack::PopAndDestroy(2,buf); //readStream, buf |
|
401 } |
|
402 |
|
403 /* |
|
404 * Get Implementation Uid of loaded Sort Plug-in from Server View |
|
405 */ |
|
406 TUid RContactRemoteView::GetViewSortPluginImplUidL() const |
|
407 { |
|
408 TUid uid; |
|
409 TPckgBuf<TInt> pckg; |
|
410 TIpcArgs args(&pckg); |
|
411 User::LeaveIfError(SendReceive(ECntGetSortPluginUidFromServer,args)); |
|
412 uid.iUid = pckg(); |
|
413 return uid; |
|
414 } |
|
415 |
|
416 // |
|
417 // CContactRemoteViewNotifier. |
|
418 // |
|
419 |
|
420 CContactRemoteViewNotifier::CContactRemoteViewNotifier(RContactRemoteView& aView,TCallBack aCallBack) |
|
421 : CActive(EPriorityStandard),iView(aView),iCallBack(aCallBack) |
|
422 { |
|
423 CActiveScheduler::Add(this); |
|
424 } |
|
425 |
|
426 CContactRemoteViewNotifier::~CContactRemoteViewNotifier() |
|
427 { |
|
428 Cancel(); |
|
429 } |
|
430 /** |
|
431 @capability ReadUserData |
|
432 */ |
|
433 void CContactRemoteViewNotifier::Start() |
|
434 { |
|
435 ASSERT(!IsActive()); |
|
436 iView.RequestViewEvent(iEvent,iStatus); |
|
437 SetActive(); |
|
438 } |
|
439 |
|
440 const TContactViewEvent& CContactRemoteViewNotifier::Event() const |
|
441 { |
|
442 return MUTABLE_CAST(CContactRemoteViewNotifier*,this)->iEvent(); |
|
443 } |
|
444 |
|
445 void CContactRemoteViewNotifier::RunL() |
|
446 { |
|
447 iCallBack.CallBack(); |
|
448 Start(); |
|
449 } |
|
450 |
|
451 void CContactRemoteViewNotifier::DoCancel() |
|
452 { |
|
453 iView.CancelRequestViewEvent(); |
|
454 } |
|
455 |
|
456 |
|
457 // |
|
458 // CContactRemoteViewBase. |
|
459 // |
|
460 |
|
461 /** |
|
462 Cancels the active notifier and closes the session with the contacts server. |
|
463 @internalComponent |
|
464 @capability None |
|
465 */ |
|
466 CContactRemoteViewBase::~CContactRemoteViewBase() |
|
467 { |
|
468 delete iNotifier; |
|
469 iView.Close(); |
|
470 } |
|
471 |
|
472 CContactRemoteViewBase::CContactRemoteViewBase(const CContactDatabase& aDb) |
|
473 : CContactViewBase(aDb), iCount(KCachedItemCountInvalid) |
|
474 /** Protected C++ constructor. |
|
475 |
|
476 @internalComponent |
|
477 @param aDb The underlying database containing the contact items. */ |
|
478 { |
|
479 } |
|
480 |
|
481 void CContactRemoteViewBase::ConstructL(MContactViewObserver& aObserver) |
|
482 /** Protected second phase constructor. |
|
483 |
|
484 Starts an active object which notifies this view (by calling its HandleContactViewEvent() |
|
485 function) when view events occur in the server side view. This remote view |
|
486 in turn passes the events to its observers. |
|
487 |
|
488 @capability ReadUserData |
|
489 @param aObserver An observer that receives notifications when this view is |
|
490 ready for use and when changes take place in it. The observer receives a TContactViewEvent::EReady |
|
491 event when the view is ready. An attempt to use the view before this notification |
|
492 causes a panic. */ |
|
493 { |
|
494 CContactViewBase::ConstructL(); |
|
495 OpenL(aObserver); |
|
496 iNotifier=new(ELeave) CContactRemoteViewNotifier(iView,TCallBack(NotifierCallBack,this)); |
|
497 iNotifier->Start(); |
|
498 } |
|
499 |
|
500 /** Returns the ID of the contact item at a specified index into the the server |
|
501 side view. |
|
502 |
|
503 @capability ReadUserData |
|
504 @param aIndex An index into the server side view. |
|
505 @leave KErrNotFound The index is greater than or equal to the number of items |
|
506 in the view. |
|
507 @leave KErrNotReady The view is not ready for use. |
|
508 @return The ID of the contact item at the specified index. |
|
509 @panic CntLock 6 The index is less than zero. */ |
|
510 TContactItemId CContactRemoteViewBase::AtL(TInt aIndex) const |
|
511 { |
|
512 #ifdef CONTACTS_API_PROFILING |
|
513 TContactsApiProfile::CntViewMethodLog(TContactsApiProfile::ECntVwClassRemoteViewBase, TContactsApiProfile::ECntViewApiAtL, aIndex); |
|
514 #endif |
|
515 if (iState != EReady) |
|
516 { |
|
517 User::Leave(KErrNotReady); |
|
518 } |
|
519 return iView.AtL(aIndex); |
|
520 } |
|
521 |
|
522 /** Returns the contact item at a specified index into the server side view. |
|
523 |
|
524 @capability ReadUserData |
|
525 @param aIndex An index into the server side view. |
|
526 @leave KErrNotFound The index is greater than or equal to the number of items |
|
527 in the view. |
|
528 @leave KErrNotReady The view is not ready for use. |
|
529 @return The contact item at the specified index. |
|
530 @panic CntLock 6 The index is less than zero. */ |
|
531 const CViewContact& CContactRemoteViewBase::ContactAtL(TInt aIndex) const |
|
532 { |
|
533 if (iState != EReady) |
|
534 { |
|
535 User::Leave(KErrNotReady); |
|
536 } |
|
537 return *CONST_CAST(RContactRemoteView&,iView).ContactAtL(aIndex); |
|
538 } |
|
539 |
|
540 /** Gets the total number of contact items in the server side view. |
|
541 |
|
542 @capability ReadUserData |
|
543 @leave KErrNotReady The view is not ready for use. |
|
544 @return The number of contact items in the view. |
|
545 */ |
|
546 TInt CContactRemoteViewBase::CountL() const |
|
547 { |
|
548 if (iState != EReady) |
|
549 { |
|
550 User::Leave(KErrNotReady); |
|
551 } |
|
552 if (iCount == KCachedItemCountInvalid) |
|
553 { |
|
554 iCount = iView.CountL(); |
|
555 } |
|
556 return iCount; |
|
557 } |
|
558 |
|
559 /** Searches for a contact item in the server side view with the specified ID. |
|
560 |
|
561 @capability ReadUserData |
|
562 @param aId The ID of the contact item to search for. |
|
563 @leave KErrNotReady The view is not ready for use. |
|
564 @return If found, the index into the view of the matching item. Otherwise, |
|
565 KErrNotFound. |
|
566 */ |
|
567 TInt CContactRemoteViewBase::FindL(TContactItemId aId) const |
|
568 { |
|
569 if (iState != EReady) |
|
570 { |
|
571 User::Leave(KErrNotReady); |
|
572 } |
|
573 return iView.FindL(aId); |
|
574 } |
|
575 |
|
576 /** Gets a descriptor containing the contents of all fields specified in the server |
|
577 side view's sort order for an item in the view. |
|
578 |
|
579 The field separator is used to separate the contents of each field. It is |
|
580 not appended to the last field. |
|
581 |
|
582 @capability ReadUserData |
|
583 @param aIndex The index of the contact item into the view. |
|
584 @param aSeparator The string to use to separate the fields. |
|
585 @leave KErrNotFound The index is greater than or equal to the number of items |
|
586 in the view. |
|
587 @leave KErrNotReady The view is not ready for use. |
|
588 @return Pointer to the contact item descriptor. |
|
589 @panic CntLock 6 The index is less than zero. */ |
|
590 HBufC* CContactRemoteViewBase::AllFieldsLC(TInt aIndex,const TDesC& aSeparator) const |
|
591 { |
|
592 if (iState != EReady) |
|
593 { |
|
594 User::Leave(KErrNotReady); |
|
595 } |
|
596 return iView.AllFieldsLC(aIndex,aSeparator); |
|
597 } |
|
598 |
|
599 /** Searches all contact items in the server side view for fields that contain |
|
600 all of the search strings specified. |
|
601 |
|
602 The search uses wildcard matching so that the search strings can occur anywhere |
|
603 in the item's fields. For a match to occur, all of the search strings must |
|
604 be found in a contact item. |
|
605 |
|
606 @capability ReadUserData |
|
607 @param aFindWords A descriptor array containing one or more search strings. |
|
608 @param aMatchedContacts On return, an array of matching contact items. */ |
|
609 void CContactRemoteViewBase::ContactsMatchingCriteriaL(const MDesCArray& aFindWords, RPointerArray<CViewContact>& aMatchedContacts) |
|
610 { |
|
611 iView.ContactsMatchingCriteriaL(aFindWords,aMatchedContacts,EFalse,GetViewFindConfigPlugin()); |
|
612 } |
|
613 |
|
614 /** Searches all contact items in the server side view for fields that contain |
|
615 all of the search strings specified. |
|
616 |
|
617 Unlike ContactsMatchingCriteriaL(), the search term can only occur at the |
|
618 beginning of a field. |
|
619 |
|
620 @capability ReadUserData |
|
621 @param aFindWords A descriptor array containing one or more search strings. |
|
622 @param aMatchedContacts On return, an array of matching contact items. */ |
|
623 void CContactRemoteViewBase::ContactsMatchingPrefixL(const MDesCArray& aFindWords, RPointerArray<CViewContact>& aMatchedContacts) |
|
624 { |
|
625 iView.ContactsMatchingCriteriaL(aFindWords,aMatchedContacts,ETrue,GetViewFindConfigPlugin()); |
|
626 } |
|
627 |
|
628 |
|
629 TInt CContactRemoteViewBase::NotifierCallBack(TAny* aSelf) |
|
630 { |
|
631 CContactRemoteViewBase* self=STATIC_CAST(CContactRemoteViewBase*,aSelf); |
|
632 self->HandleContactViewEvent(self->iNotifier->Event()); |
|
633 return 0; |
|
634 } |
|
635 |
|
636 void CContactRemoteViewBase::HandleContactViewEvent(const TContactViewEvent& aEvent) |
|
637 { |
|
638 const TInt KInvalidValueForRemoteView = -1; |
|
639 |
|
640 iCount = KCachedItemCountInvalid; |
|
641 |
|
642 switch (aEvent.iEventType) |
|
643 { |
|
644 case TContactViewEvent::EUnavailable: |
|
645 case TContactViewEvent::ESortError: |
|
646 case TContactViewEvent::EServerError: |
|
647 iState=ENotReady; |
|
648 break; |
|
649 case TContactViewEvent::EReady: |
|
650 case TContactViewEvent::ESortOrderChanged: |
|
651 iState=EReady; |
|
652 break; |
|
653 case TContactViewEvent::EItemAdded: |
|
654 // should we consume the event? |
|
655 // the very first EItemAdded event will be consumed in this view |
|
656 // and not be broadcasted forward. This is because on server side |
|
657 // EItemAdded events are sorted before being sent |
|
658 if( aEvent.iContactId == KInvalidValueForRemoteView && |
|
659 aEvent.iInt == KInvalidValueForRemoteView) |
|
660 { |
|
661 return; |
|
662 } |
|
663 |
|
664 break; |
|
665 case TContactViewEvent::EItemRemoved: |
|
666 break; |
|
667 case TContactViewEvent::EGroupChanged: |
|
668 break; |
|
669 default: |
|
670 ASSERT(EFalse); |
|
671 } |
|
672 |
|
673 NotifyObservers(aEvent); |
|
674 } |
|
675 |
|
676 /** Gets the server side view's view preferences. |
|
677 |
|
678 @capability ReadUserData |
|
679 @return The view preferences. */ |
|
680 TContactViewPreferences CContactRemoteViewBase::ContactViewPreferences() |
|
681 { |
|
682 #ifdef CONTACTS_API_PROFILING |
|
683 TContactsApiProfile::CntViewMethodLog(TContactsApiProfile::ECntVwClassRemoteViewBase, TContactsApiProfile::ECntViewApiContactViewPreferences); |
|
684 #endif |
|
685 TContactViewPreferences type=EContactsOnly; |
|
686 TRAP_IGNORE(type = iView.ContactViewPreferencesL()); |
|
687 return type; |
|
688 } |
|
689 |
|
690 /** Gets the server side view's sort order. |
|
691 |
|
692 @capability ReadUserData |
|
693 @return The sort order. |
|
694 */ |
|
695 const RContactViewSortOrder& CContactRemoteViewBase::SortOrderL() const |
|
696 { |
|
697 #ifdef CONTACTS_API_PROFILING |
|
698 TContactsApiProfile::CntViewMethodLog(TContactsApiProfile::ECntVwClassRemoteViewBase, TContactsApiProfile::ECntViewApiSortOrder); |
|
699 #endif |
|
700 return CONST_CAST(RContactRemoteView&,iView).SortOrderL(); |
|
701 } |
|
702 |
|
703 /** |
|
704 This is a reserved virtual exported function that is used for BC proofing |
|
705 against present and future additions of new exported virtual functions. |
|
706 |
|
707 @capability ReadUserData |
|
708 */ |
|
709 TAny* CContactRemoteViewBase::CContactViewBase_Reserved_1(TFunction aFunction,TAny* aParams) |
|
710 { |
|
711 switch(aFunction) |
|
712 { |
|
713 case ECContactViewBaseVirtualFunction1: |
|
714 { |
|
715 TVirtualFunction1Params* vFuncParams = STATIC_CAST(TVirtualFunction1Params*,aParams); |
|
716 GetContactIdsL(*vFuncParams->iIndexes,*vFuncParams->iIdArray); |
|
717 } |
|
718 break; |
|
719 case ECContactViewBaseVirtualFunction2: |
|
720 { |
|
721 TVirtualFunction2Params* vFuncParams = STATIC_CAST(TVirtualFunction2Params*,aParams); |
|
722 GetContactsMatchingFilterL(vFuncParams->iFilter, vFuncParams->iMatchingContacts); |
|
723 } |
|
724 break; |
|
725 default: |
|
726 return CContactViewBase::CContactViewBase_Reserved_1(aFunction,aParams); |
|
727 } |
|
728 return NULL; |
|
729 } |
|
730 |
|
731 /* |
|
732 * This function was earlier virtual.But it broke BC.so now,this function is |
|
733 * a helper function called from the reserved virtual function that is implemented |
|
734 * for BC proofing.The functionality of this function ,however,remains the same. |
|
735 */ |
|
736 |
|
737 /** Gets an array containing the IDs of the contact items at the specified indexes |
|
738 into the server side view. |
|
739 |
|
740 The IDs are appended to the array. |
|
741 |
|
742 @capability ReadUserData |
|
743 @param aIndexes An array of indexes into the server side view. |
|
744 @param aContactIds On return, an array to which the contact item IDs of each |
|
745 of the indexed items are appended. */ |
|
746 void CContactRemoteViewBase::GetContactIdsL(const CArrayFix<TInt>& aIndexes, CContactIdArray& aContactIds) |
|
747 { |
|
748 iView.GetContactIdsL(aIndexes, aContactIds); |
|
749 } |
|
750 |
|
751 /** |
|
752 Requests an array of contact IDs from the server-side view which |
|
753 match the filter provided by the client. |
|
754 |
|
755 @capability ReadUserData |
|
756 */ |
|
757 void CContactRemoteViewBase::GetContactsMatchingFilterL(TInt aFilter, RArray<TContactIdWithMapping>& aMatchingContacts) |
|
758 { |
|
759 iView.GetContactsMatchingFilterL(aFilter, aMatchingContacts); |
|
760 } |
|
761 |
|
762 // |
|
763 // CContactRemoteView. |
|
764 // |
|
765 |
|
766 /** Allocates and constructs a remote contact view object. |
|
767 |
|
768 This function causes a new local view object to be created in the contacts |
|
769 server, unless one already exists with the specified view preferences and |
|
770 sort order. In that case, this client is given shared access to it. |
|
771 |
|
772 Starts the active notifier, so that this view receives change events from |
|
773 the server side view object. These change events are in turn passed to this |
|
774 view's observers. |
|
775 |
|
776 @capability ReadUserData |
|
777 @param aObserver An observer that receives notifications when this view is |
|
778 ready for use and when changes take place in it. The observer receives a TContactViewEvent::EReady |
|
779 event when the view is ready. An attempt to use the view before this notification |
|
780 causes a panic. |
|
781 @param aDb The underlying database containing the contact items. |
|
782 @param aSortOrder Specifies the fields to use to sort the items in the server |
|
783 side view. |
|
784 @param aContactTypes Specifies which types of contact items should be included |
|
785 in the view and the behaviour for items that do not have content in any of |
|
786 the fields specified in the sort order. |
|
787 @return The newly constructed remote view object. */ |
|
788 EXPORT_C CContactRemoteView* CContactRemoteView::NewL(MContactViewObserver& aObserver,const CContactDatabase& aDb, |
|
789 const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes) |
|
790 { |
|
791 #ifdef CONTACTS_API_PROFILING |
|
792 TContactsApiProfile::CntViewMethodLog(TContactsApiProfile::ECntVwClassRemoteView, TContactsApiProfile::ECntViewApiNewL, aSortOrder, aContactTypes); |
|
793 #endif |
|
794 CContactRemoteView* self=new(ELeave) CContactRemoteView(aDb); |
|
795 CleanupStack::PushL(self); |
|
796 self->ConstructL(aObserver,aSortOrder,aContactTypes); |
|
797 CleanupStack::Pop(); // self; |
|
798 return self; |
|
799 } |
|
800 |
|
801 /** |
|
802 Allocates and constructs a remote contact view object. |
|
803 |
|
804 This function causes a new local view object to be created in the contacts |
|
805 server, unless one already exists with the specified view preferences and |
|
806 sort order. In that case, this client is given shared access to it. |
|
807 |
|
808 Starts the active notifier, so that this view receives change events from |
|
809 the server side view object. These change events are in turn passed to this |
|
810 view's observers. |
|
811 |
|
812 @capability ReadUserData |
|
813 @param aObserver An observer that receives notifications when this view is |
|
814 ready for use and when changes take place in it. The observer receives a TContactViewEvent::EReady |
|
815 event when the view is ready. An attempt to use the view before this notification |
|
816 causes a panic. |
|
817 @param aDb The underlying database containing the contact items. |
|
818 @param aSortOrder Specifies the fields to use to sort the items in the server |
|
819 side view. |
|
820 @param aContactTypes Specifies which types of contact items should be included |
|
821 in the view and the behaviour for items that do not have content in any of |
|
822 the fields specified in the sort order. |
|
823 @param aSortPluginName Specifies a plug-in that will be used to compare view contacts |
|
824 when the the view is sorted. This name is used by ECOM to select the plugin, and is matched |
|
825 with the "default_data" of all ECOM plugins that support the required interface. |
|
826 @return The newly constructed remote view object. |
|
827 */ |
|
828 EXPORT_C CContactRemoteView* CContactRemoteView::NewL(MContactViewObserver& aObserver,const CContactDatabase& aDb, |
|
829 const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes, |
|
830 const TDesC8& aSortPluginName) |
|
831 { |
|
832 #ifdef CONTACTS_API_PROFILING |
|
833 TContactsApiProfile::CntViewMethodLog(TContactsApiProfile::ECntVwClassRemoteView, TContactsApiProfile::ECntViewApiNewL, aSortOrder, aContactTypes, aSortPluginName); |
|
834 #endif |
|
835 CContactRemoteView* self=new(ELeave) CContactRemoteView(aDb); |
|
836 CleanupStack::PushL(self); |
|
837 self->ConstructL(aObserver,aSortOrder,aContactTypes, aSortPluginName); |
|
838 CleanupStack::Pop(); // self; |
|
839 return self; |
|
840 } |
|
841 |
|
842 /** |
|
843 Gets the server side view's sort order, as set in the NewL() function. |
|
844 |
|
845 @capability ReadUserData |
|
846 @param aSortOrder On return, the sort order for the server side view. |
|
847 */ |
|
848 EXPORT_C void CContactRemoteView::GetSortOrderL(RContactViewSortOrder& aSortOrder) |
|
849 { |
|
850 #ifdef CONTACTS_API_PROFILING |
|
851 TContactsApiProfile::CntViewMethodLog(TContactsApiProfile::ECntVwClassRemoteView, TContactsApiProfile::ECntViewApiGetSortOrderL); |
|
852 #endif |
|
853 iView.GetSortOrderL(aSortOrder); |
|
854 } |
|
855 /** |
|
856 This is a reserved virtual exported function that is used for BC proofing |
|
857 against present and future additions of new exported virtual functions. |
|
858 @capability ReadUserData |
|
859 @param aFunction An enum value that identifies which helper function is called. |
|
860 @param aParams Parameters to the helper function being called. |
|
861 @return Any return values of the helper function called from this function or NULL. |
|
862 */ |
|
863 TAny* CContactRemoteView::CContactViewBase_Reserved_1(TFunction aFunction,TAny* aParams) |
|
864 { |
|
865 return CContactRemoteViewBase::CContactViewBase_Reserved_1(aFunction,aParams); |
|
866 } |
|
867 |
|
868 /** Empty destructor. */ |
|
869 CContactRemoteView::~CContactRemoteView() |
|
870 { |
|
871 #ifdef CONTACTS_API_PROFILING |
|
872 TContactsApiProfile::CntViewMethodLog(TContactsApiProfile::ECntVwClassRemoteView, TContactsApiProfile::ECntViewDestructor); |
|
873 #endif |
|
874 } |
|
875 |
|
876 /** |
|
877 Protected C++ constructor. |
|
878 |
|
879 @param aDb The underlying database containing the contact items. |
|
880 */ |
|
881 CContactRemoteView::CContactRemoteView(const CContactDatabase& aDb) : CContactRemoteViewBase(aDb) |
|
882 { |
|
883 } |
|
884 |
|
885 /** |
|
886 @capability ReadUserData |
|
887 */ |
|
888 void CContactRemoteView::ConstructL(MContactViewObserver& aObserver,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes) |
|
889 { |
|
890 TUid sortPluginImplUid = FindDefaultViewSortPluginImplL(); |
|
891 iView.OpenL(iDb,aSortOrder,aContactTypes,sortPluginImplUid,KNullDesC8); |
|
892 CContactRemoteViewBase::ConstructL(aObserver); |
|
893 // load the (default) Sort Plugin on client side too |
|
894 if (sortPluginImplUid != KNullUid) |
|
895 { |
|
896 LoadViewSortPluginL (sortPluginImplUid, aContactTypes); |
|
897 // pass sort order to Sort Plugin |
|
898 CViewContactSortPlugin* sortPluginImpl = SortPluginImpl(); |
|
899 sortPluginImpl->SetSortOrderL(aSortOrder); |
|
900 } |
|
901 } |
|
902 |
|
903 /** |
|
904 @capability ReadUserData |
|
905 */ |
|
906 void CContactRemoteView::ConstructL(MContactViewObserver& aObserver,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes, const TDesC8& aSortPluginName) |
|
907 { |
|
908 TUid sortPluginImplUid = KNullUid; |
|
909 if (aSortPluginName.Length()) |
|
910 { |
|
911 sortPluginImplUid = FindSortPluginImplL(aSortPluginName); |
|
912 } |
|
913 iView.OpenL(iDb,aSortOrder,aContactTypes,sortPluginImplUid,aSortPluginName); |
|
914 CContactRemoteViewBase::ConstructL(aObserver); |
|
915 // load the Sort Plugin on client side too |
|
916 if (sortPluginImplUid != KNullUid) |
|
917 { |
|
918 LoadViewSortPluginL (sortPluginImplUid, aContactTypes); |
|
919 // pass sort order to Sort Plugin |
|
920 CViewContactSortPlugin* sortPluginImpl = SortPluginImpl(); |
|
921 sortPluginImpl->SetSortOrderL(aSortOrder); |
|
922 } |
|
923 } |
|
924 |
|
925 |
|
926 // |
|
927 // CContactNamedRemoteView. |
|
928 // |
|
929 |
|
930 /** Allocates and constructs a named remote contact view object. |
|
931 |
|
932 This function causes a new named local view object to be created in the contacts |
|
933 server, unless one already exists with the specified name. In that case, this |
|
934 client is given shared access to it. |
|
935 |
|
936 The sort order and view preferences parameters are only used if a new view |
|
937 object is created in the server. They cannot be used to change the sort order |
|
938 or view preferences of an existing view in the server. If you want to re-sort |
|
939 a shared view, use ChangeSortOrderL(). |
|
940 |
|
941 @capability ReadUserData |
|
942 @param aObserver An observer that receives notifications when this view is |
|
943 ready for use and when changes take place in it. The observer receives a TContactViewEvent::EReady |
|
944 event when the view is ready. An attempt to use the view before this notification |
|
945 causes a panic. |
|
946 @param aName The name of the view object in the server. If a view with this |
|
947 name already exists, it is shared. If not, a new view with this name is created. |
|
948 @param aDb The underlying database containing the contact items. |
|
949 @param aSortOrder Specifies the fields to use to sort the items in the new |
|
950 server side view, if one is created. |
|
951 @param aContactTypes Specifies which types of contact items should be included |
|
952 in the new server side view and the behaviour for items that do not have content |
|
953 in any of the fields specified in the sort order. This is only used if a new |
|
954 server side view is created. |
|
955 @return The newly constructed named remote view object. */ |
|
956 EXPORT_C CContactNamedRemoteView* CContactNamedRemoteView::NewL(MContactViewObserver& aObserver,const TDesC& aName,const CContactDatabase& aDb,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes) |
|
957 { |
|
958 #ifdef CONTACTS_API_PROFILING |
|
959 TContactsApiProfile::CntViewMethodLog(TContactsApiProfile::ECntVwClassNamedRemoteView, TContactsApiProfile::ECntViewApiNewL, aName, aSortOrder, aContactTypes); |
|
960 #endif |
|
961 CContactNamedRemoteView* self=new(ELeave) CContactNamedRemoteView(aDb); |
|
962 CleanupStack::PushL(self); |
|
963 self->ConstructL(aObserver,aName,aSortOrder,aContactTypes); |
|
964 CleanupStack::Pop(); // self; |
|
965 return self; |
|
966 } |
|
967 |
|
968 /** Allocates and constructs a named remote contact view object. |
|
969 |
|
970 This function causes a new named local view object to be created in the contacts |
|
971 server, unless one already exists with the specified name. In that case, this |
|
972 client is given shared access to it. |
|
973 |
|
974 The sort order and view preferences parameters are only used if a new view |
|
975 object is created in the server. They cannot be used to change the sort order |
|
976 or view preferences of an existing view in the server. If you want to re-sort |
|
977 a shared view, use ChangeSortOrderL(). |
|
978 |
|
979 @capability ReadUserData |
|
980 @param aObserver An observer that receives notifications when this view is |
|
981 ready for use and when changes take place in it. The observer receives a TContactViewEvent::EReady |
|
982 event when the view is ready. An attempt to use the view before this notification |
|
983 causes a panic. |
|
984 @param aName The name of the view object in the server. If a view with this |
|
985 name already exists, it is shared. If not, a new view with this name is created. |
|
986 @param aDb The underlying database containing the contact items. |
|
987 @param aSortOrder Specifies the fields to use to sort the items in the new |
|
988 server side view, if one is created. |
|
989 @param aContactTypes Specifies which types of contact items should be included |
|
990 in the new server side view and the behaviour for items that do not have content |
|
991 in any of the fields specified in the sort order. This is only used if a new |
|
992 server side view is created. |
|
993 @param aSortPluginName Specifies a plug-in that will be used to compare view contacts |
|
994 when the the view is sorted. This name is used by ECOM to select the plugin, and is matched |
|
995 with the "default_data" of all ECOM plugins that support the required interface. |
|
996 @return The newly constructed named remote view object. */ |
|
997 EXPORT_C CContactNamedRemoteView* CContactNamedRemoteView::NewL(MContactViewObserver& aObserver,const TDesC& aName,const CContactDatabase& aDb,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes, |
|
998 const TDesC8& aSortPluginName) |
|
999 { |
|
1000 #ifdef CONTACTS_API_PROFILING |
|
1001 TContactsApiProfile::CntViewMethodLog(TContactsApiProfile::ECntVwClassNamedRemoteView, TContactsApiProfile::ECntViewApiNewL, aName, aSortOrder, aContactTypes, aSortPluginName); |
|
1002 #endif |
|
1003 CContactNamedRemoteView* self=new(ELeave) CContactNamedRemoteView(aDb); |
|
1004 CleanupStack::PushL(self); |
|
1005 self->ConstructL(aObserver,aName,aSortOrder,aContactTypes,aSortPluginName); |
|
1006 CleanupStack::Pop(); // self; |
|
1007 return self; |
|
1008 } |
|
1009 |
|
1010 /** Re-sorts the server side view using the specified sort order. |
|
1011 |
|
1012 The sort is done using a low priority idle time active object. When sorting |
|
1013 is complete, all view observers are notified. |
|
1014 |
|
1015 @capability ReadUserData |
|
1016 @param aSortOrder Specifies the fields to use to sort the items in the view. */ |
|
1017 EXPORT_C void CContactNamedRemoteView::ChangeSortOrderL(const RContactViewSortOrder& aSortOrder) |
|
1018 { |
|
1019 #ifdef CONTACTS_API_PROFILING |
|
1020 TContactsApiProfile::CntViewMethodLog(TContactsApiProfile::ECntVwClassNamedRemoteView, TContactsApiProfile::ECntViewApiChangeSortOrderL, aSortOrder); |
|
1021 #endif |
|
1022 iView.ChangeSortOrderL(aSortOrder); |
|
1023 // pass new sort order to Sort Plugin |
|
1024 CViewContactSortPlugin* sortPluginImpl = SortPluginImpl(); |
|
1025 if (sortPluginImpl) |
|
1026 { |
|
1027 sortPluginImpl->SetSortOrderL(aSortOrder); |
|
1028 } |
|
1029 } |
|
1030 |
|
1031 /** |
|
1032 This is a reserved virtual exported function that is used for BC proofing |
|
1033 against present and future additions of new exported virtual functions. |
|
1034 @capability ReadUserData |
|
1035 @param aFunction An enum value that identifies which helper function is called. |
|
1036 @param aParams Parameters to the helper function being called. |
|
1037 @return Any return values of the helper function called from this function or NULL. |
|
1038 */ |
|
1039 TAny* CContactNamedRemoteView::CContactViewBase_Reserved_1(TFunction aFunction,TAny* aParams) |
|
1040 { |
|
1041 return CContactRemoteView::CContactViewBase_Reserved_1(aFunction,aParams); |
|
1042 } |
|
1043 |
|
1044 CContactNamedRemoteView::~CContactNamedRemoteView() |
|
1045 { |
|
1046 #ifdef CONTACTS_API_PROFILING |
|
1047 TContactsApiProfile::CntViewMethodLog(TContactsApiProfile::ECntVwClassNamedRemoteView, TContactsApiProfile::ECntViewDestructor); |
|
1048 #endif |
|
1049 } |
|
1050 |
|
1051 CContactNamedRemoteView::CContactNamedRemoteView(const CContactDatabase& aDb) : CContactRemoteView(aDb) |
|
1052 { |
|
1053 } |
|
1054 |
|
1055 /** |
|
1056 @capability ReadUserData |
|
1057 */ |
|
1058 void CContactNamedRemoteView::ConstructL(MContactViewObserver& aObserver,const TDesC& aName,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes) |
|
1059 { |
|
1060 TUid sortPluginImplUid = FindDefaultViewSortPluginImplL(); |
|
1061 iView.OpenL(iDb,aName,aSortOrder,aContactTypes,sortPluginImplUid,KNullDesC8); |
|
1062 CContactRemoteViewBase::ConstructL(aObserver); |
|
1063 // load the (default) Sort Plugin on client side too |
|
1064 if (sortPluginImplUid != KNullUid) |
|
1065 { |
|
1066 LoadViewSortPluginL (sortPluginImplUid, aContactTypes); |
|
1067 // pass sort order to Sort Plugin |
|
1068 CViewContactSortPlugin* sortPluginImpl = SortPluginImpl(); |
|
1069 sortPluginImpl->SetSortOrderL(aSortOrder); |
|
1070 } |
|
1071 } |
|
1072 |
|
1073 /** |
|
1074 @capability ReadUserData |
|
1075 */ |
|
1076 void CContactNamedRemoteView::ConstructL(MContactViewObserver& aObserver,const TDesC& aName,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes, const TDesC8& aSortPluginName) |
|
1077 { |
|
1078 TUid sortPluginImplUid = KNullUid; |
|
1079 if (aSortPluginName.Length()) |
|
1080 { |
|
1081 sortPluginImplUid = FindSortPluginImplL(aSortPluginName); |
|
1082 if (sortPluginImplUid == KNullUid) |
|
1083 { |
|
1084 User::Leave(KErrNotFound); |
|
1085 } |
|
1086 } |
|
1087 iView.OpenL(iDb,aName,aSortOrder,aContactTypes,sortPluginImplUid,aSortPluginName); |
|
1088 CContactRemoteViewBase::ConstructL(aObserver); |
|
1089 // load the same Sort Plugin on client side as on the Server side |
|
1090 sortPluginImplUid = iView.GetViewSortPluginImplUidL(); |
|
1091 if (sortPluginImplUid != KNullUid) |
|
1092 { |
|
1093 LoadViewSortPluginL (sortPluginImplUid, aContactTypes); |
|
1094 // pass sort order to Sort Plugin |
|
1095 CViewContactSortPlugin* sortPluginImpl = SortPluginImpl(); |
|
1096 sortPluginImpl->SetSortOrderL(aSortOrder); |
|
1097 } |
|
1098 } |