← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2622: add a struct that wraps the logic of simple HTTP downloads

 

------------------------------------------------------------
revno: 2622
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sun 2011-10-02 14:14:41 +0200
message:
  add a struct that wraps the logic of simple HTTP downloads
added:
  dcpp/HttpConnectionListener.h
  dcpp/HttpDownload.cpp
  dcpp/HttpDownload.h
modified:
  dcpp/FavoriteManager.h
  dcpp/HttpConnection.cpp
  dcpp/HttpConnection.h
  dcpp/SettingsManager.h
  dcpp/forward.h
  win32/AboutDlg.cpp
  win32/AboutDlg.h
  win32/DirectoryListingFrame.h
  win32/MainWindow.cpp
  win32/MainWindow.h


--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk

Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dcpp/FavoriteManager.h'
--- dcpp/FavoriteManager.h	2011-10-01 14:33:43 +0000
+++ dcpp/FavoriteManager.h	2011-10-02 12:14:41 +0000
@@ -22,7 +22,7 @@
 #include "SettingsManager.h"
 
 #include "CriticalSection.h"
-#include "HttpConnection.h"
+#include "HttpConnectionListener.h"
 #include "UserCommand.h"
 #include "FavoriteUser.h"
 #include "Singleton.h"
@@ -150,29 +150,29 @@
 	FavoriteHubEntryList::iterator getFavoriteHub(const string& aServer);
 
 	// ClientManagerListener
-	virtual void on(UserUpdated, const OnlineUser& user) noexcept;
-	virtual void on(UserConnected, const UserPtr& user) noexcept;
-	virtual void on(UserDisconnected, const UserPtr& user) noexcept;
+	void on(UserUpdated, const OnlineUser& user) noexcept;
+	void on(UserConnected, const UserPtr& user) noexcept;
+	void on(UserDisconnected, const UserPtr& user) noexcept;
 
 	// HttpConnectionListener
-	virtual void on(Data, HttpConnection*, const uint8_t*, size_t) noexcept;
-	virtual void on(Failed, HttpConnection*, const string&) noexcept;
-	virtual void on(Complete, HttpConnection*, const string&, bool) noexcept;
-	virtual void on(Redirected, HttpConnection*, const string&) noexcept;
-	virtual void on(TypeNormal, HttpConnection*) noexcept;
-	virtual void on(TypeBZ2, HttpConnection*) noexcept;
-	virtual void on(Retried, HttpConnection*, bool) noexcept; 
+	void on(Data, HttpConnection*, const uint8_t*, size_t) noexcept;
+	void on(Failed, HttpConnection*, const string&) noexcept;
+	void on(Complete, HttpConnection*, const string&, bool) noexcept;
+	void on(Redirected, HttpConnection*, const string&) noexcept;
+	void on(TypeNormal, HttpConnection*) noexcept;
+	void on(TypeBZ2, HttpConnection*) noexcept;
+	void on(Retried, HttpConnection*, bool) noexcept; 
 
 	bool onHttpFinished(bool fromHttp) noexcept;
 
 	// SettingsManagerListener
-	virtual void on(SettingsManagerListener::Load, SimpleXML& xml) noexcept {
+	void on(SettingsManagerListener::Load, SimpleXML& xml) noexcept {
 		load(xml);
 	}
 
 	void load(SimpleXML& aXml);
 
-	string getConfigFile() { return Util::getPath(Util::PATH_USER_CONFIG) + "Favorites.xml"; }
+	static string getConfigFile() { return Util::getPath(Util::PATH_USER_CONFIG) + "Favorites.xml"; }
 };
 
 } // namespace dcpp

=== modified file 'dcpp/HttpConnection.cpp'
--- dcpp/HttpConnection.cpp	2011-10-01 14:33:43 +0000
+++ dcpp/HttpConnection.cpp	2011-10-02 12:14:41 +0000
@@ -19,6 +19,7 @@
 #include "stdinc.h"
 #include "HttpConnection.h"
 
+#include "BufferedSocket.h"
 #include "format.h"
 #include "SettingsManager.h"
 #include "version.h"
@@ -27,12 +28,12 @@
 
 static const std::string CORAL_SUFFIX = ".nyud.net";
 
-HttpConnection::HttpConnection(CoralizeState coralizeState) :
+HttpConnection::HttpConnection(bool coralize) :
 ok(false),
 port("80"),
 size(-1),
 moved302(false),
