plugins/contacts/symbian/plugin/src/cntrelationshipgroup.cpp
changeset 5 603d3f8b6302
parent 0 876b1a06bc25
--- a/plugins/contacts/symbian/plugin/src/cntrelationshipgroup.cpp	Fri Sep 17 08:34:34 2010 +0300
+++ b/plugins/contacts/symbian/plugin/src/cntrelationshipgroup.cpp	Mon Oct 04 01:37:06 2010 +0300
@@ -114,6 +114,59 @@
     return true;
 }
 
+#ifdef SYMBIAN_BACKEND_USE_SQLITE
+/*!
+ * Save many relationships
+ * 
+ * \a affectedContactIds will include the affected contact ids 
+ * \a relationship to be saved
+ * \a error t
+ */
+bool CntRelationshipGroup::saveRelationshipsL(QSet<QContactLocalId> *affectedContactIds, QList<QContactRelationship> *relationships, QContactManager::Error* error)
+{
+    RArray<TContactItemId> idList;
+
+    if (relationships->count() == 0) {
+        return true;
+    }
+
+    QContactLocalId groupId = relationships->at(0).first().localId();
+    affectedContactIds->insert(groupId);
+    
+    foreach (QContactRelationship relationship, *relationships) {
+        affectedContactIds->insert(relationship.second().localId());
+        idList.AppendL(TContactItemId(relationship.second().localId()));
+    }
+
+    database()->AddContactsToGroupL(idList, TContactItemId(groupId));
+
+    *error = QContactManager::NoError;
+    return true;
+}
+
+bool CntRelationshipGroup::removeRelationshipsL(QSet<QContactLocalId> *affectedContactIds, const QList<QContactRelationship> &relationships, QContactManager::Error* error)
+{
+    RArray<TContactItemId> idList;
+
+    if (relationships.count() == 0) {
+        return true;
+    }
+
+    QContactLocalId groupId = relationships.at(0).first().localId();
+    affectedContactIds->insert(groupId);
+
+    foreach (QContactRelationship relationship, relationships) {
+        affectedContactIds->insert(relationship.second().localId());
+        idList.AppendL(TContactItemId(relationship.second().localId()));
+    }
+
+    database()->RemoveContactsFromGroupL(idList, TContactItemId(groupId));
+
+    *error = QContactManager::NoError;
+    return true;
+}
+#endif
+
 bool CntRelationshipGroup::validateRelationship(const QContactRelationship &relationship, QContactManager::Error* error)
 {
     // check that "second" is in this manager