| 384 | } |
| 385 | |
| 386 | void CUpDownClient::ProcessFileStatus(bool bUdpPacket, const CMemFile* data, const CPartFile* file) |
| 387 | { |
| 388 | // 0.42e |
| 389 | wxString strReqFileNull("ERROR: Wrong file ID (ProcessFileStatus; m_reqfile==NULL)"); |
| 390 | |
| 391 | if ( !m_reqfile || file != m_reqfile ){ |
| 392 | if (!m_reqfile) { |
| 393 | throw strReqFileNull; |
| 394 | } |
| 395 | throw wxString("ERROR: Wrong file ID (ProcessFileStatus; m_reqfile!=file)"); |
| 396 | } |
| 397 | |
| 398 | uint16 nED2KPartCount = data->ReadUInt16(); |
| 399 | |
| 400 | m_reqfile->UpdatePartsFrequency( this, false ); // Decrement |
| 401 | m_downPartStatus.clear(); |
| 402 | |
| 403 | bool bPartsNeeded = false; |
| 404 | if (!nED2KPartCount) |
| 405 | { |
| 406 | m_nPartCount = m_reqfile->GetPartCount(); |
| 407 | m_downPartStatus.setsize( m_nPartCount, 1); |
| 408 | bPartsNeeded = true; |
| 409 | m_bCompleteSource = true; |
| 410 | } |
| 411 | else |
| 412 | { |
| 413 | // Somehow this happened. |
| 414 | if (!m_reqfile) { |
| 415 | throw strReqFileNull; |
| 416 | } |
| 417 | if (m_reqfile->GetED2KPartCount() != nED2KPartCount) |
| 418 | { |
| 419 | wxString strError; |
| 420 | strError << "ProcessFileStatus - wrong part number recv=" << nED2KPartCount << |
| 421 | " expected=" << m_reqfile->GetED2KPartCount() << " " << |
| 422 | m_reqfile->GetFileHash().Encode(); |
| 423 | m_nPartCount = 0; |
| 424 | throw strError; |
| 425 | } |
| 426 | m_nPartCount = m_reqfile->GetPartCount(); |
| 427 | |
| 428 | m_bCompleteSource = false; |
| 429 | m_downPartStatus.setsize( m_nPartCount, 0 ); |
| 430 | uint16 done = 0; |
| 431 | |
| 432 | try { |
| 433 | while (done != m_nPartCount) { |
| 434 | uint8 toread = data->ReadUInt8(); |
| 435 | |
| 436 | for ( uint8 i = 0;i < 8; i++ ) { |
| 437 | bool status = ((toread>>i)&1)? 1:0; |
| 438 | m_downPartStatus.set(done, status); |
| 439 | |
| 440 | if (status) { |
| 441 | if (!m_reqfile->IsComplete(done)){ |
| 442 | bPartsNeeded = true; |
| 443 | } |
no test coverage detected