void CntSimContactSaveRequest::run() { QContactSaveRequest *r = req<QContactSaveRequest>(); if (!r->isActive()) return; m_contacts = r->contacts(); m_errorMap.clear(); m_index = 0; writeNext(); }
void CntSimContactSaveRequest::writeNext() { QContactSaveRequest *r = req<QContactSaveRequest>(); if (!r->isActive()) return; if (r->contacts().count() == 0) { QContactManagerEngine::updateContactSaveRequest(r, QList<QContact>(), QContactManager::BadArgumentError, m_errorMap, QContactAbstractRequest::FinishedState); return; } // All contacts written? if (m_index >= m_contacts.count()) { // Take first error from errormap (if any) QContactManager::Error error = QContactManager::NoError; if (m_errorMap.count()) error = m_errorMap.begin().value(); QContactManagerEngine::updateContactSaveRequest(r, m_contacts, error, m_errorMap, QContactAbstractRequest::FinishedState); return; } // Get next contact QContact contact = m_contacts.at(m_index); // Validate & write contact QContactManager::Error error = QContactManager::NoError; if (engine()->validateContact(contact, &error)) simStore()->write(contact, &error); if (error) { m_errorMap.insert(m_index, error); m_index++; singleShotTimer(KRequestDelay, this, SLOT(writeNext())); } }