Пример #1
0
	void write(Field* f, Chunk* chn)
	{
		int dy = 2;
		for (int y = 3; y < Field::HEIGHT; y++)
			add(y + dy, "      " + f->line(y));

		writeNext(chn, dy);
		writeScore(f->score, dy);
	}
void CntSimContactSaveRequest::writeComplete(QContact contact, QContactManager::Error error)
{
    if (!req()->isActive())
        return;
    
    if (error)
        m_errorMap.insert(m_index, error);
    engine()->updateDisplayLabel(contact);
    m_contacts[m_index] = contact;
    m_index++;
    singleShotTimer(KRequestDelay, this, SLOT(writeNext()));
}
void CntSimContactSaveRequest::run()
{
    QContactSaveRequest *r = req<QContactSaveRequest>();
    
    if (!r->isActive())
        return;
    
    m_contacts = r->contacts();
    m_errorMap.clear();
    m_index = 0;
    
    writeNext();
}
Пример #4
0
/*!
    Write \a len bytes from \a data to this encoder.  The length must be
    a multiple of 2, and the data should consist of 16-bit samples at 8000 Hz,
    one channel.  The samples should be in host byte order.
*/
qint64 CommonEncodeStream::writeData( const char *data, qint64 len )
{
    int requiredBytes = _payloadSize * 2;
    int temp = (int)len;
    int enclen;
    while ( temp > 1 ) {
        if ( size == 0 && (((long)data) & 1) == 0 && temp >= requiredBytes ) {

            // Encode a full packet direct from the supplied input buffer.
            enclen = encode( (short *)data, frameout );
            writeNext( ( const char *)frameout, enclen );
            data += requiredBytes;
            temp -= requiredBytes;

        } else if ( ( size * 2 + temp ) >= requiredBytes ) {

            // Fill the framein buffer and then encode it.
            int copy = requiredBytes - size * 2;
            memcpy( framein + size, data, copy );
            enclen = encode( framein, frameout );
            writeNext( ( const char *)frameout, enclen );
            data += copy;
            temp -= copy;
            size = 0;

        } else {

            // Not enough bytes yet - copy as many as we can.
            memcpy( framein + size, data, temp );
            size += temp / 2;
            data += temp;
            temp = 0;

        }
    }
    return len;
}
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()));
    }
}