59 #include <mccaconnectionext.h> |
59 #include <mccaconnectionext.h> |
60 |
60 |
61 // Service provider settings api |
61 // Service provider settings api |
62 #include <spsettingsvoiputils.h> |
62 #include <spsettingsvoiputils.h> |
63 |
63 |
64 // AIW header files |
|
65 #include <AiwContactAssignDataTypes.h> |
|
66 #include <AiwContactSelectionDataTypes.h> |
|
67 |
|
68 #include <StringLoader.h> |
64 #include <StringLoader.h> |
69 |
65 |
70 // CCA contactor service. |
66 // CCA contactor service. |
71 #include "edcontactorservice.h" |
67 #include "edcontactorservice.h" |
72 |
68 |
192 |
188 |
193 // Create a contact manager instance. |
189 // Create a contact manager instance. |
194 iContactStoreUriArray = CVPbkContactStoreUriArray::NewL(); |
190 iContactStoreUriArray = CVPbkContactStoreUriArray::NewL(); |
195 iContactStoreUriArray->AppendL( TVPbkContactStoreUriPtr( VPbkContactStoreUris::DefaultCntDbUri() ) ); |
191 iContactStoreUriArray->AppendL( TVPbkContactStoreUriPtr( VPbkContactStoreUris::DefaultCntDbUri() ) ); |
196 iContactManager = CVPbkContactManager::NewL( *iContactStoreUriArray ); |
192 iContactManager = CVPbkContactManager::NewL( *iContactStoreUriArray ); |
197 |
|
198 // Set contact store observer to listen to contact store events. |
|
199 iContactManager->ContactStoresL().OpenAllL( *this ); |
|
200 |
193 |
201 iContactDataManager = new (ELeave) CEasyDialingContactDataManager(iContactManager); |
194 iContactDataManager = new (ELeave) CEasyDialingContactDataManager(iContactManager); |
202 iContactDataManager->ConstructL(); |
195 iContactDataManager->ConstructL(); |
203 iContactDataManager->SetObserver(this); |
196 iContactDataManager->SetObserver(this); |
204 |
197 |
244 // |
237 // |
245 CEasyDialingPlugin::~CEasyDialingPlugin() |
238 CEasyDialingPlugin::~CEasyDialingPlugin() |
246 { |
239 { |
247 iObservers.Reset(); |
240 iObservers.Reset(); |
248 |
241 |
249 if ( iContactManager ) |
|
250 { |
|
251 TRAP_IGNORE( iContactManager->ContactStoresL().CloseAll( *this ) ); |
|
252 } |
|
253 |
|
254 delete iCenrepListener; |
242 delete iCenrepListener; |
255 delete iContactDataManager; |
243 delete iContactDataManager; |
256 delete iPredictiveSearchQuery; |
244 delete iPredictiveSearchQuery; |
257 delete iContactManager; |
245 delete iContactManager; |
258 delete iContactStoreUriArray; |
246 delete iContactStoreUriArray; |
259 iContactDataStores.ResetAndDestroy(); |
247 iContactDataStores.ResetAndDestroy(); |
260 |
248 |
261 if (iPredictiveContactSearchHandler) |
249 if ( iPredictiveContactSearchHandler ) |
262 { |
250 { |
263 iPredictiveContactSearchHandler->RemoveObserver(this); |
251 iPredictiveContactSearchHandler->RemoveObserver(this); |
264 } |
252 } |
265 delete iPredictiveContactSearchHandler; |
253 delete iPredictiveContactSearchHandler; |
266 |
254 |
717 // ----------------------------------------------------------------------------- |
705 // ----------------------------------------------------------------------------- |
718 // |
706 // |
719 void CEasyDialingPlugin::FocusChanged( TDrawNow aDrawNow ) |
707 void CEasyDialingPlugin::FocusChanged( TDrawNow aDrawNow ) |
720 { |
708 { |
721 iContactListBox->SetFocus( IsFocused() ); |
709 iContactListBox->SetFocus( IsFocused() ); |
722 if( !IsFocused() ) |
710 if ( !IsFocused() ) |
723 { |
711 { |
724 // To be on the safe side, cancel async callback and reset input block. |
712 // To be on the safe side, cancel async callback and reset input block. |
725 CancelActionLaunchAndInputBlock(); |
713 CancelActionLaunchAndInputBlock(); |
726 iContactListBox->View()->ItemDrawer()->ClearFlags( CListItemDrawer::ESingleClickDisabledHighlight ); |
714 iContactListBox->View()->ItemDrawer()->ClearFlags( CListItemDrawer::ESingleClickDisabledHighlight ); |
727 } |
715 } |
761 // handling etc, then dialer and thus ed is already set invisible |
749 // handling etc, then dialer and thus ed is already set invisible |
762 // and effect will not be shown as listbox is already invisible. |
750 // and effect will not be shown as listbox is already invisible. |
763 // However if user empties number entry, then it's feasible to show |
751 // However if user empties number entry, then it's feasible to show |
764 // effect. |
752 // effect. |
765 HideContactListBoxWithEffect(); |
753 HideContactListBoxWithEffect(); |
766 iInfoLabelLine1->SetTextL( *iInfoLabelTextLine1 ); |
754 SetInfoLabelVisibleL( ETrue ); |
767 iInfoLabelLine2->SetTextL( *iInfoLabelTextLine2 ); |
|
768 iInfoLabelLine1->DrawDeferred(); |
|
769 iInfoLabelLine2->DrawDeferred(); |
|
770 Reset(); |
755 Reset(); |
771 } |
756 } |
772 else // proper search string |
757 else // proper search string |
773 { |
758 { |
774 iInfoLabelLine1->SetTextL( KNullDesC ); |
759 SetInfoLabelVisibleL( EFalse ); |
775 iInfoLabelLine2->SetTextL( KNullDesC ); |
|
776 iInfoLabelLine1->DrawDeferred(); |
|
777 iInfoLabelLine2->DrawDeferred(); |
|
778 iSearchString.Copy( aSearchString.Left( iSearchString.MaxLength() ) ); |
760 iSearchString.Copy( aSearchString.Left( iSearchString.MaxLength() ) ); |
779 LaunchSearchL(); |
761 LaunchSearchL(); |
780 } |
762 } |
781 } |
763 } |
782 |
764 |
791 return iNumberOfNames; |
773 return iNumberOfNames; |
792 } |
774 } |
793 |
775 |
794 |
776 |
795 // ----------------------------------------------------------------------------- |
777 // ----------------------------------------------------------------------------- |
796 // CEasyDialingPlugin::StoreReady |
|
797 // From MVPbkContactStoreListObserver. |
|
798 // |
|
799 // ----------------------------------------------------------------------------- |
|
800 // |
|
801 void CEasyDialingPlugin::StoreReady(MVPbkContactStore& /* aContactStore */) |
|
802 { |
|
803 |
|
804 } |
|
805 |
|
806 |
|
807 // ----------------------------------------------------------------------------- |
|
808 // CEasyDialingPlugin::StoreUnavailable |
|
809 // From MVPbkContactStoreListObserver. |
|
810 // |
|
811 // ----------------------------------------------------------------------------- |
|
812 // |
|
813 void CEasyDialingPlugin::StoreUnavailable(MVPbkContactStore& /* aContactStore */, TInt /* aReason */) |
|
814 { |
|
815 |
|
816 } |
|
817 |
|
818 |
|
819 // ----------------------------------------------------------------------------- |
|
820 // CEasyDialingPlugin::HandleStoreEventL |
|
821 // From MVPbkContactStoreListObserver. |
|
822 // |
|
823 // ----------------------------------------------------------------------------- |
|
824 // |
|
825 void CEasyDialingPlugin::HandleStoreEventL( MVPbkContactStore& /* aContactStore */, |
|
826 TVPbkContactStoreEvent aStoreEvent) |
|
827 { |
|
828 // Store's observers are informed one by one using active object so one shouldn't |
|
829 // perform search syncronously as one must try to ensure that PCS has had a |
|
830 // chance to update its store. However there seems to be no way to be |
|
831 // 100% sure that PCS is up-to-date when search is launched: telephony app |
|
832 // has such a high priority and there are no APIs to query PCS' status. |
|
833 switch ( aStoreEvent.iEventType ) |
|
834 { |
|
835 case TVPbkContactStoreEvent::EContactAdded: |
|
836 case TVPbkContactStoreEvent::EContactDeleted: |
|
837 case TVPbkContactStoreEvent::EContactChanged: |
|
838 { |
|
839 DoHandleContactsChangedL(); |
|
840 } |
|
841 break; |
|
842 |
|
843 default: |
|
844 break; |
|
845 } |
|
846 } |
|
847 |
|
848 // ----------------------------------------------------------------------------- |
|
849 // CEasyDialingPlugin::OpenComplete |
|
850 // From MVPbkContactStoreListObserver. |
|
851 // |
|
852 // ----------------------------------------------------------------------------- |
|
853 // |
|
854 void CEasyDialingPlugin::OpenComplete() |
|
855 { |
|
856 } |
|
857 |
|
858 // ----------------------------------------------------------------------------- |
|
859 // EasyDialingSettingsChanged |
778 // EasyDialingSettingsChanged |
860 // From MEasyDialingCenrepListenerObserver |
779 // From MEasyDialingCenrepListenerObserver |
861 // ----------------------------------------------------------------------------- |
780 // ----------------------------------------------------------------------------- |
862 // |
781 // |
863 void CEasyDialingPlugin::EasyDialingSettingsChanged( TInt aValue ) |
782 void CEasyDialingPlugin::EasyDialingSettingsChanged( TInt aValue ) |
864 { |
783 { |
865 if ( aValue == 0 ) |
784 if ( aValue == 0 ) |
866 { |
785 { |
867 Reset(); |
786 Reset(); |
868 InformObservers( MDialingExtensionObserver::EEasyDialingDisabled ); |
787 InformObservers( MDialingExtensionObserver::EEasyDialingDisabled ); |
|
788 TRAP_IGNORE( SetInfoLabelVisibleL( EFalse ) ); |
869 } |
789 } |
870 else if ( aValue == 1 ) |
790 else if ( aValue == 1 ) |
871 { |
791 { |
872 InformObservers( MDialingExtensionObserver::EEasyDialingEnabled ); |
792 InformObservers( MDialingExtensionObserver::EEasyDialingEnabled ); |
|
793 if ( iSearchString.Length() == 0 ) |
|
794 { |
|
795 TRAP_IGNORE( SetInfoLabelVisibleL( ETrue ) ); |
|
796 } |
873 } |
797 } |
874 MakeVisible( aValue ); |
798 MakeVisible( aValue ); |
875 } |
799 } |
876 |
800 |
877 // ----------------------------------------------------------------------------- |
801 // ----------------------------------------------------------------------------- |
924 // From MEDContactorObserver |
850 // From MEDContactorObserver |
925 // ----------------------------------------------------------------------------- |
851 // ----------------------------------------------------------------------------- |
926 // |
852 // |
927 void CEasyDialingPlugin::InformContactorEvent( MEDContactorObserver::TEvent aEvent ) |
853 void CEasyDialingPlugin::InformContactorEvent( MEDContactorObserver::TEvent aEvent ) |
928 { |
854 { |
929 |
|
930 // This callback function simply propagates the events to its own listener. |
855 // This callback function simply propagates the events to its own listener. |
931 switch ( aEvent ) |
856 switch ( aEvent ) |
932 { |
857 { |
933 case MEDContactorObserver::ECommunicationStarted: |
858 case MEDContactorObserver::ECommunicationStarted: |
934 InformObservers( MDialingExtensionObserver::ECommunicationStarted ); |
859 InformObservers( MDialingExtensionObserver::ECommunicationStarted ); |
1052 // ----------------------------------------------------------------------------- |
976 // ----------------------------------------------------------------------------- |
1053 // |
977 // |
1054 void CEasyDialingPlugin::CachingStatus( TCachingStatus& aStatus, TInt& aError ) |
978 void CEasyDialingPlugin::CachingStatus( TCachingStatus& aStatus, TInt& aError ) |
1055 { |
979 { |
1056 OstTraceExt2( TRACE_NORMAL, CEASYDIALINGPLUGIN_CACHINGSTATUS, "PCS CachingStatus: %d, error: %d", ( TUint )( aStatus ), aError ); |
980 OstTraceExt2( TRACE_NORMAL, CEASYDIALINGPLUGIN_CACHINGSTATUS, "PCS CachingStatus: %d, error: %d", ( TUint )( aStatus ), aError ); |
|
981 |
|
982 switch ( aStatus ) |
|
983 { |
|
984 case ECacheUpdateContactRemoved: |
|
985 case ECacheUpdateContactModified: |
|
986 case ECacheUpdateContactAdded: |
|
987 TRAP_IGNORE( DoHandleContactsChangedL() ); |
|
988 break; |
|
989 default: |
|
990 break; |
|
991 } |
|
992 |
1057 LOGSTRING2("EasyDialingPlugin: PCS CachingStatus: %d, error: %d", aStatus, aError ); |
993 LOGSTRING2("EasyDialingPlugin: PCS CachingStatus: %d, error: %d", aStatus, aError ); |
1058 } |
994 } |
1059 |
995 |
1060 |
996 |
1061 // ----------------------------------------------------------------------------- |
997 // ----------------------------------------------------------------------------- |
1253 |
1189 |
1254 iContactLauncherActive = EFalse; |
1190 iContactLauncherActive = EFalse; |
1255 |
1191 |
1256 CAknAppUi* appUi = static_cast<CAknAppUi*>( iCoeEnv->AppUi() ); |
1192 CAknAppUi* appUi = static_cast<CAknAppUi*>( iCoeEnv->AppUi() ); |
1257 appUi->HandleCommandL( EPhoneCmdBlockingDialogClosed ); |
1193 appUi->HandleCommandL( EPhoneCmdBlockingDialogClosed ); |
1258 |
|
1259 // If contacts have been edited during contact launcher being open, a new search |
|
1260 // needs to be done. |
|
1261 if ( iNewSearchNeeded ) |
|
1262 { |
|
1263 // The cached information in contact data manager may be outdated. Call to reload makes sure that when the |
|
1264 // search is made, all data is loaded again. |
|
1265 iContactDataManager->Reload(); |
|
1266 |
|
1267 LaunchSearchL(); |
|
1268 } |
|
1269 |
1194 |
1270 // Give up focus, if iRememberFocus flag is not set. |
1195 // Give up focus, if iRememberFocus flag is not set. |
1271 if ( !iRememberFocus ) |
1196 if ( !iRememberFocus ) |
1272 { |
1197 { |
1273 SetFocus( EFalse ); |
1198 SetFocus( EFalse ); |
1984 // From MCoeForegroundObserver. |
1909 // From MCoeForegroundObserver. |
1985 // ----------------------------------------------------------------------------- |
1910 // ----------------------------------------------------------------------------- |
1986 // |
1911 // |
1987 void CEasyDialingPlugin::HandleGainingForeground() |
1912 void CEasyDialingPlugin::HandleGainingForeground() |
1988 { |
1913 { |
|
1914 if ( iNewSearchNeeded && IsEnabled() ) |
|
1915 { |
|
1916 // The cached information in contact data manager may be outdated. Call to reload makes sure that when the |
|
1917 // search is made, all data is loaded again. |
|
1918 iContactDataManager->Reload(); |
|
1919 |
|
1920 LaunchSearchL(); |
|
1921 } |
1989 } |
1922 } |
1990 |
1923 |
1991 // ----------------------------------------------------------------------------- |
1924 // ----------------------------------------------------------------------------- |
1992 // HandleLosingForeground |
1925 // HandleLosingForeground |
1993 // From MCoeForegroundObserver. |
1926 // From MCoeForegroundObserver. |
2021 // CEasyDialingPlugin::DoHandleContactsChangedL |
1954 // CEasyDialingPlugin::DoHandleContactsChangedL |
2022 // ----------------------------------------------------------------------------- |
1955 // ----------------------------------------------------------------------------- |
2023 // |
1956 // |
2024 void CEasyDialingPlugin::DoHandleContactsChangedL() |
1957 void CEasyDialingPlugin::DoHandleContactsChangedL() |
2025 { |
1958 { |
2026 if ( iSearchString.Length() > 0 ) |
1959 if ( iSearchString.Length() > 0 && IsEnabled() ) |
2027 { |
1960 { |
2028 if ( iContactLauncherActive ) |
1961 CAknAppUi* appUi = static_cast<CAknAppUi*>( iCoeEnv->AppUi() ); |
2029 { |
1962 if ( appUi->IsForeground() ) |
2030 // Set the flag to make a search when communication launcher exits. |
1963 { |
2031 iNewSearchNeeded = ETrue; |
1964 // Do new search immediately, if contacts change while we are on the |
2032 } |
1965 // foreground. This can happen for example if view is switched to |
2033 else |
1966 // dialer while deletion of multiple contacts is still ongoing or if |
2034 { |
1967 // PCS takes so long to update the cache that view gets changed |
2035 // We get here if user e.g. leaves dialer open and goes to Contacts |
1968 // before the update is ready. |
2036 // application and does some editing. |
|
2037 iContactDataManager->Reload(); // to update thumbnails |
1969 iContactDataManager->Reload(); // to update thumbnails |
2038 AsyncActionLaunchL( ELaunchSearch ); |
1970 AsyncActionLaunchL( ELaunchSearch ); |
|
1971 } |
|
1972 else |
|
1973 { |
|
1974 // Set the flag to make a search when we come back to foreground. |
|
1975 // This way, we don't make unnecessary searches when several |
|
1976 // contacts are imported or deleted, for example. |
|
1977 iNewSearchNeeded = ETrue; |
|
1978 |
|
1979 // Hide previous results so that they won't show up before the |
|
1980 // the new search is ready. |
|
1981 iContactListBox->MakeVisible( EFalse ); |
2039 } |
1982 } |
2040 } |
1983 } |
2041 } |
1984 } |
2042 |
1985 |
2043 // ----------------------------------------------------------------------------- |
1986 // ----------------------------------------------------------------------------- |
2125 if ( error == KErrNone ) |
2068 if ( error == KErrNone ) |
2126 { |
2069 { |
2127 iInfoLabelLine1->OverrideColorL( EColorLabelText, skinColor ); |
2070 iInfoLabelLine1->OverrideColorL( EColorLabelText, skinColor ); |
2128 iInfoLabelLine2->OverrideColorL( EColorLabelText, skinColor ); |
2071 iInfoLabelLine2->OverrideColorL( EColorLabelText, skinColor ); |
2129 } |
2072 } |
|
2073 } |
|
2074 |
|
2075 // ----------------------------------------------------------------------------- |
|
2076 // CEasyDialingPlugin::SetInfoLabelVisibleL |
|
2077 // ----------------------------------------------------------------------------- |
|
2078 // |
|
2079 void CEasyDialingPlugin::SetInfoLabelVisibleL( TBool aVisible ) |
|
2080 { |
|
2081 if ( aVisible ) |
|
2082 { |
|
2083 iInfoLabelLine1->SetTextL( *iInfoLabelTextLine1 ); |
|
2084 iInfoLabelLine2->SetTextL( *iInfoLabelTextLine2 ); |
|
2085 } |
|
2086 else |
|
2087 { |
|
2088 iInfoLabelLine1->SetTextL( KNullDesC ); |
|
2089 iInfoLabelLine2->SetTextL( KNullDesC ); |
|
2090 } |
|
2091 iInfoLabelLine1->DrawDeferred(); |
|
2092 iInfoLabelLine2->DrawDeferred(); |
2130 } |
2093 } |
2131 |
2094 |
2132 |
2095 |
2133 /* |
2096 /* |
2134 * ============================================================================== |
2097 * ============================================================================== |
2317 // |
2280 // |
2318 // Allocates a copy of the parameter descriptor with highlight separators |
2281 // Allocates a copy of the parameter descriptor with highlight separators |
2319 // removed. |
2282 // removed. |
2320 // ----------------------------------------------------------------------------- |
2283 // ----------------------------------------------------------------------------- |
2321 // |
2284 // |
2322 static HBufC* AllocWithoutHighlightSeparatorsLC( TDesC& aDesc ) |
2285 static HBufC* AllocWithoutHighlightSeparatorsLC( const TDesC& aDesc ) |
2323 { |
2286 { |
2324 HBufC* resultDesc = aDesc.AllocLC(); |
2287 HBufC* resultDesc = aDesc.AllocLC(); |
2325 TPtr ptr = resultDesc->Des(); |
2288 TPtr ptr = resultDesc->Des(); |
2326 AknTextUtils::StripCharacters( ptr, KHighlightSeparatorCharAsLiteral ); |
2289 AknTextUtils::StripCharacters( ptr, KHighlightSeparatorCharAsLiteral ); |
2327 return resultDesc; |
2290 return resultDesc; |