Example #1
0
void CntSimContactRemoveRequest::run()
{
    QContactRemoveRequest *r = req<QContactRemoveRequest>();
    
    if (!r->isActive())
        return;
       
    m_contactIds = r->contactIds();
    m_errorMap.clear();
    m_index = 0;
#ifdef SYMBIANSIM_BACKEND_CHECK_BEFORE_REMOVE
    m_reservedSlots.clear();
    getReservedSlots();    
#else
    removeNext();
#endif
}
Example #2
0
void CntSimContactRemoveRequest::removeNext()
{
    QContactRemoveRequest *r = req<QContactRemoveRequest>();
    
    if (!r->isActive())
        return;
    
    if (r->contactIds().count() == 0) {
        QContactManagerEngine::updateContactRemoveRequest(r, QContactManager::BadArgumentError, m_errorMap, QContactAbstractRequest::FinishedState);
        return;
    }        
    
    // All contacts removed?
    if (m_index >= m_contactIds.count())
    {
        // Take first error from errormap (if any)
        QContactManager::Error error = QContactManager::NoError;
        if (m_errorMap.count())
            error = m_errorMap.begin().value();

        QContactManagerEngine::updateContactRemoveRequest(r, error, m_errorMap, QContactAbstractRequest::FinishedState);
        return;
    }

    // Remove next contact
    QContactLocalId contactId = m_contactIds.at(m_index);
    QContactManager::Error error = QContactManager::NoError;
    
#ifdef SYMBIANSIM_BACKEND_CHECK_BEFORE_REMOVE
    if (m_reservedSlots.contains(contactId))
        simStore()->remove(contactId, &error);
    else
        error = QContactManager::DoesNotExistError;
#else
    simStore()->remove(contactId, &error);
#endif

    if (error) {
        m_errorMap.insert(m_index, error);
        m_index++;
        singleShotTimer(KRequestDelay, this, SLOT(removeNext()));
    }
}