207 // C++ default constructor can NOT contain any code, that might leave. |
217 // C++ default constructor can NOT contain any code, that might leave. |
208 // ----------------------------------------------------------------------------- |
218 // ----------------------------------------------------------------------------- |
209 // |
219 // |
210 CMyLocationsEngine::CMyLocationsEngine() : |
220 CMyLocationsEngine::CMyLocationsEngine() : |
211 CActive(EPriorityStandard), |
221 CActive(EPriorityStandard), |
212 iCalSession(NULL), iCalView(NULL), |
222 iCalSession(NULL), |
213 iContactsDb(NULL), iContactChangeNotifier(NULL), |
223 iCalView(NULL), |
|
224 iContactsDb(NULL), |
|
225 iContactChangeNotifier(NULL), |
214 iLandmarkDb(NULL), |
226 iLandmarkDb(NULL), |
215 iMapTileInterface(NULL), iMyLocationsDatabaseManager(NULL), |
227 iMapTileInterface(NULL), |
216 iMaptileDatabase(NULL), iAddressCompare(NULL), |
228 iMyLocationsDatabaseManager(NULL), |
|
229 iMaptileDatabase(NULL), |
217 iMyLocationThreeAMTimer(NULL), |
230 iMyLocationThreeAMTimer(NULL), |
218 iMaptileGeocoderPluginAvailable(EFalse),iCalenderNotification(NULL), |
231 iMaptileGeocoderPluginAvailable(EFalse), |
219 iContactManager(NULL) |
232 iCalenderNotification(NULL), |
|
233 iContactManager(NULL), |
|
234 iContactSubscriber(NULL), |
|
235 iCalendarSubscriber(NULL), |
|
236 iLastContactId( -1 ) , |
|
237 iLastCalendarId( 0 ) |
220 { |
238 { |
221 |
239 |
222 } |
240 } |
223 |
241 |
224 // ----------------------------------------------------------------------------- |
242 // ----------------------------------------------------------------------------- |
283 } |
315 } |
284 |
316 |
285 |
317 |
286 iCalenderNotification->CheckCalenderDbFileStructure( drive ); |
318 iCalenderNotification->CheckCalenderDbFileStructure( drive ); |
287 } |
319 } |
|
320 } |
|
321 // ----------------------------------------------------------------------------- |
|
322 // CMyLocationsEngine::GetChangeNoficationL() |
|
323 // To get callbacks through publisher from contact context |
|
324 // ----------------------------------------------------------------------------- |
|
325 // |
|
326 void CMyLocationsEngine::GetChangeNotificationL( TInt &aId, TInt& addressType, TInt& addressCount ) |
|
327 { |
|
328 __TRACE_CALLSTACK; |
|
329 |
|
330 iLastContactId = aId; |
|
331 |
|
332 TAppAddressInfo* addressInfo = new (ELeave) TAppAddressInfo; |
|
333 addressInfo->iUid = aId; |
|
334 addressInfo->iAddressType = addressType; |
|
335 //Memory will be freed when the queue is deleted |
|
336 if( iAddressInfo.Append(addressInfo) != KErrNone ) |
|
337 { |
|
338 delete addressInfo; |
|
339 } |
|
340 |
|
341 //Get all 3 adress |
|
342 if( addressCount > 1 && iAddressInfo.Count() < addressCount ) |
|
343 return; |
|
344 |
|
345 //If the requested id is already in queue, just return |
|
346 for( TInt index = 0 ; index < iMapTileRequestQueue.Count(); index++ ) |
|
347 { |
|
348 if( iLastContactId == iMapTileRequestQueue[index]->iUId ) |
|
349 { |
|
350 return; |
|
351 } |
|
352 } |
|
353 |
|
354 for( TInt index = 0; index < iAddressInfo.Count(); index++ ) |
|
355 { |
|
356 TUidSourceType type = static_cast<TUidSourceType>(iAddressInfo[index]->iAddressType ); |
|
357 |
|
358 //if type is contact |
|
359 if( type == ESourceContactsPref || type == ESourceContactsWork || |
|
360 type == ESourceContactsHome ) |
|
361 { |
|
362 QContact contactInfo = iContactManager->contact( iAddressInfo[index]->iUid ); |
|
363 |
|
364 CPosLandmark *contactAddressLm = NULL; |
|
365 |
|
366 TInt itemCount = 0; |
|
367 |
|
368 foreach ( QContactAddress address, contactInfo.details<QContactAddress>() ) |
|
369 { |
|
370 QStringList context = address.contexts(); |
|
371 if ( context.isEmpty() && type == ESourceContactsPref ) // no context |
|
372 { |
|
373 contactAddressLm = GetContactAddressDetailsLC( address ); |
|
374 itemCount++; |
|
375 break; |
|
376 } |
|
377 else if ( !context.isEmpty() && context.first() == QContactAddress::ContextHome && |
|
378 type == ESourceContactsHome ) |
|
379 { |
|
380 contactAddressLm = GetContactAddressDetailsLC( address ); |
|
381 itemCount++; |
|
382 break; |
|
383 } |
|
384 else if ( !context.isEmpty() && context.first() == QContactAddress::ContextWork && |
|
385 type == ESourceContactsWork ) |
|
386 { |
|
387 contactAddressLm = GetContactAddressDetailsLC( address ); |
|
388 itemCount++; |
|
389 break; |
|
390 } |
|
391 } |
|
392 |
|
393 //Update the entry with inprogress status |
|
394 TLookupItem lookupItem; |
|
395 lookupItem.iUid = iAddressInfo[index]->iUid; |
|
396 lookupItem.iSource = type; |
|
397 lookupItem.iFilePath.Zero(); |
|
398 lookupItem.iFetchingStatus = EMapTileFetchingInProgress; |
|
399 iMaptileDatabase->UpdateEntryL( lookupItem ); |
|
400 |
|
401 //Request for maptile fetching |
|
402 RequestMapTileImageL( *contactAddressLm, type, |
|
403 iAddressInfo[index]->iUid, EContactDbObserverEventContactChanged ); |
|
404 |
|
405 CleanupStack::PopAndDestroy( itemCount ); |
|
406 } |
|
407 } |
|
408 for( TInt index = 0; index < iAddressInfo.Count(); index++ ) |
|
409 { |
|
410 //free the allocated memory |
|
411 delete iAddressInfo[index]; |
|
412 iAddressInfo.Remove(index); |
|
413 iAddressInfo.Compress(); |
|
414 } |
|
415 |
|
416 iAddressInfo.Reset(); |
|
417 } |
|
418 |
|
419 // ----------------------------------------------------------------------------- |
|
420 // CMyLocationsEngine::SubscribeFromCalendarL() |
|
421 // To get callbacks through publisher from calendar context |
|
422 // ----------------------------------------------------------------------------- |
|
423 // |
|
424 void CMyLocationsEngine::SubscribeFromCalendarL(TInt aId) |
|
425 { |
|
426 __TRACE_CALLSTACK; |
|
427 iLastCalendarId = aId; |
|
428 for ( int index =0;iMapTileRequestQueue.Count()>index ;index++) |
|
429 { |
|
430 if( iLastCalendarId == iMapTileRequestQueue[index]->iUId ) |
|
431 { |
|
432 return; |
|
433 } |
|
434 } |
|
435 |
|
436 CCalEntry* calEntry = NULL; |
|
437 calEntry = iCalView->FetchL(aId); |
|
438 CleanupStack::PushL(calEntry); |
|
439 TPtrC address(calEntry->LocationL()); |
|
440 if( address.Length()>0 ) |
|
441 { |
|
442 TLookupItem lookupItem; |
|
443 lookupItem.iUid = aId; |
|
444 lookupItem.iSource = ESourceCalendar; |
|
445 lookupItem.iFilePath.Zero(); |
|
446 lookupItem.iFetchingStatus = EMapTileFetchingInProgress; |
|
447 iMaptileDatabase->UpdateEntryL( lookupItem ); |
|
448 RequestMapTileImageL( address, ESourceCalendar, aId , EChangeModify ); |
|
449 } |
|
450 CleanupStack::PopAndDestroy(calEntry); |
288 } |
451 } |
289 // ----------------------------------------------------------------------------- |
452 // ----------------------------------------------------------------------------- |
290 // CMyLocationsEngine::StartCalenderChangeNotifierL() |
453 // CMyLocationsEngine::StartCalenderChangeNotifierL() |
291 // Starts calender change notification method to get callbacks when entries are |
454 // Starts calender change notification method to get callbacks when entries are |
292 // added/modified/deleted in contacts |
455 // added/modified/deleted in contacts |
423 // ----------------------------------------------------------------------------- |
582 // ----------------------------------------------------------------------------- |
424 // |
583 // |
425 void CMyLocationsEngine::CalenderEntryAddedL(TCalChangeEntry aCalChangeEntry) |
584 void CMyLocationsEngine::CalenderEntryAddedL(TCalChangeEntry aCalChangeEntry) |
426 { |
585 { |
427 __TRACE_CALLSTACK; |
586 __TRACE_CALLSTACK; |
|
587 |
|
588 TUint32 entryId=0; |
|
589 entryId=aCalChangeEntry.iEntryId; |
|
590 //create entry in the data base and maintain a fetching state. |
|
591 TLookupItem lookupItem; |
|
592 lookupItem.iUid = entryId ; |
|
593 lookupItem.iSource = ESourceCalendar; |
|
594 lookupItem.iFilePath.Zero(); |
|
595 lookupItem.iFetchingStatus = EMapTileFetchingInProgress; |
|
596 TRAP_IGNORE( iMaptileDatabase->CreateEntryL(lookupItem) ); |
428 CCalEntry* calEntry = NULL; |
597 CCalEntry* calEntry = NULL; |
429 calEntry = iCalView->FetchL(aCalChangeEntry.iEntryId); |
598 calEntry = iCalView->FetchL( entryId ); |
|
599 CleanupStack::PushL(calEntry); |
|
600 TPtrC address(calEntry->LocationL()); |
|
601 if (address.Length() > 0) |
|
602 { |
|
603 RequestMapTileImageL( address, ESourceCalendar, entryId , EChangeAdd ); |
|
604 } |
|
605 CleanupStack::PopAndDestroy(calEntry); |
|
606 } |
|
607 |
|
608 // ----------------------------------------------------------------------------- |
|
609 // CMyLocationsEngine::CalenderEntryModifyL() |
|
610 // ----------------------------------------------------------------------------- |
|
611 // |
|
612 void CMyLocationsEngine::CalenderEntryModifyL(TCalChangeEntry aCalChangeEntry) |
|
613 { |
|
614 __TRACE_CALLSTACK; |
|
615 TUint32 entryId = 0; |
|
616 entryId = aCalChangeEntry.iEntryId; |
|
617 TLookupItem lookupItem; |
|
618 lookupItem.iSource = ESourceCalendar; |
|
619 lookupItem.iUid = entryId; |
|
620 CCalEntry* calEntry = NULL; |
|
621 calEntry = iCalView->FetchL(entryId); |
|
622 CleanupStack::PushL(calEntry); |
430 TPtrC address(calEntry->LocationL()); |
623 TPtrC address(calEntry->LocationL()); |
431 if(address.Length()>0) |
624 if (iMyLocationsDatabaseManager->CheckIfAddressChanged(address, entryId, |
432 { |
625 ESourceCalendar)) |
433 //create entry in the data base and maintain a fetching state. |
626 { |
434 TLookupItem lookupItem; |
|
435 lookupItem.iUid = aCalChangeEntry.iEntryId; |
|
436 lookupItem.iSource = ESourceCalendar; |
|
437 lookupItem.iFilePath.Zero(); |
627 lookupItem.iFilePath.Zero(); |
438 lookupItem.iFetchingStatus = EMapTileFetchingInProgress; |
628 lookupItem.iFetchingStatus = EMapTileFetchingInProgress; |
439 iMaptileDatabase->CreateEntryL(lookupItem); |
629 TRAP_IGNORE( iMaptileDatabase->ReSetEntryL(lookupItem) ); |
440 |
630 if (address.Length() > 0) |
441 RequestMapTileImageL(address,ESourceCalendar, aCalChangeEntry.iEntryId); |
631 { |
442 } |
632 RequestMapTileImageL(address, ESourceCalendar, entryId , EChangeModify); |
443 delete calEntry; |
633 } |
|
634 else |
|
635 { |
|
636 UpdateDatabaseL(NULL, entryId, ESourceCalendar, EEntryDeleted); |
|
637 } |
|
638 if ( lookupItem.iFilePath.Length() > 0 ) |
|
639 { |
|
640 iMaptileDatabase->DeleteMapTileL(lookupItem); |
|
641 } |
|
642 |
|
643 } |
|
644 CleanupStack::PopAndDestroy(calEntry); |
444 } |
645 } |
445 |
646 |
446 // ----------------------------------------------------------------------------- |
647 // ----------------------------------------------------------------------------- |
447 // CMyLocationsEngine::HandleDatabaseEventL() |
648 // CMyLocationsEngine::HandleDatabaseEventL() |
448 // Callback that provides information about the contact database change event. |
649 // Callback that provides information about the contact database change event. |
559 // If the contact is a modified one and it might already exist in |
759 // If the contact is a modified one and it might already exist in |
560 // mylocations db, so delete it |
760 // mylocations db, so delete it |
561 UpdateDatabaseL(NULL, |
761 UpdateDatabaseL(NULL, |
562 aEvent.iContactId, ESourceContactsPref, |
762 aEvent.iContactId, ESourceContactsPref, |
563 EEntryDeleted); |
763 EEntryDeleted); |
|
764 |
|
765 UpdateDatabaseL(NULL, |
|
766 aEvent.iContactId, ESourceContactsHome, |
|
767 EEntryDeleted); |
|
768 |
564 UpdateDatabaseL(NULL, |
769 UpdateDatabaseL(NULL, |
565 aEvent.iContactId, ESourceContactsWork, |
770 aEvent.iContactId, ESourceContactsWork, |
566 EEntryDeleted); |
771 EEntryDeleted); |
567 UpdateDatabaseL(NULL, |
|
568 aEvent.iContactId, ESourceContactsHome, |
|
569 EEntryDeleted); |
|
570 } |
772 } |
571 } |
773 } |
572 else |
774 else |
573 { |
775 { |
574 // There is atleast one valid address present. |
776 // There is atleast one valid address present. |
575 |
777 |
576 // Get the TEntryChangeType for contacts. |
778 // Get the TEntryChangeType for contacts. |
577 TEntryChangeType changeType = MapChangeType( |
779 TEntryChangeType changeType = MapChangeType( |
578 ESourceContactsPref, aEvent.iType); |
780 ESourceContactsPref, aEvent.iType); |
579 |
781 |
580 // if home address available, update Mylocations. |
|
581 if (homeAddressLm) |
|
582 { |
|
583 UpdateDatabaseL(homeAddressLm, |
|
584 aEvent.iContactId, ESourceContactsHome, changeType); |
|
585 } |
|
586 |
|
587 // if work address available, update Mylocations. |
|
588 if (workAddressLm) |
|
589 { |
|
590 UpdateDatabaseL(workAddressLm, |
|
591 aEvent.iContactId, ESourceContactsWork, changeType); |
|
592 } |
|
593 |
|
594 // if prefered address available, update Mylocations. |
782 // if prefered address available, update Mylocations. |
595 if (preferedAddressLm) |
783 if (preferedAddressLm) |
596 { |
784 { |
597 UpdateDatabaseL( |
785 UpdateDatabaseL( |
598 preferedAddressLm, aEvent.iContactId, |
786 preferedAddressLm, aEvent.iContactId, |
599 ESourceContactsPref, changeType); |
787 ESourceContactsPref, changeType); |
600 } |
788 } |
|
789 // if home address available, update Mylocations. |
|
790 if (homeAddressLm) |
|
791 { |
|
792 UpdateDatabaseL(homeAddressLm, |
|
793 aEvent.iContactId, ESourceContactsHome, changeType); |
|
794 } |
|
795 |
|
796 // if work address available, update Mylocations. |
|
797 if (workAddressLm) |
|
798 { |
|
799 UpdateDatabaseL(workAddressLm, |
|
800 aEvent.iContactId, ESourceContactsWork, changeType); |
|
801 } |
|
802 |
601 CleanupStack::PopAndDestroy( itemCount ); |
803 CleanupStack::PopAndDestroy( itemCount ); |
602 } |
804 } |
603 |
805 |
604 } |
806 } |
605 else if (aEvent.iType == EContactDbObserverEventContactDeleted) |
807 else if (aEvent.iType == EContactDbObserverEventContactDeleted) |
698 lookupItem.iSource = ESourceContactsPref; |
900 lookupItem.iSource = ESourceContactsPref; |
699 if (preferedAddressLm) |
901 if (preferedAddressLm) |
700 { |
902 { |
701 MYLOCLOGSTRING("preferedAddressLm address changed" ); |
903 MYLOCLOGSTRING("preferedAddressLm address changed" ); |
702 |
904 |
703 if (iAddressCompare->IsAddressChangedL(*preferedAddressLm, |
905 if ( iMyLocationsDatabaseManager->CheckIfAddressChanged(*preferedAddressLm, |
704 aEvent.iContactId, ESourceContactsPref)) |
906 aEvent.iContactId, ESourceContactsPref) ) |
705 |
907 |
706 { |
908 { |
|
909 lookupItem.iFilePath.Zero(); |
|
910 lookupItem.iFetchingStatus = EMapTileFetchingInProgress; |
|
911 TRAP_IGNORE( iMaptileDatabase->ReSetEntryL(lookupItem) ); |
|
912 |
|
913 RequestMapTileImageL(*preferedAddressLm, ESourceContactsPref, |
|
914 aEvent.iContactId, iEventType ); |
|
915 |
|
916 if ( lookupItem.iFilePath.Length() > 0 ) |
|
917 { |
|
918 iMaptileDatabase->DeleteMapTileL(lookupItem); |
|
919 } |
707 //remove entry from database |
920 //remove entry from database |
708 TRAP_IGNORE( ManipulateMapTileDataBaseL(lookupItem)); |
921 //TRAP_IGNORE( ManipulateMapTileDataBaseL(lookupItem)); |
709 RequestMapTileImageL(*preferedAddressLm, ESourceContactsPref, |
|
710 aEvent.iContactId); |
|
711 } |
922 } |
712 } |
923 } |
713 else |
924 else |
714 { |
925 { |
715 TRAP_IGNORE( ManipulateMapTileDataBaseL(lookupItem)); |
926 TRAP_IGNORE( ManipulateMapTileDataBaseL(lookupItem)); |
716 |
927 |
717 } |
928 } |
|
929 |
|
930 // if home address available, update Mylocations. |
|
931 lookupItem.iSource = ESourceContactsHome; |
|
932 if (homeAddressLm) |
|
933 { |
|
934 MYLOCLOGSTRING("homeAddressLm address changed" ); |
|
935 if ( iMyLocationsDatabaseManager->CheckIfAddressChanged(*homeAddressLm, |
|
936 aEvent.iContactId, ESourceContactsHome) ) |
|
937 { |
|
938 lookupItem.iFilePath.Zero(); |
|
939 lookupItem.iFetchingStatus = EMapTileFetchingInProgress; |
|
940 TRAP_IGNORE( iMaptileDatabase->ReSetEntryL(lookupItem) ) |
|
941 //remove entry from databse |
|
942 //TRAP_IGNORE( ManipulateMapTileDataBaseL(lookupItem)); |
|
943 RequestMapTileImageL(*homeAddressLm, ESourceContactsHome, aEvent.iContactId, |
|
944 iEventType); |
|
945 if (lookupItem.iFilePath.Length() > 0) |
|
946 { |
|
947 iMaptileDatabase->DeleteMapTileL(lookupItem); |
|
948 } |
|
949 } |
|
950 } |
|
951 else |
|
952 { |
|
953 TRAP_IGNORE( ManipulateMapTileDataBaseL(lookupItem)); |
|
954 |
|
955 } |
|
956 |
718 |
957 |
719 // if work address available, update Mylocations. |
958 // if work address available, update Mylocations. |
720 lookupItem.iSource = ESourceContactsWork; |
959 lookupItem.iSource = ESourceContactsWork; |
721 if (workAddressLm) |
960 if (workAddressLm) |
722 { |
961 { |
723 MYLOCLOGSTRING("workAddressLm address changed" ); |
962 MYLOCLOGSTRING("workAddressLm address changed" ); |
724 if (iAddressCompare->IsAddressChangedL(*workAddressLm, |
963 if ( iMyLocationsDatabaseManager->CheckIfAddressChanged(*workAddressLm, |
725 aEvent.iContactId, ESourceContactsWork)) |
964 aEvent.iContactId, ESourceContactsWork) ) |
726 //remove entry from database |
|
727 { |
965 { |
728 |
966 lookupItem.iFilePath.Zero(); |
729 TRAP_IGNORE( ManipulateMapTileDataBaseL(lookupItem)); |
967 lookupItem.iFetchingStatus = EMapTileFetchingInProgress; |
|
968 TRAP_IGNORE( iMaptileDatabase->ReSetEntryL(lookupItem) ) |
|
969 |
|
970 //remove entry from databse |
|
971 //TRAP_IGNORE( ManipulateMapTileDataBaseL(lookupItem)); |
730 RequestMapTileImageL(*workAddressLm, ESourceContactsWork, |
972 RequestMapTileImageL(*workAddressLm, ESourceContactsWork, |
731 aEvent.iContactId); |
973 aEvent.iContactId, iEventType); |
|
974 if (lookupItem.iFilePath.Length() > 0) |
|
975 { |
|
976 iMaptileDatabase->DeleteMapTileL(lookupItem); |
|
977 } |
732 } |
978 } |
|
979 |
733 } |
980 } |
734 else |
981 else |
735 { |
982 { |
736 TRAP_IGNORE( ManipulateMapTileDataBaseL(lookupItem)); |
983 TRAP_IGNORE( ManipulateMapTileDataBaseL(lookupItem)); |
737 |
984 |
738 } |
985 } |
739 |
|
740 // if home address available, update Mylocations. |
|
741 lookupItem.iSource = ESourceContactsHome; |
|
742 if (homeAddressLm) |
|
743 { |
|
744 MYLOCLOGSTRING("homeAddressLm address changed" ); |
|
745 |
|
746 if (iAddressCompare->IsAddressChangedL(*homeAddressLm, |
|
747 aEvent.iContactId, ESourceContactsHome)) |
|
748 |
|
749 { |
|
750 //remove entry from databse |
|
751 TRAP_IGNORE( ManipulateMapTileDataBaseL(lookupItem)); |
|
752 RequestMapTileImageL(*homeAddressLm, ESourceContactsHome, |
|
753 aEvent.iContactId); |
|
754 } |
|
755 |
|
756 } |
|
757 else |
|
758 { |
|
759 TRAP_IGNORE( ManipulateMapTileDataBaseL(lookupItem)); |
|
760 |
|
761 } |
|
762 // } |
|
763 break; |
986 break; |
764 } |
987 } |
765 case EContactDbObserverEventContactAdded: |
988 case EContactDbObserverEventContactAdded: |
766 { |
989 { |
|
990 TLookupItem lookupItem; |
|
991 lookupItem.iUid = aEvent.iContactId; |
|
992 lookupItem.iFilePath.Zero(); |
|
993 lookupItem.iFetchingStatus = EMapTileFetchingInProgress; |
|
994 |
767 MYLOCLOGSTRING("EContactDbObserverEventContactAdded" ); |
995 MYLOCLOGSTRING("EContactDbObserverEventContactAdded" ); |
768 if (preferedAddressLm) |
996 if (preferedAddressLm) |
769 { |
997 { |
|
998 //create entry in the data base and maintain a fetching state. |
|
999 lookupItem.iSource = ESourceContactsPref; |
|
1000 iMaptileDatabase->CreateEntryL(lookupItem); |
770 RequestMapTileImageL(*preferedAddressLm, ESourceContactsPref, |
1001 RequestMapTileImageL(*preferedAddressLm, ESourceContactsPref, |
771 aEvent.iContactId); |
1002 aEvent.iContactId, iEventType); |
|
1003 } |
|
1004 if (homeAddressLm) |
|
1005 { |
|
1006 lookupItem.iSource = ESourceContactsHome; |
|
1007 iMaptileDatabase->CreateEntryL(lookupItem); |
|
1008 RequestMapTileImageL(*homeAddressLm, ESourceContactsHome, |
|
1009 aEvent.iContactId, iEventType); |
772 } |
1010 } |
773 if (workAddressLm) |
1011 if (workAddressLm) |
774 { |
1012 { |
|
1013 lookupItem.iSource = ESourceContactsWork; |
|
1014 iMaptileDatabase->CreateEntryL(lookupItem); |
775 RequestMapTileImageL(*workAddressLm, ESourceContactsWork, |
1015 RequestMapTileImageL(*workAddressLm, ESourceContactsWork, |
776 aEvent.iContactId); |
1016 aEvent.iContactId, iEventType); |
777 } |
|
778 if (homeAddressLm) |
|
779 { |
|
780 RequestMapTileImageL(*homeAddressLm, ESourceContactsHome, |
|
781 aEvent.iContactId); |
|
782 } |
1017 } |
783 break; |
1018 break; |
784 } |
1019 } |
785 |
1020 |
786 } |
1021 } |
807 CMapTileRequest* mapTileRequest = new (ELeave) CMapTileRequest; |
1042 CMapTileRequest* mapTileRequest = new (ELeave) CMapTileRequest; |
808 |
1043 |
809 mapTileRequest->iAddressDetails = aAddressDetails.AllocL(); |
1044 mapTileRequest->iAddressDetails = aAddressDetails.AllocL(); |
810 mapTileRequest->iUId = aUId; |
1045 mapTileRequest->iUId = aUId; |
811 mapTileRequest->iAddressType = aAddressType; |
1046 mapTileRequest->iAddressType = aAddressType; |
812 mapTileRequest->iEventType = iEventType; |
1047 mapTileRequest->iEventType = aEventType; |
813 mapTileRequest->iImagePath.Zero(); |
1048 mapTileRequest->iImagePath.Zero(); |
814 mapTileRequest->iImagePath.Copy(mImagePath); |
1049 mapTileRequest->iImagePath.Copy(mImagePath); |
|
1050 |
|
1051 TInt error = KErrNone; |
|
1052 |
815 if (iMapTileRequestQueue.Count() <= 0) |
1053 if (iMapTileRequestQueue.Count() <= 0) |
816 { |
1054 { |
817 if ( KErrNone == RequestExecute(mapTileRequest) ) |
1055 error = iMapTileRequestQueue.Append(mapTileRequest); |
818 { |
1056 if ( KErrNone == error ) |
819 iMapTileRequestQueue.Append(mapTileRequest); |
1057 { |
820 } |
1058 error = RequestExecute(mapTileRequest); |
821 else |
1059 } |
822 { |
|
823 delete mapTileRequest; |
|
824 } |
|
825 } |
1060 } |
826 else |
1061 else |
827 { |
1062 { |
828 MYLOCLOGSTRING("Added one more request to request queue" ); |
1063 MYLOCLOGSTRING("Added one more request to request queue" ); |
829 iMapTileRequestQueue.Append(mapTileRequest); |
1064 error = iMapTileRequestQueue.Append(mapTileRequest); |
830 } |
1065 } |
|
1066 |
|
1067 //If any error , free the allocated memory |
|
1068 if( error != KErrNone ) |
|
1069 { |
|
1070 delete mapTileRequest; |
|
1071 } |
|
1072 |
831 } |
1073 } |
832 // ----------------------------------------------------------------------------- |
1074 // ----------------------------------------------------------------------------- |
833 // CMyLocationsEngine::RequestMapTileImageL() |
1075 // CMyLocationsEngine::RequestMapTileImageL() |
834 // Request to get maptiel |
1076 // Request to get maptiel |
835 // ----------------------------------------------------------------------------- |
1077 // ----------------------------------------------------------------------------- |
836 // |
1078 // |
837 void CMyLocationsEngine::RequestMapTileImageL(CPosLandmark& aLandmark, |
1079 void CMyLocationsEngine::RequestMapTileImageL(CPosLandmark& aLandmark, |
838 const TUidSourceType aAddressType, const TInt32 aUId) |
1080 const TUidSourceType aAddressType, const TInt32 aUId, |
|
1081 const TInt aEventType ) |
839 { |
1082 { |
840 __TRACE_CALLSTACK; |
1083 __TRACE_CALLSTACK; |
841 |
1084 |
842 MYLOCLOGSTRING("check folder path existance!"); |
1085 MYLOCLOGSTRING("check folder path existance!"); |
843 SetFolderPathL(); |
1086 SetFolderPathL(); |
846 CMapTileRequest* mapTileRequest = new (ELeave) CMapTileRequest; |
1089 CMapTileRequest* mapTileRequest = new (ELeave) CMapTileRequest; |
847 |
1090 |
848 mapTileRequest->iLandmarkInfo = CPosLandmark::NewL(aLandmark); |
1091 mapTileRequest->iLandmarkInfo = CPosLandmark::NewL(aLandmark); |
849 mapTileRequest->iUId = aUId; |
1092 mapTileRequest->iUId = aUId; |
850 mapTileRequest->iAddressType = aAddressType; |
1093 mapTileRequest->iAddressType = aAddressType; |
851 mapTileRequest->iEventType = iEventType; |
1094 mapTileRequest->iEventType = aEventType; |
852 mapTileRequest->iImagePath.Zero(); |
1095 mapTileRequest->iImagePath.Zero(); |
853 mapTileRequest->iImagePath.Copy(imageFilePath); |
1096 mapTileRequest->iImagePath.Copy(imageFilePath); |
854 MYLOCLOGSTRING1("RequestMapTileImageL() Queue count -%d",iMapTileRequestQueue.Count()); |
1097 MYLOCLOGSTRING1("RequestMapTileImageL() Queue count -%d",iMapTileRequestQueue.Count()); |
855 |
1098 |
|
1099 TInt error = KErrNone; |
|
1100 |
856 if (iMapTileRequestQueue.Count() <= 0) |
1101 if (iMapTileRequestQueue.Count() <= 0) |
857 { |
1102 { |
858 |
1103 error = iMapTileRequestQueue.Append(mapTileRequest); |
859 if( KErrNone == RequestExecute(mapTileRequest) ) |
1104 //error = RequestExecute(mapTileRequest); |
|
1105 if( KErrNone == error ) |
860 { |
1106 { |
861 iMapTileRequestQueue.Append(mapTileRequest); |
1107 //error = iMapTileRequestQueue.Append(mapTileRequest); |
|
1108 error = RequestExecute(mapTileRequest); |
862 } |
1109 } |
863 else |
1110 |
864 { |
|
865 delete mapTileRequest; |
|
866 } |
|
867 } |
1111 } |
868 else |
1112 else |
869 { |
1113 { |
870 MYLOCLOGSTRING("Added one more request to request queue" ); |
1114 MYLOCLOGSTRING("Added one more request to request queue" ); |
871 iMapTileRequestQueue.Append(mapTileRequest); |
1115 error = iMapTileRequestQueue.Append(mapTileRequest); |
872 } |
1116 } |
873 |
1117 |
874 |
1118 //If any error, free the memory allocated |
|
1119 if( error != KErrNone ) |
|
1120 { |
|
1121 delete mapTileRequest; |
|
1122 } |
875 } |
1123 } |
876 |
1124 |
877 // ----------------------------------------------------------------------------- |
1125 // ----------------------------------------------------------------------------- |
878 // CMyLocationsEngine::RequestExecute() |
1126 // CMyLocationsEngine::RequestExecute() |
879 // Executes the maptile image processing request |
1127 // Executes the maptile image processing request |
1161 |
1408 |
1162 |
1409 |
1163 lookupItem.iFilePath.Copy(aMapTilePath); |
1410 lookupItem.iFilePath.Copy(aMapTilePath); |
1164 lookupItem.iFetchingStatus = EMapTileFectchingCompleted; |
1411 lookupItem.iFetchingStatus = EMapTileFectchingCompleted; |
1165 TRAP_IGNORE( UpdateMaptileDatabaseL(iMapTileRequestQueue[0]->iEventType, lookupItem ) ); |
1412 TRAP_IGNORE( UpdateMaptileDatabaseL(iMapTileRequestQueue[0]->iEventType, lookupItem ) ); |
1166 |
1413 //Publish the maptile status |
|
1414 if( iLastContactId == iMapTileRequestQueue[0]->iUId ) |
|
1415 { |
|
1416 buffer.Zero(); |
|
1417 buffer.Format( KMaptileStatusFormat, iLastContactId, lookupItem.iSource, lookupItem.iFetchingStatus ); |
|
1418 RProperty::Set( KMaptileStatusPublish, EMaptileStatusInteger, buffer ); |
|
1419 } |
|
1420 //Publish the maptile status ,if it was from calendar |
|
1421 if( iLastCalendarId == iMapTileRequestQueue[0]->iUId ) |
|
1422 { |
|
1423 buffer.Zero(); |
|
1424 buffer.Format( KMaptileStatusFormat, iLastCalendarId, lookupItem.iSource, lookupItem.iFetchingStatus ); |
|
1425 RProperty::Set( KMaptileStatusPublish, EMaptileStatusInteger, buffer ); |
|
1426 } |
1167 MYLOCLOGSTRING("UpdateMaptileDatabaseL handled"); |
1427 MYLOCLOGSTRING("UpdateMaptileDatabaseL handled"); |
1168 |
1428 |
1169 //Process the pending maptile requests |
1429 //Process the pending maptile requests |
1170 ProcessNextMaptileRequest(); |
1430 ProcessNextMaptileRequest(); |
1171 |
1431 |
1222 CPosLandmark *addressLm = NULL; |
1497 CPosLandmark *addressLm = NULL; |
1223 |
1498 |
1224 foreach ( QContactAddress address, contactInfo.details<QContactAddress>() ) |
1499 foreach ( QContactAddress address, contactInfo.details<QContactAddress>() ) |
1225 { |
1500 { |
1226 QStringList context = address.contexts(); |
1501 QStringList context = address.contexts(); |
1227 if ( ( context.isEmpty() && iItem.iSource == ESourceContactsPref ) || |
1502 if ( ( context.isEmpty() && iItem.iSource == ESourceContactsPref ) |
1228 ( context.first() == QContactAddress::ContextHome && iItem.iSource == ESourceContactsHome ) || |
1503 || |
1229 ( context.first() == QContactAddress::ContextWork && iItem.iSource == ESourceContactsWork ) ) |
1504 ( !context.isEmpty() && |
|
1505 ( ( context.first() == QContactAddress::ContextHome && iItem.iSource == ESourceContactsHome ) || |
|
1506 ( context.first() == QContactAddress::ContextWork && iItem.iSource == ESourceContactsWork ) ) ) ) |
1230 { |
1507 { |
1231 // Get the default/prefered address details |
1508 // Get the default/prefered address details |
1232 addressLm = GetContactAddressDetailsLC( address ); |
1509 addressLm = GetContactAddressDetailsLC( address ); |
1233 if( addressLm ) |
1510 if( addressLm ) |
1234 { |
1511 { |
1235 RequestMapTileImageL( *addressLm, |
1512 RequestMapTileImageL( *addressLm, |
1236 ( TUidSourceType )iItem.iSource, iItem.iUid ); |
1513 ( TUidSourceType )iItem.iSource, iItem.iUid, EContactDbObserverEventContactChanged ); |
1237 CleanupStack::PopAndDestroy( addressLm ); |
1514 CleanupStack::PopAndDestroy( addressLm ); |
1238 break; |
1515 break; |
1239 } |
1516 } |
1240 } |
1517 } |
1241 } |
1518 } |
1395 { |
1688 { |
1396 switch (iMapTileRequestQueue[0]->iAddressType) |
1689 switch (iMapTileRequestQueue[0]->iAddressType) |
1397 { |
1690 { |
1398 //TODO: |
1691 //TODO: |
1399 case ESourceCalendar: |
1692 case ESourceCalendar: |
1400 { |
1693 { |
1401 |
1694 CPosLandmark *landmark = NULL; |
1402 CPosLandmark *landmark=NULL; |
1695 landmark = iMapTileInterface->GetLandMarkDetails(); |
1403 landmark=iMapTileInterface->GetLandMarkDetails(); |
1696 if (NULL != landmark) |
1404 TRAP_IGNORE( UpdateDatabaseL( landmark, iMapTileRequestQueue[0]->iUId, |
1697 { |
1405 ESourceCalendar, |
1698 TRAP_IGNORE( landmark->SetPositionFieldL(EPositionFieldComment, |
1406 MapChangeType( ESourceCalendar, iMapTileRequestQueue[0]->iEventType ) ) ); |
1699 iMapTileRequestQueue[0]->iAddressDetails->Des() ) ); |
1407 MYLOCLOGSTRING("Geo-codinate updated to calender db"); |
1700 TRAP_IGNORE( UpdateDatabaseL( landmark, iMapTileRequestQueue[0]->iUId, |
|
1701 ESourceCalendar, |
|
1702 MapChangeType( ESourceCalendar, iMapTileRequestQueue[0]->iEventType ) ) ); |
|
1703 } |
|
1704 MYLOCLOGSTRING("Geo-codinate updated to calender db"); |
1408 break; |
1705 break; |
1409 } |
1706 } |
1410 case ESourceContactsPref: |
1707 case ESourceContactsPref: |
1411 case ESourceContactsWork: |
1708 case ESourceContactsWork: |
1412 case ESourceContactsHome: |
1709 case ESourceContactsHome: |
1413 { |
1710 { |
1414 GeocodeUpdate::updateGeocodeToContactDB( |
1711 GeocodeUpdate geocodeUpdate; |
|
1712 geocodeUpdate.updateGeocodeToContactDB( |
1415 iMapTileRequestQueue[0]->iUId, |
1713 iMapTileRequestQueue[0]->iUId, |
1416 iMapTileRequestQueue[0]->iAddressType, aLatitude, |
1714 iMapTileRequestQueue[0]->iAddressType, aLatitude, |
1417 aLongitude); |
1715 aLongitude); |
1418 MYLOCLOGSTRING("Geo-codinate updated to contact db"); |
1716 MYLOCLOGSTRING("Geo-codinate updated to contact db"); |
1419 break; |
1717 break; |