示例#1
0
/** called on UI thread when request is completed */
void Task::onComplete() {
	if (!_complete.empty()) {
		for (auto i : _complete) {
			i(_target, isSuccessful());
		}
	}
}
示例#2
0
void rBootHttpUpdate::onTimer() {
	
	if (TcpClient::isProcessing()) return; // Will wait
	
	if (TcpClient::getConnectionState() == eTCS_Successful) {
		
		if (!isSuccessful()) {
			updateFailed();
			return;
		}
		
		currentItem++;
		if (currentItem >= items.count()) {
			debugf("\r\nFirmware download finished!");
			for (int i = 0; i < items.count(); i++) {
				debugf(" - item: %d, addr: %X, len: %d bytes", i, items[i].targetOffset, items[i].size);
			}
			
			applyUpdate();
			return;
		}
		
	} else if (TcpClient::getConnectionState() == eTCS_Failed) {
		updateFailed();
		return;
	}
	
	rBootHttpUpdateItem &it = items[currentItem];
	debugf("Download file:\r\n    (%d) %s -> %X", currentItem, it.url.c_str(), it.targetOffset);
	rBootWriteStatus = rboot_write_init(items[currentItem].targetOffset);
	startDownload(URL(it.url), eHCM_UserDefined, NULL);
}
示例#3
0
void HttpClient::onFinished(TcpClientState finishState)
{
	if (finishState == eTCS_Failed) code = 0;

	if (mode == eHCM_File)
	{
		debugf("Download file len written: %d, res^ %d", fileTell(saveFile), isSuccessful());
		if (!isSuccessful())
			fileDelete(saveFile);
		fileClose(saveFile);
	}

	if (onCompleted)
		onCompleted(*this, isSuccessful());

	TcpClient::onFinished(finishState);
}
void HttpFirmwareUpdate::onTimer()
{
	if (HttpClient::isProcessing()) return; // Will wait

	if (TcpClient::getConnectionState() == eTCS_Successful)
	{
		if (!isSuccessful())
		{
			updateFailed();
			return;
		}

		items[currentItem].size = pos - items[currentItem].flash;
		currentItem++;
		if (currentItem >= items.count())
		{
			debugf("\r\nFirmware download finished!");
			for (int i = 0; i < items.count(); i++)
				debugf("\t item: 0x%X 0x%X %d bytes", items[i].targetOffset, items[i].flash - INTERNAL_FLASH_START_ADDRESS, items[i].size);

			applyUpdate();
			return;
		}
		HttpFirmwareUpdateItem &prev = items[currentItem - 1];
		HttpFirmwareUpdateItem &cur = items[currentItem];
		int jmp = cur.targetOffset - prev.targetOffset - prev.size;
		pos += jmp;
		debugf("jump: %d", jmp);
	}
	else if (TcpClient::getConnectionState() == eTCS_Failed)
	{
		updateFailed();
		return;
	}

	HttpFirmwareUpdateItem &it = items[currentItem];
//	uint32_t sect = flashmem_get_sector_of_address(pos);
//	sect++;
//	pos = INTERNAL_FLASH_START_ADDRESS + sect * INTERNAL_FLASH_SECTOR_SIZE;
	it.flash = pos;
	debugf("Download file:\r\n    (%d) %s -> 0x%X", currentItem, it.url.c_str(), it.targetOffset);
	startDownload(URL(it.url), eHCM_UserDefined, NULL);
}
示例#5
0
    bool exec() override
    {
        Q_UNIMPLEMENTED();
//         m_reply->exec();
        return isSuccessful();
    }
示例#6
0
 bool exec() override
 {
     start();
     m_socket->waitForReadyRead();
     return isSuccessful();
 }