diff -r a32b19fb291e -r 5b14749788d7 inc/msgcontacthandler.h --- a/inc/msgcontacthandler.h Thu Jun 17 09:57:06 2010 +0100 +++ b/inc/msgcontacthandler.h Thu Jul 22 16:32:06 2010 +0100 @@ -52,37 +52,57 @@ QString& displayName, int& countPhoneNumber) { - QContactManager * phonebookManager; + QContactManager phonebookManager; + QVariant address(contactNumber); + + // apply filter on phone number field QContactDetailFilter phoneFilter; - phonebookManager = new QContactManager("symbian"); - 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); - + 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 @@ -161,17 +181,20 @@ if (versitDocuments.count() > 0) { QVersitContactImporter importer; - QList contacts = - importer.importContacts(versitDocuments); - // get display-name - if (contacts.count() > 0) + bool import_docs = importer.importDocuments(versitDocuments); + if(import_docs) { - //resolveSynthesizedDisplayLabel - QContactManager* contactManager = + QList contacts = importer.contacts(); + // get display-name + if (contacts.count() > 0) + { + //resolveSynthesizedDisplayLabel + QContactManager* contactManager = new QContactManager("symbian"); - displayName + displayName = contactManager->synthesizedDisplayLabel(contacts[0]); - delete contactManager; + delete contactManager; + } } } }