diff -r 90517678cc4f -r 453da2cfceef qtmobility/tests/auto/qcontactmanagerdataholder.h --- a/qtmobility/tests/auto/qcontactmanagerdataholder.h Mon May 03 13:18:40 2010 +0300 +++ b/qtmobility/tests/auto/qcontactmanagerdataholder.h Fri May 14 16:41:33 2010 +0300 @@ -47,6 +47,7 @@ #include #include #include +#include #include "qcontactmanager.h" @@ -70,20 +71,21 @@ { QStringList managerNames = QContactManager::availableManagers(); - foreach(QString mgr, managerNames) { + foreach(const QString& mgr, managerNames) { + // Don't bother with these + if (mgr == "memory" || mgr == "invalid" || mgr == "testdummy" || mgr == "maliciousplugin") + continue; QMap params; QString mgrUri = QContactManager::buildUri(mgr, params); QContactManager* cm = QContactManager::fromUri(mgrUri); if (cm) { - QList contacts; - foreach (const QContactLocalId id, cm->contactIds()) { - contacts.push_back(cm->contact(id)); - } + qDebug() << "Saving contacts for" << mgrUri; + QList contacts = cm->contacts(); savedContacts.insert(cm->managerName(),contacts); - QList ids = cm->contactIds(); - QMap errorMap; - cm->removeContacts(ids, &errorMap); - ids.clear(); + QList ids; + foreach(const QContact& contact, contacts) + ids.append(contact.localId()); + cm->removeContacts(ids, 0); delete cm; } } @@ -91,18 +93,13 @@ ~QContactManagerDataHolder() { - QStringList managerNames = QContactManager::availableManagers(); - - foreach(QString mgr, managerNames) { - QMap params; - QString mgrUri = QContactManager::buildUri(mgr, params); + foreach(const QString& mgrUri, savedContacts.keys()) { QContactManager* cm = QContactManager::fromUri(mgrUri); if (cm) { - QList contacts = savedContacts.value(cm->managerName()); - foreach(QContact c, contacts) { - c.setId(QContactId()); - cm->saveContact(&c); - } + qDebug() << "Restoring contacts for" << mgrUri; + QList contacts = savedContacts.value(mgrUri); + cm->saveContacts(&contacts, 0); + // XXX this doesn't restore relationships.. delete cm; } }