-coralizeState(coralizeState),
+coralizeState(coralize ? CST_DEFAULT : CST_NOCORALIZE),
 socket(0)
 {
 }
@@ -204,7 +205,7 @@
 		return;
 	}
 	coralizeState = CST_DEFAULT;
-	fire(HttpConnectionListener::Failed(), this, aLine + " (" + currentUrl + ")");
+	fire(HttpConnectionListener::Failed(), this, str(F_("%1% (%2%)") % aLine % currentUrl));
 }
 
 void HttpConnection::on(BufferedSocketListener::ModeChange) noexcept {

=== modified file 'dcpp/HttpConnection.h'
--- dcpp/HttpConnection.h	2011-10-01 14:33:43 +0000
+++ dcpp/HttpConnection.h	2011-10-02 12:14:41 +0000
@@ -19,44 +19,25 @@
 #ifndef DCPLUSPLUS_DCPP_HTTP_CONNECTION_H
 #define DCPLUSPLUS_DCPP_HTTP_CONNECTION_H
 
-#include "BufferedSocket.h"
+#include "BufferedSocketListener.h"
+#include "HttpConnectionListener.h"
+#include "Speaker.h"
 
 namespace dcpp {
 
-class HttpConnection;
-
-class HttpConnectionListener {
-public:
-	virtual ~HttpConnectionListener() { }
-	template<int I>	struct X { enum { TYPE = I }; };
-
-	typedef X<0> Data;
-	typedef X<1> Failed;
-	typedef X<2> Complete;
-	typedef X<3> Redirected;
-	typedef X<4> TypeNormal;
-	typedef X<5> TypeBZ2;
-	typedef X<6> Retried;
-
-	virtual void on(Data, HttpConnection*, const uint8_t*, size_t) noexcept = 0;
-	virtual void on(Failed, HttpConnection*, const string&) noexcept { }
-	virtual void on(Complete, HttpConnection*, const string&, bool) noexcept { }
-	virtual void on(Redirected, HttpConnection*, const string&) noexcept { }
-	virtual void on(TypeNormal, HttpConnection*) noexcept { }
-	virtual void on(TypeBZ2, HttpConnection*) noexcept { }
-	virtual void on(Retried, HttpConnection*, bool) noexcept { }
-};
+using std::string;
 
 class HttpConnection : BufferedSocketListener, public Speaker<HttpConnectionListener>, boost::noncopyable
 {
 public:
-	enum CoralizeState { CST_DEFAULT, CST_CONNECTED, CST_NOCORALIZE };
-	HttpConnection(CoralizeState coralizeState = CST_DEFAULT);
+	HttpConnection(bool coralize = true);
 	virtual ~HttpConnection();
 
 	void downloadFile(const string& aUrl);
 
 private:
+	enum CoralizeState { CST_DEFAULT, CST_CONNECTED, CST_NOCORALIZE };
+
 	string currentUrl;
 	string file;
 	string server;
@@ -70,11 +51,11 @@
 	BufferedSocket* socket;
 
 	// BufferedSocketListener
-	virtual void on(Connected) noexcept;
-	virtual void on(Line, const string&) noexcept;
-	virtual void on(Data, uint8_t*, size_t) noexcept;
-	virtual void on(ModeChange) noexcept;
-	virtual void on(Failed, const string&) noexcept;
+	void on(Connected) noexcept;
+	void on(Line, const string&) noexcept;
+	void on(Data, uint8_t*, size_t) noexcept;
+	void on(ModeChange) noexcept;
+	void on(Failed, const string&) noexcept;
 
 	void onConnected();
 	void onLine(const string& aLine);

=== added file 'dcpp/HttpConnectionListener.h'
--- dcpp/HttpConnectionListener.h	1970-01-01 00:00:00 +0000
+++ dcpp/HttpConnectionListener.h	2011-10-02 12:14:41 +0000
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2001-2011 Jacek Sieka, arnetheduck on gmail point com
+ *
+ * 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.
+ */
+
+#ifndef DCPLUSPLUS_DCPP_HTTP_CONNECTION_LISTENER_H
+#define DCPLUSPLUS_DCPP_HTTP_CONNECTION_LISTENER_H
+
+#include "forward.h"
+#include "noexcept.h"
+#include <string>
+
+namespace dcpp {
+
+using std::string;
+
+class HttpConnectionListener {
+public:
+	virtual ~HttpConnectionListener() { }
+	template<int I>	struct X { enum { TYPE = I }; };
+
+	typedef X<0> Data;
+	typedef X<1> Failed;
+	typedef X<2> Complete;
+	typedef X<3> Redirected;
+	typedef X<4> TypeNormal;
+	typedef X<5> TypeBZ2;
+	typedef X<6> Retried;
+
+	virtual void on(Data, HttpConnection*, const uint8_t*, size_t) noexcept = 0;
+	virtual void on(Failed, HttpConnection*, const string&) noexcept = 0;
+	virtual void on(Complete, HttpConnection*, const string&, bool) noexcept = 0;
+	virtual void on(Redirected, HttpConnection*, const string&) noexcept { }
+	virtual void on(TypeNormal, HttpConnection*) noexcept { }
+	virtual void on(TypeBZ2, HttpConnection*) noexcept { }
+	virtual void on(Retried, HttpConnection*, bool) noexcept { }
+};
+
+} // namespace dcpp
+
+#endif // !defined(DCPLUSPLUS_DCPP_HTTP_CONNECTION_LISTENER_H)

=== added file 'dcpp/HttpDownload.cpp'
--- dcpp/HttpDownload.cpp	1970-01-01 00:00:00 +0000
+++ dcpp/HttpDownload.cpp	2011-10-02 12:14:41 +0000
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2001-2011 Jacek Sieka, arnetheduck on gmail point com
+ *
+ * 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.
+ */
+
+#include "stdinc.h"
+#include "HttpDownload.h"
+
+namespace dcpp {
+
+HttpDownload::HttpDownload(const string& address, CompletionF f, bool coralize) :
+c(coralize),
+f(f)
+{
+	c.addListener(this);
+	c.downloadFile(address);
+}
+
+HttpDownload::~HttpDownload() {
+	c.removeListener(this);
+}
+
+void HttpDownload::on(HttpConnectionListener::Data, HttpConnection*, const uint8_t* buf_, size_t len) noexcept {
+	buf.append(reinterpret_cast<const char*>(buf_), len);
+}
+
+void HttpDownload::on(HttpConnectionListener::Failed, HttpConnection*, const string& status_) noexcept {
+	buf.clear();
+	status = status_;
+	f();
+}
+
+void HttpDownload::on(HttpConnectionListener::Complete, HttpConnection*, const string& status_, bool) noexcept {
+	status = status_;
+	f();
+}
+
+void HttpDownload::on(HttpConnectionListener::Retried, HttpConnection*, bool connected) noexcept {
+	if(connected)
+		buf.clear();
+}
+
+} // namespace dcpp

=== added file 'dcpp/HttpDownload.h'
--- dcpp/HttpDownload.h	1970-01-01 00:00:00 +0000
+++ dcpp/HttpDownload.h	2011-10-02 12:14:41 +0000
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2001-2011 Jacek Sieka, arnetheduck on gmail point com
+ *
+ * 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.
+ */
+
+#ifndef DCPLUSPLUS_DCPP_HTTP_DOWNLOAD_H
+#define DCPLUSPLUS_DCPP_HTTP_DOWNLOAD_H
+
+#include "HttpConnection.h"
+
+namespace dcpp {
+
+using std::string;
+
+/** Helper struct to manage a single HTTP download. Calls a completion function when finished. */
+struct HttpDownload : private HttpConnectionListener, private boost::noncopyable {
+	HttpConnection c;
+	string buf;
+	string status;
+	typedef std::function<void ()> CompletionF;
+	CompletionF f;
+
+	explicit HttpDownload(const string& address, CompletionF f, bool coralize = true);
+	~HttpDownload();
+
+	// HttpConnectionListener
+	void on(HttpConnectionListener::Data, HttpConnection*, const uint8_t* buf_, size_t len) noexcept;
+	void on(HttpConnectionListener::Failed, HttpConnection*, const string& status_) noexcept;
+	void on(HttpConnectionListener::Complete, HttpConnection*, const string& status_, bool) noexcept;
+	void on(HttpConnectionListener::Retried, HttpConnection*, bool connected) noexcept;
+};
+
+} // namespace dcpp
+
+#endif // !defined(DCPLUSPLUS_DCPP_HTTP_DOWNLOAD_H)

=== modified file 'dcpp/SettingsManager.h'
--- dcpp/SettingsManager.h	2011-09-30 11:59:16 +0000
+++ dcpp/SettingsManager.h	2011-10-02 12:14:41 +0000
@@ -266,7 +266,7 @@
 
 	bool isSet[SETTINGS_LAST];
 
-	string getConfigFile() { return Util::getPath(Util::PATH_USER_CONFIG) + "DCPlusPlus.xml"; }
+	static string getConfigFile() { return Util::getPath(Util::PATH_USER_CONFIG) + "DCPlusPlus.xml"; }
 
 	// Search types
 	SearchTypes searchTypes; // name, extlist

=== modified file 'dcpp/forward.h'
--- dcpp/forward.h	2011-07-30 08:58:17 +0000
+++ dcpp/forward.h	2011-10-02 12:14:41 +0000
@@ -71,6 +71,10 @@
 
 struct HintedUser;
 
+class HttpConnection;
+
+struct HttpDownload;
+
 class HubEntry;
 
 class Identity;

=== modified file 'win32/AboutDlg.cpp'
--- win32/AboutDlg.cpp	2011-10-01 14:33:43 +0000
+++ win32/AboutDlg.cpp	2011-10-02 12:14:41 +0000
@@ -20,10 +20,11 @@
 
 #include "AboutDlg.h"
 
+#include <dcpp/format.h>
+#include <dcpp/HttpDownload.h>
+#include <dcpp/SettingsManager.h>
 #include <dcpp/SimpleXML.h>
 #include <dcpp/version.h>
-#include <dcpp/format.h>
-#include <dcpp/SettingsManager.h>
 
 #include <dwt/widgets/Grid.h>
 #include <dwt/widgets/Label.h>
@@ -144,8 +145,8 @@
 	layout();
 	centerWindow();
 
-	c.addListener(this);
-	c.downloadFile("http://dcplusplus.sourceforge.net/version.xml";);
+	c.reset(new HttpDownload("http://dcplusplus.sourceforge.net/version.xml";,
+		[this] { callAsync([=] { completeDownload(); }); }));
 
 	return false;
 }
@@ -155,37 +156,28 @@
 	grid->resize(dwt::Rectangle(3, 3, sz.x - 6, sz.y - 6));
 }
 
-void AboutDlg::on(HttpConnectionListener::Data, HttpConnection* /*conn*/, const uint8_t* buf, size_t len) noexcept {
-	downBuf.append((char*)buf, len);
-}
+void AboutDlg::completeDownload() {
+	tstring str;
 
-void AboutDlg::on(HttpConnectionListener::Complete, HttpConnection* conn, const string&, bool) noexcept {
-	tstring x;
-	if(!downBuf.empty()) {
+	if(!c->buf.empty()) {
 		try {
 			SimpleXML xml;
-			xml.fromXML(downBuf);
+			xml.fromXML(c->buf);
 			if(xml.findChild("DCUpdate")) {
 				xml.stepIn();
 				if(xml.findChild("Version")) {
-					x = Text::toT(xml.getChildData());
+					const auto& ver = xml.getChildData();
+					if(!ver.empty()) {
+						str = Text::toT(ver);
+					}
 				}
 			}
-		} catch(const SimpleXMLException&) { }
+		} catch(const SimpleXMLException&) {
+			str = T_("Error processing version information");
+		}
 	}
-	if(x.empty())
-		x = T_("Error processing version information");
-	callAsync([=] { version->setText(x); });
-
-	conn->removeListener(this);
-}
-
-void AboutDlg::on(HttpConnectionListener::Failed, HttpConnection* conn, const string& aLine) noexcept {
-	callAsync([=] { version->setText(Text::toT(aLine)); });
-	conn->removeListener(this);
-}
-
-void AboutDlg::on(HttpConnectionListener::Retried, HttpConnection* /*conn*/, bool connected) noexcept {
-	if(connected)
-		downBuf.clear();
+
+	version->setText(str.empty() ? Text::toT(c->status) : str);
+
+	c.reset();
 }

=== modified file 'win32/AboutDlg.h'
--- win32/AboutDlg.h	2011-10-01 14:33:43 +0000
+++ win32/AboutDlg.h	2011-10-02 12:14:41 +0000
@@ -19,15 +19,15 @@
 #ifndef DCPLUSPLUS_WIN32_ABOUT_DLG_H
 #define DCPLUSPLUS_WIN32_ABOUT_DLG_H
 
-#include <dcpp/HttpConnection.h>
+#include <dcpp/forward.h>
 
 #include <dwt/widgets/ModalDialog.h>
 
 #include "forward.h"
 
-class AboutDlg :
-	public dwt::ModalDialog,
-	private HttpConnectionListener
+using std::unique_ptr;
+
+class AboutDlg : public dwt::ModalDialog
 {
 public:
 	AboutDlg(dwt::Widget* parent);
@@ -39,17 +39,13 @@
 	GridPtr grid;
 	LabelPtr version;
 
-	HttpConnection c;
-	string downBuf;
+	unique_ptr<HttpDownload> c;
 
 	bool handleInitDialog();
 
 	void layout();
 
-	void on(HttpConnectionListener::Data, HttpConnection* /*conn*/, const uint8_t* buf, size_t len) noexcept;
-	void on(HttpConnectionListener::Complete, HttpConnection* conn, const string&, bool) noexcept;
-	void on(HttpConnectionListener::Failed, HttpConnection* conn, const string& aLine) noexcept;
-	void on(HttpConnectionListener::Retried, HttpConnection* conn, bool connected) noexcept;		
+	void completeDownload();
 };
 
 #endif // !defined(DCPLUSPLUS_WIN32_ABOUT_DLG_H)

=== modified file 'win32/DirectoryListingFrame.h'
--- win32/DirectoryListingFrame.h	2011-09-30 11:33:12 +0000
+++ win32/DirectoryListingFrame.h	2011-10-02 12:14:41 +0000
@@ -30,6 +30,8 @@
 #include "UserInfoBase.h"
 #include "AspectUserCommand.h"
 
+using std::deque;
+
 class DirectoryListingFrame :
 	public MDIChildFrame<DirectoryListingFrame>,
 	public IRecent<DirectoryListingFrame>,

=== modified file 'win32/MainWindow.cpp'
--- win32/MainWindow.cpp	2011-10-01 14:59:18 +0000
+++ win32/MainWindow.cpp	2011-10-02 12:14:41 +0000
@@ -27,6 +27,7 @@
 #include <dcpp/Download.h>
 #include <dcpp/DownloadManager.h>
 #include <dcpp/FavoriteManager.h>
+#include <dcpp/HttpDownload.h>
 #include <dcpp/LogManager.h>
 #include <dcpp/QueueManager.h>
 #include <dcpp/ResourceManager.h>
@@ -168,7 +169,8 @@
 
 	TimerManager::getInstance()->start();
 
-	conns[CONN_VERSION].reset(new HttpConnWrapper("http://dcplusplus.sourceforge.net/version.xml";, this, [this] { completeVersionUpdate(); }));
+	conns[CONN_VERSION].reset(new HttpDownload("http://dcplusplus.sourceforge.net/version.xml";,
+		[this] { callAsync([=] { completeVersionUpdate(); }); }));
 
 	if(BOOLSETTING(GET_USER_COUNTRY)) {
 		checkGeoUpdate(true);
@@ -1303,8 +1305,8 @@
 		return;
 
 	LogManager::getInstance()->message(str(F_("Updating the %1% GeoIP database...") % (v6 ? "IPv6" : "IPv4")));
-	conn.reset(new HttpConnWrapper(Text::fromT(v6 ? links.geoip6 : links.geoip4), this,
-		[this, v6] { completeGeoUpdate(v6); }, HttpConnection::CST_NOCORALIZE));
+	conn.reset(new HttpDownload(Text::fromT(v6 ? links.geoip6 : links.geoip4),
+		[this, v6] { callAsync([=] { completeGeoUpdate(v6); }); }, false));
 }
 
 void MainWindow::completeGeoUpdate(bool v6) {
@@ -1533,49 +1535,6 @@
 	sendMessage(WM_SYSCOMMAND, SC_CONTEXTHELP);
 }
 
-MainWindow::HttpConnWrapper::HttpConnWrapper(const string& address, MainWindow* mw, CompletionF f, HttpConnection::CoralizeState coralizeState) :
-c(new HttpConnection(coralizeState)),
-mw(mw),
-f(f)
-{
-	c->addListener(mw);
-	c->downloadFile(address);
-}
-
-MainWindow::HttpConnWrapper::~HttpConnWrapper() {
-	c->removeListener(mw);
-	delete c;
-}
-
-MainWindow::HttpConnWrapper* MainWindow::getConn(HttpConnection* conn) const {
-	for(uint8_t i = 0; i < CONN_LAST; ++i) {
-		if(conns[i].get() && conns[i]->c == conn) {
-			return conns[i].get();
-		}
-	}
-	return 0;
-}
-
-void MainWindow::on(HttpConnectionListener::Data, HttpConnection* conn, const uint8_t* buf, size_t len) noexcept {
-	getConn(conn)->buf.append(reinterpret_cast<const char*>(buf), len);
-}
-
-void MainWindow::on(HttpConnectionListener::Failed, HttpConnection* conn, const string&) noexcept {
-	auto c = getConn(conn);
-	c->buf.clear();
-	callAsync([c] { c->f(); });
-}
-
-void MainWindow::on(HttpConnectionListener::Complete, HttpConnection* conn, const string&, bool) noexcept {
-	auto c = getConn(conn);
-	callAsync([c] { c->f(); });
-}
-
-void MainWindow::on(HttpConnectionListener::Retried, HttpConnection* conn, bool connected) noexcept {
-	if(connected)
-		getConn(conn)->buf.clear();
-}
-
 void MainWindow::on(PartialList, const HintedUser& aUser, const string& text) noexcept {
 	callAsync([this, aUser, text] { DirectoryListingFrame::openWindow(getTabView(), aUser, text, 0); });
 }

=== modified file 'win32/MainWindow.h'
--- win32/MainWindow.h	2011-10-01 14:33:43 +0000
+++ win32/MainWindow.h	2011-10-02 12:14:41 +0000
@@ -19,9 +19,9 @@
 #ifndef DCPLUSPLUS_WIN32_MAIN_WINDOW_H
 #define DCPLUSPLUS_WIN32_MAIN_WINDOW_H
 
+#include <dcpp/forward.h>
+#include <dcpp/LogManagerListener.h>
 #include <dcpp/QueueManagerListener.h>
-#include <dcpp/LogManagerListener.h>
-#include <dcpp/HttpConnection.h>
 #include <dcpp/User.h>
 #include <dcpp/WindowInfo.h>
 
@@ -30,9 +30,10 @@
 #include "forward.h"
 #include "AspectStatus.h"
 
+using std::unique_ptr;
+
 class MainWindow :
 	public dwt::Window,
-	private HttpConnectionListener,
 	private QueueManagerListener,
 	private LogManagerListener,
 	public AspectStatus<MainWindow>
@@ -102,18 +103,6 @@
 		tstring community;
 	} links;
 
-	struct HttpConnWrapper : boost::noncopyable {
-		HttpConnection* c;
-		string buf;
-		MainWindow* mw;
-		typedef std::function<void ()> CompletionF;
-		CompletionF f;
-
-		explicit HttpConnWrapper(const string& address, MainWindow* mw, CompletionF f,
-			HttpConnection::CoralizeState coralizeState = HttpConnection::CST_DEFAULT);
-		~HttpConnWrapper();
-	};
-
 	enum {
 		TIMER_STATUS,
 		TIMER_SAVE
@@ -141,7 +130,7 @@
 
 	bool tray_pm;
 
-	unique_ptr<HttpConnWrapper> conns[CONN_LAST];
+	unique_ptr<HttpDownload> conns[CONN_LAST];
 
 	HANDLE stopperThread;
 
@@ -222,7 +211,6 @@
 	void checkGeoUpdate(bool v6);
 	void updateGeo(bool v6);
 	void completeGeoUpdate(bool v6);
-	HttpConnWrapper* getConn(HttpConnection* conn) const;
 
 	bool filter(MSG& msg);
 
@@ -234,12 +222,6 @@
 	// LogManagerListener
 	void on(LogManagerListener::Message, time_t t, const string& m) noexcept;
 
-	// HttpConnectionListener
-	void on(HttpConnectionListener::Data, HttpConnection* conn, const uint8_t* buf, size_t len) noexcept;
-	void on(HttpConnectionListener::Failed, HttpConnection* conn, const string&) noexcept;
-	void on(HttpConnectionListener::Complete, HttpConnection* conn, const string& /*aLine*/, bool /*fromCoral*/) noexcept;
-	void on(HttpConnectionListener::Retried, HttpConnection* conn, bool connected) noexcept;
-
 	// QueueManagerListener
 	void on(QueueManagerListener::Finished, QueueItem* qi, const string& dir, int64_t speed) noexcept;
 	void on(PartialList, const HintedUser&, const string& text) noexcept;