void Document::init(const QString& filePath, const QString& mimeType) { m_filePath = filePath; emit filePathChanged(); m_mimeType = mimeType; emit mimeTypeChanged(); setState(Document::Loading); if (!m_pages.isEmpty()) { emit aboutToReset(); clearPages(); } clearDocument(); m_loader = new DocumentLoader; QObject::connect(m_loader, SIGNAL(done()), this, SLOT(loaderDone())); QObject::connect(m_loader, SIGNAL(error()), this, SLOT(loaderError())); QObject::connect(m_loader, SIGNAL(locked()), this, SLOT(loaderLocked())); m_loader->start(m_filePath, m_mimeType); }
void AutoBoot::handleCommand(quint8 command, quint16 aux) { switch (command) { case 0x3F: // Speed poll { if (!sio->port()->writeCommandAck()) { return; } sio->port()->writeComplete(); QByteArray speed(1, 0); speed[0] = sio->port()->speedByte(); sio->port()->writeDataFrame(speed); qDebug() << "!n" << tr("[%1] Speed poll.").arg(deviceName()); break; } case 0x52: { /* Read sector */ if (loaded) { passToOldHandler(command, aux); return; } if (aux >= 1 && aux <= sectorCount) { if (!sio->port()->writeCommandAck()) { return; } if (!started) { emit booterStarted(); started = true; } QByteArray data; if (readSector(aux, data)) { sio->port()->writeComplete(); sio->port()->writeDataFrame(data); qDebug() << "!n" << tr("[%1] Read sector %2 (%3 bytes).") .arg(deviceName()) .arg(aux) .arg(data.size()); } else { sio->port()->writeError(); qCritical() << "!e" << tr("[%1] Read sector %2 failed.") .arg(deviceName()) .arg(aux); } } else { passToOldHandler(command, aux); } break; } case 0x53: { /* Get status */ if (loaded) { passToOldHandler(command, aux); return; } if (!sio->port()->writeCommandAck()) { return; } QByteArray status(4, 0); status[0] = 8; status[3] = 1; sio->port()->writeComplete(); sio->port()->writeDataFrame(status); qDebug() << "!n" << tr("[%1] Get status.") .arg(deviceName()); break; } case 0xFD: { if (!sio->port()->writeCommandAck()) { return; } qDebug() << "!n" << tr("[%1] Atari is jumping to %2.") .arg(deviceName()) .arg(aux); emit loaderDone(); sio->port()->writeComplete(); break; } case 0xFE: { /* Get chunk */ if(aux >= chunks.count()) { qDebug() << "!e" << tr("[%1] Invalid chunk in get chunk: aux = %2") .arg(deviceName()) .arg(aux); return; } if (!sio->port()->writeCommandAck()) { return; } qDebug() << "!n" << tr("[%1] Get chunk %2 (%3 bytes).") .arg(deviceName()) .arg(aux) .arg(chunks.at(aux).data.size()); sio->port()->writeComplete(); sio->port()->writeDataFrame(chunks.at(aux).data); emit blockRead(aux + 1, chunks.count()); break; } case 0xFF: { /* Get chunk info */ if(aux >= chunks.count()) { qDebug() << "!e" << tr("[%1] Invalid chunk in get chunk info: aux = %2") .arg(deviceName()) .arg(aux); return; } if (!sio->port()->writeCommandAck()) { return; } if (!loaded) { loaded = true; emit booterLoaded(); } QByteArray data; data[0] = chunks.at(aux).address % 256; data[1] = chunks.at(aux).address / 256; data[2] = 1; data[3] = chunks.size() != aux + 1; data[4] = chunks.at(aux).data.size() % 256; data[5] = chunks.at(aux).data.size() / 256; qDebug() << "!d" << tr("[%1] Get chunk info %2 (%3 bytes at %4).") .arg(deviceName()) .arg(aux) .arg(chunks.at(aux).data.size()) .arg(chunks.at(aux).address); sio->port()->writeComplete(); sio->port()->writeDataFrame(data); break; } default: passToOldHandler(command, aux); return; break; } }