| 2624 | |
| 2625 | |
| 2626 | void CPartFile::PauseFile(bool bInsufficient) |
| 2627 | { |
| 2628 | SetActive(false); |
| 2629 | |
| 2630 | if ( status == PS_COMPLETE || status == PS_COMPLETING ) { |
| 2631 | return; |
| 2632 | } |
| 2633 | |
| 2634 | if (GetKadFileSearchID()) { |
| 2635 | Kademlia::CSearchManager::StopSearch(GetKadFileSearchID(), true); |
| 2636 | // If we were in the middle of searching, reset timer so they can resume searching. |
| 2637 | m_LastSearchTimeKad = 0; |
| 2638 | } |
| 2639 | |
| 2640 | m_iLastPausePurge = time(NULL); |
| 2641 | |
| 2642 | theApp->downloadqueue->RemoveLocalServerRequest(this); |
| 2643 | |
| 2644 | CPacket packet( OP_CANCELTRANSFER, 0, OP_EDONKEYPROT ); |
| 2645 | for( SourceSet::iterator it = m_SrcList.begin(); it != m_SrcList.end(); ) { |
| 2646 | CUpDownClient* cur_src = it++->GetClient(); |
| 2647 | if (cur_src->GetDownloadState() == DS_DOWNLOADING) { |
| 2648 | if (!cur_src->GetSentCancelTransfer()) { |
| 2649 | theStats::AddUpOverheadOther( packet.GetPacketSize() ); |
| 2650 | AddDebugLogLineN( logLocalClient, "Local Client: OP_CANCELTRANSFER to " + cur_src->GetFullIP() ); |
| 2651 | cur_src->SendPacket( &packet, false, true ); |
| 2652 | cur_src->SetSentCancelTransfer( true ); |
| 2653 | } |
| 2654 | cur_src->SetDownloadState(DS_ONQUEUE); |
| 2655 | // Allow immediate reconnect on resume |
| 2656 | cur_src->ResetLastAskedTime(); |
| 2657 | } |
| 2658 | } |
| 2659 | |
| 2660 | |
| 2661 | m_insufficient = bInsufficient; |
| 2662 | if (!m_paused) { |
| 2663 | MarkMetDirty(); |
| 2664 | // EC exports IsStopped() / GetStatus(); see StopFile comment. |
| 2665 | MarkECChanged(); |
| 2666 | } |
| 2667 | m_paused = true; |
| 2668 | |
| 2669 | |
| 2670 | kBpsDown = 0.0; |
| 2671 | transferingsrc = 0; |
| 2672 | |
| 2673 | SetStatus(status); |
| 2674 | } |
| 2675 | |
| 2676 | |
| 2677 | void CPartFile::ResumeFile() |
no test coverage detected