← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 3241: don't group single transfers

 

------------------------------------------------------------
revno: 3241
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Wed 2013-03-27 17:24:06 +0100
message:
  don't group single transfers
modified:
  Compile.txt
  dcpp/DownloadManager.cpp
  win32/TransferView.cpp
  win32/TransferView.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 'Compile.txt'
--- Compile.txt	2013-03-25 20:52:49 +0000
+++ Compile.txt	2013-03-27 16:24:06 +0000
@@ -56,8 +56,12 @@
 
 		We recommend using compilers from the MinGW-w64 project. All you have to do to use one is
 		download it and extract it.
-		Prefer DWARF versions of 32-bit compilers and SEH versions of 64-bit ones. (In short, avoid
-		SJLJ for performance reasons.)
+		Prefer DWARF versions (usually marked with a "-dw") of 32-bit compilers; SJLJ ones should
+		be avoided for performance reasons.
+
+		I am currently using these 2 packages by Ruben Van Boxem:
+		- 32-bit: <http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/gcc-4.8-dw2-release/>
+		- 64-bit: <http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/rubenvb/gcc-4.8-release/>
 
 		To install compilers from regular MinGW (not MinGW-w64), the easiest way is to use
 		mingw-get. Extract it to C:\MinGW and run:
@@ -76,6 +80,22 @@
 		Make sure that Cygwin\bin is in your PATH environment variable.
 		Note that building with MinGW compilers provided by Cygwin is not often tested.
 
