20
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Active object to read all the contacts from a
|
|
15 |
* particular data store. Handles add/ modify/ delete of contacts.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
// SYSTEM INCLUDES
|
|
20 |
#include <barsread.h>
|
|
21 |
#include <coemain.h>
|
|
22 |
#include <utf.h>
|
|
23 |
#include <e32std.h>
|
|
24 |
#include <badesca.h>
|
|
25 |
#include <CVPbkContactManager.h>
|
|
26 |
#include <CVPbkContactStoreUriArray.h>
|
|
27 |
#include <CVPbkContactFieldIterator.h>
|
|
28 |
#include <CVPbkFieldTypeRefsList.h>
|
|
29 |
#include <CVPbkContactLinkArray.h>
|
|
30 |
#include <TVPbkContactStoreUriPtr.h>
|
|
31 |
#include <MVPbkContactOperationBase.h>
|
|
32 |
#include <MVPbkContactStoreList.h>
|
|
33 |
#include <MVPbkContactStore.h>
|
|
34 |
#include <MVPbkStoreContact.h>
|
|
35 |
#include <MVPbkContactFieldData.h>
|
|
36 |
#include <MVPbkContactFieldTextData.h>
|
|
37 |
#include <MVPbkContactStoreProperties.h>
|
|
38 |
#include <MVPbkContactLink.h>
|
|
39 |
#include <VPbkEng.rsg>
|
|
40 |
#include <VPbkContactStoreUris.h>
|
|
41 |
#include <CVPbkContactViewDefinition.h>
|
|
42 |
#include <MVPbkContactViewBase.h>
|
|
43 |
#include <VPbkContactView.hrh>
|
|
44 |
#include <CVPbkContactIdConverter.h>
|
|
45 |
#include <centralrepository.h>
|
|
46 |
#include <MVPbkContactGroup.h>
|
|
47 |
#include <CVPbkFieldTypeSelector.h>
|
|
48 |
#include <CVPbkContactLinkArray.h>
|
|
49 |
#include <CVPbkSortOrder.h>
|
|
50 |
#include <data_caging_path_literals.hrh>
|
|
51 |
#include <bautils.h>
|
|
52 |
#include <featmgr.h>
|
|
53 |
#include <CPbk2SortOrderManager.h>
|
|
54 |
|
|
55 |
// USER INCLUDES
|
|
56 |
#include "cpcscontactstore.h"
|
|
57 |
#include "CPsData.h"
|
|
58 |
#include "CPcsDebug.h"
|
|
59 |
#include "CPcsDefs.h"
|
|
60 |
#include <contactsort.rsg>
|
|
61 |
|
|
62 |
// CONSTANTS
|
|
63 |
namespace {
|
|
64 |
const TInt KSimStoreOffset = -5000;
|
|
65 |
const TInt KTimerInterval = 100000; // 100 milliseconds
|
|
66 |
|
|
67 |
_LIT(KResourceFileName, "contactsort.rsc");
|
|
68 |
_LIT(KPcsViewPrefix,"PCSView_");
|
|
69 |
}
|
|
70 |
// FORWARD DECLARATION
|
|
71 |
|
|
72 |
// ============================== MEMBER FUNCTIONS ================================
|
|
73 |
|
|
74 |
// ---------------------------------------------------------------------------------
|
|
75 |
// 2 phase construction
|
|
76 |
// ---------------------------------------------------------------------------------
|
|
77 |
CPcsContactStore* CPcsContactStore::NewL(CVPbkContactManager& aContactManager,
|
|
78 |
MDataStoreObserver& aObserver,
|
|
79 |
const TDesC& aUri)
|
|
80 |
{
|
|
81 |
PRINT ( _L("Enter CPcsContactStore::NewL") );
|
|
82 |
|
|
83 |
CPcsContactStore* self = new ( ELeave ) CPcsContactStore( );
|
|
84 |
CleanupStack::PushL( self );
|
|
85 |
|
|
86 |
self->ConstructL(aContactManager,aObserver,aUri);
|
|
87 |
CleanupStack::Pop( self );
|
|
88 |
|
|
89 |
PRINT ( _L("End CPcsContactStore::NewL") );
|
|
90 |
return self;
|
|
91 |
}
|
|
92 |
|
|
93 |
// ---------------------------------------------------------------------------------
|
|
94 |
// Constructor
|
|
95 |
// ---------------------------------------------------------------------------------
|
|
96 |
CPcsContactStore::CPcsContactStore():
|
|
97 |
CActive( CActive::EPriorityLow ),
|
|
98 |
iInitialContactCount( 0 ),
|
|
99 |
iFetchBlockLowerNumber( 0 ),
|
|
100 |
iFetchBlockUpperNumber( 0 ),
|
|
101 |
iVPbkCallbackCount( 0 ),
|
|
102 |
iContactViewReady( EFalse )
|
|
103 |
{
|
|
104 |
PRINT ( _L("Enter CPcsContactStore::CPcsContactStore") );
|
|
105 |
CActiveScheduler::Add( this );
|
|
106 |
PRINT ( _L("End CPcsContactStore::CPcsContactStore") );
|
|
107 |
}
|
|
108 |
|
|
109 |
// ---------------------------------------------------------------------------------
|
|
110 |
// CPcsContactStore::ConstructL()
|
|
111 |
// 2nd phase constructor
|
|
112 |
// ---------------------------------------------------------------------------------
|
|
113 |
void CPcsContactStore::ConstructL(CVPbkContactManager& aContactManager,
|
|
114 |
MDataStoreObserver& aObserver,
|
|
115 |
const TDesC& aUri)
|
|
116 |
{
|
|
117 |
PRINT ( _L("Enter CPcsContactStore::ConstructL") );
|
|
118 |
|
|
119 |
iContactManager = &aContactManager;
|
|
120 |
iObserver = &aObserver;
|
|
121 |
|
|
122 |
iUri = aUri.AllocL();
|
|
123 |
|
|
124 |
// create containers for holding the sim data
|
|
125 |
iSimContactItems = CVPbkContactLinkArray::NewL();
|
|
126 |
|
|
127 |
|
|
128 |
// for creating sort order
|
|
129 |
iSortOrder = CVPbkFieldTypeRefsList::NewL();
|
|
130 |
|
|
131 |
// Read the fields to cache from the central repository
|
|
132 |
ReadFieldsToCacheFromCenrepL();
|
|
133 |
|
|
134 |
// Local timer for block fetch delay
|
|
135 |
iTimer.CreateLocal();
|
|
136 |
|
|
137 |
// Initial state
|
|
138 |
iNextState = ECreateView;
|
|
139 |
IssueRequest( 0 );
|
|
140 |
|
|
141 |
FeatureManager::InitializeLibL();
|
|
142 |
if( FeatureManager::FeatureSupported( KFeatureIdffContactsMycard ) )
|
|
143 |
{
|
|
144 |
iMyCardSupported = ETrue;
|
|
145 |
}
|
|
146 |
FeatureManager::UnInitializeLib();
|
|
147 |
|
|
148 |
PRINT ( _L("End CPcsContactStore::ConstructL") );
|
|
149 |
}
|
|
150 |
|
|
151 |
// ---------------------------------------------------------------------------------
|
|
152 |
// Destructor
|
|
153 |
// ---------------------------------------------------------------------------------
|
|
154 |
CPcsContactStore::~CPcsContactStore()
|
|
155 |
{
|
|
156 |
PRINT ( _L("Enter CPcsContactStore::~CPcsContactStore") );
|
|
157 |
|
|
158 |
delete iContactViewBase;
|
|
159 |
delete iSortOrder;
|
|
160 |
delete iSimContactItems;
|
|
161 |
delete iWait;
|
|
162 |
delete iUri;
|
|
163 |
|
|
164 |
iTimer.Cancel();
|
|
165 |
iTimer.Close();
|
|
166 |
iFieldsToCache.Close();
|
|
167 |
|
|
168 |
iFs.Close();
|
|
169 |
|
|
170 |
iInitialContactLinks.ResetAndDestroy();
|
|
171 |
|
|
172 |
if(IsActive())
|
|
173 |
{
|
|
174 |
Deque();
|
|
175 |
}
|
|
176 |
|
|
177 |
delete iSortOrderMan;
|
|
178 |
|
|
179 |
PRINT ( _L("End CPcsContactStore::~CPcsContactStore") );
|
|
180 |
}
|
|
181 |
|
|
182 |
// ---------------------------------------------------------------------------------
|
|
183 |
// Handles addition/deletion/modification of contacts
|
|
184 |
// ---------------------------------------------------------------------------------
|
|
185 |
void CPcsContactStore::HandleStoreEventL(MVPbkContactStore& aContactStore,
|
|
186 |
TVPbkContactStoreEvent aStoreEvent)
|
|
187 |
{
|
|
188 |
PRINT ( _L("Enter CPcsContactStore::HandleStoreEventL") );
|
|
189 |
|
|
190 |
PRINT2 ( _L("CPcsContactStore::HandleStoreEventL: URI=%S, event TVPbkContactStoreEventType::%d received"),
|
|
191 |
&*iUri, aStoreEvent.iEventType);
|
|
192 |
|
|
193 |
switch (aStoreEvent.iEventType)
|
|
194 |
{
|
|
195 |
case TVPbkContactStoreEvent::EContactAdded:
|
|
196 |
case TVPbkContactStoreEvent::EGroupAdded:
|
|
197 |
{
|
|
198 |
// Observer will be notified once the cache update is complete
|
|
199 |
iOngoingCacheUpdate = ECacheUpdateContactAdded;
|
|
200 |
|
|
201 |
iContactManager->RetrieveContactL( *(aStoreEvent.iContactLink), *this );
|
|
202 |
break;
|
|
203 |
}
|
|
204 |
|
|
205 |
case TVPbkContactStoreEvent::EUnknownChanges:
|
|
206 |
{
|
|
207 |
iObserver->RemoveAll( *iUri );
|
|
208 |
// To indicate that contact view is not ready when unknown changes happens
|
|
209 |
iContactViewReady = EFalse;
|
|
210 |
iContactViewBase->AddObserverL(*this);
|
|
211 |
break;
|
|
212 |
}
|
|
213 |
|
|
214 |
case TVPbkContactStoreEvent::EContactDeleted:
|
|
215 |
case TVPbkContactStoreEvent::EGroupDeleted:
|
|
216 |
case TVPbkContactStoreEvent::EContactChanged:
|
|
217 |
case TVPbkContactStoreEvent::EGroupChanged:
|
|
218 |
{
|
|
219 |
CVPbkContactIdConverter* converter = NULL;
|
|
220 |
|
|
221 |
TRAPD ( err, converter = CVPbkContactIdConverter::NewL( aContactStore ) );
|
|
222 |
|
|
223 |
TInt32 contactId(-1);
|
|
224 |
|
|
225 |
if ( err == KErrNotSupported )
|
|
226 |
{
|
|
227 |
// sim domain
|
|
228 |
// Pass the sim observer string in the next line
|
|
229 |
TInt contactLocation = iSimContactItems->Find(*aStoreEvent.iContactLink);
|
|
230 |
if( KErrNotFound != contactLocation)
|
|
231 |
{
|
|
232 |
// We are not removing from the array cache. If you try to fetch,
|
|
233 |
// then it will give an error
|
|
234 |
TInt index = CreateCacheIDfromSimArrayIndex( contactLocation );
|
|
235 |
|
|
236 |
iObserver->RemoveData(*iUri,index );
|
|
237 |
}
|
|
238 |
|
|
239 |
}
|
|
240 |
else
|
|
241 |
{
|
|
242 |
// cntdb domain
|
|
243 |
// Get contact id by mapping the link
|
|
244 |
contactId = converter->LinkToIdentifier(*(aStoreEvent.iContactLink));
|
|
245 |
|
|
246 |
// Remove the contact
|
|
247 |
iObserver->RemoveData(*iUri, contactId);
|
|
248 |
}
|
|
249 |
|
|
250 |
delete converter;
|
|
251 |
converter = NULL;
|
|
252 |
|
|
253 |
if (( aStoreEvent.iEventType == TVPbkContactStoreEvent::EContactChanged ) ||
|
|
254 |
( aStoreEvent.iEventType == TVPbkContactStoreEvent::EGroupChanged ) )
|
|
255 |
{
|
|
256 |
// Observer will be notified once the cache update is complete
|
|
257 |
iOngoingCacheUpdate = ECacheUpdateContactModified;
|
|
258 |
|
|
259 |
// Add the contact
|
|
260 |
iContactManager->RetrieveContactL( *(aStoreEvent.iContactLink), *this );
|
|
261 |
}
|
|
262 |
else
|
|
263 |
{
|
|
264 |
// Inform observer immediately about contact removal
|
|
265 |
iObserver->UpdateCachingStatus( *iUri, ECacheUpdateContactRemoved );
|
|
266 |
}
|
|
267 |
|
|
268 |
break;
|
|
269 |
}
|
|
270 |
}
|
|
271 |
|
|
272 |
PRINT ( _L("End CPcsContactStore::HandleStoreEventL") );
|
|
273 |
}
|
|
274 |
|
|
275 |
// ---------------------------------------------------------------------------
|
|
276 |
// Returns ths database URI
|
|
277 |
// ---------------------------------------------------------------------------
|
|
278 |
TDesC& CPcsContactStore::GetStoreUri()
|
|
279 |
{
|
|
280 |
return *iUri;
|
|
281 |
}
|
|
282 |
|
|
283 |
// ---------------------------------------------------------------------------
|
|
284 |
// Check next state of state machine for contacts retrieval and perform
|
|
285 |
// transition
|
|
286 |
// ---------------------------------------------------------------------------
|
|
287 |
void CPcsContactStore::CheckNextState()
|
|
288 |
{
|
|
289 |
PRINT5 ( _L("CPcsContactStore::CheckNextState(state %d) %d:(%d..%d)/%d"),
|
|
290 |
iNextState, iVPbkCallbackCount,
|
|
291 |
iFetchBlockLowerNumber, iFetchBlockUpperNumber, iInitialContactCount );
|
|
292 |
|
|
293 |
if ( iNextState == EComplete )
|
|
294 |
{
|
|
295 |
return;
|
|
296 |
}
|
|
297 |
|
|
298 |
// If during the caching of the contacts initially in the view we get some
|
|
299 |
// contact events for other contact operations from the user, then it can
|
|
300 |
// happen at the end of the caching process that iCallbackCount > iAllContactLinksCount.
|
|
301 |
// We assume that it can never be that at the end of the caching it results
|
|
302 |
// iCallbackCount < iAllContactLinksCount.
|
|
303 |
|
|
304 |
// Check if caching is complete
|
|
305 |
if( iFetchBlockUpperNumber == iInitialContactCount // All contacts initially in the view were fetched
|
|
306 |
&& iVPbkCallbackCount >= iInitialContactCount ) // We got at least the same amount of callbacks
|
|
307 |
{
|
|
308 |
iObserver->UpdateCachingStatus(*iUri, ECachingComplete);
|
|
309 |
iNextState = EComplete;
|
|
310 |
IssueRequest( 0 );
|
|
311 |
}
|
|
312 |
// We could have a number of callbacks that is the same of the fetched contacts
|
|
313 |
// from the view even before we get the all the callbacks for the fetched contacts.
|
|
314 |
// This can happen for instance if a contact is added by the user.
|
|
315 |
// With the following condition it will happen just that the fetching of more
|
|
316 |
// contacts from the initial view is happening before all the callbacks for
|
|
317 |
// those are received.
|
|
318 |
else if ( iVPbkCallbackCount >= iFetchBlockUpperNumber ) // Fetch next block
|
|
319 |
{
|
|
320 |
iObserver->UpdateCachingStatus(*iUri, ECachingInProgress);
|
|
321 |
iNextState = EFetchContactBlock;
|
|
322 |
// Delay the next fetch since contact fetch is CPU intensive,
|
|
323 |
// this will give other threads a chance to use CPU
|
|
324 |
IssueRequest( KTimerInterval ); // 100 milliseconds
|
|
325 |
}
|
|
326 |
else
|
|
327 |
{
|
|
328 |
// Otherwise, just pass through.
|
|
329 |
}
|
|
330 |
|
|
331 |
}
|
|
332 |
|
|
333 |
// ---------------------------------------------------------------------------
|
|
334 |
// Callback Method. Called when one Retrieve operation is complete
|
|
335 |
// ---------------------------------------------------------------------------
|
|
336 |
void CPcsContactStore::VPbkSingleContactOperationComplete(
|
|
337 |
MVPbkContactOperationBase& aOperation, MVPbkStoreContact* aContact)
|
|
338 |
{
|
|
339 |
PRINT ( _L("Enter CPcsContactStore::VPbkSingleContactOperationComplete") );
|
|
340 |
|
|
341 |
// We get this incremented even during add/del of contacts during caching
|
|
342 |
iVPbkCallbackCount++;
|
|
343 |
|
|
344 |
// Handle the fetched contact....
|
|
345 |
TRAPD(err, HandleRetrievedContactL(aContact) );
|
|
346 |
if( err != KErrNone)
|
|
347 |
{
|
|
348 |
iObserver->UpdateCachingStatus(*iUri, err);
|
|
349 |
}
|
|
350 |
|
|
351 |
MVPbkContactOperationBase* Opr = &aOperation;
|
|
352 |
if ( Opr )
|
|
353 |
{
|
|
354 |
delete Opr;
|
|
355 |
Opr = NULL;
|
|
356 |
}
|
|
357 |
|
|
358 |
CheckNextState();
|
|
359 |
|
|
360 |
PRINT ( _L("End CPcsContactStore::VPbkSingleContactOperationComplete") );
|
|
361 |
}
|
|
362 |
|
|
363 |
// ---------------------------------------------------------------------------
|
|
364 |
// Callback Method. Called when one Retrieve operation fails.
|
|
365 |
// ---------------------------------------------------------------------------
|
|
366 |
void CPcsContactStore::VPbkSingleContactOperationFailed(
|
|
367 |
MVPbkContactOperationBase& /*aOperation*/, TInt /*aError*/ )
|
|
368 |
{
|
|
369 |
PRINT ( _L("Enter CPcsContactStore::VPbkSingleContactOperationFailed") );
|
|
370 |
|
|
371 |
iVPbkCallbackCount++;
|
|
372 |
|
|
373 |
CheckNextState();
|
|
374 |
|
|
375 |
PRINT ( _L("End CPcsContactStore::VPbkSingleContactOperationFailed") );
|
|
376 |
}
|
|
377 |
|
|
378 |
// ---------------------------------------------------------------------------
|
|
379 |
// Handles the operations for a single contact after it is fetched
|
|
380 |
// ---------------------------------------------------------------------------
|
|
381 |
void CPcsContactStore::HandleRetrievedContactL(MVPbkStoreContact* aContact)
|
|
382 |
{
|
|
383 |
// Take the ownership
|
|
384 |
aContact->PushL();
|
|
385 |
|
|
386 |
if ( iMyCardSupported && IsMyCard( *aContact ) )
|
|
387 |
{
|
|
388 |
CleanupStack::PopAndDestroy( aContact );
|
|
389 |
return;
|
|
390 |
}
|
|
391 |
|
|
392 |
// Fill the contact link
|
|
393 |
MVPbkContactLink* tmpLink = aContact->CreateLinkLC();
|
|
394 |
|
|
395 |
// If the link is null, then it is not put on the cleanup stack,
|
|
396 |
// so we need not pop in such a case
|
|
397 |
if ( NULL == tmpLink )
|
|
398 |
{
|
|
399 |
CleanupStack::PopAndDestroy( aContact );
|
|
400 |
return;
|
|
401 |
}
|
|
402 |
|
|
403 |
CPsData* phoneContact = CPsData::NewL();
|
|
404 |
|
|
405 |
// Fill the contact id
|
|
406 |
CVPbkContactIdConverter* converter = NULL;
|
|
407 |
TRAPD ( err, converter = CVPbkContactIdConverter::NewL( aContact->ParentStore() ) );
|
|
408 |
|
|
409 |
if ( err == KErrNotSupported )
|
|
410 |
{
|
|
411 |
// simdb domain
|
|
412 |
PRINT ( _L("CPcsContactStore::HandleRetrievedContactL: SIM domain data received") );
|
|
413 |
|
|
414 |
// Set the contact link
|
|
415 |
HBufC8* extnInfo = tmpLink->PackLC();
|
|
416 |
phoneContact->SetDataExtension(extnInfo);
|
|
417 |
CleanupStack::Pop( extnInfo );
|
|
418 |
|
|
419 |
// Get the index of the SIM contact
|
|
420 |
TInt tempIndex = iSimContactItems->Find(*tmpLink);
|
|
421 |
|
|
422 |
if ( KErrNotFound == tempIndex)
|
|
423 |
{
|
|
424 |
tempIndex = iSimContactItems->Count();
|
|
425 |
iSimContactItems->AppendL(tmpLink);
|
|
426 |
CleanupStack::Pop(); // tmpLink
|
|
427 |
}
|
|
428 |
else
|
|
429 |
{
|
|
430 |
CleanupStack::PopAndDestroy(); // tmpLink
|
|
431 |
}
|
|
432 |
|
|
433 |
//Create a dummy sim index and set it
|
|
434 |
TInt simIndex = CreateCacheIDfromSimArrayIndex(tempIndex);
|
|
435 |
phoneContact->SetId(simIndex);
|
|
436 |
}
|
|
437 |
else
|
|
438 |
{
|
|
439 |
// cntdb domain
|
|
440 |
TInt32 contactId = converter->LinkToIdentifier(*tmpLink);
|
|
441 |
phoneContact->SetId(contactId);
|
|
442 |
CleanupStack::PopAndDestroy(); // tmpLink
|
|
443 |
}
|
|
444 |
|
|
445 |
MVPbkContactGroup* myContactGroup= aContact->Group();
|
|
446 |
|
|
447 |
// The retrieved contact can be a contact item or a contact group, Handle accordingly
|
|
448 |
if ( NULL == myContactGroup )
|
|
449 |
{
|
|
450 |
// The fetched contact item (and not a contact group.)
|
|
451 |
GetDataForSingleContactL( *aContact, phoneContact );
|
|
452 |
// Recover the URI
|
|
453 |
HBufC* storeUri = aContact->ParentStore().StoreProperties().Uri().UriDes().AllocL();
|
|
454 |
//Add the data to the relevent cache through the observer
|
|
455 |
iObserver->AddData(*storeUri, phoneContact);
|
|
456 |
delete storeUri;
|
|
457 |
}
|
|
458 |
else
|
|
459 |
{
|
|
460 |
// Fetch the group name
|
|
461 |
HBufC* groupName = myContactGroup->GroupLabel().AllocLC();
|
|
462 |
TInt grpArrayIndex = -1;
|
|
463 |
for (TInt i =0; i <iFieldsToCache.Count(); i++)
|
|
464 |
{
|
|
465 |
if (iFieldsToCache[i] == R_VPBK_FIELD_TYPE_LASTNAME)
|
|
466 |
{
|
|
467 |
grpArrayIndex = i;
|
|
468 |
}
|
|
469 |
phoneContact->SetDataL(i, KNullDesC);
|
|
470 |
}
|
|
471 |
if (grpArrayIndex != -1)
|
|
472 |
{
|
|
473 |
phoneContact->SetDataL(grpArrayIndex, *groupName);
|
|
474 |
|
|
475 |
// Check for the contact in the group.
|
|
476 |
MVPbkContactLinkArray* contactsContainedInGroup = myContactGroup->ItemsContainedLC();
|
|
477 |
for (TInt i = 0; i < contactsContainedInGroup->Count(); i++)
|
|
478 |
{
|
|
479 |
TInt grpContactId = converter->LinkToIdentifier(contactsContainedInGroup->At(i));
|
|
480 |
phoneContact->AddIntDataExtL(grpContactId);
|
|
481 |
}
|
|
482 |
CleanupStack::PopAndDestroy(); // contactsContainedInGroup
|
|
483 |
|
|
484 |
// Recover the URI
|
|
485 |
HBufC* storeUri = KVPbkDefaultGrpDbURI().AllocL();
|
|
486 |
|
|
487 |
//Add the data to the relevent cache through the observer
|
|
488 |
iObserver->AddData(*storeUri, phoneContact);
|
|
489 |
|
|
490 |
delete storeUri;
|
|
491 |
}
|
|
492 |
else
|
|
493 |
{
|
|
494 |
//We do not add anything here since Lastname does not exists in cenrep
|
|
495 |
delete phoneContact;
|
|
496 |
phoneContact = NULL;
|
|
497 |
}
|
|
498 |
CleanupStack::PopAndDestroy( groupName );
|
|
499 |
}
|
|
500 |
|
|
501 |
delete converter;
|
|
502 |
converter = NULL;
|
|
503 |
|
|
504 |
CleanupStack::PopAndDestroy(aContact);
|
|
505 |
|
|
506 |
// Inform observer if this contact addition was a result of contact store event.
|
|
507 |
if ( iOngoingCacheUpdate == ECacheUpdateContactModified ||
|
|
508 |
iOngoingCacheUpdate == ECacheUpdateContactAdded )
|
|
509 |
{
|
|
510 |
iObserver->UpdateCachingStatus( *iUri, iOngoingCacheUpdate );
|
|
511 |
iOngoingCacheUpdate = ECachingComplete;
|
|
512 |
}
|
|
513 |
}
|
|
514 |
|
|
515 |
// ---------------------------------------------------------------------------
|
|
516 |
// Fetches the data from a particular contact
|
|
517 |
// ---------------------------------------------------------------------------
|
|
518 |
void CPcsContactStore::GetDataForSingleContactL( MVPbkBaseContact& aContact,
|
|
519 |
CPsData* aPhoneData )
|
|
520 |
{
|
|
521 |
for(TInt i =0; i < iFieldsToCache.Count(); i++)
|
|
522 |
{
|
|
523 |
aPhoneData->SetDataL(i, KNullDesC);
|
|
524 |
AddContactFieldsL( aContact, iFieldsToCache[i], aPhoneData);
|
|
525 |
}
|
|
526 |
}
|
|
527 |
|
|
528 |
// ---------------------------------------------------------------------------
|
|
529 |
// Add the data from contact fields
|
|
530 |
// ---------------------------------------------------------------------------
|
|
531 |
void CPcsContactStore::AddContactFieldsL( MVPbkBaseContact& aContact,
|
|
532 |
TInt aFieldType,
|
|
533 |
CPsData *aPhoneData)
|
|
534 |
{
|
|
535 |
const MVPbkFieldType* myContactDataField =
|
|
536 |
iContactManager->FieldTypes().Find( aFieldType );
|
|
537 |
|
|
538 |
CVPbkBaseContactFieldTypeIterator* itr =
|
|
539 |
CVPbkBaseContactFieldTypeIterator::NewLC( *myContactDataField,
|
|
540 |
aContact.Fields() );
|
|
541 |
|
|
542 |
// Iterate through each of the data fields
|
|
543 |
while ( itr->HasNext() )
|
|
544 |
{
|
|
545 |
const MVPbkBaseContactField* field = itr->Next();
|
|
546 |
|
|
547 |
if ( ( field->FieldData()).DataType() == EVPbkFieldStorageTypeText )
|
|
548 |
{
|
|
549 |
const MVPbkContactFieldTextData& data =
|
|
550 |
MVPbkContactFieldTextData::Cast( field->FieldData() );
|
|
551 |
|
|
552 |
//If the field exist in iFieldsToCache, then set it
|
|
553 |
for ( TInt i = 0 ; i< iFieldsToCache.Count(); i++ )
|
|
554 |
{
|
|
555 |
if (aFieldType == iFieldsToCache[i])
|
|
556 |
{
|
|
557 |
// Check if the field has any data entry. If so
|
|
558 |
// concatenate the next data to the existing one.
|
|
559 |
// A unit seperator is used to show that these are
|
|
560 |
// two entries.
|
|
561 |
HBufC* previousData = aPhoneData->Data(i);
|
|
562 |
if( (previousData != NULL) && (previousData->Des().Length()> 1) )
|
|
563 |
{
|
|
564 |
HBufC* newData = HBufC::NewLC(data.Text().Length() + previousData->Des().Length() + 5);
|
|
565 |
TPtr newDataPtr(newData->Des());
|
|
566 |
newDataPtr.Append(previousData->Des());
|
|
567 |
newDataPtr.Append(KSpaceCharacter);
|
|
568 |
newDataPtr.Append(KUnitSeparator);
|
|
569 |
newDataPtr.Append(KSpaceCharacter);
|
|
570 |
newDataPtr.Append(data.Text());
|
|
571 |
aPhoneData->SetDataL(i,*newData);
|
|
572 |
CleanupStack::PopAndDestroy(newData);
|
|
573 |
}
|
|
574 |
else
|
|
575 |
{
|
|
576 |
aPhoneData->SetDataL(i,data.Text());
|
|
577 |
}
|
|
578 |
}
|
|
579 |
}
|
|
580 |
}
|
|
581 |
}
|
|
582 |
|
|
583 |
CleanupStack::PopAndDestroy( itr );
|
|
584 |
}
|
|
585 |
|
|
586 |
// ---------------------------------------------------------------------------
|
|
587 |
// Fetches all the initial contact links from vpbk
|
|
588 |
// ---------------------------------------------------------------------------
|
|
589 |
void CPcsContactStore::FetchAllInitialContactLinksL()
|
|
590 |
{
|
|
591 |
PRINT2 ( _L("CPcsContactStore::FetchAllInitialContactLinksL: URI=%S. Fetching %d contact links"),
|
|
592 |
&*iUri, iInitialContactCount );
|
|
593 |
|
|
594 |
__LATENCY_MARK ( _L("CPcsContactStore::FetchAllInitialContactLinksL ==== fetch contact links start") );
|
|
595 |
|
|
596 |
for(TInt cnt = 0; cnt < iInitialContactCount; cnt++)
|
|
597 |
{
|
|
598 |
// Get the contact link
|
|
599 |
MVPbkContactLink* tempLink = iContactViewBase->CreateLinkLC(cnt);
|
|
600 |
iInitialContactLinks.AppendL( tempLink );
|
|
601 |
CleanupStack::Pop();
|
|
602 |
}
|
|
603 |
|
|
604 |
__LATENCY_MARKEND ( _L("CPcsContactStore::FetchAllInitialContactLinksL ==== fetch contact links end") );
|
|
605 |
|
|
606 |
// No callback to wait for next state
|
|
607 |
iObserver->UpdateCachingStatus(*iUri, ECachingInProgress);
|
|
608 |
iNextState = EFetchContactBlock;
|
|
609 |
IssueRequest( 0 );
|
|
610 |
}
|
|
611 |
|
|
612 |
// ---------------------------------------------------------------------------
|
|
613 |
// Fetches the data from the vpbk using the contact links
|
|
614 |
// ---------------------------------------------------------------------------
|
|
615 |
void CPcsContactStore::FetchContactsBlockL()
|
|
616 |
{
|
|
617 |
iFetchBlockLowerNumber = iFetchBlockUpperNumber;
|
|
618 |
iFetchBlockUpperNumber += KLinksToFetchInOneGo;
|
|
619 |
if ( iFetchBlockUpperNumber > iInitialContactCount )
|
|
620 |
{
|
|
621 |
iFetchBlockUpperNumber = iInitialContactCount;
|
|
622 |
}
|
|
623 |
|
|
624 |
PRINT2 ( _L("CPcsContactStore::FetchContactsBlockL: Fetched %d contacts, fetching more until %d"),
|
|
625 |
iFetchBlockLowerNumber, iFetchBlockUpperNumber );
|
|
626 |
|
|
627 |
for(TInt cnt = iFetchBlockLowerNumber; cnt < iFetchBlockUpperNumber; cnt++)
|
|
628 |
{
|
|
629 |
// Retrieve the contact
|
|
630 |
iContactManager->RetrieveContactL( *iInitialContactLinks[cnt], *this );
|
|
631 |
}
|
|
632 |
|
|
633 |
// Destroy the array of temporary contact links when all
|
|
634 |
// contacts from the initial view are retrieved
|
|
635 |
if (iFetchBlockUpperNumber == iInitialContactCount)
|
|
636 |
{
|
|
637 |
iInitialContactLinks.ResetAndDestroy();
|
|
638 |
}
|
|
639 |
}
|
|
640 |
|
|
641 |
// ---------------------------------------------------------------------------
|
|
642 |
// Implements the view ready function of MVPbkContactViewObserver
|
|
643 |
// ---------------------------------------------------------------------------
|
|
644 |
void CPcsContactStore::ContactViewReady(
|
|
645 |
MVPbkContactViewBase& aView )
|
|
646 |
{
|
|
647 |
PRINT ( _L("Enter CPcsContactStore::ContactViewReady") );
|
|
648 |
|
|
649 |
iFs.Close();
|
|
650 |
aView.RemoveObserver(*this);
|
|
651 |
// Get the total number of contacts for this view
|
|
652 |
TRAPD(err, iInitialContactCount = aView.ContactCountL());
|
|
653 |
|
|
654 |
if(err != KErrNone)
|
|
655 |
{
|
|
656 |
PRINT( _L("CPcsContactStore::ContactViewReady: Unable to obtain Contacts count"));
|
|
657 |
iObserver->UpdateCachingStatus(*iUri, ECachingCompleteWithErrors);
|
|
658 |
iNextState = EComplete;
|
|
659 |
IssueRequest( 0 );
|
|
660 |
return;
|
|
661 |
}
|
|
662 |
|
|
663 |
PRINT1 ( _L("CPcsContactStore::ContactViewReady: Total number of contacts for this view: %d"),
|
|
664 |
iInitialContactCount );
|
|
665 |
if(iInitialContactCount == 0)
|
|
666 |
{
|
|
667 |
// No Contacts to cache, hence update the status accordingly
|
|
668 |
iObserver->UpdateCachingStatus(*iUri, ECachingComplete);
|
|
669 |
iNextState = EComplete;
|
|
670 |
IssueRequest( 0 );
|
|
671 |
return;
|
|
672 |
}
|
|
673 |
iFetchBlockLowerNumber = 0;
|
|
674 |
iFetchBlockUpperNumber = 0;
|
|
675 |
iVPbkCallbackCount = 0;
|
|
676 |
|
|
677 |
// Change the iNextState to fetch the contacts
|
|
678 |
if(iContactViewReady == EFalse)
|
|
679 |
{
|
|
680 |
iObserver->UpdateCachingStatus(*iUri, ECachingInProgress);
|
|
681 |
iContactViewReady = ETrue;
|
|
682 |
iNextState = EFetchAllLinks;
|
|
683 |
IssueRequest( 0 );
|
|
684 |
}
|
|
685 |
|
|
686 |
PRINT ( _L("End CPcsContactStore::ContactViewReady") );
|
|
687 |
}
|
|
688 |
|
|
689 |
// ---------------------------------------------------------------------------
|
|
690 |
// Implements the view unavailable function of MVPbkContactViewObserver
|
|
691 |
// ---------------------------------------------------------------------------
|
|
692 |
void CPcsContactStore::ContactViewUnavailable(
|
|
693 |
MVPbkContactViewBase& /*aView*/ )
|
|
694 |
{
|
|
695 |
PRINT ( _L("Enter CPcsContactStore::ContactViewUnavailable") );
|
|
696 |
PRINT1 ( _L("CPcsContactStore::ContactViewUnavailable: URI=%S"),
|
|
697 |
&*iUri );
|
|
698 |
|
|
699 |
// Update the caching status to cachingComplete, the client of PCS--Cmail can
|
|
700 |
// perform searching even when contactview of somestore is unavailable.
|
|
701 |
// For Contacts and Group view we get one of this event brfore ContactViewReady
|
|
702 |
iObserver->UpdateCachingStatus(*iUri, ECachingComplete);
|
|
703 |
iFs.Close();
|
|
704 |
|
|
705 |
PRINT ( _L("End CPcsContactStore::ContactViewUnavailable") );
|
|
706 |
}
|
|
707 |
|
|
708 |
// ---------------------------------------------------------------------------
|
|
709 |
// Implements the add contact function of MVPbkContactViewObserver
|
|
710 |
// ---------------------------------------------------------------------------
|
|
711 |
void CPcsContactStore::ContactAddedToView(
|
|
712 |
MVPbkContactViewBase& /*aView*/,
|
|
713 |
TInt /*aIndex*/,
|
|
714 |
const MVPbkContactLink& /*aContactLink*/ )
|
|
715 |
{
|
|
716 |
}
|
|
717 |
|
|
718 |
// ---------------------------------------------------------------------------
|
|
719 |
// Implements the remove contact function of MVPbkContactViewObserver
|
|
720 |
// ---------------------------------------------------------------------------
|
|
721 |
void CPcsContactStore::ContactRemovedFromView(
|
|
722 |
MVPbkContactViewBase& /*aView*/,
|
|
723 |
TInt /*aIndex*/,
|
|
724 |
const MVPbkContactLink& /*aContactLink*/ )
|
|
725 |
{
|
|
726 |
}
|
|
727 |
|
|
728 |
// ---------------------------------------------------------------------------
|
|
729 |
// Implements the view error function of MVPbkContactViewObserver
|
|
730 |
// ---------------------------------------------------------------------------
|
|
731 |
void CPcsContactStore::ContactViewError(
|
|
732 |
MVPbkContactViewBase& /*aView*/,
|
|
733 |
TInt aError,
|
|
734 |
TBool /*aErrorNotified*/ )
|
|
735 |
{
|
|
736 |
PRINT2 ( _L("CPcsContactStore::ContactViewError: URI=%S, Error=%d"),
|
|
737 |
&*iUri, aError );
|
|
738 |
}
|
|
739 |
|
|
740 |
// ---------------------------------------------------------------------------
|
|
741 |
// Creates the contact view to fetch data from this store
|
|
742 |
// ---------------------------------------------------------------------------
|
|
743 |
void CPcsContactStore::CreateContactFetchViewL()
|
|
744 |
{
|
|
745 |
PRINT ( _L("Enter CPcsContactStore::CreateContactFetchViewL") );
|
|
746 |
PRINT1 ( _L("CPcsContactStore::CreateContactFetchViewL: URI=%S"),
|
|
747 |
&*iUri );
|
|
748 |
|
|
749 |
// Create the view definition
|
|
750 |
CVPbkContactViewDefinition* viewDef = CVPbkContactViewDefinition::NewL();
|
|
751 |
CleanupStack::PushL( viewDef );
|
|
752 |
|
|
753 |
// Create the View Name for the view
|
|
754 |
// The views are named as PCSView_<uri>
|
|
755 |
HBufC* viewName = HBufC::NewL(KBufferMaxLen);
|
|
756 |
viewName->Des().Append(KPcsViewPrefix);
|
|
757 |
viewName->Des().Append(iUri->Des());
|
|
758 |
CleanupStack::PushL(viewName);
|
|
759 |
|
|
760 |
// Set the Uri
|
|
761 |
if ( iUri->CompareC(KVPbkDefaultGrpDbURI) == 0)
|
|
762 |
{
|
|
763 |
// Special Handling required for Groups Data Store
|
|
764 |
// Read the resource file and create the sort order
|
|
765 |
// The sort order created is used in view creation.
|
|
766 |
|
|
767 |
User::LeaveIfError( iFs.Connect() );
|
|
768 |
TPtrC driveLetter = TParsePtrC( RProcess().FileName() ).Drive();
|
|
769 |
TBuf<KMaxFileName> resourceFileName;
|
|
770 |
RResourceFile iResourceFile;
|
|
771 |
|
|
772 |
//Read the path of the resource file
|
|
773 |
resourceFileName.Copy( driveLetter );
|
|
774 |
resourceFileName.Append( KDC_RESOURCE_FILES_DIR );
|
|
775 |
resourceFileName.Append( KResourceFileName );
|
|
776 |
|
|
777 |
//Open the resource file
|
|
778 |
BaflUtils::NearestLanguageFile( iFs, resourceFileName );
|
|
779 |
iResourceFile.OpenL( iFs, resourceFileName );
|
|
780 |
iResourceFile.ConfirmSignatureL(0);
|
|
781 |
|
|
782 |
|
|
783 |
//Read resource
|
|
784 |
HBufC8* textbuffer = iResourceFile.AllocReadL(R_SORTORDER_LASTNAME);
|
|
785 |
CleanupStack::PushL(textbuffer);
|
|
786 |
|
|
787 |
// Set the resource information into the reader
|
|
788 |
TResourceReader reader;
|
|
789 |
reader.SetBuffer(textbuffer);
|
|
790 |
|
|
791 |
// Create sort order with only last name
|
|
792 |
CVPbkSortOrder* sortOrder = CVPbkSortOrder::NewL( reader,
|
|
793 |
iContactManager->FieldTypes() );
|
|
794 |
|
|
795 |
CleanupStack::PushL(sortOrder);
|
|
796 |
|
|
797 |
// Set the groups type
|
|
798 |
viewDef->SetUriL(KVPbkDefaultCntDbURI);
|
|
799 |
viewDef->SetType( EVPbkGroupsView );
|
|
800 |
|
|
801 |
// Set name for the view
|
|
802 |
viewDef->SetNameL( *viewName );
|
|
803 |
|
|
804 |
// Create the contact view
|
|
805 |
iContactViewBase = iContactManager->CreateContactViewLC(
|
|
806 |
*this,
|
|
807 |
*viewDef,
|
|
808 |
*sortOrder);
|
|
809 |
|
|
810 |
CleanupStack::Pop(); // iContactViewBase
|
|
811 |
CleanupStack::PopAndDestroy(sortOrder);
|
|
812 |
CleanupStack::PopAndDestroy(textbuffer);
|
|
813 |
|
|
814 |
// Close the resouce File
|
|
815 |
iResourceFile.Close();
|
|
816 |
}
|
|
817 |
else if ( iUri->CompareC(KVPbkDefaultCntDbURI) == 0)
|
|
818 |
{
|
|
819 |
// For phone contacts DB we use the shared "AllContacts" -view so that
|
|
820 |
// we don't need to generate a new view. This way we save some RAM
|
|
821 |
// from contacts server and some CPU time because the view is already
|
|
822 |
// generated and sorted. Difference is noticiable with larger amount
|
|
823 |
// of contacts e.g. 7000.
|
|
824 |
|
|
825 |
viewDef->SetUriL( iUri->Des() );
|
|
826 |
viewDef->SetType( EVPbkContactsView );
|
|
827 |
|
|
828 |
if( !iSortOrderMan )
|
|
829 |
{
|
|
830 |
iSortOrderMan = CPbk2SortOrderManager::NewL(
|
|
831 |
iContactManager->FieldTypes(), &iContactManager->FsSession() );
|
|
832 |
}
|
|
833 |
|
|
834 |
iContactViewBase = iContactManager->CreateContactViewLC(
|
|
835 |
*this, *viewDef, iSortOrderMan->SortOrder() );
|
|
836 |
CleanupStack::Pop(); // iContactViewBase
|
|
837 |
}
|
|
838 |
else
|
|
839 |
{
|
|
840 |
// Create sort order with the fields from cenrep
|
|
841 |
CreateSortOrderL(iContactManager->FieldTypes());
|
|
842 |
|
|
843 |
CVPbkSortOrder* sortOrderPhone = CVPbkSortOrder::NewL(*iSortOrder);
|
|
844 |
CleanupStack::PushL(sortOrderPhone);
|
|
845 |
|
|
846 |
// set contacts type
|
|
847 |
viewDef->SetUriL(iUri->Des());
|
|
848 |
viewDef->SetType( EVPbkContactsView );
|
|
849 |
|
|
850 |
// Set name for the view
|
|
851 |
viewDef->SetNameL( *viewName );
|
|
852 |
__LATENCY_MARK ( _L("CPcsContactStore::CreateContactFetchViewL ==== create view start") );
|
|
853 |
iContactViewBase = iContactManager->CreateContactViewLC(
|
|
854 |
*this,
|
|
855 |
*viewDef,
|
|
856 |
*sortOrderPhone );
|
|
857 |
__LATENCY_MARKEND ( _L("CPcsContactStore::CreateContactFetchViewL ==== create view end") );
|
|
858 |
|
|
859 |
CleanupStack::Pop(); // iContactViewBase
|
|
860 |
CleanupStack::PopAndDestroy(sortOrderPhone);
|
|
861 |
}
|
|
862 |
|
|
863 |
CleanupStack::PopAndDestroy( viewName );
|
|
864 |
CleanupStack::PopAndDestroy( viewDef );
|
|
865 |
|
|
866 |
PRINT ( _L("End CPcsContactStore::CreateContactFetchViewL") );
|
|
867 |
}
|
|
868 |
|
|
869 |
// ---------------------------------------------------------------------------------
|
|
870 |
// Implements cancellation of an outstanding request.
|
|
871 |
// ---------------------------------------------------------------------------------
|
|
872 |
void CPcsContactStore::DoCancel()
|
|
873 |
{
|
|
874 |
}
|
|
875 |
|
|
876 |
// ---------------------------------------------------------------------------------
|
|
877 |
// The function is called by the active scheduler
|
|
878 |
// ---------------------------------------------------------------------------------
|
|
879 |
void CPcsContactStore::RunL()
|
|
880 |
{
|
|
881 |
TRequestStatus timerStatus;
|
|
882 |
iTimer.Cancel();
|
|
883 |
|
|
884 |
switch( iNextState)
|
|
885 |
{
|
|
886 |
case ECreateView:
|
|
887 |
PRINT1 ( _L("CPcsContactStore::RunL(ECreateView): URI=%S. Create contact view to fetch data from store"),
|
|
888 |
&*iUri );
|
|
889 |
CreateContactFetchViewL();
|
|
890 |
break;
|
|
891 |
|
|
892 |
case EFetchAllLinks:
|
|
893 |
PRINT1 ( _L("CPcsContactStore::RunL(EFetchAllLinks): URI=%S. Get all contact links in initial view"),
|
|
894 |
&*iUri );
|
|
895 |
FetchAllInitialContactLinksL();
|
|
896 |
break;
|
|
897 |
|
|
898 |
case EFetchContactBlock:
|
|
899 |
PRINT4 ( _L("CPcsContactStore::RunL(EFetchContactBlock): URI=%S. Issuing fetch request for next block of max %d contacts (%d/%d fetched)"),
|
|
900 |
&*iUri, KLinksToFetchInOneGo, iFetchBlockUpperNumber, iInitialContactCount);
|
|
901 |
FetchContactsBlockL();
|
|
902 |
break;
|
|
903 |
|
|
904 |
case EComplete:
|
|
905 |
PRINT3 ( _L("CPcsContactStore::RunL(EComplete): URI=%S. Contacts Caching FINISHED, (%d/%d contacts fetched)"),
|
|
906 |
&*iUri, iFetchBlockUpperNumber, iInitialContactCount );
|
|
907 |
PRINT1_BOOT_PERFORMANCE ( _L("CPcsContactStore::RunL(EComplete): URI=%S. Contacts Caching FINISHED"),
|
|
908 |
&*iUri );
|
|
909 |
break;
|
|
910 |
}
|
|
911 |
}
|
|
912 |
|
|
913 |
// ---------------------------------------------------------------------------------
|
|
914 |
// Called in case of any errros
|
|
915 |
// ---------------------------------------------------------------------------------
|
|
916 |
TInt CPcsContactStore::RunError(TInt /*aError*/)
|
|
917 |
{
|
|
918 |
PRINT ( _L("Enter CPcsContactStore::RunError") );
|
|
919 |
|
|
920 |
PRINT1 ( _L("CPcsContactStore::RunError(): URI=%S. Completing caching with status ECachingCompleteWithErrors"),
|
|
921 |
&*iUri );
|
|
922 |
iObserver->UpdateCachingStatus(*iUri, ECachingCompleteWithErrors);
|
|
923 |
|
|
924 |
PRINT ( _L("End CPcsContactStore::RunError") );
|
|
925 |
return KErrNone;
|
|
926 |
}
|
|
927 |
|
|
928 |
// ---------------------------------------------------------------------------------
|
|
929 |
// Read the fields to cache from the central repository
|
|
930 |
// ---------------------------------------------------------------------------------
|
|
931 |
void CPcsContactStore::ReadFieldsToCacheFromCenrepL()
|
|
932 |
{
|
|
933 |
CRepository* repository = CRepository::NewL( KCRUidPSContacts );
|
|
934 |
|
|
935 |
// Read the data fields from cenrep
|
|
936 |
for (TInt i(KCenrepFieldsStartKey); i < KCenrepFieldsStartKey + KCenrepNumberOfFieldsCount; i++ )
|
|
937 |
{
|
|
938 |
TInt fieldToCache (-1);
|
|
939 |
TInt err = repository->Get(i, fieldToCache );
|
|
940 |
|
|
941 |
if ( KErrNone != err )
|
|
942 |
{
|
|
943 |
break;
|
|
944 |
}
|
|
945 |
if ( fieldToCache != 0 )
|
|
946 |
{
|
|
947 |
iFieldsToCache.Append(fieldToCache);
|
|
948 |
}
|
|
949 |
}
|
|
950 |
|
|
951 |
delete repository;
|
|
952 |
}
|
|
953 |
|
|
954 |
// ---------------------------------------------------------------------------------
|
|
955 |
// Creates a dummy id for the cache
|
|
956 |
// ---------------------------------------------------------------------------------
|
|
957 |
|
|
958 |
TInt CPcsContactStore::CreateCacheIDfromSimArrayIndex(TInt aSimId)
|
|
959 |
{
|
|
960 |
return (KSimStoreOffset + aSimId);
|
|
961 |
}
|
|
962 |
|
|
963 |
// ---------------------------------------------------------------------------------
|
|
964 |
// Issues request to active object to call RunL method
|
|
965 |
// ---------------------------------------------------------------------------------
|
|
966 |
void CPcsContactStore::IssueRequest( TInt aTimeDelay )
|
|
967 |
{
|
|
968 |
if( IsActive() ) // cannot activate allready active object
|
|
969 |
return;
|
|
970 |
|
|
971 |
if ( 0 == aTimeDelay )
|
|
972 |
{
|
|
973 |
TRequestStatus* status = &iStatus;
|
|
974 |
User::RequestComplete( status, KErrNone );
|
|
975 |
}
|
|
976 |
else
|
|
977 |
{
|
|
978 |
PRINT1 ( _L("CPcsContactStore::IssueRequest: Applying delay of %d milliseconds"),
|
|
979 |
aTimeDelay );
|
|
980 |
|
|
981 |
iTimer.After( iStatus, aTimeDelay);
|
|
982 |
}
|
|
983 |
|
|
984 |
SetActive();
|
|
985 |
}
|
|
986 |
|
|
987 |
// ---------------------------------------------------------------------------------
|
|
988 |
// Creates a sort order depending on the fields specified
|
|
989 |
// in the cenrep when calling this function pass the
|
|
990 |
// masterList (i.e list containing all the vpbk fields)
|
|
991 |
// ---------------------------------------------------------------------------------
|
|
992 |
void CPcsContactStore::CreateSortOrderL(const MVPbkFieldTypeList& aMasterList)
|
|
993 |
{
|
|
994 |
|
|
995 |
TInt count = aMasterList.FieldTypeCount();
|
|
996 |
|
|
997 |
// loop through the master list and find the types that are supported
|
|
998 |
for(TInt i = 0; i < count; i++)
|
|
999 |
{
|
|
1000 |
const MVPbkFieldType& fieldType = aMasterList.FieldTypeAt(i);
|
|
1001 |
TInt resourceId = fieldType.FieldTypeResId();
|
|
1002 |
// if the field type is supported
|
|
1003 |
// then append MVPbkFieldType to sortOrder
|
|
1004 |
for(TInt j =0; j < iFieldsToCache.Count(); j++)
|
|
1005 |
{
|
|
1006 |
if(iFieldsToCache[j] == resourceId)
|
|
1007 |
{
|
|
1008 |
iSortOrder->AppendL(fieldType);
|
|
1009 |
}
|
|
1010 |
}
|
|
1011 |
|
|
1012 |
if(iSortOrder->FieldTypeCount() == iFieldsToCache.Count())
|
|
1013 |
{
|
|
1014 |
break;
|
|
1015 |
}
|
|
1016 |
}
|
|
1017 |
|
|
1018 |
}
|
|
1019 |
|
|
1020 |
// ---------------------------------------------------------------------------------
|
|
1021 |
// Checks MyCard extension of contact
|
|
1022 |
// ---------------------------------------------------------------------------------
|
|
1023 |
TBool CPcsContactStore::IsMyCard( const MVPbkBaseContact& aContact )
|
|
1024 |
{
|
|
1025 |
TBool isMyCard( EFalse);
|
|
1026 |
// this is temporary solution to hide own contact from phonebook contacts list,
|
|
1027 |
// TODO remove this code when we can hide own contact with contact model
|
|
1028 |
|
|
1029 |
MVPbkBaseContact& contact = const_cast<MVPbkBaseContact&>( aContact );
|
|
1030 |
TAny* extension = contact.BaseContactExtension( KVPbkBaseContactExtension2Uid );
|
|
1031 |
|
|
1032 |
if ( extension )
|
|
1033 |
{
|
|
1034 |
MVPbkBaseContact2* baseContactExtension = static_cast<MVPbkBaseContact2*>( extension );
|
|
1035 |
TInt error( KErrNone );
|
|
1036 |
isMyCard = baseContactExtension->IsOwnContact( error );
|
|
1037 |
}
|
|
1038 |
|
|
1039 |
return isMyCard;
|
|
1040 |
}
|
|
1041 |
// End of file
|