qtmobility/plugins/contacts/symbian/src/filtering/cntfilterrelationship.cpp
changeset 4 90517678cc4f
parent 1 2b40d63a9c3d
child 11 06b8e2af4411
--- a/qtmobility/plugins/contacts/symbian/src/filtering/cntfilterrelationship.cpp	Fri Apr 16 15:51:22 2010 +0300
+++ b/qtmobility/plugins/contacts/symbian/src/filtering/cntfilterrelationship.cpp	Mon May 03 13:18:40 2010 +0300
@@ -40,7 +40,6 @@
 ****************************************************************************/
 
 #include "cntfilterrelationship.h"
-#include "qcontactrelationshipfilter.h"
 #include "cnttransformcontact.h"
 
 QTM_USE_NAMESPACE
@@ -64,29 +63,25 @@
         const QContactFilter &filter,
         const QList<QContactSortOrder> &sortOrders,
         bool &filterSupportedflag,
-        QContactManager::Error &error)  
+        QContactManager::Error *error)
 {
     Q_UNUSED(sortOrders);
     Q_UNUSED(filterSupportedflag);
     //Check if any invalid filter is passed 
     if(!filterSupported(filter) )
         {
-        error =  QContactManager::NotSupportedError;
+        *error =  QContactManager::NotSupportedError;
         return QList<QContactLocalId>();
         }
     QList<QContactLocalId> idList;
-    QContactRelationshipFilter relationfilter(filter);
- 
     QString sqlQuery;
-    getSqlquery(relationfilter,sqlQuery,error);
-    
-   
+    createSelectQuery(filter,sqlQuery,error);
     //fetch the contacts
-    idList =  m_srvConnection.searchContacts(sqlQuery, error);
+    if(*error == QContactManager::NoError )
+        {
+        idList =  m_srvConnection.searchContacts(sqlQuery, error);
+        }
     return idList;
-
-    
-    
 }
 
 
@@ -107,41 +102,41 @@
 
 void CntFilterRelationship::createSelectQuery(const QContactFilter& filter,
                               QString& sqlQuery,
-                              QContactManager::Error& error)
+                              QContactManager::Error* error)
 
 {
-    //Notthing done as of now
-    Q_UNUSED(filter);
-    Q_UNUSED(sqlQuery);
-    Q_UNUSED(error);
-    
+    if(!filterSupported(filter))
+    {
+      *error = QContactManager::NotSupportedError;
+      return;
+    }
+        
+    QContactRelationshipFilter relationfilter(filter);
+    QContactId  id_to_search = relationfilter.relatedContactId();
+
+    if(relationfilter.relatedContactRole() == QContactRelationship::First )
+    {
+        sqlQuery = QString("SELECT DISTINCT contact_group_member_id FROM  groups WHERE contact_group_id = %1").arg(id_to_search.localId());
+    }
+    else if(relationfilter.relatedContactRole() == QContactRelationship::Second )
+    {
+        sqlQuery = QString("SELECT DISTINCT contact_group_id FROM  groups WHERE contact_group_member_id = %1").arg(id_to_search.localId());
+    }
+    else if(relationfilter.relatedContactRole() == QContactRelationship::Either )
+    {
+        sqlQuery = QString("SELECT contact_group_member_id FROM  groups WHERE contact_group_id = %1").arg(id_to_search.localId());
+               + " union " + 
+               QString("SELECT DISTINCT  contact_group_id FROM  groups WHERE contact_group_id = %1").arg(id_to_search.localId());
+    }
 }
 
 
 void CntFilterRelationship::getSqlquery( const QContactRelationshipFilter& relationfilter,
                                                QString& sqlquery ,
-                                               QContactManager::Error& error) const
+                                               QContactManager::Error* error) const
 {
-
+    Q_UNUSED(relationfilter);
+    Q_UNUSED(sqlquery);
     Q_UNUSED(error);
-QContactId  id_to_search = relationfilter.otherParticipantId();
-
-if(relationfilter.role() == QContactRelationshipFilter::First )
-    {
-    sqlquery = QString("SELECT DISTINCT contact_group_id FROM  groups WHERE contact_group_member_id = %1").arg(id_to_search.localId());
-
-    }
-else if(relationfilter.role() == QContactRelationshipFilter::Second )
-    {
-    sqlquery = QString("SELECT DISTINCT contact_group_member_id FROM  groups WHERE contact_group_id = %1").arg(id_to_search.localId());
-
-    }
-else if(relationfilter.role() == QContactRelationshipFilter::Either )
-    {
-    sqlquery = QString("SELECT contact_group_member_id FROM  groups WHERE contact_group_id = %1").arg(id_to_search.localId());
-               + " union " + 
-               QString("SELECT DISTINCT  contact_group_id FROM  groups WHERE contact_group_id = %1").arg(id_to_search.localId());
-    }
-
 }