diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2006-04-18 17:06:17 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2006-04-18 17:06:17 +0000 |
| commit | 19f713b99d39cc5a672e3d56eaff7b76a2a7e72c (patch) | |
| tree | fa6374a20ad36ddf4da92b08598887c54904e47f /src/TrackerDownloadCommand.cc | |
| parent | 39276dcb00b33372e1ac5fbd0de2d60c733aeb60 (diff) | |
2006-04-19 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add a readout of estimated remaining time to normal HTTP/FTP
downloads:
* src/ConsoleDownloadEngine.h (startup): New variable.
(startupLength): New variable.
(isStartupLengthSet): New variable.
(avgSpeed): New variable.
(eta): New variable.
* src/ConsoleDownloadEngine.cc (sendStatistics): Added a readout
of
estimated remaining time.
(initStatistics): Initialized newly added variables.
(calculateStatistics): Calculate average speed and estimated
remaining
time.
To decouple TorrentDownloadEngine from HttpResponseCommand:
* src/TrackerDownloadCommand.h: Removed.
* src/TrackerDownloadCommand.cc: Removed.
* src/TrackerInitCommand.h: Removed.
* src/TrackerInitCommand.cc: Removed.
* src/TrackerUpdateCommand.h: Removed.
* src/TrackerUpdateCommand.cc: Removed.
* src/TrackerWatcherCommand.cc (execute): The construction of
request
url written in TrackerInitCommand was moved here. Do not create
tracker request command if torretnMan->trackers != 0.
* src/CompactTrackerResponseProcessor.h: New class.
* src/CompactTrackerResponseProcessor.cc: New class.
* src/message.h (MSG_TRACKER_WARNING_MESSAGE): Updated.
* src/HttpResponseCommand.cc (createHttpDownloadCommand):
Decoupled TorrentDownloadEngine from this.
* src/SegmentMan.h (init): New function.
* src/SegmentMan.cc (init): New function.
* src/TorrentMan.h (responseProcessor): New variable.
(trackers): New variable.
(setTrackerResponseProcessor): New function.
(getTrackerResponseProcessor): New function.
(processTrackerResponse): New function.
* src/TorrentMan.cc (Constructor): Initialized new variable
trackers.
(processTrackerResponse): New function.
* src/main.cc (main): Use ByteArrayDiskWriter and
CompactTrackerResponseProcessor.
* src/TorrentDownloadEngine.cc (afterEachIteration): Call
torrentMan->
processTrackerResponse().
* src/TorrentConsoleDownloadEngine.cc (printStatistics): Updated
a
readout.
* src/TorrentDownloadEngine.cc (afterEachIteration): Added log
message
which indicates download has completed.
* src/AbstractDiskWriter.cc (Destructor): fd >= 0, not fd >0
(closeFile): fd >= 0, not fd > 0
* src/main.cc (main): Added short cut for show-files.
Added short cut for torrent-file.
Added new command-line option listen-port.
Updated i18n messages.
Diffstat (limited to 'src/TrackerDownloadCommand.cc')
| -rw-r--r-- | src/TrackerDownloadCommand.cc | 99 |
1 files changed, 0 insertions, 99 deletions
diff --git a/src/TrackerDownloadCommand.cc b/src/TrackerDownloadCommand.cc deleted file mode 100644 index da3aa843..00000000 --- a/src/TrackerDownloadCommand.cc +++ /dev/null @@ -1,99 +0,0 @@ -/* <!-- 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 "TrackerDownloadCommand.h" -#include "TrackerUpdateCommand.h" -#include "ChunkedEncoding.h" -#include "DlRetryEx.h" -#include "message.h" -#include "MetaFileUtil.h" -#include "DlAbortEx.h" - -TrackerDownloadCommand::TrackerDownloadCommand(int cuid, Request* req, - TorrentDownloadEngine* e, - const Socket* s) - :AbstractCommand(cuid, req, e, s), len(0) { - resSize = 256; - res = new char[resSize]; - ChunkedEncoding* ce = new ChunkedEncoding(); - transferEncodings["chunked"] = ce; -} - -TrackerDownloadCommand::~TrackerDownloadCommand() { - delete [] res; - for(map<string, TransferEncoding*>::iterator itr = transferEncodings.begin(); itr != transferEncodings.end(); itr++) { - delete((*itr).second); - } -} - -bool TrackerDownloadCommand::executeInternal(Segment seg) { - TransferEncoding* te = NULL; - if(transferEncoding.size()) { - te = getTransferEncoding(transferEncoding); - assert(te != NULL); - } - int bufSize = 4096; - char buf[bufSize]; - socket->readData(buf, bufSize); - if(te != NULL) { - int infbufSize = 4096; - char infbuf[infbufSize]; - te->inflate(infbuf, infbufSize, buf, bufSize); - if(len+infbufSize >= resSize) { - expandBuffer(len+infbufSize); - } - memcpy(res+len, infbuf, infbufSize); - len += infbufSize; - } else { - if(len+bufSize >= resSize) { - expandBuffer(len+bufSize); - } - memcpy(res+len, buf, bufSize); - len += bufSize; - } - if(e->segmentMan->totalSize != 0 && bufSize == 0) { - throw new DlRetryEx(EX_GOT_EOF); - } - if(te != NULL && te->finished() - || te == NULL && len == e->segmentMan->totalSize - || bufSize == 0) { - if(te != NULL) te->end(); - logger->info(MSG_DOWNLOAD_COMPLETED, cuid); - MetaEntry* entry = MetaFileUtil::bdecoding(res, len); - e->commands.push(new TrackerUpdateCommand(cuid, req, (TorrentDownloadEngine*)e, entry)); - return true; - } else { - e->commands.push(this); - return false; - } -} - -TransferEncoding* TrackerDownloadCommand::getTransferEncoding(string name) { - return transferEncodings[name]; -} - -void TrackerDownloadCommand::expandBuffer(int newSize) { - char* newbuf = new char[newSize]; - memcpy(newbuf, res, len); - delete [] res; - res = newbuf; - resSize = newSize; -} |
