void MediaDownload::startRequest(unsigned position, unsigned size)
{
    Q_ASSERT(m_url.isValid());

    if (m_task)
    {
        m_task->abortLater();
        m_task->deleteLater();
    }

    m_task = new MediaDownloadTask;
    m_task->moveToThread(m_thread);

    connect(m_task, SIGNAL(requestReady(uint)), SLOT(requestReady(uint)),
            Qt::DirectConnection);
    connect(m_task, SIGNAL(dataRead(QByteArray,uint)), SLOT(incomingData(QByteArray,uint)),
            Qt::DirectConnection);
    connect(m_task, SIGNAL(finished()), SLOT(taskFinished()), Qt::DirectConnection);
    connect(m_task, SIGNAL(error(QString)), SLOT(taskError(QString)), Qt::DirectConnection);

    /* If size will reach the end of what we believe the file size to be, make it infinite instead,
     * to ease behavior with still active files */
    if (position + size >= m_fileSize)
        size = 0;

    bool ok = m_task->metaObject()->invokeMethod(m_task, "start", Q_ARG(QUrl, m_url),
                                                 Q_ARG(QList<QNetworkCookie>, m_cookies),
                                                 Q_ARG(unsigned, position),
                                                 Q_ARG(unsigned, size));
    Q_ASSERT(ok);
    Q_UNUSED(ok);
}
Beispiel #2
0
void taskErrorHook(xTaskHandle handle, signed portCHAR *name, portBASE_TYPE error) {
    printf("\nSafeRTOS Error: task=\"%s\": %s (handle = 0x%08lx)\n", name, taskError(error), (unsigned long)handle);
    fatal();
}
Beispiel #3
0
void Client::notifyTaskError( const Oscar::SNAC& s, int errCode, bool fatal )
{
	emit taskError( s, errCode, fatal );
}