400 lookupItem.iFilePath.Zero(); |
404 lookupItem.iFilePath.Zero(); |
401 lookupItem.iFetchingStatus = EMapTileFetchingInProgress; |
405 lookupItem.iFetchingStatus = EMapTileFetchingInProgress; |
402 iMaptileDatabase->UpdateEntryL( lookupItem ); |
406 iMaptileDatabase->UpdateEntryL( lookupItem ); |
403 |
407 |
404 //Request for maptile fetching |
408 //Request for maptile fetching |
405 RequestMapTileImageL( *contactAddressLm, type, |
409 if( contactAddressLm ) |
|
410 { |
|
411 RequestMapTileImageL( *contactAddressLm, type, |
406 iAddressInfo[index]->iUid, EContactDbObserverEventContactChanged ); |
412 iAddressInfo[index]->iUid, EContactDbObserverEventContactChanged ); |
|
413 } |
407 |
414 |
408 CleanupStack::PopAndDestroy( itemCount ); |
415 CleanupStack::PopAndDestroy( itemCount ); |
409 } |
416 } |
410 } |
417 } |
411 for( TInt index = 0; index < iAddressInfo.Count(); index++ ) |
418 for( TInt index = 0; index < iAddressInfo.Count(); index++ ) |
577 }; |
591 }; |
578 |
592 |
579 } |
593 } |
580 } |
594 } |
581 |
595 |
|
596 // ----------------------------------------------------------------------------- |
|
597 // CMyLocationsEngine::RefreshCalendarEntryListL() |
|
598 // ----------------------------------------------------------------------------- |
|
599 // |
|
600 void CMyLocationsEngine::RefreshCalendarEntryListL() |
|
601 { |
|
602 //Get all the calendar ids and check its validity. |
|
603 //Delete if they are no more valid. |
|
604 RArray<TUint32> ids; |
|
605 iMaptileDatabase->GetAllCalendarIdsL( ids ); |
|
606 for( TInt i = 0; i < ids.Count(); i++ ) |
|
607 { |
|
608 if( !IsCalendarEntryValidL( ids[i] ) ) |
|
609 { |
|
610 TLookupItem lookupItem; |
|
611 lookupItem.iSource = ESourceCalendar; |
|
612 lookupItem.iUid = ids[i]; |
|
613 TRAP_IGNORE( ManipulateMapTileDataBaseL( lookupItem ) ); |
|
614 TRAP_IGNORE( UpdateDatabaseL( NULL, |
|
615 ids[i], ESourceCalendar, EEntryDeleted ) ); |
|
616 |
|
617 } |
|
618 } |
|
619 } |
|
620 |
|
621 // ----------------------------------------------------------------------------- |
|
622 // CMyLocationsEngine::IsCalendarEntryValidL() |
|
623 // ----------------------------------------------------------------------------- |
|
624 // |
|
625 TBool CMyLocationsEngine::IsCalendarEntryValidL( TUint32 aId ) |
|
626 { |
|
627 return ( ( iCalView->FetchL( aId ) == NULL ) ? EFalse:ETrue ); |
|
628 } |
582 // ----------------------------------------------------------------------------- |
629 // ----------------------------------------------------------------------------- |
583 // CMyLocationsEngine::CalenderEntryAddedL() |
630 // CMyLocationsEngine::CalenderEntryAddedL() |
584 // ----------------------------------------------------------------------------- |
631 // ----------------------------------------------------------------------------- |
585 // |
632 // |
586 void CMyLocationsEngine::CalenderEntryAddedL(TCalChangeEntry aCalChangeEntry) |
633 void CMyLocationsEngine::CalenderEntryAddedL(TCalChangeEntry aCalChangeEntry) |
703 return; |
750 return; |
704 } |
751 } |
705 |
752 |
706 //Get the contact item |
753 //Get the contact item |
707 iEventType = aEvent.iType; |
754 iEventType = aEvent.iType; |
708 QContact contactInfo = iContactManager->contact( aEvent.iContactId ); |
755 QContact contactInfo = iContactManager->contact( aEvent.iContactId ); |
709 |
|
710 //Get the contact name details |
|
711 QContactName name = contactInfo.detail( QContactName::DefinitionName ); |
|
712 QString firstName = name.firstName(); |
|
713 QString lastName = name.lastName(); |
|
714 TPtrC16 tempPtr1(reinterpret_cast<const TUint16*>(firstName.utf16())); |
|
715 TPtrC16 tempPtr2( reinterpret_cast <const TUint16*>(lastName.utf16())); |
|
716 |
|
717 TBuf<KBufSize> landmarkName; |
|
718 landmarkName.Append( tempPtr1 ); |
|
719 landmarkName.Append( tempPtr2 ); |
|
720 |
|
721 CPosLandmark *preferedAddressLm = NULL; |
756 CPosLandmark *preferedAddressLm = NULL; |
722 CPosLandmark *workAddressLm = NULL; |
757 CPosLandmark *workAddressLm = NULL; |
723 CPosLandmark *homeAddressLm = NULL; |
758 CPosLandmark *homeAddressLm = NULL; |
724 |
759 |
725 TInt itemCount = 0; |
760 TInt itemCount = 0; |
758 CleanupStack::PopAndDestroy( itemCount ); |
794 CleanupStack::PopAndDestroy( itemCount ); |
759 MYLOCLOGSTRING("retrun from geolocation callback" ); |
795 MYLOCLOGSTRING("retrun from geolocation callback" ); |
760 return; |
796 return; |
761 } |
797 } |
762 } |
798 } |
763 |
799 |
|
800 TBuf<KBufSize> landmarkName; |
|
801 GetContactName(aEvent.iContactId,landmarkName); |
|
802 |
764 // if default address available, update Mylocations. |
803 // if default address available, update Mylocations. |
765 lookupItem.iSource = ESourceContactsPref; |
804 lookupItem.iSource = ESourceContactsPref; |
766 if (preferedAddressLm) |
805 if (preferedAddressLm) |
767 { |
806 { |
768 preferedAddressLm->SetLandmarkNameL( landmarkName ); |
807 iMyLocationsDatabaseManager->UpdateEntryName( aEvent.iContactId, ESourceContactsPref, |
|
808 landmarkName ); |
769 MYLOCLOGSTRING("preferedAddressLm address changed" ); |
809 MYLOCLOGSTRING("preferedAddressLm address changed" ); |
770 |
810 |
771 if ( iMyLocationsDatabaseManager->CheckIfAddressChanged(*preferedAddressLm, |
811 if ( iMyLocationsDatabaseManager->CheckIfAddressChanged(*preferedAddressLm, |
772 aEvent.iContactId, ESourceContactsPref) ) |
812 aEvent.iContactId, ESourceContactsPref) ) |
773 |
813 |
781 |
821 |
782 if ( lookupItem.iFilePath.Length() > 0 ) |
822 if ( lookupItem.iFilePath.Length() > 0 ) |
783 { |
823 { |
784 iMaptileDatabase->DeleteMapTileL(lookupItem); |
824 iMaptileDatabase->DeleteMapTileL(lookupItem); |
785 } |
825 } |
786 //remove entry from database |
826 |
787 //TRAP_IGNORE( ManipulateMapTileDataBaseL(lookupItem)); |
|
788 } |
827 } |
789 } |
828 } |
790 else |
829 else |
791 { |
830 { |
|
831 TRAP_IGNORE( UpdateDatabaseL( NULL, aEvent.iContactId, |
|
832 ESourceContactsPref, EEntryDeleted )); |
792 TRAP_IGNORE( ManipulateMapTileDataBaseL(lookupItem)); |
833 TRAP_IGNORE( ManipulateMapTileDataBaseL(lookupItem)); |
793 |
834 |
794 } |
835 } |
795 |
836 |
796 // if home address available, update Mylocations. |
837 // if home address available, update Mylocations. |
797 lookupItem.iSource = ESourceContactsHome; |
838 lookupItem.iSource = ESourceContactsHome; |
798 if (homeAddressLm) |
839 if (homeAddressLm) |
799 { |
840 { |
800 homeAddressLm->SetLandmarkNameL( landmarkName ); |
841 iMyLocationsDatabaseManager->UpdateEntryName( aEvent.iContactId, ESourceContactsHome, |
|
842 landmarkName ); |
801 MYLOCLOGSTRING("homeAddressLm address changed" ); |
843 MYLOCLOGSTRING("homeAddressLm address changed" ); |
802 if ( iMyLocationsDatabaseManager->CheckIfAddressChanged(*homeAddressLm, |
844 if ( iMyLocationsDatabaseManager->CheckIfAddressChanged(*homeAddressLm, |
803 aEvent.iContactId, ESourceContactsHome) ) |
845 aEvent.iContactId, ESourceContactsHome) ) |
804 { |
846 { |
805 lookupItem.iFilePath.Zero(); |
847 lookupItem.iFilePath.Zero(); |
806 lookupItem.iFetchingStatus = EMapTileFetchingInProgress; |
848 lookupItem.iFetchingStatus = EMapTileFetchingInProgress; |
807 TRAP_IGNORE( iMaptileDatabase->ReSetEntryL(lookupItem) ) |
849 TRAP_IGNORE( iMaptileDatabase->ReSetEntryL(lookupItem) ) |
808 //remove entry from databse |
850 //remove entry from databse |
809 //TRAP_IGNORE( ManipulateMapTileDataBaseL(lookupItem)); |
|
810 RequestMapTileImageL(*homeAddressLm, ESourceContactsHome, aEvent.iContactId, |
851 RequestMapTileImageL(*homeAddressLm, ESourceContactsHome, aEvent.iContactId, |
811 iEventType); |
852 iEventType); |
812 if (lookupItem.iFilePath.Length() > 0) |
853 if (lookupItem.iFilePath.Length() > 0) |
813 { |
854 { |
814 iMaptileDatabase->DeleteMapTileL(lookupItem); |
855 iMaptileDatabase->DeleteMapTileL(lookupItem); |
815 } |
856 } |
816 } |
857 } |
817 } |
858 } |
818 else |
859 else |
819 { |
860 { |
|
861 TRAP_IGNORE( UpdateDatabaseL( NULL, aEvent.iContactId, |
|
862 ESourceContactsHome, EEntryDeleted )); |
820 TRAP_IGNORE( ManipulateMapTileDataBaseL(lookupItem)); |
863 TRAP_IGNORE( ManipulateMapTileDataBaseL(lookupItem)); |
821 |
864 |
822 } |
865 } |
823 |
866 |
824 |
867 |
825 // if work address available, update Mylocations. |
868 // if work address available, update Mylocations. |
826 lookupItem.iSource = ESourceContactsWork; |
869 lookupItem.iSource = ESourceContactsWork; |
827 if (workAddressLm) |
870 if (workAddressLm) |
828 { |
871 { |
829 workAddressLm->SetLandmarkNameL( landmarkName ); |
872 iMyLocationsDatabaseManager->UpdateEntryName( aEvent.iContactId, ESourceContactsWork, |
|
873 landmarkName ); |
|
874 |
830 MYLOCLOGSTRING("workAddressLm address changed" ); |
875 MYLOCLOGSTRING("workAddressLm address changed" ); |
831 if ( iMyLocationsDatabaseManager->CheckIfAddressChanged(*workAddressLm, |
876 if ( iMyLocationsDatabaseManager->CheckIfAddressChanged(*workAddressLm, |
832 aEvent.iContactId, ESourceContactsWork) ) |
877 aEvent.iContactId, ESourceContactsWork) ) |
833 { |
878 { |
834 lookupItem.iFilePath.Zero(); |
879 lookupItem.iFilePath.Zero(); |
835 lookupItem.iFetchingStatus = EMapTileFetchingInProgress; |
880 lookupItem.iFetchingStatus = EMapTileFetchingInProgress; |
836 TRAP_IGNORE( iMaptileDatabase->ReSetEntryL(lookupItem) ) |
881 TRAP_IGNORE( iMaptileDatabase->ReSetEntryL(lookupItem) ) |
837 |
882 |
838 //remove entry from databse |
|
839 //TRAP_IGNORE( ManipulateMapTileDataBaseL(lookupItem)); |
|
840 RequestMapTileImageL(*workAddressLm, ESourceContactsWork, |
883 RequestMapTileImageL(*workAddressLm, ESourceContactsWork, |
841 aEvent.iContactId, iEventType); |
884 aEvent.iContactId, iEventType); |
842 if (lookupItem.iFilePath.Length() > 0) |
885 if (lookupItem.iFilePath.Length() > 0) |
843 { |
886 { |
844 iMaptileDatabase->DeleteMapTileL(lookupItem); |
887 iMaptileDatabase->DeleteMapTileL(lookupItem); |
845 } |
888 } |
846 } |
889 } |
847 |
|
848 } |
890 } |
849 else |
891 else |
850 { |
892 { |
|
893 TRAP_IGNORE( UpdateDatabaseL( NULL, aEvent.iContactId, |
|
894 ESourceContactsWork, EEntryDeleted )); |
851 TRAP_IGNORE( ManipulateMapTileDataBaseL(lookupItem)); |
895 TRAP_IGNORE( ManipulateMapTileDataBaseL(lookupItem)); |
852 |
896 |
853 } |
897 } |
854 break; |
898 break; |
855 } |
899 } |
861 lookupItem.iFetchingStatus = EMapTileFetchingInProgress; |
905 lookupItem.iFetchingStatus = EMapTileFetchingInProgress; |
862 |
906 |
863 MYLOCLOGSTRING("EContactDbObserverEventContactAdded" ); |
907 MYLOCLOGSTRING("EContactDbObserverEventContactAdded" ); |
864 if (preferedAddressLm) |
908 if (preferedAddressLm) |
865 { |
909 { |
866 preferedAddressLm->SetLandmarkNameL( landmarkName ); |
|
867 //create entry in the data base and maintain a fetching state. |
910 //create entry in the data base and maintain a fetching state. |
868 lookupItem.iSource = ESourceContactsPref; |
911 lookupItem.iSource = ESourceContactsPref; |
869 iMaptileDatabase->CreateEntryL(lookupItem); |
912 iMaptileDatabase->CreateEntryL(lookupItem); |
870 RequestMapTileImageL(*preferedAddressLm, ESourceContactsPref, |
913 RequestMapTileImageL(*preferedAddressLm, ESourceContactsPref, |
871 aEvent.iContactId, iEventType); |
914 aEvent.iContactId, iEventType); |
872 } |
915 } |
873 if (homeAddressLm) |
916 if (homeAddressLm) |
874 { |
917 { |
875 homeAddressLm->SetLandmarkNameL( landmarkName ); |
|
876 lookupItem.iSource = ESourceContactsHome; |
918 lookupItem.iSource = ESourceContactsHome; |
877 iMaptileDatabase->CreateEntryL(lookupItem); |
919 iMaptileDatabase->CreateEntryL(lookupItem); |
878 RequestMapTileImageL(*homeAddressLm, ESourceContactsHome, |
920 RequestMapTileImageL(*homeAddressLm, ESourceContactsHome, |
879 aEvent.iContactId, iEventType); |
921 aEvent.iContactId, iEventType); |
880 } |
922 } |
881 if (workAddressLm) |
923 if (workAddressLm) |
882 { |
924 { |
883 workAddressLm->SetLandmarkNameL( landmarkName ); |
|
884 lookupItem.iSource = ESourceContactsWork; |
925 lookupItem.iSource = ESourceContactsWork; |
885 iMaptileDatabase->CreateEntryL(lookupItem); |
926 iMaptileDatabase->CreateEntryL(lookupItem); |
886 RequestMapTileImageL(*workAddressLm, ESourceContactsWork, |
927 RequestMapTileImageL(*workAddressLm, ESourceContactsWork, |
887 aEvent.iContactId, iEventType); |
928 aEvent.iContactId, iEventType); |
888 } |
929 } |
1372 case ESourceContactsWork: |
1413 case ESourceContactsWork: |
1373 case ESourceContactsPref: |
1414 case ESourceContactsPref: |
1374 { |
1415 { |
1375 QContact contactInfo = iContactManager->contact( iItem.iUid ); |
1416 QContact contactInfo = iContactManager->contact( iItem.iUid ); |
1376 |
1417 |
1377 //Get the contact name details |
|
1378 QContactName name = contactInfo.detail( QContactName::DefinitionName ); |
|
1379 QString firstName = name.firstName(); |
|
1380 QString lastName = name.lastName(); |
|
1381 TPtrC16 tempPtr1(reinterpret_cast<const TUint16*>(firstName.utf16())); |
|
1382 TPtrC16 tempPtr2( reinterpret_cast <const TUint16*>(lastName.utf16())); |
|
1383 |
|
1384 TBuf<KBufSize> landmarkName; |
|
1385 landmarkName.Append( tempPtr1 ); |
|
1386 landmarkName.Append( tempPtr2 ); |
|
1387 |
|
1388 CPosLandmark *addressLm = NULL; |
1418 CPosLandmark *addressLm = NULL; |
1389 |
1419 |
1390 foreach ( QContactAddress address, contactInfo.details<QContactAddress>() ) |
1420 foreach ( QContactAddress address, contactInfo.details<QContactAddress>() ) |
1391 { |
1421 { |
1392 QStringList context = address.contexts(); |
1422 QStringList context = address.contexts(); |
1477 else |
1506 else |
1478 { |
1507 { |
1479 lookupItem.iFetchingStatus = EMapTileFetchingUnknownError; |
1508 lookupItem.iFetchingStatus = EMapTileFetchingUnknownError; |
1480 } |
1509 } |
1481 |
1510 |
1482 TRAP_IGNORE( UpdateMaptileDatabaseL(iMapTileRequestQueue[0]->iEventType,lookupItem ) ); |
1511 TRAP_IGNORE( UpdateMaptileDatabaseL( iMapTileRequestQueue[0]->iEventType,lookupItem ) ); |
|
1512 |
|
1513 // if the source type is contacts, update the contact name into the locationdatalookupdb. |
|
1514 // This has to be done, because there is a possibility that the user might change the |
|
1515 // contact name between geocodefetchingcomplete and maptilefetchingcomplete. |
|
1516 if( iMapTileRequestQueue[0]->iAddressType == ESourceContactsPref || |
|
1517 iMapTileRequestQueue[0]->iAddressType == ESourceContactsHome || |
|
1518 iMapTileRequestQueue[0]->iAddressType == ESourceContactsWork ) |
|
1519 { |
|
1520 TBuf<KBufSize> landmarkName; |
|
1521 GetContactName( iMapTileRequestQueue[0]->iUId, landmarkName ); |
|
1522 |
|
1523 iMyLocationsDatabaseManager->UpdateEntryName( |
|
1524 iMapTileRequestQueue[0]->iUId, ESourceContactsPref, landmarkName ); |
|
1525 iMyLocationsDatabaseManager->UpdateEntryName( |
|
1526 iMapTileRequestQueue[0]->iUId, ESourceContactsHome, landmarkName ); |
|
1527 iMyLocationsDatabaseManager->UpdateEntryName( |
|
1528 iMapTileRequestQueue[0]->iUId, ESourceContactsWork, landmarkName ); |
|
1529 } |
1483 |
1530 |
1484 //Publish the maptile status , if it was from contact |
1531 //Publish the maptile status , if it was from contact |
1485 if( iLastContactId == iMapTileRequestQueue[0]->iUId ) |
1532 if( iLastContactId == iMapTileRequestQueue[0]->iUId ) |
1486 { |
1533 { |
1487 TBuf8<KProtocolBufferSize> buffer; |
1534 TBuf8<KProtocolBufferSize> buffer; |
1624 { |
1671 { |
1625 iGeocodeUpdate->updateGeocodeToContactDB( |
1672 iGeocodeUpdate->updateGeocodeToContactDB( |
1626 iMapTileRequestQueue[0]->iUId, |
1673 iMapTileRequestQueue[0]->iUId, |
1627 iMapTileRequestQueue[0]->iAddressType, aLatitude, |
1674 iMapTileRequestQueue[0]->iAddressType, aLatitude, |
1628 aLongitude); |
1675 aLongitude); |
|
1676 TBuf<KBufSize> landmarkName; |
|
1677 GetContactName(iMapTileRequestQueue[0]->iUId,landmarkName); |
1629 //Update mylocation database |
1678 //Update mylocation database |
|
1679 iMapTileRequestQueue[0]->iLandmarkInfo->SetLandmarkNameL( landmarkName ); |
1630 TRAP_IGNORE( UpdateDatabaseL( |
1680 TRAP_IGNORE( UpdateDatabaseL( |
1631 iMapTileRequestQueue[0]->iLandmarkInfo, |
1681 iMapTileRequestQueue[0]->iLandmarkInfo, |
1632 iMapTileRequestQueue[0]->iUId, |
1682 iMapTileRequestQueue[0]->iUId, |
1633 iMapTileRequestQueue[0]->iAddressType, |
1683 iMapTileRequestQueue[0]->iAddressType, |
1634 MapChangeType( |
1684 MapChangeType( |
1641 }; |
1691 }; |
1642 } |
1692 } |
1643 |
1693 |
1644 } |
1694 } |
1645 |
1695 |
|
1696 |
|
1697 // ----------------------------------------------------------------------------- |
|
1698 // CMyLocationsEngine::GetContactName() |
|
1699 // ----------------------------------------------------------------------------- |
|
1700 // |
|
1701 void CMyLocationsEngine::GetContactName( TInt32 aUId,TDes& aName) |
|
1702 { |
|
1703 QContact contactInfo = iContactManager->contact( aUId ); |
|
1704 QContactName name = contactInfo.detail( QContactName::DefinitionName ); |
|
1705 QString firstName = name.firstName(); |
|
1706 QString lastName = name.lastName(); |
|
1707 QString fullName(""); |
|
1708 |
|
1709 if( lastName.isEmpty() ) |
|
1710 { |
|
1711 fullName = firstName; |
|
1712 } |
|
1713 else |
|
1714 { |
|
1715 if( !firstName.isEmpty() ) |
|
1716 { |
|
1717 fullName = firstName + KSpace; |
|
1718 } |
|
1719 fullName = fullName + lastName; |
|
1720 } |
|
1721 |
|
1722 aName.Copy( reinterpret_cast<const TUint16*>(fullName.utf16()) ); |
|
1723 } |
|
1724 |
1646 // ----------------------------------------------------------------------------- |
1725 // ----------------------------------------------------------------------------- |
1647 // CMyLocationsEngine::UpdateDatabaseL() |
1726 // CMyLocationsEngine::UpdateDatabaseL() |
1648 // ----------------------------------------------------------------------------- |
1727 // ----------------------------------------------------------------------------- |
1649 // |
1728 // |
1650 void CMyLocationsEngine::UpdateDatabaseL( CPosLandmark* aLandmark, const TUint32 aUid, |
1729 void CMyLocationsEngine::UpdateDatabaseL( CPosLandmark* aLandmark, const TUint32 aUid, |
1651 const TUint32 aSourceType, const TEntryChangeType aChangeType ) |
1730 const TUint32 aSourceType, const TEntryChangeType aChangeType ) |
1652 { |
1731 { |
1653 __TRACE_CALLSTACK; |
1732 __TRACE_CALLSTACK; |
1654 Cancel(); |
1733 if(IsActive()) |
|
1734 { |
|
1735 Cancel(); |
|
1736 } |
1655 iMyLocationsDatabaseManager->UpdateDatabaseL( aLandmark, aUid, |
1737 iMyLocationsDatabaseManager->UpdateDatabaseL( aLandmark, aUid, |
1656 aSourceType, aChangeType ); |
1738 aSourceType, aChangeType ); |
1657 if( aSourceType != ESourceLandmarks ) |
1739 if( aSourceType != ESourceLandmarks ) |
1658 { |
1740 { |
1659 StartLandmarksChangeNotifier(); |
1741 StartLandmarksChangeNotifier(); |