messagingapp/msgappfw/server/src/ccscontactsresolver.cpp
branchGCC_SURGE
changeset 47 5b14749788d7
parent 27 e4592d119491
parent 44 36f374c67aa8
--- a/messagingapp/msgappfw/server/src/ccscontactsresolver.cpp	Thu Jun 17 09:57:06 2010 +0100
+++ b/messagingapp/msgappfw/server/src/ccscontactsresolver.cpp	Thu Jul 22 16:32:06 2010 +0100
@@ -16,7 +16,7 @@
  */
 
 // SYSTEM INCLUDES
-#include "qtcontacts.h" 
+#include "qtcontacts.h"
 #include "qcontactdetailfilter.h"
 #include <QList>
 
@@ -50,21 +50,37 @@
         const QString &address,
         CCsContactDetail &contactDetail)
     {
+    // apply filter on phone number field
     QContactDetailFilter phoneFilter;
     phoneFilter.setDetailDefinitionName(
-            QContactPhoneNumber::DefinitionName, 
+            QContactPhoneNumber::DefinitionName,
             QContactPhoneNumber::FieldNumber);
-    
+
     phoneFilter.setValue(address);
     phoneFilter.setMatchFlags(QContactFilter::MatchEndsWith);
-
     QList<QContact> matchingContacts = mPhonebookManager->contacts(phoneFilter);
+    if ( matchingContacts.count() > 0 ) {
+        QContact match = matchingContacts.at(0);
+        // Fill the contact details
+        contactDetail.contactId = match.localId();
+        contactDetail.displayName = match.displayLabel();
+        return true;
+    }
 
-    if ( matchingContacts.count() > 0 ) {	        
+    // apply filter on email address field
+    QContactDetailFilter emailFilter;
+    emailFilter.setDetailDefinitionName(
+            QContactEmailAddress::DefinitionName,
+            QContactEmailAddress::FieldEmailAddress);
+
+    emailFilter.setValue(address);
+    emailFilter.setMatchFlags(QContactFilter::MatchExactly);
+    matchingContacts = mPhonebookManager->contacts(emailFilter);
+    if ( matchingContacts.count() > 0 ) {
         QContact match = matchingContacts.at(0);
-        // Fill the contact details        
+        // Fill the contact details
         contactDetail.contactId = match.localId();
-        contactDetail.displayName = match.displayLabel();   
+        contactDetail.displayName = match.displayLabel();
         return true;
     }
     return false;
@@ -76,14 +92,14 @@
 // ----------------------------------------------------------------------------
 void CCsContactsResolver::resolveContactId(
         const quint32 &contactId,
-        CCsContactDetail &contactDetail)	
+        CCsContactDetail &contactDetail)
     {
     // Fetch back the persisted contact
     QContact contact = mPhonebookManager->contact(contactId);
-    contactDetail.contactId = contact.localId(); 
-    
+    contactDetail.contactId = contact.localId();
+
     contactDetail.displayName = contact.displayLabel();
-        
+
     QList<QContactPhoneNumber> numbers = contact.details<QContactPhoneNumber>();
     int numberCount = numbers.count();
 
@@ -91,7 +107,16 @@
         {
         QString phoneNumber= numbers.at(a).number();
         contactDetail.addressList.append(phoneNumber);
-        }    
+        }
+
+    QList<QContactEmailAddress> emailAddresses = contact.details<QContactEmailAddress>();
+    int emailCount = emailAddresses.count();
+
+    for ( int a=0; a<emailCount ;++a)
+        {
+        QString emailAddr= emailAddresses.at(a).emailAddress();
+        contactDetail.addressList.append(emailAddr);
+        }
     }
 
 // EOF