+	b. Microsoft Visual Studio 2012:
+	<http://msdn.microsoft.com/en-us/visualc/default.aspx>
+
+		Make sure VS is up-to-date; in particular, you will need the Nov 2012 CTP from
+		<http://www.microsoft.com/en-us/download/details.aspx?id=35515>. Use the patch in
+		msvc/nov2012ctp.patch to patch your VC/vcvarsall.bat file to make use of it (if you
+		generate project files and compile from the VS GUI, that won't be necessary).
+
+		To generate project files for MSVC, run "scons" with "msvcproj=1" and "tools=default".
+		The resulting solution file (DCPlusPlus.sln) will be in msvc/[mode-arch]/.
+
+
+3. Additional include files and libraries
+
+	a. HTML Help support (only for MinGW)
+
 		To build a version with HTML Help support, copy the following files from a Windows SDK
 		(Windows SDK path -> DC++ source code path):
 		Include/shared/winapifamily.h -> mingw/include/winapifamily.h
@@ -87,13 +107,7 @@
 		<http://msdn.microsoft.com/en-US/windows/desktop/hh852363>; it installs into
 		"C:\Program Files (x86)\Windows Kits\8.0".
 
-	b. Microsoft Visual Studio 2012:
-	<http://msdn.microsoft.com/en-us/visualc/default.aspx>
-
-		Make sure VS is up-to-date; in particular, you will need the Nov 2012 CTP from
-		<http://www.microsoft.com/en-us/download/details.aspx?id=35515>. Use the patch in
-		msvc/nov2012ctp.patch to patch your VC/vcvarsall.bat file to make use of it (if you
-		generate project files and compile from the VS GUI, that won't be necessary).
+	b. OpenSSL (only for Visual Studio)
 
 		Download OpenSSL from www.openssl.org and compile it. You should get libraries called
 		libeay32.lib and ssleay32.lib; copy them in openssl/lib.
@@ -102,11 +116,10 @@
 		(read their instructions file; it's a matter of adding "debug" in the do_* file you use).
 		Rename debug libraries to libeay32d.lib and ssleay32d.lib; put them in openssl/lib.
 
-		To generate project files for MSVC, run "scons" with "msvcproj=1" and "tools=default".
-		The resulting solution file (DCPlusPlus.sln) will be in msvc/[mode-arch]/.
-
-
-3. Starting the build process
+		You may also ask around in the DCDev hub; someone might have already built a package.
+
+
+4. Starting the build process
 
 	Open a command prompt and type "scons" followed by some options:
 
@@ -127,7 +140,7 @@
 		If you have problems, use google. It works for me.
 
 
-4.  Other information and submitting patches
+5.  Other information and submitting patches
 
 		a. With doxygen, graphviz and some luck, you can use the supplied doxygen configuration
 		file to generate some nice docs. Just check that the paths in the doxyfile are correct.

=== modified file 'dcpp/DownloadManager.cpp'
--- dcpp/DownloadManager.cpp	2013-01-18 21:28:38 +0000
+++ dcpp/DownloadManager.cpp	2013-03-27 16:24:06 +0000
@@ -458,7 +458,7 @@
 	dcdebug("File Not Available: %s\n", d->getPath().c_str());
 
 	removeDownload(d);
-	fire(DownloadManagerListener::Failed(), d, str(F_("%1%: File not available") % d->getTargetFileName()));
+	fire(DownloadManagerListener::Failed(), d, str(F_("%1%: File not available") % Util::addBrackets(d->getTargetFileName())));
 
 	QueueManager::getInstance()->removeSource(d->getPath(), aSource->getUser(), d->getType() == Transfer::TYPE_TREE ? QueueItem::Source::FLAG_NO_TREE : QueueItem::Source::FLAG_FILE_NOT_AVAILABLE, false);
 

=== modified file 'win32/TransferView.cpp'
--- win32/TransferView.cpp	2013-03-26 22:03:28 +0000
+++ win32/TransferView.cpp	2013-03-27 16:24:06 +0000
@@ -121,10 +121,9 @@
 }
 
 int TransferView::ItemInfo::compareItems(const ItemInfo* a, const ItemInfo* b, int col) {
-	auto ta = dynamic_cast<const TransferInfo*>(a), tb = dynamic_cast<const TransferInfo*>(b);
-	if(ta && tb && ta->download != tb->download) {
+	if(const_cast<ItemInfo*>(a)->transfer().download != const_cast<ItemInfo*>(b)->transfer().download) {
 		// sort downloads before uploads.
-		return ta->download ? -1 : 1;
+		return const_cast<ItemInfo*>(a)->transfer().download ? -1 : 1;
 	}
 
 	auto ca = dynamic_cast<const ConnectionInfo*>(a), cb = dynamic_cast<const ConnectionInfo*>(b);
@@ -178,12 +177,10 @@
 
 void TransferView::ConnectionInfo::update(const UpdateInfo& ui) {
 	if(ui.updateMask & UpdateInfo::MASK_FILE) {
-		if(ui.path != parent.path) {
-			parent.path = ui.path;
-			parent.updatePath();
-			columns[COLUMN_FILE] = parent.getText(COLUMN_FILE);
-			columns[COLUMN_PATH] = parent.getText(COLUMN_PATH);
-		}
+		parent.path = ui.path;
+		parent.updatePath();
+		columns[COLUMN_FILE] = parent.getText(COLUMN_FILE);
+		columns[COLUMN_PATH] = parent.getText(COLUMN_PATH);
 	}
 
 	if(ui.updateMask & UpdateInfo::MASK_STATUS) {
@@ -261,7 +258,6 @@
 	path(path),
 	startPos(0)
 {
-	updatePath();
 }
 
 bool TransferView::TransferInfo::operator==(const TransferInfo& other) const {
@@ -596,16 +592,17 @@
 void TransferView::addConn(const UpdateInfo& ui) {
 	TransferInfo* transfer = nullptr;
 	auto conn = findConn(ui.user, ui.download);
+
 	if(ui.updateMask & UpdateInfo::MASK_FILE) {
+		// adding a connection we know the transfer of.
 		transfer = findTransfer(ui.path, ui.download);
+		if(conn && &conn->parent != transfer) {
+			removeConn(*conn);
+			conn = nullptr;
+		}
 		if(!transfer) {
 			transferItems.emplace_back(ui.tth, ui.download, ui.path);
 			transfer = &transferItems.back();
-			transfers->insert(transfer);
-		}
-		if(conn && &conn->parent != transfer) {
-			removeTransfer(conn->parent);
-			conn = nullptr;
 		}
 		if(ui.download) {
 			QueueManager::getInstance()->getSizeInfo(transfer->size, transfer->startPos, ui.path);
@@ -613,23 +610,41 @@
 			transfer->transferred = ui.transferred;
 			transfer->size = ui.size;
 		}
+
 	} else {
+		// this connection has just been created; we don't know what file it is for yet.
 		if(conn) {
 			removeConn(*conn);
 			conn = nullptr;
 		}
-		// we don't know what file this connection is for yet.
 		transferItems.emplace_back(TTHValue(), ui.download, ui.user.user->getCID().toBase32());
 		transfer = &transferItems.back();
-		transfers->insert(transfer);
 	}
+
+	auto newConn = !conn, newGroup = false;
+
 	if(!conn) {
+		if(transfer->conns.size() == 1) {
+			newGroup = true;
+			transfers->erase(&transfer->conns.front());
+		}
 		transfer->conns.emplace_back(ui.user, *transfer);
 		conn = &transfer->conns.back();
-		transfers->insertChild(reinterpret_cast<LPARAM>(transfer), reinterpret_cast<LPARAM>(conn));
 	}
+
 	conn->update(ui);
 	transfer->update();
+
+	if(newGroup) {
+		transfers->insert(transfer);
+		for(auto& child: transfer->conns) {
+			transfers->insertChild(reinterpret_cast<LPARAM>(transfer), reinterpret_cast<LPARAM>(&child));
+		}
+	} else if(newConn && transfer->conns.size() > 1) {
+		transfers->insertChild(reinterpret_cast<LPARAM>(transfer), reinterpret_cast<LPARAM>(conn));
+	} else if(newConn) {
+		transfers->insert(conn);
+	}
 }
 
 void TransferView::updateConn(const UpdateInfo& ui) {
@@ -643,11 +658,15 @@
 void TransferView::removeConn(const UpdateInfo& ui) {
 	auto conn = findConn(ui.user, ui.download);
 	if(conn) {
+		auto& parent = conn->parent;
+		auto ungroup = parent.conns.size() == 2;
+
 		removeConn(*conn);
-	}
-	auto transfer = findTransfer(ui.path, ui.download);
-	if(transfer) {
-		removeTransfer(*transfer);
+
+		if(ungroup) {
+			transfers->erase(&parent);
+			transfers->insert(&parent.conns.front());
+		}
 	}
 }
 
@@ -676,10 +695,7 @@
 }
 
 void TransferView::removeConn(ConnectionInfo& conn) {
-	auto pos = transfers->find(&conn);
-	if(pos >= 0) {
-		transfers->erase(pos);
-	}
+	transfers->erase(&conn);
 
 	auto& transfer = conn.parent;
 
@@ -851,20 +867,6 @@
 	}
 }
 
-void TransferView::on(QueueManagerListener::Removed, QueueItem* qi) noexcept {
-	/*auto ui = new UpdateInfo(HintedUser(), true);
-	ui->setFile(qi->getTTH(), qi->getTarget());
-	removedConn(ui);*/
-}
-
-void TransferView::on(QueueManagerListener::StatusUpdated, QueueItem* qi) noexcept {
-	/*if(qi->isFinished() || qi->getPriority() == QueueItem::PAUSED || qi->countOnlineUsers() == 0) {
-		auto ui = new UpdateInfo(HintedUser(), true);
-		ui->setFile(qi->getTTH(), qi->getTarget());
-		removedConn(ui);
-	}*/
-}
-
 void TransferView::on(QueueManagerListener::CRCFailed, Download* d, const string& aReason) noexcept {
 	onFailed(d, aReason);
 }
@@ -902,7 +904,6 @@
 
 void TransferView::onTransferTick(Transfer* t, bool download) {
 	auto ui = new UpdateInfo(t->getHintedUser(), download);
-	ui->setFile(t->getTTH(), t->getPath());
 	ui->setTransferred(t->getPos(), t->getActual(), t->getSize());
 	ui->setSpeed(t->getAverageSpeed());
 	updatedConn(ui);

=== modified file 'win32/TransferView.h'
--- win32/TransferView.h	2013-03-26 22:03:28 +0000
+++ win32/TransferView.h	2013-03-27 16:24:06 +0000
@@ -251,8 +251,6 @@
 	virtual void on(UploadManagerListener::Starting, Upload* u) noexcept;
 	virtual void on(UploadManagerListener::Tick, const UploadList& ul) noexcept;
 
-	virtual void on(QueueManagerListener::Removed, QueueItem* qi) noexcept;
-	virtual void on(QueueManagerListener::StatusUpdated, QueueItem* qi) noexcept;
 	virtual void on(QueueManagerListener::CRCFailed, Download* d, const string& aReason) noexcept;
 
 	void addedConn(UpdateInfo* ui);