Improved the http progress display, includes truncated names, download

progress and 10 second delay on hiding.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@286 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-02-17 21:20:18 +00:00
parent f9975ae9f2
commit 78d3d78ef3
14 changed files with 254 additions and 29 deletions
+17
View File
@@ -58,6 +58,23 @@ CurlGet::close() {
m_handle = NULL;
}
double
CurlGet::get_size_done() {
double d = 0.0;
curl_easy_getinfo(m_handle, CURLINFO_SIZE_DOWNLOAD, &d);
return d;
}
double
CurlGet::get_size_total() {
double d = 0.0;
curl_easy_getinfo(m_handle, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d);
return d;
}
void
CurlGet::perform(CURLMsg* msg) {
if (msg->msg != CURLMSG_DONE)
+3
View File
@@ -25,6 +25,9 @@ class CurlGet : public torrent::Http {
bool is_busy() { return m_handle; }
double get_size_done();
double get_size_total();
protected:
CURL* handle() { return m_handle; }
+8 -3
View File
@@ -2,6 +2,7 @@
#include <memory>
#include <sstream>
#include <functional.h>
#include <sigc++/bind.h>
#include <sigc++/hide.h>
#include <torrent/http.h>
@@ -14,7 +15,7 @@ namespace core {
HttpQueue::iterator
HttpQueue::insert(const std::string& url) {
std::auto_ptr<torrent::Http> h(m_slotFactory());
std::auto_ptr<CurlGet> h(m_slotFactory());
std::auto_ptr<std::stringstream> s(new std::stringstream);
h->set_url(url);
@@ -31,11 +32,15 @@ HttpQueue::insert(const std::string& url) {
h.release();
s.release();
m_signalInsert.emit(*itr);
return itr;
}
void
HttpQueue::erase(iterator itr) {
m_signalErase.emit(*itr);
delete (*itr)->get_stream();
delete *itr;
@@ -44,8 +49,8 @@ HttpQueue::erase(iterator itr) {
void
HttpQueue::clear() {
std::for_each(begin(), end(), func::on(func::call_delete(), std::mem_fun(&CurlGet::get_stream)));
std::for_each(begin(), end(), func::call_delete());
while (!empty())
erase(begin());
Base::clear();
}
+13 -9
View File
@@ -3,18 +3,17 @@
#include <list>
#include <iosfwd>
#include <sigc++/slot.h>
namespace torrent {
class Http;
}
#include <sigc++/signal.h>
namespace core {
class HttpQueue : private std::list<torrent::Http*> {
class CurlGet;
class HttpQueue : private std::list<CurlGet*> {
public:
typedef std::list<torrent::Http*> Base;
typedef sigc::slot0<torrent::Http*> SlotFactory;
typedef std::list<CurlGet*> Base;
typedef sigc::signal1<void, CurlGet*> SignalHttp;
typedef sigc::slot0<CurlGet*> SlotFactory;
using Base::iterator;
using Base::const_iterator;
@@ -29,7 +28,7 @@ public:
using Base::empty;
using Base::size;
// Note that any slots connected to the torrent::Http signals must be
// Note that any slots connected to the CurlGet signals must be
// pushed in front of the erase slot added by HttpQueue::insert.
iterator insert(const std::string& url);
void erase(iterator itr);
@@ -38,8 +37,13 @@ public:
void slot_factory(SlotFactory s) { m_slotFactory = s; }
SignalHttp& signal_insert() { return m_signalInsert; }
SignalHttp& signal_erase() { return m_signalErase; }
private:
SlotFactory m_slotFactory;
SignalHttp m_signalInsert;
SignalHttp m_signalErase;
};
}
+2 -2
View File
@@ -6,10 +6,10 @@
#include <istream>
#include <sigc++/bind.h>
#include <torrent/exceptions.h>
#include <torrent/http.h>
#include <torrent/torrent.h>
#include "manager.h"
#include "curl_get.h"
namespace core {
@@ -95,7 +95,7 @@ Manager::create_http(const std::string& uri) {
}
void
Manager::receive_http_done(torrent::Http* http) {
Manager::receive_http_done(CurlGet* http) {
DownloadList::iterator itr = m_downloadList.end();
try {
+1 -1
View File
@@ -29,7 +29,7 @@ public:
void stop(Download* d);
private:
void receive_http_done(torrent::Http* http);
void receive_http_done(CurlGet* http);
void create_file(const std::string& uri);
void create_http(const std::string& uri);
+5 -7
View File
@@ -6,17 +6,15 @@
#include "curl_stack.h"
namespace torrent {
class Http;
}
namespace core {
class CurlGet;
class Poll {
public:
typedef sigc::slot0<void> Slot;
typedef sigc::slot1<void, int> SlotInt;
typedef sigc::slot0<torrent::Http*> SlotFactory;
typedef sigc::slot0<void> Slot;
typedef sigc::slot1<void, int> SlotInt;
typedef sigc::slot0<CurlGet*> SlotFactory;
Poll() : m_readSet(new fd_set), m_writeSet(new fd_set), m_exceptSet(new fd_set) {}
~Poll() { delete m_readSet; delete m_writeSet; delete m_exceptSet; }