From cbbad78b6ae3d8522f5baf5619bac99c8e56f3b8 Mon Sep 17 00:00:00 2001 From: rakshasa Date: Wed, 16 Nov 2005 20:46:13 +0000 Subject: [PATCH] * Set "stopped" stated to newly added torrents, so they stay stopped when restarting the client. * Renamed Bencode::operator[] to Bencode::get_key. * Added progress percentage for hash checking. * Correctly update the delegator priority when loading resume data with file priorities. * Don't allow file names with '\0' in them. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@597 e378c898-3ddf-0310-93e7-cc216c733640 --- src/core/download_factory.cc | 2 +- src/core/downloads.cc | 59 -------------------------------- src/core/downloads.h | 65 ------------------------------------ src/core/manager.cc | 12 +++---- src/display/utils.cc | 3 +- 5 files changed, 9 insertions(+), 132 deletions(-) delete mode 100644 src/core/downloads.cc delete mode 100644 src/core/downloads.h diff --git a/src/core/download_factory.cc b/src/core/download_factory.cc index 7425fd6b..32c71df8 100644 --- a/src/core/download_factory.cc +++ b/src/core/download_factory.cc @@ -141,7 +141,7 @@ DownloadFactory::receive_success() { if (m_session) { torrent::Bencode& bencode = (*itr)->get_bencode(); - if (bencode["rtorrent"]["state"].as_string() == "started") + if (bencode.get_key("rtorrent").get_key("state").as_string() == "started") m_manager->start(*itr); } else { diff --git a/src/core/downloads.cc b/src/core/downloads.cc deleted file mode 100644 index c144ee75..00000000 --- a/src/core/downloads.cc +++ /dev/null @@ -1,59 +0,0 @@ -// rTorrent - BitTorrent client -// Copyright (C) 2005, Jari Sundell -// -// 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 -// -// In addition, as a special exception, the copyright holders give -// permission to link the code of portions of this program with the -// OpenSSL library under certain conditions as described in each -// individual source file, and distribute linked combinations -// including the two. -// -// You must obey the GNU General Public License in all respects for -// all of the code used other than OpenSSL. If you modify file(s) -// with this exception, you may extend this exception to your version -// of the file(s), but you are not obligated to do so. If you do not -// wish to do so, delete this exception statement from your version. -// If you delete this exception statement from all source files in the -// program, then also delete it here. -// -// Contact: Jari Sundell -// -// Skomakerveien 33 -// 3185 Skoppum, NORWAY - -#include "config.h" - -#include - -#include "downloads.h" - -namespace engine { - -void -Downloads::create(std::istream& str) { - torrent::Download d = torrent::download_create(str); - - Base::push_back(d); -} - -void -Downloads::erase(iterator itr) { - torrent::download_remove(itr->get_hash()); - - Base::erase(itr); -} - -} diff --git a/src/core/downloads.h b/src/core/downloads.h deleted file mode 100644 index 585180a6..00000000 --- a/src/core/downloads.h +++ /dev/null @@ -1,65 +0,0 @@ -// rTorrent - BitTorrent client -// Copyright (C) 2005, Jari Sundell -// -// 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 -// -// In addition, as a special exception, the copyright holders give -// permission to link the code of portions of this program with the -// OpenSSL library under certain conditions as described in each -// individual source file, and distribute linked combinations -// including the two. -// -// You must obey the GNU General Public License in all respects for -// all of the code used other than OpenSSL. If you modify file(s) -// with this exception, you may extend this exception to your version -// of the file(s), but you are not obligated to do so. If you do not -// wish to do so, delete this exception statement from your version. -// If you delete this exception statement from all source files in the -// program, then also delete it here. -// -// Contact: Jari Sundell -// -// Skomakerveien 33 -// 3185 Skoppum, NORWAY - -#ifndef RTORRENT_ENGINE_DOWNLOADS_H -#define RTORRENT_ENGINE_DOWNLOADS_H - -#include -#include - -namespace engine { - -class Downloads : private std::list { -public: - typedef std::list Base; - - using Base::iterator; - using Base::const_iterator; - using Base::reverse_iterator; - using Base::const_reverse_iterator; - - using Base::begin; - using Base::end; - using Base::rbegin; - using Base::rend; - - void create(std::istream& str); - void erase(iterator itr); -}; - -} - -#endif diff --git a/src/core/manager.cc b/src/core/manager.cc index d5857862..0d2eea03 100644 --- a/src/core/manager.cc +++ b/src/core/manager.cc @@ -176,7 +176,7 @@ Manager::erase(DListItr itr) { void Manager::start(Download* d) { try { - d->get_bencode()["rtorrent"]["state"] = "started"; + d->get_bencode().get_key("rtorrent").get_key("state") = "started"; if (d->get_download().is_active()) return; @@ -199,7 +199,7 @@ Manager::start(Download* d) { void Manager::stop(Download* d) { try { - d->get_bencode()["rtorrent"]["state"] = "stopped"; + d->get_bencode().get_key("rtorrent").get_key("state") = "stopped"; m_downloadList.stop(d); @@ -265,12 +265,12 @@ Manager::initialize_bencode(Download* d) { torrent::Bencode& bencode = d->get_bencode(); if (!bencode.has_key("rtorrent") || - !bencode["rtorrent"].is_map()) + !bencode.get_key("rtorrent").is_map()) bencode.insert_key("rtorrent", torrent::Bencode(torrent::Bencode::TYPE_MAP)); - if (!bencode["rtorrent"].has_key("state") || - !bencode["rtorrent"]["state"].is_string()) - bencode["rtorrent"].insert_key("state", "started"); + if (!bencode.get_key("rtorrent").has_key("state") || + !bencode.get_key("rtorrent").get_key("state").is_string()) + bencode.get_key("rtorrent").insert_key("state", "stopped"); } void diff --git a/src/display/utils.cc b/src/display/utils.cc index 99948f58..78edbbf0 100644 --- a/src/display/utils.cc +++ b/src/display/utils.cc @@ -119,7 +119,8 @@ print_download_status(char* buf, unsigned int length, core::Download* d) { buf += std::max(0, snprintf(buf, length, "Inactive: ")); if (d->get_download().is_hash_checking()) - buf += std::max(0, snprintf(buf, length, "Checking hash")); + buf += std::max(0, snprintf(buf, length, "Checking hash [%2i%%]", + (d->get_download().chunks_hashed() * 100) / d->get_download().chunks_total())); else if (d->get_download().is_tracker_busy() && d->get_download().tracker_focus() < d->get_download().size_trackers())