← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 3347: fix CCPM from an active connection

 

------------------------------------------------------------
revno: 3347
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sun 2013-09-15 19:48:08 +0200
message:
  fix CCPM from an active connection
modified:
  dcpp/ConnectionManager.cpp


--
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/ConnectionManager.cpp'
--- dcpp/ConnectionManager.cpp	2013-09-15 16:44:30 +0000
+++ dcpp/ConnectionManager.cpp	2013-09-15 17:48:08 +0000
@@ -697,6 +697,8 @@
 		return;
 	}
 
+	auto type = CONNECTION_TYPE_LAST;
+
 	if(aSource->isSet(UserConnection::FLAG_INCOMING)) {
 		string token;
 		if(!cmd.getParam("TO", 0, token)) {
@@ -706,20 +708,20 @@
 		}
 		aSource->setToken(token);
 
-		if(!checkToken(aSource).first) {
+		auto tokCheck = checkToken(aSource);
+		if(!tokCheck.first) {
 			aSource->send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_INF_FIELD, "INF TO: invalid token").addParam("FB", "TO"));
 			putConnection(aSource);
 			return;
 		}
-
-		aSource->inf(false);
+		type = tokCheck.second;
 	}
 
-	if(checkDownload(aSource)) {
+	if(type == CONNECTION_TYPE_DOWNLOAD || checkDownload(aSource)) {
 		if(!aSource->isSet(UserConnection::FLAG_DOWNLOAD)) { aSource->setFlag(UserConnection::FLAG_DOWNLOAD); }
 		addDownloadConnection(aSource);
 
-	} else if(aSource->isSet(UserConnection::FLAG_PM) || cmd.hasFlag("PM", 0)) {
+	} else if(type == CONNECTION_TYPE_PM || aSource->isSet(UserConnection::FLAG_PM) || cmd.hasFlag("PM", 0)) {
 		if(!aSource->isSet(UserConnection::FLAG_PM)) { aSource->setFlag(UserConnection::FLAG_PM); }
 		addNewConnection(aSource, CONNECTION_TYPE_PM);
 
@@ -727,6 +729,10 @@
 		if(!aSource->isSet(UserConnection::FLAG_UPLOAD)) { aSource->setFlag(UserConnection::FLAG_UPLOAD); }
 		addNewConnection(aSource, CONNECTION_TYPE_UPLOAD);
 	}
+
+	if(aSource->isSet(UserConnection::FLAG_INCOMING)) {
+		aSource->inf(false);
+	}
 }
 
 void ConnectionManager::force(const UserPtr& aUser) {