mirror of
https://github.com/aria2/aria2.git
synced 2026-04-06 20:58:52 +00:00
To add --select-file command-line option: * src/Util.cc (unfoldRange): New function. (getNum): New function. (unfoldSubRange): New function * src/main.cc (showUsage): Added help message. (main): Added --select-file command-line option. 2006-04-28 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com> To deploy upload rate based choking algorithm: * src/PeerInteractionCommand.cc (PeerInteractionCommand): Add peer to TorrentMan::activePeers to track peer currently used. (decideChoking): Deleted the choke/unchoke decision algorithm when download completes. Simplified. (receiveMessage): Updated. * src/TorrentMan.h (activePeers): New variable. (addActivePeer): New function. (getActivePeers): New function. (deleteActivePeer): New function. * src/TorrentMan.cc (addPeer): deleteOldErrorPeers is moved to the begining of the function * src/PeerAbstractCommand.cc (onAbort): Use peer->resetStatus(). * src/main.cc (PeerChokeCommand.h): Included. (main): Added the instance of ChokingCommand to the command queue. * src/Peer.h (amChoking): Renamed from amChocking (chokingRequired): New variable. (optUnchoking): New variable. (deltaUpload): New variable. (deltaDownload): New variable. (addDeltaUpload): New function. (resetDeltaUpload): New function. (addDeltaDownload): New function. (resetDeltaDownload): New function. (addPeerUpload): Added a call to addDeltaUpload. (addPeerDownload): Added a call to addDeltaDownload. * src/Peer.cc (shouldBeChoking): Renamed from shouldChoke. (resetStatus): New function. * src/PeerChokeCommand.h: New class. * src/PeerChokeCommand.cc: New class. To add lazy upload speed limiter: * src/TorrentConsoleDownloadEngine.h: Moved the variables for statistics calculation to TorrentDownloadEngine. * src/TorrentConsoleDownloadEngine.cc (sendStatistics): Renamed from printStatistics. (initStatistics): Removed. Moved to TorrentDownloadEngine. (calculateSpeed): Removed. Moved to TorrentDownloadEngine. (calculateStatistics): Removed. Moved to TorrentDownloadEngine. * src/TorrentDownloadEngine.h: Added the variables for statistics calculation. (sendStatistics): New function as pure virtual function. (getUploadSpeed): New function. * src/TorrentDownloadEngine.cc (initStatistics): New function. (calculateSpeed): New function. (calculateStatistics): New function. * src/SendMessageQueue.h (uploadLength): New variable. (send): Added an argument. (setUploadLimit): New function. (getUploadLimit): New function. * src/SendMessageQueue.cc (send): Added upload speed limiter. * src/prefs.h (PREF_UPLOAD_LIMIT): New definition. * src/PeerInteractionCommand.cc (PeerInteractionCommand): Set upload speed limit to sendMessageQueue. * src/main.cc (main): Added --upload-limit option For bug fixes: * src/main.cc (showUsage): Corrected --listen-port help Other changes: * src/TorrentMan.cc (getPeer): Return nullPeer if connection is grather than MAX_PEER_UPDATE(15) in order to leave space for incoming peers.
54 lines
1.9 KiB
C++
54 lines
1.9 KiB
C++
/* <!-- copyright */
|
|
/*
|
|
* aria2 - a simple utility for downloading files faster
|
|
*
|
|
* Copyright (C) 2006 Tatsuhiro Tsujikawa
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*/
|
|
/* copyright --> */
|
|
#include "TorrentConsoleDownloadEngine.h"
|
|
#include "Util.h"
|
|
|
|
TorrentConsoleDownloadEngine::TorrentConsoleDownloadEngine() {}
|
|
|
|
TorrentConsoleDownloadEngine::~TorrentConsoleDownloadEngine() {}
|
|
|
|
void TorrentConsoleDownloadEngine::onSelectiveDownloadingCompletes() {
|
|
printf("\nDownload of selected files has completed.\n");
|
|
fflush(stdout);
|
|
}
|
|
|
|
void TorrentConsoleDownloadEngine::sendStatistics() {
|
|
printf("\r ");
|
|
printf("\r");
|
|
if(torrentMan->downloadComplete()) {
|
|
printf("Download Completed ");
|
|
} else {
|
|
printf("%s/%sB %d%% %s D:%.2f",
|
|
Util::llitos(downloadLength, true).c_str(),
|
|
Util::llitos(totalLength, true).c_str(),
|
|
(totalLength == 0 ?
|
|
0 : (int)((downloadLength*100)/totalLength)),
|
|
avgSpeed == 0 ? "-" : Util::secfmt(eta).c_str(),
|
|
downloadSpeed/1024.0);
|
|
}
|
|
printf(" U:%.2f(%s) %d peers",
|
|
uploadSpeed/1024.0,
|
|
Util::llitos(torrentMan->getUploadLength(), true).c_str(),
|
|
torrentMan->connections);
|
|
fflush(stdout);
|
|
}
|