--- a/phoneuis/easydialing/src/easydialingplugin.cpp Thu Jul 15 18:38:16 2010 +0300
+++ b/phoneuis/easydialing/src/easydialingplugin.cpp Thu Aug 19 09:54:27 2010 +0300
@@ -46,9 +46,6 @@
// Virtual phonebook header files
#include <VPbkContactStoreUris.h>
-#include <CVPbkContactStoreUriArray.h>
-#include <TVPbkContactStoreUriPtr.h>
-#include <CVPbkContactLinkArray.h>
#include <VPbkEng.rsg> // contains virtual phonebook data fields
#include <phoneui.rsg>
@@ -181,19 +178,10 @@
//
void CEasyDialingPlugin::ConstructL()
{
- // Create a contact store array.
- HBufC* defaultCdb = VPbkContactStoreUris::DefaultCntDbUri().AllocLC();
- iContactDataStores.AppendL( defaultCdb );
- CleanupStack::Pop( defaultCdb );
-
- // Create a contact manager instance.
- iContactStoreUriArray = CVPbkContactStoreUriArray::NewL();
- iContactStoreUriArray->AppendL( TVPbkContactStoreUriPtr( VPbkContactStoreUris::DefaultCntDbUri() ) );
- iContactManager = CVPbkContactManager::NewL( *iContactStoreUriArray );
-
- iContactDataManager = new (ELeave) CEasyDialingContactDataManager(iContactManager);
- iContactDataManager->ConstructL();
- iContactDataManager->SetObserver(this);
+ iLongTapped = EFalse;
+ // Create contact data manager.
+ iContactDataManager = CEasyDialingContactDataManager::NewL();
+ iContactDataManager->SetObserver( this );
// Find a handle to ca launcher extension MCCAConnectionExt.
// Easydialing has to use the extension API, because it needs function CloseAppL
@@ -211,7 +199,7 @@
User::LeaveIfNull( any );
iContactLauncher = static_cast<MCCAConnectionExt*>( any );
- iCenrepListener = CEasyDialingCenrepListener::NewL(this);
+ iCenrepListener = CEasyDialingCenrepListener::NewL( this );
iContactorService = CEDContactorService::NewL( this );
@@ -242,8 +230,6 @@
delete iCenrepListener;
delete iContactDataManager;
delete iPredictiveSearchQuery;
- delete iContactManager;
- delete iContactStoreUriArray;
iContactDataStores.ResetAndDestroy();
if ( iPredictiveContactSearchHandler )
@@ -406,10 +392,6 @@
iPredictiveContactSearchHandler = CPSRequestHandler::NewL();
iPredictiveContactSearchHandler->AddObserverL(this);
- // Put the searched contact fields into array.
- RArray<TInt> contact_fields;
- CleanupClosePushL(contact_fields);
-
// Check which relevant contact fields are indexed in PCS search.
iFirstNamePCSIndex = FindContactFieldPCSIndexL( R_VPBK_FIELD_TYPE_FIRSTNAME );
iLastNamePCSIndex = FindContactFieldPCSIndexL( R_VPBK_FIELD_TYPE_LASTNAME );
@@ -433,32 +415,48 @@
User::Leave( KErrEasyDialingNoLastNamePCSIndexing );
}
- // First name, last name and company name (if supported) are used in PCS search.
- contact_fields.Append(R_VPBK_FIELD_TYPE_FIRSTNAME);
- contact_fields.Append(R_VPBK_FIELD_TYPE_LASTNAME);
- if ( iCompanyNamePCSIndex != KErrNotFound )
- {
- contact_fields.Append(R_VPBK_FIELD_TYPE_COMPANYNAME);
- }
+ SetupPcsSettingsL();
+
+ iPredictiveSearchQuery = CPsQuery::NewL();
+ }
- SetSortOrderL( iContactDataManager->NameOrder() );
+// -----------------------------------------------------------------------------
+// SetupPcsSettingsL
+// -----------------------------------------------------------------------------
+//
+void CEasyDialingPlugin::SetupPcsSettingsL()
+ {
+ // Get current store configuration from Phonebook settings
+ iContactDataStores.ResetAndDestroy();
+ iContactDataManager->GetCurrentStoreUrisL( iContactDataStores );
+
+ // Put the searched contact fields into array.
+ RArray<TInt> contact_fields;
+ CleanupClosePushL(contact_fields);
- // Create and fill ps settings object.
+ // First name, last name and company name (if supported) are used in PCS search.
+ contact_fields.Append( R_VPBK_FIELD_TYPE_FIRSTNAME );
+ contact_fields.Append( R_VPBK_FIELD_TYPE_LASTNAME );
+ contact_fields.Append( R_VPBK_FIELD_TYPE_COMPANYNAME );
+
+ // Create and fill PS settings object.
CPsSettings* ps_settings = CPsSettings::NewL();
- CleanupStack::PushL(ps_settings);
+ CleanupStack::PushL( ps_settings );
- ps_settings->SetSearchUrisL(iContactDataStores);
- ps_settings->SetMaxResults(KEDMaximumMatchingContactsCount);
- ps_settings->SetSortType(EAlphabetical);
- ps_settings->SetDisplayFieldsL(contact_fields);
+ ps_settings->SetSearchUrisL( iContactDataStores );
+ ps_settings->SetMaxResults( KEDMaximumMatchingContactsCount );
+ ps_settings->SetSortType( EAlphabetical );
+ ps_settings->SetDisplayFieldsL( contact_fields );
// Set the PCS settings.
- iPredictiveContactSearchHandler->SetSearchSettingsL(*ps_settings);
+ iPredictiveContactSearchHandler->SetSearchSettingsL( *ps_settings );
- CleanupStack::PopAndDestroy(ps_settings);
- CleanupStack::PopAndDestroy(&contact_fields);
+ CleanupStack::PopAndDestroy( ps_settings );
+ CleanupStack::PopAndDestroy( &contact_fields );
- iPredictiveSearchQuery = CPsQuery::NewL();
+ // Set the sort order. This must happen after the contact store settings
+ // are up-to-date.
+ SetSortOrderL( iContactDataManager->NameOrder() );
}
// -----------------------------------------------------------------------------
@@ -471,19 +469,22 @@
CleanupClosePushL( fields );
if ( aNameOrder == CEasyDialingContactDataManager::EFirstnameLastname )
{
- fields.Append(R_VPBK_FIELD_TYPE_FIRSTNAME);
- fields.Append(R_VPBK_FIELD_TYPE_LASTNAME);
+ fields.AppendL( R_VPBK_FIELD_TYPE_FIRSTNAME );
+ fields.AppendL( R_VPBK_FIELD_TYPE_LASTNAME );
}
else
{
- fields.Append(R_VPBK_FIELD_TYPE_LASTNAME);
- fields.Append(R_VPBK_FIELD_TYPE_FIRSTNAME);
+ fields.AppendL( R_VPBK_FIELD_TYPE_LASTNAME );
+ fields.AppendL( R_VPBK_FIELD_TYPE_FIRSTNAME );
}
- if ( iCompanyNamePCSIndex != KErrNotFound )
+ fields.AppendL( R_VPBK_FIELD_TYPE_COMPANYNAME );
+
+ // Set the same order for each contact store. PCS automatically ignores
+ // fields not supported by the given store.
+ for ( TInt i = 0 ; i < iContactDataStores.Count() ; ++i )
{
- fields.Append(R_VPBK_FIELD_TYPE_COMPANYNAME);
+ iPredictiveContactSearchHandler->ChangeSortOrderL( *iContactDataStores[i], fields );
}
- iPredictiveContactSearchHandler->ChangeSortOrderL( *iContactDataStores[0], fields );
CleanupStack::PopAndDestroy( &fields );
}
@@ -846,6 +847,22 @@
}
// -----------------------------------------------------------------------------
+// StoreConfigurationChanged
+// From MContactDataManagerObserver
+// -----------------------------------------------------------------------------
+//
+void CEasyDialingPlugin::StoreConfigurationChanged()
+ {
+ TRAP_IGNORE(
+ // Reconfigure PCS to update its store settings
+ SetupPcsSettingsL();
+ // Contacts available have changed and a new search is needed if we have
+ // previous results shown.
+ DoHandleContactsChangedL()
+ );
+ }
+
+// -----------------------------------------------------------------------------
// InformContactorEvent
// From MEDContactorObserver
// -----------------------------------------------------------------------------
@@ -915,7 +932,10 @@
// not to the keyboard it is made with. While this is not strictly
// identical to checking the used keyboard, this behaves identically
// in most of the normal cases, and makes the logic simpler.
- if ( IsItuTCharacter( iSearchString[i] ) )
+ // In case of hybrid mode keyboard, use always predictive default
+ // keyboard.
+ if ( iKeyboardMode == EDefaultKeyboard &&
+ IsItuTCharacter( iSearchString[i] ) )
{
item->SetMode( EPredictiveItuT );
}
@@ -1005,8 +1025,10 @@
RArray<TInt> fieldOrder;
CleanupClosePushL( fieldOrder );
- // Current implementation searches only from default database.
- // Later this may be expanded to search SIM contacts as well.
+ // PCS uses the same data plugin for all the Phonebook databases
+ // (i.e. phone contacts, SIM contacts, SDN contacts), and there can be only
+ // one data order per plugin. Thus, data order for all databases supported
+ // by us is the same, and it's enough to ask data order just for the default CDB.
const TDesC& defaultCdb = VPbkContactStoreUris::DefaultCntDbUri();
iPredictiveContactSearchHandler->GetDataOrderL( defaultCdb, fieldOrder );
@@ -1072,7 +1094,7 @@
TInt indexFromEnd = numberOfPCSMatches - i - 1;
MVPbkContactLink* link = iPredictiveContactSearchHandler->ConvertToVpbkLinkLC(
- *(aResults[indexFromEnd]), *iContactManager );
+ *(aResults[indexFromEnd]), iContactDataManager->ContactManager() );
if ( !iContactDataManager->IsFavL( link ) )
{
// handle favourites separately, in another loop
@@ -1439,8 +1461,9 @@
message = iContactDataManager->UniEditorAvailable( index );
}
- // Call menu item is not show if neither voice call nor video call are possible.
- aMenuPane.SetItemDimmed( EEasyDialingVoiceCall, !voiceCall && !videoCall );
+
+ aMenuPane.SetItemDimmed( EEasyDialingVoiceCall, !voiceCall );
+ aMenuPane.SetItemDimmed( EEasyDialingVideoCall, !videoCall );
aMenuPane.SetItemDimmed( EEasyDialingSendMessage, !message );
LOGSTRING("EasyDialingPlugin::InitializeMenuPaneL: InitializeMenuPaneL done" );
@@ -1448,27 +1471,6 @@
return ETrue;
}
- else if ( aMenuResourceId == R_EASYDIALING_OPTIONS_CALL_MENU )
- {
- TBool voiceCall = EFalse;
- TBool videoCall = EFalse;
-
- if ( iContactListBox->CurrentItemIndex() >= 0 )
- {
- TInt index = iContactListBox->CurrentContactDataIndex();
-
- voiceCall = iContactDataManager->VoiceCallAvailable( index );
- videoCall = iContactDataManager->VideoCallAvailable( index );
- }
-
- aMenuPane.SetItemDimmed( EEasyDialingVoiceCall, !voiceCall );
- aMenuPane.SetItemDimmed( EEasyDialingVideoCall, !videoCall );
-
- LOGSTRING("EasyDialingPlugin::InitializeMenuPaneL: InitializeMenuPaneL for call submenu done" );
-
- return ETrue;
- }
-
else if ( aMenuResourceId == R_EASYDIALING_OPTIONS_ON_OFF_CASCADE_MENU )
{
if ( IsEnabled() )
@@ -1512,7 +1514,7 @@
}
- TBool ret(EFalse);
+ TBool ret(ETrue);
switch ( aCommand )
{
@@ -1520,7 +1522,6 @@
iRememberFocus = ETrue;
AsyncActionLaunchL( ELaunchCurrentContact );
- ret = ETrue;
break;
// EEasyDialingEnterKeyAction is sent when Enter key is pressed.
@@ -1530,7 +1531,6 @@
// Make a call.
iRememberFocus = ETrue;
AsyncActionLaunchL( ECallCurrentContact );
- ret = ETrue;
break;
// Video call is selectable only through menu.
@@ -1538,7 +1538,6 @@
// Make a video call.
iRememberFocus = ETrue;
AsyncActionLaunchL( EVideoCallCurrentContact );
- ret = ETrue;
break;
// Uni-editor message is selectable only through menu.
@@ -1546,7 +1545,6 @@
// Create a message.
iRememberFocus = ETrue;
AsyncActionLaunchL( ESendMessageCurrentContact );
- ret = ETrue;
break;
// EEasyDialingCallHandlingActivated is sent when the in-call-ui of telephony gets activated
@@ -1563,41 +1561,37 @@
iNewSearchNeeded = EFalse;
iContactLauncher->CloseAppL();
}
- ret = ETrue;
break;
case EEasyDialingOn:
iCenrepListener->SetEasyDialingSettingsValue( 1 );
- ret = ETrue;
break;
case EEasyDialingOff:
iCenrepListener->SetEasyDialingSettingsValue( 0 );
- ret = ETrue;
break;
case EEasyDialingClosePopup:
// Not only Number Entry is removed but also closes down number selection popup in case it happens to be open.
iContactorService->CancelService();
- ret = ETrue;
break;
case EEasyDialingVkbOpened:
iVirtualKeyboardOpen = ETrue;
- ret = ETrue;
break;
case EEasyDialingVkbClosed:
iVirtualKeyboardOpen = EFalse;
- ret = ETrue;
+ HandleGainingForeground();
break;
default:
+ ret = EFalse;
break;
}
return ret;
@@ -1614,6 +1608,16 @@
}
// -----------------------------------------------------------------------------
+// SetKeyboardMode
+// Sets keyboard mode
+// -----------------------------------------------------------------------------
+//
+void CEasyDialingPlugin::SetKeyboardMode( TKeyboardMode aMode )
+ {
+ iKeyboardMode = aMode;
+ }
+
+// -----------------------------------------------------------------------------
// AsyncSimulateKeyEvent
//
// -----------------------------------------------------------------------------
@@ -1725,7 +1729,7 @@
//
// -----------------------------------------------------------------------------
//
-void CEasyDialingPlugin::DoLaunchActionL( )
+void CEasyDialingPlugin::DoLaunchActionL()
{
if ( iActionToBeLaunched == EInitializePcs )
{
@@ -1862,6 +1866,7 @@
break;
case KEasyDialingContactLongTapped:
+ iLongTapped = ETrue;
AsyncActionLaunchL( ELaunchCurrentContact );
break;
@@ -1883,11 +1888,12 @@
// Touching the listbox always removes the visual focus from any list item.
// Move the focus away from the listbox after panning has ended to
// align our internal state with the visual lack of focus.
- if ( IsFocused() )
+ if ( IsFocused() && !iLongTapped )
{
SetFocus( EFalse );
DrawDeferred();
}
+ iLongTapped = EFalse;
break;
// We are not interested about the other listbox events.
@@ -1923,7 +1929,7 @@
// search is made, all data is loaded again.
iContactDataManager->Reload();
- LaunchSearchL();
+ TRAP_IGNORE( LaunchSearchL() );
}
}
@@ -1965,7 +1971,7 @@
if ( iSearchString.Length() > 0 && IsEnabled() )
{
CAknAppUi* appUi = static_cast<CAknAppUi*>( iCoeEnv->AppUi() );
- if ( appUi->IsForeground() )
+ if ( appUi->IsForeground() && !iVirtualKeyboardOpen )
{
// Do new search immediately, if contacts change while we are on the
// foreground. This can happen for example if view is switched to