|
1 /* |
|
2 * Copyright (c) 2005 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: |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDES |
|
21 #include <spsettings.h> |
|
22 #include <spproperty.h> |
|
23 #include <MVPbkContactStore.h> |
|
24 #include <CVPbkContactManager.h> |
|
25 #include <VPbkContactStoreUris.h> |
|
26 #include <CVPbkContactLinkArray.h> |
|
27 #include <MVPbkContactStoreList.h> |
|
28 #include <CVPbkFieldTypeRefsList.h> |
|
29 #include <CVPbkContactIdConverter.h> |
|
30 #include <CPbk2StoreConfiguration.h> |
|
31 #include <MVPbkContactOperationBase.h> |
|
32 #include <MVPbkContactStoreProperties.h> |
|
33 #include <TVPbkWordParserCallbackParam.h> |
|
34 #include <CVPbkContactStoreUriArray.h> |
|
35 #include "cmsphonebookproxy.h" |
|
36 #include "cmsservercontact.h" |
|
37 #include "cmsdefines.h" |
|
38 #include "cmsserver.h" |
|
39 #include "cmsdebug.h" |
|
40 |
|
41 #include "cmsfindlinkedcontact.h" |
|
42 #include <MVPbkContactLink.h> |
|
43 |
|
44 // CONSTANTS |
|
45 const TInt KArrayGranularity = 2; |
|
46 |
|
47 // ---------------------------------------------------------- |
|
48 // CCmsPhonebookProxy::CCmsPhonebookProxy |
|
49 // |
|
50 // ---------------------------------------------------------- |
|
51 // |
|
52 CCmsPhonebookProxy::CCmsPhonebookProxy( MCmsPhonebookOperationsObserver& aCmsStoreOpencompleteObserver, |
|
53 RFs& aFileSessionHandle ) : |
|
54 iAtLeastOneStoreReady( EFalse ), |
|
55 iOpenComplete( EFalse ), |
|
56 iXspStoresInstalled( EFalse ), |
|
57 iCmsPhonebookOperationsObserver( aCmsStoreOpencompleteObserver ), |
|
58 iFileSessionHandle( aFileSessionHandle ), |
|
59 ixSPStoresArray( KArrayGranularity ) |
|
60 { |
|
61 } |
|
62 |
|
63 // ---------------------------------------------------------- |
|
64 // CCmsPhonebookProxy::NewL |
|
65 // |
|
66 // ---------------------------------------------------------- |
|
67 // |
|
68 CCmsPhonebookProxy* CCmsPhonebookProxy::NewL( |
|
69 MCmsPhonebookOperationsObserver& aCmsStoreOpencompleteObserver, |
|
70 RFs& aFileSessionHandle ) |
|
71 { |
|
72 CCmsPhonebookProxy* self = new ( ELeave ) CCmsPhonebookProxy( |
|
73 aCmsStoreOpencompleteObserver, aFileSessionHandle ); |
|
74 CleanupStack::PushL( self ); |
|
75 self->ConstructL(); |
|
76 CleanupStack::Pop(); |
|
77 return self; |
|
78 } |
|
79 |
|
80 // ---------------------------------------------------------- |
|
81 // CCmsPhonebookProxy::ConstructL |
|
82 // |
|
83 // ---------------------------------------------------------- |
|
84 // |
|
85 void CCmsPhonebookProxy::ConstructL() |
|
86 { |
|
87 PRINT ( _L("Start CCmsPhonebookProxy::ConstructL()") ); |
|
88 iStoreConfiguration = CPbk2StoreConfiguration::NewL(); |
|
89 iStoreConfiguration->AddObserverL( *this ); |
|
90 CreateConfigurationL(); |
|
91 PRINT ( _L("End CCmsPhonebookProxy::ConstructL()") ); |
|
92 } |
|
93 |
|
94 // ---------------------------------------------------------- |
|
95 // CCmsPhonebookProxy::~CCmsPhonebookProxy |
|
96 // |
|
97 // ---------------------------------------------------------- |
|
98 // |
|
99 CCmsPhonebookProxy::~CCmsPhonebookProxy() |
|
100 { |
|
101 delete iOperation; |
|
102 delete iUriList; |
|
103 delete iFieldTypeRefList; |
|
104 delete iContactManager; |
|
105 if( iStoreConfiguration ) |
|
106 { |
|
107 iStoreConfiguration->RemoveObserver( *this ); |
|
108 delete iStoreConfiguration; |
|
109 iStoreConfiguration = NULL; |
|
110 } |
|
111 iObserverArray.Close(); |
|
112 ixSPStoresArray.Reset(); |
|
113 } |
|
114 |
|
115 // ---------------------------------------------------------- |
|
116 // CCmsPhonebookProxy::StoreOpenStatus |
|
117 // |
|
118 // ---------------------------------------------------------- |
|
119 // |
|
120 TBool CCmsPhonebookProxy::StoreOpenStatus() |
|
121 { |
|
122 if(iAtLeastOneStoreReady && iOpenComplete) |
|
123 { |
|
124 return ETrue; |
|
125 } |
|
126 |
|
127 return EFalse; |
|
128 } |
|
129 |
|
130 // ---------------------------------------------------------- |
|
131 // CCmsPhonebookProxy::InitStoresL |
|
132 // |
|
133 // ---------------------------------------------------------- |
|
134 // |
|
135 void CCmsPhonebookProxy::InitStoresL() |
|
136 { |
|
137 PRINT ( _L("Start CCmsPhonebookProxy::InitStoresL()") ); |
|
138 if( !iOpenComplete ) |
|
139 { |
|
140 iStoreList->OpenAllL( *this ); |
|
141 } |
|
142 PRINT ( _L("End CCmsPhonebookProxy::InitStoresL()") ); |
|
143 } |
|
144 |
|
145 // ---------------------------------------------------------- |
|
146 // CCmsPhonebookProxy::FetchContactL |
|
147 // |
|
148 // ---------------------------------------------------------- |
|
149 // |
|
150 TInt CCmsPhonebookProxy::FetchContactL( TInt32 aContactId, MCmsContactInterface* aContactInterface ) |
|
151 { |
|
152 PRINT ( _L("Start CCmsPhonebookProxy::FetchContactL()") ); |
|
153 PRINT1 ( _L("CCmsPhonebookProxy::FetchContactL() - Contact ID: %d"), aContactId ); |
|
154 |
|
155 if( iContactStore == NULL ) //Cannot do anything if phonebook store is not available |
|
156 { |
|
157 return KErrNotReady; |
|
158 } |
|
159 |
|
160 TInt error = KErrNotFound; |
|
161 iContactInterface = aContactInterface; |
|
162 CVPbkContactIdConverter* converter = CVPbkContactIdConverter::NewL( *iContactStore ); |
|
163 CleanupStack::PushL( converter ); |
|
164 MVPbkContactLink* link = converter->IdentifierToLinkLC( aContactId ); |
|
165 if( link ) |
|
166 { |
|
167 if( iOperation ) |
|
168 { |
|
169 delete iOperation; |
|
170 iOperation = NULL; |
|
171 } |
|
172 iOperation = iContactManager->RetrieveContactL( *link, *this ); |
|
173 error = KErrNone; |
|
174 } |
|
175 CleanupStack::PopAndDestroy( 2 ); //link, converter |
|
176 PRINT ( _L("End CCmsPhonebookProxy::FetchContactL()") ); |
|
177 return error; |
|
178 } |
|
179 |
|
180 // ---------------------------------------------------------- |
|
181 // CCmsPhonebookProxy::FetchContactL |
|
182 // |
|
183 // ---------------------------------------------------------- |
|
184 // |
|
185 TInt CCmsPhonebookProxy::FetchContactL( const TDesC8& aPackedLink, MCmsContactInterface* aContactInterface ) |
|
186 { |
|
187 //Whenever we get contact link, there can be the following possibilities |
|
188 //Contact could belong to any of the foll stores - Sim Store, PBK2Store, XSP Store |
|
189 |
|
190 //If contact is from Sim Store, PBK2Store no extra effort is needed |
|
191 //just use the passed link and retreive the contact info |
|
192 |
|
193 //XSPContact |
|
194 //********** |
|
195 //If contacts is from XSP Store - then the challenge is to find whether this xspid |
|
196 //is linked to the contact in DefaultCntDbUri or not |
|
197 //How? |
|
198 //We need to search the entire DefaultCntDbUri() for any contact which is linked to this xspcontact |
|
199 //if more than 1 contact is linked to the same xspid, smartly choose anyone link(first link) |
|
200 //Once having found this linked contact in the DefaultCntDbUri(), use this found |
|
201 //contact to retreive the info |
|
202 |
|
203 PRINT ( _L("Start CCmsPhonebookProxy::FetchContactL()") ); |
|
204 TInt error = KErrNotFound; |
|
205 iContactInterface = aContactInterface; |
|
206 CVPbkContactLinkArray* linkArray = CVPbkContactLinkArray::NewLC( aPackedLink, *iStoreList ); |
|
207 if( linkArray->Count() > 0 ) |
|
208 { |
|
209 MVPbkContactLink* contactLinkToFetch = NULL; |
|
210 const MVPbkContactLink& contactLink = linkArray->At( 0 ); |
|
211 |
|
212 CCmsFindLinkedContact* findLinkedContact = NULL; |
|
213 |
|
214 //Check whether the contact belongs to xsp store or not |
|
215 if ( IsXspContact( contactLink ) ) |
|
216 { |
|
217 findLinkedContact = CCmsFindLinkedContact::NewL( |
|
218 *iContactManager ); |
|
219 CleanupStack::PushL( findLinkedContact ); |
|
220 //Its been proved that the contact passed is an XSP Contact |
|
221 //Now fetch the contact in DefaultCntDbUri which is linked to |
|
222 //the passed XSP contact |
|
223 contactLinkToFetch = |
|
224 (findLinkedContact->FetchLinkedContactL( contactLink )).CloneLC(); |
|
225 |
|
226 } |
|
227 else |
|
228 { |
|
229 contactLinkToFetch = contactLink.CloneLC(); |
|
230 } |
|
231 |
|
232 //Retreive the contact Info |
|
233 if( iOperation ) |
|
234 { |
|
235 delete iOperation; |
|
236 iOperation = NULL; |
|
237 } |
|
238 iOperation = iContactManager->RetrieveContactL( *contactLinkToFetch, *this ); |
|
239 CleanupStack::PopAndDestroy(); //contactLinkToFetch |
|
240 |
|
241 if ( findLinkedContact ) |
|
242 { |
|
243 CleanupStack::PopAndDestroy(); //findLinkedContact |
|
244 } |
|
245 |
|
246 error = KErrNone; |
|
247 } |
|
248 |
|
249 CleanupStack::PopAndDestroy(); //linkArray |
|
250 PRINT ( _L("End CCmsPhonebookProxy::FetchContactL()") ); |
|
251 return error; |
|
252 } |
|
253 |
|
254 // ---------------------------------------------------------- |
|
255 // CCmsPhonebookProxy::FetchContactL |
|
256 // |
|
257 // ---------------------------------------------------------- |
|
258 // |
|
259 TInt CCmsPhonebookProxy::FetchContactL( const TDesC& aPhoneNbr, MCmsContactInterface* aContactInterface ) |
|
260 { |
|
261 PRINT ( _L("Start CCmsPhonebookProxy::FetchContactL()") ); |
|
262 |
|
263 // Write the aPhoneNbr to log file |
|
264 PRINT1 ( _L("CCmsPhonebookProxy::FetchContactL() - Phone number: %S"), &aPhoneNbr); |
|
265 iContactInterface = aContactInterface; |
|
266 |
|
267 if( iOperation ) |
|
268 { |
|
269 delete iOperation; |
|
270 iOperation = NULL; |
|
271 } |
|
272 iOperation = iContactManager->MatchPhoneNumberL( aPhoneNbr, aPhoneNbr.Length(), *this ); |
|
273 PRINT ( _L("End CCmsPhonebookProxy::FetchContactL()") ); |
|
274 return KErrNone; |
|
275 } |
|
276 |
|
277 // ---------------------------------------------------------- |
|
278 // CCmsPhonebookProxy::AddObserverL |
|
279 // |
|
280 // ---------------------------------------------------------- |
|
281 // |
|
282 void CCmsPhonebookProxy::AddObserverL( MCmsContactInterface* aObserver ) |
|
283 { |
|
284 PRINT ( _L("Start CCmsPhonebookProxy::AddObserverL()") ); |
|
285 |
|
286 PRINT1 ( _L( "CCmsPhonebookProxy::AddObserverL(): 0x%x" ), &aObserver ); |
|
287 User::LeaveIfError( iObserverArray.Append( aObserver ) ); |
|
288 |
|
289 PRINT ( _L("End CCmsPhonebookProxy::AddObserverL()") ); |
|
290 } |
|
291 |
|
292 // ---------------------------------------------------------- |
|
293 // CCmsPhonebookProxy::RemoveObserver |
|
294 // |
|
295 // ---------------------------------------------------------- |
|
296 // |
|
297 void CCmsPhonebookProxy::RemoveObserver( MCmsContactInterface* aObserver ) |
|
298 { |
|
299 TInt index( iObserverArray.Find( aObserver ) ); |
|
300 if( 0 <= index ) |
|
301 { |
|
302 PRINT1( _L( "CCmsPhonebookProxy::RemoveObserver(): 0x%x" ), &aObserver ); |
|
303 iObserverArray.Remove( index ); |
|
304 } |
|
305 } |
|
306 |
|
307 // ---------------------------------------------------------- |
|
308 // CCmsPhonebookProxy::FindXSPContactL |
|
309 // |
|
310 // ---------------------------------------------------------- |
|
311 // |
|
312 MVPbkContactOperationBase* CCmsPhonebookProxy::FindXSPContactL( const TDesC& aXspId, /*const TDesC& aExcludedStoreUri,*/ |
|
313 MVPbkContactFindFromStoresObserver& aContacthandler ) |
|
314 { |
|
315 if( iFieldTypeRefList ) |
|
316 { |
|
317 iFieldTypeRefList->Reset(); |
|
318 delete iFieldTypeRefList; |
|
319 iFieldTypeRefList = NULL; |
|
320 } |
|
321 iFieldTypeRefList = CVPbkFieldTypeRefsList::NewL(); |
|
322 TCallBack parser( CCmsPhonebookProxy::WordParser, this ); |
|
323 iFieldTypeRefList->AppendL( *iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_IMPP ) ); |
|
324 CDesCArrayFlat* searchString = new( ELeave) CDesCArrayFlat( 1 ); |
|
325 CleanupStack::PushL( searchString ); |
|
326 searchString->AppendL( aXspId ); |
|
327 |
|
328 MVPbkContactOperationBase* XSPFindOperation = iContactManager->FindL( |
|
329 *searchString, *iFieldTypeRefList, aContacthandler, parser, ixSPStoresArray ); |
|
330 CleanupStack::PopAndDestroy( searchString ); |
|
331 |
|
332 return XSPFindOperation; |
|
333 } |
|
334 |
|
335 // ---------------------------------------------------------- |
|
336 // CCmsPhonebookProxy::NumberOfStoresInFind |
|
337 // |
|
338 // ---------------------------------------------------------- |
|
339 // |
|
340 TInt CCmsPhonebookProxy::NumberOfStoresInFind( const TDesC& aExcludedStoreUri ) |
|
341 { |
|
342 TVPbkContactStoreUriPtr excludedUri( aExcludedStoreUri ); |
|
343 if ( iUriList->IsIncluded( excludedUri ) ) |
|
344 { |
|
345 return iUriList->Count() - 1; |
|
346 } |
|
347 else |
|
348 { |
|
349 return iUriList->Count(); |
|
350 } |
|
351 } |
|
352 |
|
353 // ---------------------------------------------------------- |
|
354 // CCmsPhonebookProxy::UpdateXSPStoresListL |
|
355 // |
|
356 // ---------------------------------------------------------- |
|
357 // |
|
358 void CCmsPhonebookProxy::UpdateXSPStoresListL() |
|
359 { |
|
360 CDesCArrayFlat* xSPStoresArray = new (ELeave) |
|
361 CDesCArrayFlat( KArrayGranularity ); |
|
362 CleanupStack::PushL( xSPStoresArray ); |
|
363 FindXSPStoresL( *xSPStoresArray ); |
|
364 |
|
365 TBool configurationChanged = EFalse; |
|
366 TInt oldStoresCount = ixSPStoresArray.Count(); |
|
367 TInt newStoresCount = xSPStoresArray->Count(); |
|
368 |
|
369 if ( oldStoresCount != newStoresCount ) |
|
370 { |
|
371 configurationChanged = ETrue; |
|
372 } |
|
373 |
|
374 for ( TInt i = 0; i < oldStoresCount && !configurationChanged; i++ ) |
|
375 { |
|
376 if ( ixSPStoresArray.operator[](i).Compare( |
|
377 xSPStoresArray->operator[](i) ) != 0 ) |
|
378 { |
|
379 configurationChanged = ETrue; |
|
380 } |
|
381 } |
|
382 |
|
383 if ( configurationChanged ) |
|
384 { |
|
385 CreateConfigurationL(); |
|
386 InitStoresL(); |
|
387 } |
|
388 |
|
389 CleanupStack::PopAndDestroy( xSPStoresArray ); |
|
390 } |
|
391 |
|
392 // ---------------------------------------------------------- |
|
393 // CCmsPhonebookProxy::WordParser |
|
394 // |
|
395 // ---------------------------------------------------------- |
|
396 // |
|
397 TInt CCmsPhonebookProxy::WordParser( TAny* aWordParserParam ) |
|
398 { |
|
399 TVPbkWordParserCallbackParam* param = static_cast<TVPbkWordParserCallbackParam*>( aWordParserParam ); |
|
400 TPtrC data( param->iStringToParse->Ptr() ); |
|
401 |
|
402 PRINT1( _L( "CCmsPhonebookProxy::WordParser(): %S" ), &data ); |
|
403 |
|
404 param->iWordArray->AppendL( data ); |
|
405 return 0; |
|
406 } |
|
407 |
|
408 // ---------------------------------------------------------- |
|
409 // CCmsPhonebookProxy::ExternalStoresIntalled |
|
410 // |
|
411 // ---------------------------------------------------------- |
|
412 // |
|
413 TBool CCmsPhonebookProxy::ExternalStoresIntalled() const |
|
414 { |
|
415 return iXspStoresInstalled; |
|
416 } |
|
417 |
|
418 // ---------------------------------------------------------- |
|
419 // CCmsPhonebookProxy::ContactManager |
|
420 // |
|
421 // ---------------------------------------------------------- |
|
422 // |
|
423 CVPbkContactManager* CCmsPhonebookProxy::ContactManager() const |
|
424 { |
|
425 return iContactManager; |
|
426 } |
|
427 |
|
428 // ---------------------------------------------------------- |
|
429 // CCmsPhonebookProxy::OpenComplete |
|
430 // |
|
431 // ---------------------------------------------------------- |
|
432 // |
|
433 void CCmsPhonebookProxy::OpenComplete() |
|
434 { |
|
435 PRINT( _L("Start CCmsPhonebookProxy::OpenComplete()" ) ); |
|
436 iOpenComplete = ETrue; |
|
437 if ( iAtLeastOneStoreReady ) |
|
438 { |
|
439 iCmsPhonebookOperationsObserver.StoreOpenComplete(); |
|
440 } |
|
441 PRINT( _L("End CCmsPhonebookProxy::OpenComplete()" ) ); |
|
442 } |
|
443 |
|
444 // ---------------------------------------------------------- |
|
445 // CCmsPhonebookProxy::FindCompleteL |
|
446 // |
|
447 // ---------------------------------------------------------- |
|
448 // |
|
449 void CCmsPhonebookProxy::FindCompleteL( MVPbkContactLinkArray* aResults ) |
|
450 { |
|
451 PRINT1( _L( "CCmsPhonebookProxy::FindCompleteL() - Count: %d" ), aResults->Count() ); |
|
452 ResetData(); |
|
453 TInt count( aResults->Count() ); |
|
454 if( count > 0 ) |
|
455 { |
|
456 if( iOperation ) |
|
457 { |
|
458 delete iOperation; |
|
459 iOperation = NULL; |
|
460 } |
|
461 iOperation = iContactManager->RetrieveContactL( aResults->At( 0 ), *this ); |
|
462 } |
|
463 else |
|
464 { |
|
465 PRINT( _L( " CCmsPhonebookProxy::FindCompleteL() : No results -> complete with KErrNotFound" ) ); |
|
466 CompleteContactRequestL( KErrNotFound, NULL ); |
|
467 iCmsPhonebookOperationsObserver.CmsSingleContactOperationComplete( KErrNotFound ); |
|
468 } |
|
469 delete aResults; |
|
470 aResults = NULL; |
|
471 PRINT( _L( "End CCmsPhonebookProxy::FindCompleteL()" ) ); |
|
472 } |
|
473 |
|
474 // ---------------------------------------------------------- |
|
475 // CCmsPhonebookProxy::FindFailed |
|
476 // |
|
477 // ---------------------------------------------------------- |
|
478 // |
|
479 void CCmsPhonebookProxy::FindFailed( TInt aError ) |
|
480 { |
|
481 PRINT1( _L( "CCmsPhonebookProxy::FindFailed() - Error: %d" ), aError ); |
|
482 ResetData(); |
|
483 CompleteContactRequestL( aError, NULL ); |
|
484 iCmsPhonebookOperationsObserver.CmsSingleContactOperationComplete( aError ); |
|
485 } |
|
486 |
|
487 // ---------------------------------------------------------- |
|
488 // CCmsPhonebookProxy::FindFailed |
|
489 // |
|
490 // ---------------------------------------------------------- |
|
491 // |
|
492 void CCmsPhonebookProxy::CompleteContactRequestL( TInt aError, MVPbkStoreContact* aContact ) |
|
493 { |
|
494 PRINT1( _L( "CCmsPhonebookProxy::CompleteContactRequestL() - Error: %d" ), aError ); |
|
495 if( iContactInterface ) |
|
496 { |
|
497 iContactInterface->ContactReadyL( aError, aContact ); |
|
498 } |
|
499 else |
|
500 { |
|
501 PRINT( _L( " CCmsPhonebookProxy::CompleteContactRequestL(): No contact interface => Panic with ENullInterfaceHandle" ) ); |
|
502 CCmsServer::PanicServer( ENullInterfaceHandle ); |
|
503 } |
|
504 } |
|
505 |
|
506 // ---------------------------------------------------------- |
|
507 // CCmsPhonebookProxy::StoreReady |
|
508 // |
|
509 // ---------------------------------------------------------- |
|
510 // |
|
511 void CCmsPhonebookProxy::StoreReady( MVPbkContactStore& aContactStore ) |
|
512 { |
|
513 PRINT1( _L( "CCmsPhonebookProxy::StoreReady(): Store: %S" ), (&aContactStore.StoreProperties().Uri().UriDes()) ); |
|
514 //Set iAtLeastOneStoreReady to ETrue to indicate that |
|
515 //at least one store is available |
|
516 iAtLeastOneStoreReady = ETrue; |
|
517 using namespace VPbkContactStoreUris; |
|
518 if( aContactStore.StoreProperties().Uri().UriDes().Compare( DefaultCntDbUri() ) == 0 ) |
|
519 { |
|
520 iContactStore = &aContactStore; |
|
521 } |
|
522 } |
|
523 |
|
524 // ---------------------------------------------------------- |
|
525 // CCmsPhonebookProxy::StoreUnavailable |
|
526 // |
|
527 // ---------------------------------------------------------- |
|
528 // |
|
529 void CCmsPhonebookProxy::StoreUnavailable( MVPbkContactStore& aContactStore, TInt /*aReason*/ ) |
|
530 { |
|
531 PRINT1( _L( "CCmsPhonebookProxy::StoreUnavailable(): Store: %S" ), |
|
532 &aContactStore.StoreProperties().Uri().UriDes() ); |
|
533 } |
|
534 |
|
535 // ---------------------------------------------------------- |
|
536 // CCmsPhonebookProxy::HandleStoreEventL |
|
537 // |
|
538 // ---------------------------------------------------------- |
|
539 // |
|
540 void CCmsPhonebookProxy::HandleStoreEventL( MVPbkContactStore& /*aContactStore*/, |
|
541 TVPbkContactStoreEvent aStoreEvent ) |
|
542 { |
|
543 PRINT( _L("Start CCmsPhonebookProxy::HandleStoreEventL()" ) ); |
|
544 |
|
545 TBool found = EFalse; |
|
546 const TInt count = iObserverArray.Count(); |
|
547 for( TInt i = 0;!found && i < count;i++ ) |
|
548 { |
|
549 MCmsContactInterface* observer( iObserverArray[i] ); |
|
550 if( observer ) |
|
551 { |
|
552 TCmsPhonebookEvent event = SelectEventType( aStoreEvent.iEventType ); |
|
553 found = observer->OfferContactEventL( event, aStoreEvent.iContactLink ); |
|
554 } |
|
555 } |
|
556 PRINT( _L("End CCmsPhonebookProxy::HandleStoreEventL()" ) ); |
|
557 } |
|
558 |
|
559 // ---------------------------------------------------------- |
|
560 // CCmsPhonebookProxy::ConfigurationChanged |
|
561 // |
|
562 // ---------------------------------------------------------- |
|
563 // |
|
564 void CCmsPhonebookProxy::ConfigurationChanged() |
|
565 { |
|
566 PRINT( _L( "CCmsPhonebookProxy::ConfigurationChanged()" ) ); |
|
567 } |
|
568 |
|
569 // ---------------------------------------------------------- |
|
570 // CCmsPhonebookProxy::ConfigurationChangedComplete |
|
571 // |
|
572 // ---------------------------------------------------------- |
|
573 // |
|
574 void CCmsPhonebookProxy::ConfigurationChangedComplete() |
|
575 { |
|
576 PRINT( _L( "Start CCmsPhonebookProxy::ConfigurationChangedComplete()" ) ); |
|
577 CreateConfigurationL(); |
|
578 InitStoresL(); |
|
579 PRINT( _L( "End CCmsPhonebookProxy::ConfigurationChangedComplete()" ) ); |
|
580 } |
|
581 |
|
582 // ---------------------------------------------------------- |
|
583 // CCmsPhonebookProxy::CreateConfigurationL |
|
584 // |
|
585 // ---------------------------------------------------------- |
|
586 // |
|
587 void CCmsPhonebookProxy::CreateConfigurationL() |
|
588 { |
|
589 PRINT( _L( "Start CCmsPhonebookProxy::CreateConfigurationL()" ) ); |
|
590 |
|
591 iAtLeastOneStoreReady = EFalse; |
|
592 iOpenComplete = EFalse; |
|
593 delete iUriList; |
|
594 iUriList = NULL; |
|
595 iContactStore = NULL; |
|
596 |
|
597 // Support all contact stores, not only those defined by phonebook2 setting |
|
598 iUriList = iStoreConfiguration->SupportedStoreConfigurationL(); |
|
599 |
|
600 ixSPStoresArray.Reset(); |
|
601 FindXSPStoresL( ixSPStoresArray ); |
|
602 |
|
603 #ifdef _DEBUG |
|
604 PRINT( _L( " CCmsPhonebookProxy::CreateConfigurationL(): Current store configuration:" ) ); |
|
605 for( TInt i = 0; i < iUriList->Count(); i++ ) |
|
606 { |
|
607 PRINT2( _L( " [%d] = %S" ), i, &iUriList->operator[](i).UriDes() ); |
|
608 } |
|
609 #endif |
|
610 |
|
611 delete iContactManager; |
|
612 iContactManager = NULL; |
|
613 iContactManager = CVPbkContactManager::NewL( *iUriList, &iFileSessionHandle ); |
|
614 iStoreList = &iContactManager->ContactStoresL(); |
|
615 |
|
616 PRINT( _L( "End CCmsPhonebookProxy::CreateConfigurationL()" ) ); |
|
617 } |
|
618 |
|
619 // ---------------------------------------------------- |
|
620 // CCmsServerAsyncContact::FindXSPStoresL |
|
621 // |
|
622 // ---------------------------------------------------- |
|
623 // |
|
624 void CCmsPhonebookProxy::FindXSPStoresL( CDesCArrayFlat& aArray ) |
|
625 { |
|
626 PRINT( _L( "Start CCmsPhonebookProxy::OpenXSPStoresL()" ) ); |
|
627 |
|
628 RIdArray ids; |
|
629 CleanupClosePushL( ids ); |
|
630 iXspStoresInstalled = EFalse; |
|
631 CSPSettings* settings = CSPSettings::NewL(); |
|
632 CleanupStack::PushL( settings ); |
|
633 TInt error = settings->FindServiceIdsL( ids ); |
|
634 const TInt count = ids.Count(); |
|
635 PRINT2( _L( "CCmsPhonebookProxy::OpenXSPStoresL : Error: %d Count: %d" ), error, count ); |
|
636 |
|
637 for( TInt i = 0; i < count; i++) |
|
638 { |
|
639 CSPProperty* property = CSPProperty::NewLC(); |
|
640 error = settings->FindPropertyL( ids[i], EPropertyContactStoreId, *property ); |
|
641 if( KErrNone == error ) |
|
642 { |
|
643 RBuf uri; |
|
644 uri.Create( KSPMaxDesLength ); |
|
645 CleanupClosePushL( uri ); |
|
646 property->GetValue( uri ); |
|
647 TVPbkContactStoreUriPtr uriPtr( uri ); |
|
648 if( !iUriList->IsIncluded( uriPtr ) ) |
|
649 { |
|
650 iUriList->AppendL( uriPtr ); |
|
651 } |
|
652 aArray.AppendL( uri ); |
|
653 CleanupStack::PopAndDestroy(); //uri |
|
654 iXspStoresInstalled = ETrue; |
|
655 } |
|
656 CleanupStack::PopAndDestroy(); //property |
|
657 } |
|
658 CleanupStack::PopAndDestroy( 2 ); //settings, ids |
|
659 aArray.Sort(); |
|
660 |
|
661 PRINT( _L( "End CCmsPhonebookProxy::OpenXSPStoresL()" ) ); |
|
662 } |
|
663 |
|
664 // ---------------------------------------------------------- |
|
665 // CCmsPhonebookProxy::SelectEventType |
|
666 // |
|
667 // ---------------------------------------------------------- |
|
668 // |
|
669 TCmsPhonebookEvent CCmsPhonebookProxy::SelectEventType( TVPbkContactStoreEvent::TVPbkContactStoreEventType aPhonebookEvent ) |
|
670 { |
|
671 TCmsPhonebookEvent event = ( TCmsPhonebookEvent )-1; |
|
672 switch( aPhonebookEvent ) |
|
673 { |
|
674 case TVPbkContactStoreEvent::EContactDeleted: |
|
675 { |
|
676 event = ECmsContactDeleted; |
|
677 break; |
|
678 } |
|
679 case TVPbkContactStoreEvent::EContactChanged: |
|
680 { |
|
681 event = ECmsContactModified; |
|
682 break; |
|
683 } |
|
684 default: |
|
685 { |
|
686 event = ECmsContactModified; |
|
687 break; |
|
688 } |
|
689 } |
|
690 return event; |
|
691 } |
|
692 |
|
693 |
|
694 // ---------------------------------------------------------- |
|
695 // CCmsPhonebookProxy::ResetData |
|
696 // |
|
697 // ---------------------------------------------------------- |
|
698 // |
|
699 void CCmsPhonebookProxy::ResetData() |
|
700 { |
|
701 PRINT( _L( "Start CCmsPhonebookProxy::ResetData()" ) ); |
|
702 if( iOperation ) |
|
703 { |
|
704 delete iOperation; |
|
705 iOperation = NULL; |
|
706 } |
|
707 PRINT( _L( "End CCmsPhonebookProxy::ResetData()" ) ); |
|
708 } |
|
709 |
|
710 // ---------------------------------------------------------- |
|
711 // CCmsPhonebookProxy::VPbkSingleContactOperationComplete |
|
712 // |
|
713 // ---------------------------------------------------------- |
|
714 // |
|
715 void CCmsPhonebookProxy::VPbkSingleContactOperationComplete( |
|
716 MVPbkContactOperationBase& /*aOperation*/, |
|
717 MVPbkStoreContact* aContact ) |
|
718 { |
|
719 PRINT( _L( "Start CCmsPhonebookProxy::VPbkSingleContactOperationComplete()" ) ); |
|
720 |
|
721 ResetData(); |
|
722 CompleteContactRequestL( KErrNone, aContact ); |
|
723 iCmsPhonebookOperationsObserver.CmsSingleContactOperationComplete( KErrNone ); |
|
724 |
|
725 PRINT( _L( "End CCmsPhonebookProxy::VPbkSingleContactOperationComplete()" ) ); |
|
726 } |
|
727 |
|
728 // ---------------------------------------------------------- |
|
729 // CCmsPhonebookProxy::~CCmsPhonebookProxy |
|
730 // |
|
731 // ---------------------------------------------------------- |
|
732 // |
|
733 void CCmsPhonebookProxy::VPbkSingleContactOperationFailed( |
|
734 MVPbkContactOperationBase& /*aOperation*/, |
|
735 TInt aError ) |
|
736 { |
|
737 PRINT1( _L( "CCmsPhonebookProxy::VPbkSingleContactOperationFailed(): Error: %d" ), aError ); |
|
738 |
|
739 ResetData(); |
|
740 CompleteContactRequestL( aError, NULL ); |
|
741 iCmsPhonebookOperationsObserver.CmsSingleContactOperationComplete( aError ); |
|
742 } |
|
743 |
|
744 |
|
745 // ---------------------------------------------------------- |
|
746 // CCmsPhonebookProxy::IsXspContact |
|
747 // |
|
748 // ---------------------------------------------------------- |
|
749 // |
|
750 TBool CCmsPhonebookProxy::IsXspContact( const MVPbkContactLink& aContactLink ) const |
|
751 { |
|
752 //find whether the contact belongs to XSP Store using the StoreProperties |
|
753 TBool xspContact = ETrue; |
|
754 const TDesC& storeName = aContactLink.ContactStore().StoreProperties().Uri().UriDes(); |
|
755 |
|
756 using namespace VPbkContactStoreUris; |
|
757 if( ( storeName.CompareF( DefaultCntDbUri() ) == 0 ) || |
|
758 ( storeName.CompareF( SimGlobalAdnUri() ) == 0 ) || |
|
759 ( storeName.CompareF( SimGlobalFdnUri() ) == 0 ) || |
|
760 ( storeName.CompareF( SimGlobalSdnUri() ) == 0 ) ) |
|
761 { |
|
762 xspContact = EFalse; |
|
763 } |
|
764 |
|
765 return xspContact; |
|
766 } |
|
767 |
|
768 |
|
769 // End of File |