mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-06 22:29:23 +00:00
Moved curl to libtorrent.
This commit is contained in:
+10
-10
@@ -1,5 +1,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "display/utils.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <sstream>
|
||||
@@ -14,18 +16,16 @@
|
||||
#include <torrent/data/file_list.h>
|
||||
#include <torrent/data/file_manager.h>
|
||||
#include <torrent/download/resource_manager.h>
|
||||
#include <torrent/net/http_stack.h>
|
||||
#include <torrent/peer/client_info.h>
|
||||
|
||||
#include "core/curl_stack.h"
|
||||
#include "control.h"
|
||||
#include "globals.h"
|
||||
#include "core/download.h"
|
||||
#include "core/manager.h"
|
||||
#include "rpc/parse_commands.h"
|
||||
#include "ui/root.h"
|
||||
|
||||
#include "control.h"
|
||||
#include "globals.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace display {
|
||||
|
||||
char*
|
||||
@@ -111,7 +111,7 @@ print_download_info_full(char* first, char* last, core::Download* d) {
|
||||
first = print_buffer(first, last, "%6.1f / %6.1f MB",
|
||||
(double)d->download()->bytes_done() / (double)(1 << 20),
|
||||
(double)d->download()->file_list()->size_bytes() / (double)(1 << 20));
|
||||
|
||||
|
||||
first = print_buffer(first, last, " Rate: %5.1f / %5.1f KB Uploaded: %7.1f MB",
|
||||
(double)d->info()->up_rate()->rate() / (1 << 10),
|
||||
(double)d->info()->down_rate()->rate() / (1 << 10),
|
||||
@@ -391,7 +391,7 @@ print_status_info(char* first, char* last) {
|
||||
first = print_address(first, last, torrent::connection_manager()->local_address());
|
||||
first = print_buffer(first, last, "]");
|
||||
}
|
||||
|
||||
|
||||
if (first > last)
|
||||
throw torrent::internal_error("print_status_info(...) wrote past end of the buffer.");
|
||||
|
||||
@@ -415,14 +415,14 @@ print_status_extra(char* first, char* last) {
|
||||
torrent::resource_manager()->max_download_unchoked());
|
||||
|
||||
first = print_buffer(first, last, " [H %u/%u]",
|
||||
control->core()->http_stack()->active(),
|
||||
control->core()->http_stack()->max_active());
|
||||
torrent::net_thread::http_stack()->active(),
|
||||
torrent::net_thread::http_stack()->max_active());
|
||||
|
||||
first = print_buffer(first, last, " [S %i/%i/%i]",
|
||||
torrent::total_handshakes(),
|
||||
torrent::connection_manager()->size(),
|
||||
torrent::connection_manager()->max_size());
|
||||
|
||||
|
||||
first = print_buffer(first, last, " [F %i/%i]",
|
||||
torrent::file_manager()->open_files(),
|
||||
torrent::file_manager()->max_open_files());
|
||||
|
||||
+1
-36
@@ -1,45 +1,10 @@
|
||||
// rTorrent - BitTorrent client
|
||||
// Copyright (C) 2005-2011, 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 <jaris@ifi.uio.no>
|
||||
//
|
||||
// Skomakerveien 33
|
||||
// 3185 Skoppum, NORWAY
|
||||
|
||||
#ifndef RTORRENT_DISPLAY_UTILS_H
|
||||
#define RTORRENT_DISPLAY_UTILS_H
|
||||
|
||||
#include <ctime>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace core {
|
||||
class Download;
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
#include "display/window_http_queue.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <torrent/net/http_get.h>
|
||||
|
||||
#include "core/curl_get.h"
|
||||
#include "core/http_queue.h"
|
||||
#include "display/canvas.h"
|
||||
|
||||
@@ -17,8 +17,9 @@ WindowHttpQueue::WindowHttpQueue(core::HttpQueue* q) :
|
||||
m_queue(q) {
|
||||
|
||||
set_active(false);
|
||||
m_conn_insert = m_queue->signal_insert().insert(m_queue->signal_insert().end(), [this](auto* h) { receive_insert(h); });
|
||||
m_conn_erase = m_queue->signal_erase().insert(m_queue->signal_insert().end(), [this](auto* h) { receive_erase(h); });
|
||||
|
||||
m_conn_insert = m_queue->signal_insert().insert(m_queue->signal_insert().end(), [this](auto h) { receive_insert(h); });
|
||||
m_conn_erase = m_queue->signal_erase().insert(m_queue->signal_insert().end(), [this](auto h) { receive_erase(h); });
|
||||
|
||||
m_task_deactivate.slot() = [this] {
|
||||
if (!m_container.empty())
|
||||
@@ -55,14 +56,14 @@ WindowHttpQueue::redraw() {
|
||||
Container::iterator itr = m_container.begin();
|
||||
|
||||
while (itr != m_container.end() && pos + 10 < m_canvas->width()) {
|
||||
if (itr->m_http == NULL)
|
||||
if (!itr->m_http.is_valid())
|
||||
m_canvas->print(pos, 0, "[%s done]", itr->m_name.c_str());
|
||||
|
||||
else if (itr->m_http->size_total() == 0)
|
||||
else if (itr->m_http.size_total() == 0)
|
||||
m_canvas->print(pos, 0, "[%s ---%%]", itr->m_name.c_str());
|
||||
|
||||
else
|
||||
m_canvas->print(pos, 0, "[%s %3i%%]", itr->m_name.c_str(), (int)(100.0 * itr->m_http->size_done() / itr->m_http->size_total()));
|
||||
m_canvas->print(pos, 0, "[%s %3i%%]", itr->m_name.c_str(), (int)(100.0 * itr->m_http.size_done() / itr->m_http.size_total()));
|
||||
|
||||
pos += itr->m_name.size() + 6;
|
||||
++itr;
|
||||
@@ -72,7 +73,7 @@ WindowHttpQueue::redraw() {
|
||||
void
|
||||
WindowHttpQueue::cleanup_list() {
|
||||
for (Container::iterator itr = m_container.begin(); itr != m_container.end(); ) {
|
||||
if (itr->m_http == nullptr && itr->m_timer < torrent::this_thread::cached_time()) {
|
||||
if (!itr->m_http.is_valid() && itr->m_timer < torrent::this_thread::cached_time()) {
|
||||
itr = m_container.erase(itr);
|
||||
continue;
|
||||
}
|
||||
@@ -82,10 +83,10 @@ WindowHttpQueue::cleanup_list() {
|
||||
}
|
||||
|
||||
std::string
|
||||
WindowHttpQueue::create_name(core::CurlGet* h) {
|
||||
size_t p = h->url().rfind('/', h->url().size() - std::min<int>(10, h->url().size()));
|
||||
WindowHttpQueue::create_name(torrent::net::HttpGet http_get) {
|
||||
size_t p = http_get.url().rfind('/', http_get.url().size() - std::min<int>(10, http_get.url().size()));
|
||||
|
||||
std::string n = p != std::string::npos ? h->url().substr(p) : h->url();
|
||||
std::string n = p != std::string::npos ? http_get.url().substr(p) : http_get.url();
|
||||
|
||||
if (n.empty())
|
||||
throw std::logic_error("WindowHttpQueue::create_name(...) made a bad string");
|
||||
@@ -105,8 +106,8 @@ WindowHttpQueue::create_name(core::CurlGet* h) {
|
||||
}
|
||||
|
||||
void
|
||||
WindowHttpQueue::receive_insert(core::CurlGet* h) {
|
||||
m_container.push_back(Node(h, create_name(h)));
|
||||
WindowHttpQueue::receive_insert(torrent::net::HttpGet http_get) {
|
||||
m_container.push_back(Node(http_get, create_name(http_get)));
|
||||
|
||||
if (!is_active()) {
|
||||
set_active(true);
|
||||
@@ -117,8 +118,10 @@ WindowHttpQueue::receive_insert(core::CurlGet* h) {
|
||||
}
|
||||
|
||||
void
|
||||
WindowHttpQueue::receive_erase(core::CurlGet* h) {
|
||||
Container::iterator itr = std::find_if(m_container.begin(), m_container.end(), [h](Node& n) { return h == n.m_http; });
|
||||
WindowHttpQueue::receive_erase(torrent::net::HttpGet http_get) {
|
||||
Container::iterator itr = std::find_if(m_container.begin(),
|
||||
m_container.end(),
|
||||
[http_get](Node& n) { return http_get == n.m_http; });
|
||||
|
||||
if (itr == m_container.end())
|
||||
throw std::logic_error("WindowHttpQueue::receive_erase(...) tried to remove an object we don't have");
|
||||
|
||||
@@ -3,20 +3,20 @@
|
||||
|
||||
#include <functional>
|
||||
#include <list>
|
||||
#include <torrent/net/http_get.h>
|
||||
|
||||
#include "window.h"
|
||||
|
||||
namespace core {
|
||||
class CurlGet;
|
||||
class HttpQueue;
|
||||
class HttpQueue;
|
||||
}
|
||||
|
||||
namespace display {
|
||||
|
||||
class WindowHttpQueue : public Window {
|
||||
public:
|
||||
typedef std::function<void (core::CurlGet*)> slot_curl_get;
|
||||
typedef std::list<slot_curl_get> signal_curl_get;
|
||||
typedef std::function<void (torrent::net::HttpGet)> slot_curl_get;
|
||||
typedef std::list<slot_curl_get> signal_curl_get;
|
||||
|
||||
WindowHttpQueue(core::HttpQueue* q);
|
||||
~WindowHttpQueue() override;
|
||||
@@ -25,9 +25,9 @@ public:
|
||||
|
||||
private:
|
||||
struct Node {
|
||||
Node(core::CurlGet* h, const std::string& n) : m_http(h), m_name(n) {}
|
||||
Node(torrent::net::HttpGet h, const std::string& n) : m_http(h), m_name(n) {}
|
||||
|
||||
core::CurlGet* m_http{};
|
||||
torrent::net::HttpGet m_http{};
|
||||
std::string m_name;
|
||||
std::chrono::microseconds m_timer{};
|
||||
};
|
||||
@@ -36,10 +36,10 @@ private:
|
||||
|
||||
void cleanup_list();
|
||||
|
||||
void receive_insert(core::CurlGet* h);
|
||||
void receive_erase(core::CurlGet* h);
|
||||
void receive_insert(torrent::net::HttpGet h);
|
||||
void receive_erase(torrent::net::HttpGet h);
|
||||
|
||||
static std::string create_name(core::CurlGet* h);
|
||||
static std::string create_name(torrent::net::HttpGet h);
|
||||
|
||||
core::HttpQueue* m_queue;
|
||||
Container m_container;
|
||||
|
||||
Reference in New Issue
Block a user