|
1 /* |
|
2 * Copyright (c) 2010 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: Easy dialing contact data manager. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <e32std.h> |
|
19 #include <fbs.h> |
|
20 #include <CPbk2ImageManager.h> |
|
21 #include <CVPbkContactManager.h> |
|
22 #include <MVPbkContactStoreList.h> |
|
23 #include <MVPbkContactLink.h> |
|
24 #include <VPbkContactStoreUris.h> |
|
25 #include <TVPbkContactStoreUriPtr.h> |
|
26 #include <CVPbkTopContactManager.h> |
|
27 #include <MVPbkContactOperationBase.h> |
|
28 #include <TVPbkStoreContactAnalyzer.h> |
|
29 #include <MVPbkFieldType.h> |
|
30 #include <VPbkEng.rsg> |
|
31 |
|
32 #include <MVPbkContactViewBase.h> |
|
33 #include <MVPbkBaseContactFieldCollection.h> |
|
34 #include <MVPbkContactFieldTextData.h> |
|
35 #include <MVPbkContactFieldData.h> |
|
36 |
|
37 #include <CVPbkContactLinkArray.h> |
|
38 #include <MVPbkContactLink.h> |
|
39 #include <MVPbkContactOperationBase.h> |
|
40 #include <MVPbkOperationObserver.h> |
|
41 #include <MVPbkContactStore.h> // MVPbkContactStore |
|
42 #include <MVPbkStoreContact.h> |
|
43 #include <centralrepository.h> |
|
44 |
|
45 #include "easydialingcontactdata.h" |
|
46 #include "easydialingcontactdatamanager.h" |
|
47 #include "easydialingutils.h" |
|
48 #include "mcontactdatamanagerobserver.h" |
|
49 #include "easydialingcrkeys.h" |
|
50 #include "easydialinglogger.h" |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // CEasyDialingContactDataManager::CEasyDialingContactDataManager |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 CEasyDialingContactDataManager::CEasyDialingContactDataManager(CVPbkContactManager* aContactManager) |
|
57 : iImageOperation(NULL), iContactManager(aContactManager), iContactOperation(NULL), |
|
58 iContactThumbnailSetting(ETrue), iStoreReady(EFalse) |
|
59 { |
|
60 } |
|
61 |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // CEasyDialingContactDataManager::~CEasyDialingContactDataManager |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 CEasyDialingContactDataManager::~CEasyDialingContactDataManager() |
|
68 { |
|
69 Reset(); |
|
70 iWaitingContacts.Close(); |
|
71 iContactDataArray.Close(); |
|
72 delete iImageManager; |
|
73 delete iVPbkTopContactManager; |
|
74 delete iImageOperation; |
|
75 delete iContactOperation; |
|
76 delete iFavsView; |
|
77 if (iContactStore) |
|
78 { |
|
79 iContactStore->Close( *this); |
|
80 } |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // CEasyDialingContactDataManager::ConstructL |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 void CEasyDialingContactDataManager::ConstructL() |
|
88 { |
|
89 iImageManager = CPbk2ImageManager::NewL(*iContactManager); |
|
90 |
|
91 TVPbkContactStoreUriPtr uri( VPbkContactStoreUris::DefaultCntDbUri() ); |
|
92 iContactStore = iContactManager->ContactStoresL().Find( uri ); |
|
93 |
|
94 iVPbkTopContactManager = CVPbkTopContactManager::NewL( *iContactManager ); |
|
95 |
|
96 iImageManagerParams.iFlags = TPbk2ImageManagerParams::EScaleImage | TPbk2ImageManagerParams::EKeepAspectRatio; |
|
97 iThumbnailFieldType = iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_THUMBNAILPIC ); |
|
98 |
|
99 // Open the store |
|
100 iContactStore->OpenL( *this ); |
|
101 |
|
102 // Read easydialing setting from cenrep. |
|
103 CRepository* cenrep = CRepository::NewL( KCRUidEasyDialSettings ); |
|
104 CleanupStack::PushL( cenrep ); |
|
105 User::LeaveIfError( cenrep->Get( KEasyDialingContactThumbnails, iContactThumbnailSetting ) ); |
|
106 CleanupStack::PopAndDestroy( cenrep ); |
|
107 } |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // CEasyDialingContactDataManager::SetObserver |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 void CEasyDialingContactDataManager::SetObserver(MContactDataManagerObserver* aObserver) |
|
114 { |
|
115 iObserver = aObserver; |
|
116 } |
|
117 |
|
118 // --------------------------------------------------------------------------- |
|
119 // CEasyDialingContactDataManager::SetThumbnailSize |
|
120 // --------------------------------------------------------------------------- |
|
121 // |
|
122 void CEasyDialingContactDataManager::SetThumbnailSize(const TSize& aSize) |
|
123 { |
|
124 if (iImageManagerParams.iSize != aSize) |
|
125 { |
|
126 iImageManagerParams.iSize = aSize; |
|
127 Reload(); |
|
128 } |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------------------------- |
|
132 // CEasyDialingContactDataManager::GetThumbnailIdL |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 HBufC* CEasyDialingContactDataManager::GetThumbnailIdL( |
|
136 MVPbkContactLink* aContact, TBool aMatchThumbnails, TBool aFav ) |
|
137 { |
|
138 LOGSTRING("CEasyDialingContactDataManager: GetThumbnailIdL"); |
|
139 TInt newIndex(KErrNotFound); |
|
140 if (aMatchThumbnails) |
|
141 { |
|
142 newIndex = FindContactIndex( aContact ); |
|
143 } |
|
144 |
|
145 LOGSTRING1("newIndex = %d", newIndex); |
|
146 if (newIndex == KErrNotFound) |
|
147 { |
|
148 MVPbkContactLink* newLink = aContact->CloneLC(); |
|
149 CEasyDialingContactData *newThumbnail = new (ELeave) CEasyDialingContactData(newLink); |
|
150 CleanupStack::Pop(); // newLink |
|
151 newIndex = iContactDataArray.Count(); |
|
152 CleanupStack::PushL(newThumbnail); |
|
153 iContactDataArray.AppendL(newThumbnail); |
|
154 CleanupStack::Pop(newThumbnail); |
|
155 } |
|
156 |
|
157 iContactDataArray[ newIndex ]->SetFav( aFav ); |
|
158 |
|
159 HBufC* id = HBufC::NewL( sizeof(TInt) * 2 ); // space for hex representation of TInt |
|
160 TPtr ptr = id->Des(); |
|
161 ptr.Num(newIndex, EHex); |
|
162 LOGSTRING1("CEasyDialingContactDataManager: GetThumbnailIdL returns %S", id); |
|
163 return id; |
|
164 } |
|
165 |
|
166 // --------------------------------------------------------------------------- |
|
167 // CEasyDialingContactDataManager::GetThumbnail |
|
168 // --------------------------------------------------------------------------- |
|
169 // |
|
170 TBool CEasyDialingContactDataManager::GetThumbnailAndFav(const TDesC& aId, CFbsBitmap*& aThumbnail, TBool& aFav) |
|
171 { |
|
172 LOGSTRING("CEasyDialingContactDataManager: GetThumbnailAndFav"); |
|
173 TUint idVal(0); |
|
174 TLex lex(aId); |
|
175 lex.Val(idVal, EHex); |
|
176 |
|
177 TBool retVal; |
|
178 |
|
179 CEasyDialingContactData* thumbnail = iContactDataArray[idVal]; |
|
180 aFav = thumbnail->Fav(); |
|
181 if (thumbnail->IsLoaded()) |
|
182 { |
|
183 aThumbnail = thumbnail->Thumbnail(); |
|
184 retVal = ETrue; |
|
185 } |
|
186 else |
|
187 { |
|
188 aThumbnail = NULL; |
|
189 retVal = EFalse; |
|
190 if (iWaitingContacts.Find(idVal) == KErrNotFound) |
|
191 { |
|
192 LOGSTRING1("iWaitingContacts.Append %d", idVal); |
|
193 iWaitingContacts.Append(idVal); |
|
194 TRAPD(err, LoadNextContactDataL()); |
|
195 if (err) |
|
196 { |
|
197 HandleError(err); |
|
198 } |
|
199 } |
|
200 } |
|
201 LOGSTRING("CEasyDialingContactDataManager: GetThumbnailAndFav Exit"); |
|
202 return retVal; |
|
203 } |
|
204 |
|
205 // --------------------------------------------------------------------------- |
|
206 // CEasyDialingContactDataManager::IsFavL |
|
207 // --------------------------------------------------------------------------- |
|
208 // |
|
209 TBool CEasyDialingContactDataManager::IsFavL( MVPbkContactLink* aLink ) |
|
210 { |
|
211 if ( iFavsView && iFavsView->IndexOfLinkL( *aLink ) > KErrNotFound ) |
|
212 { |
|
213 return ETrue; |
|
214 } |
|
215 else |
|
216 { |
|
217 return EFalse; |
|
218 } |
|
219 } |
|
220 |
|
221 // --------------------------------------------------------------------------- |
|
222 // CEasyDialingContactDataManager::NumberOfFavsL |
|
223 // --------------------------------------------------------------------------- |
|
224 // |
|
225 TInt CEasyDialingContactDataManager::NumberOfFavsL() |
|
226 { |
|
227 if ( iFavsView ) |
|
228 { |
|
229 return iFavsView->ContactCountL(); |
|
230 } |
|
231 else |
|
232 { |
|
233 return 0; |
|
234 } |
|
235 } |
|
236 |
|
237 // --------------------------------------------------------------------------- |
|
238 // CEasyDialingContactDataManager::FavLinkLC |
|
239 // --------------------------------------------------------------------------- |
|
240 // |
|
241 MVPbkContactLink* CEasyDialingContactDataManager::FavLinkLC( TInt aIndex ) |
|
242 { |
|
243 if ( iFavsView ) |
|
244 { |
|
245 return iFavsView->ContactAtL( aIndex ).CreateLinkLC(); |
|
246 } |
|
247 else |
|
248 { |
|
249 return NULL; |
|
250 } |
|
251 } |
|
252 |
|
253 // --------------------------------------------------------------------------- |
|
254 // CEasyDialingContactDataManager::FavContactStringLC |
|
255 // --------------------------------------------------------------------------- |
|
256 // |
|
257 HBufC* CEasyDialingContactDataManager::FavContactStringLC( TInt aIndex, CPbkContactEngine::TPbkNameOrder aNameOrder ) |
|
258 { |
|
259 const MVPbkBaseContactFieldCollection& fields = iFavsView->ContactAtL( aIndex ).Fields(); |
|
260 TPtrC firstName; |
|
261 TPtrC lastName; |
|
262 TPtrC companyName; |
|
263 for ( TInt i = 0; i < fields.FieldCount(); i++ ) |
|
264 { |
|
265 const MVPbkFieldType* fieldType = fields.FieldAt( i ).MatchFieldType( 0 ); |
|
266 switch ( fieldType->FieldTypeResId() ) |
|
267 { |
|
268 case R_VPBK_FIELD_TYPE_LASTNAME: |
|
269 { |
|
270 const MVPbkContactFieldTextData& data = |
|
271 MVPbkContactFieldTextData::Cast( fields.FieldAt( i ).FieldData() ); |
|
272 lastName.Set( data.Text() ); |
|
273 } |
|
274 break; |
|
275 case R_VPBK_FIELD_TYPE_FIRSTNAME: |
|
276 { |
|
277 const MVPbkContactFieldTextData& data = |
|
278 MVPbkContactFieldTextData::Cast( fields.FieldAt( i ).FieldData() ); |
|
279 firstName.Set( data.Text() ); |
|
280 } |
|
281 break; |
|
282 case R_VPBK_FIELD_TYPE_COMPANYNAME: |
|
283 { |
|
284 const MVPbkContactFieldTextData& data = |
|
285 MVPbkContactFieldTextData::Cast( fields.FieldAt( i ).FieldData() ); |
|
286 companyName.Set( data.Text() ); |
|
287 } |
|
288 break; |
|
289 default: |
|
290 break; |
|
291 } |
|
292 } |
|
293 |
|
294 return EasyDialingUtils::CreateContactStringLC( firstName, lastName, companyName, aNameOrder ); |
|
295 } |
|
296 |
|
297 // --------------------------------------------------------------------------- |
|
298 // CEasyDialingContactDataManager::InitReady |
|
299 // --------------------------------------------------------------------------- |
|
300 // |
|
301 void CEasyDialingContactDataManager::InitReady() |
|
302 { |
|
303 // Initialization is ready. we can start loading contact data, if needed. |
|
304 // (It is unlikely that there is any data to load at this point) |
|
305 iStoreReady = ETrue; |
|
306 if ( iWaitingContacts.Count() ) |
|
307 { |
|
308 TRAPD( err, LoadNextContactDataL() ) |
|
309 if ( err ) |
|
310 { |
|
311 HandleError( err ); |
|
312 } |
|
313 } |
|
314 } |
|
315 |
|
316 // --------------------------------------------------------------------------- |
|
317 // CEasyDialingContactDataManager::FindContactIndex |
|
318 // --------------------------------------------------------------------------- |
|
319 // |
|
320 TInt CEasyDialingContactDataManager::FindContactIndex( MVPbkContactLink* aContact ) |
|
321 { |
|
322 TInt index( KErrNotFound ); |
|
323 |
|
324 for ( TInt i = 0; i < iContactDataArray.Count(); i++ ) |
|
325 { |
|
326 if ( iContactDataArray[i]->ContactLink()->IsSame( *aContact ) ) |
|
327 { |
|
328 index = i; |
|
329 break; |
|
330 } |
|
331 } |
|
332 |
|
333 return index; |
|
334 } |
|
335 |
|
336 |
|
337 // --------------------------------------------------------------------------- |
|
338 // CEasyDialingContactDataManager::LoadNextContactDataL |
|
339 // --------------------------------------------------------------------------- |
|
340 // |
|
341 void CEasyDialingContactDataManager::LoadNextContactDataL() |
|
342 { |
|
343 LOGSTRING("CEasyDialingContactDataManager: LoadNextContactDataL"); |
|
344 if (!iImageOperation && !iContactOperation && iWaitingContacts.Count() && iStoreReady) |
|
345 { |
|
346 // first we need to load the contact item |
|
347 CEasyDialingContactData* tn = iContactDataArray[iWaitingContacts[0]]; |
|
348 iContactOperation = iContactManager->RetrieveContactL( *(tn->ContactLink()), *this); |
|
349 |
|
350 if (!iContactOperation) |
|
351 { |
|
352 tn->LoadingComplete(); |
|
353 RDebug::Print(_L("iWaitingContacts.Remove %d"), iWaitingContacts[0]); |
|
354 iWaitingContacts.Remove(0); |
|
355 LoadNextContactDataL(); |
|
356 } |
|
357 } |
|
358 LOGSTRING("CEasyDialingContactDataManager: LoadNextContactDataL Exit"); |
|
359 } |
|
360 |
|
361 // --------------------------------------------------------------------------- |
|
362 // CEasyDialingContactDataManager::PbkImageGetComplete |
|
363 // From MPbkImageGetObserver |
|
364 // --------------------------------------------------------------------------- |
|
365 // |
|
366 void CEasyDialingContactDataManager::Pbk2ImageGetComplete(MPbk2ImageOperation& aOperation, CFbsBitmap* aBitmap) |
|
367 { |
|
368 LOGSTRING("CEasyDialingContactDataManager: Pbk2ImageGetComplete"); |
|
369 TInt index = iWaitingContacts[0]; |
|
370 LOGSTRING1("iWaitingContacts.Remove %d", iWaitingContacts[0]); |
|
371 iWaitingContacts.Remove(0); |
|
372 delete &aOperation; |
|
373 iImageOperation = NULL; |
|
374 delete iStoreContact; |
|
375 iStoreContact = NULL; |
|
376 |
|
377 TRAPD(err, DoHandleImageGetCompleteL(aBitmap, index)); |
|
378 if (err) |
|
379 { |
|
380 HandleError(err); |
|
381 } |
|
382 LOGSTRING("CEasyDialingContactDataManager: Pbk2ImageGetComplete Exit"); |
|
383 } |
|
384 |
|
385 // --------------------------------------------------------------------------- |
|
386 // CEasyDialingContactDataManager::PbkImageGetFailed |
|
387 // From MPbkImageGetObserver |
|
388 // --------------------------------------------------------------------------- |
|
389 // |
|
390 void CEasyDialingContactDataManager::Pbk2ImageGetFailed(MPbk2ImageOperation& aOperation, TInt /*aError*/) |
|
391 { |
|
392 LOGSTRING("CEasyDialingContactDataManager: Pbk2ImageGetFailed"); |
|
393 Pbk2ImageGetComplete(aOperation, NULL); |
|
394 } |
|
395 |
|
396 // --------------------------------------------------------------------------- |
|
397 // CEasyDialingContactDataManager::DoHandleImageGetCompleteL |
|
398 // --------------------------------------------------------------------------- |
|
399 // |
|
400 void CEasyDialingContactDataManager::DoHandleImageGetCompleteL(CFbsBitmap* aBitmap, TInt aIndex) |
|
401 { |
|
402 LOGSTRING("CEasyDialingContactDataManager: DoHandleImageGetCompleteL"); |
|
403 CEasyDialingContactData *tn = iContactDataArray[aIndex]; |
|
404 tn->LoadingComplete(); |
|
405 if (aBitmap) |
|
406 { |
|
407 tn->SetThumbnail(aBitmap); |
|
408 } |
|
409 |
|
410 LoadNextContactDataL(); |
|
411 InformObserver(); |
|
412 LOGSTRING("CEasyDialingContactDataManager: DoHandleImageGetCompleteL Exit"); |
|
413 } |
|
414 |
|
415 // --------------------------------------------------------------------------- |
|
416 // CEasyDialingContactDataManager::Reset |
|
417 // --------------------------------------------------------------------------- |
|
418 // |
|
419 void CEasyDialingContactDataManager::Reset() |
|
420 { |
|
421 LOGSTRING("CEasyDialingContactDataManager: Reset"); |
|
422 delete iImageOperation; |
|
423 iImageOperation = NULL; |
|
424 delete iContactOperation; |
|
425 iContactOperation = NULL; |
|
426 delete iStoreContact; |
|
427 iStoreContact = NULL; |
|
428 iWaitingContacts.Reset(); |
|
429 iContactDataArray.ResetAndDestroy(); |
|
430 } |
|
431 |
|
432 // --------------------------------------------------------------------------- |
|
433 // CEasyDialingContactDataManager::VoiceCallAvailable |
|
434 // --------------------------------------------------------------------------- |
|
435 // |
|
436 TBool CEasyDialingContactDataManager::VoiceCallAvailable( TInt aIndex ) |
|
437 { |
|
438 LOGSTRING("CEasyDialingContactDataManager: VoiceCallAvailable"); |
|
439 |
|
440 TBool ret( EFalse ); |
|
441 |
|
442 if( aIndex >= 0 ) |
|
443 { |
|
444 // If the parsed index is valid, return the availability. |
|
445 ret = iContactDataArray[ aIndex ]->VoiceCallAvailable(); |
|
446 } |
|
447 |
|
448 LOGSTRING1("CEasyDialingContactDataManager: VoiceCallAvailable returns %d", ret); |
|
449 return ret; |
|
450 } |
|
451 |
|
452 |
|
453 // --------------------------------------------------------------------------- |
|
454 // CEasyDialingContactDataManager::VideoCallAvailable |
|
455 // --------------------------------------------------------------------------- |
|
456 // |
|
457 TBool CEasyDialingContactDataManager::VideoCallAvailable( TInt aIndex ) |
|
458 { |
|
459 LOGSTRING("CEasyDialingContactDataManager: VideoCallAvailable"); |
|
460 |
|
461 TBool ret( EFalse ); |
|
462 |
|
463 if( aIndex >= 0 ) |
|
464 { |
|
465 // If the parsed index is valid, return the availability. |
|
466 ret = iContactDataArray[ aIndex ]->VideoCallAvailable(); |
|
467 } |
|
468 |
|
469 LOGSTRING1("CEasyDialingContactDataManager: VideoCallAvailable returns %d", ret); |
|
470 return ret; |
|
471 } |
|
472 |
|
473 |
|
474 // --------------------------------------------------------------------------- |
|
475 // CEasyDialingContactDataManager::UniEditorAvailable |
|
476 // --------------------------------------------------------------------------- |
|
477 // |
|
478 TBool CEasyDialingContactDataManager::UniEditorAvailable( TInt aIndex ) |
|
479 { |
|
480 LOGSTRING("CEasyDialingContactDataManager: UniEditorAvailable"); |
|
481 |
|
482 TBool ret( EFalse ); |
|
483 |
|
484 if( aIndex >= 0 ) |
|
485 { |
|
486 // If the parsed index is valid, return the availability. |
|
487 ret = iContactDataArray[ aIndex ]->UniEditorAvailable(); |
|
488 } |
|
489 |
|
490 LOGSTRING1("CEasyDialingContactDataManager: UniEditorAvailable returns %d", ret); |
|
491 return ret; |
|
492 } |
|
493 |
|
494 |
|
495 // --------------------------------------------------------------------------- |
|
496 // CEasyDialingContactDataManager::ContactLinkLC |
|
497 // --------------------------------------------------------------------------- |
|
498 // |
|
499 HBufC8* CEasyDialingContactDataManager::ContactLinkLC( TInt aIndex ) |
|
500 { |
|
501 LOGSTRING( "CEasyDialingContactDataManager: ContactLinkLC" ); |
|
502 |
|
503 if( aIndex >= 0 ) |
|
504 { |
|
505 // If the parsed index is valid, return the availability. |
|
506 return iContactDataArray[ aIndex ]->ContactLink()->PackLC(); |
|
507 } |
|
508 else |
|
509 { |
|
510 return NULL; |
|
511 } |
|
512 } |
|
513 |
|
514 |
|
515 // --------------------------------------------------------------------------- |
|
516 // CEasyDialingContactDataManager::HandleError |
|
517 // --------------------------------------------------------------------------- |
|
518 // |
|
519 void CEasyDialingContactDataManager::HandleError(TInt /*aError*/) |
|
520 { |
|
521 LOGSTRING("CEasyDialingContactDataManager: HandleError"); |
|
522 // Something went wrong, but there is no need to panic. |
|
523 // Cancel async operations and notify observer that we are done. |
|
524 iWaitingContacts.Reset(); |
|
525 delete iImageOperation; |
|
526 iImageOperation = NULL; |
|
527 delete iContactOperation; |
|
528 iContactOperation = NULL; |
|
529 if (iObserver) |
|
530 { |
|
531 iObserver->AllContactDataLoaded(); |
|
532 } |
|
533 } |
|
534 |
|
535 // --------------------------------------------------------------------------- |
|
536 // CEasyDialingContactDataManager::StoreReady |
|
537 // from MVPbkContactStoreObserver |
|
538 // Called when the contact store is ready to be used, signals |
|
539 // the next engine state. |
|
540 // @param aContactStore The store that is ready. |
|
541 // --------------------------------------------------------------------------- |
|
542 // |
|
543 |
|
544 void CEasyDialingContactDataManager::StoreReady( MVPbkContactStore& /*aContactStore*/ ) |
|
545 { |
|
546 // next open the favourites view |
|
547 TRAPD( err, iVPbkTopContactManager->GetTopContactsViewL( *this, *this ) ); |
|
548 if ( err ) |
|
549 { |
|
550 HandleError( err ); |
|
551 } |
|
552 } |
|
553 |
|
554 // --------------------------------------------------------------------------- |
|
555 // CEasyDialingContactDataManager::StoreUnavailable |
|
556 // from MVPbkContactStoreObserver |
|
557 // Called when a contact store becomes unavailable. |
|
558 // @param aContactStore The store that became unavailable. |
|
559 // @param aReason The reason why the store is unavailable. |
|
560 // This is one of the system wide error codes. |
|
561 // --------------------------------------------------------------------------- |
|
562 // |
|
563 void CEasyDialingContactDataManager::StoreUnavailable( MVPbkContactStore& /*aContactStore*/, |
|
564 TInt /*aReason*/ ) |
|
565 { |
|
566 // Opening main contact database failed. Easydialing can operate without |
|
567 // it, but thumbnails and favourite stars can't be shown, and availability |
|
568 // of action menu items can't be checked. |
|
569 // Of course, if easydialing can't open the database, probably PCSServer |
|
570 // can't open it either... |
|
571 } |
|
572 |
|
573 // --------------------------------------------------------------------------- |
|
574 // CEasyDialingContactDataManager::HandleStoreEventL |
|
575 // from MVPbkContactStoreObserver |
|
576 // Called when changes occur in the contact store. |
|
577 // IGNORED. |
|
578 // @param aContactStore A store whose event it is. |
|
579 // @param aStoreEvent The event that has occurred. |
|
580 // --------------------------------------------------------------------------- |
|
581 // |
|
582 void CEasyDialingContactDataManager::HandleStoreEventL(MVPbkContactStore& /*aContactStore*/, |
|
583 TVPbkContactStoreEvent /*aStoreEvent*/) |
|
584 { |
|
585 } |
|
586 |
|
587 // --------------------------------------------------------------------------- |
|
588 // CEasyDialingContactDataManager::VPbkOperationFailed |
|
589 // --------------------------------------------------------------------------- |
|
590 // |
|
591 void CEasyDialingContactDataManager::VPbkOperationFailed( |
|
592 MVPbkContactOperationBase* /*aOperation*/, |
|
593 TInt /*aError*/ ) |
|
594 { |
|
595 // Loading list of favourite contacts failed. |
|
596 // Continue as if none of the contacts are favourited. |
|
597 delete iFavsOperation; |
|
598 iFavsOperation = NULL; |
|
599 delete iFavsView; |
|
600 iFavsView = NULL; |
|
601 |
|
602 InitReady(); |
|
603 } |
|
604 |
|
605 // --------------------------------------------------------------------------- |
|
606 // CEasyDialingContactDataManager::VPbkOperationResultCompleted |
|
607 // --------------------------------------------------------------------------- |
|
608 // |
|
609 void CEasyDialingContactDataManager::VPbkOperationResultCompleted( |
|
610 MVPbkContactOperationBase* /*aOperation*/, |
|
611 MVPbkContactViewBase* aOperationResult ) |
|
612 { |
|
613 delete iFavsOperation; |
|
614 iFavsOperation = NULL; |
|
615 delete iFavsView; |
|
616 iFavsView = aOperationResult; |
|
617 |
|
618 InitReady(); |
|
619 } |
|
620 |
|
621 // --------------------------------------------------------------------------- |
|
622 // CEasyDialingContactDataManager::DoHandleContactOperationCompleteL |
|
623 // --------------------------------------------------------------------------- |
|
624 // |
|
625 void CEasyDialingContactDataManager::DoHandleContactOperationCompleteL( |
|
626 MVPbkStoreContact* aContact, TInt aIndex) |
|
627 { |
|
628 LOGSTRING("CEasyDialingContactDataManager: DoHandleContactOperationCompleteL"); |
|
629 if (aContact) |
|
630 { |
|
631 |
|
632 __ASSERT_DEBUG((!iStoreContact && !iImageOperation), User::Panic(_L("CEasyDialingContactDataManager"), 1)); |
|
633 iStoreContact = aContact; |
|
634 |
|
635 // Find out the available communication methods for the contact. |
|
636 GetAvailableServicesL( aContact, aIndex ); |
|
637 |
|
638 |
|
639 // Next initiate async thumbnail get operation. |
|
640 |
|
641 if(GetContactThumbnailSetting()) // reads the iContactThumbnailSetting value if it is false we dont fetch images |
|
642 { |
|
643 if (iImageManager->HasImage(*iStoreContact, *iThumbnailFieldType)) |
|
644 { |
|
645 iImageOperation = iImageManager->GetImageAsyncL( |
|
646 &iImageManagerParams, |
|
647 *iStoreContact, |
|
648 *iThumbnailFieldType, |
|
649 *this); |
|
650 } |
|
651 } |
|
652 if (!iImageOperation) |
|
653 { |
|
654 CEasyDialingContactData *tn = iContactDataArray[aIndex]; |
|
655 tn->LoadingComplete(); |
|
656 LOGSTRING1("iWaitingContacts.Remove %d", iWaitingContacts[0]); |
|
657 iWaitingContacts.Remove(0); |
|
658 delete iStoreContact; |
|
659 iStoreContact = NULL; |
|
660 LoadNextContactDataL(); |
|
661 InformObserver(); |
|
662 } |
|
663 } |
|
664 else |
|
665 { |
|
666 // Protective coding. If aContact is NULL, act like opening the contact link failed. |
|
667 CEasyDialingContactData *tn = iContactDataArray[aIndex]; |
|
668 tn->LoadingComplete(); |
|
669 LOGSTRING1("iWaitingContacts.Remove %d", iWaitingContacts[0]); |
|
670 iWaitingContacts.Remove(0); |
|
671 LoadNextContactDataL(); |
|
672 InformObserver(); |
|
673 } |
|
674 LOGSTRING("CEasyDialingContactDataManager: DoHandleContactOperationCompleteL Exit"); |
|
675 } |
|
676 |
|
677 |
|
678 // --------------------------------------------------------------------------- |
|
679 // CEasyDialingContactDataManager::GetAvailableServicesL |
|
680 // |
|
681 // Reads from parameter contact which services, i.e. communication methods, |
|
682 // can be used with this contact. |
|
683 // --------------------------------------------------------------------------- |
|
684 // |
|
685 void CEasyDialingContactDataManager::GetAvailableServicesL( MVPbkStoreContact* aContact, TInt aIndex ) |
|
686 { |
|
687 LOGSTRING1("CEasyDialingContactDataManager: GetAvailableServicesL index = %d", aIndex); |
|
688 TVPbkStoreContactAnalyzer analyzer( *iContactManager, aContact ); |
|
689 |
|
690 CEasyDialingContactData* contactData = iContactDataArray[aIndex]; |
|
691 |
|
692 // Voice call is available if either circuit-switched call or voip call is available. |
|
693 TBool csdCall = (analyzer.HasFieldL( VPbkFieldTypeSelectorFactory::EVoiceCallSelector ) != KErrNotFound); |
|
694 TBool voipCall = (analyzer.HasFieldL( VPbkFieldTypeSelectorFactory::EVOIPCallSelector ) != KErrNotFound); |
|
695 |
|
696 contactData->SetVoiceCallAvailable( csdCall || voipCall ); |
|
697 |
|
698 contactData->SetVideoCallAvailable( |
|
699 analyzer.HasFieldL( VPbkFieldTypeSelectorFactory::EVideoCallSelector ) != KErrNotFound ); |
|
700 |
|
701 contactData->SetUniEditorAvailable( |
|
702 analyzer.HasFieldL( VPbkFieldTypeSelectorFactory::EUniEditorSelector ) != KErrNotFound ); |
|
703 |
|
704 LOGSTRING("CEasyDialingContactDataManager: GetAvailableServicesL Exit"); |
|
705 } |
|
706 |
|
707 |
|
708 // --------------------------------------------------------------------------- |
|
709 // CEasyDialingContactDataManager::VPbkSingleContactOperationComplete |
|
710 // --------------------------------------------------------------------------- |
|
711 // |
|
712 void CEasyDialingContactDataManager::VPbkSingleContactOperationComplete( |
|
713 MVPbkContactOperationBase& aOperation, |
|
714 MVPbkStoreContact* aContact ) |
|
715 { |
|
716 LOGSTRING("CEasyDialingContactDataManager: VPbkSingleContactOperationComplete"); |
|
717 delete &aOperation; |
|
718 iContactOperation = NULL; |
|
719 TInt index = iWaitingContacts[0]; |
|
720 LOGSTRING1("VPbkSingleContactOperationComplete, Index=%d", index); |
|
721 TRAPD(err, DoHandleContactOperationCompleteL(aContact, index)); |
|
722 if (err) |
|
723 { |
|
724 HandleError(err); |
|
725 } |
|
726 LOGSTRING("CEasyDialingContactDataManager: VPbkSingleContactOperationComplete Exit"); |
|
727 } |
|
728 |
|
729 // --------------------------------------------------------------------------- |
|
730 // CEasyDialingContactDataManager::VPbkSingleContactOperationFailed |
|
731 // --------------------------------------------------------------------------- |
|
732 // |
|
733 void CEasyDialingContactDataManager::VPbkSingleContactOperationFailed( |
|
734 MVPbkContactOperationBase& /*aOperation*/, |
|
735 TInt aError ) |
|
736 { |
|
737 LOGSTRING("CEasyDialingContactDataManager: VPbkSingleContactOperationFailed"); |
|
738 delete iContactOperation; |
|
739 iContactOperation = NULL; |
|
740 HandleError(aError); |
|
741 LOGSTRING("CEasyDialingContactDataManager: VPbkSingleContactOperationFailed Exit"); |
|
742 } |
|
743 |
|
744 // --------------------------------------------------------------------------- |
|
745 // CEasyDialingContactDataManager::InformObserver |
|
746 // --------------------------------------------------------------------------- |
|
747 // |
|
748 void CEasyDialingContactDataManager::InformObserver() |
|
749 { |
|
750 if (iObserver && !iWaitingContacts.Count()) |
|
751 { |
|
752 iObserver->AllContactDataLoaded(); |
|
753 } |
|
754 } |
|
755 |
|
756 // --------------------------------------------------------------------------- |
|
757 // CEasyDialingContactDataManager::SetContactThumbnailSetting |
|
758 // --------------------------------------------------------------------------- |
|
759 // |
|
760 void CEasyDialingContactDataManager::SetContactThumbnailSetting( TInt aContactThumbnailSetting ) |
|
761 { |
|
762 iContactThumbnailSetting = aContactThumbnailSetting; |
|
763 } |
|
764 |
|
765 // --------------------------------------------------------------------------- |
|
766 // CEasyDialingContactDataManager::GetContactThumbnailSetting |
|
767 // --------------------------------------------------------------------------- |
|
768 // |
|
769 TBool CEasyDialingContactDataManager::GetContactThumbnailSetting( ) |
|
770 { |
|
771 return iContactThumbnailSetting; |
|
772 } |
|
773 |
|
774 // --------------------------------------------------------------------------- |
|
775 // CEasyDialingContactDataManager::Reload |
|
776 // --------------------------------------------------------------------------- |
|
777 // |
|
778 void CEasyDialingContactDataManager::Reload( ) |
|
779 { |
|
780 LOGSTRING("CEasyDialingContactDataManager: Reload"); |
|
781 for ( TInt i = 0 ; i < iContactDataArray.Count() ; i++ ) |
|
782 { |
|
783 iContactDataArray[ i ]->DeleteThumbnail(); |
|
784 } |
|
785 } |
|
786 |
|
787 // TODO: open item: sorting of favourites |
|
788 |
|
789 // End of File |
|
790 |