diff -r 35b64624a9e7 -r 36f374c67aa8 inc/msgcontacthandler.h --- a/inc/msgcontacthandler.h Wed Jun 23 18:09:17 2010 +0300 +++ b/inc/msgcontacthandler.h Tue Jul 06 14:12:40 2010 +0300 @@ -53,36 +53,56 @@ int& countPhoneNumber) { QContactManager phonebookManager; + QVariant address(contactNumber); + + // apply filter on phone number field QContactDetailFilter phoneFilter; - - phoneFilter.setDetailDefinitionName(QContactPhoneNumber::DefinitionName, - QContactPhoneNumber::FieldNumber); + phoneFilter.setDetailDefinitionName( + QContactPhoneNumber::DefinitionName, + QContactPhoneNumber::FieldNumber); - QVariant address(contactNumber); phoneFilter.setValue(address); phoneFilter.setMatchFlags(QContactFilter::MatchEndsWith); - QList matchingContacts = phonebookManager.contacts(phoneFilter); - if (matchingContacts.count() > 0) { // Fill the contact details QContact match = matchingContacts.at(0); displayName = match.displayLabel(); - QList numbers = + QList numbers = match.details (); countPhoneNumber = numbers.count(); return match.localId(); } - else // no matching contacts + + // apply filter on email address field + QContactDetailFilter emailFilter; + emailFilter.setDetailDefinitionName( + QContactEmailAddress::DefinitionName, + QContactEmailAddress::FieldEmailAddress); + + emailFilter.setValue(address); + emailFilter.setMatchFlags(QContactFilter::MatchExactly); + matchingContacts = phonebookManager.contacts(emailFilter); + if ( matchingContacts.count() > 0 ) { - displayName = contactNumber; - return -1; + // Fill the contact details + QContact match = matchingContacts.at(0); + + displayName = match.displayLabel(); + QList numbers = + match.details (); + countPhoneNumber = numbers.count(); + return match.localId(); } + + // no matching contact + displayName = contactNumber; + return -1; } - + /** * This shall resolve contact number with display name * @param contactNumber number to resolve